From b163391a122d812058dc9ab211b81e60204fffc7 Mon Sep 17 00:00:00 2001 From: Yeongil Jang Date: Fri, 21 Sep 2012 00:18:57 +0900 Subject: [PATCH] 2.0_alpha release commit --- CMakeLists.txt | 3 +- LICENSE | 21 + cl.sh | 1 - config/.email-service.db | Bin 20480 -> 0 bytes config/.email-service.db-journal | Bin 4640 -> 0 bytes dbuild.sh | 2 - debian/changelog | 21 - debian/compat | 1 - debian/control | 32 - debian/copyright | 15 - debian/dirs | 2 - debian/docs | 0 debian/email-service-0.install | 3 - debian/email-service-0.postinst | 489 - debian/email-service-dev.install | 2 - debian/email-service-tools.install | 4 - debian/email-service-tools.postinst | 65 - debian/rules | 146 - email-api/CMakeLists.txt | 4 + email-api/email-api-account.c | 372 +- email-api/email-api-etc.c | 122 + email-api/email-api-init.c | 25 +- email-api/email-api-mail.c | 1494 +- email-api/email-api-mailbox.c | 684 +- email-api/email-api-network.c | 1208 +- email-api/email-api-rule.c | 111 +- email-api/email-api-smime.c | 453 + email-api/include/email-api-account.h | 826 +- email-api/include/email-api-etc.h | 80 + email-api/include/email-api-init.h | 348 +- email-api/include/email-api-mail.h | 3296 +- email-api/include/email-api-mailbox.h | 695 +- email-api/include/email-api-network.h | 763 +- email-api/include/email-api-rule.h | 436 +- email-api/include/email-api-smime.h | 53 + email-api/include/email-api.h | 150 +- email-common-use/CMakeLists.txt | 3 +- email-common-use/email-convert.c | 1287 +- email-common-use/email-utilities.c | 1722 +- email-common-use/include/email-convert.h | 65 +- email-common-use/include/email-debug-log.h | 53 +- email-common-use/include/email-errors.h | 260 +- email-common-use/include/email-internal-types.h | 137 +- email-common-use/include/email-types.h | 3091 +- email-common-use/include/email-utilities.h | 136 +- email-common-use/include/tpl.h | 133 + email-common-use/tpl.c | 2477 + email-core/CMakeLists.txt | 6 +- email-core/email-core-account.c | 1074 +- email-core/email-core-api.c | 188 +- email-core/email-core-cert.c | 679 + email-core/email-core-event.c | 1415 +- email-core/email-core-global.c | 6 +- email-core/email-core-imap-idle.c | 83 +- email-core/email-core-imap-mailbox.c | 476 +- email-core/email-core-mail.c | 1866 +- email-core/email-core-mailbox-sync.c | 603 +- email-core/email-core-mailbox.c | 437 +- email-core/email-core-mime.c | 1044 +- email-core/email-core-mm-callbacks.c | 129 +- email-core/email-core-smime.c | 1024 + email-core/email-core-smtp.c | 1193 +- email-core/email-core-sound.c | 54 +- email-core/email-core-timer.c | 6 +- email-core/email-core-utils.c | 531 +- email-core/email-network/email-network.c | 50 +- email-core/email-storage/email-storage.c | 6041 +- email-core/email-storage/include/email-storage.h | 330 +- email-core/include/email-core-account.h | 24 +- email-core/include/email-core-cert.h | 54 + email-core/include/email-core-event.h | 24 +- email-core/include/email-core-global.h | 4 +- email-core/include/email-core-imap-mailbox.h | 14 +- email-core/include/email-core-mail.h | 73 +- email-core/include/email-core-mailbox-sync.h | 16 +- email-core/include/email-core-mailbox.h | 32 +- email-core/include/email-core-mime.h | 3 + email-core/include/email-core-smime.h | 53 + email-core/include/email-core-smtp.h | 12 +- email-core/include/email-core-sound.h | 2 +- email-core/include/email-core-timer.h | 4 +- email-core/include/email-core-utils.h | 36 +- email-daemon/CMakeLists.txt | 2 +- email-daemon/email-daemon-account.c | 530 +- email-daemon/email-daemon-auto-poll.c | 48 +- email-daemon/email-daemon-emn.c | 99 +- email-daemon/email-daemon-etc.c | 228 +- email-daemon/email-daemon-init.c | 157 +- email-daemon/email-daemon-mail.c | 998 +- email-daemon/email-daemon-mailbox.c | 623 +- email-daemon/include/.gitignore | 2 + email-daemon/include/email-daemon-account.h | 2 +- email-daemon/include/email-daemon-emn.h | 4 +- email-daemon/include/email-daemon.h | 182 +- email-daemon/main.c | 2227 +- email-ipc/CMakeLists.txt | 7 +- email-ipc/cscope.files | 36 - email-ipc/cscope.out | 78905 ------------------- email-ipc/email-ipc-api.c | 105 +- email-ipc/email-ipc-api/email-ipc-api-info.c | 140 +- email-ipc/email-ipc-api/email-ipc-param-list.c | 173 +- email-ipc/email-ipc-api/email-ipc-param.c | 19 + .../email-ipc-api/include/email-ipc-api-info.h | 38 +- .../email-ipc-api/include/email-ipc-param-list.h | 14 +- email-ipc/email-ipc-api/include/email-ipc-param.h | 4 + email-ipc/email-ipc-proxy.c | 177 +- email-ipc/email-ipc-stub.c | 14 - email-ipc/email-proxy/email-proxy-main.c | 91 +- email-ipc/email-proxy/email-proxy-socket.c | 54 +- email-ipc/email-socket/email-ipc-socket.c | 66 +- email-ipc/email-socket/include/email-ipc-socket.h | 2 +- email-ipc/email-stub/email-stub-main.c | 41 +- email-ipc/email-stub/email-stub-queue.c | 89 - email-ipc/email-stub/email-stub-response-info.c | 39 - email-ipc/email-stub/email-stub-socket.c | 6 +- email-ipc/email-stub/email-stub-task-manager.c | 10 +- email-ipc/email-stub/email-stub-task.c | 35 +- email-ipc/email-stub/include/email-stub-queue.h | 40 - .../email-stub/include/email-stub-response-info.h | 42 - email-ipc/email-stub/include/email-stub-task.h | 2 + email-ipc/include/email-ipc.h | 9 +- email-service_PG.h | 2366 +- packaging/email-service.changes | 4 - packaging/email-service.manifest | 5 - packaging/email-service.spec | 548 +- packaging/email.service | 12 - res/Q02_Notification_email.png | Bin 0 -> 5445 bytes .../test-application/include/testapp-account.h | 4 +- utilities/test-application/include/testapp-mail.h | 6 +- .../test-application/include/testapp-mailbox.h | 6 +- .../test-application/include/testapp-others.h | 4 +- utilities/test-application/include/testapp-rule.h | 6 +- .../test-application/include/testapp-thread.h | 6 +- .../test-application/include/testapp-utility.h | 24 +- utilities/test-application/main.c | 19 +- utilities/test-application/testapp-account.c | 625 +- utilities/test-application/testapp-mail.c | 1207 +- utilities/test-application/testapp-mailbox.c | 371 +- utilities/test-application/testapp-others.c | 70 +- utilities/test-application/testapp-rule.c | 81 +- utilities/test-application/testapp-thread.c | 32 +- utilities/test-application/testapp-utility.c | 75 +- 142 files changed, 28721 insertions(+), 100887 deletions(-) delete mode 100755 cl.sh delete mode 100644 config/.email-service.db delete mode 100644 config/.email-service.db-journal delete mode 100755 dbuild.sh delete mode 100755 debian/changelog delete mode 100755 debian/compat delete mode 100755 debian/control delete mode 100755 debian/copyright delete mode 100755 debian/dirs delete mode 100755 debian/docs delete mode 100755 debian/email-service-0.install delete mode 100755 debian/email-service-0.postinst delete mode 100755 debian/email-service-dev.install delete mode 100644 debian/email-service-tools.install delete mode 100644 debian/email-service-tools.postinst delete mode 100755 debian/rules create mode 100755 email-api/email-api-etc.c create mode 100755 email-api/email-api-smime.c create mode 100755 email-api/include/email-api-etc.h create mode 100755 email-api/include/email-api-smime.h create mode 100644 email-common-use/include/tpl.h create mode 100644 email-common-use/tpl.c create mode 100644 email-core/email-core-cert.c create mode 100755 email-core/email-core-smime.c create mode 100644 email-core/include/email-core-cert.h create mode 100755 email-core/include/email-core-smime.h create mode 100644 email-daemon/include/.gitignore delete mode 100644 email-ipc/cscope.files delete mode 100644 email-ipc/cscope.out delete mode 100755 email-ipc/email-stub/email-stub-queue.c delete mode 100755 email-ipc/email-stub/email-stub-response-info.c delete mode 100755 email-ipc/email-stub/include/email-stub-queue.h delete mode 100755 email-ipc/email-stub/include/email-stub-response-info.h delete mode 100644 packaging/email-service.changes delete mode 100644 packaging/email-service.manifest mode change 100644 => 100755 packaging/email-service.spec delete mode 100644 packaging/email.service create mode 100755 res/Q02_Notification_email.png diff --git a/CMakeLists.txt b/CMakeLists.txt index be31973..303a97b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,9 +54,8 @@ ADD_SUBDIRECTORY(utilities) CONFIGURE_FILE(email-service.pc.in email-service.pc @ONLY) INSTALL(FILES ${CMAKE_BINARY_DIR}/email-service.pc DESTINATION lib/pkgconfig) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config/.email-service.db DESTINATION /opt/dbspace) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config/.email-service.db-journal DESTINATION /opt/dbspace) #SET(RC_LOCAL_SCRIPT email-service) #INSTALL(PROGRAMS ${RC_LOCAL_SCRIPT} DESTINATION /etc/rc.d/init.d) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/ DESTINATION /opt/data/email/res/image FILES_MATCHING PATTERN "*.png") diff --git a/LICENSE b/LICENSE index f94008a..551863e 100644 --- a/LICENSE +++ b/LICENSE @@ -202,5 +202,26 @@ Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. See the License for the specific language governing permissions and limitations under the License. +------------------------------------------------------------------------------- +Copyright (c) 2005-2010, Troy D. Hanson http://tpl.sourceforge.net +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/cl.sh b/cl.sh deleted file mode 100755 index 2a0afdd..0000000 --- a/cl.sh +++ /dev/null @@ -1 +0,0 @@ -fakeroot debian/rules clean diff --git a/config/.email-service.db b/config/.email-service.db deleted file mode 100644 index b6a4d7c845cca7e1b903dd719bfc69d452ffaba4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20480 zcmeHP&2QX96t}Z!x9$h!Q+pv|dZ?Ne8_^^RG~!S~yFf$;G)eQPDm zG1^Mfj+di(Ytpi9>jQ)=%c{bkdR>5mtq|1j3VHDBDIirUf0K&WD*sd-v#*1E!zq(L zOjc`GF5CNyVI1JSju%F5E7^0yU~g6w@>X>E##(b}y@@tfmv3z}(emoe<{cy$2siqC zRT7{Dn)ZA@>BTw7YM?0by~ypy4a!4$h`kQ3AHG?s)-GSRfBHW6S`iikp}qS3RMGqT z(uXU}QZEQD*%K-8Yk76O`EhfN6&v(}4}-I?&moMYcRosoaqW1i-}ch!*}26!LQLLP z5(PMQ^L`g|k%chFVI0VdLN7z85W=~J3X8mLQm?QM8QB(a%^rCI&jFbIq(0@Y9FxVTf z@p^fCSZ|}oK_;)ykV_gq{~*k|k=NJpnrAC@H|o22qC?Lh2Gn|KJgkOq5n&)leGlWV zo5aP6FX?O>7HdB#&dJ(t(sf%Hp8EjyPTrLj9@NNElx!z%=!5vK2T<|NW^UnKFokZ4 zGn~7{pk$-mOSgfZ73Z3ke_rFgGlkWZh#|r z7)bjr-R-)$6hvxM>;;20L9!c13DiVkCsbOrpp$zPX`E$J5F=;3);HK!xK(w!TWQiM z0g_^()ZH*|!y{^-3>$FX_0oVSl41_eb)(zU_l z@VOAvYWcpD*6DLa!Q(C`*U6)R+5g9M;WyJBdj!n$|Ja*=0bq;~F#G=)E8k3g>=7{g z|Ja*=0bq;~Aou^I_0X~&+MD(tl>_V7X945C#pa%+2jD#+ffXh00)wtRKY=L|!BoSc z&s_xb{|#@G`@dpcvaCz?(dkoYgVrpbrm-!91HLxg)tK@F34AOP+>A^6Qa$S_FKP+UXA9Wj`mxm1=C{w6}X z8&(aw2VU+$47|iSq-VkiQScHY7df}^UY$>wIPm#oNw-6ULF}4FRTOE0>x;GJ&z9CU z(WlML`u?@k)!O@u_JJd#=DKP`c7;v`U7sBpLDyNeIJ#b?Mbl;O1<@wY!vLK1M2rTa z;MWgUs*nzH#s2Xt#U6VRmS$KK&JD4?qKcr$u3<(e5F;$q+EUU^8j)a7AZ;K=O|gKM zf{Tf9AmY&zDHzgdxP~3i&qD~aa4F^H0nT!o{s16>L~bA~U<3q5WL=Q{lD=4Y>>W)^)}OpzS63gTRe2_9*Pp+(}65BNSPytO+E}ZWd}JVtsL_SYy&O)KECErV=_gU-k>e)K=A0#(q1-a*lVrm^mAy#tV`o-= zV7=M=XlY|*9nH*ArD>y(iD#rsn8T5W2fRlg956p+Xr=D;aryqy#{~v`L}tg!K@;r` zm@d3!!ZisnG$4&~C&arnWpEu#SppB0d7Ju9dXuud*eB zHqFBCWX`5jyp2I?r1Bdoo%nV5J!#rSu zL-U1!94Ag>9see}(tUO$6_?zN>Lpl#NJd59vQZh}J9ocP?;T;H>Mk*r1xZjOqb3N* zL{`a@N14mAN-n*TJoB=v0UjV2|KIT~cSe#y;KU(d&i^M)WoEzzfn!6!e$Hg~r8^A7(1Nd%(%4!V!G!>eZ|8LkrAn&%MJ1k;hJCXrO^O ZjruH0{KG;b#{c&M-|uE>27#v`@Go9sg>?V` diff --git a/config/.email-service.db-journal b/config/.email-service.db-journal deleted file mode 100644 index 56022b7d6d23cd5bb1728586f474205d8bfef681..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4640 zcmeHKPj3@P6yLF(EK3R$ao7Vy9S%{vV$&+IqSopGT(H`RG%Y4TqY7CQdqY-QuPb|P z1=@>~{t?IW1$y8Mz(+#;4qSTad$aRz|G4FVfU1m?c=pY2-kW*vH}B0@*8BE9_rTdR z;DDNS-?CniXO(l>sV?WyyYY{(7g~ z+HKQ2J6pHzwCUE)jrMmmkHfk2o1KCj=F>U{hkc*ML+|m8Q?|RjOrCt7u>C0DLjaP$ z9|&W+tuMCQsWz^{5jw#9Zu`r2$9Gt-H=OWQYZ-#}hez~ot8@LUR;Rwc(e(Uu>NtE9 zXy7;)O@mRFD}5N3%8Po;NnxMfg~*(_@7V4~%Vf5sJ*wOY3qLp4cNvFey`*>Moy4bY zx6vTKRkgQ_h)Ks~MIRP@m<7-}RsN(#6TamVpHkDs3YEohHRvg`P1&e-$VS}z)Td57 zG)L3EQuA$R>+4o$kKSzW0rVh@f-VHaYzhiOTvf~lfjN$SX>w!pQ;&mqxO1qyBJC6n z%qRje8a#;DgLMtzy}T~OY`g-d@eddn^4$9G7l2pf_O0zO3FyIaG++sBKu#dUx<)CC zEyADKmf(XJ0<&+3i`@kfRjMy>;B56T==@Q{%$L-Ds@d-93Yj%E^??aGi{J+kbaCzx zkZ6@R#0*;3C%~uCu*V|cgwL}9LXZI7$)&38uB?z>e$*#J%;%?C^cRX}L0Q32XiNAd zn;BiC05rJ_2}yrTfFcL+RXQn3k_yuirxb_}hEX3fQ1b8xMP{MQaZ-zvMIjpl|FR}a zl>z$@Wk5?-rg;4CFizz;FtNHrHtym<52rz&CsJ6dGV0CjitT=~MrKzvJG8H5oe?P< zSW=tI5_6VfiWKt1DL?kX6nCg^gw=a|h1l-e8hPSqqR1I4f9i!)ii9!HkU8a-vL<(} zt?~>d0vl+jt&1#)gTXijGgp8@YJ%Nl0EWg_4rMk z(fMb-bmYI};MD)Hjq1BY(D#|lOpEVaCVRVO4)VZ7psRy~tTlHWVUma)vr z&CXEr{`AGEHv{F$qr?zE56^- zIAJtpAN-uXnE8}D-#gy6;d;1Ae!ge$aRRq{MMLqiRKh+ngx*VA8R?YA5W?9u!g-oR z3ShVt-WcYU3uY=*s>YeJXriuUnlv)P@F+^cVXQ80`RV;&obc-qI0-aLg7B9pTFAd9 R)O>vXWFHY~D18@re*^m*Hmd*t diff --git a/dbuild.sh b/dbuild.sh deleted file mode 100755 index 9753e52..0000000 --- a/dbuild.sh +++ /dev/null @@ -1,2 +0,0 @@ -dpkg-buildpackage -sa -rfakeroot -I.git -#dpkg -i ../email-service-0_0.1.0-1_armel.deb ../email-service-dev_0.1.0-1_armel.deb diff --git a/debian/changelog b/debian/changelog deleted file mode 100755 index a84fccd..0000000 --- a/debian/changelog +++ /dev/null @@ -1,21 +0,0 @@ -email-service (0.4.0-2) unstable; urgency=low - - * 1. Change IPC code (c++ -> c) - * 2. Fixed the memory leak - * 3. Fixed the display the time - * Git : slp/pkgs/e/email-service - * Tag : email-service_0.4.0-2 - - -- Sunghyun Kwon Wed, 04 Apr 2012 17:01:25 +0900 - -email-service (0.4.0-1) unstable; urgency=low - - * 1. Removed all deprecated functions. - * 2. attachment_mime_type is added to emf_attachment_data_t. - * 3. An attribute 'datetime' is removed from emf_mail_data_t and emf_mail_list_item_t. - * 4. An attribute 'date_time' is added to emf_mail_data_t and emf_mail_list_item_t. - * 5. emf_mail_t, emf_mail_info_t, emf_mail_body_t, emf_mail_head_t are removed from API. - * Git : slp/pkgs/e/email-service - * Tag : email-service_0.4.0-1 - - -- Kyuho Jo Thu, 08 Mar 2012 17:42:24 +0900 diff --git a/debian/compat b/debian/compat deleted file mode 100755 index 7ed6ff8..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/debian/control b/debian/control deleted file mode 100755 index 50b7190..0000000 --- a/debian/control +++ /dev/null @@ -1,32 +0,0 @@ -Source: email-service -Section: main/libs -Priority: extra -Maintainer: Kyuho Jo , Sunghyun Kwon , Sang-Hun Chung -Uploaders: Kyuho Jo , Sunghyun Kwon , Sang-Hun Chung , Changseok Oh -Build-Depends: debhelper (>= 5), libglib2.0-dev, libdbus-1-dev, libdbus-glib-1-dev, libslp-db-util-dev, libxml2-dev, libwbxml2-dev, libssl-dev, drm-service-dev, libslp-pm-dev, libuw-imap-toolkit-dev, openssl, dlog-dev, libslp-setting-dev, libcontacts-service-dev, libheynoti-dev, libss-client-dev, libalarm-dev, libaccounts-svc-dev, libdevman-dev, libmm-player-dev, libmm-session-dev, libnotification-dev, libeina-dev, libcurl-dev -Standards-Version: 3.7.2 -Homepage: N/A - -Package: email-service-dev -XB-Public-Package: yes -XB-Generate-Docs: yes -Section: main/libdevel -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, email-service-0 (= ${Source-Version}) -Description: E-mail Framework Middleware Development package - email-service-dev - -Package: email-service-0 -Section: main/libs -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libuw-imap-toolkit-0 -Description: E-mail Framework Middleware Development package - email-service-0 - -Package: email-service-dbg -Section: debug -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, email-service-0 (= ${Source-Version}) -Description: Debug for use with email-service - email-service-dbg : for debug - diff --git a/debian/copyright b/debian/copyright deleted file mode 100755 index 4479dae..0000000 --- a/debian/copyright +++ /dev/null @@ -1,15 +0,0 @@ -Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - -Contact: Kyuho Jo , Sunghyun Kwon - -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. diff --git a/debian/dirs b/debian/dirs deleted file mode 100755 index ca882bb..0000000 --- a/debian/dirs +++ /dev/null @@ -1,2 +0,0 @@ -usr/bin -usr/sbin diff --git a/debian/docs b/debian/docs deleted file mode 100755 index e69de29..0000000 diff --git a/debian/email-service-0.install b/debian/email-service-0.install deleted file mode 100755 index 8cd01dd..0000000 --- a/debian/email-service-0.install +++ /dev/null @@ -1,3 +0,0 @@ -/usr/lib/*.so -/usr/lib/*.so.* -/usr/bin/email-service diff --git a/debian/email-service-0.postinst b/debian/email-service-0.postinst deleted file mode 100755 index f3feade..0000000 --- a/debian/email-service-0.postinst +++ /dev/null @@ -1,489 +0,0 @@ -#!/bin/sh - -################################################################# -# Add preset account information -################################################################# -echo "[EMAIL-SERVICE] Start adding preset account information..." - -################################################################# -# Email Settings -################################################################# - -if [ ${USER} = "root" ] -then - - ## Setting - # Sending - vconftool set -g 5000 -t bool db/Services/Email/Sending/KeepCopy "1" - vconftool set -g 5000 -t bool db/Services/Email/Sending/SendMeCopy "1" - vconftool set -g 5000 -t bool db/Services/Email/Sending/ReqDeliveryRep "0" - vconftool set -g 5000 -t bool db/Services/Email/Sending/ReqReadRep "0" - vconftool set -g 5000 -t int db/Services/Email/Sending/Priority "1" - vconftool set -g 5000 -t string db/Services/Email/Sending/ActiveAccount "" - vconftool set -g 5000 -t bool db/Services/Email/Sending/IncBodyReply "1" - vconftool set -g 5000 -t bool db/Services/Email/Sending/IncAttachFwd "1" - # Receiving - vconftool set -g 5000 -t int db/Services/Email/Receiving/AutoPoll "0" - vconftool set -g 5000 -t int db/Services/Email/Receiving/PollTime "0" - vconftool set -g 5000 -t int db/Services/Email/Receiving/SendReadRep "2" - vconftool set -g 5000 -t int db/Services/Email/Receiving/Reclimit "0" - vconftool set -g 5000 -t int db/Services/Email/Receiving/FetchOption "0" - vconftool set -g 5000 -t bool db/Services/Email/Receiving/KeepServer "1" - vconftool set -g 5000 -t int db/Services/Email/Receiving/ServDelOption "1" - - vconftool set -g 5000 -t int db/Services/Email/NbAccount "6" - - ## Accounts - - # Gmail - vconftool set -g 5000 -t string db/Services/Email/1/General/NetworkName "default" - vconftool set -g 5000 -t string db/Services/Email/1/General/AccountName "Gmail" - vconftool set -g 5000 -t string db/Services/Email/1/General/EmailAddr "" - vconftool set -g 5000 -t string db/Services/Email/1/General/UserId "" - vconftool set -g 5000 -t string db/Services/Email/1/General/Password "" - vconftool set -g 5000 -t string db/Services/Email/1/General/LoginType "username_type" - - # MailboxType : pop3(0), imap4(1) -> pop3(1), imap4(2) in email-service - vconftool set -g 5000 -t int db/Services/Email/1/Incoming/MailboxType "1" - vconftool set -g 5000 -t string db/Services/Email/1/Incoming/ServAddr "imap.gmail.com" - vconftool set -g 5000 -t int db/Services/Email/1/Incoming/Port "993" - vconftool set -g 5000 -t int db/Services/Email/1/Incoming/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/1/Incoming/Apop "0" - vconftool set -g 5000 -t bool db/Services/Email/1/Incoming/AutoEmailSync "0" - vconftool set -g 5000 -t bool db/Services/Email/1/Incoming/IncludeAttach "0" - vconftool set -g 5000 -t int db/Services/Email/1/Incoming/ImapFetchOpt "1" - - vconftool set -g 5000 -t string db/Services/Email/1/Outgoing/ServAddr "smtp.gmail.com" - vconftool set -g 5000 -t int db/Services/Email/1/Outgoing/Port "465" - vconftool set -g 5000 -t bool db/Services/Email/1/Outgoing/SmtpAuth "0" - vconftool set -g 5000 -t int db/Services/Email/1/Outgoing/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/1/Outgoing/SameIdPwd "1" - vconftool set -g 5000 -t bool db/Services/Email/1/Outgoing/PopBeforeSmtp "0" - - # Hotmail - vconftool set -g 5000 -t string db/Services/Email/2/General/NetworkName "default" - vconftool set -g 5000 -t string db/Services/Email/2/General/AccountName "Hotmail" - vconftool set -g 5000 -t string db/Services/Email/2/General/EmailAddr "" - vconftool set -g 5000 -t string db/Services/Email/2/General/UserId "" - vconftool set -g 5000 -t string db/Services/Email/2/General/Password "" - vconftool set -g 5000 -t string db/Services/Email/2/General/LoginType "username_type" - - # MailboxType : pop3(0), imap4(1) -> pop3(1), imap4(2) in email-service - vconftool set -g 5000 -t int db/Services/Email/2/Incoming/MailboxType "0" - vconftool set -g 5000 -t string db/Services/Email/2/Incoming/ServAddr "pop3.live.com" - vconftool set -g 5000 -t int db/Services/Email/2/Incoming/Port "995" - vconftool set -g 5000 -t int db/Services/Email/2/Incoming/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/2/Incoming/Apop "0" - vconftool set -g 5000 -t bool db/Services/Email/2/Incoming/AutoEmailSync "0" - vconftool set -g 5000 -t bool db/Services/Email/2/Incoming/IncludeAttach "0" - vconftool set -g 5000 -t int db/Services/Email/2/Incoming/ImapFetchOpt "1" - - vconftool set -g 5000 -t string db/Services/Email/2/Outgoing/ServAddr "smtp.live.com" - vconftool set -g 5000 -t int db/Services/Email/2/Outgoing/Port "587" - vconftool set -g 5000 -t bool db/Services/Email/2/Outgoing/SmtpAuth "0" - vconftool set -g 5000 -t int db/Services/Email/2/Outgoing/Secure "2" - vconftool set -g 5000 -t bool db/Services/Email/2/Outgoing/SameIdPwd "1" - vconftool set -g 5000 -t bool db/Services/Email/2/Outgoing/PopBeforeSmtp "0" - - # AOL - vconftool set -g 5000 -t string db/Services/Email/3/General/NetworkName "default" - vconftool set -g 5000 -t string db/Services/Email/3/General/AccountName "AOL" - vconftool set -g 5000 -t string db/Services/Email/3/General/EmailAddr "" - vconftool set -g 5000 -t string db/Services/Email/3/General/UserId "" - vconftool set -g 5000 -t string db/Services/Email/3/General/Password "" - vconftool set -g 5000 -t string db/Services/Email/3/General/LoginType "username_type" - - # MailboxType : pop3(0), imap4(1) -> pop3(1), imap4(2) in email-service - vconftool set -g 5000 -t int db/Services/Email/3/Incoming/MailboxType "1" - vconftool set -g 5000 -t string db/Services/Email/3/Incoming/ServAddr "imap.aol.com" - vconftool set -g 5000 -t int db/Services/Email/3/Incoming/Port "143" - vconftool set -g 5000 -t int db/Services/Email/3/Incoming/Secure "0" - vconftool set -g 5000 -t bool db/Services/Email/3/Incoming/Apop "0" - vconftool set -g 5000 -t bool db/Services/Email/3/Incoming/AutoEmailSync "0" - vconftool set -g 5000 -t bool db/Services/Email/3/Incoming/IncludeAttach "0" - vconftool set -g 5000 -t int db/Services/Email/3/Incoming/ImapFetchOpt "0" - - vconftool set -g 5000 -t string db/Services/Email/3/Outgoing/ServAddr "smtp.aol.com" - vconftool set -g 5000 -t int db/Services/Email/3/Outgoing/Port "587" - vconftool set -g 5000 -t bool db/Services/Email/3/Outgoing/SmtpAuth "0" - vconftool set -g 5000 -t int db/Services/Email/3/Outgoing/Secure "0" - vconftool set -g 5000 -t bool db/Services/Email/3/Outgoing/SameIdPwd "1" - vconftool set -g 5000 -t bool db/Services/Email/3/Outgoing/PopBeforeSmtp "0" - - # Yahoo - vconftool set -g 5000 -t string db/Services/Email/6/General/NetworkName "default" - vconftool set -g 5000 -t string db/Services/Email/6/General/AccountName "Yahoomail" - vconftool set -g 5000 -t string db/Services/Email/6/General/EmailAddr "" - vconftool set -g 5000 -t string db/Services/Email/6/General/UserId "" - vconftool set -g 5000 -t string db/Services/Email/6/General/Password "" - vconftool set -g 5000 -t string db/Services/Email/6/General/LoginType "username_type" - - # MailboxType : pop3(0), imap4(1) -> pop3(1), imap4(2) in email-service - vconftool set -g 5000 -t int db/Services/Email/6/Incoming/MailboxType "0" - vconftool set -g 5000 -t string db/Services/Email/6/Incoming/ServAddr "pop.mail.yahoo.co.kr" - vconftool set -g 5000 -t int db/Services/Email/6/Incoming/Port "995" - vconftool set -g 5000 -t int db/Services/Email/6/Incoming/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/6/Incoming/Apop "0" - vconftool set -g 5000 -t bool db/Services/Email/6/Incoming/AutoEmailSync "0" - vconftool set -g 5000 -t bool db/Services/Email/6/Incoming/IncludeAttach "0" - vconftool set -g 5000 -t int db/Services/Email/6/Incoming/ImapFetchOpt "1" - - vconftool set -g 5000 -t string db/Services/Email/6/Outgoing/ServAddr "smtp.mail.yahoo.co.kr" - vconftool set -g 5000 -t int db/Services/Email/6/Outgoing/Port "465" - vconftool set -g 5000 -t bool db/Services/Email/6/Outgoing/SmtpAuth "0" - vconftool set -g 5000 -t int db/Services/Email/6/Outgoing/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/6/Outgoing/SameIdPwd "1" - vconftool set -g 5000 -t bool db/Services/Email/6/Outgoing/PopBeforeSmtp "0" - -fi - - -################################################################################################ - -if [ ${USER} = "root" ] -then - -vconftool set -t string db/email/preset_account/aol/sending_address "smtp.aol.com" -vconftool set -t int db/email/preset_account/aol/sending_port "587" -vconftool set -t int db/email/preset_account/aol/sending_ssl "0" -vconftool set -t int db/email/preset_account/aol/receiving_type "2" -vconftool set -t string db/email/preset_account/aol/receiving_address "imap.aol.com" -vconftool set -t int db/email/preset_account/aol/receiving_port "143" -vconftool set -t int db/email/preset_account/aol/receiving_ssl "0" - -vconftool set -t string db/email/preset_account/gmail/sending_address "smtp.gmail.com" -vconftool set -t int db/email/preset_account/gmail/sending_port "465" -vconftool set -t int db/email/preset_account/gmail/sending_ssl "1" -vconftool set -t int db/email/preset_account/gmail/receiving_type "2" -# for POP3 server -#vconftool set -t string db/email/preset_account/gmail/receiving_address "pop.gmail.com" -#vconftool set -t int db/email/preset_account/gmail/receiving_port "995" -# for IMAP4 server -vconftool set -t string db/email/preset_account/gmail/receiving_address "imap.gmail.com" -vconftool set -t int db/email/preset_account/gmail/receiving_port "993" -vconftool set -t int db/email/preset_account/gmail/receiving_ssl "1" - -vconftool set -t string db/email/preset_account/yahoo/sending_address "smtp.mail.yahoo.co.kr" -vconftool set -t int db/email/preset_account/yahoo/sending_port "465" -vconftool set -t int db/email/preset_account/yahoo/sending_ssl "1" -vconftool set -t int db/email/preset_account/yahoo/receiving_type "1" -vconftool set -t string db/email/preset_account/yahoo/receiving_address "pop.mail.yahoo.co.kr" -vconftool set -t int db/email/preset_account/yahoo/receiving_port "995" -vconftool set -t int db/email/preset_account/yahoo/receiving_ssl "1" - -vconftool set -t string db/email/preset_account/hotmail/sending_address "smtp.live.com" -vconftool set -t int db/email/preset_account/hotmail/sending_port "587" -vconftool set -t int db/email/preset_account/hotmail/sending_ssl "2" -vconftool set -t int db/email/preset_account/hotmail/receiving_type "1" -vconftool set -t string db/email/preset_account/hotmail/receiving_address "pop3.live.com" -vconftool set -t int db/email/preset_account/hotmail/receiving_port "995" -vconftool set -t int db/email/preset_account/hotmail/receiving_ssl "1" - -# for Active Sync - Let email app create this key -#vconftool set -t int db/email_handle/active_sync_handle "0" - -# for contact sync - sync from the first contact change -vconftool set -t int db/email/last_sync_time "0" - -# for contact sync - sync from the first contact change -vconftool set -t int db/email/slot_size "100" - -# for badge -vconftool set -t int db/badge/com.samsung.email "0" - -fi - -echo "[EMAIL-SERVICE] Finish adding preset account information" - - -################################################################# -# Set executin script -################################################################# -echo "[EMAIL-SERVICE] Set executing script ..." -EMAIL_SERVICE_EXEC_SCRIPT=/etc/rc.d/init.d/email-service -EMAIL_SERVICE_BOOT_SCRIPT=/etc/rc.d/rc3.d/S70email-service -EMAIL_SERVICE_FASTBOOT_SCRIPT=/etc/rc.d/rc5.d/S70email-service -echo '#!/bin/sh' > ${EMAIL_SERVICE_EXEC_SCRIPT} -echo '/usr/bin/email-service &' >> ${EMAIL_SERVICE_EXEC_SCRIPT} -chmod 755 ${EMAIL_SERVICE_EXEC_SCRIPT} -rm -rf ${EMAIL_SERVICE_BOOT_SCRIPT} -rm -rf ${EMAIL_SERVICE_FASTBOOT_SCRIPT} -ln -s ${EMAIL_SERVICE_EXEC_SCRIPT} ${EMAIL_SERVICE_BOOT_SCRIPT} -ln -s ${EMAIL_SERVICE_EXEC_SCRIPT} ${EMAIL_SERVICE_FASTBOOT_SCRIPT} -echo "[EMAIL-SERVICE] Finish executing script ..." - -################################################################# -# Create DB file and tables. -################################################################# -echo "[EMAIL-SERVICE] Creating Email Tables ..." -sqlite3 /opt/dbspace/.email-service.db 'PRAGMA journal_mode = PERSIST; -CREATE TABLE mail_account_tbl -( - account_bind_type INTEGER, - account_name VARCHAR(51), - receiving_server_type INTEGER, - receiving_server_addr VARCHAR(51), - email_addr VARCHAR(129), - user_name VARCHAR(51), - password VARCHAR(51), - retrieval_mode INTEGER, - port_num INTEGER, - use_security INTEGER, - sending_server_type INTEGER, - sending_server_addr VARCHAR(51), - sending_port_num INTEGER, - sending_auth INTEGER, - sending_security INTEGER, - sending_user VARCHAR(51), - sending_password VARCHAR(51), - display_name VARCHAR(31), - reply_to_addr VARCHAR(129), - return_addr VARCHAR(129), - account_id INTEGER PRIMARY KEY, - keep_on_server INTEGER, - flag1 INTEGER, - flag2 INTEGER, - pop_before_smtp INTEGER, - apop INTEGER, - logo_icon_path VARCHAR(256), - preset_account INTEGER, - target_storage INTEGER, - check_interval INTEGER, - priority INTEGER, - keep_local_copy INTEGER, - req_delivery_receipt INTEGER, - req_read_receipt INTEGER, - download_limit INTEGER, - block_address INTEGER, - block_subject INTEGER, - display_name_from VARCHAR(256), - reply_with_body INTEGER, - forward_with_files INTEGER, - add_myname_card INTEGER, - add_signature INTEGER, - signature VARCHAR(256), - add_my_address_to_bcc INTEGER, - my_account_id INTEGER, - index_color INTEGER, - sync_status INTEGER -); - -CREATE TABLE mail_attachment_tbl -( - attachment_id INTEGER PRIMARY KEY, - attachment_name VARCHAR(257), - attachment_path VARCHAR(257), - attachment_size INTEGER, - mail_id INTEGER, - account_id INTEGER, - mailbox_name VARCHAR(129), - attachment_save_status INTEGER, - attachment_drm_type INTEGER, - attachment_drm_method INTEGER, - attachment_inline_content_status INTEGER, - attachment_mime_type VARCHAR(257) -); - -CREATE TABLE mail_box_tbl -( - mailbox_id INTEGER, - account_id INTEGER, - local_yn INTEGER, - mailbox_name VARCHAR(256), - mailbox_type INTEGER, - alias VARCHAR(256), - sync_with_server_yn INTEGER, - modifiable_yn INTEGER, - total_mail_count_on_server INTEGER, - has_archived_mails INTEGER, - mail_slot_size INTEGER -); -CREATE TABLE mail_read_mail_uid_tbl -( - account_id INTEGER , - local_mbox VARCHAR(129) , - local_uid INTEGER , - mailbox_name VARCHAR(129) , - s_uid VARCHAR(129) , - data1 INTEGER , - data2 VARCHAR(257) , - flag INTEGER , - idx_num INTEGER PRIMARY KEY -); -CREATE TABLE mail_rule_tbl -( - account_id INTEGER , - rule_id INTEGER PRIMARY KEY, - type INTEGER , - value VARCHAR(257) , - action_type INTEGER , - dest_mailbox VARCHAR(129), - flag1 INTEGER , - flag2 INTEGER -); -CREATE TABLE mail_tbl -( - mail_id INTEGER PRIMARY_KEY, - account_id INTEGER, - mailbox_id INTEGER, - mailbox_name VARCHAR(129), - mailbox_type INTEGER, - subject TEXT, - date_time DATETIME, - server_mail_status INTEGER, - server_mailbox_name VARCHAR(129), - server_mail_id VARCHAR(129), - message_id VARCHAR(257), - full_address_from TEXT, - full_address_reply TEXT, - full_address_to TEXT, - full_address_cc TEXT, - full_address_bcc TEXT, - full_address_return TEXT, - email_address_sender TEXT collation user1, - email_address_recipient TEXT collation user1, - alias_sender TEXT, - alias_recipient TEXT, - body_download_status INTEGER, - file_path_plain VARCHAR(257), - file_path_html VARCHAR(257), - mail_size INTEGER, - flags_seen_field BOOLEAN, - flags_deleted_field BOOLEAN, - flags_flagged_field BOOLEAN, - flags_answered_field BOOLEAN, - flags_recent_field BOOLEAN, - flags_draft_field BOOLEAN, - flags_forwarded_field BOOLEAN, - DRM_status INTEGER, - priority INTEGER, - save_status INTEGER, - lock_status INTEGER, - report_status INTEGER, - attachment_count INTEGER, - inline_content_count INTEGER, - thread_id INTEGER, - thread_item_count INTEGER, - preview_text TEXT, - meeting_request_status INTEGER, - FOREIGN KEY(account_id) REFERENCES mail_account_tbl(account_id) -); -CREATE TABLE mail_meeting_tbl -( - mail_id INTEGER PRIMARY KEY, - account_id INTEGER, - mailbox_name TEXT , - meeting_response INTEGER, - start_time INTEGER, - end_time INTEGER, - location TEXT , - global_object_id TEXT , - offset INTEGER, - standard_name TEXT , - standard_time_start_date INTEGER, - standard_bias INTEGER, - daylight_name TEXT , - daylight_time_start_date INTEGER, - daylight_bias INTEGER -); -CREATE TABLE mail_local_activity_tbl -( - activity_id INTEGER, - account_id INTEGER, - mail_id INTEGER, - activity_type INTEGER, - server_mailid VARCHAR(129), - src_mbox VARCHAR(129), - dest_mbox VARCHAR(129) -); - - -CREATE UNIQUE INDEX mail_account_idx1 ON mail_account_tbl (account_bind_type, account_id); -CREATE UNIQUE INDEX mail_attachment_idx1 ON mail_attachment_tbl (mail_id, attachment_id); -CREATE UNIQUE INDEX mail_box_idx1 ON mail_box_tbl (account_id, local_yn, mailbox_name); -CREATE UNIQUE INDEX mail_idx1 ON mail_tbl (mail_id, account_id); -CREATE UNIQUE INDEX mail_read_mail_uid_idx1 ON mail_read_mail_uid_tbl (account_id, local_mbox, local_uid, mailbox_name, s_uid); -CREATE UNIQUE INDEX mail_meeting_idx1 ON mail_meeting_tbl (mail_id); -CREATE INDEX mail_idx_date_time ON mail_tbl (date_time); -CREATE INDEX mail_idx_thread_item_count ON mail_tbl (thread_item_count); -' - -echo "[EMAIL-SERVICE] Finish Creating Email Tables." - - -################################################################# -# Change file permission -################################################################# -#echo "[EMAIL-SERVICE] Start setting permission ..." -# 1. libraries -#chmod 644 /usr/lib/libemail-ipc.so.0.0.0 -#chmod 644 /usr/lib/libemail-core.so.0.0.0 -#chmod 644 /usr/lib/libemail-emn-storage.so.0.0.0 -#chmod 644 /usr/lib/libemail-base.so.0.0.0 -#chmod 644 /usr/lib/libem-storage.so.0.0.0 -#chmod 644 /usr/lib/libem-network.so.0.0.0 -#chmod 644 /usr/lib/libemail-mapi.so.0.0.0 -#chmod 644 /usr/lib/libem-storage.so -#chmod 644 /usr/lib/libemail-base.so.0 -#chmod 644 /usr/lib/libem-network.so.0 -#chmod 644 /usr/lib/libemail-core.so.0 -#chmod 644 /usr/lib/libemail-emn-storage.so -#chmod 644 /usr/lib/libemail-ipc.so -#chmod 644 /usr/lib/libemail-mapi.so.0 -#chmod 644 /usr/lib/libem-storage.so.0 -#chmod 644 /usr/lib/libem-network.so -#chmod 644 /usr/lib/libemail-ipc.so.0 -#chmod 644 /usr/lib/libemail-core.so -#chmod 644 /usr/lib/libemail-base.so -#chmod 644 /usr/lib/libemail-mapi.so -#chmod 644 /usr/lib/libemail-emn-storage.so.0 - -# 2. executables -#chmod 700 /usr/bin/email-service_initDB -#chmod 700 /usr/bin/email-service - -# 3. DB files -chmod 644 /opt/dbspace/.email-service.db -chmod 644 /opt/dbspace/.email-service.db-journal - - -################################################################# -# Change file owner -################################################################# -#echo "[EMAIL-SERVICE] Start setting owner ..." - - # 1. libraries -# chown root:root /usr/lib/libemail-ipc.so.0.0.0 -# chown root:root /usr/lib/libemail-core.so.0.0.0 -# chown root:root /usr/lib/libemail-emn-storage.so.0.0.0 -# chown root:root /usr/lib/libemail-base.so.0.0.0 -# chown root:root /usr/lib/libem-storage.so.0.0.0 -# chown root:root /usr/lib/libem-network.so.0.0.0 -# chown root:root /usr/lib/libemail-mapi.so.0.0.0 -# chown root:root /usr/lib/libem-storage.so -# chown root:root /usr/lib/libemail-base.so.0 -# chown root:root /usr/lib/libem-network.so.0 -# chown root:root /usr/lib/libemail-core.so.0 -# chown root:root /usr/lib/libemail-emn-storage.so -# chown root:root /usr/lib/libemail-ipc.so -# chown root:root /usr/lib/libemail-mapi.so.0 -# chown root:root /usr/lib/libem-storage.so.0 -# chown root:root /usr/lib/libem-network.so -# chown root:root /usr/lib/libemail-ipc.so.0 -# chown root:root /usr/lib/libemail-core.so -# chown root:root /usr/lib/libemail-base.so -# chown root:root /usr/lib/libemail-mapi.so -# chown root:root /usr/lib/libemail-emn-storage.so.0 - - # 2. executables -# chown root:root /usr/bin/email-service_initDB -# chown root:root /usr/bin/email-service - - # 3. DB files -if [ ${USER} = "root" ] -then - chown root:root /opt/dbspace/.email-service.db - chown root:root /opt/dbspace/.email-service.db-journal -fi - -exit 0 diff --git a/debian/email-service-dev.install b/debian/email-service-dev.install deleted file mode 100755 index deb9940..0000000 --- a/debian/email-service-dev.install +++ /dev/null @@ -1,2 +0,0 @@ -usr/include/* -usr/lib/pkgconfig/* diff --git a/debian/email-service-tools.install b/debian/email-service-tools.install deleted file mode 100644 index a35587c..0000000 --- a/debian/email-service-tools.install +++ /dev/null @@ -1,4 +0,0 @@ -#/usr/bin/email-test-app -#/opt/etc/email-service/* -#/opt/dbspace/.email-service.db -#/opt/dbspace/.email-service.db-journal diff --git a/debian/email-service-tools.postinst b/debian/email-service-tools.postinst deleted file mode 100644 index 1672378..0000000 --- a/debian/email-service-tools.postinst +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh - -################################################################# -# Copy db file to /opt/dbspace -################################################################# - -echo "[EMAIL-SERVICE] Setting db permission & owner." - -if [ ${USER} = "root" ] -then - chown :6006 /opt/dbspace/.email-service.db - chmod 660 /opt/dbspace/.email-service.db - chown :6006 /opt/dbspace/.email-service.db-journal - chmod 660 /opt/dbspace/.email-service.db-journal -else - echo "[EMAIL-SERVICE] Can't change owner. USER is not root." -fi -echo "[EMAIL-SERVICE] Finish setting and owner." - - -#echo "[EMAIL-SERVICE] Start copying db file to /opt/dbspace ..." -#DB_PATH=/opt/dbspace/ -#if test ! -d ${DB_PATH} -#then -# mkdir /opt/dbspace -# echo "[EMAIL-SERVICE] Copy Error!!! There is not '${DB_PATH}'!!" -#else -# if test ! -s "${DB_PATH}/.email-service.db" -# then -# echo "[EMAIL-SERVICE] .email-service.db is copied to ${DB_PATH}" -# cp /usr/share/email-service/.email-service.db ${DB_PATH} -# cp /usr/share/email-service/.email-service.db-journal ${DB_PATH} - # change mod and owner -# chown :6006 /opt/dbspace/.email-service.db -# chmod 660 /opt/dbspace/.email-service.db -# chown :6006 /opt/dbspace/.email-service.db-journal -# chmod 660 /opt/dbspace/.email-service.db-journal -# else -# echo "[EMAIL-SERVICE] .email-service.db already exists." -# fi -#fi -#echo "[EMAIL-SERVICE] Finish copying db file. " - -#echo "[EMAIL-TEST-APP] Start setting permission ..." -# 1. executables -#chmod 700 /usr/bin/email_test_app - -#echo "[EMAIL-TEST-APP] Finish setting permission." - -# 3. resources - - -################################################################# -# Change file owner -################################################################# -#echo "[EMAIL-TEST-APP] Start setting owner ..." -#if [ ${USER} == "root" ] -#then - # 1. executables -# chown root:root /usr/bin/email_test_app -#else -# echo "[EMAIL-TEST-APP] Can't change owner. USER is not root." -#fi -#echo "[EMAIL-TEST-APP] Finish setting and owner." - diff --git a/debian/rules b/debian/rules deleted file mode 100755 index e773968..0000000 --- a/debian/rules +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - - -# These are used for cross-compiling and for saving the configure script -# from having to guess our platform (since we know it already) -DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) - -CFLAGS ?= -CXXFLAGS ?= -LDFLAGS ?= -PREFIX ?= /usr -DATADIR ?= /opt - -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O2 - CXXFLAGS += -O2 -else - CFLAGS += -O0 - CXXFLAGS += -O0 -endif - -CFLAGS += -fPIC -Wall -g -fvisibility=hidden -CXXFLAGS += -fPIC -Wall -g -fvisibility=hidden -LDFLAGS += -Wl,--hash-style=both - -LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed - -CMAKE_TMP_DIR = $(CURDIR)/cmake_tmp - -configure: configure-stamp -configure-stamp: - dh_testdir - # Add here commands to configure the package. - - mkdir -p $(CMAKE_TMP_DIR); - cd $(CMAKE_TMP_DIR); CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX) - touch configure-stamp - -build: build-stamp - -build-stamp: configure-stamp - dh_testdir - - # Add here commands to compile the package. - cd $(CMAKE_TMP_DIR) && $(MAKE) - - for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ - cat $$f > $${f%.in}; \ - sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \ - sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \ - done - - # Make .db file - #$(CMAKE_TMP_DIR)/utilities/email-service_initDB create 0 $(CMAKE_TMP_DIR)/utilities - - touch $@ - - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # Add here commands to clean up after the build process. - -$(MAKE) clean - rm -rf CMakeCache.txt - rm -rf CMakeFiles - rm -rf cmake_install.cmake - rm -rf Makefile - rm -rf install_manifest.txt - rm -rf *.so - rm -rf $(CMAKE_TMP_DIR) - - for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ - rm -f $${f%.in}; \ - done - - # Delete .db file - rm -f .*.db .*.db-journal - # Delete auto created files - rm -f Makefile.in aclocal.m4 configure config.sub config.guess config.h.in depcomp ltmain.sh missing install-sh - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/mm-log. - cd $(CMAKE_TMP_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install - mkdir -p $(CURDIR)/debian/tmp/opt/dbspace - #cp $(CMAKE_TMP_DIR)/utilities/.email-service.db $(CURDIR)/debian/tmp/opt/dbspace - #cp $(CMAKE_TMP_DIR)/utilities/.email-service.db-journal $(CURDIR)/debian/tmp/opt/dbspace - - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs - dh_installexamples - dh_install --sourcedir=debian/tmp -# dh_installmenu -# dh_installdebconf -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_python -# dh_installinit -# dh_installcron -# dh_installinfo - dh_installman - dh_link -# dh_strip - dh_strip --dbg-package=email-service-dbg - dh_compress - dh_fixperms -# dh_perl - dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install - diff --git a/email-api/CMakeLists.txt b/email-api/CMakeLists.txt index 15ce59c..15b9e9a 100755 --- a/email-api/CMakeLists.txt +++ b/email-api/CMakeLists.txt @@ -27,6 +27,8 @@ SET(API-SRCS ${CMAKE_SOURCE_DIR}/email-api/email-api-rule.c ${CMAKE_SOURCE_DIR}/email-api/email-api-mailbox.c ${CMAKE_SOURCE_DIR}/email-api/email-api-init.c + ${CMAKE_SOURCE_DIR}/email-api/email-api-smime.c + ${CMAKE_SOURCE_DIR}/email-api/email-api-etc.c ) INCLUDE_DIRECTORIES( @@ -69,6 +71,8 @@ SET(EMAIL-API-HEADERS ${CMAKE_SOURCE_DIR}/email-api/include/email-api-mailbox.h ${CMAKE_SOURCE_DIR}/email-api/include/email-api-network.h ${CMAKE_SOURCE_DIR}/email-api/include/email-api-rule.h + ${CMAKE_SOURCE_DIR}/email-api/include/email-api-etc.h + ${CMAKE_SOURCE_DIR}/email-api/include/email-api-smime.h ${CMAKE_SOURCE_DIR}/email-common-use/include/email-types.h ${CMAKE_SOURCE_DIR}/email-common-use/include/email-errors.h ) diff --git a/email-api/email-api-account.c b/email-api/email-api-account.c index 3962e70..7290261 100755 --- a/email-api/email-api-account.c +++ b/email-api/email-api-account.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Kyuho Jo , Sunghyun Kwon -* +* * 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 @@ -25,10 +25,10 @@ * This file contains the data structures and interfaces needed for application, * to interact with email-service. * @file email-api-account.c - * @brief This file contains the data structures and interfaces of Account related Functionality provided by - * email-service . + * @brief This file contains the data structures and interfaces of Account related Functionality provided by + * email-service . */ - + #include "email-api.h" #include "string.h" #include "email-convert.h" @@ -41,85 +41,93 @@ #include "email-ipc.h" /* API - Adds the Email Account */ -EXPORT_API int email_add_account(emf_account_t* account) +EXPORT_API int email_add_account(email_account_t* account) { EM_DEBUG_FUNC_BEGIN("account[%p]", account); char* local_account_stream = NULL; - int ret = -1; int size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + int ret_from_ipc = EMAIL_ERROR_NONE; + HIPC_API hAPI = NULL; if ( !account ) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_ACCOUNT); - - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + /* 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); 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); - EM_PROXY_IF_NULL_RETURN_VALUE(local_account_stream, hAPI, EMF_ERROR_NULL_VALUE); - - if(!emipc_add_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_SAFE_FREE(local_account_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - EM_DEBUG_LOG("APPID[%d], APIID [%d]", emipc_get_app_id(hAPI), emipc_get_api_id(hAPI)); - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + /* passing account information to service */ + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - EM_SAFE_FREE(local_account_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } - - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); - if(ret == EMF_ERROR_NONE) { + + /* get result from service */ + 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) { emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &account->account_id); - } else { /* get error code */ + } + else { /* get error code */ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); } - - emipc_destroy_email_api(hAPI); - hAPI = NULL; - EM_SAFE_FREE(local_account_stream); - EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%d]", ret, err); +FINISH_OFF: + + if(hAPI) + emipc_destroy_email_api(hAPI); + + EM_DEBUG_FUNC_END("ERROR CODE [%d]", err); return err; } -EXPORT_API int email_free_account(emf_account_t** account_list, int count) +EXPORT_API int email_free_account(email_account_t** account_list, int count) { EM_DEBUG_FUNC_BEGIN("account_list[%p], count[%d]", account_list, count); /* default variable */ - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (count > 0) { if (!account_list || !*account_list) { - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - emf_account_t* p = *account_list; + email_account_t* p = *account_list; int i; - + for (i = 0; i < count; i++) { EM_SAFE_FREE(p[i].account_name); - EM_SAFE_FREE(p[i].receiving_server_addr); - EM_SAFE_FREE(p[i].email_addr); - EM_SAFE_FREE(p[i].user_name); - EM_SAFE_FREE(p[i].password); - EM_SAFE_FREE(p[i].sending_server_addr); - EM_SAFE_FREE(p[i].sending_user); - EM_SAFE_FREE(p[i].sending_password); - EM_SAFE_FREE(p[i].display_name); - EM_SAFE_FREE(p[i].reply_to_addr); - EM_SAFE_FREE(p[i].return_addr); + EM_SAFE_FREE(p[i].incoming_server_address); + EM_SAFE_FREE(p[i].user_email_address); + EM_SAFE_FREE(p[i].incoming_server_user_name); + EM_SAFE_FREE(p[i].incoming_server_password); + EM_SAFE_FREE(p[i].outgoing_server_address); + EM_SAFE_FREE(p[i].outgoing_server_user_name); + EM_SAFE_FREE(p[i].outgoing_server_password); + EM_SAFE_FREE(p[i].user_display_name); + EM_SAFE_FREE(p[i].reply_to_address); + EM_SAFE_FREE(p[i].return_address); EM_SAFE_FREE(p[i].logo_icon_path); + EM_SAFE_FREE(p[i].user_data); + p[i].user_data_length = 0; EM_SAFE_FREE(p[i].options.display_name_from); EM_SAFE_FREE(p[i].options.signature); } @@ -130,7 +138,7 @@ FINISH_OFF: EM_DEBUG_FUNC_END("ERROR CODE [%d]", err); return err; } - + /* API - Delete the Email Account */ EXPORT_API int email_delete_account(int account_id) @@ -138,32 +146,32 @@ EXPORT_API int email_delete_account(int account_id) EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id); int ret = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (account_id < 0 || account_id == 0) { + if (account_id < 0 || account_id == 0) { EM_DEBUG_EXCEPTION(" account_id[%d]", account_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; return err; } HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_ACCOUNT); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); /* account_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); - if(ret != EMF_ERROR_NONE) { /* get error code */ - emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); + if(ret != EMAIL_ERROR_NONE) { /* get error code */ + emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); } emipc_destroy_email_api(hAPI); @@ -173,24 +181,24 @@ EXPORT_API int email_delete_account(int account_id) } /* API - Update the Email Account */ -EXPORT_API int email_update_account(int account_id, emf_account_t* new_account) +EXPORT_API int email_update_account(int account_id, email_account_t* new_account) { EM_DEBUG_FUNC_BEGIN("account_id[%d], new_account[%p]", account_id, new_account); int ret = 0; int size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int with_validation = false; char* new_account_stream = NULL; if ((account_id <= 0) || !new_account || (with_validation != false && with_validation != true)) { EM_DEBUG_EXCEPTION("account_id[%d], new_account[%p], with_validation[%d]", account_id, new_account, with_validation); - return EMF_ERROR_INVALID_PARAM; + return EMAIL_ERROR_INVALID_PARAM; } HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_ACCOUNT); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); /* account_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) { @@ -200,10 +208,8 @@ EXPORT_API int email_update_account(int account_id, emf_account_t* new_account) /* new_account */ new_account_stream = em_convert_account_to_byte_stream(new_account, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(new_account_stream, hAPI, EMF_ERROR_NULL_VALUE); - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) { + EM_PROXY_IF_NULL_RETURN_VALUE(new_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE); + if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) { EM_DEBUG_EXCEPTION("emipc_add_parameter new_account failed "); goto FINISH_OFF; } @@ -214,15 +220,13 @@ EXPORT_API int email_update_account(int account_id, emf_account_t* new_account) goto FINISH_OFF; } - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - EM_SAFE_FREE(new_account_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); - - if(ret != EMF_ERROR_NONE) { + if(ret != EMAIL_ERROR_NONE) { /* get error code */ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); } @@ -232,94 +236,86 @@ FINISH_OFF: emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_SAFE_FREE(new_account_stream); EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%d]", ret, err); return err; } /* API - Update the Email Account */ -EXPORT_API int email_update_account_with_validation(int account_id, emf_account_t* new_account) +EXPORT_API int email_update_account_with_validation(int account_id, email_account_t* new_account) { EM_DEBUG_FUNC_BEGIN("account_id[%d], new_account[%p]", account_id, new_account); int ret = 0; int size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int with_validation = true; char* new_account_stream = NULL; if ((account_id <= 0) || !new_account || (with_validation != false && with_validation != true)) { EM_DEBUG_EXCEPTION(" account_id[%d], new_account[%p], with_validation[%d]", account_id, new_account, with_validation); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; return err; } HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_ACCOUNT); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); /* account_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) { EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter account_id failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* new_account */ new_account_stream = em_convert_account_to_byte_stream(new_account, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(new_account_stream, hAPI, EMF_ERROR_NULL_VALUE); - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) { + EM_PROXY_IF_NULL_RETURN_VALUE(new_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE); + if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) { EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter new_account failed "); - EM_SAFE_FREE(new_account_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* with_validation */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_validation, sizeof(int))) { EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter with_validation failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("email_update_account--emipc_execute_proxy_api failed "); /* Prevent defect 18624 */ - EM_SAFE_FREE(new_account_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); - if(ret != EMF_ERROR_NONE) { /* get error code */ - emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); + 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; - EM_SAFE_FREE(new_account_stream); EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%d]", ret, err); return err; - - } /* API - Get the account Information based on the account ID */ -EXPORT_API int email_get_account(int account_id, int pulloption, emf_account_t** account) +EXPORT_API int email_get_account(int account_id, int pulloption, email_account_t** account) { EM_DEBUG_FUNC_BEGIN(); int ret = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_account_tbl_t *account_tbl = NULL; - EM_IF_NULL_RETURN_VALUE(account_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(account, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(account, EMAIL_ERROR_INVALID_PARAM); if (pulloption == GET_FULL_DATA) - pulloption = EMF_ACC_GET_OPT_FULL_DATA; + pulloption = EMAIL_ACC_GET_OPT_FULL_DATA; - if (pulloption & EMF_ACC_GET_OPT_PASSWORD) { - pulloption = pulloption & (~(EMF_ACC_GET_OPT_PASSWORD)); /* disable password -Can't obtain password by MAPI */ + if (pulloption & EMAIL_ACC_GET_OPT_PASSWORD) { + pulloption = pulloption & (~(EMAIL_ACC_GET_OPT_PASSWORD)); /* disable password -Can't obtain password by MAPI */ EM_DEBUG_LOG("change pulloption : disable password"); } @@ -328,12 +324,12 @@ EXPORT_API int email_get_account(int account_id, int pulloption, emf_account_t** goto FINISH_OFF; } - *account = em_malloc(sizeof(emf_account_t)); + *account = em_malloc(sizeof(email_account_t)); if (!*account) { EM_DEBUG_EXCEPTION("allocation failed [%d]", err); goto FINISH_OFF; } - memset((void*)*account, 0, sizeof(emf_account_t)); + memset((void*)*account, 0, sizeof(email_account_t)); em_convert_account_tbl_to_account(account_tbl, *account); @@ -347,15 +343,15 @@ FINISH_OFF: return err; } -EXPORT_API int email_get_account_list(emf_account_t** account_list, int* count) +EXPORT_API int email_get_account_list(email_account_t** account_list, int* count) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE, i = 0; + int err = EMAIL_ERROR_NONE, i = 0; emstorage_account_tbl_t *temp_account_tbl = NULL; - EM_IF_NULL_RETURN_VALUE(account_list, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(account_list, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM); if (!emstorage_get_account_list(count, &temp_account_tbl , true, false, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err); @@ -364,12 +360,12 @@ EXPORT_API int email_get_account_list(emf_account_t** account_list, int* count) } if(temp_account_tbl && (*count) > 0) { - *account_list = em_malloc(sizeof(emf_account_t) * (*count)); + *account_list = em_malloc(sizeof(email_account_t) * (*count)); if(!*account_list) { EM_DEBUG_EXCEPTION("allocation failed [%d]", err); goto FINISH_OFF; } - memset((void*)*account_list, 0, sizeof(emf_account_t) * (*count)); + 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); } @@ -389,26 +385,26 @@ EXPORT_API int email_validate_account(int account_id, unsigned* handle) EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%p]", account_id, handle); int ret = 0; - int err = EMF_ERROR_NONE; - if (account_id <= 0) { + int err = EMAIL_ERROR_NONE; + if (account_id <= 0) { EM_DEBUG_EXCEPTION("account_id[%d]", account_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; return err; } HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_VALIDATE_ACCOUNT); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); /* account_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) { EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); /* return */ @@ -426,13 +422,13 @@ EXPORT_API int email_validate_account(int account_id, unsigned* handle) } -EXPORT_API int email_add_account_with_validation(emf_account_t* account, unsigned* handle) +EXPORT_API int email_add_account_with_validation(email_account_t* account, unsigned* handle) { EM_DEBUG_FUNC_BEGIN("account[%p]", account); char* local_account_stream = NULL; int ret = -1; int size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; EM_IF_NULL_RETURN_VALUE(account, false); @@ -442,39 +438,34 @@ EXPORT_API int email_add_account_with_validation(emf_account_t* account, unsigne return err; } + /* 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); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - EM_DEBUG_LOG("Before em_convert_account_to_byte_stream"); local_account_stream = em_convert_account_to_byte_stream(account, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(local_account_stream, hAPI, EMF_ERROR_NULL_VALUE); - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) { + EM_PROXY_IF_NULL_RETURN_VALUE(local_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE); + if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) { EM_DEBUG_EXCEPTION(" emipc_add_parameter failed "); - EM_SAFE_FREE(local_account_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } - + emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); - if(ret == EMF_ERROR_NONE) { + if(ret == EMAIL_ERROR_NONE) { if(handle) emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle); } else { /* get error code */ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); } - + emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_SAFE_FREE(local_account_stream); EM_DEBUG_FUNC_END("err[%d]", err); return err; } @@ -484,33 +475,33 @@ EXPORT_API int email_backup_accounts_into_secure_storage(const char *file_name) { EM_DEBUG_FUNC_BEGIN("file_name[%s]", file_name); int ret = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (!file_name) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if (!file_name) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; return err; } HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_BACKUP_ACCOUNTS); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); /* file_name */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)file_name, strlen(file_name))) { + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)file_name, strlen(file_name)+1)) { EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); if(0 == ret) { /* get error code */ - emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); + emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); } emipc_destroy_email_api(hAPI); @@ -524,33 +515,33 @@ EXPORT_API int email_restore_accounts_from_secure_storage(const char * file_name { EM_DEBUG_FUNC_BEGIN("file_name[%s]", file_name); int ret = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (!file_name) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if (!file_name) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; return err; } HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_RESTORE_ACCOUNTS); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); /* file_name */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)file_name, strlen(file_name))) { + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)file_name, strlen(file_name)+1)) { EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); if(0==ret) { /* get error code */ - emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); + emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); } emipc_destroy_email_api(hAPI); @@ -564,27 +555,27 @@ EXPORT_API int email_get_password_length_of_account(const int account_id, int *p { EM_DEBUG_FUNC_BEGIN("account_id[%d], password_length[%p]", account_id, password_length); int ret = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (account_id <= 0 || password_length == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if (account_id <= 0 || password_length == NULL) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; return err; } HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); /* account_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) { EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); @@ -598,14 +589,14 @@ EXPORT_API int email_get_password_length_of_account(const int account_id, int *p return err; } -EXPORT_API int email_query_server_info(const char* domain_name, emf_server_info_t **result_server_info) +EXPORT_API int email_query_server_info(const char* domain_name, email_server_info_t **result_server_info) { EM_DEBUG_FUNC_BEGIN("domain_name [%s], result_server_info [%p]", domain_name, result_server_info); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (!domain_name || !result_server_info) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if (!domain_name || !result_server_info) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; return err; } @@ -616,14 +607,14 @@ EXPORT_API int email_query_server_info(const char* domain_name, emf_server_info_ } -EXPORT_API int email_free_server_info(emf_server_info_t **result_server_info) +EXPORT_API int email_free_server_info(email_server_info_t **result_server_info) { EM_DEBUG_FUNC_BEGIN("result_server_info [%p]", result_server_info); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (!result_server_info) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if (!result_server_info) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; return err; } @@ -636,27 +627,27 @@ EXPORT_API int email_free_server_info(emf_server_info_t **result_server_info) EXPORT_API int email_update_notification_bar(int account_id) { EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (account_id == 0) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if (account_id == 0) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; return err; } HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); /* account_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) { EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); @@ -671,35 +662,32 @@ EXPORT_API int email_update_notification_bar(int account_id) EXPORT_API int email_clear_all_notification_bar() { EM_DEBUG_FUNC_BEGIN(); - int ret = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - ret = emcore_clear_all_notifications(); + err = emcore_clear_all_notifications(); - EM_DEBUG_FUNC_END("ret[%d]", ret); + EM_DEBUG_FUNC_END("ret[%d]", err); return err; } EXPORT_API int email_save_default_account_id(int input_account_id) { EM_DEBUG_FUNC_BEGIN("input_account_id [%d]", input_account_id); - int ret = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - ret = emcore_save_default_account_id(input_account_id); + err = emcore_save_default_account_id(input_account_id); - EM_DEBUG_FUNC_END("ret[%d]", ret); + EM_DEBUG_FUNC_END("ret[%d]", err); return err; } EXPORT_API int email_load_default_account_id(int *output_account_id) { EM_DEBUG_FUNC_BEGIN("output_account_id [%p]", output_account_id); - int ret = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - ret = emcore_load_default_account_id(output_account_id); + err = emcore_load_default_account_id(output_account_id); - EM_DEBUG_FUNC_END("ret[%d]", ret); + 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 new file mode 100755 index 0000000..3502c72 --- /dev/null +++ b/email-api/email-api-etc.c @@ -0,0 +1,122 @@ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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 the data structures and interfaces needed for application, + * to interact with email-service. + * @file email-api-etc.c + * @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" +#include "email-core-utils.h" +#include "email-core-mime.h" + +EXPORT_API int email_show_user_message(int id, email_action_t action, int error_code) +{ + EM_DEBUG_FUNC_BEGIN("id [%d], action [%d], error_code [%d]", id, action, error_code); + int err = EMAIL_ERROR_NONE; + + if(id < 0 || action < 0) { + EM_DEBUG_LOG("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SHOW_USER_MESSAGE); + + /* id */ + 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))) { + 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))) { + 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)) { + EM_DEBUG_LOG("ipcProxy_ExecuteAsyncAPI failed"); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); + } + + emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); + + emipc_destroy_email_api(hAPI); + hAPI = NULL; + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +EXPORT_API int email_open_eml_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_FUNC_BEGIN("eml_file_path : [%s], 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_load_eml_file_to_mail(eml_file_path, output_mail_data, output_attachment_data, output_attachment_count, &err) || !*output_mail_data) + EM_DEBUG_EXCEPTION("emcore_load_eml_file_to_mail_data failed [%d]", err); + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +EXPORT_API int email_delete_eml_data(email_mail_data_t *input_mail_data) +{ + EM_DEBUG_FUNC_BEGIN("mail_data : [%p]", input_mail_data); + int err = EMAIL_ERROR_NONE; + + EM_IF_NULL_RETURN_VALUE(input_mail_data, EMAIL_ERROR_INVALID_PARAM); + + if (!emcore_delete_eml_data(input_mail_data, &err)) + EM_DEBUG_EXCEPTION("emcore_load_eml_file_to_mail_data failed [%d]", err); + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +EXPORT_API int email_get_mime_entity(char *mime_path, char **mime_entity) +{ + EM_DEBUG_FUNC_BEGIN("mime_path : [%s]", mime_path); + int err = EMAIL_ERROR_NONE; + + EM_IF_NULL_RETURN_VALUE(mime_path, EMAIL_ERROR_INVALID_PARAM); + + if (!emcore_get_mime_entity(mime_path, mime_entity, &err)) + EM_DEBUG_EXCEPTION("emcore_get_mime_entity failed [%d]", err); + + EM_DEBUG_FUNC_END(); + return err; +} diff --git a/email-api/email-api-init.c b/email-api/email-api-init.c index 000ddc0..e9130cc 100755 --- a/email-api/email-api-init.c +++ b/email-api/email-api-init.c @@ -41,7 +41,7 @@ EXPORT_API int email_open_db(void) { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (emstorage_db_open(&error) == NULL) EM_DEBUG_EXCEPTION("emstorage_db_open failed [%d]", error); @@ -55,7 +55,7 @@ EXPORT_API int email_open_db(void) EXPORT_API int email_close_db(void) { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if ( !emstorage_db_close(&error)) EM_DEBUG_EXCEPTION("emstorage_db_close failed [%d]", error); @@ -70,12 +70,11 @@ EXPORT_API int email_service_begin(void) EM_DEBUG_FUNC_BEGIN(); int ret = -1; - signal(SIGPIPE, SIG_IGN); /* to ignore signal 13(SIGPIPE) */ + signal(SIGPIPE, SIG_IGN); /* to ignore signal 13(SIGPIPE) */ ret = emipc_initialize_proxy(); - if (ret != EMF_ERROR_NONE) - EM_DEBUG_FUNC_END("err[%d]", ret); - + + EM_DEBUG_FUNC_END("err[%d]", ret); return ret; } @@ -86,7 +85,7 @@ EXPORT_API int email_service_end(void) int ret = -1; ret = emipc_finalize_proxy(); - if (ret != EMF_ERROR_NONE) + if (ret != EMAIL_ERROR_NONE) EM_DEBUG_FUNC_END("err[%d]", ret); return ret; @@ -98,9 +97,9 @@ EXPORT_API int email_service_end(void) EXPORT_API int email_init_storage(void) { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; - if (!emstorage_create_table(EMF_CREATE_DB_CHECK, &error)) { + if (!emstorage_create_table(EMAIL_CREATE_DB_CHECK, &error)) { EM_DEBUG_EXCEPTION("emstorage_create_table failed [%d]", error); } @@ -111,14 +110,14 @@ EXPORT_API int email_init_storage(void) EXPORT_API int email_ping_service(void) { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_PING_SERVICE); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &error); diff --git a/email-api/email-api-mail.c b/email-api/email-api-mail.c index fd82130..5781c22 100755 --- a/email-api/email-api-mail.c +++ b/email-api/email-api-mail.c @@ -47,105 +47,92 @@ #define _DIRECT_TO_DB -EXPORT_API int email_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas) +#define MAX_SEARCH_LEN 1000 + +EXPORT_API 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) { 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_IF_NULL_RETURN_VALUE(input_mail_data, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(input_mail_data->account_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(input_mail_data->mailbox_name, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(input_mail_data, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(input_mail_data->account_id, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(input_mail_data->mailbox_id, EMAIL_ERROR_INVALID_PARAM); if(input_attachment_count > 0 && !input_attachment_data_list) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int size = 0; char *mail_data_stream = NULL; char *attachment_data_list_stream = NULL; char *meeting_request_stream = NULL; HIPC_API hAPI = NULL; - if(input_from_eas == 0) { + if(input_from_eas == 0) { /* native emails */ hAPI = emipc_create_email_api(_EMAIL_API_ADD_MAIL); if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } - /* emf_mail_data_t */ - mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, 1, &size); + /* email_mail_data_t */ + mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, &size); if(!mail_data_stream) { EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mail_data_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter for head failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } + emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, mail_data_stream, size); - /* emf_attachment_data_t */ + /* email_attachment_data_t */ attachment_data_list_stream = em_convert_attachment_data_to_byte_stream(input_attachment_data_list, input_attachment_count, &size); - if(!attachment_data_list_stream) { - EM_DEBUG_EXCEPTION("em_convert_attachment_data_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; + if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) { + EM_DEBUG_EXCEPTION("emipc_add_dynamic_parameter failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - /* emf_meeting_request_t */ - if ( input_mail_data->meeting_request_status != EMF_MAIL_TYPE_NORMAL ) { + /* email_meeting_request_t */ + if ( input_mail_data->meeting_request_status != EMAIL_MAIL_TYPE_NORMAL ) { meeting_request_stream = em_convert_meeting_req_to_byte_stream(input_meeting_request, &size); if(!meeting_request_stream) { EM_DEBUG_EXCEPTION("em_convert_meeting_req_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, meeting_request_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } + emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, meeting_request_stream, size); } /* input_from_eas */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } + emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int)); /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - - if(err == EMF_ERROR_NONE) { - emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &input_mail_data->mail_id); /* result mail_id */ - emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), &input_mail_data->thread_id); /* result thread_id */ + /* get result from service */ + err = *((int*)emipc_get_nth_parameter_data(hAPI, ePARAMETER_OUT, 0)); + if(err == EMAIL_ERROR_NONE) { + /* result mail_id */ + input_mail_data->mail_id = *((int*)emipc_get_nth_parameter_data(hAPI, ePARAMETER_OUT, 1)); + /* result thread_id */ + input_mail_data->thread_id = *((int*)emipc_get_nth_parameter_data(hAPI, ePARAMETER_OUT, 2)); } } - else { - if((err = emcore_add_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMF_ERROR_NONE) { + 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); + if(err != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err); goto FINISH_OFF; } @@ -155,9 +142,6 @@ FINISH_OFF: if(hAPI) emipc_destroy_email_api(hAPI); - EM_SAFE_FREE(mail_data_stream); - EM_SAFE_FREE(attachment_data_list_stream); - EM_DEBUG_FUNC_END("err [%d]", err); return err; @@ -167,29 +151,29 @@ EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receip { EM_DEBUG_FUNC_BEGIN("input_read_mail_id [%d], output_receipt_mail_id [%p]", input_read_mail_id, output_receipt_mail_id); - EM_IF_NULL_RETURN_VALUE(output_receipt_mail_id, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(output_receipt_mail_id, EMAIL_ERROR_INVALID_PARAM); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_READ_RECEIPT); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_read_mail_id, sizeof(int))) { EM_DEBUG_EXCEPTION("Add Param mail body Fail"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + 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("err [%d]", err); - if(err == EMF_ERROR_NONE) { + if(err == EMAIL_ERROR_NONE) { /* Get receipt mail id */ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_receipt_mail_id); EM_DEBUG_LOG("output_receipt_mail_id [%d]", *output_receipt_mail_id); @@ -204,14 +188,15 @@ EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receip } + int email_create_db_full() { int mailbox_index, mail_index, mailbox_count, mail_slot_size; emstorage_mail_tbl_t mail_table_data = {0}; - emf_mailbox_t *mailbox_list = NULL; - int err = EMF_ERROR_NONE; + email_mailbox_t *mailbox_list = NULL; + int err = EMAIL_ERROR_NONE; - if ( (err = email_open_db()) != EMF_ERROR_NONE) { + if ( (err = email_open_db()) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("email_open_db failed [%d]", err); return err; } @@ -220,9 +205,8 @@ int email_create_db_full() mail_table_data.full_address_from = strdup(""); mail_table_data.full_address_to = strdup(""); mail_table_data.account_id =1; - mail_table_data.mailbox_name = (char*) em_malloc(250); - if( (err = email_get_mailbox_list_ex(1, -1, 0, &mailbox_list, &mailbox_count)) < EMF_ERROR_NONE) { + if( (err = email_get_mailbox_list_ex(1, -1, 0, &mailbox_list, &mailbox_count)) < EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("email_get_mailbox_list_ex failed [%d]", err); goto FINISH_OFF; } @@ -231,7 +215,7 @@ int email_create_db_full() mail_slot_size= mailbox_list[mailbox_index].mail_slot_size; for(mail_index = 0; mail_index < mail_slot_size; mail_index++) { sprintf(mail_table_data.subject, "Subject #%d",mail_index); - strncpy(mail_table_data.mailbox_name, mailbox_list[mailbox_index].name, 250 - 1); + 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)) { EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]",err); @@ -242,7 +226,7 @@ int email_create_db_full() } FINISH_OFF: - if ( (err = email_close_db()) != EMF_ERROR_NONE) { + if ( (err = email_close_db()) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("email_close_db failed [%d]", err); } @@ -250,27 +234,25 @@ FINISH_OFF: email_free_mailbox(&mailbox_list, mailbox_count); EM_SAFE_FREE(mail_table_data.subject); - EM_SAFE_FREE(mail_table_data.mailbox_name); EM_SAFE_FREE(mail_table_data.full_address_from); EM_SAFE_FREE(mail_table_data.full_address_to); return err; } -EXPORT_API int email_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas) +EXPORT_API 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) { 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_IF_NULL_RETURN_VALUE(input_mail_data, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(input_mail_data->account_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(input_mail_data->mailbox_name, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(input_mail_data, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(input_mail_data->account_id, EMAIL_ERROR_INVALID_PARAM); if(input_attachment_count > 0 && !input_attachment_data_list) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int size = 0; char *mail_data_stream = NULL; char *attachment_data_list_stream = NULL; @@ -283,53 +265,47 @@ EXPORT_API int email_update_mail(emf_mail_data_t *input_mail_data, emf_attachmen if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } - /* emf_mail_data_t */ - mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, 1, &size); + /* email_mail_data_t */ + mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, &size); if(!mail_data_stream) { EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mail_data_stream, size)) { EM_DEBUG_EXCEPTION("emipc_add_parameter for head failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - /* emf_attachment_data_t */ + /* email_attachment_data_t */ attachment_data_list_stream = em_convert_attachment_data_to_byte_stream(input_attachment_data_list, input_attachment_count, &size); - if(!attachment_data_list_stream) { - EM_DEBUG_EXCEPTION("em_convert_attachment_data_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; + if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) { + EM_DEBUG_EXCEPTION("emipc_add_dynamic_parameter failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - /* emf_meeting_request_t */ - if ( input_mail_data->meeting_request_status != EMF_MAIL_TYPE_NORMAL ) { + /* email_meeting_request_t */ + if ( input_mail_data->meeting_request_status != EMAIL_MAIL_TYPE_NORMAL ) { meeting_request_stream = em_convert_meeting_req_to_byte_stream(input_meeting_request, &size); if(!meeting_request_stream) { EM_DEBUG_EXCEPTION("em_convert_meeting_req_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } if(!emipc_add_parameter(hAPI, ePARAMETER_IN, meeting_request_stream, size)) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } } @@ -337,26 +313,26 @@ EXPORT_API int email_update_mail(emf_mail_data_t *input_mail_data, emf_attachmen /* input_from_eas */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - if(err == EMF_ERROR_NONE) { + if(err == EMAIL_ERROR_NONE) { emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &input_mail_data->mail_id); emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), &input_mail_data->thread_id); } } else { - if( (err = emcore_update_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMF_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) { EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err); goto FINISH_OFF; } @@ -367,7 +343,6 @@ FINISH_OFF: emipc_destroy_email_api(hAPI); EM_SAFE_FREE(mail_data_stream); - EM_SAFE_FREE(attachment_data_list_stream); EM_DEBUG_FUNC_END("err [%d]", err); return err; @@ -377,15 +352,15 @@ FINISH_OFF: EXPORT_API int email_clear_mail_data() { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_CLEAR_DATA); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api Fail"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); @@ -397,74 +372,58 @@ EXPORT_API int email_clear_mail_data() } -EXPORT_API int email_count_message(emf_mailbox_t* mailbox, int* total, int* unseen) +EXPORT_API 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) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p], unseen[%p]", mailbox, total, unseen); + EM_DEBUG_FUNC_BEGIN("input_filter_list[%p], input_filter_count [%d], output_total_mail_count[%p], output_unseen_mail_count[%p]", input_filter_list, input_filter_count, output_total_mail_count, output_unseen_mail_count); int total_count = 0; int unread = 0; - int err = EMF_ERROR_NONE; - - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(unseen, EMF_ERROR_INVALID_PARAM); + int err = EMAIL_ERROR_NONE; + char *conditional_clause_string = NULL; - if (!emstorage_get_mail_count(mailbox->account_id, mailbox->name, &total_count, &unread, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed"); + EM_IF_NULL_RETURN_VALUE(input_filter_list, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(input_filter_count, EMAIL_ERROR_INVALID_PARAM); + 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); - } else { - *total = total_count; - *unseen = unread; + 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) { + EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err); + goto FINISH_OFF; } - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} - + if ((err = emstorage_query_mail_count(conditional_clause_string, true, &total_count, &unread)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_query_mail_count failed [%d]", err); + goto FINISH_OFF; + } + *output_total_mail_count = total_count; + *output_unseen_mail_count = unread; -EXPORT_API int email_count_message_all_mailboxes(emf_mailbox_t* mailbox, int* total, int* unseen) -{ - EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p], unseen[%p]", mailbox, total, unseen); - - int total_count = 0; - int unread = 0; - int err = EMF_ERROR_NONE; - - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(unseen, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM); - - if (!emstorage_get_mail_count(mailbox->account_id, NULL, &total_count, &unread, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed"); +FINISH_OFF: - } else { - *total = total_count; - *unseen = unread; - } EM_DEBUG_FUNC_END("err [%d]", err); return err; } - -EXPORT_API int email_delete_message(emf_mailbox_t* mailbox, int *mail_ids, int num, int from_server) +EXPORT_API int email_delete_mail(int input_mailbox_id, int *input_mail_ids, int input_num, int input_from_server) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%p], num[%d], from_server[%d]", mailbox, mail_ids, num, from_server); + EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], input_mail_ids[%p], input_num[%d], input_from_server[%d]", input_mailbox_id, input_mail_ids, input_num, input_from_server); - char* mailbox_stream = NULL; - int size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; HIPC_API hAPI = NULL; - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(mail_ids, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(input_mail_ids, EMAIL_ERROR_INVALID_PARAM); - if (num <= 0) { - EM_DEBUG_EXCEPTION("num = %d", num); - err = EMF_ERROR_INVALID_PARAM; + if (input_mailbox_id <= 0) { + EM_DEBUG_EXCEPTION("input_mailbox_id = %d", input_mailbox_id); + err = EMAIL_ERROR_INVALID_PARAM; + return err; + } + + if (input_num <= 0) { + EM_DEBUG_EXCEPTION("input_num = %d", input_num); + err = EMAIL_ERROR_INVALID_PARAM; return err; } @@ -472,49 +431,41 @@ EXPORT_API int email_delete_message(emf_mailbox_t* mailbox, int *mail_ids, int n if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } - /* mailbox */ - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - if(!mailbox_stream) { - EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { + /* mailbox id*/ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Number of mail_ids */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) { + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_num, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* set of mail_ids */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) { + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)input_mail_ids, input_num * sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* from-server */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&from_server, sizeof(int))) { + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_server, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } @@ -524,56 +475,47 @@ FINISH_OFF: if(hAPI) emipc_destroy_email_api(hAPI); - EM_SAFE_FREE(mailbox_stream); - EM_DEBUG_FUNC_END("err [%d]", err); return err; } -EXPORT_API int email_delete_all_message_in_mailbox(emf_mailbox_t* mailbox, int from_server) +EXPORT_API int email_delete_all_mails_in_mailbox(int input_mailbox_id, int input_from_server) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], from_server[%d]", mailbox, from_server); + EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], input_from_server[%d]", input_mailbox_id, input_from_server); - char* mailbox_stream = NULL; - int size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; HIPC_API hAPI = NULL; - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM); + if(input_mailbox_id <= 0) { + EM_DEBUG_EXCEPTION("input_mailbox_id = %d", input_mailbox_id); + err = EMAIL_ERROR_INVALID_PARAM; + return err; + } - hAPI =emipc_create_email_api(_EMAIL_API_DELETE_ALL_MAIL); + hAPI = emipc_create_email_api(_EMAIL_API_DELETE_ALL_MAIL); if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - if(!mailbox_stream) { - EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&from_server, sizeof(int))){ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_server, sizeof(int))){ EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } @@ -583,8 +525,6 @@ FINISH_OFF: if(hAPI) emipc_destroy_email_api(hAPI); - - EM_SAFE_FREE(mailbox_stream); EM_DEBUG_FUNC_END("err [%d]", err); return err; @@ -592,81 +532,62 @@ FINISH_OFF: -EXPORT_API int email_add_attachment( emf_mailbox_t* mailbox, int mail_id, emf_attachment_info_t* attachment) +EXPORT_API int email_add_attachment(int mail_id, email_attachment_data_t* attachment) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment[%p]", mailbox, mail_id, attachment); - int err = EMF_ERROR_NONE; - char* mailbox_stream = NULL; - char* pAttchStream = NULL; + EM_DEBUG_FUNC_BEGIN("mail_id[%d], attachment[%p]", mail_id, attachment); + int err = EMAIL_ERROR_NONE; + char *attchment_stream = NULL; int size = 0; HIPC_API hAPI = NULL; - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(attachment, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(mail_id, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(attachment, EMAIL_ERROR_INVALID_PARAM); hAPI = emipc_create_email_api(_EMAIL_API_ADD_ATTACHMENT); if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - /* Mailbox */ - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - if(!mailbox_stream) { - EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } /* mail_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Attachment */ - pAttchStream = em_convert_attachment_info_to_byte_stream(attachment, &size); + attchment_stream = em_convert_attachment_data_to_byte_stream(attachment, 1, &size); - if(!pAttchStream) { - EM_DEBUG_EXCEPTION("em_convert_attachment_info_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; + if(!attchment_stream) { + EM_DEBUG_EXCEPTION("em_convert_attachment_data_to_byte_stream failed"); + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pAttchStream, size)){ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, attchment_stream, size)){ EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - if(EMF_ERROR_NONE == err) { + if(EMAIL_ERROR_NONE == err) { emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &attachment->attachment_id); } FINISH_OFF: - EM_SAFE_FREE(mailbox_stream); - EM_SAFE_FREE(pAttchStream); + EM_SAFE_FREE(attchment_stream); if(hAPI) emipc_destroy_email_api(hAPI); @@ -676,60 +597,33 @@ FINISH_OFF: } -EXPORT_API int email_delete_attachment(emf_mailbox_t * mailbox, int mail_id, const char *attachment_id) +EXPORT_API int email_delete_attachment(int attachment_id) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment_id[%s]", mailbox, mail_id, attachment_id); - int err = EMF_ERROR_NONE; - char* mailbox_stream = NULL; - int size = 0; - + EM_DEBUG_FUNC_BEGIN("attachment_id[%d]", attachment_id); + int err = EMAIL_ERROR_NONE; HIPC_API hAPI = NULL; - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(attachment_id, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(attachment_id, EMAIL_ERROR_INVALID_PARAM); hAPI = emipc_create_email_api(_EMAIL_API_DELETE_ATTACHMENT); if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - /* Mailbox */ - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - if(!mailbox_stream) { - EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - /* mail_id */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } - /* attachment_id */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)attachment_id, strlen(attachment_id))) { + /* attachment_index */ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&attachment_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } @@ -739,8 +633,6 @@ FINISH_OFF: if(hAPI) emipc_destroy_email_api(hAPI); - EM_SAFE_FREE(mailbox_stream); - return err; } @@ -748,15 +640,15 @@ FINISH_OFF: Mail Search API -----------------------------------------------------------*/ -EXPORT_API int email_query_mails(char *conditional_clause_string, emf_mail_data_t** mail_list, int *result_count) +EXPORT_API int email_query_mails(char *conditional_clause_string, email_mail_data_t** mail_list, int *result_count) { EM_DEBUG_FUNC_BEGIN("conditional_clause_string [%s], mail_list [%p], result_count [%p]", conditional_clause_string, mail_list, result_count); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_mail_tbl_t *result_mail_tbl; - EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(conditional_clause_string, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(result_count, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(conditional_clause_string, EMAIL_ERROR_INVALID_PARAM); if (!emstorage_query_mail_tbl(conditional_clause_string, true, &result_mail_tbl, result_count, &err)) { EM_DEBUG_EXCEPTION("emstorage_query_mail_list failed [%d]", err); @@ -777,18 +669,17 @@ FINISH_OFF: return err; } -EXPORT_API int email_query_message_ex(char *conditional_clause_string, emf_mail_list_item_t** mail_list, int *result_count) +EXPORT_API int email_query_mail_list(char *input_conditional_clause_string, email_mail_list_item_t** output_mail_list, int *output_result_count) { - EM_DEBUG_FUNC_BEGIN("conditional_clause_string [%s], mail_list [%p], result_count [%p]", conditional_clause_string, mail_list, result_count); + EM_DEBUG_FUNC_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 = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(conditional_clause_string, EMF_ERROR_INVALID_PARAM); + 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 (!emstorage_query_mail_list(conditional_clause_string, true, mail_list, result_count, &err)) { + if (!emstorage_query_mail_list(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; } @@ -801,93 +692,66 @@ FINISH_OFF: /* ----------------------------------------------------------- Mail Get Info API -----------------------------------------------------------*/ -EXPORT_API int email_get_attachment_info(emf_mailbox_t* mailbox, int mail_id, const char* attachment_id, emf_attachment_info_t** attachment) +EXPORT_API int email_get_attachment_data(int attachment_id, email_attachment_data_t** attachment) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment_id[%s], attachment[%p]", mailbox, mail_id, attachment_id, attachment); + EM_DEBUG_FUNC_BEGIN("attachment_id[%d], attachment[%p]", attachment_id, attachment); - int err = EMF_ERROR_NONE; - int size = 0; + int err = EMAIL_ERROR_NONE; int nSize = 0; - char* mailbox_stream = NULL; - char* pAttchStream = NULL; - emf_attachment_info_t* pAttch = NULL; - + int attachment_count = 0; + char* attchment_stream = NULL; + email_attachment_data_t* attachment_data = NULL; + + EM_IF_NULL_RETURN_VALUE(attachment_id, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(attachment, EMAIL_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(attachment_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(attachment, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM); HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_ATTACHMENT); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - /* Mailbox */ - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - if(!mailbox_stream) { - EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - /* mail_id */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - /* attachment_id */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)attachment_id, strlen(attachment_id))) { + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&attachment_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - if(EMF_ERROR_NONE == err) { + if(EMAIL_ERROR_NONE == err) { nSize = emipc_get_parameter_length(hAPI, ePARAMETER_OUT, 1); if(nSize > 0) { - pAttchStream = (char*)em_malloc(nSize+1); + attchment_stream = (char*)em_malloc(nSize+1); - if(!pAttchStream) { + if(!attchment_stream) { EM_DEBUG_EXCEPTION("em_malloc failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, nSize, pAttchStream); - em_convert_byte_stream_to_attachment_info(pAttchStream, 1, &pAttch); + emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, nSize, attchment_stream); + em_convert_byte_stream_to_attachment_data(attchment_stream, nSize, &attachment_data, &attachment_count); } - if(!pAttch) { - EM_DEBUG_EXCEPTION("EMF_ERROR_NULL_VALUE"); - err = EMF_ERROR_NULL_VALUE; + if(!attachment_data) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_NULL_VALUE"); + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } - *attachment = pAttch; + *attachment = attachment_data; } FINISH_OFF: - EM_SAFE_FREE(pAttchStream); + EM_SAFE_FREE(attchment_stream); if(hAPI) emipc_destroy_email_api(hAPI); @@ -897,12 +761,12 @@ FINISH_OFF: } -EXPORT_API int email_get_attachment_data_list(int input_mail_id, emf_attachment_data_t **output_attachment_data, int *output_attachment_count) +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_FUNC_BEGIN("input_mail_id[%d], output_attachment_data[%p], output_attachment_count[%p]", input_mail_id, output_attachment_data, output_attachment_count); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if((err = emcore_get_attachment_data_list(input_mail_id, output_attachment_data, output_attachment_count)) != EMF_ERROR_NONE) { + if((err = emcore_get_attachment_data_list(input_mail_id, output_attachment_data, output_attachment_count)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed [%d]", err); } @@ -910,57 +774,75 @@ EXPORT_API int email_get_attachment_data_list(int input_mail_id, emf_attachment_ return err; } -EXPORT_API int email_free_attachment_info(emf_attachment_info_t** atch_info) +EXPORT_API int email_free_attachment_data(email_attachment_data_t **attachment_data_list, int attachment_data_count) { - EM_DEBUG_FUNC_BEGIN("atch_info[%p]", atch_info); + EM_DEBUG_FUNC_BEGIN("attachment_data_list[%p], attachment_data_count[%d]", attachment_data_list, attachment_data_count); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (!atch_info || !*atch_info) - return EMF_ERROR_INVALID_PARAM; - - emf_attachment_info_t* p = *atch_info; - emf_attachment_info_t* t; + emcore_free_attachment_data(attachment_data_list, attachment_data_count, &err); - while (p) { - EM_SAFE_FREE(p->name); - EM_SAFE_FREE(p->savename); - t = p->next; - EM_SAFE_FREE(p); - p = t; - } EM_DEBUG_FUNC_END("err [%d]", err); return err; } -EXPORT_API int email_free_attachment_data(emf_attachment_data_t **attachment_data_list, int attachment_data_count) +EXPORT_API 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) { - EM_DEBUG_FUNC_BEGIN("attachment_data_list[%p], attachment_data_count[%d]", attachment_data_list, attachment_data_count); - - int err = EMF_ERROR_NONE; + 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 *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 = 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) { + 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, output_mail_list, output_result_count, &err)) { + EM_DEBUG_EXCEPTION("emstorage_query_mail_list [%d]", err); + goto FINISH_OFF; + } + +FINISH_OFF: + EM_SAFE_FREE(conditional_clause_string); - emcore_free_attachment_data(attachment_data_list, attachment_data_count, &err); - EM_DEBUG_FUNC_END("err [%d]", err); return err; } +EXPORT_API int email_free_list_filter(email_list_filter_t **input_filter_list, int input_filter_count) +{ + EM_DEBUG_FUNC_BEGIN("input_filter_list [%p], input_filter_count[%d]", input_filter_list, input_filter_count); + int err = EMAIL_ERROR_NONE; + + EM_IF_NULL_RETURN_VALUE(input_filter_list, EMAIL_ERROR_INVALID_PARAM); + + err = emstorage_free_list_filter(input_filter_list, input_filter_count); -EXPORT_API int email_get_mails(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_data_t** mail_list, int* result_count) + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +EXPORT_API int email_get_mails(int account_id , int mailbox_id, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, email_mail_data_t** mail_list, int* result_count) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_mail_tbl_t *mail_tbl_list = NULL; - EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(result_count, EMAIL_ERROR_INVALID_PARAM); if( account_id < ALL_ACCOUNT) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM ; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM ; goto FINISH_OFF; } - if (!emstorage_get_mails(account_id, (char*)mailbox_name, NULL, thread_id, start_index, limit_count, sorting, true, &mail_tbl_list, result_count, &err)) { + if (!emstorage_get_mails(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; @@ -979,20 +861,20 @@ FINISH_OFF: return err; } -EXPORT_API int email_get_mail_list_ex(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count) +EXPORT_API int email_get_mail_list(int account_id , int mailbox_id, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, email_mail_list_item_t** mail_list, int* result_count) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(result_count, EMAIL_ERROR_INVALID_PARAM); if( account_id < ALL_ACCOUNT) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } - if (!emstorage_get_mail_list(account_id, (char*) mailbox_name, NULL, thread_id, start_index, limit_count, 0, NULL, sorting, true, mail_list, result_count, &err)) { + 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)) { EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err); goto FINISH_OFF; @@ -1003,64 +885,24 @@ FINISH_OFF: return err; } -EXPORT_API int email_find_mail (int account_id , const char *mailbox_name, int thread_id, - int search_type, char *search_value, int start_index, int limit_count, - emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count) -{ - EM_DEBUG_FUNC_BEGIN(); - - int err = EMF_ERROR_NONE; - int search_num = 0; - emf_mail_list_item_t* mail_list_item = NULL; - - EM_IF_NULL_RETURN_VALUE(mail_list, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(search_value, EMF_ERROR_INVALID_PARAM); - - switch ( search_type ) { - case EMF_SEARCH_FILTER_SUBJECT: - case EMF_SEARCH_FILTER_SENDER: - case EMF_SEARCH_FILTER_RECIPIENT: - case EMF_SEARCH_FILTER_ALL: - break; - default: - EM_DEBUG_EXCEPTION("Invalid search filter type[%d]", search_type); - err = EMF_ERROR_INVALID_PARAM; - return err; - } - - if (!emstorage_get_searched_mail_list(account_id, (char*)mailbox_name, thread_id, search_type, search_value, start_index, limit_count, sorting, true, &mail_list_item, &search_num, &err)) { - EM_DEBUG_EXCEPTION("emstorage_search_mails -- Failed [%d]", err); - - goto FINISH_OFF; - } - - *mail_list = mail_list_item; - *result_count = search_num; - -FINISH_OFF: - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} - -EXPORT_API int email_get_mail_by_address(int account_id , const char *mailbox_name, emf_email_address_list_t* addr_list, - int start_index, int limit_count, int search_type, const char *search_value, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count) +EXPORT_API int email_get_mail_by_address(int account_id , int mailbox_id, email_email_address_list_t* addr_list, + int start_index, int limit_count, int search_type, const char *search_value, email_sort_type_t sorting, email_mail_list_item_t** mail_list, int* result_count) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - emf_mail_list_item_t* mail_list_item = NULL; + email_mail_list_item_t* mail_list_item = NULL; - EM_IF_NULL_RETURN_VALUE(mail_list, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(mail_list, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(result_count, EMAIL_ERROR_INVALID_PARAM); if( account_id < ALL_ACCOUNT) { EM_DEBUG_EXCEPTION("Invalid account id param"); - err = EMF_ERROR_INVALID_PARAM ; + err = EMAIL_ERROR_INVALID_PARAM ; return err; } - if (!emstorage_get_mail_list(account_id, (char*)mailbox_name, addr_list, EMF_LIST_TYPE_NORMAL, start_index, limit_count, search_type, search_value, sorting, true, &mail_list_item, result_count, &err)) { + 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)) { EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err); goto FINISH_OFF; @@ -1073,13 +915,13 @@ FINISH_OFF: return err; } -EXPORT_API int email_get_thread_information_by_thread_id(int thread_id, emf_mail_data_t** thread_info) +EXPORT_API int email_get_thread_information_by_thread_id(int thread_id, email_mail_data_t** thread_info) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_mail_tbl_t *mail_table_data = NULL; - EM_IF_NULL_RETURN_VALUE(thread_info, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(thread_info, EMAIL_ERROR_INVALID_PARAM); if (!emstorage_get_thread_information(thread_id, &mail_table_data , true, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_thread_information failed [%d]", err); @@ -1100,35 +942,35 @@ FINISH_OFF: return err; } -EXPORT_API int email_get_thread_information_ex(int thread_id, emf_mail_list_item_t** thread_info) +EXPORT_API int email_get_thread_information_ex(int thread_id, email_mail_list_item_t** thread_info) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_mail_tbl_t *mail_table_data = NULL; - emf_mail_list_item_t *temp_thread_info = NULL; + email_mail_list_item_t *temp_thread_info = NULL; - EM_IF_NULL_RETURN_VALUE(thread_info, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(thread_info, EMAIL_ERROR_INVALID_PARAM); if (!emstorage_get_thread_information(thread_id, &mail_table_data , true, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_thread_information -- failed [%d]", err); goto FINISH_OFF; } - temp_thread_info = em_malloc(sizeof(emf_mail_list_item_t)); + temp_thread_info = em_malloc(sizeof(email_mail_list_item_t)); if(!temp_thread_info) { EM_DEBUG_EXCEPTION("em_malloc failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - EM_SAFE_STRNCPY(temp_thread_info->mailbox_name , mail_table_data->mailbox_name, STRING_LENGTH_FOR_DISPLAY); EM_SAFE_STRNCPY(temp_thread_info->from , mail_table_data->full_address_from, STRING_LENGTH_FOR_DISPLAY); EM_SAFE_STRNCPY(temp_thread_info->from_email_address , mail_table_data->email_address_sender, MAX_EMAIL_ADDRESS_LENGTH); EM_SAFE_STRNCPY(temp_thread_info->recipients , mail_table_data->email_address_recipient, STRING_LENGTH_FOR_DISPLAY); EM_SAFE_STRNCPY(temp_thread_info->subject , mail_table_data->subject, STRING_LENGTH_FOR_DISPLAY); EM_SAFE_STRNCPY(temp_thread_info->previewBodyText , mail_table_data->preview_text, MAX_PREVIEW_TEXT_LENGTH); temp_thread_info->mail_id = mail_table_data->mail_id; + temp_thread_info->mailbox_id = mail_table_data->mailbox_id; temp_thread_info->account_id = mail_table_data->account_id; temp_thread_info->date_time = mail_table_data->date_time; temp_thread_info->is_text_downloaded = mail_table_data->body_download_status; @@ -1154,12 +996,12 @@ FINISH_OFF: return err; } -EXPORT_API int email_get_mail_data(int input_mail_id, emf_mail_data_t **output_mail_data) +EXPORT_API int email_get_mail_data(int input_mail_id, email_mail_data_t **output_mail_data) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if ( ((err = emcore_get_mail_data(input_mail_id, output_mail_data)) != EMF_ERROR_NONE) || !output_mail_data) + if ( ((err = emcore_get_mail_data(input_mail_id, output_mail_data)) != EMAIL_ERROR_NONE) || !output_mail_data) EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err); EM_DEBUG_FUNC_END("err [%d]", err); @@ -1170,156 +1012,81 @@ EXPORT_API int email_get_mail_data(int input_mail_id, emf_mail_data_t **output_m /* ----------------------------------------------------------- Mail Flag API -----------------------------------------------------------*/ -EXPORT_API int email_modify_mail_flag(int mail_id, emf_mail_flag_t new_flag, int onserver) -{ - EM_DEBUG_FUNC_BEGIN("mail_id[%d], on_server [ %d] ", mail_id, onserver); - - int err = EMF_ERROR_NONE; - - int i_flag, sticky = 0; - - if ( mail_id <= 0 || (onserver != 0 && onserver != 1) ) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; - } - - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MODIFY_MAIL_FLAG); - - if(!hAPI) { - EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - /* Mail ID */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - /* new_flag */ - if(!em_convert_mail_flag_to_int(new_flag, &i_flag, &err)) { - EM_DEBUG_EXCEPTION("em_convert_mail_flag_to_int failed "); - goto FINISH_OFF; - } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(i_flag), sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - sticky = new_flag.sticky; - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(sticky), sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - /* onserver */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(onserver), sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - - /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; - goto FINISH_OFF; - } - - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - -FINISH_OFF: - if(hAPI) - emipc_destroy_email_api(hAPI); - - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} - - - EXPORT_API int email_modify_seen_flag(int *mail_ids, int num, int seen_flag, int onserver) { EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num[%d],seen_flag[%d], on_server [ %d]", mail_ids, num, seen_flag, onserver); - EM_DEBUG_FUNC_END("EMF_ERROR_NOT_IMPLEMENTED"); - return EMF_ERROR_NOT_IMPLEMENTED; + EM_DEBUG_FUNC_END("EMAIL_ERROR_NOT_IMPLEMENTED"); + return EMAIL_ERROR_NOT_IMPLEMENTED; } -EXPORT_API int email_set_flags_field(int account_id, int *mail_ids, int num, emf_flags_field_type field_type, int value, int onserver) +EXPORT_API int email_set_flags_field(int account_id, int *mail_ids, int num, email_flags_field_type field_type, int value, int onserver) { EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_ids[%p], num[%d], field_type [%d], seen_flag[%d], on_server [ %d]", account_id, mail_ids, num, field_type, value, onserver); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - EM_IF_NULL_RETURN_VALUE(mail_ids, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(mail_ids, EMAIL_ERROR_INVALID_PARAM); if (account_id == 0 || num <= 0 || (onserver != 0 && onserver != 1)) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_FLAGS_FIELD); if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } /* account_id*/ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Number of mail_ids */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* set of mail_ids */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* field_type */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&field_type, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* value */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&value, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* onserver */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(onserver), sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } @@ -1333,132 +1100,69 @@ FINISH_OFF: return err; } -EXPORT_API int email_modify_extra_mail_flag(int mail_id, emf_extra_flag_t new_flag) -{ - EM_DEBUG_FUNC_BEGIN("mail_id[%d]", mail_id); - - int size = 0; - int err = EMF_ERROR_NONE; - char* pMailExtraFlagsStream = NULL; - - - EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM); - - pMailExtraFlagsStream = em_convert_extra_flags_to_byte_stream(new_flag, &size); - - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MODIFY_MAIL_EXTRA_FLAG); - - if(!hAPI) { - EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - /* Mail ID */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - /* Flag */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pMailExtraFlagsStream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; - goto FINISH_OFF; - } - - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - -FINISH_OFF: - emipc_destroy_email_api(hAPI); - EM_SAFE_FREE(pMailExtraFlagsStream); - - EM_DEBUG_FUNC_END("err [%d]", err); - return err; - -} - - /* ----------------------------------------------------------- Mail Move API -----------------------------------------------------------*/ -EXPORT_API int email_move_mail_to_mailbox(int *mail_ids, int num, emf_mailbox_t* mailbox) +EXPORT_API int email_move_mail_to_mailbox(int *mail_ids, int num, int input_target_mailbox_id) { - EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num [%d], mailbox[%p]", mail_ids, num, mailbox); + EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num [%d], input_target_mailbox_id[%d]", mail_ids, num, input_target_mailbox_id); - int size = 0; - char* mailbox_stream = NULL; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; HIPC_API hAPI = NULL; - - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(mail_ids, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM); + if(input_target_mailbox_id <= 0) { + EM_DEBUG_EXCEPTION("input_target_mailbox_id is invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + return err; + } + EM_IF_NULL_RETURN_VALUE(mail_ids, EMAIL_ERROR_INVALID_PARAM); if (num <= 0) { EM_DEBUG_LOG("num = %d", num); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; return err; } - + hAPI = emipc_create_email_api(_EMAIL_API_MOVE_MAIL); if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } /* Number of mail_ids */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* set of mail_ids */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - /* Mailbox */ - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - if(!mailbox_stream) { - EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { + /* input_target_mailbox_id */ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_target_mailbox_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); FINISH_OFF: - EM_SAFE_FREE(mailbox_stream); - if(hAPI) emipc_destroy_email_api(hAPI); @@ -1467,165 +1171,64 @@ FINISH_OFF: } -EXPORT_API int email_move_all_mails_to_mailbox(emf_mailbox_t* src_mailbox, emf_mailbox_t* new_mailbox) +EXPORT_API int email_move_all_mails_to_mailbox(int input_source_mailbox_id, int input_target_mailbox_id) { - EM_DEBUG_FUNC_BEGIN("src_mailbox[%p] , new_mailbox[%p]", src_mailbox, new_mailbox); + EM_DEBUG_FUNC_BEGIN("input_source_mailbox_id[%d] , input_target_mailbox_id[%d]", input_source_mailbox_id, input_target_mailbox_id); - int size = 0; - int err = EMF_ERROR_NONE; - char *dest_mailbox_stream = NULL; - char *source_mailbox_stream = NULL; + int err = EMAIL_ERROR_NONE; HIPC_API hAPI = NULL; - - EM_IF_NULL_RETURN_VALUE(src_mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(new_mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(new_mailbox->account_id, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(src_mailbox->account_id, EMF_ERROR_INVALID_PARAM); + if(input_source_mailbox_id <= 0 || input_target_mailbox_id <= 0) { + EM_DEBUG_EXCEPTION("mailbox_id is invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + return err; + } hAPI = emipc_create_email_api(_EMAIL_API_MOVE_ALL_MAIL); if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } - /* Src Mailbox Information */ - source_mailbox_stream = em_convert_mailbox_to_byte_stream(src_mailbox, &size); - - if(!source_mailbox_stream) { - EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, source_mailbox_stream, size)) { + /* input_source_mailbox_id */ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_source_mailbox_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - - size = 0; - /* Dst Mailbox Information */ - dest_mailbox_stream = em_convert_mailbox_to_byte_stream(new_mailbox, &size); - - if(!dest_mailbox_stream) { - EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed"); - err = EMF_ERROR_NULL_VALUE; - goto FINISH_OFF; - } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, dest_mailbox_stream, size)) { + /* input_target_mailbox_id */ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_target_mailbox_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - + /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); FINISH_OFF: - EM_SAFE_FREE(source_mailbox_stream); - EM_SAFE_FREE(dest_mailbox_stream); - if(hAPI) emipc_destroy_email_api(hAPI); EM_DEBUG_FUNC_END("err [%d]", err); return err; } - - - -EXPORT_API int email_count_message_with_draft_flag(emf_mailbox_t* mailbox, int* total) -{ - EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p]", mailbox, total); - - int err = EMF_ERROR_NONE; - int total_count = 0; - - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM); - if (!emstorage_get_mail_count_with_draft_flag(mailbox->account_id, mailbox->name, &total_count, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed"); - - } else { - *total = total_count; - } - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} - - -EXPORT_API int email_count_message_on_sending(emf_mailbox_t* mailbox, int* total) -{ - EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p]", mailbox, total); - int err = EMF_ERROR_NONE; - int total_count = 0; - - - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM); - - if (!emstorage_get_mail_count_on_sending(mailbox->account_id, mailbox->name, &total_count, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed"); - - } else - *total = total_count; - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} - -/** - * @open - * @fn email_get_mail_flag(int account_id, int mail_id, emf_mail_flag_t* mail_flag) - * @brief Get the Mail Flag information based on the account id and Mail Id. - * - * @param[in] account_id Specifies the Account ID - * @param[in] mail_id Specifies the Mail id for which Flag details need to be fetched - * @param[in/out] mail_flag Specifies the Pointer to the structure emf_mail_flag_t. - * @remarks N/A - * @return True on Success, False on Failure. - */ -EXPORT_API int email_get_mail_flag(int account_id, int mail_id, emf_mail_flag_t* mail_flag) -{ - EM_DEBUG_FUNC_BEGIN(); - - int err = EMF_ERROR_NONE; - - if (account_id < FIRST_ACCOUNT_ID|| mail_id < 1 || mail_flag == NULL) { - EM_DEBUG_EXCEPTION("Invalid Param"); - err = EMF_ERROR_INVALID_PARAM ; - goto FINISH_OFF; - } - - /* Fetch the flag Information */ - if (!emcore_fetch_flags(account_id, mail_id, mail_flag, &err)) { - EM_DEBUG_EXCEPTION("emcore_fetch_flags Failed [%d]", err); - goto FINISH_OFF; - } -FINISH_OFF: - EM_DEBUG_FUNC_END("err [%d]", err); - return err; - -} - - -EXPORT_API int email_free_mail_data(emf_mail_data_t** mail_list, int count) +EXPORT_API int email_free_mail_data(email_mail_data_t** mail_list, int count) { EM_DEBUG_FUNC_BEGIN("mail_list[%p], count[%d]", mail_list, count); - int err = EMF_ERROR_NONE; - emcore_free_mail_data(mail_list, count, &err); + int err = EMAIL_ERROR_NONE; + emcore_free_mail_data_list(mail_list, count); EM_DEBUG_FUNC_END("err [%d]", err); return err; } @@ -1633,26 +1236,26 @@ EXPORT_API int email_free_mail_data(emf_mail_data_t** mail_list, int count) /* Convert Modified UTF-7 mailbox name to UTF-8 */ /* returns modified UTF-8 Name if success else NULL */ -EXPORT_API int email_cancel_send_mail( int mail_id) +EXPORT_API int email_cancel_sending_mail( int mail_id) { EM_DEBUG_FUNC_BEGIN("Mail ID [ %d]", mail_id); - EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(mail_id, EMAIL_ERROR_INVALID_PARAM); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int account_id = 0; - emf_mail_data_t* mail_data = NULL; + email_mail_data_t* mail_data = NULL; HIPC_API hAPI = NULL; - if ((err = emcore_get_mail_data(mail_id, &mail_data)) != EMF_ERROR_NONE) { + if ((err = emcore_get_mail_data(mail_id, &mail_data)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err); goto FINISH_OFF; } if (!mail_data) { EM_DEBUG_EXCEPTION("mail_data is null"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } @@ -1662,28 +1265,28 @@ EXPORT_API int email_cancel_send_mail( int mail_id) if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } /* Account_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Mail ID */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } @@ -1693,30 +1296,24 @@ FINISH_OFF: if(hAPI) emipc_destroy_email_api(hAPI); - if ( !emcore_free_mail_data(&mail_data, 1, &err)) - EM_DEBUG_EXCEPTION("emcore_free_mail_data Failed [%d ] ", err); + emcore_free_mail_data_list(&mail_data, 1); EM_DEBUG_FUNC_END("err [%d]", err); return err; } -/** - * EmfSendCancel - Callback function for cm popup. We set the status as EMF_MAIL_STATUS_NONE - * - **/ - -EXPORT_API int email_retry_send_mail( int mail_id, int timeout_in_sec) +EXPORT_API int email_retry_sending_mail( int mail_id, int timeout_in_sec) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(mail_id, EMAIL_ERROR_INVALID_PARAM); if( timeout_in_sec < 0 ) { EM_DEBUG_EXCEPTION("Invalid timeout_in_sec"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; return err; } @@ -1724,28 +1321,28 @@ EXPORT_API int email_retry_send_mail( int mail_id, int timeout_in_sec) if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } /* Mail ID */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* timeout */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(timeout_in_sec), sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } @@ -1758,67 +1355,13 @@ FINISH_OFF: EM_DEBUG_FUNC_END("err [%d]", err); return err; - } - -EXPORT_API int email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name) -{ - EM_DEBUG_FUNC_BEGIN(); - - int err = EMF_ERROR_NONE; - char* mailbox_name = NULL; - emstorage_mail_tbl_t* mail_table_data = NULL; - - if(mail_id <= 0) { - EM_DEBUG_EXCEPTION("mail_id is not valid"); - err= EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } - EM_IF_NULL_RETURN_VALUE(pMailbox_name, EMF_ERROR_INVALID_PARAM); - - if(!emstorage_get_mail_by_id(mail_id, &mail_table_data, true, &err)) { - EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err); - - goto FINISH_OFF; - } - - if(mail_table_data->mailbox_name) - mailbox_name = strdup(mail_table_data->mailbox_name); - - *pMailbox_name = mailbox_name; - -FINISH_OFF: - if(mail_table_data) { - emstorage_free_mail(&mail_table_data, 1, &err); - - } - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} - - -EXPORT_API int email_get_latest_unread_mail_id(int account_id, int *pMailID) -{ - EM_DEBUG_FUNC_BEGIN(); - - int err = EMF_ERROR_NONE; - - if( (!pMailID) ||(account_id <= 0 && account_id != -1)) { - err = EMF_ERROR_INVALID_PARAM; - return err; - } - if(!emstorage_get_latest_unread_mailid(account_id,pMailID, &err)) { - EM_DEBUG_LOG("emstorage_get_latest_unread_mailid - failed"); - - } - EM_DEBUG_FUNC_END("err [%d]", err); - return err; } EXPORT_API int email_get_max_mail_count(int *Count) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - EM_IF_NULL_RETURN_VALUE(Count, EMF_ERROR_INVALID_PARAM); + int err = EMAIL_ERROR_NONE; + EM_IF_NULL_RETURN_VALUE(Count, EMAIL_ERROR_INVALID_PARAM); *Count = emstorage_get_max_mail_count(); EM_DEBUG_FUNC_END("err [%d]", err); return err; @@ -1830,9 +1373,9 @@ EXPORT_API int email_get_max_mail_count(int *Count) EXPORT_API int email_get_disk_space_usage(unsigned long *total_size) { EM_DEBUG_FUNC_BEGIN("total_size[%p]", total_size); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - EM_IF_NULL_RETURN_VALUE(total_size, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(total_size, EMAIL_ERROR_INVALID_PARAM); if (!emstorage_mail_get_total_diskspace_usage(total_size,true,&err)) { EM_DEBUG_EXCEPTION("emstorage_mail_get_total_diskspace_usage failed [%d]", err); @@ -1844,140 +1387,18 @@ FINISH_OFF : return err; } -EXPORT_API int email_get_recipients_list(int account_id, const char *mailbox_name, emf_sender_list_t **recipients_list) -{ - EM_DEBUG_FUNC_BEGIN("recipients_list[%p]", recipients_list); - - int number_of_mails, index; - int number_of_recipients; - int ret=0, err = 0; - - emf_sender_list_t *temp_recipients_list = NULL; - emf_sender_list_t *p_recipients_list = NULL; - GList *addr_list = NULL, *temp_addr_list = NULL; - emstorage_mail_tbl_t *mail_table_data = NULL; - - if (!emstorage_get_mails(account_id, (char*)mailbox_name, NULL, EMF_LIST_TYPE_NORMAL, -1, -1, EMF_SORT_SENDER_HIGH, true, &mail_table_data, &number_of_mails, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mails failed"); - - goto FINISH_OFF; - } - - for (index = 0; index < number_of_mails; index++) { - addr_list = emcore_get_recipients_list(addr_list, mail_table_data[index].full_address_to, &err); - addr_list = emcore_get_recipients_list(addr_list, mail_table_data[index].full_address_cc, &err); - addr_list = emcore_get_recipients_list(addr_list, mail_table_data[index].full_address_bcc, &err); - } - - number_of_recipients = g_list_length(addr_list); - - p_recipients_list = (emf_sender_list_t *)malloc(sizeof(emf_sender_list_t) * number_of_recipients); - if (p_recipients_list == NULL) { - EM_DEBUG_EXCEPTION("malloc for emf_sender_list_t failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; - ret = err; - goto FINISH_OFF; - } - memset(p_recipients_list, 0x00, sizeof(emf_sender_list_t) * number_of_recipients); - - temp_addr_list = g_list_first(addr_list); - index = 0; - while (temp_addr_list != NULL) { - temp_recipients_list = (emf_sender_list_t *)temp_addr_list->data; - p_recipients_list[index].address = temp_recipients_list->address; - p_recipients_list[index].display_name = temp_recipients_list->display_name; - p_recipients_list[index].total_count = temp_recipients_list->total_count + 1; - EM_DEBUG_LOG("address[%s], display_name[%s], total_count[%d]", p_recipients_list[index].address, p_recipients_list[index].display_name, p_recipients_list[index].total_count); - temp_addr_list = g_list_next(temp_addr_list); - index++; - } - - ret = true; -FINISH_OFF: - if (ret == true && recipients_list) - *recipients_list = p_recipients_list; else if (p_recipients_list != NULL) { - email_free_sender_list(&p_recipients_list, number_of_recipients); - } - - EM_DEBUG_FUNC_END(); - return ret; -} - -EXPORT_API int email_get_sender_list(int account_id, const char *mailbox_name, int search_type, const char *search_value, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count) -{ - EM_DEBUG_FUNC_BEGIN("sender_list[%p],sender_count[%p], sorting[%d]", sender_list, sender_count, sorting); - - int err = EMF_ERROR_NONE; - - emf_sender_list_t *temp_sender_list = NULL; - - EM_IF_NULL_RETURN_VALUE(sender_list, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(sender_count, EMF_ERROR_INVALID_PARAM); - if( account_id < ALL_ACCOUNT) { - EM_DEBUG_EXCEPTION(" Invalid Account Id Param "); - err = EMF_ERROR_INVALID_PARAM ; - return err; - } - - if ( !emstorage_get_sender_list(account_id, mailbox_name, search_type, search_value, sorting, &temp_sender_list, sender_count, &err) ) { - EM_DEBUG_EXCEPTION("emstorage_get_sender_list failed [%d]", err); - - goto FINISH_OFF; - } - - if ( sender_list ) - *sender_list = temp_sender_list; - -FINISH_OFF: - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} - -EXPORT_API int email_get_sender_list_ex(int account_id, const char *mailbox_name, int start_index, int limit_count, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count) -{ - return EMF_ERROR_NONE; -} - -EXPORT_API int email_free_sender_list(emf_sender_list_t **sender_list, int count) -{ - EM_DEBUG_FUNC_BEGIN("sender_list[%p], count[%d]", sender_list, count); - - int err = EMF_ERROR_NONE; - - if (count > 0) { - if (!sender_list || !*sender_list) { - EM_DEBUG_EXCEPTION("sender_list[%p], count[%d]", sender_list, count); - err = EMF_ERROR_INVALID_PARAM; - return err; - } - - emf_sender_list_t* p = *sender_list; - int i = 0; - - for (; i < count; i++) { - EM_SAFE_FREE(p[i].address); - EM_SAFE_FREE(p[i].display_name); - } - - EM_SAFE_FREE(p); - *sender_list = NULL; - } - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} - -EXPORT_API int email_get_address_info_list(int mail_id, emf_address_info_list_t** address_info_list) +EXPORT_API int email_get_address_info_list(int mail_id, email_address_info_list_t** address_info_list) { EM_DEBUG_FUNC_BEGIN("mail_id[%d], address_info_list[%p]", mail_id, address_info_list); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - emf_address_info_list_t *temp_address_info_list = NULL; + email_address_info_list_t *temp_address_info_list = NULL; - EM_IF_NULL_RETURN_VALUE(address_info_list, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(address_info_list, EMAIL_ERROR_INVALID_PARAM); if( mail_id <= 0) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM ; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM ; return err; } @@ -1999,30 +1420,30 @@ FINISH_OFF: return err; } -EXPORT_API int email_free_address_info_list(emf_address_info_list_t **address_info_list) +EXPORT_API int email_free_address_info_list(email_address_info_list_t **address_info_list) { EM_DEBUG_FUNC_BEGIN("address_info_list[%p]", address_info_list); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if ( (err = emstorage_free_address_info_list(address_info_list)) != EMF_ERROR_NONE ) { + if ( (err = emstorage_free_address_info_list(address_info_list)) != EMAIL_ERROR_NONE ) { EM_DEBUG_EXCEPTION("address_info_list[%p] free failed.", address_info_list); } EM_DEBUG_FUNC_END("err [%d]", err); return err; } -EXPORT_API int email_get_structure(const char*encoded_string, void **struct_var, emf_convert_struct_type_e type) +EXPORT_API int email_get_structure(const char*encoded_string, void **struct_var, email_convert_struct_type_e type) { EM_DEBUG_FUNC_BEGIN("encoded_string[%s], struct_var[%p], type[%d]", encoded_string, struct_var, type); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; void * temp_struct = NULL; - EM_IF_NULL_RETURN_VALUE(encoded_string, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(struct_var, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(encoded_string, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(struct_var, EMAIL_ERROR_INVALID_PARAM); - if ( (err = emcore_convert_string_to_structure((char*)encoded_string, &temp_struct, type)) != EMF_ERROR_NONE ) { + if ( (err = emcore_convert_string_to_structure((char*)encoded_string, &temp_struct, type)) != EMAIL_ERROR_NONE ) { EM_DEBUG_EXCEPTION("emcore_convert_string_to_structure failed[%d]", err); goto FINISH_OFF; } @@ -2035,18 +1456,18 @@ FINISH_OFF: return err; } -EXPORT_API int email_get_meeting_request(int mail_id, emf_meeting_request_t **meeting_req) +EXPORT_API int email_get_meeting_request(int mail_id, email_meeting_request_t **meeting_req) { EM_DEBUG_FUNC_BEGIN("mail_id[%d],meeting_req[%p]", mail_id, meeting_req); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - emf_meeting_request_t *temp_meeting_req = NULL; + email_meeting_request_t *temp_meeting_req = NULL; - EM_IF_NULL_RETURN_VALUE(meeting_req, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(meeting_req, EMAIL_ERROR_INVALID_PARAM); if( mail_id <= 0 ) { EM_DEBUG_EXCEPTION(" Invalid Mail Id Param "); - err = EMF_ERROR_INVALID_PARAM ; + err = EMAIL_ERROR_INVALID_PARAM ; return err; } @@ -2064,59 +1485,66 @@ FINISH_OFF: return err; } -EXPORT_API int email_free_meeting_request(emf_meeting_request_t** meeting_req, int count) +EXPORT_API int email_free_meeting_request(email_meeting_request_t** meeting_req, int count) { EM_DEBUG_FUNC_BEGIN("meeting_req[%p], count[%d]", meeting_req, count); + if( !meeting_req | !*meeting_req ) { + EM_DEBUG_EXCEPTION("NULL PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } - int err = EMF_ERROR_NONE; + int i = 0; + email_meeting_request_t *cur = *meeting_req; + for ( ; i < count ; i++ ) + emstorage_free_meeting_request(cur + i); - emstorage_free_meeting_request(meeting_req, count, &err); + EM_SAFE_FREE(*meeting_req); - EM_DEBUG_FUNC_END("err [%d]", err); - return err; + EM_DEBUG_FUNC_END(); + return EMAIL_ERROR_NONE; } -EXPORT_API int email_move_thread_to_mailbox(int thread_id, char *target_mailbox_name, int move_always_flag) +EXPORT_API int email_move_thread_to_mailbox(int thread_id, int target_mailbox_id, int move_always_flag) { - EM_DEBUG_FUNC_BEGIN("thread_id[%d], target_mailbox_name[%p], move_always_flag[%d]", thread_id, target_mailbox_name, move_always_flag); - int err = EMF_ERROR_NONE; + EM_DEBUG_FUNC_BEGIN("thread_id[%d], target_mailbox_id[%d], move_always_flag[%d]", thread_id, target_mailbox_id, move_always_flag); + int err = EMAIL_ERROR_NONE; - EM_IF_NULL_RETURN_VALUE(target_mailbox_name, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(target_mailbox_id, EMAIL_ERROR_INVALID_PARAM); HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MOVE_THREAD_TO_MAILBOX); if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } /* thread_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))){ EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* target mailbox information */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, target_mailbox_name, strlen(target_mailbox_name))){ - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&target_mailbox_id, sizeof(int))){ + EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; } /* move_always_flag */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&move_always_flag, sizeof(int))){ EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } @@ -2133,34 +1561,34 @@ FINISH_OFF: EXPORT_API int email_delete_thread(int thread_id, int delete_always_flag) { EM_DEBUG_FUNC_BEGIN("thread_id[%d], delete_always_flag[%d]", thread_id, delete_always_flag); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_THREAD); if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } /* thread_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))){ EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* delete_always_flag */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&delete_always_flag, sizeof(int))){ EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } @@ -2177,40 +1605,40 @@ FINISH_OFF: EXPORT_API int email_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server) { EM_DEBUG_FUNC_BEGIN("thread_id[%d], seen_flag[%d], on_server[%d]", thread_id, seen_flag, on_server); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD); if(!hAPI) { EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); - err = EMF_ERROR_NULL_VALUE; + err = EMAIL_ERROR_NULL_VALUE; goto FINISH_OFF; } /* thread_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* seen_flag */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&seen_flag, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* on_server */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&on_server, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - err = EMF_ERROR_IPC_SOCKET_FAILURE; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; goto FINISH_OFF; } @@ -2223,3 +1651,99 @@ FINISH_OFF: return err; } +EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, unsigned *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; + int return_value = 0; + 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) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed[%d]", err); + goto FINISH_OFF; + } + + email_account_server_t account_server_type = EMAIL_SERVER_TYPE_NONE; + ASNotiData as_noti_data; + + 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 ) { + 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 && input_on_server == true) { + 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.expunge_mails_deleted_flagged.handle = as_handle; + as_noti_data.expunge_mails_deleted_flagged.mailbox_id = input_mailbox_id; + as_noti_data.expunge_mails_deleted_flagged.on_server = input_on_server; + + return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_EXPUNGE_MAILS_DELETED_FLAGGED, &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_EXPUNGE_MAILS_DELETED_FLAGGED); + + if(!hAPI) { + EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); + err = EMAIL_ERROR_NULL_VALUE; + goto FINISH_OFF; + } + + /* input_mailbox_id */ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) { + EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + /* input_on_server */ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_on_server, sizeof(int))) { + EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + /* Execute API */ + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emipc_execute_proxy_api 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) { + if(output_handle) + emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_handle); + } + } + +FINISH_OFF: + if(hAPI) + emipc_destroy_email_api(hAPI); + + if(mailbox_tbl_data) { + emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL); + } + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} diff --git a/email-api/email-api-mailbox.c b/email-api/email-api-mailbox.c index 3527b43..b89d4c4 100755 --- a/email-api/email-api-mailbox.c +++ b/email-api/email-api-mailbox.c @@ -41,251 +41,388 @@ /* API - Create a mailbox */ -EXPORT_API int email_add_mailbox(emf_mailbox_t* new_mailbox, int on_server, unsigned* handle) +EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle) { EM_DEBUG_FUNC_BEGIN(); - - char* local_mailbox_stream = NULL; - int size = 0; - int err = EMF_ERROR_NONE; - EM_IF_NULL_RETURN_VALUE(new_mailbox, EMF_ERROR_INVALID_PARAM); - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_MAILBOX); + int size = 0; + int err = EMAIL_ERROR_NONE; + char* local_mailbox_stream = NULL; + email_account_server_t account_server_type; + HIPC_API hAPI = NULL; + ASNotiData as_noti_data; - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - local_mailbox_stream = em_convert_mailbox_to_byte_stream(new_mailbox, &size); + memset(&as_noti_data, 0x00, sizeof(ASNotiData)); - EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(new_mailbox, EMAIL_ERROR_INVALID_PARAM); - 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, EMF_ERROR_NULL_VALUE); + /* 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 ) { + 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(!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, EMF_ERROR_NULL_VALUE); - } + if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && on_server) { + int as_handle; - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + 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.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; + + 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) + *handle = as_handle; } + else { + hAPI = emipc_create_email_api(_EMAIL_API_ADD_MAILBOX); + + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); + + local_mailbox_stream = em_convert_mailbox_to_byte_stream(new_mailbox, &size); + + EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMAIL_ERROR_NULL_VALUE); - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - EM_DEBUG_LOG(" >>>>> error VALUE [%d]", err); + 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))) { + 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) { + EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); + } - if(handle) { - emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle); - EM_DEBUG_LOG(" >>>>> Handle [%d]", *handle); - } + emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); + EM_DEBUG_LOG(" >>>>> error VALUE [%d]", err); + if(handle) { + emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle); + EM_DEBUG_LOG(" >>>>> Handle [%d]", *handle); + } - emipc_destroy_email_api(hAPI); - hAPI = NULL; + emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), &(new_mailbox->mailbox_id)); + EM_DEBUG_LOG(" >>>>> new_mailbox->mailbox_id [%d]", new_mailbox->mailbox_id); + + emipc_destroy_email_api(hAPI); + hAPI = NULL; + } + +FINISH_OFF: EM_DEBUG_FUNC_END("err [%d]", err); return err; } - -/* API - Delete a mailbox */ - -EXPORT_API int email_delete_mailbox(emf_mailbox_t* mailbox, int on_server, unsigned* handle) +EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias, int input_on_server, unsigned *output_handle) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p]", mailbox); - - char* local_mailbox_stream = NULL; - int err = EMF_ERROR_NONE; - int size = 0; - - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(mailbox->account_id, EMF_ERROR_INVALID_PARAM) ; - - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_MAILBOX); + EM_DEBUG_FUNC_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); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + int err = EMAIL_ERROR_NONE; + email_account_server_t account_server_type; + HIPC_API hAPI = NULL; + ASNotiData as_noti_data; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; - local_mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM); + 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(!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, EMF_ERROR_NULL_VALUE); + if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err); + goto FINISH_OFF; } - - 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, EMF_ERROR_NULL_VALUE); + + /* 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 ) { + 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(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + 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 ) { + 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; + + 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) + *output_handle = as_handle; } + else { + hAPI = emipc_create_email_api(_EMAIL_API_RENAME_MAILBOX); - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - EM_DEBUG_LOG("error VALUE [%d]", err); + 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(handle) { - emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle); - EM_DEBUG_LOG("Handle [%d]", handle); - } + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_name, 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, 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_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) { + 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("error VALUE [%d]", err); + emipc_destroy_email_api(hAPI); + } +FINISH_OFF: + if (mailbox_tbl) + emstorage_free_mailbox(&mailbox_tbl, 1, NULL); - emipc_destroy_email_api(hAPI); - hAPI = NULL; EM_DEBUG_FUNC_END("err [%d]", err); return err; } -/* API - Update a mailbox */ +/* API - Delete a mailbox */ -EXPORT_API int email_update_mailbox(emf_mailbox_t* old_mailbox, emf_mailbox_t* new_mailbox) +EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, unsigned* output_handle) { - EM_DEBUG_FUNC_BEGIN(); + EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_on_server, output_handle); - char* local_mailbox_stream = NULL; - int err = EMF_ERROR_NONE; - int size = 0; - int on_server = 0; - EM_DEBUG_LOG(" old_mailbox[%p], new_mailbox[%p]", old_mailbox, new_mailbox); - - EM_IF_NULL_RETURN_VALUE(old_mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(old_mailbox->account_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(new_mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(new_mailbox->account_id, EMF_ERROR_INVALID_PARAM); + int err = EMAIL_ERROR_NONE; + email_account_server_t account_server_type; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; + HIPC_API hAPI = NULL; + ASNotiData as_noti_data; - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_MAILBOX); + EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + if ( (err = emstorage_get_mailbox_by_id(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 ) { + EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err); + err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + goto FINISH_OFF; + } - local_mailbox_stream = em_convert_mailbox_to_byte_stream(old_mailbox, &size); + if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server) { + int as_handle; - EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE); - - 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, EMF_ERROR_NULL_VALUE); + 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; + + 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) + *output_handle = as_handle; + } + else { + hAPI = emipc_create_email_api(_EMAIL_API_DELETE_MAILBOX); + + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); + + 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))) { + 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) { + 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("error VALUE [%d]", err); + + if(input_on_server) { + emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_handle); + EM_DEBUG_LOG("output_handle [%d]", output_handle); + } + + emipc_destroy_email_api(hAPI); } - - local_mailbox_stream = em_convert_mailbox_to_byte_stream(new_mailbox, &size); - EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE); +FINISH_OFF: + if (mailbox_tbl) { + emstorage_free_mailbox(&mailbox_tbl, 1, NULL); + } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) { + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +EXPORT_API int email_set_mailbox_type(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); + int err = EMAIL_ERROR_NONE; + + EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM); + + HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_MAILBOX_TYPE); + + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); + + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - EM_SAFE_FREE(local_mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + 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, &input_mailbox_type, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); - } + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); + } + + emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - EM_DEBUG_LOG("error VALUE [%d]", err); emipc_destroy_email_api(hAPI); hAPI = NULL; - + EM_DEBUG_FUNC_END("err [%d]", err); return err; -} -EXPORT_API int email_get_sync_mailbox_list(int account_id, emf_mailbox_t** mailbox_list, int* count) + +} + +EXPORT_API int email_get_sync_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count) { EM_DEBUG_FUNC_BEGIN(); - int counter = 0; - emstorage_mailbox_tbl_t* mailbox = NULL; - int err = EMF_ERROR_NONE ; - - EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM); + int mailbox_count = 0; + int err = EMAIL_ERROR_NONE ; + int i = 0; + 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(account_id, 0, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &counter, &mailbox, true, &err)) { + 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); goto FINISH_OFF; } else - err = EMF_ERROR_NONE; + err = EMAIL_ERROR_NONE; - if (counter > 0) { - if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * counter))) { + if (mailbox_count > 0) { + if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * mailbox_count))) { EM_DEBUG_EXCEPTION("malloc failed..."); - err= EMF_ERROR_OUT_OF_MEMORY; + err= EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } + for (i = 0; i < mailbox_count; i++) + em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, (*mailbox_list) + i); } else *mailbox_list = NULL; - *count = counter; + *count = mailbox_count; FINISH_OFF: - if (mailbox != NULL) - emstorage_free_mailbox(&mailbox, counter, NULL); + if (mailbox_tbl_list != NULL) + emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL); EM_DEBUG_FUNC_END("err [%d]", err); return err; } -EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, emf_mailbox_t** mailbox_list, int* count) +EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, email_mailbox_t** mailbox_list, int* count) { EM_DEBUG_FUNC_BEGIN(); int mailbox_count = 0; emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL; - int err =EMF_ERROR_NONE; + int err =EMAIL_ERROR_NONE; int i; - EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM); + 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(account_id, mailbox_sync_type, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) { + if (!emstorage_get_mailbox_list(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 = EMF_ERROR_NONE; + err = EMAIL_ERROR_NONE; if (mailbox_count > 0) { - if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * mailbox_count))) { + if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * mailbox_count))) { EM_DEBUG_EXCEPTION("malloc failed for mailbox_list"); - err= EMF_ERROR_OUT_OF_MEMORY; + err= EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - for (i = 0; i < mailbox_count; i++) { - (*mailbox_list)[i].mailbox_id = mailbox_tbl_list[i].mailbox_id; - (*mailbox_list)[i].account_id = account_id; - (*mailbox_list)[i].name = mailbox_tbl_list[i].mailbox_name; - mailbox_tbl_list[i].mailbox_name = NULL; - (*mailbox_list)[i].alias = mailbox_tbl_list[i].alias; - mailbox_tbl_list[i].alias = NULL; - (*mailbox_list)[i].local = mailbox_tbl_list[i].local_yn; - (*mailbox_list)[i].mailbox_type = mailbox_tbl_list[i].mailbox_type; - (*mailbox_list)[i].synchronous = mailbox_tbl_list[i].sync_with_server_yn; - (*mailbox_list)[i].unread_count = mailbox_tbl_list[i].unread_count; - (*mailbox_list)[i].total_mail_count_on_local = mailbox_tbl_list[i].total_mail_count_on_local; - (*mailbox_list)[i].total_mail_count_on_server = mailbox_tbl_list[i].total_mail_count_on_server; - (*mailbox_list)[i].has_archived_mails = mailbox_tbl_list[i].has_archived_mails; - (*mailbox_list)[i].mail_slot_size = mailbox_tbl_list[i].mail_slot_size; - } + for (i = 0; i < mailbox_count; i++) + em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, (*mailbox_list) + i); } else *mailbox_list = NULL; @@ -301,50 +438,37 @@ FINISH_OFF: -EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type, int with_count, emf_mailbox_t** mailbox_list, int* count) +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(); int mailbox_count = 0; emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL; - int err =EMF_ERROR_NONE; + int err =EMAIL_ERROR_NONE; int i; - EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM); + 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_ex(account_id, mailbox_sync_type, with_count, &mailbox_count, &mailbox_tbl_list, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailbox_ex failed [%d]", err); + if (!emstorage_get_mailbox_list_ex(account_id, mailbox_sync_type, with_count, &mailbox_count, &mailbox_tbl_list, true, &err)) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_list_ex failed [%d]", err); goto FINISH_OFF; } else - err = EMF_ERROR_NONE; + err = EMAIL_ERROR_NONE; if (mailbox_count > 0) { - if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * mailbox_count))) { + if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * mailbox_count))) { EM_DEBUG_EXCEPTION("malloc failed for mailbox_list"); - err= EMF_ERROR_OUT_OF_MEMORY; + err= EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - for (i = 0; i < mailbox_count; i++) { - (*mailbox_list)[i].mailbox_id = mailbox_tbl_list[i].mailbox_id; - (*mailbox_list)[i].account_id = account_id; - (*mailbox_list)[i].name = mailbox_tbl_list[i].mailbox_name; - mailbox_tbl_list[i].mailbox_name = NULL; - (*mailbox_list)[i].alias = mailbox_tbl_list[i].alias; - mailbox_tbl_list[i].alias = NULL; - (*mailbox_list)[i].local = mailbox_tbl_list[i].local_yn; - (*mailbox_list)[i].mailbox_type = mailbox_tbl_list[i].mailbox_type; - (*mailbox_list)[i].synchronous = mailbox_tbl_list[i].sync_with_server_yn; - (*mailbox_list)[i].unread_count = mailbox_tbl_list[i].unread_count; - (*mailbox_list)[i].total_mail_count_on_local = mailbox_tbl_list[i].total_mail_count_on_local; - (*mailbox_list)[i].total_mail_count_on_server = mailbox_tbl_list[i].total_mail_count_on_server; - (*mailbox_list)[i].has_archived_mails = mailbox_tbl_list[i].has_archived_mails; - (*mailbox_list)[i].mail_slot_size = mailbox_tbl_list[i].mail_slot_size; - } - } else + for (i = 0; i < mailbox_count; i++) + em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, (*mailbox_list) + i); + } + else *mailbox_list = NULL; if ( count ) @@ -359,194 +483,105 @@ FINISH_OFF: } -EXPORT_API int email_get_mailbox_by_name(int account_id, const char *pMailboxName, emf_mailbox_t **pMailbox) +/* sowmya.kr, 05-Apr-2010, new MAPI*/ + +EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t** mailbox) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - emf_mailbox_t* curr_mailbox = NULL; + int err = EMAIL_ERROR_NONE; + email_mailbox_t* curr_mailbox = NULL; emstorage_mailbox_tbl_t* local_mailbox = NULL; - EM_IF_NULL_RETURN_VALUE(pMailbox, EMF_ERROR_INVALID_PARAM); - if(!pMailboxName) - return EMF_ERROR_INVALID_PARAM; - - if (!emstorage_get_mailbox_by_name(account_id, -1, (char*)pMailboxName, &local_mailbox, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d]", err); - return err; - } else { - curr_mailbox = em_malloc(sizeof(emf_mailbox_t)); - memset(curr_mailbox, 0x00, sizeof(emf_mailbox_t)); - - curr_mailbox->account_id = local_mailbox->account_id; - if(local_mailbox->mailbox_name) - curr_mailbox->name = strdup(local_mailbox->mailbox_name); - curr_mailbox->local = local_mailbox->local_yn; - if(local_mailbox->alias) - curr_mailbox->alias= strdup(local_mailbox->alias); - curr_mailbox->synchronous = local_mailbox->sync_with_server_yn; - curr_mailbox->mailbox_type = local_mailbox->mailbox_type; - curr_mailbox->unread_count = local_mailbox->unread_count; - curr_mailbox->total_mail_count_on_local= local_mailbox->total_mail_count_on_local; - curr_mailbox->total_mail_count_on_server= local_mailbox->total_mail_count_on_server; - curr_mailbox->has_archived_mails = local_mailbox->has_archived_mails; - curr_mailbox->mail_slot_size = local_mailbox->mail_slot_size; - } - - *pMailbox = curr_mailbox; - - emstorage_free_mailbox(&local_mailbox, 1, &err); - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} + EM_IF_NULL_RETURN_VALUE(mailbox, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM) ; -EXPORT_API int email_get_child_mailbox_list(int account_id, const char *parent_mailbox, emf_mailbox_t** mailbox_list, int* count) -{ - EM_DEBUG_FUNC_BEGIN("account_id[%d], parent_mailbox[%p], mailbox_list[%p], count[%p]", account_id, parent_mailbox, mailbox_list, count); - - int err = EMF_ERROR_NONE; - int counter = 0; - emstorage_mailbox_tbl_t* mailbox_tbl = NULL; - int i =0; - - EM_IF_NULL_RETURN_VALUE(account_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM); - - *mailbox_list = NULL; - *count = 0; - - if (!emstorage_get_child_mailbox_list(account_id,(char*)parent_mailbox, &counter, &mailbox_tbl, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_child_mailbox_list failed[%d]", err); - + if(mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_ALL_EMAILS) + return EMAIL_ERROR_INVALID_PARAM; + if (!emstorage_get_mailbox_by_mailbox_type(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 = EMF_ERROR_NONE; - - if (counter > 0) { - if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * counter))) { - EM_DEBUG_EXCEPTION("malloc failed for mailbox_list"); - - err= EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - memset(*mailbox_list, 0x00, (sizeof(emf_mailbox_t) * counter)); - - for (i = 0; i < counter; i++) { - (*mailbox_list)[i].mailbox_id = mailbox_tbl[i].mailbox_id; - (*mailbox_list)[i].account_id = account_id; - (*mailbox_list)[i].name = mailbox_tbl[i].mailbox_name; mailbox_tbl[i].mailbox_name = NULL; - (*mailbox_list)[i].alias = mailbox_tbl[i].alias; mailbox_tbl[i].alias = NULL; - (*mailbox_list)[i].local = mailbox_tbl[i].local_yn; - (*mailbox_list)[i].mailbox_type = mailbox_tbl[i].mailbox_type; - (*mailbox_list)[i].synchronous = mailbox_tbl[i].sync_with_server_yn; - (*mailbox_list)[i].unread_count = mailbox_tbl[i].unread_count; - (*mailbox_list)[i].total_mail_count_on_local = mailbox_tbl[i].total_mail_count_on_local; - (*mailbox_list)[i].total_mail_count_on_server = mailbox_tbl[i].total_mail_count_on_server; - (*mailbox_list)[i].has_archived_mails = mailbox_tbl[i].has_archived_mails; - (*mailbox_list)[i].mail_slot_size = mailbox_tbl[i].mail_slot_size; - } - } else - *mailbox_list = NULL; - - *count = counter; + } else { + err = EMAIL_ERROR_NONE; + curr_mailbox = em_malloc(sizeof(email_mailbox_t)); + memset(curr_mailbox, 0x00, sizeof(email_mailbox_t)); + em_convert_mailbox_tbl_to_mailbox(local_mailbox, curr_mailbox); + } + *mailbox = curr_mailbox; FINISH_OFF: - if (mailbox_tbl != NULL) - emstorage_free_mailbox(&mailbox_tbl, counter, NULL); + + if(local_mailbox) + emstorage_free_mailbox(&local_mailbox, 1, NULL); EM_DEBUG_FUNC_END("err [%d]", err); return err; } -/* sowmya.kr, 05-Apr-2010, new MAPI*/ - -EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, emf_mailbox_t** mailbox) +EXPORT_API int email_get_mailbox_by_mailbox_id(int input_mailbox_id, email_mailbox_t** output_mailbox) { EM_DEBUG_FUNC_BEGIN(); - - int err = EMF_ERROR_NONE; - emf_mailbox_t* curr_mailbox = NULL; + + int err = EMAIL_ERROR_NONE; + email_mailbox_t* curr_mailbox = NULL; emstorage_mailbox_tbl_t* local_mailbox = NULL; - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(account_id, EMF_ERROR_INVALID_PARAM) ; + 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) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err); + return err; + } else { + curr_mailbox = em_malloc(sizeof(email_mailbox_t)); - if(mailbox_type < EMF_MAILBOX_TYPE_INBOX || mailbox_type > EMF_MAILBOX_TYPE_ALL_EMAILS) - return EMF_ERROR_INVALID_PARAM; - if (!emstorage_get_mailbox_by_mailbox_type(account_id, mailbox_type, &local_mailbox, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err); + memset(curr_mailbox, 0x00, sizeof(email_mailbox_t)); - goto FINISH_OFF; - } else { - err = EMF_ERROR_NONE; - curr_mailbox = em_malloc(sizeof(emf_mailbox_t)); - memset(curr_mailbox, 0x00, sizeof(emf_mailbox_t)); - - curr_mailbox->account_id = local_mailbox->account_id; - if(local_mailbox->mailbox_name) - curr_mailbox->name = strdup(local_mailbox->mailbox_name); - curr_mailbox->local = local_mailbox->local_yn; - if(local_mailbox->alias) - curr_mailbox->alias= strdup(local_mailbox->alias); - curr_mailbox->synchronous = 1; - curr_mailbox->mailbox_type = local_mailbox->mailbox_type; - curr_mailbox->unread_count = local_mailbox->unread_count; - curr_mailbox->total_mail_count_on_local = local_mailbox->total_mail_count_on_local; - curr_mailbox->total_mail_count_on_server = local_mailbox->total_mail_count_on_server; - curr_mailbox->has_archived_mails = local_mailbox->has_archived_mails; - curr_mailbox->mail_slot_size = local_mailbox->mail_slot_size; + em_convert_mailbox_tbl_to_mailbox(local_mailbox, curr_mailbox); } - *mailbox = curr_mailbox; -FINISH_OFF: + *output_mailbox = curr_mailbox; + + emstorage_free_mailbox(&local_mailbox, 1, &err); - if(local_mailbox) - emstorage_free_mailbox(&local_mailbox, 1, NULL); EM_DEBUG_FUNC_END("err [%d]", err); return err; } -EXPORT_API int email_set_mail_slot_size(int account_id, char* mailbox_name, int new_slot_size/*, unsigned* handle*/) +EXPORT_API int email_set_mail_slot_size(int account_id, int mailbox_id, int new_slot_size) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p], new_slot_size[%d]", account_id, mailbox_name, new_slot_size); + EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_id[%d], new_slot_size[%d]", account_id, mailbox_id, new_slot_size); - int err = EMF_ERROR_NONE, *handle = NULL; + int err = EMAIL_ERROR_NONE, *handle = NULL; if(new_slot_size < 0) { EM_DEBUG_EXCEPTION("new_slot_size should be greater than 0 or should be equal to 0"); - return EMF_ERROR_INVALID_PARAM; + return EMAIL_ERROR_INVALID_PARAM; } HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_MAIL_SLOT_SIZE); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); if (hAPI) { 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, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); + } + + 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))) { EM_DEBUG_EXCEPTION(" emipc_add_parameter for new_slot_size failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - if(mailbox_name) { - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_name, strlen(mailbox_name) )) { - EM_DEBUG_EXCEPTION(" emipc_add_parameter for mailbox_name failed"); - EM_SAFE_FREE(mailbox_name); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - } - - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); @@ -563,24 +598,37 @@ EXPORT_API int email_set_mail_slot_size(int account_id, char* mailbox_name, int return err; } -EXPORT_API int email_free_mailbox(emf_mailbox_t** mailbox_list, int count) +EXPORT_API int email_stamp_sync_time_of_mailbox(int input_mailbox_id) +{ + EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d]", input_mailbox_id); + + int err = EMAIL_ERROR_NONE; + + EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM); + + err = emstorage_stamp_last_sync_time_of_mailbox(input_mailbox_id, 1); + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +EXPORT_API int email_free_mailbox(email_mailbox_t** mailbox_list, int count) { EM_DEBUG_FUNC_BEGIN("mailbox_list[%p], count[%d]", mailbox_list, count); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (count <= 0 || !mailbox_list || !*mailbox_list) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - emf_mailbox_t *p = *mailbox_list; + email_mailbox_t *p = *mailbox_list; int i; for (i = 0; i < count; i++) { - EM_SAFE_FREE(p[i].name); + EM_SAFE_FREE(p[i].mailbox_name); EM_SAFE_FREE(p[i].alias); - EM_SAFE_FREE(p[i].account_name); } EM_SAFE_FREE(p); diff --git a/email-api/email-api-network.c b/email-api/email-api-network.c index d1e9451..7aeb1d1 100755 --- a/email-api/email-api-network.c +++ b/email-api/email-api-network.c @@ -39,403 +39,101 @@ #include "email-ipc.h" #include "email-storage.h" -#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__ -#include -#include -#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ -#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__ -#define ACTIVE_SYNC_HANDLE_INIT_VALUE (-1) -#define ACTIVE_SYNC_HANDLE_BOUNDARY (-100000000) - - -static int email_get_account_server_type_by_account_id(int account_id, emf_account_server_t* account_server_type, int flag, int *error) -{ - EM_DEBUG_FUNC_BEGIN(); - emf_account_t *account=NULL; - int ret = false; - int err= EMF_ERROR_NONE; - - if (account_server_type == NULL ) { - EM_DEBUG_EXCEPTION("account_server_type is NULL"); - err = EMF_ERROR_INVALID_PARAM; - ret = false; - goto FINISH_OFF; - } - - if( (err = email_get_account(account_id,WITHOUT_OPTION,&account)) < 0) { - EM_DEBUG_EXCEPTION ("email_get_account failed [%d] ", err); - ret = false; - goto FINISH_OFF; - } - - if ( flag == false ) { /* sending server */ - *account_server_type = account->sending_server_type; - } else if ( flag == true ) { /* receiving server */ - *account_server_type = account->receiving_server_type; - } - - ret = true; - -FINISH_OFF: - if ( account != NULL ) { - email_free_account(&account, 1); - } - if ( error != NULL ) { - *error = err; - } - - return ret; -} - -static int email_get_handle_for_activesync(int *handle, int *error) +EXPORT_API int email_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle) { - EM_DEBUG_FUNC_BEGIN(); - - static int next_handle = 0; - int ret = false; - int err = EMF_ERROR_NONE; - - if ( handle == NULL ) { - EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed : handle is NULL"); - err = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } + EM_DEBUG_FUNC_BEGIN("mail_id[%d], sending_option[%p], handle[%p]", mail_id, sending_option, handle); - if ( vconf_get_int(VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE, &next_handle) != 0 ) { - EM_DEBUG_EXCEPTION("vconf_get_int failed"); - if ( next_handle != 0 ) { - err = EMF_ERROR_GCONF_FAILURE; - goto FINISH_OFF; - } - } - - EM_DEBUG_LOG(">>>>>> VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE : get lastest handle[%d]", next_handle); + char* pSendingOption = NULL; + int size = 0; + int err = EMAIL_ERROR_NONE; + emstorage_mail_tbl_t* mail_table_data = NULL; - /* set the value of the handle for active sync */ - next_handle--; - if ( next_handle < ACTIVE_SYNC_HANDLE_BOUNDARY ) { - next_handle = ACTIVE_SYNC_HANDLE_INIT_VALUE; - } - if ( vconf_set_int(VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE, next_handle) != 0) { - EM_DEBUG_EXCEPTION("vconf_set_int failed"); - err = EMF_ERROR_GCONF_FAILURE; + if(mail_id <= 0) { + EM_DEBUG_EXCEPTION("mail_id is not valid"); + err= EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - ret = true; - *handle = next_handle; - EM_DEBUG_LOG(">>>>>> return next handle[%d]", *handle); - -FINISH_OFF: - if ( error != NULL ) { - *error = err; - } - - return ret; -} - -static int email_send_notification_to_active_sync_engine(int subType, ASNotiData *data) -{ - EM_DEBUG_FUNC_BEGIN("subType [%d], data [%p]", subType, data); - - DBusConnection *connection; - DBusMessage *signal = NULL; - DBusError error; - const char *nullString = ""; - int i = 0; - dbus_int32_t array_for_time_type[9] = { 0 , }; - - dbus_error_init (&error); - connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error); - if(connection == NULL) + if(!emstorage_get_mail_by_id(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; - - signal = dbus_message_new_signal("/User/Email/ActiveSync", EMF_ACTIVE_SYNC_NOTI, "email"); - - dbus_message_append_args(signal, DBUS_TYPE_INT32, &subType, DBUS_TYPE_INVALID); - switch ( subType ) { - case ACTIVE_SYNC_NOTI_SEND_MAIL: - EM_DEBUG_LOG("handle:[%d]", data->send_mail.handle); - EM_DEBUG_LOG("account_id:[%d]", data->send_mail.account_id); - EM_DEBUG_LOG("mailbox_name:[%s]", data->send_mail.mailbox_name); - EM_DEBUG_LOG("mail_id:[%d]", data->send_mail.mail_id); - EM_DEBUG_LOG("options.priority:[%d]", data->send_mail.options.priority); - EM_DEBUG_LOG("options.keep_local_copy:[%d]", data->send_mail.options.keep_local_copy); - EM_DEBUG_LOG("options.req_delivery_receipt:[%d]", data->send_mail.options.req_delivery_receipt); - EM_DEBUG_LOG("options.req_read_receipt:[%d]", data->send_mail.options.req_read_receipt); - /* download_limit, block_address, block_subject might not be needed */ - EM_DEBUG_LOG("options.download_limit:[%d]", data->send_mail.options.download_limit); - EM_DEBUG_LOG("options.block_address:[%d]", data->send_mail.options.block_address); - EM_DEBUG_LOG("options.block_subject:[%d]", data->send_mail.options.block_subject); - EM_DEBUG_LOG("options.display_name_from:[%s]", data->send_mail.options.display_name_from); - EM_DEBUG_LOG("options.reply_with_body:[%d]", data->send_mail.options.reply_with_body); - EM_DEBUG_LOG("options.forward_with_files:[%d]", data->send_mail.options.forward_with_files); - EM_DEBUG_LOG("options.add_myname_card:[%d]", data->send_mail.options.add_myname_card); - EM_DEBUG_LOG("options.add_signature:[%d]", data->send_mail.options.add_signature); - EM_DEBUG_LOG("options.signature:[%s]", data->send_mail.options.signature); - - 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); - if ( data->send_mail.mailbox_name == NULL ) - dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID); - else - dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.mailbox_name), DBUS_TYPE_INVALID); - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.mail_id), DBUS_TYPE_INVALID); - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.priority), DBUS_TYPE_INVALID); - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.keep_local_copy), DBUS_TYPE_INVALID); - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.req_delivery_receipt), DBUS_TYPE_INVALID); - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.req_read_receipt), DBUS_TYPE_INVALID); - if ( data->send_mail.options.display_name_from == NULL ) - dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID); - else - dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.options.display_name_from), DBUS_TYPE_INVALID); - - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.reply_with_body), DBUS_TYPE_INVALID); - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.forward_with_files), DBUS_TYPE_INVALID); - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.add_myname_card), DBUS_TYPE_INVALID); - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.add_signature), DBUS_TYPE_INVALID); - if ( data->send_mail.options.signature == NULL ) - dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID); - else - dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.options.signature), 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); - break; - case ACTIVE_SYNC_NOTI_SEND_REPORT: - EM_DEBUG_EXCEPTION("Not support yet : subType[ACTIVE_SYNC_NOTI_SEND_REPORT]", subType); - break; - case ACTIVE_SYNC_NOTI_SYNC_HEADER: - EM_DEBUG_LOG("handle:[%d]", data->sync_header.handle); - EM_DEBUG_LOG("account_id:[%d]", data->sync_header.account_id); - EM_DEBUG_LOG("mailbox_name:[%s]", data->sync_header.mailbox_name); - - 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); - if ( data->sync_header.mailbox_name == NULL ) - dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID); - else - dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->sync_header.mailbox_name), 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); - EM_DEBUG_LOG("account_id:[%d]", data->download_body.account_id); - EM_DEBUG_LOG("mail_id:[%d]", data->download_body.mail_id); - EM_DEBUG_LOG("with_attachment:[%d]", data->download_body.with_attachment); - - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.handle ), DBUS_TYPE_INVALID); - 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); - break; - case ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT: - EM_DEBUG_LOG("handle:[%d]", data->download_attachment.handle); - EM_DEBUG_LOG("account_id:[%d]", data->download_attachment.account_id ); - EM_DEBUG_LOG("mail_id:[%d]", data->download_attachment.mail_id); - EM_DEBUG_LOG("with_attachment:[%s]", data->download_attachment.attachment_order ); - - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.handle ), DBUS_TYPE_INVALID); - 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); - if ( data->download_attachment.attachment_order == NULL ) - dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID); - else - dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->download_attachment.attachment_order), 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); - - 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); - 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_name:[%s]", data->search_mail_on_server.mailbox_name ); - EM_DEBUG_LOG("search_filter_count:[%d]", data->search_mail_on_server.search_filter_count ); - EM_DEBUG_LOG("handle to cancel:[%d]", data->search_mail_on_server.handle); - - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.account_id), DBUS_TYPE_INVALID); - dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->search_mail_on_server.mailbox_name), DBUS_TYPE_INVALID); - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_count), DBUS_TYPE_INVALID); - for(i = 0; i < data->search_mail_on_server.search_filter_count; i++) { - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_list[i].search_filter_type), DBUS_TYPE_INVALID); - switch(data->search_mail_on_server.search_filter_list[i].search_filter_type) { - case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO : - case EMAIL_SEARCH_FILTER_TYPE_UID : - 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_DELETED : - 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 : - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_list[i].search_filter_key_value.integer_type_key_value), DBUS_TYPE_INVALID); - break; - - case EMAIL_SEARCH_FILTER_TYPE_BCC : - case EMAIL_SEARCH_FILTER_TYPE_CC : - case EMAIL_SEARCH_FILTER_TYPE_FROM : - case EMAIL_SEARCH_FILTER_TYPE_KEYWORD : - case EMAIL_SEARCH_FILTER_TYPE_SUBJECT : - case EMAIL_SEARCH_FILTER_TYPE_TO : - case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID : - 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; - - case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE : - case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON : - case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE : { - array_for_time_type[0] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_sec; - array_for_time_type[1] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_min; - array_for_time_type[2] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_hour; - array_for_time_type[3] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_mday; - array_for_time_type[4] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_mon; - array_for_time_type[5] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_year; - array_for_time_type[6] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_wday; - array_for_time_type[7] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_yday; - array_for_time_type[8] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_isdst; - dbus_message_append_args(signal, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, array_for_time_type, 9, DBUS_TYPE_INVALID); - } - break; - default : - EM_DEBUG_EXCEPTION("Invalid filter type [%d]", data->search_mail_on_server.search_filter_list[i].search_filter_type); - break; - } - } - dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.handle), DBUS_TYPE_INVALID); - break; - default: - EM_DEBUG_EXCEPTION("Invalid Notification type of Active Sync : subType[%d]", subType); - return FAILURE; } - - if(!dbus_connection_send (connection, signal, NULL)) { - EM_DEBUG_EXCEPTION("dbus_connection_send is failed"); - return FAILURE; - } else - EM_DEBUG_LOG("dbus_connection_send is successful"); - - dbus_connection_flush(connection); - -FINISH_OFF: - - if(signal) - dbus_message_unref(signal); - - EM_DEBUG_FUNC_END(); - return true; -} -#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ - - -EXPORT_API int email_send_mail( emf_mailbox_t* mailbox, int mail_id, emf_option_t* sending_option, unsigned* handle) -{ - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], sending_option[%p], handle[%p]", mailbox, mail_id, sending_option, handle); - - char* mailbox_stream = NULL; - char* pSendingOption = NULL; - int size = 0; - int err = EMF_ERROR_NONE; - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(mailbox->name, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM); + EM_IF_ACCOUNT_ID_NULL(mail_table_data->account_id, EMAIL_ERROR_INVALID_PARAM); - EM_DEBUG_LOG("Account ID [ %d],mailbox->name[%s], mailbox->account_id[%d] ", mailbox->account_id, mailbox->name, mailbox->account_id); + EM_DEBUG_LOG("mail_table_data->account_id[%d], mail_table_data->mailbox_name[%s]", mail_table_data->account_id, mail_table_data->mailbox_name); -#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__ - emf_account_server_t account_server_type; + email_account_server_t account_server_type; HIPC_API hAPI = NULL; ASNotiData as_noti_data; memset(&as_noti_data, 0x00, sizeof(ASNotiData)); /* check account bind type and branch off */ - if ( email_get_account_server_type_by_account_id(mailbox->account_id, &account_server_type, false, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err); - err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + if ( em_get_account_server_type_by_account_id(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; } - if ( account_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) { + if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) { int as_handle; - if ( email_get_handle_for_activesync(&as_handle, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err); - err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + 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.send_mail.handle = as_handle; - as_noti_data.send_mail.account_id = mailbox->account_id; - as_noti_data.send_mail.mailbox_name = strdup(mailbox->name); + as_noti_data.send_mail.account_id = mail_table_data->account_id; as_noti_data.send_mail.mail_id = mail_id; - memcpy(&as_noti_data.send_mail.options, sending_option, sizeof(emf_option_t)); + memcpy(&as_noti_data.send_mail.options, sending_option, sizeof(email_option_t)); - if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEND_MAIL, &as_noti_data) == false) { - EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed."); - err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + 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."); + err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE; goto FINISH_OFF; } if(handle) *handle = as_handle; - } else { + } + else { hAPI = emipc_create_email_api(_EMAIL_API_SEND_MAIL); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - /* Mailbox */ - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)){ - EM_DEBUG_EXCEPTION("email_send_mail--Add Param mailbox failed"); - EM_SAFE_FREE(mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - /* mail_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))){ EM_DEBUG_EXCEPTION("email_send_mail--Add Param mail_id failed"); - EM_SAFE_FREE(mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* sending options */ pSendingOption = em_convert_option_to_byte_stream(sending_option, &size); if ( NULL == pSendingOption) { - EM_SAFE_FREE(mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pSendingOption, size)){ EM_DEBUG_EXCEPTION("email_send_mail--Add Param Sending_Option failed "); - EM_SAFE_FREE(mailbox_stream); EM_SAFE_FREE(pSendingOption); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("email_send_mail--emipc_execute_proxy_api failed "); - EM_SAFE_FREE(pSendingOption); - EM_SAFE_FREE(mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_CRASH); + EM_SAFE_FREE(pSendingOption); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_CRASH); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - if (err == EMF_ERROR_NONE) { + if (err == EMAIL_ERROR_NONE) { if(handle) emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle); } @@ -445,108 +143,48 @@ FINISH_OFF: emipc_destroy_email_api(hAPI); hAPI = (HIPC_API)NULL; EM_SAFE_FREE(pSendingOption); - EM_SAFE_FREE(mailbox_stream); - EM_SAFE_FREE(as_noti_data.send_mail.mailbox_name); -#else /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SEND_MAIL); - - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - /* Mailbox */ - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE); - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)){ - EM_DEBUG_EXCEPTION("Add Param mailbox failed "); - EM_SAFE_FREE(mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - /* mail_id */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))){ - EM_DEBUG_EXCEPTION("Add Param mail_id failed "); - EM_SAFE_FREE(mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - /* sending options */ - pSendingOption = em_convert_option_to_byte_stream(sending_option, &size); - - if ( NULL == pSendingOption) - EM_SAFE_FREE(mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pSendingOption, size)){ - EM_DEBUG_EXCEPTION("Add Param Sending_Option failed "); - EM_SAFE_FREE(mailbox_stream); - EM_SAFE_FREE(pSendingOption); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - if(!emipc_execute_proxy_api(hAPI, NULL)) { - EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed "); - EM_SAFE_FREE(pSendingOption); - EM_SAFE_FREE(mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - err emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), ); - if (err == EMF_ERROR_NONE) - { - if(handle) - handle = *(unsigned int*)emipc_get_parameter(hAPI, ePARAMETER_OUT, 1); /* Warning removal changes */ - } - - EM_DEBUG_LOG(" >>>>>> ERROR CODE : %d ", err); - - emipc_destroy_email_api(hAPI); - hAPI = NULL; - EM_SAFE_FREE(pSendingOption); - EM_SAFE_FREE(mailbox_stream); -#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ EM_DEBUG_FUNC_END("err [%d]", err); return err; } -EXPORT_API int email_send_saved(int account_id, emf_option_t* sending_option, unsigned* handle) +EXPORT_API int email_send_saved(int account_id, email_option_t* sending_option, unsigned* handle) { EM_DEBUG_FUNC_BEGIN("account_id[%d], sending_option[%p], handle[%p]", account_id, sending_option, handle); char* pOptionStream = NULL; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int size = 0; - EM_IF_NULL_RETURN_VALUE(account_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(sending_option, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(sending_option, EMAIL_ERROR_INVALID_PARAM); + EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_INVALID_PARAM); HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SEND_SAVED); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); /* Account ID */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(account_id), sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* Sending Option */ pOptionStream = em_convert_option_to_byte_stream(sending_option, &size); - EM_PROXY_IF_NULL_RETURN_VALUE(pOptionStream, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(pOptionStream, hAPI, EMAIL_ERROR_NULL_VALUE); if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pOptionStream, size)) { EM_DEBUG_EXCEPTION("Add Param sending option failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); EM_SAFE_FREE(pOptionStream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); @@ -559,94 +197,41 @@ EXPORT_API int email_send_saved(int account_id, emf_option_t* sending_option, un return err; } -EXPORT_API int email_sync_local_activity(int account_id) -{ - EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id); - - int err = EMF_ERROR_NONE; - - if (account_id < 0 || account_id == 0) { - EM_DEBUG_EXCEPTION("account_id[%d]", account_id); - - return EMF_ERROR_INVALID_PARAM; - } - - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SYNC_LOCAL_ACTIVITY); - - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - /* account_id */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); - } - - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - - emipc_destroy_email_api(hAPI); - - hAPI = NULL; - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} - -int EmfMailboxSyncHeader(emf_mailbox_t* mailbox, unsigned* handle, int* err_code) +EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], handle[%p], err_code[%p]", mailbox, handle, err_code); - int err = EMF_ERROR_NONE; - - err = email_sync_header(mailbox,handle); - - if (err_code != NULL) - *err_code = err; - - return (err >= 0); -} - -EXPORT_API int email_sync_header(emf_mailbox_t* mailbox, unsigned* handle) -{ - EM_DEBUG_FUNC_BEGIN("mailbox[%p], handle[%p]", mailbox, handle); - char* mailbox_stream = NULL; - int err = EMF_ERROR_NONE; - int size = 0; + EM_DEBUG_FUNC_BEGIN("input_account_id[%d], input_mailbox_id[%d] handle[%p]", input_account_id, input_mailbox_id, handle); + int err = EMAIL_ERROR_NONE; /* int total_count = 0; */ - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM); + EM_IF_ACCOUNT_ID_NULL(input_account_id, EMAIL_ERROR_INVALID_PARAM); -#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__ - emf_account_server_t account_server_type; + email_account_server_t account_server_type; HIPC_API hAPI = NULL; ASNotiData as_noti_data; memset(&as_noti_data, 0x00, sizeof(ASNotiData)); /* 2010/02/12 ch715.lee : check account bind type and branch off */ - if ( email_get_account_server_type_by_account_id(mailbox->account_id, &account_server_type, true, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err); + if ( em_get_account_server_type_by_account_id(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 == EMF_SERVER_TYPE_ACTIVE_SYNC ) { + if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) { int as_handle; - if ( email_get_handle_for_activesync(&as_handle, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err); + 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.sync_header.handle = as_handle; - as_noti_data.sync_header.account_id = mailbox->account_id; + 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_name = (mailbox && mailbox->name) ? strdup(mailbox->name) : NULL; + as_noti_data.sync_header.mailbox_id = input_mailbox_id; - if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SYNC_HEADER, &as_noti_data) == false) { - EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed."); - err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + 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; } @@ -657,26 +242,30 @@ EXPORT_API int email_sync_header(emf_mailbox_t* mailbox, unsigned* handle) else { hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_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 failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + /* input_mailbox_id */ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) { + EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; } - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + 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, EMF_ERROR_IPC_SOCKET_FAILURE); + 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 != EMF_ERROR_NONE) + if (err != EMAIL_ERROR_NONE) goto FINISH_OFF; if(handle) @@ -686,42 +275,6 @@ EXPORT_API int email_sync_header(emf_mailbox_t* mailbox, unsigned* handle) FINISH_OFF: emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_SAFE_FREE(mailbox_stream); - EM_SAFE_FREE(as_noti_data.sync_header.mailbox_name); -#else /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER); - - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE); - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - EM_SAFE_FREE(mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - - EM_DEBUG_LOG("RETURN VALUE : %d ", err); - - if (err != EMF_ERROR_NONE) - goto FINISH_OFF; - - if(handle) - emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle); -FINISH_OFF: - emipc_destroy_email_api(hAPI); - hAPI = NULL; - EM_SAFE_FREE(mailbox_stream); -#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ EM_DEBUG_FUNC_END("err [%d]", err); return err; @@ -732,50 +285,47 @@ EXPORT_API int email_sync_header_for_all_account(unsigned* handle) { EM_DEBUG_FUNC_BEGIN("handle[%p]", handle); char* mailbox_stream = NULL; - emf_mailbox_t mailbox; - int err = EMF_ERROR_NONE; - int size = 0; + int err = EMAIL_ERROR_NONE; HIPC_API hAPI = NULL; int return_handle; -#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__ ASNotiData as_noti_data; int i, account_count = 0; emstorage_account_tbl_t *account_tbl_array = NULL; int as_err; -#endif + int input_account_id = ALL_ACCOUNT; + int input_mailbox_id = 0; /* all case */ hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - mailbox.account_id = ALL_ACCOUNT; - mailbox.name = NULL; - mailbox.alias = NULL; - mailbox.account_name = NULL; - - mailbox_stream = em_convert_mailbox_to_byte_stream(&mailbox, &size); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_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 failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + /* input_account_id */ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) { + EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; } - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + 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, EMF_ERROR_IPC_SOCKET_FAILURE); + 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 != EMF_ERROR_NONE) + if (err != EMAIL_ERROR_NONE) goto FINISH_OFF; emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &return_handle); -#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__ memset(&as_noti_data, 0x00, sizeof(ASNotiData)); /* Get all accounts for sending notification to active sync engine. */ @@ -786,12 +336,12 @@ EXPORT_API int email_sync_header_for_all_account(unsigned* handle) } for(i = 0; i < account_count; i++) { - if ( account_tbl_array[i].receiving_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) { + if ( account_tbl_array[i].incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) { /* use returned handle value for a active sync handle */ /* int as_handle; */ /* - if ( email_get_handle_for_activesync(&as_handle, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err); + if ( em_get_handle_for_activesync(&as_handle, &err) == false ) { + EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err); goto FINISH_OFF; } */ @@ -800,17 +350,15 @@ EXPORT_API int email_sync_header_for_all_account(unsigned* handle) 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_name = NULL; + as_noti_data.sync_header.mailbox_id = 0; - if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SYNC_HEADER, &as_noti_data) == false) { - EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed."); - err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + 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; } } } -#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ - if(handle) *handle = return_handle; @@ -819,7 +367,7 @@ FINISH_OFF: emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_SAFE_FREE(mailbox_stream); + if ( account_tbl_array ) emstorage_free_account(&account_tbl_array, account_count, NULL); @@ -827,45 +375,53 @@ FINISH_OFF: return err; } -EXPORT_API int email_download_body(emf_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle) +EXPORT_API int email_download_body(int mail_id, int with_attachment, unsigned* handle) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d],with_attachment[%d]", mailbox, mail_id, with_attachment); - char* mailbox_stream = NULL; - int err = EMF_ERROR_NONE; - int size = 0; - - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM); - -#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__ - emf_account_server_t account_server_type; + EM_DEBUG_FUNC_BEGIN("mail_id[%d],with_attachment[%d]", mail_id, with_attachment); + 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; memset(&as_noti_data, 0x00, sizeof(ASNotiData)); + if(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(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; + } + + EM_IF_ACCOUNT_ID_NULL(mail_table_data->account_id, EMAIL_ERROR_INVALID_PARAM); + account_id = mail_table_data->account_id; + /* 2010/02/12 ch715.lee : check account bind type and branch off */ - if ( email_get_account_server_type_by_account_id(mailbox->account_id, &account_server_type, true, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err); + if ( em_get_account_server_type_by_account_id(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 == EMF_SERVER_TYPE_ACTIVE_SYNC ) { + if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) { int as_handle; - if ( email_get_handle_for_activesync(&as_handle, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err); + 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.download_body.handle = as_handle; - as_noti_data.download_body.account_id = mailbox->account_id; + 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; - if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_BODY, &as_noti_data) == false) { - EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed."); - err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + 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."); + err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE; goto FINISH_OFF; } @@ -874,38 +430,32 @@ EXPORT_API int email_download_body(emf_mailbox_t* mailbox, int mail_id, int with } else { hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_BODY); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - /* MailBox Information */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { + /* Account Id */ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - /* Mail Id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* with_attachment */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_attachment, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + 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, EMF_ERROR_IPC_SOCKET_FAILURE); + 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 != EMF_ERROR_NONE) + if (err != EMAIL_ERROR_NONE) goto FINISH_OFF; if(handle) @@ -919,57 +469,10 @@ EXPORT_API int email_download_body(emf_mailbox_t* mailbox, int mail_id, int with FINISH_OFF: emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_SAFE_FREE(mailbox_stream); -#else /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_BODY); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE); - - /* MailBox Information */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - /* Mail Id */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - /* with_attachment */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_attachment, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - EM_SAFE_FREE(mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + if(mail_table_data) { + emstorage_free_mail(&mail_table_data, 1, &err); } - - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - if (err != EMF_ERROR_NONE) - goto FINISH_OFF; - - /* Download handle */ - if(handle) { - emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle); - EM_DEBUG_LOG("RETURN VALUE : %d handle %d", err, *handle); - - } -FINISH_OFF: - - emipc_destroy_email_api(hAPI); - hAPI = NULL; - EM_SAFE_FREE(mailbox_stream); - -#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ EM_DEBUG_FUNC_END("err [%d]", err); return err; @@ -977,49 +480,54 @@ FINISH_OFF: } - - - /* API - Downloads the Email Attachment Information [ INTERNAL ] */ -EXPORT_API int email_download_attachment(emf_mailbox_t* mailbox,int mail_id, const char* nth,unsigned* handle) +EXPORT_API int email_download_attachment(int mail_id, int nth, unsigned* handle) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], nth[%p], handle[%p]", mailbox, mail_id, nth, handle); + EM_DEBUG_FUNC_BEGIN("mail_id[%d], nth[%d], handle[%p]", mail_id, nth, handle); char* mailbox_stream = NULL; - int err = EMF_ERROR_NONE; - int size = 0; - - EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM); - EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM); - /* EM_IF_NULL_RETURN_VALUE(nth, EMF_ERROR_INVALID_PARAM); */ - -#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__ - emf_account_server_t account_server_type; + 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; memset(&as_noti_data, 0x00, sizeof(ASNotiData)); - if ( email_get_account_server_type_by_account_id(mailbox->account_id, &account_server_type, true, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err); + if(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(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; + } + + EM_IF_ACCOUNT_ID_NULL(mail_table_data->account_id, EMAIL_ERROR_INVALID_PARAM); + account_id = mail_table_data->account_id; + + if ( em_get_account_server_type_by_account_id(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 == EMF_SERVER_TYPE_ACTIVE_SYNC ) { + if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) { int as_handle; - if ( email_get_handle_for_activesync(&as_handle, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err); + 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.download_attachment.handle = as_handle; - as_noti_data.download_attachment.account_id = mailbox->account_id; + 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 = strdup(nth); - if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT, &as_noti_data) == false) { - EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed."); - err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + as_noti_data.download_attachment.attachment_order = nth; + 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; goto FINISH_OFF; } @@ -1028,39 +536,35 @@ EXPORT_API int email_download_attachment(emf_mailbox_t* mailbox,int mail_id, con } else { hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_ATTACHMENT); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - /* Mailbox */ - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE); - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + /* Account Id */ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) { + EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* Mail ID */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* nth */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*) nth, sizeof(nth))) { + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(nth), sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + 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, EMF_ERROR_IPC_SOCKET_FAILURE); + 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 != EMF_ERROR_NONE) + if (err != EMAIL_ERROR_NONE) goto FINISH_OFF; if(handle) @@ -1071,102 +575,54 @@ EXPORT_API int email_download_attachment(emf_mailbox_t* mailbox,int mail_id, con FINISH_OFF: emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_SAFE_FREE(mailbox_stream); - EM_SAFE_FREE(as_noti_data.download_attachment.attachment_order); -#else /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_ATTACHMENT); - - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - /* Mailbox */ - mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE); - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) { - EM_DEBUG_EXCEPTION("Add Param mailbox failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - /* Mail ID */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - /* nth */ - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, nth, sizeof(nth))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("EmfDownloadAttachment--emipc_execute_proxy_api failed"); - EM_SAFE_FREE(mailbox_stream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + if(mail_table_data) { + emstorage_free_mail(&mail_table_data, 1, &err); } - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - - EM_DEBUG_LOG(" >>>>> EmfDownloadAttachment RETURN VALUE : %d ", err); - - if (err != EMF_ERROR_NONE) - goto FINISH_OFF; - - if(handle) - emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle); - - /* Prevent defect 36700 */ - /* EM_DEBUG_LOG(" >>>>> Handle_proxy : %d ", *handle); */ -FINISH_OFF: - emipc_destroy_email_api(hAPI); - hAPI = NULL; - EM_SAFE_FREE(mailbox_stream); -#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ - EM_DEBUG_FUNC_END("err [%d]", err); return err; } -EXPORT_API int email_cancel_job(int account_id, int handle) +EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_cancelation_type input_cancel_type) { - EM_DEBUG_FUNC_BEGIN("account_id [%d], handle [%d]", account_id, handle); - int err = EMF_ERROR_NONE; - - if(account_id < 0) - return EMF_ERROR_INVALID_PARAM; -#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__ - emf_account_server_t account_server_type; + EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_handle [%d], input_cancel_type [%d]", input_account_id, input_handle, input_cancel_type); + int err = EMAIL_ERROR_NONE; + email_account_server_t account_server_type; HIPC_API hAPI = NULL; ASNotiData as_noti_data; emstorage_account_tbl_t *account_list = NULL; int i, account_count = 0; - if ( account_id == ALL_ACCOUNT ) { /* this means that job is executed with all account */ + if(input_account_id < 0) + return EMAIL_ERROR_INVALID_PARAM; + + 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)) { - EM_DEBUG_EXCEPTION("email_get_account_list-- Failed [ %d ] ", err); - + EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err); goto FINISH_OFF; } for(i = 0; i < account_count; i++) { - if ( email_get_account_server_type_by_account_id(account_list[i].account_id, &account_server_type, true, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err); + if ( em_get_account_server_type_by_account_id(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 == EMF_SERVER_TYPE_ACTIVE_SYNC ) { + 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 = handle; + 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; + - if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) { - EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed."); - err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + 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."); + err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE; goto FINISH_OFF; } } @@ -1175,22 +631,22 @@ EXPORT_API int email_cancel_job(int account_id, int handle) /* request canceling to stub */ hAPI = emipc_create_email_api(_EMAIL_API_CANCEL_JOB); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) { /* account_id == 0 */ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_account_id, sizeof(int))) { /* input_account_id == 0 */ EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &handle, sizeof(int))) { + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_handle, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); @@ -1198,40 +654,40 @@ EXPORT_API int email_cancel_job(int account_id, int handle) hAPI = NULL; } else { - if ( email_get_account_server_type_by_account_id(account_id, &account_server_type, true, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err); + if ( em_get_account_server_type_by_account_id(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 == EMF_SERVER_TYPE_ACTIVE_SYNC ) { + if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) { memset(&as_noti_data, 0x00, sizeof(ASNotiData)); - as_noti_data.cancel_job.account_id = account_id; - as_noti_data.cancel_job.handle = handle; + as_noti_data.cancel_job.account_id = input_account_id; + as_noti_data.cancel_job.handle = input_handle; - if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) { - EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed."); - err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + 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."); + err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE; goto FINISH_OFF; } } else { hAPI = emipc_create_email_api(_EMAIL_API_CANCEL_JOB); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) { + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_account_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &handle, sizeof(int))) { + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_handle, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); emipc_destroy_email_api(hAPI); @@ -1245,72 +701,43 @@ FINISH_OFF: if ( account_list ) emstorage_free_account(&account_list, account_count, NULL); -#else /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ - HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_CANCEL_JOB); - - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &handle, sizeof(int))) { - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); - } - - /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); - } - - emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - - EM_DEBUG_LOG(" >>>>> EmfCancelJob RETURN VALUE : %d ", err); - - emipc_destroy_email_api(hAPI); - hAPI = NULL; -#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ - EM_DEBUG_FUNC_END("err [%d]", err); return err; } -EXPORT_API int email_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t * status) +EXPORT_API int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t * status) { EM_DEBUG_FUNC_BEGIN("action[%d], account_id[%d], mail_id[%d], status[%p]", action, account_id, mail_id, status); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_NULL_VALUE); + EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_NULL_VALUE); HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_PENDING_JOB); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &action, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter action failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &mail_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); @@ -1333,18 +760,18 @@ EXPORT_API int email_get_pending_job(emf_action_t action, int account_id, int ma EXPORT_API int email_get_network_status(int* on_sending, int* on_receiving) { EM_DEBUG_FUNC_BEGIN("on_sending[%p], on_receiving[%p]", on_sending, on_receiving); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_NETWORK_GET_STATUS); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); /* Execute API */ - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); emipc_destroy_email_api(hAPI); hAPI = NULL; - err = EMF_ERROR_IPC_SOCKET_FAILURE ; + err = EMAIL_ERROR_IPC_SOCKET_FAILURE ; EM_DEBUG_FUNC_END("err [%d]", err); return err; } @@ -1359,15 +786,15 @@ EXPORT_API int email_get_network_status(int* on_sending, int* on_receiving) return err; } -EXPORT_API int email_get_imap_mailbox_list(int account_id, const char* mailbox, unsigned* handle) +EXPORT_API int email_sync_imap_mailbox_list(int account_id, unsigned* handle) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if(account_id <= 0 || !mailbox) { + if(account_id <= 0) { EM_DEBUG_LOG("invalid parameters"); - return EMF_ERROR_INVALID_PARAM; + return EMAIL_ERROR_INVALID_PARAM; } HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_IMAP_MAILBOX_LIST); @@ -1375,12 +802,12 @@ EXPORT_API int email_get_imap_mailbox_list(int account_id, const char* mailbox, /* account_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) { EM_DEBUG_LOG("emipc_add_parameter failed "); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } if(!emipc_execute_proxy_api(hAPI)) { EM_DEBUG_LOG("ipcProxy_ExecuteAsyncAPI failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); @@ -1394,53 +821,49 @@ EXPORT_API int email_get_imap_mailbox_list(int account_id, const char* mailbox, return err; } -EXPORT_API int email_search_mail_on_server(int input_account_id, const char *input_mailbox_name, email_search_filter_t *input_search_filter_list, int input_search_filter_count, unsigned *output_handle) +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, unsigned *output_handle) { - EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_mailbox_name [%p], input_search_filter_list [%p], input_search_filter_count [%d], output_handle [%p]", input_account_id, input_mailbox_name, input_search_filter_list, input_search_filter_count, output_handle); + EM_DEBUG_FUNC_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 = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int return_value = 0; int stream_size_for_search_filter_list = 0; char *stream_for_search_filter_list = NULL; HIPC_API hAPI = NULL; - - EM_IF_NULL_RETURN_VALUE(input_account_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(input_mailbox_name, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(input_search_filter_list, EMF_ERROR_INVALID_PARAM); - -#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__ - emf_account_server_t account_server_type = EMF_SERVER_TYPE_NONE; + 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); + memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */ - if ( email_get_account_server_type_by_account_id(input_account_id, &account_server_type, true, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err); + if ( em_get_account_server_type_by_account_id(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 == EMF_SERVER_TYPE_ACTIVE_SYNC ) { + if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) { int as_handle = 0; - if ( email_get_handle_for_activesync(&as_handle, &err) == false ) { - EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err); + 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_name = EM_SAFE_STRDUP(input_mailbox_name); + 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; - return_value = email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEARCH_ON_SERVER, &as_noti_data); - - EM_SAFE_FREE(as_noti_data.search_mail_on_server.mailbox_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("email_send_notification_to_active_sync_engine failed."); - err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed."); + err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE; goto FINISH_OFF; } @@ -1448,42 +871,41 @@ EXPORT_API int email_search_mail_on_server(int input_account_id, const char *inp *output_handle = as_handle; } else -#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */ { hAPI = emipc_create_email_api(_EMAIL_API_SEARCH_MAIL_ON_SERVER); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + 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 = EMF_ERROR_IPC_PROTOCOL_FAILURE; + err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE; goto FINISH_OFF; } - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)input_mailbox_name, strlen(input_mailbox_name))){ + if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_mailbox_id, sizeof(int))){ EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - err = EMF_ERROR_IPC_PROTOCOL_FAILURE; + 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, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(stream_for_search_filter_list, hAPI, EMAIL_ERROR_NULL_VALUE); if(!emipc_add_parameter(hAPI, ePARAMETER_IN, stream_for_search_filter_list, stream_size_for_search_filter_list)) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - err = EMF_ERROR_IPC_PROTOCOL_FAILURE; + err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE; goto FINISH_OFF; } - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + 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 != EMF_ERROR_NONE) { + if (err != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("_EMAIL_API_SEARCH_MAIL_ON_SERVER failed [%d]", err); goto FINISH_OFF; } @@ -1501,3 +923,87 @@ FINISH_OFF: EM_DEBUG_FUNC_END("err [%d]", err); return err; } + +EXPORT_API int email_clear_result_of_search_mail_on_server(int input_account_id) +{ + EM_DEBUG_FUNC_BEGIN("input_account_id [%d]", input_account_id); + + int err = EMAIL_ERROR_NONE; + int return_value = 0; + HIPC_API hAPI = NULL; + email_account_server_t account_server_type = EMAIL_SERVER_TYPE_NONE; + ASNotiData as_noti_data; + emstorage_mailbox_tbl_t* mailbox = NULL; + int mailbox_id = 0; + + EM_IF_NULL_RETURN_VALUE(input_account_id, EMAIL_ERROR_INVALID_PARAM); + + memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */ + + if ( em_get_account_server_type_by_account_id(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; + + 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 { + if (!emstorage_get_mailbox_by_mailbox_type(input_account_id, EMAIL_MAILBOX_TYPE_SEARCH_RESULT, &mailbox, true, &err) || !mailbox) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err); + goto FINISH_OFF; + } + mailbox_id = mailbox->mailbox_id; + + 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*)&mailbox_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; + } + + if(mailbox) + emstorage_free_mailbox(&mailbox, 1, &err); + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} diff --git a/email-api/email-api-rule.c b/email-api/email-api-rule.c index 73c6389..2e16050 100755 --- a/email-api/email-api-rule.c +++ b/email-api/email-api-rule.c @@ -37,21 +37,21 @@ #include "email-utilities.h" #include "email-ipc.h" -EXPORT_API int email_get_rule(int filter_id, emf_rule_t** filtering_set) +EXPORT_API int email_get_rule(int filter_id, email_rule_t** filtering_set) { EM_DEBUG_FUNC_BEGIN("filter_id[%d], filtering_set[%p]", filter_id, filtering_set); int err = 0; - EM_IF_NULL_RETURN_VALUE(filtering_set, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(filter_id, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(filtering_set, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(filter_id, EMAIL_ERROR_INVALID_PARAM); if (!emstorage_get_rule_by_id(0, 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 = EMF_ERROR_NONE; + err = EMAIL_ERROR_NONE; FINISH_OFF: EM_DEBUG_FUNC_END("error value [%d]", err); @@ -59,15 +59,15 @@ FINISH_OFF: } -EXPORT_API int email_get_rule_list(emf_rule_t** filtering_set, int* count) +EXPORT_API int email_get_rule_list(email_rule_t** filtering_set, int* count) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int is_completed = 0; - EM_IF_NULL_RETURN_VALUE(filtering_set, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(filtering_set, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM); *count = 1000; @@ -77,7 +77,7 @@ EXPORT_API int email_get_rule_list(emf_rule_t** filtering_set, int* count) goto FINISH_OFF; } else - err = EMF_ERROR_NONE; + err = EMAIL_ERROR_NONE; FINISH_OFF: @@ -86,38 +86,35 @@ FINISH_OFF: } -EXPORT_API int email_add_rule(emf_rule_t* filtering_set) +EXPORT_API int email_add_rule(email_rule_t* filtering_set) { EM_DEBUG_FUNC_BEGIN("filtering_set[%p]", filtering_set); int size = 0; - int err = EMF_ERROR_NONE; - char* pRuleStream = NULL; + int err = EMAIL_ERROR_NONE; + char* stream = NULL; - EM_IF_NULL_RETURN_VALUE(filtering_set, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(filtering_set, EMAIL_ERROR_INVALID_PARAM); + /* make rule info */ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_RULE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - pRuleStream = em_convert_rule_to_byte_stream(filtering_set, &size); - - EM_PROXY_IF_NULL_RETURN_VALUE(pRuleStream, hAPI, EMF_ERROR_NULL_VALUE); - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pRuleStream, size)) { + stream = em_convert_rule_to_byte_stream(filtering_set, &size); + EM_PROXY_IF_NULL_RETURN_VALUE(stream, hAPI, EMAIL_ERROR_NULL_VALUE); + if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, stream, size)) { EM_DEBUG_EXCEPTION("Add Param Failed"); - EM_SAFE_FREE(pRuleStream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + /* pass rule info */ + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api Failed"); - EM_SAFE_FREE(pRuleStream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - EM_SAFE_FREE(pRuleStream); + emipc_destroy_email_api(hAPI); hAPI = NULL; EM_DEBUG_FUNC_END("error value [%d]", err); @@ -126,49 +123,44 @@ EXPORT_API int email_add_rule(emf_rule_t* filtering_set) -EXPORT_API int email_update_rule(int filter_id, emf_rule_t* new_set) +EXPORT_API int email_update_rule(int filter_id, email_rule_t* new_set) { EM_DEBUG_FUNC_BEGIN("filter_id[%d], new_set[%p]", filter_id, new_set); int size = 0; - char* pFilterStream = NULL; - int err = EMF_ERROR_NONE; + char* stream = NULL; + int err = EMAIL_ERROR_NONE; - EM_IF_NULL_RETURN_VALUE(filter_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(new_set, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(filter_id, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(new_set, EMAIL_ERROR_INVALID_PARAM); HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_RULE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); - - /* filter_id */ + /* make filter info */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&filter_id, sizeof(int))) { EM_DEBUG_EXCEPTION("Add Param filter_id Failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - /* new_set */ - pFilterStream = em_convert_rule_to_byte_stream(new_set, &size); - - if(NULL == pFilterStream) { - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + stream = em_convert_rule_to_byte_stream(new_set, &size); + if(NULL == stream) { + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - - if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pFilterStream, size)){ + if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, stream, size)){ EM_DEBUG_EXCEPTION("Add Param new_set Failed"); - EM_SAFE_FREE(pFilterStream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + /* request update rule with filter info */ + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emipc_execute_proxy_api Failed"); - EM_SAFE_FREE(pFilterStream); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } + /* get result */ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - EM_SAFE_FREE(pFilterStream); emipc_destroy_email_api(hAPI); hAPI = NULL; @@ -183,23 +175,23 @@ EXPORT_API int email_delete_rule(int filter_id) { EM_DEBUG_FUNC_BEGIN("filter_id[%d]", filter_id); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - EM_IF_NULL_RETURN_VALUE(filter_id, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(filter_id, EMAIL_ERROR_INVALID_PARAM); HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_RULE); - EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE); + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); /* filter_id */ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&filter_id, sizeof(int))) { EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); } - if(emipc_execute_proxy_api(hAPI) != EMF_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, EMF_ERROR_IPC_SOCKET_FAILURE); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); } emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); @@ -210,20 +202,19 @@ EXPORT_API int email_delete_rule(int filter_id) return err; } -EXPORT_API int email_free_rule (emf_rule_t** filtering_set, int count) +EXPORT_API int email_free_rule (email_rule_t** filtering_set, int count) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE, i; + int err = EMAIL_ERROR_NONE, i; - EM_IF_NULL_RETURN_VALUE(filtering_set, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(filtering_set, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM); if (count > 0) { - emf_rule_t* p = *filtering_set; + email_rule_t* p = *filtering_set; for (i = 0; i < count; i++) { EM_SAFE_FREE(p[i].value); - EM_SAFE_FREE(p[i].mailbox); } EM_SAFE_FREE(p); *filtering_set = NULL; diff --git a/email-api/email-api-smime.c b/email-api/email-api-smime.c new file mode 100755 index 0000000..cb3aba8 --- /dev/null +++ b/email-api/email-api-smime.c @@ -0,0 +1,453 @@ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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 the data structures and interfaces needed for application, + * to interact with Email Engine. + * @file email-api-smime.c + * @brief This file contains the data structures and interfaces of SMIME related Functionality provided by + * Email Engine . + */ + +#include "email-api.h" +#include "string.h" +#include "email-convert.h" +#include "email-api-account.h" +#include "email-storage.h" +#include "email-utilities.h" +#include "email-core-mail.h" +#include "email-core-account.h" +#include "email-core-cert.h" +#include "email-ipc.h" + +EXPORT_API int email_add_certificate(char *certificate_path, char *email_address) +{ + EM_DEBUG_FUNC_BEGIN("Certificate path : [%s]", certificate_path); + int result_from_ipc = 0; + int err = EMAIL_ERROR_NONE; + + if (!certificate_path) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_CERTIFICATE); + if (hAPI == NULL) { + EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); + err = EMAIL_ERROR_NULL_VALUE; + goto FINISH_OFF; + } + + if (!emipc_add_parameter(hAPI, ePARAMETER_IN, certificate_path, strlen(certificate_path)+1)) { + EM_DEBUG_EXCEPTION("emipc_add_parameter certificate_path[%s] failed", certificate_path); + err = EMAIL_ERROR_NULL_VALUE; + goto FINISH_OFF; + } + + if (!emipc_add_parameter(hAPI, ePARAMETER_IN, email_address, strlen(email_address)+1)) { + EM_DEBUG_EXCEPTION("emipc_add_parameter certificate_path[%s] failed", email_address); + err = EMAIL_ERROR_NULL_VALUE; + goto FINISH_OFF; + } + + if (emipc_execute_proxy_api(hAPI) < 0) { + EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; + goto FINISH_OFF; + } + + result_from_ipc = emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); + if (result_from_ipc != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emipc_get_parameter failed"); + err = EMAIL_ERROR_IPC_CRASH; + goto FINISH_OFF; + } + +FINISH_OFF: + + if (hAPI) + emipc_destroy_email_api(hAPI); + + EM_DEBUG_FUNC_END("ERROR CODE [%d]", err); + return err; +} + +EXPORT_API int email_delete_certificate(char *email_address) +{ + EM_DEBUG_FUNC_BEGIN("Eamil_address : [%s]", email_address); + int result_from_ipc = 0; + int err = EMAIL_ERROR_NONE; + + if (!email_address) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_CERTIFICATE); + if (hAPI == NULL) { + EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); + err = EMAIL_ERROR_NULL_VALUE; + goto FINISH_OFF; + } + + if (!emipc_add_parameter(hAPI, ePARAMETER_IN, email_address, strlen(email_address)+1)) { + EM_DEBUG_EXCEPTION("emipc_add_parameter email_address[%s] failed", email_address); + err = EMAIL_ERROR_NULL_VALUE; + goto FINISH_OFF; + } + + if (emipc_execute_proxy_api(hAPI) < 0) { + EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; + goto FINISH_OFF; + } + + result_from_ipc = emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); + if (result_from_ipc != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emipc_get_parameter failed"); + err = EMAIL_ERROR_IPC_CRASH; + goto FINISH_OFF; + } + +FINISH_OFF: + + if (hAPI) + emipc_destroy_email_api(hAPI); + + EM_DEBUG_FUNC_END("ERROR CODE [%d]", err); + return err; +} + +EXPORT_API int email_get_certificate(char *email_address, email_certificate_t **certificate) +{ + EM_DEBUG_FUNC_BEGIN(); + int err = EMAIL_ERROR_NONE; + char temp_email_address[130] = {0, }; + 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); + 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)) { + EM_DEBUG_EXCEPTION("emstorage_get_certificate_by_index failed - %d", err); + return err; + } + + if (!em_convert_certificate_tbl_to_certificate(cert, certificate, &err)) { + EM_DEBUG_EXCEPTION("em_convert_certificate_tbl_to_certificate failed"); + return err; + } + + EM_DEBUG_FUNC_END("ERROR CODE [%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) +{ + EM_DEBUG_FUNC_BEGIN("mail_id : [%s]", mail_id); + int err = EMAIL_ERROR_NONE; + email_mail_data_t *p_output_mail_data = NULL; + emstorage_account_tbl_t *p_account = NULL; + + EM_IF_NULL_RETURN_VALUE(mail_id, EMAIL_ERROR_INVALID_PARAM); + + if (!output_mail_data || !output_attachment_data || !output_attachment_count) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + if ((err = emcore_get_mail_data(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, false, &err)) { + EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed"); + goto FINISH_OFF; + } +#if 0 + emcore_smime_set_decrypt_message(p_output_mail_data->file_path_mime_entity, p_account->certificate_path, decrypt_message, &err); + + /* Change decrpyt_message to mail_data_t */ + +#endif +FINISH_OFF: + + EM_DEBUG_FUNC_END("ERROR CODE [%d]", err); + return err; +} + +EXPORT_API int email_verify_signature(char *certificate_path, int mail_id, int *verify) +{ + EM_DEBUG_FUNC_BEGIN("Certificate path : [%s]", certificate_path); + int result_from_ipc = 0; + int err = EMAIL_ERROR_NONE; + int p_verify = 0; + + if (!certificate_path) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + return EMAIL_ERROR_INVALID_PARAM; + } + + HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_VERIFY_SIGNATURE); + if (hAPI == NULL) { + EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); + err = EMAIL_ERROR_NULL_VALUE; + goto FINISH_OFF; + } + + if (!emipc_add_parameter(hAPI, ePARAMETER_IN, certificate_path, strlen(certificate_path)+1)) { + EM_DEBUG_EXCEPTION("emipc_add_parameter certificate_path[%s] failed", certificate_path); + err = EMAIL_ERROR_NULL_VALUE; + goto FINISH_OFF; + } + + if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &mail_id, sizeof(int))) { + EM_DEBUG_EXCEPTION("emipc_add_parameter pass_phrase[%d] failed", mail_id); + err = EMAIL_ERROR_NULL_VALUE; + goto FINISH_OFF; + } + + if (emipc_execute_proxy_api(hAPI) < 0) { + EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; + goto FINISH_OFF; + } + + result_from_ipc = emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &p_verify); + if (result_from_ipc != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emipc_get_parameter failed"); + err = EMAIL_ERROR_IPC_CRASH; + goto FINISH_OFF; + } + +FINISH_OFF: + + if (hAPI) + emipc_destroy_email_api(hAPI); + + if (verify != NULL) + *verify = p_verify; + + EM_DEBUG_FUNC_END("ERROR CODE [%d]", err); + return err; +} + +EXPORT_API int email_verify_certificate(char *certificate_path, int *verify) +{ + EM_DEBUG_FUNC_BEGIN("certificate : [%s]", certificate_path); + int err = EMAIL_ERROR_NONE; + int result_from_ipc = 0; + int p_verify = 0; + + if (!certificate_path) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + return EMAIL_ERROR_INVALID_PARAM; + } + + HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_VERIFY_CERTIFICATE); + if (hAPI == NULL) { + EM_DEBUG_EXCEPTION("emipc_create_email_api failed"); + err = EMAIL_ERROR_NULL_VALUE; + goto FINISH_OFF; + } + + if (!emipc_add_parameter(hAPI, ePARAMETER_IN, certificate_path, strlen(certificate_path)+1)) { + EM_DEBUG_EXCEPTION("emipc_add_paramter failed : [%s]", certificate_path); + err = EMAIL_ERROR_NULL_VALUE; + goto FINISH_OFF; + } + + if (emipc_execute_proxy_api(hAPI) < 0) { + EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed"); + err = EMAIL_ERROR_IPC_SOCKET_FAILURE; + goto FINISH_OFF; + } + + result_from_ipc = emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &p_verify); + if (result_from_ipc != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emipc_get_parameter failed"); + err = EMAIL_ERROR_IPC_CRASH; + goto FINISH_OFF; + } + +FINISH_OFF: + + if (hAPI) + emipc_destroy_email_api(hAPI); + + if (verify != NULL) + *verify = p_verify; + + EM_DEBUG_FUNC_END("ERROR CODE [%d]", err); + return err; +} + +/* +EXPORT_API int email_check_ocsp_status(char *email_address, char *response_url, unsigned *handle) +{ + EM_DEBUG_FUNC_BEGIN("email_address : [%s], response_url : [%s], handle : [%p]", email_address, response_url, handle); + + EM_IF_NULL_RETURN_VALUE(email_address, EMAIL_ERROR_INVALID_PARAM); + + int err = EMAIL_ERROR_NONE; + HIPC_API hAPI = NULL; + + hAPI = emipc_create_email_api(_EMAIL_API_CHECK_OCSP_STATUS); + + EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE); + + if (!emipc_add_parameter(hAPI, ePARAMETER_IN, email_address, strlen(email_address)+1)) { + EM_DEBUG_EXCEPTION("email_check_ocsp_status--ADD Param email_address failed"); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); + } + + if (!emipc_add_parameter(hAPI, ePARAMETER_IN, response_url, strlen(response_url)+1)) { + EM_DEBUG_EXCEPTION("email_check_ocsp_status--ADD Param response_url 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("email_check_oscp_status--emipc_execute_proxy_api failed"); + EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE); + } + + emipc_get_paramter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); + if (err == EMAIL_ERROR_NONE) { + if (handle) + emipc_get_paramter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle); + } +} +*/ +EXPORT_API int email_validate_certificate(int account_id, char *email_address, unsigned *handle) +{ + EM_DEBUG_FUNC_BEGIN("account_id : [%d], email_address : [%s], handle : [%p]", account_id, email_address, handle); + + EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(email_address, EMAIL_ERROR_INVALID_PARAM); + + int err = EMAIL_ERROR_NONE; + int as_handle = 0; + email_account_server_t account_server_type; + ASNotiData as_noti_data; + + memset(&as_noti_data, 0x00, sizeof(ASNotiData)); + + if (em_get_account_server_type_by_account_id(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) { + EM_DEBUG_EXCEPTION("This api is not supported except of active sync"); + err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + goto FINISH_OFF; + } + + 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; + } + + 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); + + 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"); + err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + goto FINISH_OFF; + } + + if (handle) + *handle = as_handle; + +FINISH_OFF: + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +EXPORT_API int email_get_resolve_recipients(int account_id, char *email_address, unsigned *handle) +{ + EM_DEBUG_FUNC_BEGIN("account_id : [%d], email_address : [%s], handle : [%p]", account_id, email_address, handle); + + EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(email_address, EMAIL_ERROR_INVALID_PARAM); + + int err = EMAIL_ERROR_NONE; + int as_handle = 0; + email_account_server_t account_server_type; + ASNotiData as_noti_data; + + memset(&as_noti_data, 0x00, sizeof(ASNotiData)); + + if (em_get_account_server_type_by_account_id(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) { + EM_DEBUG_EXCEPTION("This api is not supported except of active sync"); + err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + goto FINISH_OFF; + } + + 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; + } + + 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); + + 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"); + err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE; + goto FINISH_OFF; + } + + if (handle) + *handle = as_handle; + +FINISH_OFF: + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +EXPORT_API int email_free_certificate(email_certificate_t **certificate, int count) +{ + EM_DEBUG_FUNC_BEGIN("certificate[%p], count[%d]", certificate, count); + int err = EMAIL_ERROR_NONE; + emcore_free_certificate(certificate, count, &err); + EM_DEBUG_FUNC_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 49c68e6..f201782 100755 --- a/email-api/include/email-api-account.h +++ b/email-api/include/email-api-account.h @@ -1,415 +1,411 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - -#ifndef __EMAIL_API_ACCOUNT_H__ -#define __EMAIL_API_ACCOUNT_H__ - -#include "email-types.h" - -/** -* @defgroup EMAIL_SERVICE Email Service -* @{ -*/ - - -/** -* @ingroup EMAIL_SERVICE -* @defgroup EMAIL_API_ACCOUNT Email Account API -* @{ -*/ - -/** - * - * This file contains the data structures and interfaces needed for application, - * to interact with email-service. - * @file email-api-account.h - * @author Kyuho Jo - * @author Sunghyun Kwon - * @version 0.1 - * @brief This file contains the data structures and interfaces of Accounts provided by - * email-service . - * -* @{ - -* @code -* #include "emf_mapi_account.h" -* bool -* other_app_invoke_uniform_api_sample(int* error_code) -* { -* emf_account_t *account = NULL; -* emf_account_t *new_account = NULL; -* -* account = malloc(sizeof(emf_account_t)); -* memset(account, 0x00, sizeof(emf_account_t)); -* -* account->account_bind_type = 1; -* account->retrieval_mode = 1; -* account->use_security = 1; -* account->sending_server_type = EMF_SERVER_TYPE_SMTP; -* account->sending_port_num = EMF_SMTP_PORT; -* account->sending_auth = 1; -* account->flag1 = 2; -* account->account_bind_type = 1; -* account->account_name = strdup("gmail"); -* account->display_name = strdup("Tom"); -* account->email_addr = strdup("tom@gmail.com"); -* account->reply_to_addr = strdup("tom@gmail.com"); -* account->return_addr = strdup("tom@gmail.com"); -* account->receiving_server_type = EMF_SERVER_TYPE_POP3; -* account->receiving_server_addr = strdup("pop3.gmail.com"); -* account->port_num = 995; -* account->use_security = 1; -* account->retrieval_mode = EMF_IMAP4_RETRIEVAL_MODE_ALL; -* account->user_name = strdup("tom"); -* account->password = strdup("password"); -* account->sending_server_type = EMF_SERVER_TYPE_SMTP; -* account->sending_server_addr = strdup("smtp.gmail.com"); -* account->sending_port_num = 587; -* account->sending_security = 0x02; -* account->sending_auth = 1; -* account->sending_user = strdup("tom@gmail.com"); -* account->sending_password = strdup("password"); -* account->pop_before_smtp = 0; -* account->apop = 0; -* account->flag1 = 2; -* account->flag2 = 1; -* account->preset_account = 1; -* account->logo_icon_path = strdup("Logo Icon Path"); -* account->target_storage = 0; -* 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 = strdup("Display name from"); -* 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("Signature"); -* account->check_interval = 0; -* // Add account -* if(EMF_ERROR_NONE != email_add_account(account)) -* //failure -* //else -* { -* //success -* if(account_id) -* *account_id = account->account_id; -* } -* if(EMF_ERROR_NONE != email_validate_account(account_id,&account_handle)) -* //failure -* else -* //success -* if(EMF_ERROR_NONE != email_delete_account(account_id)) -* //failure -* else -* //success -* new_account = malloc(sizeof(emf_account_t)); -* memset(new_account, 0x00, sizeof(emf_account_t)); -* new_account->flag1 = 1; -* new_account->account_name = strdup("samsung001"); -* new_account->display_name = strdup("Tom001"); -* new_account->options.keep_local_copy = 1; -* new_account->check_interval = 55; -* // Update account -* if(EMF_ERROR_NONE != email_update_account(acount_id,new_account)) -* //failure -* else -* //success -* // Get account -* if(EMF_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&account)) -* //failure -* else -* //success -* // Get list of accounts -* if(EMF_ERROR_NONE != email_get_account_list(&account_list,&count)) -* //failure -* else -* //success -* // free account -* email_free_account(&account, 1); -* } - * - * @endcode - * @} - */ - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @open - * @fn email_add_account(emf_account_t* account) - * @brief Create a new email account.This function is invoked when user wants to add new email account - * - * @param[in] account Specifies the structure pointer of account. - * @exception none - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @see emf_account_t - * @remarks N/A - */ -EXPORT_API int email_add_account(emf_account_t* account); - -/** - * @open - * @fn email_delete_account(int account_id) - * @brief Delete a email account.This function is invoked when user wants to delete an existing email account - * - * @param[in] account_id Specifies the account ID. - * @exception #EMF_ERROR_INVALID_PARAM -Invalid argument - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @see - * @remarks N/A - */ -EXPORT_API int email_delete_account(int account_id); - -/** - * @open - * @fn email_update_account(int account_id, emf_account_t* new_account) - * @brief Change the information of a email account.This function is getting invoked when user wants to change some information of existing email account. - * - * @param[in] account_id Specifies the orignal account ID. - * @param[in] new_account Specifies the information of new account. - * @param[in] with_validation If this is 1, email-service will validate the account before updating. If this is 0, email-service will update the account without validation. - * @exception #EMF_ERROR_INVALID_PARAM -Invalid argument - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @see emf_account_t - * @remarks N/A - */ -EXPORT_API int email_update_account(int account_id, emf_account_t* new_account); - -/** - * @open - * @fn email_update_account_with_validation(int account_id, emf_account_t* new_account) - * @brief Change the information of a email account.This function is getting invoked when user wants to change some information of existing email account. - * - * @param[in] account_id Specifies the orignal account ID. - * @param[in] new_account Specifies the information of new account. - * @param[in] with_validation If this is 1, email-service will validate the account before updating. If this is 0, email-service will update the account without validation. - * @exception #EMF_ERROR_INVALID_PARAM -Invalid argument - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @see emf_account_t - * @remarks N/A - */ -EXPORT_API int email_update_account_with_validation(int account_id, emf_account_t* new_account); - -/** - * @open - * @fn email_get_account(int account_id, int pulloption, emf_account_t** account) - * @brief Get an email account by ID. This function is getting invoked when user wants to get the account informantion based on account id and option (GET_FULL_DATA/WITHOUT_OPTION/ONLY_OPTION).
- * Memory for account information will be allocated to 3rd param(account). The allocated memory should be freed by email_free_account(). - * - * @param[in] account_id Specifies the account ID.This function is invoked when user - * @param[in] pulloption Option to specify to get full details or partial, see definition of EMF_ACC_GET_OPT_XXX - * @param[out] account The returned account is saved here. - * @exception #EMF_ERR_INVALID_PARAM -Invalid argument - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @see emf_account_t - * @remarks N/A - */ - -EXPORT_API int email_get_account(int account_id, int pulloption, emf_account_t** account); - -/** - * @open - * @fn email_get_account_list(emf_account_t** account_list, int* count); - * @brief Get Account List.This function is getting invoked when user wants to get all account information based on the count of accounts provided by user.
- * Memory for account information will be allocated to 3rd param(account). The allocated memory should be freed by email_free_account(). - * - * @param[in] account_list Specifies the structure pointer of account. - * @param[out] count Specifies the count of accounts. - * @exception #EMF_ERR_INVALID_PARAM -Invalid argument - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @see emf_account_t - * @remarks N/A - */ -EXPORT_API int email_get_account_list(emf_account_t** account_list, int* count); - - /** - * @open - * @fn email_free_account(emf_account_t** account_list, int count); - * @brief Free allocated memory.This function is getting invoked when user wants to delete all account information. - * - * @param[in] account_list Specifies the structure pointer of account. - * @param[out] count Specifies the count of accounts. - * @exception #EMF_ERR_INVALID_PARAM -Invalid argument - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @see emf_account_t - * @remarks N/A - */ -EXPORT_API int email_free_account(emf_account_t** account_list, int count); - - -/** - * @open - * @fn email_validate_account(int account_id, unsigned* handle) - * @brief Validate account.This function is getting invoked after adding one account to validate it.If account is not validated then user should retry once again to add the account . - * - * @param[in] account_id Specifies the account Id to validate. - * @param[out] handle Specifies the sending handle. - * @remarks N/A - * @exception #EMF_ERR_INVALID_PARAM -Invalid argument - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @see none - * @remarks N/A - */ -EXPORT_API int email_validate_account(int account_id, unsigned* handle); - -/** - * @open - * @fn email_add_account_with_validation(emf_account_t* account, unsigned* handle) - * @brief Add an account when the account is validated. This function is getting invoked when user want to validate an account. If account is not validated then user should retry once again to add the account.
- * Validation is executed without saving an account to DB - * - * @param[in] account Specifies the structure pointer of account. - * @param[out] handle Specifies the sending handle. - * @remarks N/A - * @return This function returns true on success or false on failure. - */ -EXPORT_API int email_add_account_with_validation(emf_account_t* account, unsigned* handle); - - -/** - * @open - * @fn email_backup_accounts_into_secure_storage(const char *file_name) - * @brief Back up information of all accounts into secure storage. - * This function is getting invoked when user want to backup account information safely. - * - * @param[in] file_name Specifies the file name in secure storage - * @remarks N/A - * @return This function returns true on success or false on failure. - */ -EXPORT_API int email_backup_accounts_into_secure_storage(const char *file_name); - -/** - * @open - * @fn email_restore_accounts_from_secure_storage(const char *file_name) - * @brief Restore accounts from stored file in secure storage. - * This function is getting invoked when user want to restore accounts. - * - * @param[in] file_name Specifies the file name in secure storage - * @remarks N/A - * @return This function returns true on success or false on failure. - */ -EXPORT_API int email_restore_accounts_from_secure_storage(const char * file_name); - -/** - * @open - * @fn email_get_password_length_of_account(const int account_id, int *password_length) - * @brief Get password length of an account. - * This function is getting invoked when user want to know the length of an account. - * - * @param[in] account_id Specifies the account id - * @param[out] handle Specifies the password length. - * @remarks N/A - * @return This function returns true on success or false on failure. - */ -EXPORT_API int email_get_password_length_of_account(const int account_id, int *password_length); - - -/** - * @open - * @fn email_query_server_info(const char* domain_name, emf_server_info_t **result_server_info) - * @brief Query email server information. - * This function is getting invoked when user want to get email server information. - * - * @param[in] domain_name Specifies the domain name of server - * @param[out] result_server_info Specifies the information of email server. - * @remarks N/A - * @return This function returns true on success or false on failure. - */ -EXPORT_API int email_query_server_info(const char* domain_name, emf_server_info_t **result_server_info); - -/** - * @open - * @fn email_free_server_info(emf_server_info_t **result_server_info) - * @brief Free emf_server_info_t. - * This function is getting invoked when user want to free emf_server_info_t. - * - * @param[in] result_server_info Specifies the pointer of in secure storage - * @remarks N/A - * @return This function returns true on success or false on failure. - */ -EXPORT_API int email_free_server_info(emf_server_info_t **result_server_info); - -/** - * @open - * @fn email_update_notification_bar(int account_id) - * @brief Update notifications on notification bar. - * This function is getting invoked when user want to update notification bar. - * - * @param[in] account_id Specifies the id of account. - * @remarks N/A - * @return This function returns true on success or false on failure. - */ -EXPORT_API int email_update_notification_bar(int account_id); - -/** - * @open - * @fn email_clear_all_notification_bar() - * @brief Clear all notification on notification bar. - * This function is getting invoked when user want to clear notification bar. - * - * @remarks N/A - * @return This function returns true on success or false on failure. - */ -EXPORT_API int email_clear_all_notification_bar(); - - -/** - * @open - * @fn email_save_default_account_id() - * @brief Save default account id to vconf storage. - * This function is getting invoked when user want to save default account id. - * - * @remarks N/A - * @return This function returns true on success or false on failure. - */ -EXPORT_API int email_save_default_account_id(int input_account_id); - -/** - * @open - * @fn email_load_default_account_id() - * @brief Load default account id to vconf storage. - * This function is getting invoked when user want to load default account id. - * - * @remarks N/A - * @return This function returns true on success or false on failure. - */ -EXPORT_API int email_load_default_account_id(int *output_account_id); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -/** -* @} @} -*/ - -#endif /* __EMAIL_API_ACCOUNT_H__ */ - - +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +#ifndef __EMAIL_API_ACCOUNT_H__ +#define __EMAIL_API_ACCOUNT_H__ + +#include "email-types.h" + +/** +* @defgroup EMAIL_SERVICE Email Service +* @{ +*/ + + +/** +* @ingroup EMAIL_SERVICE +* @defgroup EMAIL_API_ACCOUNT Email Account API +* @{ +*/ + +/** + * + * This file contains the data structures and interfaces needed for application, + * to interact with email-service. + * @file email-api-account.h + * @author Kyuho Jo + * @author Sunghyun Kwon + * @version 0.1 + * @brief This file contains the data structures and interfaces of Accounts provided by + * email-service . + * +* @{ + +* @code +* #include "email-api-account.h" +* bool +* other_app_invoke_uniform_api_sample(int* error_code) +* { +* email_account_t *account = NULL; +* email_account_t *new_account = NULL; +* +* account = malloc(sizeof(email_account_t)); +* memset(account, 0x00, sizeof(email_account_t)); +* +* account->retrieval_mode = 1; +* account->incoming_server_secure_connection = 1; +* account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; +* account->outgoing_server_port_number = EMAIL_SMTP_PORT; +* account->outgoing_server_need_authentication = 1; +* account->account_name = strdup("gmail"); +* account->display_name = strdup("Tom"); +* account->user_email_address = strdup("tom@gmail.com"); +* account->reply_to_addr = strdup("tom@gmail.com"); +* account->return_addr = strdup("tom@gmail.com"); +* account->incoming_server_type = EMAIL_SERVER_TYPE_POP3; +* account->incoming_server_address = strdup("pop3.gmail.com"); +* account->incoming_server_port_number = 995; +* account->incoming_server_secure_connection = 1; +* account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL; +* account->incoming_server_user_name = strdup("tom"); +* account->password = strdup("password"); +* account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; +* account->outgoing_server_address = strdup("smtp.gmail.com"); +* account->outgoing_server_port_number = 587; +* account->outgoing_server_secure_connection = 0x02; +* account->outgoing_server_need_authentication = 1; +* account->outgoing_server_user_name = strdup("tom@gmail.com"); +* account->sending_password = strdup("password"); +* account->pop_before_smtp = 0; +* account->incoming_server_requires_apop = 0; +* account->flag1 = 2; +* account->flag2 = 1; +* account->is_preset_account = 1; +* account->logo_icon_path = strdup("Logo Icon Path"); +* 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 = strdup("Display name from"); +* 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("Signature"); +* account->check_interval = 0; +* // Add account +* if(EMAIL_ERROR_NONE != email_add_account(account)) +* //failure +* //else +* { +* //success +* if(account_id) +* *account_id = account->account_id; +* } +* if(EMAIL_ERROR_NONE != email_validate_account(account_id,&account_handle)) +* //failure +* else +* //success +* if(EMAIL_ERROR_NONE != email_delete_account(account_id)) +* //failure +* else +* //success +* new_account = malloc(sizeof(email_account_t)); +* memset(new_account, 0x00, sizeof(email_account_t)); +* new_account->flag1 = 1; +* new_account->account_name = strdup("samsung001"); +* new_account->display_name = strdup("Tom001"); +* new_account->options.keep_local_copy = 1; +* new_account->check_interval = 55; +* // Update account +* if(EMAIL_ERROR_NONE != email_update_account(acount_id,new_account)) +* //failure +* else +* //success +* // Get account +* if(EMAIL_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&account)) +* //failure +* else +* //success +* // Get list of accounts +* if(EMAIL_ERROR_NONE != email_get_account_list(&account_list,&count)) +* //failure +* else +* //success +* // free account +* email_free_account(&account, 1); +* } + * + * @endcode + * @} + */ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @open + * @fn email_add_account(email_account_t* account) + * @brief Create a new email account.This function is invoked when user wants to add new email account + * + * @param[in] account Specifies the structure pointer of account. + * @exception none + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @see email_account_t + * @remarks N/A + */ +EXPORT_API int email_add_account(email_account_t* account); + +/** + * @open + * @fn email_delete_account(int account_id) + * @brief Delete a email account.This function is invoked when user wants to delete an existing email account + * + * @param[in] account_id Specifies the account ID. + * @exception #EMAIL_ERROR_INVALID_PARAM -Invalid argument + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @see + * @remarks N/A + */ +EXPORT_API int email_delete_account(int account_id); + +/** + * @open + * @fn email_update_account(int account_id, email_account_t* new_account) + * @brief Change the information of a email account.This function is getting invoked when user wants to change some information of existing email account. + * + * @param[in] account_id Specifies the orignal account ID. + * @param[in] new_account Specifies the information of new account. + * @param[in] with_validation If this is 1, email-service will validate the account before updating. If this is 0, email-service will update the account without validation. + * @exception #EMAIL_ERROR_INVALID_PARAM -Invalid argument + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @see email_account_t + * @remarks N/A + */ +EXPORT_API int email_update_account(int account_id, email_account_t* new_account); + +/** + * @open + * @fn email_update_account_with_validation(int account_id, email_account_t* new_account) + * @brief Change the information of a email account.This function is getting invoked when user wants to change some information of existing email account. + * + * @param[in] account_id Specifies the orignal account ID. + * @param[in] new_account Specifies the information of new account. + * @param[in] with_validation If this is 1, email-service will validate the account before updating. If this is 0, email-service will update the account without validation. + * @exception #EMAIL_ERROR_INVALID_PARAM -Invalid argument + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @see email_account_t + * @remarks N/A + */ +EXPORT_API int email_update_account_with_validation(int account_id, email_account_t* new_account); + +/** + * @open + * @fn email_get_account(int account_id, int pulloption, email_account_t** account) + * @brief Get an email account by ID. This function is getting invoked when user wants to get the account informantion based on account id and option (GET_FULL_DATA/WITHOUT_OPTION/ONLY_OPTION).
+ * Memory for account information will be allocated to 3rd param(account). The allocated memory should be freed by email_free_account(). + * + * @param[in] account_id Specifies the account ID.This function is invoked when user + * @param[in] pulloption Option to specify to get full details or partial, see definition of EMAIL_ACC_GET_OPT_XXX + * @param[out] account The returned account is saved here. + * @exception #EMAIL_ERR_INVALID_PARAM -Invalid argument + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @see email_account_t + * @remarks N/A + */ + +EXPORT_API int email_get_account(int account_id, int pulloption, email_account_t** account); + +/** + * @open + * @fn email_get_account_list(email_account_t** account_list, int* count); + * @brief Get Account List.This function is getting invoked when user wants to get all account information based on the count of accounts provided by user.
+ * Memory for account information will be allocated to 3rd param(account). The allocated memory should be freed by email_free_account(). + * + * @param[in] account_list Specifies the structure pointer of account. + * @param[out] count Specifies the count of accounts. + * @exception #EMAIL_ERR_INVALID_PARAM -Invalid argument + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @see email_account_t + * @remarks N/A + */ +EXPORT_API int email_get_account_list(email_account_t** account_list, int* count); + + /** + * @open + * @fn email_free_account(email_account_t** account_list, int count); + * @brief Free allocated memory.This function is getting invoked when user wants to delete all account information. + * + * @param[in] account_list Specifies the structure pointer of account. + * @param[out] count Specifies the count of accounts. + * @exception #EMAIL_ERR_INVALID_PARAM -Invalid argument + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @see email_account_t + * @remarks N/A + */ +EXPORT_API int email_free_account(email_account_t** account_list, int count); + + +/** + * @open + * @fn email_validate_account(int account_id, unsigned* handle) + * @brief Validate account.This function is getting invoked after adding one account to validate it.If account is not validated then user should retry once again to add the account . + * + * @param[in] account_id Specifies the account Id to validate. + * @param[out] handle Specifies the sending handle. + * @remarks N/A + * @exception #EMAIL_ERR_INVALID_PARAM -Invalid argument + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @see none + * @remarks N/A + */ +EXPORT_API int email_validate_account(int account_id, unsigned* handle); + +/** + * @open + * @fn email_add_account_with_validation(email_account_t* account, unsigned* handle) + * @brief Add an account when the account is validated. This function is getting invoked when user want to validate an account. If account is not validated then user should retry once again to add the account.
+ * Validation is executed without saving an account to DB + * + * @param[in] account Specifies the structure pointer of account. + * @param[out] handle Specifies the sending handle. + * @remarks N/A + * @return This function returns true on success or false on failure. + */ +EXPORT_API int email_add_account_with_validation(email_account_t* account, unsigned* handle); + + +/** + * @open + * @fn email_backup_accounts_into_secure_storage(const char *file_name) + * @brief Back up information of all accounts into secure storage. + * This function is getting invoked when user want to backup account information safely. + * + * @param[in] file_name Specifies the file name in secure storage + * @remarks N/A + * @return This function returns true on success or false on failure. + */ +EXPORT_API int email_backup_accounts_into_secure_storage(const char *file_name); + +/** + * @open + * @fn email_restore_accounts_from_secure_storage(const char *file_name) + * @brief Restore accounts from stored file in secure storage. + * This function is getting invoked when user want to restore accounts. + * + * @param[in] file_name Specifies the file name in secure storage + * @remarks N/A + * @return This function returns true on success or false on failure. + */ +EXPORT_API int email_restore_accounts_from_secure_storage(const char * file_name); + +/** + * @open + * @fn email_get_password_length_of_account(const int account_id, int *password_length) + * @brief Get password length of an account. + * This function is getting invoked when user want to know the length of an account. + * + * @param[in] account_id Specifies the account id + * @param[out] handle Specifies the password length. + * @remarks N/A + * @return This function returns true on success or false on failure. + */ +EXPORT_API int email_get_password_length_of_account(const int account_id, int *password_length); + + +/** + * @open + * @fn email_query_server_info(const char* domain_name, email_server_info_t **result_server_info) + * @brief Query email server information. + * This function is getting invoked when user want to get email server information. + * + * @param[in] domain_name Specifies the domain name of server + * @param[out] result_server_info Specifies the information of email server. + * @remarks N/A + * @return This function returns true on success or false on failure. + */ +EXPORT_API int email_query_server_info(const char* domain_name, email_server_info_t **result_server_info); + +/** + * @open + * @fn email_free_server_info(email_server_info_t **result_server_info) + * @brief Free email_server_info_t. + * This function is getting invoked when user want to free email_server_info_t. + * + * @param[in] result_server_info Specifies the pointer of in secure storage + * @remarks N/A + * @return This function returns true on success or false on failure. + */ +EXPORT_API int email_free_server_info(email_server_info_t **result_server_info); + +/** + * @open + * @fn email_update_notification_bar(int account_id) + * @brief Update notifications on notification bar. + * This function is getting invoked when user want to update notification bar. + * + * @param[in] account_id Specifies the id of account. + * @remarks N/A + * @return This function returns true on success or false on failure. + */ +EXPORT_API int email_update_notification_bar(int account_id); + +/** + * @open + * @fn email_clear_all_notification_bar() + * @brief Clear all notification on notification bar. + * This function is getting invoked when user want to clear notification bar. + * + * @remarks N/A + * @return This function returns true on success or false on failure. + */ +EXPORT_API int email_clear_all_notification_bar(); + + +/** + * @open + * @fn email_save_default_account_id() + * @brief Save default account id to vconf storage. + * This function is getting invoked when user want to save default account id. + * + * @remarks N/A + * @return This function returns true on success or false on failure. + */ +EXPORT_API int email_save_default_account_id(int input_account_id); + +/** + * @open + * @fn email_load_default_account_id() + * @brief Load default account id to vconf storage. + * This function is getting invoked when user want to load default account id. + * + * @remarks N/A + * @return This function returns true on success or false on failure. + */ +EXPORT_API int email_load_default_account_id(int *output_account_id); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/** +* @} @} +*/ + +#endif /* __EMAIL_API_ACCOUNT_H__ */ + + diff --git a/email-api/include/email-api-etc.h b/email-api/include/email-api-etc.h new file mode 100755 index 0000000..4123636 --- /dev/null +++ b/email-api/include/email-api-etc.h @@ -0,0 +1,80 @@ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + +/** +* @defgroup EMAIL_SERVICE Email Service +* @{ +*/ + +/** +* @ingroup EMAIL_SERVICE +* @defgroup EMAIL_API_ETC Email API +* @{ +*/ + +/** + * + * This file contains the data structures and interfaces needed for application, + * to interact with email-service. + * @file email-api-etc.h + * @author Kyuho Jo + * @author Sunghyun Kwon + * @version 0.1 + * @brief This file contains the data structures and interfaces of Accounts provided by + * email-service . + */ + +#ifndef __EMAIL_API_ETC_H__ +#define __EMAIL_API_ETC_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "email-types.h" + +/** + + * @open + * @fn email_show_user_message(void) + * @brief This function show user message. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @exception none + * @see email_action_t + * @remarks N/A + */ +EXPORT_API int email_show_user_message(int id, email_action_t action, int error_code); + +EXPORT_API int email_open_eml_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_delete_eml_data(email_mail_data_t *input_mail_data); + +EXPORT_API int email_get_mime_entity(char *mime_path, char **mime_entity); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __EMAIL_API_ETC_H__ */ + +/** +* @} @} +*/ diff --git a/email-api/include/email-api-init.h b/email-api/include/email-api-init.h index cd4e00c..63fa085 100755 --- a/email-api/include/email-api-init.h +++ b/email-api/include/email-api-init.h @@ -1,174 +1,174 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - -#ifndef __EMAIL_API_INTI_H__ -#define __EMAIL_API_INTI_H__ - -#include "email-types.h" - -/** -* @defgroup EMAIL_SERVICE Email Service -* @{ -*/ - - -/** -* @ingroup EMAIL_SERVICE -* @defgroup EMAIL_API_INIT Email Initialization API -* @{ -*/ - -/** - * - * This file contains the data structures and interfaces needed for application, - * to interact with email-service. - * @file email-api-init.h - * @author Kyuho Jo - * @author Sunghyun Kwon - * @version 0.1 - * @brief This file contains the data structures and interfaces of Email FW Initialization provided by - * email-service . - *@{ - *@code - * - * #include "emf_mapi_init.h" - * - * bool - * other_app_invoke_uniform_api_sample(int* error_code) - * { - * int err = EMF_ERROR_NONE; - * - * // Open connections to email-service and DB - * // The connections will be maintain throughout application's execution - * if(EMF_ERROR_NONE == email_service_begin()) - * { - * If(EMF_ERROR_NONE != email_open_db()) - * { - * return false; - * } - * - * // Execute email_init_storage() if and only if there is no db file. - * // This fuction will create db file and tables for email service - * If(EMF_ERROR_NONE !=email_init_storage()) - * { - * return false; - * } - * } - * - * ...... - * - * // Work with calling MAPI functions - * - * ...... - * - * // Close the connections to email-service and DB after all email job is finished. (ex. close an email application) - * // DO NOT have to call these funtions until the connections is not needed any more. - * err =email_close_db(); - * err =email_service_end(); - * } - * - * @endcode - * @} - */ - - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - - * @open - * @fn email_init_storage(void) - * @brief Create all table for email. Exposed to External Application- core team.Creates all Email DB tables [ EXTERNAL] - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure - * @exception none - * @see none - * @remarks N/A - */ -EXPORT_API int email_init_storage(void); - -/** - - * @open - * @fn email_open_db(void) - * @brief This function Open the email DB and register busy handler - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @exception none - * @see none - * @remarks N/A - */ -EXPORT_API int email_open_db(void); - - -/** - - * @open - * @fn email_close_db(void) - * @brief This function closes the connection of the email DB - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @exception none - * @see none - * @remarks N/A - */ -EXPORT_API int email_close_db(void); - -/** - - * @open - * @fn email_service_begin(void) - * @brief Does the IPC Proxy Initialization by the Application which used the Email FW API's - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @exception none - * @see none - * @remarks N/A - */ -EXPORT_API int email_service_begin(void); - -/** - - * @open - * @fn email_service_end(void) - * @brief This function does the IPC Proxy Finaization by the Application which used the Email FW API's - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @exception none - * @see none - * @remarks N/A - */ -EXPORT_API int email_service_end(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -/** -* @} @} -*/ - - -#endif /* __EMAIL_API_INTI_H__ */ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +#ifndef __EMAIL_API_INTI_H__ +#define __EMAIL_API_INTI_H__ + +#include "email-types.h" + +/** +* @defgroup EMAIL_SERVICE Email Service +* @{ +*/ + + +/** +* @ingroup EMAIL_SERVICE +* @defgroup EMAIL_API_INIT Email Initialization API +* @{ +*/ + +/** + * + * This file contains the data structures and interfaces needed for application, + * to interact with email-service. + * @file email-api-init.h + * @author Kyuho Jo + * @author Sunghyun Kwon + * @version 0.1 + * @brief This file contains the data structures and interfaces of Email FW Initialization provided by + * email-service . + *@{ + *@code + * + * #include "email-api-init.h" + * + * bool + * other_app_invoke_uniform_api_sample(int* error_code) + * { + * int err = EMAIL_ERROR_NONE; + * + * // Open connections to email-service and DB + * // The connections will be maintain throughout application's execution + * if(EMAIL_ERROR_NONE == email_service_begin()) + * { + * If(EMAIL_ERROR_NONE != email_open_db()) + * { + * return false; + * } + * + * // Execute email_init_storage() if and only if there is no db file. + * // This fuction will create db file and tables for email service + * If(EMAIL_ERROR_NONE !=email_init_storage()) + * { + * return false; + * } + * } + * + * ...... + * + * // Work with calling MAPI functions + * + * ...... + * + * // Close the connections to email-service and DB after all email job is finished. (ex. close an email application) + * // DO NOT have to call these funtions until the connections is not needed any more. + * err =email_close_db(); + * err =email_service_end(); + * } + * + * @endcode + * @} + */ + + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + + * @open + * @fn email_init_storage(void) + * @brief Create all table for email. Exposed to External Application- core team.Creates all Email DB tables [ EXTERNAL] + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure + * @exception none + * @see none + * @remarks N/A + */ +EXPORT_API int email_init_storage(void); + +/** + + * @open + * @fn email_open_db(void) + * @brief This function Open the email DB and register busy handler + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @exception none + * @see none + * @remarks N/A + */ +EXPORT_API int email_open_db(void); + + +/** + + * @open + * @fn email_close_db(void) + * @brief This function closes the connection of the email DB + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @exception none + * @see none + * @remarks N/A + */ +EXPORT_API int email_close_db(void); + +/** + + * @open + * @fn email_service_begin(void) + * @brief Does the IPC Proxy Initialization by the Application which used the Email FW API's + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @exception none + * @see none + * @remarks N/A + */ +EXPORT_API int email_service_begin(void); + +/** + + * @open + * @fn email_service_end(void) + * @brief This function does the IPC Proxy Finaization by the Application which used the Email FW API's + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @exception none + * @see none + * @remarks N/A + */ +EXPORT_API int email_service_end(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/** +* @} @} +*/ + + +#endif /* __EMAIL_API_INTI_H__ */ diff --git a/email-api/include/email-api-mail.h b/email-api/include/email-api-mail.h index e6d4048..8b3b227 100755 --- a/email-api/include/email-api-mail.h +++ b/email-api/include/email-api-mail.h @@ -1,1869 +1,1427 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - -#ifndef __EMAIL_API_MESSAGE_H__ -#define __EMAIL_API_MESSAGE_H__ - -#include "email-types.h" - -#include - -#include -#include -#include - -/** -* @defgroup EMAIL_SERVICE Email Service -* @{ -*/ - - -/** -* @ingroup EMAIL_SERVICE -* @defgroup EMAIL_API_MAIL Email Mail API -* @{ -*/ - -/** - * - * This file contains the data structures and interfaces needed for application, - * to interact with email-service. - * @file email-api-mail.h - * @author Kyuho Jo - * @author Sunghyun Kwon - * @version 0.1 - * @brief This file contains the data structures and interfaces of Messages provided by - * email-service . - */ - - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @open - * @fn email_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas) - * @brief Save a mail. This function is invoked when user wants to add a mail. - * If the option from_eas is 1 then this will save the message on server as well as on locally. - * If the receiving_server_type is EMF_SERVER_TYPE_POP3 then from_eas value will be 0 - * If the receiving_server_type is EMF_SERVER_TYPE_IMAP4 then from_eas value will be 1/0 - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] input_mail_data Specifies the saving mail. - * @param[in] input_attachment_data_list Specifies the mailbox structure for saving email. - * @param[in] input_attachment_count Specifies if the mail comes from composer. - * @param[in] input_meeting_request Specifies if the mail comes from composer. - * @param[in] input_from_eas Specifies if the mail will be saved on server. - - * @exception none - * @see emf_mail_data_t and emf_mailbox_t - * @remarks N/A - * @code - * #include "email-api-mail.h" - * int _test_add_mail () - * { - * int i = 0; - * int account_id = 0; - * int from_eas = 0; - * int attachment_count = 0; - * int err = EMF_ERROR_NONE; - * char arg[50] = { 0 , }; - * char *body_file_path = "/opt/data/email/.emfdata/tmp/mail.txt"; - * emf_mailbox_t *mailbox_data = NULL; - * emf_mail_data_t *test_mail_data = NULL; - * emf_attachment_data_t *attachment_data = NULL; - * emf_meeting_request_t *meeting_req = NULL; - * FILE *body_file; - * - * printf("\n > Enter account id : "); - * scanf("%d", &account_id); - * - * - * memset(arg, 0x00, 50); - * printf("\n > Enter mailbox name : "); - * scanf("%s", arg); - * - * email_get_mailbox_by_name(account_id, arg, &mailbox_data); - * - * test_mail_data = malloc(sizeof(emf_mail_data_t)); - * memset(test_mail_data, 0x00, sizeof(emf_mail_data_t)); - * - * printf("\n From EAS? [0/1]> "); - * scanf("%d", &from_eas); - * - * test_mail_data->account_id = account_id; - * test_mail_data->save_status = 1; - * test_mail_data->flags_seen_field = 1; - * test_mail_data->file_path_plain = strdup(body_file_path); - * test_mail_data->mailbox_name = strdup(mailbox_data->name); - * test_mail_data->mailbox_type = mailbox_data->mailbox_type; - * test_mail_data->full_address_from = strdup(""); - * test_mail_data->full_address_to = strdup(""); - * test_mail_data->full_address_cc = strdup(""); - * test_mail_data->full_address_bcc = strdup(""); - * test_mail_data->subject = strdup("Meeting request mail"); - * - * body_file = fopen(body_file_path, "w"); - * - * for(i = 0; i < 500; i++) - * fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2"); - * fflush(body_file); - * fclose(body_file); - * - * printf(" > Attach file? [0/1] : "); - * scanf("%d",&attachment_count); - * - * if ( attachment_count ) { - * memset(arg, 0x00, 50); - * printf("\n > Enter attachment name : "); - * scanf("%s", arg); - * - * attachment_data = malloc(sizeof(emf_attachment_data_t)); - * - * attachment_data->attachment_name = strdup(arg); - * - * memset(arg, 0x00, 50); - * printf("\n > Enter attachment absolute path : "); - * scanf("%s",arg); - * - * attachment_data->attachment_path = strdup(arg); - * attachment_data->save_status = 1; - * test_mail_data->attachment_count = attachment_count; - * } - * - * printf("\n > Meeting Request? [0: no, 1: yes (request from server), 2: yes (response from local)]"); - * scanf("%d", &(test_mail_data->meeting_request_status)); - * - * if ( test_mail_data->meeting_request_status == 1 - * || test_mail_data->meeting_request_status == 2 ) { - * time_t current_time; - * meeting_req = malloc(sizeof(emf_meeting_request_t)); - * memset(meeting_req, 0x00, sizeof(emf_meeting_request_t)); - * - * meeting_req->meeting_response = 1; - * current_time = time(NULL); - * gmtime_r(¤t_time, &(meeting_req->start_time)); - * gmtime_r(¤t_time, &(meeting_req->end_time)); - * meeting_req->location = malloc(strlen("Seoul") + 1); - * memset(meeting_req->location, 0x00, strlen("Seoul") + 1); - * strcpy(meeting_req->location, "Seoul"); - * strcpy(meeting_req->global_object_id, "abcdef12345"); - * - * meeting_req->time_zone.offset_from_GMT = 9; - * strcpy(meeting_req->time_zone.standard_name, "STANDARD_NAME"); - * gmtime_r(¤t_time, &(meeting_req->time_zone.standard_time_start_date)); - * meeting_req->time_zone.standard_bias = 3; - * - * strcpy(meeting_req->time_zone.daylight_name, "DAYLIGHT_NAME"); - * gmtime_r(¤t_time, &(meeting_req->time_zone.daylight_time_start_date)); - * meeting_req->time_zone.daylight_bias = 7; - * - * } - * - * if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMF_ERROR_NONE) - * printf("email_add_mail failed. [%d]\n", err); - * else - * printf("email_add_mail success.\n"); - * - * if(attachment_data) - * email_free_attachment_data(&attachment_data, attachment_count); - * - * if(meeting_req) - * email_free_meeting_request(&meeting_req, 1); - * - * email_free_mail_data(&test_mail_data, 1); - * email_free_mailbox(&mailbox_data, 1); - * - * printf("saved mail id = [%d]\n", test_mail_data->mail_id); - * - * return 0; - * } - * @endcode - */ -EXPORT_API int email_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas); - - /** - * @open - * @fn email_add_read_receipt(int input_read_mail_id, unsigned *output_handle) - * @brief Add a read receipt mail. This function is invoked when user receives a mail with read report enable and wants to send a read report for the same. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] input_read_mail_id Specifies the id of mail which has been read. - * @param[out] output_receipt_mail_id Specifies the receipt mail id . - * @exception none - * @see - * @remarks N/A - */ -EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receipt_mail_id); - -/** - * @open - * @fn email_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_composer) - * @brief Update a existing email information. This function is invoked when user wants to change some existing email information with new email information. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] input_mail_data Specifies the mail ID. - * @param[in] input_attachment_data_list Specifies the pointer of attachment data. - * @param[in] input_attachment_count Specifies the number of attachment data. - * @param[in] input_meeting_request Specifies the meeting request data. - * @param[in] input_from_eas Specifies whether sync server. - - * @exception none - * @see emf_mail_data_t - * @code - * #include "email-api-account.h" - * int email_test_update_mail() - * { - * int mail_id = 0; - * int err = EMF_ERROR_NONE; - * int test_attachment_data_count = 0; - * char arg[50]; - * emf_mail_data_t *test_mail_data = NULL; - * emf_attachment_data_t *test_attachment_data_list = NULL; - * emf_meeting_request_t *meeting_req = NULL; - * - * printf("\n > Enter mail id : "); - * scanf("%d", &mail_id); - * - * email_get_mail_data(mail_id, &test_mail_data); - * - * printf("\n > Enter Subject: "); - * scanf("%s", arg); - * - * test_mail_data->subject= strdup(arg); - * - * - * - * if (test_mail_data->attachment_count > 0) { - * if ( (err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMF_ERROR_NONE ) { - * printf("email_get_meeting_request() failed [%d]\n", err); - * return -1; - * } - * } - * - * if ( test_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_REQUEST - * || test_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_RESPONSE - * || test_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { - * - * if ( (err = email_get_meeting_request(mail_id, &meeting_req)) != EMF_ERROR_NONE ) { - * printf("email_get_meeting_request() failed [%d]\n", err); - * return -1; - * } - * - * printf("\n > Enter meeting response: "); - * scanf("%d", (int*)&(meeting_req->meeting_response)); - * } - * - * if ( (err = email_update_mail(test_mail_data, test_attachment_data_list, test_attachment_data_count, meeting_req, 0)) != EMF_ERROR_NONE) - * printf("email_update_mail failed.[%d]\n", err); - * else - * printf("email_update_mail success\n"); - * - * if(test_mail_data) - * email_free_mail_data(&test_mail_data, 1); - * - * if(test_attachment_data_list) - * email_free_attachment_data(&test_attachment_data_list, test_attachment_data_count); - * - * if(meeting_req) - * email_free_meeting_request(&meeting_req, 1); - * - * return 0; - * } - - * @endcode - * @remarks N/A - */ -EXPORT_API int email_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas); - -/** - * @open - * @fn email_count_message(emf_mailbox_t* mailbox, int* total, int* unseen) - * @brief Get mail count from mailbox.This function is invoked when user wants to know how many toatl mails and out of that - * how many unseen mails are there in a given mailbox. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Specifies the pointer of mailbox structure. - * @param[out] total Total email count is saved here. - * @param[out] unseen Unread email count is saved here. - * @exception none - * @see emf_mailbox_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_count_message() - * { - * emf_mailbox_t mailbox; - * int account_id = 0; - * int total = 0; - * int unseen = 0; - * - * memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - * printf("\n > Enter account_id (0 means all accounts) : "); - * scanf("%d", &account_id); - * if(account_id == 0) - * { - * mailbox.name = NULL; - * } - * else - * { - * printf("\n > Enter maibox name: "); - * mailbox.name = strdup("SENTBOX"); - * } - * mailbox.account_id = account_id; - * if(EMF_ERROR_NONE == email_count_message(&mailbox, &total, &unseen)) - * printf("\n Total: %d, Unseen: %d \n", total, unseen); - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_count_message(emf_mailbox_t* mailbox, int* total, int* unseen); - - -/** - * @open - * @fn email_delete_message(emf_mailbox_t* mailbox, int *mail_ids, int num, int from_server) - * @brief Delete a mail or multiple mails.Based on from_server value this function will delte a mail or multiple mails from server or loaclly. - * @param[in] mailbox Reserved. - * If the receiving_server_type is EMF_SERVER_TYPE_POP3 then from_server value will be 0 - * If the receiving_server_type is EMF_SERVER_TYPE_IMAP4 then from_server value will be 1/0 - * - * @param[in] mail_ids[] 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. - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @exception none - * @see emf_mailbox_t - * @code - * #include "email-api-account.h" - * bool - * _api_sample_delete_all_messages_in_mailbox() - * { - * int count, i, mail_id=0, account_id =0; - * emf_mailbox_t mbox = {0}; - * - * printf("\n > Enter Account_id: "); - * scanf("%d",&account_id); - * printf("\n > Enter Mail_id: "); - * scanf("%d",&mail_id); - * printf("\n > Enter Mailbox name: "); - * mbox.account_id = account_id; - * mbox.name = strdup("INBOX"); - * if(EMF_ERROR_NONE == email_delete_message(&mbox, &mail_id, 1, 1)) - * printf("\n email_delete_message success"); - * else - * printf("\n email_delete_message failed"); - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_delete_message(emf_mailbox_t* mailbox, int *mail_ids, int num, int from_server); - - -/** - * @open - * @fn email_delete_all_message_in_mailbox(emf_mailbox_t* mailbox, int from_server) - * @brief Delete all mail from a mailbox. - * If the receiving_server_type is EMF_SERVER_TYPE_POP3 then from_server value will be 0 - * If the receiving_server_type is EMF_SERVER_TYPE_IMAP4 then from_server value will be 1/0 - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Specifies the structure of mailbox. - * @param[in] from_server Specifies whether mails are also deleted from server. - * @exception none - * @see emf_mailbox_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_delete_all_messages_in_mailbox() - * { - * int count, account_id =0; - * emf_mailbox_t mbox = {0}; - * - * printf("\n > Enter Account_id: "); - * scanf("%d",&account_id); - * printf("\n > Enter Mailbox name: "); - * mbox.account_id = account_id; - * mbox.name = strdup("INBOX"); - * - * if (EMF_ERROR_NONE != email_delete_all_message_in_mailbox(&mbox, 0)) - * printf("email_delete_all_message_in_mailbox failed"); - * else - * printf("email_delete_all_message_in_mailbox Success"); - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_delete_all_message_in_mailbox(emf_mailbox_t* mailbox, int from_server); - - - -/** - * @open - * @fn email_clear_mail_data() - * @brief delete email data from storage. This API will be used by the Settings Application - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @exception none - * @see none - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_clear_mail_data() - * { - * if(EMF_ERROR_NONE == email_clear_mail_data()) - * //success - * else - * //failure - * - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_clear_mail_data(); - - -/** - * @open - * @fn email_add_attachment( emf_mailbox_t* mailbox, int mail_id, emf_attachment_info_t* attachment) - * @brief Append a attachment to email.This function is invoked when user wants to add attachment to existing mail. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mail_id Specifies the mail ID. - * @param[in] attachment Specifies the structure of attachment. - * @exception none - * @see emf_mailbox_t and emf_attachment_info_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_mail_add_attachment() - * { - * int account_id = 0; - * int mail_id = 0; - * emf_mailbox_t mbox; - * emf_attachment_info_t attachment; - * - * printf("\n > Enter Mail Id: "); - * scanf("%d", &mail_id); - * printf("\n > Enter Account_id: "); - * scanf("%d",&account_id); - * memset(&mbox, 0x00, sizeof(emf_attachment_info_t)); - * mbox.account_id = account_id; - * mbox.name = strdup("INBOX"); - * memset(&attachment, 0x00, sizeof(emf_attachment_info_t)); - * printf("\n > Enter attachment name: "); - * attachment.name = strdup("Test"); - * printf("\n > Enter attachment absolute path: "); - * attachment.savename = strdup("/tmp/test.txt"); - * attachment.next = NULL; - * if(EMF_ERROR_NONE != email_add_attachment( &mbox, mail_id, &attachment)) - * printf("email_add_attachment failed\n"); - * else - * printf(email_add_attachment success\n"); - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_add_attachment( emf_mailbox_t* mailbox, int mail_id, emf_attachment_info_t* attachment); - - -/** - * @open - * @fn email_delete_attachment(emf_mailbox_t * mailbox, int mail_id, const char * attachment_id) - * @brief delete a attachment from email.This function is invoked when user wants to delete a attachment from existing mailbased on mail Id and attachment Id - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Specifies the structure of mailbox. - * @param[in] mail_id Specifies the mail ID. - * @param[in] attachment_id Specifies the attachment id. - * @exception none - * @see emf_mailbox_t - * @code - * #include "email-api-account.h" - * bool - * _api_sample_mail_delete_attachment() - * { - * int account_id = 0; - * int mail_id = 0; - * char *attchment_id; - * emf_mailbox_t mbox; - * - * mail_id = 1; // mail id in the DB - * mbox.account_id = 1; // account id in the DB - * mbox.name = strdup("INBOX"); // mailbox name - * attachment_id = strdup("1"); // the first attachment item in a attachment list - * - * if(EMF_ERROR_NONE != email_delete_attachment(&mbox,mail_id,attachment_id)) - * //failure - * else - * //success - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_delete_attachment(emf_mailbox_t * mailbox, int mail_id, const char *attachment_id); - - -/* ----------------------------------------------------------- - Mail Search API - -----------------------------------------------------------*/ - -/** - * @open - * @fn email_query_mails(char *conditional_clause_string, emf_mail_data_t** mail_list, int *result_count) - * @brief Query the mail list information from DB based on the mailbox name. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] conditional_clause_string Specifies the where clause string. - * @param[in/out] mail_list Specifies the pointer to the structure emf_mail_data_t. - * @param[in/out] result_count Specifies the number of mails returned. - * @exception None - * @see emf_mail_list_item_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_query_mail() - * { - * emf_mail_data_t *mail_list = NULL; - * char conditional_clause_string[500]; - * int result_count = 0; - * - * memset(mailbox_name, 0x00, 10); - * printf("\n > Enter where clause: "); - * scanf("%s", conditional_clause_string); - * - * - * if (EMF_ERROR_NONE != email_query_mails(conditional_clause_string, &mail_list, &result_count)) - * printf("email_query_message_ex failed \n"); - * else { - * printf("Success\n"); - * //do something - * free(mail_list); - * } - * - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_query_mails(char *conditional_clause_string, emf_mail_data_t** mail_list, int *result_count); - -/** - * @open - * @fn email_query_message_ex(char *conditional_clause_string, emf_mail_list_item_t** mail_list, int *result_count) - * @brief Query the mail list information from DB based on the mailbox name. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] conditional_clause_string Specifies the where clause string. - * @param[in/out] mail_list Specifies the pointer to the structure emf_mail_list_item_t. - * @param[in/out] result_count Specifies the number of mails returned. - * @exception None - * @see emf_mail_list_item_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_query_mail() - * { - * emf_mail_list_item_t *mail_list = NULL; - * char conditional_clause_string[500]; - * int result_count = 0; - * - * memset(mailbox_name, 0x00, 10); - * printf("\n > Enter where clause: "); - * scanf("%s", conditional_clause_string); - * - * - * if (EMF_ERROR_NONE != email_query_message_ex(conditional_clause_string, &mail_list, &result_count)) - * printf("email_query_message_ex failed \n"); - * else { - * printf("Success\n"); - * //do something - * free(mail_list); - * } - * - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_query_message_ex(char *conditional_clause_string, emf_mail_list_item_t** mail_list, int *result_count); - - -/** - * @open - * @fn email_get_attachment_info(emf_mailbox_t* mailbox, int mail_id, const char* attachment_id, emf_attachment_info_t** attachment) - * @brief Get a mail attachment.This function is invoked when user wants to get the attachment information based on attachment id for the specified mail Id. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Reserved. - * @param[in] mail_id Specifies the mail ID. - * @param[in] attachment_id Specifies the buffer that a attachment ID been saved. - * @param[out] attachment The returned attachment is save here. - * @exception none - * @see emf_mailbox_t and emf_mail_attachment_info_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_mail_get_attachment_info() - * { - * emf_mailbox_t mailbox; - * emf_mail_attachment_info_t *mail_attach_info = NULL; - * int mail_id = 0,account_id = 0; - * char arg[10]; - * int err = EMF_ERROR_NONE; - * - * memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - * - * printf("\n > Enter Mail Id: "); - * scanf("%d", &mail_id); - * printf("\n > Enter account Id: "); - * scanf("%d", &account_id); - * printf("> attachment Id\n"); - * scanf("%s",arg); - * mailbox.account_id = account_id; - * if (EMF_ERROR_NONE != email_get_attachment_info(&mailbox, mail_id, &mail_attach_info)) - * printf("email_get_attachment_info failed\n"); - * else - * { - * printf("email_get_attachment_info SUCCESS\n"); - * //do something - * email_free_attachment_info(&mail_attach_info,1); - * } - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_attachment_info(emf_mailbox_t* mailbox, int mail_id, const char* attachment_id, emf_attachment_info_t** attachment); - -EXPORT_API int email_get_attachment_data_list(int input_mail_id, emf_attachment_data_t **output_attachment_data, int *output_attachment_count); - -/** - * @open - * @fn email_free_attachment_info(emf_attachment_info_t** atch_info) - * @brief Free allocated memroy for email attachment. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] atch_info Specifies the pointer of mail attachment structure pointer. - * @exception none - * @see emf_mail_attachment_info_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_mail_free_attachment_info() - * { - * emf_mailbox_t mailbox; - * emf_mail_attachment_info_t *mail_attach_info = NULL; - * int mail_id = 0,account_id = 0; - * char arg[10]; - * int err = EMF_ERROR_NONE; - * - * memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - * - * printf("\n > Enter Mail Id: "); - * scanf("%d", &mail_id); - * printf("\n > Enter account Id: "); - * scanf("%d", &account_id); - * printf("> attachment Id\n"); - * scanf("%s",arg); - * mailbox.account_id = account_id; - * if (EMF_ERROR_NONE != email_get_attachment_info(&mailbox, mail_id, &mail_attach_info)) - * printf("email_get_attachment_info failed\n"); - * else - * { - * printf("email_get_attachment_info SUCCESS\n"); - * //do something - * email_free_attachment_info(&mail_attach_info,1); - * } - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_free_attachment_info(emf_attachment_info_t** atch_info); - -EXPORT_API int email_free_attachment_data(emf_attachment_data_t **attachment_data_list, int attachment_data_count); - -/** - * @open - * @fn email_get_mail_data(int input_mail_id, emf_mail_data_t **output_mail_data) - * @brief Get a mail by its mail id. This function is invoked when user wants to get a mail based on mail id existing in DB. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] input_mail_id specifies the mail id. - * @param[out] output_mail_data The returned mail is save here. - * @exception none - * @see emf_mail_data_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_mail_data() - * { - * emf_mail_data_t *mail = NULL; - * int mail_id = 0 ; - * int err = EMF_ERROR_NONE; - * - * printf("\n > Enter mail id: "); - * scanf("%d", &mail_id); - * - * if (EMF_ERROR_NONE != email_get_mail_data(mail_id, &mail)) - * printf("email_get_mail_data failed\n"); - * else - * { - * printf("email_get_mail_data SUCCESS\n"); - * //do something - * email_free_mail_data(&mail,1); - * } - * } - * @endcode - * @remarks N/A - */ - -EXPORT_API int email_get_mail_data(int input_mail_id, emf_mail_data_t **output_mail_data); - - -/* ----------------------------------------------------------- - Mail Flag API - -----------------------------------------------------------*/ - -/** - * @open - * @fn email_modify_mail_flag(int mail_id, emf_mail_flag_t new_flag, int onserver) - * @brief Change email flag.[ Seen,Deleted,flagged,answered,recent,draft,has_attachment,reserved_1] - * If the receiving_server_type is EMF_SERVER_TYPE_POP3 then from_server value will be 0 - * If the receiving_server_type is EMF_SERVER_TYPE_IMAP4 then from_server value will be 1/0 - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mail_id Specifies the mail ID. - * @param[in] new_flag Specifies the new email flag. - * @param[in] onserver Specifies whether mail Flag updation in server - * @exception none - * @see emf_mail_flag_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_modify_mail_flag() - * { - * emf_mail_flag_t newflag; - * int mail_id = 0; - * int err = EMF_ERROR_NONE; - * - * memset(&newflag, 0x00, sizeof(emf_mail_flag_t)); - * newflag.seen = 1; - * newflag.answered = 0; - * newflag.sticky = 1; - * - * printf("\n > Enter Mail Id: "); - * scanf("%d", &mail_id); - * if (EMF_ERROR_NONE != email_modify_mail_flag(mail_id, newflag, 1)) - * printf("email_modify_mail_flag failed\n"); - * else - * { - * printf("email_modify_mail_flag SUCCESS\n"); - * //do something - * - * } - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_modify_mail_flag(int mail_id, emf_mail_flag_t new_flag, int onserver); - -/** - * @open - * @fn email_set_flags_field(int *mail_ids, int num, emf_flags_field_type field_type, int value, int onserver) - * @brief Change email flags field. - * If the receiving_server_type is EMF_SERVER_TYPE_POP3 then from_server value will be 0 - * If the receiving_server_type is EMF_SERVER_TYPE_IMAP4 then from_server value will be 1/0 - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies account ID. - * @param[in] mail_ids Specifies the array of mail ID. - * @param[in] num Specifies the number of mail ID. - * @param[in] field_type Specifies the field type what you want to set. Refer emf_flags_field_type. - * @param[in] value Specifies the value what you want to set. - * @param[in] onserver Specifies whether mail Flag updation in server - * @exception none - * @see none - * @code - * #include "email-api-account.h" - * bool - * _api_sample_set_flags_field() - * { - * int mail_id = 0; - * int err = EMF_ERROR_NONE; - * - * printf("\n > Enter Mail Id: "); - * scanf("%d", &mail_id); - * if (EMF_ERROR_NONE != email_set_flags_field(&mail_id, EMFF_LAGS_SEEN_FIELD, 1, 0)) - * printf("email_set_flags_field failed\n"); - * else - * { - * printf("email_set_flags_field SUCCESS\n"); - * //do something - * } - * } - * @endcode - * @remarks N/A - */ - -EXPORT_API int email_set_flags_field(int account_id, int *mail_ids, int num, emf_flags_field_type field_type, int value, int onserver); - -/** - * @open - * @fn email_modify_extra_mail_flag(int mail_id, emf_extra_flag_t new_flag) - * @brief Change email extra flag.[priority,Delivery report status, Drm, Protection etc] - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mail_id Specifies the mail ID. - * @param[in] new_flag Specifies the new email extra flag. - * @exception none - * @see emf_extra_flag_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_modify_extra_mail_flag() - * { - * emf_extra_flag_t newflag; - * int mail_id = 0; - * int err = EMF_ERROR_NONE; - * - * memset(&newflag, 0x00, sizeof(emf_extra_flag_t)); - * - * printf("\n > Enter Mail Id: "); - * scanf("%d", &mail_id); - * - * if(EMF_ERROR_NONE != email_modify_extra_mail_flag(mail_id, newflag)) - * printf("email_modify_extra_mail_flag failed"); - * else - * printf("email_modify_extra_mail_flag success"); - * - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_modify_extra_mail_flag(int mail_id, emf_extra_flag_t new_flag); - - - -/* ----------------------------------------------------------- - Mail Move API - -----------------------------------------------------------*/ - -/** - * @open - * @fn email_move_mail_to_mailbox(int *mail_ids, int num, emf_mailbox_t* new_mailbox) - * @brief Move a email to another mailbox. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mail_id Specifies the array of mail ID. - * @param[in] num Specifies the count of mail IDs. - * @param[in] new_mailbox Specifies the mailbox structure for moving email. - * @exception none - * @see emf_mailbox_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_move_mail_to_mailbox() - * { - * int mail_id = 1; - * int account_id =0; - * emf_mailbox_t mbox; - * char arg[10]; - * int err = EMF_ERROR_NONE; - * int i = 0; - * - * printf("\n > Enter Account_id: "); - * scanf("%d",&account_id); - * - * memset(&mbox, 0x00, sizeof(emf_mailbox_t)); - * - * mbox.account_id = account_id; - * mbox.name = strdup("Test"); - * if(EMF_ERROR_NONE == email_move_mail_to_mailbox(mail_id, 1, &mbox)) - * printf("Success\n"); - * - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_move_mail_to_mailbox(int *mail_ids, int num, emf_mailbox_t* new_mailbox); - - -/** - * @open - * @fn email_move_all_mails_to_mailbox(emf_mailbox_t* src_mailbox, emf_mailbox_t* new_mailbox) - * @brief Move all email to another mailbox. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] src_mailbox Specifies the source mailbox structure for moving email. - * @param[in] new_mailbox Specifies the destination mailbox structure for moving email. - * @exception none - * @see emf_mailbox_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_move_all_mails_to_mailbox() - * { - * emf_mailbox_t src_mailbox; - * emf_mailbox_t dest_mailbox; - * int total_count; - * int err = EMF_ERROR_NONE; - * char temp[128]; - * - * memset(&src_mailbox, 0x00, sizeof(emf_mailbox_t)); - * memset(&dest_mailbox, 0x00, sizeof(emf_mailbox_t)); - * - * // input mailbox information : need account_id and name (src & dest) - * printf("src mail account id(0: All account)> "); - * scanf("%d", &src_mailbox.account_id); - * printf("src mailbox_name(0 : NULL)> "); - * src_mailbox = strdup("INBOX"); - * // Destination mailbox - * printf("dest mail account id> "); - * scanf("%d", &dest_mailbox.account_id); - * printf("dest_mailbox_name(0 : NULL)> "); - * dest_mailbox = strdup("INBOX"); - * - * ( EMF_ERROR_NONE == email_move_all_mails_to_mailbox(&src_mailbox, &dest_mailbox)) - * { - * printf(" fail email_move_all_mails_to_mailbox: \n"); - * } - * else - * //success - * if ( src_mailbox) - * { - * free(src_mailbox); - * } - * if ( dest_mailbox ) - * { - * free(dest_mailbox); - * } - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_move_all_mails_to_mailbox(emf_mailbox_t* src_mailbox, emf_mailbox_t* new_mailbox); - - -/** - * @open - * @fn email_count_message_with_draft_flag(emf_mailbox_t* mailbox, int* total) - * @brief Get mail count from mailbox having draft flag. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Specifies the pointer of mailbox structure. - * @param[out] total Total email count is saved with draft flag enabled. - * @exception none - * @see emf_mailbox_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_count_message_with_draft_flag() - * { - * emf_mailbox_t mailbox; - * int total_count; - * int err = EMF_ERROR_NONE; - * - * memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - * // input mailbox information : need account_id and name - * printf("mail account id(0: All account)> "); - * scanf("%d", &mailbox.account_id); - * mailbox.name = strdup("Inbox"); - * if ( EMF_ERROR_NONE != email_count_message_with_draft_flag(&mailbox, &total_count)) - * { - * printf(" fail email_count_message_with_draft_flag:\n); - * } - * else - * { - * printf(" success email_count_message_with_draft_flag:\n); - * } - * if ( mailbox.name ) - * { - * free(mailbox.name); - * } - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_count_message_with_draft_flag(emf_mailbox_t* mailbox, int* total); - - -/** - * @open - * @fn email_count_message_on_sending(emf_mailbox_t* mailbox, int* total) - * @brief Get the number of mails which are being sent in specific mailbox.This function gives the list of mails having on sending status for a given mailbox. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Specifies the pointer of mailbox structure. - * @param[out] total Total email count is saved with draft flag enabled. - * @exception none - * @see emf_mailbox_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_count_message_on_sending() - * { - * emf_mailbox_t mailbox; - * int total_count; - * int err = EMF_ERROR_NONE; - * - * memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - * // input mailbox information : need account_id and name - * printf("mail account id(0: All account)> "); - * scanf("%d", &mailbox.account_id); - * mailbox.name = strdup("Draft"); - * if (EMF_ERROR_NONE != email_count_message_on_sending(&mailbox, &total_count)) - * { - * printf(" fail email_count_message_on_sending: \n"); - * } - * else - * { - * printf(" success email_count_message_on_sending:\n"); - * } - * if ( mailbox.name ) - * { - * free(mailbox.name); - * } - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_count_message_on_sending(emf_mailbox_t* mailbox, int* total); - -/** - * @open - * @fn email_free_mail_data(emf_mail_data_t** mail_list, int count) - * @brief Free allocated memroy for emails. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mail_list Specifies the pointer of mail structure pointer. - * @param[in] count Specifies the count of mails. - * @exception none - * @see emf_mail_data_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_free_mail() - * { - * emf_mail_data_t *mail; - * - * //fill the mail structure - * //count - number of mail structure user want to free - * if(EMF_ERROR_NONE == email_free_mail_data(&mail,count)) - * //success - * else - * //failure - * - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_free_mail_data(emf_mail_data_t** mail_list, int count); - -/** - * @open - * @fn email_get_mails(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_data_t** mail_list, int* result_count) - * @brief Get the Mail List information from DB based on the mailbox name. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account ID - * @param[in] mailbox_name Specifies the mailbox name - * @param[in] thread_id Specifies the thread id. It can be EMF_LIST_TYPE_THREAD, EMF_LIST_TYPE_NORMAL or thread id. - * @param[in] start_index Specifies start index for LIMIT clause of SQL query. - * @param[in] limit_count Specifies limit count for LIMIT clause of SQL query. - * @param[in] sorting Specifies the sorting type. - * @param[in/out] mail_list Specifies the pointer to the structure emf_mail_data_t. - * @param[in/out] result_count Specifies the number of mails returned. - * @exception none - * @see emf_mail_data_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_mail() - * { - * emf_mail_data_t *mail_list = NULL; - * char mailbox_name[50]; - * int result_count = 0; - * int account_id = 0; - * int err_code = EMF_ERROR_NONE; - * - * memset(mailbox_name, 0x00, 10); - * printf("\n > Enter Mailbox name: "); - * scanf("%s", mailbox_name); - * - * printf("\n > Enter Account_id: "); - * scanf("%d",&account_id); - * - * if (EMF_ERROR_NONE != email_get_mails(account_id, mailbox_name, EMF_LIST_TYPE_NORMAL, 0, 100, EMF_SORT_DATETIME_HIGH, &mail_list, &result_count)) { - * printf("email_get_mails failed \n"); - * } - * else { - * printf("Success\n"); - * //do something - * free(mail_list); - * } - * - * } - * @endcode - * @remarks N/A - */ - -EXPORT_API int email_get_mails(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_data_t** mail_list, int* result_count); - -/** - * @open - * @fn email_get_mail_list_ex(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count) - * @brief Get the Mail List information from DB based on the mailbox name. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account ID - * @param[in] mailbox_name Specifies the mailbox name - * @param[in] thread_id Specifies the thread id. It can be EMF_LIST_TYPE_THREAD, EMF_LIST_TYPE_NORMAL or thread id. - * @param[in] start_index Specifies start index for LIMIT clause of SQL query. - * @param[in] limit_count Specifies limit count for LIMIT clause of SQL query. - * @param[in] sorting Specifies the sorting type. - * @param[in/out] mail_list Specifies the pointer to the structure emf_mail_list_item_t. - * @param[in/out] result_count Specifies the number of mails returned. - * @exception none - * @see emf_mail_list_item_t - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_mail() - * { - * emf_mail_list_item_t *mail_list = NULL; - * char mailbox_name[50]; - * int result_count = 0; - * int account_id = 0; - * int err_code = EMF_ERROR_NONE; - * - * memset(mailbox_name, 0x00, 10); - * printf("\n > Enter Mailbox name: "); - * scanf("%s", mailbox_name); - * - * printf("\n > Enter Account_id: "); - * scanf("%d",&account_id); - * - * if (EMF_ERROR_NONE != email_get_mail_list_ex(account_id, mailbox_name, EMF_LIST_TYPE_NORMAL, 0, 100, EMF_SORT_DATETIME_HIGH, &mail_list, &result_count)) - * { - * printf("email_get_mail_list failed \n"); - * } - * else - * { - * printf("Success\n"); - * //do something - * free(mail_list); - * } - * - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_mail_list_ex(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count); - -/** - * @open - * @fn email_find_mail(int account_id , const char *mailbox_name, int thread_id, - int search_type, char *search_value, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count) - * @brief Get the Searched Mail List information from the DB based on the mailbox name account_id, type and value of searching. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the Account ID - * @param[in] mailbox_name Specifies the Mailbox Name - * @param[in] thread_id Specifies the thread_id. If thread_id = EMF_LIST_TYPE_NORMAL, search a mail without regarding thread. The case of thread_id > 0 is for getting mail list of specific thread. - * @param[in] search_type Specifies the searching type(EMF_SEARCH_FILTER_SUBJECT, EMF_SEARCH_FILTER_SENDER, EMF_SEARCH_FILTER_RECIPIENT, EMF_SEARCH_FILTER_ALL) - * @param[in] search_value Specifies the value to use for searching. (ex : Subject, email address, display name) - * @param[in] start_index Specifies the first mail index of searched mail. This function will return mails whose index in the result list are from start_index to start_index + limit_count. The first start index is 0. - * @param[in] limit_count Specifies the max number of returned mails. - * @param[in] sorting Specifies the sorting order. see emf_sort_type_t - * @param[in/out] mail_list Specifies the Pointer to the structure emf_mail_list_item_t. - * @param[in/out] result_count Specifies the Number of searched Mails - * @exception none - * @see emf_sort_type_t, emf_mail_list_item_t - * @code - * @endcode - * @remarks N/A - */ -EXPORT_API int email_find_mail(int account_id , const char *mailbox_name, int thread_id, - int search_type, char *search_value, - int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count); - -/** - * @open - * @fn email_get_mail_by_address(int account_id , const char *mailbox_name, emf_email_address_list_t* addr_list, - int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count) - * @brief Get the Mail List information from the DB based on the mailbox name account_id and sender address. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the Account ID - * @param[in] mailbox_name Specifies the Mailbox Name - * @param[in] addr_list Specifies the addresses of senders. see emf_email_address_list_t - * @param[in] start_index Specifies the first mail index of searched mail. This function will return mails whose index in the result list are from start_index to start_index + limit_count - * @param[in] limit_count Specifies the max number of returned mails. - * @param[in] search_type Specifies the search type. - * @param[in] search_value Specifies the search value. - * @param[in] sorting Specifies the sorting order. see emf_sort_type_t - * @param[in/out] mail_list Specifies the Pointer to the structure emf_mail_list_item_t. - * @param[in/out] result_count Specifies the Number of searched Mails - * @exception none - * @see emf_email_address_list_t, emf_sort_type_t, emf_mail_list_item_t - * @code - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_mail_by_address(int account_id , const char *mailbox_name, emf_email_address_list_t* addr_list, - int start_index, int limit_count, int search_type, const char *search_value, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count); - -/** - * @open - * @fn email_get_thread_information_by_thread_id(int thread_id, emf_mail_data_t** thread_info) - * @brief Get the thread information for specific thread from DB based on the mailbox name. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] thread_id Specifies the thread_id - * @param[in/out] thread_info Specifies the Pointer to the structure emf_mail_data_t. - * @exception none - * @see emf_mail_data_t - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_thread_information() - * { - * emf_mail_data_t *thread_info = NULL; - * int thread_id = 0; - * int err_code = EMF_ERROR_NONE; - * - * printf("\n > Enter thread_id: "); - * scanf("%d",&thread_id); - * - * if ( EMF_ERROR_NONE != email_get_thread_information_by_thread_id(thread_id, &thread_info)) - * { - * printf("email_get_thread_information_by_thread_id failed :\n"); * - * } - * else - * { - * printf("Success\n"); - * //do something - * } - * - * } - * @endcode - * @remarks N/A - */ - - -EXPORT_API int email_get_thread_information_by_thread_id(int thread_id, emf_mail_data_t** thread_info); - -/** - * @open - * @fn email_get_thread_information_ex(int thread_id, emf_mail_list_item_t** thread_info) - * @brief Get the Mail List information for specific thread from DB based on the mailbox name. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] thread_id Specifies the thread_id - * @param[in/out] thread_info Specifies the Pointer to the structure emf_mail_list_item_t. - * @exception none - * @see emf_mail_list_item_t - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_thread_information_ex() - * { - * emf_mail_list_item_t *thread_info = NULL; - * int thread_id = 0; - * int err_code = EMF_ERROR_NONE; - * - * printf("\n > Enter thread_id: "); - * scanf("%d",&thread_id); - * - * if ( EMF_ERROR_NONE != email_get_thread_information_ex(thread_id, &thread_info)) - * { - * printf("email_get_mail_list_of_thread failed :\n"); * - * } - * else - * { - * printf("Success\n"); - * //do something - * } - * - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_thread_information_ex(int thread_id, emf_mail_list_item_t** thread_info); - -/** - * @open - * @fn email_get_mail_flag(int account_id, int mail_id, emf_mail_flag_t* mail_flag) - * @brief Get the Mail Flag information based on the account id and Mail Id. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the Account ID - * @param[in] mail_id Specifies the Mail id for which Flag details need to be fetched - * @param[in/out] mail_flag Specifies the Pointer to the structure emf_mail_flag_t. - * @exception none - * @see emf_mail_flag_t - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_mail_flag() - * { - * emf_mail_flag_t *mail_flag = NULL; - * int account_id = 0; - * int mail_id = 0; - * int err_code = EMF_ERROR_NONE; - * - * printf("\n > Enter account_id: "); - * scanf("%d",&account_id); - * printf("\n > Enter mail_id: "); - * scanf("%d",&mail_id); - * - * if ( EMF_ERROR_NONE != email_get_mail_flag(account_id,mail_id, &mail_flag)) - * { - * printf("email_get_mail_flag failed :\n"); - * } - * else - * { - * printf("Success\n"); - * //do something - * } - * - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_mail_flag(int account_id, int mail_id, emf_mail_flag_t* mail_flag); - -/** - * @open - * @fn email_retry_send_mail( int mail_id, int timeout_in_sec) - * @brief Retry mail send - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mail_id Specifies the mail id for the mail to resend - * @param[in] timeout_in_sec Specifies the timeout value in seconds - * @exception none - * @see none - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_retry_send_mail() - * { - * int mail_id = 1; - * int timeout_in_sec = 2; - * - * if(EMF_ERROR_NONE == email_retry_send_mail(mail_id,timeout_in_sec)) - * //success - * else - * //failure - * - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_retry_send_mail( int mail_id, int timeout_in_sec); - - -/** - * @open - * @fn email_create_db_full() - * @brief Create DB full - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @exception none - * @see none - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_create_db_full() - * { - * - * if(EMF_ERROR_NONE == email_create_db_full()) - * //success - * else - * //failure - * - * } - * @endcode - * @remarks N/A - */ - -EXPORT_API int email_create_db_full(); - -/** - * @open - * @fn email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name) - * @brief get mailBox naem by mailID - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mail_id Specifies the mailID - * @param[out] pMailbox_name Specifies the mailbox name - * @exception none - * @see none - - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_mailbox_name_by_mail_id() - * { - * char *mailbox_name =NULL; - * int mail_id = 10; - * - * - * if(EMF_ERROR_NONE == email_get_mailbox_name_by_mail_id(mail_id,&mailbox_name)) - * //success - * else - * //failure - * - * } - * @endcode - * @remarks N/A - */ - -EXPORT_API int email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name); - -/** - * @open - * @fn email_cancel_send_mail( int mail_id) - * @brief Callback function for cm popup. We set the status as EMF_MAIL_STATUS_SEND_CANCELED - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mail_id Specifies the mailID - * @exception none - * @see none - * @code - * #include "email-api-account.h" - * bool - * _api_sample_cancel_send_mail() - * { - * int mail_id = 10; - * - * - * if(EMF_ERROR_NONE == email_cancel_send_mail(mail_id,)) - * //success - * else - * //failure - * - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_cancel_send_mail( int mail_id) ; - - -/** - * @open - * @fn email_count_message_all_mailboxes(emf_mailbox_t* mailbox, int* total, int* unseen) - * @brief Get the Total count and Unread count of all mailboxes - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Specifies the mailbox structure - * @param[out] total Specifies the total count - * @param[out] seen Specifies the unseen mail count - * @exception none - * @see emf_mailbox_t - * @code - * #include "email-api-account.h" - * bool - * _api_sample_count_message_all_mailboxes() - * { - * emf_mailbox_t mailbox; - * int total =0; - * int unseen = 0; - * - * memset(&mailbox,0x00,sizeof(emf_mailbox_t)); - * mailbox.account_id = 0; - * mailbox.name = strdup("INBOX"); - * - * if(EMF_ERROR_NONE == email_count_message_all_mailboxes(&mailbox,&total,&unseen)) - * //success - * else - * //failure - * - * } - * @endcode - * @remarks N/A - */ - -EXPORT_API int email_count_message_all_mailboxes(emf_mailbox_t* mailbox, int* total, int* unseen); - - -/* sowmya.kr@samsung.com, 01282010 - Changes to get latest unread mail id for given account */ -/** - * @open - * @fn email_get_latest_unread_mail_id(int account_id, int *pMailID) - * @brief Gets the latest unread MailId for given account. If account_id passed is -1, returns latest unread mail Id. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account id for which latest unread mail has to be fetched - * @param[out] pMailID Specifies the latest unread mail - * @exception none - * @see none - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_latest_unread_mail_id() - * { - * int mail_id = 0,account_id = 0; - * int err = EMF_ERROR_NONE; - * - * - * printf("Enter account Id to get latest unread mail Id,<-1 to get latest irrespective of account id> "); - * scanf("%d", &account_id); - * - * - * if ( EMF_ERROR_NONE != email_get_latest_unread_mail_id(account_id, &mail_id) ) - * { - * printf(" fail email_get_latest_unread_mail_id: err[%d]\n", err); - * } - * else - * { - * printf(" success email_get_latest_unread_mail_id: Latest unread mail id : %d\n", mail_id); - * } - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_latest_unread_mail_id(int account_id, int *pMailID); - -/** - * @open - * @fn email_get_max_mail_count(int *Count) - * @brief Gets the max count of mails which can be supported by email-service - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[out] Count max count of mails which can be supported by email-service - * @exception none - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_max_mail_count() - * { - * int max_count = -1; - * - * if(EMF_ERROR_NONE == email_get_max_mail_count(&max_count)) - * printf("\n\t>>>>> email_get_max_mail_count() return [%d]\n\n", max_count); - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_max_mail_count(int *Count); - - - /** - * @open - * @fn email_get_disk_space_usage(unsigned long *total_size) - * @brief Gets the total disk usage of emails in KB. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[out] total_size total disk usage of emails - * @exception none - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_disk_space_usage() - * { - * unsigned long total_size = 0; - * - * if ( EMF_ERROR_NONE != email_get_disk_space_usage(&total_size)) - * printf("email_get_disk_space_usage failed err : %d\n",err_code); - * else - * printf("email_get_disk_space_usage SUCCESS, total disk usage in KB : %ld \n", total_size); - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_disk_space_usage(unsigned long *total_size); - - -EXPORT_API int email_get_recipients_list(int account_id, const char *mailbox_name, emf_sender_list_t **sender_list); -/** - * @open - * @fn email_get_sender_list(int account_id, const char *mailbox_name, int search_type, char *search_value, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count) - * @brief Get the sender list with the total number of sender's mails and the number of sender's unread mails. - * This is used to show email address and display name of each sender with the number of mails (unread and total). - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account id to get the list. If this is 0, a sender list of "All Account" will be returned. - * @param[in] mailbox_name Specifies the mailbox name to get the list. If this is NULL, a sender list of "All Mailbox" will be returned. - * @param[in] search_type Specifies the search type - * @param[in] search_value Specifies the search value - * @param[in] sorting Specifies the sorting order. - * @param[out] sender_list Specifies the Pointer to the structure emf_sender_list_t. Memory for a new sender list will be allocated to this. Call email_free_sender_list() to free the memory allocated to this. - * @param[out] sender_count Specifies the number of senders in a sender list. - * @exception none - * @see emf_sort_type_t, emf_sender_list_t, email_free_sender_list() - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_sender_list() - * { - * emf_sender_list_t *sender_list = NULL; - * int sender_count = 0; - * int account_id = 0; - * int sorting = 0; - * int err_code = EMF_ERROR_NONE; - * - * account_id = 0; // For All accounts - * mailbox_name = NULL; // For All mail boxes - * sorting = EMF_SORT_DATETIME_HIGH; - * - * - * if ( EMF_ERROR_NONE != (err_code = email_get_sender_list(account_id, mailbox_name, EMF_SEARCH_FILTER_NONE, NULL, sorting, &sender_list, &sender_count)) ) - * { - * printf("email_get_sender_list failed :\n"); * - * return false; - * } - * else - * { - * printf("Success\n"); - * //do something - * } - * - * // Free sender list - * if ( sender_list ) - * { - * email_free_sender_list(&sender_list, sender_count); - * } - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_sender_list(int account_id, const char *mailbox_name, int search_type, const char *search_value, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count); - -/** - * @open - * @fn email_get_sender_list_ex(int account_id, const char *mailbox_name, int start_index, int limit_count, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count) - * @brief Get the sender list with the total number of sender's mails and the number of sender's unread mails. - * This is used to show email address and display name of each sender with the number of mails (unread and total). - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account id to get the list. If this is 0, a sender list of "All Account" will be returned. - * @param[in] mailbox_name Specifies the mailbox name to get the list. If this is NULL, a sender list of "All Mailbox" will be returned. - * @param[in] start_index Specifies the start index in the sender list. This function will return a partial sender list from start_index to (start_index + limit_count - 1) in the sender list. negative value means "from the first sender". start_index is zero-based value. - * @param[in] limit_count Specifies the max number of sender list. negative value means "All senders from the start_index in sender list" - * @param[in] sorting Specifies the sorting order. - * @param[out] sender_list Specifies the Pointer to the structure emf_sender_list_t. Memory for a new sender list will be allocated to this. Call email_free_sender_list() to free the memory allocated to this. - * @param[out] sender_count Specifies the number of senders in a sender list. - * @exception none - * @see emf_sort_type_t, emf_sender_list_t, email_free_sender_list() - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_sender_list() - * { - * emf_sender_list_t *sender_list = NULL; - * int sender_count = 0; - * int account_id = 0; - * int start_index = 10; // from the 11th sender in sender list - * int limit_count = 5; // to the (11 + 5)th sender in sender list - * int sorting = 0; - * int err_code = EMF_ERROR_NONE; - * - * account_id = 0; // For All accounts - * mailbox_name = NULL; // For All mail boxes - * sorting = EMF_SORT_DATETIME_HIGH; - * - * - * if ( EMF_ERROR_NONE != (err_code = email_get_sender_list_ex(account_id, mailbox_name, start_index, limit_count, sorting, &sender_list, &sender_count)) ) - * { - * printf("email_get_sender_list_ex failed :\n"); * - * return false; - * } - * else - * { - * printf("Success\n"); - * //do something - * } - * - * // Free sender list - * if ( sender_list ) - * { - * email_free_sender_list(&sender_list, sender_count); - * } - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_sender_list_ex(int account_id, const char *mailbox_name, int start_index, int limit_count, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count); - - -/** - * @open - * @fn email_free_sender_list(emf_sender_list_t **sender_list, int count) - * @brief Free the sender list allocated by email_get_sender_list(). This function will free the memory which is allocated to sender_list itself. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] sender_list Specifies the Pointer to the structure emf_sender_list_t to be freed. - * @param[in] count Specifies the number of senders in a sender list. - * @exception none - * @see emf_sender_list_t, email_get_sender_list() - */ -EXPORT_API int email_free_sender_list(emf_sender_list_t **sender_list, int count); - - -/** - * @open - * @fn email_get_address_info_list(int mail_id, emf_address_info_list_t** address_info_list) - * @brief Get the address info list. The address info list contains from, to, cc, bcc addresses and their display name, contact id and etc. (see emf_address_info_list_t) - * Each GList (from, to, cc, bcc) is the list of emf_address_info_t data. - * "data" variable of GList structure contains emf_address_info_t data.
- * To get emf_address_info_t data from GList, Use type casting from GList node. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mail_id Specifies the mail id to get the list. - * @param[out] address_info_list Specifies the Pointer to the structure emf_address_info_list_t. Memory for a new address info list will be allocated to this. Call email_free_address_info_list() to free the memory allocated to this. - * @exception none - * @see emf_address_info_list_t, emf_address_info_t, email_free_address_info_list() - * @code - * #include "email-api-account.h" - * bool - * _api_sample_get_address_info_list() - * { - * emf_address_info_list_t *p_address_info_list= NULL; - * emf_address_info_t *p_address_info = NULL; - * int mai_id; - * int err_code = EMF_ERROR_NONE; - * - * mail_id = 1; - * - * if ( EMF_ERROR_NONE != (err_code = email_get_address_info_list(mail_id, &p_address_info_list)) ) - * { - * printf("email_get_address_info_list failed :\n"); * - * return false; - * } - * else - * { - * printf("Success\n"); - * //do something with p_address_info_list - * GList *list = p_address_info_list->from; - * GList *node = g_list_first(list); - * while ( node != NULL ) - * { - * p_address_info = (emf_address_info_t*)node->data; - * printf("%d, %s, %s, %d\n", p_address_info->address_type, p_address_info->address, p_address_info->display_name, p_address_info->contact_id); - * - * node = g_list_next(node); - * } - * } - * - * // Free sender list - * if ( p_address_info_list ) - * { - * email_free_address_info_list(&p_address_info_list); - * } - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_address_info_list(int mail_id, emf_address_info_list_t** address_info_list); - -/** - * @open - * @fn email_free_address_info_list(emf_address_info_list_t **address_info_list) - * @brief Free the address info list allocated by email_get_address_info_list(). This function will free the memory which is allocated to address_info_list itself. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] address_info_list Specifies the Pointer to the structure emf_address_info_list_t to be freed. - * @exception none - * @see emf_address_info_list_t, email_get_address_info_list() - */ -EXPORT_API int email_free_address_info_list(emf_address_info_list_t **address_info_list); - -/** - * @open - * @fn email_get_structure(const char*encoded_string, void **struct_var, emf_convert_struct_type_e type) - * @brief This function returns the structure of the type which is indicated by 'type' variable. This function will allocate new memory to 'struct_var' for structure.
- * Some notifications such as NOTI_DOWNLOAD_NEW_MAIL are published with string parameter. The string contains various values that might be divided by delimiter.
- * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] encoded_string Specifies the Pointer to the string from notification. - * @param[out] struct_var Specifies the Pointer to the structure to be returned. If success, new memory for structure will be allocated. - * @param[in] type Specifies the converting type. see emf_convert_struct_type_e - * @exception none - * @see emf_convert_struct_type_e - */ -EXPORT_API int email_get_structure(const char*encoded_string, void **struct_var, emf_convert_struct_type_e type); - -/** - * @open - * @fn email_get_meeting_request(int mail_id, emf_meeting_request_t **meeting_req) - * @brief Get the information of meeting request. The information of meeting request is based on Mail Id.
- * The information of meeting request is corresponding to only one mail. - * For this reason, the information of meeting request can be added by using email_add_message_with_meeting_request() with a matched mail information. - * - * @return This function returns EMF_ERROR_NONE on success. This function returns EMF_ERROR_DATA_NOT_FOUND if there isn't a matched mail. Otherwise it returns error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mail_id Specifies the Mail id for which meeting request details need to be fetched - * @param[in/out] meeting_req Specifies the Pointer to the structure emf_meeting_request_t. - * @exception none - * @see emf_meeting_request_t - */ -EXPORT_API int email_get_meeting_request(int mail_id, emf_meeting_request_t **meeting_req); - - -/** - * @open - * @fn email_free_meeting_request(emf_meeting_request_t** meeting_req, int count) - * @brief Free the meeting request allocated by email_get_meeting_request() or alloacted to add. This function will free the memory which is allocated to meeting_req (= *meeting_req) itself. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] emf_meeting_request_t Specifies the Pointer to the structure emf_meeting_request_t to be freed. - * @param[in] count Specifies the number of elements in meeting_req array. this is usually 1. - * @exception none - * @see emf_meeting_request_t, email_get_meeting_request() - */ -EXPORT_API int email_free_meeting_request(emf_meeting_request_t** meeting_req, int count); - -EXPORT_API int email_move_thread_to_mailbox(int thread_id, char *target_mailbox_name, int move_always_flag); - -EXPORT_API int email_delete_thread(int thread_id, int delete_always_flag); - -EXPORT_API int email_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -/** -* @} @} -*/ - - -#endif /* __EMAIL_API_MESSAGE_H__ */ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +#ifndef __EMAIL_API_MAIL_H__ +#define __EMAIL_API_MAIL_H__ + +#include "email-types.h" + +#include + +#include +#include +#include + +/** +* @defgroup EMAIL_SERVICE Email Service +* @{ +*/ + + +/** +* @ingroup EMAIL_SERVICE +* @defgroup EMAIL_API_MAIL Email Mail API +* @{ +*/ + +/** + * + * This file contains the data structures and interfaces needed for application, + * to interact with email-service. + * @file email-api-mail.h + * @author Kyuho Jo + * @author Sunghyun Kwon + * @version 0.1 + * @brief This file contains the data structures and interfaces of Messages provided by + * email-service . + */ + + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @open + * @fn 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) + * @brief Save a mail. This function is invoked when user wants to add a mail. + * If the option from_eas is 1 then this will save the message on server as well as on locally. + * If the incoming_server_type is EMAIL_SERVER_TYPE_POP3 then from_eas value will be 0 + * If the incoming_server_type is EMAIL_SERVER_TYPE_IMAP4 then from_eas value will be 1/0 + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_mail_data Specifies the saving mail. + * @param[in] input_attachment_data_list Specifies the mailbox structure for saving email. + * @param[in] input_attachment_count Specifies if the mail comes from composer. + * @param[in] input_meeting_request Specifies if the mail comes from composer. + * @param[in] input_from_eas Specifies if the mail will be saved on server. + + * @exception none + * @see email_mail_data_t and email_mailbox_t + * @remarks N/A + * @code + * #include "email-api-mail.h" + * int _test_add_mail () + * { + * int i = 0; + * int account_id = 0; + * int from_eas = 0; + * int attachment_count = 0; + * int err = EMAIL_ERROR_NONE; + * char arg[50] = { 0 , }; + * char *body_file_path = "/opt/data/email/.emfdata/tmp/mail.txt"; + * email_mailbox_t *mailbox_data = NULL; + * email_mail_data_t *test_mail_data = NULL; + * email_attachment_data_t *attachment_data = NULL; + * email_meeting_request_t *meeting_req = NULL; + * FILE *body_file; + * + * printf("\n > Enter account id : "); + * scanf("%d", &account_id); + * + * + * memset(arg, 0x00, 50); + * printf("\n > Enter mailbox name : "); + * scanf("%s", arg); + * + * email_get_mailbox_by_name(account_id, arg, &mailbox_data); + * + * test_mail_data = malloc(sizeof(email_mail_data_t)); + * memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); + * + * printf("\n From EAS? [0/1]> "); + * scanf("%d", &from_eas); + * + * test_mail_data->account_id = account_id; + * test_mail_data->save_status = 1; + * test_mail_data->flags_seen_field = 1; + * test_mail_data->file_path_plain = strdup(body_file_path); + * test_mail_data->mailbox_id = mailbox_data->mailbox_id; + * test_mail_data->mailbox_type = mailbox_data->mailbox_type; + * test_mail_data->full_address_from = strdup(""); + * test_mail_data->full_address_to = strdup(""); + * test_mail_data->full_address_cc = strdup(""); + * test_mail_data->full_address_bcc = strdup(""); + * test_mail_data->subject = strdup("Meeting request mail"); + * + * body_file = fopen(body_file_path, "w"); + * + * for(i = 0; i < 500; i++) + * fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2"); + * fflush(body_file); + * fclose(body_file); + * + * printf(" > Attach file? [0/1] : "); + * scanf("%d",&attachment_count); + * + * if ( attachment_count ) { + * memset(arg, 0x00, 50); + * printf("\n > Enter attachment name : "); + * scanf("%s", arg); + * + * attachment_data = malloc(sizeof(email_attachment_data_t)); + * + * attachment_data->attachment_name = strdup(arg); + * + * memset(arg, 0x00, 50); + * printf("\n > Enter attachment absolute path : "); + * scanf("%s",arg); + * + * attachment_data->attachment_path = strdup(arg); + * attachment_data->save_status = 1; + * test_mail_data->attachment_count = attachment_count; + * } + * + * printf("\n > Meeting Request? [0: no, 1: yes (request from server), 2: yes (response from local)]"); + * scanf("%d", &(test_mail_data->meeting_request_status)); + * + * if ( test_mail_data->meeting_request_status == 1 + * || test_mail_data->meeting_request_status == 2 ) { + * time_t current_time; + * meeting_req = malloc(sizeof(email_meeting_request_t)); + * memset(meeting_req, 0x00, sizeof(email_meeting_request_t)); + * + * meeting_req->meeting_response = 1; + * current_time = time(NULL); + * gmtime_r(¤t_time, &(meeting_req->start_time)); + * gmtime_r(¤t_time, &(meeting_req->end_time)); + * meeting_req->location = malloc(strlen("Seoul") + 1); + * memset(meeting_req->location, 0x00, strlen("Seoul") + 1); + * strcpy(meeting_req->location, "Seoul"); + * strcpy(meeting_req->global_object_id, "abcdef12345"); + * + * meeting_req->time_zone.offset_from_GMT = 9; + * strcpy(meeting_req->time_zone.standard_name, "STANDARD_NAME"); + * gmtime_r(¤t_time, &(meeting_req->time_zone.standard_time_start_date)); + * meeting_req->time_zone.standard_bias = 3; + * + * strcpy(meeting_req->time_zone.daylight_name, "DAYLIGHT_NAME"); + * gmtime_r(¤t_time, &(meeting_req->time_zone.daylight_time_start_date)); + * meeting_req->time_zone.daylight_bias = 7; + * + * } + * + * if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE) + * printf("email_add_mail failed. [%d]\n", err); + * else + * printf("email_add_mail success.\n"); + * + * if(attachment_data) + * email_free_attachment_data(&attachment_data, attachment_count); + * + * if(meeting_req) + * email_free_meeting_request(&meeting_req, 1); + * + * email_free_mail_data(&test_mail_data, 1); + * email_free_mailbox(&mailbox_data, 1); + * + * printf("saved mail id = [%d]\n", test_mail_data->mail_id); + * + * return 0; + * } + * @endcode + */ +EXPORT_API 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); + + /** + * @open + * @fn email_add_read_receipt(int input_read_mail_id, unsigned *output_handle) + * @brief Add a read receipt mail. This function is invoked when user receives a mail with read report enable and wants to send a read report for the same. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_read_mail_id Specifies the id of mail which has been read. + * @param[out] output_receipt_mail_id Specifies the receipt mail id . + * @exception none + * @see + * @remarks N/A + */ +EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receipt_mail_id); + +/** + * @open + * @fn 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_composer) + * @brief Update a existing email information. This function is invoked when user wants to change some existing email information with new email information. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_mail_data Specifies the mail ID. + * @param[in] input_attachment_data_list Specifies the pointer of attachment data. + * @param[in] input_attachment_count Specifies the number of attachment data. + * @param[in] input_meeting_request Specifies the meeting request data. + * @param[in] input_from_eas Specifies whether sync server. + + * @exception none + * @see email_mail_data_t + * @code + * #include "email-api-account.h" + * int email_test_update_mail() + * { + * int mail_id = 0; + * int err = EMAIL_ERROR_NONE; + * int test_attachment_data_count = 0; + * char arg[50]; + * email_mail_data_t *test_mail_data = NULL; + * email_attachment_data_t *test_attachment_data_list = NULL; + * email_meeting_request_t *meeting_req = NULL; + * + * printf("\n > Enter mail id : "); + * scanf("%d", &mail_id); + * + * email_get_mail_data(mail_id, &test_mail_data); + * + * printf("\n > Enter Subject: "); + * scanf("%s", arg); + * + * test_mail_data->subject= strdup(arg); + * + * + * + * if (test_mail_data->attachment_count > 0) { + * if ( (err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMAIL_ERROR_NONE ) { + * printf("email_get_meeting_request() failed [%d]\n", err); + * return -1; + * } + * } + * + * if ( test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST + * || test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE + * || test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { + * + * if ( (err = email_get_meeting_request(mail_id, &meeting_req)) != EMAIL_ERROR_NONE ) { + * printf("email_get_meeting_request() failed [%d]\n", err); + * return -1; + * } + * + * printf("\n > Enter meeting response: "); + * scanf("%d", (int*)&(meeting_req->meeting_response)); + * } + * + * if ( (err = email_update_mail(test_mail_data, test_attachment_data_list, test_attachment_data_count, meeting_req, 0)) != EMAIL_ERROR_NONE) + * printf("email_update_mail failed.[%d]\n", err); + * else + * printf("email_update_mail success\n"); + * + * if(test_mail_data) + * email_free_mail_data(&test_mail_data, 1); + * + * if(test_attachment_data_list) + * email_free_attachment_data(&test_attachment_data_list, test_attachment_data_count); + * + * if(meeting_req) + * email_free_meeting_request(&meeting_req, 1); + * + * return 0; + * } + + * @endcode + * @remarks N/A + */ +EXPORT_API 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); + +/** + * @open + * @fn email_count_mail(email_mailbox_t* mailbox, int* total, int* unseen) + * @brief Get mail count from mailbox.This function is invoked when user wants to know how many toatl mails and out of that + * how many unseen mails are there in a given mailbox. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mailbox Specifies the pointer of mailbox structure. + * @param[out] total Total email count is saved here. + * @param[out] unseen Unread email count is saved here. + * @exception none + * @see email_mailbox_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_count_mail() + * { + * int total = 0; + * int unseen = 0; + * email_list_filter_t *filter_list = NULL; + * int err = EMAIL_ERROR_NONE; + * int i = 0; + * 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_SUBJECT; + * filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + * filter_list[0].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + * filter_list[0].list_filter_item.rule.case_sensitivity = false; + * + * filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + * filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + * + * filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + * filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_TO; + * filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + * filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + * filter_list[2].list_filter_item.rule.case_sensitivity = false; + * + * if(EMAIL_ERROR_NONE == email_count_mail(filter_list, 3, &total, &unseen)) + * printf("\n Total: %d, Unseen: %d \n", total, unseen); + * } + * @endcode + * @remarks N/A + */ +EXPORT_API 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); + +/** + * @open + * @fn email_get_max_mail_count(int *Count) + * @brief Gets the max count of mails which can be supported by email-service + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[out] Count max count of mails which can be supported by email-service + * @exception none + * @code + * #include "email-api-account.h" + * bool + * _api_sample_get_max_mail_count() + * { + * int max_count = -1; + * + * if(EMAIL_ERROR_NONE == email_get_max_mail_count(&max_count)) + * printf("\n\t>>>>> email_get_max_mail_count() return [%d]\n\n", max_count); + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_get_max_mail_count(int *count); + +/** + * @open + * @fn email_delete_mail(email_mailbox_t* mailbox, int *mail_ids, int num, int from_server) + * @brief Delete a mail or multiple mails.Based on from_server value this function will delte a mail or multiple mails from server or loaclly. + * @param[in] mailbox Reserved. + * If the incoming_server_type is EMAIL_SERVER_TYPE_POP3 then from_server value will be 0 + * If the incoming_server_type is EMAIL_SERVER_TYPE_IMAP4 then from_server value will be 1/0 + * + * @param[in] mail_ids[] 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. + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @exception none + * @see email_mailbox_t + * @code + * #include "email-api-account.h" + * bool + * _api_sample_delete_mail() + * { + * int count, i, mail_id=0, mailbox_id =0; + * + * printf("\n > Enter Mail_id: "); + * scanf("%d",&mail_id); + * printf("\n > Enter Mailbox ID: "); + * scanf("%d",&mailbox_id); + * if(EMAIL_ERROR_NONE == email_delete_mail(mailbox_id, &mail_id, 1, 1)) + * printf("\n email_delete_mail success"); + * else + * printf("\n email_delete_mail failed"); + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_delete_mail(int input_mailbox_id, int *input_mail_ids, int input_num, int input_from_server); + + +/** + * @open + * @fn email_delete_all_mails_in_mailbox(int input_mailbox_id, int input_from_server) + * @brief Delete all mail from a mailbox. + * If the incoming_server_type is EMAIL_SERVER_TYPE_POP3 then from_server value will be 0 + * If the incoming_server_type is EMAIL_SERVER_TYPE_IMAP4 then from_server value will be 1/0 + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mailbox Specifies the structure of mailbox. + * @param[in] from_server Specifies whether mails are also deleted from server. + * @exception none + * @see email_mailbox_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_delete_all_mails_in_mailbox() + * { + * int count, mailbox_id =0; + * + * printf("\n > Enter mailbox_id: "); + * scanf("%d",&mailbox_id); + * + * if (EMAIL_ERROR_NONE != email_delete_all_mails_in_mailbox(mailbox_id, 0)) + * printf("email_delete_all_mails_in_mailbox failed"); + * else + * printf("email_delete_all_mails_in_mailbox Success"); + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_delete_all_mails_in_mailbox(int input_mailbox_id, int input_from_server); + +/** + * @open + * @fn email_clear_mail_data() + * @brief delete email data from storage. This API will be used by the Settings Application + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @exception none + * @see none + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_clear_mail_data() + * { + * if(EMAIL_ERROR_NONE == email_clear_mail_data()) + * //success + * else + * //failure + * + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_clear_mail_data(); + + +/** + * @open + * @fn email_add_attachment(int mail_id, email_attachment_data_t* attachment) + * @brief Append a attachment to email.This function is invoked when user wants to add attachment to existing mail. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_id Specifies the mail ID. + * @param[in] attachment Specifies the structure of attachment. + * @exception none + * @see email_attachment_data_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_mail_add_attachment() + * { + * int mail_id = 0; + * email_attachment_data_t attachment; + * + * printf("\n > Enter Mail Id: "); + * scanf("%d", &mail_id); + * memset(&attachment, 0x00, sizeof(email_attachment_data_t)); + * printf("\n > Enter attachment name: "); + * attachment.name = strdup("Test"); + * printf("\n > Enter attachment absolute path: "); + * attachment.savename = strdup("/tmp/test.txt"); + * attachment.next = NULL; + * if(EMAIL_ERROR_NONE != email_add_attachment(mail_id, &attachment)) + * printf("email_add_attachment failed\n"); + * else + * printf(email_add_attachment success\n"); + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_add_attachment(int mail_id, email_attachment_data_t* attachment); + + +/** + * @open + * @fn email_delete_attachment(int mail_id, const char * attachment_id) + * @brief delete a attachment from email.This function is invoked when user wants to delete a attachment from existing mailbased on mail Id and attachment Id + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_id Specifies the mail ID. + * @param[in] attachment_id Specifies the attachment id. + * @exception none + * @see email_mailbox_t + * @code + * #include "email-api-account.h" + * bool + * _api_sample_mail_delete_attachment() + * { + * + * if(EMAIL_ERROR_NONE != email_delete_attachment(1)) + * //failure + * else + * //success + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_delete_attachment(int attachment_id); + +/** + * @open + * @fn email_get_attachment_data(int mail_id, const char* attachment_id, email_attachment_data_t** attachment) + * @brief Get a mail attachment.This function is invoked when user wants to get the attachment information based on attachment id for the specified mail Id. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_id Specifies the mail ID. + * @param[in] attachment_id Specifies the buffer that a attachment ID been saved. + * @param[out] attachment The returned attachment is save here. + * @exception none + * @see email_mailbox_t and email_mail_attachment_info_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_mail_get_attachment_info() + * { + * email_mail_attachment_info_t *mail_attach_info = NULL; + * int mail_id = 0; + * char arg[10]; + * int err = EMAIL_ERROR_NONE; + * + * + * printf("\n > Enter Mail Id: "); + * scanf("%d", &mail_id); + * printf("> attachment Id\n"); + * scanf("%s",arg); + * if (EMAIL_ERROR_NONE != email_get_attachment_data(mail_id, &mail_attach_info)) + * printf("email_get_attachment_data failed\n"); + * else + * { + * printf("email_get_attachment_data SUCCESS\n"); + * //do something + * email_free_attachment_data(&mail_attach_info,1); + * } + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_get_attachment_data(int attachment_id, email_attachment_data_t** attachment); + +EXPORT_API int email_get_attachment_data_list(int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count); + +/** + * @open + * @fn email_free_attachment_data(email_attachment_data_t **attachment_data_list, int attachment_data_count) + * @brief Free allocated memroy for email attachment. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] atch_info Specifies the pointer of mail attachment structure pointer. + * @exception none + * @see email_mail_attachment_info_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_mail_free_attachment_info() + * { + * email_mailbox_t mailbox; + * email_mail_attachment_info_t *mail_attach_info = NULL; + * int mail_id = 0,account_id = 0; + * char arg[10]; + * int err = EMAIL_ERROR_NONE; + * + * memset(&mailbox, 0x00, sizeof(email_mailbox_t)); + * + * printf("\n > Enter Mail Id: "); + * scanf("%d", &mail_id); + * printf("\n > Enter account Id: "); + * scanf("%d", &account_id); + * printf("> attachment Id\n"); + * scanf("%s",arg); + * mailbox.account_id = account_id; + * if (EMAIL_ERROR_NONE != email_get_attachment_data(&mailbox, mail_id, &mail_attach_info)) + * printf("email_get_attachment_data failed\n"); + * else + * { + * printf("email_get_attachment_data SUCCESS\n"); + * //do something + * email_free_attachment_info(&mail_attach_info,1); + * } + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_free_attachment_data(email_attachment_data_t **attachment_data_list, int attachment_data_count); + +/* ----------------------------------------------------------- + Mail Information API + -----------------------------------------------------------*/ + + +/** + * @open + * @fn email_query_mails(char *conditional_clause_string, email_mail_data_t** mail_list, int *result_count) + * @brief Query the mail list information from DB based on the mailbox name. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] conditional_clause_string Specifies the where clause string. + * @param[in/out] mail_list Specifies the pointer to the structure email_mail_data_t. + * @param[in/out] result_count Specifies the number of mails returned. + * @exception None + * @see email_mail_list_item_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_query_mail() + * { + * email_mail_data_t *mail_list = NULL; + * char conditional_clause_string[500]; + * int result_count = 0; + * + * memset(conditional_clause_string, 0x00, 10); + * printf("\n > Enter where clause: "); + * scanf("%s", conditional_clause_string); + * + * + * if (EMAIL_ERROR_NONE != email_query_mails(conditional_clause_string, &mail_list, &result_count)) + * printf("email_query_mails failed \n"); + * else { + * printf("Success\n"); + * //do something + * free(mail_list); + * } + * + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_query_mails(char *conditional_clause_string, email_mail_data_t** mail_list, int *result_count); + +/** + * @open + * @fn email_query_mail_list(char *input_conditional_clause_string, email_mail_list_item_t** output_mail_list, int *output_result_count) + * @brief Query the mail list information from DB. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_conditional_clause_string Specifies the where clause string. + * @param[in/out] output_mail_list Specifies the pointer to the structure email_mail_list_item_t. + * @param[in/out] output_result_count Specifies the number of mails returned. + * @exception None + * @see email_mail_list_item_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_query_mail_list() + * { + * email_mail_list_item_t *mail_list = NULL; + * char conditional_clause_string[500]; + * int result_count = 0; + * + * memset(conditional_clause_string, 0x00, 10); + * printf("\n > Enter where clause: "); + * scanf("%s", conditional_clause_string); + * + * + * if (EMAIL_ERROR_NONE != email_query_mail_list(conditional_clause_string, &mail_list, &result_count)) + * printf("email_query_mail_list failed \n"); + * else { + * printf("Success\n"); + * //do something + * free(mail_list); + * } + * + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_query_mail_list(char *input_conditional_clause_string, email_mail_list_item_t** output_mail_list, int *output_result_count); + +/** + * @open + * @fn email_get_mail_data(int input_mail_id, email_mail_data_t **output_mail_data) + * @brief Get a mail by its mail id. This function is invoked when user wants to get a mail based on mail id existing in DB. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_mail_id specifies the mail id. + * @param[out] output_mail_data The returned mail is save here. + * @exception none + * @see email_mail_data_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_get_mail_data() + * { + * email_mail_data_t *mail = NULL; + * int mail_id = 0 ; + * int err = EMAIL_ERROR_NONE; + * + * printf("\n > Enter mail id: "); + * scanf("%d", &mail_id); + * + * if (EMAIL_ERROR_NONE != email_get_mail_data(mail_id, &mail)) + * printf("email_get_mail_data failed\n"); + * else + * { + * printf("email_get_mail_data SUCCESS\n"); + * //do something + * email_free_mail_data(&mail,1); + * } + * } + * @endcode + * @remarks N/A + */ + +EXPORT_API int email_get_mail_data(int input_mail_id, email_mail_data_t **output_mail_data); + + +/** + * @open + * @fn email_free_mail_data(email_mail_data_t** mail_list, int count) + * @brief Free allocated memroy for emails. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_list Specifies the pointer of mail structure pointer. + * @param[in] count Specifies the count of mails. + * @exception none + * @see email_mail_data_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_free_mail() + * { + * email_mail_data_t *mail; + * + * //fill the mail structure + * //count - number of mail structure user want to free + * if(EMAIL_ERROR_NONE == email_free_mail_data(&mail,count)) + * //success + * else + * //failure + * + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_free_mail_data(email_mail_data_t** mail_list, int count); + +/* ----------------------------------------------------------- + Mail Flag API + -----------------------------------------------------------*/ + +/** + * @open + * @fn email_set_flags_field(int *mail_ids, int num, email_flags_field_type field_type, int value, int onserver) + * @brief Change email flags field. + * If the incoming_server_type is EMAIL_SERVER_TYPE_POP3 then from_server value will be 0 + * If the incoming_server_type is EMAIL_SERVER_TYPE_IMAP4 then from_server value will be 1/0 + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] account_id Specifies account ID. + * @param[in] mail_ids Specifies the array of mail ID. + * @param[in] num Specifies the number of mail ID. + * @param[in] field_type Specifies the field type what you want to set. Refer email_flags_field_type. + * @param[in] value Specifies the value what you want to set. + * @param[in] onserver Specifies whether mail Flag updation in server + * @exception none + * @see none + * @code + * #include "email-api-account.h" + * bool + * _api_sample_set_flags_field() + * { + * int account_id = 0; + * int mail_id = 0; + * int err = EMAIL_ERROR_NONE; + * + * printf("\n > Enter account id: "); + * scanf("%d", &account_id); + * + * printf("\n > Enter mail id: "); + * scanf("%d", &mail_id); + * if (EMAIL_ERROR_NONE != email_set_flags_field(&account_id, &mail_id, EMAIL_FLAGS_SEEN_FIELD, 1, 0)) + * printf("email_set_flags_field failed\n"); + * else + * { + * printf("email_set_flags_field succeed\n"); + * //do something + * } + * } + * @endcode + * @remarks N/A + */ + +EXPORT_API int email_set_flags_field(int account_id, int *mail_ids, int num, email_flags_field_type field_type, int value, int onserver); + +/* ----------------------------------------------------------- + Mail Move API + -----------------------------------------------------------*/ + +/** + * @open + * @fn email_move_mail_to_mailbox(int *mail_ids, int num, int input_target_mailbox_id) + * @brief Move a email to another mailbox. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_id Specifies the array of mail ID. + * @param[in] num Specifies the count of mail IDs. + * @param[in] input_target_mailbox_id Specifies the mailbox ID for moving email. + * @exception none + * @see email_mailbox_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_move_mail_to_mailbox() + * { + * int mail_id = 0; + * int mailbox_id = 0; + * int err = EMAIL_ERROR_NONE; + + * printf("\n > Enter mail_id: "); + * scanf("%d",&mail_id); + * + * printf("\n > Enter target mailbox_id: "); + * scanf("%d",&mailbox_id); + * + * if(EMAIL_ERROR_NONE == email_move_mail_to_mailbox(&mail_id, 1, mailbox_id)) + * printf("Success\n"); + * + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_move_mail_to_mailbox(int *mail_ids, int num, int input_target_mailbox_id); + + +/** + * @open + * @fn email_move_all_mails_to_mailbox(int input_source_mailbox_id, int input_target_mailbox_id) + * @brief Move all email to another mailbox. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_source_mailbox_id Specifies the source mailbox ID for moving email. + * @param[in] input_target_mailbox_id Specifies the destination mailbox ID for moving email. + * @exception none + * @see email_mailbox_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_move_all_mails_to_mailbox() + * { + * int src_mailbox_id; + * int dst_mailbox_id; + * int total_count; + * int err = EMAIL_ERROR_NONE; + * char temp[128]; + * + * + * // input mailbox information : need account_id and name (src & dest) + * printf("src mail maibox id> "); + * scanf("%d", &src_mailbox_id); + * + * // Destination mailbox + * printf("dest mailbox id> "); + * scanf("%d", &dst_mailbox_id); + * + * if( EMAIL_ERROR_NONE == email_move_all_mails_to_mailbox(src_mailbox_id, dst_mailbox_id)) + * { + * printf(" fail email_move_all_mails_to_mailbox: \n"); + * } + * else + * //success + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_move_all_mails_to_mailbox(int input_source_mailbox_id, int input_target_mailbox_id); + + +/** + * @open + * @fn 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) + * @brief Get the Mail List information from DB. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_filter_list Specifies the filter list + * @param[in] input_filter_count Specifies the number of filter + * @param[in] input_sorting_rule_list Specifies the sorting rule list. + * @param[in] input_sorting_rule_count Specifies the number of sorting rule + * @param[in] input_start_index Specifies start index for LIMIT clause of SQL query. + * @param[in] input_limit_count Specifies limit count for LIMIT clause of SQL query. + * @param[in/out] output_mail_list Specifies the pointer to the structure email_mail_list_item_t. + * @param[in/out] output_result_count Specifies the number of mails returned. + * @exception none + * @see email_mail_list_item_t + * @code + * email_list_filter_t *filter_list = NULL; + * email_list_sorting_rule_t *sorting_rule_list = NULL; + * email_mail_list_item_t *result_mail_list = NULL; + * int result_mail_count = 0; + * int err = EMAIL_ERROR_NONE; + * int i = 0; + * filter_list = malloc(sizeof(email_list_filter_t) * 9); + * memset(filter_list, 0 , sizeof(email_list_filter_t) * 9); + * + * filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + * filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT; + * filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + * filter_list[0].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + * filter_list[0].list_filter_item.rule.case_sensitivity = false; + * + * filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + * filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + * + * filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + * filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_TO; + * filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + * filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + * filter_list[2].list_filter_item.rule.case_sensitivity = false; + * + * filter_list[3].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + * filter_list[3].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + * + * filter_list[4].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + * filter_list[4].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_CC; + * filter_list[4].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + * filter_list[4].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + * filter_list[4].list_filter_item.rule.case_sensitivity = false; + * + * filter_list[5].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + * filter_list[5].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + * + * filter_list[6].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + * filter_list[6].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_BCC; + * filter_list[6].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + * filter_list[6].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + * filter_list[6].list_filter_item.rule.case_sensitivity = false; + * + * filter_list[7].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + * filter_list[7].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + * + * filter_list[8].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + * filter_list[8].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_FROM; + * filter_list[8].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + * filter_list[8].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + * filter_list[8].list_filter_item.rule.case_sensitivity = false; + * + * sorting_rule_list = malloc(sizeof(email_list_sorting_rule_t) * 2); + * memset(sorting_rule_list, 0 , sizeof(email_list_sorting_rule_t) * 2); + * + * sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_FLAGS_SEEN_FIELD; + * sorting_rule_list[0].sort_order = EMAIL_SORT_ORDER_ASCEND; + * + * sorting_rule_list[1].target_attribute = EMAIL_MAIL_ATTRIBUTE_DATE_TIME; + * sorting_rule_list[1].sort_order = EMAIL_SORT_ORDER_ASCEND; + * + * err = email_get_mail_list_ex(filter_list, 9, sorting_rule_list, 2, -1, -1, &result_mail_list, &result_mail_count); + * + * if(err == EMAIL_ERROR_NONE) { + * printf("email_get_mail_list_ex succeed.\n"); + * + * for(i = 0; i < result_mail_count; i++) { + * printf("mail_id [%d], subject [%s], from [%s]\n", result_mail_list[i].mail_id, result_mail_list[i].subject, result_mail_list[i].from); + * } + * } + * else { + * printf("email_get_mail_list_ex failed.\n"); + * } + * + * email_free_list_filter(&filter_list, 9); + * + * return FALSE; + * @endcode + * @remarks N/A + */ +EXPORT_API 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); + +EXPORT_API int email_free_list_filter(email_list_filter_t **input_filter_list, int input_filter_count); + +/** + * @open + * @fn email_get_mails(int account_id , int mailbox_id, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, email_mail_data_t** mail_list, int* result_count) + * @brief Get the Mail List information from DB based on the mailbox name. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] account_id Specifies the account ID + * @param[in] mailbox_id Specifies the mailbox id + * @param[in] thread_id Specifies the thread id. It can be EMAIL_LIST_TYPE_THREAD, EMAIL_LIST_TYPE_NORMAL or thread id. + * @param[in] start_index Specifies start index for LIMIT clause of SQL query. + * @param[in] limit_count Specifies limit count for LIMIT clause of SQL query. + * @param[in] sorting Specifies the sorting type. + * @param[in/out] mail_list Specifies the pointer to the structure email_mail_data_t. + * @param[in/out] result_count Specifies the number of mails returned. + * @exception none + * @see email_mail_data_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_get_mail() + * { + * email_mail_data_t *mail_list = NULL; + * int mailbox_id; + * int result_count = 0; + * int account_id = 0; + * int err_code = EMAIL_ERROR_NONE; + * + * printf("\n > Enter Mailbox id: "); + * scanf("%d", mailbox_id); + * + * printf("\n > Enter Account_id: "); + * scanf("%d",&account_id); + * + * if (EMAIL_ERROR_NONE != email_get_mails(account_id, mailbox_id, EMAIL_LIST_TYPE_NORMAL, 0, 100, EMAIL_SORT_DATETIME_HIGH, &mail_list, &result_count)) { + * printf("email_get_mails failed \n"); + * } + * else { + * printf("Success\n"); + * //do something + * free(mail_list); + * } + * + * } + * @endcode + * @remarks N/A + */ + +EXPORT_API int email_get_mails(int account_id , int mailbox_id, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, email_mail_data_t** mail_list, int* result_count); + +/** + * @open + * @fn email_get_mail_list(int account_id, int mailbox_id, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, email_mail_list_item_t** mail_list, int* result_count) + * @brief Get the Mail List information from DB based on the mailbox name. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] account_id Specifies the account id + * @param[in] mailbox_id Specifies the mailbox id + * @param[in] thread_id Specifies the thread id. It can be EMAIL_LIST_TYPE_THREAD, EMAIL_LIST_TYPE_NORMAL or thread id. + * @param[in] start_index Specifies start index for LIMIT clause of SQL query. + * @param[in] limit_count Specifies limit count for LIMIT clause of SQL query. + * @param[in] sorting Specifies the sorting type. + * @param[in/out] mail_list Specifies the pointer to the structure email_mail_list_item_t. + * @param[in/out] result_count Specifies the number of mails returned. + * @exception none + * @see email_mail_list_item_t + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_get_mail() + * { + * email_mail_list_item_t *mail_list = NULL; + * int mailbox_id; + * int result_count = 0; + * int account_id = 0; + * int err_code = EMAIL_ERROR_NONE; + * + * printf("\n > Enter Mailbox id: "); + * scanf("%d", mailbox_id); + * + * printf("\n > Enter Account_id: "); + * scanf("%d",&account_id); + * + * if (EMAIL_ERROR_NONE != email_get_mail_list(account_id, mailbox_id, EMAIL_LIST_TYPE_NORMAL, 0, 100, EMAIL_SORT_DATETIME_HIGH, &mail_list, &result_count)) + * { + * printf("email_get_mail_list_ex failed \n"); + * } + * else + * { + * printf("Success\n"); + * //do something + * free(mail_list); + * } + * + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_get_mail_list(int account_id, int mailbox_id, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, email_mail_list_item_t** mail_list, int* result_count); + +/** + * @open + * @fn email_get_mail_by_address(int account_id, int mailbox_id, email_email_address_list_t* addr_list, + int start_index, int limit_count, email_sort_type_t sorting, email_mail_list_item_t** mail_list, int* result_count) + * @brief Get the Mail List information from the DB based on the mailbox name account_id and sender address. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] account_id Specifies the Account ID + * @param[in] mailbox_id Specifies the Mailbox ID + * @param[in] addr_list Specifies the addresses of senders. see email_email_address_list_t + * @param[in] start_index Specifies the first mail index of searched mail. This function will return mails whose index in the result list are from start_index to start_index + limit_count + * @param[in] limit_count Specifies the max number of returned mails. + * @param[in] search_type Specifies the search type. + * @param[in] search_value Specifies the search value. + * @param[in] sorting Specifies the sorting order. see email_sort_type_t + * @param[in/out] mail_list Specifies the Pointer to the structure email_mail_list_item_t. + * @param[in/out] result_count Specifies the Number of searched Mails + * @exception none + * @see email_email_address_list_t, email_sort_type_t, email_mail_list_item_t + * @code + * @endcode + * @remarks N/A + */ +EXPORT_API int email_get_mail_by_address(int account_id , int mailbox_id, email_email_address_list_t* addr_list, + int start_index, int limit_count, int search_type, const char *search_value, email_sort_type_t sorting, email_mail_list_item_t** mail_list, int* result_count); + +/** + * @open + * @fn email_get_thread_information_by_thread_id(int thread_id, email_mail_data_t** thread_info) + * @brief Get the thread information for specific thread from DB based on the mailbox name. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] thread_id Specifies the thread_id + * @param[in/out] thread_info Specifies the Pointer to the structure email_mail_data_t. + * @exception none + * @see email_mail_data_t + * @code + * #include "email-api-account.h" + * bool + * _api_sample_get_thread_information() + * { + * email_mail_data_t *thread_info = NULL; + * int thread_id = 0; + * int err_code = EMAIL_ERROR_NONE; + * + * printf("\n > Enter thread_id: "); + * scanf("%d",&thread_id); + * + * if ( EMAIL_ERROR_NONE != email_get_thread_information_by_thread_id(thread_id, &thread_info)) + * { + * printf("email_get_thread_information_by_thread_id failed :\n"); * + * } + * else + * { + * printf("Success\n"); + * //do something + * } + * + * } + * @endcode + * @remarks N/A + */ + + +EXPORT_API int email_get_thread_information_by_thread_id(int thread_id, email_mail_data_t** thread_info); + +/** + * @open + * @fn email_get_thread_information_ex(int thread_id, email_mail_list_item_t** thread_info) + * @brief Get the Mail List information for specific thread from DB based on the mailbox name. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] thread_id Specifies the thread_id + * @param[in/out] thread_info Specifies the Pointer to the structure email_mail_list_item_t. + * @exception none + * @see email_mail_list_item_t + * @code + * #include "email-api-account.h" + * bool + * _api_sample_get_thread_information_ex() + * { + * email_mail_list_item_t *thread_info = NULL; + * int thread_id = 0; + * int err_code = EMAIL_ERROR_NONE; + * + * printf("\n > Enter thread_id: "); + * scanf("%d",&thread_id); + * + * if ( EMAIL_ERROR_NONE != email_get_thread_information_ex(thread_id, &thread_info)) + * { + * printf("email_get_mail_list_of_thread failed :\n"); * + * } + * else + * { + * printf("Success\n"); + * //do something + * } + * + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_get_thread_information_ex(int thread_id, email_mail_list_item_t** thread_info); + + + +/** + * @open + * @fn email_retry_sending_mail( int mail_id, int timeout_in_sec) + * @brief Retry mail send + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_id Specifies the mail id for the mail to resend + * @param[in] timeout_in_sec Specifies the timeout value in seconds + * @exception none + * @see none + + * @code + * #include "email-api-account.h" + * bool + * _api_sample_retry_send_mail() + * { + * int mail_id = 1; + * int timeout_in_sec = 2; + * + * if(EMAIL_ERROR_NONE == email_retry_sending_mail(mail_id,timeout_in_sec)) + * //success + * else + * //failure + * + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_retry_sending_mail(int mail_id, int timeout_in_sec); + +EXPORT_API int email_create_db_full(); + +/** + * @open + * @fn email_cancel_sending_mail( int mail_id) + * @brief Callback function for cm popup. We set the status as EMAIL_MAIL_STATUS_SEND_CANCELED + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_id Specifies the mailID + * @exception none + * @see none + * @code + * #include "email-api-account.h" + * bool + * _api_sample_cancel_send_mail() + * { + * int mail_id = 10; + * + * + * if(EMAIL_ERROR_NONE == email_cancel_sending_mail(mail_id,)) + * //success + * else + * //failure + * + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_cancel_sending_mail(int mail_id) ; + + /** + * @open + * @fn email_get_disk_space_usage(unsigned long *total_size) + * @brief Gets the total disk usage of emails in KB. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[out] total_size total disk usage of emails + * @exception none + * @code + * #include "email-api-account.h" + * bool + * _api_sample_get_disk_space_usage() + * { + * unsigned long total_size = 0; + * + * if ( EMAIL_ERROR_NONE != email_get_disk_space_usage(&total_size)) + * printf("email_get_disk_space_usage failed err : %d\n",err_code); + * else + * printf("email_get_disk_space_usage SUCCESS, total disk usage in KB : %ld \n", total_size); + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_get_disk_space_usage(unsigned long *total_size); + +/** + * @open + * @fn email_get_address_info_list(int mail_id, email_address_info_list_t** address_info_list) + * @brief Get the address info list. The address info list contains from, to, cc, bcc addresses and their display name, contact id and etc. (see email_address_info_list_t) + * Each GList (from, to, cc, bcc) is the list of email_address_info_t data. + * "data" variable of GList structure contains email_address_info_t data.
+ * To get email_address_info_t data from GList, Use type casting from GList node. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_id Specifies the mail id to get the list. + * @param[out] address_info_list Specifies the Pointer to the structure email_address_info_list_t. Memory for a new address info list will be allocated to this. Call email_free_address_info_list() to free the memory allocated to this. + * @exception none + * @see email_address_info_list_t, email_address_info_t, email_free_address_info_list() + * @code + * #include "email-api-account.h" + * bool + * _api_sample_get_address_info_list() + * { + * email_address_info_list_t *p_address_info_list= NULL; + * email_address_info_t *p_address_info = NULL; + * int mai_id; + * int err_code = EMAIL_ERROR_NONE; + * + * mail_id = 1; + * + * if ( EMAIL_ERROR_NONE != (err_code = email_get_address_info_list(mail_id, &p_address_info_list)) ) + * { + * printf("email_get_address_info_list failed :\n"); * + * return false; + * } + * else + * { + * printf("Success\n"); + * //do something with p_address_info_list + * GList *list = p_address_info_list->from; + * GList *node = g_list_first(list); + * while ( node != NULL ) + * { + * p_address_info = (email_address_info_t*)node->data; + * printf("%d, %s, %s, %d\n", p_address_info->address_type, p_address_info->address, p_address_info->display_name, p_address_info->contact_id); + * + * node = g_list_next(node); + * } + * } + * + * // Free sender list + * if ( p_address_info_list ) + * { + * email_free_address_info_list(&p_address_info_list); + * } + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_get_address_info_list(int mail_id, email_address_info_list_t** address_info_list); + +/** + * @open + * @fn email_free_address_info_list(email_address_info_list_t **address_info_list) + * @brief Free the address info list allocated by email_get_address_info_list(). This function will free the memory which is allocated to address_info_list itself. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] address_info_list Specifies the Pointer to the structure email_address_info_list_t to be freed. + * @exception none + * @see email_address_info_list_t, email_get_address_info_list() + */ +EXPORT_API int email_free_address_info_list(email_address_info_list_t **address_info_list); + +/** + * @open + * @fn email_get_structure(const char*encoded_string, void **struct_var, email_convert_struct_type_e type) + * @brief This function returns the structure of the type which is indicated by 'type' variable. This function will allocate new memory to 'struct_var' for structure.
+ * Some notifications such as NOTI_DOWNLOAD_NEW_MAIL are published with string parameter. The string contains various values that might be divided by delimiter.
+ * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] encoded_string Specifies the Pointer to the string from notification. + * @param[out] struct_var Specifies the Pointer to the structure to be returned. If success, new memory for structure will be allocated. + * @param[in] type Specifies the converting type. see email_convert_struct_type_e + * @exception none + * @see email_convert_struct_type_e + */ +EXPORT_API int email_get_structure(const char*encoded_string, void **struct_var, email_convert_struct_type_e type); + +/** + * @open + * @fn email_get_meeting_request(int mail_id, email_meeting_request_t **meeting_req) + * @brief Get the information of meeting request. The information of meeting request is based on Mail Id.
+ * The information of meeting request is corresponding to only one mail. + * For this reason, the information of meeting request can be added by using email_add_message_with_meeting_request() with a matched mail information. + * + * @return This function returns EMAIL_ERROR_NONE on success. This function returns EMAIL_ERROR_DATA_NOT_FOUND if there isn't a matched mail. Otherwise it returns error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_id Specifies the Mail id for which meeting request details need to be fetched + * @param[in/out] meeting_req Specifies the Pointer to the structure email_meeting_request_t. + * @exception none + * @see email_meeting_request_t + */ +EXPORT_API int email_get_meeting_request(int mail_id, email_meeting_request_t **meeting_req); + + +/** + * @open + * @fn email_free_meeting_request(email_meeting_request_t** meeting_req, int count) + * @brief Free the meeting request allocated by email_get_meeting_request() or alloacted to add. This function will free the memory which is allocated to meeting_req (= *meeting_req) itself. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] email_meeting_request_t Specifies the Pointer to the structure email_meeting_request_t to be freed. + * @param[in] count Specifies the number of elements in meeting_req array. this is usually 1. + * @exception none + * @see email_meeting_request_t, email_get_meeting_request() + */ +EXPORT_API int email_free_meeting_request(email_meeting_request_t** meeting_req, int count); + +EXPORT_API int email_move_thread_to_mailbox(int thread_id, int target_mailbox_id, int move_always_flag); + +EXPORT_API int email_delete_thread(int thread_id, int delete_always_flag); + +EXPORT_API int email_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server); + +EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, unsigned *output_handle); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/** +* @} @} +*/ + + +#endif /* __EMAIL_API_MAIL_H__ */ diff --git a/email-api/include/email-api-mailbox.h b/email-api/include/email-api-mailbox.h index a1a23b6..62a57f7 100755 --- a/email-api/include/email-api-mailbox.h +++ b/email-api/include/email-api-mailbox.h @@ -1,353 +1,342 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - -#ifndef __EMAIL_API_MAILBOX_H__ -#define __EMAIL_API_MAILBOX_H__ - -#include "email-types.h" - -/** -* @defgroup EMAIL_SERVICE Email Service -* @{ -*/ - - -/** -* @ingroup EMAIL_SERVICE -* @defgroup EMAIL_API_MAILBOX Email Mailbox API -* @{ -*/ - -/** - * - * This file contains the data structures and interfaces needed for application, - * to interact with email-service. - * @file email-api-mailbox.h - * @author Kyuho Jo - * @author Sunghyun Kwon - * @version 0.1 - * @brief This file contains the data structures and interfaces of mailbox provided by - * email-service . - * @{ - * @code - * - * #include "email_api_mailbox.h" - * - * bool other_app_invoke_uniform_api_sample(int *error_code) - * { - * emf_mailbox_t mbox; - * emf_mailbox_t *new_mailbox =NULL; - * emf_mailbox_t *mailbox_list = NULL; - * int count = 0; - * int mailbox_type; - * unsigned handle = 0; - * char *pMaiboxName; - * char *pParentMailbox; - * - * memset(&mbox,0x00,sizeof(emf_mailbox_t)); - * mbox.name = strdup("test"); - * mbox.alias = strdup("Personal"); - * mbox.account_id = 1; - * printf("Enter local_yn(1/0)"); - * scanf("%d",&local_yn); - * mbox.local=local_yn; - * mbox.mailbox_type = 7; - * - * //create new mailbox - * - * if(EMF_ERR_NONE != email_add_mailbox(&mbox,local_yn,&handle)) - * printf("email_add_mailbox failed\n"); - * else - * printf("email_add_mailbox success"); - * - * //update mailbox - * new_mailbox = malloc(sizeof(emf_mailbox_t)); - * memset(new_mailbox,0x00,sizeof(emf_mailbox_t)); - * - * new_mailbox->name = strdup("PersonalUse"); - * - * if(EMF_ERROR_NONE != email_update_mailbox(&mbox,new_mailbox)) - * printf("email_update_mailbox failed\n"); - * else - * printf("email_update_mailbox success\n"); - * //delete mailbox - * - * if(EMF_ERROR_NONE != email_delete_mailbox(mbox,local_yn,&handle)) - * printf("email_delete_mailbox failed\n"); - * else - * printf("email_delete_mailbox success\n"); - * - * //free mailbox - * email_free_mailbox("new_mailbox,1"); - * - * //Get mailbox list - * if(EMF_ERROR_NONE != email_get_mailbox_list(account_id,local_yn,&mailbox_list,&count)) - * //failure - * else - * //success - * - * //Get mailbox by name - * pMailboxName = strdup("test"); - * if(EMF_ERROR_NONE != email_get_mailbox_by_name(account_id,pMailboxName,&mailbox_list)) - * //failure - * else - * //success - * - * //Get child mailbox list - * pParentMailbox = strdup("test"); - * if(EMF_ERROR_NONE != email_get_child_mailbox_list(account_id, paerent_mailbox,&mailbox_list,&count)) - * //failure - * else - * //success - * - * //Get mailbox by mailbox_type - * printf("Enter mailbox_type\n"); - * scanf("%d",&mailbox_type); - * if(EMF_ERROR_NONE != email_get_mailbox_by_mailbox_type(account_id,mailbox_type,&mailbox_list)) - * //failure - * else - * //success - * - * } - * - * @endcode - * @} - */ - - - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - - -/** - - * @open - * @fn EXPORT_API int email_add_mailbox(emf_mailbox_t* new_mailbox, int on_server, unsigned* handle) - * @brief Create a new mailbox or mailbox.This function is invoked when user wants to create a new mailbox for the specified account. - * If On_server is true then it will create the mailbox on server as well as in local also. - * - * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure. - * @param[in] new_mailbox Specifies the pointer of creating mailbox information. -* @param[in] on_server Specifies the creating mailbox information on server. - * @param[out] handle Specifies the sending handle. - * @exception none - * @see emf_mailbox_t - * @remarks N/A - */ -EXPORT_API int email_add_mailbox(emf_mailbox_t* new_mailbox, int on_server, unsigned* handle); - - -/** - - * @open - * @fn EXPORT_API int email_delete_mailbox(emf_mailbox_t* mailbox, int on_server, unsigned* handle) - * @brief Delete a mailbox or mailbox.This function deletes the existing mailbox for specified account based on the option on_server. - * If the on_server is true then it deletes mailbox from server as well as locally. - * - * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Specifies the pointer of deleting mailbox information. - * @param[in] on_server Specifies the creating mailbox information on server. - * @param[out] handle Specifies the sending handle. - * @exception #EMF_ERROR_INVALID_PARAM -Invaid argument - * @see emf_mailbox_t - * @remarks N/A - */ -EXPORT_API int email_delete_mailbox(emf_mailbox_t* mailbox, int on_server, unsigned* handle); - - -/** - - * @fn EXPORT_API int email_update_mailbox(emf_mailbox_t* old_mailbox, emf_mailbox_t* new_mailbox) - * @brief Change mailbox or mailbox information.This function is invoked when user wants to change the existing mail box information. - * This supports ONLY updating mailbox_type in local db. This can be used to match a specific mail box and a specific mailbox_type. - * - * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure. - * @param[in] old_mailbox Specifies the information of previous mailbox.
mandatory field : account_id, name - * @param[in] new_mailbox Specifies the information of new mailbox.
Enter account id: "); - * scanf("%d", &account_id); - * printf("\n > Enter mailbox_sync_type: "); - * scanf("%d", &mailbox_sync_type); - * - * if((EMF_ERROR_NONE != email_get_mailbox_list(account_id, mailbox_sync_type, &mailbox_list, &count))) - * { - * printf(" Error\n"); - * } - * else - * { - * printf("Success\n"); - * email_free_mailbox(&mailbox_list,count); - * } - * } - * @endcode - * @remarks N/A - */ -EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, emf_mailbox_t** mailbox_list, int* count); - -EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type, int with_count, emf_mailbox_t** mailbox_list, int* count); - -/** - - * @open - * @fn EXPORT_API int email_get_mailbox_by_name(int account_id, const char *pMailboxName, emf_mailbox_t **pMailbox); - * @brief Get the mailbox information by name.This function gets the mailbox by given mailbox name for a specified account. - * - * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the information of account Id. - * @param[in] pMailboxName Specifies the mailbox name. - * @param[out] pMailbox Specifies the information of mailbox - * @exception none - * @see emf_mailbox_t - * @remarks N/A - */ - -EXPORT_API int email_get_mailbox_by_name(int account_id, const char *pMailboxName, emf_mailbox_t **pMailbox); - -// Belows are for A Project - -/** - - * @open - * @fn email_get_child_mailbox_list(int account_id, char *parent_mailbox, emf_mailbox_t** mailbox_list, int* count) - * @brief Get all sub mailboxes for given parent mailbox.This function gives all the child mailbox list for a given parent mailbox for specified account. - * - * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account ID. - * @param[in] parent_mailbox Specifies the parent mailbox - * @param[out] mailbox_list Specifies the pointer of mailbox structure pointer.(possibly NULL) - * @param[out] count The mailbox count - * @exception #EMF_ERROR_INVALID_PARAM -Invalid argument - * @see emf_mailbox_t - * @remarks N/A - * @return This function returns true on success or false on failure. - */ -EXPORT_API int email_get_child_mailbox_list(int account_id, const char *parent_mailbox, emf_mailbox_t** mailbox_list, int* count); - - -/** - * @open - * @fn email_get_mailbox_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, emf_mailbox_t** mailbox) - * @brief Get mailbox by mailbox_type.This function is invoked when user wants to know the mailbox information by mailbox_type for the given account. - * - * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account ID. - * @param[in] mailbox_type Specifies the mailbox type. - * @param[out] mailbox Specifies the pointer of mailbox structure pointer.(possibly NULL) - * @exception none - * @see emf_mailbox_t - * @remarks N/A - */ -EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, emf_mailbox_t** mailbox); - -/** - * @open - * @fn email_set_mail_slot_size(int account_id, char* mailbox_name, int new_slot_size, unsigned* handle) - * @brief Set mail slot size.This function is invoked when user wants to set the size of mail slot. - * - * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account ID. - * @param[in] mailbox_name Specifies the mailbox name. - * @param[in] new_slot_size Specifies the mail slot size. - * @exception none - * @see emf_mailbox_t - * @remarks N/A - */ -EXPORT_API int email_set_mail_slot_size(int account_id, char* mailbox_name, int new_slot_size/*, unsigned* handle*/); - -/** - * @open - * @fn email_free_mailbox(emf_mailbox_t** mailbox_list, int count) - * @brief Free allocated memory for mailbox information. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox_list Specifies the pointer for searching mailbox structure pointer. - * @param[in] count Specifies the count of mailboxes. - * @exception none - * @see emf_mailbox_t - - * @code - * #include "email-api-mailbox.h" - * bool - * _api_sample_free_mailbox_info() - * { - * emf_mailbox_t *mailbox; - * - * //fill the mailbox structure - * //count - number of mailbox structure user want to free - * if(EMF_ERROR_NONE == email_free_mailbox(&mailbox,count)) - * //success - * else - * //failure - * - * } - * @endcode - * @remarks N/A - */ - -EXPORT_API int email_free_mailbox(emf_mailbox_t** mailbox_list, int count); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -/** -* @} @} -*/ - - - -#endif /* __EMAIL_API_MAILBOX_H__ */ - - +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +#ifndef __EMAIL_API_MAILBOX_H__ +#define __EMAIL_API_MAILBOX_H__ + +#include "email-types.h" + +/** +* @defgroup EMAIL_SERVICE Email Service +* @{ +*/ + + +/** +* @ingroup EMAIL_SERVICE +* @defgroup EMAIL_API_MAILBOX Email Mailbox API +* @{ +*/ + +/** + * + * This file contains the data structures and interfaces needed for application, + * to interact with email-service. + * @file email-api-mailbox.h + * @author Kyuho Jo + * @author Sunghyun Kwon + * @version 0.1 + * @brief This file contains the data structures and interfaces of mailbox provided by + * email-service . + * @{ + * @code + * + * #include "email_api_mailbox.h" + * + * bool other_app_invoke_uniform_api_sample(int *error_code) + * { + * email_mailbox_t mailbox; + * email_mailbox_t *new_mailbox =NULL; + * email_mailbox_t *mailbox_list = NULL; + * int count = 0; + * int mailbox_type; + * unsigned handle = 0; + * char *pMaiboxName; + * char *pParentMailbox; + * + * memset(&mailbox,0x00,sizeof(email_mailbox_t)); + * mailbox.mailbox_name = strdup("test"); + * mailbox.alias = strdup("Personal"); + * mailbox.account_id = 1; + * printf("Enter local_yn(1/0)"); + * scanf("%d",&local_yn); + * mailbox.local=local_yn; + * mailbox.mailbox_type = 7; + * + * //create new mailbox + * + * if(EMAIL_ERR_NONE != email_add_mailbox(&mailbox,local_yn,&handle)) + * printf("email_add_mailbox failed\n"); + * else + * printf("email_add_mailbox success"); + * + * //delete mailbox + * + * if(EMAIL_ERROR_NONE != email_delete_mailbox(mailbox,local_yn,&handle)) + * printf("email_delete_mailbox failed\n"); + * else + * printf("email_delete_mailbox success\n"); + * + * //free mailbox + * email_free_mailbox("new_mailbox,1"); + * + * //Get mailbox list + * if(EMAIL_ERROR_NONE != email_get_mailbox_list(account_id,local_yn,&mailbox_list,&count)) + * //failure + * else + * //success + * + * //Get mailbox by name + * pMailboxName = strdup("test"); + * if(EMAIL_ERROR_NONE != email_get_mailbox_by_name(account_id,pMailboxName,&mailbox_list)) + * //failure + * else + * //success + * + * //Get child mailbox list + * pParentMailbox = strdup("test"); + * if(EMAIL_ERROR_NONE != email_get_child_mailbox_list(account_id, paerent_mailbox,&mailbox_list,&count)) + * //failure + * else + * //success + * + * //Get mailbox by mailbox_type + * printf("Enter mailbox_type\n"); + * scanf("%d",&mailbox_type); + * if(EMAIL_ERROR_NONE != email_get_mailbox_by_mailbox_type(account_id,mailbox_type,&mailbox_list)) + * //failure + * else + * //success + * + * } + * + * @endcode + * @} + */ + + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/** + * @open + * @fn int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle) + * @brief Create a new mailbox or mailbox.This function is invoked when user wants to create a new mailbox for the specified account. + * If On_server is true then it will create the mailbox on server as well as in local also. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure. + * @param[in] new_mailbox Specifies the pointer of creating mailbox information. +* @param[in] on_server Specifies the creating mailbox on server. + * @param[out] handle Specifies the sending handle. + * @exception none + * @see email_mailbox_t + * @remarks N/A + */ +EXPORT_API int email_add_mailbox(email_mailbox_t *new_mailbox, int on_server, unsigned* handle); + +/** + * @fn int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias) + * @brief Change mailbox name. This function is invoked when user wants to change the name of existing mail box. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_mailbox_id Specifies the id of the mailbox. + * @param[in] input_mailbox_name Specifies the name of the mailbox. + * @param[in] input_mailbox_alias Specifies the alias of the mailbox. + * @param[in] input_on_server Specifies the moving mailbox on server. + * @param[out] output_handle Specifies the handle to manage tasks. + * + * @exception see email-errors.h + * @see email_mailbox_t, email_mailbox_type_e + * @remarks N/A + */ +EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias, int input_on_server, unsigned *output_handle); + +/** + * @open + * @fn int email_delete_mailbox(int input_mailbox_id, int input_on_server, unsigned* output_handle) + * @brief Delete a mailbox or mailbox.This function deletes the existing mailbox for specified account based on the option on_server. + * If the on_server is true then it deletes mailbox from server as well as locally. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_mailbox_id Specifies the id of target mailbox . + * @param[in] input_on_server Specifies the deleting mailbox on server. + * @param[out] output_handle Specifies the sending handle. + * @exception see email-errors.h + * @see email_mailbox_t + * @remarks N/A + */ +EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, unsigned* output_handle); + +/** + * @fn int email_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type) + * @brief Change the mailbox type. This function is invoked when user wants to change the mailbox type. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_mailbox_id Specifies the id of the mailbox. + * @param[in] input_mailbox_type Specifies the mailbox type. + * @exception see email-errors.h + * @see email_mailbox_type_e + * @remarks N/A + */ +EXPORT_API int email_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type); + +/** + + * @open + * @fn email_get_mailbox_list(int account_id, int mailbox_sync_type, email_mailbox_t** mailbox_list, int* count) + * @brief Get all mailboxes from account. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure. + * @param[in] account_id Specifies the account ID. + * @param[in] mailbox_sync_type Specifies the sync type. + * @param[out] mailbox_list Specifies the pointer of mailbox structure pointer.(possibly NULL) + * @param[out] count The mailbox count is saved here.(possibly 0) + * @exception none + * @see email_mailbox_t + + * @code + * #include "email-api-mailbox.h" + * bool + * _api_sample_get_mailbox_list() + * { + * int account_id =0,count = 0; + * int mailbox_sync_type; + * int error_code = EMAIL_ERROR_NONE; + * email_mailbox_t *mailbox_list=NULL; + * + * printf("\n > Enter account id: "); + * scanf("%d", &account_id); + * printf("\n > Enter mailbox_sync_type: "); + * scanf("%d", &mailbox_sync_type); + * + * if((EMAIL_ERROR_NONE != email_get_mailbox_list(account_id, mailbox_sync_type, &mailbox_list, &count))) + * { + * printf(" Error\n"); + * } + * else + * { + * printf("Success\n"); + * email_free_mailbox(&mailbox_list,count); + * } + * } + * @endcode + * @remarks N/A + */ +EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, email_mailbox_t** mailbox_list, int* count); + +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); + +/** + * @open + * @fn email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t** mailbox) + * @brief Get mailbox by mailbox_type.This function is invoked when user wants to know the mailbox information by mailbox_type for the given account. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure. + * @param[in] account_id Specifies the account ID. + * @param[in] mailbox_type Specifies the mailbox type. + * @param[out] mailbox Specifies the pointer of mailbox structure pointer.(possibly NULL) + * @exception none + * @see email_mailbox_t + * @remarks N/A + */ +EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t** mailbox); + +/** + * @open + * @fn email_get_mailbox_by_mailbox_id(int input_mailbox_id, email_mailbox_t** output_mailbox) + * @brief Get mailbox by mailbox_id. This function is invoked when user wants to know the mailbox information by mailbox id. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_mailbox_id Specifies the mailbox id. + * @param[out] output_mailbox Specifies the pointer of mailbox structure pointer.(possibly NULL) + * @exception none + * @see email_mailbox_t + * @remarks N/A + */ +EXPORT_API int email_get_mailbox_by_mailbox_id(int input_mailbox_id, email_mailbox_t** output_mailbox); + +/** + * @open + * @fn email_set_mail_slot_size(int input_account_id, int input_mailbox_id, int input_new_slot_size) + * @brief Set mail slot size.This function is invoked when user wants to set the size of mail slot. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_account_id Specifies the account ID. + * @param[in] input_mailbox_id Specifies the mailbox id. + * @param[in] input_new_slot_size Specifies the mail slot size. + * @exception none + * @see email_mailbox_t + * @remarks N/A + */ +EXPORT_API int email_set_mail_slot_size(int input_account_id, int input_mailbox_id, int input_new_slot_size); + +/** + * @open + * @fn email_stamp_sync_time_of_mailbox(int input_mailbox_id) + * @brief Stamp sync time of mailbox. This function is invoked when user wants to set the sync time of the mailbox. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_mailbox_id Specifies the mailbox id. + * @exception none + * @see email_mailbox_t + * @remarks N/A + */ +EXPORT_API int email_stamp_sync_time_of_mailbox(int input_mailbox_id); + + +/** + * @open + * @fn email_free_mailbox(email_mailbox_t** mailbox_list, int count) + * @brief Free allocated memory for mailbox information. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mailbox_list Specifies the pointer for searching mailbox structure pointer. + * @param[in] count Specifies the count of mailboxes. + * @exception none + * @see email_mailbox_t + + * @code + * #include "email-api-mailbox.h" + * bool + * _api_sample_free_mailbox_info() + * { + * email_mailbox_t *mailbox; + * + * //fill the mailbox structure + * //count - number of mailbox structure user want to free + * if(EMAIL_ERROR_NONE == email_free_mailbox(&mailbox,count)) + * //success + * else + * //failure + * + * } + * @endcode + * @remarks N/A + */ + +EXPORT_API int email_free_mailbox(email_mailbox_t** mailbox_list, int count); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/** +* @} @} +*/ + +#endif /* __EMAIL_API_MAILBOX_H__ */ + + diff --git a/email-api/include/email-api-network.h b/email-api/include/email-api-network.h index 462e66b..c13c037 100755 --- a/email-api/include/email-api-network.h +++ b/email-api/include/email-api-network.h @@ -1,403 +1,360 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - -#ifndef __EMAIL_API_NETWORK_H__ -#define __EMAIL_API_NETWORK_H__ - -#include "email-types.h" - -/** -* @defgroup EMAIL_SERVICE Email Service -* @{ -*/ - -/** -* @ingroup EMAIL_SERVICE -* @defgroup EMAIL_API_NETWORK Email Network API -* @{ -*/ - -/** - * - * This file contains the data structures and interfaces needed for application, - * to interact with email-service. - * @file email-api-network.h - * @author Kyuho Jo - * @author Sunghyun Kwon - * @version 0.1 - * @brief This file contains the data structures and interfaces of Network related Functionality provided by - * email-service . - * - * @{ - - * @code - - * #include "email-api.h" - * - * bool - * other_app_invoke_uniform_api_sample(int* error_code) - * { - * - * // Send a mail - * emf_mailbox_t mbox; - * emf_attachment_info_t attachment; - * emf_option_t option; - * int account_id = 1; - * int err = EMF_ERROR_NONE; - * int mail_id = 0; - * char arg[50]; //Input attachment number need to be download - * emf_event_status_type_t status; - * int action = -1; - * int on_sending = 0; - * int on_receiving = 0; - * -* printf("Enter mailbox name\n"); - * scanf("%s",&mbox.mailbox_name); - * printf("Enter mail id\n"); - * scanf("%d",&mail_id); - * option.keep_local_copy = 1; - * - * if(EMF_ERROR_NONE == email_send_mail(&mbox, mail_id, &option, &handle)) - * //success - * else - * //failure - * - * // Download header of new emails from mail server - * unsigned handle = 0; - * - * memset(&mbox, 0x00, sizeof(emf_mailbox_t)); - * - * mbox.account_id = account_id; - * mbox.name = strdup("INBOX"); - * if(EMF_ERROR_NONE == email_sync_header (&mbox,&handle)) - * //success - * else - * //failure - * - * //Sync mail header for all accounts - * if(EMF_ERROR_NONE == email_sync_header_for_all_account(&handle)) - * //success - * else - * //failure - * - * //Download email body from server - * - * memset(&mbox, 0x00, sizeof(emf_mailbox_t)); - * mbox.account_id = account_id; - * mbox.name = strdup("INBOX"); - * if(EMF_ERROR_NONE == email_download_body (&mbox,mail_id,0,&handle)) - * //success - * else - * //failure - * - * //Download a email nth-attachment from server - * prinf("Enter attachment number\n"); - * scanf("%s",arg); - * memset(&mbox, 0x00, sizeof(emf_mailbox_t)); - * mbox.name = strdup("INBOX"); - * mbox.account_id = account_id; - * if(EMF_ERROR_NONE == email_download_attachment(&mailbox,mail_id,arg,&handle)) - * //success - * else - * //failure - * - * //Cancel job - * if(EMF_ERROR_NONE == email_cancel_job(account_id,handle))//canceling download email nth attachment from server job. - * //so this handle contains the value return by the email_download_attachment() - * //success - * else - * //failure - * //Get pending job listfor an account - * - * printf( " Enter Action \n SEND_MAIL = 0 \n SYNC_HEADER = 1 \n" \ - * " DOWNLOAD_BODY,= 2 \n DOWNLOAD_ATTACHMENT = 3 \n" \ - * " DELETE_MAIL = 4 \n SEARCH_MAIL = 5 \n SAVE_MAIL = 6 \n" \ - * " NUM = 7 \n"); - * scanf("%d",&action); - * if(EMF_ERROR_NONE == email_get_pending_job(action,account_id,mail_id,&status)) - * //success - * else - * //error - * - * //Get Network status - * if(EMF_ERROR_NONE == email_get_network_status(&sending,&receiving)) - * //success - * else - * //failure - * - * //Send read report - * if(EMF_ERROR_NONE == email_send_report(mail ,&handle)) - * //success - * else - * //failure - * //Save and send - * - * mbox.account_id = account_id; - * mbox.name = strdup("DRAFTBOX"); - * - * if(EMF_ERROR_NONE == email_add_message(mail,&mbox,1)) - * { - * if(EMF_ERROR_NONE == email_send_saved(account_id,&option,&handle)) - * //success - * else - * //failure - * } - * //Get Imap mailbox list - * printf("\n > Enter server name:\n"); - * scanf("%s",arg); - * if(EMF_ERROR_NONE == email_get_imap_mailbox_list(account_id , arg , &handle)) - * //success - * else - * //failure - * - * //sync local activity - * if(EMF_ERROR_NONE == email_sync_local_activity(account_id)) - * //success - * else - * //failure - * } - * - * @endcode - * @} - - */ - - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @open - * @fn email_send_mail( emf_mailbox_t* mailbox, int mail_id, emf_option_t* sending_option, unsigned* handle) - * @brief Send a mail.This function is invoked when user wants to send a composed mail. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Specifies the mailbox to consist a sending email. - * @param[in] mail_id Specifies the mail ID. - * @param[in] sending_option Specifies the sending option. - * @param[out] handle Specifies the sending handle. - * @exception none - * @see emf_mailbox_t and emf_option_t - * @remarks N/A - */ -EXPORT_API int email_send_mail( emf_mailbox_t* mailbox, - int mail_id, - emf_option_t* sending_option, - unsigned* handle); - - -/** - * @open - * @fn email_sync_header(emf_mailbox_t* mailbox, unsigned* handle) - * @brief Download header of new emails from mail server.This function is invoked when user wants to download only header of new mails. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Specifies the structure of mailbox. - * @param[out] handle Specifies the handle for stopping downloading. - * @exception none - * @see emf_mailbox_t - * @remarks N/A - */ -EXPORT_API int email_sync_header(emf_mailbox_t* mailbox, unsigned* handle); - - -/** - * @open - * @fn email_sync_header_for_all_account(unsigned* handle) - * @brief Download header of new emails from mail server for all emails.This function is invoked when user wants to download header of new mails for all accounts. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[out] handle Specifies the handle for stopping downloading. - * @exception none - * @see none - * @remarks N/A - */ -EXPORT_API int email_sync_header_for_all_account(unsigned* handle); - - -/** - * @open - * @fn email_download_body(emf_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle) - * @brief Download email body from server.This function is invoked when user wants to download email body with/without attachment based on the option with_attachment - * from the server. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Specifies the structure of mailbox. - * @param[in] mail_id Specifies the mail ID. - * @param[in] with_attachment Specifies the whether attachment is there or not. - * @param[out] handle Specifies the handle for stopping downloading. - * @exception none - * @see emf_mailbox_t - * @remarks N/A - */ -EXPORT_API int email_download_body(emf_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle); - - - - - - -/** - * @open - * @fn email_download_attachment(emf_mailbox_t* mailbox, int mail_id, char* nth, unsigned* handle); - * @brief Download a email nth-attachment from server.This function is invoked if user wants to download only specific attachment of a mail whose body is already downloaded. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] mailbox Reserved. - * @param[in] mail_id Specifies the mail ID. - * @param[in] nth Specifies the buffer that a attachment number been saved. the minimum number is "1". - * @param[out] handle Specifies the handle for stopping downloading. - * @exception none - * @see emf_mailbox_t - * @remarks N/A - */ -EXPORT_API int email_download_attachment(emf_mailbox_t* mailbox, - int mail_id, - const char* nth, - unsigned* handle); - - -/** - * @open - * @fn email_cancel_job(int account_id, int handle); - * @brief cancel the ongoing job.This function is invoked if user wants to cancel any ongoing job of a specified account. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account ID. - * @param[in] handle Specifies the handle for stopping the operation. - * @exception none - * @see none - * @remarks N/A - */ - -EXPORT_API int email_cancel_job(int account_id, int handle); - - -/** - * @open - * @fn email_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t * status); - * @brief get pending job list.This function is invoked if user wants to get the pending job list with status information . - * Based on action item of a mail is for a specific account this will give all pending job list. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the action of the job. - * @param[in] account_id Specifies the account ID. - * @param[in] mail_id Specifies the mail ID. - * @param[out]status Specifies the status of the job. - * @exception none - * @see emf_action_t and emf_event_status_type_t - * @remarks N/A - */ -EXPORT_API int email_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t * status); - - -/** - * @open - * @fn email_get_network_status(int* on_sending, int* on_receiving) - * @brief This function gives the current network status.This gives the information to the user whether sending operation is in progress or receiving operation. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[out] on_sending True if sending is in progress. - * @param[out] on_receiving True if receivng is in progress. - * @exception none - * @see none - * @remarks N/A - */ -EXPORT_API int email_get_network_status(int* on_sending, int* on_receiving); - -/** - * @open - * @fn email_send_saved(int account_id, emf_option_t* sending_option, unsigned* handle) - * @brief Send all mails to been saved in Offline-mode.This function is invoked when user wants to send an email and after saving it. - * This will save the email in draft mailbox and then sends. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account ID. - * @param[in] sending_option Specifies the sending option. - * @param[out] handle Specifies the handle for stopping sending. - * @exception none - * @see emf_option_t - * @remarks N/A - */ -EXPORT_API int email_send_saved(int account_id, emf_option_t* sending_option, unsigned* handle); - -/** - * @open - * @fn email_get_imap_mailbox_list(int account_id, char* mailbox, unsigned* handle) - * @brief fetch all the mailbox names from server and store the non-existing mailboxes in DB.This function is invoked when user wants to download all server mailboxes from IMAP server - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account ID. - * @param[in] mailbox Specifies the mailbox name. - * @param[out] handle Specifies the handle for stopping Network operation. - * @exception none - * @see none - * @remarks N/A - */ -EXPORT_API int email_get_imap_mailbox_list(int account_id, const char* mailbox, unsigned* handle); - - - -/** - * @open - * @fn email_sync_local_activity(int account_id) - * @brief sync local activity - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the account ID. - * @exception none - * @see none - * @remarks N/A - */ -EXPORT_API int email_sync_local_activity(int account_id); - - -/** - * @open - * @fn email_search_mail_on_server(int account_id, const char *mailbox_name, int search_type, char *search_value) - * @brief Search the mails on server. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] account_id Specifies the Account ID - * @param[in] mailbox_name Specifies the Mailbox Name - * @param[in] search_type Specifies the searching type(EMF_SEARCH_FILTER_SUBJECT, EMF_SEARCH_FILTER_SENDER, EMF_SEARCH_FILTER_RECIPIENT, EMF_SEARCH_FILTER_ALL) - * @param[in] search_value Specifies the value to use for searching. (ex : Subject, email address, display name) - * @exception none - * @see - * @code - * @endcode - * @remarks N/A - */ -EXPORT_API int email_search_mail_on_server(int input_account_id, const char *input_mailbox_name, email_search_filter_t *input_search_filter_list, int input_search_filter_count, unsigned *output_handle); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -/** -* @} -*/ - - -#endif /* __EMAIL_API_NETWORK_H__ */ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +#ifndef __EMAIL_API_NETWORK_H__ +#define __EMAIL_API_NETWORK_H__ + +#include "email-types.h" + +/** +* @defgroup EMAIL_SERVICE Email Service +* @{ +*/ + +/** +* @ingroup EMAIL_SERVICE +* @defgroup EMAIL_API_NETWORK Email Network API +* @{ +*/ + +/** + * + * This file contains the data structures and interfaces needed for application, + * to interact with email-service. + * @file email-api-network.h + * @author Kyuho Jo + * @author Sunghyun Kwon + * @version 0.1 + * @brief This file contains the data structures and interfaces of Network related Functionality provided by + * email-service . + * + * @{ + + * @code + + * #include "email-api.h" + * + * bool + * other_app_invoke_uniform_api_sample(int* error_code) + * { + * + * // Send a mail + * email_attachment_data_t attachment; + * email_option_t option; + * int account_id = 1; + * int mailbox_id = 0; + * int attachment_id = 0; + * int err = EMAIL_ERROR_NONE; + * int mail_id = 0; + * int action = -1; + * + * printf("Enter mail id\n"); + * scanf("%d",&mail_id); + * option.keep_local_copy = 1; + * + * if(EMAIL_ERROR_NONE == email_send_mail(mail_id, &option, &handle)) + * //success + * else + * //failure + * + * // Download header of new emails from mail server + * unsigned handle = 0; + * + * mailbox.account_id = account_id; + * printf("Enter mailbox id\n"); + * scanf("%d",&mailbox_id); + * if(EMAIL_ERROR_NONE == email_sync_header (account_id, mailbox_id, &handle)) + * //success + * else + * //failure + * + * //Sync mail header for all accounts + * if(EMAIL_ERROR_NONE == email_sync_header_for_all_account(&handle)) + * //success + * else + * //failure + * + * //Download email body from server + * + * if(EMAIL_ERROR_NONE == email_download_body (mail_id,0,&handle)) + * //success + * else + * //failure + * + * //Download a email nth-attachment from server + * prinf("Enter attachment number\n"); + * scanf("%d",&attachment_id); + * if(EMAIL_ERROR_NONE == email_download_attachment(mail_id, attachment_id, &handle)) + * //success + * else + * //failure + * + * //Cancel job + * if(EMAIL_ERROR_NONE == email_cancel_job(account_id,handle))//canceling download email nth attachment from server job. + * //so this handle contains the value return by the email_download_attachment() + * //success + * else + * //failure + * //Get pending job listfor an account + * + * printf( " Enter Action \n SEND_MAIL = 0 \n SYNC_HEADER = 1 \n" \ + * " DOWNLOAD_BODY,= 2 \n DOWNLOAD_ATTACHMENT = 3 \n" \ + * " DELETE_MAIL = 4 \n SEARCH_MAIL = 5 \n SAVE_MAIL = 6 \n" \ + * " NUM = 7 \n"); + * scanf("%d",&action); + * if(EMAIL_ERROR_NONE == email_get_pending_job(action,account_id,mail_id,&status)) + * //success + * else + * //error + * + * //Get Network status + * if(EMAIL_ERROR_NONE == email_get_network_status(&sending,&receiving)) + * //success + * else + * //failure + * + * //Send read report + * if(EMAIL_ERROR_NONE == email_send_report(mail ,&handle)) + * //success + * else + * //failure + * //Save and send + * + * + * if(EMAIL_ERROR_NONE == email_add_mail(mail,NULL,0, NULL, 0)) + * { + * if(EMAIL_ERROR_NONE == email_send_saved(account_id,&option,&handle)) + * //success + * else + * //failure + * } + * //Get Imap mailbox list + * if(EMAIL_ERROR_NONE == email_sync_imap_mailbox_list(account_id, &handle)) + * //success + * else + * //failure + * + * } + * + * @endcode + * @} + + */ + + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @open + * @fn email_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle) + * @brief Send a mail.This function is invoked when user wants to send a composed mail. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_id Specifies the mail ID. + * @param[in] sending_option Specifies the sending option. + * @param[out] handle Specifies the sending handle. + * @exception none + * @see email_mailbox_t and email_option_t + * @remarks N/A + */ +EXPORT_API int email_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle); + + +/** + * @open + * @fn email_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle) + * @brief Download header of new emails from mail server.This function is invoked when user wants to download only header of new mails. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_account_id Specifies the account ID. + * @param[in] input_mailbox_id Specifies the mailbox ID. + * @param[out] handle Specifies the handle for stopping downloading. + * @exception none + * @see email_mailbox_t + * @remarks N/A + */ +EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle); + + +/** + * @open + * @fn email_sync_header_for_all_account(unsigned* handle) + * @brief Download header of new emails from mail server for all emails.This function is invoked when user wants to download header of new mails for all accounts. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[out] handle Specifies the handle for stopping downloading. + * @exception none + * @see none + * @remarks N/A + */ +EXPORT_API int email_sync_header_for_all_account(unsigned* handle); + + +/** + * @open + * @fn email_download_body(int mail_id, int with_attachment, unsigned* handle) + * @brief Download email body from server.This function is invoked when user wants to download email body with/without attachment based on the option with_attachment + * from the server. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_id Specifies the mail ID. + * @param[in] with_attachment Specifies the whether attachment is there or not. + * @param[out] handle Specifies the handle for stopping downloading. + * @exception none + * @see email_mailbox_t + * @remarks N/A + */ +EXPORT_API int email_download_body(int mail_id, int with_attachment, unsigned* handle); + + + + + + +/** + * @open + * @fn email_download_attachment(int mail_id, const char* nth, unsigned* handle); + * @brief Download a email nth-attachment from server.This function is invoked if user wants to download only specific attachment of a mail whose body is already downloaded. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] mail_id Specifies the mail ID. + * @param[in] nth Specifies the attachment number been saved. the minimum number is "1". + * @param[out] handle Specifies the handle for stopping downloading. + * @exception none + * @see email_mailbox_t + * @remarks N/A + */ +EXPORT_API int email_download_attachment(int mail_id, int nth, unsigned* handle); + + +/** + * @open + * @fn email_cancel_job(int account_id, int handle); + * @brief cancel the ongoing job.This function is invoked if user wants to cancel any ongoing job of a specified account. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] input_account_id Specifies the account ID. + * @param[in] input_handle Specifies the handle for stopping the operation. + * @param[in] input_cancel_type Specifies the type of cancellation. + * @exception none + * @see none + * @remarks N/A + */ + +EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_cancelation_type input_cancel_type); + + +/** + * @open + * @fn email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t * status); + * @brief get pending job list.This function is invoked if user wants to get the pending job list with status information . + * Based on action item of a mail is for a specific account this will give all pending job list. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] account_id Specifies the action of the job. + * @param[in] account_id Specifies the account ID. + * @param[in] mail_id Specifies the mail ID. + * @param[out]status Specifies the status of the job. + * @exception none + * @see email_action_t and email_event_status_type_t + * @remarks N/A + */ +EXPORT_API int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t * status); + + +/** + * @open + * @fn email_get_network_status(int* on_sending, int* on_receiving) + * @brief This function gives the current network status.This gives the information to the user whether sending operation is in progress or receiving operation. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[out] on_sending True if sending is in progress. + * @param[out] on_receiving True if receivng is in progress. + * @exception none + * @see none + * @remarks N/A + */ +EXPORT_API int email_get_network_status(int* on_sending, int* on_receiving); + +/** + * @open + * @fn email_send_saved(int account_id, email_option_t* sending_option, unsigned* handle) + * @brief Send all mails to been saved in Offline-mode.This function is invoked when user wants to send an email and after saving it. + * This will save the email in draft mailbox and then sends. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] account_id Specifies the account ID. + * @param[in] sending_option Specifies the sending option. + * @param[out] handle Specifies the handle for stopping sending. + * @exception none + * @see email_option_t + * @remarks N/A + */ +EXPORT_API int email_send_saved(int account_id, email_option_t* sending_option, unsigned* handle); + +/** + * @open + * @fn email_sync_imap_mailbox_list(int account_id, unsigned* handle) + * @brief fetch all the mailbox names from server and store the non-existing mailboxes in DB.This function is invoked when user wants to download all server mailboxes from IMAP server + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] account_id Specifies the account ID. + * @param[out] handle Specifies the handle for stopping Network operation. + * @exception none + * @see none + * @remarks N/A + */ +EXPORT_API int email_sync_imap_mailbox_list(int account_id, unsigned* handle); + +/** + * @open + * @fn 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, unsigned *output_handle) + * @brief Search the mails on server. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] account_id Specifies the Account ID + * @param[in] mailbox_id Specifies the Mailbox ID + * @param[in] search_type Specifies the searching type(EMAIL_SEARCH_FILTER_SUBJECT, EMAIL_SEARCH_FILTER_SENDER, EMAIL_SEARCH_FILTER_RECIPIENT, EMAIL_SEARCH_FILTER_ALL) + * @param[in] search_value Specifies the value to use for searching. (ex : Subject, email address, display name) + * @exception none + * @see email_search_filter_t, + * @code + * @endcode + * @remarks N/A + */ +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, unsigned *output_handle); + +EXPORT_API int email_clear_result_of_search_mail_on_server(int input_account_id); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/** +* @} +*/ + + +#endif /* __EMAIL_API_NETWORK_H__ */ diff --git a/email-api/include/email-api-rule.h b/email-api/include/email-api-rule.h index 71a1ca2..096b98e 100755 --- a/email-api/include/email-api-rule.h +++ b/email-api/include/email-api-rule.h @@ -1,218 +1,218 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - -#ifndef __EMAIL_API_RULE_H__ -#define __EMAIL_API_RULE_H__ - -#include "email-types.h" - -/** -* @defgroup EMAIL_SERVICE Email Service -* @{ -*/ - -/** -* @ingroup EMAIL_SERVICE -* @defgroup EMAIL_API_RULE Email Rule API -* @{ -*/ - - /** - * - * This file contains the data structures and interfaces needed for application, - * to interact with email-service. - * @file email-api-rule.h - * @author Kyuho Jo - * @author Sunghyun Kwon - * @version 0.1 - * @brief This file contains the data structures and interfaces of Rule related Functionality provided by - * email-service . - * @{ - - * @code - * #include "email-api-rule.h" - * bool - * other_app_invoke_uniform_api_sample(int* error_code) - * { - * int err = EMF_ERROR_NONE; - * emf_rule_t* rule = NULL; - * int filter_id = 1; - * int count = 0; - * - * // Get a information of filtering - * printf("Enter filter Id:\n"); - * scanf("%d",&filter_id); - * - * if(EMF_ERROR_NONE == email_get_rule (filter_id,&rule)) - * //success - * else - * //failure - * - * // Get all filterings - * if(EMF_ERROR_NONE == email_get_rule_list(&rule,&count)) - * //success - * else - * //failure - * - * - * // Add a filter information - * if(EMF_ERROR_NONE == email_add_rule (rule)) - * //success - * else - * //failure - * err = email_free_rule (&rule,1); - * - * // Change a filter information - * if(EMF_ERROR_NONE == email_update_rule (filter_id,rule)) - * //success - * else - * //failure - * err = email_free_rule (&rule,1); - * - * // Delete a filter information - * printf("Enter filter Id:\n"); - * scanf("%d",&filter_id); - * - * if(EMF_ERROR_NONE == email_delete_rule (filter_id)) - * //success - * else - * //failure - * - * // Free allocated memory - * if(EMF_ERROR_NONE == email_free_rule (&rule,1)) - * //success - * else - * //failure - * - * } - * - * @endcode - * @} - */ - - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - - * @open - * @fn email_get_rule(int filter_id, emf_rule_t** filtering_set) - * @brief Get a information of filtering. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure - * @param[in] filter_id Specifies the filter ID. - * @param[out] filtering_set The returned information of filter are saved here. - * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument - * @see emf_rule_t - * @remarks N/A - */ -EXPORT_API int email_get_rule(int filter_id, emf_rule_t** filtering_set); - -/** - - * @open - * @fn email_get_rule_list(emf_rule_t** filtering_set, int* count) - * @brief Get all filterings.This function gives all the filter rules already set before by user. - * This will provide total number of filter rules available and information of all rules. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure - * @param[out] filtering_set The returned filterings are saved here.(possibly NULL) - * @param[out] count The count of returned filters is saved here.(possibly 0) - * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument - * @see emf_rule_t - * @remarks N/A - */ -EXPORT_API int email_get_rule_list(emf_rule_t** filtering_set, int* count); - -/** - - * @open - * @fn email_add_rule(emf_rule_t* filtering_set) - * @brief Add a filter information.This function is invoked if user wants to add a new filter rule. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] filtering_set Specifies the pointer of adding filter structure. - * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument - * @see emf_rule_t - * @remarks N/A - */ -EXPORT_API int email_add_rule(emf_rule_t* filtering_set); - -/** - - * @open - * @fn email_update_rule(int filter_id, emf_rule_t* new_set) - * @brief Change a filter information.This function will update the existing filter rule with new information. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure. - * @param[in] filter_id Specifies the original filter ID. - * @param[in] new_set Specifies the information of new filter. - * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument - * @see emf_rule_t - * @remarks N/A - */ -EXPORT_API int email_update_rule(int filter_id, emf_rule_t* new_set); - -/** - - * @open - * @fn email_delete_rule(int filter_id) - * @brief Delete a filter information.This function will delete the exsting filter information by specified filter Id. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure - * @param[in] filter_id Specifies the filter ID. - * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument - * @see none - * @remarks N/A - */ -EXPORT_API int email_delete_rule(int filter_id); - - - -/** - - * @open - * @fn email_free_rule (emf_rule_t** filtering_set, int count) - * @brief Free allocated memory. - * - * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure - * @param[in] filtering_set Specifies the pointer of pointer of filter structure for memory free. - * @param[in] count Specifies the count of filter. - * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument - * @see emf_rule_t - * @remarks N/A - */ -EXPORT_API int email_free_rule (emf_rule_t** filtering_set, int count); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -/** -* @} @} -*/ - - -#endif /* __EMAIL_API_RULE_H__ */ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +#ifndef __EMAIL_API_RULE_H__ +#define __EMAIL_API_RULE_H__ + +#include "email-types.h" + +/** +* @defgroup EMAIL_SERVICE Email Service +* @{ +*/ + +/** +* @ingroup EMAIL_SERVICE +* @defgroup EMAIL_API_RULE Email Rule API +* @{ +*/ + + /** + * + * This file contains the data structures and interfaces needed for application, + * to interact with email-service. + * @file email-api-rule.h + * @author Kyuho Jo + * @author Sunghyun Kwon + * @version 0.1 + * @brief This file contains the data structures and interfaces of Rule related Functionality provided by + * email-service . + * @{ + + * @code + * #include "email-api-rule.h" + * bool + * other_app_invoke_uniform_api_sample(int* error_code) + * { + * int err = EMAIL_ERROR_NONE; + * email_rule_t* rule = NULL; + * int filter_id = 1; + * int count = 0; + * + * // Get a information of filtering + * printf("Enter filter Id:\n"); + * scanf("%d",&filter_id); + * + * if(EMAIL_ERROR_NONE == email_get_rule (filter_id,&rule)) + * //success + * else + * //failure + * + * // Get all filterings + * if(EMAIL_ERROR_NONE == email_get_rule_list(&rule,&count)) + * //success + * else + * //failure + * + * + * // Add a filter information + * if(EMAIL_ERROR_NONE == email_add_rule (rule)) + * //success + * else + * //failure + * err = email_free_rule (&rule,1); + * + * // Change a filter information + * if(EMAIL_ERROR_NONE == email_update_rule (filter_id,rule)) + * //success + * else + * //failure + * err = email_free_rule (&rule,1); + * + * // Delete a filter information + * printf("Enter filter Id:\n"); + * scanf("%d",&filter_id); + * + * if(EMAIL_ERROR_NONE == email_delete_rule (filter_id)) + * //success + * else + * //failure + * + * // Free allocated memory + * if(EMAIL_ERROR_NONE == email_free_rule (&rule,1)) + * //success + * else + * //failure + * + * } + * + * @endcode + * @} + */ + + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + + * @open + * @fn email_get_rule(int filter_id, email_rule_t** filtering_set) + * @brief Get a information of filtering. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure + * @param[in] filter_id Specifies the filter ID. + * @param[out] filtering_set The returned information of filter are saved here. + * @exception #EMAIL_ERROR-INVALID_PARAM -Invalid argument + * @see email_rule_t + * @remarks N/A + */ +EXPORT_API int email_get_rule(int filter_id, email_rule_t** filtering_set); + +/** + + * @open + * @fn email_get_rule_list(email_rule_t** filtering_set, int* count) + * @brief Get all filterings.This function gives all the filter rules already set before by user. + * This will provide total number of filter rules available and information of all rules. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure + * @param[out] filtering_set The returned filterings are saved here.(possibly NULL) + * @param[out] count The count of returned filters is saved here.(possibly 0) + * @exception #EMAIL_ERROR-INVALID_PARAM -Invalid argument + * @see email_rule_t + * @remarks N/A + */ +EXPORT_API int email_get_rule_list(email_rule_t** filtering_set, int* count); + +/** + + * @open + * @fn email_add_rule(email_rule_t* filtering_set) + * @brief Add a filter information.This function is invoked if user wants to add a new filter rule. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] filtering_set Specifies the pointer of adding filter structure. + * @exception #EMAIL_ERROR-INVALID_PARAM -Invalid argument + * @see email_rule_t + * @remarks N/A + */ +EXPORT_API int email_add_rule(email_rule_t* filtering_set); + +/** + + * @open + * @fn email_update_rule(int filter_id, email_rule_t* new_set) + * @brief Change a filter information.This function will update the existing filter rule with new information. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure. + * @param[in] filter_id Specifies the original filter ID. + * @param[in] new_set Specifies the information of new filter. + * @exception #EMAIL_ERROR-INVALID_PARAM -Invalid argument + * @see email_rule_t + * @remarks N/A + */ +EXPORT_API int email_update_rule(int filter_id, email_rule_t* new_set); + +/** + + * @open + * @fn email_delete_rule(int filter_id) + * @brief Delete a filter information.This function will delete the exsting filter information by specified filter Id. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure + * @param[in] filter_id Specifies the filter ID. + * @exception #EMAIL_ERROR-INVALID_PARAM -Invalid argument + * @see none + * @remarks N/A + */ +EXPORT_API int email_delete_rule(int filter_id); + + + +/** + + * @open + * @fn email_free_rule (email_rule_t** filtering_set, int count) + * @brief Free allocated memory. + * + * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure + * @param[in] filtering_set Specifies the pointer of pointer of filter structure for memory free. + * @param[in] count Specifies the count of filter. + * @exception #EMAIL_ERROR-INVALID_PARAM -Invalid argument + * @see email_rule_t + * @remarks N/A + */ +EXPORT_API int email_free_rule (email_rule_t** filtering_set, int count); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/** +* @} @} +*/ + + +#endif /* __EMAIL_API_RULE_H__ */ diff --git a/email-api/include/email-api-smime.h b/email-api/include/email-api-smime.h new file mode 100755 index 0000000..2e46eed --- /dev/null +++ b/email-api/include/email-api-smime.h @@ -0,0 +1,53 @@ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + +#ifndef __EMAIL_API_SMIME_H__ +#define __EMAIL_API_SMIME_H__ + +#include "email-types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +EXPORT_API int email_add_certificate(char *certificate_path, char *email_address); + +EXPORT_API int email_delete_certificate(char *email_address); + +EXPORT_API int email_get_certificate(char *email_address, email_certificate_t **certificate); + +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_verify_signature(char *certificate_path, int mail_id, int *verify); + +EXPORT_API int email_verify_certificate(char *certificate_path, int *verify); + +EXPORT_API int email_get_resolve_recipients(int account_id, char *email_address, unsigned *handle); + +EXPORT_API int email_validate_certificate(int account_id, char *email_address, unsigned *handle); + +EXPORT_API int email_free_certificate(email_certificate_t **certificate, int count); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __EMAIL_API_SMIME_H__ */ diff --git a/email-api/include/email-api.h b/email-api/include/email-api.h index 67e7f2d..b7b294d 100755 --- a/email-api/include/email-api.h +++ b/email-api/include/email-api.h @@ -1,74 +1,76 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - -#ifndef __EMAIL_API_H__ -#define __EMAIL_API_H__ - -#include -#include -#include "email-types.h" -#include "email-api-account.h" -#include "email-api-init.h" -#include "email-api-mail.h" -#include "email-api-mailbox.h" -#include "email-api-network.h" -#include "email-api-rule.h" - - -/** -* @defgroup EMAIL_SERVICE Email Service -* @{ -*/ - -/** -* @{ -*/ - -/** - * - * This file contains the data structures and interfaces needed for application, - * to interact with email-service. - * @file email-api.h - * @author Kyuho Jo - * @author Sunghyun Kwon - * @version 0.1 - * @brief This file contains the data structures and interfaces provided by - * email-service. - */ - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#ifdef __cplusplus -} -#endif - -/** -* @} @} -*/ - -#endif /* __EMAIL_MAPI_H__ */ - - +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +#ifndef __EMAIL_API_H__ +#define __EMAIL_API_H__ + +#include +#include +#include "email-types.h" +#include "email-api-account.h" +#include "email-api-init.h" +#include "email-api-mail.h" +#include "email-api-mailbox.h" +#include "email-api-network.h" +#include "email-api-rule.h" +#include "email-api-smime.h" +#include "email-api-etc.h" + + +/** +* @defgroup EMAIL_SERVICE Email Service +* @{ +*/ + +/** +* @{ +*/ + +/** + * + * This file contains the data structures and interfaces needed for application, + * to interact with email-service. + * @file email-api.h + * @author Kyuho Jo + * @author Sunghyun Kwon + * @version 0.1 + * @brief This file contains the data structures and interfaces provided by + * email-service. + */ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#ifdef __cplusplus +} +#endif + +/** +* @} @} +*/ + +#endif /* __EMAIL_MAPI_H__ */ + + diff --git a/email-common-use/CMakeLists.txt b/email-common-use/CMakeLists.txt index df3e34e..a1d63df 100755 --- a/email-common-use/CMakeLists.txt +++ b/email-common-use/CMakeLists.txt @@ -17,6 +17,7 @@ SET(COMMON-USE-LIB "email-common-use") SET(COMMON-USE-SRCS ${CMAKE_SOURCE_DIR}/email-common-use/email-convert.c ${CMAKE_SOURCE_DIR}/email-common-use/email-utilities.c + ${CMAKE_SOURCE_DIR}/email-common-use/tpl.c ) INCLUDE_DIRECTORIES( @@ -27,7 +28,7 @@ INCLUDE_DIRECTORIES( ) INCLUDE(FindPkgConfig) -pkg_check_modules(common_pkgs REQUIRED glib-2.0 dlog vconf contacts-service uw-imap-toolkit) +pkg_check_modules(common_pkgs REQUIRED glib-2.0 dlog dbus-1 vconf contacts-service uw-imap-toolkit) FOREACH(flag ${common_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/email-common-use/email-convert.c b/email-common-use/email-convert.c index 7b11f77..07834af 100755 --- a/email-common-use/email-convert.c +++ b/email-common-use/email-convert.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Kyuho Jo , Sunghyun Kwon -* +* * 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 @@ -28,7 +28,7 @@ #include "email-core-utils.h" #include "email-utilities.h" #include "email-storage.h" - +#include "tpl.h" #define fSEEN 0x1 #define fDELETED 0x2 @@ -39,18 +39,18 @@ #define fATTACHMENT 0x40 #define fFORWARD 0x80 -INTERNAL_FUNC int em_convert_mail_flag_to_int(emf_mail_flag_t flag, int *i_flag, int *err_code) +INTERNAL_FUNC int em_convert_mail_flag_to_int(email_mail_flag_t flag, int *i_flag, int *err_code) { EM_DEBUG_FUNC_BEGIN("i_flag[%p], err_code[%p]", i_flag, err_code); if (!i_flag) { if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - *i_flag = + *i_flag = (flag.seen ? fSEEN : 0) | (flag.deleted ? fDELETED : 0) | (flag.flagged ? fFLAGGED : 0) | @@ -64,17 +64,17 @@ INTERNAL_FUNC int em_convert_mail_flag_to_int(emf_mail_flag_t flag, int *i_flag, return true; } -INTERNAL_FUNC int em_convert_mail_int_to_flag(int i_flag, emf_mail_flag_t* flag, int* err_code) +INTERNAL_FUNC int em_convert_mail_int_to_flag(int i_flag, email_mail_flag_t* flag, int* err_code) { EM_DEBUG_FUNC_BEGIN("i_flag[0x%02x], flag[%p], err_code[%p]", i_flag, flag, err_code); - + if (!flag) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - + flag->seen = (i_flag & fSEEN ? 1 : 0); flag->deleted = (i_flag & fDELETED ? 1 : 0); flag->flagged = (i_flag & fFLAGGED ? 1 : 0); @@ -93,15 +93,15 @@ INTERNAL_FUNC int em_convert_mail_int_to_flag(int i_flag, emf_mail_flag_t* flag, INTERNAL_FUNC int em_convert_mail_tbl_to_mail_status(emstorage_mail_tbl_t *mail_tbl_data, int *result_mail_status, int* err_code) { EM_DEBUG_FUNC_BEGIN("mail_tbl_data[%p], result_mail_status [%p], err_code[%p]", mail_tbl_data, result_mail_status, err_code); - int ret = false, error_code = EMF_ERROR_NONE; + int ret = false, error_code = EMAIL_ERROR_NONE; int has_attachment = 0; - + if(!mail_tbl_data || !result_mail_status) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - error_code = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - + has_attachment = (mail_tbl_data->attachment_count > mail_tbl_data->inline_content_count) ? 1 : 0; *result_mail_status = (mail_tbl_data->flags_seen_field ? fSEEN : 0) | @@ -117,19 +117,19 @@ INTERNAL_FUNC int em_convert_mail_tbl_to_mail_status(emstorage_mail_tbl_t *mail_ FINISH_OFF: if (err_code != NULL) *err_code = error_code; - + EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; } - + INTERNAL_FUNC int em_convert_mail_status_to_mail_tbl(int mail_status, emstorage_mail_tbl_t *result_mail_tbl_data, int* err_code) { EM_DEBUG_FUNC_BEGIN("mail_status[%d], result_mail_tbl_data [%p], err_code[%p]", mail_status, result_mail_tbl_data, err_code); - int ret = false, error_code = EMF_ERROR_NONE; + int ret = false, error_code = EMAIL_ERROR_NONE; if(!result_mail_tbl_data) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - error_code = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -145,19 +145,19 @@ INTERNAL_FUNC int em_convert_mail_status_to_mail_tbl(int mail_status, emstorage_ FINISH_OFF: if (err_code != NULL) *err_code = error_code; - + EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; } -INTERNAL_FUNC int em_convert_mail_tbl_to_mail_flag(emstorage_mail_tbl_t *mail_tbl_data, emf_mail_flag_t *result_flag, int* err_code) +INTERNAL_FUNC int em_convert_mail_tbl_to_mail_flag(emstorage_mail_tbl_t *mail_tbl_data, email_mail_flag_t *result_flag, int* err_code) { EM_DEBUG_FUNC_BEGIN("mail_tbl_data[%p], result_flag [%p], err_code[%p]", mail_tbl_data, result_flag, err_code); - int ret = false, error_code = EMF_ERROR_NONE; + int ret = false, error_code = EMAIL_ERROR_NONE; if(!mail_tbl_data || !result_flag) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - error_code = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -174,19 +174,19 @@ INTERNAL_FUNC int em_convert_mail_tbl_to_mail_flag(emstorage_mail_tbl_t *mail_tb FINISH_OFF: if (err_code != NULL) *err_code = error_code; - + EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; } -INTERNAL_FUNC int em_convert_mail_flag_to_mail_tbl(emf_mail_flag_t *flag, emstorage_mail_tbl_t *result_mail_tbl_data, int* err_code) +INTERNAL_FUNC int em_convert_mail_flag_to_mail_tbl(email_mail_flag_t *flag, emstorage_mail_tbl_t *result_mail_tbl_data, int* err_code) { EM_DEBUG_FUNC_BEGIN("flag[%p], result_mail_tbl_data [%p], err_code[%p]", flag, result_mail_tbl_data, err_code); - int ret = false, error_code = EMF_ERROR_NONE; + int ret = false, error_code = EMAIL_ERROR_NONE; if(!flag || !result_mail_tbl_data) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - error_code = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -202,148 +202,203 @@ INTERNAL_FUNC int em_convert_mail_flag_to_mail_tbl(emf_mail_flag_t *flag, emstor FINISH_OFF: if (err_code != NULL) *err_code = error_code; - + EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; } -INTERNAL_FUNC int em_convert_account_to_account_tbl(emf_account_t *account, emstorage_account_tbl_t *account_tbl) +INTERNAL_FUNC int em_convert_account_to_account_tbl(email_account_t *account, emstorage_account_tbl_t *account_tbl) { EM_DEBUG_FUNC_BEGIN("account[%p], account_tbl[%p]", account, account_tbl); int ret = 1; - account_tbl->account_bind_type = account->account_bind_type; - account_tbl->account_name = EM_SAFE_STRDUP(account->account_name); - account_tbl->receiving_server_type = account->receiving_server_type; - account_tbl->receiving_server_addr = EM_SAFE_STRDUP(account->receiving_server_addr); - account_tbl->email_addr = EM_SAFE_STRDUP(account->email_addr); - account_tbl->user_name = EM_SAFE_STRDUP(account->user_name); - account_tbl->password = EM_SAFE_STRDUP(account->password); - account_tbl->retrieval_mode = account->retrieval_mode; - account_tbl->port_num = account->port_num; - account_tbl->use_security = account->use_security; - account_tbl->sending_server_type = account->sending_server_type; - account_tbl->sending_server_addr = EM_SAFE_STRDUP(account->sending_server_addr); - account_tbl->sending_port_num = account->sending_port_num; - account_tbl->sending_auth = account->sending_auth; - account_tbl->sending_security = account->sending_security; - account_tbl->sending_user = EM_SAFE_STRDUP(account->sending_user); - account_tbl->sending_password = EM_SAFE_STRDUP(account->sending_password); - account_tbl->display_name = EM_SAFE_STRDUP(account->display_name); - account_tbl->reply_to_addr = EM_SAFE_STRDUP(account->reply_to_addr); - account_tbl->return_addr = EM_SAFE_STRDUP(account->return_addr); - account_tbl->account_id = account->account_id; - account_tbl->keep_on_server = account->keep_on_server; - account_tbl->flag1 = account->flag1; - account_tbl->flag2 = account->flag2; - account_tbl->pop_before_smtp = account->pop_before_smtp; - account_tbl->apop = account->apop; - account_tbl->logo_icon_path = EM_SAFE_STRDUP(account->logo_icon_path); - account_tbl->preset_account = account->preset_account; - account_tbl->options.priority = account->options.priority; - account_tbl->options.keep_local_copy = account->options.keep_local_copy; - account_tbl->options.req_delivery_receipt = account->options.req_delivery_receipt; - account_tbl->options.req_read_receipt = account->options.req_read_receipt; - account_tbl->options.download_limit = account->options.download_limit; - account_tbl->options.block_address = account->options.block_address; - account_tbl->options.block_subject = account->options.block_subject; - account_tbl->options.display_name_from = EM_SAFE_STRDUP(account->options.display_name_from); - account_tbl->options.reply_with_body = account->options.reply_with_body; - account_tbl->options.forward_with_files = account->options.forward_with_files; - account_tbl->options.add_myname_card = account->options.add_myname_card; - account_tbl->options.add_signature = account->options.add_signature; - account_tbl->options.signature = EM_SAFE_STRDUP(account->options.signature); - account_tbl->options.add_my_address_to_bcc = account->options.add_my_address_to_bcc; - account_tbl->target_storage = account->target_storage; - account_tbl->check_interval = account->check_interval; - account_tbl->my_account_id = account->my_account_id; - account_tbl->index_color = account->index_color; - + account_tbl->account_name = EM_SAFE_STRDUP(account->account_name); + account_tbl->incoming_server_type = account->incoming_server_type; + account_tbl->incoming_server_address = EM_SAFE_STRDUP(account->incoming_server_address); + account_tbl->user_email_address = EM_SAFE_STRDUP(account->user_email_address); + account_tbl->incoming_server_user_name = EM_SAFE_STRDUP(account->incoming_server_user_name); + account_tbl->incoming_server_password = EM_SAFE_STRDUP(account->incoming_server_password); + account_tbl->retrieval_mode = account->retrieval_mode; + account_tbl->incoming_server_port_number = account->incoming_server_port_number; + account_tbl->incoming_server_secure_connection = account->incoming_server_secure_connection; + account_tbl->outgoing_server_type = account->outgoing_server_type; + account_tbl->outgoing_server_address = EM_SAFE_STRDUP(account->outgoing_server_address); + account_tbl->outgoing_server_port_number = account->outgoing_server_port_number; + account_tbl->outgoing_server_need_authentication = account->outgoing_server_need_authentication; + account_tbl->outgoing_server_secure_connection = account->outgoing_server_secure_connection; + account_tbl->outgoing_server_user_name = EM_SAFE_STRDUP(account->outgoing_server_user_name); + account_tbl->outgoing_server_password = EM_SAFE_STRDUP(account->outgoing_server_password); + account_tbl->user_display_name = EM_SAFE_STRDUP(account->user_display_name); + account_tbl->reply_to_address = EM_SAFE_STRDUP(account->reply_to_address); + account_tbl->return_address = EM_SAFE_STRDUP(account->return_address); + account_tbl->account_id = account->account_id; + account_tbl->keep_mails_on_pop_server_after_download = account->keep_mails_on_pop_server_after_download; + account_tbl->auto_download_size = account->auto_download_size; + account_tbl->outgoing_server_use_same_authenticator = account->outgoing_server_use_same_authenticator; + account_tbl->pop_before_smtp = account->pop_before_smtp; + account_tbl->incoming_server_requires_apop = account->incoming_server_requires_apop; + account_tbl->logo_icon_path = EM_SAFE_STRDUP(account->logo_icon_path); + + account_tbl->user_data = em_memdup(account->user_data, account->user_data_length); + account_tbl->user_data_length = account->user_data_length; + + account_tbl->options.priority = account->options.priority; + account_tbl->options.keep_local_copy = account->options.keep_local_copy; + account_tbl->options.req_delivery_receipt = account->options.req_delivery_receipt; + account_tbl->options.req_read_receipt = account->options.req_read_receipt; + account_tbl->options.download_limit = account->options.download_limit; + account_tbl->options.block_address = account->options.block_address; + account_tbl->options.block_subject = account->options.block_subject; + account_tbl->options.display_name_from = EM_SAFE_STRDUP(account->options.display_name_from); + account_tbl->options.reply_with_body = account->options.reply_with_body; + account_tbl->options.forward_with_files = account->options.forward_with_files; + account_tbl->options.add_myname_card = account->options.add_myname_card; + account_tbl->options.add_signature = account->options.add_signature; + account_tbl->options.signature = EM_SAFE_STRDUP(account->options.signature); + account_tbl->options.add_my_address_to_bcc = account->options.add_my_address_to_bcc; + account_tbl->check_interval = account->check_interval; + account_tbl->account_svc_id = account->account_svc_id; + account_tbl->sync_status = account->sync_status; + account_tbl->sync_disabled = account->sync_disabled; + account_tbl->default_mail_slot_size = account->default_mail_slot_size; + account_tbl->smime_type = account->smime_type; + account_tbl->certificate_path = EM_SAFE_STRDUP(account->certificate_path); + account_tbl->cipher_type = account->cipher_type; + account_tbl->digest_type = account->digest_type; + + EM_DEBUG_FUNC_END(); return ret; } -INTERNAL_FUNC int em_convert_account_tbl_to_account(emstorage_account_tbl_t *account_tbl, emf_account_t *account) +INTERNAL_FUNC int em_convert_account_tbl_to_account(emstorage_account_tbl_t *account_tbl, email_account_t *account) { EM_DEBUG_FUNC_BEGIN("account_tbl[%p], account[%p]", account_tbl, account); int ret = 1; - account->account_bind_type = account_tbl->account_bind_type; - account->account_name = EM_SAFE_STRDUP(account_tbl->account_name); - account->receiving_server_type = account_tbl->receiving_server_type; - account->receiving_server_addr = EM_SAFE_STRDUP(account_tbl->receiving_server_addr); - account->email_addr = EM_SAFE_STRDUP(account_tbl->email_addr); - account->user_name = EM_SAFE_STRDUP(account_tbl->user_name); - account->password = EM_SAFE_STRDUP(account_tbl->password); - account->retrieval_mode = account_tbl->retrieval_mode; - account->port_num = account_tbl->port_num; - account->use_security = account_tbl->use_security; - account->sending_server_type = account_tbl->sending_server_type; - account->sending_server_addr = EM_SAFE_STRDUP(account_tbl->sending_server_addr); - account->sending_port_num = account_tbl->sending_port_num; - account->sending_auth = account_tbl->sending_auth; - account->sending_security = account_tbl->sending_security; - account->sending_user = EM_SAFE_STRDUP(account_tbl->sending_user); - account->sending_password = EM_SAFE_STRDUP(account_tbl->sending_password); - account->display_name = EM_SAFE_STRDUP(account_tbl->display_name); - account->reply_to_addr = EM_SAFE_STRDUP(account_tbl->reply_to_addr); - account->return_addr = EM_SAFE_STRDUP(account_tbl->return_addr); - account->account_id = account_tbl->account_id; - account->keep_on_server = account_tbl->keep_on_server; - account->flag1 = account_tbl->flag1; - account->flag2 = account_tbl->flag2; - account->pop_before_smtp = account_tbl->pop_before_smtp; - account->apop = account_tbl->apop; - account->logo_icon_path = EM_SAFE_STRDUP(account_tbl->logo_icon_path); - account->preset_account = account_tbl->preset_account; - account->options.priority = account_tbl->options.priority; - account->options.keep_local_copy = account_tbl->options.keep_local_copy; - account->options.req_delivery_receipt = account_tbl->options.req_delivery_receipt; - account->options.req_read_receipt = account_tbl->options.req_read_receipt; - account->options.download_limit = account_tbl->options.download_limit; - account->options.block_address = account_tbl->options.block_address; - account->options.block_subject = account_tbl->options.block_subject; - account->options.display_name_from = EM_SAFE_STRDUP(account_tbl->options.display_name_from); - account->options.reply_with_body = account_tbl->options.reply_with_body; - account->options.forward_with_files = account_tbl->options.forward_with_files; - account->options.add_myname_card = account_tbl->options.add_myname_card; - account->options.add_signature = account_tbl->options.add_signature; - account->options.signature = EM_SAFE_STRDUP(account_tbl->options.signature); - account->options.add_my_address_to_bcc = account_tbl->options.add_my_address_to_bcc; - account->target_storage = account_tbl->target_storage; - account->check_interval = account_tbl->check_interval; - account->my_account_id = account_tbl->my_account_id; - account->index_color = account_tbl->index_color; - + account->account_name = EM_SAFE_STRDUP(account_tbl->account_name); + account->incoming_server_type = account_tbl->incoming_server_type; + account->incoming_server_address = EM_SAFE_STRDUP(account_tbl->incoming_server_address); + account->user_email_address = EM_SAFE_STRDUP(account_tbl->user_email_address); + account->incoming_server_user_name = EM_SAFE_STRDUP(account_tbl->incoming_server_user_name); + account->incoming_server_password = EM_SAFE_STRDUP(account_tbl->incoming_server_password); + account->retrieval_mode = account_tbl->retrieval_mode; + account->incoming_server_port_number = account_tbl->incoming_server_port_number; + account->incoming_server_secure_connection = account_tbl->incoming_server_secure_connection; + account->outgoing_server_type = account_tbl->outgoing_server_type; + account->outgoing_server_address = EM_SAFE_STRDUP(account_tbl->outgoing_server_address); + account->outgoing_server_port_number = account_tbl->outgoing_server_port_number; + account->outgoing_server_need_authentication = account_tbl->outgoing_server_need_authentication; + account->outgoing_server_secure_connection = account_tbl->outgoing_server_secure_connection; + account->outgoing_server_user_name = EM_SAFE_STRDUP(account_tbl->outgoing_server_user_name); + account->outgoing_server_password = EM_SAFE_STRDUP(account_tbl->outgoing_server_password); + account->user_display_name = EM_SAFE_STRDUP(account_tbl->user_display_name); + account->reply_to_address = EM_SAFE_STRDUP(account_tbl->reply_to_address); + account->return_address = EM_SAFE_STRDUP(account_tbl->return_address); + account->account_id = account_tbl->account_id; + account->keep_mails_on_pop_server_after_download = account_tbl->keep_mails_on_pop_server_after_download; + account->auto_download_size = account_tbl->auto_download_size; + account->outgoing_server_use_same_authenticator = account_tbl->outgoing_server_use_same_authenticator; + account->pop_before_smtp = account_tbl->pop_before_smtp; + account->incoming_server_requires_apop = account_tbl->incoming_server_requires_apop; + account->logo_icon_path = EM_SAFE_STRDUP(account_tbl->logo_icon_path); + account->user_data = em_memdup(account_tbl->user_data, account_tbl->user_data_length); + account->user_data_length = account_tbl->user_data_length; + account->options.priority = account_tbl->options.priority; + account->options.keep_local_copy = account_tbl->options.keep_local_copy; + account->options.req_delivery_receipt = account_tbl->options.req_delivery_receipt; + account->options.req_read_receipt = account_tbl->options.req_read_receipt; + account->options.download_limit = account_tbl->options.download_limit; + account->options.block_address = account_tbl->options.block_address; + account->options.block_subject = account_tbl->options.block_subject; + account->options.display_name_from = EM_SAFE_STRDUP(account_tbl->options.display_name_from); + account->options.reply_with_body = account_tbl->options.reply_with_body; + account->options.forward_with_files = account_tbl->options.forward_with_files; + account->options.add_myname_card = account_tbl->options.add_myname_card; + account->options.add_signature = account_tbl->options.add_signature; + account->options.signature = EM_SAFE_STRDUP(account_tbl->options.signature); + account->options.add_my_address_to_bcc = account_tbl->options.add_my_address_to_bcc; + account->check_interval = account_tbl->check_interval; + account->account_svc_id = account_tbl->account_svc_id; + account->sync_status = account_tbl->sync_status; + account->sync_disabled = account_tbl->sync_disabled; + account->default_mail_slot_size = account_tbl->default_mail_slot_size; + account->smime_type = account_tbl->smime_type; + account->certificate_path = EM_SAFE_STRDUP(account_tbl->certificate_path); + account->cipher_type = account_tbl->cipher_type; + account->digest_type = account_tbl->digest_type; + + EM_DEBUG_FUNC_END(); + return ret; +} + +INTERNAL_FUNC int em_convert_mailbox_to_mailbox_tbl(email_mailbox_t *mailbox, emstorage_mailbox_tbl_t *mailbox_tbl) +{ + EM_DEBUG_FUNC_BEGIN("mailbox[%p], mailbox_tbl[%p]", mailbox, mailbox_tbl); + int ret = 1; + + mailbox_tbl->account_id = mailbox->account_id; + mailbox_tbl->mailbox_id = mailbox->mailbox_id; + mailbox_tbl->mailbox_name = EM_SAFE_STRDUP(mailbox->mailbox_name); + mailbox_tbl->alias = EM_SAFE_STRDUP(mailbox->alias); + mailbox_tbl->local_yn = mailbox->local; + mailbox_tbl->mailbox_type = mailbox->mailbox_type; + mailbox_tbl->unread_count = mailbox->unread_count; + mailbox_tbl->total_mail_count_on_local = mailbox->total_mail_count_on_local; + mailbox_tbl->total_mail_count_on_server = mailbox->total_mail_count_on_server; + mailbox_tbl->mail_slot_size = mailbox->mail_slot_size; + EM_DEBUG_FUNC_END(); return ret; } -INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_table_data, int item_count, emf_mail_data_t **mail_data, int *error) +INTERNAL_FUNC int em_convert_mailbox_tbl_to_mailbox(emstorage_mailbox_tbl_t *mailbox_tbl, email_mailbox_t *mailbox) +{ + EM_DEBUG_FUNC_BEGIN("mailbox_tbl[%p], mailbox[%p]", mailbox_tbl, mailbox); + int ret = 1; + + mailbox->account_id = mailbox_tbl->account_id; + mailbox->mailbox_id = mailbox_tbl->mailbox_id; + mailbox->mailbox_name = EM_SAFE_STRDUP(mailbox_tbl->mailbox_name); + mailbox->alias = EM_SAFE_STRDUP(mailbox_tbl->alias); + mailbox->local = mailbox_tbl->local_yn; + mailbox->mailbox_type = mailbox_tbl->mailbox_type; + mailbox->unread_count = mailbox_tbl->unread_count; + mailbox->total_mail_count_on_local = mailbox_tbl->total_mail_count_on_local; + mailbox->total_mail_count_on_server = mailbox_tbl->total_mail_count_on_server; + mailbox->mail_slot_size = mailbox_tbl->mail_slot_size; + mailbox->last_sync_time = mailbox_tbl->last_sync_time; + + EM_DEBUG_FUNC_END(); + return ret; +} + + +INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_table_data, int item_count, email_mail_data_t **mail_data, int *error) { EM_DEBUG_FUNC_BEGIN("mail_table_data[%p], item_count [%d], mail_data[%p]", mail_table_data, item_count, mail_data); - int i, ret = false, err_code = EMF_ERROR_NONE; - emf_mail_data_t *temp_mail_data = NULL; + int i, ret = false, err_code = EMAIL_ERROR_NONE; + email_mail_data_t *temp_mail_data = NULL; if (!mail_table_data || !mail_data || !item_count) { EM_DEBUG_EXCEPTION("Invalid parameter"); - err_code = EMF_ERROR_INVALID_PARAM; + err_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - temp_mail_data = em_malloc(sizeof(emf_mail_data_t) * item_count); - + temp_mail_data = em_malloc(sizeof(email_mail_data_t) * item_count); + if(!temp_mail_data) { EM_DEBUG_EXCEPTION("em_malloc failed"); - err_code = EMF_ERROR_OUT_OF_MEMORY; + err_code = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } for(i = 0; i < item_count; i++) { temp_mail_data[i].mail_id = mail_table_data[i].mail_id; temp_mail_data[i].account_id = mail_table_data[i].account_id; - temp_mail_data[i].mailbox_name = EM_SAFE_STRDUP(mail_table_data[i].mailbox_name); + temp_mail_data[i].mailbox_id = mail_table_data[i].mailbox_id; temp_mail_data[i].mailbox_type = mail_table_data[i].mailbox_type; temp_mail_data[i].subject = EM_SAFE_STRDUP(mail_table_data[i].subject); temp_mail_data[i].date_time = mail_table_data[i].date_time; @@ -364,6 +419,7 @@ INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_ta temp_mail_data[i].body_download_status = mail_table_data[i].body_download_status; temp_mail_data[i].file_path_plain = EM_SAFE_STRDUP(mail_table_data[i].file_path_plain); temp_mail_data[i].file_path_html = EM_SAFE_STRDUP(mail_table_data[i].file_path_html); + temp_mail_data[i].file_path_mime_entity = EM_SAFE_STRDUP(mail_table_data[i].file_path_mime_entity); temp_mail_data[i].mail_size = mail_table_data[i].mail_size; temp_mail_data[i].flags_seen_field = mail_table_data[i].flags_seen_field; temp_mail_data[i].flags_deleted_field = mail_table_data[i].flags_deleted_field; @@ -383,6 +439,9 @@ INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_ta temp_mail_data[i].thread_item_count = mail_table_data[i].thread_item_count; temp_mail_data[i].preview_text = EM_SAFE_STRDUP(mail_table_data[i].preview_text); temp_mail_data[i].meeting_request_status = mail_table_data[i].meeting_request_status; + temp_mail_data[i].message_class = mail_table_data[i].message_class; + temp_mail_data[i].digest_type = mail_table_data[i].digest_type; + temp_mail_data[i].smime_type = mail_table_data[i].smime_type; } *mail_data = temp_mail_data; @@ -391,36 +450,36 @@ INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_ta FINISH_OFF: if(error) - *error = err_code; + *error = err_code; EM_DEBUG_FUNC_END(); return ret; } -INTERNAL_FUNC int em_convert_mail_data_to_mail_tbl(emf_mail_data_t *mail_data, int item_count, emstorage_mail_tbl_t **mail_table_data, int *error) +INTERNAL_FUNC int em_convert_mail_data_to_mail_tbl(email_mail_data_t *mail_data, int item_count, emstorage_mail_tbl_t **mail_table_data, int *error) { EM_DEBUG_FUNC_BEGIN("mail_data[%p], item_count [%d], mail_table_data[%p]", mail_data, item_count, mail_table_data); - int i, ret = false, err_code = EMF_ERROR_NONE; + int i, ret = false, err_code = EMAIL_ERROR_NONE; emstorage_mail_tbl_t *temp_mail_tbl = NULL; if (!mail_data || !mail_table_data || !item_count) { EM_DEBUG_EXCEPTION("Invalid parameter"); - err_code = EMF_ERROR_INVALID_PARAM; + err_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } temp_mail_tbl = em_malloc(sizeof(emstorage_mail_tbl_t) * item_count); - + if(!temp_mail_tbl) { EM_DEBUG_EXCEPTION("em_malloc failed"); - err_code = EMF_ERROR_OUT_OF_MEMORY; + err_code = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } for(i = 0; i < item_count; i++) { temp_mail_tbl[i].mail_id = mail_data[i].mail_id; temp_mail_tbl[i].account_id = mail_data[i].account_id; - temp_mail_tbl[i].mailbox_name = EM_SAFE_STRDUP(mail_data[i].mailbox_name); + temp_mail_tbl[i].mailbox_id = mail_data[i].mailbox_id; temp_mail_tbl[i].mailbox_type = mail_data[i].mailbox_type; temp_mail_tbl[i].date_time = mail_data[i].date_time; temp_mail_tbl[i].subject = EM_SAFE_STRDUP(mail_data[i].subject); @@ -441,6 +500,7 @@ INTERNAL_FUNC int em_convert_mail_data_to_mail_tbl(emf_mail_data_t *mail_data, temp_mail_tbl[i].body_download_status = mail_data[i].body_download_status; temp_mail_tbl[i].file_path_plain = EM_SAFE_STRDUP(mail_data[i].file_path_plain); temp_mail_tbl[i].file_path_html = EM_SAFE_STRDUP(mail_data[i].file_path_html); + temp_mail_tbl[i].file_path_mime_entity = EM_SAFE_STRDUP(mail_data[i].file_path_mime_entity); temp_mail_tbl[i].mail_size = mail_data[i].mail_size; temp_mail_tbl[i].flags_seen_field = mail_data[i].flags_seen_field; temp_mail_tbl[i].flags_deleted_field = mail_data[i].flags_deleted_field; @@ -460,6 +520,9 @@ INTERNAL_FUNC int em_convert_mail_data_to_mail_tbl(emf_mail_data_t *mail_data, temp_mail_tbl[i].thread_item_count = mail_data[i].thread_item_count; temp_mail_tbl[i].preview_text = EM_SAFE_STRDUP(mail_data[i].preview_text); temp_mail_tbl[i].meeting_request_status = mail_data[i].meeting_request_status; + temp_mail_tbl[i].message_class = mail_data[i].message_class; + temp_mail_tbl[i].digest_type = mail_data[i].digest_type; + temp_mail_tbl[i].smime_type = mail_data[i].smime_type; } *mail_table_data = temp_mail_tbl; @@ -472,7 +535,7 @@ FINISH_OFF: EM_DEBUG_FUNC_END(); return ret; - + } @@ -486,7 +549,7 @@ INTERNAL_FUNC int em_convert_string_to_time_t(char *input_datetime_string, time_ if (!input_datetime_string || !output_time) { EM_DEBUG_EXCEPTION("input_datetime_string[%p], output_time[%p]", input_datetime_string, output_time); - return EMF_ERROR_INVALID_PARAM; + return EMAIL_ERROR_INVALID_PARAM; } memset(buf, 0x00, sizeof(buf)); @@ -517,8 +580,8 @@ INTERNAL_FUNC int em_convert_string_to_time_t(char *input_datetime_string, time_ EM_DEBUG_LOG("*output_time [%d", *output_time); - EM_DEBUG_FUNC_END("err %d", EMF_ERROR_NONE); - return EMF_ERROR_NONE; + EM_DEBUG_FUNC_END("err %d", EMAIL_ERROR_NONE); + return EMAIL_ERROR_NONE; } INTERNAL_FUNC int em_convert_time_t_to_string(time_t *input_time, char **output_datetime_string) @@ -528,105 +591,146 @@ INTERNAL_FUNC int em_convert_time_t_to_string(time_t *input_time, char **output_ struct tm *temp_time_info; if (!input_time || !output_datetime_string) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } temp_time_info = localtime(input_time); if(!temp_time_info) { EM_DEBUG_EXCEPTION("localtime failed."); - return EMF_ERROR_SYSTEM_FAILURE; + return EMAIL_ERROR_SYSTEM_FAILURE; } SNPRINTF(temp_buffer, sizeof(temp_buffer), "%04d%02d%02d%02d%02d%02d", temp_time_info->tm_year + 1970, temp_time_info->tm_mon, temp_time_info->tm_mday, temp_time_info->tm_hour, temp_time_info->tm_min, temp_time_info->tm_sec); *output_datetime_string = EM_SAFE_STRDUP(temp_buffer); - EM_DEBUG_FUNC_END("err %d", EMF_ERROR_NONE); - return EMF_ERROR_NONE; + EM_DEBUG_FUNC_END("err %d", EMAIL_ERROR_NONE); + return EMAIL_ERROR_NONE; } -static char* append_sized_data_to_stream(char *input_stream, int *input_output_stream_length, char *input_sized_data, int input_data_size) +static char* append_sized_data_to_stream(char *stream, int *stream_len, char *src, int src_len) { - EM_DEBUG_FUNC_BEGIN("input_stream [%p], input_output_stream_length [%p], input_sized_data [%p], input_data_size [%d]", input_stream, input_output_stream_length, input_sized_data, input_data_size); + /* EM_DEBUG_FUNC_BEGIN("input_stream [%p], input_output_stream_length [%p], input_sized_data [%p], input_data_size [%d]", input_stream, input_output_stream_length, input_sized_data, input_data_size); */ char *new_stream = NULL; - int source_stream_length = 0; - if( !input_output_stream_length || input_data_size == 0 || input_sized_data == NULL|| - (input_stream != NULL && *input_output_stream_length == 0) || (input_stream == NULL && *input_output_stream_length != 0) ) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return NULL; + if( !stream_len || src_len == 0 || src == NULL || (stream != NULL && *stream_len == 0) || + (stream == NULL && *stream_len != 0) ) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return NULL; } - source_stream_length = *input_output_stream_length; + int old_stream_len = *stream_len; - new_stream = (char*)em_malloc((source_stream_length) * sizeof(char) + input_data_size); + /*TODO: don't increase stream buffer incrementally when appending new data */ + new_stream = (char*)em_malloc(old_stream_len + src_len); if(!new_stream) { - EM_DEBUG_EXCEPTION("EMF_ERROR_OUT_OF_MEMORY"); - return NULL; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY"); + return NULL; } - if(input_stream != NULL) - memcpy(new_stream, input_stream, source_stream_length * sizeof(char)); + if(stream != NULL) + memcpy(new_stream, stream, old_stream_len); - memcpy(new_stream + source_stream_length, input_sized_data, input_data_size); + memcpy(new_stream + old_stream_len, src, src_len); - *input_output_stream_length = source_stream_length + input_data_size; - - EM_SAFE_FREE(input_stream); - EM_DEBUG_FUNC_END("*input_output_stream_length [%d]", *input_output_stream_length); - return new_stream; + *stream_len = old_stream_len + src_len; + + EM_SAFE_FREE(stream); + /* EM_DEBUG_FUNC_END("*input_output_stream_length [%d]", *input_output_stream_length); */ + return new_stream; } + static char* append_string_to_stream(char *input_stream, int *input_output_stream_length, char *input_source_string) { EM_DEBUG_FUNC_BEGIN("input_stream [%p], input_output_stream_length [%p] input_source_string[%p]", input_stream, input_output_stream_length, input_source_string); char *new_stream = NULL; int data_length = 0; - int source_stream_length = 0; - if( !input_output_stream_length || (input_stream != NULL && *input_output_stream_length == 0) || (input_stream == NULL && *input_output_stream_length != 0)) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return NULL; + if( !input_output_stream_length || (input_stream != NULL && *input_output_stream_length == 0) || + (input_stream == NULL && *input_output_stream_length != 0) ) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return NULL; } - source_stream_length = *input_output_stream_length; + int source_stream_length = *input_output_stream_length; - if(input_source_string != NULL) - data_length = EM_SAFE_STRLEN(input_source_string); + data_length = EM_SAFE_STRLEN(input_source_string); - new_stream = (char*)em_malloc((source_stream_length + data_length) * sizeof(char) + sizeof(int)); + new_stream = (char*)em_malloc(source_stream_length + data_length + sizeof(int)); if(!new_stream) { - EM_DEBUG_EXCEPTION("EMF_ERROR_OUT_OF_MEMORY"); - return NULL; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY"); + return NULL; } if(input_stream != NULL) - memcpy(new_stream, input_stream, source_stream_length * sizeof(char)); + memcpy(new_stream, input_stream, source_stream_length); + /* write string length */ memcpy(new_stream + source_stream_length, (char*)&data_length, sizeof(int)); - if(input_source_string) + /* write string */ + if(input_source_string) memcpy(new_stream + source_stream_length + sizeof(int), input_source_string, data_length); + /* for example, "abc" is written to stream buffer with "3abc" */ *input_output_stream_length = source_stream_length + sizeof(int) + data_length; - - EM_SAFE_FREE(input_stream); + + EM_SAFE_FREE(input_stream); EM_DEBUG_FUNC_END("*input_output_stream_length [%d]", *input_output_stream_length); - return new_stream; + return new_stream; +} + +#if 0 +static char* append_binary_to_stream(char *stream, int *stream_length, char *src, int src_size) +{ + /* EM_DEBUG_FUNC_BEGIN("input_stream [%p], input_output_stream_length [%p], input_sized_data [%p], input_data_size [%d]", input_stream, input_output_stream_length, input_sized_data, input_data_size); */ + char *new_stream = NULL; + + if( !stream_length || (stream && *stream_length == 0) || (!stream && *stream_length != 0) || + src_size < 0 ) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return NULL; + } + + /*TODO: don't increase stream buffer incrementally when appending new data */ + new_stream = (char*)em_malloc(*stream_length + sizeof(int) + src_size); + + if(!new_stream) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY"); + return NULL; + } + + + if(stream != NULL) + memcpy(new_stream, stream, *stream_length); + + memcpy(new_stream + *stream_length, &src_size, sizeof(int)); + + if( src_size > 0 ) + memcpy(new_stream + *stream_length + sizeof(int), src, src_size); + + *stream_length = *stream_length + sizeof(int) + src_size; + + EM_SAFE_FREE(stream); + /* EM_DEBUG_FUNC_END("*input_output_stream_length [%d]", *input_output_stream_length); */ + + return new_stream; } +#endif -static int fetch_sized_data_from_stream(char *input_stream, int *input_output_stream_offset, int input_data_size, char *output_data) +static int fetch_sized_data_from_stream(char *input_stream, int *input_output_stream_offset, int input_data_size, char *output_data) { - EM_DEBUG_FUNC_BEGIN("input_stream [%p], input_output_stream_offset [%p] input_data_size [%d], output_data[%p]", input_stream, input_output_stream_offset, input_data_size, output_data); + /* EM_DEBUG_FUNC_BEGIN("input_stream [%p], input_output_stream_offset [%p] input_data_size [%d], output_data[%p]", input_stream, input_output_stream_offset, input_data_size, output_data); */ int stream_offset = 0; if( !input_stream || !input_output_stream_offset || !input_data_size || !output_data) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } stream_offset = *input_output_stream_offset; @@ -636,33 +740,30 @@ static int fetch_sized_data_from_stream(char *input_stream, int *input_output_st *input_output_stream_offset = stream_offset; - EM_DEBUG_FUNC_END("stream_offset [%d]", stream_offset); - return EMF_ERROR_NONE; + /* EM_DEBUG_FUNC_END("stream_offset [%d]", stream_offset); */ + return EMAIL_ERROR_NONE; } -static int fetch_string_from_stream(char *input_stream, int *input_output_stream_offset, char **output_string) + +static int fetch_string_from_stream(char *input_stream, int *input_output_stream_offset, char **output_string) { - EM_DEBUG_FUNC_BEGIN("input_stream [%p], input_output_stream_offset [%p] output_string[%p]", input_stream, input_output_stream_offset, output_string); + /* EM_DEBUG_FUNC_BEGIN("input_stream [%p], input_output_stream_offset [%p] output_string[%p]", input_stream, input_output_stream_offset, output_string); */ int string_length = 0; int stream_offset = 0; char *result_string = NULL; if( !input_stream || !input_output_stream_offset || !output_string) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } stream_offset = *input_output_stream_offset; - /* - EM_DEBUG_LOG("stream_offset [%d]", stream_offset); - */ + /* EM_DEBUG_LOG("stream_offset [%d]", stream_offset); */ memcpy(&string_length, input_stream + stream_offset, sizeof(int)); stream_offset += sizeof(int); - /* - EM_DEBUG_LOG("string_length [%d]", string_length); - */ + /* EM_DEBUG_LOG("string_length [%d]", string_length); */ if(string_length != 0) { result_string = (char*)em_malloc(string_length + 1); @@ -678,47 +779,107 @@ static int fetch_string_from_stream(char *input_stream, int *input_output_stream *output_string = result_string; *input_output_stream_offset = stream_offset; - - EM_DEBUG_FUNC_END("stream_offset [%d]", stream_offset); - return EMF_ERROR_NONE; + + /* EM_DEBUG_FUNC_END("stream_offset [%d]", stream_offset); */ + return EMAIL_ERROR_NONE; } -INTERNAL_FUNC char* em_convert_account_to_byte_stream(emf_account_t* input_account, int *output_stream_size) +#if 0 +static int fetch_binary_from_stream(char *stream, int *stream_offset, void **dest) { + /* EM_DEBUG_FUNC_BEGIN("input_stream [%p], input_output_stream_offset [%p] output_string[%p]", input_stream, input_output_stream_offset, output_string); */ + int length = 0; + + if( !stream || !stream_offset || !dest) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + int offset = *stream_offset; + + memcpy((void*)&length, (void*) stream + offset, sizeof(int)); + offset += sizeof(int); + + *dest = NULL; + if(length > 0) { + *dest = (void*)em_malloc(length); + if(!*dest) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY"); + return EMAIL_ERROR_OUT_OF_MEMORY; + } + + memcpy(*dest, (void*) stream + offset, length); + offset += length; + } + + *stream_offset = offset; + + return EMAIL_ERROR_NONE; +} +#endif + /* divide struct at binary field (void* user_data)*/ +#define EMAIL_ACCOUNT_FMT "S(" "isiii" "is" ")" "B" "S(" "issss" "isiss" "iiiii" "isiss" "iii"\ + "$(" "iiiii" "iisii" "iisi" ")" "iiisii" ")" + + +INTERNAL_FUNC char* em_convert_account_to_byte_stream(email_account_t* account, int *stream_len) +{ + EM_DEBUG_FUNC_END(); + EM_IF_NULL_RETURN_VALUE(account, NULL); + + tpl_node *tn = NULL; + tpl_bin tb; + + tn = tpl_map(EMAIL_ACCOUNT_FMT, account, &tb, &(account->user_data_length)); + tb.sz = account->user_data_length; + tb.addr = account->user_data; + tpl_pack(tn, 0); + + /* write account to buffer */ + void *buf = NULL; + size_t len = 0; + tpl_dump(tn, TPL_MEM, &buf, &len); + tpl_free(tn); + + *stream_len = len; + EM_DEBUG_FUNC_END(); + return (char*) buf; + +#if 0 EM_DEBUG_FUNC_BEGIN("input_account [%p], output_stream_size [%p]", input_account, output_stream_size); char *result_stream = NULL; int stream_size = 0; EM_IF_NULL_RETURN_VALUE(input_account, NULL); - - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->account_bind_type), sizeof(int)); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->account_name); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->receiving_server_type), sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_account->receiving_server_addr); - result_stream = append_string_to_stream(result_stream, &stream_size, input_account->email_addr); - result_stream = append_string_to_stream(result_stream, &stream_size, input_account->user_name); - result_stream = append_string_to_stream(result_stream, &stream_size, input_account->password); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->incoming_server_type), sizeof(int)); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->incoming_server_address); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->user_email_address); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->incoming_server_user_name); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->incoming_server_password); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->retrieval_mode), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->port_num), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->use_security), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->sending_server_type), sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_account->sending_server_addr); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->sending_port_num), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->sending_auth), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->sending_security), sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_account->sending_user); - result_stream = append_string_to_stream(result_stream, &stream_size, input_account->sending_password); - result_stream = append_string_to_stream(result_stream, &stream_size, input_account->display_name); - result_stream = append_string_to_stream(result_stream, &stream_size, input_account->reply_to_addr); - result_stream = append_string_to_stream(result_stream, &stream_size, input_account->return_addr); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->incoming_server_port_number), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->incoming_server_secure_connection), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->outgoing_server_type), sizeof(int)); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->outgoing_server_address); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->outgoing_server_port_number), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->outgoing_server_need_authentication), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->outgoing_server_secure_connection), sizeof(int)); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->outgoing_server_user_name); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->outgoing_server_password); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->user_display_name); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->reply_to_address); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->return_address); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->account_id), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->keep_on_server), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->flag1), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->flag2), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->keep_mails_on_pop_server_after_download), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->auto_download_size), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->outgoing_server_use_same_authenticator), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->pop_before_smtp), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->apop), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->incoming_server_requires_apop), sizeof(int)); result_stream = append_string_to_stream(result_stream, &stream_size, input_account->logo_icon_path); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->preset_account), sizeof(int)); + result_stream = append_binary_to_stream(result_stream, &stream_size, input_account->user_data, input_account->user_data_length); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*) &input_account->user_data_length, sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->options.priority), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->options.keep_local_copy), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->options.req_delivery_receipt), sizeof(int)); @@ -733,54 +894,78 @@ INTERNAL_FUNC char* em_convert_account_to_byte_stream(emf_account_t* input_accou result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->options.add_signature), sizeof(int)); result_stream = append_string_to_stream(result_stream, &stream_size, input_account->options.signature); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->options.add_my_address_to_bcc), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->target_storage), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->check_interval), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->my_account_id), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->index_color), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->account_svc_id), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->sync_status), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->sync_disabled), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->default_mail_slot_size), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->smime_type), sizeof(int)); + result_stream = append_string_to_stream(result_stream, &stream_size, input_account->certificate_path); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->cipher_type), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_account->digest_type), sizeof(int)); *output_stream_size = stream_size; + EM_DEBUG_FUNC_END("stream_size [%d]", stream_size); return result_stream; +#endif } -INTERNAL_FUNC void em_convert_byte_stream_to_account(char *input_stream, emf_account_t *output_account) +INTERNAL_FUNC void em_convert_byte_stream_to_account(char *stream, int stream_len, email_account_t *account) { + EM_DEBUG_FUNC_END(); + EM_NULL_CHECK_FOR_VOID(stream); + EM_NULL_CHECK_FOR_VOID(account); + + tpl_node *tn = NULL; + tpl_bin tb; + + tn = tpl_map(EMAIL_ACCOUNT_FMT, account, &tb, &(account->user_data_length)); + tpl_load(tn, TPL_MEM, stream, stream_len); + tpl_unpack(tn, 0); + tpl_free(tn); + + /* tb will be destroyed at end of func, but tb.addr remains */ + account->user_data = tb.addr; + + EM_DEBUG_FUNC_END(); +#if 0 EM_DEBUG_FUNC_BEGIN(); int stream_offset = 0; EM_NULL_CHECK_FOR_VOID(input_stream); EM_NULL_CHECK_FOR_VOID(output_account); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->account_bind_type); fetch_string_from_stream(input_stream, &stream_offset, &output_account->account_name); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->receiving_server_type); - fetch_string_from_stream(input_stream, &stream_offset, &output_account->receiving_server_addr); - fetch_string_from_stream(input_stream, &stream_offset, &output_account->email_addr); - fetch_string_from_stream(input_stream, &stream_offset, &output_account->user_name); - fetch_string_from_stream(input_stream, &stream_offset, &output_account->password); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->incoming_server_type); + fetch_string_from_stream(input_stream, &stream_offset, &output_account->incoming_server_address); + fetch_string_from_stream(input_stream, &stream_offset, &output_account->user_email_address); + fetch_string_from_stream(input_stream, &stream_offset, &output_account->incoming_server_user_name); + fetch_string_from_stream(input_stream, &stream_offset, &output_account->incoming_server_password); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->retrieval_mode); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->port_num); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->use_security); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->sending_server_type); - fetch_string_from_stream(input_stream, &stream_offset, &output_account->sending_server_addr); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->sending_port_num); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->sending_auth); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->sending_security); - fetch_string_from_stream(input_stream, &stream_offset, &output_account->sending_user); - fetch_string_from_stream(input_stream, &stream_offset, &output_account->sending_password); - fetch_string_from_stream(input_stream, &stream_offset, &output_account->display_name); - fetch_string_from_stream(input_stream, &stream_offset, &output_account->reply_to_addr); - fetch_string_from_stream(input_stream, &stream_offset, &output_account->return_addr); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->incoming_server_port_number); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->incoming_server_secure_connection); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->outgoing_server_type); + fetch_string_from_stream(input_stream, &stream_offset, &output_account->outgoing_server_address); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->outgoing_server_port_number); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->outgoing_server_need_authentication); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->outgoing_server_secure_connection); + fetch_string_from_stream(input_stream, &stream_offset, &output_account->outgoing_server_user_name); + fetch_string_from_stream(input_stream, &stream_offset, &output_account->outgoing_server_password); + fetch_string_from_stream(input_stream, &stream_offset, &output_account->user_display_name); + fetch_string_from_stream(input_stream, &stream_offset, &output_account->reply_to_address); + fetch_string_from_stream(input_stream, &stream_offset, &output_account->return_address); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->account_id); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->keep_on_server); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->flag1); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->flag2); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->keep_mails_on_pop_server_after_download); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->auto_download_size); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->outgoing_server_use_same_authenticator); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->pop_before_smtp); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->apop); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->incoming_server_requires_apop); fetch_string_from_stream(input_stream, &stream_offset, &output_account->logo_icon_path); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->preset_account); + fetch_binary_from_stream(input_stream, &stream_offset, &output_account->user_data); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->user_data_length); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->options.priority); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->options.keep_local_copy); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->options.req_delivery_receipt); @@ -795,85 +980,51 @@ INTERNAL_FUNC void em_convert_byte_stream_to_account(char *input_stream, emf_ac fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->options.add_signature); fetch_string_from_stream(input_stream, &stream_offset, &output_account->options.signature); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->options.add_my_address_to_bcc); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->target_storage); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->check_interval); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->my_account_id); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->index_color); - - EM_DEBUG_FUNC_END(); -} - -INTERNAL_FUNC char* em_convert_attachment_info_to_byte_stream(emf_attachment_info_t *input_attachment_info, int *output_stream_size) -{ - EM_DEBUG_FUNC_BEGIN(); - - char *result_stream = NULL; - int stream_size = 0; - - EM_IF_NULL_RETURN_VALUE(input_attachment_info, NULL); - EM_IF_NULL_RETURN_VALUE(output_stream_size, NULL); - - while(input_attachment_info) { - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_info->inline_content, sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_info->attachment_id, sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_attachment_info->name); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_info->size, sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_info->downloaded, sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_attachment_info->savename); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_info->drm, sizeof(int)); - - input_attachment_info = input_attachment_info->next; - } - - *output_stream_size = stream_size; + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->account_svc_id); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->sync_status); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->sync_disabled); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->default_mail_slot_size); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->smime_type); + fetch_string_from_stream(input_stream, &stream_offset, &output_account->certificate_path); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->cipher_type); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&output_account->digest_type); EM_DEBUG_FUNC_END(); - return result_stream; +#endif } -INTERNAL_FUNC void em_convert_byte_stream_to_attachment_info(char *input_stream, int attachment_count, emf_attachment_info_t **output_attachment_info) +#define EMAIL_MAIL_DATA_FMT "S(" "iiiis" "iisss" "sssss" "sssss" "isssi"\ + "ccccc" "cciii" "iiiii" "isiii" "i" ")" + +INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_data, int *stream_len) { - EM_DEBUG_FUNC_BEGIN(); + EM_DEBUG_FUNC_END(); + EM_IF_NULL_RETURN_VALUE(mail_data, NULL); + EM_IF_NULL_RETURN_VALUE(stream_len, NULL); - int i = 0; - int stream_offset = 0; - emf_attachment_info_t *temp_attachment_info = NULL; - emf_attachment_info_t *current_attachment_info = NULL; + tpl_node *tn = NULL; - EM_NULL_CHECK_FOR_VOID(input_stream); + tn = tpl_map(EMAIL_MAIL_DATA_FMT, mail_data); + tpl_pack(tn, 0); - for(i = 0; i < attachment_count; i++) { - temp_attachment_info = (emf_attachment_info_t*)malloc(sizeof(emf_attachment_info_t)); + /* write account to buffer */ + void *buf = NULL; + size_t len = 0; + tpl_dump(tn, TPL_MEM, &buf, &len); + tpl_free(tn); - if(i == 0) - *output_attachment_info = current_attachment_info = temp_attachment_info; - else { - current_attachment_info->next = temp_attachment_info; - current_attachment_info = temp_attachment_info; - } - - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&temp_attachment_info->inline_content); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&temp_attachment_info->attachment_id); - fetch_string_from_stream(input_stream, &stream_offset, &temp_attachment_info->name); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&temp_attachment_info->size); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&temp_attachment_info->downloaded); - fetch_string_from_stream(input_stream, &stream_offset, &temp_attachment_info->savename); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&temp_attachment_info->drm); - - temp_attachment_info->next = NULL; - } - + *stream_len = len; EM_DEBUG_FUNC_END(); -} + return (char*) buf; -INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(emf_mail_data_t *input_mail_data, int input_mail_data_count, int *output_stream_size) -{ +#if 0 EM_DEBUG_FUNC_BEGIN("input_mail_data [%p], input_mail_data_count[%d], output_stream_size[%p]", input_mail_data, input_mail_data_count, output_stream_size); - + char *result_stream = NULL; int stream_size = 0; int i = 0; - + EM_IF_NULL_RETURN_VALUE(input_mail_data, NULL); EM_IF_NULL_RETURN_VALUE(output_stream_size, NULL); @@ -882,7 +1033,7 @@ INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(emf_mail_data_t *input_m for(i = 0; i < input_mail_data_count; i++) { result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].mail_id), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].account_id), sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].mailbox_name); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].mailbox_id), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].mailbox_type), sizeof(int)); result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].subject); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].date_time), sizeof(int)); @@ -903,6 +1054,7 @@ INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(emf_mail_data_t *input_m result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].body_download_status), sizeof(int)); result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].file_path_plain); result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].file_path_html); + result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].file_path_mime_entity); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].mail_size), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].flags_seen_field), sizeof(char)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].flags_deleted_field), sizeof(char)); @@ -922,16 +1074,32 @@ INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(emf_mail_data_t *input_m result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].thread_item_count), sizeof(int)); result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].preview_text); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].meeting_request_status), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].message_class), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].digest_type), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].smime_type), sizeof(int)); } *output_stream_size = stream_size; EM_DEBUG_FUNC_END("stream_size [%d]", stream_size); return result_stream; +#endif } -INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *input_stream, emf_mail_data_t **output_mail_data, int *output_mail_data_count) +INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_len, email_mail_data_t *mail_data) { + EM_NULL_CHECK_FOR_VOID(stream); + EM_NULL_CHECK_FOR_VOID(mail_data); + + tpl_node *tn = NULL; + + tn = tpl_map(EMAIL_MAIL_DATA_FMT, mail_data); + tpl_load(tn, TPL_MEM, stream, stream_len); + tpl_unpack(tn, 0); + tpl_free(tn); + + EM_DEBUG_FUNC_END(); +#if 0 EM_DEBUG_FUNC_BEGIN("input_stream [%p], output_mail_data[%p], output_mail_data_count[%p]", input_stream, output_mail_data, output_mail_data_count); int stream_offset = 0; @@ -950,7 +1118,7 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *input_stream, emf_m return; } - *output_mail_data = (emf_mail_data_t*)em_malloc(sizeof(emf_mail_data_t) * (*output_mail_data_count)); + *output_mail_data = (email_mail_data_t*)em_malloc(sizeof(email_mail_data_t) * (*output_mail_data_count)); if(!*output_mail_data) { EM_DEBUG_EXCEPTION("em_malloc failed"); @@ -960,7 +1128,7 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *input_stream, emf_m for(i = 0; i < *output_mail_data_count; i++) { fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].mail_id); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].account_id); - fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].mailbox_name); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].mailbox_id); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].mailbox_type); fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].subject); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].date_time); @@ -981,6 +1149,7 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *input_stream, emf_m fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].body_download_status); fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].file_path_plain); fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].file_path_html); + fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].file_path_mime_entity); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].mail_size); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(char), (char*)&(*output_mail_data)[i].flags_seen_field); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(char), (char*)&(*output_mail_data)[i].flags_deleted_field); @@ -1000,15 +1169,57 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *input_stream, emf_m fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].thread_item_count); fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].preview_text); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].meeting_request_status); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].message_class); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].digest_type); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].smime_type); } EM_DEBUG_FUNC_END(); +#endif } -INTERNAL_FUNC char* em_convert_attachment_data_to_byte_stream(emf_attachment_data_t *input_attachment_data, int input_attachment_count, int* output_stream_size) + +#define EMAIL_ATTACHMENT_DATA_FMT "A(S(" "issii" "iciii" "s" "))" + +INTERNAL_FUNC char* em_convert_attachment_data_to_byte_stream(email_attachment_data_t *attachment, int attachment_count, int* stream_len) { + EM_DEBUG_FUNC_BEGIN(); + EM_IF_NULL_RETURN_VALUE(stream_len, NULL); + if(!attachment) { + EM_DEBUG_LOG("no attachment to be included"); + *stream_len = 0; + return NULL; + } + + + email_attachment_data_t cur = {0}; + tpl_node *tn = 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); + int i=0; + for( ; i < attachment_count ; i++ ) { + memcpy(&cur, attachment+i, sizeof(cur)); /* copy data to cur : swallow copy */ + tpl_pack(tn, 1); /* pack data at &cur: deep copy */ + } + + /* write data to buffer */ + void *buf = NULL; + size_t len = 0; + tpl_dump(tn, TPL_MEM, &buf, &len); + tpl_free(tn); + + *stream_len = len; + + EM_DEBUG_LOG("stream_len: %d", len); + + EM_DEBUG_FUNC_END(); + return (char*) buf; + +#if 0 EM_DEBUG_FUNC_BEGIN("input_attachment_data [%p], input_attachment_count [%d], output_stream_size [%p]", input_attachment_data, input_attachment_count, output_stream_size); - + char *result_stream = NULL; int stream_size = 0; int i = 0; @@ -1026,7 +1237,7 @@ INTERNAL_FUNC char* em_convert_attachment_data_to_byte_stream(emf_attachment_dat result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].attachment_size, sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].mail_id, sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].account_id, sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_attachment_data[i].mailbox_name); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].mailbox_id, sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].save_status, sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].drm_status, sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].inline_content_status,sizeof(int)); @@ -1036,10 +1247,55 @@ INTERNAL_FUNC char* em_convert_attachment_data_to_byte_stream(emf_attachment_dat EM_DEBUG_FUNC_END("stream_size [%d]", stream_size); return result_stream; +#endif } -INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *input_stream, emf_attachment_data_t **output_attachment_data, int *output_attachment_count) +INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *stream, int stream_len, email_attachment_data_t **attachment_data, int *attachment_count) { + EM_DEBUG_FUNC_BEGIN(); + EM_NULL_CHECK_FOR_VOID(stream); + EM_NULL_CHECK_FOR_VOID(attachment_data); + EM_NULL_CHECK_FOR_VOID(attachment_count); + + + email_attachment_data_t cur = {0}; + tpl_node *tn = NULL; + tn = tpl_map(EMAIL_ATTACHMENT_DATA_FMT, &cur); + tpl_load(tn, TPL_MEM, stream, stream_len); + + /* tpl does not return the size of variable-length array, but we need variable-length array */ + /* so, make list and get list count in the first phase, */ + /* and then copy list to var array after allocating memory */ + GList *head = NULL; + int count = 0; + while( tpl_unpack(tn, 1) > 0) { + email_attachment_data_t* pdata = (email_attachment_data_t*) em_malloc(sizeof(email_attachment_data_t)); + memcpy(pdata, &cur, sizeof(email_attachment_data_t)); /* copy unpacked data to list item */ + head = g_list_prepend(head, pdata); /* add it to list */ + memset(&cur, 0, sizeof(email_attachment_data_t)); /* initialize variable, used for unpacking */ + count++; + } + tpl_free(tn); + + /*finally we get the list count and allocate var length array */ + email_attachment_data_t *attached = (email_attachment_data_t*) em_malloc(sizeof(email_attachment_data_t)*count); + + /*write glist item into variable array*/ + head = g_list_reverse(head); + GList *p = g_list_first(head); + int i=0; + for( ; p ; p = g_list_next(p), i++ ) { + email_attachment_data_t* pdata = (email_attachment_data_t*) g_list_nth_data(p, 0); + memcpy( attached+i, pdata, sizeof(email_attachment_data_t)); + EM_SAFE_FREE(pdata); /*now, list item is useless */ + } + + g_list_free(head); + + *attachment_count = count; + *attachment_data = attached; + EM_DEBUG_FUNC_END(); +#if 0 EM_DEBUG_FUNC_BEGIN("input_stream [%p], output_attachment_data[%p]", input_stream, output_attachment_data); int stream_offset = 0; @@ -1058,7 +1314,7 @@ INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *input_stream, return; } - *output_attachment_data = (emf_attachment_data_t*)em_malloc(sizeof(emf_attachment_data_t) * (*output_attachment_count)); + *output_attachment_data = (email_attachment_data_t*)em_malloc(sizeof(email_attachment_data_t) * (*output_attachment_count)); if(!*output_attachment_data) { EM_DEBUG_EXCEPTION("em_malloc failed"); @@ -1072,19 +1328,41 @@ INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *input_stream, fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].attachment_size)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].mail_id)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].account_id)); - fetch_string_from_stream(input_stream, &stream_offset, &(*output_attachment_data)[i].mailbox_name); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].mailbox_id)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].save_status)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].drm_status)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].inline_content_status)); } EM_DEBUG_FUNC_END(); +#endif } +#define EMAIL_MAILBOX_FMT "S(" "isisi" "iiiii" "i" ")" -INTERNAL_FUNC char* em_convert_mailbox_to_byte_stream(emf_mailbox_t *input_mailbox_data, int *output_stream_size) +INTERNAL_FUNC char* em_convert_mailbox_to_byte_stream(email_mailbox_t *mailbox_data, int *stream_len) { + EM_DEBUG_FUNC_BEGIN(); + EM_IF_NULL_RETURN_VALUE(mailbox_data, NULL); + EM_IF_NULL_RETURN_VALUE(stream_len, NULL); + + tpl_node *tn = NULL; + + tn = tpl_map(EMAIL_MAILBOX_FMT, mailbox_data); + tpl_pack(tn, 0); + + /* write account to buffer */ + void *buf = NULL; + size_t len = 0; + tpl_dump(tn, TPL_MEM, &buf, &len); + tpl_free(tn); + + *stream_len = len; + EM_DEBUG_FUNC_END("serialized len: %d", len); + return (char*) buf; + +#if 0 EM_DEBUG_FUNC_BEGIN("input_mailbox_data [%p], output_stream_size [%p]", input_mailbox_data, output_stream_size); char *result_stream = NULL; @@ -1094,115 +1372,178 @@ INTERNAL_FUNC char* em_convert_mailbox_to_byte_stream(emf_mailbox_t *input_mailb EM_IF_NULL_RETURN_VALUE(output_stream_size, NULL); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->mailbox_id), sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_mailbox_data->name); + result_stream = append_string_to_stream(result_stream, &stream_size, input_mailbox_data->mailbox_name); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->mailbox_type), sizeof(int)); result_stream = append_string_to_stream(result_stream, &stream_size, input_mailbox_data->alias); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->unread_count), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->total_mail_count_on_local), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->total_mail_count_on_server), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->hold_connection), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->local), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->synchronous), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->account_id), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->user_data), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->mail_stream), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->has_archived_mails), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mailbox_data->mail_slot_size), sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_mailbox_data->account_name); *output_stream_size = stream_size; EM_DEBUG_FUNC_END(); return result_stream; +#endif } -INTERNAL_FUNC void em_convert_byte_stream_to_mailbox(char *input_stream, emf_mailbox_t *output_mailbox_data) +INTERNAL_FUNC void em_convert_byte_stream_to_mailbox(char *stream, int stream_len, email_mailbox_t *mailbox_data) { - EM_DEBUG_FUNC_BEGIN("input_stream [%p], output_mailbox_data [%p]", input_stream, output_mailbox_data); + EM_DEBUG_FUNC_BEGIN(); + EM_NULL_CHECK_FOR_VOID(stream); + EM_NULL_CHECK_FOR_VOID(mailbox_data); + + tpl_node *tn = NULL; + + tn = tpl_map(EMAIL_MAILBOX_FMT, mailbox_data); + tpl_load(tn, TPL_MEM, stream, stream_len); + tpl_unpack(tn, 0); + tpl_free(tn); + + EM_DEBUG_FUNC_END("deserialized len %d", stream_len); + +/* EM_DEBUG_FUNC_BEGIN("input_stream [%p], output_mailbox_data [%p]", input_stream, output_mailbox_data); int stream_offset = 0; EM_NULL_CHECK_FOR_VOID(input_stream); EM_NULL_CHECK_FOR_VOID(output_mailbox_data); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->mailbox_id)); - fetch_string_from_stream(input_stream, &stream_offset, &output_mailbox_data->name); + fetch_string_from_stream(input_stream, &stream_offset, &output_mailbox_data->mailbox_name); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->mailbox_type)); fetch_string_from_stream(input_stream, &stream_offset, &output_mailbox_data->alias); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->unread_count)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->total_mail_count_on_local)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->total_mail_count_on_server)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->hold_connection)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->local)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->synchronous)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->account_id)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->user_data)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->mail_stream)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->has_archived_mails)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_mailbox_data->mail_slot_size)); - fetch_string_from_stream(input_stream, &stream_offset, &output_mailbox_data->account_name); EM_DEBUG_FUNC_END(); +*/ } +#define EMAIL_OPTION_FMT "S(" "iiiii" "iisii" "iisi" ")" -INTERNAL_FUNC char* em_convert_option_to_byte_stream(emf_option_t* input_option, int* output_stream_size) +INTERNAL_FUNC char* em_convert_option_to_byte_stream(email_option_t* option, int* stream_len) { EM_DEBUG_FUNC_BEGIN(); + EM_IF_NULL_RETURN_VALUE(option, NULL); + EM_IF_NULL_RETURN_VALUE(stream_len, NULL); + + tpl_node *tn = NULL; + + tn = tpl_map(EMAIL_OPTION_FMT, option); + tpl_pack(tn, 0); + + /* write account to buffer */ + void *buf = NULL; + size_t len = 0; + tpl_dump(tn, TPL_MEM, &buf, &len); + tpl_free(tn); + + *stream_len = len; + EM_DEBUG_FUNC_END("serialized len: %d", len); + return (char*) buf; + + +#if 0 + EM_DEBUG_FUNC_BEGIN(); char *result_stream = NULL; int stream_size = 0; EM_IF_NULL_RETURN_VALUE(input_option, NULL); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->priority), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->keep_local_copy), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->keep_local_copy), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->req_delivery_receipt), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->req_read_receipt), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->download_limit), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->block_address), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->block_subject), sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_option->display_name_from); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->reply_with_body), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->block_address), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->block_subject), sizeof(int)); + result_stream = append_string_to_stream(result_stream, &stream_size, input_option->display_name_from); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->reply_with_body), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->forward_with_files), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->add_myname_card), sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->add_signature), sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_option->signature); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->add_my_address_to_bcc), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->add_myname_card), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->add_signature), sizeof(int)); + result_stream = append_string_to_stream(result_stream, &stream_size, input_option->signature); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_option->add_my_address_to_bcc), sizeof(int)); *output_stream_size = stream_size; EM_DEBUG_FUNC_END(); return result_stream; - +#endif } -INTERNAL_FUNC void em_convert_byte_stream_to_option(char *input_stream, emf_option_t *output_option) +INTERNAL_FUNC void em_convert_byte_stream_to_option(char *stream, int stream_len, email_option_t *option) { EM_DEBUG_FUNC_BEGIN(); + EM_NULL_CHECK_FOR_VOID(stream); + EM_NULL_CHECK_FOR_VOID(option); + + tpl_node *tn = NULL; + + tn = tpl_map(EMAIL_OPTION_FMT, option); + tpl_load(tn, TPL_MEM, stream, stream_len); + tpl_unpack(tn, 0); + tpl_free(tn); + + EM_DEBUG_FUNC_END("deserialized len %d", stream_len); + +#if 0 + EM_DEBUG_FUNC_BEGIN(); int stream_offset = 0; EM_NULL_CHECK_FOR_VOID(input_stream); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->priority)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->keep_local_copy)); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->keep_local_copy)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->req_delivery_receipt)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->req_read_receipt)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->download_limit)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->block_address)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->block_subject)); - fetch_string_from_stream(input_stream, &stream_offset, &output_option->display_name_from); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->reply_with_body)); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->block_address)); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->block_subject)); + fetch_string_from_stream(input_stream, &stream_offset, &output_option->display_name_from); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->reply_with_body)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->forward_with_files)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->add_myname_card)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->add_signature)); - fetch_string_from_stream(input_stream, &stream_offset, &output_option->signature); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->add_my_address_to_bcc)); - + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->add_myname_card)); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->add_signature)); + fetch_string_from_stream(input_stream, &stream_offset, &output_option->signature); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_option->add_my_address_to_bcc)); EM_DEBUG_FUNC_END(); +#endif } -INTERNAL_FUNC char* em_convert_rule_to_byte_stream(emf_rule_t *input_rule, int *output_stream_size) + +#define EMAIL_RULE_FMT "S(" "iiisi" "iii" ")" + +INTERNAL_FUNC char* em_convert_rule_to_byte_stream(email_rule_t *rule, int *stream_len) { EM_DEBUG_FUNC_BEGIN(); + EM_IF_NULL_RETURN_VALUE(rule, NULL); + EM_IF_NULL_RETURN_VALUE(stream_len, NULL); + + tpl_node *tn = NULL; + + tn = tpl_map(EMAIL_RULE_FMT, rule); + tpl_pack(tn, 0); + + /* write account to buffer */ + void *buf = NULL; + size_t len = 0; + tpl_dump(tn, TPL_MEM, &buf, &len); + tpl_free(tn); + + *stream_len = len; + EM_DEBUG_FUNC_END("serialized len: %d", len); + return (char*) buf; + + +#if 0 + EM_DEBUG_FUNC_BEGIN(); char *result_stream = NULL; int stream_size = 0; @@ -1214,7 +1555,7 @@ INTERNAL_FUNC char* em_convert_rule_to_byte_stream(emf_rule_t *input_rule, int * result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_rule->type), sizeof(int)); result_stream = append_string_to_stream(result_stream, &stream_size, input_rule->value); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_rule->faction), sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_rule->mailbox); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_rule->target_mailbox_id), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_rule->flag1), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_rule->flag2), sizeof(int)); @@ -1222,11 +1563,28 @@ INTERNAL_FUNC char* em_convert_rule_to_byte_stream(emf_rule_t *input_rule, int * EM_DEBUG_FUNC_END(); return result_stream; +#endif } -INTERNAL_FUNC void em_convert_byte_stream_to_rule(char *input_stream, emf_rule_t *output_rule) +INTERNAL_FUNC void em_convert_byte_stream_to_rule(char *stream, int stream_len, email_rule_t *rule) { EM_DEBUG_FUNC_BEGIN(); + EM_NULL_CHECK_FOR_VOID(stream); + EM_NULL_CHECK_FOR_VOID(rule); + + tpl_node *tn = NULL; + + tn = tpl_map(EMAIL_RULE_FMT, rule); + tpl_load(tn, TPL_MEM, stream, stream_len); + tpl_unpack(tn, 0); + tpl_free(tn); + + EM_DEBUG_FUNC_END("deserialized len %d", stream_len); + + + +#if 0 + EM_DEBUG_FUNC_BEGIN(); int stream_offset = 0; EM_NULL_CHECK_FOR_VOID(input_stream); @@ -1237,14 +1595,17 @@ INTERNAL_FUNC void em_convert_byte_stream_to_rule(char *input_stream, emf_rule_t fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_rule->type)); fetch_string_from_stream(input_stream, &stream_offset, &output_rule->value); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_rule->faction)); - fetch_string_from_stream(input_stream, &stream_offset, &output_rule->mailbox); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_rule->target_mailbox_id)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_rule->flag1)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_rule->flag2)); - + EM_DEBUG_FUNC_END(); +#endif } -INTERNAL_FUNC char* em_convert_extra_flags_to_byte_stream(emf_extra_flag_t input_extra_flag, int *output_stream_size) + +#if 0 +INTERNAL_FUNC char* em_convert_extra_flags_to_byte_stream(email_extra_flag_t extra_flag, int *stream_len) { EM_DEBUG_FUNC_BEGIN(); char *result_stream = NULL; @@ -1275,7 +1636,8 @@ INTERNAL_FUNC char* em_convert_extra_flags_to_byte_stream(emf_extra_flag_t input return result_stream; } -INTERNAL_FUNC void em_convert_byte_stream_to_extra_flags(char *input_stream, emf_extra_flag_t *output_extra_flag) + +INTERNAL_FUNC void em_convert_byte_stream_to_extra_flags(char *input_stream, email_extra_flag_t *output_extra_flag) { EM_DEBUG_FUNC_BEGIN(); @@ -1302,9 +1664,56 @@ INTERNAL_FUNC void em_convert_byte_stream_to_extra_flags(char *input_stream, emf EM_DEBUG_FUNC_END(); } +#endif + -INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(emf_meeting_request_t *input_meeting_req, int *output_stream_size) +#define EMAIL_MEETING_REQUEST_FMT "iiBBs" "sic#Bi" "c#Bi" + +INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(email_meeting_request_t *meeting_req, int *stream_len) { + + EM_DEBUG_FUNC_END(); + EM_IF_NULL_RETURN_VALUE(meeting_req, NULL); + + tpl_node *tn = NULL; + tpl_bin tb[4]; + + tn = tpl_map(EMAIL_MEETING_REQUEST_FMT, + &meeting_req->mail_id, + &meeting_req->meeting_response, + &tb[0], + &tb[1], + &meeting_req->location, + &meeting_req->global_object_id, + &meeting_req->time_zone.offset_from_GMT, + meeting_req->time_zone.standard_name, 32, + &tb[2], + &meeting_req->time_zone.standard_bias, + meeting_req->time_zone.daylight_name, 32, + &tb[3], + &meeting_req->time_zone.daylight_bias + ); + 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 */ + void *buf = NULL; + size_t len = 0; + tpl_dump(tn, TPL_MEM, &buf, &len); + tpl_free(tn); + + *stream_len = len; + EM_DEBUG_FUNC_END(); + return (char*) buf; + + +#if 0 EM_DEBUG_FUNC_BEGIN(); char *result_stream = NULL; @@ -1312,7 +1721,7 @@ INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(emf_meeting_request_t EM_IF_NULL_RETURN_VALUE(input_meeting_req, NULL); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->mail_id), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->mail_id), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->meeting_response), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->start_time), sizeof(struct tm)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->end_time), sizeof(struct tm)); @@ -1321,27 +1730,67 @@ INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(emf_meeting_request_t result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->time_zone.offset_from_GMT), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_meeting_req->time_zone.standard_name, 32); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->time_zone.standard_time_start_date), sizeof(struct tm)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->time_zone.standard_bias), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->time_zone.standard_bias), sizeof(int)); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_meeting_req->time_zone.daylight_name, 32); result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->time_zone.daylight_time_start_date), sizeof(struct tm)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->time_zone.daylight_bias), sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_meeting_req->time_zone.daylight_bias), sizeof(int)); *output_stream_size = stream_size; EM_DEBUG_FUNC_END(); return result_stream; +#endif } -INTERNAL_FUNC void em_convert_byte_stream_to_meeting_req(char *input_stream, emf_meeting_request_t *output_meeting_req) +INTERNAL_FUNC void em_convert_byte_stream_to_meeting_req(char *stream, int stream_len, email_meeting_request_t *meeting_req) { + EM_DEBUG_FUNC_END(); + EM_NULL_CHECK_FOR_VOID(stream); + EM_NULL_CHECK_FOR_VOID(meeting_req); + + tpl_node *tn = NULL; + tpl_bin tb[4]; + + tn = tpl_map(EMAIL_MEETING_REQUEST_FMT, + &meeting_req->mail_id, + &meeting_req->meeting_response, + &tb[0], + &tb[1], + &meeting_req->location, + &meeting_req->global_object_id, + &meeting_req->time_zone.offset_from_GMT, + meeting_req->time_zone.standard_name, 32, + &tb[2], + &meeting_req->time_zone.standard_bias, + meeting_req->time_zone.daylight_name, 32, + &tb[3], + &meeting_req->time_zone.daylight_bias + ); + tpl_load(tn, TPL_MEM, stream, stream_len); + tpl_unpack(tn, 0); + tpl_free(tn); + + /* tb will be destroyed at end of func, but tb.addr remains */ + memcpy(&meeting_req->start_time, tb[0].addr, sizeof(struct tm)); + memcpy(&meeting_req->end_time, tb[1].addr, sizeof(struct tm)); + memcpy(&meeting_req->time_zone.standard_time_start_date, tb[2].addr, sizeof(struct tm)); + memcpy(&meeting_req->time_zone.daylight_time_start_date, tb[3].addr, sizeof(struct tm)); + + int i=0; + for(i=0; i< 4 ; i++) + EM_SAFE_FREE(tb[i].addr); + + EM_DEBUG_FUNC_END(); + +#if 0 EM_DEBUG_FUNC_BEGIN(); int stream_offset = 0; EM_NULL_CHECK_FOR_VOID(input_stream); EM_NULL_CHECK_FOR_VOID(output_meeting_req); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_meeting_req->mail_id)); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_meeting_req->mail_id)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_meeting_req->meeting_response)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(struct tm), (char*)&(output_meeting_req->start_time)); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(struct tm), (char*)&(output_meeting_req->end_time)); @@ -1350,15 +1799,17 @@ INTERNAL_FUNC void em_convert_byte_stream_to_meeting_req(char *input_stream, em fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_meeting_req->time_zone.offset_from_GMT)); fetch_sized_data_from_stream(input_stream, &stream_offset, 32, output_meeting_req->time_zone.standard_name); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(struct tm), (char*)&(output_meeting_req->time_zone.standard_time_start_date)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_meeting_req->time_zone.standard_bias)); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_meeting_req->time_zone.standard_bias)); fetch_sized_data_from_stream(input_stream, &stream_offset, 32, output_meeting_req->time_zone.daylight_name); fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(struct tm), (char*)&(output_meeting_req->time_zone.daylight_time_start_date)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_meeting_req->time_zone.daylight_bias)); + fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(output_meeting_req->time_zone.daylight_bias)); EM_DEBUG_FUNC_END(); +#endif } -INTERNAL_FUNC char* em_convert_search_filter_to_byte_stream(email_search_filter_t *input_search_filter_list, int input_search_filter_count, int *output_stream_size) +INTERNAL_FUNC char* em_convert_search_filter_to_byte_stream(email_search_filter_t *input_search_filter_list, + int input_search_filter_count, int *output_stream_size) { EM_DEBUG_FUNC_BEGIN("input_search_filter_list [%p] input_search_filter_count [%d]", input_search_filter_list, input_search_filter_count); @@ -1413,7 +1864,8 @@ INTERNAL_FUNC char* em_convert_search_filter_to_byte_stream(email_search_filter_ return result_stream; } -INTERNAL_FUNC void em_convert_byte_stream_to_search_filter(char *input_stream, email_search_filter_t **output_search_filter_list, int *output_search_filter_count) +INTERNAL_FUNC void em_convert_byte_stream_to_search_filter(char *input_stream, + email_search_filter_t **output_search_filter_list, int *output_search_filter_count) { EM_DEBUG_FUNC_BEGIN("input_stream [%p] output_search_filter_list [%p] output_search_filter_count [%p]", input_stream, output_search_filter_list, output_search_filter_count); @@ -1485,3 +1937,68 @@ FINISH_OFF: EM_DEBUG_FUNC_END(); } + +INTERNAL_FUNC int em_convert_certificate_tbl_to_certificate(emstorage_certificate_tbl_t *certificate_tbl, email_certificate_t **certificate, int *error) +{ + EM_DEBUG_FUNC_BEGIN("certficate_tbl[%p], certificate[%p]", certificate_tbl, certificate); + + int err_code = EMAIL_ERROR_NONE; + int ret = false; + email_certificate_t *temp_certificate = NULL; + + if (!certificate_tbl || !certificate) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + err_code = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + temp_certificate = em_malloc(sizeof(email_certificate_t)) ; + if (!temp_certificate) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err_code = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + temp_certificate->certificate_id = certificate_tbl->certificate_id; + temp_certificate->issue_year = certificate_tbl->issue_year; + temp_certificate->issue_month = certificate_tbl->issue_month; + temp_certificate->issue_day = certificate_tbl->issue_day; + temp_certificate->expiration_year = certificate_tbl->expiration_year; + temp_certificate->expiration_month = certificate_tbl->expiration_month; + temp_certificate->expiration_day = certificate_tbl->expiration_day; + temp_certificate->issue_organization_name = EM_SAFE_STRDUP(certificate_tbl->issue_organization_name); + temp_certificate->email_address = EM_SAFE_STRDUP(certificate_tbl->email_address); + temp_certificate->subject_str = EM_SAFE_STRDUP(certificate_tbl->subject_str); + temp_certificate->filepath = EM_SAFE_STRDUP(certificate_tbl->filepath); + + *certificate = temp_certificate; + + ret = true; +FINISH_OFF: + if (error) + *error = err_code; + + EM_DEBUG_FUNC_END(); + return true; +} + +INTERNAL_FUNC int em_convert_certificate_to_certificate_tbl(email_certificate_t *certificate, emstorage_certificate_tbl_t *certificate_tbl) +{ + EM_DEBUG_FUNC_BEGIN("certficate[%p], certificate_tbl[%p]", certificate, certificate_tbl); + + certificate_tbl->certificate_id = certificate->certificate_id; + certificate_tbl->issue_year = certificate->issue_year; + certificate_tbl->issue_month = certificate->issue_month; + certificate_tbl->issue_day = certificate->issue_day; + certificate_tbl->expiration_year = certificate->expiration_year; + certificate_tbl->expiration_month = certificate->expiration_month; + certificate_tbl->expiration_day = certificate->expiration_day; + certificate_tbl->issue_organization_name = EM_SAFE_STRDUP(certificate->issue_organization_name); + certificate_tbl->email_address = EM_SAFE_STRDUP(certificate->email_address); + certificate_tbl->subject_str = EM_SAFE_STRDUP(certificate->subject_str); + certificate_tbl->filepath = EM_SAFE_STRDUP(certificate->filepath); + + EM_DEBUG_FUNC_END(); + return true; +} + diff --git a/email-common-use/email-utilities.c b/email-common-use/email-utilities.c index 5cebaf9..d5ba501 100755 --- a/email-common-use/email-utilities.c +++ b/email-common-use/email-utilities.c @@ -1,643 +1,1079 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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-utilities.c - * - * Created on: 2012. 3. 6. - * Author: kyuho.jo@samsung.com - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "c-client.h" - -#include "email-types.h" -#include "email-internal-types.h" -#include "email-utilities.h" - -INTERNAL_FUNC void* em_malloc(unsigned len) -{ - /* EM_DEBUG_LOG("Memory allocation size[%d] bytes", len); */ - void *p = NULL; - - if (len <= 0) { - EM_DEBUG_EXCEPTION("len should be positive.[%d]", len); - return NULL; - } - - p = malloc(len); - - if (p) - memset(p, 0x00, len); - else - EM_DEBUG_EXCEPTION("malloc failed"); - return p; -} - -/* remove left space, tab, CR, L */ -INTERNAL_FUNC char *em_trim_left(char *str) -{ - char *p, *temp_buffer = NULL; - - /* EM_DEBUG_FUNC_BEGIN() */ - if (!str) return NULL; - - p = str; - while (*p && (*p == ' ' || *p == '\t' || *p == LF || *p == CR)) p++; - - if (!*p) return NULL; - - temp_buffer = EM_SAFE_STRDUP(p); - - strncpy(str, temp_buffer, strlen(str)); - str[strlen(temp_buffer)] = NULL_CHAR; - - EM_SAFE_FREE(temp_buffer); - - return str; -} - -/* remove right space, tab, CR, L */ -INTERNAL_FUNC char *em_trim_right(char *str) -{ - char *p; - - /* EM_DEBUG_FUNC_BEGIN() */ - if (!str) return NULL; - - p = str+strlen(str)-1; - while (((int)p >= (int)str) && (*p == ' ' || *p == '\t' || *p == LF || *p == CR)) - *p --= '\0'; - - if ((int) p < (int)str) - return NULL; - - return str; -} - -INTERNAL_FUNC char* em_upper_string(char *str) -{ - char *p = str; - while (*p) { - *p = toupper(*p); - p++; - } - return str; -} - -INTERNAL_FUNC char* em_lower_string(char *str) -{ - char *p = str; - while (*p) { - *p = tolower(*p); - p++; - } - return str; -} - -INTERNAL_FUNC int em_upper_path(char *path) -{ - int i = 0, is_utf7 = 0, len = path ? (int)strlen(path) : -1; - for (; i < len; i++) { - if (path[i] == '&' || path[i] == 5) { - is_utf7 = 1; - } - else { - if (is_utf7) { - if (path[i] == '-') is_utf7 = 0; - } - else { - path[i] = toupper(path[i]); - } - } - } - - return 1; -} - -INTERNAL_FUNC void em_skip_whitespace(char *addr_str, char **pAddr) -{ - EM_DEBUG_FUNC_BEGIN("addr_str[%p]", addr_str); - - if (!addr_str) - return ; - char *str = addr_str; - char ptr[strlen(str)+1] ; - int i, j = 0; - - str = addr_str ; - for (i = 0; str[i] != NULL_CHAR ; i++) { - if (str[i] != SPACE && str[i] != TAB && str[i] != CR && str[i] != LF) - ptr[j++] = str[i]; - } - ptr[j] = NULL_CHAR; - - *pAddr = EM_SAFE_STRDUP(ptr); - EM_DEBUG_FUNC_END("ptr[%s]", ptr); -} - -INTERNAL_FUNC char* em_skip_whitespace_without_strdup(char *source_string) -{ - EM_DEBUG_FUNC_BEGIN("source_string[%p]", source_string); - - if (!source_string) - return NULL; - int i; - - for (i = 0; source_string[i] != NULL_CHAR ; i++) { - if (source_string[i] != SPACE) /* || source_string[i] != TAB || source_string[i] != CR || source_string[i] || LF) */ - break; - } - - EM_DEBUG_FUNC_END("i[%d]", i); - return source_string + i; -} - -INTERNAL_FUNC char* em_replace_string(char *source_string, char *old_string, char *new_string) -{ - EM_DEBUG_FUNC_BEGIN(); - char *result_buffer = NULL; - char *p = NULL; - int buffer_length = 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); - - p = strstr(source_string, old_string); - - if (p == NULL) { - EM_DEBUG_EXCEPTION("old_string not found in source_string"); - EM_DEBUG_FUNC_END("return NULL"); - return NULL; - } - - buffer_length = strlen(source_string) + 1024; - result_buffer = (char *)em_malloc(buffer_length); - - if (!result_buffer) { - EM_DEBUG_EXCEPTION("em_malloc failed"); - return NULL; - } - - strncpy(result_buffer, source_string, p - source_string); - snprintf(result_buffer + strlen(result_buffer), buffer_length - strlen(result_buffer), "%s%s", new_string, p + strlen(old_string)); - - EM_DEBUG_FUNC_END("result_buffer[%s]", result_buffer); - return result_buffer; -} - -/* Memory clean up */ -#include - -/* #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(); -} - -#define DATE_TIME_STRING_LEGNTH 14 - -INTERNAL_FUNC char *em_get_extension_from_file_path(char *source_file_path, int *err_code) -{ - EM_DEBUG_FUNC_BEGIN("source_file_path[%s]", source_file_path); - int err = EMF_ERROR_NONE, pos_on_string = 0; - char *extension = NULL; - - if (!source_file_path) { - EM_DEBUG_EXCEPTION("Invalid Parameter"); - err = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } - - pos_on_string = strlen(source_file_path) - 1; - - while(pos_on_string > 0 && source_file_path[pos_on_string--] != '.') ; - - if(pos_on_string > 0) - extension = source_file_path + pos_on_string + 2; - - EM_DEBUG_LOG("*extension [%s] pos_on_string [%d]", extension, pos_on_string); - -FINISH_OFF: - if (err_code) - *err_code = err; - EM_DEBUG_FUNC_END(); - return extension; -} - -INTERNAL_FUNC int em_get_encoding_type_from_file_path(const char *input_file_path, char **output_encoding_type) -{ - EM_DEBUG_FUNC_BEGIN("input_file_path[%d], output_encoding_type[%p]", input_file_path, output_encoding_type); - int err = EMF_ERROR_NONE; - int pos_of_filename = 0; - int pos_of_dot = 0; - int enf_of_string = 0; - int result_string_length = 0; - char *filename = NULL; - char *result_encoding_type = NULL; - - if (!input_file_path || !output_encoding_type) { - EM_DEBUG_EXCEPTION("Invalid Parameter"); - err = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } - - enf_of_string = pos_of_filename = strlen(input_file_path) - 1; - - while(pos_of_filename >= 0 && input_file_path[pos_of_filename--] != '/') { - if(input_file_path[pos_of_filename] == '.') - pos_of_dot = pos_of_filename; - } - - if(pos_of_filename != 0) - pos_of_filename += 2; - - filename = (char*)input_file_path + pos_of_filename; - - if(pos_of_dot != 0 && pos_of_dot > pos_of_filename) - result_string_length = pos_of_dot - pos_of_filename; - else - result_string_length = enf_of_string - pos_of_filename; - - EM_DEBUG_LOG("pos_of_dot [%d], pos_of_filename [%d], enf_of_string[%d],result_string_length [%d]", pos_of_dot, pos_of_filename, enf_of_string, result_string_length); - - if( !(result_encoding_type = em_malloc(sizeof(char) * (result_string_length + 1))) ) { - EM_DEBUG_EXCEPTION("EMF_ERROR_OUT_OF_MEMORY"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - memcpy(result_encoding_type, input_file_path + pos_of_filename, result_string_length); - - EM_DEBUG_LOG("*result_encoding_type [%s]", result_encoding_type); - - *output_encoding_type = result_encoding_type; - -FINISH_OFF: - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} - -INTERNAL_FUNC int em_get_content_type_from_extension_string(const char *extension_string, int *err_code) -{ - EM_DEBUG_FUNC_BEGIN("extension_string[%s]", extension_string); - int i = 0, err = EMF_ERROR_NONE, result_content_type = TYPEAPPLICATION; - char *image_extension[] = { "jpeg", "jpg", "png", "gif", "bmp", "pic", "agif", "tif", "wbmp" , NULL}; - - if (!extension_string) { - EM_DEBUG_EXCEPTION("Invalid Parameter"); - err = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } - - while(image_extension[i]) { - EM_DEBUG_LOG("image_extension[%d] [%s]", i, image_extension[i]); - if(strcasecmp(image_extension[i], extension_string) == 0) { - result_content_type = TYPEIMAGE; - break; - } - i++; - } - -FINISH_OFF: - if (err_code) - *err_code = err; - EM_DEBUG_FUNC_END(); - return result_content_type; -} - -#define EMAIL_ACCOUNT_RGEX "([a-z0-9!#$%&'*+/=?^_`{|}~-]+.)*[a-z0-9!#$%&'*+/=?^_`{|}~-]+" -#define EMAIL_DOMAIN_RGEX "([a-z0-9!#$%&'*+/=?^_`{|}~-]+.)+[a-z0-9!#$%&'*+/=?^_`{|}~-]+" - -#define EMAIL_ADDR_RGEX "[[:space:]]*<"EMAIL_ACCOUNT_RGEX"@"EMAIL_DOMAIN_RGEX">[[:space:]]*" -#define EMAIL_ALIAS_RGEX "([[:space:]]*\"[^\"]*\")?"EMAIL_ADDR_RGEX -#define EMAIL_ALIAS_LIST_RGEX "^("EMAIL_ALIAS_RGEX"[;,])*"EMAIL_ALIAS_RGEX"[;,]?[[:space:]]*$" - -#define EMAIL_ADDR_WITHOUT_BRACKET_RGEX "[[:space:]]*"EMAIL_ACCOUNT_RGEX"@"EMAIL_DOMAIN_RGEX"[[:space:]]*" -#define EMAIL_ALIAS_WITHOUT_BRACKET_RGEX "([[:space:]]*\"[^\"]*\")?"EMAIL_ADDR_WITHOUT_BRACKET_RGEX -#define EMAIL_ALIAS_LIST_WITHOUT_BRACKET_RGEX "("EMAIL_ALIAS_WITHOUT_BRACKET_RGEX"[;,])*"EMAIL_ADDR_WITHOUT_BRACKET_RGEX"[;,]?[[:space:]]*$" - -INTERNAL_FUNC int em_verify_email_address(char *address, int without_bracket, int *err_code) -{ - EM_DEBUG_FUNC_BEGIN("address[%s] without_bracket[%d]", address, without_bracket); - - /* this following code verfies the email alias string using reg. exp. */ - regex_t alias_list_regex = {0}; - int ret = false, error = EMF_ERROR_NONE; - char *reg_rule = NULL; - - if(!address || strlen(address) == 0) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - if (err_code) - *err_code = EMF_ERROR_INVALID_PARAM; - return false; - } - - if(without_bracket) - reg_rule = EMAIL_ALIAS_LIST_WITHOUT_BRACKET_RGEX; - else - reg_rule = EMAIL_ALIAS_LIST_RGEX; - - if (regcomp(&alias_list_regex, reg_rule, REG_ICASE | REG_EXTENDED)) { - EM_DEBUG_EXCEPTION("email alias regex unrecognized"); - if (err_code) - *err_code = EMF_ERROR_UNKNOWN; - return false; - } - - int alias_len = strlen(address) + 1; - regmatch_t pmatch[alias_len]; - - bzero(pmatch, alias_len); - - if (regexec(&alias_list_regex, address, alias_len, pmatch, 0) == REG_NOMATCH) - EM_DEBUG_LOG("failed :[%s]", address); - else { - EM_DEBUG_LOG("success :[%s]", address); - ret = true; - } - - regfree(&alias_list_regex); - - if (err_code) - *err_code = error; - - EM_DEBUG_FUNC_END("ret [%d]", ret); - return ret; -} - -INTERNAL_FUNC int em_verify_email_address_of_mail_data(emf_mail_data_t *mail_data, int without_bracket, int *err_code) -{ - EM_DEBUG_FUNC_BEGIN("mail_data[%p] without_bracket[%d]", mail_data, without_bracket); - char *address_array[4] = { mail_data->full_address_from, mail_data->full_address_to, mail_data->full_address_cc, mail_data->full_address_bcc}; - int ret = false, err = EMF_ERROR_NONE, i; - - /* check for email_address validation */ - for (i = 0; i < 4; i++) { - if (address_array[i] && address_array[i][0] != 0) { - if (!em_verify_email_address(address_array[i] , without_bracket, &err)) { - err = EMF_ERROR_INVALID_ADDRESS; - EM_DEBUG_EXCEPTION("Invalid Email Address [%d][%s]", i, address_array[i]); - goto FINISH_OFF; - } - } - } - ret = true; -FINISH_OFF: - EM_DEBUG_FUNC_END("ret [%d]", ret); - return ret; -} - -INTERNAL_FUNC int em_verify_email_address_of_mail_tbl(emstorage_mail_tbl_t *input_mail_tbl, int input_without_bracket) -{ - EM_DEBUG_FUNC_BEGIN("input_mail_tbl[%p] input_without_bracket[%d]", input_mail_tbl, input_without_bracket); - char *address_array[4] = { input_mail_tbl->full_address_to, input_mail_tbl->full_address_cc, input_mail_tbl->full_address_bcc, input_mail_tbl->full_address_from}; - int err = EMF_ERROR_NONE, i; - - /* check for email_address validation */ - for (i = 0; i < 4; i++) { - if (address_array[i] && address_array[i][0] != 0) { - if (!em_verify_email_address(address_array[i] , input_without_bracket, &err)) { - err = EMF_ERROR_INVALID_ADDRESS; - EM_DEBUG_EXCEPTION("Invalid Email Address [%d][%s]", i, address_array[i]); - goto FINISH_OFF; - } - } - } - -FINISH_OFF: - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} - -INTERNAL_FUNC int em_find_tag_for_thread_view(char *subject, int *result) -{ - EM_DEBUG_FUNC_BEGIN(); - int error_code = EMF_ERROR_NONE; - char *copy_of_subject = NULL; - - EM_IF_NULL_RETURN_VALUE(subject, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(result, EMF_ERROR_INVALID_PARAM); - - *result = FALSE; - - copy_of_subject = EM_SAFE_STRDUP(subject); - - if (copy_of_subject == NULL) { - EM_DEBUG_EXCEPTION("strdup is failed."); - goto FINISH_OFF; - } - - em_upper_string(copy_of_subject); - EM_DEBUG_LOG("em_upper_string result : %s\n", copy_of_subject); - - if (strstr(copy_of_subject, "RE:") == NULL) { - if (strstr(copy_of_subject, "FWD:") == NULL) { - if (strstr(copy_of_subject, "FW:") != NULL) - *result = TRUE; - } - else - *result = TRUE; - } - else - *result = TRUE; - -FINISH_OFF: - EM_SAFE_FREE(copy_of_subject); - - EM_DEBUG_FUNC_END("result : %d", *result); - - return error_code; -} - -INTERNAL_FUNC int em_find_pos_stripped_subject_for_thread_view(char *subject, char *stripped_subject) -{ - EM_DEBUG_FUNC_BEGIN(); - int error_code = EMF_ERROR_NONE; - int gap; - char *copy_of_subject = NULL, *curpos = NULL, *result; - - EM_IF_NULL_RETURN_VALUE(subject, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(stripped_subject, EMF_ERROR_INVALID_PARAM); - - copy_of_subject = EM_SAFE_STRDUP(subject); - - if (copy_of_subject == NULL) { - EM_DEBUG_EXCEPTION("strdup is failed"); - goto FINISH_OFF; - } - - em_upper_string(copy_of_subject); - curpos = copy_of_subject; - - EM_DEBUG_LOG("em_upper_string result : %s", copy_of_subject); - - while ((result = strstr(curpos, "RE:")) != NULL) { - curpos = result + 3; - EM_DEBUG_LOG("RE result : %s", curpos); - } - - while ((result = strstr(curpos, "FWD:")) != NULL) { - curpos = result + 4; - EM_DEBUG_LOG("FWD result : %s", curpos); - } - - while ((result = strstr(curpos, "FW:")) != NULL) { - curpos = result + 3; - EM_DEBUG_LOG("FW result : %s", curpos); - } - - while (curpos != NULL && *curpos == ' ') { - curpos++; - } - - gap = curpos - copy_of_subject; - - strcpy(stripped_subject, subject + gap); - -FINISH_OFF: - EM_SAFE_FREE(copy_of_subject); - - if (error_code == EMF_ERROR_NONE && stripped_subject) - EM_DEBUG_LOG("result[%s]", stripped_subject); - - EM_DEBUG_FUNC_END("error_code[%d]", error_code); - return error_code; -} - - -/* - * encoding base64 - */ -INTERNAL_FUNC int em_encode_base64(char *src, unsigned long src_len, char **enc, unsigned long* enc_len, int *err_code) -{ - EM_DEBUG_FUNC_BEGIN(); - - unsigned char *content; - int ret = true, err = EMF_ERROR_NONE; - - if (err_code != NULL) { - *err_code = EMF_ERROR_NONE; - } - - content = rfc822_binary(src, src_len, enc_len); - - if (content) - *enc = (char *)content; - else { - err = EMF_ERROR_UNKNOWN; - ret = false; - } - - if (err_code) - *err_code = err; - - EM_DEBUG_FUNC_END(); - return ret; -} - -/* - * decoding base64 - */ -INTERNAL_FUNC int em_decode_base64(unsigned char *enc_text, unsigned long enc_len, char **dec_text, unsigned long* dec_len, int *err_code) -{ - unsigned char *text = enc_text; - unsigned long size = enc_len; - unsigned char *content; - int ret = true, err = EMF_ERROR_NONE; - - if (err_code != NULL) { - *err_code = EMF_ERROR_NONE; - } - - EM_DEBUG_FUNC_BEGIN(); - - content = rfc822_base64(text, size, dec_len); - if (content) - *dec_text = (char *)content; - else - { - err = EMF_ERROR_UNKNOWN; - ret = false; - } - - if (err_code) - *err_code = err; - - return ret; -} +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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-utilities.c + * + * Created on: 2012. 3. 6. + * Author: kyuho.jo@samsung.com + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "c-client.h" + +#include "email-types.h" +#include "email-internal-types.h" +#include "email-utilities.h" + +INTERNAL_FUNC void* em_malloc(int len) +{ + /* EM_DEBUG_LOG("Memory allocation size[%d] bytes", len); */ + if (len <= 0) { + EM_DEBUG_EXCEPTION("len should be positive.[%d]", len); + return NULL; + } + + void *p = calloc(1,len); + if (!p) + EM_DEBUG_PERROR("malloc failed"); + + return p; +} + + +INTERNAL_FUNC void* em_memdup(void* src, int len) +{ + /* EM_DEBUG_LOG("Memory allocation size[%d] bytes", len); */ + if (len <= 0) { + EM_DEBUG_EXCEPTION("len should be positive.[%d]", len); + return NULL; + } + + void *p = calloc(1,len); + if (!p) + EM_DEBUG_EXCEPTION("malloc failed"); + + memcpy(p, src, len); + + return p; +} + + +/* remove left space, tab, CR, L */ +INTERNAL_FUNC char *em_trim_left(char *str) +{ + char *p, *temp_buffer = NULL; + + /* EM_DEBUG_FUNC_BEGIN() */ + if (!str) return NULL; + + p = str; + while (*p && (*p == ' ' || *p == '\t' || *p == LF || *p == CR)) p++; + + if (!*p) return NULL; + + temp_buffer = EM_SAFE_STRDUP(p); + + strncpy(str, temp_buffer, strlen(str)); + str[strlen(temp_buffer)] = NULL_CHAR; + + EM_SAFE_FREE(temp_buffer); + + return str; +} + +/* remove right space, tab, CR, L */ +INTERNAL_FUNC char *em_trim_right(char *str) +{ + char *p; + + /* EM_DEBUG_FUNC_BEGIN() */ + if (!str) return NULL; + + p = str+strlen(str)-1; + while (((int)p >= (int)str) && (*p == ' ' || *p == '\t' || *p == LF || *p == CR)) + *p --= '\0'; + + if ((int) p < (int)str) + return NULL; + + return str; +} + +INTERNAL_FUNC char* em_upper_string(char *str) +{ + char *p = str; + while (*p) { + *p = toupper(*p); + p++; + } + return str; +} + +INTERNAL_FUNC char* em_lower_string(char *str) +{ + char *p = str; + while (*p) { + *p = tolower(*p); + p++; + } + return str; +} + +INTERNAL_FUNC int em_upper_path(char *path) +{ + int i = 0, is_utf7 = 0, len = path ? (int)strlen(path) : -1; + for (; i < len; i++) { + if (path[i] == '&' || path[i] == 5) { + is_utf7 = 1; + } + else { + if (is_utf7) { + if (path[i] == '-') is_utf7 = 0; + } + else { + path[i] = toupper(path[i]); + } + } + } + + return 1; +} + +INTERNAL_FUNC void em_skip_whitespace(char *addr_str, char **pAddr) +{ + EM_DEBUG_FUNC_BEGIN("addr_str[%p]", addr_str); + + if (!addr_str) + return ; + char *str = addr_str; + char ptr[strlen(str)+1] ; + int i, j = 0; + + str = addr_str ; + for (i = 0; str[i] != NULL_CHAR ; i++) { + if (str[i] != SPACE && str[i] != TAB && str[i] != CR && str[i] != LF) + ptr[j++] = str[i]; + } + ptr[j] = NULL_CHAR; + + *pAddr = EM_SAFE_STRDUP(ptr); + EM_DEBUG_FUNC_END("ptr[%s]", ptr); +} + +INTERNAL_FUNC char* em_skip_whitespace_without_strdup(char *source_string) +{ + EM_DEBUG_FUNC_BEGIN("source_string[%p]", source_string); + + if (!source_string) + return NULL; + int i; + + for (i = 0; source_string[i] != NULL_CHAR ; i++) { + if (source_string[i] != SPACE) /* || source_string[i] != TAB || source_string[i] != CR || source_string[i] || LF) */ + break; + } + + EM_DEBUG_FUNC_END("i[%d]", i); + return source_string + i; +} + + +INTERNAL_FUNC char* em_replace_all_string(char *source_string, char *old_string, char *new_string) +{ + EM_DEBUG_FUNC_BEGIN(); + char *result_buffer = NULL; + char *p = NULL; + int i = 0, count = 0; + int old_str_length = 0; + int new_str_length = 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); + + old_str_length = strlen(old_string); + new_str_length = strlen(new_string); + + if (old_str_length != new_str_length) { + for (i = 0; source_string[i] != '\0';) { + if (memcmp(&source_string[i], old_string, old_str_length) == 0) { + count++; + i += old_str_length; + } else { + i++; + } + } + } else { + i = strlen(source_string); + } + + result_buffer = (char *)malloc(i + 1 + count*(new_str_length-old_str_length)); + if (result_buffer == NULL) + return NULL; + + p = result_buffer; + while (*source_string) { + if (memcmp(source_string, old_string, old_str_length) == 0) { + memcpy(p, new_string, new_str_length); + p += new_str_length; + source_string += old_str_length; + } else { + *p++ = *source_string++; + } + } + *p = '\0'; + + EM_DEBUG_FUNC_END("result_buffer : %s", result_buffer); + return result_buffer; +} + +INTERNAL_FUNC char* em_replace_string(char *source_string, char *old_string, char *new_string) +{ + EM_DEBUG_FUNC_BEGIN(); + char *result_buffer = NULL; + char *p = NULL; + int buffer_length = 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); + + p = strstr(source_string, old_string); + + if (p == NULL) { + EM_DEBUG_EXCEPTION("old_string not found in source_string"); + EM_DEBUG_FUNC_END("return NULL"); + return NULL; + } + + buffer_length = strlen(source_string) + 1024; + result_buffer = (char *)em_malloc(buffer_length); + + if (!result_buffer) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + return NULL; + } + + strncpy(result_buffer, source_string, p - source_string); + snprintf(result_buffer + strlen(result_buffer), buffer_length - strlen(result_buffer), "%s%s", new_string, p + strlen(old_string)); + + EM_DEBUG_FUNC_END("result_buffer[%s]", result_buffer); + return result_buffer; +} + +/* Memory clean up */ +#include + +/* #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_and_extension_from_file_path(char *input_source_file_path, char **output_file_name, char **output_extension) +{ + EM_DEBUG_FUNC_BEGIN("input_source_file_path[%s], output_file_name [%p], output_extension [%p]", input_source_file_path, output_file_name, output_extension); + int err = EMAIL_ERROR_NONE; + int pos_on_string = 0; + int file_name_length = 0; + int extention_length = 0; + char *start_pos_of_file_name = NULL; + char *end_pos_of_file_name = NULL; + char *dot_pos_of_file_path = NULL; + char *end_pos_of_file_path = NULL; + char file_name_string[MAX_PATH] = { 0, }; + char extension_string[MAX_PATH] = { 0, }; + + if (!input_source_file_path || !output_file_name || !output_extension) { + EM_DEBUG_EXCEPTION("Invalid Parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + pos_on_string = strlen(input_source_file_path) - 1; + end_pos_of_file_path = input_source_file_path + pos_on_string; + end_pos_of_file_name = end_pos_of_file_path; + + while(pos_on_string >= 0 && input_source_file_path[pos_on_string] != '/') { + if(input_source_file_path[pos_on_string] == '.') { + if(dot_pos_of_file_path == NULL) { + end_pos_of_file_name = input_source_file_path + pos_on_string; + dot_pos_of_file_path = end_pos_of_file_name; + } + } + pos_on_string--; + } + + pos_on_string++; + + if(pos_on_string >= 0) { + start_pos_of_file_name = input_source_file_path + pos_on_string; + file_name_length = end_pos_of_file_name - start_pos_of_file_name; + memcpy(file_name_string, start_pos_of_file_name, file_name_length); + } + + if(dot_pos_of_file_path != NULL) { + extention_length = (end_pos_of_file_path + 1) - (dot_pos_of_file_path + 1); + memcpy(extension_string, dot_pos_of_file_path + 1, extention_length); + } + + EM_DEBUG_LOG("*file_name_string [%s] pos_on_string [%d]", file_name_string, pos_on_string); + + *output_file_name = EM_SAFE_STRDUP(file_name_string); + *output_extension = EM_SAFE_STRDUP(extension_string); + +FINISH_OFF: + EM_DEBUG_FUNC_END("err = [%d]", err); + return err; +} + +INTERNAL_FUNC char *em_get_extension_from_file_path(char *source_file_path, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("source_file_path[%s]", source_file_path); + int err = EMAIL_ERROR_NONE, pos_on_string = 0; + char *extension = NULL; + + if (!source_file_path) { + EM_DEBUG_EXCEPTION("Invalid Parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + pos_on_string = strlen(source_file_path) - 1; + + while(pos_on_string > 0 && source_file_path[pos_on_string--] != '.') ; + + if(pos_on_string > 0) + extension = source_file_path + pos_on_string + 2; + + EM_DEBUG_LOG("*extension [%s] pos_on_string [%d]", extension, pos_on_string); + +FINISH_OFF: + if (err_code) + *err_code = err; + EM_DEBUG_FUNC_END(); + return extension; +} + +INTERNAL_FUNC int em_get_encoding_type_from_file_path(const char *input_file_path, char **output_encoding_type) +{ + EM_DEBUG_FUNC_BEGIN("input_file_path[%d], output_encoding_type[%p]", input_file_path, output_encoding_type); + int err = EMAIL_ERROR_NONE; + int pos_of_filename = 0; + int pos_of_dot = 0; + int enf_of_string = 0; + int result_string_length = 0; + char *filename = NULL; + char *result_encoding_type = NULL; + + if (!input_file_path || !output_encoding_type) { + EM_DEBUG_EXCEPTION("Invalid Parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + enf_of_string = pos_of_filename = strlen(input_file_path); + + while(pos_of_filename >= 0 && input_file_path[pos_of_filename--] != '/') { + if(input_file_path[pos_of_filename] == '.') + pos_of_dot = pos_of_filename; + } + + if(pos_of_filename != 0) + pos_of_filename += 2; + + filename = (char*)input_file_path + pos_of_filename; + + if(pos_of_dot != 0 && pos_of_dot > pos_of_filename) + result_string_length = pos_of_dot - pos_of_filename; + else + result_string_length = enf_of_string - pos_of_filename; + + EM_DEBUG_LOG("pos_of_dot [%d], pos_of_filename [%d], enf_of_string[%d],result_string_length [%d]", pos_of_dot, pos_of_filename, enf_of_string, result_string_length); + + if( !(result_encoding_type = em_malloc(sizeof(char) * (result_string_length + 1))) ) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + memcpy(result_encoding_type, input_file_path + pos_of_filename, result_string_length); + + EM_DEBUG_LOG("*result_encoding_type [%s]", result_encoding_type); + + *output_encoding_type = result_encoding_type; + +FINISH_OFF: + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +INTERNAL_FUNC int em_get_content_type_from_extension_string(const char *extension_string, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("extension_string[%s]", extension_string); + int i = 0, err = EMAIL_ERROR_NONE, result_content_type = TYPEAPPLICATION; + char *image_extension[] = { "jpeg", "jpg", "png", "gif", "bmp", "pic", "agif", "tif", "wbmp" , NULL}; + + if (!extension_string) { + EM_DEBUG_EXCEPTION("Invalid Parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + while(image_extension[i]) { + EM_DEBUG_LOG("image_extension[%d] [%s]", i, image_extension[i]); + if(strcasecmp(image_extension[i], extension_string) == 0) { + result_content_type = TYPEIMAGE; + break; + } + i++; + } + +FINISH_OFF: + if (err_code) + *err_code = err; + EM_DEBUG_FUNC_END(); + return result_content_type; +} + +#define EMAIL_ACCOUNT_RGEX "([a-z0-9!#$%&'*+/=?^_`{|}~-]+.)*[a-z0-9!#$%&'*+/=?^_`{|}~-]+" +#define EMAIL_DOMAIN_RGEX "([a-z0-9!#$%&'*+/=?^_`{|}~-]+.)+[a-z0-9!#$%&'*+/=?^_`{|}~-]+" + +#define EMAIL_ADDR_RGEX "[[:space:]]*<"EMAIL_ACCOUNT_RGEX"@"EMAIL_DOMAIN_RGEX">[[:space:]]*" +#define EMAIL_ALIAS_RGEX "([[:space:]]*\"[^\"]*\")?"EMAIL_ADDR_RGEX +#define EMAIL_ALIAS_LIST_RGEX "^("EMAIL_ALIAS_RGEX"[;,])*"EMAIL_ALIAS_RGEX"[;,]?[[:space:]]*$" + +#define EMAIL_ADDR_WITHOUT_BRACKET_RGEX "[[:space:]]*"EMAIL_ACCOUNT_RGEX"@"EMAIL_DOMAIN_RGEX"[[:space:]]*" +#define EMAIL_ALIAS_WITHOUT_BRACKET_RGEX "([[:space:]]*\"[^\"]*\")?"EMAIL_ADDR_WITHOUT_BRACKET_RGEX +#define EMAIL_ALIAS_LIST_WITHOUT_BRACKET_RGEX "("EMAIL_ALIAS_WITHOUT_BRACKET_RGEX"[;,])*"EMAIL_ADDR_WITHOUT_BRACKET_RGEX"[;,]?[[:space:]]*$" + +INTERNAL_FUNC int em_verify_email_address(char *address, int without_bracket, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("address[%s] without_bracket[%d]", address, without_bracket); + + /* this following code verfies the email alias string using reg. exp. */ + regex_t alias_list_regex = {0}; + int ret = false, error = EMAIL_ERROR_NONE; + char *reg_rule = NULL; + + if(!address || strlen(address) == 0) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + if (err_code) + *err_code = EMAIL_ERROR_INVALID_PARAM; + return false; + } + + if(without_bracket) + reg_rule = EMAIL_ALIAS_LIST_WITHOUT_BRACKET_RGEX; + else + reg_rule = EMAIL_ALIAS_LIST_RGEX; + + if (regcomp(&alias_list_regex, reg_rule, REG_ICASE | REG_EXTENDED)) { + EM_DEBUG_EXCEPTION("email alias regex unrecognized"); + if (err_code) + *err_code = EMAIL_ERROR_UNKNOWN; + return false; + } + + int alias_len = strlen(address) + 1; + regmatch_t pmatch[alias_len]; + + bzero(pmatch, alias_len); + + if (regexec(&alias_list_regex, address, alias_len, pmatch, 0) == REG_NOMATCH) + EM_DEBUG_LOG("failed :[%s]", address); + else { + EM_DEBUG_LOG("success :[%s]", address); + ret = true; + } + + regfree(&alias_list_regex); + + if (err_code) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} + +INTERNAL_FUNC int em_verify_email_address_of_mail_data(email_mail_data_t *mail_data, int without_bracket, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("mail_data[%p] without_bracket[%d]", mail_data, without_bracket); + char *address_array[4] = { mail_data->full_address_from, mail_data->full_address_to, mail_data->full_address_cc, mail_data->full_address_bcc}; + int ret = false, err = EMAIL_ERROR_NONE, i; + + /* check for email_address validation */ + for (i = 0; i < 4; i++) { + if (address_array[i] && address_array[i][0] != 0) { + if (!em_verify_email_address(address_array[i] , without_bracket, &err)) { + err = EMAIL_ERROR_INVALID_ADDRESS; + EM_DEBUG_EXCEPTION("Invalid Email Address [%d][%s]", i, address_array[i]); + goto FINISH_OFF; + } + } + } + ret = true; +FINISH_OFF: + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} + +INTERNAL_FUNC int em_verify_email_address_of_mail_tbl(emstorage_mail_tbl_t *input_mail_tbl, int input_without_bracket) +{ + EM_DEBUG_FUNC_BEGIN("input_mail_tbl[%p] input_without_bracket[%d]", input_mail_tbl, input_without_bracket); + char *address_array[4] = { input_mail_tbl->full_address_to, input_mail_tbl->full_address_cc, input_mail_tbl->full_address_bcc, input_mail_tbl->full_address_from}; + int err = EMAIL_ERROR_NONE, i; + + /* check for email_address validation */ + for (i = 0; i < 4; i++) { + if (address_array[i] && address_array[i][0] != 0) { + if (!em_verify_email_address(address_array[i] , input_without_bracket, &err)) { + err = EMAIL_ERROR_INVALID_ADDRESS; + EM_DEBUG_EXCEPTION("Invalid Email Address [%d][%s]", i, address_array[i]); + goto FINISH_OFF; + } + } + } + +FINISH_OFF: + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +INTERNAL_FUNC int em_find_tag_for_thread_view(char *subject, int *result) +{ + EM_DEBUG_FUNC_BEGIN(); + int error_code = EMAIL_ERROR_NONE; + char *copy_of_subject = NULL; + + EM_IF_NULL_RETURN_VALUE(subject, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(result, EMAIL_ERROR_INVALID_PARAM); + + *result = FALSE; + + copy_of_subject = EM_SAFE_STRDUP(subject); + + if (copy_of_subject == NULL) { + EM_DEBUG_EXCEPTION("strdup is failed."); + goto FINISH_OFF; + } + + em_upper_string(copy_of_subject); + EM_DEBUG_LOG("em_upper_string result : %s\n", copy_of_subject); + + if (strstr(copy_of_subject, "RE:") == NULL) { + if (strstr(copy_of_subject, "FWD:") == NULL) { + if (strstr(copy_of_subject, "FW:") != NULL) + *result = TRUE; + } + else + *result = TRUE; + } + else + *result = TRUE; + +FINISH_OFF: + EM_SAFE_FREE(copy_of_subject); + + EM_DEBUG_FUNC_END("result : %d", *result); + + return error_code; +} + +INTERNAL_FUNC int em_find_pos_stripped_subject_for_thread_view(char *subject, char *stripped_subject) +{ + EM_DEBUG_FUNC_BEGIN(); + int error_code = EMAIL_ERROR_NONE; + int gap; + char *copy_of_subject = NULL, *curpos = NULL, *result; + + EM_IF_NULL_RETURN_VALUE(subject, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(stripped_subject, EMAIL_ERROR_INVALID_PARAM); + + copy_of_subject = EM_SAFE_STRDUP(subject); + + if (copy_of_subject == NULL) { + EM_DEBUG_EXCEPTION("strdup is failed"); + goto FINISH_OFF; + } + + em_upper_string(copy_of_subject); + curpos = copy_of_subject; + + EM_DEBUG_LOG("em_upper_string result : %s", copy_of_subject); + + while ((result = strstr(curpos, "RE:")) != NULL) { + curpos = result + 3; + EM_DEBUG_LOG("RE result : %s", curpos); + } + + while ((result = strstr(curpos, "FWD:")) != NULL) { + curpos = result + 4; + EM_DEBUG_LOG("FWD result : %s", curpos); + } + + while ((result = strstr(curpos, "FW:")) != NULL) { + curpos = result + 3; + EM_DEBUG_LOG("FW result : %s", curpos); + } + + while (curpos != NULL && *curpos == ' ') { + curpos++; + } + + gap = curpos - copy_of_subject; + + strcpy(stripped_subject, subject + gap); + +FINISH_OFF: + EM_SAFE_FREE(copy_of_subject); + + if (error_code == EMAIL_ERROR_NONE && stripped_subject) + EM_DEBUG_LOG("result[%s]", stripped_subject); + + EM_DEBUG_FUNC_END("error_code[%d]", error_code); + return error_code; +} + + +/* + * encoding base64 + */ +INTERNAL_FUNC int em_encode_base64(char *src, unsigned long src_len, char **enc, unsigned long* enc_len, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN(); + + unsigned char *content; + int ret = true, err = EMAIL_ERROR_NONE; + + if (err_code != NULL) { + *err_code = EMAIL_ERROR_NONE; + } + + content = rfc822_binary(src, src_len, enc_len); + + if (content) + *enc = (char *)content; + else { + err = EMAIL_ERROR_UNKNOWN; + ret = false; + } + + if (err_code) + *err_code = err; + + EM_DEBUG_FUNC_END(); + return ret; +} + +/* + * decoding base64 + */ +INTERNAL_FUNC int em_decode_base64(unsigned char *enc_text, unsigned long enc_len, char **dec_text, unsigned long* dec_len, int *err_code) +{ + unsigned char *text = enc_text; + unsigned long size = enc_len; + unsigned char *content; + int ret = true, err = EMAIL_ERROR_NONE; + + if (err_code != NULL) { + *err_code = EMAIL_ERROR_NONE; + } + + EM_DEBUG_FUNC_BEGIN(); + + content = rfc822_base64(text, size, dec_len); + if (content) + *dec_text = (char *)content; + else + { + err = EMAIL_ERROR_UNKNOWN; + ret = false; + } + + if (err_code) + *err_code = err; + + 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) +{ + EM_DEBUG_FUNC_BEGIN(); + emstorage_account_tbl_t *account_tbl_data = NULL; + int ret = false; + int err= EMAIL_ERROR_NONE; + + if (account_server_type == NULL ) { + EM_DEBUG_EXCEPTION("account_server_type is NULL"); + err = EMAIL_ERROR_INVALID_PARAM; + ret = false; + goto FINISH_OFF; + } + + if( !emstorage_get_account_by_id(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; + } + + if ( flag == false ) { /* sending server */ + *account_server_type = account_tbl_data->outgoing_server_type; + } else if ( flag == true ) { /* receiving server */ + *account_server_type = account_tbl_data->incoming_server_type; + } + + ret = true; + +FINISH_OFF: + if ( account_tbl_data != NULL ) { + emstorage_free_account(&account_tbl_data, 1, NULL); + } + if ( error != NULL ) { + *error = err; + } + + return ret; +} + +#include +#include + +#define ACTIVE_SYNC_HANDLE_INIT_VALUE (-1) +#define ACTIVE_SYNC_HANDLE_BOUNDARY (-100000000) + + +INTERNAL_FUNC int em_get_handle_for_activesync(int *handle, int *error) +{ + EM_DEBUG_FUNC_BEGIN(); + + static int next_handle = 0; + int ret = false; + int err = EMAIL_ERROR_NONE; + + if ( handle == NULL ) { + EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed : handle is NULL"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + if ( vconf_get_int(VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE, &next_handle) != 0 ) { + EM_DEBUG_EXCEPTION("vconf_get_int failed"); + if ( next_handle != 0 ) { + err = EMAIL_ERROR_GCONF_FAILURE; + goto FINISH_OFF; + } + } + + EM_DEBUG_LOG(">>>>>> VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE : get lastest handle[%d]", next_handle); + + /* set the value of the handle for active sync */ + next_handle--; + if ( next_handle < ACTIVE_SYNC_HANDLE_BOUNDARY ) { + next_handle = ACTIVE_SYNC_HANDLE_INIT_VALUE; + } + if ( vconf_set_int(VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE, next_handle) != 0) { + EM_DEBUG_EXCEPTION("vconf_set_int failed"); + err = EMAIL_ERROR_GCONF_FAILURE; + goto FINISH_OFF; + } + ret = true; + *handle = next_handle; + EM_DEBUG_LOG(">>>>>> return next handle[%d]", *handle); + +FINISH_OFF: + if ( error != NULL ) { + *error = err; + } + + 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); + + DBusConnection *connection; + DBusMessage *signal = NULL; + DBusError error; + const char *nullString = ""; + int i = 0; + + dbus_error_init (&error); + connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error); + + if(connection == NULL) + goto FINISH_OFF; + + signal = dbus_message_new_signal("/User/Email/ActiveSync", EMAIL_ACTIVE_SYNC_NOTI, "email"); + + dbus_message_append_args(signal, DBUS_TYPE_INT32, &subType, DBUS_TYPE_INVALID); + switch ( subType ) { + case ACTIVE_SYNC_NOTI_SEND_MAIL: + EM_DEBUG_LOG("handle:[%d]", data->send_mail.handle); + EM_DEBUG_LOG("account_id:[%d]", data->send_mail.account_id); + EM_DEBUG_LOG("mail_id:[%d]", data->send_mail.mail_id); + EM_DEBUG_LOG("options.priority:[%d]", data->send_mail.options.priority); + EM_DEBUG_LOG("options.keep_local_copy:[%d]", data->send_mail.options.keep_local_copy); + EM_DEBUG_LOG("options.req_delivery_receipt:[%d]", data->send_mail.options.req_delivery_receipt); + EM_DEBUG_LOG("options.req_read_receipt:[%d]", data->send_mail.options.req_read_receipt); + /* download_limit, block_address, block_subject might not be needed */ + EM_DEBUG_LOG("options.download_limit:[%d]", data->send_mail.options.download_limit); + EM_DEBUG_LOG("options.block_address:[%d]", data->send_mail.options.block_address); + EM_DEBUG_LOG("options.block_subject:[%d]", data->send_mail.options.block_subject); + EM_DEBUG_LOG("options.display_name_from:[%s]", data->send_mail.options.display_name_from); + EM_DEBUG_LOG("options.reply_with_body:[%d]", data->send_mail.options.reply_with_body); + EM_DEBUG_LOG("options.forward_with_files:[%d]", data->send_mail.options.forward_with_files); + EM_DEBUG_LOG("options.add_myname_card:[%d]", data->send_mail.options.add_myname_card); + EM_DEBUG_LOG("options.add_signature:[%d]", data->send_mail.options.add_signature); + EM_DEBUG_LOG("options.signature:[%s]", data->send_mail.options.signature); + + 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); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.priority), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.keep_local_copy), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.req_delivery_receipt), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.req_read_receipt), DBUS_TYPE_INVALID); + if ( data->send_mail.options.display_name_from == NULL ) + dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID); + else + dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.options.display_name_from), DBUS_TYPE_INVALID); + + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.reply_with_body), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.forward_with_files), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.add_myname_card), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.add_signature), DBUS_TYPE_INVALID); + if ( data->send_mail.options.signature == NULL ) + dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID); + else + dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.options.signature), 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); + break; + case ACTIVE_SYNC_NOTI_SEND_REPORT: + EM_DEBUG_EXCEPTION("Not support yet : subType[ACTIVE_SYNC_NOTI_SEND_REPORT]", subType); + break; + case ACTIVE_SYNC_NOTI_SYNC_HEADER: + EM_DEBUG_LOG("handle:[%d]", data->sync_header.handle); + EM_DEBUG_LOG("account_id:[%d]", data->sync_header.account_id); + EM_DEBUG_LOG("mailbox_id:[%d]", data->sync_header.mailbox_id); + + 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); + break; + case ACTIVE_SYNC_NOTI_DOWNLOAD_BODY: /* publish a download body notification to ASE */ + EM_DEBUG_LOG("handle:[%d]", data->download_body.handle); + EM_DEBUG_LOG("account_id:[%d]", data->download_body.account_id); + EM_DEBUG_LOG("mail_id:[%d]", data->download_body.mail_id); + EM_DEBUG_LOG("with_attachment:[%d]", data->download_body.with_attachment); + + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.handle ), DBUS_TYPE_INVALID); + 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); + break; + case ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT: + EM_DEBUG_LOG("handle:[%d]", data->download_attachment.handle); + EM_DEBUG_LOG("account_id:[%d]", data->download_attachment.account_id ); + EM_DEBUG_LOG("mail_id:[%d]", data->download_attachment.mail_id); + EM_DEBUG_LOG("with_attachment:[%d]", data->download_attachment.attachment_order ); + + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.handle ), DBUS_TYPE_INVALID); + 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); + 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); + EM_DEBUG_LOG("cancel_type:[%d]", data->cancel_job.cancel_type); + + 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); + 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 ); + EM_DEBUG_LOG("search_filter_count:[%d]", data->search_mail_on_server.search_filter_count ); + EM_DEBUG_LOG("handle to cancel:[%d]", data->search_mail_on_server.handle); + + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.account_id), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.mailbox_id), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_count), DBUS_TYPE_INVALID); + for(i = 0; i < data->search_mail_on_server.search_filter_count; i++) { + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_list[i].search_filter_type), DBUS_TYPE_INVALID); + switch(data->search_mail_on_server.search_filter_list[i].search_filter_type) { + case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO : + case EMAIL_SEARCH_FILTER_TYPE_UID : + 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_DELETED : + 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 : + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_list[i].search_filter_key_value.integer_type_key_value), DBUS_TYPE_INVALID); + break; + + case EMAIL_SEARCH_FILTER_TYPE_BCC : + case EMAIL_SEARCH_FILTER_TYPE_CC : + case EMAIL_SEARCH_FILTER_TYPE_FROM : + case EMAIL_SEARCH_FILTER_TYPE_KEYWORD : + case EMAIL_SEARCH_FILTER_TYPE_SUBJECT : + case EMAIL_SEARCH_FILTER_TYPE_TO : + case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID : + 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; + + case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE : + case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON : + case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE : + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value), DBUS_TYPE_INVALID); + break; + default : + EM_DEBUG_EXCEPTION("Invalid filter type [%d]", data->search_mail_on_server.search_filter_list[i].search_filter_type); + break; + } + } + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.handle), 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); + break; + + case ACTIVE_SYNC_NOTI_EXPUNGE_MAILS_DELETED_FLAGGED : + 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); + 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); + 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); + break; + + case ACTIVE_SYNC_NOTI_ADD_MAILBOX : + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->add_mailbox.account_id), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->add_mailbox.mailbox_path), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->add_mailbox.mailbox_alias), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->add_mailbox.handle), DBUS_TYPE_INVALID); + break; + + case ACTIVE_SYNC_NOTI_RENAME_MAILBOX : + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->rename_mailbox.account_id), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->rename_mailbox.mailbox_id), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->rename_mailbox.mailbox_name), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->rename_mailbox.mailbox_alias), DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->rename_mailbox.handle), 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); + break; + + default: + EM_DEBUG_EXCEPTION("Invalid Notification type of Active Sync : subType[%d]", subType); + return FAILURE; + } + + if(!dbus_connection_send (connection, signal, NULL)) { + EM_DEBUG_EXCEPTION("dbus_connection_send is failed"); + return FAILURE; + } else + EM_DEBUG_LOG("dbus_connection_send is successful"); + + dbus_connection_flush(connection); + +FINISH_OFF: + + if(signal) + dbus_message_unref(signal); + + EM_DEBUG_FUNC_END(); + return true; +} diff --git a/email-common-use/include/email-convert.h b/email-common-use/include/email-convert.h index 72bbd04..ba040f5 100755 --- a/email-common-use/include/email-convert.h +++ b/email-common-use/include/email-convert.h @@ -28,58 +28,65 @@ #include "email-storage.h" /* Account */ -INTERNAL_FUNC char* em_convert_account_to_byte_stream(emf_account_t* account, int* nStreamSize); -INTERNAL_FUNC void em_convert_byte_stream_to_account(char* pAccountStream, emf_account_t* account); -INTERNAL_FUNC int em_convert_account_to_account_tbl(emf_account_t *account, emstorage_account_tbl_t *account_tbl); -INTERNAL_FUNC int em_convert_account_tbl_to_account(emstorage_account_tbl_t *account_tbl, emf_account_t *account); +INTERNAL_FUNC char* em_convert_account_to_byte_stream(email_account_t* account, int* stream_len); +INTERNAL_FUNC void em_convert_byte_stream_to_account(char* stream, int stream_len, email_account_t* account); +INTERNAL_FUNC int em_convert_account_to_account_tbl(email_account_t *account, emstorage_account_tbl_t *account_tbl); +INTERNAL_FUNC int em_convert_account_tbl_to_account(emstorage_account_tbl_t *account_tbl, email_account_t *account); /* Mail */ -INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(emf_mail_data_t *input_mail_data, int intput_mail_data_count, int *output_stream_size); -INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *intput_stream, emf_mail_data_t **output_mail_data, int *output_mail_data_count); +INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_data, int *stream_size); +INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_len, email_mail_data_t *mail_data); -INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_table_data, int item_count, emf_mail_data_t **mail_data, int *error); -INTERNAL_FUNC int em_convert_mail_data_to_mail_tbl(emf_mail_data_t *mail_data, int item_count, emstorage_mail_tbl_t **mail_table_data, int *error); +INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_table_data, int item_count, email_mail_data_t **mail_data, int *error); +INTERNAL_FUNC int em_convert_mail_data_to_mail_tbl(email_mail_data_t *mail_data, int item_count, emstorage_mail_tbl_t **mail_table_data, int *error); /* Attachment */ -INTERNAL_FUNC char* em_convert_attachment_data_to_byte_stream(emf_attachment_data_t *input_attachment_data, int intput_attachment_count, int* output_stream_size); -INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *intput_stream, emf_attachment_data_t **output_attachment_data, int *output_attachment_count); - -INTERNAL_FUNC char* em_convert_attachment_info_to_byte_stream(emf_attachment_info_t* mail_atch, int* nStreamSize); -INTERNAL_FUNC void em_convert_byte_stream_to_attachment_info(char* pStream, int attachment_num, emf_attachment_info_t** mail_atch); +INTERNAL_FUNC char* em_convert_attachment_data_to_byte_stream(email_attachment_data_t *attachment_data, int attachment_count, int* stream_len); +INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *stream, int stream_len, email_attachment_data_t **attachment_data, int *attachment_count); /* Mailbox */ -INTERNAL_FUNC char* em_convert_mailbox_to_byte_stream(emf_mailbox_t* pMailbox, int* nStreamSize); -INTERNAL_FUNC void em_convert_byte_stream_to_mailbox(char* pStream, emf_mailbox_t* pMailbox); +INTERNAL_FUNC int em_convert_mailbox_to_mailbox_tbl(email_mailbox_t *mailbox, emstorage_mailbox_tbl_t *mailbox_tbl); +INTERNAL_FUNC int em_convert_mailbox_tbl_to_mailbox(emstorage_mailbox_tbl_t *mailbox_tbl, email_mailbox_t *mailbox); + + +INTERNAL_FUNC char* em_convert_mailbox_to_byte_stream(email_mailbox_t* mailbox, int* stream_len); +INTERNAL_FUNC void em_convert_byte_stream_to_mailbox(char* stream, int stream_len, email_mailbox_t* mailbox); /* Rule */ -INTERNAL_FUNC char* em_convert_rule_to_byte_stream(emf_rule_t* pRule, int* nStreamSize); -INTERNAL_FUNC void em_convert_byte_stream_to_rule(char* pStream, emf_rule_t* pMailbox); +INTERNAL_FUNC char* em_convert_rule_to_byte_stream(email_rule_t* rule, int* stream_len); +INTERNAL_FUNC void em_convert_byte_stream_to_rule(char *stream, int stream_len, email_rule_t *rule); /* Sending options */ -INTERNAL_FUNC char* em_convert_option_to_byte_stream(emf_option_t* pOption, int* nStreamSize); -INTERNAL_FUNC void em_convert_byte_stream_to_option(char* pStream, emf_option_t* pOption); +INTERNAL_FUNC char* em_convert_option_to_byte_stream(email_option_t* option, int* stream_len); +INTERNAL_FUNC void em_convert_byte_stream_to_option(char *stream, int stream_len, email_option_t *option); /* time_t */ INTERNAL_FUNC int em_convert_string_to_time_t(char *input_datetime_string, time_t *output_time); INTERNAL_FUNC int em_convert_time_t_to_string(time_t *input_time, char **output_datetime_string); -/* emf_extra_flag_t */ -INTERNAL_FUNC char* em_convert_extra_flags_to_byte_stream(emf_extra_flag_t new_flag, int* StreamSize); -INTERNAL_FUNC void em_convert_byte_stream_to_extra_flags(char* pStream, emf_extra_flag_t* new_flag); +/* email_extra_flag_t */ +INTERNAL_FUNC char* em_convert_extra_flags_to_byte_stream(email_extra_flag_t new_flag, int* StreamSize); +INTERNAL_FUNC void em_convert_byte_stream_to_extra_flags(char* pStream, email_extra_flag_t* new_flag); -/* emf_meeting_request_t */ -INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(emf_meeting_request_t* meeting_req, int* nStreamSize); -INTERNAL_FUNC void em_convert_byte_stream_to_meeting_req(char* pStream, emf_meeting_request_t* meeting_req); +/* email_meeting_request_t */ +INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(email_meeting_request_t* meeting_req, int* nStreamSize); +INTERNAL_FUNC void em_convert_byte_stream_to_meeting_req(char* stream, int stream_len, email_meeting_request_t* meeting_req); -INTERNAL_FUNC int em_convert_mail_flag_to_int(emf_mail_flag_t flag, int* i_flag, int* err_code); -INTERNAL_FUNC int em_convert_mail_int_to_flag(int i_flag, emf_mail_flag_t* flag, int* err_code); +INTERNAL_FUNC int em_convert_mail_flag_to_int(email_mail_flag_t flag, int* i_flag, int* err_code); +INTERNAL_FUNC int em_convert_mail_int_to_flag(int i_flag, email_mail_flag_t* flag, int* err_code); INTERNAL_FUNC int em_convert_mail_status_to_mail_tbl(int mail_status, emstorage_mail_tbl_t *result_mail_tbl_data, int* err_code); INTERNAL_FUNC int em_convert_mail_tbl_to_mail_status(emstorage_mail_tbl_t *mail_tbl_data, int *result_mail_status, int* err_code); -INTERNAL_FUNC int em_convert_mail_tbl_to_mail_flag(emstorage_mail_tbl_t *mail_tbl_data, emf_mail_flag_t *result_flag, int* err_code); -INTERNAL_FUNC int em_convert_mail_flag_to_mail_tbl(emf_mail_flag_t *flag, emstorage_mail_tbl_t *result_mail_tbl_data, int* err_code); +INTERNAL_FUNC int em_convert_mail_tbl_to_mail_flag(emstorage_mail_tbl_t *mail_tbl_data, email_mail_flag_t *result_flag, int* err_code); +INTERNAL_FUNC int em_convert_mail_flag_to_mail_tbl(email_mail_flag_t *flag, emstorage_mail_tbl_t *result_mail_tbl_data, int* err_code); /* Search filter options */ INTERNAL_FUNC char* em_convert_search_filter_to_byte_stream(email_search_filter_t *input_search_filter_list, int input_search_filter_count, int *output_stream_size); INTERNAL_FUNC void em_convert_byte_stream_to_search_filter(char *input_stream, email_search_filter_t **output_search_filter_list, int *output_search_filter_count); + +/* convert certificate */ +INTERNAL_FUNC int em_convert_certificate_tbl_to_certificate(emstorage_certificate_tbl_t *certificate_tbl, email_certificate_t **certificate, int *error); + +INTERNAL_FUNC int em_convert_certificate_to_certificate_tbl(email_certificate_t *certificate, emstorage_certificate_tbl_t *certificate_tbl); + #endif /* __EMAIL_CONVERT_H__ */ diff --git a/email-common-use/include/email-debug-log.h b/email-common-use/include/email-debug-log.h index 3344215..84dffbe 100755 --- a/email-common-use/include/email-debug-log.h +++ b/email-common-use/include/email-debug-log.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Kyuho Jo , Sunghyun Kwon -* +* * 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 @@ -41,11 +41,12 @@ extern "C" #include #include #include +#include #define __FEATURE_DEBUG_LOG__ #ifdef __FEATURE_DEBUG_LOG__ - + /* definition of LOG_TAG */ #ifdef LOG_TAG #undef LOG_TAG @@ -53,13 +54,17 @@ extern "C" #define LOG_TAG "email-service" -#define EM_DEBUG_LOG(format, arg...) SLOGD("[%s:%s():%d] " format "\n", (rindex(__FILE__, '/')? rindex(__FILE__,'/')+1 : __FILE__ ), __FUNCTION__, __LINE__, ##arg) -#define EM_DEBUG_EXCEPTION(format, arg...) SLOGE("[%s:%s():%d][EXCEPTION!!] " format "\n", (rindex(__FILE__, '/')? rindex(__FILE__,'/')+1 : __FILE__ ), __FUNCTION__, __LINE__, ##arg) +#define EM_DEBUG_LOG(format, arg...) \ + SLOGD("[%s() :%s:%d] " format "\n", __FUNCTION__, \ + (rindex(__FILE__, '/')? rindex(__FILE__,'/')+1 : __FILE__ ), __LINE__, ##arg) +#define EM_DEBUG_EXCEPTION(format, arg...) \ + SLOGE("[%s() :%s:%d][EXCEPTION!!] " format "\n", __FUNCTION__, \ + (rindex(__FILE__, '/')? rindex(__FILE__,'/')+1 : __FILE__ ), __LINE__, ##arg) #ifdef _DEBUG_MIME_PARSE_ #define EM_DEBUG_LOG_MIME(format, arg...) EM_DEBUG_LOG(format, ##arg) #else /* _DEBUG_MIME_PARSE */ -#define EM_DEBUG_LOG_MIME(format, arg...) +#define EM_DEBUG_LOG_MIME(format, arg...) #endif /* _DEBUG_MIME_PARSE */ #define EM_DEBUG_FUNC_BEGIN(format, arg...) EM_DEBUG_LOG("BEGIN - "format, ##arg) @@ -68,9 +73,23 @@ extern "C" #define EM_DEBUG_DB_EXEC(eval, expr, X) if (eval) { EM_DEBUG_LOG X; expr;} else {;} #define EM_DEBUG_ERROR_FILE_PATH "/opt/data/email/.emfdata/.critical_error.log" -#define EM_DEBUG_CRITICAL_EXCEPTION(format, arg...) { FILE *fp_error = NULL; fp_error = fopen(EM_DEBUG_ERROR_FILE_PATH, "a");\ - if(fp_error) {fprintf(fp_error, "[%s:%s():%d] " format "\n", (rindex(__FILE__, '/')? rindex(__FILE__,'/')+1 : __FILE__ ), __FUNCTION__, __LINE__, ##arg); \ - fclose(fp_error);}} +#define EM_DEBUG_CRITICAL_EXCEPTION(format, arg...) \ + {\ + FILE *fp_error = NULL;\ + fp_error = fopen(EM_DEBUG_ERROR_FILE_PATH, "a");\ + if(fp_error) {\ + fprintf(fp_error, "[%s() :%s:%d] " format "\n", \ + __FUNCTION__, (rindex(__FILE__, '/')? rindex(__FILE__,'/')+1 : __FILE__ ),\ + __LINE__, ##arg); \ + fclose(fp_error);\ + }\ + } +#define EM_DEBUG_PERROR(str) ({\ + char buf[128] = {0};\ + strerror_r(errno, buf, sizeof(buf));\ + EM_DEBUG_EXCEPTION("%s: %s(%d)", str, buf, errno);\ + }) + #ifdef _USE_PROFILE_DEBUG_ #define EM_PROFILE_BEGIN(pfid) \ unsigned int __prf_l1_##pfid = __LINE__;\ @@ -78,10 +97,10 @@ extern "C" struct timeval __prf_2_##pfid;\ do {\ gettimeofday(&__prf_1_##pfid, 0);\ - EM_DEBUG_LOG("**PROFILE BEGIN** [EMAILFW: %s: %s() %u ~ ] " #pfid \ + EM_DEBUG_LOG("**PROFILE BEGIN** [EMAILFW: %s() :%s %u ~ ] " #pfid \ " -> Start Time: %u.%06u seconds\n",\ + __FUNCTION__,\ rindex(__FILE__,'/')+1, \ - __FUNCTION__,\ __prf_l1_##pfid,\ (unsigned int)__prf_1_##pfid.tv_sec,\ (unsigned int)__prf_1_##pfid.tv_usec );\ @@ -94,10 +113,10 @@ extern "C" long __ds = __prf_2_##pfid.tv_sec - __prf_1_##pfid.tv_sec;\ long __dm = __prf_2_##pfid.tv_usec - __prf_1_##pfid.tv_usec;\ if ( __dm < 0 ) { __ds--; __dm = 1000000 + __dm; } \ - EM_DEBUG_LOG("**PROFILE END** [EMAILFW: %s: %s() %u ~ %u] " #pfid \ + EM_DEBUG_LOG("**PROFILE END** [EMAILFW: %s() :%s %u ~ %u] " #pfid \ " -> Elapsed Time: %u.%06u seconds\n",\ + __FUNCTION__,\ rindex(__FILE__, '/')+1,\ - __FUNCTION__,\ __prf_l1_##pfid,\ __prf_l2_##pfid,\ (unsigned int)(__ds),\ @@ -109,12 +128,12 @@ extern "C" #define EM_PROFILE_END(pfid) #endif - - + + #else /* __FEATURE_DEBUG_LOG__ */ - + #define EM_DEBUG_LINE - #define EM_DEBUG_LOG(format, arg...) + #define EM_DEBUG_LOG(format, arg...) #define EM_DEBUG_ASSERT(format, arg...) #define EM_DEBUG_EXCEPTION(format, arg...) @@ -211,7 +230,7 @@ extern "C" return ret;\ }\ } - + #define EM_STRERROR(err) ({ char buf[128]; strerror_r(err, buf, sizeof(buf));}) diff --git a/email-common-use/include/email-errors.h b/email-common-use/include/email-errors.h index 2a8a718..491c916 100755 --- a/email-common-use/include/email-errors.h +++ b/email-common-use/include/email-errors.h @@ -1,129 +1,131 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - -#ifndef __EMAIL_ERRORS_H__ -#define __EMAIL_ERRORS_H__ - -/*****************************************************************************/ -/* Errors */ -/*****************************************************************************/ - - -#define EMF_ERROR_NONE 1 /* There is no error */ -#define EMF_ERROR_INVALID_PARAM -1001 /* invalid parameter was given. - Invalid input parameter */ -#define EMF_ERROR_INVALID_ACCOUNT -1002 /* invalid account information was given. - Unsupported account */ -#define EMF_ERROR_INVALID_USER -1003 /* invalid user ID was given. - Invalid user or password */ -#define EMF_ERROR_INVALID_PASSWORD -1004 /* invalid password was given. - Invalid user or password */ -#define EMF_ERROR_INVALID_SERVER -1005 /* invalid server information was given. - Server unavailable */ -#define EMF_ERROR_INVALID_MAIL -1006 /* invalid mail information was given */ -#define EMF_ERROR_INVALID_ADDRESS -1007 /* invalid address information was given. - Incorrect address */ -#define EMF_ERROR_INVALID_ATTACHMENT -1008 /* invalid attachment information was given */ -#define EMF_ERROR_INVALID_MAILBOX -1009 /* invalid mailbox information was given */ -#define EMF_ERROR_INVALID_FILTER -1010 /* invalid filter information was given */ -#define EMF_ERROR_INVALID_PATH -1011 /* invalid flle path was given */ -#define EMF_ERROR_INVALID_DATA -1012 /* invalid data */ -#define EMF_ERROR_INVALID_RESPONSE -1013 /* unexpected network response was given. - Invalid server response */ -#define EMF_ERROR_ACCOUNT_NOT_FOUND -1014 /* no matched account was found */ -#define EMF_ERROR_MAIL_NOT_FOUND -1015 /* no matched mail was found */ -#define EMF_ERROR_MAILBOX_NOT_FOUND -1016 /* no matched mailbox was found */ -#define EMF_ERROR_ATTACHMENT_NOT_FOUND -1017 /* no matched attachment was found */ -#define EMF_ERROR_FILTER_NOT_FOUND -1018 /* no matched filter was found */ -#define EMF_ERROR_CONTACT_NOT_FOUND -1019 /* no matched contact was found */ -#define EMF_ERROR_FILE_NOT_FOUND -1020 /* no matched file was found */ -#define EMF_ERROR_DATA_NOT_FOUND -1021 /* no matched data was found */ -#define EMF_ERROR_NO_MORE_DATA -1022 /* No more data available */ -#define EMF_ERROR_ALREADY_EXISTS -1023 /* data duplicated */ -#define EMF_ERROR_MAX_EXCEEDED -1024 /* Can't handle more data */ -#define EMF_ERROR_DATA_TOO_LONG -1025 /* Data is too long */ -#define EMF_ERROR_DATA_TOO_SMALL -1026 /* Data is too small */ -#define EMF_ERROR_NETWORK_TOO_BUSY -1027 /* Network is busy */ -#define EMF_ERROR_OUT_OF_MEMORY -1028 /* There is not enough memory */ -#define EMF_ERROR_DB_FAILURE -1029 /* database operation failed */ -#define EMF_ERROR_PROFILE_FAILURE -1030 /* no proper profile was found */ -#define EMF_ERROR_SOCKET_FAILURE -1031 /* socket operation failed */ -#define EMF_ERROR_CONNECTION_FAILURE -1032 /* network connection failed */ -#define EMF_ERROR_CONNECTION_BROKEN -1033 /* network connection was broken */ -#define EMF_ERROR_DISCONNECTED -1034 /* connection was disconnected */ -#define EMF_ERROR_LOGIN_FAILURE -1035 /* login failed */ -#define EMF_ERROR_NO_RESPONSE -1036 /* There is no server response */ -#define EMF_ERROR_MAILBOX_FAILURE -1037 /* The agent failed to scan mailboxes in server */ -#define EMF_ERROR_AUTH_NOT_SUPPORTED -1038 /* The server doesn't support authentication */ -#define EMF_ERROR_AUTHENTICATE -1039 /* The server failed to authenticate user */ -#define EMF_ERROR_TLS_NOT_SUPPORTED -1040 /* The server doesn't support TLS */ -#define EMF_ERROR_TLS_SSL_FAILURE -1041 /* The agent failed TLS/SSL */ -#define EMF_ERROR_APPEND_FAILURE -1042 /* The agent failed to append mail to server */ -#define EMF_ERROR_COMMAND_NOT_SUPPORTED -1043 /* The server doesn't support this command */ -#define EMF_ERROR_ANNONYM_NOT_SUPPORTED -1044 /* The server doesn't support anonymous user */ -#define EMF_ERROR_CERTIFICATE_FAILURE -1045 /* certificate failure - Invalid server certificate */ -#define EMF_ERROR_CANCELLED -1046 /* The job was canceled by user */ -#define EMF_ERROR_NOT_IMPLEMENTED -1047 /* The function was not implemented */ -#define EMF_ERROR_NOT_SUPPORTED -1048 /* The function is not supported */ -#define EMF_ERROR_MAIL_LOCKED -1049 /* The mail was locked */ -#define EMF_ERROR_SYSTEM_FAILURE -1050 /* There is a system error */ -#define EMF_ERROR_MAIL_MAX_COUNT -1052 /* The mailbox is full */ -#define EMF_ERROR_ACCOUNT_MAX_COUNT -1053 /* There is too many account */ -#define EMF_ERROR_MAIL_MEMORY_FULL -1054 /* There is no more storage */ -#define EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER -1055 /* The expected mail is not found in server */ -#define EMF_ERROR_LOAD_ENGINE_FAILURE -1056 /* loading engine failed */ -#define EMF_ERROR_CLOSE_FAILURE -1057 /* engine is still used */ -#define EMF_ERROR_GCONF_FAILURE -1058 /* The error occurred on accessing Gconf */ -#define EMF_ERROR_NO_SUCH_HOST -1059 /* no such host was found */ -#define EMF_ERROR_EVENT_QUEUE_FULL -1060 /* event queue is full */ -#define EMF_ERROR_EVENT_QUEUE_EMPTY -1061 /* event queue is empty */ -#define EMF_ERROR_NO_RECIPIENT -1062 /* no recipients information was found */ -#define EMF_ERROR_SMTP_SEND_FAILURE -1063 /* SMTP send failed */ -#define EMF_ERROR_MAILBOX_OPEN_FAILURE -1064 /* accessing mailbox failed */ -#define EMF_ERROR_RETRIEVE_HEADER_DATA_FAILURE -1065 /* retrieving header failed */ -#define EMF_ERROR_XML_PARSER_FAILURE -1066 /* XML parsing failed */ -#define EMF_ERROR_SESSION_NOT_FOUND -1067 /* no matched session was found */ -#define EMF_ERROR_INVALID_STREAM -1068 -#define EMF_ERROR_AUTH_REQUIRED -1069 /* SMTP Authentication needed */ -#define EMF_ERROR_POP3_DELE_FAILURE -1100 -#define EMF_ERROR_POP3_UIDL_FAILURE -1101 -#define EMF_ERROR_POP3_LIST_FAILURE -1102 -#define EMF_ERROR_IMAP4_STORE_FAILURE -1200 -#define EMF_ERROR_IMAP4_EXPUNGE_FAILURE -1201 -#define EMF_ERROR_IMAP4_FETCH_UID_FAILURE -1202 -#define EMF_ERROR_IMAP4_FETCH_SIZE_FAILURE -1203 -#define EMF_ERROR_IMAP4_IDLE_FAILURE -1204 /* IDLE faile */ -#define EMF_ERROR_NO_SIM_INSERTED -1205 -#define EMF_ERROR_FLIGHT_MODE -1206 -#define EMF_ERROR_VALIDATE_ACCOUNT -1208 -#define EMF_ERROR_NO_MMC_INSERTED -1209 -#define EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE -1300 -#define EMF_ERROR_HANDLE_NOT_FOUND -1301 -#define EMF_ERROR_NULL_VALUE -1302 -#define EMF_ERROR_FAILED_BY_SECURITY_POLICY -1303 -#define EMF_ERROR_CANNOT_NEGOTIATE_TLS -1400 /* "Cannot negotiate TLS" */ -#define EMF_ERROR_STARTLS -1401 /* "STARTLS" */ -#define EMF_ERROR_IPC_CRASH -1500 -#define EMF_ERROR_IPC_CONNECTION_FAILURE -1501 -#define EMF_ERROR_IPC_SOCKET_FAILURE -1502 -#define EMF_ERROR_IPC_PROTOCOL_FAILURE -1503 -#define EMF_ERROR_LOGIN_ALLOWED_EVERY_15_MINS -1600 /* "login allowed only every 15 minutes" */ -#define EMF_ERROR_TOO_MANY_LOGIN_FAILURE -1601 /* "Too many login failure" */ -#define EMF_ERROR_ON_PARSING -1700 -#define EMF_ERROR_NETWORK_NOT_AVAILABLE -1800 /* WIFI not availble*/ -#define EMF_ERROR_CANNOT_STOP_THREAD -2000 -#define EMF_ERROR_UNKNOWN -8000 /* unknown error */ - -#endif /* __EMAIL_ERRORS_H__ */ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +#ifndef __EMAIL_ERRORS_H__ +#define __EMAIL_ERRORS_H__ + +/*****************************************************************************/ +/* Errors */ +/*****************************************************************************/ + + +#define EMAIL_ERROR_NONE 1 /* There is no error */ +#define EMAIL_ERROR_INVALID_PARAM -1001 /* invalid parameter was given. - Invalid input parameter */ +#define EMAIL_ERROR_INVALID_ACCOUNT -1002 /* invalid account information was given. - Unsupported account */ +#define EMAIL_ERROR_INVALID_USER -1003 /* invalid user ID was given. - Invalid user or password */ +#define EMAIL_ERROR_INVALID_PASSWORD -1004 /* invalid password was given. - Invalid user or password */ +#define EMAIL_ERROR_INVALID_SERVER -1005 /* invalid server information was given. - Server unavailable */ +#define EMAIL_ERROR_INVALID_MAIL -1006 /* invalid mail information was given */ +#define EMAIL_ERROR_INVALID_ADDRESS -1007 /* invalid address information was given. - Incorrect address */ +#define EMAIL_ERROR_INVALID_ATTACHMENT -1008 /* invalid attachment information was given */ +#define EMAIL_ERROR_INVALID_MAILBOX -1009 /* invalid mailbox information was given */ +#define EMAIL_ERROR_INVALID_FILTER -1010 /* invalid filter information was given */ +#define EMAIL_ERROR_INVALID_PATH -1011 /* invalid flle path was given */ +#define EMAIL_ERROR_INVALID_DATA -1012 /* invalid data */ +#define EMAIL_ERROR_INVALID_RESPONSE -1013 /* unexpected network response was given. - Invalid server response */ +#define EMAIL_ERROR_ACCOUNT_NOT_FOUND -1014 /* no matched account was found */ +#define EMAIL_ERROR_MAIL_NOT_FOUND -1015 /* no matched mail was found */ +#define EMAIL_ERROR_MAILBOX_NOT_FOUND -1016 /* no matched mailbox was found */ +#define EMAIL_ERROR_ATTACHMENT_NOT_FOUND -1017 /* no matched attachment was found */ +#define EMAIL_ERROR_FILTER_NOT_FOUND -1018 /* no matched filter was found */ +#define EMAIL_ERROR_CONTACT_NOT_FOUND -1019 /* no matched contact was found */ +#define EMAIL_ERROR_FILE_NOT_FOUND -1020 /* no matched file was found */ +#define EMAIL_ERROR_DATA_NOT_FOUND -1021 /* no matched data was found */ +#define EMAIL_ERROR_NO_MORE_DATA -1022 /* No more data available */ +#define EMAIL_ERROR_ALREADY_EXISTS -1023 /* data duplicated */ +#define EMAIL_ERROR_MAX_EXCEEDED -1024 /* Can't handle more data */ +#define EMAIL_ERROR_DATA_TOO_LONG -1025 /* Data is too long */ +#define EMAIL_ERROR_DATA_TOO_SMALL -1026 /* Data is too small */ +#define EMAIL_ERROR_NETWORK_TOO_BUSY -1027 /* Network is busy */ +#define EMAIL_ERROR_OUT_OF_MEMORY -1028 /* There is not enough memory */ +#define EMAIL_ERROR_DB_FAILURE -1029 /* database operation failed */ +#define EMAIL_ERROR_PROFILE_FAILURE -1030 /* no proper profile was found */ +#define EMAIL_ERROR_SOCKET_FAILURE -1031 /* socket operation failed */ +#define EMAIL_ERROR_CONNECTION_FAILURE -1032 /* network connection failed */ +#define EMAIL_ERROR_CONNECTION_BROKEN -1033 /* network connection was broken */ +#define EMAIL_ERROR_DISCONNECTED -1034 /* connection was disconnected */ +#define EMAIL_ERROR_LOGIN_FAILURE -1035 /* login failed */ +#define EMAIL_ERROR_NO_RESPONSE -1036 /* There is no server response */ +#define EMAIL_ERROR_MAILBOX_FAILURE -1037 /* The agent failed to scan mailboxes in server */ +#define EMAIL_ERROR_AUTH_NOT_SUPPORTED -1038 /* The server doesn't support authentication */ +#define EMAIL_ERROR_AUTHENTICATE -1039 /* The server failed to authenticate user */ +#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_APPEND_FAILURE -1042 /* The agent failed to append mail to server */ +#define EMAIL_ERROR_COMMAND_NOT_SUPPORTED -1043 /* The server doesn't support this command */ +#define EMAIL_ERROR_ANNONYM_NOT_SUPPORTED -1044 /* The server doesn't support anonymous user */ +#define EMAIL_ERROR_CERTIFICATE_FAILURE -1045 /* certificate failure - Invalid server certificate */ +#define EMAIL_ERROR_CANCELLED -1046 /* The job was canceled by user */ +#define EMAIL_ERROR_NOT_IMPLEMENTED -1047 /* The function was not implemented */ +#define EMAIL_ERROR_NOT_SUPPORTED -1048 /* The function is not supported */ +#define EMAIL_ERROR_MAIL_LOCKED -1049 /* The mail was locked */ +#define EMAIL_ERROR_SYSTEM_FAILURE -1050 /* There is a system error */ +#define EMAIL_ERROR_MAIL_MAX_COUNT -1052 /* The mailbox is full */ +#define EMAIL_ERROR_ACCOUNT_MAX_COUNT -1053 /* There is too many account */ +#define EMAIL_ERROR_MAIL_MEMORY_FULL -1054 /* There is no more storage */ +#define EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER -1055 /* The expected mail is not found in server */ +#define EMAIL_ERROR_LOAD_ENGINE_FAILURE -1056 /* loading engine failed */ +#define EMAIL_ERROR_CLOSE_FAILURE -1057 /* engine is still used */ +#define EMAIL_ERROR_GCONF_FAILURE -1058 /* The error occurred on accessing Gconf */ +#define EMAIL_ERROR_NO_SUCH_HOST -1059 /* no such host was found */ +#define EMAIL_ERROR_EVENT_QUEUE_FULL -1060 /* event queue is full */ +#define EMAIL_ERROR_EVENT_QUEUE_EMPTY -1061 /* event queue is empty */ +#define EMAIL_ERROR_NO_RECIPIENT -1062 /* no recipients information was found */ +#define EMAIL_ERROR_SMTP_SEND_FAILURE -1063 /* SMTP send failed */ +#define EMAIL_ERROR_MAILBOX_OPEN_FAILURE -1064 /* accessing mailbox failed */ +#define EMAIL_ERROR_RETRIEVE_HEADER_DATA_FAILURE -1065 /* retrieving header failed */ +#define EMAIL_ERROR_XML_PARSER_FAILURE -1066 /* XML parsing failed */ +#define EMAIL_ERROR_SESSION_NOT_FOUND -1067 /* no matched session was found */ +#define EMAIL_ERROR_INVALID_STREAM -1068 +#define EMAIL_ERROR_AUTH_REQUIRED -1069 /* SMTP Authentication needed */ +#define EMAIL_ERROR_POP3_DELE_FAILURE -1100 +#define EMAIL_ERROR_POP3_UIDL_FAILURE -1101 +#define EMAIL_ERROR_POP3_LIST_FAILURE -1102 +#define EMAIL_ERROR_IMAP4_STORE_FAILURE -1200 +#define EMAIL_ERROR_IMAP4_EXPUNGE_FAILURE -1201 +#define EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE -1202 +#define EMAIL_ERROR_IMAP4_FETCH_SIZE_FAILURE -1203 +#define EMAIL_ERROR_IMAP4_IDLE_FAILURE -1204 /* IDLE faile */ +#define EMAIL_ERROR_NO_SIM_INSERTED -1205 +#define EMAIL_ERROR_FLIGHT_MODE -1206 +#define EMAIL_ERROR_VALIDATE_ACCOUNT -1208 +#define EMAIL_ERROR_NO_MMC_INSERTED -1209 +#define EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE -1300 +#define EMAIL_ERROR_HANDLE_NOT_FOUND -1301 +#define EMAIL_ERROR_NULL_VALUE -1302 +#define EMAIL_ERROR_FAILED_BY_SECURITY_POLICY -1303 +#define EMAIL_ERROR_CANNOT_NEGOTIATE_TLS -1400 /* "Cannot negotiate TLS" */ +#define EMAIL_ERROR_STARTLS -1401 /* "STARTLS" */ +#define EMAIL_ERROR_IPC_CRASH -1500 +#define EMAIL_ERROR_IPC_CONNECTION_FAILURE -1501 +#define EMAIL_ERROR_IPC_SOCKET_FAILURE -1502 +#define EMAIL_ERROR_IPC_PROTOCOL_FAILURE -1503 +#define EMAIL_ERROR_IPC_ALREADY_INITIALIZED -1504 +#define EMAIL_ERROR_LOGIN_ALLOWED_EVERY_15_MINS -1600 /* "login allowed only every 15 minutes" */ +#define EMAIL_ERROR_TOO_MANY_LOGIN_FAILURE -1601 /* "Too many login failure" */ +#define EMAIL_ERROR_ON_PARSING -1700 +#define EMAIL_ERROR_NETWORK_NOT_AVAILABLE -1800 /* WIFI not availble*/ +#define EMAIL_ERROR_CANNOT_STOP_THREAD -2000 +#define EMAIL_ERROR_SECURED_STORAGE_FAILURE -2100 /* Error from secured storage */ +#define EMAIL_ERROR_UNKNOWN -8000 /* unknown error */ + +#endif /* __EMAIL_ERRORS_H__ */ diff --git a/email-common-use/include/email-internal-types.h b/email-common-use/include/email-internal-types.h index eb214fd..d0116c9 100755 --- a/email-common-use/include/email-internal-types.h +++ b/email-common-use/include/email-internal-types.h @@ -45,7 +45,6 @@ extern "C" /* ----------------------------------------------------------------------------- */ /* Feature definitions */ -#define __FEATURE_USING_MY_ACCOUNT__ #define __FEATURE_BACKUP_ACCOUNT__ #define __FEATURE_MOVE_TO_OUTBOX_FIRST__ /* #define __FEATURE_PARTIAL_BODY_FOR_POP3__ */ @@ -60,11 +59,9 @@ extern "C" #define __FEATURE_AUTO_POLLING__ #define __FEATURE_DEBUG_LOG__ #define __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__ +#define __FEATURE_XLIST_SUPPORT__ /* #define __FEATURE_USE_SHARED_MUTEX_FOR_PROTECTED_FUNC_CALL__ */ /* #define __FEATURE_IMAP_IDLE__ */ -#define __FEATURE_SUPPORT_ACTIVE_SYNC__ -#define __HEADER_OPTIMIZATION__ /* Will be removed */ -#define __DOWNLOAD_BODY_ATTACHMENT_OPTIMIZATION__ /* Will be removed */ /* ----------------------------------------------------------------------------- */ /* Macro */ @@ -80,8 +77,8 @@ extern "C" #define PARTIAL_BODY_SIZE_IN_BYTES 15360 /* Partial Body download - 15K */ #define NO_LIMITATION 0 #define MAX_MAILBOX_TYPE 100 -#define EMF_SYNC_ALL_MAILBOX 1 -#define EMF_ATTACHMENT_MAX_COUNT 512 +#define EMAIL_SYNC_ALL_MAILBOX 1 +#define EMAIL_ATTACHMENT_MAX_COUNT 512 #define DOWNLOAD_MAX_BUFFER_SIZE 8000 #define LOCAL_MAX_BUFFER_SIZE 1000000 #define IMAP_MAX_COMMAND_LENGTH 1000 @@ -105,19 +102,13 @@ extern "C" #define MAILHOME DATA_PATH"/email/.emfdata" #define DIRECTORY_PERMISSION 0755 -#define VCONF_KEY_LAST_SYNC_TIME "db/email/last_sync_time" -#define VCONF_KEY_DEFAULT_SLOT_SIZE "db/email/slot_size" -#define VCONF_KEY_LATEST_MAIL_ID "db/email/latest_mail_id" -#define VCONF_KEY_DEFAULT_ACCOUNT_ID "db/email/defaultaccount" -#define VCONF_KEY_UNREAD_MAIL_COUNT "db/badge/com.samsung.email" - #define MIME_SUBTYPE_DRM_OBJECT "vnd.oma.drm.message" #define MIME_SUBTYPE_DRM_RIGHTS "vnd.oma.drm.rights+xml" #define MIME_SUBTYPE_DRM_DCF "vnd.oma.drm.dcf" #define SHM_FILE_FOR_DB_LOCK "/.email_shm_db_lock" -#define NATIVE_EMAIL_APPLICATION_PKG "com.samsung.email" +#define NATIVE_EMAIL_APPLICATION_PKG "org.tizen.email" #ifdef __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__ #define SHM_FILE_FOR_MAIL_ID_LOCK "/.email_shm_mail_id_lock" @@ -133,10 +124,6 @@ extern "C" #define LF_STRING "\n" #define CRLF_STRING "\r\n" -#define SYNC_STATUS_FINISHED 0 /* BIN 00000000 */ -#define SYNC_STATUS_SYNCING 1 /* BIN 00000001 */ -#define SYNC_STATUS_HAVE_NEW_MAILS 2 /* BIN 00000010 */ - #define GRAB_TYPE_TEXT 1 /* retrieve text and attachment list */ #define GRAB_TYPE_ATTACHMENT 2 /* retrieve attachment */ @@ -144,7 +131,7 @@ extern "C" #define SAVE_TYPE_BUFFER 2 /* save content to buffer */ #define SAVE_TYPE_FILE 3 /* save content to temporary file */ -#define FINISH_OFF_IF_CANCELED if (!emcore_check_thread_status()) { err = EMF_ERROR_CANCELLED; goto FINISH_OFF; } +#define FINISH_OFF_IF_CANCELED if (!emcore_check_thread_status()) { err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } #define CHECK_JOB_CANCELED() {if (!emcore_check_thread_status()) goto JOB_CANCEL; } #define SNPRINTF(buff, size, format, args...) snprintf(buff, size, format, ##args) @@ -182,11 +169,16 @@ extern "C" #define DELETE_RECURSIVE_CRITICAL_SECTION(cs) {EM_DEBUG_LOG("DELETE_RECURSIVE_CRITICAL_SECTION "#cs); if(cs) pthread_mutex_destroy(cs);} typedef pthread_t thread_t; -#define SMTP_RESPONSE_OK 250 -#define SMTP_RESPONSE_READY 354 -#define SMTP_RESPONSE_WANT_AUTH 505 -#define SMTP_RESPONSE_WANT_AUTH2 530 -#define SMTP_RESPONSE_UNAVAIL 550 +#define SMTP_RESPONSE_OK 250 +#define SMTP_RESPONSE_READY 354 +#define SMTP_RESPONSE_WANT_AUTH 505 +#define SMTP_RESPONSE_WANT_AUTH2 530 +#define SMTP_RESPONSE_UNAVAIL 550 + +#define VCONF_KEY_DEFAULT_SLOT_SIZE "db/private/email-service/slot_size" +#define VCONF_KEY_LATEST_MAIL_ID "db/private/email-service/latest_mail_id" +#define VCONF_KEY_DEFAULT_ACCOUNT_ID "db/private/email-service/default_account_id" + /* ----------------------------------------------------------------------------- */ /* Type */ typedef enum @@ -197,23 +189,36 @@ typedef enum #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__ _SERVICE_THREAD_TYPE_PBD = 3, #endif /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ */ -} emf_service_thread_type; +} email_service_thread_type; typedef enum { - EMF_PROTOCOL_NONE = 0, - EMF_PROTOCOL_POP3 = 1, - EMF_PROTOCOL_IMAP = 2, - EMF_PROTOCOL_SMTP = 3, -} emf_protocol_type_t; + EMAIL_PROTOCOL_NONE = 0, + EMAIL_PROTOCOL_POP3 = 1, + EMAIL_PROTOCOL_IMAP = 2, + EMAIL_PROTOCOL_SMTP = 3, +} email_protocol_type_t; +typedef enum +{ + ACCOUNT_SVC_SYNC_STATUS_RUNNING = 0, + ACCOUNT_SVC_SYNC_STATUS_IDLE = 1, + ACCOUNT_SVC_SYNC_STATUS_OFF = 2, +} email_account_svc_sync_status; + +typedef enum { + SET_TYPE_SET = 1, + SET_TYPE_UNION = 2, + SET_TYPE_MINUS = 3, + SET_TYPE_INTERSECT = 4 /* Not supported */ +} email_set_type_t; #ifdef __FEATURE_KEEP_CONNECTION__ enum { - EMF_STREAM_STATUS_DISCONNECTED = 0, - EMF_STREAM_STATUS_CONNECTED = 1 + EMAIL_STREAM_STATUS_DISCONNECTED = 0, + EMAIL_STREAM_STATUS_CONNECTED = 1 } ; #endif /* __FEATURE_KEEP_CONNECTION__ */ @@ -221,57 +226,92 @@ enum typedef struct { int account_id; /* in general, account id */ - emf_event_type_t type; - emf_event_status_type_t status; - char *event_param_data_1; /* in general, mailbox name (exception in emcore_send_mail, emcore_send_saved_mail it is emf_option_t **/ + email_event_type_t type; + email_event_status_type_t status; + 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; int event_param_data_4; int event_param_data_5; int event_param_data_6; /* in general, notification parameter #1 */ int event_param_data_7; /* in general, notification parameter #2 */ -} emf_event_t; + int event_param_data_8; +} email_event_t; typedef struct { int num; void *data; -} emf_callback_holder_t; +} email_callback_holder_t; -typedef struct emf_search_key_t emf_search_key_t; -struct emf_search_key_t +typedef struct email_search_key_t email_search_key_t; +struct email_search_key_t { int type; char *value; - emf_search_key_t *next; + email_search_key_t *next; }; typedef struct { int tid; - emf_protocol_type_t protocol; + email_protocol_type_t protocol; void *stream; int auth; int network; int error; int status; -} emf_session_t; +} email_session_t; + +typedef struct +{ + int mailbox_id; /**< Unique id on mailbox table.*/ + char *mailbox_name; /**< Specifies the path of mailbox.*/ + email_mailbox_type_e mailbox_type; /**< Specifies the type of mailbox */ + char *alias; /**< Specifies the display name of mailbox.*/ + int unread_count; /**< Specifies the Unread Mail count in the mailbox.*/ + int total_mail_count_on_local; /**< Specifies the total number of mails in the mailbox in the local DB.*/ + int total_mail_count_on_server; /**< Specifies the total number of mails in the mailbox in the mail server.*/ + int local; /**< Specifies the local mailbox.*/ + int synchronous; /**< Specifies the mailbox with synchronized the server.*/ + int account_id; /**< Specifies the account ID for mailbox.*/ + int has_archived_mails; /**< Specifies the archived mails.*/ + int mail_slot_size; /**< Specifies how many mails can be stored in local mailbox.*/ + void *user_data; /**< Specifies the internal data.*/ + void *mail_stream; /**< Specifies the internal data.*/ +} email_internal_mailbox_t; #ifdef __FEATURE_KEEP_CONNECTION__ -typedef struct emf_connection_info +typedef struct email_connection_info { int account_id; int sending_server_stream_status; void *sending_server_stream; int receiving_server_stream_status; void *receiving_server_stream; - struct emf_connection_info *next; -} emf_connection_info_t; + struct email_connection_info *next; +} email_connection_info_t; #endif /* __FEATURE_KEEP_CONNECTION__ */ -typedef void (*emf_event_callback)(int total, int done, int status, int account_id, int mail_id, int handle, void *user_data, int error); +typedef struct +{ + char *contact_name; + char *email_address; + char *alias; + int storage_type; + int contact_id; +} email_mail_contact_info_t; + +/* global account lis */ +typedef struct email_account_list +{ + email_account_t *account; + struct email_account_list *next; +} email_account_list_t; + +typedef void (*email_event_callback)(int total, int done, int status, int account_id, int mail_id, int handle, void *user_data, int error); /* ----------------------------------------------------------------------------- */ /* Please contact Himanshu [h.gahlaut@samsung.com] for any explanation in code here under __FEATURE_PARTIAL_BODY_DOWNLOAD__ MACRO */ @@ -281,7 +321,7 @@ typedef enum ACTIVITY_PARTIAL_BODY_DOWNLOAD_IMAP4 = 1, ACTIVITY_PARTIAL_BODY_DOWNLOAD_POP3_WAIT, ACTIVITY_PARTIAL_BODY_DOWNLOAD_POP3_ACTIVE -} emf_pdb_activity_type_e; +} email_pdb_activity_type_e; typedef struct { @@ -289,11 +329,12 @@ typedef struct int mail_id; unsigned long server_mail_id; int activity_id; + int mailbox_id; char *mailbox_name; - emf_event_type_t event_type; /* Event Type Null means event is created from local activitys */ + 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 */ -} emf_event_partial_body_thd; +} email_event_partial_body_thd; #endif /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ */ #ifdef __cplusplus diff --git a/email-common-use/include/email-types.h b/email-common-use/include/email-types.h index bb02ab6..4a56377 100755 --- a/email-common-use/include/email-types.h +++ b/email-common-use/include/email-types.h @@ -1,1382 +1,1709 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - -#ifndef __EMAIL_TYPES_H__ -#define __EMAIL_TYPES_H__ - -/** -* @defgroup EMAIL_SERVICE Email Service -* @{ -*/ - -/** -* @ingroup EMAIL_SERVICE -* @defgroup EMAIL_TYPES Email Types -* @{ -*/ -/** - * This file defines structures and enums of Email Framework. - * @file email-types.h - * @author Kyu-ho Jo(kyuho.jo@samsung.com) - * @author Choongho Lee(ch715.lee@samsung.com) - * @version 0.1 - * @brief This file is the header file of Email Framework library. - */ - - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include -#include -#include "email-errors.h" - - -/*****************************************************************************/ -/* Macros */ -/*****************************************************************************/ - -#define MAILBOX_NAME_LENGTH 256 -#define MAX_EMAIL_ADDRESS_LENGTH 320 /* 64(user name) + 1(@) + 255(host name */ -#define MAX_DATETIME_STRING_LENGTH 20 -#define MAX_PREVIEW_TEXT_LENGTH 512 -#define STRING_LENGTH_FOR_DISPLAY 100 -#define MEETING_REQ_OBJECT_ID_LENGTH 256 - -#define ALL_ACCOUNT 0 -#define NEW_ACCOUNT_ID 0xFFFFFFFE -#define ALL_MAIL -1 - -#define EMF_SEARCH_FILTER_NONE 0x00 -#define EMF_SEARCH_FILTER_SUBJECT 0x01 -#define EMF_SEARCH_FILTER_SENDER 0x02 -#define EMF_SEARCH_FILTER_RECIPIENT 0x04 -#define EMF_SEARCH_FILTER_ALL 0x07 /* EMF_SEARCH_FILTER_SUBJECT + EMF_SEARCH_FILTER_SENDER + EMF_SEARCH_FILTER_RECIPIEN */ - -#define EMF_SUCCESS 0 /* we need to modify the success return valu */ - -#define EMF_ACC_GET_OPT_DEFAULT 0x01 /**< Default values without account name */ -#define EMF_ACC_GET_OPT_ACCOUNT_NAME 0x02 /**< Account name */ -#define EMF_ACC_GET_OPT_PASSWORD 0x04 /**< With password */ -#define EMF_ACC_GET_OPT_OPTIONS 0x08 /**< Account options : emf_option_t */ -#define EMF_ACC_GET_OPT_FULL_DATA 0xFF /**< With all data of account */ - -#define GET_FULL_DATA 0x00 -#define GET_FULL_DATA_WITHOUT_PASSWORD (EMF_ACC_GET_OPT_DEFAULT | EMF_ACC_GET_OPT_ACCOUNT_NAME | EMF_ACC_GET_OPT_OPTIONS ) -#define WITHOUT_OPTION (EMF_ACC_GET_OPT_DEFAULT | EMF_ACC_GET_OPT_ACCOUNT_NAME ) -#define ONLY_OPTION (EMF_ACC_GET_OPT_OPTIONS) - -#define THREAD_TYPE_RECEIVING 0 /**< for function 'email_activate_pdp' */ -#define THREAD_TYPE_SENDING 1 /**< for function 'email_activate_pdp' */ - -#define EMF_IMAP_PORT 143 /**< Specifies the default IMAP port.*/ -#define EMF_POP3_PORT 110 /**< Specifies the default POP3 port.*/ -#define EMF_SMTP_PORT 25 /**< Specifies the default SMTP port.*/ -#define EMF_IMAPS_PORT 993 /**< Specifies the default IMAP SSL port.*/ -#define EMF_POP3S_PORT 995 /**< Specifies the default POP3 SSL port.*/ -#define EMF_SMTPS_PORT 465 /**< Specifies the default SMTP SSL port.*/ -#define EMF_ACCOUNT_MAX 10 /**< Specifies the MAX account.*/ - -#define EMF_INBOX_NAME "INBOX" /**< Specifies the name of inbox.*/ -#define EMF_DRAFTBOX_NAME "DRAFTBOX" /**< Specifies the name of draftbox.*/ -#define EMF_OUTBOX_NAME "OUTBOX" /**< Specifies the name of outbox.*/ -#define EMF_SENTBOX_NAME "SENTBOX" /**< Specifies the name of sentbox.*/ -#define EMF_TRASH_NAME "TRASH" /**< Specifies the name of trash.*/ -#define EMF_SPAMBOX_NAME "SPAMBOX" /**< Specifies the name of spambox.*/ - -#define EMF_INBOX_DISPLAY_NAME "Inbox" /**< Specifies the display name of inbox.*/ -#define EMF_DRAFTBOX_DISPLAY_NAME "Draftbox" /**< Specifies the display name of draftbox.*/ -#define EMF_OUTBOX_DISPLAY_NAME "Outbox" /**< Specifies the display name of outbox.*/ -#define EMF_SENTBOX_DISPLAY_NAME "Sentbox" /**< Specifies the display name of sentbox.*/ -#define EMF_TRASH_DISPLAY_NAME "Trash" /**< Specifies the display name of sentbox.*/ -#define EMF_SPAMBOX_DISPLAY_NAME "Spambox" /**< Specifies the display name of spambox.*/ - -#define EMF_SEARCH_RESULT_MAILBOX_NAME "_`S1!E2@A3#R4$C5^H6&R7*E8(S9)U0-L=T_" /**< Specifies the name of search mailbox.*/ - -#define FAILURE -1 -#define SUCCESS 0 - -#define DAEMON_EXECUTABLE_PATH "/usr/bin/email-service" - -#ifndef EXPORT_API -#define EXPORT_API __attribute__((visibility("default"))) -#endif - -#ifndef DEPRECATED -#define DEPRECATED __attribute__((deprecated)) -#endif - - -/* __FEATURE_LOCAL_ACTIVITY__ supported -#define BULK_OPERATION_COUNT 50 -#define ALL_ACTIVITIES 0 -*/ - -/*****************************************************************************/ -/* Enumerations */ -/*****************************************************************************/ -enum { - // Account - _EMAIL_API_ADD_ACCOUNT = 0x01000000, - _EMAIL_API_DELETE_ACCOUNT = 0x01000001, - _EMAIL_API_UPDATE_ACCOUNT = 0x01000002, - _EMAIL_API_GET_ACCOUNT = 0x01000003, - _EMAIL_API_GET_ACCOUNT_LIST = 0x01000005, - _EMAIL_API_GET_MAILBOX_COUNT = 0x01000007, - _EMAIL_API_VALIDATE_ACCOUNT = 0x01000008, - _EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION = 0x01000009, - _EMAIL_API_BACKUP_ACCOUNTS = 0x0100000A, - _EMAIL_API_RESTORE_ACCOUNTS = 0x0100000B, - _EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT = 0x0100000C, - - // Message - _EMAIL_API_DELETE_MAIL = 0x01100002, - _EMAIL_API_DELETE_ALL_MAIL = 0x01100004, - _EMAIL_API_GET_MAILBOX_LIST = 0x01100006, - _EMAIL_API_GET_SUBMAILBOX_LIST = 0x01100007, - _EMAIL_API_CLEAR_DATA = 0x01100009, - _EMAIL_API_MOVE_MAIL = 0x0110000A, - _EMAIL_API_MOVE_ALL_MAIL = 0x0110000B, - _EMAIL_API_ADD_ATTACHMENT = 0x0110000C, - _EMAIL_API_GET_ATTACHMENT = 0x0110000D, - _EMAIL_API_DELETE_ATTACHMENT = 0x0110000E, - _EMAIL_API_MODIFY_MAIL_FLAG = 0x0110000F, - _EMAIL_API_MODIFY_MAIL_EXTRA_FLAG = 0x01100011, - _EMAIL_API_SET_FLAGS_FIELD = 0x01100016, - _EMAIL_API_ADD_MAIL = 0x01100017, - _EMAIL_API_UPDATE_MAIL = 0x01100018, - _EMAIL_API_ADD_READ_RECEIPT = 0x01100019, - - // Thread - _EMAIL_API_MOVE_THREAD_TO_MAILBOX = 0x01110000, - _EMAIL_API_DELETE_THREAD = 0x01110001, - _EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD = 0x01110002, - - // Mailbox - _EMAIL_API_ADD_MAILBOX = 0x01200000, - _EMAIL_API_DELETE_MAILBOX = 0x01200001, - _EMAIL_API_UPDATE_MAILBOX = 0x01200002, - _EMAIL_API_SET_MAIL_SLOT_SIZE = 0x01200007, - - // Network - _EMAIL_API_SEND_MAIL = 0x01300000, - _EMAIL_API_SYNC_HEADER = 0x01300001, - _EMAIL_API_DOWNLOAD_BODY = 0x01300002, - _EMAIL_API_DOWNLOAD_ATTACHMENT = 0x01300003, - _EMAIL_API_NETWORK_GET_STATUS = 0x01300004, - _EMAIL_API_SEND_SAVED = 0x01300005, - _EMAIL_API_DELETE_EMAIL = 0x01300007, - _EMAIL_API_DELETE_EMAIL_ALL = 0x01300008, - _EMAIL_API_GET_IMAP_MAILBOX_LIST = 0x01300015, - _EMAIL_API_SEND_MAIL_CANCEL_JOB = 0x01300017, - _EMAIL_API_SEARCH_MAIL_ON_SERVER = 0x01300019, - - // Rule - _EMAIL_API_ADD_RULE = 0x01400000, - _EMAIL_API_GET_RULE = 0x01400001, - _EMAIL_API_GET_RULE_LIST = 0x01400002, - _EMAIL_API_FIND_RULE = 0x01400003, - _EMAIL_API_DELETE_RULE = 0x01400004, - _EMAIL_API_UPDATE_RULE = 0x01400005, - _EMAIL_API_CANCEL_JOB = 0x01400006, - _EMAIL_API_GET_PENDING_JOB = 0x01400007, - _EMAIL_API_SEND_RETRY = 0x01400008, - _EMAIL_API_UPDATE_ACTIVITY = 0x01400009, - _EMAIL_API_SYNC_LOCAL_ACTIVITY = 0x0140000A, - _EMAIL_API_PRINT_RECEIVING_EVENT_QUEUE = 0x0140000B, - - // Etc - _EMAIL_API_PING_SERVICE = 0x01500000, - _EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL = 0x01500001, -}; - -enum -{ - EMF_DELETE_LOCALLY = 0, /**< Specifies Mail Delete local only */ - EMF_DELETE_LOCAL_AND_SERVER, /**< Specifies Mail Delete local & server */ - EMF_DELETE_FOR_SEND_THREAD, /**< Created to check which activity to delete in send thread */ -}; - -typedef enum -{ - NOTI_MAIL_ADD = 10000, - NOTI_MAIL_DELETE = 10001, - NOTI_MAIL_DELETE_ALL = 10002, - NOTI_MAIL_DELETE_WITH_ACCOUNT = 10003, - NOTI_MAIL_DELETE_FAIL = 10007, - NOTI_MAIL_DELETE_FINISH = 10008, - - NOTI_MAIL_UPDATE = 10004, - NOTI_MAIL_FIELD_UPDATE = 10020, - - NOTI_MAIL_MOVE = 10005, - NOTI_MAIL_MOVE_FAIL = 10010, - NOTI_MAIL_MOVE_FINISH = 10006, - - NOTI_THREAD_MOVE = 11000, - NOTI_THREAD_DELETE = 11001, - NOTI_THREAD_MODIFY_SEEN_FLAG = 11002, - - NOTI_ACCOUNT_ADD = 20000, - NOTI_ACCOUNT_DELETE = 20001, - NOTI_ACCOUNT_DELETE_FAIL = 20003, - NOTI_ACCOUNT_UPDATE = 20002, - NOTI_ACCOUNT_UPDATE_SYNC_STATUS = 20010, - - - NOTI_MAILBOX_ADD = 40000, - NOTI_MAILBOX_DELETE = 40001, - NOTI_MAILBOX_UPDATE = 40002, - /* To be added more */ -}emf_noti_on_storage_event; - -typedef enum -{ - NOTI_SEND_START = 1002, - NOTI_SEND_FINISH = 1004, - NOTI_SEND_FAIL = 1005, - NOTI_SEND_CANCEL = 1003, - - NOTI_DOWNLOAD_START = 2000, - NOTI_DOWNLOAD_FINISH, - NOTI_DOWNLOAD_FAIL, - NOTI_DOWNLOAD_CANCEL = 2004, - NOTI_DOWNLOAD_NEW_MAIL = 2003, - - NOTI_DOWNLOAD_BODY_START = 3000, - NOTI_DOWNLOAD_BODY_FINISH = 3002, - NOTI_DOWNLOAD_BODY_FAIL = 3004, - NOTI_DOWNLOAD_BODY_CANCEL = 3003, - NOTI_DOWNLOAD_MULTIPART_BODY = 3001, - - NOTI_DOWNLOAD_ATTACH_START = 4000, - NOTI_DOWNLOAD_ATTACH_FINISH, - NOTI_DOWNLOAD_ATTACH_FAIL, - NOTI_DOWNLOAD_ATTACH_CANCEL, - - NOTI_MAIL_DELETE_ON_SERVER_FAIL = 5000, - NOTI_MAIL_MOVE_ON_SERVER_FAIL, - - NOTI_VALIDATE_ACCOUNT_FINISH = 7000, - NOTI_VALIDATE_ACCOUNT_FAIL, - NOTI_VALIDATE_ACCOUNT_CANCEL, - - NOTI_VALIDATE_AND_CREATE_ACCOUNT_FINISH = 8000, - NOTI_VALIDATE_AND_CREATE_ACCOUNT_FAIL, - NOTI_VALIDATE_AND_CREATE_ACCOUNT_CANCEL, - - NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FINISH = 9000, - NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FAIL, - NOTI_VALIDATE_AND_UPDATE_ACCOUNT_CANCEL, - - /* To be added more */ -}emf_noti_on_network_event; - - -/** - * This enumeration specifies the mail type of account. - */ -typedef enum -{ - EMF_BIND_TYPE_DISABLE = 0, /**< Specifies the bind type for Disabled account.*/ - EMF_BIND_TYPE_EM_CORE = 1, /**< Specifies the bind type for Callia.*/ -} emf_account_bind_t; - -/** - * This enumeration specifies the server type of account. - */ -typedef enum -{ - EMF_SERVER_TYPE_POP3 = 1, /**< Specifies the POP3 Server.*/ - EMF_SERVER_TYPE_IMAP4, /**< Specifies the IMAP4 Server.*/ - EMF_SERVER_TYPE_SMTP, /**< Specifies the SMTP Server.*/ - EMF_SERVER_TYPE_NONE, /**< Specifies the Local.*/ - EMF_SERVER_TYPE_ACTIVE_SYNC, /** < Specifies the Active Sync. */ -} emf_account_server_t; - -/** - * This enumeration specifies the mode of retrieval. - */ -typedef enum -{ - EMF_IMAP4_RETRIEVAL_MODE_NEW = 0, /**< Specifies the retrieval mode for new email.*/ - EMF_IMAP4_RETRIEVAL_MODE_ALL, /**< Specifies the retrieval mode for all email.*/ -} emf_imap4_retrieval_mode_t; - -/** - * This enumeration specifies the filtering type. - */ -typedef enum -{ - EMF_FILTER_FROM = 1, /**< Specifies the filtering of sender.*/ - EMF_FILTER_SUBJECT, /**< Specifies the filtering of email subject.*/ - EMF_FILTER_BODY, /** < Specifies the filterinf of email body.*/ -} emf_rule_type_t; - - -/** - * This enumeration specifies the rules for filtering type. - */ -typedef enum -{ - RULE_TYPE_INCLUDES = 1, /**< Specifies the filtering rule for includes.*/ - RULE_TYPE_EXACTLY, /**< Specifies the filtering rule for Exactly same as.*/ -} emf_filtering_type_t; - - -/** - * This enumeration specifies the action for filtering type. - */ -typedef enum -{ - EMF_FILTER_MOVE = 1, /**< Specifies the move of email.*/ - EMF_FILTER_BLOCK = 2, /**< Specifies the block of email.*/ - EMF_FILTER_DELETE = 3, /**< Specifies delete email.*/ -} emf_rule_action_t; - -/** - * This enumeration specifies the email status. - */ -typedef enum -{ - EMF_MAIL_STATUS_NONE = 0, /**< The Mail is in No Operation state */ - EMF_MAIL_STATUS_RECEIVED, /**< The mail is a received mail.*/ - EMF_MAIL_STATUS_SENT, /**< The mail is a sent mail.*/ - EMF_MAIL_STATUS_SAVED, /**< The mail is a saved mail.*/ - EMF_MAIL_STATUS_SAVED_OFFLINE, /**< The mail is a saved mail in offline-mode.*/ - EMF_MAIL_STATUS_SENDING, /**< The mail is being sent.*/ - EMF_MAIL_STATUS_SEND_FAILURE, /**< The mail is a mail to been failed to send.*/ - EMF_MAIL_STATUS_SEND_CANCELED, /**< The mail is a cancelled mail.*/ - EMF_MAIL_STATUS_SEND_WAIT, /**< The mail is a mail to be send .*/ -} emf_mail_status_t; - -/** - * This enumeration specifies the email priority. - */ -typedef enum -{ - EMF_MAIL_PRIORITY_HIGH = 1, /**< The priority is high.*/ - EMF_MAIL_PRIORITY_NORMAL = 3, /**< The priority is normal.*/ - EMF_MAIL_PRIORITY_LOW = 5, /**< The priority is low.*/ -} emf_mail_priority_t; - -/** - * This enumeration specifies the email status. - */ -typedef enum -{ - EMF_MAIL_REPORT_NONE = 0, /**< The mail isn't report mail.*/ - EMF_MAIL_REPORT_DSN, /**< The mail is a delivery-status report mail.*/ - EMF_MAIL_REPORT_MDN, /**< The mail is a read-status report mail.*/ - EMF_MAIL_REPORT_REQUEST, /**< The mail require a read-status report mail.*/ -} emf_mail_report_t; - -/** - * This enumeration specifies the DRM type - */ -typedef enum -{ - EMF_ATTACHMENT_DRM_NONE = 0, /**< The mail isn't DRM file.*/ - EMF_ATTACHMENT_DRM_OBJECT, /**< The mail is a DRM object.*/ - EMF_ATTACHMENT_DRM_RIGHTS, /**< The mail is a DRM rights as xml format.*/ - EMF_ATTACHMENT_DRM_DCF, /**< The mail is a DRM dcf.*/ -} emf_attachment_drm_t; - -/** - * This enumeration specifies the meeting request type - */ -typedef enum -{ - EMF_MAIL_TYPE_NORMAL = 0, /**< NOT a meeting request mail. A Normal mail */ - EMF_MAIL_TYPE_MEETING_REQUEST = 1, /**< a meeting request mail from a serve */ - EMF_MAIL_TYPE_MEETING_RESPONSE = 2, /**< a response mail about meeting reques */ - EMF_MAIL_TYPE_MEETING_ORIGINATINGREQUEST = 3 /**< a originating mail about meeting reques */ -} emf_mail_type_t; - -/** - * This enumeration specifies the meeting response type - */ -typedef enum -{ - EMF_MEETING_RESPONSE_NONE = 0, /**< NOT response */ - EMF_MEETING_RESPONSE_ACCEPT = 1, /**< The response is acceptance */ - EMF_MEETING_RESPONSE_TENTATIVE = 2, /**< The response is tentative */ - EMF_MEETING_RESPONSE_DECLINE = 3, /**< The response is decline */ - EMF_MEETING_RESPONSE_REQUEST = 4, /**< The response is request */ - EMF_MEETING_RESPONSE_CANCEL = 5, /**< The response is cancelation */ -} emf_meeting_response_t; - -typedef enum -{ - EMF_ACTION_SEND_MAIL = 0, - EMF_ACTION_SYNC_HEADER = 1, - EMF_ACTION_DOWNLOAD_BODY = 2, - EMF_ACTION_DOWNLOAD_ATTACHMENT = 3, - EMF_ACTION_DELETE_MAIL = 4, - EMF_ACTION_SEARCH_MAIL = 5, - EMF_ACTION_SAVE_MAIL = 6, - EMF_ACTION_SYNC_MAIL_FLAG_TO_SERVER = 7, - EMF_ACTION_SYNC_FLAGS_FIELD_TO_SERVER = 8, - EMF_ACTION_MOVE_MAIL = 9, - EMF_ACTION_CREATE_MAILBOX = 10, - EMF_ACTION_DELETE_MAILBOX = 11, - EMF_ACTION_SYNC_HEADER_OMA = 12, - EMF_ACTION_VALIDATE_ACCOUNT = 13, - EMF_ACTION_VALIDATE_AND_CREATE_ACCOUNT = 14, - EMF_ACTION_VALIDATE_AND_UPDATE_ACCOUNT = 15, - EMF_ACTION_ACTIVATE_PDP = 20, - EMF_ACTION_DEACTIVATE_PDP = 21, - EMF_ACTION_UPDATE_MAIL = 30, - EMF_ACTION_SET_MAIL_SLOT_SIZE = 31, - EMF_ACTION_NUM, -} emf_action_t; - -/** - * This enumeration specifies the status of getting envelope list. - */ -typedef enum -{ - EMF_LIST_NONE = 0, - EMF_LIST_WAITING, - EMF_LIST_PREPARE, /**< Specifies the preparation.*/ - EMF_LIST_CONNECTION_START, /**< Specifies the connection start.*/ - EMF_LIST_CONNECTION_SUCCEED, /**< Specifies the success of connection.*/ - EMF_LIST_CONNECTION_FINISH, /**< Specifies the connection finish.*/ - EMF_LIST_CONNECTION_FAIL, /**< Specifies the connection failure.*/ - EMF_LIST_START, /**< Specifies the getting start.*/ - EMF_LIST_PROGRESS, /**< Specifies the status of getting.*/ - EMF_LIST_FINISH, /**< Specifies the getting complete.*/ - EMF_LIST_FAIL, /**< Specifies the download failure.*/ -} emf_envelope_list_status_t; - -/** - * This enumeration specifies the downloaded status of email. - */ -typedef enum -{ - EMF_DOWNLOAD_NONE = 0, - EMF_DOWNLOAD_WAITING, - EMF_DOWNLOAD_PREPARE, /**< Specifies the preparation.*/ - EMF_DOWNLOAD_CONNECTION_START, /**< Specifies the connection start.*/ - EMF_DOWNLOAD_CONNECTION_SUCCEED, /**< Specifies the success of connection.*/ - EMF_DOWNLOAD_CONNECTION_FINISH, /**< Specifies the connection finish.*/ - EMF_DOWNLOAD_CONNECTION_FAIL, /**< Specifies the connection failure.*/ - EMF_DOWNLOAD_START, /**< Specifies the download start.*/ - EMF_DOWNLOAD_PROGRESS, /**< Specifies the status of download.*/ - EMF_DOWNLOAD_FINISH, /**< Specifies the download complete.*/ - EMF_DOWNLOAD_FAIL, /**< Specifies the download failure.*/ -} emf_download_status_t; - -/** - * This enumeration specifies the status of sending email. - */ -typedef enum -{ - EMF_SEND_NONE = 0, - EMF_SEND_WAITING, - EMF_SEND_PREPARE, /**< Specifies the preparation.*/ - EMF_SEND_CONNECTION_START, /**< Specifies the connection start.*/ - EMF_SEND_CONNECTION_SUCCEED, /**< Specifies the success of connection.*/ - EMF_SEND_CONNECTION_FINISH, /**< Specifies the connection finish.*/ - EMF_SEND_CONNECTION_FAIL, /**< Specifies the connection failure.*/ - EMF_SEND_START, /**< Specifies the sending start.*/ - EMF_SEND_PROGRESS, /**< Specifies the status of sending.*/ - EMF_SEND_FINISH, /**< Specifies the sending complete.*/ - EMF_SEND_FAIL, /**< Specifies the sending failure.*/ - EMF_SAVE_WAITING, /**< Specfies the Waiting of Sync */ -} emf_send_status_t; - -typedef enum -{ - EMF_SYNC_NONE = 0, - EMF_SYNC_WAITING, - EMF_SYNC_PREPARE, - EMF_SYNC_CONNECTION_START, - EMF_SYNC_CONNECTION_SUCCEED, - EMF_SYNC_CONNECTION_FINISH, - EMF_SYNC_CONNECTION_FAIL, - EMF_SYNC_START, - EMF_SYNC_PROGRESS, - EMF_SYNC_FINISH, - EMF_SYNC_FAIL, -} emf_sync_status_t; - -/** -* This enumeration specifies the deleting status of email. -*/ -typedef enum -{ - EMF_DELETE_NONE = 0, - EMF_DELETE_WAITING, - EMF_DELETE_PREPARE, /**< Specifies the preparation.*/ - EMF_DELETE_CONNECTION_START, /**< Specifies the connection start.*/ - EMF_DELETE_CONNECTION_SUCCEED, /**< Specifies the success of connection.*/ - EMF_DELETE_CONNECTION_FINISH, /**< Specifies the connection finish.*/ - EMF_DELETE_CONNECTION_FAIL, /**< Specifies the connection failure.*/ - EMF_DELETE_START, /**< Specifies the deletion start.*/ - EMF_DELETE_PROGRESS, /**< Specifies the status of deleting.*/ - EMF_DELETE_SERVER_PROGRESS, /**< Specifies the status of server deleting.*/ - EMF_DELETE_LOCAL_PROGRESS, /**< Specifies the status of local deleting.*/ - EMF_DELETE_FINISH, /**< Specifies the deletion complete.*/ - EMF_DELETE_FAIL, /**< Specifies the deletion failure.*/ -} emf_delete_status_t; - -/** -* This enumeration specifies the status of validating account -*/ -typedef enum -{ - EMF_VALIDATE_ACCOUNT_NONE = 0, - EMF_VALIDATE_ACCOUNT_WAITING, - EMF_VALIDATE_ACCOUNT_PREPARE, /**< Specifies the preparation.*/ - EMF_VALIDATE_ACCOUNT_CONNECTION_START, /**< Specifies the connection start.*/ - EMF_VALIDATE_ACCOUNT_CONNECTION_SUCCEED, /**< Specifies the success of connection.*/ - EMF_VALIDATE_ACCOUNT_CONNECTION_FINISH, /**< Specifies the connection finish.*/ - EMF_VALIDATE_ACCOUNT_CONNECTION_FAIL, /**< Specifies the connection failure.*/ - EMF_VALIDATE_ACCOUNT_START, /**< Specifies the getting start.*/ - EMF_VALIDATE_ACCOUNT_PROGRESS, /**< Specifies the status of getting.*/ - EMF_VALIDATE_ACCOUNT_FINISH, /**< Specifies the getting complete.*/ - EMF_VALIDATE_ACCOUNT_FAIL, /**< Specifies the validation failure.*/ -} emf_validate_account_status_t; - -typedef enum -{ - EMF_SET_SLOT_SIZE_NONE = 0, - EMF_SET_SLOT_SIZE_WAITING, - EMF_SET_SLOT_SIZE_START, - EMF_SET_SLOT_SIZE_FINISH, - EMF_SET_SLOT_SIZE_FAIL, -}emf_set_slot_size_status_e; - -/** -* This enumeration specifies the type of mailbox -*/ -typedef enum -{ - EMF_MAILBOX_TYPE_NONE = 0, /**< Unspecified mailbox type*/ - EMF_MAILBOX_TYPE_INBOX = 1, /**< Specified inbox type*/ - EMF_MAILBOX_TYPE_SENTBOX = 2, /**< Specified sent box type*/ - EMF_MAILBOX_TYPE_TRASH = 3, /**< Specified trash type*/ - EMF_MAILBOX_TYPE_DRAFT = 4, /**< Specified draft box type*/ - EMF_MAILBOX_TYPE_SPAMBOX = 5, /**< Specified spam box type*/ - EMF_MAILBOX_TYPE_OUTBOX = 6, /**< Specified outbox type*/ - EMF_MAILBOX_TYPE_ALL_EMAILS = 7, /**< Specified all emails type of gmail*/ - EMF_MAILBOX_TYPE_SEARCH_RESULT = 8, /**< Specified mailbox type for result of search on server */ - EMF_MAILBOX_TYPE_USER_DEFINED = 0xFF, /**< Specified mailbox type for all other mailboxes */ -}emf_mailbox_type_e; - -typedef enum -{ - EMF_SYNC_LATEST_MAILS_FIRST = 0, - EMF_SYNC_OLDEST_MAILS_FIRST, - EMF_SYNC_ALL_MAILBOX_50_MAILS, -} EMF_RETRIEVE_MODE; - -/* event typ */ -typedef enum -{ - EMF_EVENT_NONE = 0, - EMF_EVENT_SYNC_HEADER = 1, /* synchronize mail headers with server (network used) */ - EMF_EVENT_DOWNLOAD_BODY = 2, /* download mail body from server (network used)*/ - EMF_EVENT_DOWNLOAD_ATTACHMENT = 3, /* download mail attachment from server (network used) */ - EMF_EVENT_SEND_MAIL = 4, /* send a mail (network used) */ - EMF_EVENT_SEND_MAIL_SAVED = 5, /* send all mails in 'outbox' box (network used) */ - EMF_EVENT_SYNC_IMAP_MAILBOX = 6, /* download imap mailboxes from server (network used) */ - EMF_EVENT_DELETE_MAIL = 7, /* delete mails (network unused) */ - EMF_EVENT_DELETE_MAIL_ALL = 8, /* delete all mails (network unused) */ - EMF_EVENT_SYNC_MAIL_FLAG_TO_SERVER = 9, /* sync mail flag to server */ - EMF_EVENT_SYNC_FLAGS_FIELD_TO_SERVER = 10, /* sync a field of flags to server */ - EMF_EVENT_SAVE_MAIL = 11, - EMF_EVENT_MOVE_MAIL = 12, /* move mails to specific mailbox on server */ - EMF_EVENT_CREATE_MAILBOX = 13, - EMF_EVENT_UPDATE_MAILBOX = 14, - EMF_EVENT_DELETE_MAILBOX = 15, - EMF_EVENT_ISSUE_IDLE = 16, - EMF_EVENT_SYNC_HEADER_OMA = 17, - EMF_EVENT_VALIDATE_ACCOUNT = 18, - EMF_EVENT_VALIDATE_AND_CREATE_ACCOUNT = 19, - EMF_EVENT_VALIDATE_AND_UPDATE_ACCOUNT = 20, - - EMF_EVENT_ADD_MAIL = 10001, - EMF_EVENT_UPDATE_MAIL_OLD = 10002, - EMF_EVENT_UPDATE_MAIL = 10003, - EMF_EVENT_SET_MAIL_SLOT_SIZE = 20000, - -/* EMF_EVENT_LOCAL_ACTIVITY, // __LOCAL_ACTIVITY_ */ - - EMF_EVENT_BULK_PARTIAL_BODY_DOWNLOAD, /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ supported */ - EMF_EVENT_LOCAL_ACTIVITY_SYNC_BULK_PBD, /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ supported */ - EMF_EVENT_GET_PASSWORD_LENGTH /* get password length of an account */ -} emf_event_type_t; - -/* event statu */ -typedef enum -{ - EMF_EVENT_STATUS_UNUSED = 0, - EMF_EVENT_STATUS_WAIT, - EMF_EVENT_STATUS_STARTED, - EMF_EVENT_STATUS_CANCELED, -} emf_event_status_type_t; - - -/* sorting_orde */ -typedef enum -{ - EMF_SORT_DATETIME_HIGH = 0, - EMF_SORT_DATETIME_LOW, - EMF_SORT_SENDER_HIGH, - EMF_SORT_SENDER_LOW, - EMF_SORT_RCPT_HIGH, - EMF_SORT_RCPT_LOW, - EMF_SORT_SUBJECT_HIGH, - EMF_SORT_SUBJECT_LOW, - EMF_SORT_PRIORITY_HIGH, - EMF_SORT_PRIORITY_LOW, - EMF_SORT_ATTACHMENT_HIGH, - EMF_SORT_ATTACHMENT_LOW, - EMF_SORT_FAVORITE_HIGH, - EMF_SORT_FAVORITE_LOW, - EMF_SORT_MAILBOX_NAME_HIGH, - EMF_SORT_MAILBOX_NAME_LOW, - EMF_SORT_FLAGGED_FLAG_HIGH, - EMF_SORT_FLAGGED_FLAG_LOW, - EMF_SORT_SEEN_FLAG_HIGH, - EMF_SORT_SEEN_FLAG_LOW, - EMF_SORT_END, -}emf_sort_type_t; - -typedef enum -{ - EMAIL_MAILBOX_SORT_BY_NAME_ASC = 0, - EMAIL_MAILBOX_SORT_BY_NAME_DSC, - EMAIL_MAILBOX_SORT_BY_TYPE_ASC, - EMAIL_MAILBOX_SORT_BY_TYPE_DSC, -} email_mailbox_sort_type_t; - - -/** -* This enumeration specifies the priority. -*/ -enum -{ - EMF_OPTION_PRIORITY_HIGH = 1, /**< Specifies the high priority.*/ - EMF_OPTION_PRIORITY_NORMAL = 3, /**< Specifies the normal priority*/ - EMF_OPTION_PRIORITY_LOW = 5, /**< Specifies the low priority.*/ -}; - -/** -* This enumeration specifies the saving save a copy after sending. -*/ -enum -{ - EMF_OPTION_KEEP_LOCAL_COPY_OFF = 0, /**< Specifies off the keeping local copy.*/ - EMF_OPTION_KEEP_LOCAL_COPY_ON = 1, /**< Specifies on the keeping local copy.*/ -}; - -/** -* This enumeration specifies the request of delivery report. -*/ -enum -{ - EMF_OPTION_REQ_DELIVERY_RECEIPT_OFF = 0, /**< Specifies off the requesting delivery receipt.*/ - EMF_OPTION_REQ_DELIVERY_RECEIPT_ON = 1, /**< Specifies on the requesting delivery receipt.*/ -}; - -/** -* This enumeration specifies the request of read receipt. -*/ -enum -{ - EMF_OPTION_REQ_READ_RECEIPT_OFF = 0, /**< Specifies off the requesting read receipt.*/ - EMF_OPTION_REQ_READ_RECEIPT_ON = 1, /**< Specifies on the requesting read receipt.*/ -}; - -/** -* This enumeration specifies the blocking of address. -*/ -enum -{ - EMF_OPTION_BLOCK_ADDRESS_OFF = 0, /**< Specifies off the blocking by address.*/ - EMF_OPTION_BLOCK_ADDRESS_ON = 1, /**< Specifies on the blocking by address.*/ -}; - -/** -* This enumeration specifies the blocking of subject. -*/ -enum -{ - EMF_OPTION_BLOCK_SUBJECT_OFF = 0, /**< Specifies off the blocking by subject.*/ - EMF_OPTION_BLOCK_SUBJECT_ON = 1, /**< Specifies on the blocking by subject.*/ -}; - -enum -{ - EMF_LIST_TYPE_UNREAD = -3, - EMF_LIST_TYPE_LOCAL = -2, - EMF_LIST_TYPE_THREAD = -1, - EMF_LIST_TYPE_NORMAL = 0 -}; - -/** -* This enumeration specifies the mailbox sync type. -*/ -enum -{ - EMF_MAILBOX_ALL = -1, /**< All mailboxes.*/ - EMF_MAILBOX_FROM_SERVER = 0, /**< Mailboxes from server. */ - EMF_MAILBOX_FROM_LOCAL = 1, /**< Mailboxes from local. */ -}; - -typedef enum -{ - APPEND_BODY = 1, - UPDATE_MAILBOX, - UPDATE_ATTACHMENT_INFO, - UPDATE_FLAG, - UPDATE_SAVENAME, - UPDATE_EXTRA_FLAG, - UPDATE_MAIL, - UPDATE_DATETIME, - UPDATE_FROM_CONTACT_INFO, - UPDATE_TO_CONTACT_INFO, - UPDATE_ALL_CONTACT_NAME, - UPDATE_ALL_CONTACT_INFO, - UPDATE_STICKY_EXTRA_FLAG, - UPDATE_PARTIAL_BODY_DOWNLOAD, - UPDATE_MEETING, - UPDATE_SEEN_FLAG_OF_THREAD, -} emf_mail_change_type_t; - - -/** -* This enumeration specifies the address type. -*/ -typedef enum -{ - EMF_ADDRESS_TYPE_FROM = 1, /**< Specifies the from address.*/ - EMF_ADDRESS_TYPE_TO, /**< Specifies the to receipient address.*/ - EMF_ADDRESS_TYPE_CC, /**< Specifies the cc receipient address.*/ - EMF_ADDRESS_TYPE_BCC, /**< Specifies the bcc receipient address.*/ - EMF_ADDRESS_TYPE_REPLY, /**< Specifies the reply receipient address.*/ - EMF_ADDRESS_TYPE_RETURN, /**< Specifies the return receipient address.*/ -} emf_address_type_t; - -/** - * This enumeration specifies the search type for searching mailbox. - */ -typedef enum -{ - EMF_MAILBOX_SEARCH_KEY_TYPE_SUBJECT, /**< The search key is for searching subject.*/ - EMF_MAILBOX_SEARCH_KEY_TYPE_FROM, /**< The search key is for searching sender address.*/ - EMF_MAILBOX_SEARCH_KEY_TYPE_BODY, /**< The search key is for searching body.*/ - EMF_MAILBOX_SEARCH_KEY_TYPE_TO, /**< The search key is for searching recipient address.*/ -} emf_mailbox_search_key_t; - -/** - * This enumeration specifies the download status of mail body. - */ - -typedef enum -{ - EMF_BODY_DOWNLOAD_STATUS_NONE = 0, - EMF_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED = 1, - EMF_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED = 2, -} emf_body_download_status_t; - -/** - * This enumeration specifies the moving type. - */ -typedef enum -{ - EMF_MOVED_BY_COMMAND = 0, - EMF_MOVED_BY_MOVING_THREAD, - EMF_MOVED_AFTER_SENDING -} emf_move_type; - -/** - * This enumeration specifies the deletion type. - */ -typedef enum -{ - EMF_DELETED_BY_COMMAND = 0, - EMF_DELETED_BY_OVERFLOW, - EMF_DELETED_BY_DELETING_THREAD, - EMF_DELETED_BY_MOVING_TO_OTHER_ACCOUNT, - EMF_DELETED_AFTER_SENDING, - EMF_DELETED_FROM_SERVER, -} emf_delete_type; - -/** - * This enumeration specifies the status field type. - */ -typedef enum -{ - EMF_FLAGS_SEEN_FIELD = 0, - EMF_FLAGS_DELETED_FIELD, - EMF_FLAGS_FLAGGED_FIELD, - EMF_FLAGS_ANSWERED_FIELD, - EMF_FLAGS_RECENT_FIELD, - EMF_FLAGS_DRAFT_FIELD, - EMF_FLAGS_FORWARDED_FIELD, - EMF_FLAGS_FIELD_COUNT, -} emf_flags_field_type; - -typedef enum { - EMF_FLAG_NONE = 0, - EMF_FLAG_FLAGED = 1, - EMF_FLAG_TASK_STATUS_CLEAR = 2, - EMF_FLAG_TASK_STATUS_ACTIVE = 3, - EMF_FLAG_TASK_STATUS_COMPLETE = 4, -} emf_flagged_type; - -typedef enum { - EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO = 1, /* integer type */ - EMAIL_SEARCH_FILTER_TYPE_UID = 2, /* integer type */ - EMAIL_SEARCH_FILTER_TYPE_BCC = 7, /* string type */ - EMAIL_SEARCH_FILTER_TYPE_CC = 9, /* string type */ - EMAIL_SEARCH_FILTER_TYPE_FROM = 10, /* string type */ - EMAIL_SEARCH_FILTER_TYPE_KEYWORD = 11, /* string type */ - EMAIL_SEARCH_FILTER_TYPE_SUBJECT = 13, /* string type */ - EMAIL_SEARCH_FILTER_TYPE_TO = 15, /* string type */ - EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER = 16, /* integer type */ - EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER = 17, /* integer type */ - EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE = 20, /* time type */ - EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON = 21, /* time type */ - EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE = 22, /* time type */ - EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED = 26, /* integer type */ - EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED = 28, /* integer type */ - EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT = 30, /* integer type */ - EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED = 32, /* integer type */ - EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT = 34, /* integer type */ - EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN = 36, /* integer type */ - EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID = 43, /* string type */ -} email_search_filter_type; - -typedef enum { - EMAIL_DRM_TYPE_NONE = 0, - EMAIL_DRM_TYPE_OBJECT = 1, - EMAIL_DRM_TYPE_RIGHT = 2, - EMAIL_DRM_TYPE_DCF = 3 -} email_drm_type; - -typedef enum { - EMAIL_DRM_METHOD_NONE = 0, - EMAIL_DRM_METHOD_FL = 1, - EMAIL_DRM_METHOD_CD = 2, - EMAIL_DRM_METHOD_SSD = 3, - EMAIL_DRM_METHOD_SD = 4 -} email_drm_method; - -/*****************************************************************************/ -/* Data Structures */ -/*****************************************************************************/ - -/** - * This structure is used to save mail time. - */ -typedef struct -{ - unsigned short year; /**< Specifies the Year.*/ - unsigned short month; /**< Specifies the Month.*/ - unsigned short day; /**< Specifies the Day.*/ - unsigned short hour; /**< Specifies the Hour.*/ - unsigned short minute; /**< Specifies the Minute.*/ - unsigned short second; /**< Specifies the Second.*/ -} emf_datetime_t; - -/** - * This structure is used to save the options. - */ -typedef struct -{ - int priority; /**< Specifies the prority. 1=high 3=normal 5=low.*/ - int keep_local_copy; /**< Specifies the saving save a copy after sending.*/ - int req_delivery_receipt; /**< Specifies the request of delivery report. 0=off 1=on*/ - int req_read_receipt; /**< Specifies the request of read receipt. 0=off 1=on*/ - int download_limit; /**< Specifies the limit of size for downloading.*/ - int block_address; /**< Specifies the blocking of address. 0=off 1=on*/ - int block_subject; /**< Specifies the blocking of subject. 0=off 1=on*/ - char *display_name_from; /**< Specifies the display name of from.*/ - int reply_with_body; /**< Specifies the replying with body 0=off 1=on*/ - int forward_with_files; /**< Specifies the fowarding with files 0=off 1=on*/ - int add_myname_card; /**< Specifies the adding name card 0=off 1=on*/ - int add_signature; /**< Specifies the adding signature 0=off 1=on*/ - char *signature; /**< Specifies the signature*/ - int add_my_address_to_bcc; /**< Specifies whether bcc field should be always filled with my address. 0=off 1=on*/ -} emf_option_t; - -/** - * This structure is used to save the information of email account. - */ -typedef struct -{ - emf_account_bind_t account_bind_type; /**< Specifies the Bind Type.*/ - char *account_name; /**< Specifies the account name.*/ - emf_account_server_t receiving_server_type; /**< Specifies the receiving server type.*/ - char *receiving_server_addr; /**< Specifies the address of receiving server.*/ - char *email_addr; /**< Specifies the email adderee.*/ - char *user_name; /**< Specifies the user name.*/ - char *password; /**< Specifies the password.*/ - emf_imap4_retrieval_mode_t retrieval_mode; /**< Specifies the retrieval mode in IMAP case.*/ - int port_num; /**< Specifies the port number of receiving server.*/ - int use_security; /**< Specifies the security such as SSL.*/ - emf_account_server_t sending_server_type; /**< Specifies the type of sending server.*/ - char *sending_server_addr; /**< Specifies the address of sending server.*/ - int sending_port_num; /**< Specifies the port number of sending server.*/ - int sending_auth; /**< Specifies the authentication of sending server.*/ - int sending_security; /**< Specifies the security such as SSL.*/ - char *sending_user; /**< Specifies the user name of SMTP server.*/ - char *sending_password; /**< Specifies the user password of SMTP server.*/ - char *display_name; /**< Specifies the display name.*/ - char *reply_to_addr; /**< Specifies the reply email address.*/ - char *return_addr; /**< Specifies the email address for return.*/ - int account_id; /**< Specifies the ID of account. Especially, 1 is assigned to Local Account.*/ - int keep_on_server; /**< Specifies the keeping mail on server.*/ - int flag1; /**< Specifies the downloading option. 0 is subject only, 1 is text body, 2 is normal.*/ - int flag2; /**< Specifies the 'Same as POP3' option. 0 is none, 1 is 'Same as POP3'.*/ - int pop_before_smtp; /**< POP before SMTP authentication */ - int apop; /**< APOP Authentication */ - char *logo_icon_path; /**< Account logo icon */ - int preset_account; /**< Preset account or not */ - emf_option_t options; /**< Specifies the Sending options */ - int target_storage; /**< Specifies the targetStorage. 0 is phone, 1 is MMC */ - int check_interval; /**< Specifies the Check interval. Unit is minutes */ - int my_account_id; /**< Specifies accout id of my account */ - int index_color; /**< Specifies index color for displaying classifying accounts */ -}emf_account_t; - -/** - * This structure is used to save the information of email server. - */ - -typedef struct -{ - int configuration_id; /**< Specifies the id of configuration.*/ - emf_account_server_t protocol_type; /**< Specifies the type of configuration.*/ - char *server_addr; /**< Specifies the address of configuration.*/ - int port_number; /**< Specifies the port number of configuration.*/ - int security_type; /**< Specifies the security such as SSL.*/ - int auth_type; /**< Specifies the authentication type of configuration.*/ -} emf_protocol_config_t; - -typedef struct -{ - char *service_name; /**< Specifies the name of service.*/ - int authname_format; /**< Specifies the type of user name for authentication.*/ - int protocol_conf_count; /**< Specifies count of protocol configurations.*/ - emf_protocol_config_t *protocol_config_array; /**< Specifies array of protocol configurations.*/ -} emf_server_info_t; - -typedef struct -{ - int mailbox_type; - char mailbox_name[MAILBOX_NAME_LENGTH]; -} emf_mailbox_type_item_t; - -/** - * This structure is contains the Mail information. - */ - -typedef struct -{ - int mail_id; /**< Specifies the Mail ID.*/ - int account_id; /**< Specifies the Account ID.*/ - char *mailbox_name; /**< Specifies the Mailbox Name.*/ - int mailbox_type; /**< Specifies the mailbox type of the mail. */ - char *subject; /**< Specifies the subject.*/ - time_t date_time; /**< Specifies the Date time.*/ - int server_mail_status; /**< Specifies the Whether sever mail or not.*/ - char *server_mailbox_name; /**< Specifies the server mailbox.*/ - char *server_mail_id; /**< Specifies the Server Mail ID.*/ - char *message_id; /**< Specifies the message id */ - char *full_address_from; /**< Specifies the From Addr.*/ - char *full_address_reply; /**< Specifies the Reply to addr */ - char *full_address_to; /**< Specifies the To addr.*/ - char *full_address_cc; /**< Specifies the CC addr.*/ - char *full_address_bcc; /**< Specifies the BCC addr*/ - char *full_address_return; /**< Specifies the return Path*/ - char *email_address_sender; /**< Specifies the email address of sender.*/ - char *email_address_recipient; /**< Specifies the email address of recipients.*/ - char *alias_sender; /**< Specifies the alias of sender. */ - char *alias_recipient; /**< Specifies the alias of recipients. */ - int body_download_status; /**< Specifies the Text donwloaded or not.*/ - char *file_path_plain; /**< Specifies the path of text mail body.*/ - char *file_path_html; /**< Specifies the path of HTML mail body.*/ - int mail_size; /**< Specifies the Mail Size.*/ - char flags_seen_field; /**< Specifies the seen flags*/ - char flags_deleted_field; /**< Specifies the deleted flags*/ - char flags_flagged_field; /**< Specifies the flagged flags*/ - char flags_answered_field; /**< Specifies the answered flags*/ - char flags_recent_field; /**< Specifies the recent flags*/ - char flags_draft_field; /**< Specifies the draft flags*/ - char flags_forwarded_field; /**< Specifies the forwarded flags*/ - int DRM_status; /**< Has the mail DRM content? (1 : true, 0 : false) */ - int priority; /**< Specifies the priority of the mail.*/ - int save_status; /**< Specifies the save status*/ - int lock_status; /**< Specifies the Locked*/ - int report_status; /**< Specifies the Mail Report.*/ - int attachment_count; /**< Specifies the attachment count. */ - int inline_content_count; /**< Specifies the inline content count. */ - int thread_id; /**< Specifies the thread id for thread view. */ - int thread_item_count; /**< Specifies the item count of specific thread. */ - char *preview_text; /**< Specifies the preview body. */ - int meeting_request_status; /**< Specifies the status of meeting request. */ -}emf_mail_data_t; - -/** - * This structure is contains information for displaying mail list. - */ -typedef struct -{ - int mail_id; /**< Specifies the Mail ID.*/ - int account_id; /**< Specifies the Account ID.*/ - char mailbox_name[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the Mailbox Name.*/ - char from[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the from display name.*/ - char from_email_address[MAX_EMAIL_ADDRESS_LENGTH]; /**< Specifies the from email address.*/ - char recipients[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the recipients display name.*/ - char subject[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the subject.*/ - int is_text_downloaded; /**< Specifies the Text donwloaded or not.*/ - time_t date_time; /**< Specifies the Date time.*/ - char flags_seen_field; /**< Specifies the seen flags*/ - char flags_deleted_field; /**< Specifies the deleted flags*/ - char flags_flagged_field; /**< Specifies the flagged flags*/ - char flags_answered_field; /**< Specifies the answered flags*/ - char flags_recent_field; /**< Specifies the recent flags*/ - char flags_draft_field; /**< Specifies the draft flags*/ - char flags_forwarded_field; /**< Specifies the forwarded flags*/ - int priority; /**< Specifies the priority of Mails.*/ - int save_status; /**< Specifies the save status*/ - int is_locked; /**< Specifies the Locked*/ - int is_report_mail; /**< Specifies the Mail Report.*/ - int recipients_count; /**< Specifies the number of to Recipients*/ - int has_attachment; /**< the mail has attachments or not[ 0: none, 1: over one] */ - int has_drm_attachment; /**< the mail has drm attachment or not*/ - char previewBodyText[MAX_PREVIEW_TEXT_LENGTH]; /**< text for preview body*/ - int thread_id; /**< thread id for thread view*/ - int thread_item_count; /**< item count of specific thread */ - int is_meeting_request; /**< Whether the mail is a meeting request or not */ -}emf_mail_list_item_t; - -/** - * This structure is used to save the filtering structure. - */ -typedef struct -{ - int account_id; /**< Specifies the account ID.*/ - int filter_id; /**< Specifies the filtering ID.*/ - emf_rule_type_t type; /**< Specifies the filtering type.*/ - char *value; /**< Specifies the filtering value.*/ - emf_rule_action_t faction; /**< Specifies the action type for filtering.*/ - char *mailbox; /**< Specifies the mail box if action type means move.*/ - int flag1; /**< Specifies the activation.*/ - int flag2; /**< Reserved.*/ -} emf_rule_t; - -/** - * This structure is used to save the information of mail flag. - */ -typedef struct -{ - unsigned int seen : 1; /**< Specifies the read email.*/ - unsigned int deleted : 1; /**< Reserved.*/ - unsigned int flagged : 1; /**< Specifies the flagged email.*/ - unsigned int answered : 1; /**< Reserved.*/ - unsigned int recent : 1; /**< Reserved.*/ - unsigned int draft : 1; /**< Specifies the draft email.*/ - unsigned int has_attachment : 1; /**< Reserved.*/ - unsigned int forwarded : 1; /**< Reserved.*/ - unsigned int sticky : 1; /**< Sticky flagged mails cannot be deleted */ -} emf_mail_flag_t; - - -/** - * This structure is used to save the information of mail extra flag. - */ -typedef struct -{ - unsigned int priority : 3; /**< Specifies the mail priority. - The value is greater than or equal to EMF_MAIL_PRIORITY_HIGH. - The value is less than or eqult to EMF_MAIL_PRIORITY_LOW.*/ - unsigned int status : 4; /**< Specifies the mail status. - The value is a value of enumeration emf_mail_status_t.*/ - unsigned int noti : 1; /**< Specifies the notified mail.*/ - unsigned int lock : 1; /**< Specifies the locked mail.*/ - unsigned int report : 2; /**< Specifies the MDN/DSN mail. The value is a value of enumeration emf_mail_report_t.*/ - unsigned int drm : 1; /**< Specifies the drm mail.*/ - unsigned int text_download_yn : 2; /**< body download y/n*/ /* To be removed */ -} emf_extra_flag_t; - -/** - * This structure is used to save the information of attachment. - */ -typedef struct st_emf_attachment_info -{ - int inline_content; - int attachment_id; /**< Specifies the attachment ID*/ - char *name; /**< Specifies the attachment name.*/ - int size; /**< Specifies the attachment size.*/ - int downloaded; /**< Specifies the download of attachment.*/ - char *savename; /**< Specifies the absolute path of attachment.*/ - int drm; /**< Specifies the drm type.*/ - char *attachment_mime_type; /**< Specifies the context mime type.*/ - struct st_emf_attachment_info *next; /**< Specifies the pointer of next attachment.*/ -} emf_attachment_info_t; - -typedef struct -{ - int attachment_id; - char *attachment_name; - char *attachment_path; - int attachment_size; - int mail_id; - int account_id; - char *mailbox_name; - int save_status; - int drm_status; - int inline_content_status; - char *attachment_mime_type; /**< Specifies the context mime type.*/ -} emf_attachment_data_t; - -typedef struct -{ - int offset_from_GMT; - char standard_name[32]; - struct tm standard_time_start_date; - int standard_bias; - char daylight_name[32]; - struct tm daylight_time_start_date; - int daylight_bias; -} emf_time_zone_t; - -typedef struct -{ - int mail_id; /**< Specifies the mail id of meeting request on DB. This is the primary key. */ - emf_meeting_response_t meeting_response; /**< Specifies the meeting response. */ - struct tm start_time; - struct tm end_time; - char *location; /**< Specifies the location of meeting. Maximum length of this string is 32768 */ - char *global_object_id; /**< Specifies the object id. */ - emf_time_zone_t time_zone; -} emf_meeting_request_t; - -/** - * This structure is used to save the informatioin of sender list with unread/total mail counts - */ -typedef struct -{ - char *address; /**< Specifies the address of a sender.*/ - char *display_name; /**< Specifies a display name. This may be one of contact name, alias in original mail and email address of sender. (Priority order : contact name, alias, email address) */ - int unread_count; /**< Specifies the number of unread mails received from sender address*/ - int total_count; /**< Specifies the total number of mails which are received from sender address*/ -} emf_sender_list_t; - - -/* Creates a type name for structure emf_mailbox_st */ -typedef struct emf_mailbox_st emf_mailbox_t; /**< This is an information of mail box. */ - -/** - * This structure is used to save the information of mailbox. - */ -struct emf_mailbox_st -{ - int mailbox_id; /**< Unique id on mailbox table.*/ - char *name; /**< Specifies the path of mailbox.*/ - emf_mailbox_type_e mailbox_type; - char *alias; /**< Specifies the display name of mailbox.*/ - int unread_count; /**< Specifies the Unread Mail count in the mailbox.*/ - int total_mail_count_on_local; /**< Specifies the total number of mails in the mailbox in the local DB.*/ - int total_mail_count_on_server; /**< Specifies the total number of mails in the mailbox in the mail server.*/ - int hold_connection; /**< Will have a valid socket descriptor when connection to server is active.. else 0>*/ - int local; /**< Specifies the local mailbox.*/ - int synchronous; /**< Specifies the mailbox with synchronized the server.*/ - int account_id; /**< Specifies the account ID for mailbox.*/ - void *user_data; /**< Specifies the internal data.*/ - void *mail_stream; /**< Specifies the internal data.*/ - int has_archived_mails; /**< Specifies the archived mails.*/ - int mail_slot_size; /**< Specifies how many mails can be stored.*/ - char *account_name; /**< Specifies the name of account.*/ - emf_mailbox_t *next; /**< Reserved.*/ -}; - - -typedef struct -{ - char *contact_name; - char *email_address; - char *alias; - int storage_type; - int contact_id; -} emf_mail_contact_info_t; - -typedef struct -{ - emf_address_type_t address_type; - char *address; - char *display_name; - int storage_type; - int contact_id; -} emf_address_info_t; - -typedef struct -{ - GList *from; - GList *to; - GList *cc; - GList *bcc; -} emf_address_info_list_t; - -typedef struct -{ - int address_type; /* type of mail (sender : 0, recipient : 1)*/ - int address_count; /* The number of email addresse */ - char **address_list; /* strings of email addresse */ -}emf_email_address_list_t; - -/* global account lis */ -typedef struct emf_account_list_t emf_account_list_t; -struct emf_account_list_t -{ - emf_account_t *account; - emf_account_list_t *next; -}; - - -typedef struct _email_search_filter_t { - email_search_filter_type search_filter_type; /* type of search filter */ - union { - int integer_type_key_value; - struct tm time_type_key_value; - char *string_type_key_value; - } search_filter_key_value; -} email_search_filter_t; - - -/*****************************************************************************/ -/* For Active Sync */ -/*****************************************************************************/ - -#define VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE "db/email_handle/active_sync_handle" -#define EMF_ACTIVE_SYNC_NOTI "User.Email.ActiveSync" - -typedef enum -{ - ACTIVE_SYNC_NOTI_SEND_MAIL, /* a sending notification to ASE (active sync engine */ - ACTIVE_SYNC_NOTI_SEND_SAVED, /* a sending notification to ASE (active sync engine), All saved mails should be sent */ - ACTIVE_SYNC_NOTI_SEND_REPORT, /* a sending notification to ASE (active sync engine), report should be sen */ - ACTIVE_SYNC_NOTI_SYNC_HEADER, /* a sync header - download mails from server. */ - /* It is depended on account/s flag1 field whether it excutes downloading header only or downloading header + body */ - /* downloading option : 0 is subject only, 1 is text body, 2 is normal */ - ACTIVE_SYNC_NOTI_DOWNLOAD_BODY, /* a downloading body notification to AS */ - ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT, /* a downloading attachment notification to AS */ - ACTIVE_SYNC_NOTI_VALIDATE_ACCOUNT, /* a account validating notification to AS */ - ACTIVE_SYNC_NOTI_CANCEL_JOB, /* a cancling job notification to AS */ - ACTIVE_SYNC_NOTI_SEARCH_ON_SERVER, /* a searching on server notification to AS */ -} eactivesync_noti_t; - -typedef union -{ - struct _send_mail - { - int handle; - int account_id; - char *mailbox_name; - int mail_id; - emf_option_t options; - } send_mail; - - struct _send_mail_saved - {/* not defined ye */ - int handle; - int account_id; - } send_mail_saved; - - struct _send_report - {/* not defined ye */ - int handle; - int account_id; - } send_report; - - struct _sync_header - { - int handle; - int account_id; - char *mailbox_name; - } sync_header; - - struct _download_body - { - int handle; - int account_id; - int mail_id; - int with_attachment; /* 0: without attachments, 1: with attachment */ - } download_body; - - struct _download_attachment - { - int handle; - int account_id; - int mail_id; - char *attachment_order; - } download_attachment; - - struct _cancel_job - { - int account_id; - int handle; /* job handle to be canceled. this value is issued by email-service (actually in Emf_Mapi_xxx() */ - } cancel_job; - - struct _validate_account - {/* not defined yet */ - int handle; - int account_id; - } validate_account; - - struct _search_mail_on_server - { - int handle; - int account_id; - char *mailbox_name; - email_search_filter_t *search_filter_list; - int search_filter_count; - } search_mail_on_server; - -} ASNotiData; - - -/* types for noti string */ -typedef enum -{ - EMF_CONVERT_STRUCT_TYPE_MAIL_LIST_ITEM, /** specifies emf_mail_list_t */ -} emf_convert_struct_type_e; - -#ifdef __cplusplus -} -#endif - -/** -* @} @} -*/ - -#endif /* __EMF_LIB_H__ */ - +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +#ifndef __EMAIL_TYPES_H__ +#define __EMAIL_TYPES_H__ + +/** +* @defgroup EMAIL_SERVICE Email Service +* @{ +*/ + +/** +* @ingroup EMAIL_SERVICE +* @defgroup EMAIL_TYPES Email Types +* @{ +*/ +/** + * This file defines structures and enums of Email Framework. + * @file email-types.h + * @author Kyu-ho Jo(kyuho.jo@samsung.com) + * @author Choongho Lee(ch715.lee@samsung.com) + * @version 0.1 + * @brief This file is the header file of Email Framework library. + */ + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include +#include +#include "email-errors.h" + + +/*****************************************************************************/ +/* Macros */ +/*****************************************************************************/ + +#define MAILBOX_NAME_LENGTH 256 +#define MAX_EMAIL_ADDRESS_LENGTH 320 /* 64(user name) + 1(@) + 255(host name */ +#define MAX_DATETIME_STRING_LENGTH 20 +#define MAX_PREVIEW_TEXT_LENGTH 512 +#define STRING_LENGTH_FOR_DISPLAY 100 +#define MEETING_REQ_OBJECT_ID_LENGTH 256 + +#define ALL_ACCOUNT 0 +#define NEW_ACCOUNT_ID 0xFFFFFFFE +#define ALL_MAIL -1 + +#define EMAIL_SEARCH_FILTER_NONE 0x00 +#define EMAIL_SEARCH_FILTER_SUBJECT 0x01 +#define EMAIL_SEARCH_FILTER_SENDER 0x02 +#define EMAIL_SEARCH_FILTER_RECIPIENT 0x04 +#define EMAIL_SEARCH_FILTER_ALL 0x07 /* EMAIL_SEARCH_FILTER_SUBJECT + EMAIL_SEARCH_FILTER_SENDER + EMAIL_SEARCH_FILTER_RECIPIEN */ + +#define EMAIL_SUCCESS 0 /* we need to modify the success return valu */ + +#define EMAIL_ACC_GET_OPT_DEFAULT 0x01 /**< Default values without account name */ +#define EMAIL_ACC_GET_OPT_ACCOUNT_NAME 0x02 /**< Account name */ +#define EMAIL_ACC_GET_OPT_PASSWORD 0x04 /**< With password */ +#define EMAIL_ACC_GET_OPT_OPTIONS 0x08 /**< Account options : email_option_t */ +#define EMAIL_ACC_GET_OPT_FULL_DATA 0xFF /**< With all data of account */ + +#define GET_FULL_DATA (EMAIL_ACC_GET_OPT_FULL_DATA) +#define GET_FULL_DATA_WITHOUT_PASSWORD (EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_ACCOUNT_NAME | EMAIL_ACC_GET_OPT_OPTIONS ) +#define WITHOUT_OPTION (EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_ACCOUNT_NAME ) +#define ONLY_OPTION (EMAIL_ACC_GET_OPT_OPTIONS) + +#define THREAD_TYPE_RECEIVING 0 /**< for function 'email_activate_pdp' */ +#define THREAD_TYPE_SENDING 1 /**< for function 'email_activate_pdp' */ + +#define EMAIL_IMAP_PORT 143 /**< Specifies the default IMAP port.*/ +#define EMAIL_POP3_PORT 110 /**< Specifies the default POP3 port.*/ +#define EMAIL_SMTP_PORT 25 /**< Specifies the default SMTP port.*/ +#define EMAIL_IMAPS_PORT 993 /**< Specifies the default IMAP SSL port.*/ +#define EMAIL_POP3S_PORT 995 /**< Specifies the default POP3 SSL port.*/ +#define EMAIL_SMTPS_PORT 465 /**< Specifies the default SMTP SSL port.*/ +#define EMAIL_ACCOUNT_MAX 10 /**< Specifies the MAX account.*/ + +#define EMAIL_INBOX_NAME "INBOX" /**< Specifies the name of inbox.*/ +#define EMAIL_DRAFTBOX_NAME "DRAFTBOX" /**< Specifies the name of draftbox.*/ +#define EMAIL_OUTBOX_NAME "OUTBOX" /**< Specifies the name of outbox.*/ +#define EMAIL_SENTBOX_NAME "SENTBOX" /**< Specifies the name of sentbox.*/ +#define EMAIL_TRASH_NAME "TRASH" /**< Specifies the name of trash.*/ +#define EMAIL_SPAMBOX_NAME "SPAMBOX" /**< Specifies the name of spambox.*/ + +#define EMAIL_INBOX_DISPLAY_NAME "Inbox" /**< Specifies the display name of inbox.*/ +#define EMAIL_DRAFTBOX_DISPLAY_NAME "Draftbox" /**< Specifies the display name of draftbox.*/ +#define EMAIL_OUTBOX_DISPLAY_NAME "Outbox" /**< Specifies the display name of outbox.*/ +#define EMAIL_SENTBOX_DISPLAY_NAME "Sentbox" /**< Specifies the display name of sentbox.*/ +#define EMAIL_TRASH_DISPLAY_NAME "Trash" /**< Specifies the display name of sentbox.*/ +#define EMAIL_SPAMBOX_DISPLAY_NAME "Spambox" /**< Specifies the display name of spambox.*/ + +#define EMAIL_SEARCH_RESULT_MAILBOX_NAME "_`S1!E2@A3#R4$C5^H6&R7*E8(S9)U0-L=T_" /**< Specifies the name of search result mailbox.*/ + +#define SYNC_STATUS_FINISHED 0 /* BIN 00000000 */ +#define SYNC_STATUS_SYNCING 1 /* BIN 00000001 */ +#define SYNC_STATUS_HAVE_NEW_MAILS 2 /* BIN 00000010 */ + + +#define FAILURE -1 +#define SUCCESS 0 + +#define DAEMON_EXECUTABLE_PATH "/usr/bin/email-service" + +#ifndef EXPORT_API +#define EXPORT_API __attribute__((visibility("default"))) +#endif + +#ifndef DEPRECATED +#define DEPRECATED __attribute__((deprecated)) +#endif + +/* __FEATURE_LOCAL_ACTIVITY__ supported +#define BULK_OPERATION_COUNT 50 +#define ALL_ACTIVITIES 0 +*/ + +/*****************************************************************************/ +/* Enumerations */ +/*****************************************************************************/ +enum { + /* Account */ + _EMAIL_API_ADD_ACCOUNT = 0x01000000, + _EMAIL_API_DELETE_ACCOUNT = 0x01000001, + _EMAIL_API_UPDATE_ACCOUNT = 0x01000002, + _EMAIL_API_GET_ACCOUNT = 0x01000003, + _EMAIL_API_GET_ACCOUNT_LIST = 0x01000005, + _EMAIL_API_GET_MAILBOX_COUNT = 0x01000007, + _EMAIL_API_VALIDATE_ACCOUNT = 0x01000008, + _EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION = 0x01000009, + _EMAIL_API_BACKUP_ACCOUNTS = 0x0100000A, + _EMAIL_API_RESTORE_ACCOUNTS = 0x0100000B, + _EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT = 0x0100000C, + + /* Mail */ + _EMAIL_API_DELETE_MAIL = 0x01100002, + _EMAIL_API_DELETE_ALL_MAIL = 0x01100004, + _EMAIL_API_GET_MAILBOX_LIST = 0x01100006, + _EMAIL_API_GET_SUBMAILBOX_LIST = 0x01100007, + _EMAIL_API_CLEAR_DATA = 0x01100009, + _EMAIL_API_MOVE_MAIL = 0x0110000A, + _EMAIL_API_MOVE_ALL_MAIL = 0x0110000B, + _EMAIL_API_ADD_ATTACHMENT = 0x0110000C, + _EMAIL_API_GET_ATTACHMENT = 0x0110000D, + _EMAIL_API_DELETE_ATTACHMENT = 0x0110000E, + _EMAIL_API_MODIFY_MAIL_FLAG = 0x0110000F, + _EMAIL_API_MODIFY_MAIL_EXTRA_FLAG = 0x01100011, + _EMAIL_API_SET_FLAGS_FIELD = 0x01100016, + _EMAIL_API_ADD_MAIL = 0x01100017, + _EMAIL_API_UPDATE_MAIL = 0x01100018, + _EMAIL_API_ADD_READ_RECEIPT = 0x01100019, + _EMAIL_API_EXPUNGE_MAILS_DELETED_FLAGGED = 0x0110001A, + + /* Thread */ + _EMAIL_API_MOVE_THREAD_TO_MAILBOX = 0x01110000, + _EMAIL_API_DELETE_THREAD = 0x01110001, + _EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD = 0x01110002, + + /* Mailbox */ + _EMAIL_API_ADD_MAILBOX = 0x01200000, + _EMAIL_API_DELETE_MAILBOX = 0x01200001, + _EMAIL_API_UPDATE_MAILBOX = 0x01200002, + _EMAIL_API_SET_MAIL_SLOT_SIZE = 0x01200007, + _EMAIL_API_RENAME_MAILBOX = 0x01200008, + _EMAIL_API_SET_MAILBOX_TYPE = 0x01200009, + + /* Network */ + _EMAIL_API_SEND_MAIL = 0x01300000, + _EMAIL_API_SYNC_HEADER = 0x01300001, + _EMAIL_API_DOWNLOAD_BODY = 0x01300002, + _EMAIL_API_DOWNLOAD_ATTACHMENT = 0x01300003, + _EMAIL_API_NETWORK_GET_STATUS = 0x01300004, + _EMAIL_API_SEND_SAVED = 0x01300005, + _EMAIL_API_DELETE_EMAIL = 0x01300007, + _EMAIL_API_DELETE_EMAIL_ALL = 0x01300008, + _EMAIL_API_GET_IMAP_MAILBOX_LIST = 0x01300015, + _EMAIL_API_SEND_MAIL_CANCEL_JOB = 0x01300017, + _EMAIL_API_SEARCH_MAIL_ON_SERVER = 0x01300019, + _EMAIL_API_CLEAR_RESULT_OF_SEARCH_MAIL_ON_SERVER = 0x0130001A, + + /* Rule */ + _EMAIL_API_ADD_RULE = 0x01400000, + _EMAIL_API_GET_RULE = 0x01400001, + _EMAIL_API_GET_RULE_LIST = 0x01400002, + _EMAIL_API_FIND_RULE = 0x01400003, + _EMAIL_API_DELETE_RULE = 0x01400004, + _EMAIL_API_UPDATE_RULE = 0x01400005, + _EMAIL_API_CANCEL_JOB = 0x01400006, + _EMAIL_API_GET_PENDING_JOB = 0x01400007, + _EMAIL_API_SEND_RETRY = 0x01400008, + _EMAIL_API_UPDATE_ACTIVITY = 0x01400009, + _EMAIL_API_SYNC_LOCAL_ACTIVITY = 0x0140000A, + _EMAIL_API_PRINT_RECEIVING_EVENT_QUEUE = 0x0140000B, + + /* Etc */ + _EMAIL_API_PING_SERVICE = 0x01500000, + _EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL = 0x01500001, + _EMAIL_API_SHOW_USER_MESSAGE = 0x01500002, + + /* Smime */ + _EMAIL_API_ADD_CERTIFICATE = 0x01600000, + _EMAIL_API_DELETE_CERTIFICATE = 0x01600001, + _EMAIL_API_VERIFY_SIGNATURE = 0x01600002, + _EMAIL_API_VERIFY_CERTIFICATE = 0x01600003, +}; + +typedef enum +{ + EMAIL_DELETE_LOCALLY = 0, /**< Specifies Mail Delete local only */ + EMAIL_DELETE_LOCAL_AND_SERVER, /**< Specifies Mail Delete local & server */ + EMAIL_DELETE_FOR_SEND_THREAD, /**< Created to check which activity to delete in send thread */ + EMAIL_DELETE_FROM_SERVER, +} email_delete_option_t; + +typedef enum +{ + NOTI_MAIL_ADD = 10000, + NOTI_MAIL_DELETE = 10001, + NOTI_MAIL_DELETE_ALL = 10002, + NOTI_MAIL_DELETE_WITH_ACCOUNT = 10003, + NOTI_MAIL_DELETE_FAIL = 10007, + NOTI_MAIL_DELETE_FINISH = 10008, + + NOTI_MAIL_UPDATE = 10004, + NOTI_MAIL_FIELD_UPDATE = 10020, + + NOTI_MAIL_MOVE = 10005, + NOTI_MAIL_MOVE_FAIL = 10010, + NOTI_MAIL_MOVE_FINISH = 10006, + + NOTI_THREAD_MOVE = 11000, + NOTI_THREAD_DELETE = 11001, + NOTI_THREAD_MODIFY_SEEN_FLAG = 11002, + + NOTI_ACCOUNT_ADD = 20000, + NOTI_ACCOUNT_DELETE = 20001, + NOTI_ACCOUNT_DELETE_FAIL = 20003, + NOTI_ACCOUNT_UPDATE = 20002, + NOTI_ACCOUNT_UPDATE_SYNC_STATUS = 20010, + + NOTI_MAILBOX_ADD = 40000, + NOTI_MAILBOX_DELETE = 40001, + NOTI_MAILBOX_UPDATE = 40002, + + NOTI_MAILBOX_RENAME = 40010, + NOTI_MAILBOX_RENAME_FAIL = 40011, + + NOTI_CERTIFICATE_ADD = 50000, + NOTI_CERTIFICATE_DELETE = 50001, + NOTI_CERTIFICATE_UPDATE = 50002, + /* To be added more */ +} email_noti_on_storage_event; + +typedef enum +{ + NOTI_SEND_START = 1002, + NOTI_SEND_FINISH = 1004, + NOTI_SEND_FAIL = 1005, + NOTI_SEND_CANCEL = 1003, + + NOTI_DOWNLOAD_START = 2000, + NOTI_DOWNLOAD_FINISH, + NOTI_DOWNLOAD_FAIL, + NOTI_DOWNLOAD_CANCEL = 2004, + NOTI_DOWNLOAD_NEW_MAIL = 2003, + + NOTI_DOWNLOAD_BODY_START = 3000, + NOTI_DOWNLOAD_BODY_FINISH = 3002, + NOTI_DOWNLOAD_BODY_FAIL = 3004, + NOTI_DOWNLOAD_BODY_CANCEL = 3003, + NOTI_DOWNLOAD_MULTIPART_BODY = 3001, + + NOTI_DOWNLOAD_ATTACH_START = 4000, + NOTI_DOWNLOAD_ATTACH_FINISH, + NOTI_DOWNLOAD_ATTACH_FAIL, + NOTI_DOWNLOAD_ATTACH_CANCEL, + + NOTI_MAIL_DELETE_ON_SERVER_FAIL = 5000, + NOTI_MAIL_MOVE_ON_SERVER_FAIL, + + NOTI_SEARCH_ON_SERVER_START = 6000, + NOTI_SEARCH_ON_SERVER_FINISH = 6001, + NOTI_SEARCH_ON_SERVER_FAIL = 6002, + NOTI_SEARCH_ON_SERVER_CANCEL = 6003, + + NOTI_VALIDATE_ACCOUNT_FINISH = 7000, + NOTI_VALIDATE_ACCOUNT_FAIL, + NOTI_VALIDATE_ACCOUNT_CANCEL, + + NOTI_VALIDATE_AND_CREATE_ACCOUNT_FINISH = 8000, + NOTI_VALIDATE_AND_CREATE_ACCOUNT_FAIL, + NOTI_VALIDATE_AND_CREATE_ACCOUNT_CANCEL, + + NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FINISH = 9000, + NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FAIL, + NOTI_VALIDATE_AND_UPDATE_ACCOUNT_CANCEL, + + NOTI_VALIDATE_CERTIFICATE_FINISH = 10000, + NOTI_VALIDATE_CERTIFICATE_FAIL = 10001, + NOTI_VALIDATE_CERTIFICATE_CANCEL = 10002, + + NOTI_RESOLVE_RECIPIENT_START = 11000, + NOTI_RESOLVE_RECIPIENT_FINISH, + NOTI_RESOLVE_RECIPIENT_FAIL, + NOTI_RESOLVE_RECIPIENT_CANCEL, + + NOTI_RENAME_MAILBOX_START = 12000, + NOTI_RENAME_MAILBOX_FINISH, + NOTI_RENAME_MAILBOX_FAIL, + NOTI_RENAME_MAILBOX_CANCEL, + + NOTI_ADD_MAILBOX_START = 12100, + NOTI_ADD_MAILBOX_FINISH, + NOTI_ADD_MAILBOX_FAIL, + NOTI_ADD_MAILBOX_CANCEL, + + NOTI_DELETE_MAILBOX_START = 12200, + NOTI_DELETE_MAILBOX_FINISH, + NOTI_DELETE_MAILBOX_FAIL, + NOTI_DELETE_MAILBOX_CANCEL, + + /* To be added more */ +} email_noti_on_network_event; + +typedef enum +{ + RESPONSE_SUCCEEDED = 0, + RESPONSE_FAILED = 1, + RESPONSE_CANCELED = 2 + /* To be added more */ +} email_response_to_request; + +/** + * This enumeration specifies the mail type of account. + */ +typedef enum +{ + EMAIL_BIND_TYPE_DISABLE = 0, /**< Specifies the bind type for Disabled account.*/ + EMAIL_BIND_TYPE_EM_CORE = 1, /**< Specifies the bind type for Callia.*/ +} email_account_bind_t DEPRECATED; + +/** + * This enumeration specifies the server type of account. + */ +typedef enum +{ + EMAIL_SERVER_TYPE_POP3 = 1, /**< Specifies the POP3 Server.*/ + EMAIL_SERVER_TYPE_IMAP4, /**< Specifies the IMAP4 Server.*/ + EMAIL_SERVER_TYPE_SMTP, /**< Specifies the SMTP Server.*/ + EMAIL_SERVER_TYPE_NONE, /**< Specifies the Local.*/ + EMAIL_SERVER_TYPE_ACTIVE_SYNC, /** < Specifies the Active Sync. */ +} email_account_server_t; + +/** + * This enumeration specifies the mode of retrieval. + */ +typedef enum +{ + EMAIL_IMAP4_RETRIEVAL_MODE_NEW = 0, /**< Specifies the retrieval mode for new email.*/ + EMAIL_IMAP4_RETRIEVAL_MODE_ALL, /**< Specifies the retrieval mode for all email.*/ +} email_imap4_retrieval_mode_t; + +/** + * This enumeration specifies the filtering type. + */ +typedef enum +{ + EMAIL_FILTER_FROM = 1, /**< Specifies the filtering of sender.*/ + EMAIL_FILTER_SUBJECT, /**< Specifies the filtering of email subject.*/ + EMAIL_FILTER_BODY, /** < Specifies the filterinf of email body.*/ +} email_rule_type_t; + + +/** + * This enumeration specifies the rules for filtering type. + */ +typedef enum +{ + RULE_TYPE_INCLUDES = 1, /**< Specifies the filtering rule for includes.*/ + RULE_TYPE_EXACTLY, /**< Specifies the filtering rule for Exactly same as.*/ +} email_filtering_type_t; + + +/** + * This enumeration specifies the action for filtering type. + */ +typedef enum +{ + EMAIL_FILTER_MOVE = 1, /**< Specifies the move of email.*/ + EMAIL_FILTER_BLOCK = 2, /**< Specifies the block of email.*/ + EMAIL_FILTER_DELETE = 3, /**< Specifies delete email.*/ +} email_rule_action_t; + +/** + * This enumeration specifies the email status. + */ +typedef enum +{ + EMAIL_MAIL_STATUS_NONE = 0, /**< The Mail is in No Operation state */ + EMAIL_MAIL_STATUS_RECEIVED, /**< The mail is a received mail.*/ + EMAIL_MAIL_STATUS_SENT, /**< The mail is a sent mail.*/ + EMAIL_MAIL_STATUS_SAVED, /**< The mail is a saved mail.*/ + EMAIL_MAIL_STATUS_SAVED_OFFLINE, /**< The mail is a saved mail in offline-mode.*/ + EMAIL_MAIL_STATUS_SENDING, /**< The mail is being sent.*/ + EMAIL_MAIL_STATUS_SEND_FAILURE, /**< The mail is a mail to been failed to send.*/ + EMAIL_MAIL_STATUS_SEND_CANCELED, /**< The mail is a cancelled mail.*/ + EMAIL_MAIL_STATUS_SEND_WAIT, /**< The mail is a mail to be send .*/ +} email_mail_status_t; + +/** + * This enumeration specifies the email priority. + */ +typedef enum +{ + EMAIL_MAIL_PRIORITY_HIGH = 1, /**< The priority is high.*/ + EMAIL_MAIL_PRIORITY_NORMAL = 3, /**< The priority is normal.*/ + EMAIL_MAIL_PRIORITY_LOW = 5, /**< The priority is low.*/ +} email_mail_priority_t; + +/** + * This enumeration specifies the email status. + */ +typedef enum +{ + EMAIL_MAIL_REPORT_NONE = 0, /**< The mail isn't report mail.*/ + EMAIL_MAIL_REPORT_DSN, /**< The mail is a delivery-status report mail.*/ + EMAIL_MAIL_REPORT_MDN, /**< The mail is a read-status report mail.*/ + EMAIL_MAIL_REPORT_REQUEST, /**< The mail require a read-status report mail.*/ +} email_mail_report_t; + +/** + * This enumeration specifies the DRM type + */ +typedef enum +{ + EMAIL_ATTACHMENT_DRM_NONE = 0, /**< The mail isn't DRM file.*/ + EMAIL_ATTACHMENT_DRM_OBJECT, /**< The mail is a DRM object.*/ + EMAIL_ATTACHMENT_DRM_RIGHTS, /**< The mail is a DRM rights as xml format.*/ + EMAIL_ATTACHMENT_DRM_DCF, /**< The mail is a DRM dcf.*/ +} email_attachment_drm_t; + +/** + * This enumeration specifies the meeting request type + */ +typedef enum +{ + EMAIL_MAIL_TYPE_NORMAL = 0, /**< NOT a meeting request mail. A Normal mail */ + EMAIL_MAIL_TYPE_MEETING_REQUEST = 1, /**< a meeting request mail from a serve */ + EMAIL_MAIL_TYPE_MEETING_RESPONSE = 2, /**< a response mail about meeting reques */ + EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST = 3 /**< a originating mail about meeting reques */ +} email_mail_type_t; + +/** + * This enumeration specifies the meeting response type + */ +typedef enum +{ + EMAIL_MEETING_RESPONSE_NONE = 0, /**< NOT response */ + EMAIL_MEETING_RESPONSE_ACCEPT = 1, /**< The response is acceptance */ + EMAIL_MEETING_RESPONSE_TENTATIVE = 2, /**< The response is tentative */ + EMAIL_MEETING_RESPONSE_DECLINE = 3, /**< The response is decline */ + EMAIL_MEETING_RESPONSE_REQUEST = 4, /**< The response is request */ + EMAIL_MEETING_RESPONSE_CANCEL = 5, /**< The response is cancelation */ +} email_meeting_response_t; + +typedef enum +{ + EMAIL_ACTION_SEND_MAIL = 0, + EMAIL_ACTION_SYNC_HEADER = 1, + EMAIL_ACTION_DOWNLOAD_BODY = 2, + EMAIL_ACTION_DOWNLOAD_ATTACHMENT = 3, + EMAIL_ACTION_DELETE_MAIL = 4, + EMAIL_ACTION_SEARCH_MAIL = 5, + EMAIL_ACTION_SAVE_MAIL = 6, + EMAIL_ACTION_SYNC_MAIL_FLAG_TO_SERVER = 7, + EMAIL_ACTION_SYNC_FLAGS_FIELD_TO_SERVER = 8, + EMAIL_ACTION_MOVE_MAIL = 9, + EMAIL_ACTION_CREATE_MAILBOX = 10, + EMAIL_ACTION_DELETE_MAILBOX = 11, + EMAIL_ACTION_SYNC_HEADER_OMA = 12, + EMAIL_ACTION_VALIDATE_ACCOUNT = 13, + EMAIL_ACTION_VALIDATE_AND_CREATE_ACCOUNT = 14, + EMAIL_ACTION_VALIDATE_AND_UPDATE_ACCOUNT = 15, + EMAIL_ACTION_UPDATE_MAIL = 30, + EMAIL_ACTION_SET_MAIL_SLOT_SIZE = 31, + EMAIL_ACTION_EXPUNGE_MAILS_DELETED_FLAGGED = 32, + EMAIL_ACTION_SEARCH_ON_SERVER = 33, + EMAIL_ACTION_MOVE_MAILBOX = 34, + EMAIL_ACTION_NUM, +} email_action_t; + +/** + * This enumeration specifies the status of getting envelope list. + */ +typedef enum +{ + EMAIL_LIST_NONE = 0, + EMAIL_LIST_WAITING, + EMAIL_LIST_PREPARE, /**< Specifies the preparation.*/ + EMAIL_LIST_CONNECTION_START, /**< Specifies the connection start.*/ + EMAIL_LIST_CONNECTION_SUCCEED, /**< Specifies the success of connection.*/ + EMAIL_LIST_CONNECTION_FINISH, /**< Specifies the connection finish.*/ + EMAIL_LIST_CONNECTION_FAIL, /**< Specifies the connection failure.*/ + EMAIL_LIST_START, /**< Specifies the getting start.*/ + EMAIL_LIST_PROGRESS, /**< Specifies the status of getting.*/ + EMAIL_LIST_FINISH, /**< Specifies the getting complete.*/ + EMAIL_LIST_FAIL, /**< Specifies the download failure.*/ +} email_envelope_list_status_t; + +/** + * This enumeration specifies the downloaded status of email. + */ +typedef enum +{ + EMAIL_DOWNLOAD_NONE = 0, + EMAIL_DOWNLOAD_WAITING, + EMAIL_DOWNLOAD_PREPARE, /**< Specifies the preparation.*/ + EMAIL_DOWNLOAD_CONNECTION_START, /**< Specifies the connection start.*/ + EMAIL_DOWNLOAD_CONNECTION_SUCCEED, /**< Specifies the success of connection.*/ + EMAIL_DOWNLOAD_CONNECTION_FINISH, /**< Specifies the connection finish.*/ + EMAIL_DOWNLOAD_CONNECTION_FAIL, /**< Specifies the connection failure.*/ + EMAIL_DOWNLOAD_START, /**< Specifies the download start.*/ + EMAIL_DOWNLOAD_PROGRESS, /**< Specifies the status of download.*/ + EMAIL_DOWNLOAD_FINISH, /**< Specifies the download complete.*/ + EMAIL_DOWNLOAD_FAIL, /**< Specifies the download failure.*/ +} email_download_status_t; + +/** + * This enumeration specifies the status of sending email. + */ +typedef enum +{ + EMAIL_SEND_NONE = 0, + EMAIL_SEND_WAITING, + EMAIL_SEND_PREPARE, /**< Specifies the preparation.*/ + EMAIL_SEND_CONNECTION_START, /**< Specifies the connection start.*/ + EMAIL_SEND_CONNECTION_SUCCEED, /**< Specifies the success of connection.*/ + EMAIL_SEND_CONNECTION_FINISH, /**< Specifies the connection finish.*/ + EMAIL_SEND_CONNECTION_FAIL, /**< Specifies the connection failure.*/ + EMAIL_SEND_START, /**< Specifies the sending start.*/ + EMAIL_SEND_PROGRESS, /**< Specifies the status of sending.*/ + EMAIL_SEND_FINISH, /**< Specifies the sending complete.*/ + EMAIL_SEND_FAIL, /**< Specifies the sending failure.*/ + EMAIL_SAVE_WAITING, /**< Specfies the Waiting of Sync */ +} email_send_status_t; + +typedef enum +{ + EMAIL_SYNC_NONE = 0, + EMAIL_SYNC_WAITING, + EMAIL_SYNC_PREPARE, + EMAIL_SYNC_CONNECTION_START, + EMAIL_SYNC_CONNECTION_SUCCEED, + EMAIL_SYNC_CONNECTION_FINISH, + EMAIL_SYNC_CONNECTION_FAIL, + EMAIL_SYNC_START, + EMAIL_SYNC_PROGRESS, + EMAIL_SYNC_FINISH, + EMAIL_SYNC_FAIL, +} email_sync_status_t; + +/** +* This enumeration specifies the deleting status of email. +*/ +typedef enum +{ + EMAIL_DELETE_NONE = 0, + EMAIL_DELETE_WAITING, + EMAIL_DELETE_PREPARE, /**< Specifies the preparation.*/ + EMAIL_DELETE_CONNECTION_START, /**< Specifies the connection start.*/ + EMAIL_DELETE_CONNECTION_SUCCEED, /**< Specifies the success of connection.*/ + EMAIL_DELETE_CONNECTION_FINISH, /**< Specifies the connection finish.*/ + EMAIL_DELETE_CONNECTION_FAIL, /**< Specifies the connection failure.*/ + EMAIL_DELETE_START, /**< Specifies the deletion start.*/ + EMAIL_DELETE_PROGRESS, /**< Specifies the status of deleting.*/ + EMAIL_DELETE_SERVER_PROGRESS, /**< Specifies the status of server deleting.*/ + EMAIL_DELETE_LOCAL_PROGRESS, /**< Specifies the status of local deleting.*/ + EMAIL_DELETE_FINISH, /**< Specifies the deletion complete.*/ + EMAIL_DELETE_FAIL, /**< Specifies the deletion failure.*/ +} email_delete_status_t; + +/** +* This enumeration specifies the status of validating account +*/ +typedef enum +{ + EMAIL_VALIDATE_ACCOUNT_NONE = 0, + EMAIL_VALIDATE_ACCOUNT_WAITING, + EMAIL_VALIDATE_ACCOUNT_PREPARE, /**< Specifies the preparation.*/ + EMAIL_VALIDATE_ACCOUNT_CONNECTION_START, /**< Specifies the connection start.*/ + EMAIL_VALIDATE_ACCOUNT_CONNECTION_SUCCEED, /**< Specifies the success of connection.*/ + EMAIL_VALIDATE_ACCOUNT_CONNECTION_FINISH, /**< Specifies the connection finish.*/ + EMAIL_VALIDATE_ACCOUNT_CONNECTION_FAIL, /**< Specifies the connection failure.*/ + EMAIL_VALIDATE_ACCOUNT_START, /**< Specifies the getting start.*/ + EMAIL_VALIDATE_ACCOUNT_PROGRESS, /**< Specifies the status of getting.*/ + EMAIL_VALIDATE_ACCOUNT_FINISH, /**< Specifies the getting complete.*/ + EMAIL_VALIDATE_ACCOUNT_FAIL, /**< Specifies the validation failure.*/ +} email_validate_account_status_t; + +typedef enum +{ + EMAIL_SET_SLOT_SIZE_NONE = 0, + EMAIL_SET_SLOT_SIZE_WAITING, + EMAIL_SET_SLOT_SIZE_START, + EMAIL_SET_SLOT_SIZE_FINISH, + EMAIL_SET_SLOT_SIZE_FAIL, +}email_set_slot_size_status_e; + +typedef enum +{ + EMAIL_EXPUNGE_MAILS_DELETED_FLAGGED_NONE = 0, + EMAIL_EXPUNGE_MAILS_DELETED_FLAGGED_WAITING, + EMAIL_EXPUNGE_MAILS_DELETED_FLAGGED_START, + EMAIL_EXPUNGE_MAILS_DELETED_FLAGGED_FINISH, + EMAIL_EXPUNGE_MAILS_DELETED_FLAGGED_FAIL, +}email_expunge_mails_deleted_flagged_status_e; + +typedef enum +{ + EMAIL_SEARCH_ON_SERVER_NONE = 0, + EMAIL_SEARCH_ON_SERVER_WAITING, + EMAIL_SEARCH_ON_SERVER_START, + EMAIL_SEARCH_ON_SERVER_FINISH, + EMAIL_SEARCH_ON_SERVER_FAIL, +}email_search_on_server_status_e; + +typedef enum +{ + EMAIL_MOVE_MAILBOX_ON_IMAP_SERVER_NONE = 0, + EMAIL_MOVE_MAILBOX_ON_IMAP_SERVER_WAITING, + EMAIL_MOVE_MAILBOX_ON_IMAP_SERVER_START, + EMAIL_MOVE_MAILBOX_ON_IMAP_SERVER_FINISH, + EMAIL_MOVE_MAILBOX_ON_IMAP_SERVER_FAIL, +}email_move_mailbox_status_e; + +typedef enum +{ + EMAIL_UPDATE_MAIL_NONE = 0, + EMAIL_UPDATE_MAIL_WAITING, + EMAIL_UPDATE_MAIL_START, + EMAIL_UPDATE_MAIL_FINISH, + EMAIL_UPDATE_MAIL_FAIL, +}email_update_mail_status_e; + +/** +* This enumeration specifies the type of mailbox +*/ +typedef enum +{ + EMAIL_MAILBOX_TYPE_NONE = 0, /**< Unspecified mailbox type*/ + EMAIL_MAILBOX_TYPE_INBOX = 1, /**< Specified inbox type*/ + EMAIL_MAILBOX_TYPE_SENTBOX = 2, /**< Specified sent box type*/ + EMAIL_MAILBOX_TYPE_TRASH = 3, /**< Specified trash type*/ + EMAIL_MAILBOX_TYPE_DRAFT = 4, /**< Specified draft box type*/ + EMAIL_MAILBOX_TYPE_SPAMBOX = 5, /**< Specified spam box type*/ + EMAIL_MAILBOX_TYPE_OUTBOX = 6, /**< Specified outbox type*/ + EMAIL_MAILBOX_TYPE_ALL_EMAILS = 7, /**< Specified all emails type of gmail*/ + 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; + +typedef enum +{ + EMAIL_SYNC_LATEST_MAILS_FIRST = 0, + EMAIL_SYNC_OLDEST_MAILS_FIRST, + EMAIL_SYNC_ALL_MAILBOX_50_MAILS, +} EMAIL_RETRIEVE_MODE; + +/* event type */ +typedef enum +{ + EMAIL_EVENT_NONE = 0, + EMAIL_EVENT_SYNC_HEADER = 1, /* synchronize mail headers with server (network used) */ + EMAIL_EVENT_DOWNLOAD_BODY = 2, /* download mail body from server (network used)*/ + EMAIL_EVENT_DOWNLOAD_ATTACHMENT = 3, /* download mail attachment from server (network used) */ + EMAIL_EVENT_SEND_MAIL = 4, /* send a mail (network used) */ + EMAIL_EVENT_SEND_MAIL_SAVED = 5, /* send all mails in 'outbox' box (network used) */ + EMAIL_EVENT_SYNC_IMAP_MAILBOX = 6, /* download imap mailboxes from server (network used) */ + EMAIL_EVENT_DELETE_MAIL = 7, /* delete mails (network unused) */ + EMAIL_EVENT_DELETE_MAIL_ALL = 8, /* delete all mails (network unused) */ + EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER = 9, /* sync mail flag to server */ + EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER = 10, /* sync a field of flags to server */ + EMAIL_EVENT_SAVE_MAIL = 11, /* Deprecated */ + EMAIL_EVENT_MOVE_MAIL = 12, /* move mails to specific mailbox on server */ + EMAIL_EVENT_CREATE_MAILBOX = 13, + EMAIL_EVENT_UPDATE_MAILBOX = 14, + EMAIL_EVENT_DELETE_MAILBOX = 15, + EMAIL_EVENT_ISSUE_IDLE = 16, + EMAIL_EVENT_SYNC_HEADER_OMA = 17, + EMAIL_EVENT_VALIDATE_ACCOUNT = 18, + EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT = 19, + EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT = 20, + EMAIL_EVENT_SEARCH_ON_SERVER = 21, + EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER = 22, + + EMAIL_EVENT_ADD_MAIL = 10001, /* Deprecated */ + EMAIL_EVENT_UPDATE_MAIL_OLD = 10002, /* Deprecated */ + EMAIL_EVENT_UPDATE_MAIL = 10003, + EMAIL_EVENT_SET_MAIL_SLOT_SIZE = 20000, + EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED = 20001, + +/* EMAIL_EVENT_LOCAL_ACTIVITY, __LOCAL_ACTIVITY_ */ + + EMAIL_EVENT_BULK_PARTIAL_BODY_DOWNLOAD = 20002, /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ supported */ + EMAIL_EVENT_LOCAL_ACTIVITY_SYNC_BULK_PBD = 20003, /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ supported */ + EMAIL_EVENT_GET_PASSWORD_LENGTH = 20004, /* get password length of an account */ +} email_event_type_t; + +/* event statu */ +typedef enum +{ + EMAIL_EVENT_STATUS_UNUSED = 0, + EMAIL_EVENT_STATUS_WAIT, + EMAIL_EVENT_STATUS_STARTED, + EMAIL_EVENT_STATUS_CANCELED, +} email_event_status_type_t; + + +/* sorting_orde */ +typedef enum +{ + EMAIL_SORT_DATETIME_HIGH = 0, + EMAIL_SORT_DATETIME_LOW, + EMAIL_SORT_SENDER_HIGH, + EMAIL_SORT_SENDER_LOW, + EMAIL_SORT_RCPT_HIGH, + EMAIL_SORT_RCPT_LOW, + EMAIL_SORT_SUBJECT_HIGH, + EMAIL_SORT_SUBJECT_LOW, + EMAIL_SORT_PRIORITY_HIGH, + EMAIL_SORT_PRIORITY_LOW, + EMAIL_SORT_ATTACHMENT_HIGH, + EMAIL_SORT_ATTACHMENT_LOW, + EMAIL_SORT_FAVORITE_HIGH, + EMAIL_SORT_FAVORITE_LOW, + EMAIL_SORT_MAILBOX_NAME_HIGH, + EMAIL_SORT_MAILBOX_NAME_LOW, + EMAIL_SORT_FLAGGED_FLAG_HIGH, + EMAIL_SORT_FLAGGED_FLAG_LOW, + EMAIL_SORT_SEEN_FLAG_HIGH, + EMAIL_SORT_SEEN_FLAG_LOW, + EMAIL_SORT_END, +}email_sort_type_t; + +typedef enum +{ + EMAIL_MAILBOX_SORT_BY_NAME_ASC = 0, + EMAIL_MAILBOX_SORT_BY_NAME_DSC, + EMAIL_MAILBOX_SORT_BY_TYPE_ASC, + EMAIL_MAILBOX_SORT_BY_TYPE_DSC, +} email_mailbox_sort_type_t; + + +/** +* This enumeration specifies the priority. +*/ +enum +{ + EMAIL_OPTION_PRIORITY_HIGH = 1, /**< Specifies the high priority.*/ + EMAIL_OPTION_PRIORITY_NORMAL = 3, /**< Specifies the normal priority*/ + EMAIL_OPTION_PRIORITY_LOW = 5, /**< Specifies the low priority.*/ +}; + +/** +* This enumeration specifies the saving save a copy after sending. +*/ +enum +{ + EMAIL_OPTION_KEEP_LOCAL_COPY_OFF = 0, /**< Specifies off the keeping local copy.*/ + EMAIL_OPTION_KEEP_LOCAL_COPY_ON = 1, /**< Specifies on the keeping local copy.*/ +}; + +/** +* This enumeration specifies the request of delivery report. +*/ +enum +{ + EMAIL_OPTION_REQ_DELIVERY_RECEIPT_OFF = 0, /**< Specifies off the requesting delivery receipt.*/ + EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON = 1, /**< Specifies on the requesting delivery receipt.*/ +}; + +/** +* This enumeration specifies the request of read receipt. +*/ +enum +{ + EMAIL_OPTION_REQ_READ_RECEIPT_OFF = 0, /**< Specifies off the requesting read receipt.*/ + EMAIL_OPTION_REQ_READ_RECEIPT_ON = 1, /**< Specifies on the requesting read receipt.*/ +}; + +/** +* This enumeration specifies the blocking of address. +*/ +enum +{ + EMAIL_OPTION_BLOCK_ADDRESS_OFF = 0, /**< Specifies off the blocking by address.*/ + EMAIL_OPTION_BLOCK_ADDRESS_ON = 1, /**< Specifies on the blocking by address.*/ +}; + +/** +* This enumeration specifies the blocking of subject. +*/ +enum +{ + EMAIL_OPTION_BLOCK_SUBJECT_OFF = 0, /**< Specifies off the blocking by subject.*/ + EMAIL_OPTION_BLOCK_SUBJECT_ON = 1, /**< Specifies on the blocking by subject.*/ +}; + +enum +{ + EMAIL_LIST_TYPE_UNREAD = -3, + EMAIL_LIST_TYPE_LOCAL = -2, + EMAIL_LIST_TYPE_THREAD = -1, + EMAIL_LIST_TYPE_NORMAL = 0 +}; + +/** +* This enumeration specifies the mailbox sync type. +*/ +enum +{ + EMAIL_MAILBOX_ALL = -1, /**< All mailboxes.*/ + EMAIL_MAILBOX_FROM_SERVER = 0, /**< Mailboxes from server. */ + EMAIL_MAILBOX_FROM_LOCAL = 1, /**< Mailboxes from local. */ +}; + +typedef enum +{ + APPEND_BODY = 1, + UPDATE_MAILBOX, + UPDATE_ATTACHMENT_INFO, + UPDATE_FLAG, + UPDATE_SAVENAME, + UPDATE_EXTRA_FLAG, + UPDATE_MAIL, + UPDATE_DATETIME, + UPDATE_FROM_CONTACT_INFO, + UPDATE_TO_CONTACT_INFO, + UPDATE_ALL_CONTACT_NAME, + UPDATE_ALL_CONTACT_INFO, + UPDATE_STICKY_EXTRA_FLAG, + UPDATE_PARTIAL_BODY_DOWNLOAD, + UPDATE_MEETING, + UPDATE_SEEN_FLAG_OF_THREAD, +} email_mail_change_type_t; + + +/** +* This enumeration specifies the address type. +*/ +typedef enum +{ + EMAIL_ADDRESS_TYPE_FROM = 1, /**< Specifies the from address.*/ + EMAIL_ADDRESS_TYPE_TO, /**< Specifies the to receipient address.*/ + EMAIL_ADDRESS_TYPE_CC, /**< Specifies the cc receipient address.*/ + EMAIL_ADDRESS_TYPE_BCC, /**< Specifies the bcc receipient address.*/ + EMAIL_ADDRESS_TYPE_REPLY, /**< Specifies the reply receipient address.*/ + EMAIL_ADDRESS_TYPE_RETURN, /**< Specifies the return receipient address.*/ +} email_address_type_t; + +/** + * This enumeration specifies the search type for searching mailbox. + */ +typedef enum +{ + EMAIL_MAILBOX_SEARCH_KEY_TYPE_SUBJECT, /**< The search key is for searching subject.*/ + EMAIL_MAILBOX_SEARCH_KEY_TYPE_FROM, /**< The search key is for searching sender address.*/ + EMAIL_MAILBOX_SEARCH_KEY_TYPE_BODY, /**< The search key is for searching body.*/ + EMAIL_MAILBOX_SEARCH_KEY_TYPE_TO, /**< The search key is for searching recipient address.*/ +} email_mailbox_search_key_t; + +/** + * This enumeration specifies the download status of mail body. + */ + +typedef enum +{ + EMAIL_BODY_DOWNLOAD_STATUS_NONE = 0, + EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED = 1, + EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED = 2, +} email_body_download_status_t; + +/** + * This enumeration specifies the moving type. + */ +typedef enum +{ + EMAIL_MOVED_BY_COMMAND = 0, + EMAIL_MOVED_BY_MOVING_THREAD, + EMAIL_MOVED_AFTER_SENDING, + EMAIL_MOVED_CANCELATION_MAIL +} email_move_type; + +/** + * This enumeration specifies the deletion type. + */ +typedef enum +{ + EMAIL_DELETED_BY_COMMAND = 0, + EMAIL_DELETED_BY_OVERFLOW, + EMAIL_DELETED_BY_DELETING_THREAD, + EMAIL_DELETED_BY_MOVING_TO_OTHER_ACCOUNT, + EMAIL_DELETED_AFTER_SENDING, + EMAIL_DELETED_FROM_SERVER, +} email_delete_type; + +/** + * This enumeration specifies the status field type. + */ +typedef enum +{ + EMAIL_FLAGS_SEEN_FIELD = 0, + EMAIL_FLAGS_DELETED_FIELD, + EMAIL_FLAGS_FLAGGED_FIELD, + EMAIL_FLAGS_ANSWERED_FIELD, + EMAIL_FLAGS_RECENT_FIELD, + EMAIL_FLAGS_DRAFT_FIELD, + EMAIL_FLAGS_FORWARDED_FIELD, + EMAIL_FLAGS_FIELD_COUNT, +} email_flags_field_type; + +typedef enum { + EMAIL_FLAG_NONE = 0, + EMAIL_FLAG_FLAGED = 1, + EMAIL_FLAG_TASK_STATUS_CLEAR = 2, + EMAIL_FLAG_TASK_STATUS_ACTIVE = 3, + EMAIL_FLAG_TASK_STATUS_COMPLETE = 4, +} email_flagged_type; + +typedef enum { + EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO = 1, /* integer type */ + EMAIL_SEARCH_FILTER_TYPE_UID = 2, /* integer type */ + EMAIL_SEARCH_FILTER_TYPE_BCC = 7, /* string type */ + EMAIL_SEARCH_FILTER_TYPE_CC = 9, /* string type */ + EMAIL_SEARCH_FILTER_TYPE_FROM = 10, /* string type */ + EMAIL_SEARCH_FILTER_TYPE_KEYWORD = 11, /* string type */ + EMAIL_SEARCH_FILTER_TYPE_SUBJECT = 13, /* string type */ + EMAIL_SEARCH_FILTER_TYPE_TO = 15, /* string type */ + EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER = 16, /* integer type */ + EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER = 17, /* integer type */ + EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE = 20, /* time type */ + EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON = 21, /* time type */ + EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE = 22, /* time type */ + EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED = 26, /* integer type */ + EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED = 28, /* integer type */ + EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT = 30, /* integer type */ + EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED = 32, /* integer type */ + EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT = 34, /* integer type */ + EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN = 36, /* integer type */ + EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID = 43, /* string type */ +} email_search_filter_type; + +typedef enum { + EMAIL_DRM_TYPE_NONE = 0, + EMAIL_DRM_TYPE_OBJECT = 1, + EMAIL_DRM_TYPE_RIGHT = 2, + EMAIL_DRM_TYPE_DCF = 3 +} email_drm_type; + +typedef enum { + EMAIL_DRM_METHOD_NONE = 0, + EMAIL_DRM_METHOD_FL = 1, + EMAIL_DRM_METHOD_CD = 2, + EMAIL_DRM_METHOD_SSD = 3, + EMAIL_DRM_METHOD_SD = 4 +} email_drm_method; + +typedef enum { + EMAIL_CANCELED_BY_USER = 0, + EMAIL_CANCELED_BY_MDM = 1, +} email_cancelation_type; + +typedef enum { + EMAIL_MAIL_ATTRIBUTE_MAIL_ID = 0, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID = 1, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_MAILBOX_ID = 2, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME = 3, /* string type */ + EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE = 4, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_SUBJECT = 5, /* string type */ + EMAIL_MAIL_ATTRIBUTE_DATE_TIME = 6, /* datetime type */ + EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_STATUS = 7, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME = 8, /* string type */ + EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID = 9, /* string type */ + EMAIL_MAIL_ATTRIBUTE_MESSAGE_ID = 10, /* string type */ + EMAIL_MAIL_ATTRIBUTE_FROM = 11, /* string type */ + EMAIL_MAIL_ATTRIBUTE_TO = 12, /* string type */ + EMAIL_MAIL_ATTRIBUTE_CC = 13, /* string type */ + EMAIL_MAIL_ATTRIBUTE_BCC = 14, /* string type */ + EMAIL_MAIL_ATTRIBUTE_BODY_DOWNLOAD_STATUS = 15, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN = 16, /* string type */ + EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML = 17, /* string type */ + EMAIL_MAIL_ATTRIBUTE_FILE_SIZE = 18, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_FLAGS_SEEN_FIELD = 19, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD = 20, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_FLAGS_FLAGGED_FIELD = 21, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_FLAGS_ANSWERED_FIELD = 22, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_FLAGS_RECENT_FIELD = 23, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_FLAGS_DRAFT_FIELD = 24, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_FLAGS_FORWARDED_FIELD = 25, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_DRM_STATUS = 26, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_PRIORITY = 27, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_SAVE_STATUS = 28, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_LOCK_STATUS = 29, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_REPORT_STATUS = 30, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_ATTACHMENT_COUNT = 31, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_INLINE_CONTENT_COUNT = 32, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_THREAD_ID = 33, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_THREAD_ITEM_COUNT = 34, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT = 35, /* string type */ + EMAIL_MAIL_ATTRIBUTE_MEETING_REQUEST_STATUS = 36, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_MESSAGE_CLASS = 37, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_DIGEST_TYPE = 38, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_SMIME_TYPE = 39, /* integer type */ + EMAIL_MAIL_ATTRIBUTE_END +} email_mail_attribute_type; + +typedef enum { + EMAIL_ADD_MY_ADDRESS_OPTION_DO_NOT_ADD = 0, + EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_CC = 1, + EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_BCC = 2, +} email_add_my_address_option_type; + +typedef enum { + EMAIL_MESSAGE_CLASS_UNSPECIFIED, + EMAIL_MESSAGE_CLASS_UNKNOWN, + EMAIL_MESSAGE_CLASS_NOTE, + EMAIL_MESSAGE_CLASS_NOTE_RULES_OF_TEMPLATE_MICROSOFT, + EMAIL_MESSAGE_CLASS_NOTE_SMIME, + EMAIL_MESSAGE_CLASS_NOTE_SMIME_MULTIPART_SIGNED, + EMAIL_MESSAGE_CLASS_NOTIFICATION_MEETING, + EMAIL_MESSAGE_CLASS_OCTEL_VOICE, + EMAIL_MESSAGE_CLASS_SCHEDULE_MEETING_REQUEST, + EMAIL_MESSAGE_CLASS_SCHEDULE_MEETING_CANCELED, + EMAIL_MESSAGE_CLASS_SCHEDULE_MEETING_RESP_POS, + EMAIL_MESSAGE_CLASS_SCHEDULE_MEETING_RESP_TENT, + EMAIL_MESSAGE_CLASS_SCHEDULE_MEETING_RESP_NEG, + EMAIL_MESSAGE_CLASS_POST, + EMAIL_MESSAGE_CLASS_INFO_PATH_FORM, + EMAIL_MESSAGE_CLASS_VOICE_NOTES, + EMAIL_MESSAGE_CLASS_SHARING, + EMAIL_MESSAGE_CLASS_NOTE_EXCHANGE_ACTIVE_SYNC_REMOTE_WIPE_CONFIRMATION, + EMAIL_MESSAGE_CLASS_VOICE_MAIL, + EMAIL_MESSAGE_CLASS_REPORT_DELIVERY_RECEIPT = 0x80000000, + EMAIL_MESSAGE_CLASS_REPORT_NON_DELIVERY_RECEIPT = 0x40000000, + EMAIL_MESSAGE_CLASS_REPORT_READ_REPORT = 0x20000000, + EMAIL_MESSAGE_CLASS_REPORT_NOT_READ_REPORT = 0x10000000 +} email_message_class; + +typedef enum{ + EMAIL_SMIME_NONE = 0, /* Not use smime */ + EMAIL_SMIME_SIGNED, + EMAIL_SMIME_ENCRYPTED, + EMAIL_SMIME_SIGNED_AND_ENCRYPTED, +} email_smime_type; + +typedef enum { + CIPHER_TYPE_DES3 = 0, + CIPHER_TYPE_DES, + CIPHER_TYPE_RC2_128, + CIPHER_TYPE_RC2_64, + CIPHER_TYPE_RC2_40, +} email_cipher_type; + +typedef enum { + DIGEST_TYPE_SHA1 = 0, + DIGEST_TYPE_MD5, +} email_digest_type; + +/*****************************************************************************/ +/* Data Structures */ +/*****************************************************************************/ + +/** + * This structure is used to save mail time. + */ +typedef struct +{ + unsigned short year; /**< Specifies the Year.*/ + unsigned short month; /**< Specifies the Month.*/ + unsigned short day; /**< Specifies the Day.*/ + unsigned short hour; /**< Specifies the Hour.*/ + unsigned short minute; /**< Specifies the Minute.*/ + unsigned short second; /**< Specifies the Second.*/ +} email_datetime_t DEPRECATED; + +/** + * This structure is used to save the options. + */ +typedef struct +{ + email_mail_priority_t priority; /**< Specifies the prority. 1=high 3=normal 5=low.*/ + int keep_local_copy; /**< Specifies the saving save a copy after sending.*/ + int req_delivery_receipt; /**< Specifies the request of delivery report. 0=off 1=on*/ + int req_read_receipt; /**< Specifies the request of read receipt. 0=off 1=on*/ + int download_limit; /**< Specifies the limit of size for downloading.*/ + int block_address; /**< Specifies the blocking of address. 0=off 1=on*/ + int block_subject; /**< Specifies the blocking of subject. 0=off 1=on*/ + char *display_name_from; /**< Specifies the display name of from.*/ + int reply_with_body; /**< Specifies the replying with body 0=off 1=on*/ + int forward_with_files; /**< Specifies the fowarding with files 0=off 1=on*/ + int add_myname_card; /**< Specifies the adding name card 0=off 1=on*/ + int add_signature; /**< Specifies the adding signature 0=off 1=on*/ + char *signature; /**< Specifies the signature*/ + email_add_my_address_option_type add_my_address_to_bcc; /**< Specifies whether cc or bcc field should be always filled with my address. */ +} email_option_t; + +/** + * This structure is used to save the information of email account. + */ +typedef struct +{ + /* General account information */ + int account_id; /**< Account id */ + char *account_name; /**< Account name */ + int account_svc_id; /**< AccountSvc priv data: Specifies id from account-svc */ + int sync_status; /**< Sync Status. SYNC_STATUS_FINISHED, SYNC_STATUS_SYNCING, SYNC_STATUS_HAVE_NEW_MAILS */ + int sync_disabled; /**< If this attriube is set as true, email-service will not synchronize this account. */ + int default_mail_slot_size; + char *logo_icon_path; /**< account logo icon (used by account svc and email app) */ + void *user_data; /**< binary user data */ + int user_data_length; /**< user data length */ + + /* User information */ + char *user_display_name; /**< User's display */ + char *user_email_address; /**< User's email address */ + char *reply_to_address; /**< Email address for reply */ + char *return_address; /**< Email address for error from server*/ + + /* Configuration for incoming server */ + email_account_server_t incoming_server_type; /**< Incoming server type */ + char *incoming_server_address; /**< Incoming server address */ + int incoming_server_port_number; /**< Incoming server port number */ + char *incoming_server_user_name; /**< Incoming server user name */ + char *incoming_server_password; /**< Incoming server password */ + int incoming_server_secure_connection; /**< Does incoming server requires secured connection? */ + + /* Options for incoming server */ + email_imap4_retrieval_mode_t retrieval_mode; /**< Retrieval mode : EMAIL_IMAP4_RETRIEVAL_MODE_NEW or EMAIL_IMAP4_RETRIEVAL_MODE_ALL */ + int keep_mails_on_pop_server_after_download; /**< Keep mails on POP server after download */ + int check_interval; /**< Specifies the interval for checking new mail periodically */ + int auto_download_size; /**< Specifies the size for auto download in bytes. -1 means entire mails body */ + + /* Configuration for outgoing server */ + email_account_server_t outgoing_server_type; /**< Outgoing server type */ + char *outgoing_server_address; /**< Outgoing server address */ + int outgoing_server_port_number; /**< Outgoing server port number */ + char *outgoing_server_user_name; /**< Outgoing server user name */ + char *outgoing_server_password; /**< Outgoing server password */ + int outgoing_server_secure_connection; /**< Does outgoing server requires secured connection? */ + int outgoing_server_need_authentication; /**< Does outgoing server requires authentication? */ + int outgoing_server_use_same_authenticator; /**< Use same authenticator for outgoing server */ + + + /* Options for outgoing server */ + email_option_t options; + + /* Authentication Options */ + int pop_before_smtp; /**< POP before SMTP Authentication */ + int incoming_server_requires_apop; /**< APOP authentication */ + + /* S/MIME Options */ + email_smime_type smime_type; /**< Sepeifies the smime type 0=Normal 1=Clear signed 2=encrypted 3=Signed + encrypted */ + 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*/ +} email_account_t; + +/** + * This structure is used to save the information of certificiate + */ + +typedef struct +{ + int certificate_id; + int issue_year; + int issue_month; + int issue_day; + int expiration_year; + int expiration_month; + int expiration_day; + char *issue_organization_name; + char *email_address; + char *subject_str; + char *filepath; +} email_certificate_t; + +/** + * This structure is used to save the information of email server. + */ + +typedef struct +{ + int configuration_id; /**< Specifies the id of configuration.*/ + email_account_server_t protocol_type; /**< Specifies the type of configuration.*/ + char *server_addr; /**< Specifies the address of configuration.*/ + int port_number; /**< Specifies the port number of configuration.*/ + int security_type; /**< Specifies the security such as SSL.*/ + int auth_type; /**< Specifies the authentication type of configuration.*/ +} email_protocol_config_t; + +typedef struct +{ + char *service_name; /**< Specifies the name of service.*/ + int authname_format; /**< Specifies the type of user name for authentication.*/ + int protocol_conf_count; /**< Specifies count of protocol configurations.*/ + email_protocol_config_t *protocol_config_array; /**< Specifies array of protocol configurations.*/ +} email_server_info_t; + +typedef struct +{ + int mailbox_type; + char mailbox_name[MAILBOX_NAME_LENGTH]; +} email_mailbox_type_item_t; + +/** + * This structure is contains the Mail information. + */ + +typedef struct +{ + int mail_id; /**< Specifies the Mail ID.*/ + int account_id; /**< Specifies the Account ID.*/ + int mailbox_id; /**< Specifies the Mailbox ID.*/ + email_mailbox_type_e mailbox_type; /**< Specifies the mailbox type of the mail. */ + char *subject; /**< Specifies the subject.*/ + time_t date_time; /**< Specifies the Date time.*/ + int server_mail_status; /**< Specifies the Whether sever mail or not.*/ + char *server_mailbox_name; /**< Specifies the server mailbox.*/ + char *server_mail_id; /**< Specifies the Server Mail ID.*/ + char *message_id; /**< Specifies the message id */ + char *full_address_from; /**< Specifies the From Addr.*/ + char *full_address_reply; /**< Specifies the Reply to addr */ + char *full_address_to; /**< Specifies the To addr.*/ + char *full_address_cc; /**< Specifies the CC addr.*/ + char *full_address_bcc; /**< Specifies the BCC addr*/ + char *full_address_return; /**< Specifies the return Path*/ + char *email_address_sender; /**< Specifies the email address of sender.*/ + char *email_address_recipient; /**< Specifies the email address of recipients.*/ + char *alias_sender; /**< Specifies the alias of sender. */ + char *alias_recipient; /**< Specifies the alias of recipients. */ + int body_download_status; /**< Specifies the Text donwloaded or not.*/ + char *file_path_plain; /**< Specifies the path of text mail body.*/ + char *file_path_html; /**< Specifies the path of HTML mail body.*/ + char *file_path_mime_entity; /**< Specifies the path of mime entity. */ + int mail_size; /**< Specifies the Mail Size.*/ + char flags_seen_field; /**< Specifies the seen flags*/ + char flags_deleted_field; /**< Specifies the deleted flags*/ + char flags_flagged_field; /**< Specifies the flagged flags*/ + char flags_answered_field; /**< Specifies the answered flags*/ + char flags_recent_field; /**< Specifies the recent flags*/ + char flags_draft_field; /**< Specifies the draft flags*/ + char flags_forwarded_field; /**< Specifies the forwarded flags*/ + int DRM_status; /**< Has the mail DRM content? (1 : true, 0 : false) */ + email_mail_priority_t priority; /**< Specifies the priority of the mail.*/ + int save_status; /**< Specifies the save status*/ + int lock_status; /**< Specifies the Locked*/ + int report_status; /**< Specifies the Mail Report.*/ + int attachment_count; /**< Specifies the attachment count. */ + int inline_content_count; /**< Specifies the inline content count. */ + int thread_id; /**< Specifies the thread id for thread view. */ + int thread_item_count; /**< Specifies the item count of specific thread. */ + char *preview_text; /**< Specifies the preview body. */ + int meeting_request_status; /**< Specifies the status of meeting request. */ + email_message_class message_class; + email_digest_type digest_type; /**< Sepeifies the digest algorithm*/ + email_smime_type smime_type; /**< Specifies the smime type. */ +} email_mail_data_t; + +/** + * This structure is contains information for displaying mail list. + */ +typedef struct +{ + int mail_id; /**< Specifies the mail id.*/ + int account_id; /**< Specifies the account id.*/ + int mailbox_id; /**< Specifies the mailbox id.*/ + char from[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the from display name.*/ + char from_email_address[MAX_EMAIL_ADDRESS_LENGTH]; /**< Specifies the from email address.*/ + char recipients[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the recipients display name.*/ + char subject[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the subject.*/ + int is_text_downloaded; /**< Specifies the text donwloaded or not.*/ + time_t date_time; /**< Specifies the date time.*/ + char flags_seen_field; /**< Specifies the seen flags*/ + char flags_deleted_field; /**< Specifies the deleted flags*/ + char flags_flagged_field; /**< Specifies the flagged flags*/ + char flags_answered_field; /**< Specifies the answered flags*/ + char flags_recent_field; /**< Specifies the recent flags*/ + char flags_draft_field; /**< Specifies the draft flags*/ + char flags_forwarded_field; /**< Specifies the forwarded flags*/ + int priority; /**< Specifies the priority of Mails.*/ + int save_status; /**< Specifies the save status*/ + int is_locked; /**< Specifies the locked*/ + int is_report_mail; /**< Specifies the mail report.*/ + int recipients_count; /**< Specifies the number of to Recipients*/ + int has_attachment; /**< the mail has attachments or not[ 0: none, 1: over one] */ + int has_drm_attachment; /**< the mail has drm attachment or not*/ + char previewBodyText[MAX_PREVIEW_TEXT_LENGTH]; /**< text for preview body*/ + int thread_id; /**< thread id for thread view*/ + int thread_item_count; /**< item count of specific thread */ + int is_meeting_request; /**< Whether the mail is a meeting request or not */ + int message_class; /**< Specifies the message class */ + int smime_type; /**< Specifies the smime type */ +} email_mail_list_item_t; + +/** + * This structure is used to save the filtering structure. + */ +typedef struct +{ + int account_id; /**< Specifies the account ID.*/ + int filter_id; /**< Specifies the filtering ID.*/ + email_rule_type_t type; /**< Specifies the filtering type.*/ + char *value; /**< Specifies the filtering value.*/ + email_rule_action_t faction; /**< Specifies the action type for filtering.*/ + int target_mailbox_id; /**< Specifies the mail box if action type means move.*/ + int flag1; /**< Specifies the activation.*/ + int flag2; /**< Reserved.*/ +} email_rule_t; + +/** + * This structure is used to save the information of mail flag. + */ +typedef struct +{ + unsigned int seen : 1; /**< Specifies the read email.*/ + unsigned int deleted : 1; /**< Reserved.*/ + unsigned int flagged : 1; /**< Specifies the flagged email.*/ + unsigned int answered : 1; /**< Reserved.*/ + unsigned int recent : 1; /**< Reserved.*/ + unsigned int draft : 1; /**< Specifies the draft email.*/ + unsigned int has_attachment : 1; /**< Reserved.*/ + unsigned int forwarded : 1; /**< Reserved.*/ + unsigned int sticky : 1; /**< Sticky flagged mails cannot be deleted */ +} email_mail_flag_t /* DEPRECATED */; + + +/** + * This structure is used to save the information of mail extra flag. + */ +typedef struct +{ + unsigned int priority : 3; /**< Specifies the mail priority. + The value is greater than or equal to EMAIL_MAIL_PRIORITY_HIGH. + The value is less than or eqult to EMAIL_MAIL_PRIORITY_LOW.*/ + unsigned int status : 4; /**< Specifies the mail status. + The value is a value of enumeration email_mail_status_t.*/ + unsigned int noti : 1; /**< Specifies the notified mail.*/ + unsigned int lock : 1; /**< Specifies the locked mail.*/ + unsigned int report : 2; /**< Specifies the MDN/DSN mail. The value is a value of enumeration email_mail_report_t.*/ + unsigned int drm : 1; /**< Specifies the drm mail.*/ + unsigned int text_download_yn : 2; /**< body download y/n*/ +} email_extra_flag_t /* DEPRECATED */; + +/** + * This structure is used to save the information of attachment. + */ +typedef struct +{ + int attachment_id; + char *attachment_name; + char *attachment_path; + int attachment_size; + int mail_id; + int account_id; + char mailbox_id; + int save_status; + int drm_status; + int inline_content_status; + char *attachment_mime_type; /**< Specifies the context mime type.*/ +} email_attachment_data_t; + +typedef struct +{ + int offset_from_GMT; + char standard_name[32]; + struct tm standard_time_start_date; + int standard_bias; + char daylight_name[32]; + struct tm daylight_time_start_date; + int daylight_bias; +} email_time_zone_t; + +typedef struct +{ + int mail_id; /**< Specifies the mail id of meeting request on DB. This is the primary key. */ + email_meeting_response_t meeting_response; /**< Specifies the meeting response. */ + struct tm start_time; + struct tm end_time; + char *location; /**< Specifies the location of meeting. Maximum length of this string is 32768 */ + char *global_object_id; /**< Specifies the object id. */ + email_time_zone_t time_zone; +} email_meeting_request_t; + +/** + * This structure is used to save the informatioin of sender list with unread/total mail counts + */ +typedef struct +{ + char *address; /**< Specifies the address of a sender.*/ + char *display_name; /**< Specifies a display name. This may be one of contact name, alias in original mail and email address of sender. (Priority order : contact name, alias, email address) */ + int unread_count; /**< Specifies the number of unread mails received from sender address*/ + int total_count; /**< Specifies the total number of mails which are received from sender address*/ +} email_sender_list_t /* DEPRECATED */; + + +/** + * This structure is used to save the information of mailbox. + */ +typedef struct +{ + int mailbox_id; /**< Unique id on mailbox table.*/ + char *mailbox_name; /**< Specifies the path of mailbox.*/ + email_mailbox_type_e mailbox_type; /**< Specifies the type of mailbox */ + char *alias; /**< Specifies the display name of mailbox.*/ + int unread_count; /**< Specifies the unread mail count in the mailbox.*/ + int total_mail_count_on_local; /**< Specifies the total number of mails in the mailbox in the local DB.*/ + int total_mail_count_on_server; /**< Specifies the total number of mails in the mailbox in the mail server.*/ + int local; /**< Specifies the local mailbox.*/ + int account_id; /**< Specifies the account ID for mailbox.*/ + int mail_slot_size; /**< Specifies how many mails can be stored in local mailbox.*/ + int no_select; /**< Specifies the 'no_select' attribute from xlist.*/ + time_t last_sync_time; +} email_mailbox_t; + +typedef struct +{ + email_address_type_t address_type; + char *address; + char *display_name; + int storage_type; + int contact_id; +} email_address_info_t; + +typedef struct +{ + GList *from; + GList *to; + GList *cc; + GList *bcc; +} email_address_info_list_t; + +typedef struct +{ + int address_type; /* type of mail (sender : 0, recipient : 1)*/ + int address_count; /* The number of email addresse */ + char **address_list; /* strings of email addresse */ +} email_email_address_list_t; + + +typedef struct _email_search_filter_t { + email_search_filter_type search_filter_type; /* type of search filter */ + union { + int integer_type_key_value; + time_t time_type_key_value; + char *string_type_key_value; + } search_filter_key_value; +} email_search_filter_t; + +typedef enum { + EMAIL_LIST_FILTER_RULE_EQUAL = 0, + EMAIL_LIST_FILTER_RULE_NOT_EQUAL = 1, + EMAIL_LIST_FILTER_RULE_LESS_THAN = 2, + EMAIL_LIST_FILTER_RULE_GREATER_THAN = 3, + EMAIL_LIST_FILTER_RULE_LESS_THAN_OR_EQUAL = 4, + EMAIL_LIST_FILTER_RULE_GREATER_THAN_OR_EQUAL = 5, + EMAIL_LIST_FILTER_RULE_INCLUDE = 6, + EMAIL_LIST_FILTER_RULE_IN = 7, + EMAIL_LIST_FILTER_RULE_NOT_IN = 8 +} email_list_filter_rule_type_t; + +typedef enum { + EMAIL_CASE_SENSITIVE = 0, + EMAIL_CASE_INSENSITIVE = 1, +} email_list_filter_case_sensitivity_t; + +typedef struct { + email_list_filter_rule_type_t rule_type; + email_mail_attribute_type target_attribute; + + union { + int integer_type_value; + char *string_type_value; + time_t datetime_type_value; + } key_value; + + email_list_filter_case_sensitivity_t case_sensitivity; +} email_list_filter_rule_t; + +typedef enum { + EMAIL_LIST_FILTER_ITEM_RULE = 0, + EMAIL_LIST_FILTER_ITEM_OPERATOR = 1, +} email_list_filter_item_type_t; + +typedef enum { + EMAIL_LIST_FILTER_OPERATOR_AND = 0, + EMAIL_LIST_FILTER_OPERATOR_OR = 1, + EMAIL_LIST_FILTER_OPERATOR_LEFT_PARENTHESIS = 2, + EMAIL_LIST_FILTER_OPERATOR_RIGHT_PARENTHESIS = 3 +} email_list_filter_operator_type_t; + +typedef struct { + email_list_filter_item_type_t list_filter_item_type; + + union { + email_list_filter_rule_t rule; + email_list_filter_operator_type_t operator_type; + } list_filter_item; + +} email_list_filter_t; + +typedef enum { + EMAIL_SORT_ORDER_ASCEND = 0, + EMAIL_SORT_ORDER_DESCEND = 1 +} email_list_filter_sort_order_t; + +typedef struct { + email_mail_attribute_type target_attribute; + bool force_boolean_check; + email_list_filter_sort_order_t sort_order; +} email_list_sorting_rule_t; + +/*****************************************************************************/ +/* For Active Sync */ +/*****************************************************************************/ + +#define VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE "db/email_handle/active_sync_handle" +#define EMAIL_ACTIVE_SYNC_NOTI "User.Email.ActiveSync" + +typedef enum +{ + ACTIVE_SYNC_NOTI_SEND_MAIL, /* a sending notification to ASE (active sync engine */ + ACTIVE_SYNC_NOTI_SEND_SAVED, /* a sending notification to ASE (active sync engine), All saved mails should be sent */ + ACTIVE_SYNC_NOTI_SEND_REPORT, /* a sending notification to ASE (active sync engine), report should be sen */ + ACTIVE_SYNC_NOTI_SYNC_HEADER, /* a sync header - download mails from server. */ + /* It is depended on account/s flag1 field whether it excutes downloading header only or downloading header + body */ + /* downloading option : 0 is subject only, 1 is text body, 2 is normal */ + ACTIVE_SYNC_NOTI_DOWNLOAD_BODY, /* a downloading body notification to AS */ + ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT, /* a downloading attachment notification to AS */ + ACTIVE_SYNC_NOTI_VALIDATE_ACCOUNT, /* a account validating notification to AS */ + ACTIVE_SYNC_NOTI_CANCEL_JOB, /* a cancling job notification to AS */ + ACTIVE_SYNC_NOTI_SEARCH_ON_SERVER, /* a searching on server notification to AS */ + ACTIVE_SYNC_NOTI_CLEAR_RESULT_OF_SEARCH_ON_SERVER, /* a notification for clearing result of search on server to AS */ + ACTIVE_SYNC_NOTI_EXPUNGE_MAILS_DELETED_FLAGGED, /* a notification to expunge deleted flagged mails */ + ACTIVE_SYNC_NOTI_RESOLVE_RECIPIENT, /* a notification to get the resolve recipients */ + ACTIVE_SYNC_NOTI_VALIDATE_CERTIFICATE, /* a notification to validate certificate */ + ACTIVE_SYNC_NOTI_ADD_MAILBOX, /* a notification to add mailbox */ + ACTIVE_SYNC_NOTI_RENAME_MAILBOX, /* a notification to rename mailbox */ + ACTIVE_SYNC_NOTI_DELETE_MAILBOX, /* a notification to delete mailbox */ +} eactivesync_noti_t; + +typedef union +{ + struct _send_mail + { + int handle; + int account_id; + int mail_id; + email_option_t options; + } send_mail; + + struct _send_mail_saved + {/* not defined ye */ + int handle; + int account_id; + } send_mail_saved; + + struct _send_report + {/* not defined ye */ + int handle; + int account_id; + } send_report; + + struct _sync_header + { + int handle; + int account_id; + int mailbox_id; + } sync_header; + + struct _download_body + { + int handle; + int account_id; + int mail_id; + int with_attachment; /* 0: without attachments, 1: with attachment */ + } download_body; + + struct _download_attachment + { + int handle; + int account_id; + int mail_id; + int attachment_order; + } download_attachment; + + struct _cancel_job + { + int account_id; + int handle; /* job handle to be canceled. this value is issued by email-service. */ + int cancel_type; + } cancel_job; + + struct _validate_account + {/* not defined yet */ + int handle; + int account_id; + } validate_account; + + struct _search_mail_on_server + { + int handle; + int account_id; + int mailbox_id; + email_search_filter_t *search_filter_list; + int search_filter_count; + } search_mail_on_server; + + struct _clear_result_of_search_mail_on_server + { + int handle; + int account_id; + } clear_result_of_search_mail_on_server; + + struct _expunge_mails_deleted_flagged + { + int handle; + int mailbox_id; + int on_server; + } expunge_mails_deleted_flagged; + + struct _get_resolve_recipients + { + int handle; + int account_id; + char *email_address; + } get_resolve_recipients; + + struct _validate_certificate + { + int handle; + int account_id; + char *email_address; + } validate_certificate; + + struct _add_mailbox + { + int handle; + int account_id; + char *mailbox_path; + char *mailbox_alias; + } add_mailbox; + + struct _rename_mailbox + { + int handle; + int account_id; + int mailbox_id; + char *mailbox_name; + char *mailbox_alias; + } rename_mailbox; + + struct _delete_mailbox + { + int handle; + int account_id; + int mailbox_id; + } delete_mailbox; + +} ASNotiData; + + +/* types for noti string */ +typedef enum +{ + EMAIL_CONVERT_STRUCT_TYPE_MAIL_LIST_ITEM, /** specifies email_mail_list_t */ +} email_convert_struct_type_e; + +#ifdef __cplusplus +} +#endif + +/** +* @} @} +*/ + +#endif /* __EMAIL_TYPES_H__ */ diff --git a/email-common-use/include/email-utilities.h b/email-common-use/include/email-utilities.h index 8f63cc3..87e7d5b 100755 --- a/email-common-use/include/email-utilities.h +++ b/email-common-use/include/email-utilities.h @@ -1,64 +1,72 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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-utilities.h - * - * Created on: 2012. 3. 6. - * Author: kyuho.jo@samsung.com - */ - -#ifndef __EMAIL_UTILITIES_H__ -#define __EMAIL_UTILITIES_H__ - -#include "email-types.h" -#include "email-internal-types.h" -#include "email-debug-log.h" -#include "email-storage.h" - -INTERNAL_FUNC void* em_malloc(unsigned len); -INTERNAL_FUNC char* em_trim_left(char *str); -INTERNAL_FUNC char* em_trim_right(char *str); -INTERNAL_FUNC char* em_upper_string(char *str); -INTERNAL_FUNC char* em_lower_string(char *str); -INTERNAL_FUNC int em_upper_path(char *path); - -INTERNAL_FUNC void em_skip_whitespace(char *addr_str , char **pAddr); -INTERNAL_FUNC char* em_skip_whitespace_without_strdup(char *source_string); -INTERNAL_FUNC char* em_replace_string(char *source_string, char *old_string, char *new_string); -INTERNAL_FUNC void em_flush_memory(); -INTERNAL_FUNC char* em_get_extension_from_file_path(char *source_file_path, int *err_code); -INTERNAL_FUNC int em_get_encoding_type_from_file_path(const char *input_file_path, char **output_encoding_type); -INTERNAL_FUNC int em_get_content_type_from_extension_string(const char *extension_string, int *err_code); - -INTERNAL_FUNC int em_verify_email_address(char *address, int without_bracket, int *err_code); -INTERNAL_FUNC int em_verify_email_address_of_mail_data(emf_mail_data_t *mail_data, int without_bracket, int *err_code); -INTERNAL_FUNC int em_verify_email_address_of_mail_tbl(emstorage_mail_tbl_t *input_mail_tbl, int input_without_bracket); - -INTERNAL_FUNC int em_find_pos_stripped_subject_for_thread_view(char *subject, char *stripped_subject); -INTERNAL_FUNC int em_find_tag_for_thread_view(char *subject, int *result); - -INTERNAL_FUNC int em_encode_base64(char *src, unsigned long src_len, char **enc, unsigned long* enc_len, int *err_code); -INTERNAL_FUNC int em_decode_base64(unsigned char *enc_text, unsigned long enc_len, char **dec_text, unsigned long* dec_len, int *err_code); - -extern char* strcasestr(__const char *__haystack, __const char *__needle) __THROW __attribute_pure__ __nonnull ((1, 2)); - -#endif /* __EMAIL_UTILITIES_H__ */ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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-utilities.h + * + * Created on: 2012. 3. 6. + * Author: kyuho.jo@samsung.com + */ + +#ifndef __EMAIL_UTILITIES_H__ +#define __EMAIL_UTILITIES_H__ + +#include "email-types.h" +#include "email-internal-types.h" +#include "email-debug-log.h" +#include "email-storage.h" + +INTERNAL_FUNC void* em_malloc(int len); +INTERNAL_FUNC void* em_memdup(void* src, int len); +INTERNAL_FUNC char* em_trim_left(char *str); +INTERNAL_FUNC char* em_trim_right(char *str); +INTERNAL_FUNC char* em_upper_string(char *str); +INTERNAL_FUNC char* em_lower_string(char *str); +INTERNAL_FUNC int em_upper_path(char *path); + +INTERNAL_FUNC void em_skip_whitespace(char *addr_str , char **pAddr); +INTERNAL_FUNC char* em_skip_whitespace_without_strdup(char *source_string); +INTERNAL_FUNC char* em_replace_all_string(char *source_string, char *old_string, char *new_string); +INTERNAL_FUNC char* em_replace_string(char *source_string, char *old_string, char *new_string); +INTERNAL_FUNC void em_flush_memory(); +INTERNAL_FUNC int em_get_file_name_and_extension_from_file_path(char *input_source_file_path, char **output_file_name, char **output_extention); +INTERNAL_FUNC char* em_get_extension_from_file_path(char *source_file_path, int *err_code); +INTERNAL_FUNC int em_get_encoding_type_from_file_path(const char *input_file_path, char **output_encoding_type); +INTERNAL_FUNC int em_get_content_type_from_extension_string(const char *extension_string, int *err_code); + +INTERNAL_FUNC int em_verify_email_address(char *address, int without_bracket, int *err_code); +INTERNAL_FUNC int em_verify_email_address_of_mail_data(email_mail_data_t *mail_data, int without_bracket, int *err_code); +INTERNAL_FUNC int em_verify_email_address_of_mail_tbl(emstorage_mail_tbl_t *input_mail_tbl, int input_without_bracket); + +INTERNAL_FUNC int em_find_pos_stripped_subject_for_thread_view(char *subject, char *stripped_subject); +INTERNAL_FUNC int em_find_tag_for_thread_view(char *subject, int *result); + +INTERNAL_FUNC int em_encode_base64(char *src, unsigned long src_len, char **enc, unsigned long* enc_len, int *err_code); +INTERNAL_FUNC int em_decode_base64(unsigned char *enc_text, unsigned long enc_len, char **dec_text, unsigned long* dec_len, int *err_code); + +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_handle_for_activesync(int *handle, int *error); +INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNotiData *data); + +#endif /* __EMAIL_UTILITIES_H__ */ diff --git a/email-common-use/include/tpl.h b/email-common-use/include/tpl.h new file mode 100644 index 0000000..e23953b --- /dev/null +++ b/email-common-use/include/tpl.h @@ -0,0 +1,133 @@ +/* +Copyright (c) 2005-2010, Troy D. Hanson http://tpl.sourceforge.net +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef TPL_H +#define TPL_H + +#include /* size_t */ + +#ifdef __INTEL_COMPILER +#include +#endif /* Intel Compiler efficient memcpy etc */ + +#ifdef _MSC_VER +typedef unsigned int uint32_t; +#else +#include /* uint32_t */ +#endif + +#if defined __cplusplus +extern "C" { +#endif + +#ifdef _WIN32 +#ifdef TPL_EXPORTS +#define TPL_API __declspec(dllexport) +#else /* */ +#ifdef TPL_NOLIB +#define TPL_API +#else +#define TPL_API __declspec(dllimport) +#endif /* TPL_NOLIB */ +#endif /* TPL_EXPORTS*/ +#else +#define TPL_API +#endif + +/* bit flags (external) */ +#define TPL_FILE (1 << 0) +#define TPL_MEM (1 << 1) +#define TPL_PREALLOCD (1 << 2) +#define TPL_EXCESS_OK (1 << 3) +#define TPL_FD (1 << 4) +#define TPL_UFREE (1 << 5) +#define TPL_DATAPEEK (1 << 6) +#define TPL_FXLENS (1 << 7) +#define TPL_GETSIZE (1 << 8) +/* do not add flags here without renumbering the internal flags! */ + +/* flags for tpl_gather mode */ +#define TPL_GATHER_BLOCKING 1 +#define TPL_GATHER_NONBLOCKING 2 +#define TPL_GATHER_MEM 3 + +/* Hooks for error logging, memory allocation functions and fatal */ +typedef int (tpl_print_fcn)(const char *fmt, ...); +typedef void *(tpl_malloc_fcn)(size_t sz); +typedef void *(tpl_realloc_fcn)(void *ptr, size_t sz); +typedef void (tpl_free_fcn)(void *ptr); +typedef void (tpl_fatal_fcn)(char *fmt, ...); + +typedef struct tpl_hook_t { + tpl_print_fcn *oops; + tpl_malloc_fcn *malloc; + tpl_realloc_fcn *realloc; + tpl_free_fcn *free; + tpl_fatal_fcn *fatal; + size_t gather_max; +} tpl_hook_t; + +typedef struct tpl_node { + int type; + void *addr; + void *data; /* r:tpl_root_data*. A:tpl_atyp*. ow:szof type */ + int num; /* length of type if its a C array */ + size_t ser_osz; /* serialization output size for subtree */ + struct tpl_node *children; /* my children; linked-list */ + struct tpl_node *next,*prev; /* my siblings (next child of my parent) */ + struct tpl_node *parent; /* my parent */ +} tpl_node; + +/* used when un/packing 'B' type (binary buffers) */ +typedef struct tpl_bin { + void *addr; + uint32_t sz; +} tpl_bin; + +/* for async/piecemeal reading of tpl images */ +typedef struct tpl_gather_t { + char *img; + int len; +} tpl_gather_t; + +/* Callback used when tpl_gather has read a full tpl image */ +typedef int (tpl_gather_cb)(void *img, size_t sz, void *data); + +/* Prototypes */ +TPL_API tpl_node *tpl_map(char *fmt,...); /* define tpl using format */ +TPL_API void tpl_free(tpl_node *r); /* free a tpl map */ +TPL_API int tpl_pack(tpl_node *r, int i); /* pack the n'th packable */ +TPL_API int tpl_unpack(tpl_node *r, int i); /* unpack the n'th packable */ +TPL_API int tpl_dump(tpl_node *r, int mode, ...); /* serialize to mem/file */ +TPL_API int tpl_load(tpl_node *r, int mode, ...); /* set mem/file to unpack */ +TPL_API int tpl_Alen(tpl_node *r, int i); /* array len of packable i */ +TPL_API char* tpl_peek(int mode, ...); /* sneak peek at format string */ +TPL_API int tpl_gather( int mode, ...); /* non-blocking image gather */ +TPL_API int tpl_jot(int mode, ...); /* quick write a simple tpl */ + +#if defined __cplusplus + } +#endif + +#endif /* TPL_H */ + diff --git a/email-common-use/tpl.c b/email-common-use/tpl.c new file mode 100644 index 0000000..60b3be8 --- /dev/null +++ b/email-common-use/tpl.c @@ -0,0 +1,2477 @@ +/* +Copyright (c) 2005-2010, Troy D. Hanson http://tpl.sourceforge.net +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define TPL_VERSION 1.5 + +static const char id[]="$Id: tpl.c 192 2009-04-24 10:35:30Z thanson $"; + + +#include /* malloc */ +#include /* va_list */ +#include /* memcpy, memset, strchr */ +#include /* printf (tpl_hook.oops default function) */ + +#ifndef _WIN32 +#include /* for ftruncate */ +#else +#include +#define ftruncate(x,y) _chsize(x,y) +#endif +#include /* for 'open' */ +#include /* for 'open' */ +#include /* for 'open' */ +#include +#ifndef _WIN32 +#include /* uint32_t, uint64_t, etc */ +#else +typedef unsigned short ushort; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +#endif + + +#if ( defined __CYGWIN__ || defined __MINGW32__ || defined _WIN32 ) +#include "win/mman.h" /* mmap */ +#else +#include /* mmap */ +#endif + +#include "tpl.h" +#include "email-debug-log.h" + + +#define TPL_GATHER_BUFLEN 8192 +#define TPL_MAGIC "tpl" + +/* macro to add a structure to a doubly-linked list */ +#define DL_ADD(head,add) \ + do { \ + if (head) { \ + (add)->prev = (head)->prev; \ + (head)->prev->next = (add); \ + (head)->prev = (add); \ + (add)->next = NULL; \ + } else { \ + (head)=(add); \ + (head)->prev = (head); \ + (head)->next = NULL; \ + } \ + } while (0); + +#define fatal_oom() tpl_hook.fatal("out of memory\n") + +/* bit flags (internal). preceded by the external flags in tpl.h */ +#define TPL_WRONLY (1 << 9) /* app has initiated tpl packing */ +#define TPL_RDONLY (1 << 10) /* tpl was loaded (for unpacking) */ +#define TPL_XENDIAN (1 << 11) /* swap endianness when unpacking */ +#define TPL_OLD_STRING_FMT (1 << 12) /* tpl has strings in 1.2 format */ + +/* values for the flags byte that appears after the magic prefix */ +#define TPL_SUPPORTED_BITFLAGS 3 +#define TPL_FL_BIGENDIAN (1 << 0) +#define TPL_FL_NULLSTRINGS (1 << 1) + +/* char values for node type */ +#define TPL_TYPE_ROOT 0 +#define TPL_TYPE_INT32 1 +#define TPL_TYPE_UINT32 2 +#define TPL_TYPE_BYTE 3 +#define TPL_TYPE_STR 4 +#define TPL_TYPE_ARY 5 +#define TPL_TYPE_BIN 6 +#define TPL_TYPE_DOUBLE 7 +#define TPL_TYPE_INT64 8 +#define TPL_TYPE_UINT64 9 +#define TPL_TYPE_INT16 10 +#define TPL_TYPE_UINT16 11 +#define TPL_TYPE_POUND 12 + +/* error codes */ +#define ERR_NOT_MINSIZE (-1) +#define ERR_MAGIC_MISMATCH (-2) +#define ERR_INCONSISTENT_SZ (-3) +#define ERR_FMT_INVALID (-4) +#define ERR_FMT_MISSING_NUL (-5) +#define ERR_FMT_MISMATCH (-6) +#define ERR_FLEN_MISMATCH (-7) +#define ERR_INCONSISTENT_SZ2 (-8) +#define ERR_INCONSISTENT_SZ3 (-9) +#define ERR_INCONSISTENT_SZ4 (-10) +#define ERR_UNSUPPORTED_FLAGS (-11) + +/* access to A(...) nodes by index */ +typedef struct tpl_pidx { + struct tpl_node *node; + struct tpl_pidx *next,*prev; +} tpl_pidx; + +/* A(...) node datum */ +typedef struct tpl_atyp { + uint32_t num; /* num elements */ + size_t sz; /* size of each backbone's datum */ + struct tpl_backbone *bb,*bbtail; + void *cur; +} tpl_atyp; + +/* backbone to extend A(...) lists dynamically */ +typedef struct tpl_backbone { + struct tpl_backbone *next; + /* when this structure is malloc'd, extra space is alloc'd at the + * end to store the backbone "datum", and data points to it. */ +#if __STDC_VERSION__ < 199901 + char *data; +#else + char data[]; +#endif +} tpl_backbone; + +/* mmap record */ +typedef struct tpl_mmap_rec { + int fd; + void *text; + size_t text_sz; +} tpl_mmap_rec; + +/* root node datum */ +typedef struct tpl_root_data { + int flags; + tpl_pidx *pidx; + tpl_mmap_rec mmap; + char *fmt; + int *fxlens, num_fxlens; +} tpl_root_data; + +/* node type to size mapping */ +struct tpl_type_t { + char c; + int sz; +}; + + +/* Internal prototypes */ +static tpl_node *tpl_node_new(tpl_node *parent); +static tpl_node *tpl_find_i(tpl_node *n, int i); +static void *tpl_cpv(void *datav, void *data, size_t sz); +static void *tpl_extend_backbone(tpl_node *n); +static char *tpl_fmt(tpl_node *r); +static void *tpl_dump_atyp(tpl_node *n, tpl_atyp* at, void *dv); +static size_t tpl_ser_osz(tpl_node *n); +static void tpl_free_atyp(tpl_node *n,tpl_atyp *atyp); +static int tpl_dump_to_mem(tpl_node *r, void *addr, size_t sz); +static int tpl_mmap_file(char *filename, tpl_mmap_rec *map_rec); +static int tpl_mmap_output_file(char *filename, size_t sz, void **text_out); +static int tpl_cpu_bigendian(void); +static int tpl_needs_endian_swap(void *); +static void tpl_byteswap(void *word, int len); +static void tpl_fatal(char *fmt, ...); +static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen); +static int tpl_unpackA0(tpl_node *r); +static int tpl_oops(const char *fmt, ...); +static int tpl_gather_mem( char *buf, size_t len, tpl_gather_t **gs, tpl_gather_cb *cb, void *data); +static int tpl_gather_nonblocking( int fd, tpl_gather_t **gs, tpl_gather_cb *cb, void *data); +static int tpl_gather_blocking(int fd, void **img, size_t *sz); +static tpl_node *tpl_map_va(char *fmt, va_list ap); + +/* This is used internally to help calculate padding when a 'double' + * follows a smaller datatype in a structure. Normally under gcc + * on x86, d will be aligned at +4, however use of -malign-double + * causes d to be aligned at +8 (this is actually faster on x86). + * Also SPARC and x86_64 seem to align always on +8. + */ +struct tpl_double_alignment_detector { + char a; + double d; /* some platforms align this on +4, others on +8 */ +}; + +/* this is another case where alignment varies. mac os x/gcc was observed + * to align the int64_t at +4 under -m32 and at +8 under -m64 */ +struct tpl_int64_alignment_detector { + int i; + int64_t j; /* some platforms align this on +4, others on +8 */ +}; + +typedef struct { + size_t inter_elt_len; /* padded inter-element len; i.e. &a[1].field - &a[0].field */ + tpl_node *iter_start_node; /* node to jump back to, as we start each new iteration */ + size_t iternum; /* current iteration number (total req'd. iter's in n->num) */ +} tpl_pound_data; + +/* Hooks for customizing tpl mem alloc, error handling, etc. Set defaults. */ +tpl_hook_t tpl_hook = { + /* .oops = */ tpl_oops, + /* .malloc = */ malloc, + /* .realloc = */ realloc, + /* .free = */ free, + /* .fatal = */ tpl_fatal, + /* .gather_max = */ 0 /* max tpl size (bytes) for tpl_gather */ +}; + +static const char tpl_fmt_chars[] = "AS($)BiucsfIUjv#"; /* valid format chars */ +static const char tpl_S_fmt_chars[] = "iucsfIUjv#$()"; /* valid within S(...) */ +static const char tpl_datapeek_ok_chars[] = "iucsfIUjv"; /* valid in datapeek */ +static const struct tpl_type_t tpl_types[] = { + /* [TPL_TYPE_ROOT] = */ {'r', 0}, + /* [TPL_TYPE_INT32] = */ {'i', sizeof(int32_t)}, + /* [TPL_TYPE_UINT32] = */ {'u', sizeof(uint32_t)}, + /* [TPL_TYPE_BYTE] = */ {'c', sizeof(char)}, + /* [TPL_TYPE_STR] = */ {'s', sizeof(char*)}, + /* [TPL_TYPE_ARY] = */ {'A', 0}, + /* [TPL_TYPE_BIN] = */ {'B', 0}, + /* [TPL_TYPE_DOUBLE] = */ {'f', 8}, /* not sizeof(double) as that varies */ + /* [TPL_TYPE_INT64] = */ {'I', sizeof(int64_t)}, + /* [TPL_TYPE_UINT64] = */ {'U', sizeof(uint64_t)}, + /* [TPL_TYPE_INT16] = */ {'j', sizeof(int16_t)}, + /* [TPL_TYPE_UINT16] = */ {'v', sizeof(uint16_t)}, + /* [TPL_TYPE_POUND] = */ {'#', 0}, +}; + +/* default error-reporting function. Just writes to stderr. */ +static int tpl_oops(const char *fmt, ...) { + char buf[256]; + va_list ap; + va_start(ap,fmt); +/* vfprintf(stderr,fmt,ap); */ + snprintf(buf, sizeof(buf)-1, fmt, ap); + EM_DEBUG_EXCEPTION("%s", buf); + va_end(ap); + return 0; +} + + +static tpl_node *tpl_node_new(tpl_node *parent) { + tpl_node *n; + if ((n=tpl_hook.malloc(sizeof(tpl_node))) == NULL) { + fatal_oom(); + } + n->addr=NULL; + n->data=NULL; + n->num=1; + n->ser_osz=0; + n->children=NULL; + n->next=NULL; + n->parent=parent; + return n; +} + +/* Used in S(..) formats to pack several fields from a structure based on + * only the structure address. We need to calculate field addresses + * manually taking into account the size of the fields and intervening padding. + * The wrinkle is that double is not normally aligned on x86-32 but the + * -malign-double compiler option causes it to be. Double are aligned + * on Sparc, and apparently on 64 bit x86. We use a helper structure + * to detect whether double is aligned in this compilation environment. + */ +char *calc_field_addr(tpl_node *parent, int type,char *struct_addr, int ordinal) { + tpl_node *prev; + int offset; + int align_sz; + + if (ordinal == 1) return struct_addr; /* first field starts on structure address */ + + /* generate enough padding so field addr is divisible by it's align_sz. 4, 8, etc */ + prev = parent->children->prev; + switch(type) { + case TPL_TYPE_DOUBLE: + align_sz = sizeof(struct tpl_double_alignment_detector) > 12 ? 8 : 4; + break; + case TPL_TYPE_INT64: + case TPL_TYPE_UINT64: + align_sz = sizeof(struct tpl_int64_alignment_detector) > 12 ? 8 : 4; + break; + default: + align_sz = tpl_types[type].sz; + break; + } + offset = ((uintptr_t)prev->addr - (uintptr_t)struct_addr) + + (tpl_types[prev->type].sz * prev->num); + offset = (offset + align_sz - 1) / align_sz * align_sz; + return struct_addr + offset; +} + +TPL_API tpl_node *tpl_map(char *fmt,...) { + va_list ap; + tpl_node *tn; + + va_start(ap,fmt); + tn = tpl_map_va(fmt, ap); + va_end(ap); + return tn; +} + +static tpl_node *tpl_map_va(char *fmt, va_list ap) { + int lparen_level=0,expect_lparen=0,t=0,in_structure=0,ordinal=0; + int in_nested_structure=0; + char *c, *peek, *struct_addr=NULL, *struct_next; + tpl_node *root,*parent,*n=NULL,*preceding,*iter_start_node=NULL, + *struct_widest_node=NULL, *np; tpl_pidx *pidx; + tpl_pound_data *pd; + int *fxlens, num_fxlens, pound_num, pound_prod, applies_to_struct; + int contig_fxlens[10]; /* temp space for contiguous fxlens */ + int num_contig_fxlens, i, j; + ptrdiff_t inter_elt_len=0; /* padded element length of contiguous structs in array */ + + + root = tpl_node_new(NULL); + root->type = TPL_TYPE_ROOT; + root->data = (tpl_root_data*)tpl_hook.malloc(sizeof(tpl_root_data)); + if (!root->data) fatal_oom(); + memset((tpl_root_data*)root->data,0,sizeof(tpl_root_data)); + + /* set up root nodes special ser_osz to reflect overhead of preamble */ + root->ser_osz = sizeof(uint32_t); /* tpl leading length */ + root->ser_osz += strlen(fmt) + 1; /* fmt + NUL-terminator */ + root->ser_osz += 4; /* 'tpl' magic prefix + flags byte */ + + parent=root; + + c=fmt; + while (*c != '\0') { + switch (*c) { + case 'c': + case 'i': + case 'u': + case 'j': + case 'v': + case 'I': + case 'U': + case 'f': + if (*c=='c') t=TPL_TYPE_BYTE; + else if (*c=='i') t=TPL_TYPE_INT32; + else if (*c=='u') t=TPL_TYPE_UINT32; + else if (*c=='j') t=TPL_TYPE_INT16; + else if (*c=='v') t=TPL_TYPE_UINT16; + else if (*c=='I') t=TPL_TYPE_INT64; + else if (*c=='U') t=TPL_TYPE_UINT64; + else if (*c=='f') t=TPL_TYPE_DOUBLE; + + if (expect_lparen) goto fail; + n = tpl_node_new(parent); + n->type = t; + if (in_structure) { + if (ordinal == 1) { + /* for S(...)# iteration. Apply any changes to case 's' too!!! */ + iter_start_node = n; + struct_widest_node = n; + } + if (tpl_types[n->type].sz > tpl_types[struct_widest_node->type].sz) { + struct_widest_node = n; + } + n->addr = calc_field_addr(parent,n->type,struct_addr,ordinal++); + } else n->addr = (void*)va_arg(ap,void*); + n->data = tpl_hook.malloc(tpl_types[t].sz); + if (!n->data) fatal_oom(); + if (n->parent->type == TPL_TYPE_ARY) + ((tpl_atyp*)(n->parent->data))->sz += tpl_types[t].sz; + DL_ADD(parent->children,n); + break; + case 's': + if (expect_lparen) goto fail; + n = tpl_node_new(parent); + n->type = TPL_TYPE_STR; + if (in_structure) { + if (ordinal == 1) { + iter_start_node = n; /* for S(...)# iteration */ + struct_widest_node = n; + } + if (tpl_types[n->type].sz > tpl_types[struct_widest_node->type].sz) { + struct_widest_node = n; + } + n->addr = calc_field_addr(parent,n->type,struct_addr,ordinal++); + } else n->addr = (void*)va_arg(ap,void*); + n->data = tpl_hook.malloc(sizeof(char*)); + if (!n->data) fatal_oom(); + *(char**)(n->data) = NULL; + if (n->parent->type == TPL_TYPE_ARY) + ((tpl_atyp*)(n->parent->data))->sz += sizeof(void*); + DL_ADD(parent->children,n); + break; + case '#': + /* apply a 'num' to preceding atom */ + if (!parent->children) goto fail; + preceding = parent->children->prev; /* first child's prev is 'last child'*/ + t = preceding->type; + applies_to_struct = (*(c-1) == ')') ? 1 : 0; + if (!applies_to_struct) { + if (!(t == TPL_TYPE_BYTE || t == TPL_TYPE_INT32 || + t == TPL_TYPE_UINT32 || t == TPL_TYPE_DOUBLE || + t == TPL_TYPE_UINT64 || t == TPL_TYPE_INT64 || + t == TPL_TYPE_UINT16 || t == TPL_TYPE_INT16 || + t == TPL_TYPE_STR )) goto fail; + } + /* count up how many contiguous # and form their product */ + pound_prod=1; + num_contig_fxlens=0; + for(peek=c; *peek == '#'; peek++) { + pound_num = va_arg(ap, int); + if (pound_num < 1) { + tpl_hook.fatal("non-positive iteration count %d\n", pound_num); + } + if (num_contig_fxlens >= (sizeof(contig_fxlens)/sizeof(contig_fxlens[0]))) { + tpl_hook.fatal("contiguous # exceeds hardcoded limit\n"); + } + contig_fxlens[num_contig_fxlens++] = pound_num; + pound_prod *= pound_num; + } + /* increment c to skip contiguous # so its points to last one */ + c = peek-1; + /* differentiate atom-# from struct-# by noting preceding rparen */ + if (applies_to_struct) { /* insert # node to induce looping */ + n = tpl_node_new(parent); + n->type = TPL_TYPE_POUND; + n->num = pound_prod; + n->data = tpl_hook.malloc(sizeof(tpl_pound_data)); + if (!n->data) fatal_oom(); + pd = (tpl_pound_data*)n->data; + pd->inter_elt_len = inter_elt_len; + pd->iter_start_node = iter_start_node; + pd->iternum = 0; + DL_ADD(parent->children,n); + /* multiply the 'num' and data space on each atom in the structure */ + for(np = iter_start_node; np != n; np = np->next) { + if (n->parent->type == TPL_TYPE_ARY) { + ((tpl_atyp*)(n->parent->data))->sz += + tpl_types[np->type].sz * (np->num * (n->num - 1)); + } + np->data = tpl_hook.realloc(np->data, tpl_types[np->type].sz * + np->num * n->num); + if (!np->data) fatal_oom(); + memset(np->data, 0, tpl_types[np->type].sz * np->num * n->num); + } + } else { /* simple atom-# form does not require a loop */ + preceding->num = pound_prod; + preceding->data = tpl_hook.realloc(preceding->data, + tpl_types[t].sz * preceding->num); + if (!preceding->data) fatal_oom(); + memset(preceding->data,0,tpl_types[t].sz * preceding->num); + if (n->parent->type == TPL_TYPE_ARY) { + ((tpl_atyp*)(n->parent->data))->sz += tpl_types[t].sz * + (preceding->num-1); + } + } + root->ser_osz += (sizeof(uint32_t) * num_contig_fxlens); + + j = ((tpl_root_data*)root->data)->num_fxlens; /* before incrementing */ + (((tpl_root_data*)root->data)->num_fxlens) += num_contig_fxlens; + num_fxlens = ((tpl_root_data*)root->data)->num_fxlens; /* new value */ + fxlens = ((tpl_root_data*)root->data)->fxlens; + fxlens = tpl_hook.realloc(fxlens, sizeof(int) * num_fxlens); + if (!fxlens) fatal_oom(); + ((tpl_root_data*)root->data)->fxlens = fxlens; + for(i=0; i < num_contig_fxlens; i++) fxlens[j++] = contig_fxlens[i]; + + break; + case 'B': + if (expect_lparen) goto fail; + if (in_structure) goto fail; + n = tpl_node_new(parent); + n->type = TPL_TYPE_BIN; + n->addr = (tpl_bin*)va_arg(ap,void*); + n->data = tpl_hook.malloc(sizeof(tpl_bin*)); + if (!n->data) fatal_oom(); + *((tpl_bin**)n->data) = NULL; + if (n->parent->type == TPL_TYPE_ARY) + ((tpl_atyp*)(n->parent->data))->sz += sizeof(tpl_bin); + DL_ADD(parent->children,n); + break; + case 'A': + if (in_structure) goto fail; + n = tpl_node_new(parent); + n->type = TPL_TYPE_ARY; + DL_ADD(parent->children,n); + parent = n; + expect_lparen=1; + pidx = (tpl_pidx*)tpl_hook.malloc(sizeof(tpl_pidx)); + if (!pidx) fatal_oom(); + pidx->node = n; + pidx->next = NULL; + DL_ADD(((tpl_root_data*)(root->data))->pidx,pidx); + /* set up the A's tpl_atyp */ + n->data = (tpl_atyp*)tpl_hook.malloc(sizeof(tpl_atyp)); + if (!n->data) fatal_oom(); + ((tpl_atyp*)(n->data))->num = 0; + ((tpl_atyp*)(n->data))->sz = 0; + ((tpl_atyp*)(n->data))->bb = NULL; + ((tpl_atyp*)(n->data))->bbtail = NULL; + ((tpl_atyp*)(n->data))->cur = NULL; + if (n->parent->type == TPL_TYPE_ARY) + ((tpl_atyp*)(n->parent->data))->sz += sizeof(void*); + break; + case 'S': + if (in_structure) goto fail; + expect_lparen=1; + ordinal=1; /* index upcoming atoms in S(..) */ + in_structure=1+lparen_level; /* so we can tell where S fmt ends */ + struct_addr = (char*)va_arg(ap,void*); + break; + case '$': /* nested structure */ + if (!in_structure) goto fail; + expect_lparen=1; + in_nested_structure++; + break; + case ')': + lparen_level--; + if (lparen_level < 0) goto fail; + if (*(c-1) == '(') goto fail; + if (in_nested_structure) in_nested_structure--; + else if (in_structure && (in_structure-1 == lparen_level)) { + /* calculate delta between contiguous structures in array */ + struct_next = calc_field_addr(parent, struct_widest_node->type, + struct_addr, ordinal++); + inter_elt_len = struct_next - struct_addr; + in_structure=0; + } + else parent = parent->parent; /* rparen ends A() type, not S() type */ + break; + case '(': + if (!expect_lparen) goto fail; + expect_lparen=0; + lparen_level++; + break; + default: + tpl_hook.oops("unsupported option %c\n", *c); + goto fail; + } + c++; + } + if (lparen_level != 0) goto fail; + + /* copy the format string, save for convenience */ + ((tpl_root_data*)(root->data))->fmt = tpl_hook.malloc(strlen(fmt)+1); + if (((tpl_root_data*)(root->data))->fmt == NULL) + fatal_oom(); + memcpy(((tpl_root_data*)(root->data))->fmt,fmt,strlen(fmt)+1); + + return root; + +fail: + tpl_hook.oops("failed to parse %s\n", fmt); + tpl_free(root); + return NULL; +} + +static int tpl_unmap_file( tpl_mmap_rec *mr) { + + if ( munmap( mr->text, mr->text_sz ) == -1 ) { + tpl_hook.oops("Failed to munmap: %s\n", strerror(errno)); + } + close(mr->fd); + mr->text = NULL; + mr->text_sz = 0; + return 0; +} + +static void tpl_free_keep_map(tpl_node *r) { + int mmap_bits = (TPL_RDONLY|TPL_FILE); + int ufree_bits = (TPL_MEM|TPL_UFREE); + tpl_node *nxtc,*c; + int find_next_node=0,looking,i; + size_t sz; + + /* For mmap'd files, or for 'ufree' memory images , do appropriate release */ + if ((((tpl_root_data*)(r->data))->flags & mmap_bits) == mmap_bits) { + tpl_unmap_file( &((tpl_root_data*)(r->data))->mmap); + } else if ((((tpl_root_data*)(r->data))->flags & ufree_bits) == ufree_bits) { + tpl_hook.free( ((tpl_root_data*)(r->data))->mmap.text ); + } + + c = r->children; + if (c) { + while(c->type != TPL_TYPE_ROOT) { /* loop until we come back to root node */ + switch (c->type) { + case TPL_TYPE_BIN: + /* free any binary buffer hanging from tpl_bin */ + if ( *((tpl_bin**)(c->data)) ) { + if ( (*((tpl_bin**)(c->data)))->addr ) { + tpl_hook.free( (*((tpl_bin**)(c->data)))->addr ); + } + *((tpl_bin**)c->data) = NULL; /* reset tpl_bin */ + } + find_next_node=1; + break; + case TPL_TYPE_STR: + /* free any packed (copied) string */ + for(i=0; i < c->num; i++) { + char *str = ((char**)c->data)[i]; + if (str) { + tpl_hook.free(str); + ((char**)c->data)[i] = NULL; + } + } + find_next_node=1; + break; + case TPL_TYPE_INT32: + case TPL_TYPE_UINT32: + case TPL_TYPE_INT64: + case TPL_TYPE_UINT64: + case TPL_TYPE_BYTE: + case TPL_TYPE_DOUBLE: + case TPL_TYPE_INT16: + case TPL_TYPE_UINT16: + case TPL_TYPE_POUND: + find_next_node=1; + break; + case TPL_TYPE_ARY: + c->ser_osz = 0; /* zero out the serialization output size */ + + sz = ((tpl_atyp*)(c->data))->sz; /* save sz to use below */ + tpl_free_atyp(c,c->data); + + /* make new atyp */ + c->data = (tpl_atyp*)tpl_hook.malloc(sizeof(tpl_atyp)); + if (!c->data) fatal_oom(); + ((tpl_atyp*)(c->data))->num = 0; + ((tpl_atyp*)(c->data))->sz = sz; /* restore bb datum sz */ + ((tpl_atyp*)(c->data))->bb = NULL; + ((tpl_atyp*)(c->data))->bbtail = NULL; + ((tpl_atyp*)(c->data))->cur = NULL; + + c = c->children; + break; + default: + tpl_hook.fatal("unsupported format character\n"); + break; + } + + if (find_next_node) { + find_next_node=0; + looking=1; + while(looking) { + if (c->next) { + nxtc=c->next; + c=nxtc; + looking=0; + } else { + if (c->type == TPL_TYPE_ROOT) break; /* root node */ + else { + nxtc=c->parent; + c=nxtc; + } + } + } + } + } + } + + ((tpl_root_data*)(r->data))->flags = 0; /* reset flags */ +} + +TPL_API void tpl_free(tpl_node *r) { + int mmap_bits = (TPL_RDONLY|TPL_FILE); + int ufree_bits = (TPL_MEM|TPL_UFREE); + tpl_node *nxtc,*c; + int find_next_node=0,looking,i; + tpl_pidx *pidx,*pidx_nxt; + + /* For mmap'd files, or for 'ufree' memory images , do appropriate release */ + if ((((tpl_root_data*)(r->data))->flags & mmap_bits) == mmap_bits) { + tpl_unmap_file( &((tpl_root_data*)(r->data))->mmap); + } else if ((((tpl_root_data*)(r->data))->flags & ufree_bits) == ufree_bits) { + tpl_hook.free( ((tpl_root_data*)(r->data))->mmap.text ); + } + + c = r->children; + if (c) { + while(c->type != TPL_TYPE_ROOT) { /* loop until we come back to root node */ + switch (c->type) { + case TPL_TYPE_BIN: + /* free any binary buffer hanging from tpl_bin */ + if ( *((tpl_bin**)(c->data)) ) { + if ( (*((tpl_bin**)(c->data)))->sz != 0 ) { + tpl_hook.free( (*((tpl_bin**)(c->data)))->addr ); + } + tpl_hook.free(*((tpl_bin**)c->data)); /* free tpl_bin */ + } + tpl_hook.free(c->data); /* free tpl_bin* */ + find_next_node=1; + break; + case TPL_TYPE_STR: + /* free any packed (copied) string */ + for(i=0; i < c->num; i++) { + char *str = ((char**)c->data)[i]; + if (str) { + tpl_hook.free(str); + ((char**)c->data)[i] = NULL; + } + } + tpl_hook.free(c->data); + find_next_node=1; + break; + case TPL_TYPE_INT32: + case TPL_TYPE_UINT32: + case TPL_TYPE_INT64: + case TPL_TYPE_UINT64: + case TPL_TYPE_BYTE: + case TPL_TYPE_DOUBLE: + case TPL_TYPE_INT16: + case TPL_TYPE_UINT16: + case TPL_TYPE_POUND: + tpl_hook.free(c->data); + find_next_node=1; + break; + case TPL_TYPE_ARY: + tpl_free_atyp(c,c->data); + if (c->children) c = c->children; /* normal case */ + else find_next_node=1; /* edge case, handle bad format A() */ + break; + default: + tpl_hook.fatal("unsupported format character\n"); + break; + } + + if (find_next_node) { + find_next_node=0; + looking=1; + while(looking) { + if (c->next) { + nxtc=c->next; + tpl_hook.free(c); + c=nxtc; + looking=0; + } else { + if (c->type == TPL_TYPE_ROOT) break; /* root node */ + else { + nxtc=c->parent; + tpl_hook.free(c); + c=nxtc; + } + } + } + } + } + } + + /* free root */ + for(pidx=((tpl_root_data*)(r->data))->pidx; pidx; pidx=pidx_nxt) { + pidx_nxt = pidx->next; + tpl_hook.free(pidx); + } + tpl_hook.free(((tpl_root_data*)(r->data))->fmt); + if (((tpl_root_data*)(r->data))->num_fxlens > 0) { + tpl_hook.free(((tpl_root_data*)(r->data))->fxlens); + } + tpl_hook.free(r->data); /* tpl_root_data */ + tpl_hook.free(r); +} + + +/* Find the i'th packable ('A' node) */ +static tpl_node *tpl_find_i(tpl_node *n, int i) { + int j=0; + tpl_pidx *pidx; + if (n->type != TPL_TYPE_ROOT) return NULL; + if (i == 0) return n; /* packable 0 is root */ + for(pidx=((tpl_root_data*)(n->data))->pidx; pidx; pidx=pidx->next) { + if (++j == i) return pidx->node; + } + return NULL; +} + +static void *tpl_cpv(void *datav, void *data, size_t sz) { + if (sz>0) memcpy(datav,data,sz); + return (void*)((uintptr_t)datav + sz); +} + +static void *tpl_extend_backbone(tpl_node *n) { + tpl_backbone *bb; + bb = (tpl_backbone*)tpl_hook.malloc(sizeof(tpl_backbone) + + ((tpl_atyp*)(n->data))->sz ); /* datum hangs on coattails of bb */ + if (!bb) fatal_oom(); +#if __STDC_VERSION__ < 199901 + bb->data = (char*)((uintptr_t)bb + sizeof(tpl_backbone)); +#endif + memset(bb->data,0,((tpl_atyp*)(n->data))->sz); + bb->next = NULL; + /* Add the new backbone to the tail, also setting head if necessary */ + if (((tpl_atyp*)(n->data))->bb == NULL) { + ((tpl_atyp*)(n->data))->bb = bb; + ((tpl_atyp*)(n->data))->bbtail = bb; + } else { + ((tpl_atyp*)(n->data))->bbtail->next = bb; + ((tpl_atyp*)(n->data))->bbtail = bb; + } + + ((tpl_atyp*)(n->data))->num++; + return bb->data; +} + +/* Get the format string corresponding to a given tpl (root node) */ +static char *tpl_fmt(tpl_node *r) { + return ((tpl_root_data*)(r->data))->fmt; +} + +/* Get the fmt # lengths as a contiguous buffer of ints (length num_fxlens) */ +static int *tpl_fxlens(tpl_node *r, int *num_fxlens) { + *num_fxlens = ((tpl_root_data*)(r->data))->num_fxlens; + return ((tpl_root_data*)(r->data))->fxlens; +} + +/* called when serializing an 'A' type node into a buffer which has + * already been set up with the proper space. The backbone is walked + * which was obtained from the tpl_atyp header passed in. + */ +static void *tpl_dump_atyp(tpl_node *n, tpl_atyp* at, void *dv) { + tpl_backbone *bb; + tpl_node *c; + void *datav; + uint32_t slen; + tpl_bin *binp; + char *strp; + tpl_atyp *atypp; + tpl_pound_data *pd; + int i; + size_t itermax; + + /* handle 'A' nodes */ + dv = tpl_cpv(dv,&at->num,sizeof(uint32_t)); /* array len */ + for(bb=at->bb; bb; bb=bb->next) { + datav = bb->data; + c=n->children; + while(c) { + switch (c->type) { + case TPL_TYPE_BYTE: + case TPL_TYPE_DOUBLE: + case TPL_TYPE_INT32: + case TPL_TYPE_UINT32: + case TPL_TYPE_INT64: + case TPL_TYPE_UINT64: + case TPL_TYPE_INT16: + case TPL_TYPE_UINT16: + dv = tpl_cpv(dv,datav,tpl_types[c->type].sz * c->num); + datav = (void*)((uintptr_t)datav + tpl_types[c->type].sz * c->num); + break; + case TPL_TYPE_BIN: + /* dump the buffer length followed by the buffer */ + memcpy(&binp,datav,sizeof(tpl_bin*)); /* cp to aligned */ + slen = binp->sz; + dv = tpl_cpv(dv,&slen,sizeof(uint32_t)); + dv = tpl_cpv(dv,binp->addr,slen); + datav = (void*)((uintptr_t)datav + sizeof(tpl_bin*)); + break; + case TPL_TYPE_STR: + /* dump the string length followed by the string */ + for(i=0; i < c->num; i++) { + memcpy(&strp,datav,sizeof(char*)); /* cp to aligned */ + slen = strp ? (strlen(strp)+1) : 0; + dv = tpl_cpv(dv,&slen,sizeof(uint32_t)); + if (slen > 1) dv = tpl_cpv(dv,strp,slen-1); + datav = (void*)((uintptr_t)datav + sizeof(char*)); + } + break; + case TPL_TYPE_ARY: + memcpy(&atypp,datav,sizeof(tpl_atyp*)); /* cp to aligned */ + dv = tpl_dump_atyp(c,atypp,dv); + datav = (void*)((uintptr_t)datav + sizeof(void*)); + break; + case TPL_TYPE_POUND: + /* iterate over the preceding nodes */ + pd = (tpl_pound_data*)c->data; + itermax = c->num; + if (++(pd->iternum) < itermax) { + c = pd->iter_start_node; + continue; + } else { /* loop complete. */ + pd->iternum = 0; + } + break; + default: + tpl_hook.fatal("unsupported format character\n"); + break; + } + c=c->next; + } + } + return dv; +} + +/* figure the serialization output size needed for tpl whose root is n*/ +static size_t tpl_ser_osz(tpl_node *n) { + tpl_node *c, *np; + size_t sz, itermax; + tpl_bin *binp; + char *strp; + tpl_pound_data *pd; + int i; + + /* handle the root node ONLY (subtree's ser_osz have been bubbled-up) */ + if (n->type != TPL_TYPE_ROOT) { + tpl_hook.fatal("internal error: tpl_ser_osz on non-root node\n"); + } + + sz = n->ser_osz; /* start with fixed overhead, already stored */ + c=n->children; + while (c) { + switch (c->type) { + case TPL_TYPE_BYTE: + case TPL_TYPE_DOUBLE: + case TPL_TYPE_INT32: + case TPL_TYPE_UINT32: + case TPL_TYPE_INT64: + case TPL_TYPE_UINT64: + case TPL_TYPE_INT16: + case TPL_TYPE_UINT16: + sz += tpl_types[c->type].sz * c->num; + break; + case TPL_TYPE_BIN: + sz += sizeof(uint32_t); /* binary buf len */ + memcpy(&binp,c->data,sizeof(tpl_bin*)); /* cp to aligned */ + sz += binp->sz; + break; + case TPL_TYPE_STR: + for(i=0; i < c->num; i++) { + sz += sizeof(uint32_t); /* string len */ + memcpy(&strp,&((char**)c->data)[i],sizeof(char*)); /* cp to aligned */ + sz += strp ? strlen(strp) : 0; + } + break; + case TPL_TYPE_ARY: + sz += sizeof(uint32_t); /* array len */ + sz += c->ser_osz; /* bubbled-up child array ser_osz */ + break; + case TPL_TYPE_POUND: + /* iterate over the preceding nodes */ + itermax = c->num; + pd = (tpl_pound_data*)c->data; + if (++(pd->iternum) < itermax) { + for(np=pd->iter_start_node; np != c; np = np->next) { + np->data = (char*)(np->data) + + (tpl_types[np->type].sz * np->num); + } + c = pd->iter_start_node; + continue; + } else { /* loop complete. */ + pd->iternum = 0; + for(np=pd->iter_start_node; np != c; np = np->next) { + np->data = (char*)(np->data) - ((itermax-1) * + tpl_types[np->type].sz * + np->num); + } + } + break; + default: + tpl_hook.fatal("unsupported format character\n"); + break; + } + c=c->next; + } + return sz; +} + + +TPL_API int tpl_dump(tpl_node *r, int mode, ...) { + va_list ap; + char *filename, *bufv; + void **addr_out,*buf, *pa_addr; + int fd,rc=0; + size_t sz,*sz_out, pa_sz; + + if (((tpl_root_data*)(r->data))->flags & TPL_RDONLY) { /* unusual */ + tpl_hook.oops("error: tpl_dump called for a loaded tpl\n"); + return -1; + } + + sz = tpl_ser_osz(r); /* compute the size needed to serialize */ + + va_start(ap,mode); + if (mode & TPL_FILE) { + filename = va_arg(ap,char*); + fd = tpl_mmap_output_file(filename, sz, &buf); + if (fd == -1) rc = -1; + else { + rc = tpl_dump_to_mem(r,buf,sz); + if (msync(buf,sz,MS_SYNC) == -1) { + tpl_hook.oops("msync failed on fd %d: %s\n", fd, strerror(errno)); + } + if (munmap(buf, sz) == -1) { + tpl_hook.oops("munmap failed on fd %d: %s\n", fd, strerror(errno)); + } + close(fd); + } + } else if (mode & TPL_FD) { + fd = va_arg(ap, int); + if ( (buf = tpl_hook.malloc(sz)) == NULL) fatal_oom(); + tpl_dump_to_mem(r,buf,sz); + bufv = buf; + do { + rc = write(fd,bufv,sz); + if (rc > 0) { + sz -= rc; + bufv += rc; + } else if (rc == -1) { + if (errno == EINTR || errno == EAGAIN) continue; + tpl_hook.oops("error writing to fd %d: %s\n", fd, strerror(errno)); + free(buf); + return -1; + } + } while (sz > 0); + free(buf); + rc = 0; + } else if (mode & TPL_MEM) { + if (mode & TPL_PREALLOCD) { /* caller allocated */ + pa_addr = (void*)va_arg(ap, void*); + pa_sz = va_arg(ap, size_t); + if (pa_sz < sz) { + tpl_hook.oops("tpl_dump: buffer too small, need %d bytes\n", sz); + return -1; + } + rc=tpl_dump_to_mem(r,pa_addr,sz); + } else { /* we allocate */ + addr_out = (void**)va_arg(ap, void*); + sz_out = va_arg(ap, size_t*); + if ( (buf = tpl_hook.malloc(sz)) == NULL) fatal_oom(); + *sz_out = sz; + *addr_out = buf; + rc=tpl_dump_to_mem(r,buf,sz); + } + } else if (mode & TPL_GETSIZE) { + sz_out = va_arg(ap, size_t*); + *sz_out = sz; + } else { + tpl_hook.oops("unsupported tpl_dump mode %d\n", mode); + rc=-1; + } + va_end(ap); + return rc; +} + +/* This function expects the caller to have set up a memory buffer of + * adequate size to hold the serialized tpl. The sz parameter must be + * the result of tpl_ser_osz(r). + */ +static int tpl_dump_to_mem(tpl_node *r,void *addr,size_t sz) { + uint32_t slen, sz32; + int *fxlens, num_fxlens, i; + void *dv; + char *fmt,flags; + tpl_node *c, *np; + tpl_pound_data *pd; + size_t itermax; + + fmt = tpl_fmt(r); + flags = 0; + if (tpl_cpu_bigendian()) flags |= TPL_FL_BIGENDIAN; + if (strchr(fmt,'s')) flags |= TPL_FL_NULLSTRINGS; + sz32 = sz; + + dv = addr; + dv = tpl_cpv(dv,TPL_MAGIC,3); /* copy tpl magic prefix */ + dv = tpl_cpv(dv,&flags,1); /* copy flags byte */ + dv = tpl_cpv(dv,&sz32,sizeof(uint32_t));/* overall length (inclusive) */ + dv = tpl_cpv(dv,fmt,strlen(fmt)+1); /* copy format with NUL-term */ + fxlens = tpl_fxlens(r,&num_fxlens); + dv = tpl_cpv(dv,fxlens,num_fxlens*sizeof(uint32_t));/* fmt # lengths */ + + /* serialize the tpl content, iterating over direct children of root */ + c = r->children; + while (c) { + switch (c->type) { + case TPL_TYPE_BYTE: + case TPL_TYPE_DOUBLE: + case TPL_TYPE_INT32: + case TPL_TYPE_UINT32: + case TPL_TYPE_INT64: + case TPL_TYPE_UINT64: + case TPL_TYPE_INT16: + case TPL_TYPE_UINT16: + dv = tpl_cpv(dv,c->data,tpl_types[c->type].sz * c->num); + break; + case TPL_TYPE_BIN: + slen = (*(tpl_bin**)(c->data))->sz; + dv = tpl_cpv(dv,&slen,sizeof(uint32_t)); /* buffer len */ + dv = tpl_cpv(dv,(*(tpl_bin**)(c->data))->addr,slen); /* buf */ + break; + case TPL_TYPE_STR: + for(i=0; i < c->num; i++) { + char *str = ((char**)c->data)[i]; + slen = str ? strlen(str)+1 : 0; + dv = tpl_cpv(dv,&slen,sizeof(uint32_t)); /* string len */ + if (slen>1) dv = tpl_cpv(dv,str,slen-1); /*string*/ + } + break; + case TPL_TYPE_ARY: + dv = tpl_dump_atyp(c,(tpl_atyp*)c->data,dv); + break; + case TPL_TYPE_POUND: + pd = (tpl_pound_data*)c->data; + itermax = c->num; + if (++(pd->iternum) < itermax) { + + /* in start or midst of loop. advance data pointers. */ + for(np=pd->iter_start_node; np != c; np = np->next) { + np->data = (char*)(np->data) + + (tpl_types[np->type].sz * np->num); + } + /* do next iteration */ + c = pd->iter_start_node; + continue; + + } else { /* loop complete. */ + + /* reset iteration index and addr/data pointers. */ + pd->iternum = 0; + for(np=pd->iter_start_node; np != c; np = np->next) { + np->data = (char*)(np->data) - ((itermax-1) * + tpl_types[np->type].sz * + np->num); + } + + } + break; + default: + tpl_hook.fatal("unsupported format character\n"); + break; + } + c = c->next; + } + + return 0; +} + +static int tpl_cpu_bigendian() { + unsigned i = 1; + char *c; + c = (char*)&i; + return (c[0] == 1 ? 0 : 1); +} + + +/* + * algorithm for sanity-checking a tpl image: + * scan the tpl whilst not exceeding the buffer size (bufsz) , + * formulating a calculated (expected) size of the tpl based + * on walking its data. When calcsize has been calculated it + * should exactly match the buffer size (bufsz) and the internal + * recorded size (intlsz) + */ +static int tpl_sanity(tpl_node *r, int excess_ok) { + uint32_t intlsz; + int found_nul=0,rc, octothorpes=0, num_fxlens, *fxlens, flen; + void *d, *dv; + char intlflags, *fmt, c, *mapfmt; + size_t bufsz, serlen; + + d = ((tpl_root_data*)(r->data))->mmap.text; + bufsz = ((tpl_root_data*)(r->data))->mmap.text_sz; + + dv = d; + if (bufsz < (4 + sizeof(uint32_t) + 1)) return ERR_NOT_MINSIZE; /* min sz: magic+flags+len+nul */ + if (memcmp(dv,TPL_MAGIC, 3) != 0) return ERR_MAGIC_MISMATCH; /* missing tpl magic prefix */ + if (tpl_needs_endian_swap(dv)) ((tpl_root_data*)(r->data))->flags |= TPL_XENDIAN; + dv = (void*)((uintptr_t)dv + 3); + memcpy(&intlflags,dv,sizeof(char)); /* extract flags */ + if (intlflags & ~TPL_SUPPORTED_BITFLAGS) return ERR_UNSUPPORTED_FLAGS; + /* TPL1.3 stores strings with a "length+1" prefix to discern NULL strings from + empty strings from non-empty strings; TPL1.2 only handled the latter two. + So we need to be mindful of which string format we're reading from. */ + if (!(intlflags & TPL_FL_NULLSTRINGS)) { + ((tpl_root_data*)(r->data))->flags |= TPL_OLD_STRING_FMT; + } + dv = (void*)((uintptr_t)dv + 1); + memcpy(&intlsz,dv,sizeof(uint32_t)); /* extract internal size */ + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) tpl_byteswap(&intlsz, sizeof(uint32_t)); + if (!excess_ok && (intlsz != bufsz)) return ERR_INCONSISTENT_SZ; /* inconsisent buffer/internal size */ + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); + + /* dv points to the start of the format string. Look for nul w/in buf sz */ + fmt = (char*)dv; + while ((uintptr_t)dv-(uintptr_t)d < bufsz && !found_nul) { + if ( (c = *(char*)dv) != '\0') { + if (strchr(tpl_fmt_chars,c) == NULL) + return ERR_FMT_INVALID; /* invalid char in format string */ + if ( (c = *(char*)dv) == '#') octothorpes++; + dv = (void*)((uintptr_t)dv + 1); + } + else found_nul = 1; + } + if (!found_nul) return ERR_FMT_MISSING_NUL; /* runaway format string */ + dv = (void*)((uintptr_t)dv + 1); /* advance to octothorpe lengths buffer */ + + /* compare the map format to the format of this tpl image */ + mapfmt = tpl_fmt(r); + rc = strcmp(mapfmt,fmt); + if (rc != 0) return ERR_FMT_MISMATCH; + + /* compare octothorpe lengths in image to the mapped values */ + if ((((uintptr_t)dv + (octothorpes * 4)) - (uintptr_t)d) > bufsz) return ERR_INCONSISTENT_SZ4; + fxlens = tpl_fxlens(r,&num_fxlens); /* mapped fxlens */ + while(num_fxlens--) { + memcpy(&flen,dv,sizeof(uint32_t)); /* stored flen */ + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) tpl_byteswap(&flen, sizeof(uint32_t)); + if (flen != *fxlens) return ERR_FLEN_MISMATCH; + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); + fxlens++; + } + + /* dv now points to beginning of data */ + rc = tpl_serlen(r,r,dv,&serlen); /* get computed serlen of data part */ + if (rc == -1) return ERR_INCONSISTENT_SZ2; /* internal inconsistency in tpl image */ + serlen += ((uintptr_t)dv - (uintptr_t)d); /* add back serlen of preamble part */ + if (excess_ok && (bufsz < serlen)) return ERR_INCONSISTENT_SZ3; + if (!excess_ok && (serlen != bufsz)) return ERR_INCONSISTENT_SZ3; /* buffer/internal sz exceeds serlen */ + return 0; +} + +static void *tpl_find_data_start(void *d) { + int octothorpes=0; + d = (void*)((uintptr_t)d + 4); /* skip TPL_MAGIC and flags byte */ + d = (void*)((uintptr_t)d + 4); /* skip int32 overall len */ + while(*(char*)d != '\0') { + if (*(char*)d == '#') octothorpes++; + d = (void*)((uintptr_t)d + 1); + } + d = (void*)((uintptr_t)d + 1); /* skip NUL */ + d = (void*)((uintptr_t)d + (octothorpes * sizeof(uint32_t))); /* skip # array lens */ + return d; +} + +static int tpl_needs_endian_swap(void *d) { + char *c; + int cpu_is_bigendian; + c = (char*)d; + cpu_is_bigendian = tpl_cpu_bigendian(); + return ((c[3] & TPL_FL_BIGENDIAN) == cpu_is_bigendian) ? 0 : 1; +} + +static size_t tpl_size_for(char c) { + int i; + for(i=0; i < sizeof(tpl_types)/sizeof(tpl_types[0]); i++) { + if (tpl_types[i].c == c) return tpl_types[i].sz; + } + return 0; +} + +TPL_API char* tpl_peek(int mode, ...) { + va_list ap; + int xendian=0,found_nul=0,old_string_format=0; + char *filename=NULL, *datapeek_f=NULL, *datapeek_c, *datapeek_s; + void *addr=NULL, *dv, *datapeek_p=NULL; + size_t sz=0, fmt_len, first_atom, num_fxlens=0; + uint32_t datapeek_ssz, datapeek_csz, datapeek_flen; + tpl_mmap_rec mr = {0,NULL,0}; + char *fmt,*fmt_cpy=NULL,c; + uint32_t intlsz, **fxlens=NULL, *num_fxlens_out=NULL, *fxlensv; + + va_start(ap,mode); + if ((mode & TPL_FXLENS) && (mode & TPL_DATAPEEK)) { + tpl_hook.oops("TPL_FXLENS and TPL_DATAPEEK mutually exclusive\n"); + goto fail; + } + if (mode & TPL_FILE) filename = va_arg(ap,char *); + else if (mode & TPL_MEM) { + addr = va_arg(ap,void *); + sz = va_arg(ap,size_t); + } else { + tpl_hook.oops("unsupported tpl_peek mode %d\n", mode); + goto fail; + } + if (mode & TPL_DATAPEEK) { + datapeek_f = va_arg(ap, char*); + } + if (mode & TPL_FXLENS) { + num_fxlens_out = va_arg(ap,uint32_t *); + fxlens = va_arg(ap,uint32_t **); + *num_fxlens_out = 0; + *fxlens = NULL; + } + + if (mode & TPL_FILE) { + if (tpl_mmap_file(filename, &mr) != 0) { + tpl_hook.oops("tpl_peek failed for file %s\n", filename); + goto fail; + } + addr = mr.text; + sz = mr.text_sz; + } + + dv = addr; + if (sz < (4 + sizeof(uint32_t) + 1)) goto fail; /* min sz */ + if (memcmp(dv,TPL_MAGIC, 3) != 0) goto fail; /* missing tpl magic prefix */ + if (tpl_needs_endian_swap(dv)) xendian=1; + if ((((char*)dv)[3] & TPL_FL_NULLSTRINGS)==0) old_string_format=1; + dv = (void*)((uintptr_t)dv + 4); + memcpy(&intlsz,dv,sizeof(uint32_t)); /* extract internal size */ + if (xendian) tpl_byteswap(&intlsz, sizeof(uint32_t)); + if (intlsz != sz) goto fail; /* inconsisent buffer/internal size */ + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); + + /* dv points to the start of the format string. Look for nul w/in buf sz */ + fmt = (char*)dv; + while ((uintptr_t)dv-(uintptr_t)addr < sz && !found_nul) { + if ( (c = *(char*)dv) == '\0') { + found_nul = 1; + } else if (c == '#') { + num_fxlens++; + } + dv = (void*)((uintptr_t)dv + 1); + } + if (!found_nul) goto fail; /* runaway format string */ + fmt_len = (char*)dv - fmt; /* include space for \0 */ + fmt_cpy = tpl_hook.malloc(fmt_len); + if (fmt_cpy == NULL) { + fatal_oom(); + } + memcpy(fmt_cpy, fmt, fmt_len); + + /* retrieve the octothorpic lengths if requested */ + if (num_fxlens > 0) { + if (sz < ((uintptr_t)dv + (num_fxlens * sizeof(uint32_t)) - (uintptr_t)addr)) { + goto fail; + } + } + if ((mode & TPL_FXLENS) && (num_fxlens > 0)) { + *fxlens = tpl_hook.malloc(num_fxlens * sizeof(uint32_t)); + if (*fxlens == NULL) tpl_hook.fatal("out of memory"); + *num_fxlens_out = num_fxlens; + fxlensv = *fxlens; + while(num_fxlens--) { + memcpy(fxlensv,dv,sizeof(uint32_t)); + if (xendian) tpl_byteswap(fxlensv, sizeof(uint32_t)); + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); + fxlensv++; + } + } + /* if caller requested, peek into the specified data elements */ + if (mode & TPL_DATAPEEK) { + + first_atom = strspn(fmt, "S()"); /* skip any leading S() */ + + datapeek_flen = strlen(datapeek_f); + if (strspn(datapeek_f, tpl_datapeek_ok_chars) < datapeek_flen) { + tpl_hook.oops("invalid TPL_DATAPEEK format: %s\n", datapeek_f); + tpl_hook.free(fmt_cpy); fmt_cpy = NULL; /* fail */ + goto fail; + } + + if (strncmp( &fmt[first_atom], datapeek_f, datapeek_flen) != 0) { + tpl_hook.oops("TPL_DATAPEEK format mismatches tpl iamge\n"); + tpl_hook.free(fmt_cpy); fmt_cpy = NULL; /* fail */ + goto fail; + } + + /* advance to data start, then copy out requested elements */ + dv = (void*)((uintptr_t)dv + (num_fxlens * sizeof(uint32_t))); + for(datapeek_c = datapeek_f; *datapeek_c != '\0'; datapeek_c++) { + datapeek_p = va_arg(ap, void*); + if (*datapeek_c == 's') { /* special handling for strings */ + if ((uintptr_t)dv-(uintptr_t)addr + sizeof(uint32_t) > sz) { + tpl_hook.oops("tpl_peek: tpl has insufficient length\n"); + tpl_hook.free(fmt_cpy); fmt_cpy = NULL; /* fail */ + goto fail; + } + memcpy(&datapeek_ssz,dv,sizeof(uint32_t)); /* get slen */ + if (xendian) tpl_byteswap(&datapeek_ssz, sizeof(uint32_t)); + if (old_string_format) datapeek_ssz++; + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); /* adv. to str */ + if (datapeek_ssz == 0) datapeek_s = NULL; + else { + if ((uintptr_t)dv-(uintptr_t)addr + datapeek_ssz-1 > sz) { + tpl_hook.oops("tpl_peek: tpl has insufficient length\n"); + tpl_hook.free(fmt_cpy); fmt_cpy = NULL; /* fail */ + goto fail; + } + datapeek_s = tpl_hook.malloc(datapeek_ssz); + if (datapeek_s == NULL) fatal_oom(); + memcpy(datapeek_s, dv, datapeek_ssz-1); + datapeek_s[datapeek_ssz-1] = '\0'; + dv = (void*)((uintptr_t)dv + datapeek_ssz-1); + } + *(char**)datapeek_p = datapeek_s; + } else { + datapeek_csz = tpl_size_for(*datapeek_c); + if ((uintptr_t)dv-(uintptr_t)addr + datapeek_csz > sz) { + tpl_hook.oops("tpl_peek: tpl has insufficient length\n"); + tpl_hook.free(fmt_cpy); fmt_cpy = NULL; /* fail */ + goto fail; + } + memcpy(datapeek_p, dv, datapeek_csz); + if (xendian) tpl_byteswap(datapeek_p, datapeek_csz); + dv = (void*)((uintptr_t)dv + datapeek_csz); + } + } + } + +fail: + va_end(ap); + if ((mode & TPL_FILE) && mr.text != NULL) tpl_unmap_file( &mr ); + return fmt_cpy; +} + +/* tpl_jot(TPL_FILE, "file.tpl", "si", &s, &i); */ +/* tpl_jot(TPL_MEM, &buf, &sz, "si", &s, &i); */ +/* tpl_jot(TPL_FD, fd, "si", &s, &i); */ +TPL_API int tpl_jot(int mode, ...) { + va_list ap; + char *filename, *fmt; + size_t *sz; + int fd, rc=0; + void **buf; + tpl_node *tn; + + va_start(ap,mode); + if (mode & TPL_FILE) { + filename = va_arg(ap,char*); + fmt = va_arg(ap,char*); + tn = tpl_map_va(fmt, ap); + if (tn == NULL) { rc=-1; goto fail;} + tpl_pack(tn, 0); + rc = tpl_dump(tn, TPL_FILE, filename); + tpl_free(tn); + } else if (mode & TPL_MEM) { + buf = va_arg(ap,void*); + sz = va_arg(ap,size_t*); + fmt = va_arg(ap,char*); + tn = tpl_map_va(fmt,ap); + if (tn == NULL) { rc=-1; goto fail;} + tpl_pack(tn,0); + rc = tpl_dump(tn, TPL_MEM, buf, sz); + tpl_free(tn); + } else if (mode & TPL_FD) { + fd = va_arg(ap,int); + fmt = va_arg(ap,char*); + tn = tpl_map_va(fmt,ap); + if (tn == NULL) { rc=-1; goto fail;} + tpl_pack(tn,0); + rc = tpl_dump(tn, TPL_FD, fd); + tpl_free(tn); + } else { + tpl_hook.fatal("invalid tpl_jot mode\n"); + } + +fail: + va_end(ap); + return rc; +} + +TPL_API int tpl_load(tpl_node *r, int mode, ...) { + va_list ap; + int rc=0,fd=0; + char *filename=NULL; + void *addr; + size_t sz; + + va_start(ap,mode); + if (mode & TPL_FILE) filename = va_arg(ap,char *); + else if (mode & TPL_MEM) { + addr = va_arg(ap,void *); + sz = va_arg(ap,size_t); + } else if (mode & TPL_FD) { + fd = va_arg(ap,int); + } else { + tpl_hook.oops("unsupported tpl_load mode %d\n", mode); + return -1; + } + va_end(ap); + + if (r->type != TPL_TYPE_ROOT) { + tpl_hook.oops("error: tpl_load to non-root node\n"); + return -1; + } + if (((tpl_root_data*)(r->data))->flags & (TPL_WRONLY|TPL_RDONLY)) { + /* already packed or loaded, so reset it as if newly mapped */ + tpl_free_keep_map(r); + } + if (mode & TPL_FILE) { + if (tpl_mmap_file(filename, &((tpl_root_data*)(r->data))->mmap) != 0) { + tpl_hook.oops("tpl_load failed for file %s\n", filename); + return -1; + } + if ( (rc = tpl_sanity(r, (mode & TPL_EXCESS_OK))) != 0) { + if (rc == ERR_FMT_MISMATCH) { + tpl_hook.oops("%s: format signature mismatch\n", filename); + } else if (rc == ERR_FLEN_MISMATCH) { + tpl_hook.oops("%s: array lengths mismatch\n", filename); + } else { + tpl_hook.oops("%s: not a valid tpl file\n", filename); + } + tpl_unmap_file( &((tpl_root_data*)(r->data))->mmap ); + return -1; + } + ((tpl_root_data*)(r->data))->flags = (TPL_FILE | TPL_RDONLY); + } else if (mode & TPL_MEM) { + ((tpl_root_data*)(r->data))->mmap.text = addr; + ((tpl_root_data*)(r->data))->mmap.text_sz = sz; + if ( (rc = tpl_sanity(r, (mode & TPL_EXCESS_OK))) != 0) { + if (rc == ERR_FMT_MISMATCH) { + tpl_hook.oops("format signature mismatch\n"); + } else { + tpl_hook.oops("not a valid tpl file\n"); + } + return -1; + } + ((tpl_root_data*)(r->data))->flags = (TPL_MEM | TPL_RDONLY); + if (mode & TPL_UFREE) ((tpl_root_data*)(r->data))->flags |= TPL_UFREE; + } else if (mode & TPL_FD) { + /* if fd read succeeds, resulting mem img is used for load */ + if (tpl_gather(TPL_GATHER_BLOCKING,fd,&addr,&sz) > 0) { + return tpl_load(r, TPL_MEM|TPL_UFREE, addr, sz); + } else return -1; + } else { + tpl_hook.oops("invalid tpl_load mode %d\n", mode); + return -1; + } + /* this applies to TPL_MEM or TPL_FILE */ + if (tpl_needs_endian_swap(((tpl_root_data*)(r->data))->mmap.text)) + ((tpl_root_data*)(r->data))->flags |= TPL_XENDIAN; + tpl_unpackA0(r); /* prepare root A nodes for use */ + return 0; +} + +TPL_API int tpl_Alen(tpl_node *r, int i) { + tpl_node *n; + + n = tpl_find_i(r,i); + if (n == NULL) { + tpl_hook.oops("invalid index %d to tpl_unpack\n", i); + return -1; + } + if (n->type != TPL_TYPE_ARY) return -1; + return ((tpl_atyp*)(n->data))->num; +} + +static void tpl_free_atyp(tpl_node *n, tpl_atyp *atyp) { + tpl_backbone *bb,*bbnxt; + tpl_node *c; + void *dv; + tpl_bin *binp; + tpl_atyp *atypp; + char *strp; + size_t itermax; + tpl_pound_data *pd; + int i; + + bb = atyp->bb; + while (bb) { + bbnxt = bb->next; + dv = bb->data; + c=n->children; + while (c) { + switch (c->type) { + case TPL_TYPE_BYTE: + case TPL_TYPE_DOUBLE: + case TPL_TYPE_INT32: + case TPL_TYPE_UINT32: + case TPL_TYPE_INT64: + case TPL_TYPE_UINT64: + case TPL_TYPE_INT16: + case TPL_TYPE_UINT16: + dv = (void*)((uintptr_t)dv + tpl_types[c->type].sz*c->num); + break; + case TPL_TYPE_BIN: + memcpy(&binp,dv,sizeof(tpl_bin*)); /* cp to aligned */ + if (binp->addr) tpl_hook.free( binp->addr ); /* free buf */ + tpl_hook.free(binp); /* free tpl_bin */ + dv = (void*)((uintptr_t)dv + sizeof(tpl_bin*)); + break; + case TPL_TYPE_STR: + for(i=0; i < c->num; i++) { + memcpy(&strp,dv,sizeof(char*)); /* cp to aligned */ + if (strp) tpl_hook.free(strp); /* free string */ + dv = (void*)((uintptr_t)dv + sizeof(char*)); + } + break; + case TPL_TYPE_POUND: + /* iterate over the preceding nodes */ + itermax = c->num; + pd = (tpl_pound_data*)c->data; + if (++(pd->iternum) < itermax) { + c = pd->iter_start_node; + continue; + } else { /* loop complete. */ + pd->iternum = 0; + } + break; + case TPL_TYPE_ARY: + memcpy(&atypp,dv,sizeof(tpl_atyp*)); /* cp to aligned */ + tpl_free_atyp(c,atypp); /* free atyp */ + dv = (void*)((uintptr_t)dv + sizeof(void*)); + break; + default: + tpl_hook.fatal("unsupported format character\n"); + break; + } + c=c->next; + } + tpl_hook.free(bb); + bb = bbnxt; + } + tpl_hook.free(atyp); +} + +/* determine (by walking) byte length of serialized r/A node at address dv + * returns 0 on success, or -1 if the tpl isn't trustworthy (fails consistency) + */ +static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen) { + uint32_t slen; + int num,fidx; + tpl_node *c; + size_t len=0, alen, buf_past, itermax; + tpl_pound_data *pd; + + buf_past = ((uintptr_t)((tpl_root_data*)(r->data))->mmap.text + + ((tpl_root_data*)(r->data))->mmap.text_sz); + + if (n->type == TPL_TYPE_ROOT) num = 1; + else if (n->type == TPL_TYPE_ARY) { + if ((uintptr_t)dv + sizeof(uint32_t) > buf_past) return -1; + memcpy(&num,dv,sizeof(uint32_t)); + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) + tpl_byteswap(&num, sizeof(uint32_t)); + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); + len += sizeof(uint32_t); + } else tpl_hook.fatal("internal error in tpl_serlen\n"); + + while (num-- > 0) { + c=n->children; + while (c) { + switch (c->type) { + case TPL_TYPE_BYTE: + case TPL_TYPE_DOUBLE: + case TPL_TYPE_INT32: + case TPL_TYPE_UINT32: + case TPL_TYPE_INT64: + case TPL_TYPE_UINT64: + case TPL_TYPE_INT16: + case TPL_TYPE_UINT16: + for(fidx=0; fidx < c->num; fidx++) { /* octothorpe support */ + if ((uintptr_t)dv + tpl_types[c->type].sz > buf_past) return -1; + dv = (void*)((uintptr_t)dv + tpl_types[c->type].sz); + len += tpl_types[c->type].sz; + } + break; + case TPL_TYPE_BIN: + len += sizeof(uint32_t); + if ((uintptr_t)dv + sizeof(uint32_t) > buf_past) return -1; + memcpy(&slen,dv,sizeof(uint32_t)); + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) + tpl_byteswap(&slen, sizeof(uint32_t)); + len += slen; + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); + if ((uintptr_t)dv + slen > buf_past) return -1; + dv = (void*)((uintptr_t)dv + slen); + break; + case TPL_TYPE_STR: + for(fidx=0; fidx < c->num; fidx++) { /* octothorpe support */ + len += sizeof(uint32_t); + if ((uintptr_t)dv + sizeof(uint32_t) > buf_past) return -1; + memcpy(&slen,dv,sizeof(uint32_t)); + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) + tpl_byteswap(&slen, sizeof(uint32_t)); + if (!(((tpl_root_data*)(r->data))->flags & TPL_OLD_STRING_FMT)) + slen = (slen>1) ? (slen-1) : 0; + len += slen; + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); + if ((uintptr_t)dv + slen > buf_past) return -1; + dv = (void*)((uintptr_t)dv + slen); + } + break; + case TPL_TYPE_ARY: + if ( tpl_serlen(r,c,dv, &alen) == -1) return -1; + dv = (void*)((uintptr_t)dv + alen); + len += alen; + break; + case TPL_TYPE_POUND: + /* iterate over the preceding nodes */ + itermax = c->num; + pd = (tpl_pound_data*)c->data; + if (++(pd->iternum) < itermax) { + c = pd->iter_start_node; + continue; + } else { /* loop complete. */ + pd->iternum = 0; + } + break; + default: + tpl_hook.fatal("unsupported format character\n"); + break; + } + c=c->next; + } + } + *serlen = len; + return 0; +} + +static int tpl_mmap_output_file(char *filename, size_t sz, void **text_out) { + void *text; + int fd,perms; + +#ifndef _WIN32 + perms = S_IRUSR|S_IWUSR|S_IWGRP|S_IRGRP|S_IROTH; /* ug+w o+r */ + fd=open(filename,O_CREAT|O_TRUNC|O_RDWR,perms); +#else + perms = _S_IWRITE; + fd=_open(filename,_O_CREAT|_O_TRUNC|_O_RDWR,perms); +#endif + + if ( fd == -1 ) { + tpl_hook.oops("Couldn't open file %s: %s\n", filename, strerror(errno)); + return -1; + } + + text = mmap(0, sz, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); + if (text == MAP_FAILED) { + tpl_hook.oops("Failed to mmap %s: %s\n", filename, strerror(errno)); + close(fd); + return -1; + } + if (ftruncate(fd,sz) == -1) { + tpl_hook.oops("ftruncate failed: %s\n", strerror(errno)); + munmap( text, sz ); + close(fd); + return -1; + } + *text_out = text; + return fd; +} + +static int tpl_mmap_file(char *filename, tpl_mmap_rec *mr) { + struct stat stat_buf; + + if ( (mr->fd = open(filename, O_RDONLY)) == -1 ) { + tpl_hook.oops("Couldn't open file %s: %s\n", filename, strerror(errno)); + return -1; + } + + if ( fstat(mr->fd, &stat_buf) == -1) { + close(mr->fd); + tpl_hook.oops("Couldn't stat file %s: %s\n", filename, strerror(errno)); + return -1; + } + + mr->text_sz = (size_t)stat_buf.st_size; + mr->text = mmap(0, stat_buf.st_size, PROT_READ, MAP_PRIVATE, mr->fd, 0); + if (mr->text == MAP_FAILED) { + close(mr->fd); + tpl_hook.oops("Failed to mmap %s: %s\n", filename, strerror(errno)); + return -1; + } + + return 0; +} + +TPL_API int tpl_pack(tpl_node *r, int i) { + tpl_node *n, *child, *np; + void *datav=NULL; + size_t sz, itermax; + uint32_t slen; + char *str; + tpl_bin *bin; + tpl_pound_data *pd; + int fidx; + + n = tpl_find_i(r,i); + if (n == NULL) { + tpl_hook.oops("invalid index %d to tpl_pack\n", i); + return -1; + } + + if (((tpl_root_data*)(r->data))->flags & TPL_RDONLY) { + /* convert to an writeable tpl, initially empty */ + tpl_free_keep_map(r); + } + + ((tpl_root_data*)(r->data))->flags |= TPL_WRONLY; + + if (n->type == TPL_TYPE_ARY) datav = tpl_extend_backbone(n); + child = n->children; + while(child) { + switch(child->type) { + case TPL_TYPE_BYTE: + case TPL_TYPE_DOUBLE: + case TPL_TYPE_INT32: + case TPL_TYPE_UINT32: + case TPL_TYPE_INT64: + case TPL_TYPE_UINT64: + case TPL_TYPE_INT16: + case TPL_TYPE_UINT16: + /* no need to use fidx iteration here; we can copy multiple values in one memcpy */ + memcpy(child->data,child->addr,tpl_types[child->type].sz * child->num); + if (datav) datav = tpl_cpv(datav,child->data,tpl_types[child->type].sz * child->num); + if (n->type == TPL_TYPE_ARY) n->ser_osz += tpl_types[child->type].sz * child->num; + break; + case TPL_TYPE_BIN: + /* copy the buffer to be packed */ + slen = ((tpl_bin*)child->addr)->sz; + if (slen >0) { + str = tpl_hook.malloc(slen); + if (!str) fatal_oom(); + memcpy(str,((tpl_bin*)child->addr)->addr,slen); + } else str = NULL; + /* and make a tpl_bin to point to it */ + bin = tpl_hook.malloc(sizeof(tpl_bin)); + if (!bin) fatal_oom(); + bin->addr = str; + bin->sz = slen; + /* now pack its pointer, first deep freeing any pre-existing bin */ + if (*(tpl_bin**)(child->data) != NULL) { + if ((*(tpl_bin**)(child->data))->sz != 0) { + tpl_hook.free( (*(tpl_bin**)(child->data))->addr ); + } + tpl_hook.free(*(tpl_bin**)(child->data)); + } + memcpy(child->data,&bin,sizeof(tpl_bin*)); + if (datav) { + datav = tpl_cpv(datav, &bin, sizeof(tpl_bin*)); + *(tpl_bin**)(child->data) = NULL; + } + if (n->type == TPL_TYPE_ARY) { + n->ser_osz += sizeof(uint32_t); /* binary buf len word */ + n->ser_osz += bin->sz; /* binary buf */ + } + break; + case TPL_TYPE_STR: + for(fidx=0; fidx < child->num; fidx++) { + /* copy the string to be packed. slen includes \0. this + block also works if the string pointer is NULL. */ + char *caddr = ((char**)child->addr)[fidx]; + char **cdata = &((char**)child->data)[fidx]; + slen = caddr ? (strlen(caddr) + 1) : 0; + if (slen) { + str = tpl_hook.malloc(slen); + if (!str) fatal_oom(); + memcpy(str,caddr,slen); /* include \0 */ + } else { + str = NULL; + } + /* now pack its pointer, first freeing any pre-existing string */ + if (*cdata != NULL) { + tpl_hook.free(*cdata); + } + memcpy(cdata,&str,sizeof(char*)); + if (datav) { + datav = tpl_cpv(datav, &str, sizeof(char*)); + *cdata = NULL; + } + if (n->type == TPL_TYPE_ARY) { + n->ser_osz += sizeof(uint32_t); /* string len word */ + if (slen>1) n->ser_osz += slen-1;/* string (without nul) */ + } + } + break; + case TPL_TYPE_ARY: + /* copy the child's tpl_atype* and reset it to empty */ + if (datav) { + sz = ((tpl_atyp*)(child->data))->sz; + datav = tpl_cpv(datav, &child->data, sizeof(void*)); + child->data = tpl_hook.malloc(sizeof(tpl_atyp)); + if (!child->data) fatal_oom(); + ((tpl_atyp*)(child->data))->num = 0; + ((tpl_atyp*)(child->data))->sz = sz; + ((tpl_atyp*)(child->data))->bb = NULL; + ((tpl_atyp*)(child->data))->bbtail = NULL; + } + /* parent is array? then bubble up child array's ser_osz */ + if (n->type == TPL_TYPE_ARY) { + n->ser_osz += sizeof(uint32_t); /* array len word */ + n->ser_osz += child->ser_osz; /* child array ser_osz */ + child->ser_osz = 0; /* reset child array ser_osz */ + } + break; + + case TPL_TYPE_POUND: + /* we need to iterate n times over preceding nodes in S(...). + * we may be in the midst of an iteration each time or starting. */ + pd = (tpl_pound_data*)child->data; + itermax = child->num; + + /* itermax is total num of iterations needed */ + /* pd->iternum is current iteration index */ + /* pd->inter_elt_len is element-to-element len of contiguous structs */ + /* pd->iter_start_node is where we jump to at each iteration. */ + + if (++(pd->iternum) < itermax) { + + /* in start or midst of loop. advance addr/data pointers. */ + for(np=pd->iter_start_node; np != child; np = np->next) { + np->data = (char*)(np->data) + + (tpl_types[np->type].sz * np->num); + np->addr = (char*)(np->addr) + pd->inter_elt_len; + } + /* do next iteration */ + child = pd->iter_start_node; + continue; + + } else { /* loop complete. */ + + /* reset iteration index and addr/data pointers. */ + pd->iternum = 0; + for(np=pd->iter_start_node; np != child; np = np->next) { + np->data = (char*)(np->data) - ((itermax-1) * + tpl_types[np->type].sz * + np->num); + np->addr = (char*)(np->addr) - ((itermax-1) * pd->inter_elt_len); + } + + } + break; + default: + tpl_hook.fatal("unsupported format character\n"); + break; + } + child=child->next; + } + return 0; +} + +TPL_API int tpl_unpack(tpl_node *r, int i) { + tpl_node *n, *c, *np; + uint32_t slen; + int rc=1, fidx; + char *str; + void *dv=NULL, *caddr; + size_t A_bytes, itermax; + tpl_pound_data *pd; + void *img; + size_t sz; + + + /* handle unusual case of tpl_pack,tpl_unpack without an + * intervening tpl_dump. do a dump/load implicitly. */ + if (((tpl_root_data*)(r->data))->flags & TPL_WRONLY) { + if (tpl_dump(r,TPL_MEM,&img,&sz) != 0) return -1; + if (tpl_load(r,TPL_MEM|TPL_UFREE,img,sz) != 0) { + tpl_hook.free(img); + return -1; + }; + } + + n = tpl_find_i(r,i); + if (n == NULL) { + tpl_hook.oops("invalid index %d to tpl_unpack\n", i); + return -1; + } + + /* either root node or an A node */ + if (n->type == TPL_TYPE_ROOT) { + dv = tpl_find_data_start( ((tpl_root_data*)(n->data))->mmap.text ); + } else if (n->type == TPL_TYPE_ARY) { + if (((tpl_atyp*)(n->data))->num <= 0) return 0; /* array consumed */ + else rc = ((tpl_atyp*)(n->data))->num--; + dv = ((tpl_atyp*)(n->data))->cur; + if (!dv) tpl_hook.fatal("must unpack parent of node before node itself\n"); + } + + c = n->children; + while (c) { + switch (c->type) { + case TPL_TYPE_BYTE: + case TPL_TYPE_DOUBLE: + case TPL_TYPE_INT32: + case TPL_TYPE_UINT32: + case TPL_TYPE_INT64: + case TPL_TYPE_UINT64: + case TPL_TYPE_INT16: + case TPL_TYPE_UINT16: + /* unpack elements of cross-endian octothorpic array individually */ + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) { + for(fidx=0; fidx < c->num; fidx++) { + caddr = (void*)((uintptr_t)c->addr + (fidx * tpl_types[c->type].sz)); + memcpy(caddr,dv,tpl_types[c->type].sz); + tpl_byteswap(caddr, tpl_types[c->type].sz); + dv = (void*)((uintptr_t)dv + tpl_types[c->type].sz); + } + } else { + /* bulk unpack ok if not cross-endian */ + memcpy(c->addr, dv, tpl_types[c->type].sz * c->num); + dv = (void*)((uintptr_t)dv + tpl_types[c->type].sz * c->num); + } + break; + case TPL_TYPE_BIN: + memcpy(&slen,dv,sizeof(uint32_t)); + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) + tpl_byteswap(&slen, sizeof(uint32_t)); + if (slen > 0) { + str = (char*)tpl_hook.malloc(slen); + if (!str) fatal_oom(); + } else str=NULL; + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); + if (slen>0) memcpy(str,dv,slen); + memcpy(&(((tpl_bin*)c->addr)->addr),&str,sizeof(void*)); + memcpy(&(((tpl_bin*)c->addr)->sz),&slen,sizeof(uint32_t)); + dv = (void*)((uintptr_t)dv + slen); + break; + case TPL_TYPE_STR: + for(fidx=0; fidx < c->num; fidx++) { + memcpy(&slen,dv,sizeof(uint32_t)); + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) + tpl_byteswap(&slen, sizeof(uint32_t)); + if (((tpl_root_data*)(r->data))->flags & TPL_OLD_STRING_FMT) + slen += 1; + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); + if (slen) { /* slen includes \0 */ + str = (char*)tpl_hook.malloc(slen); + if (!str) fatal_oom(); + if (slen>1) memcpy(str,dv,slen-1); + str[slen-1] = '\0'; /* nul terminate */ + dv = (void*)((uintptr_t)dv + slen-1); + } else str=NULL; + memcpy(&((char**)c->addr)[fidx],&str,sizeof(char*)); + } + break; + case TPL_TYPE_POUND: + /* iterate over preceding nodes */ + pd = (tpl_pound_data*)c->data; + itermax = c->num; + if (++(pd->iternum) < itermax) { + /* in start or midst of loop. advance addr/data pointers. */ + for(np=pd->iter_start_node; np != c; np = np->next) { + np->addr = (char*)(np->addr) + pd->inter_elt_len; + } + /* do next iteration */ + c = pd->iter_start_node; + continue; + + } else { /* loop complete. */ + + /* reset iteration index and addr/data pointers. */ + pd->iternum = 0; + for(np=pd->iter_start_node; np != c; np = np->next) { + np->addr = (char*)(np->addr) - ((itermax-1) * pd->inter_elt_len); + } + + } + break; + case TPL_TYPE_ARY: + if (tpl_serlen(r,c,dv, &A_bytes) == -1) + tpl_hook.fatal("internal error in unpack\n"); + memcpy( &((tpl_atyp*)(c->data))->num, dv, sizeof(uint32_t)); + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) + tpl_byteswap(&((tpl_atyp*)(c->data))->num, sizeof(uint32_t)); + ((tpl_atyp*)(c->data))->cur = (void*)((uintptr_t)dv+sizeof(uint32_t)); + dv = (void*)((uintptr_t)dv + A_bytes); + break; + default: + tpl_hook.fatal("unsupported format character\n"); + break; + } + + c = c->next; + } + if (n->type == TPL_TYPE_ARY) ((tpl_atyp*)(n->data))->cur = dv; /* next element */ + return rc; +} + +/* Specialized function that unpacks only the root's A nodes, after tpl_load */ +static int tpl_unpackA0(tpl_node *r) { + tpl_node *n, *c; + uint32_t slen; + int rc=1,fidx,i; + void *dv; + size_t A_bytes, itermax; + tpl_pound_data *pd; + + n = r; + dv = tpl_find_data_start( ((tpl_root_data*)(r->data))->mmap.text); + + c=n->children; + while (c) { + switch (c->type) { + case TPL_TYPE_BYTE: + case TPL_TYPE_DOUBLE: + case TPL_TYPE_INT32: + case TPL_TYPE_UINT32: + case TPL_TYPE_INT64: + case TPL_TYPE_UINT64: + case TPL_TYPE_INT16: + case TPL_TYPE_UINT16: + for(fidx=0;fidx < c->num; fidx++) { + dv = (void*)((uintptr_t)dv + tpl_types[c->type].sz); + } + break; + case TPL_TYPE_BIN: + memcpy(&slen,dv,sizeof(uint32_t)); + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) + tpl_byteswap(&slen, sizeof(uint32_t)); + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); + dv = (void*)((uintptr_t)dv + slen); + break; + case TPL_TYPE_STR: + for(i=0; inum; i++) { + memcpy(&slen,dv,sizeof(uint32_t)); + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) + tpl_byteswap(&slen, sizeof(uint32_t)); + if (((tpl_root_data*)(r->data))->flags & TPL_OLD_STRING_FMT) + slen += 1; + dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); + if (slen>1) dv = (void*)((uintptr_t)dv + slen-1); + } + break; + case TPL_TYPE_POUND: + /* iterate over the preceding nodes */ + itermax = c->num; + pd = (tpl_pound_data*)c->data; + if (++(pd->iternum) < itermax) { + c = pd->iter_start_node; + continue; + } else { /* loop complete. */ + pd->iternum = 0; + } + break; + case TPL_TYPE_ARY: + if ( tpl_serlen(r,c,dv, &A_bytes) == -1) + tpl_hook.fatal("internal error in unpackA0\n"); + memcpy( &((tpl_atyp*)(c->data))->num, dv, sizeof(uint32_t)); + if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) + tpl_byteswap(&((tpl_atyp*)(c->data))->num, sizeof(uint32_t)); + ((tpl_atyp*)(c->data))->cur = (void*)((uintptr_t)dv+sizeof(uint32_t)); + dv = (void*)((uintptr_t)dv + A_bytes); + break; + default: + tpl_hook.fatal("unsupported format character\n"); + break; + } + c=c->next; + } + return rc; +} + +/* In-place byte order swapping of a word of length "len" bytes */ +static void tpl_byteswap(void *word, int len) { + int i; + char c, *w; + w = (char*)word; + for(i=0; i0) ? rc : 0; + } while ((rc==-1 && (errno==EINTR||errno==EAGAIN)) || (rc>0 && i<8)); + + if (rc<0) { + tpl_hook.oops("tpl_gather_fd_blocking failed: %s\n", strerror(errno)); + return -1; + } else if (rc == 0) { + /* tpl_hook.oops("tpl_gather_fd_blocking: eof\n"); */ + return 0; + } else if (i != 8) { + tpl_hook.oops("internal error\n"); + return -1; + } + + if (preamble[0] == 't' && preamble[1] == 'p' && preamble[2] == 'l') { + memcpy(&tpllen,&preamble[4],4); + if (tpl_needs_endian_swap(preamble)) tpl_byteswap(&tpllen,4); + } else { + tpl_hook.oops("tpl_gather_fd_blocking: non-tpl input\n"); + return -1; + } + + /* malloc space for remainder of tpl image (overall length tpllen) + * and read it in + */ + if (tpl_hook.gather_max > 0 && + tpllen > tpl_hook.gather_max) { + tpl_hook.oops("tpl exceeds max length %d\n", + tpl_hook.gather_max); + return -2; + } + *sz = tpllen; + if ( (*img = tpl_hook.malloc(tpllen)) == NULL) { + fatal_oom(); + } + + memcpy(*img,preamble,8); /* copy preamble to output buffer */ + i=8; + do { + rc = read(fd,&((*(char**)img)[i]),tpllen-i); + i += (rc>0) ? rc : 0; + } while ((rc==-1 && (errno==EINTR||errno==EAGAIN)) || (rc>0 && iimg); + tpl_hook.free(*gs); + *gs = NULL; + } + return -1; /* error, caller should close fd */ + } + } else if (rc == 0) { + if (*gs) { + tpl_hook.oops("tpl_gather: partial tpl image precedes EOF\n"); + tpl_hook.free((*gs)->img); + tpl_hook.free(*gs); + *gs = NULL; + } + return 0; /* EOF, caller should close fd */ + } else { + /* concatenate any partial tpl from last read with new buffer */ + if (*gs) { + catlen = (*gs)->len + rc; + if (tpl_hook.gather_max > 0 && + catlen > tpl_hook.gather_max) { + tpl_hook.free( (*gs)->img ); + tpl_hook.free( (*gs) ); + *gs = NULL; + tpl_hook.oops("tpl exceeds max length %d\n", + tpl_hook.gather_max); + return -2; /* error, caller should close fd */ + } + if ( (img = tpl_hook.realloc((*gs)->img, catlen)) == NULL) { + fatal_oom(); + } + memcpy(img + (*gs)->len, buf, rc); + tpl_hook.free(*gs); + *gs = NULL; + } else { + img = buf; + catlen = rc; + } + /* isolate any full tpl(s) in img and invoke cb for each */ + tpl = img; + keep_looping = (tpl+8 < img+catlen) ? 1 : 0; + while (keep_looping) { + if (strncmp("tpl", tpl, 3) != 0) { + tpl_hook.oops("tpl prefix invalid\n"); + if (img != buf) tpl_hook.free(img); + tpl_hook.free(*gs); + *gs = NULL; + return -3; /* error, caller should close fd */ + } + memcpy(&tpllen,&tpl[4],4); + if (tpl_needs_endian_swap(tpl)) tpl_byteswap(&tpllen,4); + if (tpl+tpllen <= img+catlen) { + cbrc = (cb)(tpl,tpllen,data); /* invoke cb for tpl image */ + tpl += tpllen; /* point to next tpl image */ + if (cbrc < 0) keep_looping = 0; + else keep_looping = (tpl+8 < img+catlen) ? 1 : 0; + } else keep_looping=0; + } + /* check if app callback requested closure of tpl source */ + if (cbrc < 0) { + tpl_hook.oops("tpl_fd_gather aborted by app callback\n"); + if (img != buf) tpl_hook.free(img); + if (*gs) tpl_hook.free(*gs); + *gs = NULL; + return -4; + } + /* store any leftover, partial tpl fragment for next read */ + if (tpl == img && img != buf) { + /* consumed nothing from img!=buf */ + if ( (*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL ) { + fatal_oom(); + } + (*gs)->img = tpl; + (*gs)->len = catlen; + } else if (tpl < img+catlen) { + /* consumed 1+ tpl(s) from img!=buf or 0 from img==buf */ + if ( (*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL ) { + fatal_oom(); + } + if ( ((*gs)->img = tpl_hook.malloc(img+catlen - tpl)) == NULL ) { + fatal_oom(); + } + (*gs)->len = img+catlen - tpl; + memcpy( (*gs)->img, tpl, img+catlen - tpl); + /* free partially consumed concat buffer if used */ + if (img != buf) tpl_hook.free(img); + } else { /* tpl(s) fully consumed */ + /* free consumed concat buffer if used */ + if (img != buf) tpl_hook.free(img); + } + } + } +} + +/* gather tpl piecemeal from memory buffer (not fd) e.g., from a lower-level api */ +static int tpl_gather_mem( char *buf, size_t len, tpl_gather_t **gs, tpl_gather_cb *cb, void *data) { + char *img, *tpl; + int keep_looping, cbrc=0; + size_t catlen; + uint32_t tpllen; + + /* concatenate any partial tpl from last read with new buffer */ + if (*gs) { + catlen = (*gs)->len + len; + if (tpl_hook.gather_max > 0 && + catlen > tpl_hook.gather_max) { + tpl_hook.free( (*gs)->img ); + tpl_hook.free( (*gs) ); + *gs = NULL; + tpl_hook.oops("tpl exceeds max length %d\n", + tpl_hook.gather_max); + return -2; /* error, caller should stop accepting input from source*/ + } + if ( (img = tpl_hook.realloc((*gs)->img, catlen)) == NULL) { + fatal_oom(); + } + memcpy(img + (*gs)->len, buf, len); + tpl_hook.free(*gs); + *gs = NULL; + } else { + img = buf; + catlen = len; + } + /* isolate any full tpl(s) in img and invoke cb for each */ + tpl = img; + keep_looping = (tpl+8 < img+catlen) ? 1 : 0; + while (keep_looping) { + if (strncmp("tpl", tpl, 3) != 0) { + tpl_hook.oops("tpl prefix invalid\n"); + if (img != buf) tpl_hook.free(img); + tpl_hook.free(*gs); + *gs = NULL; + return -3; /* error, caller should stop accepting input from source*/ + } + memcpy(&tpllen,&tpl[4],4); + if (tpl_needs_endian_swap(tpl)) tpl_byteswap(&tpllen,4); + if (tpl+tpllen <= img+catlen) { + cbrc = (cb)(tpl,tpllen,data); /* invoke cb for tpl image */ + tpl += tpllen; /* point to next tpl image */ + if (cbrc < 0) keep_looping = 0; + else keep_looping = (tpl+8 < img+catlen) ? 1 : 0; + } else keep_looping=0; + } + /* check if app callback requested closure of tpl source */ + if (cbrc < 0) { + tpl_hook.oops("tpl_mem_gather aborted by app callback\n"); + if (img != buf) tpl_hook.free(img); + if (*gs) tpl_hook.free(*gs); + *gs = NULL; + return -4; + } + /* store any leftover, partial tpl fragment for next read */ + if (tpl == img && img != buf) { + /* consumed nothing from img!=buf */ + if ( (*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL ) { + fatal_oom(); + } + (*gs)->img = tpl; + (*gs)->len = catlen; + } else if (tpl < img+catlen) { + /* consumed 1+ tpl(s) from img!=buf or 0 from img==buf */ + if ( (*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL ) { + fatal_oom(); + } + if ( ((*gs)->img = tpl_hook.malloc(img+catlen - tpl)) == NULL ) { + fatal_oom(); + } + (*gs)->len = img+catlen - tpl; + memcpy( (*gs)->img, tpl, img+catlen - tpl); + /* free partially consumed concat buffer if used */ + if (img != buf) tpl_hook.free(img); + } else { /* tpl(s) fully consumed */ + /* free consumed concat buffer if used */ + if (img != buf) tpl_hook.free(img); + } + return 1; +} diff --git a/email-core/CMakeLists.txt b/email-core/CMakeLists.txt index 864695f..3b38b85 100755 --- a/email-core/CMakeLists.txt +++ b/email-core/CMakeLists.txt @@ -72,7 +72,7 @@ INCLUDE_DIRECTORIES( INCLUDE(FindPkgConfig) -pkg_check_modules(storage_pkgs REQUIRED drm-service glib-2.0 dlog db-util openssl vconf secure-storage dbus-1 contacts-service) +pkg_check_modules(storage_pkgs REQUIRED drm-client glib-2.0 dlog db-util openssl vconf secure-storage dbus-1 contacts-service) set(EXTRA_CFLAGS "") FOREACH(flag ${storage_pkgs_CFLAGS}) @@ -151,6 +151,8 @@ SET(CORE-SRCS ${CMAKE_SOURCE_DIR}/email-core/email-core-global.c ${CMAKE_SOURCE_DIR}/email-core/email-core-account.c ${CMAKE_SOURCE_DIR}/email-core/email-core-mime.c + ${CMAKE_SOURCE_DIR}/email-core/email-core-smime.c + ${CMAKE_SOURCE_DIR}/email-core/email-core-cert.c ${CMAKE_SOURCE_DIR}/email-core/email-core-sound.c ) @@ -165,7 +167,7 @@ INCLUDE_DIRECTORIES( INCLUDE(FindPkgConfig) -pkg_check_modules(core_pkgs REQUIRED glib-2.0 drm-service dlog dbus-1 gthread-2.0 uw-imap-toolkit vconf contacts-service secure-storage openssl accounts-svc mm-player mm-session devman_haptic alarm-service notification libcurl libxml-2.0) +pkg_check_modules(core_pkgs REQUIRED glib-2.0 drm-client dlog dbus-1 gthread-2.0 uw-imap-toolkit vconf contacts-service secure-storage openssl accounts-svc mm-player mm-session devman_haptic alarm-service notification libcurl libxml-2.0 cert-svc) set(EXTRA_CFLAGS "") FOREACH(flag ${core_pkgs_CFLAGS}) diff --git a/email-core/email-core-account.c b/email-core/email-core-account.c index 76add79..04c84a7 100755 --- a/email-core/email-core-account.c +++ b/email-core/email-core-account.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Kyuho Jo , Sunghyun Kwon -* +* * 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 @@ -24,9 +24,9 @@ * File : email-core-account.c * Desc : Account Management * - * Auth : Kyuho Jo + * Auth : Kyuho Jo * - * History : + * History : * 2010.08.25 : created *****************************************************************************/ #include @@ -46,54 +46,50 @@ #include "email-core-utils.h" #include "email-core-event.h" #include "email-core-global.h" -#include "email-core-account.h" +#include "email-core-account.h" #include "email-core-mailbox.h" #include "email-core-imap-mailbox.h" -#ifdef __FEATURE_USING_MY_ACCOUNT__ -#include "account.h" -#endif /* __FEATURE_USING_MY_ACCOUNT__ */ - -char *g_default_mbox_alias[MAILBOX_COUNT] = +char *g_default_mbox_alias[MAILBOX_COUNT] = { - EMF_INBOX_DISPLAY_NAME, - EMF_DRAFTBOX_DISPLAY_NAME, - EMF_OUTBOX_DISPLAY_NAME, - EMF_SENTBOX_DISPLAY_NAME, - EMF_TRASH_DISPLAY_NAME, - EMF_SPAMBOX_DISPLAY_NAME, + EMAIL_INBOX_DISPLAY_NAME, + EMAIL_DRAFTBOX_DISPLAY_NAME, + EMAIL_OUTBOX_DISPLAY_NAME, + EMAIL_SENTBOX_DISPLAY_NAME, + EMAIL_TRASH_DISPLAY_NAME, + EMAIL_SPAMBOX_DISPLAY_NAME, }; -char *g_default_mbox_name[MAILBOX_COUNT] = +char *g_default_mbox_name[MAILBOX_COUNT] = { - EMF_INBOX_NAME, - EMF_DRAFTBOX_NAME, - EMF_OUTBOX_NAME, - EMF_SENTBOX_NAME, - EMF_TRASH_DISPLAY_NAME, - EMF_SPAMBOX_NAME, + EMAIL_INBOX_NAME, + EMAIL_DRAFTBOX_NAME, + EMAIL_OUTBOX_NAME, + EMAIL_SENTBOX_NAME, + EMAIL_TRASH_DISPLAY_NAME, + EMAIL_SPAMBOX_NAME, }; -emf_mailbox_type_e g_default_mbox_type[MAILBOX_COUNT] = +email_mailbox_type_e g_default_mbox_type[MAILBOX_COUNT] = { - EMF_MAILBOX_TYPE_INBOX, - EMF_MAILBOX_TYPE_DRAFT, - EMF_MAILBOX_TYPE_OUTBOX, - EMF_MAILBOX_TYPE_SENTBOX, - EMF_MAILBOX_TYPE_TRASH, - EMF_MAILBOX_TYPE_SPAMBOX, + EMAIL_MAILBOX_TYPE_INBOX, + EMAIL_MAILBOX_TYPE_DRAFT, + EMAIL_MAILBOX_TYPE_OUTBOX, + EMAIL_MAILBOX_TYPE_SENTBOX, + EMAIL_MAILBOX_TYPE_TRASH, + EMAIL_MAILBOX_TYPE_SPAMBOX, }; -INTERNAL_FUNC emf_account_t* emcore_get_account_reference(int account_id) +INTERNAL_FUNC email_account_t* emcore_get_account_reference(int account_id) { EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id); EM_PROFILE_BEGIN(profile_emcore_get_account_reference); - emf_account_list_t **p; + email_account_list_t **p; if (account_id == NEW_ACCOUNT_ID) return emcore_get_new_account_reference(); - if (account_id > 0) { + if (account_id > 0) { p = &g_account_list; while (*p) { if ((*p)->account->account_id == account_id) @@ -107,30 +103,30 @@ INTERNAL_FUNC emf_account_t* emcore_get_account_reference(int account_id) while (*p) { if ((*p)->account->account_id == account_id) return ((*p)->account); - + p = &(*p)->next; } } } - + EM_PROFILE_END(profile_emcore_get_account_reference); EM_DEBUG_FUNC_END(); return NULL; } -INTERNAL_FUNC int emcore_validate_account_with_account_info(emf_account_t *account, int *err_code) +INTERNAL_FUNC int emcore_validate_account_with_account_info(email_account_t *account, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account[%p], err_code[%p], receiving_server_addr [%s]", account, err_code, account->receiving_server_addr); + EM_DEBUG_FUNC_BEGIN("account[%p], err_code[%p], incoming_server_address [%s]", account, err_code, account->incoming_server_address); int ret = false; - int err = EMF_ERROR_NONE; - emf_session_t *session = NULL; + int err = EMAIL_ERROR_NONE; + email_session_t *session = NULL; SENDSTREAM *stream = NULL; MAILSTREAM *tmp_stream = NULL; - if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + if (!emcore_check_thread_status()) { + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -140,69 +136,69 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(emf_account_t *accou } EM_DEBUG_LOG("Network available"); - if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + if (!emcore_check_thread_status()) { + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } - if (!emcore_get_empty_session(&session)) { + if (!emcore_get_empty_session(&session)) { EM_DEBUG_EXCEPTION("emcore_get_empty_session failed..."); - err = EMF_ERROR_SESSION_NOT_FOUND; + err = EMAIL_ERROR_SESSION_NOT_FOUND; goto FINISH_OFF; } -#ifdef _SMTP_ACCOUNT_VALIDATION_ +#ifdef _SMTP_ACCOUNT_VALIDATION_ /* validate connection for smt */ EM_DEBUG_LOG("Validate connection for SMTP"); if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } if (!emcore_connect_to_remote_mailbox_with_account_info(account, (char *)ENCODED_PATH_SMTP, (void **)&stream, &err) || !stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed 1 - %d", err); - if (EMF_ERROR_AUTHENTICATE == err || EMF_ERROR_LOGIN_FAILURE == err) { /* wrong password or etc */ + 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 fail 1- %d", err); goto FINISH_OFF; } - if (account->sending_security == 0x01) /* 0x01 == ss */ { + if (account->outgoing_server_secure_connection == 0x01) /* 0x01 == ss */ { /* retry with tl */ EM_DEBUG_LOG("Retry with TLS"); - account->sending_security = 0x02; /* 0x02 == tl */ + account->outgoing_server_secure_connection = 0x02; /* 0x02 == tl */ if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } - + if (!emcore_connect_to_remote_mailbox_with_account_info(account, (char *)ENCODED_PATH_SMTP, (void **)&stream, &err) || !stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed 2 - %d", err); - if (EMF_ERROR_AUTHENTICATE == err || EMF_ERROR_LOGIN_FAILURE == err) { /* wrong password or etc */ + 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 fail 2 - %d", err); - } - else if (EMF_ERROR_CONNECTION_FAILURE != err) { - err = EMF_ERROR_VALIDATE_ACCOUNT; } - account->sending_security = 0x01; /* restore to the previous value */ + else if (EMAIL_ERROR_CONNECTION_FAILURE != err) { + err = EMAIL_ERROR_VALIDATE_ACCOUNT; + } + account->outgoing_server_secure_connection = 0x01; /* restore to the previous value */ goto FINISH_OFF; } if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } - /* save sending_security = 0x02 (tls) to the d */ + /* save outgoing_server_secure_connection = 0x02 (tls) to the d */ if (!emstorage_update_account(account_id, (emstorage_account_tbl_t *)account, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_update_account failed - %d", err); - account->sending_security = 0x01; /* restore to the previous value */ - err = EMF_ERROR_VALIDATE_ACCOUNT; + account->outgoing_server_secure_connection = 0x01; /* restore to the previous value */ + err = EMAIL_ERROR_VALIDATE_ACCOUNT; goto FINISH_OFF; } } else { - if (EMF_ERROR_CONNECTION_FAILURE != err) - err = EMF_ERROR_VALIDATE_ACCOUNT; + if (EMAIL_ERROR_CONNECTION_FAILURE != err) + err = EMAIL_ERROR_VALIDATE_ACCOUNT; goto FINISH_OFF; } } @@ -210,38 +206,38 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(emf_account_t *accou /* validate connection for pop3/ima */ EM_DEBUG_LOG("Validate connection for POP3/IMAP4"); - if (EMF_ERROR_NONE == err) { + if (EMAIL_ERROR_NONE == err) { if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; - goto FINISH_OFF; + err = EMAIL_ERROR_CANCELLED; + goto FINISH_OFF; } - - if (!emcore_connect_to_remote_mailbox_with_account_info(account, NULL, (void **)&tmp_stream, &err) || !tmp_stream) + + if (!emcore_connect_to_remote_mailbox_with_account_info(account, 0, (void **)&tmp_stream, &err) || !tmp_stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed - %d", err); - if (EMF_ERROR_AUTHENTICATE == err || EMF_ERROR_LOGIN_FAILURE == err) { /* wrong password or etc */ + 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); } - else if (EMF_ERROR_CONNECTION_FAILURE != err) { - /* err = EMF_ERROR_VALIDATE_ACCOUNT */ + else if (EMAIL_ERROR_CONNECTION_FAILURE != err) { + /* err = EMAIL_ERROR_VALIDATE_ACCOUNT */ } goto FINISH_OFF; - } + } } - + if (!emcore_check_thread_status()) { - if (!emcore_delete_account_(account->account_id, NULL)) + if (!emcore_delete_account(account->account_id, NULL)) EM_DEBUG_EXCEPTION("emdaemon_delete_account failed [%d]", account->account_id); - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } - + ret = true; -FINISH_OFF: +FINISH_OFF: if (stream) smtp_close(stream); - + if (tmp_stream) emcore_close_mailbox(0 , tmp_stream); @@ -259,14 +255,14 @@ INTERNAL_FUNC int emcore_validate_account(int account_id, int *err_code) { EM_DEBUG_FUNC_BEGIN("account_id[%d], err_code[%p]", account_id, err_code); - int err = EMF_ERROR_NONE, ret = false; - emf_account_t *ref_account = NULL; + int err = EMAIL_ERROR_NONE, ret = false; + email_account_t *ref_account = NULL; - if (account_id <= 0) + if (account_id <= 0) { EM_DEBUG_EXCEPTION("account_id[%p]", account_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -279,7 +275,7 @@ INTERNAL_FUNC int emcore_validate_account(int account_id, int *err_code) ret = true; -FINISH_OFF: +FINISH_OFF: if (err_code) *err_code = err; @@ -289,31 +285,31 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_delete_account_(int account_id, int *err_code) +INTERNAL_FUNC int emcore_delete_account(int account_id, int *err_code) { EM_DEBUG_FUNC_BEGIN("account_id[%d], err_code[%p]", account_id, err_code); - + /* default variabl */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (account_id < FIRST_ACCOUNT_ID) { + if (account_id < FIRST_ACCOUNT_ID) { EM_DEBUG_EXCEPTION("account_id[%d]", account_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } -#ifdef __FEATURE_LOCAL_ACTIVITY__ +#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; - + if (!emcore_delete_activity(&activity, &err)) { EM_DEBUG_LOG("\t emcore_delete_activity failed - %d", err); - + goto FINISH_OFF; } -#endif +#endif #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__ if (false == emcore_clear_partial_body_thd_event_que(&err)) @@ -321,60 +317,39 @@ INTERNAL_FUNC int emcore_delete_account_(int account_id, int *err_code) if (false == emstorage_delete_full_pbd_activity_data(account_id, true, &err)) EM_DEBUG_EXCEPTION("emstorage_delete_full_pbd_activity_data failed [%d]", err); - -#endif -#ifdef __FEATURE_USING_MY_ACCOUNT__ - { - int error_code; - emf_account_t *account_to_be_deleted; - - account_to_be_deleted = emcore_get_account_reference(account_id); - if (account_to_be_deleted && account_to_be_deleted->receiving_server_type != EMF_SERVER_TYPE_ACTIVE_SYNC) { - EM_DEBUG_LOG("Calling account_svc_delete with my_account_id[%d]", account_to_be_deleted->my_account_id); - error_code = account_connect(); - EM_DEBUG_LOG("account_connect returns [%d]", error_code); - account_delete_from_db_by_id(account_to_be_deleted->my_account_id); - error_code = account_disconnect(); - EM_DEBUG_LOG("account_disconnect returns [%d]", error_code); - } - } #endif - if (emcore_cancel_all_threads_of_an_account(account_id) < EMF_ERROR_NONE) { + + if (emcore_cancel_all_threads_of_an_account(account_id) < EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("There are some remaining jobs. I couldn't stop them."); - err = EMF_ERROR_CANNOT_STOP_THREAD; + err = EMAIL_ERROR_CANNOT_STOP_THREAD; goto FINISH_OFF; } - - emf_mailbox_t mbox; /* BEGIN TRANSACTION; */ emstorage_begin_transaction(NULL, NULL, NULL); if (!emstorage_delete_account(account_id, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_delete_account failed - %d", err); + EM_DEBUG_EXCEPTION("emstorage_delete_account failed [%d]", err); goto FINISH_OFF; } - + #ifdef __FEATURE_KEEP_CONNECTION__ /* emcore_reset_streams(); */ emcore_remove_connection_info(account_id); #endif - mbox.account_id = account_id; - mbox.name = NULL; - - if (!emcore_delete_mail_all(&mbox, 0, &err)) { - EM_DEBUG_EXCEPTION("emcore_delete_mail_all failed - %d", err); + if ((err = emcore_delete_all_mails_of_acount(account_id)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_acount failed [%d]", err); goto FINISH_OFF; } - + /* delete all mailboxe */ - if (!emstorage_delete_mailbox(account_id, -1, NULL, false, &err)) { + if (!emstorage_delete_mailbox(account_id, -1, 0, false, &err)) { EM_DEBUG_EXCEPTION("emstorage_delete_mailbox failed - %d", err); goto FINISH_OFF; } - + /* delete local imap sync mailbox from imap mailbox tabl */ if (!emstorage_remove_downloaded_mail(account_id, NULL, NULL, false, &err)) { EM_DEBUG_EXCEPTION("emstorage_remove_downloaded_mail failed - %d", err); @@ -384,13 +359,13 @@ INTERNAL_FUNC int emcore_delete_account_(int account_id, int *err_code) emcore_check_unread_mail(); emcore_delete_notification_by_account(account_id); emcore_refresh_account_reference(); - + ret = true; - -FINISH_OFF: + +FINISH_OFF: if (ret == true) { /* COMMIT TRANSACTION; */ if (emstorage_commit_transaction(NULL, NULL, NULL) == false) { - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; ret = false; } if (!emstorage_notify_storage_event(NOTI_ACCOUNT_DELETE, account_id, 0, NULL, 0)) @@ -399,10 +374,10 @@ FINISH_OFF: } else { /* ROLLBACK TRANSACTION; */ if (emstorage_rollback_transaction(NULL, NULL, NULL) == false) - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; if (!emstorage_notify_storage_event(NOTI_ACCOUNT_DELETE_FAIL, account_id, err, NULL, 0)) EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event[ NOTI_ACCOUNT_DELETE] : Notification Failed >>> "); - } + } if (err_code) *err_code = err; @@ -412,84 +387,57 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_create_account(emf_account_t *account, int *err_code) +INTERNAL_FUNC int emcore_create_account(email_account_t *account, int *err_code) { EM_DEBUG_FUNC_BEGIN("account[%p], err_code[%p]", account, err_code); - + int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int i, count = 0, is_preset_IMAP_account = false; - emf_mailbox_t local_mailbox = {0}; + email_mailbox_t local_mailbox = {0}; emstorage_account_tbl_t *temp_account_tbl = NULL; - + if (!account) { EM_DEBUG_EXCEPTION("account[%p]", account); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - + if (!emstorage_get_account_count(&count, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_account_count failed - %d", err); goto FINISH_OFF; } - if (count >= EMF_ACCOUNT_MAX) { + if (count >= EMAIL_ACCOUNT_MAX) { EM_DEBUG_EXCEPTION("too many accounts..."); - err = EMF_ERROR_ACCOUNT_MAX_COUNT; + err = EMAIL_ERROR_ACCOUNT_MAX_COUNT; goto FINISH_OFF; } account->account_id = 0; - /* check for email address validation */ - EM_DEBUG_LOG("account->email_addr[%s]", account->email_addr); - if (account->email_addr) { - if (!em_verify_email_address(account->email_addr, true, &err)) { - err = EMF_ERROR_INVALID_ADDRESS; - EM_DEBUG_EXCEPTION("Invalid Email Address"); - goto FINISH_OFF; - } + /* Temporarily code - begin */ + if (account->auto_download_size == 0) { + account->auto_download_size = PARTIAL_BODY_SIZE_IN_BYTES; + EM_DEBUG_LOG("account->auto_download_size [%d]", account->auto_download_size); } -#ifdef __FEATURE_USING_MY_ACCOUNT__ - if (account->receiving_server_type != EMF_SERVER_TYPE_ACTIVE_SYNC) { - int account_svc_id = 0; - int error_code; - account_h account_handle = NULL; - - error_code = account_connect(); - error_code = account_create(&account_handle); - - if(error_code != ACCOUNT_ERROR_NONE) { - EM_DEBUG_EXCEPTION("account_create failed [%d]", error_code); - err = error_code; - goto FINISH_OFF; - } + if (account->default_mail_slot_size == 0) { + account->default_mail_slot_size = 50; + EM_DEBUG_LOG("account->default_mail_slot_size [%d]", account->default_mail_slot_size); + } + /* Temporarily code - end */ - account_set_user_name(account_handle, account->user_name); - account_set_domain_name(account_handle, account->account_name); - account_set_email_address(account_handle, account->email_addr); - account_set_source(account_handle, "SLP EMAIL"); - account_set_package_name(account_handle, "email-setting-efl"); - account_set_capability(account_handle , ACCOUNT_CAPABILITY_EMAIL, ACCOUNT_CAPABILITY_ENABLED); - if (account->logo_icon_path) - account_set_icon_path(account_handle, account->logo_icon_path); - error_code = account_insert_to_db(account_handle, &account_svc_id); - - if (error_code != ACCOUNT_ERROR_NONE) { - EM_DEBUG_EXCEPTION("account_insert_to_db failed [%d]", error_code); - err = error_code; + /* check for email address validation */ + EM_DEBUG_LOG("account->user_email_address[%s]", account->user_email_address); + if (account->user_email_address) { + if (!em_verify_email_address(account->user_email_address, true, &err)) { + err = EMAIL_ERROR_INVALID_ADDRESS; + EM_DEBUG_EXCEPTION("Invalid Email Address"); goto FINISH_OFF; } - - account->my_account_id = account_svc_id; - - EM_DEBUG_LOG("account_insert_to_db succeed"); - - account_disconnect(); } -#endif /* __FEATURE_USING_MY_ACCOUNT__ */ temp_account_tbl = em_malloc(sizeof(emstorage_account_tbl_t)); if (!temp_account_tbl) { @@ -503,25 +451,23 @@ INTERNAL_FUNC int emcore_create_account(emf_account_t *account, int *err_code) goto FINISH_OFF; } account->account_id = temp_account_tbl->account_id; - is_preset_IMAP_account = ((account->receiving_server_type == EMF_SERVER_TYPE_IMAP4)) ? true : false;/* && (account->preset_account)) ? true : false */ + is_preset_IMAP_account = ((account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4)) ? true : false;/* && (account->is_preset_account)) ? true : false */ EM_DEBUG_LOG("is_preset_IMAP_account : %d", is_preset_IMAP_account); - if ((account->receiving_server_type != EMF_SERVER_TYPE_ACTIVE_SYNC) && (!is_preset_IMAP_account)) { + if ((account->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) && (!is_preset_IMAP_account)) { /* 1. create default local mailbox * (Inbox, Draft, Outbox, Sentbox) */ for (i = 0; i < MAILBOX_COUNT; i++) { EM_DEBUG_LOG("g_default_mbox_name [%d/%d] is [%s]", i, MAILBOX_COUNT, g_default_mbox_name[i]); local_mailbox.account_id = temp_account_tbl->account_id; - local_mailbox.name = g_default_mbox_name[i]; + local_mailbox.mailbox_name = g_default_mbox_name[i]; local_mailbox.mailbox_type = g_default_mbox_type[i]; - if (local_mailbox.mailbox_type == EMF_MAILBOX_TYPE_INBOX) { - local_mailbox.local = EMF_MAILBOX_FROM_SERVER; - local_mailbox.synchronous = 1; + if (local_mailbox.mailbox_type == EMAIL_MAILBOX_TYPE_INBOX) { + local_mailbox.local = EMAIL_MAILBOX_FROM_SERVER; } else { - local_mailbox.local = EMF_MAILBOX_FROM_LOCAL; - local_mailbox.synchronous = 0; + local_mailbox.local = EMAIL_MAILBOX_FROM_LOCAL; } local_mailbox.alias = g_default_mbox_alias[i]; emcore_get_default_mail_slot_count(&local_mailbox.mail_slot_size, NULL); @@ -543,7 +489,7 @@ FINISH_OFF: emstorage_free_account(&temp_account_tbl, 1, NULL); if (ret == false && account != NULL) { - if (!emcore_delete_account_(account->account_id, NULL)) + if (!emcore_delete_account(account->account_id, NULL)) EM_DEBUG_EXCEPTION("emdaemon_delete_account Failed [%d]", account->account_id); } @@ -559,12 +505,11 @@ INTERNAL_FUNC int emcore_init_account_reference() { EM_DEBUG_FUNC_BEGIN(); - int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - emf_account_list_t *account_list = NULL; - emf_account_list_t **p = NULL; - emf_account_t *account = NULL; + 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; @@ -572,31 +517,30 @@ INTERNAL_FUNC int emcore_init_account_reference() if (!g_account_retrieved) { count = 1000; if (!emstorage_get_account_list(&count, &account_tbl_array, true, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_account_list failed - %d", err); + EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err); goto FINISH_OFF; } for (p = &account_list, i = 0; i < count; i++) { - account = malloc(sizeof(emf_account_t)); + account = em_malloc(sizeof(email_account_t)); if (!account) { EM_DEBUG_EXCEPTION("malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } em_convert_account_tbl_to_account(account_tbl_array + i, account); - /* memcpy(account, accounts + i, sizeof(emf_account_t)) */ - /* memset(accounts + i, 0x00, sizeof(emf_account_t)) */ + /* memcpy(account, accounts + i, sizeof(email_account_t)) */ + /* memset(accounts + i, 0x00, sizeof(email_account_t)) */ - (*p) = malloc(sizeof(emf_account_list_t)); + *p = (email_account_list_t*) em_malloc(sizeof(email_account_list_t)); if (!(*p)) { EM_DEBUG_EXCEPTION("malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - memset((*p), 0x00, sizeof(emf_account_list_t)); (*p)->account = account; @@ -609,19 +553,17 @@ INTERNAL_FUNC int emcore_init_account_reference() g_account_list = account_list; } - ret = true; - FINISH_OFF: - if (account_tbl_array != NULL) + if (account_tbl_array) emstorage_free_account(&account_tbl_array, count, NULL); - if (!ret) { + if (err != EMAIL_ERROR_NONE) { g_account_list = account_list; emcore_free_account_reference(); } - EM_DEBUG_FUNC_END("ret [%d]", ret); - return ret; + EM_DEBUG_FUNC_END("err [%d]", err); + return err; } INTERNAL_FUNC int emcore_refresh_account_reference() @@ -635,7 +577,7 @@ INTERNAL_FUNC int emcore_refresh_account_reference() g_account_num = 0; g_account_list = NULL; - if (!emcore_init_account_reference()) { + if (emcore_init_account_reference() != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emcore_init_account_reference failed..."); return false; } @@ -647,12 +589,14 @@ INTERNAL_FUNC int emcore_free_account_reference() { EM_DEBUG_FUNC_BEGIN(); - emf_account_list_t *p = g_account_list, *p_next; + email_account_list_t *p = g_account_list; + email_account_list_t *p_next = NULL; while (p) { - emcore_free_account(&p->account, 1, NULL); + emcore_free_account(p->account); + EM_SAFE_FREE(p->account); p_next = p->next; - free(p); + EM_SAFE_FREE(p); p = p_next; } @@ -663,42 +607,25 @@ INTERNAL_FUNC int emcore_free_account_reference() return true; } -INTERNAL_FUNC int emcore_free_account(emf_account_t **account_list, int count, int *err_code) +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); - /* default variabl */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (count > 0) { - if (!account_list || !*account_list) { - err = EMF_ERROR_INVALID_PARAM; + if (count <= 0 || !account_list || !*account_list) { + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; - } - - emf_account_t *p = *account_list; - int i; + } - for (i = 0; i < count; i++) { - EM_SAFE_FREE(p[i].account_name); - EM_SAFE_FREE(p[i].receiving_server_addr); - EM_SAFE_FREE(p[i].email_addr); - EM_SAFE_FREE(p[i].user_name); - EM_SAFE_FREE(p[i].password); - EM_SAFE_FREE(p[i].sending_server_addr); - EM_SAFE_FREE(p[i].sending_user); - EM_SAFE_FREE(p[i].sending_password); - EM_SAFE_FREE(p[i].display_name); - EM_SAFE_FREE(p[i].reply_to_addr); - EM_SAFE_FREE(p[i].return_addr); - EM_SAFE_FREE(p[i].logo_icon_path); - EM_SAFE_FREE(p[i].options.display_name_from); - EM_SAFE_FREE(p[i].options.signature); - } + email_account_t *p = *account_list; + int i; + for (i = 0; i < count; i++) + emcore_free_account(p+i); - EM_SAFE_FREE(p); *account_list = NULL; - } + EM_SAFE_FREE(p); + *account_list = NULL; ret = true; @@ -709,19 +636,51 @@ FINISH_OFF: return ret; } +INTERNAL_FUNC void emcore_free_option(email_option_t *option) +{ + EM_SAFE_FREE(option->display_name_from); + EM_SAFE_FREE(option->signature); +} -INTERNAL_FUNC int emcore_get_account_reference_list(emf_account_t **account_list, int *count, int *err_code) + +INTERNAL_FUNC void emcore_free_account(email_account_t *account) +{ + if(!account) return; + + EM_SAFE_FREE(account->account_name); + EM_SAFE_FREE(account->incoming_server_address); + EM_SAFE_FREE(account->user_email_address); + EM_SAFE_FREE(account->incoming_server_user_name); + EM_SAFE_FREE(account->incoming_server_password); + EM_SAFE_FREE(account->outgoing_server_address); + EM_SAFE_FREE(account->outgoing_server_user_name); + EM_SAFE_FREE(account->outgoing_server_password); + EM_SAFE_FREE(account->user_display_name); + EM_SAFE_FREE(account->reply_to_address); + EM_SAFE_FREE(account->return_address); + EM_SAFE_FREE(account->logo_icon_path); + EM_SAFE_FREE(account->certificate_path); + EM_SAFE_FREE(account->user_data); + account->user_data_length = 0; + emcore_free_option(&account->options); + + + 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 = EMF_ERROR_NONE; - emf_account_t *accountRef; - emf_account_list_t *p; + int err = EMAIL_ERROR_NONE; + email_account_t *accountRef; + email_account_list_t *p; if (!account_list || !count) { EM_DEBUG_EXCEPTION("account_list[%p], count[%p]", account_list, count); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -736,10 +695,10 @@ INTERNAL_FUNC int emcore_get_account_reference_list(emf_account_t **account_list *count = countOfAccounts; if (countOfAccounts > 0) { - *account_list = malloc(sizeof(emf_account_t) * countOfAccounts); + *account_list = malloc(sizeof(email_account_t) * countOfAccounts); if (!*account_list) { EM_DEBUG_LOG("malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } } @@ -747,7 +706,7 @@ INTERNAL_FUNC int emcore_get_account_reference_list(emf_account_t **account_list p = g_account_list; for (i = 0; i < countOfAccounts; i++) { accountRef = (*account_list) + i; - memcpy(accountRef, p->account , sizeof(emf_account_t)); + memcpy(accountRef, p->account , sizeof(email_account_t)); p = p->next; } @@ -777,11 +736,11 @@ FINISH_OFF: static int append_data_into_buffer(char **target_buffer, int *target_buffer_lenth, char *input_data, int input_data_length, int *error_code) { EM_DEBUG_FUNC_BEGIN("target_buffer [%p], target_buffer_lenth [%p], input_data [%p], input_data_length[%d]", target_buffer, target_buffer_lenth, input_data, input_data_length); - int local_error_code = EMF_ERROR_NONE, ret_code = false; + int local_error_code = EMAIL_ERROR_NONE, ret_code = false; if (!target_buffer || !target_buffer_lenth || !input_data) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - local_error_code = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + local_error_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -790,7 +749,7 @@ static int append_data_into_buffer(char **target_buffer, int *target_buffer_lent *target_buffer = realloc(*target_buffer, (*target_buffer_lenth) + input_data_length); if (!*target_buffer) { EM_DEBUG_EXCEPTION("realloc failed"); - local_error_code = EMF_ERROR_OUT_OF_MEMORY; + local_error_code = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } memcpy(*target_buffer + (*target_buffer_lenth), input_data, input_data_length); @@ -798,8 +757,8 @@ static int append_data_into_buffer(char **target_buffer, int *target_buffer_lent EM_DEBUG_LOG("*target_buffer_lenth [%d] input_data_length [%d]", *target_buffer_lenth, input_data_length); } else { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - local_error_code = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + local_error_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -818,17 +777,14 @@ FINISH_OFF: static int emcore_write_account_into_buffer(char **target_buffer, int *target_buffer_lenth, emstorage_account_tbl_t *account_tbl_ptr, int *error_code) { EM_DEBUG_FUNC_BEGIN("target_buffer [%p], target_buffer_lenth [%p], account_tbl_ptr [%p], error_code [%p]", target_buffer, target_buffer_lenth, account_tbl_ptr, error_code); - int local_error_code = EMF_ERROR_NONE, ret_code = false, stream_length = 0; - emf_account_t *temp_account = NULL; + int local_error_code = EMAIL_ERROR_NONE, ret_code = false, stream_length = 0; + email_account_t temp_account = {0}; char *byte_stream = NULL; - temp_account = em_malloc(sizeof(emf_account_t)); - memset(temp_account, 0, sizeof(emf_account_t)); - - if (em_convert_account_tbl_to_account(account_tbl_ptr, temp_account)) { - byte_stream = em_convert_account_to_byte_stream(temp_account, &stream_length); + if (em_convert_account_tbl_to_account(account_tbl_ptr, &temp_account)) { + byte_stream = em_convert_account_to_byte_stream(&temp_account, &stream_length); EM_DEBUG_LOG("stream_length [%d]", stream_length); - /* EM_DEBUG_LOG("password [%s]", temp_account->password) */ + /* EM_DEBUG_LOG("incoming_server_password [%s]", temp_account->password) */ if (byte_stream) { if (!append_data_into_buffer(target_buffer, target_buffer_lenth, (char *)&stream_length, sizeof(int), &local_error_code)) { @@ -846,14 +802,13 @@ static int emcore_write_account_into_buffer(char **target_buffer, int *target_bu } else { EM_DEBUG_EXCEPTION("em_convert_account_tbl_to_account failed"); - local_error_code = EMF_ERROR_SYSTEM_FAILURE; + local_error_code = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } ret_code = true; FINISH_OFF: - if (temp_account) - emcore_free_account(&temp_account, 1, NULL); + emcore_free_account(&temp_account); if (error_code) *error_code = local_error_code; @@ -866,14 +821,14 @@ FINISH_OFF: INTERNAL_FUNC int emcore_backup_accounts(const char *file_path, int *error_code) { EM_DEBUG_FUNC_BEGIN("file_path [%s], error_code [%p]", file_path, error_code); - int local_error_code = EMF_ERROR_NONE, local_error_code_2 = EMF_ERROR_NONE, ret_code = false; + int local_error_code = EMAIL_ERROR_NONE, local_error_code_2 = EMAIL_ERROR_NONE, ret_code = false; int select_num, i, target_buff_length = 0; char *target_buffer = NULL; emstorage_account_tbl_t *account_list = NULL; if (!file_path) { - local_error_code = EMF_ERROR_INVALID_PARAM; - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + local_error_code = EMAIL_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); goto FINISH_OFF; } @@ -887,10 +842,10 @@ INTERNAL_FUNC int emcore_backup_accounts(const char *file_path, int *error_code) EM_DEBUG_LOG("select_num [%d]", select_num); if (account_list) { - target_buffer = malloc(sizeof(int)); + target_buffer = em_malloc(sizeof(int)); if (!target_buffer) { EM_DEBUG_EXCEPTION("malloc failed"); - local_error_code = EMF_ERROR_OUT_OF_MEMORY; + local_error_code = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -910,7 +865,7 @@ INTERNAL_FUNC int emcore_backup_accounts(const char *file_path, int *error_code) if (ssm_write_buffer(target_buffer, target_buff_length, file_path, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { EM_DEBUG_EXCEPTION("ssm_write_buffer failed [%d]", local_error_code); - local_error_code = EMF_ERROR_SYSTEM_FAILURE; + local_error_code = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -933,25 +888,26 @@ FINISH_OFF: INTERNAL_FUNC int emcore_restore_accounts(const char *file_path, int *error_code) { EM_DEBUG_FUNC_BEGIN("file_path [%s], error_code [%p]", file_path, error_code); - int local_error_code = EMF_ERROR_NONE, ret_code = false, buffer_length = 0, read_length = 0; + int local_error_code = EMAIL_ERROR_NONE, ret_code = false, buffer_length = 0, read_length = 0; int account_count = 0, i = 0, account_stream_length = 0; char *temp_buffer = NULL, *account_stream = NULL, *buffer_ptr = NULL; - emf_account_t *temp_account = NULL, *account_list = NULL; + email_account_t temp_account = {0}; + email_account_t *account_list = NULL; ssm_file_info_t sfi; if (!file_path) { - local_error_code = EMF_ERROR_INVALID_PARAM; - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + local_error_code = EMAIL_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); goto FINISH_OFF; } if (emcore_get_account_reference_list(&account_list, &account_count, &ret_code)) { for (i = 0; i < account_count; i++) { - if (account_list[i].receiving_server_type != EMF_SERVER_TYPE_ACTIVE_SYNC) { - if (!emcore_delete_account_(account_list[i].account_id, &ret_code)) { - local_error_code = EMF_ERROR_INVALID_ACCOUNT; - EM_DEBUG_EXCEPTION("emcore_delete_account_ failed"); + if (account_list[i].incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) { + if (!emcore_delete_account(account_list[i].account_id, &ret_code)) { + local_error_code = EMAIL_ERROR_INVALID_ACCOUNT; + EM_DEBUG_EXCEPTION("emcore_delete_account failed"); goto FINISH_OFF; } } @@ -960,7 +916,7 @@ INTERNAL_FUNC int emcore_restore_accounts(const char *file_path, int *error_code if (ssm_getinfo(file_path, &sfi, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { EM_DEBUG_EXCEPTION("ssm_getinfo() failed."); - ret_code = EMF_ERROR_SYSTEM_FAILURE; + ret_code = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -968,13 +924,13 @@ INTERNAL_FUNC int emcore_restore_accounts(const char *file_path, int *error_code EM_DEBUG_LOG("account buffer_length[%d]", buffer_length); if ((temp_buffer = (char *)em_malloc(buffer_length + 1)) == NULL) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - ret_code = EMF_ERROR_OUT_OF_MEMORY; + ret_code = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } if (ssm_read(file_path, temp_buffer, buffer_length, (size_t *)&read_length, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { EM_DEBUG_EXCEPTION("ssm_read() failed."); - ret_code = EMF_ERROR_SYSTEM_FAILURE; + ret_code = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -994,42 +950,32 @@ INTERNAL_FUNC int emcore_restore_accounts(const char *file_path, int *error_code account_stream = em_malloc(account_stream_length); if (!account_stream) { EM_DEBUG_EXCEPTION("em_malloc() failed."); - ret_code = EMF_ERROR_OUT_OF_MEMORY ; + ret_code = EMAIL_ERROR_OUT_OF_MEMORY ; goto FINISH_OFF; } memcpy(account_stream, buffer_ptr, account_stream_length); - temp_account = em_malloc(sizeof(emf_account_t)); - - if (!temp_account) { - EM_DEBUG_EXCEPTION("em_malloc() failed."); - ret_code = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - em_convert_byte_stream_to_account(account_stream, temp_account); + em_convert_byte_stream_to_account(account_stream, account_stream_length, &temp_account); EM_SAFE_FREE(account_stream); - if (!emcore_create_account(temp_account, &ret_code)) { + if (!emcore_create_account(&temp_account, &ret_code)) { EM_DEBUG_EXCEPTION("emcore_create_account() failed."); goto FINISH_OFF; } - emcore_free_account(&temp_account, 1, &ret_code); - temp_account = NULL; + emcore_free_account(&temp_account); } buffer_ptr += account_stream_length; account_stream_length = 0; } } else { EM_DEBUG_EXCEPTION("ssm_read() failed."); - ret_code = EMF_ERROR_SYSTEM_FAILURE; + ret_code = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } ret_code = true; FINISH_OFF: - if (temp_account) - emcore_free_account(&temp_account, 1, NULL); + emcore_free_account(&temp_account); EM_SAFE_FREE(account_stream); EM_SAFE_FREE(temp_buffer); @@ -1039,489 +985,167 @@ FINISH_OFF: #endif /* __FEATURE_BACKUP_ACCOUNT_ */ -#ifdef __FEATURE_WDS_SUPPORT__ -#include -#include -#include -#include -#include -static int emcore_fetch_server_info_from_wds(const char *domain_name, char **output_file_path) +INTERNAL_FUNC int emcore_query_server_info(const char* domain_name, email_server_info_t **result_server_info) { - EM_DEBUG_FUNC_BEGIN("domain_name [%s]", domain_name); - CURL *curl = NULL; - int ret_code = EMF_ERROR_NONE, curl_error = CURLE_OK, file_path_len = 0; - char *wds_url = "https://servicemine-api.wdsglobal.com/servicemine-api/email?domainName="; - char *query_url = NULL; - char *user_password = "samsung:xi7Claso"; - char curl_error_buffer[CURL_ERROR_SIZE] = { 0, }; - FILE *file_from_curl = NULL; - - if(!domain_name) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - ret_code = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } - - query_url = em_malloc(strlen(wds_url) + strlen(domain_name) + 1); - - if(!query_url) { - EM_DEBUG_EXCEPTION("EMF_ERROR_OUT_OF_MEMORY"); - ret_code = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } + EM_DEBUG_FUNC_BEGIN("domain_name [%s], result_server_info [%p]", domain_name, result_server_info); + int ret_code = EMAIL_ERROR_NONE; + EM_DEBUG_FUNC_END("ret_code [%d]", ret_code); + return ret_code; +} - sprintf(query_url, "%s%s", wds_url, domain_name); - - curl = curl_easy_init(); - if(!curl) { - EM_DEBUG_EXCEPTION("curl_easy_init failed"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } +INTERNAL_FUNC int emcore_free_server_info(email_server_info_t **target_server_info) +{ + EM_DEBUG_FUNC_BEGIN("result_server_info [%p]", target_server_info); + int i, ret_code = EMAIL_ERROR_NONE; + email_server_info_t *server_info = NULL; - if( (curl_error = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_error_buffer) ) != CURLE_OK) { - EM_DEBUG_EXCEPTION("curl_easy_setopt for CURLOPT_ERRORBUFFER failed"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; + if(target_server_info && *target_server_info) { + server_info = *target_server_info; + EM_SAFE_FREE(server_info->service_name); + for(i = 0; i < server_info->protocol_conf_count; i++) { + EM_SAFE_FREE(server_info->protocol_config_array[i].server_addr); + } + EM_SAFE_FREE(server_info->protocol_config_array); + EM_SAFE_FREE(server_info); } + EM_DEBUG_FUNC_END("ret_code [%d]", ret_code); + return ret_code; +} - if( (curl_error = curl_easy_setopt(curl, CURLOPT_URL, query_url) ) != CURLE_OK) { - EM_DEBUG_EXCEPTION("curl_easy_setopt for CURLOPT_URL failed"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } +INTERNAL_FUNC int emcore_save_default_account_id(int input_account_id) +{ + EM_DEBUG_FUNC_BEGIN("account_id [%d]", input_account_id); + int ret_code = EMAIL_ERROR_NONE, result_value = 0; - if( (curl_error = curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY) ) != CURLE_OK) { - EM_DEBUG_EXCEPTION("curl_easy_setopt for CURLOPT_HTTPAUTH failed"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; + result_value = vconf_set_int(VCONF_KEY_DEFAULT_ACCOUNT_ID, input_account_id); + if (result_value < 0) { + EM_DEBUG_EXCEPTION("vconf_set_int failed [%d]", result_value); + ret_code = EMAIL_ERROR_SYSTEM_FAILURE; } - if( (curl_error = curl_easy_setopt(curl, CURLOPT_USERPWD, user_password) ) != CURLE_OK) { - EM_DEBUG_EXCEPTION("curl_easy_setopt for CURLOPT_USERPWD failed"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } + EM_DEBUG_FUNC_END("ret_code [%d]", ret_code); + return ret_code; +} - if( (curl_error = curl_easy_setopt(curl, CURLOPT_HTTPGET, 1) ) != CURLE_OK) { - EM_DEBUG_EXCEPTION("curl_easy_setopt for CURLOPT_HTTPGET failed"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } +static int _recover_from_invalid_default_account_id(int *output_account_id) +{ + EM_DEBUG_FUNC_BEGIN("account_id [%p]", output_account_id); + int ret_code = EMAIL_ERROR_NONE; + int account_count = 100; + emstorage_account_tbl_t *result_account_list = NULL; - if( (curl_error = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L) ) != CURLE_OK) { - EM_DEBUG_EXCEPTION("curl_easy_setopt for CURLOPT_SSL_VERIFYPEER failed"); - ret_code = EMF_ERROR_UNKNOWN; + if (output_account_id == NULL) { + ret_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - file_path_len = strlen(MAILHOME "/tmp/") + strlen(domain_name) + strlen(".xml") + 1; - *output_file_path = em_malloc(file_path_len + 1); - - if(!output_file_path) { - EM_DEBUG_EXCEPTION("EMF_ERROR_OUT_OF_MEMORY"); - ret_code = EMF_ERROR_OUT_OF_MEMORY; + if(!emstorage_get_account_list(&account_count, &result_account_list, false, false, &ret_code) || !result_account_list) { + EM_DEBUG_EXCEPTION("emstorage_get_account_list() failed [%d]", ret_code); + *output_account_id = 0; goto FINISH_OFF; } - snprintf(*output_file_path, file_path_len, "%s%s%s", "/tmp/", domain_name, ".xml"); - - file_from_curl = fopen(*output_file_path, "w"); - - if(!file_from_curl) { - EM_DEBUG_EXCEPTION("fopen failed [%s]", *output_file_path); - ret_code = EMF_ERROR_SYSTEM_FAILURE; - goto FINISH_OFF; - } - - if( (curl_easy_setopt(curl, CURLOPT_WRITEDATA, file_from_curl) ) != CURLE_OK) { - EM_DEBUG_EXCEPTION("curl_easy_setopt for CURLOPT_WRITEDATA failed"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } - - if(curl_easy_perform(curl) != CURLE_OK) { - EM_DEBUG_EXCEPTION("curl_easy_perform failed [%s]", curl_error_buffer); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; + if (account_count > 0) { + *output_account_id = result_account_list[0].account_id; } - EM_DEBUG_LOG("curl_easy_perform passed"); - -FINISH_OFF: - if(file_from_curl) - fclose(file_from_curl); + EM_DEBUG_LOG("output_account_id [%d]", *output_account_id); - EM_SAFE_FREE(query_url); +FINISH_OFF: - if(curl) - curl_easy_cleanup(curl); + if (result_account_list) + emstorage_free_account(&result_account_list, account_count, NULL); EM_DEBUG_FUNC_END("ret_code [%d]", ret_code); return ret_code; } -static int emcore_parse_server_info_from_wds(char *xml_file_path, emf_server_info_t **result_server_info) +INTERNAL_FUNC int emcore_load_default_account_id(int *output_account_id) { - EM_DEBUG_FUNC_BEGIN("xml_file_path [%s], result_server_info [%p]", xml_file_path, result_server_info); - - int ret_code = EMF_ERROR_NONE; - xmlDocPtr doc = NULL; - xmlXPathContextPtr xpath_context = NULL; - xmlXPathObjectPtr xpath_obj_service = NULL, xpath_obj_configuration = NULL, xpath_obj_result_of_query = NULL; - xmlChar *xpath_service = (xmlChar*)"/servicemine/discovery/*/service-provider/service"; - xmlChar *xpath_configuration = (xmlChar*)"/servicemine/discovery/*/service-provider/service/configuration"; - xmlChar *xpath_configuration_query = NULL; - xmlChar *service_name = NULL, *id_string = NULL, *result_content = NULL; - emf_server_info_t *server_info = NULL; - int i, j, id_len; - - if(!xml_file_path || !result_server_info) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - ret_code = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } + EM_DEBUG_FUNC_BEGIN("account_id [%p]", output_account_id); + int ret_code = EMAIL_ERROR_NONE; + int result_value = 0; + emstorage_account_tbl_t *result_account = NULL; - xmlInitParser(); - LIBXML_TEST_VERSION; - - doc = xmlReadFile(xml_file_path, NULL, 0); - if (doc == NULL) { - EM_DEBUG_EXCEPTION("Failed to parse [%s]", xml_file_path); - ret_code = EMF_ERROR_UNKNOWN; + if (output_account_id == NULL) { + ret_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - /* Create xpath evaluation context */ - xpath_context = xmlXPathNewContext(doc); - if(xpath_context == NULL) { - EM_DEBUG_EXCEPTION("unable to create new XPath context"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } - - xpath_obj_service = xmlXPathEvalExpression(xpath_service, xpath_context); - if(xpath_obj_service == NULL) { - EM_DEBUG_EXCEPTION("unable to evaluate xpath expression [%s]", xpath_service); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } + result_value = vconf_get_int(VCONF_KEY_DEFAULT_ACCOUNT_ID, output_account_id); - if(xpath_obj_service->nodesetval->nodeNr > 0 && xpath_obj_service->nodesetval->nodeTab) { - service_name = xmlGetProp(xpath_obj_service->nodesetval->nodeTab[0] , (xmlChar*)"name"); - if(service_name) { - EM_DEBUG_LOG("service_name [%s]", service_name); - } - else { - EM_DEBUG_EXCEPTION("xmlGetProp failed"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } - } - else { - EM_DEBUG_EXCEPTION("nodesetval empty"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } - - xpath_obj_configuration = xmlXPathEvalExpression(xpath_configuration, xpath_context); - if(xpath_obj_configuration == NULL) { - EM_DEBUG_EXCEPTION("unable to evaluate xpath expression [%s]", xpath_configuration); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; + if (result_value < 0) { + EM_DEBUG_EXCEPTION("vconf_get_int() failed [%d]", result_value); + ret_code = EMAIL_ERROR_SYSTEM_FAILURE; + *output_account_id = 0; } - server_info = em_malloc(sizeof(emf_server_info_t)); - - if(!server_info){ - EM_DEBUG_EXCEPTION("em_malloc failed"); - ret_code = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; + if (*output_account_id != 0) { + if (!emstorage_get_account_by_id(*output_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &result_account, false, &ret_code)) { + EM_DEBUG_EXCEPTION("emstorage_get_account_by_id() failed [%d]", ret_code); + if(ret_code == EMAIL_ERROR_ACCOUNT_NOT_FOUND) + *output_account_id = 0; + else + goto FINISH_OFF; + } } - server_info->service_name = (char*)service_name; - - if(xpath_obj_configuration->nodesetval->nodeNr) { - EM_DEBUG_LOG("node count [%d]", xpath_obj_configuration->nodesetval->nodeNr); - server_info->protocol_config_array = em_malloc(sizeof(emf_protocol_config_t) * xpath_obj_configuration->nodesetval->nodeNr); - server_info->protocol_conf_count = xpath_obj_configuration->nodesetval->nodeNr; - } - else { - EM_DEBUG_EXCEPTION("xmlXPathEvalExpression failed"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } - - for(i = 0; i < xpath_obj_configuration->nodesetval->nodeNr; i++) { - id_string = xmlGetProp(xpath_obj_configuration->nodesetval->nodeTab[i] , (xmlChar*)"id"); - if(id_string) { - EM_DEBUG_LOG("id_string [%s]", id_string); - server_info->protocol_config_array[i].configuration_id = atoi((char*)id_string); - id_len = strlen((char*)id_string); - } - else { - EM_DEBUG_EXCEPTION("xmlGetProp failed"); - continue; - } - - xpath_configuration_query = em_malloc(strlen((char*)xpath_configuration) + id_len + 300); - if(!xpath_configuration_query) { - EM_DEBUG_EXCEPTION("em_malloc failed"); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; + if (*output_account_id == 0) { + if ( (ret_code = _recover_from_invalid_default_account_id(output_account_id)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("_recover_from_invalid_default_account() failed [%d]", ret_code); + *output_account_id = 0; } - - /* searching in discovery element */ - - sprintf((char*)xpath_configuration_query, "/servicemine/discovery//service-provider/service/configuration[@id=\"%s\"]/email/*", (char*)id_string); - EM_DEBUG_LOG("[%s]", xpath_configuration_query); - - xpath_obj_result_of_query = xmlXPathEvalExpression(xpath_configuration_query, xpath_context); - if(xpath_obj_result_of_query == NULL) { - EM_DEBUG_EXCEPTION("unable to evaluate xpath expression [%s]", xpath_configuration_query); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } - - if(xpath_obj_result_of_query->nodesetval && xpath_obj_result_of_query->nodesetval->nodeNr) { - EM_DEBUG_LOG("node count [%d]", xpath_obj_result_of_query->nodesetval->nodeNr); - } - else { - EM_DEBUG_EXCEPTION("xmlXPathEvalExpression failed [%p]", xpath_obj_result_of_query->nodesetval); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } - - for(j = 0; j < xpath_obj_result_of_query->nodesetval->nodeNr; j++) { - if(xpath_obj_result_of_query->nodesetval->nodeTab[j]->name) { - EM_DEBUG_LOG("element name [%s]", xpath_obj_result_of_query->nodesetval->nodeTab[j]->name); - EM_DEBUG_LOG("element type [%d]", xpath_obj_result_of_query->nodesetval->nodeTab[j]->type); - result_content = xmlNodeGetContent(xpath_obj_result_of_query->nodesetval->nodeTab[j]); - EM_DEBUG_LOG("content name [%s]", (char*)result_content); - if(strncmp((char*)xpath_obj_result_of_query->nodesetval->nodeTab[j]->name, "protocol", strlen("protocol")) == 0) { - server_info->protocol_config_array[i].protocol_type = EMF_SERVER_TYPE_NONE; - if(result_content) { - if(strncmp((char*)result_content, "smtp", strlen("smtp")) == 0) { - server_info->protocol_config_array[i].protocol_type = EMF_SERVER_TYPE_SMTP; - } - else if(strncmp((char*)result_content, "pop3", strlen("pop3")) == 0) { - server_info->protocol_config_array[i].protocol_type = EMF_SERVER_TYPE_POP3; - } - else if(strncmp((char*)result_content, "imap4", strlen("imap4")) == 0) { - server_info->protocol_config_array[i].protocol_type = EMF_SERVER_TYPE_IMAP4; - } - } - EM_DEBUG_LOG("protocol_type [%d]", server_info->protocol_config_array[i].protocol_type); - } - else if(strncmp((char*)xpath_obj_result_of_query->nodesetval->nodeTab[j]->name, "encryption-type", strlen("encryption-type")) == 0) { - server_info->protocol_config_array[i].security_type = 0; - if(result_content) { - if(strncmp((char*)result_content, "ssl/tls", strlen("ssl/tls")) == 0) { - server_info->protocol_config_array[i].security_type = 1; - } - else if(strncmp((char*)result_content, "none", strlen("none")) == 0) { - server_info->protocol_config_array[i].security_type = 0; - } - - } - EM_DEBUG_LOG("security_type [%d]", server_info->protocol_config_array[i].security_type); - } - else if(strncmp((char*)xpath_obj_result_of_query->nodesetval->nodeTab[j]->name, "requires-auth", strlen("requires-auth")) == 0) { - if(result_content) { - if(strncmp((char*)result_content, "true", strlen("true")) == 0) { - server_info->protocol_config_array[i].auth_type = 1; - } - else { - server_info->protocol_config_array[i].auth_type = 0; - } - } - EM_DEBUG_LOG("auth_type [%d]", server_info->protocol_config_array[i].auth_type); - } - EM_SAFE_FREE(result_content); - } - } - - if(xpath_obj_result_of_query) { - xmlXPathFreeObject(xpath_obj_result_of_query); - xpath_obj_result_of_query = NULL; - } - - /* searching server address in configuration-parameters element */ - - sprintf((char*)xpath_configuration_query, "/servicemine/configuration-parameters/configuration[@id=\"%s\"]/wap-provisioningdoc/characteristic/characteristic[@type=\"APPADDR\"]/parm", (char*)id_string); - EM_DEBUG_LOG("[%s]", xpath_configuration_query); - - xpath_obj_result_of_query = xmlXPathEvalExpression(xpath_configuration_query, xpath_context); - if(xpath_obj_result_of_query == NULL) { - EM_DEBUG_EXCEPTION(" unable to evaluate xpath expression [%s]", xpath_configuration_query); - goto FINISH_OFF; - } - - if(xpath_obj_result_of_query->nodesetval->nodeNr > 0 && xpath_obj_result_of_query->nodesetval->nodeTab) { - result_content = xmlGetProp(xpath_obj_result_of_query->nodesetval->nodeTab[0] , (const xmlChar *)"value"); - if(result_content) { - EM_DEBUG_LOG("result_content [%s]", (char*)result_content); - server_info->protocol_config_array[i].server_addr = strdup((char*)result_content); - EM_SAFE_FREE(result_content); - } - else { - EM_DEBUG_EXCEPTION("xmlGetProp failed"); - server_info->protocol_config_array[i].server_addr = NULL; - } - } - - if(xpath_obj_result_of_query) { - xmlXPathFreeObject(xpath_obj_result_of_query); - xpath_obj_result_of_query = NULL; - } - - /* searching server address in configuration-parameters element */ - - sprintf((char*)xpath_configuration_query, "/servicemine/configuration-parameters/configuration[@id=\"%s\"]/wap-provisioningdoc/characteristic/characteristic[@type=\"APPADDR\"]/characteristic[@type=\"PORT\"]/parm", (char*)id_string); - EM_DEBUG_LOG("[%s]", xpath_configuration_query); - - xpath_obj_result_of_query = xmlXPathEvalExpression(xpath_configuration_query, xpath_context); - if(xpath_obj_result_of_query == NULL) { - EM_DEBUG_EXCEPTION(" unable to evaluate xpath expression [%s]", (char*)xpath_configuration_query); - ret_code = EMF_ERROR_UNKNOWN; - goto FINISH_OFF; - } - - if(xpath_obj_result_of_query->nodesetval->nodeNr > 0 && xpath_obj_result_of_query->nodesetval->nodeTab) { - result_content = xmlGetProp(xpath_obj_result_of_query->nodesetval->nodeTab[0] , (const xmlChar *)"value"); - if(result_content) { - EM_DEBUG_LOG("result_content [%s]", (char*)result_content); - server_info->protocol_config_array[i].port_number = atoi((char*)result_content); - EM_SAFE_FREE(result_content); - } - else { - EM_DEBUG_EXCEPTION("xmlGetProp failed"); - server_info->protocol_config_array[i].port_number = 0; - } - } - - if(xpath_obj_result_of_query) { - xmlXPathFreeObject(xpath_obj_result_of_query); - xpath_obj_result_of_query = NULL; - } - - EM_SAFE_FREE(xpath_configuration_query); - EM_SAFE_FREE(id_string); - } - - *result_server_info = server_info; - -FINISH_OFF: - - if(doc) - xmlFreeDoc(doc); - - if(xpath_context) - xmlXPathFreeContext(xpath_context); - - if(xpath_obj_service) - xmlXPathFreeObject(xpath_obj_service); - - if(xpath_obj_configuration) - xmlXPathFreeObject(xpath_obj_configuration); - - if(xpath_obj_result_of_query) { - xmlXPathFreeObject(xpath_obj_result_of_query); - xpath_obj_result_of_query = NULL; } - xmlCleanupParser(); /* Cleanup function for the XML library. */ - +FINISH_OFF: + if (result_account) + emstorage_free_account(&result_account, 1, NULL); + EM_DEBUG_FUNC_END("ret_code [%d]", ret_code); - return ret_code; + return ret_code; } -#endif /* __FEATURE_WDS_SUPPORT__ */ - - -INTERNAL_FUNC int emcore_query_server_info(const char* domain_name, emf_server_info_t **result_server_info) +INTERNAL_FUNC int emcore_recover_from_secured_storage_failure() { - EM_DEBUG_FUNC_BEGIN("domain_name [%s], result_server_info [%p]", domain_name, result_server_info); - int ret_code = EMF_ERROR_NONE; -#ifdef __FEATURE_WDS_SUPPORT__ - char *result_file_path = NULL; + EM_DEBUG_FUNC_BEGIN(); + int err = EMAIL_ERROR_NONE; + int i = 0; + int account_count = 50; + emstorage_account_tbl_t *temp_account_tbl_list = NULL; + emstorage_account_tbl_t *temp_account_tbl = NULL; - if( (ret_code = emcore_fetch_server_info_from_wds(domain_name, &result_file_path)) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emcore_fetch_server_info_from_wds failed"); + if (!emstorage_get_account_list(&account_count, &temp_account_tbl_list, true, false, &err)) { + EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err); goto FINISH_OFF; } - if(result_file_path) { - if( (ret_code = emcore_parse_server_info_from_wds(result_file_path, result_server_info)) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emcore_parse_server_info_from_wds failed"); - goto FINISH_OFF; - } - } - -FINISH_OFF: - EM_SAFE_FREE(result_file_path); -#endif /* __FEATURE_WDS_SUPPORT__ */ - EM_DEBUG_FUNC_END("ret_code [%d]", ret_code); - return ret_code; -} - - -INTERNAL_FUNC int emcore_free_server_info(emf_server_info_t **target_server_info) -{ - EM_DEBUG_FUNC_BEGIN("result_server_info [%p]", target_server_info); - int i, ret_code = EMF_ERROR_NONE; - emf_server_info_t *server_info = NULL; - - if(target_server_info && *target_server_info) { - server_info = *target_server_info; - EM_SAFE_FREE(server_info->service_name); - for(i = 0; i < server_info->protocol_conf_count; i++) { - EM_SAFE_FREE(server_info->protocol_config_array[i].server_addr); + 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(err == EMAIL_ERROR_SECURED_STORAGE_FAILURE) { + if(!emcore_delete_account(temp_account_tbl_list[i].account_id, &err)) { + EM_DEBUG_EXCEPTION("emcore_delete_account failed [%d]", err); + goto FINISH_OFF; + } + } } - EM_SAFE_FREE(server_info->protocol_config_array); - EM_SAFE_FREE(server_info); } - EM_DEBUG_FUNC_END("ret_code [%d]", ret_code); - return ret_code; -} - -INTERNAL_FUNC int emcore_save_default_account_id(int input_account_id) -{ - EM_DEBUG_FUNC_BEGIN("account_id [%d]", input_account_id); - int ret_code = EMF_ERROR_NONE, result_value = 0; - result_value = vconf_set_int(VCONF_KEY_DEFAULT_ACCOUNT_ID, input_account_id); - if (result_value < 0) { - EM_DEBUG_EXCEPTION("vconf_set_int failed [%d]", result_value); - ret_code = EMF_ERROR_SYSTEM_FAILURE; - } +FINISH_OFF: - EM_DEBUG_FUNC_END("ret_code [%d]", ret_code); - return ret_code; + EM_DEBUG_FUNC_END("err [%d]", err); + return err; } -INTERNAL_FUNC int emcore_load_default_account_id(int *output_account_id) +INTERNAL_FUNC int emcore_update_sync_status_of_account(int input_account_id, email_set_type_t input_set_operator, int input_sync_status) { - EM_DEBUG_FUNC_BEGIN("account_id [%p]", output_account_id); - int ret_code = EMF_ERROR_NONE, result_value = 0; - - if (output_account_id == NULL) { - ret_code = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } - - result_value = vconf_get_int(VCONF_KEY_DEFAULT_ACCOUNT_ID, output_account_id); + 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; - if (result_value < 0) { - EM_DEBUG_EXCEPTION("vconf_get_int() failed [%d]", result_value); - ret_code = EMF_ERROR_SYSTEM_FAILURE; - *output_account_id = 0; - } + if (!emstorage_update_sync_status_of_account(input_account_id, input_set_operator, input_sync_status, true, &err)) + EM_DEBUG_EXCEPTION("emstorage_update_sync_status_of_account failed [%d]", err); -FINISH_OFF: - - EM_DEBUG_FUNC_END("ret_code [%d]", ret_code); - return ret_code; + EM_DEBUG_FUNC_END("err [%d]", err); + return err; } diff --git a/email-core/email-core-api.c b/email-core/email-core-api.c index 14a1cac..384809b 100755 --- a/email-core/email-core-api.c +++ b/email-core/email-core-api.c @@ -1,94 +1,94 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - -/****************************************************************************** - * File : email-core-api.h - * Desc : Mail Engine API - * - * Auth : - * - * History : - * 2006.08.16 : created - *****************************************************************************/ -#include -#include -#include - -#include "c-client.h" -#include "email-core-global.h" -#include "email-network.h" -#include "email-core-event.h" -#include "email-core-mailbox.h" -#include "email-core-utils.h" -#include "email-debug-log.h" - -extern void * -pop3_parameters(long function, void *value); -extern void * -imap_parameters(long function, void *value); - - - -/* initialize mail core */ -INTERNAL_FUNC int emcore_init(int *err_code) -{ - EM_DEBUG_FUNC_BEGIN(); - - if (err_code != NULL) { - *err_code = EMF_ERROR_NONE; - } - - mail_link(&imapdriver); /* link in the imap driver */ - mail_link(&pop3driver); /* link in the pop3 driver */ - - mail_link(&unixdriver); /* link in the unix driver */ - mail_link(&dummydriver); /* link in the dummy driver */ - - ssl_onceonlyinit(); - - auth_link(&auth_md5); /* link in the md5 authenticator */ - auth_link(&auth_pla); /* link in the pla authenticator */ - auth_link(&auth_log); /* link in the log authenticator */ - - /* Disabled to authenticate with plain text */ - mail_parameters(NIL, SET_DISABLEPLAINTEXT, (void *) 2); - - /* Set max trials for login */ - imap_parameters(SET_MAXLOGINTRIALS, (void *)1); - pop3_parameters(SET_MAXLOGINTRIALS, (void *)1); - smtp_parameters(SET_MAXLOGINTRIALS, (void *)1); - - mail_parameters(NIL, SET_SSLCERTIFICATEQUERY, (void *)emnetwork_callback_ssl_cert_query); - mail_parameters(NIL, SET_SSLCAPATH, (void *)SSL_CERT_DIRECTORY); - - /* Set time out in second */ - mail_parameters(NIL, SET_OPENTIMEOUT , (void *)50); - mail_parameters(NIL, SET_READTIMEOUT , (void *)180); - mail_parameters(NIL, SET_WRITETIMEOUT , (void *)180); - mail_parameters(NIL, SET_CLOSETIMEOUT , (void *)30); - - if (err_code) - *err_code = EMF_ERROR_NONE; - - return true; -} - +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +/****************************************************************************** + * File : email-core-api.h + * Desc : Mail Engine API + * + * Auth : + * + * History : + * 2006.08.16 : created + *****************************************************************************/ +#include +#include +#include + +#include "c-client.h" +#include "email-core-global.h" +#include "email-network.h" +#include "email-core-event.h" +#include "email-core-mailbox.h" +#include "email-core-utils.h" +#include "email-debug-log.h" + +extern void * +pop3_parameters(long function, void *value); +extern void * +imap_parameters(long function, void *value); + + + +/* initialize mail core */ +INTERNAL_FUNC int emcore_init(int *err_code) +{ + EM_DEBUG_FUNC_BEGIN(); + + if (err_code != NULL) { + *err_code = EMAIL_ERROR_NONE; + } + + mail_link(&imapdriver); /* link in the imap driver */ + mail_link(&pop3driver); /* link in the pop3 driver */ + + mail_link(&unixdriver); /* link in the unix driver */ + mail_link(&dummydriver); /* link in the dummy driver */ + + ssl_onceonlyinit(); + + auth_link(&auth_md5); /* link in the md5 authenticator */ + auth_link(&auth_pla); /* link in the pla authenticator */ + auth_link(&auth_log); /* link in the log authenticator */ + + /* Disabled to authenticate with plain text */ + mail_parameters(NIL, SET_DISABLEPLAINTEXT, (void *) 2); + + /* Set max trials for login */ + imap_parameters(SET_MAXLOGINTRIALS, (void *)1); + pop3_parameters(SET_MAXLOGINTRIALS, (void *)1); + smtp_parameters(SET_MAXLOGINTRIALS, (void *)1); + + mail_parameters(NIL, SET_SSLCERTIFICATEQUERY, (void *)emnetwork_callback_ssl_cert_query); + mail_parameters(NIL, SET_SSLCAPATH, (void *)SSL_CERT_DIRECTORY); + + /* Set time out in second */ + mail_parameters(NIL, SET_OPENTIMEOUT , (void *)50); + mail_parameters(NIL, SET_READTIMEOUT , (void *)180); + mail_parameters(NIL, SET_WRITETIMEOUT , (void *)180); + mail_parameters(NIL, SET_CLOSETIMEOUT , (void *)30); + + if (err_code) + *err_code = EMAIL_ERROR_NONE; + + return true; +} + diff --git a/email-core/email-core-cert.c b/email-core/email-core-cert.c new file mode 100644 index 0000000..e685770 --- /dev/null +++ b/email-core/email-core-cert.c @@ -0,0 +1,679 @@ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +/****************************************************************************** + * File : email-core-cert.h + * Desc : Certificate API + * + * Auth : + * + * History : + * 2006.08.16 : created + *****************************************************************************/ +#include +#include +#include +#include +#include +#include + +#include "email-core-cert.h" +#include "email-core-mail.h" +#include "email-utilities.h" +#include "email-storage.h" +#include "email-debug-log.h" + +#define READ_MODE "r" +#define WRITE_MODE "w" + +#define EMAIL_ERROR_CERTIFICATE_LOAD_FAIL 2300 +#define EMAIL_ERROR_FILE_NOT_OPEN 2301 +#define EMAIL_ERROR_INVALID_CERTIFICATE 2302 + +#define TRUSTED_USER "trusteduser/email/" + +typedef enum { + CERT_TYPE_ETC = 0, + CERT_TYPE_PKCS12, + CERT_TYPE_PKCS7, + CERT_TYPE_P7S +} cert_type; + +static int emcore_get_certificate_type(char *extension, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("extensiong is [%s]", extension); + int index = 0; + int type = 0; + int err = EMAIL_ERROR_NONE; + char *supported_file_type[] = {"pfx", "p12", "p7s", "pem", "der", "crt", "cer", NULL}; + + if (!extension) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + while(supported_file_type[index]) { + EM_DEBUG_LOG("certificate extension[%d]:[%s]", index, supported_file_type[index]); + if (strcasecmp(extension, supported_file_type[index]) == 0) { + switch (index) { + case 0: + case 1: + type = CERT_TYPE_PKCS12; + err = EMAIL_ERROR_INVALID_CERTIFICATE; + break; + case 2: + type = CERT_TYPE_P7S; + break; + case 3: + case 4: + case 5: + case 6: + type = CERT_TYPE_PKCS7; + break; + default: + type = CERT_TYPE_ETC; + err = EMAIL_ERROR_INVALID_CERTIFICATE; + break; + } + } + index++; + } + +FINISH_OFF: + + if (err_code) { + *err_code = err; + } + + EM_DEBUG_FUNC_END("File type is [%d]", type); + return type; +} +/* +static GList *emcore_make_glist_from_string(char *email_address_list) +{ + EM_DEBUG_FUNC_BEGIN("email_address list : [%s]", email_address_list); + int index = 0; + const gchar seperator = 0x01; + GList *email_list = NULL; + gchar *p_email_address_list = NULL; + gchar **token_list = NULL; + + p_email_address_list = g_strdup(email_address_list); + + token_list = g_strsplit(p_email_address_list, &seperator, -1); + while (token_list[index] != NULL) { + email_list = g_list_append(email_list, token_list[index]); + index++; + } + + if (p_email_address_list) + g_free(p_email_address_list); + + return email_list; +} +*/ +static int emcore_load_public_of_p7s(CERT_CONTEXT *context, char *public_cert_path, STACK_OF(X509) **certificates, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN(); + + int ret = false; + int err = EMAIL_ERROR_NONE; + int cert_size = 0; + unsigned char *cert_string = NULL; + PKCS7 *pkcs7 = NULL; + BIO *infile = NULL; + X509 *cert = NULL; + STACK_OF(X509) *certs = NULL; + + if (public_cert_path == NULL) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + OpenSSL_add_all_algorithms(); + + /* Open p7s file */ + infile = BIO_new_file(public_cert_path, READ_MODE); + if (infile == NULL) { + EM_DEBUG_EXCEPTION("File open failed [%s]", public_cert_path); + err = EMAIL_ERROR_FILE_NOT_FOUND; + goto FINISH_OFF; + } + + /* Load the p7s file */ + pkcs7 = d2i_PKCS7_bio(infile, NULL); + if (pkcs7 == NULL) { + EM_DEBUG_EXCEPTION("smime.p7s load failed"); + err = EMAIL_ERROR_CERTIFICATE_LOAD_FAIL; + goto FINISH_OFF; + } + + /* Extract the signature in pkcs7 */ + certs = PKCS7_get0_signers(pkcs7, NULL, 0); + if (certs == NULL) { + EM_DEBUG_EXCEPTION("smime.p7s extract failed"); + err = EMAIL_ERROR_CERTIFICATE_LOAD_FAIL; + goto FINISH_OFF; + } + + /* Change from the p7s to the pem file */ + if (sk_X509_num(certs) > 1) { + EM_DEBUG_EXCEPTION("Has one or more signature.\nIt is not support"); + err = EMAIL_ERROR_UNKNOWN; + goto FINISH_OFF; + } + + cert = sk_X509_value(certs, 0); + cert_size = i2d_X509(cert, &cert_string); + if (cert_size < 0) { + EM_DEBUG_EXCEPTION("Fail to convert certificate"); + err = EMAIL_ERROR_UNKNOWN; + goto FINISH_OFF; + } + + /* Initilize the certificate and CERT_CONTEXT buffer */ + cert_string = (unsigned char *)em_malloc(sizeof(unsigned char *) * cert_size); + if (cert_string == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + context->certBuf = (cert_svc_mem_buff *)em_malloc(sizeof(cert_svc_mem_buff)); + if (context->certBuf == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + /* Set CERT_CONTEXT structure */ + context->certBuf->data = cert_string; + context->certBuf->size = cert_size; + + ret = true; + +FINISH_OFF: + + if (infile) + BIO_free(infile); + + if (pkcs7) + PKCS7_free(pkcs7); + + if (cert) + X509_free(cert); + + if (ret) { + if (certificates != NULL) + *certificates = certs; + + if (err_code != NULL) + *err_code = err; + } else { + if (certs) + sk_X509_free(certs); + + EM_SAFE_FREE(cert_string); + } + + EVP_cleanup(); + + EM_DEBUG_FUNC_END(); + + return ret; +} +/* +static char *emcore_store_public_certificate(STACK_OF(X509) *certificates, char *email_address, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN(); + int index = 0; + int err = EMAIL_ERROR_NONE; + char *file_path = NULL; + BIO *outfile = NULL; + + file_path = (char *)em_malloc(256); + if (file_path == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + SNPRINTF(file_path, 256, "%s%s%s", CERT_SVC_STORE_PATH, TRUSTED_USER, email_address); + outfile = BIO_new_file(file_path, WRITE_MODE); + if (outfile == NULL) { + EM_DEBUG_EXCEPTION("File open failed[write mode]"); + err = EMAIL_ERROR_FILE_NOT_OPEN; + goto FINISH_OFF; + } + + for (index = 0; index < sk_X509_num(certificates); index++) { + EM_DEBUG_LOG("Write the certificate in pem file : [%d]", index); + PEM_write_bio_X509(outfile, sk_X509_value(certificates, index)); + } + +FINISH_OFF: + + if (outfile) + BIO_free(outfile); + + EM_DEBUG_FUNC_END(); + + return file_path; +} +*/ +INTERNAL_FUNC int emcore_load_PFX_file(char *certificate, char *password, EVP_PKEY **pri_key, X509 **cert, STACK_OF(X509) **ca, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("Certificate path : [%s], password : [%s]", certificate, password); + + int err = EMAIL_ERROR_NONE; + int ret = false; + FILE *fp = NULL; + PKCS12 *p12 = NULL; + + OpenSSL_add_all_algorithms(); + ERR_load_crypto_strings(); + if (!(fp = fopen(certificate, "rb"))) { + EM_DEBUG_EXCEPTION("fopen failed : [%s]", certificate); + err = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } + + p12 = d2i_PKCS12_fp(fp, NULL); + if (!p12) { + EM_DEBUG_EXCEPTION("d2i_PKCS12_fp failed"); + err = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } + + if (!PKCS12_parse(p12, password, pri_key, cert, ca)) { + EM_DEBUG_EXCEPTION("PKCS12_parse failed"); + err = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } + + ret = true; + +FINISH_OFF: + + if (fp) + fclose(fp); + + if (p12) + PKCS12_free(p12); + + 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) +{ + EM_DEBUG_FUNC_BEGIN("Path [%s], filename [%s]", public_cert_path, save_name); + int err = EMAIL_ERROR_NONE; + int ret = false; + int validity = 0; + int cert_type = 0; + char temp_file[512] = {0, }; + char temp_save_name[512] = {0, }; + char filepath[512] = {0, }; + char *extension = NULL; + emstorage_certificate_tbl_t *cert = NULL; + CERT_CONTEXT *context = NULL; + + if (public_cert_path == NULL || save_name == NULL) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + /* Initilize the structure of certificate */ + context = cert_svc_cert_context_init(); + + /* Parse the file type */ + extension = em_get_extension_from_file_path(public_cert_path, NULL); + if (extension == NULL) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + /* Get the file type information */ + cert_type = emcore_get_certificate_type(extension, &err); + if (!cert_type || err == EMAIL_ERROR_INVALID_CERTIFICATE) { + EM_DEBUG_EXCEPTION("Invalid certificate"); + goto FINISH_OFF; + } + + /* Create temp file and rename */ + if (cert_type == CERT_TYPE_P7S) { + extension = "der"; + } + + SNPRINTF(temp_file, sizeof(temp_file), "%s%s%s%s%s.%s", MAILHOME, DIR_SEPERATOR, MAILTEMP, DIR_SEPERATOR, save_name, extension); + EM_DEBUG_LOG("temp cert path : [%s]", temp_file); + + if (!emstorage_copy_file(public_cert_path, temp_file, false, &err)) { + EM_DEBUG_EXCEPTION("emstorage_copy_file failed [%d]", err); + goto FINISH_OFF; + } + + /* Load the public certificate */ + err = cert_svc_load_file_to_context(context, temp_file); + if (err != CERT_SVC_ERR_NO_ERROR) { + EM_DEBUG_EXCEPTION("Load cert failed : [%d]", err); + err = EMAIL_ERROR_INVALID_CERTIFICATE; + goto FINISH_OFF; + } + + /* Verify the certificate */ + if (cert_svc_verify_certificate(context, &validity) != CERT_SVC_ERR_NO_ERROR) { + EM_DEBUG_EXCEPTION("cert_svc_verify_certificate failed"); +// err = EMAIL_ERROR_INVALID_CERTIFICATE; +// goto FINISH_OFF; + } + + if (validity <= 0) { + EM_DEBUG_LOG("Invalid certificate"); + } + + /* Load the certificate information */ + if (cert_svc_extract_certificate_data(context) != CERT_SVC_ERR_NO_ERROR) { + EM_DEBUG_EXCEPTION("Extract the certificate failed"); + err = EMAIL_ERROR_UNKNOWN; + goto FINISH_OFF; + } + + /* Store the certificate file to trusted folder */ + if (cert_svc_add_certificate_to_store(temp_file, TRUSTED_USER) != CERT_SVC_ERR_NO_ERROR) { + EM_DEBUG_EXCEPTION("Add certificate to trusted folder"); + err = EMAIL_ERROR_UNKNOWN; + goto FINISH_OFF; + } + + /* Store the certificate to DB */ + SNPRINTF(filepath, sizeof(filepath), "%s%s%s.%s", CERT_SVC_STORE_PATH, TRUSTED_USER, save_name, extension); + SNPRINTF(temp_save_name, sizeof(temp_save_name), "<%s>", save_name); + + cert = (emstorage_certificate_tbl_t *)em_malloc(sizeof(emstorage_certificate_tbl_t)); + if (cert == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + cert->issue_year = context->certDesc->info.validPeriod.firstYear; + cert->issue_year = context->certDesc->info.validPeriod.firstYear; + cert->issue_month = context->certDesc->info.validPeriod.firstMonth; + cert->issue_day = context->certDesc->info.validPeriod.firstDay; + cert->expiration_year= context->certDesc->info.validPeriod.secondYear; + cert->expiration_month = context->certDesc->info.validPeriod.secondMonth; + cert->expiration_day = context->certDesc->info.validPeriod.secondDay; + cert->issue_organization_name = EM_SAFE_STRDUP(context->certDesc->info.issuer.organizationName); + cert->email_address = EM_SAFE_STRDUP(temp_save_name); + cert->subject_str = EM_SAFE_STRDUP(context->certDesc->info.issuerStr); + cert->filepath = EM_SAFE_STRDUP(filepath); + + if (emstorage_add_certificate(cert, true, &err)) { + EM_DEBUG_EXCEPTION("emstorage_add_certificate failed"); + goto FINISH_OFF; + } + + if (!emstorage_delete_file(public_cert_path, &err)) { + EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", err); + goto FINISH_OFF; + } + + ret = true; + +FINISH_OFF: + + emstorage_free_certificate(&cert, 1, NULL); + + cert_svc_cert_context_final(context); + + if (err_code != NULL) { + *err_code = err; + } + + EM_DEBUG_FUNC_END(); + + return ret; + +} + +INTERNAL_FUNC int emcore_delete_public_certificate(char *email_address, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN(); + int ret = false; + int err = EMAIL_ERROR_NONE; + emstorage_certificate_tbl_t *certificate = NULL; + + if (email_address == NULL) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + if (!emstorage_get_certificate_by_email_address(email_address, &certificate, false, 0, &err)) { + EM_DEBUG_EXCEPTION("emstorage_get_certificate failed"); + goto FINISH_OFF; + } + + if (remove(certificate->filepath) < 0) { + EM_DEBUG_EXCEPTION("remove failed : [%s]", certificate->filepath); + goto FINISH_OFF; + } + + if (!emstorage_delete_certificate(certificate->certificate_id, true, &err)) { + EM_DEBUG_EXCEPTION("emstorage_delete_certificate failed"); + goto FINISH_OFF; + } + + ret = true; +FINISH_OFF: + + if (certificate != NULL) + emstorage_free_certificate(&certificate, 1, NULL); + + if (err_code != NULL) + *err_code = err; + + EM_DEBUG_FUNC_END(); + + return ret; +} + +INTERNAL_FUNC int emcore_verify_signature(char *p7s_file_path, char *mime_entity, int *validity, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("path[%s], mime_entiy[%s]", p7s_file_path, mime_entity); + int ret = false; + int err = EMAIL_ERROR_NONE; + int i = 0, j = 0; + + int p_validity = 0; + int msg_len = 0; + unsigned char *msg = NULL; + int sig_len = 0; + unsigned char *sig = NULL; + unsigned char *tmp_sig = NULL; + FILE *fp_msg = NULL; + FILE *fp_sig = NULL; + size_t f_size = 0; + + CERT_CONTEXT *context = NULL; + + context = cert_svc_cert_context_init(); + + if (!emcore_load_public_of_p7s(context, p7s_file_path, NULL, &err)) { + EM_DEBUG_EXCEPTION("emcore_load_public_of_p7s failed"); + goto FINISH_OFF; + } + + fp_msg = fopen(mime_entity, "rb"); + fseek(fp_msg, 0L, SEEK_END); + msg_len = ftell(fp_msg); + fseek(fp_msg, 0L, SEEK_SET); + msg = (unsigned char *)em_malloc(sizeof(unsigned char) * (msg_len + 1)); + if (msg == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + if ((f_size = fread(msg, sizeof(unsigned char), msg_len, fp_msg)) < 0) { + EM_DEBUG_EXCEPTION("File read failed"); + goto FINISH_OFF; + } + + fp_sig = fopen(p7s_file_path, "rb"); + fseek(fp_sig, 0L, SEEK_END); + sig_len = ftell(fp_sig); + fseek(fp_sig, 0L, SEEK_SET); + sig = (unsigned char *)em_malloc(sizeof(unsigned char) * (sig_len + 1)); + if (sig == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + tmp_sig = (unsigned char *)em_malloc(sizeof(unsigned char) * (sig_len + 1)); + if (tmp_sig == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + if ((f_size = fread(sig, sizeof(unsigned char), sig_len, fp_sig)) < 0) { + EM_DEBUG_EXCEPTION("File read failed"); + goto FINISH_OFF; + } + + for(i = 0; i < sig_len; i++) { + if(sig[i] != '\n') { + tmp_sig[j] = sig[i]; + j++; + } + } + + err = cert_svc_verify_signature(context, msg, msg_len, tmp_sig, NULL, &p_validity); + if (err != CERT_SVC_ERR_NO_ERROR) { + EM_DEBUG_EXCEPTION("Verify signature failed"); + goto FINISH_OFF; + } + + ret = true; + +FINISH_OFF: + + EM_SAFE_FREE(tmp_sig); + + EM_SAFE_FREE(sig); + + EM_SAFE_FREE(msg); + + if (fp_sig != NULL) + fclose(fp_sig); + + if (fp_msg != NULL) + fclose(fp_msg); + + cert_svc_cert_context_final(context); + + + + if (err_code != NULL) + *err_code = err; + + EM_DEBUG_FUNC_END(); + return ret; +} + +INTERNAL_FUNC int emcore_verify_certificate(char *certificate, int *validity, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN(); + int ret = false; + int err = EMAIL_ERROR_NONE; + int p_validity = 0; + + CERT_CONTEXT *context = NULL; + + context = cert_svc_cert_context_init(); + + err = cert_svc_load_file_to_context(context, certificate); + if (err != CERT_SVC_ERR_NO_ERROR) { + EM_DEBUG_EXCEPTION("Certificate load failed"); + goto FINISH_OFF; + } + + err = cert_svc_verify_certificate(context, &p_validity); + if (err != CERT_SVC_ERR_NO_ERROR) { + EM_DEBUG_EXCEPTION("Certificate verify failed"); + goto FINISH_OFF; + } + + ret = true; + +FINISH_OFF: + + if (validity != NULL) + *validity = p_validity; + + if (err_code != NULL) { + *err_code = err; + } + + EM_DEBUG_FUNC_END(); + return ret; +} + +INTERNAL_FUNC int emcore_free_certificate(email_certificate_t **certificate, int count, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("certificate [%p], count [%d]", certificate, count); + + if (count <= 0 || !certificate || !*certificate) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + if (err_code) + *err_code = EMAIL_ERROR_INVALID_PARAM; + return false; + } + + email_certificate_t *p_certificate = *certificate; + int i; + + for (i=0;ievent_param_data_4; /* NOT ALWAYS */ switch (event_data->type) { - case EMF_EVENT_SEND_MAIL: - emcore_execute_event_callback(EMF_ACTION_SEND_MAIL, 0, 0, EMF_SEND_WAITING, account_id, mail_id, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_SEND_MAIL: + emcore_execute_event_callback(EMAIL_ACTION_SEND_MAIL, 0, 0, EMAIL_SEND_WAITING, account_id, mail_id, queue_idx, EMAIL_ERROR_NONE); break; - case EMF_EVENT_SYNC_HEADER: - emcore_execute_event_callback(EMF_ACTION_SYNC_HEADER, 0, 0, EMF_LIST_WAITING, account_id, 0, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_SYNC_HEADER: + emcore_execute_event_callback(EMAIL_ACTION_SYNC_HEADER, 0, 0, EMAIL_LIST_WAITING, account_id, 0, queue_idx, EMAIL_ERROR_NONE); break; - case EMF_EVENT_SYNC_HEADER_OMA: - emcore_execute_event_callback(EMF_ACTION_SYNC_HEADER_OMA, 0, 0, EMF_LIST_WAITING, account_id, 0, queue_idx, EMF_ERROR_NONE); - break; + case EMAIL_EVENT_SYNC_HEADER_OMA: + emcore_execute_event_callback(EMAIL_ACTION_SYNC_HEADER_OMA, 0, 0, EMAIL_LIST_WAITING, account_id, 0, queue_idx, EMAIL_ERROR_NONE); + break; - case EMF_EVENT_DOWNLOAD_BODY: - emcore_execute_event_callback(EMF_ACTION_DOWNLOAD_BODY, 0, 0, EMF_DOWNLOAD_WAITING, account_id, mail_id, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_DOWNLOAD_BODY: + emcore_execute_event_callback(EMAIL_ACTION_DOWNLOAD_BODY, 0, 0, EMAIL_DOWNLOAD_WAITING, account_id, mail_id, queue_idx, EMAIL_ERROR_NONE); break; #ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__ - case EMF_EVENT_SYNC_MAIL_FLAG_TO_SERVER: - emcore_execute_event_callback(EMF_ACTION_SYNC_MAIL_FLAG_TO_SERVER, 0, 0, EMF_SYNC_WAITING, account_id, mail_id, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER: + emcore_execute_event_callback(EMAIL_ACTION_SYNC_MAIL_FLAG_TO_SERVER, 0, 0, EMAIL_SYNC_WAITING, account_id, mail_id, queue_idx, EMAIL_ERROR_NONE); break; #endif - case EMF_EVENT_DOWNLOAD_ATTACHMENT: - emcore_execute_event_callback(EMF_ACTION_DOWNLOAD_ATTACHMENT, 0, 0, EMF_DOWNLOAD_WAITING, account_id, mail_id, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_DOWNLOAD_ATTACHMENT: + emcore_execute_event_callback(EMAIL_ACTION_DOWNLOAD_ATTACHMENT, 0, 0, EMAIL_DOWNLOAD_WAITING, account_id, mail_id, queue_idx, EMAIL_ERROR_NONE); + break; + + case EMAIL_EVENT_DELETE_MAIL: + case EMAIL_EVENT_DELETE_MAIL_ALL: + emcore_execute_event_callback(EMAIL_ACTION_DELETE_MAIL, 0, 0, EMAIL_DELETE_WAITING, account_id, 0, queue_idx, EMAIL_ERROR_NONE); + break; + + case EMAIL_EVENT_VALIDATE_ACCOUNT: + emcore_execute_event_callback(EMAIL_ACTION_VALIDATE_ACCOUNT, 0, 0, EMAIL_VALIDATE_ACCOUNT_WAITING, account_id, 0, queue_idx, EMAIL_ERROR_NONE); + break; + + case EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT: + emcore_execute_event_callback(EMAIL_ACTION_VALIDATE_AND_CREATE_ACCOUNT, 0, 0, EMAIL_VALIDATE_ACCOUNT_WAITING, account_id, 0, queue_idx, EMAIL_ERROR_NONE); break; - case EMF_EVENT_DELETE_MAIL: - case EMF_EVENT_DELETE_MAIL_ALL: - emcore_execute_event_callback(EMF_ACTION_DELETE_MAIL, 0, 0, EMF_DELETE_WAITING, account_id, 0, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_MOVE_MAIL: + emcore_execute_event_callback(EMAIL_ACTION_MOVE_MAIL, 0, 0, EMAIL_LIST_WAITING, account_id, 0, queue_idx, EMAIL_ERROR_NONE); break; - case EMF_EVENT_VALIDATE_ACCOUNT: - emcore_execute_event_callback(EMF_ACTION_VALIDATE_ACCOUNT, 0, 0, EMF_VALIDATE_ACCOUNT_WAITING, account_id, 0, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_CREATE_MAILBOX: + emcore_execute_event_callback(EMAIL_ACTION_CREATE_MAILBOX, 0, 0, EMAIL_LIST_WAITING, account_id, 0, queue_idx, EMAIL_ERROR_NONE); break; - case EMF_EVENT_VALIDATE_AND_CREATE_ACCOUNT: - emcore_execute_event_callback(EMF_ACTION_VALIDATE_AND_CREATE_ACCOUNT, 0, 0, EMF_VALIDATE_ACCOUNT_WAITING, account_id, 0, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT: + emcore_execute_event_callback(EMAIL_ACTION_VALIDATE_AND_UPDATE_ACCOUNT, 0, 0, EMAIL_VALIDATE_ACCOUNT_WAITING, account_id, 0, queue_idx, EMAIL_ERROR_NONE); break; - case EMF_EVENT_MOVE_MAIL: - emcore_execute_event_callback(EMF_ACTION_MOVE_MAIL, 0, 0, EMF_LIST_WAITING, account_id, 0, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_UPDATE_MAIL: break; - case EMF_EVENT_CREATE_MAILBOX: - emcore_execute_event_callback(EMF_ACTION_CREATE_MAILBOX, 0, 0, EMF_LIST_WAITING, account_id, 0, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_SET_MAIL_SLOT_SIZE: + emcore_execute_event_callback(EMAIL_ACTION_SET_MAIL_SLOT_SIZE, 0, 0, EMAIL_SET_SLOT_SIZE_WAITING, account_id, 0, queue_idx, EMAIL_ERROR_NONE); break; - case EMF_EVENT_VALIDATE_AND_UPDATE_ACCOUNT: - emcore_execute_event_callback(EMF_ACTION_VALIDATE_AND_UPDATE_ACCOUNT, 0, 0, EMF_VALIDATE_ACCOUNT_WAITING, account_id, 0, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED: + emcore_execute_event_callback(EMAIL_ACTION_EXPUNGE_MAILS_DELETED_FLAGGED, 0, 0, EMAIL_EXPUNGE_MAILS_DELETED_FLAGGED_WAITING, account_id, event_data->event_param_data_4, queue_idx, EMAIL_ERROR_NONE); break; - case EMF_EVENT_UPDATE_MAIL: + case EMAIL_EVENT_SEARCH_ON_SERVER: + emcore_execute_event_callback(EMAIL_ACTION_SEARCH_ON_SERVER, 0, 0, EMAIL_SYNC_WAITING, account_id, 0, queue_idx, EMAIL_ERROR_NONE); break; - case EMF_EVENT_SET_MAIL_SLOT_SIZE: - emcore_execute_event_callback(EMF_ACTION_SET_MAIL_SLOT_SIZE, 0, 0, EMF_SET_SLOT_SIZE_WAITING, account_id, 0, queue_idx, EMF_ERROR_NONE); + case EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER: + /* emcore_execute_event_callback(EMAIL_ACTION_CREATE_MAILBOX, 0, 0, EMAIL_LIST_WAITING, account_id, 0, queue_idx, EMAIL_ERROR_NONE); */ break; + default: break; } EM_DEBUG_FUNC_END(); } -static void fail_status_notify(emf_event_t *event_data, int error) +static void fail_status_notify(email_event_t *event_data, int error) { EM_DEBUG_FUNC_BEGIN(); int account_id, mail_id; if(!event_data) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); return; } account_id = event_data->account_id; @@ -426,62 +460,78 @@ static void fail_status_notify(emf_event_t *event_data, int error) EM_DEBUG_LOG("account_id[%d], mail_id[%d], error[%d]", account_id, mail_id, error); switch (event_data->type) { - case EMF_EVENT_SEND_MAIL: - /* case EMF_EVENT_SEND_MAIL_SAVED: */ - /* emcore_execute_event_callback(EMF_ACTION_SEND_MAIL, 0, 0, EMF_SEND_FAIL, account_id, mail_id, -1, error); */ - emcore_show_popup(mail_id, EMF_ACTION_SEND_MAIL, 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); break; - case EMF_EVENT_SYNC_HEADER: - emcore_execute_event_callback(EMF_ACTION_SYNC_HEADER, 0, 0, EMF_LIST_FAIL, account_id, 0, -1, error); - emcore_show_popup(account_id, EMF_ACTION_SYNC_HEADER, error); + 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); break; - case EMF_EVENT_DOWNLOAD_BODY: - emcore_execute_event_callback(EMF_ACTION_DOWNLOAD_BODY, 0, 0, EMF_DOWNLOAD_FAIL, account_id, mail_id, -1, error); - emcore_show_popup(account_id, EMF_ACTION_DOWNLOAD_BODY, error); + 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); break; - case EMF_EVENT_DOWNLOAD_ATTACHMENT: - emcore_execute_event_callback(EMF_ACTION_DOWNLOAD_ATTACHMENT, 0, 0, EMF_DOWNLOAD_FAIL, account_id, mail_id, -1, error); - emcore_show_popup(account_id, EMF_ACTION_DOWNLOAD_ATTACHMENT, error); + 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); break; - case EMF_EVENT_DELETE_MAIL: - case EMF_EVENT_DELETE_MAIL_ALL: - emcore_execute_event_callback(EMF_ACTION_DELETE_MAIL, 0, 0, EMF_DELETE_FAIL, account_id, 0, -1, error); - emcore_show_popup(account_id, EMF_ACTION_DELETE_MAIL, error); + 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); break; - case EMF_EVENT_VALIDATE_ACCOUNT: - emcore_execute_event_callback(EMF_ACTION_VALIDATE_ACCOUNT, 0, 0, EMF_VALIDATE_ACCOUNT_FAIL, account_id, 0, -1, error); - emcore_show_popup(account_id, EMF_ACTION_VALIDATE_ACCOUNT, error); + 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); break; - case EMF_EVENT_VALIDATE_AND_CREATE_ACCOUNT: - emcore_execute_event_callback(EMF_ACTION_VALIDATE_AND_CREATE_ACCOUNT, 0, 0, EMF_VALIDATE_ACCOUNT_FAIL, account_id, 0, -1, error); - emcore_show_popup(account_id, EMF_ACTION_VALIDATE_AND_CREATE_ACCOUNT, error); + 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); break; - case EMF_EVENT_CREATE_MAILBOX: - emcore_execute_event_callback(EMF_ACTION_CREATE_MAILBOX, 0, 0, EMF_LIST_FAIL, account_id, 0, -1, error); - emcore_show_popup(account_id, EMF_ACTION_CREATE_MAILBOX, error); + 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); break; - case EMF_EVENT_DELETE_MAILBOX: - emcore_execute_event_callback(EMF_ACTION_DELETE_MAILBOX, 0, 0, EMF_LIST_FAIL, account_id, 0, -1, error); - emcore_show_popup(account_id, EMF_ACTION_DELETE_MAILBOX, error); + + 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); break; - case EMF_EVENT_VALIDATE_AND_UPDATE_ACCOUNT: - emcore_execute_event_callback(EMF_ACTION_VALIDATE_AND_UPDATE_ACCOUNT, 0, 0, EMF_VALIDATE_ACCOUNT_FAIL, account_id, 0, -1, error); - emcore_show_popup(account_id, EMF_ACTION_VALIDATE_AND_UPDATE_ACCOUNT, error); + 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); break; - case EMF_EVENT_SET_MAIL_SLOT_SIZE: - emcore_execute_event_callback(EMF_ACTION_SET_MAIL_SLOT_SIZE, 0, 0, EMF_SET_SLOT_SIZE_FAIL, account_id, 0, -1, EMF_ERROR_NONE); + 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 EMF_EVENT_UPDATE_MAIL: + + 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(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); + break; + + case EMAIL_EVENT_UPDATE_MAIL: + emcore_execute_event_callback(EMAIL_ACTION_UPDATE_MAIL, 0, 0, EMAIL_UPDATE_MAIL_FAIL, account_id, 0, -1, EMAIL_ERROR_NONE); + break; + + case EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED: + emcore_execute_event_callback(EMAIL_ACTION_EXPUNGE_MAILS_DELETED_FLAGGED, 0, 0, EMAIL_EXPUNGE_MAILS_DELETED_FLAGGED_FAIL, account_id, event_data->event_param_data_4, -1, EMAIL_ERROR_NONE); break; default: @@ -497,13 +547,13 @@ static void emcore_initialize_event_callback_table() int i; - for (i = 0; i < EMF_ACTION_NUM; i++) + for (i = 0; i < EMAIL_ACTION_NUM; i++) _event_callback_table[i] = NULL; LEAVE_RECURSIVE_CRITICAL_SECTION(_event_callback_table_lock); } -int emcore_register_event_callback(emf_action_t action, emf_event_callback callback, void *event_data) +int emcore_register_event_callback(email_action_t action, email_event_callback callback, void *event_data) { EM_DEBUG_FUNC_BEGIN("action[%d], callback[%p], event_data[%p]", action, callback, event_data); @@ -525,7 +575,7 @@ int emcore_register_event_callback(emf_action_t action, emf_event_callback callb /* not found, so keep going */ - node = malloc(sizeof(EVENT_CALLBACK_LIST)); + node = em_malloc(sizeof(EVENT_CALLBACK_LIST)); if (node == NULL) /* not enough memory */ goto EXIT; @@ -544,7 +594,7 @@ EXIT : return ret; } -int emcore_unregister_event_callback(emf_action_t action, emf_event_callback callback) +int emcore_unregister_event_callback(email_action_t action, email_event_callback callback) { EM_DEBUG_FUNC_BEGIN("action[%d], callback[%p]", action, callback); @@ -580,7 +630,7 @@ int emcore_unregister_event_callback(emf_action_t action, emf_event_callback cal return ret; } -void emcore_execute_event_callback(emf_action_t action, int total, int done, int status, int account_id, int mail_id, int handle, int error) +void emcore_execute_event_callback(email_action_t action, int total, int done, int status, int account_id, int mail_id, int handle, int error) { EM_DEBUG_FUNC_BEGIN("action[%d], total[%d], done[%d], status[%d], account_id[%d], mail_id[%d], handle[%d], error[%d]", action, total, done, status, account_id, mail_id, handle, error); @@ -609,33 +659,33 @@ void emcore_execute_event_callback(emf_action_t action, int total, int done, int } /* insert a event to event queue */ -INTERNAL_FUNC int emcore_insert_event(emf_event_t *event_data, int *handle, int *err_code) +INTERNAL_FUNC int emcore_insert_event(email_event_t *event_data, int *handle, int *err_code) { EM_DEBUG_FUNC_BEGIN("event_data[%p], handle[%p], err_code[%p]", event_data, handle, err_code); if (!event_data) { EM_DEBUG_EXCEPTION("Invalid Parameter"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } if (!g_srv_thread) { EM_DEBUG_EXCEPTION("email-service is not ready"); if (err_code != NULL) - *err_code = EMF_ERROR_LOAD_ENGINE_FAILURE; + *err_code = EMAIL_ERROR_LOAD_ENGINE_FAILURE; return false; } int ret = true; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; ENTER_RECURSIVE_CRITICAL_SECTION(_event_queue_lock); if (!g_event_que[g_event_que_idx].type) { /* if current buffer has not event, insert event data to current buffer */ EM_DEBUG_LOG("Current buffer has not a event. [%d]", g_event_que_idx); - memcpy(g_event_que+g_event_que_idx, event_data, sizeof(emf_event_t)); - g_event_que[g_event_que_idx].status = EMF_EVENT_STATUS_WAIT; + memcpy(g_event_que+g_event_que_idx, event_data, sizeof(email_event_t)); + g_event_que[g_event_que_idx].status = EMAIL_EVENT_STATUS_WAIT; waiting_status_notify(event_data, g_event_que_idx); if (handle) *handle = g_event_que_idx; @@ -654,8 +704,8 @@ INTERNAL_FUNC int emcore_insert_event(emf_event_t *event_data, int *handle, int if (i < EVENT_QUEUE_MAX) { EM_DEBUG_LOG("I found available buffer. [%d]", g_event_que + j); - memcpy(g_event_que+j, event_data, sizeof(emf_event_t)); - g_event_que[j].status = EMF_EVENT_STATUS_WAIT; + memcpy(g_event_que+j, event_data, sizeof(email_event_t)); + g_event_que[j].status = EMAIL_EVENT_STATUS_WAIT; waiting_status_notify(event_data, j); if (handle) @@ -663,7 +713,7 @@ INTERNAL_FUNC int emcore_insert_event(emf_event_t *event_data, int *handle, int } else { EM_DEBUG_EXCEPTION("event que is full..."); - error = EMF_ERROR_EVENT_QUEUE_FULL; + error = EMAIL_ERROR_EVENT_QUEUE_FULL; ret = false; } } @@ -674,29 +724,32 @@ INTERNAL_FUNC int emcore_insert_event(emf_event_t *event_data, int *handle, int event_data->event_param_data_1 = NULL; /* MUST BE - to prevent double-free */ switch (event_data->type) { - case EMF_EVENT_SEND_MAIL: - case EMF_EVENT_SEND_MAIL_SAVED: + case EMAIL_EVENT_SEND_MAIL: + case EMAIL_EVENT_SEND_MAIL_SAVED: _sending_busy_ref(); break; - case EMF_EVENT_SYNC_HEADER: - case EMF_EVENT_DOWNLOAD_BODY: - case EMF_EVENT_DOWNLOAD_ATTACHMENT: - case EMF_EVENT_SYNC_MAIL_FLAG_TO_SERVER: - case EMF_EVENT_SYNC_FLAGS_FIELD_TO_SERVER: - case EMF_EVENT_ISSUE_IDLE: - case EMF_EVENT_SYNC_IMAP_MAILBOX: - case EMF_EVENT_VALIDATE_ACCOUNT: - case EMF_EVENT_VALIDATE_AND_CREATE_ACCOUNT: - case EMF_EVENT_MOVE_MAIL: - case EMF_EVENT_DELETE_MAIL: - case EMF_EVENT_DELETE_MAIL_ALL: - case EMF_EVENT_SYNC_HEADER_OMA: - case EMF_EVENT_CREATE_MAILBOX: - case EMF_EVENT_DELETE_MAILBOX: - case EMF_EVENT_VALIDATE_AND_UPDATE_ACCOUNT: - case EMF_EVENT_SET_MAIL_SLOT_SIZE: - case EMF_EVENT_UPDATE_MAIL: + case EMAIL_EVENT_SYNC_HEADER: + case EMAIL_EVENT_DOWNLOAD_BODY: + case EMAIL_EVENT_DOWNLOAD_ATTACHMENT: + case EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER: + case EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER: + case EMAIL_EVENT_ISSUE_IDLE: + case EMAIL_EVENT_SYNC_IMAP_MAILBOX: + case EMAIL_EVENT_VALIDATE_ACCOUNT: + case EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT: + case EMAIL_EVENT_MOVE_MAIL: + case EMAIL_EVENT_DELETE_MAIL: + case EMAIL_EVENT_DELETE_MAIL_ALL: + case EMAIL_EVENT_SYNC_HEADER_OMA: + case EMAIL_EVENT_CREATE_MAILBOX: + case EMAIL_EVENT_DELETE_MAILBOX: + case EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT: + 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: _receiving_busy_ref(); break; default: @@ -729,26 +782,26 @@ INTERNAL_FUNC int emcore_insert_event(emf_event_t *event_data, int *handle, int } /* get a event from event_data queue */ -static int emcore_retrieve_event(emf_event_t *event_data, int *err_code) +static int emcore_retrieve_event(email_event_t *event_data, int *err_code) { EM_DEBUG_FUNC_BEGIN("event_data[%p], err_code[%p]", event_data, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; ENTER_RECURSIVE_CRITICAL_SECTION(_event_queue_lock); /* get a event_data if this queue is not empty */ if (g_event_que[g_event_que_idx].type) { - memcpy(event_data, g_event_que+g_event_que_idx, sizeof(emf_event_t)); + memcpy(event_data, g_event_que+g_event_que_idx, sizeof(email_event_t)); - if (event_data->status != EMF_EVENT_STATUS_WAIT) { /* EMF_EVENT_STATUS_CANCELED */ - memset(g_event_que+g_event_que_idx, 0x00, sizeof(emf_event_t)); + if (event_data->status != EMAIL_EVENT_STATUS_WAIT) { /* EMAIL_EVENT_STATUS_CANCELED */ + memset(g_event_que+g_event_que_idx, 0x00, sizeof(email_event_t)); g_active_que = 0; } else { EM_DEBUG_LINE; - g_event_que[g_event_que_idx].status = EMF_EVENT_STATUS_STARTED; + g_event_que[g_event_que_idx].status = EMAIL_EVENT_STATUS_STARTED; g_active_que = g_event_que_idx; ret = true; } @@ -760,7 +813,7 @@ static int emcore_retrieve_event(emf_event_t *event_data, int *err_code) } else { g_active_que = 0; - error = EMF_ERROR_EVENT_QUEUE_EMPTY; + error = EMAIL_ERROR_EVENT_QUEUE_EMPTY; } LEAVE_RECURSIVE_CRITICAL_SECTION(_event_queue_lock); @@ -780,7 +833,7 @@ static int emcore_event_loop_continue() -INTERNAL_FUNC int emcore_insert_send_event(emf_event_t *event_data, int *handle, int *err_code) +INTERNAL_FUNC int emcore_insert_event_for_sending_mails(email_event_t *event_data, int *handle, int *err_code) { EM_DEBUG_FUNC_BEGIN("event_data[%p], handle[%p], err_code[%p]", event_data, handle, err_code); @@ -788,21 +841,21 @@ INTERNAL_FUNC int emcore_insert_send_event(emf_event_t *event_data, int *handle, EM_DEBUG_EXCEPTION("\t event_data[%p], handle[%p]", event_data, handle); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = true; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; ENTER_RECURSIVE_CRITICAL_SECTION(_send_event_queue_lock); if (!g_send_event_que[g_send_event_que_idx].type) { /* if current buffer has not event_data, insert event_data data to current buffer */ EM_DEBUG_LOG("Current buffer has not a event_data. [%d]", g_send_event_que_idx); - memcpy(g_send_event_que+g_send_event_que_idx, event_data, sizeof(emf_event_t)); + memcpy(g_send_event_que+g_send_event_que_idx, event_data, sizeof(email_event_t)); - g_send_event_que[g_send_event_que_idx].status = EMF_EVENT_STATUS_WAIT; + g_send_event_que[g_send_event_que_idx].status = EMAIL_EVENT_STATUS_WAIT; if (handle) *handle = g_send_event_que_idx; @@ -822,13 +875,13 @@ INTERNAL_FUNC int emcore_insert_send_event(emf_event_t *event_data, int *handle, if (i < EVENT_QUEUE_MAX) { EM_DEBUG_LOG("I found available buffer. [%d]", j); - memcpy(g_send_event_que+j, event_data, sizeof(emf_event_t)); - g_send_event_que[j].status = EMF_EVENT_STATUS_WAIT; + memcpy(g_send_event_que+j, event_data, sizeof(email_event_t)); + g_send_event_que[j].status = EMAIL_EVENT_STATUS_WAIT; if (handle) *handle = j; } else { EM_DEBUG_EXCEPTION("event_data queue is full..."); - error = EMF_ERROR_EVENT_QUEUE_FULL; + error = EMAIL_ERROR_EVENT_QUEUE_FULL; ret = false; } } @@ -842,7 +895,7 @@ INTERNAL_FUNC int emcore_insert_send_event(emf_event_t *event_data, int *handle, } if (handle) - EM_DEBUG_LOG("emcore_insert_send_event-handle[%d]", *handle); + EM_DEBUG_LOG("emcore_insert_event_for_sending_mails-handle[%d]", *handle); if (err_code != NULL) *err_code = error; @@ -852,24 +905,24 @@ INTERNAL_FUNC int emcore_insert_send_event(emf_event_t *event_data, int *handle, } -static int emcore_retrieve_send_event(emf_event_t *event_data, int *err_code) +static int emcore_retrieve_send_event(email_event_t *event_data, int *err_code) { EM_DEBUG_FUNC_BEGIN(); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; ENTER_RECURSIVE_CRITICAL_SECTION(_send_event_queue_lock); /* get a event_data if this queue is not empty */ if (g_send_event_que[g_send_event_que_idx].type) { - memcpy(event_data, g_send_event_que+g_send_event_que_idx, sizeof(emf_event_t)); + memcpy(event_data, g_send_event_que+g_send_event_que_idx, sizeof(email_event_t)); - if (event_data->status != EMF_EVENT_STATUS_WAIT) { - memset(g_send_event_que+g_send_event_que_idx, 0x00, sizeof(emf_event_t)); + if (event_data->status != EMAIL_EVENT_STATUS_WAIT) { + memset(g_send_event_que+g_send_event_que_idx, 0x00, sizeof(email_event_t)); g_send_active_que = 0; } else { - g_send_event_que[g_send_event_que_idx].status = EMF_EVENT_STATUS_STARTED; + g_send_event_que[g_send_event_que_idx].status = EMAIL_EVENT_STATUS_STARTED; EM_DEBUG_LOG("g_send_event_que_idx[%d]", g_send_event_que_idx); g_send_active_que = g_send_event_que_idx; @@ -884,7 +937,7 @@ static int emcore_retrieve_send_event(emf_event_t *event_data, int *err_code) else { EM_DEBUG_LOG("\t send event_data queue is empty..."); g_send_active_que = 0; - error = EMF_ERROR_EVENT_QUEUE_EMPTY; + error = EMAIL_ERROR_EVENT_QUEUE_EMPTY; } LEAVE_RECURSIVE_CRITICAL_SECTION(_send_event_queue_lock); @@ -896,12 +949,12 @@ static int emcore_retrieve_send_event(emf_event_t *event_data, int *err_code) } -void* send_event_handler(void *arg) +void* thread_func_branch_command_for_sending_mails(void *arg) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - emf_event_t event_data; - emf_session_t *session = NULL; + int err = EMAIL_ERROR_NONE; + email_event_t event_data; + email_session_t *session = NULL; if (!emstorage_open(&err)) { EM_DEBUG_EXCEPTION("\t emstorage_open falied - %d", err); @@ -949,12 +1002,12 @@ void* send_event_handler(void *arg) EM_DEBUG_LOG(">>>>>>>>>>>>>>Got SEND event_data>>>>>>>>>>>>>>>>"); send_thread_run = 1; g_client_run = 1; - emf_option_t *option = NULL; + email_option_t *option = NULL; if (!emnetwork_check_network_status( &err)) { EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); - emcore_show_popup(event_data.event_param_data_4, EMF_ACTION_SEND_MAIL, err); + emcore_show_user_message(event_data.event_param_data_4, EMAIL_ACTION_SEND_MAIL, err); if (!emstorage_notify_network_event(NOTI_SEND_FAIL, event_data.account_id, NULL , event_data.event_param_data_4, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_SEND_FAIL] Failed >>>> "); goto FINISH_OFF; @@ -962,11 +1015,11 @@ void* send_event_handler(void *arg) switch (event_data.type) { - case EMF_EVENT_SEND_MAIL: + case EMAIL_EVENT_SEND_MAIL: emdevice_set_dimming_on_off(false, NULL); - option = (emf_option_t *)event_data.event_param_data_1; + option = (email_option_t *)event_data.event_param_data_1; - if (!emcore_send_mail(event_data.account_id, event_data.event_param_data_3, event_data.event_param_data_4, option, &err)) + if (!emcore_send_mail(event_data.account_id, event_data.event_param_data_5, event_data.event_param_data_4, option, &err)) EM_DEBUG_EXCEPTION("emcore_send_mail failed [%d]", err); if (option) @@ -974,10 +1027,10 @@ void* send_event_handler(void *arg) emdevice_set_dimming_on_off(true, NULL); break; - case EMF_EVENT_SEND_MAIL_SAVED: /* send mails to been saved in offline-mode */ + case EMAIL_EVENT_SEND_MAIL_SAVED: /* send mails to been saved in offline-mode */ emdevice_set_dimming_on_off(false, NULL); - emf_option_t *option = (emf_option_t *)event_data.event_param_data_1; + email_option_t *option = (email_option_t *)event_data.event_param_data_1; if (!emcore_send_saved_mail(event_data.account_id, event_data.event_param_data_3, option, &err)) EM_DEBUG_EXCEPTION("emcore_send_saved_mail failed - %d", err); @@ -989,7 +1042,7 @@ void* send_event_handler(void *arg) break; #ifdef __FEATURE_LOCAL_ACTIVITY__ - case EMF_EVENT_LOCAL_ACTIVITY: { + case EMAIL_EVENT_LOCAL_ACTIVITY: { emdevice_set_dimming_on_off(false, NULL); emstorage_activity_tbl_t *local_activity = NULL; int activity_id_count = 0; @@ -1018,9 +1071,9 @@ void* send_event_handler(void *arg) case ACTIVITY_DELETEMAIL_SEND: /* New Activity Type Added for Race Condition and Crash Fix */ { if (!emcore_delete_mail(local_activity[0].account_id, &local_activity[0].mail_id, - EMF_DELETE_FOR_SEND_THREAD, + EMAIL_DELETE_FOR_SEND_THREAD, true, - EMF_DELETED_BY_COMMAND, + EMAIL_DELETED_BY_COMMAND, false, &err)) { EM_DEBUG_LOG("\t emcore_delete_mail failed - %d", err); @@ -1060,7 +1113,7 @@ void* send_event_handler(void *arg) ENTER_RECURSIVE_CRITICAL_SECTION(_send_event_queue_lock); - memset(g_send_event_que+g_send_active_que, 0x00, sizeof(emf_event_t)); + memset(g_send_event_que+g_send_active_que, 0x00, sizeof(email_event_t)); LEAVE_RECURSIVE_CRITICAL_SECTION(_send_event_queue_lock); @@ -1078,11 +1131,11 @@ FINISH_OFF: } -int event_handler_EMF_EVENT_SYNC_HEADER(int input_account_id, char *input_mailbox_name, int handle_to_be_published, int *error) +int event_handler_EMAIL_EVENT_SYNC_HEADER(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_name [%p], handle_to_be_published [%d], error[%p]", input_account_id, input_mailbox_name, handle_to_be_published, error); + EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_mailbox_id [%d], handle_to_be_published [%d], error[%p]", input_account_id, input_mailbox_id, handle_to_be_published, error); - int err = EMF_ERROR_NONE, sync_type = 0, ret = false; + int err = EMAIL_ERROR_NONE, sync_type = 0, ret = false; int mailbox_count = 0, account_count = 0; int counter, account_index; int unread = 0, total_unread = 0; @@ -1092,51 +1145,53 @@ int event_handler_EMF_EVENT_SYNC_HEADER(int input_account_id, char *input_mailbo #ifndef __FEATURE_KEEP_CONNECTION__ MAILSTREAM *stream = NULL; #endif + char mailbox_id_param_string[10] = {0,}; - if (input_mailbox_name == NULL) - sync_type = EMF_SYNC_ALL_MAILBOX; + if (input_mailbox_id == 0) + sync_type = EMAIL_SYNC_ALL_MAILBOX; else { - if (!emstorage_get_mailbox_by_name(input_account_id, -1, input_mailbox_name, &mailbox_tbl_target, true, &err) || !mailbox_tbl_target) { - EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d]", err); + if (!emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl_target) || !mailbox_tbl_target) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err); goto FINISH_OFF; } } + if(mailbox_tbl_target) + SNPRINTF(mailbox_id_param_string, 10, "%d", mailbox_tbl_target->mailbox_id); - if (!emstorage_notify_network_event(NOTI_DOWNLOAD_START, input_account_id, input_mailbox_name, handle_to_be_published, 0)) - EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_DOWNLOAD_START] Failed >>>> "); + if (!emstorage_notify_network_event(NOTI_DOWNLOAD_START, input_account_id, (input_mailbox_id == 0 )? NULL : mailbox_id_param_string, handle_to_be_published, 0)) + EM_DEBUG_EXCEPTION("emstorage_notify_network_event [ NOTI_DOWNLOAD_START] Failed >>>> "); if (!emnetwork_check_network_status(&err)) { EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); - if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, input_account_id, input_mailbox_name, handle_to_be_published, err)) + if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, input_account_id, (input_mailbox_id == 0 )? NULL : mailbox_id_param_string, handle_to_be_published, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_DOWNLOAD_FAIL] Failed >>>> "); } else { - if (sync_type != EMF_SYNC_ALL_MAILBOX) { /* Sync only particular mailbox */ + if (sync_type != EMAIL_SYNC_ALL_MAILBOX) { /* Sync only particular mailbox */ - if (!emstorage_update_sync_status_of_account(input_account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING, true, &err)) - EM_DEBUG_EXCEPTION("emstorage_update_sync_status_of_account failed [%d]", err); - - if (!emstorage_get_mailbox_by_mailbox_type(input_account_id, EMF_MAILBOX_TYPE_SPAMBOX, &mailbox_tbl_spam, false, &err)) { - + if ((err = emcore_update_sync_status_of_account(input_account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE) + EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err); + + if (!emstorage_get_mailbox_by_mailbox_type(input_account_id, EMAIL_MAILBOX_TYPE_SPAMBOX, &mailbox_tbl_spam, false, &err)) { EM_DEBUG_LOG("emstorage_get_mailbox_by_mailbox_type failed [%d]", err); } if (!emcore_sync_header(mailbox_tbl_target, mailbox_tbl_spam, NULL, &uid_list, &unread, &err)) { EM_DEBUG_EXCEPTION("emcore_sync_header failed [%d]", err); - if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, mailbox_tbl_target->account_id, mailbox_tbl_target->mailbox_name, handle_to_be_published, err)) + if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, mailbox_tbl_target->account_id, mailbox_id_param_string, handle_to_be_published, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [NOTI_DOWNLOAD_FAIL] Failed >>>> "); } else { EM_DEBUG_LOG("emcore_sync_header succeeded [%d]", err); - if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FINISH, mailbox_tbl_target->account_id, mailbox_tbl_target->mailbox_name, handle_to_be_published, 0)) + if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FINISH, mailbox_tbl_target->account_id, mailbox_id_param_string, handle_to_be_published, 0)) EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_DOWNLOAD_FINISH] Failed >>>> "); } - total_unread = total_unread + unread; + total_unread += unread; - if (total_unread > 0 && !emstorage_update_sync_status_of_account(input_account_id, SET_TYPE_UNION, SYNC_STATUS_HAVE_NEW_MAILS, true, &err)) - EM_DEBUG_EXCEPTION("emstorage_update_sync_status_of_account failed [%d]", err); + if (total_unread > 0 && (err = emcore_update_sync_status_of_account(input_account_id, SET_TYPE_UNION, SYNC_STATUS_HAVE_NEW_MAILS)) != EMAIL_ERROR_NONE) + EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err); if (!emcore_finalize_sync(input_account_id, &err)) EM_DEBUG_EXCEPTION("emcore_finalize_sync failed [%d]", err); @@ -1146,8 +1201,8 @@ int event_handler_EMF_EVENT_SYNC_HEADER(int input_account_id, char *input_mailbo /* Sync of all mailbox */ if (input_account_id == ALL_ACCOUNT) { - if (!emstorage_update_sync_status_of_account(ALL_ACCOUNT, SET_TYPE_SET, SYNC_STATUS_SYNCING, true, &err)) - EM_DEBUG_EXCEPTION("emstorage_update_sync_status_of_account failed [%d]", err); + if ((err = emcore_update_sync_status_of_account(ALL_ACCOUNT, SET_TYPE_SET, 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)) { EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [ %d ] ", err); @@ -1159,12 +1214,12 @@ int event_handler_EMF_EVENT_SYNC_HEADER(int input_account_id, char *input_mailbo else { EM_DEBUG_LOG("Sync all mailbox of an account[%d].", input_account_id); - if (!emstorage_update_sync_status_of_account(input_account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING, true, &err)) - EM_DEBUG_EXCEPTION("emstorage_update_sync_status_of_account failed [%d]", err); + if ((err = emcore_update_sync_status_of_account(input_account_id, SET_TYPE_SET, 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, EMF_ACC_GET_OPT_DEFAULT, &account_tbl_array, true, &err)) { + if (!emstorage_get_account_by_id(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 (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, input_account_id, input_mailbox_name, handle_to_be_published, err)) + if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, input_account_id, (input_mailbox_id == 0 )? NULL : mailbox_id_param_string, handle_to_be_published, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_DOWNLOAD_FAIL] Failed >>>> "); goto FINISH_OFF; } @@ -1172,46 +1227,46 @@ int event_handler_EMF_EVENT_SYNC_HEADER(int input_account_id, char *input_mailbo } for (account_index = 0 ; account_index < account_count; account_index++) { - if (account_tbl_array[account_index].receiving_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC) { + if (account_tbl_array[account_index].incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) { EM_DEBUG_LOG("account[%d] is for ActiveSync. Skip ", account_index); continue; } - - if (!emstorage_get_mailbox(account_tbl_array[account_index].account_id, 0, EMAIL_MAILBOX_SORT_BY_TYPE_ASC, &mailbox_count, &mailbox_tbl_list, true, &err) || mailbox_count <= 0) { + if (!emstorage_get_mailbox_list(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 failed [%d]", err); - if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, account_tbl_array[account_index].account_id, input_mailbox_name, handle_to_be_published, err)) + if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, account_tbl_array[account_index].account_id, (input_mailbox_id == 0 )? NULL : mailbox_id_param_string, handle_to_be_published, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_DOWNLOAD_FAIL] Failed >>>> "); - goto FINISH_OFF; + + continue; } - EM_DEBUG_LOG("emcore_get_list_to_be_sync returns [%d] mailboxes", mailbox_count); + EM_DEBUG_LOG("emcore_get_mailbox_list_to_be_sync returns [%d] mailboxes", mailbox_count); if(mailbox_tbl_spam) { if (!emstorage_free_mailbox(&mailbox_tbl_spam, 1, &err)) { - EM_DEBUG_EXCEPTION("emstorage_free_mailbox failed [%d]", err); } mailbox_tbl_spam = NULL; } - if (!emstorage_get_mailbox_by_mailbox_type(account_tbl_array[account_index].account_id, EMF_MAILBOX_TYPE_SPAMBOX, &mailbox_tbl_spam, false, &err)) { - + if (!emstorage_get_mailbox_by_mailbox_type(account_tbl_array[account_index].account_id, EMAIL_MAILBOX_TYPE_SPAMBOX, &mailbox_tbl_spam, false, &err)) { EM_DEBUG_LOG("emstorage_get_mailbox_by_mailbox_type failed [%d]", err); } if (mailbox_count > 0) { #ifndef __FEATURE_KEEP_CONNECTION__ - if (account_tbl_array[account_index].receiving_server_type == EMF_SERVER_TYPE_IMAP4) { - if (!emcore_connect_to_remote_mailbox(account_tbl_array[account_index].account_id, mailbox_tbl_list[0].mailbox_name, (void **)&stream, &err)) { + 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, mailbox_tbl_list[0].mailbox_id, (void **)&stream, &err)) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err); - if (err == EMF_ERROR_LOGIN_FAILURE) - EM_DEBUG_EXCEPTION("EMF_ERROR_LOGIN_FAILURE "); + if (err == EMAIL_ERROR_LOGIN_FAILURE) + EM_DEBUG_EXCEPTION("EMAIL_ERROR_LOGIN_FAILURE "); /* continue; */ - if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, account_tbl_array[account_index].account_id, mailbox_tbl_list[0].mailbox_name, handle_to_be_published, err)) + if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, account_tbl_array[account_index].account_id, mailbox_id_param_string, handle_to_be_published, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [NOTI_DOWNLOAD_FAIL] Failed >>>> "); - goto FINISH_OFF; + continue; } EM_DEBUG_LOG("emcore_connect_to_remote_mailbox returns [%d] : ", err); } @@ -1221,24 +1276,26 @@ int event_handler_EMF_EVENT_SYNC_HEADER(int input_account_id, char *input_mailbo } for (counter = 0; counter < mailbox_count; counter++) { - if ( mailbox_tbl_list[counter].mailbox_type == EMF_MAILBOX_TYPE_ALL_EMAILS - || mailbox_tbl_list[counter].mailbox_type == EMF_MAILBOX_TYPE_TRASH - /*|| mailbox_tbl_list[counter].mailbox_type == EMF_MAILBOX_TYPE_SPAMBOX */) + if ( mailbox_tbl_list[counter].mailbox_type == EMAIL_MAILBOX_TYPE_ALL_EMAILS + || mailbox_tbl_list[counter].mailbox_type == EMAIL_MAILBOX_TYPE_TRASH + /*|| mailbox_tbl_list[counter].mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX */) EM_DEBUG_LOG("Skipped for all emails or trash"); - else if ((mailbox_tbl_list[counter].sync_with_server_yn)) { - EM_DEBUG_LOG("..........syncing %s mailbox......", mailbox_tbl_list[counter].mailbox_name); + else if (!mailbox_tbl_list[counter].local_yn) { + EM_DEBUG_LOG("..........syncing %s mailbox( mailbox_id = %d)......", mailbox_tbl_list[counter].mailbox_name, mailbox_tbl_list[counter].mailbox_id); #ifdef __FEATURE_KEEP_CONNECTION__ if (!emcore_sync_header((mailbox_tbl_list + counter) , mailbox_tbl_spam, NULL, &uid_list, &unread, &err)) { #else /* __FEATURE_KEEP_CONNECTION__ */ if (!emcore_sync_header((mailbox_tbl_list + counter) , mailbox_tbl_spam, (void *)stream, &uid_list, &unread, &err)) { #endif /* __FEATURE_KEEP_CONNECTION__ */ - EM_DEBUG_EXCEPTION("emcore_sync_header for %s failed [%d]", mailbox_tbl_list[counter].mailbox_name, err); + EM_DEBUG_EXCEPTION("emcore_sync_header for %s(mailbox_id = %d) failed [%d]", mailbox_tbl_list[counter].mailbox_name, mailbox_tbl_list[counter].mailbox_id, err); #ifndef __FEATURE_KEEP_CONNECTION__ - if (err == EMF_ERROR_CONNECTION_BROKEN || err == EMF_ERROR_NO_SUCH_HOST || err == EMF_ERROR_SOCKET_FAILURE) + if (err == EMAIL_ERROR_CONNECTION_BROKEN || err == EMAIL_ERROR_NO_SUCH_HOST || err == EMAIL_ERROR_SOCKET_FAILURE) stream = NULL; /* Don't retry to connect for broken connection. It might cause crash. */ #endif /* __FEATURE_KEEP_CONNECTION__ */ - if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, account_tbl_array[account_index].account_id, mailbox_tbl_list[counter].mailbox_name, handle_to_be_published, err)) + memset(mailbox_id_param_string, 0, 10); + SNPRINTF(mailbox_id_param_string, 10, "%d", mailbox_tbl_list[counter].mailbox_id); + if (!emstorage_notify_network_event(NOTI_DOWNLOAD_FAIL, account_tbl_array[account_index].account_id, mailbox_id_param_string, handle_to_be_published, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_DOWNLOAD_FAIL] Failed >>>> "); break; @@ -1248,11 +1305,11 @@ int event_handler_EMF_EVENT_SYNC_HEADER(int input_account_id, char *input_mailbo } EM_DEBUG_LOG("Sync for account_id(%d) is completed....!", account_tbl_array[account_index].account_id); - if ((err == EMF_ERROR_NONE) && !emstorage_notify_network_event(NOTI_DOWNLOAD_FINISH, account_tbl_array[account_index].account_id, NULL, handle_to_be_published, 0)) + if ((err == EMAIL_ERROR_NONE) && !emstorage_notify_network_event(NOTI_DOWNLOAD_FINISH, account_tbl_array[account_index].account_id, NULL, handle_to_be_published, 0)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_DOWNLOAD_FINISH] Failed >>>> "); - if ((total_unread || unread) && !emstorage_update_sync_status_of_account(account_tbl_array[account_index].account_id, SET_TYPE_UNION, SYNC_STATUS_HAVE_NEW_MAILS, true, &err)) - EM_DEBUG_EXCEPTION("emstorage_update_sync_status_of_account failed [%d]", err); + if ((total_unread > 0) && (err = emcore_update_sync_status_of_account(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 [%d]", err); if (!emcore_finalize_sync(account_tbl_array[account_index].account_id, &err)) EM_DEBUG_EXCEPTION("emcore_finalize_sync failed [%d]", err); @@ -1292,18 +1349,18 @@ FINISH_OFF: return ret; } -int event_handler_EMF_EVENT_VALIDATE_AND_CREATE_ACCOUNT(emf_account_t *account, int handle_to_be_published, int *error) +int event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(email_account_t *account, int handle_to_be_published, int *error) { EM_DEBUG_FUNC_BEGIN("account [%p]", account); int err, ret = false; if(!account) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - EM_DEBUG_LOG("receiving_server_addr : %s", account->receiving_server_addr); + EM_DEBUG_LOG("incoming_server_address : %s", account->incoming_server_address); if (!emnetwork_check_network_status(&err)) { EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); @@ -1313,11 +1370,11 @@ int event_handler_EMF_EVENT_VALIDATE_AND_CREATE_ACCOUNT(emf_account_t *account, goto FINISH_OFF; } else { - EM_DEBUG_LOG("receiving_server_addr : %s", account->receiving_server_addr); + EM_DEBUG_LOG("incoming_server_address : %s", account->incoming_server_address); if (!emcore_validate_account_with_account_info(account, &err)) { EM_DEBUG_EXCEPTION("emcore_validate_account_with_account_info failed err : %d", err); - if (err == EMF_ERROR_CANCELLED) { + if (err == EMAIL_ERROR_CANCELLED) { EM_DEBUG_EXCEPTION(" notify : NOTI_VALIDATE_AND_CREATE_ACCOUNT_CANCEL "); if (!emstorage_notify_network_event(NOTI_VALIDATE_AND_CREATE_ACCOUNT_CANCEL, account->account_id, NULL, handle_to_be_published, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_VALIDATE_AND_CREATE_ACCOUNT_CANCEL] Failed"); @@ -1334,11 +1391,11 @@ int event_handler_EMF_EVENT_VALIDATE_AND_CREATE_ACCOUNT(emf_account_t *account, emcore_refresh_account_reference(); - if ((EMF_SERVER_TYPE_IMAP4 == account->receiving_server_type)) { + if ((EMAIL_SERVER_TYPE_IMAP4 == account->incoming_server_type)) { if (!emcore_sync_mailbox_list(account->account_id, "", &err)) { - EM_DEBUG_EXCEPTION("emcore_get_list_to_be_sync falied [%d]", err); + EM_DEBUG_EXCEPTION("emcore_get_mailbox_list_to_be_sync falied [%d]", err); /* delete account whose mailbox couldn't be obtained from server */ - emcore_delete_account_(account->account_id, NULL); + emcore_delete_account(account->account_id, NULL); goto FINISH_OFF; } @@ -1354,7 +1411,7 @@ int event_handler_EMF_EVENT_VALIDATE_AND_CREATE_ACCOUNT(emf_account_t *account, FINISH_OFF: - if (ret == false && err != EMF_ERROR_CANCELLED) { + if (ret == false && err != EMAIL_ERROR_CANCELLED) { if (!emstorage_notify_network_event(NOTI_VALIDATE_AND_CREATE_ACCOUNT_FAIL, account->account_id, NULL, handle_to_be_published, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_VALIDATE_AND_CREATE_ACCOUNT_FAIL] Failed"); } @@ -1365,7 +1422,7 @@ FINISH_OFF: return ret; } -int event_handler_EMF_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(int account_id, emf_account_t *new_account_info, int handle_to_be_published, int *error) +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) { EM_DEBUG_FUNC_BEGIN("account_id [%d], new_account_info [%p]", account_id, new_account_info); int err, ret = false; @@ -1373,7 +1430,7 @@ int event_handler_EMF_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(int account_id, emf_acco if (!new_account_info) { EM_DEBUG_EXCEPTION("Invalid Parameter"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1385,14 +1442,14 @@ int event_handler_EMF_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(int account_id, emf_acco goto FINISH_OFF; } else { - EM_DEBUG_LOG("receiving_server_addr : %s", new_account_info->receiving_server_addr); + EM_DEBUG_LOG("incoming_server_address: (%s)", new_account_info->incoming_server_address); if (!emcore_validate_account_with_account_info(new_account_info, &err)) { - EM_DEBUG_EXCEPTION("\t emcore_validate_account_with_account_info failed err : %d", err); - if (err == EMF_ERROR_CANCELLED) { + 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 "); if (!emstorage_notify_network_event(NOTI_VALIDATE_AND_UPDATE_ACCOUNT_CANCEL, new_account_info->account_id, NULL, handle_to_be_published, err)) - EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_VALIDATE_AND_UPDATE_ACCOUNT_CANCEL] Failed"); + EM_DEBUG_EXCEPTION("emstorage_notify_network_event [ NOTI_VALIDATE_AND_UPDATE_ACCOUNT_CANCEL] Failed"); goto FINISH_OFF; } else { @@ -1417,7 +1474,7 @@ int event_handler_EMF_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(int account_id, emf_acco emcore_refresh_account_reference(); } - EM_DEBUG_EXCEPTION("validating and updating an account are succeeded for account id [%d], err [%d]", new_account_info->account_id, err); + EM_DEBUG_LOG("validating and updating an account are succeeded for account id [%d], err [%d]", new_account_info->account_id, err); if (!emstorage_notify_network_event(NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FINISH, new_account_info->account_id, NULL, handle_to_be_published, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FINISH] Success"); } @@ -1431,7 +1488,7 @@ FINISH_OFF: if (new_account_tbl) emstorage_free_account(&new_account_tbl, 1, NULL); - if (ret == false && err != EMF_ERROR_CANCELLED) { + if (ret == false && err != EMAIL_ERROR_CANCELLED) { if (!emstorage_notify_network_event(NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FAIL, new_account_info->account_id, NULL, handle_to_be_published, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_VALIDATE_AND_CREATE_ACCOUNT_FAIL] Failed"); } @@ -1443,24 +1500,44 @@ FINISH_OFF: return ret; } -int event_handler_EMF_EVENT_SET_MAIL_SLOT_SIZE(int account_id, char *mailbox_name, int new_slot_size, int handle_to_be_published, int *error) +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) { EM_DEBUG_FUNC_BEGIN(); - emcore_set_mail_slot_size(account_id, mailbox_name, new_slot_size, error); + emcore_set_mail_slot_size(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) +{ + 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) { + 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) { + EM_DEBUG_EXCEPTION("emcore_expunge_mails_deleted_flagged_from_local_storage failed [%d]", err); + goto FINISH_OFF; + } + +FINISH_OFF: + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} #ifdef __FEATURE_LOCAL_ACTIVITY__ -int event_handler_EMF_EVENT_LOCAL_ACTIVITY(int account_id, int *error) +int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(int account_id, int *error) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - emf_mailbox_t mailbox; + int err = EMAIL_ERROR_NONE; + email_mailbox_t mailbox; emstorage_activity_tbl_t *local_activity = NULL; int activity_id_count = 0; int activity_chunk_count = 0; @@ -1515,8 +1592,8 @@ int event_handler_EMF_EVENT_LOCAL_ACTIVITY(int account_id, int *error) if (!emcore_delete_mail(local_activity[k-1].account_id, mail_id_list, j, - EMF_DELETE_LOCAL_AND_SERVER, - EMF_DELETED_BY_COMMAND, + EMAIL_DELETE_LOCAL_AND_SERVER, + EMAIL_DELETED_BY_COMMAND, false, &err)) EM_DEBUG_LOG("\t emcore_delete_mail failed - %d", err); @@ -1577,16 +1654,15 @@ int event_handler_EMF_EVENT_LOCAL_ACTIVITY(int account_id, int *error) } #endif /* __FEATURE_LOCAL_ACTIVITY__ */ -int event_handler_EMF_EVENT_DOWNLOAD_BODY(int account_id, char *mailbox_name, int mail_id, int option, int handle_to_be_published, int *error) +int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(int account_id, int mail_id, int option, int handle_to_be_published, int *error) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - emf_mailbox_t mailbox; + int err = EMAIL_ERROR_NONE; + email_mailbox_t mailbox; memset(&mailbox, 0x00, sizeof(mailbox)); mailbox.account_id = account_id; - mailbox.name = mailbox_name; if (!emnetwork_check_network_status(&err)) { EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); @@ -1612,30 +1688,26 @@ int event_handler_EMF_EVENT_DOWNLOAD_BODY(int account_id, char *mailbox_name, in return true; } -int event_handler_EMF_EVENT_DOWNLOAD_ATTACHMENT(int account_id, char *mailbox_name, int mail_id, char *attachment_no, int handle_to_be_published, int *error) +int event_handler_EMAIL_EVENT_DOWNLOAD_ATTACHMENT(int account_id, int mail_id, int attachment_no, int handle_to_be_published, int *error) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - emf_mailbox_t mailbox; + int err = EMAIL_ERROR_NONE; - EM_DEBUG_LOG("attachment_no is %d", atoi(attachment_no)); + EM_DEBUG_LOG("attachment_no is %d", attachment_no); if (!emnetwork_check_network_status(&err)) { EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); - emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, NULL, atoi(attachment_no), err); + emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, NULL, attachment_no, err); } else { - memset(&mailbox, 0x00, sizeof(mailbox)); - mailbox.account_id = account_id; - mailbox.name = mailbox_name; - + #ifdef __ATTACHMENT_OPTI__ - if (!emcore_download_attachment_bulk(mailbox.account_id, mail_id, (char *)attachment_no, &err)) - EM_DEBUG_EXCEPTION("\t emcore_download_attachment failed - %d", err); + if (!emcore_download_attachment_bulk(account_id, mail_id, attachment_no, &err)) + EM_DEBUG_EXCEPTION("\t emcore_download_attachment failed [%d]", err); #else - if (!emcore_download_attachment(mailbox.account_id, mail_id, (char *)attachment_no, &err)) - EM_DEBUG_EXCEPTION("\t emcore_download_attachment failed - %d", err); + if (!emcore_download_attachment(account_id, mail_id, attachment_no, &err)) + EM_DEBUG_EXCEPTION("\t emcore_download_attachment failed [%d]", err); #endif } @@ -1646,11 +1718,11 @@ int event_handler_EMF_EVENT_DOWNLOAD_ATTACHMENT(int account_id, char *mailbox_na return true; } -int event_handler_EMF_EVENT_SYNC_FLAGS_FIELD_TO_SERVER(int mail_ids[], int num, emf_flags_field_type field_type, int value, int *error) +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) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!emnetwork_check_network_status(&err)) EM_DEBUG_EXCEPTION("dnet_init failed [%d]", err); @@ -1664,11 +1736,11 @@ int event_handler_EMF_EVENT_SYNC_FLAGS_FIELD_TO_SERVER(int mail_ids[], int num, return true; } -int event_handler_EMF_EVENT_VALIDATE_ACCOUNT(int account_id, int handle_to_be_published, int *error) +int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(int account_id, int handle_to_be_published, int *error) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!emnetwork_check_network_status(&err)) { EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); @@ -1681,7 +1753,7 @@ int event_handler_EMF_EVENT_VALIDATE_ACCOUNT(int account_id, int handle_to_be_pu if (!emcore_validate_account(account_id, &err)) { EM_DEBUG_EXCEPTION("emcore_validate_account failed account id : %d err : %d", account_id, err); - if (err == EMF_ERROR_CANCELLED) { + if (err == EMAIL_ERROR_CANCELLED) { EM_DEBUG_EXCEPTION("notify : NOTI_VALIDATE_ACCOUNT_CANCEL "); if (!emstorage_notify_network_event(NOTI_VALIDATE_ACCOUNT_CANCEL, account_id, NULL, handle_to_be_published, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_VALIDATE_ACCOUNT_CANCEL] Failed >>>> "); @@ -1692,17 +1764,16 @@ int event_handler_EMF_EVENT_VALIDATE_ACCOUNT(int account_id, int handle_to_be_pu } } else { - emf_account_t *account_ref; + email_account_t *account_ref; account_ref = emcore_get_account_reference(account_id); if (account_ref) { - EM_DEBUG_LOG("account_ref->receiving_server_type[%d]", account_ref->receiving_server_type); - EM_DEBUG_LOG("account_ref->preset_account[%d]", account_ref->preset_account); - if ((EMF_SERVER_TYPE_IMAP4 == account_ref->receiving_server_type) && (account_ref->preset_account)) { + EM_DEBUG_LOG("account_ref->incoming_server_type[%d]", account_ref->incoming_server_type); + if ( EMAIL_SERVER_TYPE_IMAP4 == account_ref->incoming_server_type ) { if (!emcore_check_thread_status()) - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; else if (!emcore_sync_mailbox_list(account_id, "", &err)) - EM_DEBUG_EXCEPTION("\t emcore_get_list_to_be_sync falied - %d", err); + EM_DEBUG_EXCEPTION("\t emcore_get_mailbox_list_to_be_sync falied - %d", err); } if (err > 0) { @@ -1721,61 +1792,57 @@ int event_handler_EMF_EVENT_VALIDATE_ACCOUNT(int account_id, int handle_to_be_pu return true; } -int event_handler_EMF_EVENT_UPDATE_MAIL(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas, int handle_to_be_published) +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) { 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 = EMF_ERROR_NONE; + 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)) != EMF_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) EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err); if(input_mail_data) - emcore_free_mail_data(&input_mail_data, 1, NULL); + emcore_free_mail_data_list(&input_mail_data, 1); if(input_attachment_data_list) emcore_free_attachment_data(&input_attachment_data_list, input_attachment_count, NULL); if(input_meeting_request) - emstorage_free_meeting_request(&input_meeting_request, 1, NULL); + emstorage_free_meeting_request(input_meeting_request); EM_DEBUG_FUNC_END("err [%d", err); return err; } -int event_handler_EMF_EVENT_MOVE_MAIL(int account_id, char *srt_mailbox_name, int *mail_ids, int mail_id_count, char *dest_mailbox_name, int handle_to_be_published, int *error) +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) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE, ret = false; - emf_mailbox_t dest_mailbox; - emf_account_t *account_ref = NULL; + int err = EMAIL_ERROR_NONE, ret = false; + email_account_t *account_ref = NULL; if (!(account_ref = emcore_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - memset(&dest_mailbox, 0, sizeof(emf_mailbox_t)); - dest_mailbox.name = dest_mailbox_name; - - /* Remove mail local */ + /* Move mail local */ /* - if (!emcore_mail_move(mail_ids, mail_id_count, dest_mailbox.name, EMF_MOVED_BY_COMMAND, 0, &err)) { + if (!emcore_mail_move(mail_ids, mail_id_count, dest_mailbox.mailbox_name, EMAIL_MOVED_BY_COMMAND, 0, &err)) { EM_DEBUG_EXCEPTION("emcore_mail_move failed [%d]", err); goto FINISH_OFF; } */ - if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4) { - /* Remove mail on server */ + if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) { + /* Move mail on server */ if (!emnetwork_check_network_status(&err)) 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 , srt_mailbox_name, mail_ids, mail_id_count, dest_mailbox_name, &err)) + if (!emcore_move_mail_on_server_ex(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 , srt_mailbox_name, mail_ids, mail_id_count, dest_mailbox_name, &err)) + if (!emcore_move_mail_on_server(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 } @@ -1791,20 +1858,15 @@ FINISH_OFF: return ret; } -int event_handler_EMF_EVENT_DELETE_MAILBOX(int account_id, char *mailbox_name, int on_server, int handle_to_be_published, int *error) +int event_handler_EMAIL_EVENT_DELETE_MAILBOX(int mailbox_id, int on_server, int handle_to_be_published, int *error) { - EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - emf_mailbox_t mailbox; - - memset(&mailbox, 0x00, sizeof(mailbox)); - mailbox.account_id = account_id; - mailbox.name = mailbox_name; + EM_DEBUG_FUNC_BEGIN("mailbox_id [%d], on_server [%d], handle_to_be_published [%d], error [%p]", mailbox_id, on_server, handle_to_be_published, error); + int err = EMAIL_ERROR_NONE; if (!emnetwork_check_network_status(&err)) EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); else { - if (!emcore_delete_mailbox(&mailbox, on_server, &err)) + if (!emcore_delete_mailbox(mailbox_id, on_server, &err)) EM_DEBUG_LOG("emcore_delete failed - %d", err); } @@ -1815,16 +1877,16 @@ int event_handler_EMF_EVENT_DELETE_MAILBOX(int account_id, char *mailbox_name, i return true; } -int event_handler_EMF_EVENT_CREATE_MAILBOX(int account_id, char *mailbox_name, char *mailbox_alias, int mailbox_type, int on_server, int handle_to_be_published, int *error) +int event_handler_EMAIL_EVENT_CREATE_MAILBOX(int account_id, char *mailbox_name, char *mailbox_alias, int mailbox_type, int on_server, int handle_to_be_published, int *error) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - emf_mailbox_t mailbox; + int err = EMAIL_ERROR_NONE; + email_mailbox_t mailbox; memset(&mailbox, 0x00, sizeof(mailbox)); mailbox.account_id = account_id; - mailbox.name = mailbox_name; + mailbox.mailbox_name = mailbox_name; mailbox.alias = mailbox_alias; mailbox.mailbox_type = mailbox_type; @@ -1844,11 +1906,11 @@ int event_handler_EMF_EVENT_CREATE_MAILBOX(int account_id, char *mailbox_name, c return true; } -int event_handler_EMF_EVENT_SYNC_MAIL_FLAG_TO_SERVER(int mail_id, int *error) +int event_handler_EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER(int mail_id, int *error) { EM_DEBUG_FUNC_BEGIN("mail_id [%d], error [%p]", mail_id, error); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!emnetwork_check_network_status(&err)) EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); @@ -1879,17 +1941,13 @@ int event_handler_EMF_EVENT_SYNC_MAIL_FLAG_TO_SERVER(int mail_id, int *error) return true; } -int event_handler_EMF_EVENT_DELETE_MAIL_ALL(int account_id, char *mailbox_name, int with_server, int *error) +int event_handler_EMAIL_EVENT_DELETE_MAIL_ALL(int input_mailbox_id, int input_from_server, int *error) { - EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_name [%p], with_server [%d], error [%p]", account_id, mailbox_name, with_server, error); - int err = EMF_ERROR_NONE; - emf_mailbox_t temp_mailbox = { 0 }; + EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_from_server [%d], error [%p]", input_mailbox_id, input_from_server, error); + int err = EMAIL_ERROR_NONE; - temp_mailbox.account_id = account_id; - temp_mailbox.name = mailbox_name; - - if (!emcore_delete_mail_all(&temp_mailbox, with_server, &err)) - EM_DEBUG_EXCEPTION("emcore_delete_mail_all failed [%d]", err); + if (!emcore_delete_all_mails_of_mailbox(input_mailbox_id, input_from_server, &err)) + EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err); if (error) *error = err; @@ -1898,32 +1956,22 @@ int event_handler_EMF_EVENT_DELETE_MAIL_ALL(int account_id, char *mailbox_name, return true; } -int event_handler_EMF_EVENT_DELETE_MAIL(int account_id, int *mail_id_list, int mail_id_count, char *mailbox_name, int *error) +int event_handler_EMAIL_EVENT_DELETE_MAIL(int account_id, int *mail_id_list, int mail_id_count, int *error) { EM_DEBUG_FUNC_BEGIN(); - int mail_id = 0, err = EMF_ERROR_NONE, ret = false; - emf_account_t *account_ref = NULL; + int err = EMAIL_ERROR_NONE; + int ret = false; + email_account_t *account_ref = NULL; if (!(account_ref = emcore_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4) { - if (!emnetwork_check_network_status(&err)) { - EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); - - if (!emstorage_notify_network_event(NOTI_MAIL_DELETE_ON_SERVER_FAIL, account_id, mailbox_name, mail_id, err)) - EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [NOTI_MAIL_DELETE_ON_SERVER_FAIL] Failed"); - - } - else if (!emcore_delete_mail(account_id, mail_id_list, mail_id_count, EMF_DELETE_LOCAL_AND_SERVER, EMF_DELETED_BY_COMMAND, false, &err)) { - EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err); - - if (!emstorage_notify_network_event(NOTI_MAIL_DELETE_ON_SERVER_FAIL, account_id, mailbox_name, mail_id, err)) - EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_MAIL_DELETE_ON_SERVER_FAIL] Failed"); - } + if (!emcore_delete_mail(account_id, mail_id_list, mail_id_count, EMAIL_DELETE_FROM_SERVER, EMAIL_DELETED_BY_COMMAND, false, &err)) { + EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err); + goto FINISH_OFF; } ret = true; @@ -1936,10 +1984,10 @@ FINISH_OFF: return ret; } -int event_hanlder_EMF_EVENT_SYNC_HEADER_OMA(int account_id, char *maibox_name, int *error) +int event_hanlder_EMAIL_EVENT_SYNC_HEADER_OMA(int account_id, char *maibox_name, int *error) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!emnetwork_check_network_status(&err)) { EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); @@ -1959,13 +2007,161 @@ int event_hanlder_EMF_EVENT_SYNC_HEADER_OMA(int account_id, char *maibox_name, i return true; } +int event_handler_EMAIL_EVENT_SEARCH_ON_SERVER(int account_id, int mailbox_id, char *criteria, int handle_to_be_published, int *error) +{ + EM_DEBUG_FUNC_BEGIN("account_id : [%d], mailbox_id : [%d], criteria : [%s]", account_id, mailbox_id, criteria); + + int err = EMAIL_ERROR_NONE; + int i = 0; + int mail_id = 0; + int thread_id = 0; + char temp_uid_string[20] = {0,}; + + emcore_uid_list uid_elem; + emstorage_mailbox_tbl_t *search_mailbox = NULL; + emstorage_mail_tbl_t *new_mail_tbl_data = NULL; + + MAILSTREAM *stream = NULL; + MESSAGECACHE *mail_cache_element = NULL; + ENVELOPE *env = NULL; + emstorage_mailbox_tbl_t* local_mailbox = NULL; + char mailbox_id_param_string[10] = {0,}; + + if (account_id < 0 || mailbox_id == 0) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + if ( (err = emstorage_get_mailbox_by_id(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 (!emstorage_notify_network_event(NOTI_SEARCH_ON_SERVER_START, account_id, mailbox_id_param_string, handle_to_be_published, 0)) + EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_SEARCH_ON_SERVER_START] failed >>>>"); + + if (!emnetwork_check_network_status(&err)) { + EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); + if (!emstorage_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, 0, err)) + EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_DOWNLOAD_FAIL] Failed"); + goto FINISH_OFF; + } + + if (!emcore_connect_to_remote_mailbox(account_id, mailbox_id, (void **)&stream, &err)) { + EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed"); + if (!emstorage_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err)) + EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>"); + goto FINISH_OFF; + } + + if (!mail_search_full(stream, NIL, mail_criteria(criteria), SE_FREE)) { + EM_DEBUG_EXCEPTION("mail_search failed"); + if (!emstorage_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err)) + EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>"); + goto FINISH_OFF; + } + + for (i = 1; i <= stream->nmsgs; ++i) { + mail_cache_element = mail_elt(stream, i); + if (mail_cache_element->searched) { + env = mail_fetchstructure_full(stream, i, NULL, FT_PEEK); + + memset(&uid_elem, 0x00, sizeof(uid_elem)); + + uid_elem.msgno = mail_cache_element->msgno; + SNPRINTF(temp_uid_string, 20, "%4lu", mail_cache_element->private.uid); + uid_elem.uid = temp_uid_string; + uid_elem.flag.seen = mail_cache_element->seen; + + if (!emcore_make_mail_tbl_data_from_envelope(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); + if (!emstorage_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err)) + EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>"); + goto FINISH_OFF; + } + + if (!emstorage_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_SEARCH_RESULT, &search_mailbox, false, &err)) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err); + if (!emstorage_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err)) + EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>"); + goto FINISH_OFF; + } + + if ((err = emcore_add_mail_to_mailbox(search_mailbox, new_mail_tbl_data, &mail_id, &thread_id)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox failed [%d]", err); + if (!emstorage_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err)) + EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>"); + goto FINISH_OFF; + } + memset(mailbox_id_param_string, 0, 10); + SNPRINTF(mailbox_id_param_string, 10, "%d", search_mailbox->mailbox_id); + if (!emstorage_notify_storage_event(NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id)) { + EM_DEBUG_EXCEPTION("emstorage_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; + } + } + } + + if (err == EMAIL_ERROR_NONE && !emstorage_notify_network_event(NOTI_SEARCH_ON_SERVER_FINISH, account_id, NULL, handle_to_be_published, 0)) + EM_DEBUG_EXCEPTION("emstorage_notify_network_event[NOTI_SEARCH_ON_SERVER_FINISH] Failed >>>>>"); + +FINISH_OFF: + + 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); + + if (local_mailbox) + emstorage_free_mailbox(&local_mailbox, 1, NULL); + + if (error) + *error = err; + + EM_DEBUG_FUNC_END(); + 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, int handle_to_be_published) +{ + EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_mailbox_id [%d], input_old_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, handle_to_be_published); + int err = EMAIL_ERROR_NONE; + + if ((err = emcore_move_mailbox_on_imap_server(input_account_id, input_old_mailbox_path, input_new_mailbox_path)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emcore_move_mailbox_on_imap_server failed [%d]", err); + goto FINISH_OFF; + } + + if (err == EMAIL_ERROR_NONE) { + if(!emstorage_notify_network_event(NOTI_RENAME_MAILBOX_FINISH, input_mailbox_id, input_new_mailbox_path, handle_to_be_published, 0)) + EM_DEBUG_EXCEPTION("emstorage_notify_network_event[NOTI_RENAME_MAILBOX_FINISH] failed"); + } + else if (!emstorage_notify_network_event(NOTI_RENAME_MAILBOX_FAIL, input_mailbox_id, input_new_mailbox_path, handle_to_be_published, 0)) + EM_DEBUG_EXCEPTION("emstorage_notify_network_event[NOTI_RENAME_MAILBOX_FAIL] failed"); + +FINISH_OFF: + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + void* thread_func_branch_command(void *arg) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE, is_storage_full = false, noti_id = 0; - emf_event_t event_data; - emf_session_t *session = NULL; + int err = EMAIL_ERROR_NONE; + int is_storage_full = false; + int noti_id = 0; + email_event_t event_data; + email_session_t *session = NULL; + emstorage_account_tbl_t *account_tbl = NULL; int handle_to_be_published = 0; if (!emstorage_open(&err)) { @@ -2043,19 +2239,19 @@ void* thread_func_branch_command(void *arg) /* Handling storage full */ is_storage_full = false; - if (event_data.type == EMF_EVENT_SYNC_HEADER || event_data.type == EMF_EVENT_SYNC_HEADER_OMA || - event_data.type == EMF_EVENT_DOWNLOAD_BODY || event_data.type == EMF_EVENT_DOWNLOAD_ATTACHMENT) { + if (event_data.type == EMAIL_EVENT_SYNC_HEADER || event_data.type == EMAIL_EVENT_SYNC_HEADER_OMA || + event_data.type == EMAIL_EVENT_DOWNLOAD_BODY || event_data.type == EMAIL_EVENT_DOWNLOAD_ATTACHMENT) { if (emcore_is_storage_full(&err) == true) { EM_DEBUG_EXCEPTION("Storage is full"); switch (event_data.type) { - case EMF_EVENT_SYNC_HEADER: - case EMF_EVENT_SYNC_HEADER_OMA: + case EMAIL_EVENT_SYNC_HEADER: + case EMAIL_EVENT_SYNC_HEADER_OMA: noti_id = NOTI_DOWNLOAD_FAIL; break; - case EMF_EVENT_DOWNLOAD_BODY: + case EMAIL_EVENT_DOWNLOAD_BODY: noti_id = NOTI_DOWNLOAD_BODY_FAIL; break; - case EMF_EVENT_DOWNLOAD_ATTACHMENT: + case EMAIL_EVENT_DOWNLOAD_ATTACHMENT: noti_id = NOTI_DOWNLOAD_ATTACH_FAIL; break; default: @@ -2070,143 +2266,176 @@ void* thread_func_branch_command(void *arg) emdevice_set_dimming_on_off(false, NULL); - switch (event_data.type) { - case EMF_EVENT_SYNC_IMAP_MAILBOX: /* get imap mailbox list */ - if (!emnetwork_check_network_status(&err)) - EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); - else { - if (!emcore_sync_mailbox_list(event_data.account_id, event_data.event_param_data_3, &err)) - EM_DEBUG_EXCEPTION("emcore_sync_mailbox_list failed [%d]", err); - } - EM_SAFE_FREE(event_data.event_param_data_3); - break; - - case EMF_EVENT_SYNC_HEADER: /* synchronize mail header */ - if (is_storage_full == false) - event_handler_EMF_EVENT_SYNC_HEADER(event_data.account_id, event_data.event_param_data_1, handle_to_be_published, &err); - EM_SAFE_FREE(event_data.event_param_data_1); - break; + 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)) { + EM_DEBUG_EXCEPTION("emstorage_get_account_by_id [%d]", err); + } + } - case EMF_EVENT_SYNC_HEADER_OMA: /* synchronize mail header for OMA */ - if (is_storage_full == false) - event_hanlder_EMF_EVENT_SYNC_HEADER_OMA(event_data.account_id, event_data.event_param_data_1, &err); - EM_SAFE_FREE(event_data.event_param_data_1); - break; - - case EMF_EVENT_DOWNLOAD_BODY: /* download mail body */ - if (is_storage_full == false) - event_handler_EMF_EVENT_DOWNLOAD_BODY(event_data.account_id, event_data.event_param_data_1, (int)event_data.event_param_data_4, (int)event_data.event_param_data_3, handle_to_be_published, &err); - event_data.event_param_data_3 = NULL; /* MUST BE */ - EM_SAFE_FREE(event_data.event_param_data_1); - break; - - case EMF_EVENT_DOWNLOAD_ATTACHMENT: /* download attachment */ - if (is_storage_full == false) - event_handler_EMF_EVENT_DOWNLOAD_ATTACHMENT(event_data.account_id, event_data.event_param_data_1, (int)event_data.event_param_data_4, event_data.event_param_data_3, handle_to_be_published, &err); - EM_SAFE_FREE(event_data.event_param_data_3); - break; + if (account_tbl) + EM_DEBUG_LOG("account_id : [%d], sync_disabled : [%d]", event_data.account_id, account_tbl->sync_disabled); + + if (!account_tbl || account_tbl->sync_disabled == 0) { + switch (event_data.type) { + case EMAIL_EVENT_SYNC_IMAP_MAILBOX: /* get imap mailbox list */ + if (!emnetwork_check_network_status(&err)) + EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); + else { + if (!emcore_sync_mailbox_list(event_data.account_id, event_data.event_param_data_3, &err)) + EM_DEBUG_EXCEPTION("emcore_sync_mailbox_list failed [%d]", err); + } + EM_SAFE_FREE(event_data.event_param_data_3); + break; - case EMF_EVENT_SYNC_FLAGS_FIELD_TO_SERVER: /* Sync flags field */ - event_handler_EMF_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); - EM_SAFE_FREE(event_data.event_param_data_3); - break; - - case EMF_EVENT_DELETE_MAIL: /* delete mails */ - event_handler_EMF_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_1, &err); - EM_SAFE_FREE(event_data.event_param_data_1); - EM_SAFE_FREE(event_data.event_param_data_3); - break; - - case EMF_EVENT_DELETE_MAIL_ALL: /* delete all mails */ - event_handler_EMF_EVENT_DELETE_MAIL_ALL((int)event_data.account_id, (char *)event_data.event_param_data_1, (int)event_data.event_param_data_4, &err); - EM_SAFE_FREE(event_data.event_param_data_1); - 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); + 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, &err); + EM_SAFE_FREE(event_data.event_param_data_1); + break; + + case EMAIL_EVENT_DOWNLOAD_BODY: /* download mail body */ + if (is_storage_full == false) + event_handler_EMAIL_EVENT_DOWNLOAD_BODY(event_data.account_id, (int)event_data.event_param_data_4, (int)event_data.event_param_data_3, handle_to_be_published, &err); + event_data.event_param_data_3 = NULL; /* MUST BE */ + 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); + 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); + EM_SAFE_FREE(event_data.event_param_data_3); + 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, &err); + EM_SAFE_FREE(event_data.event_param_data_3); + break; + + case EMAIL_EVENT_DELETE_MAIL_ALL: /* delete all mails */ + event_handler_EMAIL_EVENT_DELETE_MAIL_ALL(event_data.event_param_data_4, (int)event_data.event_param_data_5, &err); + break; #ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__ - case EMF_EVENT_SYNC_MAIL_FLAG_TO_SERVER: - event_handler_EMF_EVENT_SYNC_MAIL_FLAG_TO_SERVER((int)event_data.event_param_data_4, &err); - break; + case EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER: + event_handler_EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER((int)event_data.event_param_data_4, &err); + break; #endif - - case EMF_EVENT_CREATE_MAILBOX: - event_handler_EMF_EVENT_CREATE_MAILBOX(event_data.account_id, event_data.event_param_data_1, event_data.event_param_data_2, GPOINTER_TO_INT(event_data.event_param_data_3), event_data.event_param_data_4, handle_to_be_published, &err); - EM_SAFE_FREE(event_data.event_param_data_1); - EM_SAFE_FREE(event_data.event_param_data_2); - break; - case EMF_EVENT_DELETE_MAILBOX: - event_handler_EMF_EVENT_DELETE_MAILBOX(event_data.account_id, event_data.event_param_data_1, event_data.event_param_data_4, handle_to_be_published, &err); - EM_SAFE_FREE(event_data.event_param_data_1); - break; + case EMAIL_EVENT_CREATE_MAILBOX: + event_handler_EMAIL_EVENT_CREATE_MAILBOX(event_data.account_id, event_data.event_param_data_1, event_data.event_param_data_2, GPOINTER_TO_INT(event_data.event_param_data_3), event_data.event_param_data_4, handle_to_be_published, &err); + EM_SAFE_FREE(event_data.event_param_data_1); + EM_SAFE_FREE(event_data.event_param_data_2); + break; - case EMF_EVENT_MOVE_MAIL: - event_handler_EMF_EVENT_MOVE_MAIL(event_data.account_id, event_data.event_param_data_2, (int *)event_data.event_param_data_3, event_data.event_param_data_4, event_data.event_param_data_1, handle_to_be_published, &err); + case EMAIL_EVENT_DELETE_MAILBOX: + event_handler_EMAIL_EVENT_DELETE_MAILBOX(event_data.event_param_data_4, event_data.event_param_data_4, handle_to_be_published, &err); + break; - EM_SAFE_FREE(event_data.event_param_data_1); - EM_SAFE_FREE(event_data.event_param_data_2); - EM_SAFE_FREE(event_data.event_param_data_3); - 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); - case EMF_EVENT_VALIDATE_ACCOUNT: - event_handler_EMF_EVENT_VALIDATE_ACCOUNT(event_data.account_id, handle_to_be_published, &err); - break; + EM_SAFE_FREE(event_data.event_param_data_3); + break; - case EMF_EVENT_VALIDATE_AND_CREATE_ACCOUNT: - event_handler_EMF_EVENT_VALIDATE_AND_CREATE_ACCOUNT(emcore_get_new_account_reference(), 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); + break; - case EMF_EVENT_VALIDATE_AND_UPDATE_ACCOUNT: { - emf_account_t *pAccount = (emf_account_t *)event_data.event_param_data_1; - event_handler_EMF_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(event_data.account_id, pAccount, handle_to_be_published, &err); - emcore_free_account(&pAccount, 1, NULL); - } - break; + case EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT: { +/* event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(emcore_get_new_account_reference(), handle_to_be_published, &err);*/ + 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); + emcore_free_account(account); + memset(account, 0, sizeof(email_account_t)); /*global account */ + } + break; - case EMF_EVENT_UPDATE_MAIL: - event_handler_EMF_EVENT_UPDATE_MAIL((emf_mail_data_t*)event_data.event_param_data_1, (emf_attachment_data_t*)event_data.event_param_data_2, event_data.event_param_data_4, (emf_meeting_request_t*)event_data.event_param_data_3, event_data.event_param_data_5, handle_to_be_published); - - event_data.event_param_data_1 = NULL; - event_data.event_param_data_2 = NULL; - event_data.event_param_data_3 = NULL; - break; + case EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT: { + email_account_t *pAccount = (email_account_t *)event_data.event_param_data_1; + event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(event_data.account_id, pAccount, handle_to_be_published, &err); + emcore_free_account(pAccount); + EM_SAFE_FREE(pAccount); + } + break; - case EMF_EVENT_SET_MAIL_SLOT_SIZE: - event_handler_EMF_EVENT_SET_MAIL_SLOT_SIZE(event_data.account_id, event_data.event_param_data_3, event_data.event_param_data_4, handle_to_be_published, &err); - EM_SAFE_FREE(event_data.event_param_data_3); - break; - -#ifdef __FEATURE_LOCAL_ACTIVITY__ - case EMF_EVENT_LOCAL_ACTIVITY: - event_handler_EMF_EVENT_LOCAL_ACTIVITY(event_data.account_id, &err); - break; -#endif /* __FEATURE_LOCAL_ACTIVITY__*/ - - default: - 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_data.event_param_data_1 = NULL; + event_data.event_param_data_2 = NULL; + event_data.event_param_data_3 = NULL; + 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); + 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); + break; + + #ifdef __FEATURE_LOCAL_ACTIVITY__ + case EMAIL_EVENT_LOCAL_ACTIVITY: + event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(event_data.account_id, &err); + break; + #endif /* __FEATURE_LOCAL_ACTIVITY__*/ + + case EMAIL_EVENT_SEARCH_ON_SERVER: + event_handler_EMAIL_EVENT_SEARCH_ON_SERVER(event_data.account_id, event_data.event_param_data_4, (char *)event_data.event_param_data_1, handle_to_be_published, &err); + EM_SAFE_FREE(event_data.event_param_data_1); + 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, handle_to_be_published); + EM_SAFE_FREE(event_data.event_param_data_1); + EM_SAFE_FREE(event_data.event_param_data_2); + break; + + default: + break; + } + } + + if (account_tbl) { + emstorage_free_account(&account_tbl, 1, NULL); + account_tbl = NULL; } + if (!emstorage_notify_response_to_api(event_data.type, handle_to_be_published, err)) + EM_DEBUG_EXCEPTION("emstorage_notify_response_to_api failed"); + emdevice_set_dimming_on_off(true, NULL); em_flush_memory(); switch (event_data.type) { - case EMF_EVENT_SEND_MAIL: - case EMF_EVENT_SEND_MAIL_SAVED: + case EMAIL_EVENT_SEND_MAIL: + case EMAIL_EVENT_SEND_MAIL_SAVED: _sending_busy_unref(); break; - case EMF_EVENT_SYNC_HEADER: - case EMF_EVENT_SYNC_HEADER_OMA: - case EMF_EVENT_DOWNLOAD_BODY: - case EMF_EVENT_DOWNLOAD_ATTACHMENT: - case EMF_EVENT_SYNC_MAIL_FLAG_TO_SERVER: - case EMF_EVENT_SYNC_FLAGS_FIELD_TO_SERVER: - case EMF_EVENT_DELETE_MAIL: - case EMF_EVENT_DELETE_MAIL_ALL: - case EMF_EVENT_VALIDATE_ACCOUNT: - case EMF_EVENT_SYNC_IMAP_MAILBOX: - case EMF_EVENT_MOVE_MAIL: - case EMF_EVENT_CREATE_MAILBOX: - case EMF_EVENT_DELETE_MAILBOX: - case EMF_EVENT_SET_MAIL_SLOT_SIZE: + case EMAIL_EVENT_SYNC_HEADER: + case EMAIL_EVENT_SYNC_HEADER_OMA: + case EMAIL_EVENT_DOWNLOAD_BODY: + case EMAIL_EVENT_DOWNLOAD_ATTACHMENT: + case EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER: + case EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER: + case EMAIL_EVENT_DELETE_MAIL: + case EMAIL_EVENT_DELETE_MAIL_ALL: + case EMAIL_EVENT_VALIDATE_ACCOUNT: + case EMAIL_EVENT_SYNC_IMAP_MAILBOX: + case EMAIL_EVENT_MOVE_MAIL: + 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: _receiving_busy_unref(); break; @@ -2217,7 +2446,7 @@ void* thread_func_branch_command(void *arg) event_data.type = 0; ENTER_RECURSIVE_CRITICAL_SECTION(_event_queue_lock); - memset(g_event_que+g_active_que, 0x00, sizeof(emf_event_t)); + memset(g_event_que+g_active_que, 0x00, sizeof(email_event_t)); LEAVE_RECURSIVE_CRITICAL_SECTION(_event_queue_lock); } @@ -2231,20 +2460,20 @@ void* thread_func_branch_command(void *arg) return SUCCESS; } /*Send event_data loop*/ -INTERNAL_FUNC int emcore_send_event_loop_start(int *err_code) +INTERNAL_FUNC int emcore_start_event_loop_for_sending_mails(int *err_code) { EM_DEBUG_FUNC_BEGIN(); int thread_error = -1; if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; memset(&g_send_event_que, 0x00, sizeof(g_send_event_que)); if (g_send_srv_thread) { EM_DEBUG_EXCEPTION("\t send service thread is already running..."); if (err_code != NULL) - *err_code = EMF_ERROR_UNKNOWN; + *err_code = EMAIL_ERROR_UNKNOWN; return true; } @@ -2258,17 +2487,17 @@ INTERNAL_FUNC int emcore_send_event_loop_start(int *err_code) INITIALIZE_CONDITION_VARIABLE(_send_event_available_signal); /* create thread */ - THREAD_CREATE_JOINABLE(g_send_srv_thread, send_event_handler, thread_error); + THREAD_CREATE_JOINABLE(g_send_srv_thread, thread_func_branch_command_for_sending_mails, thread_error); if (thread_error != 0) { EM_DEBUG_EXCEPTION("cannot make thread..."); if (err_code != NULL) - *err_code = EMF_ERROR_UNKNOWN; + *err_code = EMAIL_ERROR_UNKNOWN; return FAILURE; } if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; EM_DEBUG_FUNC_END(); return SUCCESS; } @@ -2279,11 +2508,11 @@ INTERNAL_FUNC int emcore_send_event_loop_stop(int *err_code) EM_DEBUG_FUNC_BEGIN(); if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; if (!g_send_srv_thread) { if (err_code != NULL) - *err_code = EMF_ERROR_UNKNOWN; + *err_code = EMAIL_ERROR_UNKNOWN; return false; } @@ -2308,7 +2537,7 @@ INTERNAL_FUNC int emcore_send_event_loop_stop(int *err_code) g_send_active_que = 0; if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; return true; } @@ -2320,14 +2549,14 @@ INTERNAL_FUNC int emcore_start_event_loop(int *err_code) int thread_error; if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; memset(&g_event_que, 0x00, sizeof(g_event_que)); if (g_srv_thread) { EM_DEBUG_EXCEPTION("service thread is already running..."); if (err_code != NULL) - *err_code = EMF_ERROR_UNKNOWN; + *err_code = EMAIL_ERROR_UNKNOWN; return true; } @@ -2347,12 +2576,12 @@ INTERNAL_FUNC int emcore_start_event_loop(int *err_code) if (thread_error != 0) { EM_DEBUG_EXCEPTION("cannot create thread"); if (err_code != NULL) - *err_code = EMF_ERROR_SYSTEM_FAILURE; + *err_code = EMAIL_ERROR_SYSTEM_FAILURE; return FAILURE; } if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; return false; } @@ -2363,11 +2592,11 @@ INTERNAL_FUNC int emcore_stop_event_loop(int *err_code) EM_DEBUG_FUNC_BEGIN(); if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; if (!g_srv_thread) { if (err_code != NULL) - *err_code = EMF_ERROR_UNKNOWN; + *err_code = EMAIL_ERROR_UNKNOWN; return false; } @@ -2395,7 +2624,7 @@ INTERNAL_FUNC int emcore_stop_event_loop(int *err_code) g_active_que = 0; if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; EM_DEBUG_FUNC_END(); return true; } @@ -2414,7 +2643,7 @@ INTERNAL_FUNC int emcore_check_thread_status() if (g_active_que <= 0) return true; - return (g_event_que[g_active_que].status == EMF_EVENT_STATUS_STARTED); + return (g_event_que[g_active_que].status == EMAIL_EVENT_STATUS_STARTED); } /* cancel a job */ @@ -2423,11 +2652,11 @@ INTERNAL_FUNC int emcore_cancel_thread(int handle, void *arg, int *err_code) EM_DEBUG_FUNC_BEGIN("handle[%d], arg[%p], err_code[%p]", handle, arg, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (handle <= 0 || handle > (EVENT_QUEUE_MAX - 1)) { EM_DEBUG_EXCEPTION("handle[%d], arg[%p]", handle, arg); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2435,48 +2664,50 @@ INTERNAL_FUNC int emcore_cancel_thread(int handle, void *arg, int *err_code) EM_DEBUG_LOG("status[%d], type[%d], handle[%d]", g_event_que[handle].status, g_event_que[handle].type, handle); - if (g_event_que[handle].status == EMF_EVENT_STATUS_WAIT) { - fail_status_notify(&g_event_que[handle], EMF_ERROR_CANCELLED); + if (g_event_que[handle].status == EMAIL_EVENT_STATUS_WAIT) { + fail_status_notify(&g_event_que[handle], EMAIL_ERROR_CANCELLED); switch (g_event_que[handle].type) { - case EMF_EVENT_SEND_MAIL: - case EMF_EVENT_SEND_MAIL_SAVED: - EM_DEBUG_LOG("EMF_EVENT_SEND_MAIL or EMF_EVENT_SEND_MAIL_SAVED"); + case EMAIL_EVENT_SEND_MAIL: + case EMAIL_EVENT_SEND_MAIL_SAVED: + EM_DEBUG_LOG("EMAIL_EVENT_SEND_MAIL or EMAIL_EVENT_SEND_MAIL_SAVED"); _sending_busy_unref(); if (!emstorage_notify_network_event(NOTI_SEND_CANCEL, g_event_que[handle].account_id, NULL , g_event_que[handle].event_param_data_4, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_SEND_CANCEL] Failed >>>> "); break; - case EMF_EVENT_DOWNLOAD_BODY: - EM_DEBUG_LOG("EMF_EVENT_DOWNLOAD_BODY"); + case EMAIL_EVENT_DOWNLOAD_BODY: + EM_DEBUG_LOG("EMAIL_EVENT_DOWNLOAD_BODY"); _receiving_busy_unref(); if (!emstorage_notify_network_event(NOTI_DOWNLOAD_BODY_CANCEL, g_event_que[handle].account_id, NULL , g_event_que[handle].event_param_data_4, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_SEND_CANCEL] Failed >>>> "); break; - case EMF_EVENT_SYNC_HEADER: - case EMF_EVENT_SYNC_HEADER_OMA: - case EMF_EVENT_DOWNLOAD_ATTACHMENT: - case EMF_EVENT_SYNC_MAIL_FLAG_TO_SERVER: - case EMF_EVENT_SYNC_FLAGS_FIELD_TO_SERVER: - EM_DEBUG_LOG("EMF_EVENT_SYNC_HEADER, EMF_EVENT_DOWNLOAD_ATTACHMENT"); + case EMAIL_EVENT_SYNC_HEADER: + case EMAIL_EVENT_SYNC_HEADER_OMA: + case EMAIL_EVENT_DOWNLOAD_ATTACHMENT: + case EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER: + case EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER: + EM_DEBUG_LOG("EMAIL_EVENT_SYNC_HEADER, EMAIL_EVENT_DOWNLOAD_ATTACHMENT"); _receiving_busy_unref(); break; - case EMF_EVENT_VALIDATE_ACCOUNT: + case EMAIL_EVENT_VALIDATE_ACCOUNT: EM_DEBUG_LOG(" validate account waiting : cancel acc id : %d", g_event_que[handle].account_id); _receiving_busy_unref(); if (!emstorage_notify_network_event(NOTI_VALIDATE_ACCOUNT_CANCEL, g_event_que[handle].account_id, NULL , g_event_que[handle].event_param_data_4, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_VALIDATE_ACCOUNT_CANCEL] Failed >>>> "); break; - case EMF_EVENT_DELETE_MAIL: - case EMF_EVENT_DELETE_MAIL_ALL: - case EMF_EVENT_SYNC_IMAP_MAILBOX: - case EMF_EVENT_MOVE_MAIL: - case EMF_EVENT_CREATE_MAILBOX: - case EMF_EVENT_DELETE_MAILBOX: - case EMF_EVENT_SET_MAIL_SLOT_SIZE: - EM_DEBUG_LOG("EMF_EVENT_DELETE_MAIL, EMF_EVENT_SYNC_IMAP_MAILBOX"); + case EMAIL_EVENT_DELETE_MAIL: + case EMAIL_EVENT_DELETE_MAIL_ALL: + case EMAIL_EVENT_SYNC_IMAP_MAILBOX: + case EMAIL_EVENT_MOVE_MAIL: + 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"); _receiving_busy_unref(); break; default: @@ -2484,8 +2715,8 @@ INTERNAL_FUNC int emcore_cancel_thread(int handle, void *arg, int *err_code) } } - memset(g_event_que+handle, 0x00, sizeof(emf_event_t)); - g_event_que[handle].status = EMF_EVENT_STATUS_CANCELED; + memset(g_event_que+handle, 0x00, sizeof(email_event_t)); + g_event_que[handle].status = EMAIL_EVENT_STATUS_CANCELED; LEAVE_RECURSIVE_CRITICAL_SECTION(_event_queue_lock); @@ -2509,17 +2740,17 @@ int emcore_check_send_mail_thread_status() return true; EM_DEBUG_LOG("g_send_event_que[g_send_active_que[%d]].status[%d]", g_send_active_que, g_send_event_que[g_send_active_que].status); EM_DEBUG_FUNC_END(); - return (g_send_event_que[g_send_active_que].status == EMF_EVENT_STATUS_STARTED); + return (g_send_event_que[g_send_active_que].status == EMAIL_EVENT_STATUS_STARTED); } INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(int account_id) { EM_DEBUG_FUNC_BEGIN(); - int error_code = EMF_ERROR_NONE; + int error_code = EMAIL_ERROR_NONE; int i, event_count = EVENT_QUEUE_MAX, exit_flag = 0, sleep_count = 0; for (i = 0 ; i < event_count; i++) { - if (g_event_que[i].type && g_event_que[i].status != EMF_EVENT_STATUS_UNUSED) { + if (g_event_que[i].type && g_event_que[i].status != EMAIL_EVENT_STATUS_UNUSED) { EM_DEBUG_LOG("There is a live thread. %d", i); if (g_event_que[i].account_id == account_id || g_event_que[i].account_id == ALL_ACCOUNT) { EM_DEBUG_LOG("And it is for account %d", g_event_que[i].account_id); @@ -2535,7 +2766,7 @@ INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(int account_id) sleep_count++; exit_flag = 1; for (i = 0 ; i < event_count; i++) { - if (g_event_que[i].type && g_event_que[i].status != EMF_EVENT_STATUS_UNUSED) { + if (g_event_que[i].type && g_event_que[i].status != EMAIL_EVENT_STATUS_UNUSED) { EM_DEBUG_LOG("There is still a live thread. %d", i); if (g_event_que[i].account_id == account_id || g_event_que[i].account_id == ALL_ACCOUNT) { EM_DEBUG_LOG("And it is for account %d. So, I should sleep for a while.", g_event_que[i].account_id); @@ -2548,9 +2779,9 @@ INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(int account_id) EM_DEBUG_LOG("Sleep count %d", sleep_count); if (sleep_count >= 30) - error_code = EMF_ERROR_CANNOT_STOP_THREAD; + error_code = EMAIL_ERROR_CANNOT_STOP_THREAD; else - error_code = EMF_ERROR_NONE; + error_code = EMAIL_ERROR_NONE; EM_DEBUG_FUNC_END(); return error_code; } @@ -2562,11 +2793,11 @@ INTERNAL_FUNC int emcore_cancel_send_mail_thread(int handle, void *arg, int *err EM_DEBUG_FUNC_BEGIN("handle[%d], arg[%p], err_code[%p]", handle, arg, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (handle <= 0 || handle > (EVENT_QUEUE_MAX - 1)) { EM_DEBUG_EXCEPTION("handle[%d], arg[%p]", handle, arg); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2574,14 +2805,14 @@ INTERNAL_FUNC int emcore_cancel_send_mail_thread(int handle, void *arg, int *err EM_DEBUG_LOG("event_data.status[%d], handle[%d]", g_send_event_que[handle].status, handle); - if (g_send_event_que[handle].status == EMF_EVENT_STATUS_WAIT) { - fail_status_notify(&g_send_event_que[handle], EMF_ERROR_CANCELLED); + if (g_send_event_que[handle].status == EMAIL_EVENT_STATUS_WAIT) { + fail_status_notify(&g_send_event_que[handle], EMAIL_ERROR_CANCELLED); switch (g_send_event_que[handle].type) { - case EMF_EVENT_SEND_MAIL: - case EMF_EVENT_SEND_MAIL_SAVED: + case EMAIL_EVENT_SEND_MAIL: + case EMAIL_EVENT_SEND_MAIL_SAVED: _sending_busy_unref(); - g_send_event_que[handle].status = EMF_EVENT_STATUS_CANCELED; + g_send_event_que[handle].status = EMAIL_EVENT_STATUS_CANCELED; if (!emstorage_notify_network_event(NOTI_SEND_CANCEL, g_send_event_que[handle].account_id, NULL , g_send_event_que[handle].event_param_data_4, err)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_SEND_CANCEL] Failed >>>> "); break; @@ -2591,8 +2822,8 @@ INTERNAL_FUNC int emcore_cancel_send_mail_thread(int handle, void *arg, int *err } EM_DEBUG_LOG("send_mail_cancel"); - memset(g_send_event_que+handle, 0x00, sizeof(emf_event_t)); - g_send_event_que[handle].status = EMF_EVENT_STATUS_CANCELED; + memset(g_send_event_que+handle, 0x00, sizeof(email_event_t)); + g_send_event_que[handle].status = EMAIL_EVENT_STATUS_CANCELED; EM_DEBUG_LOG("event_data.status[%d], handle[%d]", g_send_event_que[handle].status, handle); @@ -2609,13 +2840,13 @@ FINISH_OFF: } -INTERNAL_FUNC int emcore_get_receiving_event_queue(emf_event_t **event_queue, int *event_active_queue, int *err) +INTERNAL_FUNC int emcore_get_receiving_event_queue(email_event_t **event_queue, int *event_active_queue, int *err) { if (event_queue == NULL || event_active_queue == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM event_queue[%p] event_active_queue[%p]", event_queue, event_active_queue); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM event_queue[%p] event_active_queue[%p]", event_queue, event_active_queue); if (err) - *err = EMF_ERROR_INVALID_PARAM; + *err = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -2626,7 +2857,7 @@ INTERNAL_FUNC int emcore_get_receiving_event_queue(emf_event_t **event_queue, in return true; } -INTERNAL_FUNC int emcore_free_event(emf_event_t *event_data) +INTERNAL_FUNC int emcore_free_event(email_event_t *event_data) { EM_DEBUG_FUNC_BEGIN("event_data [%p]", event_data); @@ -2679,7 +2910,7 @@ static int emcore_clear_bulk_pbd_que(int *err_code) EM_DEBUG_FUNC_BEGIN(); int ret = true; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int i = 0; for (i = 0; i < BULK_PARTIAL_BODY_DOWNLOAD_COUNT; ++i) { @@ -2736,7 +2967,7 @@ INTERNAL_FUNC int emcore_clear_partial_body_thd_event_que(int *err_code) EM_DEBUG_FUNC_BEGIN(); int ret = true; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int i = 0; ENTER_CRITICAL_SECTION(_partial_body_thd_event_queue_lock); @@ -2809,15 +3040,15 @@ Also never call any function from this API which uses _partial_body_thd_event_qu */ -static int emcore_copy_partial_body_thd_event(emf_event_partial_body_thd *src, emf_event_partial_body_thd *dest, int *error_code) +static int emcore_copy_partial_body_thd_event(email_event_partial_body_thd *src, email_event_partial_body_thd *dest, int *error_code) { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int ret = false; if (NULL == src || NULL == dest) { EM_DEBUG_LOG(" Invalid Parameter src [%p] dest [%p]", src, dest); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2825,6 +3056,7 @@ static int emcore_copy_partial_body_thd_event(emf_event_partial_body_thd *src, e dest->mail_id = src->mail_id; dest->server_mail_id = src->server_mail_id; dest->activity_id = src->activity_id; + dest->mailbox_id = src->mailbox_id; dest->mailbox_name = EM_SAFE_STRDUP(src->mailbox_name); dest->activity_type = src->activity_type; dest->event_type = src->event_type; @@ -2855,25 +3087,25 @@ Also never call any function from this API which uses _partial_body_thd_event_qu */ -INTERNAL_FUNC int emcore_free_partial_body_thd_event(emf_event_partial_body_thd *partial_body_thd_event, int *error_code) +INTERNAL_FUNC int emcore_free_partial_body_thd_event(email_event_partial_body_thd *partial_body_thd_event, int *error_code) { EM_DEBUG_FUNC_BEGIN(); if (NULL == partial_body_thd_event) { - *error_code = EMF_ERROR_INVALID_PARAM; + *error_code = EMAIL_ERROR_INVALID_PARAM; return false; } - emf_event_partial_body_thd *pbd_event = partial_body_thd_event; + email_event_partial_body_thd *pbd_event = partial_body_thd_event; /*Free character pointers in event_data cell */ EM_SAFE_FREE(pbd_event->mailbox_name); - memset(pbd_event, 0x00, sizeof(emf_event_partial_body_thd)); + memset(pbd_event, 0x00, sizeof(email_event_partial_body_thd)); EM_DEBUG_FUNC_END(); return true; } -INTERNAL_FUNC int emcore_insert_partial_body_thread_event(emf_event_partial_body_thd *partial_body_thd_event, int *error_code) +INTERNAL_FUNC int emcore_insert_partial_body_thread_event(email_event_partial_body_thd *partial_body_thd_event, int *error_code) { EM_DEBUG_FUNC_BEGIN(); @@ -2881,13 +3113,13 @@ INTERNAL_FUNC int emcore_insert_partial_body_thread_event(emf_event_partial_body EM_DEBUG_EXCEPTION("\t partial_body_thd_event [%p] ", partial_body_thd_event); if (error_code != NULL) { - *error_code = EMF_ERROR_INVALID_PARAM; + *error_code = EMAIL_ERROR_INVALID_PARAM; } return false; } int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int empty_cell_index = -1; int index = 0; int count = 0; @@ -2933,7 +3165,7 @@ INTERNAL_FUNC int emcore_insert_partial_body_thread_event(emf_event_partial_body } else { EM_DEBUG_LOG(" partial body thread event_data queue is full "); - error = EMF_ERROR_EVENT_QUEUE_FULL; + error = EMAIL_ERROR_EVENT_QUEUE_FULL; g_partial_body_thd_queue_full = true; g_partial_body_thd_queue_empty = false; @@ -2952,12 +3184,12 @@ INTERNAL_FUNC int emcore_insert_partial_body_thread_event(emf_event_partial_body /* h.gahlaut : Return true only if event_data is retrieved successfully */ -static int emcore_retrieve_partial_body_thread_event(emf_event_partial_body_thd *partial_body_thd_event, int *error_code) +static int emcore_retrieve_partial_body_thread_event(email_event_partial_body_thd *partial_body_thd_event, int *error_code) { EM_DEBUG_FUNC_BEGIN(); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int index = 0; /* Lock Mutex to protect event_data queue and associated global variables variables*/ @@ -2967,7 +3199,7 @@ static int emcore_retrieve_partial_body_thread_event(emf_event_partial_body_thd index = g_partial_body_thd_next_event_idx; if (0 == g_partial_body_thd_event_que[index].event_type) { - error = EMF_ERROR_EVENT_QUEUE_EMPTY; + error = EMAIL_ERROR_EVENT_QUEUE_EMPTY; g_partial_body_thd_queue_empty = true; g_partial_body_thd_queue_full = false; } @@ -3014,9 +3246,9 @@ gpointer partial_body_download_thread(gpointer data) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - emf_session_t *session = NULL; - emf_event_partial_body_thd partial_body_thd_event; + int err = EMAIL_ERROR_NONE; + email_session_t *session = NULL; + email_event_partial_body_thd partial_body_thd_event; EM_DEBUG_LOG(" ************ PB THREAD ID IS ALIVE. ID IS [%d] ********************" , THREAD_SELF()); @@ -3036,10 +3268,10 @@ gpointer partial_body_download_thread(gpointer data) if (false == emcore_get_empty_session(&session)) EM_DEBUG_EXCEPTION("emcore_get_empty_session failed..."); else { /* Get and Event from the Partial Body thread Event Queue */ - memset(&partial_body_thd_event, 0x00, sizeof(emf_event_partial_body_thd)); + memset(&partial_body_thd_event, 0x00, sizeof(email_event_partial_body_thd)); if (false == emcore_retrieve_partial_body_thread_event(&partial_body_thd_event, &err)) { - if (EMF_ERROR_EVENT_QUEUE_EMPTY != err) + if (EMAIL_ERROR_EVENT_QUEUE_EMPTY != err) EM_DEBUG_EXCEPTION("emcore_retrieve_partial_body_thread_event failed [%d]", err); else { EM_DEBUG_LOG(" partial body thread event_data queue is empty."); @@ -3048,6 +3280,7 @@ gpointer partial_body_download_thread(gpointer data) if (!g_partial_body_bulk_dwd_queue_empty) { partial_body_thd_event.event_type = 0; 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); if (false == emcore_mail_partial_body_download(&partial_body_thd_event, &err)) @@ -3103,13 +3336,13 @@ gpointer partial_body_download_thread(gpointer data) EM_DEBUG_LOG("partial_body_thd_event.account_id[%d]", partial_body_thd_event.account_id); switch (partial_body_thd_event.event_type) { - case EMF_EVENT_BULK_PARTIAL_BODY_DOWNLOAD: { + case EMAIL_EVENT_BULK_PARTIAL_BODY_DOWNLOAD: { 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); } break; } - case EMF_EVENT_LOCAL_ACTIVITY_SYNC_BULK_PBD: { + case EMAIL_EVENT_LOCAL_ACTIVITY_SYNC_BULK_PBD: { partial_body_thd_event.event_type = 0; /* Both the checks below make sure that before starting local activity there is no new/pending event_data in @@ -3145,7 +3378,7 @@ gpointer partial_body_download_thread(gpointer data) return SUCCESS; } -INTERNAL_FUNC int emcore_partial_body_thread_loop_start(int *err_code) +INTERNAL_FUNC int emcore_start_thread_for_downloading_partial_body(int *err_code) { EM_DEBUG_FUNC_BEGIN(); @@ -3154,13 +3387,15 @@ INTERNAL_FUNC int emcore_partial_body_thread_loop_start(int *err_code) /* Clear Partial Body Event Queue*/ memset(&g_partial_body_thd_event_que, 0x00, sizeof(g_partial_body_thd_event_que)); - for (i = 0; i < TOTAL_PARTIAL_BODY_EVENTS; ++i) - g_partial_body_thd_event_que[i].mailbox_name = NULL; + for (i = 0; i < TOTAL_PARTIAL_BODY_EVENTS; ++i) { + g_partial_body_thd_event_que[i].mailbox_name = NULL; + g_partial_body_thd_event_que[i].mailbox_id = 0; + } if (g_partial_body_thd) { EM_DEBUG_EXCEPTION("partial body thread is already running..."); if (err_code != NULL) - *err_code = EMF_ERROR_UNKNOWN; + *err_code = EMAIL_ERROR_UNKNOWN; return true; } @@ -3179,12 +3414,12 @@ INTERNAL_FUNC int emcore_partial_body_thread_loop_start(int *err_code) if (thread_error != 0) { EM_DEBUG_EXCEPTION("cannot make thread..."); if (err_code != NULL) - *err_code = EMF_ERROR_UNKNOWN; + *err_code = EMAIL_ERROR_UNKNOWN; return FAILURE; } if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; return false; @@ -3194,12 +3429,12 @@ INTERNAL_FUNC int emcore_partial_body_thread_loop_start(int *err_code) static int emcore_partial_body_bulk_flush(int *error_code) { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int ret = false; 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_name, (void **)&tmp_stream, &error) || (NULL == tmp_stream)) { + 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)) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", error); goto FINISH_OFF; } @@ -3232,33 +3467,33 @@ FINISH_OFF: /* Function to pass UID list and Data for bulk partial body download [santosh.br@samsung.com]/[h.gahlaut@samsung.com] */ -INTERNAL_FUNC int emcore_mail_partial_body_download(emf_event_partial_body_thd *pbd_event, int *error_code) +INTERNAL_FUNC int emcore_mail_partial_body_download(email_event_partial_body_thd *pbd_event, int *error_code) { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int num_activity = 0; int ret = false; int count = 0; int i = 0, m = 0; MAILSTREAM *stream = NULL; void *tmp_stream = NULL; - emf_event_partial_body_thd *activity_data_list = NULL; - char **mailbox_list = NULL; + email_event_partial_body_thd *activity_data_list = NULL; + int *mailbox_list = NULL; if (NULL == pbd_event) { EM_DEBUG_EXCEPTION("Invalid Parameter pbd_event [%p] ", pbd_event); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } /*Check if the event_data is to flush the event_data que array */ - if (EMF_EVENT_BULK_PARTIAL_BODY_DOWNLOAD == pbd_event->event_type) { - EM_DEBUG_LOG("pbd_event->event_type is EMF_EVENT_BULK_PARTIAL_BODY_DOWNLOAD"); + if (EMAIL_EVENT_BULK_PARTIAL_BODY_DOWNLOAD == pbd_event->event_type) { + EM_DEBUG_LOG("pbd_event->event_type is EMAIL_EVENT_BULK_PARTIAL_BODY_DOWNLOAD"); /*Check if the mailbox name and account id for this event_data is same as the mailbox name and account id for earlier events saved in download que array then append this event_data also to download que array */ - if ((NULL != g_partial_body_bulk_dwd_que[0].mailbox_name) && (0 == strncmp(g_partial_body_bulk_dwd_que[0].mailbox_name, pbd_event->mailbox_name, strlen(g_partial_body_bulk_dwd_que[0].mailbox_name))) && \ + if ((0 != g_partial_body_bulk_dwd_que[0].mailbox_id) && g_partial_body_bulk_dwd_que[0].mailbox_id == pbd_event->mailbox_id && \ (g_partial_body_bulk_dwd_que[0].account_id == pbd_event->account_id)) { 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."); @@ -3297,7 +3532,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download(emf_event_partial_body_thd * /* Get all the accounts for which local activities are pending */ if (false == emstorage_get_pbd_account_list(&account_list, &account_count, false, &error)) { EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_list failed.. [%d]", error); - error = EMF_ERROR_MAILBOX_NOT_FOUND; + error = EMAIL_ERROR_MAILBOX_NOT_FOUND; goto FINISH_OFF; } @@ -3305,7 +3540,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download(emf_event_partial_body_thd * /* 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)) { EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_list failed.. [%d]", error); - error = EMF_ERROR_MAILBOX_NOT_FOUND; + error = EMAIL_ERROR_MAILBOX_NOT_FOUND; goto FINISH_OFF; } @@ -3313,7 +3548,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download(emf_event_partial_body_thd * int k = 0; int activity_count = 0; - if (!emcore_connect_to_remote_mailbox(account_list[m], mailbox_list[i], (void **)&tmp_stream, &error)) { + if (!emcore_connect_to_remote_mailbox(account_list[m], mailbox_list[i], (void **)&tmp_stream, &error)) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", error); stream = NULL; goto FINISH_OFF; @@ -3327,7 +3562,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download(emf_event_partial_body_thd * } if (activity_count > 0) { - int temp_error = EMF_ERROR_NONE; + int temp_error = EMAIL_ERROR_NONE; int j = 0; int iter = 0; int remainder = 0; @@ -3352,7 +3587,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download(emf_event_partial_body_thd * /*Call bulk download here */ if (false == emcore_download_bulk_partial_mail_body(stream, activity_data_list+index, num, &error)) { EM_DEBUG_EXCEPTION(" emcore_download_bulk_partial_mail_body failed.. [%d]", error); - temp_error = EMF_ERROR_NO_RESPONSE; + temp_error = EMAIL_ERROR_NO_RESPONSE; } for (k = 0; k < num; k++) { @@ -3367,8 +3602,8 @@ INTERNAL_FUNC int emcore_mail_partial_body_download(emf_event_partial_body_thd * ret = true; goto FINISH_OFF; /* Stop Local Activity Sync */ } - if (EMF_ERROR_NO_RESPONSE == temp_error) { - temp_error = EMF_ERROR_NONE; + if (EMAIL_ERROR_NO_RESPONSE == temp_error) { + temp_error = EMAIL_ERROR_NONE; break; } } @@ -3401,11 +3636,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download(emf_event_partial_body_thd * FINISH_OFF: - if (mailbox_list) { - for (i = 0; i < count; i++) - EM_SAFE_FREE(mailbox_list[i]); - EM_SAFE_FREE(mailbox_list); - } + EM_SAFE_FREE(mailbox_list); if (activity_data_list) { for (i = 0; i < num_activity; i++) { diff --git a/email-core/email-core-global.c b/email-core/email-core-global.c index 67a0b40..f9b7c77 100755 --- a/email-core/email-core-global.c +++ b/email-core/email-core-global.c @@ -35,14 +35,14 @@ #include #include "email-core-global.h" -emf_account_t g_new_account; -emf_account_list_t *g_account_list = NULL; +email_account_t g_new_account; +email_account_list_t *g_account_list = NULL; int g_account_num = 0; int g_account_retrieved = 0; extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) __THROW __nonnull ((1)); -INTERNAL_FUNC emf_account_t *emcore_get_new_account_reference() +INTERNAL_FUNC email_account_t *emcore_get_new_account_reference() { return &g_new_account; } diff --git a/email-core/email-core-imap-idle.c b/email-core/email-core-imap-idle.c index b995071..abc76e6 100755 --- a/email-core/email-core-imap-idle.c +++ b/email-core/email-core-imap-idle.c @@ -63,14 +63,14 @@ thread_t imap_idle_thread; int g_imap_idle_thread_alive = 0; void* emcore_imap_idle_run(void* thread_user_data); -static int emcore_imap_idle_parse_response_stream(emf_mailbox_t *mailbox, int *err_code); -static int emcore_imap_idle_connect_and_idle_on_mailbox(emf_mailbox_t *mailbox, int *err_code); +static int emcore_imap_idle_parse_response_stream(email_mailbox_t *mailbox, int *err_code); +static int emcore_imap_idle_connect_and_idle_on_mailbox(email_mailbox_t *mailbox, int *err_code); int emcore_create_imap_idle_thread(int account_id, int *err_code) { EM_DEBUG_FUNC_BEGIN("account_id [%d], err_code [%p]", account_id, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int thread_error; g_imap_idle_thread_alive = 1; @@ -78,7 +78,7 @@ int emcore_create_imap_idle_thread(int account_id, int *err_code) if (thread_error != 0) { EM_DEBUG_EXCEPTION("cannot make IMAP IDLE thread..."); - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; g_imap_idle_thread_alive = 0; goto FINISH_OFF; } @@ -102,7 +102,7 @@ int emcore_kill_imap_idle_thread(int *err_code) { EM_DEBUG_FUNC_BEGIN("err_code [%p]", err_code); int ret = true; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; EM_DEBUG_LOG("killing thread"); @@ -122,22 +122,22 @@ int emcore_kill_imap_idle_thread(int *err_code) return ret; } -int emcore_imap_idle_loop_start(emf_mailbox_t *mailbox_list, int num, int *err_code) +int emcore_imap_idle_loop_start(email_mailbox_t *mailbox_list, int num, int *err_code) { EM_DEBUG_FUNC_BEGIN("mailbox_list[%p], num[%d]", mailbox_list, num); fd_set readfds; int maxfd = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int counter = 0; int select_result = 0; int ret = false; - emf_mailbox_t *temp = NULL; + email_mailbox_t *temp = NULL; struct timeval timeout; EM_DEBUG_EXCEPTION(">>>>>>> emcore_imap_idle_loop_start start "); if (!mailbox_list || !num) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -243,16 +243,16 @@ void* emcore_imap_idle_run(void* thread_user_data) EM_DEBUG_FUNC_BEGIN("thread_user_data [%p]", thread_user_data); char *mailbox_list[3]; int mailbox_num = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int flag = true; int num = 0; int counter = 0; int accountID = (int)thread_user_data; - emf_mailbox_t *mail_box_list = NULL; - emf_mailbox_t *curr_mailbox = NULL; - emf_mailbox_t *prev_mailbox = NULL; + email_mailbox_t *mail_box_list = NULL; + email_mailbox_t *curr_mailbox = NULL; + email_mailbox_t *prev_mailbox = NULL; emstorage_mailbox_tbl_t *local_mailbox = NULL; - emf_session_t *session = NULL; + email_session_t *session = NULL; if ( !emnetwork_check_network_status(&err)) { EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); @@ -282,13 +282,14 @@ void* emcore_imap_idle_run(void* thread_user_data) EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d]", err); } else { - curr_mailbox = em_malloc(sizeof(emf_mailbox_t)); + curr_mailbox = em_malloc(sizeof(email_mailbox_t)); curr_mailbox->account_id = local_mailbox->account_id; - curr_mailbox->name = EM_SAFE_STRDUP(local_mailbox->mailbox_name); + curr_mailbox->mailbox_name = EM_SAFE_STRDUP(local_mailbox->mailbox_name); curr_mailbox->local = local_mailbox->local_yn; if (!emcore_imap_idle_connect_and_idle_on_mailbox(curr_mailbox, &err)) { EM_DEBUG_EXCEPTION("emcore_imap_idle_connect_and_idle_on_mailbox failed [%d]", err); - emcore_free_mailbox(&curr_mailbox, 1, NULL); + emcore_free_mailbox(curr_mailbox); + EM_SAFE_FREE(curr_mailbox); } else { if (flag) { @@ -321,23 +322,23 @@ FINISH_OFF: return NULL; } -int emcore_imap_idle_insert_sync_event(emf_mailbox_t *mailbox, int *err_code) +int emcore_imap_idle_insert_sync_event(email_mailbox_t *mailbox, int *err_code) { EM_DEBUG_FUNC_BEGIN(); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int handle; if (!mailbox || mailbox->account_id <= 0) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - emf_event_t event_data = { 0 }; + email_event_t event_data = { 0 }; - event_data.type = EMF_EVENT_SYNC_HEADER; - event_data.event_param_data_1 = mailbox ? EM_SAFE_STRDUP(mailbox->name) : NULL; + event_data.type = EMAIL_EVENT_SYNC_HEADER; + event_data.event_param_data_1 = mailbox ? EM_SAFE_STRDUP(mailbox->mailbox_name) : NULL; event_data.event_param_data_3 = NULL; event_data.account_id = mailbox->account_id; @@ -357,7 +358,7 @@ FINISH_OFF: } /* connects to given mailbox. send idle and returns socket id */ -static int emcore_imap_idle_connect_and_idle_on_mailbox(emf_mailbox_t *mailbox, int *err_code) +static int emcore_imap_idle_connect_and_idle_on_mailbox(email_mailbox_t *mailbox, int *err_code) { EM_DEBUG_FUNC_BEGIN("mailbox [%p], err_code [%p]", mailbox, err_code); void *mail_stream = NULL; @@ -366,28 +367,28 @@ static int emcore_imap_idle_connect_and_idle_on_mailbox(emf_mailbox_t *mailbox, char *p = NULL; int socket_id = 0; int ret = 0; - int err = EMF_ERROR_NONE; - emf_account_t *ref_account = NULL; + int err = EMAIL_ERROR_NONE; + email_account_t *ref_account = NULL; IMAPLOCAL *imap_local = NULL; NETSTREAM *net_stream = NULL; TCPSTREAM *tcp_stream = NULL; /* NULL param check */ if (!mailbox) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } ref_account = emcore_get_account_reference(mailbox->account_id); if (!ref_account) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed. account_id[%d]", mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } /* Open connection to mailbox */ - if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->name, (void **)&mail_stream, &err) || !mail_stream) { + if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->mailbox_name, (void **)&mail_stream, &err) || !mail_stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err); goto FINISH_OFF; } @@ -397,7 +398,7 @@ static int emcore_imap_idle_connect_and_idle_on_mailbox(emf_mailbox_t *mailbox, /* check if ssl option is enabled on this account - shasikala.p */ - if (ref_account->use_security){ + if (ref_account->incoming_server_secure_connection){ SSLSTREAM *ssl_stream = net_stream->stream; tcp_stream = ssl_stream->tcpstream; } @@ -412,8 +413,8 @@ static int emcore_imap_idle_connect_and_idle_on_mailbox(emf_mailbox_t *mailbox, /* Send IDLE command */ if (!imap_local->netstream || !net_sout(imap_local->netstream, cmd, (int)strlen(cmd))) { - EM_DEBUG_EXCEPTION("network error - failed to IDLE on Mailbox - %s ", mailbox->name); - err = EMF_ERROR_IMAP4_IDLE_FAILURE; + EM_DEBUG_EXCEPTION("network error - failed to IDLE on Mailbox - %s ", mailbox->mailbox_name); + err = EMAIL_ERROR_IMAP4_IDLE_FAILURE; goto FINISH_OFF; } @@ -453,17 +454,17 @@ FINISH_OFF: return ret; } -static int emcore_imap_idle_parse_response_stream(emf_mailbox_t *mailbox, int *err_code) +static int emcore_imap_idle_parse_response_stream(email_mailbox_t *mailbox, int *err_code) { EM_DEBUG_FUNC_BEGIN("mailbox [%p], err_code [%p]", mailbox, err_code); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char *p = NULL; int ret = false; IMAPLOCAL *imap_local = NULL; if (!mailbox || !mailbox->mail_stream) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -471,7 +472,7 @@ static int emcore_imap_idle_parse_response_stream(emf_mailbox_t *mailbox, int *e if (!imap_local){ EM_DEBUG_EXCEPTION("imap_local is NULL"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -486,7 +487,7 @@ static int emcore_imap_idle_parse_response_stream(emf_mailbox_t *mailbox, int *e } else { if (!emcore_imap_idle_insert_sync_event(mailbox, &err)) - EM_DEBUG_EXCEPTION("Syncing mailbox %s failed with err_code [%d]", mailbox->name, err); + EM_DEBUG_EXCEPTION("Syncing mailbox %s failed with err_code [%d]", mailbox->mailbox_name, err); EM_SAFE_FREE(p); break; } diff --git a/email-core/email-core-imap-mailbox.c b/email-core/email-core-imap-mailbox.c index 4e529ea..bcab129 100755 --- a/email-core/email-core-imap-mailbox.c +++ b/email-core/email-core-imap-mailbox.c @@ -53,12 +53,12 @@ INTERNAL_FUNC int emcore_get_default_mail_slot_count(int *output_count, int *err EM_DEBUG_FUNC_BEGIN(); EM_DEBUG_LOG("output_count[%p], err_code[%p]", output_count, err_code); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int mail_slot_count; int ret = false, ret2; if (output_count == NULL) { - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -90,29 +90,29 @@ INTERNAL_FUNC int emcore_remove_overflowed_mails(emstorage_mailbox_tbl_t *intput int ret = false; int *mail_id_list = NULL, mail_id_list_count = 0; - int err = EMF_ERROR_NONE; - emf_account_t *account_ref = NULL; + int err = EMAIL_ERROR_NONE; + email_account_t *account_ref = NULL; if (!intput_mailbox_tbl || intput_mailbox_tbl->account_id < 1) { if (intput_mailbox_tbl) EM_DEBUG_EXCEPTION("Invalid Parameter. intput_mailbox_tbl->account_id [%d]", intput_mailbox_tbl->account_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } account_ref = emcore_get_account_reference(intput_mailbox_tbl->account_id); if (account_ref) { - if (account_ref->receiving_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC) { + if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) { EM_DEBUG_LOG("ActiveSync Account didn't support mail slot"); - err = EMF_ERROR_NOT_SUPPORTED; + err = EMAIL_ERROR_NOT_SUPPORTED; goto FINISH_OFF; } } - if (!emstorage_get_overflowed_mail_id_list(intput_mailbox_tbl->account_id, intput_mailbox_tbl->mailbox_name, intput_mailbox_tbl->mail_slot_size, &mail_id_list, &mail_id_list_count, true, &err)) { - if (err == EMF_ERROR_MAIL_NOT_FOUND) { + if (!emstorage_get_overflowed_mail_id_list(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("There are enough slot in intput_mailbox_tbl [%s]", intput_mailbox_tbl->mailbox_name); - err = EMF_ERROR_NONE; + err = EMAIL_ERROR_NONE; ret = true; } else @@ -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, false, EMF_DELETED_BY_OVERFLOW, false, &err)) { + 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)) { EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err); goto FINISH_OFF; } @@ -139,19 +139,21 @@ FINISH_OFF: } -INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, char *mailbox_name, int new_slot_size, int *err_code) +INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, int mailbox_id, int new_slot_size, int *err_code) { - EM_DEBUG_FUNC_BEGIN(); - EM_DEBUG_LOG("account_id [%d], mailbox_name[%p], err_code[%p]", account_id, mailbox_name, err_code); + EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_id[%d], err_code[%p]", account_id, mailbox_id, err_code); - int ret = false, err = EMF_ERROR_NONE; - int i, mailbox_count = 0; - emf_account_t *account_ref = NULL; + int ret = false, err = EMAIL_ERROR_NONE; + int i = 0; + int account_count = 100; + int mailbox_count = 0; + email_account_t *account_ref = NULL; + emstorage_account_tbl_t *account_tbl_list = NULL; emstorage_mailbox_tbl_t *mailbox_tbl_list = NULL; if (account_id > ALL_ACCOUNT) { account_ref = emcore_get_account_reference(account_id); - if (account_ref && account_ref->receiving_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC) { + 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; goto FINISH_OFF; @@ -160,14 +162,35 @@ INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, char *mailbox_name, EM_DEBUG_EXCEPTION("emcore_get_account_reference failed"); 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) { + EM_DEBUG_EXCEPTION("emstorage_set_field_of_accounts_with_integer_value failed [%d]", err); + goto FINISH_OFF; + } + } + } + else { + if (mailbox_id == 0) { + if ( !emstorage_get_account_list(&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) { + EM_DEBUG_EXCEPTION("emstorage_set_field_of_accounts_with_integer_value failed [%d]", err); + goto FINISH_OFF; + } + } + } } - if (!emstorage_set_mail_slot_size(account_id, mailbox_name, new_slot_size, true, &err)) { + + if (!emstorage_set_mail_slot_size(account_id, mailbox_id, new_slot_size, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_set_mail_slot_size failed [%d]", err); goto FINISH_OFF; } - if (mailbox_name) { + if (mailbox_id) { mailbox_count = 1; if (new_slot_size > 0) { mailbox_tbl_list = em_malloc(sizeof(emstorage_mailbox_tbl_t) * mailbox_count); @@ -176,19 +199,19 @@ INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, char *mailbox_name, goto FINISH_OFF; } mailbox_tbl_list->account_id = account_id; - mailbox_tbl_list->mailbox_name = EM_SAFE_STRDUP(mailbox_name); + mailbox_tbl_list->mailbox_id = mailbox_id; mailbox_tbl_list->mail_slot_size = new_slot_size; } else { /* read information from DB */ - if (!emstorage_get_mailbox_by_name(account_id, EMF_MAILBOX_ALL, mailbox_name, &mailbox_tbl_list, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err); + if ((err = emstorage_get_mailbox_by_id(mailbox_id, &mailbox_tbl_list)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err); goto FINISH_OFF; } } } else { - if (!emstorage_get_mailbox(account_id, EMF_MAILBOX_ALL, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) { + if (!emstorage_get_mailbox_list(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; } @@ -196,18 +219,20 @@ INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, char *mailbox_name, for (i = 0; i < mailbox_count; i++) { if (!emcore_remove_overflowed_mails(mailbox_tbl_list + i, &err)) { - if (err == EMF_ERROR_MAIL_NOT_FOUND || err == EMF_ERROR_NOT_SUPPORTED) - err = EMF_ERROR_NONE; + if (err == EMAIL_ERROR_MAIL_NOT_FOUND || err == EMAIL_ERROR_NOT_SUPPORTED) + err = EMAIL_ERROR_NONE; else EM_DEBUG_EXCEPTION("emcore_remove_overflowed_mails failed [%d]", err); } } - - ret = true; + FINISH_OFF: + if (account_tbl_list) + emstorage_free_account(&account_tbl_list, account_count, NULL); + if (mailbox_tbl_list) emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL); @@ -217,10 +242,9 @@ FINISH_OFF: return ret; } - static int emcore_get_mailbox_connection_path(int account_id, char *mailbox_name, char **path, int *err_code) { - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; size_t path_len = 0; @@ -230,29 +254,29 @@ static int emcore_get_mailbox_connection_path(int account_id, char *mailbox_name return 0; } - path_len = strlen(ref_account->receiving_server_addr) + + path_len = strlen(ref_account->incoming_server_address) + (mailbox_name ? strlen(mailbox_name) : 0) + 50; - *path = em_malloc(path_len);/* strlen(ref_account->receiving_server_addr) + */ + *path = em_malloc(path_len);/* strlen(ref_account->incoming_server_address) + */ /* (mailbox_name ? strlen(mailbox_name) : 0) + 20); */ if (!*path) return 0; memset(*path, 0x00, path_len); /* 1. server address / server type */ - if (ref_account->receiving_server_type == EMF_SERVER_TYPE_POP3) { - SNPRINTF(*path + 1, path_len-1, "%s:%d/pop", ref_account->receiving_server_addr, ref_account->port_num); + if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) { + SNPRINTF(*path + 1, path_len-1, "%s:%d/pop", ref_account->incoming_server_address, ref_account->incoming_server_port_number); } else { - SNPRINTF(*path + 1, path_len-1, "%s:%d/imap", ref_account->receiving_server_addr, ref_account->port_num); + SNPRINTF(*path + 1, path_len-1, "%s:%d/imap", ref_account->incoming_server_address, ref_account->incoming_server_port_number); } /* 2. set tls option if security connection */ -/* if (ref_account->use_security) strncat(*path + 1, "/tls", path_len-(strlen(*path)-1)); */ - if (ref_account->use_security & 0x01) { +/* if (ref_account->incoming_server_secure_connection) strncat(*path + 1, "/tls", path_len-(strlen(*path)-1)); */ + if (ref_account->incoming_server_secure_connection & 0x01) { strncat(*path + 1, "/ssl", path_len-(strlen(*path)-1)); } - if (ref_account->use_security & 0x02) + if (ref_account->incoming_server_secure_connection & 0x02) strncat(*path + 1, "/tls", path_len-(strlen(*path)-1)); else strncat(*path + 1, "/notls", path_len-(strlen(*path)-1)); @@ -271,37 +295,37 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p], err_code[%p]", account_id, mailbox_name, err_code); int ret = false; - int err = EMF_ERROR_NONE; - int status = EMF_DOWNLOAD_FAIL; + int err = EMAIL_ERROR_NONE; + int status = EMAIL_DOWNLOAD_FAIL; MAILSTREAM *stream = NULL; - emf_mailbox_t *mailbox_list = NULL; - emf_account_t *ref_account = NULL; + email_internal_mailbox_t *mailbox_list = NULL; + email_account_t *ref_account = NULL; void *tmp_stream = NULL; char *mbox_path = NULL; - int i = 0, count = 0, counter = 0, mailbox_type_list[EMF_MAILBOX_TYPE_ALL_EMAILS + 1] = {-1, -1, -1, -1, -1, -1, -1, -1}; + int i = 0, count = 0, counter = 0, mailbox_type_list[EMAIL_MAILBOX_TYPE_ALL_EMAILS + 1] = {-1, -1, -1, -1, -1, -1, -1, -1}; char *mailbox_name_for_mailbox_type = NULL; if (err_code) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } ref_account = emcore_get_account_reference(account_id); if (!ref_account) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } /* if not imap4 mail, return */ - if (ref_account->account_bind_type != EMF_BIND_TYPE_EM_CORE || ref_account->receiving_server_type != EMF_SERVER_TYPE_IMAP4) { + if ( ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) { EM_DEBUG_EXCEPTION("unsupported account..."); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } @@ -314,20 +338,20 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } stream = NULL; - if (!emcore_connect_to_remote_mailbox(account_id, NULL, (void **)&tmp_stream, &err) || !tmp_stream) { + if (!emcore_connect_to_remote_mailbox(account_id, 0, (void **)&tmp_stream, &err) || !tmp_stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed - %d", err); - if (err == EMF_ERROR_CONNECTION_BROKEN) - err = EMF_ERROR_CANCELLED; + if (err == EMAIL_ERROR_CONNECTION_BROKEN) + err = EMAIL_ERROR_CANCELLED; else - err = EMF_ERROR_CONNECTION_FAILURE; + err = EMAIL_ERROR_CONNECTION_FAILURE; - status = EMF_DOWNLOAD_CONNECTION_FAIL; + status = EMAIL_DOWNLOAD_CONNECTION_FAIL; goto FINISH_OFF; } @@ -336,7 +360,7 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i stream = (MAILSTREAM *)tmp_stream; if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -347,25 +371,27 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i } if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } for (i = 0; i < count; i++) { if (!emcore_check_thread_status()) { EM_DEBUG_LOG("emcore_check_thread_status - cancelled"); - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } - if (mailbox_list[i].name) { - EM_DEBUG_LOG("mailbox name - %s", mailbox_list[i].name); + if (mailbox_list[i].mailbox_name) { + EM_DEBUG_LOG("mailbox name - %s", mailbox_list[i].mailbox_name); emcore_get_default_mail_slot_count(&(mailbox_list[i].mail_slot_size), NULL); - emcore_bind_mailbox_type(mailbox_list + i); - if (mailbox_list[i].mailbox_type <= EMF_MAILBOX_TYPE_ALL_EMAILS) { /* if result mailbox type is duplicated, */ + if(mailbox_list[i].mailbox_type == EMAIL_MAILBOX_TYPE_NONE) + emcore_bind_mailbox_type(mailbox_list + i); + + if (mailbox_list[i].mailbox_type <= EMAIL_MAILBOX_TYPE_ALL_EMAILS) { /* if result mailbox type is duplicated, */ if (mailbox_type_list[mailbox_list[i].mailbox_type] != -1) { - EM_DEBUG_LOG("Mailbox type [%d] of [%s] is duplicated", mailbox_list[i].mailbox_type, mailbox_list[i].name); - mailbox_list[i].mailbox_type = EMF_MAILBOX_TYPE_USER_DEFINED; /* ignore latest one */ + EM_DEBUG_LOG("Mailbox type [%d] of [%s] is duplicated", mailbox_list[i].mailbox_type, mailbox_list[i].mailbox_name); + mailbox_list[i].mailbox_type = EMAIL_MAILBOX_TYPE_USER_DEFINED; /* ignore latest one */ } else mailbox_type_list[mailbox_list[i].mailbox_type] = i; @@ -381,11 +407,11 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i } - for (counter = EMF_MAILBOX_TYPE_INBOX; counter <= EMF_MAILBOX_TYPE_OUTBOX; counter++) { - /* if (!emstorage_get_mailboxname_by_mailbox_type(account_id, counter, &mailbox_name_for_mailbox_type, false, &err)) */ + for (counter = EMAIL_MAILBOX_TYPE_INBOX; counter <= EMAIL_MAILBOX_TYPE_OUTBOX; counter++) { + /* if (!emstorage_get_mailbox_name_by_mailbox_type(account_id, counter, &mailbox_name_for_mailbox_type, false, &err)) */ if (mailbox_type_list[counter] == -1) { - /* EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed - %d", err); */ - /* if (EMF_ERROR_MAILBOX_NOT_FOUND == err) */ + /* EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed - %d", err); */ + /* if (EMAIL_ERROR_MAILBOX_NOT_FOUND == err) */ /* { */ emstorage_mailbox_tbl_t mailbox_tbl; @@ -395,40 +421,40 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i mailbox_tbl.mailbox_id = 0; mailbox_tbl.local_yn = 1; mailbox_tbl.mailbox_type = counter; - mailbox_tbl.sync_with_server_yn = 1; + mailbox_tbl.sync_with_server_yn = 0; mailbox_tbl.modifiable_yn = 1; mailbox_tbl.total_mail_count_on_server = 0; emcore_get_default_mail_slot_count(&mailbox_tbl.mail_slot_size, NULL); switch (counter) { - case EMF_MAILBOX_TYPE_SENTBOX: - mailbox_tbl.mailbox_name = EMF_SENTBOX_NAME; - mailbox_tbl.alias = EMF_SENTBOX_DISPLAY_NAME; + case EMAIL_MAILBOX_TYPE_SENTBOX: + mailbox_tbl.mailbox_name = EMAIL_SENTBOX_NAME; + mailbox_tbl.alias = EMAIL_SENTBOX_DISPLAY_NAME; break; - case EMF_MAILBOX_TYPE_TRASH: - mailbox_tbl.mailbox_name = EMF_TRASH_NAME; - mailbox_tbl.alias = EMF_TRASH_DISPLAY_NAME; + case EMAIL_MAILBOX_TYPE_TRASH: + mailbox_tbl.mailbox_name = EMAIL_TRASH_NAME; + mailbox_tbl.alias = EMAIL_TRASH_DISPLAY_NAME; break; - case EMF_MAILBOX_TYPE_DRAFT: - mailbox_tbl.mailbox_name = EMF_DRAFTBOX_NAME; - mailbox_tbl.alias = EMF_DRAFTBOX_DISPLAY_NAME; + case EMAIL_MAILBOX_TYPE_DRAFT: + mailbox_tbl.mailbox_name = EMAIL_DRAFTBOX_NAME; + mailbox_tbl.alias = EMAIL_DRAFTBOX_DISPLAY_NAME; break; - case EMF_MAILBOX_TYPE_SPAMBOX: - mailbox_tbl.mailbox_name = EMF_SPAMBOX_NAME; - mailbox_tbl.alias = EMF_SPAMBOX_DISPLAY_NAME; + case EMAIL_MAILBOX_TYPE_SPAMBOX: + mailbox_tbl.mailbox_name = EMAIL_SPAMBOX_NAME; + mailbox_tbl.alias = EMAIL_SPAMBOX_DISPLAY_NAME; break; - case EMF_MAILBOX_TYPE_OUTBOX: - mailbox_tbl.mailbox_name = EMF_OUTBOX_NAME; - mailbox_tbl.alias = EMF_OUTBOX_DISPLAY_NAME; + case EMAIL_MAILBOX_TYPE_OUTBOX: + mailbox_tbl.mailbox_name = EMAIL_OUTBOX_NAME; + mailbox_tbl.alias = EMAIL_OUTBOX_DISPLAY_NAME; break; default: - mailbox_tbl.mailbox_name = EMF_INBOX_NAME; - mailbox_tbl.alias = EMF_INBOX_DISPLAY_NAME; + mailbox_tbl.mailbox_name = EMAIL_INBOX_NAME; + mailbox_tbl.alias = EMAIL_INBOX_DISPLAY_NAME; break; } @@ -451,16 +477,17 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i emstorage_mailbox_tbl_t *local_mailbox_list = NULL; int select_num = 0; i = 0; - emf_mailbox_t mailbox; + email_mailbox_t mailbox; if (emstorage_get_mailbox_by_modifiable_yn(account_id, 0 /* modifiable_yn */, &select_num, &local_mailbox_list, true, &err)) { if (select_num > 0) { for (i = 0; i < select_num; i++) { EM_DEBUG_LOG(">>> MailBox needs to be Deleted[ %s ] ", local_mailbox_list[i].mailbox_name); mailbox.account_id = local_mailbox_list[i].account_id; - mailbox.name = local_mailbox_list[i].mailbox_name; + mailbox.mailbox_name = local_mailbox_list[i].mailbox_name; + mailbox.mailbox_id = local_mailbox_list[i].mailbox_id; if (!emcore_delete_mailbox_all(&mailbox, &err)) { - EM_DEBUG_EXCEPTION(" emcore_delete_all of Mailbox [%s] Failed ", mailbox.name); + EM_DEBUG_EXCEPTION(" emcore_delete_all of Mailbox [%s] Failed ", mailbox.mailbox_name); emstorage_free_mailbox(&local_mailbox_list, select_num, NULL); local_mailbox_list = NULL; goto FINISH_OFF; @@ -477,7 +504,7 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i } if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -495,7 +522,7 @@ FINISH_OFF: emcore_close_mailbox(account_id, stream); if (mailbox_list) - emcore_free_mailbox(&mailbox_list, count, NULL); + emcore_free_internal_mailbox(&mailbox_list, count, NULL); if (err_code != NULL) *err_code = err; @@ -504,62 +531,60 @@ FINISH_OFF: } int emcore_download_mailbox_list(void *mail_stream, - char *mailbox, - emf_mailbox_t **mailbox_list, + char *mailbox_name, + email_internal_mailbox_t **mailbox_list, int *count, int *err_code) { + EM_DEBUG_FUNC_BEGIN("mail_stream [%p], mailbox_name [%p], mailbox_list [%p], count [%p], err_code [%p]", mail_stream, mailbox_name, mailbox_list, count, err_code); + MAILSTREAM *stream = mail_stream; - emf_callback_holder_t holder; + email_callback_holder_t holder; char *pattern = NULL; char *reference = NULL; - int err = EMF_ERROR_NONE; - int ret = false; - - EM_DEBUG_FUNC_BEGIN(); - - if (err_code) { - *err_code = EMF_ERROR_NONE; - } + int err = EMAIL_ERROR_NONE; + int ret = false; if (!stream || !mailbox_list || !count) { - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } memset(&holder, 0x00, sizeof(holder)); /* reference (ex : "{mail.test.com}", "{mail.test.com}inbox") */ - if (mailbox) { + if (mailbox_name) { char *s = NULL; - reference = em_malloc(strlen(stream->original_mailbox) + strlen(mailbox) + 1); + reference = em_malloc(strlen(stream->original_mailbox) + strlen(mailbox_name) + 1); if (reference) { strncpy(reference, stream->original_mailbox, (size_t)strlen(stream->original_mailbox)); if ((s = strchr(reference, '}'))) *(++s) = '\0'; - strcat(reference, mailbox); + strcat(reference, mailbox_name); } } else reference = EM_SAFE_STRDUP(stream->original_mailbox); - pattern = "*"; + pattern = "*"; stream->sparep = &holder; - /* imap command : tag LIST reference * */ + /* imap command : tag LIST reference * */ + /* see callback function mm_list */ mail_list(stream, reference, pattern); stream->sparep = NULL; EM_SAFE_FREE(reference); - *count = holder.num; - *mailbox_list = (emf_mailbox_t *)holder.data; + *count = holder.num; + *mailbox_list = (email_internal_mailbox_t*)holder.data; ret = true; FINISH_OFF: - if (err_code) *err_code = err; + if (err_code) + *err_code = err; return ret; } @@ -573,29 +598,29 @@ FINISH_OFF: * succeed : 1 * fail : 0 */ -int emcore_check_sync_imap_mailbox(emf_mailbox_t *mailbox, int *synchronous, int *err_code) +int emcore_check_sync_imap_mailbox(email_mailbox_t *mailbox, int *synchronous, int *err_code) { EM_DEBUG_FUNC_BEGIN(); EM_DEBUG_LOG("\t mailbox[%p], synchronous[%p], err_code[%p]", mailbox, synchronous, err_code); if (err_code) { - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; } if (!mailbox || !synchronous) { EM_DEBUG_EXCEPTION("\t mailbox[%p], synchronous[%p]", mailbox, synchronous); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_mailbox_tbl_t *imap_mailbox_tbl = NULL; - if (!emstorage_get_mailbox_by_name(mailbox->account_id, 0, mailbox->name, &imap_mailbox_tbl, true, &err)) { + if (!emstorage_get_mailbox_by_name(mailbox->account_id, 0, mailbox->mailbox_name, &imap_mailbox_tbl, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed - %d", err); goto FINISH_OFF; } @@ -625,19 +650,19 @@ FINISH_OFF: * fail : 0 */ -INTERNAL_FUNC int emcore_set_sync_imap_mailbox(emf_mailbox_t *mailbox, int synchronous, int *err_code) +INTERNAL_FUNC int emcore_set_sync_imap_mailbox(email_internal_mailbox_t *mailbox, int synchronous, int *err_code) { EM_DEBUG_FUNC_BEGIN("mailbox[%p], synchronous[%d], err_code[%p]", mailbox, synchronous, err_code); if (!mailbox) { EM_DEBUG_EXCEPTION("mailbox[%p], synchronous[%d]", mailbox, synchronous); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_mailbox_tbl_t *imap_mailbox_tbl_item = NULL; emcore_uid_list *uid_list = NULL; emstorage_read_mail_uid_tbl_t *downloaded_uids = NULL; @@ -651,17 +676,17 @@ INTERNAL_FUNC int emcore_set_sync_imap_mailbox(emf_mailbox_t *mailbox, int synch if (synchronous) { /* if synchcronous, insert imap mailbox to db */ - if (emstorage_get_mailbox_by_name(mailbox->account_id, 0, mailbox->name, &imap_mailbox_tbl_item, true, &err)) { + if (emstorage_get_mailbox_by_name(mailbox->account_id, 0, mailbox->mailbox_name, &imap_mailbox_tbl_item, true, &err)) { /* mailbox already exists */ /* mailbox Found, Do set the modifiable_yn = 1 */ EM_DEBUG_LOG("mailbox already exists and setting modifiable_yn to 1"); - if (!emstorage_update_mailbox_modifiable_yn(mailbox->account_id, 0, mailbox->name, 1, true, &err)) { + if (!emstorage_update_mailbox_modifiable_yn(mailbox->account_id, 0, mailbox->mailbox_name, 1, true, &err)) { EM_DEBUG_EXCEPTION(" emstorage_update_mailbox_modifiable_yn Failed [ %d ] ", err); goto JOB_ERROR; } } else { - if (err != EMF_ERROR_MAILBOX_NOT_FOUND) { + if (err != EMAIL_ERROR_MAILBOX_NOT_FOUND) { EM_DEBUG_EXCEPTION(">>>>.>>>>>Getting mailbox failed>>>>>>>>>>>>>>"); /* This is error scenario so finish the job */ goto JOB_ERROR; @@ -675,16 +700,16 @@ INTERNAL_FUNC int emcore_set_sync_imap_mailbox(emf_mailbox_t *mailbox, int synch EM_DEBUG_LINE; sprintf(tag, "%08lx", 0xffffffff & (((MAILSTREAM *)stream)->gensym++)); EM_DEBUG_LINE; - sprintf(cmd, "%s SELECT %s\015\012", tag, mailbox->name); + sprintf(cmd, "%s SELECT %s\015\012", tag, mailbox->mailbox_name); EM_DEBUG_LINE; } /* select the mailbox and get its UID */ if (!imap_local || !imap_local->netstream || !net_sout(imap_local->netstream, cmd, (int)strlen(cmd))) { - EM_DEBUG_EXCEPTION("network error - failed to IDLE on Mailbox [%s]", mailbox->name); + EM_DEBUG_EXCEPTION("network error - failed to IDLE on Mailbox [%s]", mailbox->mailbox_name); /* - err = EMF_ERROR_CONNECTION_BROKEN; + err = EMAIL_ERROR_CONNECTION_BROKEN; if(imap_local) imap_local->netstream = NULL; mailbox->mail_stream = NULL; @@ -714,13 +739,13 @@ INTERNAL_FUNC int emcore_set_sync_imap_mailbox(emf_mailbox_t *mailbox, int synch /* check if OK or BAD response comes. */ /* if response is OK the try getting UID list. */ if (!strncmp((char *)imap_local->reply.key, "OK", strlen("OK"))) { - EM_DEBUG_LOG(">>>>>>>>>>Select success on %s mailbox", mailbox->name); + EM_DEBUG_LOG(">>>>>>>>>>Select success on %s mailbox", mailbox->mailbox_name); if (!imap4_mailbox_get_uids(stream, &uid_list, &err)) { EM_DEBUG_EXCEPTION("imap4_mailbox_get_uids failed - %d", err); EM_SAFE_FREE(uid_list); } else { - if (!emstorage_get_downloaded_list(mailbox->account_id, NULL, &downloaded_uids, &j, true, &err)) { + if (!emstorage_get_downloaded_list(mailbox->account_id, 0, &downloaded_uids, &j, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_downloaded_list failed [%d]", err); downloaded_uids = NULL; @@ -750,7 +775,7 @@ INTERNAL_FUNC int emcore_set_sync_imap_mailbox(emf_mailbox_t *mailbox, int synch if (mailbox_renamed) /* renamed mailbox */ { EM_DEBUG_LOG("downloaded_uids[temp].mailbox_name [%s]", downloaded_uids[temp].mailbox_name); /* Do a mailbox rename in the DB */ - if (!emstorage_modify_mailbox_of_mails(downloaded_uids[temp].mailbox_name, mailbox->name, true, &err)) + if (!emstorage_modify_mailbox_of_mails(downloaded_uids[temp].mailbox_name, mailbox->mailbox_name, true, &err)) EM_DEBUG_EXCEPTION(" emstorage_modify_mailbox_of_mails Failed [%d]", err); mailbox_renamed = 0; @@ -758,22 +783,20 @@ INTERNAL_FUNC int emcore_set_sync_imap_mailbox(emf_mailbox_t *mailbox, int synch emstorage_mailbox_tbl_t mailbox_tbl; mailbox_tbl.account_id = mailbox->account_id; mailbox_tbl.local_yn = 0; - mailbox_tbl.mailbox_name = mailbox->name; + mailbox_tbl.mailbox_name = mailbox->mailbox_name; mailbox_tbl.mailbox_type = mailbox->mailbox_type; /* Get the Alias Name after parsing the Full mailbox Path */ - mailbox->alias = emcore_get_alias_of_mailbox((const char *)mailbox->name); + if(mailbox->alias == NULL) + mailbox->alias = emcore_get_alias_of_mailbox((const char *)mailbox->mailbox_name); - if (mailbox->alias) - EM_DEBUG_LOG("mailbox->alias [%s] ", mailbox->alias); - mailbox_tbl.alias = mailbox->alias; - mailbox_tbl.sync_with_server_yn = 0; + mailbox_tbl.sync_with_server_yn = 1; mailbox_tbl.modifiable_yn = 1; mailbox_tbl.total_mail_count_on_server = 0; /* if non synchronous, delete imap mailbox from db */ - if (!emstorage_update_mailbox(mailbox->account_id, 0, downloaded_uids[temp].mailbox_name, &mailbox_tbl, true, &err)) { + if (!emstorage_update_mailbox(mailbox->account_id, 0, downloaded_uids[temp].mailbox_id, &mailbox_tbl, true, &err)) { EM_DEBUG_EXCEPTION(" emstorage_update_mailbox Failed [ %d ] ", err); goto JOB_ERROR; } @@ -785,11 +808,12 @@ INTERNAL_FUNC int emcore_set_sync_imap_mailbox(emf_mailbox_t *mailbox, int synch mailbox_tbl.account_id = mailbox->account_id; mailbox_tbl.local_yn = 0; mailbox_tbl.mailbox_type = mailbox->mailbox_type; - mailbox_tbl.mailbox_name = mailbox->name; + mailbox_tbl.mailbox_name = mailbox->mailbox_name; mailbox_tbl.mail_slot_size = mailbox->mail_slot_size; /* Get the Alias Name after Parsing the Full mailbox Path */ - mailbox->alias = emcore_get_alias_of_mailbox((const char *)mailbox->name); + if(mailbox->alias == NULL) + mailbox->alias = emcore_get_alias_of_mailbox((const char *)mailbox->mailbox_name); if (mailbox->alias) { EM_DEBUG_LOG("mailbox->alias [%s] ", mailbox->alias); @@ -838,47 +862,47 @@ JOB_ERROR: * succeed : 1 * fail : 0 */ -INTERNAL_FUNC int emcore_create_imap_mailbox(emf_mailbox_t *mailbox, int *err_code) +INTERNAL_FUNC int emcore_create_imap_mailbox(email_mailbox_t *mailbox, int *err_code) { MAILSTREAM *stream = NULL; char *long_enc_path = NULL; void *tmp_stream = NULL; int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; EM_DEBUG_FUNC_BEGIN(); if (err_code) { - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; } if (!mailbox) { - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto JOB_ERROR; } /* connect mail server */ stream = NULL; - if (!emcore_connect_to_remote_mailbox(mailbox->account_id, NULL, (void **)&tmp_stream, NULL)) + if (!emcore_connect_to_remote_mailbox(mailbox->account_id, 0, (void **)&tmp_stream, NULL)) { - err = EMF_ERROR_CONNECTION_FAILURE; + err = EMAIL_ERROR_CONNECTION_FAILURE; goto JOB_ERROR; } 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->name, '/', &long_enc_path, err_code)) + if (!emcore_get_long_encoded_path(mailbox->account_id, mailbox->mailbox_name, '/', &long_enc_path, err_code)) { - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; goto JOB_ERROR; } /* create mailbox */ if (!mail_create(stream, long_enc_path)) { - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; goto JOB_ERROR; } @@ -908,68 +932,66 @@ JOB_ERROR: /* description * delete a imap mailbox * arguments - * mailbox : mailbox to be deleted + * input_mailbox_id : mailbox ID to be deleted * return * succeed : 1 * fail : 0 */ -INTERNAL_FUNC int emcore_delete_imap_mailbox(emf_mailbox_t *mailbox, int *err_code) +INTERNAL_FUNC int emcore_delete_imap_mailbox(int input_mailbox_id, int *err_code) { MAILSTREAM *stream = NULL; char *long_enc_path = NULL; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; void *tmp_stream = NULL; int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; EM_DEBUG_FUNC_BEGIN(); if (err_code) { - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; } - if (!mailbox) - { - err = EMF_ERROR_INVALID_PARAM; - goto JOB_ERROR; - } + if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err); + goto JOB_ERROR; + } - ref_account = emcore_get_account_reference(mailbox->account_id); + ref_account = emcore_get_account_reference(mailbox_tbl->account_id); if (!ref_account) { - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto JOB_ERROR; } /* if not imap4 mail, return */ - if (ref_account->account_bind_type != EMF_BIND_TYPE_EM_CORE || - ref_account->receiving_server_type != EMF_SERVER_TYPE_IMAP4) - { - err = EMF_ERROR_INVALID_PARAM; + if (ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) { + err = EMAIL_ERROR_INVALID_PARAM; goto JOB_ERROR; } /* connect mail server */ stream = NULL; - if (!emcore_connect_to_remote_mailbox(ref_account->account_id, NULL, (void **)&tmp_stream, NULL)) + if (!emcore_connect_to_remote_mailbox(ref_account->account_id, 0, (void **)&tmp_stream, NULL)) { - err = EMF_ERROR_CONNECTION_FAILURE; + err = EMAIL_ERROR_CONNECTION_FAILURE; goto JOB_ERROR; } 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->name, '/', &long_enc_path, err_code)) + if (!emcore_get_long_encoded_path(mailbox_tbl->account_id, mailbox_tbl->mailbox_name, '/', &long_enc_path, err_code)) { - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; goto JOB_ERROR; } /* delete mailbox */ if (!mail_delete(stream, long_enc_path)) { - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; goto JOB_ERROR; } @@ -979,7 +1001,7 @@ INTERNAL_FUNC int emcore_delete_imap_mailbox(emf_mailbox_t *mailbox, int *err_co EM_SAFE_FREE(long_enc_path); /* if deleted imap mailbox is synchronous mailbox, delete db imap mailbox from db */ - if (!emstorage_delete_mailbox(ref_account->account_id, 0, mailbox->name, true, &err)) { + if (!emstorage_delete_mailbox(ref_account->account_id, 0, input_mailbox_id, true, &err)) { EM_DEBUG_EXCEPTION("\t emstorage_delete_mailbox failed - %d", err); goto JOB_ERROR; } @@ -995,6 +1017,9 @@ JOB_ERROR: EM_SAFE_FREE(long_enc_path); + if (mailbox_tbl) + emstorage_free_mailbox(&mailbox_tbl, 1, NULL); + if (err_code) *err_code = err; @@ -1002,121 +1027,66 @@ JOB_ERROR: } -/* description - * change imap mailbox name - * arguments - * old_mailbox : previous mailbox - * new_mailbox : renamed mailbox - * return - * succeed : 1 - * fail : 0 - */ -INTERNAL_FUNC int emcore_modify_imap_mailbox(emf_mailbox_t *old_mailbox, emf_mailbox_t *new_mailbox, int *err_code) +INTERNAL_FUNC int emcore_move_mailbox_on_imap_server(int input_account_id, char *input_old_mailbox_path, char *input_new_mailbox_path) { + EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_old_mailbox_path [%p], input_new_mailbox_path [%p]", input_account_id, input_old_mailbox_path, input_new_mailbox_path); MAILSTREAM *stream = NULL; - char *long_enc_path = NULL; + char *long_enc_path_old = NULL; char *long_enc_path_new = NULL; - emstorage_mailbox_tbl_t imap_mailbox_tbl_item; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; void *tmp_stream = NULL; - int ret = false; - int err = EMF_ERROR_NONE; - - EM_DEBUG_FUNC_BEGIN(); - - if (err_code) { - *err_code = EMF_ERROR_NONE; - } + int err = EMAIL_ERROR_NONE; - if (!old_mailbox || !new_mailbox) - { - err = EMF_ERROR_INVALID_PARAM; - goto JOB_ERROR; - } - - ref_account = emcore_get_account_reference(old_mailbox->account_id); - if (!ref_account) - { - err = EMF_ERROR_INVALID_PARAM; - goto JOB_ERROR; + if (!input_old_mailbox_path || !input_new_mailbox_path) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; } - if (!emcore_get_account_reference(new_mailbox->account_id)) - { - err = EMF_ERROR_INVALID_PARAM; - goto JOB_ERROR; - } + ref_account = emcore_get_account_reference(input_account_id); - /* if not imap4 mail, return */ - if (ref_account->account_bind_type != EMF_BIND_TYPE_EM_CORE || - ref_account->receiving_server_type != EMF_SERVER_TYPE_IMAP4) - { - err = EMF_ERROR_INVALID_PARAM; - goto JOB_ERROR; + if (!ref_account || ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_ACCOUNT"); + err = EMAIL_ERROR_INVALID_ACCOUNT; + goto FINISH_OFF; } /* connect mail server */ stream = NULL; - if (!emcore_connect_to_remote_mailbox(ref_account->account_id, NULL, (void **)&tmp_stream, NULL)) - { - err = EMF_ERROR_CONNECTION_FAILURE; - goto JOB_ERROR; + if (!emcore_connect_to_remote_mailbox(input_account_id, 0, (void **)&tmp_stream, &err)) { + EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed. [%d]", err); + goto FINISH_OFF; } 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(old_mailbox->account_id, old_mailbox->name, '/', &long_enc_path, err_code)) - { - err = EMF_ERROR_UNKNOWN; - goto JOB_ERROR; + if (!emcore_get_long_encoded_path(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(new_mailbox->account_id, new_mailbox->name, '/', &long_enc_path_new, err_code)) - { - err = EMF_ERROR_UNKNOWN; - goto JOB_ERROR; + if (!emcore_get_long_encoded_path(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; } /* rename mailbox */ - if (!mail_rename(stream, long_enc_path, long_enc_path_new)) - { - err = EMF_ERROR_UNKNOWN; - goto JOB_ERROR; - } - - EM_SAFE_FREE(long_enc_path); - EM_SAFE_FREE(long_enc_path_new); - - emcore_close_mailbox(0, stream); - stream = NULL; - - imap_mailbox_tbl_item.alias = NULL; - imap_mailbox_tbl_item.mailbox_name = new_mailbox->name; - imap_mailbox_tbl_item.modifiable_yn = 1; - - /* if modified imap mailbox is synchronous mailbox, update mailbox name from imap mailbox table */ - if (!emstorage_update_mailbox(ref_account->account_id, 0, old_mailbox->name, &imap_mailbox_tbl_item, true, &err)) - { - EM_DEBUG_EXCEPTION("emstorage_update_mailbox failed - %d", err); - goto JOB_ERROR; + if (!mail_rename(stream, long_enc_path_old, long_enc_path_new)) { + err = EMAIL_ERROR_UNKNOWN; + goto FINISH_OFF; } - ret = true; - -JOB_ERROR: - EM_SAFE_FREE(long_enc_path); +FINISH_OFF: + EM_SAFE_FREE(long_enc_path_old); EM_SAFE_FREE(long_enc_path_new); - if (stream) - { + if (stream) { emcore_close_mailbox(0, stream); stream = NULL; } - if (err_code) - *err_code = err; - - return ret; + EM_DEBUG_FUNC_END("err [%d]", err); + return err; } diff --git a/email-core/email-core-mail.c b/email-core/email-core-mail.c index 2bbac96..5ad0936 100755 --- a/email-core/email-core-mail.c +++ b/email-core/email-core-mail.c @@ -56,6 +56,7 @@ #include "email-core-mime.h" #include "email-core-mailbox.h" #include "email-storage.h" +#include "email-network.h" #include "email-core-mailbox-sync.h" #include "email-core-event.h" #include "email-core-account.h" @@ -64,7 +65,7 @@ #include "email-debug-log.h" #ifdef __FEATURE_DRM__ -#include +#include #endif /* __FEATURE_DRM__ */ #define ST_SILENT (long) 0x2 /* don't return results */ @@ -89,8 +90,9 @@ int _imap4_download_noti_interval_value = 0; BODY **g_inline_list = NULL ; int g_inline_count = 0; -static int emcore_delete_mail_from_server(emf_account_t *account, emf_mailbox_t *mailbox, int msgno, int *err_code); -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); + +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_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); @@ -207,7 +209,7 @@ static int pop3_mail_delete(MAILSTREAM *stream, int msgno, int *err_code) EM_DEBUG_FUNC_BEGIN("stream[%p], msgno[%d], err_code[%p]", stream, msgno, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; POP3LOCAL *pop3local = NULL; char cmd[64]; @@ -215,13 +217,13 @@ static int pop3_mail_delete(MAILSTREAM *stream, int msgno, int *err_code) if (!stream) { EM_DEBUG_EXCEPTION("stream[%p]", stream); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!(pop3local = stream->local) || !pop3local->netstream) { EM_DEBUG_EXCEPTION("invalid POP3 stream detected..."); - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; goto FINISH_OFF; } @@ -236,14 +238,14 @@ static int pop3_mail_delete(MAILSTREAM *stream, int msgno, int *err_code) /* send command : delete specified mail */ if (!net_sout(pop3local->netstream, cmd, (int)strlen(cmd))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_CONNECTION_BROKEN; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } /* receive response */ if (!(p = net_getline(pop3local->netstream))) { EM_DEBUG_EXCEPTION("net_getline failed..."); - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -252,12 +254,12 @@ static int pop3_mail_delete(MAILSTREAM *stream, int msgno, int *err_code) #endif if (*p == '-') { /* '-ERR' */ - err = EMF_ERROR_POP3_DELE_FAILURE; /* EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; */ + err = EMAIL_ERROR_POP3_DELE_FAILURE; /* EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER; */ goto FINISH_OFF; } if (*p != '+') { /* '+OK' ... */ - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -282,7 +284,7 @@ static void emcore_mail_copyuid_ex(MAILSTREAM *stream, char *mailbox, unsigned l int index = -1; int i = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; unsigned long first_uid = 0; unsigned long last_uid = 0; @@ -420,30 +422,31 @@ static void emcore_mail_copyuid_ex(MAILSTREAM *stream, char *mailbox, unsigned l } -INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, char *src_mailbox, int mail_ids[], int num, char *dest_mailbox, int *error_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) { EM_DEBUG_FUNC_BEGIN(); MAILSTREAM *stream = NULL; - int err_code = EMF_ERROR_NONE; - emf_account_t *ref_account = NULL; + int err_code = EMAIL_ERROR_NONE; + email_account_t *ref_account = NULL; int ret = false; int i = 0; - emf_id_set_t *id_set = NULL; + email_id_set_t *id_set = NULL; int id_set_count = 0; - emf_uid_range_set *uid_range_set = NULL; + email_uid_range_set *uid_range_set = NULL; int len_of_each_range = 0; - emf_uid_range_set *uid_range_node = NULL; + email_uid_range_set *uid_range_node = NULL; char **string_list = NULL; int string_count = 0; + emstorage_mailbox_tbl_t* dest_mailbox = NULL; - if (num <= 0 || account_id <= 0 || NULL == src_mailbox || NULL == dest_mailbox || NULL == mail_ids) { + if (num <= 0 || account_id <= 0 || src_mailbox_id <= 0 || dest_mailbox_id <= 0 || NULL == mail_ids) { if (error_code != NULL) { - *error_code = EMF_ERROR_INVALID_PARAM; + *error_code = EMAIL_ERROR_INVALID_PARAM; } - EM_DEBUG_LOG("Invalid Parameters- num[%d], account_id[%d], src_mailbox[%p], dest_mailbox[%p], mail_ids[%p]", num, account_id, src_mailbox, dest_mailbox, mail_ids); + EM_DEBUG_LOG("Invalid Parameters- num[%d], account_id[%d], src_mailbox_id[%d], dest_mailbox_id[%d], mail_ids[%p]", num, account_id, src_mailbox_id, dest_mailbox_id, mail_ids); return false; } @@ -452,18 +455,18 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, char *src_mailbo if (NULL == ref_account) { EM_DEBUG_EXCEPTION(" emcore_get_account_reference failed[%d]", account_id); - *error_code = EMF_ERROR_INVALID_ACCOUNT; + *error_code = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - if (ref_account->receiving_server_type != EMF_SERVER_TYPE_IMAP4) { - *error_code = EMF_ERROR_INVALID_PARAM; + if (ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) { + *error_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (!emcore_connect_to_remote_mailbox(account_id, src_mailbox, (void **)&stream, &err_code)) { + if (!emcore_connect_to_remote_mailbox(account_id, src_mailbox_id, (void **)&stream, &err_code)) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed[%d]", err_code); goto FINISH_OFF; @@ -482,6 +485,11 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, char *src_mailbo goto FINISH_OFF; } + if ( (err_code = emstorage_get_mailbox_by_id(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; + } + /* Now execute one by one each comma separated string of mail_ids */ for (i = 0; i < string_count; ++i) { @@ -507,7 +515,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, char *src_mailbo /* Remove comma from end of uid_range */ uid_range_node->uid_range[strlen(uid_range_node->uid_range) - 1] = '\0'; EM_DEBUG_LOG("uid_range_node->uid_range - %s", uid_range_node->uid_range); - if (!mail_copy_full(stream, uid_range_node->uid_range, dest_mailbox, CP_UID | CP_MOVE)) { + if (!mail_copy_full(stream, uid_range_node->uid_range, dest_mailbox->mailbox_name, CP_UID | CP_MOVE)) { EM_DEBUG_EXCEPTION("emcore_move_mail_on_server_ex : Mail cannot be moved failed"); EM_DEBUG_EXCEPTION("Mail MOVE failed "); goto FINISH_OFF; @@ -545,7 +553,7 @@ FINISH_OFF: stream = NULL; #ifdef __FEATURE_LOCAL_ACTIVITY__ - if (ret || ref_account->receiving_server_type != EMF_SERVER_TYPE_IMAP4) /* Delete local activity for POP3 mails and successful move operation in IMAP */ { + if (ret || ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) /* Delete local activity for POP3 mails and successful move operation in IMAP */ { emstorage_activity_tbl_t new_activity; for (i = 0; imail_stream; - if (!stream) { - EM_DEBUG_EXCEPTION(" Stream is NULL "); - err = EMF_ERROR_INVALID_PARAM; + for(i = 0; i < num; i++) { + if (!emstorage_get_downloaded_mail(mail_ids[i], &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; + } + else + break; + } + } + + if (!emcore_connect_to_remote_mailbox(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; - } /* [h.gahlaut] Break the set of mail_ids into comma separated strings of given length */ @@ -649,7 +665,7 @@ int imap4_mail_delete_ex(emf_mailbox_t *mailbox, int mail_ids[], int num, int * if (!(imaplocal = stream->local) || !imaplocal->netstream) { EM_DEBUG_EXCEPTION("invalid IMAP4 stream detected..."); - err = EMF_ERROR_CONNECTION_BROKEN; + err = EMAIL_ERROR_CONNECTION_BROKEN; goto FINISH_OFF; } @@ -666,7 +682,7 @@ int imap4_mail_delete_ex(emf_mailbox_t *mailbox, int mail_ids[], int num, int * if (!net_sout(imaplocal->netstream, cmd, (int)strlen(cmd))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; /* EMF_ERROR_UNKNOWN */ + err = EMAIL_ERROR_CONNECTION_BROKEN; /* EMAIL_ERROR_UNKNOWN */ goto FINISH_OFF; } @@ -676,7 +692,7 @@ int imap4_mail_delete_ex(emf_mailbox_t *mailbox, int mail_ids[], int num, int * if (!(p = net_getline(imaplocal->netstream))) { EM_DEBUG_EXCEPTION("net_getline failed..."); - err = EMF_ERROR_INVALID_RESPONSE; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_INVALID_RESPONSE; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } @@ -705,7 +721,7 @@ int imap4_mail_delete_ex(emf_mailbox_t *mailbox, int mail_ids[], int num, int * else { /* 'NO' or 'BAD' */ delete_success = false; - err = EMF_ERROR_IMAP4_STORE_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */ + err = EMAIL_ERROR_IMAP4_STORE_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */ goto FINISH_OFF; } } @@ -727,7 +743,7 @@ int imap4_mail_delete_ex(emf_mailbox_t *mailbox, int mail_ids[], int num, int * if (!net_sout(imaplocal->netstream, cmd, (int)strlen(cmd))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; + err = EMAIL_ERROR_CONNECTION_BROKEN; goto FINISH_OFF; } @@ -736,7 +752,7 @@ int imap4_mail_delete_ex(emf_mailbox_t *mailbox, int mail_ids[], int num, int * if (!(p = net_getline(imaplocal->netstream))) { EM_DEBUG_EXCEPTION("net_getline failed..."); - err = EMF_ERROR_INVALID_RESPONSE; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_INVALID_RESPONSE; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } @@ -751,7 +767,7 @@ int imap4_mail_delete_ex(emf_mailbox_t *mailbox, int mail_ids[], int num, int * mail = (emstorage_mail_tbl_t **) em_malloc(num * sizeof(emstorage_mail_tbl_t *)); if (!mail) { EM_DEBUG_EXCEPTION("em_malloc failed"); - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; goto FINISH_OFF; } @@ -760,8 +776,8 @@ int imap4_mail_delete_ex(emf_mailbox_t *mailbox, int mail_ids[], int num, int * if (!emstorage_get_downloaded_mail(mail_ids[index], &mail[index], false, &err)) { EM_DEBUG_LOG("emstorage_get_uid_by_mail_id failed [%d]", err); - if (err == EMF_ERROR_MAIL_NOT_FOUND) { - EM_DEBUG_LOG("EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER : "); + if (err == EMAIL_ERROR_MAIL_NOT_FOUND) { + EM_DEBUG_LOG("EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER : "); continue; } } @@ -769,7 +785,7 @@ int imap4_mail_delete_ex(emf_mailbox_t *mailbox, int mail_ids[], int num, int * if (mail[index]) { /* Clear entry from mail_read_mail_uid_tbl */ if (mail[index]->server_mail_id != NULL) { - if (!emstorage_remove_downloaded_mail(mailbox->account_id, mailbox->name, mail[index]->server_mail_id, true, &err)) { + if (!emstorage_remove_downloaded_mail(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); } } @@ -777,9 +793,9 @@ int imap4_mail_delete_ex(emf_mailbox_t *mailbox, int mail_ids[], int num, int * /* Delete local activity */ emstorage_activity_tbl_t new_activity; memset(&new_activity, 0x00, sizeof(emstorage_activity_tbl_t)); - if (from_server == EMF_DELETE_FOR_SEND_THREAD) { + if (from_server == EMAIL_DELETE_FOR_SEND_THREAD) { new_activity.activity_type = ACTIVITY_DELETEMAIL_SEND; - EM_DEBUG_LOG("from_server == EMF_DELETE_FOR_SEND_THREAD "); + EM_DEBUG_LOG("from_server == EMAIL_DELETE_FOR_SEND_THREAD "); } else { new_activity.activity_type = ACTIVITY_DELETEMAIL; @@ -827,7 +843,7 @@ int imap4_mail_delete_ex(emf_mailbox_t *mailbox, int mail_ids[], int num, int * break; } else { /* 'NO' or 'BAD' */ - err = EMF_ERROR_IMAP4_EXPUNGE_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */ + err = EMAIL_ERROR_IMAP4_EXPUNGE_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */ goto FINISH_OFF; } } @@ -865,124 +881,6 @@ FINISH_OFF: #endif -static int imap4_mail_delete(MAILSTREAM *stream, int msgno, int *err_code) -{ - EM_DEBUG_FUNC_BEGIN("stream[%p], msgno[%d], err_code[%p]", stream, msgno, err_code); - - int ret = false; - int err = EMF_ERROR_NONE; - - IMAPLOCAL *imaplocal = NULL; - char tag[16], cmd[64]; - char *p = NULL; - - if (!(imaplocal = stream->local) || !imaplocal->netstream) { - EM_DEBUG_EXCEPTION("invalid IMAP4 stream detected..."); - - err = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN */ - goto FINISH_OFF; - } - - memset(tag, 0x00, sizeof(tag)); - memset(cmd, 0x00, sizeof(cmd)); - - SNPRINTF(tag, sizeof(tag), "%08lx", 0xffffffff & (stream->gensym++)); - SNPRINTF(cmd, sizeof(cmd), "%s STORE %d +FLAGS.SILENT (\\Deleted)\015\012", tag, msgno); - -#ifdef FEATURE_CORE_DEBUG - EM_DEBUG_LOG("[IMAP4] >>> %s", cmd); -#endif - - /* send command : set deleted flag */ - if (!net_sout(imaplocal->netstream, cmd, (int)strlen(cmd))) { - EM_DEBUG_EXCEPTION("net_sout failed..."); - - err = EMF_ERROR_CONNECTION_BROKEN; /* EMF_ERROR_UNKNOWN */ - goto FINISH_OFF; - } - - while (imaplocal->netstream) { - /* receive response */ - if (!(p = net_getline(imaplocal->netstream))) { - EM_DEBUG_EXCEPTION("net_getline failed..."); - - err = EMF_ERROR_INVALID_RESPONSE; /* EMF_ERROR_UNKNOWN; */ - goto FINISH_OFF; - } - -#ifdef FEATURE_CORE_DEBUG - EM_DEBUG_LOG("[IMAP4] <<< %s", p); -#endif - if (!strncmp(p, tag, strlen(tag))) { - if (!strncmp(p + strlen(tag) + 1, "OK", 2)) { - EM_SAFE_FREE(p); - break; - } - else { /* 'NO' or 'BAD' */ - err = EMF_ERROR_IMAP4_STORE_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */ - goto FINISH_OFF; - } - } - - EM_SAFE_FREE(p); - } - - memset(tag, 0x00, sizeof(tag)); - memset(cmd, 0x00, sizeof(cmd)); - - SNPRINTF(tag, sizeof(tag), "%08lx", 0xffffffff & (stream->gensym++)); - SNPRINTF(cmd, sizeof(cmd), "%s EXPUNGE\015\012", tag); - -#ifdef FEATURE_CORE_DEBUG - EM_DEBUG_LOG("[IMAP4] >>> %s", cmd); -#endif - - /* send command : delete flaged mail */ - if (!net_sout(imaplocal->netstream, cmd, (int)strlen(cmd))) { - EM_DEBUG_EXCEPTION("net_sout failed..."); - - err = EMF_ERROR_CONNECTION_BROKEN; - goto FINISH_OFF; - } - - while (imaplocal->netstream) { - /* receive response */ - if (!(p = net_getline(imaplocal->netstream))) { - EM_DEBUG_EXCEPTION("net_getline failed..."); - - err = EMF_ERROR_INVALID_RESPONSE; /* EMF_ERROR_UNKNOWN; */ - goto FINISH_OFF; - } - -#ifdef FEATURE_CORE_DEBUG - EM_DEBUG_LOG("[IMAP4] <<< %s", p); -#endif - - if (!strncmp(p, tag, strlen(tag))) { - if (!strncmp(p + strlen(tag) + 1, "OK", 2)) { - EM_SAFE_FREE(p); - break; - } - else { /* 'NO' or 'BAD' */ - err = EMF_ERROR_IMAP4_EXPUNGE_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */ - goto FINISH_OFF; - } - } - - EM_SAFE_FREE(p); - } - - ret = true; - -FINISH_OFF: - EM_SAFE_FREE(p); - - if (err_code) - *err_code = err; - - return ret; -} - typedef enum { IMAP4_CMD_EXPUNGE } imap4_cmd_t; @@ -992,7 +890,7 @@ static int imap4_send_command(MAILSTREAM *stream, imap4_cmd_t cmd_type, int *err EM_DEBUG_FUNC_BEGIN("stream[%p], cmd_type[%d], err_code[%p]", stream, cmd_type, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; IMAPLOCAL *imaplocal = NULL; char tag[16], cmd[64]; @@ -1001,7 +899,7 @@ static int imap4_send_command(MAILSTREAM *stream, imap4_cmd_t cmd_type, int *err if (!(imaplocal = stream->local) || !imaplocal->netstream) { EM_DEBUG_EXCEPTION("invalid IMAP4 stream detected..."); - err = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN */ + err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN */ goto FINISH_OFF; } @@ -1019,7 +917,7 @@ static int imap4_send_command(MAILSTREAM *stream, imap4_cmd_t cmd_type, int *err if (!net_sout(imaplocal->netstream, cmd, (int)strlen(cmd))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; + err = EMAIL_ERROR_CONNECTION_BROKEN; goto FINISH_OFF; } @@ -1028,7 +926,7 @@ static int imap4_send_command(MAILSTREAM *stream, imap4_cmd_t cmd_type, int *err if (!(p = net_getline(imaplocal->netstream))) { EM_DEBUG_EXCEPTION("net_getline failed..."); - err = EMF_ERROR_INVALID_RESPONSE; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_INVALID_RESPONSE; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } @@ -1042,7 +940,7 @@ static int imap4_send_command(MAILSTREAM *stream, imap4_cmd_t cmd_type, int *err break; } else { /* 'NO' or 'BAD' */ - err = EMF_ERROR_IMAP4_EXPUNGE_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */ + err = EMAIL_ERROR_IMAP4_EXPUNGE_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */ goto FINISH_OFF; } } @@ -1061,12 +959,12 @@ FINISH_OFF: return ret; } -int emcore_get_mail_contact_info(emf_mail_contact_info_t *contact_info, char *full_address, int *err_code) +int emcore_get_mail_contact_info(email_mail_contact_info_t *contact_info, char *full_address, int *err_code) { EM_DEBUG_FUNC_BEGIN("contact_info[%p], full_address[%s], err_code[%p]", contact_info, full_address, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!emcore_get_mail_contact_info_with_update(contact_info, full_address, 0, &err)) EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info_with_update failed [%d]", err); @@ -1102,7 +1000,7 @@ INTERNAL_FUNC int emcore_get_mail_display_name(CTSvalue *contact_name_value, cha display = (char *)EM_SAFE_STRDUP(last); } else - display = g_strdup(contacts_svc_value_get_str(contact_name_value, CTS_NAME_VAL_DISPLAY_STR)); + display = g_strdup(contacts_svc_value_get_str(contact_name_value, CTS_NAME_VAL_FIRST_STR)); if (contact_display_name != NULL) *contact_display_name = display; @@ -1110,12 +1008,12 @@ INTERNAL_FUNC int emcore_get_mail_display_name(CTSvalue *contact_name_value, cha return true; } -int emcore_get_mail_contact_info_with_update(emf_mail_contact_info_t *contact_info, char *full_address, int mail_id, int *err_code) +int emcore_get_mail_contact_info_with_update(email_mail_contact_info_t *contact_info, char *full_address, int mail_id, int *err_code) { EM_DEBUG_FUNC_BEGIN("contact_info[%p], full_address[%s], mail_id[%d], err_code[%p]", contact_info, full_address, mail_id, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; ADDRESS *addr = NULL; char *address = NULL; char *temp_emailaddr = NULL; @@ -1140,7 +1038,7 @@ int emcore_get_mail_contact_info_with_update(emf_mail_contact_info_t *contact_in if (!contact_info) { EM_DEBUG_EXCEPTION("contact_info[%p]", contact_info); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1180,7 +1078,7 @@ int emcore_get_mail_contact_info_with_update(emf_mail_contact_info_t *contact_in if (!addr) { EM_DEBUG_EXCEPTION("rfc822_parse_adrlist failed..."); - err = EMF_ERROR_INVALID_ADDRESS; + err = EMAIL_ERROR_INVALID_ADDRESS; goto FINISH_OFF; } @@ -1189,7 +1087,7 @@ int emcore_get_mail_contact_info_with_update(emf_mail_contact_info_t *contact_in if (!contact_name) { EM_DEBUG_EXCEPTION("Memory allocation error!"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -1267,7 +1165,7 @@ int emcore_get_mail_contact_info_with_update(emf_mail_contact_info_t *contact_in if (contact_name == NULL) { EM_DEBUG_EXCEPTION("Memory allocation failed."); EM_SAFE_FREE(temp); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } snprintf(contact_name, contact_name_buffer_size, "%s", temp); @@ -1338,7 +1236,7 @@ int emcore_get_mail_contact_info_with_update(emf_mail_contact_info_t *contact_in if (contact_name == NULL) { EM_DEBUG_EXCEPTION("Memory allocation failed."); EM_SAFE_FREE(temp); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } snprintf(contact_name, contact_name_buffer_size, "%s", temp); @@ -1414,16 +1312,16 @@ FINISH_OFF: return ret; } -int emcore_free_contact_info(emf_mail_contact_info_t *contact_info, int *err_code) +int emcore_free_contact_info(email_mail_contact_info_t *contact_info, int *err_code) { EM_DEBUG_FUNC_BEGIN("contact_info[%p], err_code[%p]", contact_info, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!contact_info) { EM_DEBUG_EXCEPTION("contact_info[%p]", contact_info); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1449,21 +1347,21 @@ int emcore_sync_contact_info(int mail_id, int *err_code) EM_DEBUG_FUNC_BEGIN(); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_mail_tbl_t *mail = NULL; - emf_mail_contact_info_t contact_info_from; - emf_mail_contact_info_t contact_info_to; - emf_mail_contact_info_t contact_info_cc; - emf_mail_contact_info_t contact_info_bcc; + email_mail_contact_info_t contact_info_from; + email_mail_contact_info_t contact_info_to; + email_mail_contact_info_t contact_info_cc; + email_mail_contact_info_t contact_info_bcc; EM_DEBUG_LOG("mail_id[%d], err_code[%p]", mail_id, err_code); - memset(&contact_info_from, 0x00, sizeof(emf_mail_contact_info_t)); - memset(&contact_info_to, 0x00, sizeof(emf_mail_contact_info_t)); - memset(&contact_info_cc, 0x00, sizeof(emf_mail_contact_info_t)); - memset(&contact_info_bcc, 0x00, sizeof(emf_mail_contact_info_t)); + memset(&contact_info_from, 0x00, sizeof(email_mail_contact_info_t)); + memset(&contact_info_to, 0x00, sizeof(email_mail_contact_info_t)); + 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) { EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err); @@ -1544,26 +1442,26 @@ FINISH_OFF: /* 1. parsing : alias and address */ /* 2. sync with contact */ /* 3. make glist of address info */ -static int emcore_sync_address_info(emf_address_type_t address_type, char *full_address, GList **address_info_list, int *err_code) +static int emcore_sync_address_info(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); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int contact_index = -1; int is_search = false; char *alias = NULL; char *address = NULL; char *contact_display_name_from_contact_info = NULL; char email_address[MAX_EMAIL_ADDRESS_LENGTH]; - emf_address_info_t *p_address_info = NULL; + email_address_info_t *p_address_info = NULL; ADDRESS *addr = NULL; CTSstruct *contact = NULL; CTSvalue *contact_name_value = NULL; - if (full_address == NULL || address_info_list == NULL) { - EM_DEBUG_EXCEPTION("Invalid param : full_address or address_info_list is NULL"); - error = EMF_ERROR_INVALID_PARAM; + if (address_info_list == NULL) { + EM_DEBUG_EXCEPTION("Invalid param : address_info_list is NULL"); + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1590,7 +1488,7 @@ static int emcore_sync_address_info(emf_address_type_t address_type, char *full_ if (!addr) { EM_DEBUG_EXCEPTION("rfc822_parse_adrlist failed..."); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1615,12 +1513,12 @@ static int emcore_sync_address_info(emf_address_type_t address_type, char *full_ /* 2) alias (if a alias in an original mail doesn't exist, this field is set with email address */ /* 3) email address */ - if (!(p_address_info = (emf_address_info_t *)malloc(sizeof(emf_address_info_t)))) { + if (!(p_address_info = (email_address_info_t *)malloc(sizeof(email_address_info_t)))) { EM_DEBUG_EXCEPTION("malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - memset(p_address_info, 0x00, sizeof(emf_address_info_t)); + memset(p_address_info, 0x00, sizeof(email_address_info_t)); SNPRINTF(email_address, MAX_EMAIL_ADDRESS_LENGTH, "%s@%s", addr->mailbox ? addr->mailbox : "", addr->host ? addr->host : ""); @@ -1721,8 +1619,8 @@ FINISH_OFF: static gint address_compare(gconstpointer a, gconstpointer b) { EM_DEBUG_FUNC_BEGIN(); - emf_sender_list_t *recipients_list1 = (emf_sender_list_t *)a; - emf_sender_list_t *recipients_list2 = (emf_sender_list_t *)b; + email_sender_list_t *recipients_list1 = (email_sender_list_t *)a; + email_sender_list_t *recipients_list2 = (email_sender_list_t *)b; EM_DEBUG_FUNC_END(); return strcmp(recipients_list1->address, recipients_list2->address); @@ -1732,7 +1630,7 @@ INTERNAL_FUNC GList *emcore_get_recipients_list(GList *old_recipients_list, char { EM_DEBUG_FUNC_BEGIN(); - int i = 0, err = EMF_ERROR_NONE; + int i = 0, err = EMAIL_ERROR_NONE; int contact_index = -1; int is_search = false; char *address = NULL; @@ -1745,12 +1643,12 @@ INTERNAL_FUNC GList *emcore_get_recipients_list(GList *old_recipients_list, char GList *new_recipients_list = old_recipients_list; GList *recipients_list; - emf_sender_list_t *temp_recipients_list = NULL; - emf_sender_list_t *old_recipients_list_t = NULL; + email_sender_list_t *temp_recipients_list = NULL; + email_sender_list_t *old_recipients_list_t = NULL; if (full_address == NULL || strlen(full_address) == 0) { EM_DEBUG_EXCEPTION("Invalid param : full_address NULL or empty"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1773,7 +1671,7 @@ INTERNAL_FUNC GList *emcore_get_recipients_list(GList *old_recipients_list, char if (!addr) { EM_DEBUG_EXCEPTION("rfc822_parse_adrlist failed..."); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1790,7 +1688,7 @@ INTERNAL_FUNC GList *emcore_get_recipients_list(GList *old_recipients_list, char continue; } - temp_recipients_list = g_new0(emf_sender_list_t, 1); + temp_recipients_list = g_new0(email_sender_list_t, 1); SNPRINTF(email_address, MAX_EMAIL_ADDRESS_LENGTH, "%s@%s", addr->mailbox ? addr->mailbox : "", addr->host ? addr->host : ""); @@ -1850,7 +1748,7 @@ INTERNAL_FUNC GList *emcore_get_recipients_list(GList *old_recipients_list, char recipients_list = g_list_first(new_recipients_list); while (recipients_list != NULL) { - old_recipients_list_t = (emf_sender_list_t *)recipients_list->data; + old_recipients_list_t = (email_sender_list_t *)recipients_list->data; if (!strcmp(old_recipients_list_t->address, temp_recipients_list->address)) { old_recipients_list_t->total_count = old_recipients_list_t->total_count + 1; if (temp_recipients_list != NULL) @@ -1887,20 +1785,20 @@ FINISH_OFF: return new_recipients_list; } -INTERNAL_FUNC int emcore_get_mail_address_info_list(int mail_id, emf_address_info_list_t **address_info_list, 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) { EM_DEBUG_FUNC_BEGIN("mail_id[%d], address_info_list[%p]", mail_id, address_info_list); - int ret = false, err = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; int failed = true; int contact_error; emstorage_mail_tbl_t *mail = NULL; - emf_address_info_list_t *p_address_info_list = NULL; + email_address_info_list_t *p_address_info_list = NULL; if (mail_id <= 0 || !address_info_list) { EM_DEBUG_EXCEPTION("mail_id[%d], address_info_list[%p]", mail_id, address_info_list); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1912,29 +1810,29 @@ INTERNAL_FUNC int emcore_get_mail_address_info_list(int mail_id, emf_address_inf goto FINISH_OFF; } - if (!(p_address_info_list = (emf_address_info_list_t *)malloc(sizeof(emf_address_info_list_t)))) { + if (!(p_address_info_list = (email_address_info_list_t *)malloc(sizeof(email_address_info_list_t)))) { EM_DEBUG_EXCEPTION("malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - memset(p_address_info_list, 0x00, sizeof(emf_address_info_list_t)); + memset(p_address_info_list, 0x00, sizeof(email_address_info_list_t)); if ((contact_error = contacts_svc_connect()) == CTS_SUCCESS) { EM_DEBUG_LOG("Open Contact Service Success"); } else { EM_DEBUG_EXCEPTION("contact_db_service_connect failed [%d]", contact_error); - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; } - if (emcore_sync_address_info(EMF_ADDRESS_TYPE_FROM, mail->full_address_from, &p_address_info_list->from, &err)) + if (mail->full_address_from && emcore_sync_address_info(EMAIL_ADDRESS_TYPE_FROM, mail->full_address_from, &p_address_info_list->from, &err)) failed = false; - if (emcore_sync_address_info(EMF_ADDRESS_TYPE_TO, mail->full_address_to, &p_address_info_list->to, &err)) + if (mail->full_address_to && emcore_sync_address_info(EMAIL_ADDRESS_TYPE_TO, mail->full_address_to, &p_address_info_list->to, &err)) failed = false; - if (emcore_sync_address_info(EMF_ADDRESS_TYPE_CC, mail->full_address_cc, &p_address_info_list->cc, &err)) + if (mail->full_address_cc && emcore_sync_address_info(EMAIL_ADDRESS_TYPE_CC, mail->full_address_cc, &p_address_info_list->cc, &err)) failed = false; - if (emcore_sync_address_info(EMF_ADDRESS_TYPE_BCC, mail->full_address_bcc, &p_address_info_list->bcc, &err)) + if (mail->full_address_bcc && emcore_sync_address_info(EMAIL_ADDRESS_TYPE_BCC, mail->full_address_bcc, &p_address_info_list->bcc, &err)) failed = false; if ((contact_error = contacts_svc_disconnect()) == CTS_SUCCESS) @@ -1967,21 +1865,21 @@ FINISH_OFF: * input_mail_id : [in] mail id * output_mail_data : [out] double pointer to hold mail data. * return - * succeed : EMF_ERROR_NONE + * succeed : EMAIL_ERROR_NONE * fail : error code */ -INTERNAL_FUNC int emcore_get_mail_data(int input_mail_id, emf_mail_data_t **output_mail_data) +INTERNAL_FUNC int emcore_get_mail_data(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); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int result_mail_count = 0; char conditional_clause_string[QUERY_SIZE] = { 0, }; emstorage_mail_tbl_t *result_mail_tbl = NULL; if (input_mail_id == 0 || !output_mail_data) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - error = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2019,17 +1917,20 @@ int emcore_check_drm(emstorage_attachment_tbl_t *input_attachment_tb_data) EM_DEBUG_FUNC_BEGIN(); int ret = 0; #ifdef __FEATURE_DRM__ - drm_dcf_info_t fileInfo; + drm_bool_type_e drm_file = DRM_UNKNOWN; + drm_file_info_s drm_file_info; if (input_attachment_tb_data == NULL) return ret; - if (drm_svc_is_drm_file (input_attachment_tb_data->attachment_path)) { - if (drm_svc_get_dcf_file_info (input_attachment_tb_data->attachment_path, &fileInfo) == DRM_RESULT_SUCCESS) { + ret = drm_is_drm_file(input_attachment_tb_data->attachment_path, &drm_file); + + if (ret == DRM_RETURN_SUCCESS && drm_file == DRM_TRUE) { + if (drm_get_file_info (input_attachment_tb_data->attachment_path, &drm_file_info) == DRM_RETURN_SUCCESS) { input_attachment_tb_data->attachment_drm_type = 0; - EM_DEBUG_LOG ("fileInfo is [%d]", fileInfo.method); - if (fileInfo.method != DRM_METHOD_UNDEFINED) { - input_attachment_tb_data->attachment_drm_type = fileInfo.method; + EM_DEBUG_LOG ("fileInfo is [%d]", drm_file_info.oma_info.method); + if (drm_file_info.oma_info.method != DRM_METHOD_TYPE_UNDEFINED) { + input_attachment_tb_data->attachment_drm_type = drm_file_info.oma_info.method; ret = 1; } } @@ -2056,44 +1957,42 @@ int emcore_check_drm(emstorage_attachment_tbl_t *input_attachment_tb_data) * succeed : 1 * fail : 0 */ -INTERNAL_FUNC int emcore_get_attachment_info(int mail_id, char *attachment_id_string, emf_attachment_info_t **attachment, int *err_code) +INTERNAL_FUNC int emcore_get_attachment_info(int attachment_id, email_attachment_data_t **attachment, int *err_code) { - EM_DEBUG_FUNC_BEGIN("mail_id[%d], attachment_id_string[%p], attachment[%p], err_code[%p]", mail_id, attachment_id_string, attachment, err_code); + EM_DEBUG_FUNC_BEGIN("attachment_id[%d], attachment[%p], err_code[%p]", attachment_id, attachment, err_code); - if (attachment == NULL || attachment_id_string == NULL) { - EM_DEBUG_EXCEPTION("mail_id[%d], attachment_id_string[%p], attachment[%p]", mail_id, attachment_id_string, attachment); + if (attachment == NULL || attachment_id == 0) { + EM_DEBUG_EXCEPTION("attachment_id[%d], attachment[%p]", attachment_id, attachment); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_attachment_tbl_t *attachment_tbl = NULL; - int attachment_id = atoi(attachment_id_string); /* get attachment from attachment tbl */ - if (!emstorage_get_attachment(mail_id, attachment_id, &attachment_tbl, true, &err) || !attachment_tbl) { + if (!emstorage_get_attachment(attachment_id, &attachment_tbl, true, &err) || !attachment_tbl) { EM_DEBUG_EXCEPTION("emstorage_get_attachment failed [%d]", err); goto FINISH_OFF; } - *attachment = em_malloc(sizeof(emf_attachment_info_t)); + *attachment = em_malloc(sizeof(email_attachment_data_t)); if (!*attachment) { EM_DEBUG_EXCEPTION("malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } (*attachment)->attachment_id = attachment_id; - (*attachment)->name = attachment_tbl->attachment_name; attachment_tbl->attachment_name = NULL; - (*attachment)->size = attachment_tbl->attachment_size; - (*attachment)->downloaded = attachment_tbl->attachment_save_status; - (*attachment)->savename = attachment_tbl->attachment_path; attachment_tbl->attachment_path = NULL; - (*attachment)->drm = attachment_tbl->attachment_drm_type; - (*attachment)->inline_content = attachment_tbl->attachment_inline_content_status; - (*attachment)->next = NULL; + (*attachment)->attachment_name = attachment_tbl->attachment_name; attachment_tbl->attachment_name = NULL; + (*attachment)->attachment_size = attachment_tbl->attachment_size; + (*attachment)->save_status = attachment_tbl->attachment_save_status; + (*attachment)->attachment_path = attachment_tbl->attachment_path; attachment_tbl->attachment_path = NULL; + (*attachment)->drm_status = attachment_tbl->attachment_drm_type; + (*attachment)->inline_content_status = attachment_tbl->attachment_inline_content_status; ret = true; @@ -2114,26 +2013,26 @@ FINISH_OFF: * output_attachment_data : result attahchment data * output_attachment_count : result attahchment count * return - * succeed : EMF_ERROR_NONE + * succeed : EMAIL_ERROR_NONE * fail : error code */ -INTERNAL_FUNC int emcore_get_attachment_data_list(int input_mail_id, emf_attachment_data_t **output_attachment_data, int *output_attachment_count) +INTERNAL_FUNC int emcore_get_attachment_data_list(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); if (input_mail_id == 0|| output_attachment_data == NULL || output_attachment_count == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } int i = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int attachment_tbl_count = 0; emstorage_attachment_tbl_t *attachment_tbl_list = NULL; - emf_attachment_data_t *temp_attachment_data = NULL; + 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)) != EMF_ERROR_NONE ){ + if ( (err = emstorage_get_attachment_list(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; @@ -2142,11 +2041,11 @@ INTERNAL_FUNC int emcore_get_attachment_data_list(int input_mail_id, emf_attachm if (attachment_tbl_count) { EM_DEBUG_LOG("attchment count %d", attachment_tbl_count); - *output_attachment_data = em_malloc(sizeof(emf_attachment_data_t) * attachment_tbl_count); + *output_attachment_data = em_malloc(sizeof(email_attachment_data_t) * attachment_tbl_count); if(*output_attachment_data == NULL) { EM_DEBUG_EXCEPTION("em_malloc failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2159,7 +2058,7 @@ INTERNAL_FUNC int emcore_get_attachment_data_list(int input_mail_id, emf_attachm temp_attachment_data->attachment_size = attachment_tbl_list[i].attachment_size; temp_attachment_data->mail_id = attachment_tbl_list[i].mail_id; temp_attachment_data->account_id = attachment_tbl_list[i].account_id; - temp_attachment_data->mailbox_name = attachment_tbl_list[i].mailbox_name; attachment_tbl_list[i].mailbox_name = NULL; + temp_attachment_data->mailbox_id = attachment_tbl_list[i].mailbox_id; temp_attachment_data->save_status = attachment_tbl_list[i].attachment_save_status; temp_attachment_data->drm_status = attachment_tbl_list[i].attachment_drm_type; temp_attachment_data->inline_content_status = attachment_tbl_list[i].attachment_inline_content_status; @@ -2177,29 +2076,25 @@ FINISH_OFF: } -INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, char *nth, int *err_code) +INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, int nth, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], nth[%p], err_code[%p]", account_id, mail_id, nth, 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 attachment_no = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (mail_id < 1 || !nth) { - EM_DEBUG_EXCEPTION("mail_id[%d], nth[%p]", mail_id, nth); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("mail_id[%d], nth[%d]", mail_id, nth); + err = EMAIL_ERROR_INVALID_PARAM; if (err_code != NULL) *err_code = err; - if (nth) - attachment_no = atoi(nth); - - emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, 0, attachment_no, err); + emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, 0, nth, err); return false; } int ret = false; - int status = EMF_DOWNLOAD_FAIL; + int status = EMAIL_DOWNLOAD_FAIL; MAILSTREAM *stream = NULL; BODY *mbody = NULL; emstorage_mail_tbl_t *mail = NULL; @@ -2207,15 +2102,16 @@ INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, char * struct attachment_info *ai = NULL; struct _m_content_info *cnt_info = NULL; void *tmp_stream = NULL; - char *s_uid = NULL, *server_mbox = NULL, buf[1024]; + char *s_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; if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -2230,15 +2126,14 @@ INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, char * if (!mail->server_mail_status) { EM_DEBUG_EXCEPTION("not synchronous mail..."); - err = EMF_ERROR_INVALID_MAIL; + err = EMAIL_ERROR_INVALID_MAIL; goto FINISH_OFF; } - attachment_no = atoi(nth); - if (attachment_no == 0) { /* download all attachments, nth starts from 1, not zero */ + if (nth == 0) { /* download all attachments, nth starts from 1, not zero */ /* get attachment list from db */ - attachment_count_to_be_downloaded = EMF_ATTACHMENT_MAX_COUNT; - if ( (err = emstorage_get_attachment_list(mail_id, true, &attachment_list, &attachment_count_to_be_downloaded)) != EMF_ERROR_NONE ){ + 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; @@ -2246,7 +2141,7 @@ INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, char * } 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(mail_id, nth, &attachment_list, true, &err) || !attachment_list) { EM_DEBUG_EXCEPTION("emstorage_get_attachment_nth failed [%d]", err); goto FINISH_OFF; @@ -2254,18 +2149,18 @@ INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, char * } if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } account_id = mail->account_id; s_uid = EM_SAFE_STRDUP(mail->server_mail_id); - server_mbox = EM_SAFE_STRDUP(mail->mailbox_name); + server_mbox_id = mail->mailbox_id; /* 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(account_id, server_mbox_id, (void **)&tmp_stream, &err) || !tmp_stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err); - status = EMF_DOWNLOAD_CONNECTION_FAIL; + status = EMAIL_DOWNLOAD_CONNECTION_FAIL; goto FINISH_OFF; } @@ -2275,19 +2170,19 @@ INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, char * EM_DEBUG_LOG(" >>>>>> Attachment Downloading [%d / %d] start", i + 1, attachment_count_to_be_downloaded); attachment = attachment_list + i; - if (attachment_no == 0) /* download all attachments, nth starts from 1, not zero */ + 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 = attachment_no; /* attachment no */ + current_attachment_no = nth; /* attachment no */ if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } if (!(cnt_info = em_malloc(sizeof(struct _m_content_info)))) { EM_DEBUG_EXCEPTION("malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2304,7 +2199,7 @@ INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, char * mail_parameters(stream, SET_FREEBODYSPAREP, emcore_free_body_sharep); if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -2318,7 +2213,7 @@ INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, char * } if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -2341,7 +2236,7 @@ INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, char * } if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -2391,7 +2286,7 @@ INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, char * #ifdef __FEATURE_DRM__ if (emcore_check_drm(attachment)) { /* has drm attachment ? */ - if (drm_svc_register_file(attachment->attachment_path) == DRM_RESULT_SUCCESS) + if (drm_process_request(DRM_REQUEST_TYPE_REGISTER_FILE, (void *)attachment->attachment_path, NULL) == DRM_RETURN_SUCCESS) EM_DEBUG_LOG("drm_svc_register_file success"); else EM_DEBUG_EXCEPTION("drm_svc_register_file fail"); @@ -2401,7 +2296,7 @@ INTERNAL_FUNC int emcore_download_attachment(int account_id, int mail_id, char * } else { EM_DEBUG_EXCEPTION("invalid attachment sequence..."); - err = EMF_ERROR_INVALID_ATTACHMENT; + err = EMAIL_ERROR_INVALID_ATTACHMENT; goto FINISH_OFF; } @@ -2430,12 +2325,11 @@ FINISH_OFF: emstorage_free_mail(&mail, 1, NULL); EM_SAFE_FREE(s_uid); - EM_SAFE_FREE(server_mbox); if (ret == true) - emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_FINISH, mail_id, NULL, attachment_no, 0); + emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_FINISH, mail_id, NULL, nth, 0); else - emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, NULL, attachment_no, err); + emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, NULL, nth, err); if (err_code != NULL) *err_code = err; @@ -2445,14 +2339,13 @@ FINISH_OFF: } #ifdef __ATTACHMENT_OPTI__ -INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, char *nth, int *err_code) +INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, int nth, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], nth[%p], err_code[%p]", account_id, mail_id, nth, 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 attachment_no = 0; - int err = EMF_ERROR_NONE; /* Prevent Defect - 25093 */ + int err = EMAIL_ERROR_NONE; /* Prevent Defect - 25093 */ int ret = false; - int status = EMF_DOWNLOAD_FAIL; + int status = EMAIL_DOWNLOAD_FAIL; MAILSTREAM *stream = NULL; emstorage_mail_tbl_t *mail = NULL; emstorage_attachment_tbl_t *attachment = NULL; @@ -2473,8 +2366,8 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c int bIs_full = 0; int bIsAdd_to_mmc = false; int is_on_mmc = false; - emf_file_list *pFileListMMc = NULL; - emf_file_list *pFileList = NULL; + email_file_list *pFileListMMc = NULL; + email_file_list *pFileList = NULL; #endif /* SUPPORT_EXTERNAL_MEMORY */ @@ -2483,7 +2376,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c if (mail_id < 1 || !nth) { EM_DEBUG_EXCEPTION("account_id[%d], mail_id[%d], nth[%p]", account_id, mail_id, nth); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; if (err_code != NULL) *err_code = err; @@ -2497,7 +2390,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c } if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } only_body_download = false; @@ -2507,8 +2400,8 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c if (attachment_no == 0) { /* download all attachments, nth starts from 1, not zero */ /* get attachment list from db */ - attachment_count_to_be_downloaded = EMF_ATTACHMENT_MAX_COUNT; - if ( (err = emstorage_get_attachment_list(mail_id, true, &attachment_list, &attachment_count_to_be_downloaded)) != EMF_ERROR_NONE || !attachment_list){ + 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){ EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err); goto FINISH_OFF; @@ -2526,7 +2419,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -2542,7 +2435,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c /* if (!mail->server_mail_yn || !mail->text_download_yn) {*/ /* faizan.h@samsung.com */ if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -2556,7 +2449,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c if (!emcore_connect_to_remote_mailbox(account_id, server_mbox, (void **)&tmp_stream, &err) || !tmp_stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err); - status = EMF_DOWNLOAD_CONNECTION_FAIL; + status = EMAIL_DOWNLOAD_CONNECTION_FAIL; goto FINISH_OFF; } @@ -2564,7 +2457,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -2583,7 +2476,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c } if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -2624,7 +2517,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c if (bIs_full) { /* If external memory not present, return error */ if (PS_MMC_REMOVED == emstorage_get_mmc_status()) { - err = EMF_ERROR_MAIL_MEMORY_FULL; + err = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; } bIsAdd_to_mmc = true; @@ -2667,7 +2560,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c #endif /* __FEATURE_DRM__ */ if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -2697,7 +2590,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, c if (ret == true) emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_FINISH, mail_id, NULL, attachment_no, 0); - else if (err != EMF_ERROR_CANCELLED) + else if (err != EMAIL_ERROR_CANCELLED) emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, NULL, attachment_no, err); if (err_code != NULL) @@ -2713,17 +2606,17 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in 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 = EMF_ERROR_NONE; - int status = EMF_DOWNLOAD_FAIL; + int err = EMAIL_ERROR_NONE; + int status = EMAIL_DOWNLOAD_FAIL; int pop3_body_size = 0; int pop3_downloaded_size = 0; MAILSTREAM *stream = NULL; BODY *mbody = NULL; PARTLIST *section_list = NULL; - emf_mailbox_t mbox = { 0 }; + email_internal_mailbox_t mailbox = { 0 }; emstorage_mail_tbl_t *mail = NULL; emstorage_attachment_tbl_t attachment = {0, 0, NULL, }; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; struct attachment_info *ai = NULL; struct _m_content_info *cnt_info = NULL; void *tmp_stream = NULL; @@ -2736,10 +2629,11 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in #ifdef CHANGE_HTML_BODY_TO_ATTACHMENT int html_changed = 0; #endif + int mailbox_id = 0; 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 = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; if (err_code != NULL) *err_code = err; @@ -2763,27 +2657,27 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in if (1 == mail->body_download_status) { EM_DEBUG_EXCEPTION("not synchronous mail..."); - err = EMF_ERROR_INVALID_MAIL; + err = EMAIL_ERROR_INVALID_MAIL; goto FINISH_OFF; } - account_id = mail->account_id; - s_uid = mail->server_mail_id; - server_mbox = mail->server_mailbox_name; - mail->server_mail_id = NULL; - mail->server_mailbox_name = NULL; - - attachment.account_id = mail->account_id; - attachment.mail_id = mail->mail_id; - attachment.mailbox_name = mail->mailbox_name; mail->mailbox_name = NULL; + account_id = mail->account_id; + s_uid = mail->server_mail_id; + server_mbox = mail->server_mailbox_name; + mail->server_mail_id = NULL; + mail->server_mailbox_name = NULL; + + attachment.account_id = mail->account_id; + attachment.mail_id = mail->mail_id; + attachment.mailbox_id = mail->mailbox_id; attachment.attachment_save_status = 0; - + mailbox_id = mail->mailbox_id; emstorage_free_mail(&mail, 1, NULL); mail = NULL; if (!(ref_account = emcore_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } @@ -2791,9 +2685,9 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in /* open mail server. */ if (!mail_stream) { - if (!emcore_connect_to_remote_mailbox(account_id, mailbox_name, (void **)&tmp_stream, &err) || !tmp_stream) { + if (!emcore_connect_to_remote_mailbox(account_id, mailbox_id, (void **)&tmp_stream, &err) || !tmp_stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err); - status = EMF_DOWNLOAD_CONNECTION_FAIL; + status = EMAIL_DOWNLOAD_CONNECTION_FAIL; goto FINISH_OFF; } stream = (MAILSTREAM *)tmp_stream; @@ -2801,27 +2695,28 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in else stream = (MAILSTREAM *)mail_stream; - free(server_mbox); server_mbox = NULL; - + free(server_mbox); + server_mbox = NULL; FINISH_OFF_IF_CANCELED; if (!(cnt_info = em_malloc(sizeof(struct _m_content_info)))) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - if (ref_account->receiving_server_type == EMF_SERVER_TYPE_POP3) { /* POP3 */ + 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; attachment.attachment_save_status = 1; /* all attachments should be downloaded in the case of POP3 */ - mbox.account_id = account_id; - mbox.mail_stream = stream; + mailbox.account_id = account_id; + mailbox.mail_stream = stream; /* download all uids from server. */ - if (!emcore_download_uid_all(&mbox, &uid_list, NULL, NULL, 0, EM_CORE_GET_UIDS_FOR_NO_DELETE, &err)) { + if (!emcore_download_uid_all(&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; } @@ -2829,14 +2724,14 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in /* 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 = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; + err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER; goto FINISH_OFF; } free(s_uid); s_uid = NULL; if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -2846,8 +2741,7 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in _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)) - /* if (!emcore_mail_cmd_read_mail_pop3(stream, msgno, PARTIAL_BODY_SIZE_IN_BYTES, &pop3_downloaded_size, &pop3_body_size, &err)) */ { + 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; } @@ -2889,7 +2783,7 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in /* 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 = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; + err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER; goto FINISH_OFF; } @@ -2908,22 +2802,23 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in if (((body->id) && strlen(body->id) > 1) || (body->location)) is_attachment = 0; else if (body->disposition.type) { /* "attachment" or "inline" or etc... */ - PARAMETER *param = body->disposition.parameter; + PARAMETER *param = body->disposition.parameter; - while (param) { - EM_DEBUG_LOG("param->attribute [%s], param->value [%s]", param->attribute, param->value); + 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(">>>>> FILENAME [%s] ", filename); - break; + if (!strcasecmp(param->attribute, "filename")) { /* attribute is "filename" */ + strncpy(filename, param->value, MAX_PATH); + EM_DEBUG_LOG(">>>>> FILENAME [%s] ", filename); + break; + } + param = param->next; } - param = param->next; - } is_attachment = 1; - if (!*filename) { /* it may be report msg */ + if (!*filename) { + /* it may be report msg */ if (body->disposition.type[0] == 'i' || body->disposition.type[0] == 'I') is_attachment = 0; } @@ -2934,7 +2829,8 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in multi_part_body_size = multi_part_body_size + body->size.bytes; } } - else { /* download all */ + 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; } @@ -3026,10 +2922,10 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in mail->file_path_html = EM_SAFE_STRDUP(buf); } - if (ref_account->receiving_server_type == EMF_SERVER_TYPE_POP3 && limited_size != NO_LIMITATION && limited_size < pop3_body_size) - mail->body_download_status = EMF_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED; + if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 && limited_size != NO_LIMITATION && limited_size < pop3_body_size) + mail->body_download_status = EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED; else - mail->body_download_status = EMF_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED; + mail->body_download_status = EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED; #ifdef CHANGE_HTML_BODY_TO_ATTACHMENT if (html_changed) mail->flag2 = 1; @@ -3110,8 +3006,8 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in #ifdef __FEATURE_DRM__ if (emcore_check_drm(&attachment)) /* is drm content ?*/ { - if (!drm_svc_register_file(attachment.attachment_path)) - EM_DEBUG_EXCEPTION("drm_svc_register_file fail"); + if (drm_process_request(DRM_REQUEST_TYPE_REGISTER_FILE, attachment.attachment_path, NULL) != DRM_RETURN_SUCCESS) + EM_DEBUG_EXCEPTION("drm_process_request : register file fail"); mail->DRM_status = attachment.attachment_drm_type; } #endif/* __FEATURE_DRM__ */ @@ -3124,7 +3020,7 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in /* 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 == EMF_ERROR_ATTACHMENT_NOT_FOUND) { /* save only attachment file. */ + 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) @@ -3189,8 +3085,6 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in /* ROLLBACK TRANSACTION; */ emstorage_rollback_transaction(NULL, NULL, NULL); - - goto FINISH_OFF; } } @@ -3222,15 +3116,15 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in 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->receiving_server_type == EMF_SERVER_TYPE_POP3) { + 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_on_server) { - if (!emcore_delete_mail_from_server(&mbox, delmsg, &err)) - EM_DEBUG_EXCEPTION("emcore_delete_mail_from_server failed [%d]", err); + 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 @@ -3268,12 +3162,9 @@ FINISH_OFF: emcore_free_content_info(cnt_info); if (mail) emstorage_free_mail(&mail, 1, NULL); - if (attachment.mailbox_name) - free(attachment.mailbox_name); - if (server_mbox) - free(server_mbox); - if (s_uid) - free(s_uid); + EM_SAFE_FREE(server_mbox); + EM_SAFE_FREE(s_uid); + EM_SAFE_FREE(mailbox_name); multi_part_body_size = 0; @@ -3282,9 +3173,6 @@ FINISH_OFF: else emstorage_notify_network_event(NOTI_DOWNLOAD_BODY_FAIL, mail_id, NULL, event_handle, err); - if (mailbox_name) - free (mailbox_name); - if (err_code != NULL) *err_code = err; @@ -3321,310 +3209,222 @@ void emcore_mail_copyuid(MAILSTREAM *stream, char *mailbox, } } -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) +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) { - 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); + 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); - int ret = false; - int err = EMF_ERROR_NONE; - int status = EMF_DELETE_FAIL; - - emf_account_t *account = NULL; - emf_mailbox_t mailbox; - emstorage_mail_tbl_t *mail = NULL; - void *stream = NULL; - int mail_id = 0; - int i = 0; - int msgno = 0, parameter_string_length = 0; - char *parameter_string = NULL, mail_id_string[10]; - #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__ + int err = EMAIL_ERROR_NONE; + email_account_t *account = NULL; +#ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__ int bulk_flag = false; - #endif - - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); +#endif - if (!account_id || !mail_ids || !num) { - EM_DEBUG_EXCEPTION("account_id[%d], mail_ids[%p], num[%d], from_server[%d]", account_id, mail_ids, num, from_server); - err = EMF_ERROR_INVALID_PARAM; + if (!(account = emcore_get_account_reference(input_account_id))) { + EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", input_account_id); + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - mail_id = mail_ids[0]; - - if (!(account = emcore_get_account_reference(account_id))) { - EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + if (!emnetwork_check_network_status(&err)) { + EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err); goto FINISH_OFF; - } - if (account->receiving_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC) - from_server = EMF_DELETE_LOCALLY; + } FINISH_OFF_IF_CANCELED; - parameter_string_length = sizeof(char) * (num * 8 + 128 /* MAILBOX_LEN_IN_MAIL_TBL */ * 2); - parameter_string = malloc(parameter_string_length); - - if (parameter_string == NULL) { - EM_DEBUG_EXCEPTION("Memory allocation for mail_id_list_string failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; + 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)) { + 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; + goto FINISH_OFF; + } + else + bulk_flag = true; } - - memset(parameter_string, 0, parameter_string_length); - - if (from_server == EMF_DELETE_LOCAL_AND_SERVER || from_server == EMF_DELETE_FOR_SEND_THREAD) { /* server delete */ - for (i = 0; i < num; i++) { - mail_id = mail_ids[i]; - - if (!emstorage_get_downloaded_mail(mail_id, &mail, false, &err) || !mail) { - EM_DEBUG_EXCEPTION("emstorage_get_uid_by_mail_id failed [%d]", err); - - if (err == EMF_ERROR_MAIL_NOT_FOUND) { /* not server mail */ - /* err = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; */ - continue; - } - else - - - goto FINISH_OFF; - } - - EM_SAFE_FREE(mailbox.user_data); - - if (stream == NULL) { - if (!emcore_connect_to_remote_mailbox(account_id, mail->server_mailbox_name , (void **)&stream, &err)) { - EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err); - status = EMF_DELETE_CONNECTION_FAIL; - goto FINISH_OFF; - } - - mailbox.account_id = account_id; - mailbox.name = mail->server_mailbox_name; - mailbox.mail_stream = stream; - - FINISH_OFF_IF_CANCELED; - } - -#ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__ - if (account->receiving_server_type == EMF_SERVER_TYPE_IMAP4) { + 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)) { + EM_DEBUG_EXCEPTION("emcore_delete_mails_from_pop3_server falied [%d]", err); + goto FINISH_OFF; + } #ifdef __FEATURE_LOCAL_ACTIVITY__ - if (!bulk_flag && !imap4_mail_delete_ex(&mailbox, mail_ids, num, from_server, &err)) { -#else /* __FEATURE_LOCAL_ACTIVITY__ */ - if (!bulk_flag && !imap4_mail_delete_ex(&mailbox, mail_ids, num, &err)) { -#endif /* __FEATURE_LOCAL_ACTIVITY__ */ - EM_DEBUG_EXCEPTION("imap4_mail_delete_ex failed [%d]", err); - if (err == EMF_ERROR_IMAP4_STORE_FAILURE) - err = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; - goto FINISH_OFF; - } - else - bulk_flag = true; - + else { + /* Remove local activity */ + emstorage_activity_tbl_t new_activity; + memset(&new_activity, 0x00, sizeof(emstorage_activity_tbl_t)); + if (from_server == EMAIL_DELETE_FOR_SEND_THREAD) { + new_activity.activity_type = ACTIVITY_DELETEMAIL_SEND; + EM_DEBUG_LOG("from_server == EMAIL_DELETE_FOR_SEND_THREAD "); + } + else { + new_activity.activity_type = ACTIVITY_DELETEMAIL; } - else if (account->receiving_server_type == EMF_SERVER_TYPE_POP3) { - if (!emcore_get_mail_msgno_by_uid(account, &mailbox, mail->server_mail_id, &msgno, &err)) { - EM_DEBUG_EXCEPTION("emcore_get_mail_msgno_by_uid faild [%d]", err); - if (err == EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER) - goto NOT_FOUND_ON_SERVER; - else - goto FINISH_OFF; - } - - FINISH_OFF_IF_CANCELED; - - if (!emcore_delete_mail_from_server(account, &mailbox, msgno, &err)) { - EM_DEBUG_EXCEPTION("emcore_delete_mail_from_server falied [%d]", err); - goto FINISH_OFF; - } -#ifdef __FEATURE_LOCAL_ACTIVITY__ - else { - /* Remove local activity */ - emstorage_activity_tbl_t new_activity; - memset(&new_activity, 0x00, sizeof(emstorage_activity_tbl_t)); - if (from_server == EMF_DELETE_FOR_SEND_THREAD) { - new_activity.activity_type = ACTIVITY_DELETEMAIL_SEND; - EM_DEBUG_LOG("from_server == EMF_DELETE_FOR_SEND_THREAD "); - } - else { - new_activity.activity_type = ACTIVITY_DELETEMAIL; - } - - new_activity.mail_id = mail->mail_id; - new_activity.server_mailid = mail->server_mail_id; - new_activity.src_mbox = NULL; - new_activity.dest_mbox = NULL; - if (!emcore_delete_activity(&new_activity, &err)) { - EM_DEBUG_EXCEPTION(" emcore_delete_activity failed - %d ", err); - } - - /* Fix for issue - Sometimes mail move and immediately followed by mail delete is not reflected on server */ - if (!emstorage_remove_downloaded_mail(account_id, mail->server_mailbox_name, mail->server_mail_id, true, &err)) { - EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err); - } - } + new_activity.mail_id = mail->mail_id; + new_activity.server_mailid = mail->server_mail_id; + new_activity.src_mbox = NULL; + new_activity.dest_mbox = NULL; -#endif /* __FEATURE_LOCAL_ACTIVITY__ */ + if (!emcore_delete_activity(&new_activity, &err)) { + EM_DEBUG_EXCEPTION(" emcore_delete_activity failed - %d ", err); } -#else /* __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__ */ - if (!emcore_get_mail_msgno_by_uid(account, &mailbox, mail->server_mail_id, &msgno, &err)) { - EM_DEBUG_LOG("emcore_get_mail_msgno_by_uid faild [%d]", err); - if (err == EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER) /* Prevent Defect - 9561 */ - goto NOT_FOUND_ON_SERVER; - else - goto FINISH_OFF; + /* 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)) { + EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err); } + } - FINISH_OFF_IF_CANCELED; - - if (!emcore_delete_mail_from_server(account, &mailbox, msgno, &err)) { - EM_DEBUG_LOG("emcore_delete_mail_from_server falied [%d]", err); +#endif /* __FEATURE_LOCAL_ACTIVITY__ */ + } - goto FINISH_OFF; - } -#endif /* __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__ */ +FINISH_OFF: - if (!emstorage_remove_downloaded_mail(account_id, mail->server_mailbox_name, mail->server_mail_id, true, &err)) - EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err); + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} - /* emcore_delete_notification_for_read_mail(mail_id); */ +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) +{ + 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); -NOT_FOUND_ON_SERVER: - memset(mail_id_string, 0, 10); - SNPRINTF(mail_id_string, 10, "%d,", mail_id); - strcat(parameter_string, mail_id_string); + int ret = false; + int err = EMAIL_ERROR_NONE; + email_account_t *account = NULL; - FINISH_OFF_IF_CANCELED; - - emstorage_free_mail(&mail, 1, NULL); - } + if (!account_id || !mail_ids || !num) { + EM_DEBUG_EXCEPTION("account_id[%d], mail_ids[%p], num[%d], from_server[%d]", account_id, mail_ids, num, from_server); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; } - else if (from_server == EMF_DELETE_LOCALLY) /* Local Delete */ { - emcore_delete_mail_from_local_storage(account_id, mail_ids, num, noti_param_1, noti_param_2, err_code); - for (i = 0; i < num; i++) { - /* emcore_delete_notification_for_read_mail(mail_id); */ - SNPRINTF(mail_id_string, 10, "%d,", mail_id); - strcat(parameter_string, mail_id_string); - } - emcore_check_unread_mail(); + if (!(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; } - - ret = true; -FINISH_OFF: + if (account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) + from_server = EMAIL_DELETE_LOCALLY; - if (stream) { - emcore_close_mailbox(0, stream); - stream = NULL; - } + FINISH_OFF_IF_CANCELED; - if (mailbox.user_data != NULL) { - emcore_free_uids(mailbox.user_data, NULL); - mailbox.user_data = NULL; + 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_check_unread_mail(); + } + else { /* Delete mails from server*/ + emcore_delete_mails_from_remote_server(account_id, mail_ids, num, from_server); } - EM_SAFE_FREE(parameter_string); - - if (mail != NULL) - emstorage_free_mail(&mail, 1, NULL); + ret = true; +FINISH_OFF: if (from_server) - emcore_show_popup(account_id, EMF_ACTION_DELETE_MAIL, ret == true ? 0 : err); + emcore_show_user_message(account_id, EMAIL_ACTION_DELETE_MAIL, ret == true ? 0 : err); if (err_code != NULL) *err_code = err; + EM_DEBUG_FUNC_END("err [%d]", err); + return ret; } - -int emcore_delete_mail_all(emf_mailbox_t *mailbox, int with_server, int *err_code) +int emcore_delete_all_mails_of_acount(int input_account_id) { - EM_DEBUG_FUNC_BEGIN("mailbox [%p], with_server [%d], err_code [%p]", mailbox, with_server, err_code); + EM_DEBUG_FUNC_BEGIN("input_account_id [%d]"); - int ret = false; - int err = EMF_ERROR_NONE; - int search_handle = 0; - int *mail_ids = NULL; - int i = 0; - int total = 0; + int err = EMAIL_ERROR_NONE; char buf[512] = { 0, }; - if (!mailbox || mailbox->account_id < FIRST_ACCOUNT_ID) { - err = EMF_ERROR_INVALID_PARAM; + /* emstorage_delete_mail_by_account is available only locally */ + if (!emstorage_delete_mail_by_account(input_account_id, false, &err)) { + EM_DEBUG_EXCEPTION("emstorage_delete_mail_by_account failed [%d]", err); goto FINISH_OFF; } - if (mailbox->name != NULL) { - /* Delete all mails in specific mailbox */ - if (!emstorage_mail_search_start(NULL, mailbox->account_id, mailbox->name, 0, &search_handle, &total, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_mail_search_start failed [%d]", err); - - goto FINISH_OFF; - } + if (!emstorage_delete_attachment_all_on_db(input_account_id, NULL, false, &err)) { + EM_DEBUG_EXCEPTION("emstorage_delete_attachment_all_on_db failed [%d]", err); + goto FINISH_OFF; + } - EM_DEBUG_LOG("emstorage_mail_search_start returns [%d]", total); + /* delete mail contents from filesystem */ + if (!emstorage_get_save_name(input_account_id, 0, 0, NULL, buf, &err)) { + EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err); + goto FINISH_OFF; + } - if (total > 0) { - mail_ids = em_malloc(sizeof(int) * total); - if (mail_ids == NULL) { - EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } + if (!emstorage_delete_dir(buf, &err)) { + EM_DEBUG_EXCEPTION("emstorage_delete_dir failed [%d]", err); + } - for (i = 0; i < total; i++) { - if (!emstorage_mail_search_result(search_handle, RETRIEVE_ID, (void**)&mail_ids[i], true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_mail_search_result failed [%d]", err); + /* delete meeting request */ + if (!emstorage_delete_meeting_request(input_account_id, 0, 0, false, &err)) { + EM_DEBUG_EXCEPTION("emstorage_delete_attachment_all_on_db failed [%d]", err); + goto FINISH_OFF; + } - goto FINISH_OFF; - } - } + emcore_check_unread_mail(); - if (!emcore_delete_mail(mailbox->account_id, mail_ids, total, with_server, EMF_DELETED_BY_COMMAND, false, &err)) { - EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err); - goto FINISH_OFF; - } - } - } - else if (with_server == EMF_DELETE_LOCALLY){ - /* emstorage_delete_mail_by_account is available only locally */ - if (!emstorage_delete_mail_by_account(mailbox->account_id, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_delete_mail_by_account failed [%d]", err); +FINISH_OFF: + EM_DEBUG_FUNC_END("err [%d]",err); + return err; +} - goto FINISH_OFF; - } +int emcore_delete_all_mails_of_mailbox(int input_mailbox_id, int input_from_server, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_from_server [%d], err_code [%p]", input_mailbox_id, input_from_server, err_code); - if (!emstorage_delete_attachment_all_on_db(mailbox->account_id, NULL, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_delete_attachment_all_on_db failed [%d]", err); + int ret = false; + int err = EMAIL_ERROR_NONE; + int search_handle = 0; + int *mail_ids = NULL; + int i = 0; + int total = 0; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; - goto FINISH_OFF; - } + if (!input_mailbox_id) { + err = EMAIL_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + goto FINISH_OFF; + } - /* delete mail contents from filesystem */ - if (!emstorage_get_save_name(mailbox->account_id, 0, 0, NULL, buf, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err); + if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl) != EMAIL_ERROR_NONE)) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err); + goto FINISH_OFF; + } + /* Delete all mails in specific mailbox */ + if (!emstorage_mail_search_start(NULL, mailbox_tbl->account_id, mailbox_tbl->mailbox_name, 0, &search_handle, &total, true, &err)) { + EM_DEBUG_EXCEPTION("emstorage_mail_search_start failed [%d]", err); + + goto FINISH_OFF; + } + + EM_DEBUG_LOG("emstorage_mail_search_start returns [%d]", total); + if (total > 0) { + mail_ids = em_malloc(sizeof(int) * total); + if (mail_ids == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed..."); + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - if (!emstorage_delete_dir(buf, &err)) { - EM_DEBUG_EXCEPTION("emstorage_delete_dir failed [%d]", err); + for (i = 0; i < total; i++) { + if (!emstorage_mail_search_result(search_handle, RETRIEVE_ID, (void**)&mail_ids[i], true, &err)) { + EM_DEBUG_EXCEPTION("emstorage_mail_search_result failed [%d]", err); + goto FINISH_OFF; + } } - /* delete meeting request */ - if (!emstorage_delete_meeting_request(mailbox->account_id, 0, NULL, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_delete_attachment_all_on_db failed [%d]", err); - + if (!emcore_delete_mail(mailbox_tbl->account_id, mail_ids, total, input_from_server, EMAIL_DELETED_BY_COMMAND, false, &err)) { + EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err); goto FINISH_OFF; } - - emcore_check_unread_mail(); } ret = true; @@ -3635,6 +3435,9 @@ FINISH_OFF: EM_DEBUG_EXCEPTION("emstorage_mail_search_end failed [%d]", err); } + if (mailbox_tbl) + emstorage_free_mailbox(&mailbox_tbl, 1, NULL); + EM_SAFE_FREE(mail_ids); if (err_code != NULL) *err_code = err; @@ -3642,15 +3445,14 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_delete_mail_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(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 = EMF_ERROR_NONE, i; + int ret = false, err = EMAIL_ERROR_NONE, i; emstorage_mail_tbl_t *result_mail_list; char mail_id_string[10], *noti_param_string = NULL, 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) { EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_multiple_mail_id failed [%d]", err); goto FINISH_OFF; @@ -3667,7 +3469,7 @@ INTERNAL_FUNC int emcore_delete_mail_from_local_storage(int account_id, int *mai if(!noti_param_string) { EM_DEBUG_EXCEPTION("em_malloc failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -3697,10 +3499,10 @@ INTERNAL_FUNC int emcore_delete_mail_from_local_storage(int account_id, int *mai for(i = 0; i < num; i++) { /* Deleting attachments */ - if (!emstorage_delete_attachment_on_db(result_mail_list[i].mail_id, 0, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_delete_attachment_on_db failed [%d]", err); - if (err == EMF_ERROR_ATTACHMENT_NOT_FOUND) - err = EMF_ERROR_NONE; + if (!emstorage_delete_all_attachments_of_mail(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; } /* Deleting Directories */ @@ -3717,9 +3519,9 @@ INTERNAL_FUNC int emcore_delete_mail_from_local_storage(int account_id, int *mai } /* Deleting Meeting Request */ - if (!emstorage_delete_meeting_request(account_id, result_mail_list[i].mail_id, NULL, false, &err)) { + if (!emstorage_delete_meeting_request(account_id, result_mail_list[i].mail_id, 0, false, &err)) { EM_DEBUG_EXCEPTION("emstorage_delete_meeting_request failed [%d]", err); - if (err != EMF_ERROR_CONTACT_NOT_FOUND) { + if (err != EMAIL_ERROR_CONTACT_NOT_FOUND) { goto FINISH_OFF; } } @@ -3737,74 +3539,125 @@ FINISH_OFF: return ret; } -int emcore_delete_mail_from_server(emf_account_t *account, emf_mailbox_t *mailbox, int msgno, int *err_code) +static int emcore_delete_mails_from_pop3_server(email_account_t *input_account, int input_mail_ids[], int input_mail_id_count) { - EM_DEBUG_FUNC_BEGIN("account[%p], mailbox[%p], msgno[%d], err_code[%p]", account, mailbox, msgno, err_code); + 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); - int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + int i = 0; + int mail_id = 0; + int msgno = 0; + void *stream = NULL; + email_internal_mailbox_t mailbox_data; + emstorage_mail_tbl_t *mail_tbl_data = NULL; - if (!account || !mailbox) { - EM_DEBUG_EXCEPTION("account[%p], mailbox[%p], msgno[%d]", account, mailbox, msgno); - - err = EMF_ERROR_INVALID_PARAM; + if (!input_account || !input_mail_ids) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (account->receiving_server_type == EMF_SERVER_TYPE_POP3) { - if (!pop3_mail_delete(mailbox->mail_stream, msgno, &err)) { - EM_DEBUG_EXCEPTION("pop3_mail_delete failed [%d]", err); + for (i = 0; i < input_mail_id_count; i++) { + FINISH_OFF_IF_CANCELED; - if (err == EMF_ERROR_POP3_DELE_FAILURE) - err = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; - goto FINISH_OFF; + mail_id = input_mail_ids[i]; + + if (!emstorage_get_downloaded_mail(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; + } + else + goto FINISH_OFF; + } + + if (stream == NULL) { + if (!emcore_connect_to_remote_mailbox(input_account->account_id, mail_tbl_data->mailbox_id , (void **)&stream, &err)) { + EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err); + goto FINISH_OFF; + } + + mailbox_data.mail_stream = stream; + mailbox_data.account_id = input_account->account_id; + mailbox_data.mailbox_id = mail_tbl_data->mailbox_id; + } + + if (mailbox_data.user_data != NULL) { + emcore_free_uids(mailbox_data.user_data, NULL); + mailbox_data.user_data = NULL; } - } - else { /* EMF_SERVER_TYPE_IMAP4 */ - if (!imap4_mail_delete(mailbox->mail_stream, msgno, &err)) { - EM_DEBUG_EXCEPTION("imap4_mail_delete failed [%d]", err); - if (err == EMF_ERROR_IMAP4_STORE_FAILURE) - err = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; + if (!emcore_get_mail_msgno_by_uid(input_account, &mailbox_data, mail_tbl_data->server_mail_id, &msgno, &err)) { + EM_DEBUG_EXCEPTION("emcore_get_mail_msgno_by_uid faild [%d]", err); + if (err == EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER) + goto NOT_FOUND_ON_SERVER; + else + goto FINISH_OFF; + } + + if (!pop3_mail_delete(mailbox_data.mail_stream, msgno, &err)) { + EM_DEBUG_EXCEPTION("pop3_mail_delete failed [%d]", err); + + if (err == EMAIL_ERROR_POP3_DELE_FAILURE) + err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER; 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)) + EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err); + +NOT_FOUND_ON_SERVER : + + if (mail_tbl_data != NULL) + emstorage_free_mail(&mail_tbl_data, 1, NULL); } - - ret = true; FINISH_OFF: - if (err_code) - *err_code = err; - EM_DEBUG_FUNC_END(); - return ret; + + if (mail_tbl_data != NULL) + emstorage_free_mail(&mail_tbl_data, 1, NULL); + + if (stream) { + emcore_close_mailbox(0, stream); + stream = NULL; + } + + if (mailbox_data.user_data != NULL) { + emcore_free_uids(mailbox_data.user_data, NULL); + mailbox_data.user_data = NULL; + } + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; } -INTERNAL_FUNC int emcore_get_mail_msgno_by_uid(emf_account_t *account, emf_mailbox_t *mailbox, char *uid, int *msgno, 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) { EM_DEBUG_FUNC_BEGIN("account[%p], mailbox[%p], uid[%s], msgno[%p], err_code[%p]", account, mailbox, uid, msgno, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emcore_uid_list *uid_list = NULL; emcore_uid_list *pTemp_uid_list = NULL; if (!account || !mailbox || !uid || !msgno) { EM_DEBUG_EXCEPTION("account[%p], mailbox[%p], uid[%s], msgno[%p]", account, mailbox, uid, msgno); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } uid_list = mailbox->user_data; if (uid_list == NULL) { - if (account->receiving_server_type == EMF_SERVER_TYPE_POP3) { + if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) { if (!pop3_mailbox_get_uids(mailbox->mail_stream, &uid_list, &err)) { EM_DEBUG_EXCEPTION("pop3_mailbox_get_uids failed [%d]", err); goto FINISH_OFF; } } - else { /* EMF_SERVER_TYPE_IMAP4 */ + else { /* EMAIL_SERVER_TYPE_IMAP4 */ if (!imap4_mailbox_get_uids(mailbox->mail_stream, &uid_list, &err)) { EM_DEBUG_EXCEPTION("imap4_mailbox_get_uids failed [%d]", err); goto FINISH_OFF; @@ -3824,7 +3677,7 @@ INTERNAL_FUNC int emcore_get_mail_msgno_by_uid(emf_account_t *account, emf_mailb uid_list = uid_list->next; } - err = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; + err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER; FINISH_OFF: if (err_code != NULL) @@ -3840,6 +3693,149 @@ FINISH_OFF: return ret; } +INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(int input_mailbox_id) +{ + EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d]", input_mailbox_id); + int err = EMAIL_ERROR_NONE; + char *conditional_clause_string = NULL; + email_list_filter_t *filter_list = NULL; + int filter_count = 0; + int *result_mail_id_list = NULL; + int result_count = 0; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; + + if ( input_mailbox_id <= 0) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err); + goto FINISH_OFF; + } + + filter_count = 3; + + filter_list = em_malloc(sizeof(email_list_filter_t) * filter_count); + + if (filter_list == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_ID; + filter_list[0].list_filter_item.rule.key_value.integer_type_value = input_mailbox_id; + + filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_AND; + + filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + 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) { + 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) { + 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)) { + EM_DEBUG_EXCEPTION("emcore_delete_mails_from_local_storage [%d]", err); + goto FINISH_OFF; + } + +FINISH_OFF: + + if(mailbox_tbl) + emstorage_free_mailbox(&mailbox_tbl, 1, NULL); + + if(filter_list) + emstorage_free_list_filter(&filter_list, filter_count); + + EM_SAFE_FREE(result_mail_id_list); + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(int input_account_id, int input_mailbox_id) +{ + int err = EMAIL_ERROR_NONE; + char *conditional_clause_string = NULL; + email_list_filter_t *filter_list = NULL; + int filter_count = 0; + int *result_mail_id_list = NULL; + int result_count = 0; + + if ( input_mailbox_id <= 0) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + filter_count = 3; + + filter_list = em_malloc(sizeof(email_list_filter_t) * filter_count); + + if (filter_list == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_ID; + filter_list[0].list_filter_item.rule.key_value.integer_type_value = input_mailbox_id; + + filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_AND; + + filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + 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) { + 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) { + 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)) { + EM_DEBUG_EXCEPTION("emcore_delete_mail [%d]", err); + goto FINISH_OFF; + } + +FINISH_OFF: + + if(filter_list) + emstorage_free_list_filter(&filter_list, filter_count); + + EM_SAFE_FREE(result_mail_id_list); + + EM_DEBUG_FUNC_END("err [%d]", err); + + return err; +} + /* description * add a attachment to mail. * arguments @@ -3850,18 +3846,18 @@ FINISH_OFF: * succeed : 1 * fail : 0 */ -INTERNAL_FUNC int emcore_mail_add_attachment(int mail_id, emf_attachment_info_t *attachment, int *err_code) +INTERNAL_FUNC int emcore_mail_add_attachment(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); if (attachment == NULL) { EM_DEBUG_EXCEPTION("mail_id[%d], attachment[%p]", mail_id, attachment); if (err_code) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - int ret = false, err = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; emstorage_mail_tbl_t *mail_table_data = NULL; int attachment_id = 0; @@ -3880,13 +3876,13 @@ INTERNAL_FUNC int emcore_mail_add_attachment(int mail_id, emf_attachment_info_t mail_table_data->attachment_count = mail_table_data->attachment_count + 1; attachment_tbl.account_id = mail_table_data->account_id; - attachment_tbl.mailbox_name = mail_table_data->mailbox_name; + attachment_tbl.mailbox_id = mail_table_data->mailbox_id; attachment_tbl.mail_id = mail_id; - attachment_tbl.attachment_name = attachment->name; - attachment_tbl.attachment_size = attachment->size; - attachment_tbl.attachment_save_status = attachment->downloaded; - attachment_tbl.attachment_drm_type = attachment->drm; - attachment_tbl.attachment_inline_content_status = attachment->inline_content; + attachment_tbl.attachment_name = attachment->attachment_name; + attachment_tbl.attachment_size = attachment->attachment_size; + attachment_tbl.attachment_save_status = attachment->save_status; + attachment_tbl.attachment_drm_type = attachment->drm_status; + attachment_tbl.attachment_inline_content_status = attachment->inline_content_status; /* BEGIN TRANSACTION; */ emstorage_begin_transaction(NULL, NULL, NULL); @@ -3899,10 +3895,10 @@ INTERNAL_FUNC int emcore_mail_add_attachment(int mail_id, emf_attachment_info_t attachment->attachment_id = attachment_tbl.attachment_id; - if (attachment->savename) { + if (attachment->attachment_path) { char buf[512]; - if (!attachment->inline_content) { + if (!attachment->inline_content_status) { if (!emstorage_create_dir(account_id, mail_id, attachment_tbl.attachment_id, &err)) { EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err); goto FINISH_OFF; @@ -3910,7 +3906,7 @@ INTERNAL_FUNC int emcore_mail_add_attachment(int mail_id, emf_attachment_info_t attachment_id = attachment_tbl.attachment_id; } - if (!emstorage_get_save_name(account_id, mail_id, attachment_id, attachment->name, buf, &err)) { + if (!emstorage_get_save_name(account_id, mail_id, attachment_id, attachment->attachment_name, buf, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err); goto FINISH_OFF; } @@ -3928,8 +3924,8 @@ INTERNAL_FUNC int emcore_mail_add_attachment(int mail_id, emf_attachment_info_t goto FINISH_OFF; } - if (attachment->downloaded) { - if (!emstorage_move_file(attachment->savename, buf, false, &err)) { + if (attachment->save_status) { + if (!emstorage_move_file(attachment->attachment_path, buf, false, &err)) { EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err); goto FINISH_OFF; @@ -3944,8 +3940,8 @@ INTERNAL_FUNC int emcore_mail_add_attachment(int mail_id, emf_attachment_info_t goto FINISH_OFF; } - EM_SAFE_FREE(attachment->savename); - attachment->savename = EM_SAFE_STRDUP(buf); + EM_SAFE_FREE(attachment->attachment_path); + attachment->attachment_path = EM_SAFE_STRDUP(buf); } ret = true; @@ -3953,13 +3949,13 @@ INTERNAL_FUNC int emcore_mail_add_attachment(int mail_id, emf_attachment_info_t FINISH_OFF: if (ret == true) { /* COMMIT TRANSACTION; */ if (emstorage_commit_transaction(NULL, NULL, NULL) == false) { - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; ret = false; } } else { /* ROLLBACK TRANSACTION; */ if (emstorage_rollback_transaction(NULL, NULL, NULL) == false) - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; } FINISH_OFF2: @@ -3973,19 +3969,19 @@ FINISH_OFF2: } -INTERNAL_FUNC int emcore_mail_add_attachment_data(int input_mail_id, emf_attachment_data_t *input_attachment_data) +INTERNAL_FUNC int emcore_mail_add_attachment_data(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 = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int attachment_id = 0; char buf[512] = { 0, }; emstorage_mail_tbl_t *mail_table_data = NULL; emstorage_attachment_tbl_t attachment_tbl = { 0 }; if (input_attachment_data == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + 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) { @@ -3997,7 +3993,7 @@ INTERNAL_FUNC int emcore_mail_add_attachment_data(int input_mail_id, emf_attachm mail_table_data->attachment_count = mail_table_data->attachment_count + 1; attachment_tbl.account_id = mail_table_data->account_id; - attachment_tbl.mailbox_name = mail_table_data->mailbox_name; + attachment_tbl.mailbox_id = mail_table_data->mailbox_id; attachment_tbl.mail_id = input_mail_id; attachment_tbl.attachment_name = input_attachment_data->attachment_name; attachment_tbl.attachment_size = input_attachment_data->attachment_size; @@ -4064,14 +4060,14 @@ INTERNAL_FUNC int emcore_mail_add_attachment_data(int input_mail_id, emf_attachm } FINISH_OFF: - if (err == EMF_ERROR_NONE) { /* COMMIT TRANSACTION; */ + if (err == EMAIL_ERROR_NONE) { /* COMMIT TRANSACTION; */ if (emstorage_commit_transaction(NULL, NULL, NULL) == false) { - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; } } else { /* ROLLBACK TRANSACTION; */ if (emstorage_rollback_transaction(NULL, NULL, NULL) == false) - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; } FINISH_OFF2: @@ -4094,25 +4090,24 @@ FINISH_OFF2: * succeed : 1 * fail : 0 */ -int emcore_delete_mail_attachment(int mail_id, char *attachment_id_string, int *err_code) +int emcore_delete_mail_attachment(int attachment_id, int *err_code) { - EM_DEBUG_FUNC_BEGIN("mail_id[%d], attachment_id_string[%s], err_code[%p]", mail_id, attachment_id_string, err_code); + EM_DEBUG_FUNC_BEGIN("attachment_id[%d], err_code[%p]", attachment_id, err_code); - if (attachment_id_string == NULL) { - EM_DEBUG_EXCEPTION("mail_id[%d], attachment_id[%p]", mail_id, attachment_id_string); + if (attachment_id == 0) { + EM_DEBUG_EXCEPTION("attachment_id[%d]", attachment_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; - int attachment_id = atoi(attachment_id_string); + int error = EMAIL_ERROR_NONE; /* BEGIN TRANSACTION; */ emstorage_begin_transaction(NULL, NULL, NULL); - if (!emstorage_delete_attachment_on_db(mail_id, attachment_id, false, &error)) { + if (!emstorage_delete_attachment_on_db(attachment_id, false, &error)) { EM_DEBUG_EXCEPTION("emstorage_delete_attachment_on_db failed [%d]", error); goto FINISH_OFF; } @@ -4122,13 +4117,13 @@ int emcore_delete_mail_attachment(int mail_id, char *attachment_id_string, in FINISH_OFF: if (ret == true) { /* COMMIT TRANSACTION; */ if (emstorage_commit_transaction(NULL, NULL, NULL) == false) { - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; ret = false; } } else { /* ROLLBACK TRANSACTION; */ if (emstorage_rollback_transaction(NULL, NULL, NULL) == false) - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } if (err_code != NULL) @@ -4137,11 +4132,11 @@ FINISH_OFF: return ret; } -static int emcore_mail_update_attachment_data(int input_mail_id, emf_attachment_data_t *input_attachment_data) +static int emcore_mail_update_attachment_data(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 = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int attachment_id = 0; char buf[512] = { 0 , }; emstorage_attachment_tbl_t *existing_attachment_info = NULL; @@ -4149,11 +4144,11 @@ static int emcore_mail_update_attachment_data(int input_mail_id, emf_attachment_ if (input_attachment_data == NULL) { EM_DEBUG_EXCEPTION("Invalid Parameter"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF2; } - if (!emstorage_get_attachment(input_mail_id, input_attachment_data->attachment_id, &existing_attachment_info, 1, &err)) { + if (!emstorage_get_attachment(input_attachment_data->attachment_id, &existing_attachment_info, 1, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_attachment failed [%d]", err); goto FINISH_OFF2; @@ -4161,12 +4156,12 @@ static int emcore_mail_update_attachment_data(int input_mail_id, emf_attachment_ attachment_tbl.mail_id = input_mail_id; attachment_tbl.account_id = existing_attachment_info->account_id; - attachment_tbl.mailbox_name = existing_attachment_info->mailbox_name; + attachment_tbl.mailbox_id = existing_attachment_info->mailbox_id; attachment_tbl.attachment_name = input_attachment_data->attachment_name; attachment_tbl.attachment_size = input_attachment_data->attachment_size; attachment_tbl.attachment_path = input_attachment_data->attachment_path; attachment_tbl.attachment_save_status = input_attachment_data->save_status; - attachment_tbl.attachment_drm_type = input_attachment_data->drm_status; + attachment_tbl.attachment_drm_type = input_attachment_data->drm_status; attachment_tbl.attachment_inline_content_status = input_attachment_data->inline_content_status; attachment_tbl.attachment_id = input_attachment_data->attachment_id; @@ -4207,14 +4202,14 @@ static int emcore_mail_update_attachment_data(int input_mail_id, emf_attachment_ } FINISH_OFF: - if (err == EMF_ERROR_NONE) { /* COMMIT TRANSACTION; */ + if (err == EMAIL_ERROR_NONE) { /* COMMIT TRANSACTION; */ if (emstorage_commit_transaction(NULL, NULL, NULL) == false) { - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; } } else { /* ROLLBACK TRANSACTION; */ if (emstorage_rollback_transaction(NULL, NULL, NULL) == false) - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; } FINISH_OFF2: @@ -4226,17 +4221,17 @@ FINISH_OFF2: } -static int emcore_mail_compare_filename_of_attachment_data(int input_mail_id, int input_attachment_a_id, emf_attachment_data_t *input_attachment_b_data, int *result) +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) { 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); EM_IF_NULL_RETURN_VALUE(input_attachment_b_data, false); EM_IF_NULL_RETURN_VALUE(result, false); - int err, err_2, ret = EMF_ERROR_NONE; + int err, err_2, ret = EMAIL_ERROR_NONE; emstorage_attachment_tbl_t *attachment_a_tbl = NULL; - if (!emstorage_get_attachment(input_mail_id, input_attachment_a_id, &attachment_a_tbl, 1, &err)) { + if (!emstorage_get_attachment(input_attachment_a_id, &attachment_a_tbl, 1, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_attachment failed [%d]", err); goto FINISH_OFF; @@ -4268,17 +4263,17 @@ FINISH_OFF: * succeed : 1 * fail : 0 */ -INTERNAL_FUNC int emcore_mail_copy(int mail_id, emf_mailbox_t *dst_mailbox, int *err_code) +INTERNAL_FUNC int emcore_mail_copy(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); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int i; emstorage_mail_tbl_t *mail = NULL; emstorage_attachment_tbl_t *atch_list = NULL; char buf[512]; - int count = EMF_ATTACHMENT_MAX_COUNT; + int count = EMAIL_ATTACHMENT_MAX_COUNT; char *mailbox_name = NULL; if (!emstorage_get_mail_by_id(mail_id, &mail, true, &err) || !mail) { @@ -4287,7 +4282,7 @@ INTERNAL_FUNC int emcore_mail_copy(int mail_id, emf_mailbox_t *dst_mailbox, int goto FINISH_OFF; } - if ( (err = emstorage_get_attachment_list(mail_id, true, &atch_list, &count)) != EMF_ERROR_NONE ){ + if ( (err = emstorage_get_attachment_list(mail_id, true, &atch_list, &count)) != EMAIL_ERROR_NONE ){ EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err); goto FINISH_OFF; @@ -4364,7 +4359,7 @@ INTERNAL_FUNC int emcore_mail_copy(int mail_id, emf_mailbox_t *dst_mailbox, int mail->account_id = dst_mailbox->account_id; mail->mailbox_id = dst_mailbox->mailbox_id; - mail->mailbox_name = EM_SAFE_STRDUP(dst_mailbox->name); + mail->mailbox_name = EM_SAFE_STRDUP(dst_mailbox->mailbox_name); mail->mailbox_type = dst_mailbox->mailbox_type; if (!emstorage_add_mail(mail, 0, false, &err)) { @@ -4417,10 +4412,7 @@ INTERNAL_FUNC int emcore_mail_copy(int mail_id, emf_mailbox_t *dst_mailbox, int atch_list[i].account_id = dst_mailbox->account_id; atch_list[i].mail_id = mail->mail_id; - - EM_SAFE_FREE(atch_list[i].mailbox_name); - - atch_list[i].mailbox_name = EM_SAFE_STRDUP(mail->mailbox_name); + atch_list[i].mailbox_id = mail->mailbox_id; if (!emstorage_add_attachment(&atch_list[i], 0, false, &err)) { EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err); @@ -4463,18 +4455,18 @@ INTERNAL_FUNC int emcore_mail_copy(int mail_id, emf_mailbox_t *dst_mailbox, int } if (emstorage_commit_transaction(NULL, NULL, NULL) == false) { - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; if (emstorage_rollback_transaction(NULL, NULL, NULL) == false) - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; } - if (!emstorage_get_mailboxname_by_mailbox_type(dst_mailbox->account_id, EMF_MAILBOX_TYPE_INBOX, &mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); + if (!emstorage_get_mailbox_name_by_mailbox_type(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->name, mailbox_name) && !(mail->flags_seen_field)) + if (!strcmp(dst_mailbox->mailbox_name, mailbox_name) && !(mail->flags_seen_field)) emcore_check_unread_mail(); ret = true; @@ -4504,21 +4496,20 @@ FINISH_OFF: * succeed : 1 * fail : 0 */ -INTERNAL_FUNC int emcore_mail_move(int mail_ids[], int mail_ids_count, char *dst_mailbox_name, int noti_param_1, int noti_param_2 ,int *err_code) +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) { - EM_DEBUG_FUNC_BEGIN("mail_ids[%p], mail_ids_count[%d], dst_mailbox_name[%s], noti_param [%d], err_code[%p]", mail_ids, mail_ids_count, dst_mailbox_name, noti_param_1, 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); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_mail_tbl_t *mail_list = NULL; int account_id = 0; int i = 0, parameter_string_length = 0; char *parameter_string = NULL, mail_id_string[10]; - emstorage_attachment_tbl_t attachment; - if (!dst_mailbox_name && mail_ids_count < 1) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if ( dst_mailbox_id <= 0 && mail_ids_count < 1) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -4530,7 +4521,7 @@ INTERNAL_FUNC int emcore_mail_move(int mail_ids[], int mail_ids_count, char *dst account_id = mail_list[0].account_id; - if(!emstorage_move_multiple_mails(account_id, dst_mailbox_name, mail_ids, mail_ids_count, true, &err)) { + if(!emstorage_move_multiple_mails(account_id, dst_mailbox_id, mail_ids, mail_ids_count, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_move_multiple_mails failed [%d]", err); goto FINISH_OFF; } @@ -4539,12 +4530,12 @@ INTERNAL_FUNC int emcore_mail_move(int mail_ids[], int mail_ids_count, char *dst parameter_string_length = sizeof(char) * (mail_ids_count * 10 + 128/*MAILBOX_LEN_IN_MAIL_TBL*/ * 2); parameter_string = em_malloc(parameter_string_length); - if (mail_list[0].mailbox_name) - SNPRINTF(parameter_string, parameter_string_length, "%s%c%s%c", mail_list[0].mailbox_name, 0x01, dst_mailbox_name , 0x01); + if (mail_list[0].mailbox_id > 0) + SNPRINTF(parameter_string, parameter_string_length, "%d%c%d%c", mail_list[0].mailbox_id, 0x01, dst_mailbox_id , 0x01); if (parameter_string == NULL) { EM_DEBUG_EXCEPTION("Memory allocation for mail_id_list_string failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -4559,8 +4550,6 @@ INTERNAL_FUNC int emcore_mail_move(int mail_ids[], int mail_ids_count, char *dst if (!emstorage_notify_storage_event(NOTI_MAIL_MOVE, account_id, noti_param_1, parameter_string, noti_param_2)) EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event failed [NOTI_MAIL_MOVE] >>>> "); - /* Upating thread mail info should be done as soon as possible */ - attachment.mailbox_name = dst_mailbox_name; for (i = 0; i < mail_ids_count; i++) { if (!emstorage_update_latest_thread_mail(account_id, mail_list[i].thread_id, 0, 0, true, &err)) @@ -4584,12 +4573,12 @@ FINISH_OFF: } -INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, char *src_mailbox, int mail_ids[], int num, char *dest_mailbox, int *error_code) +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) { EM_DEBUG_FUNC_BEGIN(); MAILSTREAM *stream = NULL; int err_code = 0; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; emstorage_mail_tbl_t *mail = NULL; int ret = 1; int mail_id = 0; @@ -4600,15 +4589,14 @@ INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, char *src_mailbox, ref_account = emcore_get_account_reference(account_id); if (!ref_account) { EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed : get account reference[%d]", account_id); - *error_code = EMF_ERROR_INVALID_ACCOUNT; + *error_code = EMAIL_ERROR_INVALID_ACCOUNT; ret = 0; goto FINISH_OFF; } - /* if not imap4 mail, return */ - if (ref_account->account_bind_type != EMF_BIND_TYPE_EM_CORE || - ref_account->receiving_server_type != EMF_SERVER_TYPE_IMAP4) { - *error_code = EMF_ERROR_INVALID_PARAM; + /* if not imap4 mail, return */ + if (ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) { + *error_code = EMAIL_ERROR_INVALID_PARAM; ret = 0; goto FINISH_OFF; } @@ -4619,8 +4607,8 @@ INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, char *src_mailbox, if (!emstorage_get_mail_by_id(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 == EMF_ERROR_MAIL_NOT_FOUND) { /* not server mail */ - /* err = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; */ + if (err_code == EMAIL_ERROR_MAIL_NOT_FOUND) { /* not server mail */ + /* err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER; */ /* continue; */ } else { @@ -4631,7 +4619,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, char *src_mailbox, goto FINISH_OFF; } - if (!emcore_connect_to_remote_mailbox(account_id, src_mailbox, (void **)&stream, &err_code)) /* faizan.h@samsung.com mail_move_fix_07042009 */ { + if (!emcore_connect_to_remote_mailbox(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; @@ -4654,8 +4642,8 @@ INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, char *src_mailbox, if (!imap4_send_command(stream, IMAP4_CMD_EXPUNGE, &err_code)) { EM_DEBUG_EXCEPTION("imap4_send_command failed [%d]", err_code); - if (err_code == EMF_ERROR_IMAP4_STORE_FAILURE) - err_code = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; + if (err_code == EMAIL_ERROR_IMAP4_STORE_FAILURE) + err_code = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER; goto FINISH_OFF; } @@ -4697,11 +4685,11 @@ static int emcore_save_mail_file(int account_id, int mail_id, int attachment_id, { 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 ret = false, err = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; if (!file_name || !full_path || !src_file_path) { EM_DEBUG_EXCEPTION("Invalid paramter"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -4734,21 +4722,21 @@ FINISH_OFF: /* description * update mail information */ -INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas) +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) { 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, }; int i = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int local_inline_content_count = 0; emstorage_mail_tbl_t *converted_mail_tbl_data = NULL; - emf_meeting_request_t *meeting_req = NULL; + email_meeting_request_t *meeting_req = NULL; struct stat st_buf; if (!input_mail_data || (input_attachment_count && !input_attachment_data_list) || (!input_attachment_count &&input_attachment_data_list)) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF2; } @@ -4756,7 +4744,7 @@ INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attac if (input_mail_data->file_path_plain) { if (stat(input_mail_data->file_path_plain, &st_buf) < 0) { EM_DEBUG_EXCEPTION("input_mail_data->file_path_plain, stat(\"%s\") failed...", input_mail_data->file_path_plain); - err = EMF_ERROR_INVALID_MAIL; + err = EMAIL_ERROR_INVALID_MAIL; goto FINISH_OFF; } } @@ -4764,7 +4752,7 @@ INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attac if (input_mail_data->file_path_html) { if (stat(input_mail_data->file_path_html, &st_buf) < 0) { EM_DEBUG_EXCEPTION("input_mail_data->file_path_html, stat(\"%s\") failed...", input_mail_data->file_path_html); - err = EMF_ERROR_INVALID_MAIL; + err = EMAIL_ERROR_INVALID_MAIL; goto FINISH_OFF; } } @@ -4774,7 +4762,7 @@ INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attac 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) { EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_attachment_data_list[i].attachment_path); - err = EMF_ERROR_INVALID_ATTACHMENT; + err = EMAIL_ERROR_INVALID_ATTACHMENT; goto FINISH_OFF; } } @@ -4787,13 +4775,13 @@ INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attac } if (!input_mail_data->full_address_from) { - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; if (!(ref_account = emcore_get_account_reference(input_mail_data->account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", input_mail_data->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF2; } - input_mail_data->full_address_from = ref_account->email_addr; + input_mail_data->full_address_from = ref_account->user_email_address; } if (input_mail_data->file_path_plain) { /* Save plain text body. */ @@ -4813,16 +4801,24 @@ INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attac 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, &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_attachment_data_list && input_attachment_count) { int i = 0; int compare_result = 1; - char attachment_id[20]; - emf_attachment_data_t *temp_attachment_data = NULL; + email_attachment_data_t *temp_attachment_data = NULL; 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, temp_attachment_data->attachment_id, temp_attachment_data, &compare_result)) != EMF_ERROR_NONE) { + if ( (err = emcore_mail_compare_filename_of_attachment_data(input_mail_data->mail_id, temp_attachment_data->attachment_id, temp_attachment_data, &compare_result)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emcore_mail_compare_filename_of_attachment_data failed [%d]", err); compare_result = 1; } @@ -4836,16 +4832,14 @@ INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attac } else { EM_DEBUG_LOG("save names are different"); - SNPRINTF(attachment_id, sizeof(attachment_id), "%d", temp_attachment_data->attachment_id); - if(temp_attachment_data->attachment_id > 0) { - if (!emcore_delete_mail_attachment(input_mail_data->mail_id, attachment_id, &err)) { + if (!emcore_delete_mail_attachment(temp_attachment_data->attachment_id, &err)) { EM_DEBUG_EXCEPTION("emcore_delete_mail_attachment failed [%d]", err); goto FINISH_OFF2; } } - if ( (err = emcore_mail_add_attachment_data(input_mail_data->mail_id, temp_attachment_data)) != EMF_ERROR_NONE) { + if ( (err = emcore_mail_add_attachment_data(input_mail_data->mail_id, temp_attachment_data)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emcore_mail_add_attachment failed [%d]", err); goto FINISH_OFF2; } @@ -4866,7 +4860,7 @@ INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attac 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))) != EMF_ERROR_NONE) { + 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) { EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file failed[%d]", err); goto FINISH_OFF2; } @@ -4886,16 +4880,16 @@ INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attac goto FINISH_OFF; } - if (input_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_REQUEST - || input_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_RESPONSE - || input_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { + if (input_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST + || 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 != EMF_ERROR_DATA_NOT_FOUND) { + if (!emstorage_get_meeting_request(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; } EM_SAFE_FREE(meeting_req); - if (err == EMF_ERROR_DATA_NOT_FOUND) { /* insert */ + 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)) { @@ -4904,7 +4898,7 @@ INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attac } if (original_mail) { - if (!emstorage_add_meeting_request(input_mail_data->account_id, original_mail->mailbox_name, input_meeting_request, false, &err)) { + 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); goto FINISH_OFF; @@ -4922,10 +4916,10 @@ INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attac } FINISH_OFF: - if (err == EMF_ERROR_NONE) { + if (err == EMAIL_ERROR_NONE) { /* COMMIT TRANSACTION; */ if (emstorage_commit_transaction(NULL, NULL, NULL) == false) { - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; } if (input_mail_data->meeting_request_status && !emstorage_notify_storage_event(NOTI_MAIL_UPDATE, input_mail_data->account_id, input_mail_data->mail_id, NULL, UPDATE_MEETING)) @@ -4934,13 +4928,13 @@ FINISH_OFF: else { /* ROLLBACK TRANSACTION; */ if (emstorage_rollback_transaction(NULL, NULL, NULL) == false) - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; } FINISH_OFF2: if(meeting_req) - emstorage_free_meeting_request(&meeting_req, 1, NULL); + emstorage_free_meeting_request(meeting_req); if(converted_mail_tbl_data) emstorage_free_mail(&converted_mail_tbl_data, 1, NULL); @@ -4949,7 +4943,7 @@ FINISH_OFF2: return err; } -INTERNAL_FUNC int emcore_fetch_flags(int account_id, int mail_id, emf_mail_flag_t *mail_flag, int *err_code) +INTERNAL_FUNC int emcore_fetch_flags(int account_id, int mail_id, email_mail_flag_t *mail_flag, int *err_code) { EM_DEBUG_FUNC_BEGIN(); @@ -4989,16 +4983,16 @@ FINISH_OFF: /* description : modify flag of msgno. return 1(success), 0(failure) */ -INTERNAL_FUNC int emcore_modify_flag(int mail_id, emf_mail_flag_t new_flag, int sticky_flag, int *err_code) +INTERNAL_FUNC int emcore_modify_flag(int mail_id, email_mail_flag_t new_flag, int sticky_flag, int *err_code) { EM_DEBUG_FUNC_BEGIN("mail_id[%d], err_code[%p]", mail_id, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int old_seen, new_seen; emstorage_mail_tbl_t *mail = NULL; - emf_mail_flag_t old_flag; + email_mail_flag_t old_flag; if (!emstorage_get_mail_field_by_id(mail_id, RETRIEVE_FLAG, &mail, true, &err) || !mail) { EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_id failed [%d]", err); @@ -5045,29 +5039,28 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_set_flags_field(int account_id, int mail_ids[], int num, emf_flags_field_type field_type, int value, 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) { 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); int ret = false; - int err = EMF_ERROR_NONE; - char *field_type_name[EMF_FLAGS_FIELD_COUNT] = { "flags_seen_field" + int err = EMAIL_ERROR_NONE; + char *field_type_name[EMAIL_FLAGS_FIELD_COUNT] = { "flags_seen_field" , "flags_deleted_field", "flags_flagged_field", "flags_answered_field" , "flags_recent_field", "flags_draft_field", "flags_forwarded_field" }; - if(field_type < 0 || field_type >= EMF_FLAGS_FIELD_COUNT || mail_ids == NULL || num <= 0 || account_id == 0) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } + if(field_type < 0 || field_type >= EMAIL_FLAGS_FIELD_COUNT || mail_ids == NULL || num <= 0 || account_id == 0) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; + 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)) { EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err); - - goto FINISH_OFF; - } + goto FINISH_OFF; + } - emcore_check_unread_mail(); + emcore_check_unread_mail(); ret = true; @@ -5075,6 +5068,7 @@ FINISH_OFF: if (err_code) *err_code = err; + EM_DEBUG_FUNC_END("err [%d]", err); return ret; } @@ -5083,12 +5077,12 @@ FINISH_OFF: /* description : modify extra flag of msgno. return 0(success), -1(failure) */ -INTERNAL_FUNC int emcore_modify_extra_flag(int mail_id, emf_extra_flag_t new_flag, int *err_code) +INTERNAL_FUNC int emcore_modify_extra_flag(int mail_id, email_extra_flag_t new_flag, int *err_code) { EM_DEBUG_FUNC_BEGIN("mail_id[%d], err_code[%p]", mail_id, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_mail_tbl_t mail; memset(&mail, 0x00, sizeof(emstorage_mail_tbl_t)); @@ -5121,7 +5115,7 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in EM_DEBUG_FUNC_BEGIN("stream[%p], msgno[%d], limited_size[%d], err_code[%p]", stream, msgno, limited_size, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int total_body_size = 0; char command[32]; char *response = NULL; @@ -5129,14 +5123,14 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in if (!stream || !result_total_body_size) { EM_DEBUG_EXCEPTION("stream[%p], total_body_size[%p]", stream, msgno, result_total_body_size); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } pop3local = (POP3LOCAL *)(((MAILSTREAM *)stream)->local); if (!pop3local || !pop3local->netstream) { - err = EMF_ERROR_INVALID_STREAM; + err = EMAIL_ERROR_INVALID_STREAM; goto FINISH_OFF; } memset(command, 0x00, sizeof(command)); @@ -5152,7 +5146,7 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in if (!net_sout(pop3local->netstream, command, (int)strlen(command))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -5175,7 +5169,7 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in char *p = NULL; if (!(p = strchr(response + strlen("+OK "), ' '))) { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -5188,11 +5182,11 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in } } else if (*response == '-') { /* "- ERR" */ - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } else { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -5210,21 +5204,21 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in EM_DEBUG_LOG("[POP3] >>> %s", command); - emcore_set_network_error(EMF_ERROR_NONE); /* set current network error as EMF_ERROR_NONE before network operation */ + emcore_set_network_error(EMAIL_ERROR_NONE); /* set current network error as EMAIL_ERROR_NONE before network operation */ /* get mail from mail server */ if (!pop3_send((MAILSTREAM *)stream, command, NULL)) { EM_DEBUG_EXCEPTION("pop3_send failed..."); - emf_session_t *session = NULL; + email_session_t *session = NULL; if (!emcore_get_current_session(&session)) { EM_DEBUG_EXCEPTION("emcore_get_current_session failed..."); - err = EMF_ERROR_SESSION_NOT_FOUND; + err = EMAIL_ERROR_SESSION_NOT_FOUND; goto FINISH_OFF; } - if (session->network == EMF_ERROR_NONE) - err = EMF_ERROR_UNKNOWN; + if (session->network == EMAIL_ERROR_NONE) + err = EMAIL_ERROR_UNKNOWN; else err = session->network; @@ -5249,26 +5243,26 @@ INTERNAL_FUNC int emcore_sync_flag_with_server(int mail_id, int *err_code) if (mail_id < 1) { if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int err = EMF_ERROR_NONE; - int status = EMF_DOWNLOAD_FAIL; + int err = EMAIL_ERROR_NONE; + int status = EMAIL_DOWNLOAD_FAIL; MAILSTREAM *stream = NULL; - emf_mailbox_t mbox = {0}; + email_internal_mailbox_t mailbox = {0}; emstorage_mail_tbl_t *mail = NULL; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; int account_id = 0; int msgno = 0; - emf_mail_flag_t new_flag = {0}; + email_mail_flag_t new_flag = {0}; char set_flags[100] = { 0, }; char clear_flags[100] = { 0, }; char tmp[100] = { 0, }; if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -5283,34 +5277,34 @@ INTERNAL_FUNC int emcore_sync_flag_with_server(int mail_id, int *err_code) if (!(ref_account = emcore_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } /* open mail server. */ - if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_name, (void **)&stream, &err) || !stream) { + if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_id, (void **)&stream, &err) || !stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err); - status = EMF_LIST_CONNECTION_FAIL; + status = EMAIL_LIST_CONNECTION_FAIL; goto FINISH_OFF; } if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } - mbox.name = mail->mailbox_name; - mbox.account_id = account_id; - mbox.mail_stream = stream; + mailbox.mailbox_name = mail->mailbox_name; + mailbox.account_id = account_id; + mailbox.mail_stream = stream; /* download all uids from server. */ - if (!emcore_get_mail_msgno_by_uid(ref_account, &mbox, mail->server_mail_id, &msgno, &err)) { + if (!emcore_get_mail_msgno_by_uid(ref_account, &mailbox, mail->server_mail_id, &msgno, &err)) { EM_DEBUG_EXCEPTION("emcore_get_mail_msgno_by_uid failed message_no : %d ", err); goto FINISH_OFF; } @@ -5362,7 +5356,7 @@ INTERNAL_FUNC int emcore_sync_flag_with_server(int mail_id, int *err_code) EM_DEBUG_LOG(">>>> Returning from emcore_sync_flag_with_server "); if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -5385,27 +5379,27 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(int mail_ids[], int num, int if (mail_ids[0] < 1) { if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int err = EMF_ERROR_NONE; - int status = EMF_DOWNLOAD_FAIL; + int err = EMAIL_ERROR_NONE; + int status = EMAIL_DOWNLOAD_FAIL; MAILSTREAM *stream = NULL; - emf_mailbox_t mbox; + email_internal_mailbox_t mailbox; emstorage_mail_tbl_t *mail = NULL; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; int account_id = 0; int msgno = 0; - emf_mail_flag_t new_flag; + email_mail_flag_t new_flag; char set_flags[100]; char clear_flags[100]; char tmp[100]; int mail_id = 0; int i = 0; - memset(&mbox, 0x00, sizeof(emf_mailbox_t)); + memset(&mailbox, 0x00, sizeof(email_mailbox_t)); mail_id = mail_ids[0]; @@ -5419,26 +5413,26 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(int mail_ids[], int num, int if (!(ref_account = emcore_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } /* open mail server. */ - if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_name, (void **)&stream, &err) || !stream) { + if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_id, (void **)&stream, &err) || !stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err); - status = EMF_LIST_CONNECTION_FAIL; + status = EMAIL_LIST_CONNECTION_FAIL; goto FINISH_OFF; } - mbox.name = mail->mailbox_name; - mbox.account_id = account_id; - mbox.mail_stream = stream; + mailbox.mailbox_name = mail->mailbox_name; + mailbox.account_id = account_id; + mailbox.mail_stream = stream; for (i = 0; i < num; i++) { mail_id = mail_ids[i]; if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -5452,12 +5446,12 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(int mail_ids[], int num, int em_convert_mail_tbl_to_mail_flag(mail, &new_flag, NULL); if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } /* download message number from server. */ - if (!emcore_get_mail_msgno_by_uid(ref_account, &mbox, mail->server_mail_id, &msgno, &err)) { + if (!emcore_get_mail_msgno_by_uid(ref_account, &mailbox, mail->server_mail_id, &msgno, &err)) { EM_DEBUG_LOG("emcore_get_mail_msgno_by_uid failed message_no : %d ", err); goto FINISH_OFF; } @@ -5488,7 +5482,7 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(int mail_ids[], int num, int EM_DEBUG_LOG(">>>> Returning from emcore_sync_flag_with_server "); if (!emcore_check_thread_status()) { - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } } @@ -5505,94 +5499,66 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_free_mail_data(emf_mail_data_t **mail_list, int count, int *err_code) +INTERNAL_FUNC void emcore_free_mail_data_list(email_mail_data_t **mail_list, int count) { - EM_DEBUG_FUNC_BEGIN("mail_list[%p], count[%d]", mail_list, count); + EM_DEBUG_FUNC_BEGIN("count[%d]", count); if (count <= 0 || !mail_list || !*mail_list) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - if(err_code) - *err_code = EMF_ERROR_INVALID_PARAM; - return false; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return; } - emf_mail_data_t* p = *mail_list; + email_mail_data_t* p = *mail_list; int i; - for (i = 0; i < count; i++) { - EM_SAFE_FREE(p[i].mailbox_name); - EM_SAFE_FREE(p[i].subject); - EM_SAFE_FREE(p[i].server_mailbox_name); - EM_SAFE_FREE(p[i].server_mail_id); - EM_SAFE_FREE(p[i].message_id); - EM_SAFE_FREE(p[i].full_address_from); - EM_SAFE_FREE(p[i].full_address_reply); - EM_SAFE_FREE(p[i].full_address_to); - EM_SAFE_FREE(p[i].full_address_cc); - EM_SAFE_FREE(p[i].full_address_bcc); - EM_SAFE_FREE(p[i].full_address_return); - EM_SAFE_FREE(p[i].email_address_sender); - EM_SAFE_FREE(p[i].email_address_recipient); - EM_SAFE_FREE(p[i].alias_sender); - EM_SAFE_FREE(p[i].alias_recipient); - EM_SAFE_FREE(p[i].file_path_plain); - EM_SAFE_FREE(p[i].file_path_html); - EM_SAFE_FREE(p[i].preview_text); - } - - EM_SAFE_FREE(p); *mail_list = NULL; - - if(err_code) - *err_code = EMF_ERROR_NONE; - - EM_DEBUG_FUNC_END(); - return true; -} + for (i = 0; i < count; i++) + emcore_free_mail_data( p+i); + EM_SAFE_FREE(*mail_list); -INTERNAL_FUNC int emcore_free_attachment_info(emf_attachment_info_t **atch_info, int *err_code) -{ - EM_DEBUG_FUNC_BEGIN("atch_info[%p], err_code[%p]", atch_info, err_code); - - if (!atch_info || !*atch_info) { - if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; - return false; + EM_DEBUG_FUNC_END(); } - emf_attachment_info_t *p = *atch_info; - emf_attachment_info_t *t; - - while (p) { - EM_SAFE_FREE(p->name); - EM_SAFE_FREE(p->savename); - t = p->next; - free(p); p = NULL; - p = t; - } +INTERNAL_FUNC void emcore_free_mail_data(email_mail_data_t *mail_data) +{ + EM_DEBUG_FUNC_BEGIN(); + + EM_SAFE_FREE(mail_data->subject); + EM_SAFE_FREE(mail_data->server_mailbox_name); + EM_SAFE_FREE(mail_data->server_mail_id); + EM_SAFE_FREE(mail_data->message_id); + EM_SAFE_FREE(mail_data->full_address_from); + EM_SAFE_FREE(mail_data->full_address_reply); + EM_SAFE_FREE(mail_data->full_address_to); + EM_SAFE_FREE(mail_data->full_address_cc); + EM_SAFE_FREE(mail_data->full_address_bcc); + EM_SAFE_FREE(mail_data->full_address_return); + EM_SAFE_FREE(mail_data->email_address_sender); + EM_SAFE_FREE(mail_data->email_address_recipient); + EM_SAFE_FREE(mail_data->alias_sender); + EM_SAFE_FREE(mail_data->alias_recipient); + EM_SAFE_FREE(mail_data->file_path_plain); + EM_SAFE_FREE(mail_data->file_path_html); + EM_SAFE_FREE(mail_data->preview_text); - if (err_code != NULL) - *err_code = EMF_ERROR_NONE; - EM_DEBUG_FUNC_END(); - return true; + EM_DEBUG_FUNC_END(); } -INTERNAL_FUNC int emcore_free_attachment_data(emf_attachment_data_t **attachment_data_list, int attachment_data_count, int *err_code) +INTERNAL_FUNC int emcore_free_attachment_data(email_attachment_data_t **attachment_data_list, int attachment_data_count, int *err_code) { EM_DEBUG_FUNC_BEGIN("attachment_data_list[%p], attachment_data_count [%d], err_code[%p]", attachment_data_list, attachment_data_count, err_code); if (!attachment_data_list || !*attachment_data_list) { if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - emf_attachment_data_t* p = *attachment_data_list; + email_attachment_data_t* p = *attachment_data_list; int i = 0; for (i = 0; i < attachment_data_count; i++) { - EM_SAFE_FREE(p[i].mailbox_name); EM_SAFE_FREE(p[i].attachment_name); EM_SAFE_FREE(p[i].attachment_path); } @@ -5600,7 +5566,7 @@ INTERNAL_FUNC int emcore_free_attachment_data(emf_attachment_data_t **attachment EM_SAFE_FREE(p); *attachment_data_list = NULL; if(err_code) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; EM_DEBUG_FUNC_END(); return true; @@ -5617,19 +5583,17 @@ INTERNAL_FUNC int emcore_delete_pbd_activity(int account_id, int mail_id, int ac if (account_id < FIRST_ACCOUNT_ID || mail_id < 0) { EM_DEBUG_EXCEPTION("account_id[%d], mail_id[%d], err_code[%p]", account_id, mail_id, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_begin_transaction(NULL, NULL, NULL); if (!emstorage_delete_pbd_activity(account_id, mail_id, activity_id, false, &err)) { EM_DEBUG_EXCEPTION("emstorage_delete_pbd_activity failed [%d]", err); - - goto FINISH_OFF; } @@ -5638,13 +5602,13 @@ 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) { - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; ret = false; } } else { /* ROLLBACK TRANSACTION; */ if (emstorage_rollback_transaction(NULL, NULL, NULL) == false) - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; } if (err_code != NULL) @@ -5653,19 +5617,19 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_insert_pbd_activity(emf_event_partial_body_thd *local_activity, int *activity_id, int *err_code) +INTERNAL_FUNC int emcore_insert_pbd_activity(email_event_partial_body_thd *local_activity, int *activity_id, int *err_code) { EM_DEBUG_FUNC_BEGIN("local_activity[%p], activity_id[%p], err_code[%p]", local_activity, activity_id, err_code); if (!local_activity || !activity_id) { EM_DEBUG_EXCEPTION("local_activity[%p], activity_id[%p] err_code[%p]", local_activity, activity_id, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_begin_transaction(NULL, NULL, NULL); @@ -5681,13 +5645,13 @@ INTERNAL_FUNC int emcore_insert_pbd_activity(emf_event_partial_body_thd *local_a FINISH_OFF: if (ret == true) { /* COMMIT TRANSACTION; */ if (emstorage_commit_transaction(NULL, NULL, NULL) == false) { - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; ret = false; } } else { /* ROLLBACK TRANSACTION; */ if (emstorage_rollback_transaction(NULL, NULL, NULL) == false) - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; } if (err_code != NULL) @@ -5702,14 +5666,14 @@ 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, emf_flags_field_type field_type, int value, int *err_code) +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) { 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); - if (NULL == mail_ids || num <= 0 || field_type < 0 || field_type >= EMF_FLAGS_FIELD_COUNT) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + if (NULL == mail_ids || num <= 0 || field_type < 0 || field_type >= EMAIL_FLAGS_FIELD_COUNT) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) { - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; } return false; } @@ -5721,7 +5685,7 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, e char *p = NULL; char **string_list = NULL; int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int command_success = false; int account_id = 0; int mail_id = 0; @@ -5729,12 +5693,12 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, e int id_set_count = 0; int len_of_each_range = 0; int string_count = 0; - emf_account_t *temp_account; - emf_id_set_t *id_set = NULL; + email_account_t *temp_account; + email_id_set_t *id_set = NULL; emstorage_mail_tbl_t *mail = NULL; - emf_uid_range_set *uid_range_set = NULL; - emf_uid_range_set *uid_range_node = NULL; - char *field_type_name[EMF_FLAGS_FIELD_COUNT] = { "\\Seen" + email_uid_range_set *uid_range_set = NULL; + email_uid_range_set *uid_range_node = NULL; + char *field_type_name[EMAIL_FLAGS_FIELD_COUNT] = { "\\Seen" , "\\Deleted", "\\Flagged", "\\Answered" , "\\Recent", "\\Draft", "$Forwarded" }; @@ -5752,17 +5716,17 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, e if (!temp_account) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - if (temp_account->receiving_server_type != EMF_SERVER_TYPE_IMAP4) { - EM_DEBUG_EXCEPTION("Syncing seen flag is available only for IMAP4 server. The server type [%d]", temp_account->receiving_server_type); - err = EMF_ERROR_NOT_SUPPORTED; + if (temp_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) { + EM_DEBUG_EXCEPTION("Syncing seen flag is available only for IMAP4 server. The server type [%d]", temp_account->incoming_server_type); + err = EMAIL_ERROR_NOT_SUPPORTED; goto FINISH_OFF; } - if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_name, (void **)&stream, &err) || !stream) { + if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_id, (void **)&stream, &err) || !stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err); goto FINISH_OFF; } @@ -5824,13 +5788,13 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, e if (!(imaplocal = stream->local) || !imaplocal->netstream) { EM_DEBUG_EXCEPTION("invalid IMAP4 stream detected..."); - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; goto FINISH_OFF; } if (!net_sout(imaplocal->netstream, cmd, (int)strlen(cmd))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; + err = EMAIL_ERROR_CONNECTION_BROKEN; goto FINISH_OFF; } @@ -5842,7 +5806,7 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, e if (!(p = net_getline(imaplocal->netstream))) { EM_DEBUG_EXCEPTION("net_getline failed..."); - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -5859,7 +5823,7 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, e else { /* 'NO' or 'BAD' */ command_success = false; - err = EMF_ERROR_IMAP4_STORE_FAILURE; + err = EMAIL_ERROR_IMAP4_STORE_FAILURE; EM_SAFE_FREE(p); goto FINISH_OFF; } @@ -5919,20 +5883,20 @@ FINISH_OFF: } #endif -INTERNAL_FUNC int emcore_mail_filter_by_rule(emf_rule_t *filter_info, int *err_code) +INTERNAL_FUNC int emcore_mail_filter_by_rule(email_rule_t *filter_info, int *err_code) { EM_DEBUG_FUNC_BEGIN("filter_info[%p], err_code[%p]", filter_info, err_code); - int ret = false, err = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; int account_index, account_count, mail_id_index = 0; - emf_account_t *account_ref = NULL, *account_list_ref = NULL; + email_account_t *account_ref = NULL, *account_list_ref = NULL; int filtered_mail_id_count = 0, *filtered_mail_id_list = NULL, parameter_string_length = 0; char *parameter_string = NULL, mail_id_string[10] = { 0x00, }; emstorage_mailbox_tbl_t *spam_mailbox = NULL; if (!filter_info) { EM_DEBUG_EXCEPTION("filter_info[%p]", filter_info); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -5944,23 +5908,22 @@ INTERNAL_FUNC int emcore_mail_filter_by_rule(emf_rule_t *filter_info, int *err_c for (account_index = 0; account_index < account_count; account_index++) { account_ref = account_list_ref + account_index; - if (!emstorage_get_mailbox_by_mailbox_type(account_ref->account_id, EMF_MAILBOX_TYPE_SPAMBOX, &spam_mailbox, false, &err)) + if (!emstorage_get_mailbox_by_mailbox_type(account_ref->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_ref->account_id, err); - else if (spam_mailbox && spam_mailbox->mailbox_name) { - if (!emstorage_filter_mails_by_rule(account_ref->account_id, spam_mailbox->mailbox_name, (emstorage_rule_tbl_t *)filter_info, &filtered_mail_id_list, &filtered_mail_id_count, &err)) + else if (spam_mailbox && spam_mailbox->mailbox_id > 0) { + if (!emstorage_filter_mails_by_rule(account_ref->account_id, spam_mailbox->mailbox_id, (emstorage_rule_tbl_t *)filter_info, &filtered_mail_id_list, &filtered_mail_id_count, &err)) EM_DEBUG_EXCEPTION("emstorage_filter_mails_by_rule failed [%d]", err); else { if (filtered_mail_id_count) { - parameter_string_length = strlen(spam_mailbox->mailbox_name) + 7 + (10 * filtered_mail_id_count); + parameter_string_length = 10 /*mailbox_id length*/ + 7 + (10 * filtered_mail_id_count); parameter_string = em_malloc(sizeof(char) * parameter_string_length); if (parameter_string == NULL) { - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; EM_DEBUG_EXCEPTION("em_malloc failed for parameter_string"); goto FINISH_OFF; } - - SNPRINTF(parameter_string, parameter_string_length, "[NA]%c%s%c", 0x01, spam_mailbox->mailbox_name, 0x01); + SNPRINTF(parameter_string, parameter_string_length, "[NA]%c%d%c", 0x01, spam_mailbox->mailbox_id, 0x01); for (mail_id_index = 0; mail_id_index < filtered_mail_id_count; mail_id_index++) { memset(mail_id_string, 0, 10); @@ -6002,3 +5965,4 @@ FINISH_OFF: EM_DEBUG_FUNC_END(); return ret; } + diff --git a/email-core/email-core-mailbox-sync.c b/email-core/email-core-mailbox-sync.c index 7d0a0c7..3c4e2d8 100755 --- a/email-core/email-core-mailbox-sync.c +++ b/email-core/email-core-mailbox-sync.c @@ -59,8 +59,8 @@ static char g_append_uid_rsp[129]; /* added for getting server response */ extern void imap_parse_body_structure (MAILSTREAM *stream, BODY *body, unsigned char **txtptr, IMAPPARSEDREPLY *reply); #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__ -static emf_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply); -static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id, char *uid, char *mailbox, int *err_code); +static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply, int input_download_size); +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__ @@ -73,7 +73,7 @@ int pop3_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *er EM_DEBUG_FUNC_BEGIN(); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; POP3LOCAL *pop3local = NULL; char command[16]; @@ -82,12 +82,12 @@ int pop3_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *er if (!stream || !size) { EM_DEBUG_EXCEPTION(" stream[%p], msgno[%d], size[%p]\n", stream, msgno, size); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!(pop3local = stream->local) || !pop3local->netstream) { - err = EMF_ERROR_INVALID_STREAM; + err = EMAIL_ERROR_INVALID_STREAM; goto FINISH_OFF; } @@ -101,13 +101,13 @@ int pop3_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *er if (!net_sout(pop3local->netstream, command, (int)strlen(command))) { EM_DEBUG_EXCEPTION(" net_sout failed..."); - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } /* receive response */ if (!(response = net_getline(pop3local->netstream))) { - err = EMF_ERROR_CONNECTION_BROKEN; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_CONNECTION_BROKEN; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } @@ -117,18 +117,18 @@ int pop3_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *er char *p = NULL; if (!(p = strchr(response + strlen("+OK "), ' '))) { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } *size = atoi(p + 1); } else if (*response == '-') { /* "- ERR" */ - err = EMF_ERROR_POP3_LIST_FAILURE; + err = EMAIL_ERROR_POP3_LIST_FAILURE; goto FINISH_OFF; } else { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -149,7 +149,7 @@ int imap4_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *e EM_DEBUG_FUNC_BEGIN(); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; IMAPLOCAL *imaplocal = NULL; char tag[32], command[128]; @@ -158,12 +158,12 @@ int imap4_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *e if (!stream || !size) { EM_DEBUG_EXCEPTION("stream[%p], msgno[%d], size[%p]", stream, msgno, size); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!(imaplocal = stream->local) || !imaplocal->netstream) { - err = EMF_ERROR_INVALID_STREAM; + err = EMAIL_ERROR_INVALID_STREAM; goto FINISH_OFF; } @@ -179,7 +179,7 @@ int imap4_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *e if (!net_sout(imaplocal->netstream, command, (int)strlen(command))) { EM_DEBUG_EXCEPTION(" net_sout failed..."); - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -199,7 +199,7 @@ int imap4_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *e break; } else { /* 'NO' or 'BAD' */ - err = EMF_ERROR_IMAP4_FETCH_SIZE_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */ + err = EMAIL_ERROR_IMAP4_FETCH_SIZE_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */ goto FINISH_OFF; } } @@ -213,7 +213,7 @@ int imap4_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *e s = t + strlen("FETCH (RFC822.SIZE "); if (!(t = strchr(s, ' '))) { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -244,7 +244,7 @@ int pop3_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int *e EM_DEBUG_FUNC_BEGIN("stream[%p], uid_list[%p], err_code[%p]", stream, uid_list, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; POP3LOCAL *pop3local = NULL; char command[64]; @@ -253,13 +253,13 @@ int pop3_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int *e if (!stream || !uid_list) { EM_DEBUG_EXCEPTION("stream[%p], uid_list[%p]n", stream, uid_list); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!(pop3local = stream->local) || !pop3local->netstream) { EM_DEBUG_EXCEPTION("invalid POP3 stream detected..."); - err = EMF_ERROR_INVALID_STREAM; + err = EMAIL_ERROR_INVALID_STREAM; goto FINISH_OFF; } @@ -274,7 +274,7 @@ int pop3_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int *e /* send command : get msgno/uid for all message */ if (!net_sout(pop3local->netstream, command, (int)strlen(command))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_CONNECTION_BROKEN; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } @@ -286,7 +286,7 @@ int pop3_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int *e /* receive response */ if (!(response = net_getline(pop3local->netstream))) { EM_DEBUG_EXCEPTION("net_getline failed..."); - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -295,7 +295,7 @@ int pop3_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int *e #endif if (*response == '-') { /* "-ERR" */ - err = EMF_ERROR_POP3_UIDL_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */ + err = EMAIL_ERROR_POP3_UIDL_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */ goto FINISH_OFF; } @@ -314,7 +314,7 @@ int pop3_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int *e if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) { EM_DEBUG_EXCEPTION("malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -327,7 +327,7 @@ int pop3_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int *e *uid_list = uid_elem; } else { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -354,7 +354,7 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int * EM_DEBUG_FUNC_BEGIN("stream[%p], uid_list[%p], err_code[%p]", stream, uid_list, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; IMAPLOCAL *imaplocal = NULL; char tag[16], command[64]; @@ -363,18 +363,18 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int * if (!stream || !uid_list) { EM_DEBUG_EXCEPTION("stream[%p], uid_list[%p]", stream, uid_list); - err = EMF_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 = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN */ + err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN */ goto FINISH_OFF; } if (stream->nmsgs == 0){ - err = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; + err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER; goto FINISH_OFF; } memset(tag, 0x00, sizeof(tag)); @@ -390,7 +390,7 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int * /* send command : get msgno/uid for all message */ if (!net_sout(imaplocal->netstream, command, (int)strlen(command))) { EM_DEBUG_EXCEPTION(" net_sout failed...\n"); - err = EMF_ERROR_CONNECTION_BROKEN; + err = EMAIL_ERROR_CONNECTION_BROKEN; goto FINISH_OFF; } @@ -405,7 +405,7 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int * /* receive response */ if (!(response = net_getline(imaplocal->netstream))) { EM_DEBUG_EXCEPTION("net_getline failed..."); - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -419,7 +419,7 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int * break; } else { /* 'NO' or 'BAD' */ - err = EMF_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */ + err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */ goto FINISH_OFF; } } @@ -442,7 +442,7 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int * if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -457,13 +457,13 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int * *uid_list = uid_elem; } else { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } } } else { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -536,7 +536,7 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui EM_DEBUG_FUNC_BEGIN("stream[%p], uid_list[%p], err_code[%p]", stream, uid_list, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; IMAPLOCAL *imaplocal = NULL; char tag[16], command[64]; @@ -553,13 +553,13 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui if (!stream || !uid_list) { EM_DEBUG_EXCEPTION(" stream[%p], uid_list[%p]", stream, uid_list); - err = EMF_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 = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN */ + err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN */ goto FINISH_OFF; } @@ -604,7 +604,7 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui /* send command : get msgno/uid for all message */ if (!net_sout(imaplocal->netstream, command, (int)strlen(command))) { EM_DEBUG_EXCEPTION(" net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; /* EMF_ERROR_UNKNOWN */ + err = EMAIL_ERROR_CONNECTION_BROKEN; /* EMAIL_ERROR_UNKNOWN */ goto FINISH_OFF; } @@ -615,7 +615,7 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui /* receive response */ if (!(response = net_getline(imaplocal->netstream))) { EM_DEBUG_EXCEPTION(" net_getline failed..."); - err = EMF_ERROR_INVALID_RESPONSE; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_INVALID_RESPONSE; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } #ifdef FEATURE_CORE_DEBUG @@ -628,7 +628,7 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui break; } else { /* 'NO' or 'BAD' */ - err = EMF_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */ + err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */ goto FINISH_OFF; } } @@ -644,7 +644,7 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) { EM_DEBUG_EXCEPTION(" malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -660,7 +660,7 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui return 1; } else { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -689,7 +689,7 @@ static int emcore_parse_header(char *rfc822_header, int *req_read_receipt, int * return false; if (err_code) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; EM_PROFILE_BEGIN(emCoreMailboxParseHeader); @@ -759,7 +759,7 @@ static int emcore_parse_header(char *rfc822_header, int *req_read_receipt, int * EM_PROFILE_END(emCoreMailboxParseHeader); if (err_code) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; return true; } @@ -771,7 +771,7 @@ static int emcore_get_mail_extra_info(MAILSTREAM *stream, int msgno, int *req_re EM_DEBUG_FUNC_BEGIN("stream[%p], msgno[%d], req_read_receipt[%p], priority[%p], err_code[%p]", stream, msgno, req_read_receipt, priority, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char *rfc822_header = NULL; unsigned long len = 0; @@ -795,7 +795,7 @@ static int emcore_get_mail_extra_info(MAILSTREAM *stream, int msgno, int *req_re if (!rfc822_header || !*rfc822_header) { EM_DEBUG_EXCEPTION("mail_fetch_header failed..."); - err = EMF_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } @@ -815,13 +815,13 @@ FINISH_OFF: return ret; } -static int emcore_get_uids_to_download(MAILSTREAM *stream, emf_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(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); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_read_mail_uid_tbl_t *downloaded_uids = NULL; int i = 0, j = 0, uid_count = 0, uid_to_be_downloaded_count = 0; @@ -832,30 +832,32 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, emf_account_t *accoun if (!account || !input_mailbox_tbl || !uid_list) { EM_DEBUG_EXCEPTION("account[%p], input_mailbox_tbl[%p], uid_list[%p]", account, input_mailbox_tbl, uid_list); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } *uid_list = NULL; - if (account->receiving_server_type == EMF_SERVER_TYPE_POP3) { + if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) { if (!pop3_mailbox_get_uids(stream, uid_list, &err)) { EM_DEBUG_EXCEPTION("pop3_mailbox_get_uids failed - %d", err); goto FINISH_OFF; } } - else { /* EMF_SERVER_TYPE_IMAP4 */ + else { /* EMAIL_SERVER_TYPE_IMAP4 */ /* sowmya.kr commented , since imap4_mailbox_get_uids_by_timestamp will fetch mails since last week and not all mails */ EM_DEBUG_LOG("calling imap4_mailbox_get_uids"); if (!imap4_mailbox_get_uids(stream, uid_list, &err)) { EM_DEBUG_EXCEPTION("imap4_mailbox_get_uids failed [%d]", err); - if (err != EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER) + if (err != EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER) goto FINISH_OFF; } } - if (!emstorage_get_downloaded_list(input_mailbox_tbl->account_id, input_mailbox_tbl->mailbox_name, &downloaded_uids, &j, true, &err)) { + 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, &j, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_downloaded_list failed [%d]", err); goto FINISH_OFF; @@ -876,7 +878,7 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, emf_account_t *accoun while (uid_elem) { next_uid_elem = uid_elem->next; - if ((account->retrieval_mode == EMF_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 */ if (uid_elem->uid) free(uid_elem->uid); @@ -902,11 +904,11 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, emf_account_t *accoun /* EM_DEBUG_LOG("Is uid[%s] going to be downloded ? [%d]", uid_elem->uid, to_be_downloaded); */ if (to_be_downloaded) { - if (retrieve_mode == EMF_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 EMF_SYNC_LATEST_MAILS_FIRST, add uid elem to end so that latest mails are in front of list */ + 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; @@ -941,14 +943,14 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, emf_account_t *accoun if (downloaded_uids[i].reserved == 0) { /* deleted on server */ if (!emstorage_get_maildata_by_servermailid(input_mailbox_tbl->account_id, downloaded_uids[i].s_uid, &mail, true, &err)){ EM_DEBUG_EXCEPTION("emstorage_get_maildata_by_servermailid for uid[%s] Failed [%d] \n ", downloaded_uids[i].s_uid, err); - if (err == EMF_ERROR_MAIL_NOT_FOUND){ + if (err == EMAIL_ERROR_MAIL_NOT_FOUND){ continue; } } - if (account->receiving_server_type == EMF_SERVER_TYPE_IMAP4) { - if (!emcore_delete_mail_from_local_storage(input_mailbox_tbl->account_id, &(mail->mail_id), 1, EMF_DELETED_FROM_SERVER, false, &err)) { - EM_DEBUG_EXCEPTION("emcore_delete_mail_from_local_storage falied - %d", err); + if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) { + if (!emcore_delete_mails_from_local_storage(input_mailbox_tbl->account_id, &(mail->mail_id), 1, EMAIL_DELETED_FROM_SERVER, false, &err)) { + EM_DEBUG_EXCEPTION("emcore_delete_mails_from_local_storage falied - %d", err); goto FINISH_OFF; } /* emcore_delete_notification_for_read_mail(mail->mail_id); */ @@ -962,7 +964,7 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, emf_account_t *accoun } } - else if (account->receiving_server_type == EMF_SERVER_TYPE_IMAP4 && downloaded_uids[i].reserved == 1) { + else if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && downloaded_uids[i].reserved == 1) { /* unseen on server */ if (!emstorage_get_mail_by_id(downloaded_uids[i].local_uid, &mail, true, &err)){ EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed for [%d] - [%d]", downloaded_uids[i].local_uid, err); @@ -1010,35 +1012,33 @@ 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) { - EM_PROFILE_BEGIN(emCoreMailboxAddReadMailUid); EM_DEBUG_FUNC_BEGIN("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); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - emstorage_read_mail_uid_tbl_t read_mail_uid = { 0 }; - char *mailbox_name = NULL; + emstorage_read_mail_uid_tbl_t read_mail_uid = { 0 }; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; if (!input_maibox_data || !uid) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } read_mail_uid.account_id = input_maibox_data->account_id; if (!(input_maibox_data->mailbox_name) || !(server_mailbox_name)){ - if (!emstorage_get_mailboxname_by_mailbox_type(input_maibox_data->account_id, EMF_MAILBOX_TYPE_INBOX, &mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); - + if (!emstorage_get_mailbox_by_mailbox_type(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; } } - if (input_maibox_data->mailbox_name) - read_mail_uid.local_mbox = input_maibox_data->mailbox_name; + if (input_maibox_data->mailbox_id) + read_mail_uid.mailbox_id = input_maibox_data->mailbox_id; else - read_mail_uid.local_mbox = mailbox_name; + read_mail_uid.mailbox_id = mailbox_tbl->mailbox_id; read_mail_uid.local_uid = mail_id; EM_DEBUG_LOG("MAIL ID [%d] LOCAL_UID [%d]", mail_id, read_mail_uid.local_uid); @@ -1046,7 +1046,7 @@ static int emcore_add_read_mail_uid(emstorage_mailbox_tbl_t *input_maibox_data, if (server_mailbox_name) read_mail_uid.mailbox_name = server_mailbox_name; else - read_mail_uid.mailbox_name = mailbox_name; + read_mail_uid.mailbox_name = mailbox_tbl->mailbox_name; read_mail_uid.s_uid = uid; read_mail_uid.data1 = rfc822_size; @@ -1061,28 +1061,28 @@ static int emcore_add_read_mail_uid(emstorage_mailbox_tbl_t *input_maibox_data, ret = true; FINISH_OFF: - EM_SAFE_FREE(mailbox_name); + if (mailbox_tbl) + emstorage_free_mailbox(&mailbox_tbl, 1, NULL); if (err_code) *err_code = err; - EM_PROFILE_END(emCoreMailboxAddReadMailUid); EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; } -static 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) +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) { 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 = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int thread_id = -1; int thread_item_count = 0; int latest_mail_id_in_thread = -1; if (!input_maibox_data || !input_new_mail_tbl_data) { EM_DEBUG_EXCEPTION("Invalid Parameter"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1099,7 +1099,7 @@ static int emcore_add_mail_to_mailbox(emstorage_mailbox_tbl_t *input_maibox_data 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) != EMF_ERROR_NONE) + 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) EM_DEBUG_LOG(" emstorage_get_thread_id_of_thread_mails is failed."); if (thread_id == -1){ @@ -1151,15 +1151,15 @@ int emcore_check_rule(const char *input_full_address_from, const char *input_sub { EM_DEBUG_FUNC_BEGIN("input_full_address_from [%p], input_subject [%p], rule [%p], rule_len [%d], matched [%p], err_code [%p]", input_full_address_from, input_subject, rule, rule_len, matched, err_code); - int ret = false, err = EMF_ERROR_NONE, i; + int ret = false, err = EMAIL_ERROR_NONE, i; size_t len = 0; char *src = NULL; /* string which will be compared with rules */ char *from_address = NULL; ADDRESS *addr = NULL; if (!matched || !input_full_address_from || !input_subject) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1178,7 +1178,7 @@ int emcore_check_rule(const char *input_full_address_from, const char *input_sub if (!(from_address = em_malloc(len))) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -1186,14 +1186,14 @@ int emcore_check_rule(const char *input_full_address_from, const char *input_sub } else { EM_DEBUG_EXCEPTION("rfc822_parse_adrlist failed."); - err = EMF_ERROR_INVALID_ADDRESS; + err = EMAIL_ERROR_INVALID_ADDRESS; goto FINISH_OFF; } for (i = 0; i < rule_len; i++) { if (!(rule + i)) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1203,14 +1203,14 @@ int emcore_check_rule(const char *input_full_address_from, const char *input_sub /* 'ON' */ EM_DEBUG_LOG("rule[%d].flag2(rule id[%d]) is %d", i, rule[i].rule_id, rule[i].flag2); switch (rule[i].type) { - case EMF_FILTER_FROM: + case EMAIL_FILTER_FROM: src = from_address; break; - case EMF_FILTER_SUBJECT: + case EMAIL_FILTER_SUBJECT: src = (char*)input_subject; break; - case EMF_FILTER_BODY: - err = EMF_ERROR_NOT_SUPPORTED; + case EMAIL_FILTER_BODY: + err = EMAIL_ERROR_NOT_SUPPORTED; goto FINISH_OFF; break; } @@ -1258,12 +1258,12 @@ static int emcore_get_utf8_address(char **dest, ADDRESS *address, int *err_code) if (!dest || !address) { EM_DEBUG_EXCEPTION("dest[%p], address[%p]", dest, address); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; gchar *concatenated = NULL; gchar *utf8_address = NULL; @@ -1320,13 +1320,13 @@ FINISH_OFF: } -static int emcore_make_mail_tbl_data_from_envelope(MAILSTREAM *mail_stream, ENVELOPE *input_envelope, emcore_uid_list *input_uid_elem, emstorage_mail_tbl_t **output_mail_tbl_data, int *err_code) +int emcore_make_mail_tbl_data_from_envelope(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); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int priority = 3; int req_read_receipt = 0; struct tm temp_time_info; @@ -1334,20 +1334,20 @@ static int emcore_make_mail_tbl_data_from_envelope(MAILSTREAM *mail_stream, ENVE emstorage_mail_tbl_t *temp_mail_tbl_data = NULL; if (!output_mail_tbl_data) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!(temp_mail_tbl_data = em_malloc(sizeof(emstorage_mail_tbl_t)))) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } if (!(mail_cache_element = mail_elt(mail_stream, input_uid_elem->msgno))) { EM_DEBUG_EXCEPTION("mail_elt failed..."); - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; goto FINISH_OFF; } @@ -1476,10 +1476,10 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, EM_DEBUG_FUNC_BEGIN("input_mailbox_tbl[%p], input_mailbox_tbl_spam[%p], input_uid_list [%p], err_code[%p]", input_mailbox_tbl, input_mailbox_tbl_spam, input_uid_list, err_code); int ret = false; - int err = EMF_ERROR_NONE, err_2 = EMF_ERROR_NONE; - int status = EMF_LIST_FAIL; + int err = EMAIL_ERROR_NONE, err_2 = EMAIL_ERROR_NONE; + int status = EMAIL_LIST_FAIL; int download_limit_count; - emf_account_t *account_ref = 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; @@ -1488,10 +1488,11 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, int account_id = 0, mail_id = 0, rule_len = 1000, total = 0, unread = 0, i = 0, percentage = 0, thread_id = -1; void *stream = NULL; char *uid_range = NULL; + char mailbox_id_param_string[10] = {0,}; if (!input_mailbox_tbl) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM:input_mailbox_tbl[%p]", input_mailbox_tbl); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM:input_mailbox_tbl[%p]", input_mailbox_tbl); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1499,13 +1500,13 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, account_ref = emcore_get_account_reference(account_id); if (!account_ref) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - if(account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4 && input_mailbox_tbl->sync_with_server_yn == 0) { - EM_DEBUG_EXCEPTION("sync_with_server_yn flag is false for this mailbox"); - err = EMF_ERROR_INVALID_MAILBOX; + if(account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && input_mailbox_tbl->local_yn == 1) { + EM_DEBUG_EXCEPTION("local_yn flag is false for this mailbox"); + err = EMAIL_ERROR_INVALID_MAILBOX; goto FINISH_OFF; } @@ -1517,16 +1518,16 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, stream = stream_recycle; /* set stream for recycling connection. */ #endif - if (!emcore_connect_to_remote_mailbox(account_id, input_mailbox_tbl->mailbox_name, (void **)&stream, &err) || !stream){ + if (!emcore_connect_to_remote_mailbox(account_id, input_mailbox_tbl->mailbox_id, (void **)&stream, &err) || !stream){ EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed - %d", err); - status = EMF_LIST_CONNECTION_FAIL; + status = EMAIL_LIST_CONNECTION_FAIL; goto FINISH_OFF; } FINISH_OFF_IF_CANCELED; /* save total mail count on server to DB */ - if (!emstorage_update_mailbox_total_count(account_id, input_mailbox_tbl->mailbox_name, ((MAILSTREAM *)stream)->nmsgs, 1, &err)){ + if (!emstorage_update_mailbox_total_count(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; @@ -1534,7 +1535,7 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, /* if (((MAILSTREAM *)stream)->nmsgs > 0) */ { - emf_option_t *opt_ref = &account_ref->options; + email_option_t *opt_ref = &account_ref->options; EM_DEBUG_LOG("block_address = %d, block_subject = %d", opt_ref->block_address, opt_ref->block_subject); if (opt_ref->block_address || opt_ref->block_subject) { @@ -1542,15 +1543,15 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, int type = 0; if (!opt_ref->block_address) - type = EMF_FILTER_SUBJECT; + type = EMAIL_FILTER_SUBJECT; else if (!opt_ref->block_subject) - type = EMF_FILTER_FROM; + type = EMAIL_FILTER_FROM; if (!emstorage_get_rule(ALL_ACCOUNT, type, 0, &rule_len, &is_completed, &rule, true, &err) || !rule) EM_DEBUG_EXCEPTION("emstorage_get_rule failed - %d", err); } download_limit_count = input_mailbox_tbl->mail_slot_size; - if (!emcore_get_uids_to_download(stream, account_ref, input_mailbox_tbl, download_limit_count, &uid_list, &total, EMF_SYNC_LATEST_MAILS_FIRST, &err)){ + 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); uid_list = NULL; goto FINISH_OFF; @@ -1571,7 +1572,7 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, EM_DEBUG_LOG("((MAILSTREAM *)stream)->nmsgs [%d]", ((MAILSTREAM *)stream)->nmsgs); EM_DEBUG_LOG("uid_list [%p]", uid_list); - if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4 && uid_list != NULL){ + if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && uid_list != NULL){ emcore_uid_list *uid_list_prev = NULL; emcore_uid_list *uid_list_fast = uid_list; int index = 0; @@ -1583,7 +1584,7 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, if (uid_range == NULL){ EM_DEBUG_EXCEPTION("memory allocation for uid_range failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -1658,7 +1659,7 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, /* h.gahlaut@samsung.com : Clear the event queue of partial body download thread before starting fetching new headers */ #ifndef __PARTIAL_BODY_FOR_POP3__ - if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4){ + if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4){ #endif /* __PARTIAL_BODY_FOR_POP3__ */ /* Partial body download feature is only for IMAP accounts */ if (false == emcore_clear_partial_body_thd_event_que(&err)) @@ -1677,7 +1678,7 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, else{ #ifdef __FEATURE_HEADER_OPTIMIZATION__ - if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4) /* Fetch env from cache in case of IMAP */ + 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); @@ -1703,13 +1704,13 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, if (matched >= 0 && input_mailbox_tbl_spam){ /* add filtered mails to SPAMBOX */ EM_DEBUG_LOG("mail[%d] added to spambox", mail_id); - if ( (err = emcore_add_mail_to_mailbox(input_mailbox_tbl_spam, new_mail_tbl_data, &mail_id, &thread_id)) != EMF_ERROR_NONE) { + if ( (err = emcore_add_mail_to_mailbox(input_mailbox_tbl_spam, new_mail_tbl_data, &mail_id, &thread_id)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox falied [%d]", err); goto FINISH_OFF; } - if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4){ - if (!emcore_move_mail_on_server(account_id, input_mailbox_tbl->mailbox_name, &mail_id, 1, input_mailbox_tbl_spam->mailbox_name, &err)){ + if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4){ + if (!emcore_move_mail_on_server(account_id, input_mailbox_tbl->mailbox_id, &mail_id, 1, input_mailbox_tbl_spam->mailbox_name, &err)){ EM_DEBUG_EXCEPTION("emcore_move_mail_on_server falied [%d]", err); goto FINISH_OFF; } @@ -1717,22 +1718,24 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, } else { /* add mails to specified mail box */ EM_DEBUG_LOG("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)) != EMF_ERROR_NONE) { + if ( (err = emcore_add_mail_to_mailbox(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 FINISH_OFF; } /*h.gahlaut : Start partial body dowload using partial body thread only for IMAP accounts*/ #ifndef __PARTIAL_BODY_FOR_POP3__ - if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4) { + if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) { #endif /* __PARTIAL_BODY_FOR_POP3__ */ - if (false == emcore_initiate_pbd(stream, account_id, mail_id, uid_elem->uid, input_mailbox_tbl->mailbox_name, &err)) - EM_DEBUG_LOG("Partial body download initiation failed [%d]", err); + 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 __PARTIAL_BODY_FOR_POP3__ } #endif /* __PARTIAL_BODY_FOR_POP3__ */ - if (!uid_elem->flag.seen && input_mailbox_tbl->mailbox_type != EMF_MAILBOX_TYPE_SPAMBOX) + if (!uid_elem->flag.seen && input_mailbox_tbl->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX) emcore_add_notification_for_unread_mail(new_mail_tbl_data); FINISH_OFF_IF_CANCELED; @@ -1742,8 +1745,9 @@ INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, 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 (!emstorage_notify_storage_event(NOTI_MAIL_ADD, account_id, mail_id, input_mailbox_tbl->mailbox_name, thread_id)) + if (!emstorage_notify_storage_event(NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id)) EM_DEBUG_EXCEPTION("emstorage_notify_storage_event [NOTI_MAIL_ADD] failed"); } @@ -1772,6 +1776,8 @@ FINISH_OFF: if (!emcore_remove_overflowed_mails(input_mailbox_tbl, &err_2)) EM_DEBUG_EXCEPTION("emcore_remove_overflowed_mails failed - %d", err_2); + emstorage_stamp_last_sync_time_of_mailbox(input_mailbox_tbl->mailbox_id, 1); + if (new_mail_tbl_data) emstorage_free_mail(&new_mail_tbl_data, 1, NULL); @@ -1825,15 +1831,15 @@ emcore_uid_list *__ReverseList(emcore_uid_list *uid_list) -int emcore_download_uid_all(emf_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(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); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; MAILSTREAM *stream = NULL; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; emcore_uid_list *uid_elem = NULL; emcore_uid_list *fetch_data_p = NULL; void *tmp_stream = NULL; @@ -1843,19 +1849,19 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, if (!mailbox || !uid_list) { EM_DEBUG_EXCEPTION("mailbox[%p], uid_list[%p], total[%p], downloaded_uids[%p], count[%d], for_delete[%d]", mailbox, uid_list, total, downloaded_uids, count, for_delete); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!(ref_account = emcore_get_account_reference(mailbox->account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } if (!mailbox->mail_stream) { - if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->name, (void **)&tmp_stream, &err)){ + if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->mailbox_id, (void **)&tmp_stream, &err)){ EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed..."); goto FINISH_OFF; @@ -1866,11 +1872,11 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, else stream = mailbox->mail_stream; - if (ref_account->receiving_server_type == EMF_SERVER_TYPE_POP3) { /* POP3 */ + if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) { /* POP3 */ POP3LOCAL *pop3local = NULL; if (!stream || !(pop3local = stream->local) || !pop3local->netstream) { - err = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } @@ -1886,7 +1892,7 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, if (!net_sout(pop3local->netstream, cmd, (int)strlen(cmd))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; + err = EMAIL_ERROR_CONNECTION_BROKEN; goto FINISH_OFF; } @@ -1903,7 +1909,7 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, /* replied error "-ERR" */ if (*p == '-') { - err = EMF_ERROR_MAIL_NOT_FOUND; + err = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } @@ -1923,7 +1929,7 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, if (!uid_elem) { EM_DEBUG_EXCEPTION("malloc falied..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -1974,7 +1980,7 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, char *t = NULL; if (!stream || !(imaplocal = stream->local) || !imaplocal->netstream) { - err = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } @@ -1990,7 +1996,7 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, if (!net_sout(imaplocal->netstream, cmd, (int)strlen(cmd))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; + err = EMAIL_ERROR_CONNECTION_BROKEN; goto FINISH_OFF; } @@ -2013,7 +2019,7 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, } if (for_delete == EM_CORE_GET_UIDS_FOR_NO_DELETE) { - if ((ref_account->retrieval_mode == EMF_IMAP4_RETRIEVAL_MODE_NEW) && (strstr(p, "\\Seen"))) { + if ((ref_account->retrieval_mode == EMAIL_IMAP4_RETRIEVAL_MODE_NEW) && (strstr(p, "\\Seen"))) { free(p); p = NULL; continue; } @@ -2023,7 +2029,7 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, if (!uid_elem) { EM_DEBUG_EXCEPTION("malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2035,7 +2041,7 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, t = strchr(s, ' '); if (!t) { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -2054,14 +2060,14 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, t = strchr(s, ')'); if (!t) { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } *t = '\0'; } else { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -2123,15 +2129,15 @@ FINISH_OFF: return ret; } -int emcore_download_imap_msgno(emf_mailbox_t *mailbox, char *uid, int *msgno, int *err_code) +int emcore_download_imap_msgno(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); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; MAILSTREAM *stream = NULL; IMAPLOCAL *imaplocal = NULL; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; void *tmp_stream = NULL; char tag[32], cmd[64]; char *p = NULL; @@ -2139,24 +2145,24 @@ int emcore_download_imap_msgno(emf_mailbox_t *mailbox, char *uid, int *msgno, in if (!mailbox || !uid) { EM_DEBUG_EXCEPTION("mailbox[%p], uid[%p], msgno[%p]", mailbox, uid, msgno); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!(ref_account = emcore_get_account_reference(mailbox->account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - if (ref_account->receiving_server_type != EMF_SERVER_TYPE_IMAP4) { - err = EMF_ERROR_INVALID_ACCOUNT; /* EMF_ERROR_INVALID_PARAM; */ + if (ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) { + err = EMAIL_ERROR_INVALID_ACCOUNT; /* EMAIL_ERROR_INVALID_PARAM; */ goto FINISH_OFF; } if (!mailbox->mail_stream) { - if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->name, (void **)&tmp_stream, &err)) { + if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->mailbox_id, (void **)&tmp_stream, &err)) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed - %d", err); goto FINISH_OFF; @@ -2168,7 +2174,7 @@ int emcore_download_imap_msgno(emf_mailbox_t *mailbox, char *uid, int *msgno, in stream = mailbox->mail_stream; if (!stream || !(imaplocal = stream->local) || !imaplocal->netstream) { - err = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } @@ -2182,7 +2188,7 @@ int emcore_download_imap_msgno(emf_mailbox_t *mailbox, char *uid, int *msgno, in if (!net_sout(imaplocal->netstream, cmd, (int)strlen(cmd))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; + err = EMAIL_ERROR_CONNECTION_BROKEN; goto FINISH_OFF; } @@ -2211,7 +2217,7 @@ int emcore_download_imap_msgno(emf_mailbox_t *mailbox, char *uid, int *msgno, in } if (ret != true) - err = EMF_ERROR_MAIL_NOT_FOUND; + err = EMAIL_ERROR_MAIL_NOT_FOUND; FINISH_OFF: if (p) @@ -2234,12 +2240,12 @@ int emcore_get_msgno(emcore_uid_list *uid_list, char *uid, int *msgno, int *err_ EM_DEBUG_FUNC_BEGIN("uid_list[%p], uid[%s], msgno[%p], err_code[%p]", uid_list, uid, msgno, err_code); int ret = false; - int err = EMF_ERROR_MAIL_NOT_FOUND; /* EMF_ERROR_NONE; */ + int err = EMAIL_ERROR_MAIL_NOT_FOUND; /* EMAIL_ERROR_NONE; */ if (!uid || !msgno || !uid_list) { EM_DEBUG_EXCEPTION("uid_list[%p], uid[%p], msgno[%p]", uid_list, uid, msgno); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2251,7 +2257,7 @@ int emcore_get_msgno(emcore_uid_list *uid_list, char *uid, int *msgno, int *err_ EM_DEBUG_LOG("*msgno[%d]", *msgno); - err = EMF_ERROR_NONE; + err = EMAIL_ERROR_NONE; ret = true; break; @@ -2272,10 +2278,10 @@ int emcore_get_uid(emcore_uid_list *uid_list, int msgno, char **uid, int *err_co { EM_DEBUG_FUNC_BEGIN(); - int ret = false, err = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; if (!uid || msgno <= 0 || !uid_list){ - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2284,7 +2290,7 @@ int emcore_get_uid(emcore_uid_list *uid_list, int msgno, char **uid, int *err_co if (uid) { if (!(*uid = EM_SAFE_STRDUP(uid_list->uid))) { EM_DEBUG_EXCEPTION("strdup failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2297,7 +2303,7 @@ int emcore_get_uid(emcore_uid_list *uid_list, int msgno, char **uid, int *err_co } if (ret != true) - err = EMF_ERROR_MAIL_NOT_FOUND; + err = EMAIL_ERROR_MAIL_NOT_FOUND; FINISH_OFF: if (err_code) @@ -2312,13 +2318,13 @@ int emcore_free_uids(emcore_uid_list *uid_list, int *err_code) EM_DEBUG_FUNC_BEGIN("uid_list[%p], err_code[%p]", uid_list, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emcore_uid_list *p = NULL; if (!uid_list) { EM_DEBUG_EXCEPTION(" uid_list[%p]\n", uid_list); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2358,7 +2364,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int account_id, int mai { EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_id [%d], err_code [%p]", account_id, mail_id, *err_code); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int ret = false; int len = 0; int read_size = 0; @@ -2376,8 +2382,8 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int account_id, int mai emstorage_mailbox_tbl_t *mailbox_tbl = NULL; if (mail_id < 1){ - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2387,7 +2393,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int account_id, int mai goto FINISH_OFF; } - if ( (err = emstorage_get_attachment_list(mail_id, false, &attachment_tbl_data, &attachment_tbl_count)) != EMF_ERROR_NONE) { + if ( (err = emstorage_get_attachment_list(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; } @@ -2400,7 +2406,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int account_id, int mai if (mailbox_tbl->sync_with_server_yn == 0) { EM_DEBUG_EXCEPTION("The mailbox [%s] is not on server.", mail_table_data->mailbox_name); - err = EMF_ERROR_INVALID_MAILBOX; + err = EMAIL_ERROR_INVALID_MAILBOX; goto FINISH_OFF; } @@ -2422,14 +2428,14 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int account_id, int mai if (fname){ if (!(fp = fopen(fname, "a+"))) { EM_DEBUG_EXCEPTION("fopen failed - %s", fname); - err = EMF_ERROR_SYSTEM_FAILURE; + err = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } } if (!fp) { EM_DEBUG_EXCEPTION("fp is NULL..!"); - err = EMF_ERROR_SYSTEM_FAILURE; + err = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -2444,7 +2450,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int account_id, int mai ret = 0; stream = NULL; - if (!emcore_connect_to_remote_mailbox(mail_table_data->account_id, NULL, (void **)&stream, &err)){ + if (!emcore_connect_to_remote_mailbox(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; } @@ -2543,37 +2549,44 @@ FINISH_OFF: #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__ -static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id, char *uid, char *input_mailbox_name, int *err_code) +static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id, char *uid, int input_maibox_id, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_id[%d], uid[%p], input_mailbox_name[%p]", account_id, mail_id, uid, input_mailbox_name); + EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_id[%d], uid[%p], input_maibox_id[%d]", account_id, mail_id, uid, input_maibox_id); int ret = false; - int err = EMF_ERROR_NONE; - emf_account_t *account_ref; + int err = EMAIL_ERROR_NONE; + email_account_t *account_ref; + emstorage_mailbox_tbl_t* mailbox = NULL; - if (account_id < FIRST_ACCOUNT_ID || mail_id < 0 || NULL == uid || NULL == input_mailbox_name){ - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if (account_id < FIRST_ACCOUNT_ID || mail_id < 0 || NULL == uid || 0 == input_maibox_id){ + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } account_ref = emcore_get_account_reference(account_id); - emf_event_partial_body_thd pbd_event; + email_event_partial_body_thd pbd_event; - memset(&pbd_event, 0x00, sizeof(emf_event_partial_body_thd)); + memset(&pbd_event, 0x00, sizeof(email_event_partial_body_thd)); pbd_event.account_id = account_id; - if (account_ref && account_ref->receiving_server_type == EMF_SERVER_TYPE_POP3) + if (account_ref && account_ref->incoming_server_type == EMAIL_SERVER_TYPE_POP3) pbd_event.activity_type = ACTIVITY_PARTIAL_BODY_DOWNLOAD_POP3_WAIT; 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_name = EM_SAFE_STRDUP(input_mailbox_name); - pbd_event.mail_id = mail_id; + 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); - EM_DEBUG_LOG("input_mailbox_name name [%s]", pbd_event.mailbox_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); @@ -2588,7 +2601,7 @@ static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id, on the basis of activity_type and event_type fields */ pbd_event.activity_type = 0; - pbd_event.event_type = EMF_EVENT_BULK_PARTIAL_BODY_DOWNLOAD; + pbd_event.event_type = EMAIL_EVENT_BULK_PARTIAL_BODY_DOWNLOAD; if (!emcore_insert_partial_body_thread_event(&pbd_event, &err)){ EM_DEBUG_EXCEPTION("Inserting Partial body thread event failed with error[%d]", err); @@ -2608,6 +2621,10 @@ static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id, FINISH_OFF: + if (mailbox) { + emstorage_free_mailbox(&mailbox, 1, &err); + } + if (NULL != err_code) *err_code = err; @@ -2622,7 +2639,7 @@ static int emcore_parse_html_part_for_partial_body(char *start_header, char *bou { EM_DEBUG_FUNC_BEGIN("start_header [%s], boundary_string [%s], bufsendforparse [%s], text_html [%s], body_size [%d]", start_header, boundary_string, bufsendforparse, text_html, body_size); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int html_uidno = 0; int iEncodingHeader = 0; int enc_type = ENCOTHER, dec_len = 0, html_length = 0; @@ -2689,7 +2706,7 @@ static int emcore_parse_html_part_for_partial_body(char *start_header, char *bou EM_DEBUG_LOG("end [%p], txt_html [%p]", end, txt_html); if (end == NULL) { - EM_DEBUG_LOG("HTML body contents exceeds %d Bytes", PARTIAL_BODY_SIZE_IN_BYTES); + EM_DEBUG_LOG("HTML body contents exceeds limited Bytes"); end = txt_html + body_size - (txt_html - bufsendforparse); html_uidno = 1; @@ -2783,7 +2800,7 @@ static int emcore_parse_html_part_for_partial_body(char *start_header, char *bou 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[%s], start_header[%s], boundary_string [%s], bufsendforparse [%s], text_plain [%s]", header_start_string, start_header, boundary_string, bufsendforparse, text_plain); - int err = EMF_ERROR_NONE, iEncodingHeader = 0, enc_type = ENCOTHER; + 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, }; @@ -2822,7 +2839,7 @@ static int emcore_parse_plain_part_for_partial_body(char *header_start_string, c end = strstr(txt_plain, boundary_string); if (end == NULL){ - EM_DEBUG_LOG("Text body contents exceeds %d Bytes", PARTIAL_BODY_SIZE_IN_BYTES); + EM_DEBUG_LOG("Text body contents exceeds limited Bytes"); end = txt_plain + body_size - (txt_plain - bufsendforparse); } else{ @@ -2893,14 +2910,14 @@ static int emcore_parse_plain_part_for_partial_body(char *header_start_string, c /* Content-Type: IMAGE/octet-stream; name = Default.png */ /* Content-Transfer-Encoding: BASE64 */ -/* Content-ID: <4b0d6810b17291f9438783a8eb9d5228@com.samsung.slp.email> */ +/* Content-ID: <4b0d6810b17291f9438783a8eb9d5228@org.tizen.email> */ /* Content-Disposition: inline; filename = Default.png */ -static int emcore_parse_image_part_for_partial_body(char *header_start_string, char *start_header, char *boundary_string, char *bufsendforparse, emf_image_data *image_data, int body_size) +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(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char *multiple_image = NULL; int donot_parse_next_image = 0; char *image_boundary = NULL; @@ -2915,6 +2932,11 @@ static int emcore_parse_image_part_for_partial_body(char *header_start_string, c char *cid_end = NULL; char *temp_enc1 = NULL; + if(image_data == NULL) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; + return 0; + } image_boundary = start_header; image_boundary_end = image_boundary - 2; @@ -2951,6 +2973,7 @@ static int emcore_parse_image_part_for_partial_body(char *header_start_string, c int boundarylen = -1; char *cid = NULL; char *temp_name = NULL; + char *decoded_filename = NULL; memset(image_data[i].image_file_name, 0, 100); txt_image = start_header; @@ -2973,6 +2996,13 @@ static int emcore_parse_image_part_for_partial_body(char *header_start_string, c if ((*(temp_name+4) == '=') && (*(temp_name+5) != '\"')) image_data[i].image_file_name[ch_image-1] = '\0'; + + decoded_filename = emcore_decode_rfc2047_text(image_data[i].image_file_name, &err); + if(decoded_filename) { + memset(image_data[i].image_file_name, 0, 100); + 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)){ @@ -2985,7 +3015,7 @@ static int emcore_parse_image_part_for_partial_body(char *header_start_string, c 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){ + 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); } @@ -3005,7 +3035,7 @@ static int emcore_parse_image_part_for_partial_body(char *header_start_string, c if (end == NULL){ - EM_DEBUG_LOG("HTML body contents exceeds %d Bytes", PARTIAL_BODY_SIZE_IN_BYTES); + 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); } @@ -3073,12 +3103,12 @@ static int emcore_parse_image_part_for_partial_body(char *header_start_string, c 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 = EMF_ERROR_NONE; + 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("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -3097,7 +3127,7 @@ static int emcore_find_boundary_string_of_the_part(const char *whole_string, con boundary_string = em_malloc(boundary_end - boundary_cur + 15); if(!boundary_string) { EM_DEBUG_EXCEPTION("em_malloc failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } memcpy(boundary_string, boundary_cur, boundary_end - boundary_cur); @@ -3106,13 +3136,13 @@ static int emcore_find_boundary_string_of_the_part(const char *whole_string, con } else { EM_DEBUG_EXCEPTION("There is no string before the part"); - err = EMF_ERROR_ON_PARSING; + err = EMAIL_ERROR_ON_PARSING; goto FINISH_OFF; } } else { EM_DEBUG_EXCEPTION("There is no string before the part"); - err = EMF_ERROR_ON_PARSING; + err = EMAIL_ERROR_ON_PARSING; goto FINISH_OFF; } ret = true; @@ -3127,11 +3157,11 @@ FINISH_OFF: #define TAG_LENGTH 16 #define COMMAND_LENGTH 2000 -INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *stream, emf_event_partial_body_thd *pbd_event, int item_count, int *error) +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], pbd_event [%p], item_count [%d], error [%p]", stream, pbd_event, item_count, 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 = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; int encoding = 0; int j = 0; int i32_index = 0, temp_string_index = 0; @@ -3141,9 +3171,9 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st int total_parsed_len_per_uid = 0, total_parsed_len = 0; unsigned long uidno = 0; char buf[512] = {0, }; - char text_plain[PARTIAL_BODY_SIZE_IN_BYTES + 1] = {0, }; - char text_html[PARTIAL_BODY_SIZE_IN_BYTES + 1] = {0, }; - char temp_text_buf[PARTIAL_BODY_SIZE_IN_BYTES + 1] = {0, }; + char *text_plain = NULL; + char *text_html = NULL; + char *temp_text_buf = NULL; char uid_range_string_to_be_downloaded[UID_RANGE_STRING_LENGTH] = {0, }; char imap_tag[TAG_LENGTH] = {0, }; char command[COMMAND_LENGTH] = {0, }; @@ -3153,28 +3183,42 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st char *start_header = NULL; char *boundary_string = NULL; char *temp_content_type1 = NULL; + char *temp_data_html = NULL; char *bodystructure_start = NULL, *bodystructure_end = NULL, *body_structure_string = NULL, *modified_body_structure_string = NULL; char *plain_text_file_name_from_content_info = NULL, *html_text_file_name_from_content_info = NULL, *plain_charset_from_content_info = NULL; char temp_string[TEMP_STRING_LENGTH] = {0, }; IMAPLOCAL *imaplocal = NULL; IMAPPARSEDREPLY *reply_from_server = NULL; emstorage_mail_tbl_t *mail = NULL; - emf_partial_buffer *imap_response = NULL; + email_partial_buffer *imap_response = NULL; BODY *body = NULL; struct _m_content_info *cnt_info = NULL; struct attachment_info *attach_info = NULL; emstorage_attachment_tbl_t attachment_tbl; - emf_event_partial_body_thd *stSectionNo = NULL; - emf_image_data image_data[IMAGE_DISPLAY_PARTIAL_BODY_COUNT]; + email_event_partial_body_thd *stSectionNo = NULL; + email_image_data image_data[IMAGE_DISPLAY_PARTIAL_BODY_COUNT]; if (!(stream) || !(imaplocal = stream->local) || !imaplocal->netstream || !pbd_event) { EM_DEBUG_EXCEPTION("invalid parameter"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; } - memset(image_data, 0x00 , sizeof(emf_image_data) * IMAGE_DISPLAY_PARTIAL_BODY_COUNT); + text_plain = em_malloc(sizeof(char) * (input_download_size + 1)); + text_html = em_malloc(sizeof(char) * (input_download_size + 1)); + temp_text_buf = em_malloc(sizeof(char) * (input_download_size + 1)); + + if(!text_plain || !text_plain || !temp_text_buf) { + EM_SAFE_FREE(text_plain); + EM_SAFE_FREE(text_html); + EM_SAFE_FREE(temp_text_buf); + + EM_DEBUG_EXCEPTION("em_malloc failed"); + return EMAIL_ERROR_OUT_OF_MEMORY; + } + + memset(image_data, 0x00 , sizeof(email_image_data) * IMAGE_DISPLAY_PARTIAL_BODY_COUNT); EM_DEBUG_LOG("Start of emcore_get_section_for_partial_download, item_count = %d ", item_count); @@ -3196,19 +3240,19 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st } SNPRINTF(imap_tag, TAG_LENGTH, "%08lx", 0xffffffff & (stream->gensym++)); - SNPRINTF(command, COMMAND_LENGTH, "%s UID FETCH %s (BODYSTRUCTURE BODY.PEEK[TEXT]<0.15360>)\015\012", imap_tag, uid_range_string_to_be_downloaded); + 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)strlen(command))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; + 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); + imap_response = emcore_get_response_from_server(imaplocal->netstream, imap_tag, &reply_from_server, input_download_size); if (!imap_response || !reply_from_server ){ EM_DEBUG_EXCEPTION(" Invalid response from emcore_get_response_from_server"); @@ -3236,7 +3280,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st if (bodystructure_length > response_buffer_length){ EM_DEBUG_EXCEPTION("bodystructure_length[%d] is longer than response_buffer_length[%d]", bodystructure_length, response_buffer_length); - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -3244,7 +3288,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st if (NULL == body_structure_string){ EM_DEBUG_EXCEPTION("em_malloc failed...!"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -3277,7 +3321,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st if (!(cnt_info = em_malloc(sizeof(struct _m_content_info)))) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -3285,7 +3329,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st if (emcore_get_body(stream, 0, 0, 0, body, cnt_info, &err) < 0 || !cnt_info) { EM_DEBUG_EXCEPTION("emcore_get_body falied [%d]", err); - err = EMF_ERROR_IMAP4_FETCH_UID_FAILURE; + err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE; goto FINISH_OFF; } @@ -3310,14 +3354,14 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st } body_size = atoi(temp_string); - if (body_size > PARTIAL_BODY_SIZE_IN_BYTES) - body_size = PARTIAL_BODY_SIZE_IN_BYTES; + if (body_size >= input_download_size) + body_size = input_download_size + 2; EM_DEBUG_LOG("body_size [%d]", body_size); } else{ body_size = 0; EM_DEBUG_EXCEPTION("Can't find body size from MIME header"); - /* err = EMF_ERROR_INVALID_RESPONSE; */ + /* err = EMAIL_ERROR_INVALID_RESPONSE; */ /* goto FINISH_OFF; */ } @@ -3328,8 +3372,8 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st tempmailparselen++; if (imap_response->buflen < (total_parsed_len + body_size)){ - err = EMF_ERROR_CONNECTION_BROKEN; - EM_DEBUG_EXCEPTION("EMF_ERROR_CONNECTION_BROKEN : imap_response->buflen [%d], total_parsed_len [%d], body_size [%d]", imap_response->buflen, total_parsed_len, body_size); + err = EMAIL_ERROR_CONNECTION_BROKEN; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_CONNECTION_BROKEN : imap_response->buflen [%d], total_parsed_len [%d], body_size [%d]", imap_response->buflen, total_parsed_len, body_size); goto FINISH_OFF; } else { @@ -3378,7 +3422,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st if (!emstorage_get_maildata_by_servermailid(pbd_event[temp_count].account_id, temp_string, &mail , true, &err) || !mail){ EM_DEBUG_EXCEPTION("emstorage_get_maildata_by_servermailid failed [%d]", err); - if (err == EMF_ERROR_MAIL_NOT_FOUND || !mail) + if (err == EMAIL_ERROR_MAIL_NOT_FOUND || !mail) goto FINISH_OFF; } @@ -3388,11 +3432,11 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st /* Update attachment details except inline content */ if (cnt_info->file && cnt_info->file->name){ - memset(&attachment_tbl, 0x00, sizeof(emf_attachment_info_t)); + memset(&attachment_tbl, 0x00, sizeof(email_attachment_data_t)); attachment_tbl.account_id = pbd_event[temp_count].account_id; attachment_tbl.mail_id = mail->mail_id; - attachment_tbl.mailbox_name = pbd_event[temp_count].mailbox_name; + attachment_tbl.mailbox_id = pbd_event[temp_count].mailbox_id; attachment_tbl.attachment_save_status = 0; for (attachment_num = 1, attach_info = cnt_info->file; attach_info; attach_info = attach_info->next, attachment_num++) { @@ -3452,7 +3496,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st if (bufsendforparse == NULL){ EM_DEBUG_EXCEPTION("Allocation for bufsendforparse failed."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -3467,7 +3511,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st EM_DEBUG_LOG("string bufendforparse :[%s]", bufsendforparse); p = bufsendforparse; - if (mail && mail->body_download_status == EMF_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED) /* No need to save */ + if (mail && mail->body_download_status == EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED) /* No need to save */ goto NEXTUIDPARSING; if (!strcasestr(p, "Content-Type: text/plain") && !strcasestr(p, "Content-Type: text/html") && !strcasestr(p, "Content-type: image/jpeg") @@ -3504,7 +3548,6 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st } else{ /* 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, "Content-type: multipart/alternative")) != NULL)){ /* Found 'alternative' */ if (((temp_content_type1 = (char *)strcasestr(p, "Content-type: text/plain")) != NULL)){ if (temp_content_type1 < temp_alternative_plain_header) /* This part is text/plain not alternative. */ @@ -3579,6 +3622,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st } if (((start_header = (char *)strcasestr((const char *)p, "Content-type: image/jpeg")) != (char *)NULL) || + ((start_header = (char *)strcasestr((const char *)p, "Content-Type: image/jpg")) != (char *)NULL) || ((start_header = (char *)strcasestr((const char *)p, "Content-Type: image/gif")) != (char *)NULL) || ((start_header = (char *)strcasestr((const char *)p, "Content-Type: image/bmp")) != (char *)NULL) || ((start_header = (char *)strcasestr((const char *)p, "Content-Type: image/png")) != (char *)NULL)) @@ -3604,10 +3648,17 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st if (image_data[0].text_image != NULL && image_data[0].text_image[0] != NULL_CHAR){ char *result_string_of_replcaing = NULL; - char temp_data_html[PARTIAL_BODY_SIZE_IN_BYTES + 1] = {0}; int store_file = 0; int content_index = 0; + temp_data_html = em_malloc(sizeof(char) * (input_download_size + 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[0] != NULL_CHAR) memcpy(temp_data_html, text_html, strlen(text_html)); @@ -3623,11 +3674,11 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st 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 != EMF_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED){ + 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_name = stream->mailbox; + 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; @@ -3647,7 +3698,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st 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. */ result_string_of_replcaing = em_replace_string((char *)temp_data_html, (char *)image_data[content_index].content_id, (char *)image_data[content_index].image_file_name); - EM_SAFE_STRNCPY(temp_data_html, result_string_of_replcaing, PARTIAL_BODY_SIZE_IN_BYTES); + EM_SAFE_STRNCPY(temp_data_html, result_string_of_replcaing, input_download_size); EM_SAFE_FREE(result_string_of_replcaing); if (strstr(temp_data_html, image_data[content_index].content_id) != NULL) @@ -3662,11 +3713,13 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st } image_length = 0; - memset(text_html, 0, PARTIAL_BODY_SIZE_IN_BYTES+1); + memset(text_html, 0, (input_download_size + 1)); if (temp_data_html[0] != NULL_CHAR) memcpy(text_html, temp_data_html, strlen(temp_data_html)); - memset(temp_data_html, 0x00, PARTIAL_BODY_SIZE_IN_BYTES+1); + memset(temp_data_html, 0x00, (input_download_size + 1)); + + EM_SAFE_FREE(temp_data_html); } if (strlen(text_html) > 0){ @@ -3696,11 +3749,11 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *st } - mail->body_download_status = (total_mail_size_except_attach < PARTIAL_BODY_SIZE_IN_BYTES) ? 1 : 2; + mail->body_download_status = (total_mail_size_except_attach < input_download_size) ? 1 : 2; EM_DEBUG_LOG("total_mail_size_except_attach [%d], mail->body_download_status [%d]", total_mail_size_except_attach, 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))) != EMF_ERROR_NONE) + 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 */ @@ -3726,9 +3779,9 @@ NEXTUIDPARSING: EM_SAFE_FREE(bufsendforparse); - memset(text_html, 0, PARTIAL_BODY_SIZE_IN_BYTES+1); - memset(text_plain, 0, PARTIAL_BODY_SIZE_IN_BYTES+1); - memset(temp_text_buf, 0, PARTIAL_BODY_SIZE_IN_BYTES+1); + memset(text_html, 0, input_download_size+1); + memset(text_plain, 0, input_download_size+1); + memset(temp_text_buf, 0, input_download_size+1); if (mail) emstorage_free_mail(&mail, 1, NULL); @@ -3763,6 +3816,10 @@ FINISH_OFF: EM_SAFE_FREE(reply_from_server); } + EM_SAFE_FREE(text_plain); + EM_SAFE_FREE(text_html); + EM_SAFE_FREE(temp_text_buf); + EM_SAFE_FREE(bufsendforparse); EM_SAFE_FREE(plain_text_file_name_from_content_info); EM_SAFE_FREE(html_text_file_name_from_content_info); @@ -3785,15 +3842,15 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_pop3(MAILSTREAM *stream, emf_event_partial_body_thd *pbd_event, int item_count, int *error) +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); - int ret = false, err = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; int i; if (!stream || !pbd_event) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -3801,7 +3858,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_pop3(MAILSTREAM *st EM_DEBUG_LOG("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); - if (!emcore_download_body_multi_sections_bulk(stream, pbd_event[i].account_id, pbd_event[i].mail_id, false, false, PARTIAL_BODY_SIZE_IN_BYTES, 0 , &err)){ + if (!emcore_download_body_multi_sections_bulk(stream, pbd_event[i].account_id, pbd_event[i].mail_id, false, false, input_download_size, 0 , &err)){ EM_DEBUG_EXCEPTION("emcore_download_body_multi_sections_bulk failed"); goto FINISH_OFF; } @@ -3824,35 +3881,35 @@ FINISH_OFF: -INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream, emf_event_partial_body_thd *pbd_event, int item_count, int *error) +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); - int ret = false, err = EMF_ERROR_NONE; - emf_account_t *pbd_account = NULL; + int ret = false, err = EMAIL_ERROR_NONE; + emstorage_account_tbl_t *pbd_account_tbl = NULL; + int auto_download_size = 0; if (!stream || !pbd_event) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - pbd_account = emcore_get_account_reference(pbd_event[0].account_id); - - if (pbd_account == NULL){ - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_ACCOUNT"); - err = EMF_ERROR_INVALID_ACCOUNT; + if (!emstorage_get_account_by_id(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; } - switch (pbd_account->receiving_server_type){ - case EMF_SERVER_TYPE_IMAP4: - ret = emcore_download_bulk_partial_mail_body_for_imap(stream, pbd_event, item_count, &err); + 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: + ret = emcore_download_bulk_partial_mail_body_for_imap(stream, auto_download_size, pbd_event, item_count, &err); break; - case EMF_SERVER_TYPE_POP3: - ret = emcore_download_bulk_partial_mail_body_for_pop3(stream, pbd_event, item_count, &err); + case EMAIL_SERVER_TYPE_POP3: + ret = emcore_download_bulk_partial_mail_body_for_pop3(stream, auto_download_size, pbd_event, item_count, &err); break; default: - err = EMF_ERROR_NOT_SUPPORTED; + err = EMAIL_ERROR_NOT_SUPPORTED; ret = false; break; } @@ -3867,25 +3924,25 @@ FINISH_OFF: } -static emf_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply) +static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply, int input_download_size) { EM_DEBUG_FUNC_BEGIN(); if (!nstream || !tag || !reply){ - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); return NIL; } - emf_partial_buffer *retPartialBuffer = NULL; + email_partial_buffer *retPartialBuffer = NULL; IMAPPARSEDREPLY *ret_reply = NULL; char *pline = NULL; int linelen = 0; int bytes_copied = 0; int temp_body_buffer_size = 0; int flags = 0; - int allocated_buffer_size = (BULK_PARTIAL_BODY_DOWNLOAD_COUNT + 2) * PARTIAL_BODY_SIZE_IN_BYTES ; + int allocated_buffer_size = (BULK_PARTIAL_BODY_DOWNLOAD_COUNT + 2) * input_download_size ; - retPartialBuffer = (emf_partial_buffer *)em_malloc(sizeof(emf_partial_buffer)); + retPartialBuffer = (email_partial_buffer *)em_malloc(sizeof(email_partial_buffer)); if (NULL == retPartialBuffer){ EM_DEBUG_EXCEPTION("em_malloc failed"); @@ -3918,13 +3975,13 @@ static emf_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, temp_body_buffer_size = temp_body_buffer_size + linelen + 2; } - if (temp_body_buffer_size > PARTIAL_BODY_SIZE_IN_BYTES && !flags) { - linelen = linelen - (temp_body_buffer_size - PARTIAL_BODY_SIZE_IN_BYTES); - temp_body_buffer_size = PARTIAL_BODY_SIZE_IN_BYTES; + if (temp_body_buffer_size > input_download_size && !flags) { + linelen = linelen - (temp_body_buffer_size - input_download_size) + 2; + temp_body_buffer_size = input_download_size; flags = 1; } - if (temp_body_buffer_size <= PARTIAL_BODY_SIZE_IN_BYTES) { + if (temp_body_buffer_size <= input_download_size) { memcpy(retPartialBuffer->buffer + bytes_copied, pline, linelen); bytes_copied += linelen; memcpy(retPartialBuffer->buffer + bytes_copied, CRLF_STRING, 2); diff --git a/email-core/email-core-mailbox.c b/email-core/email-core-mailbox.c index 4df8c4c..9d08caf 100755 --- a/email-core/email-core-mailbox.c +++ b/email-core/email-core-mailbox.c @@ -52,52 +52,40 @@ extern int recv_thread_run; static void *g_partial_body_thd_stream = NULL; /* Stores the pb thd stream for next time reuse */ static int prev_acc_id_pb_thd = 0; /* Stores the account id for which pb thd stream is open */ -__thread emf_connection_info_t *g_connection_info_list = NULL; +__thread email_connection_info_t *g_connection_info_list = NULL; static pthread_mutex_t _close_stream_lock = PTHREAD_MUTEX_INITIALIZER; /* Mutex to protect closing stream */ #endif /* __FEATURE_KEEP_CONNECTION__ */ /* Binding IMAP mailbox with its function */ -static emf_mailbox_type_item_t g_mailbox_type[MAX_MAILBOX_TYPE] = { - {EMF_MAILBOX_TYPE_INBOX, "INBOX" }, +static email_mailbox_type_item_t g_mailbox_type[MAX_MAILBOX_TYPE] = { + {EMAIL_MAILBOX_TYPE_INBOX, "INBOX" }, /* Naver */ - {EMF_MAILBOX_TYPE_INBOX, "Inbox" }, - {EMF_MAILBOX_TYPE_SENTBOX, "Sent Messages"} , - {EMF_MAILBOX_TYPE_SPAMBOX, "&wqTTOLpUx3zVaA-"} , - {EMF_MAILBOX_TYPE_DRAFT, "Drafts"} , - {EMF_MAILBOX_TYPE_TRASH, "Deleted Messages" } , - /* Google English */ - {EMF_MAILBOX_TYPE_SENTBOX, "[Gmail]/Sent Mail"} , - {EMF_MAILBOX_TYPE_SPAMBOX, "[Gmail]/Spam"} , - {EMF_MAILBOX_TYPE_DRAFT, "[Gmail]/Drafts"} , - {EMF_MAILBOX_TYPE_TRASH, "[Gmail]/Trash" } , - {EMF_MAILBOX_TYPE_ALL_EMAILS, "[Gmail]/All Mail" } , - /* Google Korean */ - {EMF_MAILBOX_TYPE_SENTBOX, "[Gmail]/&vPSwuNO4ycDVaA-"} , - {EMF_MAILBOX_TYPE_SPAMBOX, "[Gmail]/&wqTTONVo-" }, - {EMF_MAILBOX_TYPE_DRAFT, "[Gmail]/&x4TC3Lz0rQDVaA-"} , - {EMF_MAILBOX_TYPE_TRASH, "[Gmail]/&1zTJwNG1-"} , - {EMF_MAILBOX_TYPE_ALL_EMAILS, "[Gmail]/&yATMtLz0rQDVaA-" } , + {EMAIL_MAILBOX_TYPE_INBOX, "Inbox" }, + {EMAIL_MAILBOX_TYPE_SENTBOX, "Sent Messages"} , + {EMAIL_MAILBOX_TYPE_SPAMBOX, "&wqTTOLpUx3zVaA-"} , + {EMAIL_MAILBOX_TYPE_DRAFT, "Drafts"} , + {EMAIL_MAILBOX_TYPE_TRASH, "Deleted Messages" } , /* AOL */ - {EMF_MAILBOX_TYPE_SENTBOX, "Sent"} , - {EMF_MAILBOX_TYPE_SPAMBOX, "Spam" }, - {EMF_MAILBOX_TYPE_DRAFT, "Drafts"} , - {EMF_MAILBOX_TYPE_TRASH, "Trash"}, + {EMAIL_MAILBOX_TYPE_SENTBOX, "Sent"} , + {EMAIL_MAILBOX_TYPE_SPAMBOX, "Spam" }, + {EMAIL_MAILBOX_TYPE_DRAFT, "Drafts"} , + {EMAIL_MAILBOX_TYPE_TRASH, "Trash"}, /* DAUM */ - {EMF_MAILBOX_TYPE_SPAMBOX, "&wqTTONO4ycDVaA-"}, + {EMAIL_MAILBOX_TYPE_SPAMBOX, "&wqTTONO4ycDVaA-"}, /* ETC */ - {EMF_MAILBOX_TYPE_SENTBOX, "mail/sent-mail"}, - {EMF_MAILBOX_TYPE_SPAMBOX, "mail/spam-mail" }, - {EMF_MAILBOX_TYPE_DRAFT, "mail/saved-drafts"} , - {EMF_MAILBOX_TYPE_TRASH, "mail/mail-trash"}, + {EMAIL_MAILBOX_TYPE_SENTBOX, "mail/sent-mail"}, + {EMAIL_MAILBOX_TYPE_SPAMBOX, "mail/spam-mail" }, + {EMAIL_MAILBOX_TYPE_DRAFT, "mail/saved-drafts"} , + {EMAIL_MAILBOX_TYPE_TRASH, "mail/mail-trash"}, }; #ifdef __FEATURE_KEEP_CONNECTION__ -emf_connection_info_t* emcore_get_connection_info_by_account_id(int account_id) +email_connection_info_t* emcore_get_connection_info_by_account_id(int account_id) { EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id); - emf_connection_info_t *connection_info = g_connection_info_list; + email_connection_info_t *connection_info = g_connection_info_list; while(connection_info) { if(connection_info->account_id == account_id) @@ -109,19 +97,19 @@ emf_connection_info_t* emcore_get_connection_info_by_account_id(int account_id) return connection_info; } -int emcore_append_connection_info(emf_connection_info_t *new_connection_info) +int emcore_append_connection_info(email_connection_info_t *new_connection_info) { EM_DEBUG_FUNC_BEGIN("new_connection_info [%p]", new_connection_info); - emf_connection_info_t *connection_info = g_connection_info_list; + email_connection_info_t *connection_info = g_connection_info_list; if(!new_connection_info) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } if(emcore_get_connection_info_by_account_id(new_connection_info->account_id)) { - EM_DEBUG_EXCEPTION("EMF_ERROR_ALREADY_EXISTS"); - return EMF_ERROR_ALREADY_EXISTS; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_ALREADY_EXISTS"); + return EMAIL_ERROR_ALREADY_EXISTS; } if(connection_info) { @@ -138,14 +126,14 @@ int emcore_append_connection_info(emf_connection_info_t *new_connection_info) g_connection_info_list = new_connection_info; } - EM_DEBUG_FUNC_END("EMF_ERROR_NONE"); - return EMF_ERROR_NONE; + EM_DEBUG_FUNC_END("EMAIL_ERROR_NONE"); + return EMAIL_ERROR_NONE; } INTERNAL_FUNC int emcore_remove_connection_info(int account_id) { EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id); - emf_connection_info_t *connection_info = g_connection_info_list, *prev_connection_info = NULL; + email_connection_info_t *connection_info = g_connection_info_list, *prev_connection_info = NULL; while(connection_info) { if(connection_info->account_id == account_id) { @@ -163,7 +151,7 @@ INTERNAL_FUNC int emcore_remove_connection_info(int account_id) } EM_DEBUG_FUNC_END(""); - return EMF_ERROR_NONE; + return EMAIL_ERROR_NONE; } #endif /* __FEATURE_KEEP_CONNECTION__ */ @@ -172,58 +160,56 @@ INTERNAL_FUNC int emcore_remove_connection_info(int account_id) /* description * get local mailbox list */ -INTERNAL_FUNC int emcore_get_list(int account_id, emf_mailbox_t **mailbox_list, int *p_count, int *err_code) +INTERNAL_FUNC int emcore_get_list(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); 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); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; emstorage_mailbox_tbl_t *local_mailbox_list = NULL; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; int i, count = 512; /* get mailbox list from mailbox table */ if (!(ref_account = emcore_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION(" emcore_get_account_reference failed - %d", account_id); - error = EMF_ERROR_INVALID_ACCOUNT; + error = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - if (!emstorage_get_mailbox(ref_account->account_id, EMF_MAILBOX_ALL, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &count, &local_mailbox_list, true, &error)) { + if (!emstorage_get_mailbox_list(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; } if (count > 0) { - if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * count))) { + if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * count))) { EM_DEBUG_EXCEPTION(" mailloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - memset(*mailbox_list, 0x00, (sizeof(emf_mailbox_t) * count)); + memset(*mailbox_list, 0x00, (sizeof(email_mailbox_t) * count)); for (i = 0; i < count; i++) { (*mailbox_list)[i].mailbox_id = local_mailbox_list[i].mailbox_id; (*mailbox_list)[i].account_id = account_id; - (*mailbox_list)[i].name = local_mailbox_list[i].mailbox_name; local_mailbox_list[i].mailbox_name = NULL; + (*mailbox_list)[i].mailbox_name = local_mailbox_list[i].mailbox_name; local_mailbox_list[i].mailbox_name = NULL; (*mailbox_list)[i].alias = local_mailbox_list[i].alias; local_mailbox_list[i].alias = NULL; (*mailbox_list)[i].local = local_mailbox_list[i].local_yn; (*mailbox_list)[i].mailbox_type = local_mailbox_list[i].mailbox_type; - (*mailbox_list)[i].synchronous = local_mailbox_list[i].sync_with_server_yn; (*mailbox_list)[i].unread_count = local_mailbox_list[i].unread_count; (*mailbox_list)[i].total_mail_count_on_local = local_mailbox_list[i].total_mail_count_on_local; (*mailbox_list)[i].total_mail_count_on_server = local_mailbox_list[i].total_mail_count_on_server; - (*mailbox_list)[i].has_archived_mails = local_mailbox_list[i].has_archived_mails; (*mailbox_list)[i].mail_slot_size = local_mailbox_list[i].mail_slot_size; } } @@ -248,54 +234,53 @@ FINISH_OFF: /* description * get imap sync mailbox list */ -int emcore_get_list_to_be_sync(int account_id, emf_mailbox_t **mailbox_list, int *p_count, int *err_code) +int emcore_get_mailbox_list_to_be_sync(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); if (account_id <= 0 || !mailbox_list || !p_count) { EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_list[%p], p_count[%p]", account_id, mailbox_list, p_count); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; - emf_mailbox_t *tmp_mailbox_list = NULL; + int error = EMAIL_ERROR_NONE; + email_mailbox_t *tmp_mailbox_list = NULL; emstorage_mailbox_tbl_t *mailbox_tbl_list = NULL; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; int i, count = 512; /* get mailbox list from mailbox table */ if (!(ref_account = emcore_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", account_id); - error = EMF_ERROR_INVALID_ACCOUNT; + error = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - if (!emstorage_get_mailbox(ref_account->account_id, 0, EMAIL_MAILBOX_SORT_BY_TYPE_ASC, &count, &mailbox_tbl_list, true, &error)) { + if (!emstorage_get_mailbox_list(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; } if (count > 0) { - if (!(tmp_mailbox_list = em_malloc(sizeof(emf_mailbox_t) * count))) { + if (!(tmp_mailbox_list = em_malloc(sizeof(email_mailbox_t) * count))) { EM_DEBUG_EXCEPTION("malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - memset(tmp_mailbox_list, 0x00, (sizeof(emf_mailbox_t) * count)); + memset(tmp_mailbox_list, 0x00, (sizeof(email_mailbox_t) * count)); for (i = 0; i < count; i++) { tmp_mailbox_list[i].mailbox_id = mailbox_tbl_list[i].mailbox_id; tmp_mailbox_list[i].account_id = account_id; - tmp_mailbox_list[i].name = mailbox_tbl_list[i].mailbox_name; mailbox_tbl_list[i].mailbox_name = NULL; + tmp_mailbox_list[i].mailbox_name = mailbox_tbl_list[i].mailbox_name; mailbox_tbl_list[i].mailbox_name = NULL; tmp_mailbox_list[i].mailbox_type = mailbox_tbl_list[i].mailbox_type; tmp_mailbox_list[i].alias = mailbox_tbl_list[i].alias; mailbox_tbl_list[i].alias = NULL; tmp_mailbox_list[i].local = mailbox_tbl_list[i].local_yn; - tmp_mailbox_list[i].synchronous = mailbox_tbl_list[i].sync_with_server_yn; tmp_mailbox_list[i].unread_count = mailbox_tbl_list[i].unread_count; tmp_mailbox_list[i].total_mail_count_on_local = mailbox_tbl_list[i].total_mail_count_on_local; tmp_mailbox_list[i].total_mail_count_on_server = mailbox_tbl_list[i].total_mail_count_on_server; @@ -321,20 +306,20 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_get_mail_count(emf_mailbox_t *mailbox, int *total, int *unseen, int *err_code) +INTERNAL_FUNC int emcore_get_mail_count(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); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!mailbox) { EM_DEBUG_EXCEPTION(" mailbox[%p], total[%p], unseen[%p]", mailbox, total, unseen); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (!emstorage_get_mail_count(mailbox->account_id, mailbox->name, total, unseen, true, &err)) { + if (!emstorage_get_mail_count(mailbox->account_id, mailbox->mailbox_name, total, unseen, true, &err)) { EM_DEBUG_EXCEPTION(" emstorage_get_mail_count failed - %d", err); goto FINISH_OFF; @@ -350,15 +335,15 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_create_mailbox(emf_mailbox_t *new_mailbox, int on_server, int *err_code) +INTERNAL_FUNC int emcore_create_mailbox(email_mailbox_t *new_mailbox, int on_server, int *err_code) { EM_DEBUG_FUNC_BEGIN("new_mailbox[%p], err_code[%p]", new_mailbox, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_mailbox_tbl_t local_mailbox; - if (new_mailbox == NULL || new_mailbox->name == NULL) { - err = EMF_ERROR_INVALID_PARAM; + if (new_mailbox == NULL || new_mailbox->mailbox_name == NULL) { + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -374,35 +359,36 @@ INTERNAL_FUNC int emcore_create_mailbox(emf_mailbox_t *new_mailbox, int on_serve } memset(&local_mailbox, 0x00, sizeof(emstorage_mailbox_tbl_t)); - EM_DEBUG_LOG("box name[%s] local yn[%d] mailbox_type[%d]", new_mailbox->name, local_mailbox.local_yn, new_mailbox->mailbox_type); + EM_DEBUG_LOG("box name[%s] local yn[%d] mailbox_type[%d]", new_mailbox->mailbox_name, local_mailbox.local_yn, new_mailbox->mailbox_type); /* add local mailbox into local mailbox table */ local_mailbox.mailbox_id = new_mailbox->mailbox_id; local_mailbox.account_id = new_mailbox->account_id; local_mailbox.local_yn = new_mailbox->local; - local_mailbox.mailbox_name = new_mailbox->name; + local_mailbox.sync_with_server_yn = local_mailbox.local_yn ? 0 : 1; + local_mailbox.mailbox_name = new_mailbox->mailbox_name; local_mailbox.alias = new_mailbox->alias; - local_mailbox.sync_with_server_yn = new_mailbox->synchronous; local_mailbox.mailbox_type = new_mailbox->mailbox_type; local_mailbox.unread_count = 0; local_mailbox.total_mail_count_on_local = 0; local_mailbox.total_mail_count_on_server = 0; emcore_get_default_mail_slot_count(&local_mailbox.mail_slot_size, NULL); - if (strncmp(new_mailbox->name, EMF_INBOX_NAME, strlen(EMF_INBOX_NAME)) == 0 || - strncmp(new_mailbox->name, EMF_DRAFTBOX_NAME, strlen(EMF_DRAFTBOX_NAME)) == 0 || - strncmp(new_mailbox->name, EMF_OUTBOX_NAME, strlen(EMF_OUTBOX_NAME)) == 0 || - strncmp(new_mailbox->name, EMF_SENTBOX_NAME, strlen(EMF_SENTBOX_NAME)) == 0) + if (strncmp(new_mailbox->mailbox_name, EMAIL_INBOX_NAME, strlen(EMAIL_INBOX_NAME)) == 0 || + strncmp(new_mailbox->mailbox_name, EMAIL_DRAFTBOX_NAME, strlen(EMAIL_DRAFTBOX_NAME)) == 0 || + strncmp(new_mailbox->mailbox_name, EMAIL_OUTBOX_NAME, strlen(EMAIL_OUTBOX_NAME)) == 0 || + strncmp(new_mailbox->mailbox_name, EMAIL_SENTBOX_NAME, strlen(EMAIL_SENTBOX_NAME)) == 0) local_mailbox.modifiable_yn = 0; /* can be deleted/modified */ else local_mailbox.modifiable_yn = 1; if (!emstorage_add_mailbox(&local_mailbox, true, &err)) { - EM_DEBUG_EXCEPTION(" emstorage_add_mailbox failed - %d", err); - + EM_DEBUG_EXCEPTION("emstorage_add_mailbox failed [%d]", err); goto FINISH_OFF; } + + new_mailbox->mailbox_id = local_mailbox.mailbox_id; ret = true; FINISH_OFF: @@ -412,33 +398,39 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_delete_mailbox(emf_mailbox_t *mailbox, int on_server, int *err_code) +INTERNAL_FUNC int emcore_delete_mailbox(int input_mailbox_id, int on_server, int *err_code) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], err_code[%p]", mailbox, err_code); + EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], err_code[%p]", input_mailbox_id, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; - if (mailbox == NULL) { - EM_DEBUG_EXCEPTION(" mailbox[%p]", mailbox); - err = EMF_ERROR_INVALID_PARAM; + if (input_mailbox_id == 0) { + EM_DEBUG_EXCEPTION(" input_mailbox_id == 0"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (!emcore_delete_mail_all(mailbox, on_server, &err)) { - EM_DEBUG_EXCEPTION(" emcore_delete_mail_all failed - %d", err); + if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err); + goto FINISH_OFF; + } + + if (!emcore_delete_all_mails_of_mailbox(input_mailbox_id, on_server, &err)) { + EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err); goto FINISH_OFF; } if (on_server) { EM_DEBUG_LOG(">> Delete the mailbox in Sever >>> "); - if (!emcore_delete_imap_mailbox(mailbox, &err)) - EM_DEBUG_EXCEPTION(">>> Delete the mailbox in Server : FAILED >>> "); + if (!emcore_delete_imap_mailbox(input_mailbox_id, &err)) + EM_DEBUG_EXCEPTION("Delete the mailbox in server : failed"); else - EM_DEBUG_LOG(">>> Delete the mailbox in Server : SUCCESS >>> "); + EM_DEBUG_LOG("Delete the mailbox in server : success"); } - if (!emstorage_delete_mailbox(mailbox->account_id, -1, mailbox->name, true, &err)) { + if (!emstorage_delete_mailbox(mailbox_tbl->account_id, -1, input_mailbox_id, true, &err)) { EM_DEBUG_EXCEPTION(" emstorage_delete_mailbox failed - %d", err); goto FINISH_OFF; @@ -446,36 +438,39 @@ INTERNAL_FUNC int emcore_delete_mailbox(emf_mailbox_t *mailbox, int on_server, i ret = true; -FINISH_OFF: +FINISH_OFF: + if (mailbox_tbl) + emstorage_free_mailbox(&mailbox_tbl, 1, NULL); + if (err_code != NULL) *err_code = err; return ret; } -INTERNAL_FUNC int emcore_delete_mailbox_all(emf_mailbox_t *mailbox, int *err_code) +INTERNAL_FUNC int emcore_delete_mailbox_all(email_mailbox_t *mailbox, int *err_code) { EM_DEBUG_FUNC_BEGIN(); EM_DEBUG_LOG(" mailbox[%p], err_code[%p]", mailbox, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (mailbox == NULL) { EM_DEBUG_EXCEPTION(" mailbox[%p]", mailbox); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (!emcore_delete_mail_all(mailbox, 0, /*NULL, */ &err)) { - EM_DEBUG_EXCEPTION(" emcore_delete_mail_all failed - %d", err); + if (!emcore_delete_all_mails_of_mailbox(mailbox->mailbox_id, 0, /*NULL, */ &err)) { + EM_DEBUG_EXCEPTION(" emcore_delete_all_mails_of_mailbox failed - %d", err); goto FINISH_OFF; } - if (!emstorage_delete_mailbox(mailbox->account_id, -1, mailbox->name, true, &err)) { + if (!emstorage_delete_mailbox(mailbox->account_id, -1, mailbox->mailbox_id, true, &err)) { EM_DEBUG_EXCEPTION(" emstorage_delete_mailbox failed - %d", err); @@ -491,17 +486,17 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_update_mailbox(emf_mailbox_t *old_mailbox, emf_mailbox_t *new_mailbox, int *err_code) +INTERNAL_FUNC int emcore_update_mailbox(email_mailbox_t *old_mailbox, email_mailbox_t *new_mailbox, int *err_code) { EM_DEBUG_FUNC_BEGIN("old_mailbox[%p], new_mailbox[%p], err_code[%p]", old_mailbox, new_mailbox, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (old_mailbox == NULL || new_mailbox == NULL) { EM_DEBUG_EXCEPTION("old_mailbox[%p], new_mailbox[%p]", old_mailbox, new_mailbox); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -512,32 +507,29 @@ INTERNAL_FUNC int emcore_update_mailbox(emf_mailbox_t *old_mailbox, emf_mailbox_ new_mailbox_tbl.mailbox_type = new_mailbox->mailbox_type; if (old_mailbox->mailbox_type != new_mailbox_tbl.mailbox_type) { - if (!emstorage_update_mailbox_type(old_mailbox->account_id, -1, old_mailbox->name, &new_mailbox_tbl, true, &err)) { + if (!emstorage_update_mailbox_type(old_mailbox->account_id, -1, old_mailbox->mailbox_name, new_mailbox_tbl.mailbox_type, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_update_mailbox failed - %d", err); - goto FINISH_OFF; } } new_mailbox_tbl.mailbox_id = old_mailbox->mailbox_id; new_mailbox_tbl.account_id = old_mailbox->account_id; - new_mailbox_tbl.mailbox_name = new_mailbox->name; + new_mailbox_tbl.mailbox_name = new_mailbox->mailbox_name; new_mailbox_tbl.mailbox_type = new_mailbox->mailbox_type; new_mailbox_tbl.alias = new_mailbox->alias; - new_mailbox_tbl.sync_with_server_yn = new_mailbox->synchronous; new_mailbox_tbl.mail_slot_size = new_mailbox->mail_slot_size; new_mailbox_tbl.total_mail_count_on_server = new_mailbox->total_mail_count_on_server; - if (!emstorage_update_mailbox(old_mailbox->account_id, -1, old_mailbox->name, &new_mailbox_tbl, true, &err)) { + if (!emstorage_update_mailbox(old_mailbox->account_id, -1, old_mailbox->mailbox_id, &new_mailbox_tbl, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_update_mailbox failed - %d", err); goto FINISH_OFF; } - if (EM_SAFE_STRCMP(old_mailbox->name, new_mailbox_tbl.mailbox_name) != 0) { - if (!emstorage_rename_mailbox(old_mailbox->account_id, old_mailbox->name, new_mailbox_tbl.mailbox_name, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_rename_mailbox failed - %d", err); - + if (EM_SAFE_STRCMP(old_mailbox->mailbox_name, new_mailbox_tbl.mailbox_name) != 0) { + if ( (err = emstorage_rename_mailbox(old_mailbox->mailbox_id, new_mailbox_tbl.mailbox_name, new_mailbox_tbl.alias, true)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_rename_mailbox failed [%d]", err); goto FINISH_OFF; } } @@ -558,45 +550,47 @@ extern int try_auth_smtp; 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(emf_account_t *account, char *mailbox, void **result_stream, int *err_code) +INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(email_account_t *account, int input_mailbox_id, void **result_stream, int *err_code) { EM_PROFILE_BEGIN(emCoreMailboxOpen); - EM_DEBUG_FUNC_BEGIN("account[%p], mailbox[%p], mail_stream[%p], err_code[%p]", account, mailbox, result_stream, err_code); + EM_DEBUG_FUNC_BEGIN("account[%p], input_mailbox_id[%d], mail_stream[%p], err_code[%p]", account, input_mailbox_id, result_stream, err_code); int ret = false; - int error = EMF_ERROR_NONE; - emf_session_t *session = NULL; + int error = EMAIL_ERROR_NONE; + email_session_t *session = NULL; char *mbox_path = NULL; void *reusable_stream = NULL; int is_connection_for = _SERVICE_THREAD_TYPE_NONE; + emstorage_mailbox_tbl_t* mailbox = NULL; + char *mailbox_name = NULL; if (account == NULL) { EM_DEBUG_EXCEPTION("Invalid Parameter."); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!emcore_get_current_session(&session)) { EM_DEBUG_EXCEPTION("emcore_get_current_session failed..."); - error = EMF_ERROR_SESSION_NOT_FOUND; + error = EMAIL_ERROR_SESSION_NOT_FOUND; goto FINISH_OFF; } - if (mailbox == NULL || (mailbox && strcmp(mailbox, ENCODED_PATH_SMTP) != 0)) + if (input_mailbox_id == 0 || input_mailbox_id != EMAIL_CONNECT_FOR_SENDING) is_connection_for = _SERVICE_THREAD_TYPE_RECEIVING; else is_connection_for = _SERVICE_THREAD_TYPE_SENDING; #ifdef __FEATURE_KEEP_CONNECTION__ - emf_connection_info_t *connection_info = emcore_get_connection_info_by_account_id(account->account_id); + email_connection_info_t *connection_info = emcore_get_connection_info_by_account_id(account->account_id); if(connection_info) { if (is_connection_for == _SERVICE_THREAD_TYPE_RECEIVING) { - if(connection_info->receiving_server_stream_status == EMF_STREAM_STATUS_CONNECTED) + if(connection_info->receiving_server_stream_status == EMAIL_STREAM_STATUS_CONNECTED) reusable_stream = connection_info->receiving_server_stream; } else { - if(connection_info->sending_server_stream_status == EMF_STREAM_STATUS_CONNECTED) + if(connection_info->sending_server_stream_status == EMAIL_STREAM_STATUS_CONNECTED) reusable_stream = connection_info->sending_server_stream; } } @@ -607,14 +601,27 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(emf_account reusable_stream = *result_stream; #endif - session->error = EMF_ERROR_NONE; - emcore_set_network_error(EMF_ERROR_NONE); /* set current network error as EMF_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 */ + if (input_mailbox_id == EMAIL_CONNECT_FOR_SENDING) { + mailbox_name = EM_SAFE_STRDUP(ENCODED_PATH_SMTP); + } + 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) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", error); + goto FINISH_OFF; + } + mailbox_name = EM_SAFE_STRDUP(mailbox->mailbox_name); + } + if (is_connection_for == _SERVICE_THREAD_TYPE_RECEIVING) { /* open pop3/imap server */ MAILSTREAM *mail_stream = NULL; - if (!emcore_get_long_encoded_path_with_account_info(account, mailbox, '/', &mbox_path, &error)) { + if (!emcore_get_long_encoded_path_with_account_info(account, mailbox_name, '/', &mbox_path, &error)) { EM_DEBUG_EXCEPTION("emcore_get_long_encoded_path failed - %d", error); session->error = error; goto FINISH_OFF; @@ -628,10 +635,10 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(emf_account if (!(mail_stream = mail_open(reusable_stream, mbox_path, IMAP_2004_LOG))) { EM_DEBUG_EXCEPTION("mail_open failed. session->error[%d], session->network[%d]", session->error, session->network); - if (session->network != EMF_ERROR_NONE) + if (session->network != EMAIL_ERROR_NONE) session->error = session->network; - if ((session->error == EMF_ERROR_UNKNOWN) || (session->error == EMF_ERROR_NONE)) - session->error = EMF_ERROR_CONNECTION_FAILURE; + if ((session->error == EMAIL_ERROR_UNKNOWN) || (session->error == EMAIL_ERROR_NONE)) + session->error = EMAIL_ERROR_CONNECTION_FAILURE; error = session->error; @@ -663,7 +670,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(emf_account } #endif if(!send_stream) { - if (!emcore_get_long_encoded_path_with_account_info(account, mailbox, 0, &mbox_path, &error)) { + if (!emcore_get_long_encoded_path_with_account_info(account, mailbox_name, 0, &mbox_path, &error)) { EM_DEBUG_EXCEPTION(" emcore_get_long_encoded_path failed - %d", error); session->error = error; goto FINISH_OFF; @@ -671,17 +678,18 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(emf_account EM_DEBUG_LOG("open SMTP connection to mbox_path [%s]", mbox_path); - try_auth_smtp = account->sending_auth ? 1 : 0; - session->auth = account->sending_auth ? 1 : 0; + try_auth_smtp = account->outgoing_server_need_authentication ? 1 : 0; + session->auth = account->outgoing_server_need_authentication ? 1 : 0; host_list[0] = mbox_path; if (!(send_stream = smtp_open(host_list, 1))) { - EM_DEBUG_EXCEPTION("smtp_open failed... : current sending_security[%d] session->error[%d] session->network[%d]", account->sending_security, session->error, session->network); - if (session->network != EMF_ERROR_NONE) + EM_DEBUG_EXCEPTION("smtp_open failed... : current outgoing_server_secure_connection[%d] session->error[%d] session->network[%d]", + account->outgoing_server_secure_connection, session->error, session->network); + if (session->network != EMAIL_ERROR_NONE) session->error = session->network; - if ((session->error == EMF_ERROR_UNKNOWN) || (session->error == EMF_ERROR_NONE)) - session->error = EMF_ERROR_CONNECTION_FAILURE; + if ((session->error == EMAIL_ERROR_UNKNOWN) || (session->error == EMAIL_ERROR_NONE)) + session->error = EMAIL_ERROR_CONNECTION_FAILURE; error = session->error; goto FINISH_OFF; @@ -697,7 +705,7 @@ FINISH_OFF: #ifdef __FEATURE_KEEP_CONNECTION__ if (ret == true) { if(!connection_info) { - connection_info = em_malloc(sizeof(emf_connection_info_t)); + connection_info = em_malloc(sizeof(email_connection_info_t)); connection_info->account_id = account->account_id; if(!connection_info) EM_DEBUG_EXCEPTION("em_malloc for connection_info failed."); @@ -709,17 +717,24 @@ FINISH_OFF: /* connection_info->account_id = account->account_id; */ if (is_connection_for == _SERVICE_THREAD_TYPE_RECEIVING) { connection_info->receiving_server_stream = *result_stream; - connection_info->receiving_server_stream_status = EMF_STREAM_STATUS_CONNECTED; + connection_info->receiving_server_stream_status = EMAIL_STREAM_STATUS_CONNECTED; } else { connection_info->sending_server_stream = *result_stream; - connection_info->sending_server_stream_status = EMF_STREAM_STATUS_CONNECTED; + connection_info->sending_server_stream_status = EMAIL_STREAM_STATUS_CONNECTED; } } } #endif EM_SAFE_FREE(mbox_path); + + EM_SAFE_FREE(mailbox_name); + + if (mailbox) { + emstorage_free_mailbox(&mailbox, 1, &error); + } + if (err_code != NULL) *err_code = error; EM_PROFILE_END(emCoreMailboxOpen); @@ -741,12 +756,12 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox(int account_id, char *mailbox EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox[%p], mail_stream[%p], err_code[%p]", account_id, mailbox, mail_stream, err_code); int ret = false; - int error = EMF_ERROR_NONE; - emf_account_t *ref_account = emcore_get_account_reference(account_id); + int error = EMAIL_ERROR_NONE; + email_account_t *ref_account = emcore_get_account_reference(account_id); if (!ref_account) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - account id[%d]", account_id); - error = EMF_ERROR_INVALID_ACCOUNT; + error = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } @@ -801,21 +816,21 @@ INTERNAL_FUNC void emcore_reset_streams() #else /* __FEATURE_KEEP_CONNECTION__ */ -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(int account_id, int input_mailbox_id, 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); + 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); int ret = false; - int error = EMF_ERROR_NONE; - emf_account_t *ref_account = emcore_get_account_reference(account_id); + int error = EMAIL_ERROR_NONE; + email_account_t *ref_account = emcore_get_account_reference(account_id); if (!ref_account) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - account id[%d]", account_id); - error = EMF_ERROR_INVALID_ACCOUNT; + 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(ref_account, input_mailbox_id, mail_stream, &error); FINISH_OFF: if (err_code) @@ -855,59 +870,95 @@ INTERNAL_FUNC int emcore_close_mailbox(int account_id, void *mail_stream) return true; } -INTERNAL_FUNC int emcore_free_mailbox(emf_mailbox_t **mailbox_list, int count, int *err_code) +INTERNAL_FUNC void emcore_free_mailbox_list(email_mailbox_t **mailbox_list, int count) { - EM_DEBUG_FUNC_BEGIN("mailbox_list[%p], count[%d], err_code[%p]", mailbox_list, count, err_code); + EM_DEBUG_FUNC_BEGIN("mailbox_list[%p], count[%d]", mailbox_list, count); + + if (count <= 0 || !mailbox_list || !*mailbox_list) { + EM_DEBUG_EXCEPTION("INVALID_PARAM: mailbox_list[%p], count[%d]", mailbox_list, count); + return; + } + + email_mailbox_t *p = *mailbox_list; + int i; + + for (i = 0; i < count; i++) + emcore_free_mailbox(p+i); + + EM_SAFE_FREE(p); + *mailbox_list = NULL; + + EM_DEBUG_FUNC_END(); + } + + +INTERNAL_FUNC void emcore_free_mailbox(email_mailbox_t *mailbox) +{ + EM_DEBUG_FUNC_BEGIN(); + + if (!mailbox) { + EM_DEBUG_EXCEPTION("INVALID_PARAM"); + return; + } + + EM_SAFE_FREE(mailbox->mailbox_name); + EM_SAFE_FREE(mailbox->alias); + EM_DEBUG_FUNC_END(); +} + + +INTERNAL_FUNC int emcore_free_internal_mailbox(email_internal_mailbox_t **mailbox_list, int count, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("mailbox_list[%p], count[%d], err_code[%p]", mailbox_list, count, err_code); + /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; - + int err = EMAIL_ERROR_NONE; + if (count > 0) { if (!mailbox_list || !*mailbox_list) { EM_DEBUG_EXCEPTION(" mailbox_list[%p], count[%d]", mailbox_list, count); - - err = EMF_ERROR_INVALID_PARAM; + + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - - emf_mailbox_t *p = *mailbox_list; + + email_internal_mailbox_t *p = *mailbox_list; int i; - + /* EM_DEBUG_LOG("before loop"); */ for (i = 0; i < count; i++) { - /* EM_DEBUG_LOG("p[%d].name [%p]", i, p[i].name); */ - /* EM_DEBUG_LOG("p[%d].alias [%p]", i, p[i].alias); */ - EM_SAFE_FREE(p[i].name); + EM_SAFE_FREE(p[i].mailbox_name); EM_SAFE_FREE(p[i].alias); } /* EM_DEBUG_LOG("p [%p]", p); */ - free(p); + free(p); *mailbox_list = NULL; } - + ret = true; - -FINISH_OFF: + +FINISH_OFF: if (err_code) *err_code = err; EM_DEBUG_FUNC_END(); return ret; } -INTERNAL_FUNC void emcore_bind_mailbox_type(emf_mailbox_t *mailbox_list) +INTERNAL_FUNC void emcore_bind_mailbox_type(email_internal_mailbox_t *mailbox_list) { EM_DEBUG_FUNC_BEGIN("mailbox_list[%p]", mailbox_list); int i = 0; int bIsNotUserMailbox = false; - emf_mailbox_type_item_t *pMailboxType1 = NULL ; + email_mailbox_type_item_t *pMailboxType1 = NULL ; for (i = 0 ; i < MAX_MAILBOX_TYPE ; i++) { pMailboxType1 = g_mailbox_type + i; if (pMailboxType1->mailbox_name) { - if (0 == strcmp(pMailboxType1->mailbox_name, mailbox_list->name)) { + if (0 == strcmp(pMailboxType1->mailbox_name, mailbox_list->mailbox_name)) { mailbox_list->mailbox_type = pMailboxType1->mailbox_type; EM_DEBUG_LOG("mailbox_list->mailbox_type[%d]", mailbox_list->mailbox_type); bIsNotUserMailbox = true; @@ -917,35 +968,35 @@ INTERNAL_FUNC void emcore_bind_mailbox_type(emf_mailbox_t *mailbox_list) } if (false == bIsNotUserMailbox) - mailbox_list->mailbox_type = EMF_MAILBOX_TYPE_USER_DEFINED; + mailbox_list->mailbox_type = EMAIL_MAILBOX_TYPE_USER_DEFINED; EM_DEBUG_FUNC_END(); } -INTERNAL_FUNC int emcore_send_mail_event(emf_mailbox_t *mailbox, int mail_id , int *err_code) +INTERNAL_FUNC int emcore_send_mail_event(email_mailbox_t *mailbox, int mail_id , int *err_code) { EM_DEBUG_FUNC_BEGIN(); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int handle; - emf_event_t event_data; + email_event_t event_data; if (!mailbox || mailbox->account_id <= 0) { EM_DEBUG_LOG(" mailbox[%p]", mailbox); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - memset(&event_data, 0x00, sizeof(emf_event_t)); + memset(&event_data, 0x00, sizeof(email_event_t)); - event_data.type = EMF_EVENT_SEND_MAIL; + event_data.type = EMAIL_EVENT_SEND_MAIL; event_data.account_id = mailbox->account_id; - event_data.event_param_data_3 = EM_SAFE_STRDUP(mailbox->name); event_data.event_param_data_4 = mail_id; event_data.event_param_data_1 = NULL; + event_data.event_param_data_5 = mailbox->mailbox_id; - if (!emcore_insert_send_event(&event_data, &handle, &err)) { + if (!emcore_insert_event_for_sending_mails(&event_data, &handle, &err)) { EM_DEBUG_LOG(" emcore_insert_event failed - %d", err); goto FINISH_OFF; } @@ -964,7 +1015,7 @@ INTERNAL_FUNC int emcore_partial_body_thd_local_activity_sync(int *is_event_inse EM_DEBUG_FUNC_BEGIN(); int activity_count = 0; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (false == emstorage_get_pbd_activity_count(&activity_count, false, &error)) { EM_DEBUG_LOG("emstorage_get_pbd_activity_count failed [%d]", error); @@ -973,13 +1024,13 @@ INTERNAL_FUNC int emcore_partial_body_thd_local_activity_sync(int *is_event_inse if (activity_count > 0) { - emf_event_partial_body_thd pbd_event; + email_event_partial_body_thd pbd_event; /* Carefully initialise the event */ - memset(&pbd_event, 0x00, sizeof(emf_event_partial_body_thd)); + memset(&pbd_event, 0x00, sizeof(email_event_partial_body_thd)); - pbd_event.event_type = EMF_EVENT_LOCAL_ACTIVITY_SYNC_BULK_PBD; - pbd_event.activity_type = EMF_EVENT_LOCAL_ACTIVITY_SYNC_BULK_PBD; + pbd_event.event_type = EMAIL_EVENT_LOCAL_ACTIVITY_SYNC_BULK_PBD; + pbd_event.activity_type = EMAIL_EVENT_LOCAL_ACTIVITY_SYNC_BULK_PBD; if (false == emcore_insert_partial_body_thread_event(&pbd_event, &error)) { EM_DEBUG_LOG(" emcore_insert_partial_body_thread_event failed [%d]", error); @@ -1006,15 +1057,15 @@ INTERNAL_FUNC int emcore_partial_body_thd_local_activity_sync(int *is_event_inse return ret; } -INTERNAL_FUNC int emcore_get_mailbox_by_type(int account_id, emf_mailbox_type_e mailbox_type, emf_mailbox_t *result_mailbox, int *err_code) +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) { EM_DEBUG_FUNC_BEGIN("account_id [%d], result_mailbox [%p], err_code [%p]", account_id, result_mailbox, err_code); - int ret = false, err = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; emstorage_mailbox_tbl_t *mail_box_tbl_spam = NULL; if (result_mailbox == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1025,7 +1076,7 @@ INTERNAL_FUNC int emcore_get_mailbox_by_type(int account_id, emf_mailbox_type_e else { if (mail_box_tbl_spam) { result_mailbox->mailbox_type = mail_box_tbl_spam->mailbox_type; - result_mailbox->name = EM_SAFE_STRDUP(mail_box_tbl_spam->mailbox_name); + result_mailbox->mailbox_name = EM_SAFE_STRDUP(mail_box_tbl_spam->mailbox_name); result_mailbox->account_id = mail_box_tbl_spam->account_id; result_mailbox->mail_slot_size = mail_box_tbl_spam->mail_slot_size; if (!emstorage_free_mailbox(&mail_box_tbl_spam, 1, &err)) @@ -1053,10 +1104,10 @@ INTERNAL_FUNC int emcore_local_activity_sync(int account_id, int *err_code) int err = 0; int handle = 0; int ret = false; - emf_event_t event_data; + email_event_t event_data; - memset(&event_data, 0x00, sizeof(emf_event_t)); + memset(&event_data, 0x00, sizeof(email_event_t)); EM_IF_NULL_RETURN_VALUE(err_code, false); @@ -1075,7 +1126,7 @@ INTERNAL_FUNC int emcore_local_activity_sync(int account_id, int *err_code) EM_DEBUG_LOG(">>> emdaemon_sync_local_activity 5 "); if (activity_count > 0) { - event_data.type = EMF_EVENT_LOCAL_ACTIVITY; + event_data.type = EMAIL_EVENT_LOCAL_ACTIVITY; event_data.account_id = account_id; if (!emcore_insert_event(&event_data, &handle, &err)) { EM_DEBUG_LOG(" emcore_insert_event failed - %d", err); @@ -1109,9 +1160,9 @@ INTERNAL_FUNC int emcore_save_local_activity_sync(int account_id, int *err_code) int err = 0; int ret = false; int handle = 0; - emf_event_t event_data; + email_event_t event_data; - memset(&event_data, 0x00, sizeof(emf_event_t)); + memset(&event_data, 0x00, sizeof(email_event_t)); EM_IF_NULL_RETURN_VALUE(err_code, false); @@ -1128,9 +1179,9 @@ INTERNAL_FUNC int emcore_save_local_activity_sync(int account_id, int *err_code) if (activity_count > 0) { - event_data.type = EMF_EVENT_LOCAL_ACTIVITY; + event_data.type = EMAIL_EVENT_LOCAL_ACTIVITY; event_data.account_id = account_id; - if (!emcore_insert_send_event(&event_data, &handle, &err)) { + if (!emcore_insert_event_for_sending_mails(&event_data, &handle, &err)) { EM_DEBUG_LOG(" emcore_insert_event failed - %d", err); goto FINISH_OFF; } diff --git a/email-core/email-core-mime.c b/email-core/email-core-mime.c index 04c5a27..3c170d5 100755 --- a/email-core/email-core-mime.c +++ b/email-core/email-core-mime.c @@ -51,7 +51,6 @@ #include "email-core-account.h" #include "email-debug-log.h" - #define MIME_MESG_IS_SOCKET #define MIME_LINE_LEN 1024 @@ -93,6 +92,8 @@ #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 */ + /* MIME Structure Example @@ -218,7 +219,7 @@ struct _m_mesg { /* ---------------------------------------------------------------------- */ /* Global variable */ static bool next_decode_string = false; - +static int eml_data_count = 0; /* ---------------------------------------------------------------------- */ /* External variable */ @@ -299,7 +300,7 @@ int emcore_mime_skip_content_data(void *stream, void *callback, int *err_code); -static int emcore_get_file_pointer(BODY *body, char *buf, struct _m_content_info *cnt_info , int *err); +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); @@ -453,16 +454,16 @@ int emcore_mime_flush_receiving_buffer(void *stream, int is_file, char *boundary if (!stream) { if (err_code) - *err_code = EMF_ERROR_INVALID_PARAM; - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + *err_code = EMAIL_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); return false; } while (TRUE) { if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; - EM_DEBUG_FUNC_END("EMF_ERROR_CANCELLED"); + *err_code = EMAIL_ERROR_CANCELLED; + EM_DEBUG_FUNC_END("EMAIL_ERROR_CANCELLED"); return false; } @@ -513,7 +514,7 @@ int emcore_parse_mime(void *stream, int is_file, struct _m_content_info *cnt_inf if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; + *err_code = EMAIL_ERROR_CANCELLED; return false; } @@ -556,7 +557,7 @@ int emcore_mime_parse_header(void *stream, int is_file, struct _rfc822header **r if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; + *err_code = EMAIL_ERROR_CANCELLED; return false; } @@ -569,13 +570,13 @@ int emcore_mime_parse_header(void *stream, int is_file, struct _rfc822header **r if (!(tmp_header = em_malloc(sizeof(struct _m_mesg_header)))) { EM_DEBUG_EXCEPTION("malloc failed..."); if (err_code != NULL) - *err_code = EMF_ERROR_OUT_OF_MEMORY; + *err_code = EMAIL_ERROR_OUT_OF_MEMORY; return false; } if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; + *err_code = EMAIL_ERROR_CANCELLED; return false; } @@ -635,20 +636,20 @@ int emcore_mime_parse_header(void *stream, int is_file, struct _rfc822header **r } else if (memcmp(name, "MIME-VERSION", 12) == 0) { /* EM_DEBUG_FUNC_BEGIN() */ - /* ignored because we need only contents informatio */ + /* ignored because we need only contents information */ /* tmp_header->version = EM_SAFE_STRDUP(value) */ /* RFC822 Heade */ } else { - /* in socket stream case, ignored because we need only contents informatio */ + /* 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); } if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; + *err_code = EMAIL_ERROR_CANCELLED; return false; } if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, err_code)) || @@ -689,7 +690,7 @@ int emcore_mime_parse_part_header(void *stream, int is_file, struct _m_part_head if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; + *err_code = EMAIL_ERROR_CANCELLED; return false; } @@ -731,7 +732,7 @@ int emcore_mime_parse_part_header(void *stream, int is_file, struct _m_part_head if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; + *err_code = EMAIL_ERROR_CANCELLED; return false; } @@ -757,11 +758,11 @@ int emcore_mime_parse_body(void *stream, int is_file, struct _m_mesg *mmsg, stru 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); char *content_type = NULL, *content_encoding = NULL, *holder = NULL, *attachment_name, *t = NULL; - int type = 0, end_of_parsing = 0, size, local_err_code = EMF_ERROR_NONE; + int type = 0, end_of_parsing = 0, size, local_err_code = EMAIL_ERROR_NONE; if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; + *err_code = EMAIL_ERROR_CANCELLED; return false; } @@ -797,7 +798,7 @@ int emcore_mime_parse_body(void *stream, int is_file, struct _m_mesg *mmsg, stru } /* after finishing body parsing, make stream empty to get next mail. (get line from sock or file until '.' is read */ - if (end_of_parsing == true && local_err_code != EMF_ERROR_NO_MORE_DATA) + if (end_of_parsing == true && local_err_code != EMAIL_ERROR_NO_MORE_DATA) emcore_mime_flush_receiving_buffer(stream, is_file, NULL, NULL, NULL, err_code); if (err_code) @@ -807,13 +808,26 @@ int emcore_mime_parse_body(void *stream, int is_file, struct _m_mesg *mmsg, stru 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(" attachment = [%s]", attachment_name); } - + + if (strstr(content_type, "PKCS7-MIME")) { + EM_DEBUG_LOG("Encrypted mail do not include the body"); + cnt_info->file = em_malloc(sizeof(struct attachment_info)); + if (cnt_info->file) { + cnt_info->file->type = 2; + cnt_info->file->name = EM_SAFE_STRDUP(attachment_name); + emcore_mime_get_content_data(stream, is_file, false, NULL, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code); + cnt_info->file->save = holder; + cnt_info->file->size = size; + } + break; + } + if (cnt_info->grab_type & GRAB_TYPE_TEXT) { /* EM_DEBUG_LINE */ /* get content data. content data is saved in file */ @@ -862,11 +876,13 @@ int emcore_mime_parse_part(void *stream, int is_file, struct _m_part_header *par char *content_encoding = NULL; char *holder = NULL; char *attachment_name = NULL; + char *content_disposition = NULL; char *t = NULL; char *pTemp = NULL; int type = 0; + int content_disposition_type = 0; int end_of_parsing = 0; - int size = 0, local_err_code = EMF_ERROR_NONE; + int size = 0, local_err_code = EMAIL_ERROR_NONE; int is_skip = false; boundary_str = emcore_mime_get_header_value(parent_header, CONTENT_BOUNDARY, err_code); @@ -882,7 +898,7 @@ int emcore_mime_parse_part(void *stream, int is_file, struct _m_part_header *par while (true) { if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; + *err_code = EMAIL_ERROR_CANCELLED; return false; } if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, err_code)) || @@ -981,7 +997,7 @@ int emcore_mime_parse_part(void *stream, int is_file, struct _m_part_header *par if (err_code) *err_code = local_err_code; - if (end_of_parsing && local_err_code != EMF_ERROR_NO_MORE_DATA) /* working with imap */ + 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); @@ -992,6 +1008,7 @@ int emcore_mime_parse_part(void *stream, int is_file, struct _m_part_header *par default: EM_DEBUG_LOG("default"); attachment_name = NULL; + content_disposition = NULL; if (type == TYPE_MESSAGE) is_skip = true; @@ -1007,26 +1024,36 @@ int emcore_mime_parse_part(void *stream, int is_file, struct _m_part_header *par /* first check inline content */ /* if the content id or content location exis */ - attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_ID, err_code); - if (!attachment_name) - attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_LOCATION, err_code); - - if (!attachment_name) { - /* check if the content is attachment */ - /* if Content-Disposition Header exists, the content is attachment */ - if (emcore_mime_get_header_value(tmp_body->part_header, CONTENT_DISPOSITION, err_code)) { - attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_FILENAME, err_code); - EM_DEBUG_LOG_MIME(">> attachment = [%s]", attachment_name ? attachment_name : NIL); + content_disposition = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_DISPOSITION, err_code); + EM_DEBUG_LOG("content_disposition : [%s]", content_disposition); + if (content_disposition) { + if (!strcasecmp(content_disposition, "inline")) { + if (!attachment_name) + attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_ID, err_code); + if (!attachment_name) + attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_LOCATION, err_code); + + content_disposition_type = 1; + } else if (!strcasecmp(content_disposition, "attachment")) { + if (!attachment_name) { + attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_FILENAME, err_code); + EM_DEBUG_LOG_MIME(">> attachment = [%s]", attachment_name ? attachment_name : NIL); + } + content_disposition_type = 2; } - } - + } else if (strstr(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); + } + if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; - EM_DEBUG_EXCEPTION("EMF_ERROR_CANCELLED"); + *err_code = EMAIL_ERROR_CANCELLED; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_CANCELLED"); EM_DEBUG_FUNC_END("false"); return false; } + /* get content and content information */ if (!attachment_name) { /* text */ /* get content by buffe */ @@ -1081,17 +1108,12 @@ int emcore_mime_parse_part(void *stream, int is_file, struct _m_part_header *par *file = em_malloc(sizeof(struct attachment_info)); if (*file) { - if ((emcore_mime_get_header_value(tmp_body->part_header, CONTENT_ID, err_code)) || - (emcore_mime_get_header_value(tmp_body->part_header, CONTENT_LOCATION, err_code))) { /* this is inline conten */ - (*file)->type = 1; - } - else { /* this is attachment content */ - (*file)->type = 2; - } + (*file)->type = content_disposition_type; EM_DEBUG_LOG_MIME("file->type : %d", (*file)->type); (*file)->name = EM_SAFE_STRDUP(attachment_name); + (*file)->content_id = EM_SAFE_STRDUP(tmp_body->part_header->content_id); if(tmp_body->part_header->type && tmp_body->part_header->subtype) { SNPRINTF(mime_type_buffer, 128, "%s/%s", tmp_body->part_header->type, tmp_body->part_header->subtype); (*file)->attachment_mime_type = EM_SAFE_STRDUP(mime_type_buffer); @@ -1120,11 +1142,11 @@ int emcore_mime_parse_part(void *stream, int is_file, struct _m_part_header *par pTemp = content_type + strlen(APPLICATION_STR); if (strcasecmp(pTemp, MIME_SUBTYPE_DRM_OBJECT) == 0) - (*file)->drm = EMF_ATTACHMENT_DRM_OBJECT; + (*file)->drm = EMAIL_ATTACHMENT_DRM_OBJECT; else if (strcasecmp(pTemp, MIME_SUBTYPE_DRM_RIGHTS) == 0) - (*file)->drm = EMF_ATTACHMENT_DRM_RIGHTS; + (*file)->drm = EMAIL_ATTACHMENT_DRM_RIGHTS; else if (strcasecmp(pTemp, MIME_SUBTYPE_DRM_DCF) == 0) - (*file)->drm = EMF_ATTACHMENT_DRM_DCF; + (*file)->drm = EMAIL_ATTACHMENT_DRM_DCF; } } else { @@ -1137,8 +1159,8 @@ int emcore_mime_parse_part(void *stream, int is_file, struct _m_part_header *par if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; - EM_DEBUG_EXCEPTION("EMF_ERROR_CANCELLED"); + *err_code = EMAIL_ERROR_CANCELLED; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_CANCELLED"); EM_DEBUG_FUNC_END("false"); return false; } @@ -1259,7 +1281,7 @@ int emcore_mime_set_part_header_value(struct _m_part_header **header, char *name if (!name || !value) { EM_DEBUG_EXCEPTION("Invalid parameter"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -1280,7 +1302,7 @@ int emcore_mime_set_part_header_value(struct _m_part_header **header, char *name if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; + *err_code = EMAIL_ERROR_CANCELLED; return false; } @@ -1405,7 +1427,7 @@ int emcore_mime_get_param_from_str(char *str, struct _parameter **param, int *er em_upper_string(p_val); /* = ? ENCODING_TYPE ? B(Q) ? ENCODED_STRING ? */ - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char *utf8_text = NULL; if (!(utf8_text = emcore_decode_rfc2047_text(p_val, &err))) @@ -1444,7 +1466,7 @@ char *emcore_mime_get_header_value(struct _m_part_header *header, int type, int EM_DEBUG_EXCEPTION("header[%p], type[%d]", header, type); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return NULL; } @@ -1569,7 +1591,7 @@ int emcore_mime_get_content_data(void *stream, int is_file, int is_text, char *b int sz = 0, fd = 0, result_buffer_size = 0;; int encoding = ENC7BIT; int dec_len = 0; - int error = EMF_ERROR_NONE, ret = false; + int error = EMAIL_ERROR_NONE, ret = false; char *pTemp = NULL; if ((mode == SAVE_TYPE_FILE || mode == SAVE_TYPE_BUFFER) && !holder) @@ -1633,16 +1655,16 @@ int emcore_mime_get_content_data(void *stream, int is_file, int is_text, char *b SNPRINTF(boundary_end, BOUNDARY_LEN, "--%s%s", boundary_str, "--\r\n"); } - while (TRUE) { - if (!emcore_check_thread_status()) { - EM_DEBUG_EXCEPTION("EMF_ERROR_CANCELLED"); - error = EMF_ERROR_CANCELLED; + while (TRUE) { + if (!emcore_check_thread_status()) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_CANCELLED"); + error = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; - } + } if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, &error)) || (is_file == 1 && !emcore_get_line_from_file(stream, buf, MIME_LINE_LEN, &error))) { - if (error == EMF_ERROR_NO_MORE_DATA) + if (error == EMAIL_ERROR_NO_MORE_DATA) EM_DEBUG_EXCEPTION("End of data"); else EM_DEBUG_EXCEPTION("emcore_mime_get_line_from_sock failed"); @@ -1663,27 +1685,27 @@ int emcore_mime_get_content_data(void *stream, int is_file, int is_text, char *b ret = true; goto FINISH_OFF; } - } + } /* parsing string started by '.' in POP3 */ if ((buf[0] == '.' && buf[1] == '.') && (encoding == ENCQUOTEDPRINTABLE || encoding == ENC7BIT)) { strncpy(buf, buf+1, MIME_LINE_LEN-1); buf[strlen(buf)] = NULL_CHAR; - } + } - if (encoding == ENCBASE64) { + if (encoding == ENCBASE64) { if (strlen(buf) >= 2) buf[strlen(buf)-2] = NULL_CHAR; - } - else if (encoding == ENCQUOTEDPRINTABLE) { + } else if (encoding == ENCQUOTEDPRINTABLE) { /* if (strcmp(buf, CRLF_STRING) == 0 */ /* continue */ - } + } - dec_len = strlen(buf); + dec_len = strlen(buf); - if (mode > SAVE_TYPE_SIZE) { /* decode conten */ + if (mode > SAVE_TYPE_SIZE) { /* decode content */ emcore_decode_body_text(buf, dec_len, encoding, &dec_len, err_code); + EM_DEBUG_LOG("decode buf : [%s]", buf); if (is_text) { result_buffer = em_replace_string(buf, "cid:", ""); @@ -1696,12 +1718,11 @@ int emcore_mime_get_content_data(void *stream, int is_file, int is_text, char *b result_buffer_size = dec_len; } - if (result_buffer) { - if (mode == SAVE_TYPE_BUFFER) { /* save content to buffe */ - pTemp = realloc(*holder, sz + result_buffer_size + 2); + 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 = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; EM_SAFE_FREE(*holder); EM_SAFE_FREE(result_buffer); @@ -1712,36 +1733,35 @@ int emcore_mime_get_content_data(void *stream, int is_file, int is_text, char *b memcpy(*holder + sz, result_buffer, result_buffer_size); (*holder)[sz + strlen(result_buffer) + 1] = NULL_CHAR; - } - else if (mode == SAVE_TYPE_FILE) { /* save content to fil */ - if (write(fd, result_buffer, result_buffer_size) != result_buffer_size) { - if (is_text && (result_buffer != buf)) - EM_SAFE_FREE(result_buffer); - EM_DEBUG_EXCEPTION("write failed"); - error = EMF_ERROR_SYSTEM_FAILURE; - goto FINISH_OFF; - } - } - if (is_text && (result_buffer != buf)) - EM_SAFE_FREE(result_buffer); - result_buffer = NULL; + } else if (mode == SAVE_TYPE_FILE) { /* save content to file */ + if (write(fd, result_buffer, result_buffer_size) != result_buffer_size) { + if (is_text && (result_buffer != buf)) + EM_SAFE_FREE(result_buffer); + EM_DEBUG_EXCEPTION("write failed"); + error = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; } } - sz += dec_len; + + if (is_text && (result_buffer != buf)) + EM_SAFE_FREE(result_buffer); + result_buffer = NULL; } + sz += dec_len; + } ret = true; FINISH_OFF: - if (err_code != NULL) + if (err_code != NULL) *err_code = error; - if (fd > 0) - close(fd); + if (fd > 0) + close(fd); if (ret) { - if (size) - *size = sz; - } + if (size) + *size = sz; + } EM_DEBUG_FUNC_END("ret [%d], sz [%d]", ret, sz); return ret; @@ -1770,7 +1790,7 @@ int emcore_mime_skip_content_data(void *stream, if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; + *err_code = EMAIL_ERROR_CANCELLED; return false; } if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, err_code)) || @@ -1794,7 +1814,7 @@ int emcore_mime_skip_content_data(void *stream, if (!emcore_check_thread_status()) { if (err_code != NULL) - *err_code = EMF_ERROR_CANCELLED; + *err_code = EMAIL_ERROR_CANCELLED; return false; } if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, err_code)) || @@ -1866,9 +1886,9 @@ char *emcore_mime_get_line_from_sock(void *stream, char *buf, int size, int *err POP3LOCAL *p_pop3local = NULL; if (!stream || !buf) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return NULL; } @@ -1878,7 +1898,7 @@ char *emcore_mime_get_line_from_sock(void *stream, char *buf, int size, int *err if (!p_pop3local) { EM_DEBUG_EXCEPTION("stream->local[%p]", p_pop3local); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return NULL; } @@ -1889,7 +1909,7 @@ char *emcore_mime_get_line_from_sock(void *stream, char *buf, int size, int *err free(p_pop3local->response); p_pop3local->response = NULL; if (err_code != NULL) - *err_code = EMF_ERROR_NO_MORE_DATA; + *err_code = EMAIL_ERROR_NO_MORE_DATA; EM_DEBUG_FUNC_END("end of response"); return NULL; } @@ -1917,7 +1937,7 @@ char *emcore_mime_get_line_from_sock(void *stream, char *buf, int size, int *err else { EM_DEBUG_EXCEPTION("p_pop3local->response is null. network error... "); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_RESPONSE; + *err_code = EMAIL_ERROR_INVALID_RESPONSE; EM_DEBUG_FUNC_END(); return NULL; } @@ -2052,6 +2072,7 @@ void emcore_free_content_info(struct _m_content_info *cnt_info) EM_SAFE_FREE(cnt_info->file->name); EM_SAFE_FREE(cnt_info->file->save); EM_SAFE_FREE(cnt_info->file->attachment_mime_type); + EM_SAFE_FREE(cnt_info->file->content_id); free(cnt_info->file); cnt_info->file = NULL; cnt_info->file = p; } @@ -2145,7 +2166,7 @@ PARTLIST* emcore_get_body_full(MAILSTREAM *stream, int msg_uid, BODY *body, stru 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 = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return NULL; } @@ -2173,13 +2194,13 @@ PARTLIST* emcore_get_body_full(MAILSTREAM *stream, int msg_uid, BODY *body, stru struct attachment_info *next_ai = NULL; int i = 0; - if (emcore_get_file_pointer(body, filename, cnt_info , (int *)NULL) < 0) + 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 */ prev_ai = NULL; next_ai = NULL; - ai = &cnt_info->file; + ai = &cnt_info->file; EM_DEBUG_LOG(" ai - %p ", (*ai)); @@ -2195,7 +2216,7 @@ PARTLIST* emcore_get_body_full(MAILSTREAM *stream, int msg_uid, BODY *body, stru for (i = 1; *ai; ai = &(*ai)->next) { if ((*ai)->type == 1) { /* Means inline image */ - EM_DEBUG_LOG(" Found Inline Content "); + EM_DEBUG_LOG("Found Inline Content "); next_ai = (*ai); break; } @@ -2208,18 +2229,18 @@ PARTLIST* emcore_get_body_full(MAILSTREAM *stream, int msg_uid, BODY *body, stru EM_DEBUG_EXCEPTION("em_malloc failed..."); } else { - if (ai == NULL) { + if (ai == NULL) cnt_info->file = (*ai); - } if ((body->id) || (body->location) || ((body->disposition.type != NULL) && ((body->disposition.type[0] == 'i') || (body->disposition.type[0] == 'I')))) - (*ai)->type = 1; + (*ai)->type = 1; /* inline contents */ else - (*ai)->type = 2; + (*ai)->type = 2; /* attachment */ (*ai)->name = EM_SAFE_STRDUP(filename); (*ai)->size = body->size.bytes; - if ( emcore_get_content_type_from_mail_bodystruct(body, 512, content_type_buffer) == EMF_ERROR_NONE) + (*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__ @@ -2233,11 +2254,11 @@ PARTLIST* emcore_get_body_full(MAILSTREAM *stream, int msg_uid, BODY *body, stru EM_DEBUG_LOG("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 = EMF_ATTACHMENT_DRM_OBJECT; + (*ai)->drm = EMAIL_ATTACHMENT_DRM_OBJECT; else if (!strcasecmp(body->subtype, MIME_SUBTYPE_DRM_RIGHTS)) - (*ai)->drm = EMF_ATTACHMENT_DRM_RIGHTS; + (*ai)->drm = EMAIL_ATTACHMENT_DRM_RIGHTS; else if (!strcasecmp(body->subtype, MIME_SUBTYPE_DRM_DCF)) - (*ai)->drm = EMF_ATTACHMENT_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; } @@ -2322,7 +2343,7 @@ INTERNAL_FUNC int emcore_get_body_part_list_full(MAILSTREAM *stream, int msg_uid 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 = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return FAILURE; } section_list = emcore_get_body_full(stream, msg_uid, body, cnt_info, err_code, section_list); @@ -2345,23 +2366,26 @@ INTERNAL_FUNC int emcore_get_body_part_list_full(MAILSTREAM *stream, int msg_uid 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 temp_decoded_len = 0; + int inline_support = 0; + int ret = false; + int error = EMAIL_ERROR_NONE; int not_found = true; - FILE *fp = NULL; - char *decoded = NULL; - unsigned long decoded_len = 0; 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; - char save_file_name[MAX_PATH+1] = {0, }; - char html_cid_path[MAX_PATH+1] = {0, }; - int temp_decoded_len = 0; - int inline_support = 0; - int error = EMF_ERROR_NONE; + if (!encoded || !filename || !write_mode) { EM_DEBUG_EXCEPTION("Invalid Param "); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2393,10 +2417,11 @@ static int emcore_write_response_into_file(char *filename, char *write_mode, cha if (decoded != NULL) { EM_DEBUG_LOG("Decoded Length [%d] " , decoded_len); + EM_DEBUG_LOG("filename [%s] " , filename); if (!(fp = fopen(filename, write_mode))) { EM_DEBUG_EXCEPTION("fopen failed - %s", filename); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; return false; } @@ -2437,7 +2462,7 @@ static int emcore_write_response_into_file(char *filename, char *write_mode, cha memset(html_cid_path, 0x00, MAX_PATH); /* Finding 'filename' attribute from content inf */ - emcore_get_file_pointer(body_inline, save_file_name, NULL, &error); + emcore_get_file_pointer(body_inline, true, save_file_name, NULL, &error); if (strlen(save_file_name) > 0) { /* Content ID will be replaced with its file name in html */ @@ -2481,21 +2506,23 @@ static int emcore_write_response_into_file(char *filename, char *write_mode, cha } } - EM_DEBUG_LOG("Before fwrite"); + 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("fwrite(\"%s\") failed...", decoded); - EM_DEBUG_EXCEPTION(" Error Occured while writing "); - error = EMF_ERROR_SYSTEM_FAILURE; + 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 "); + EM_DEBUG_EXCEPTION("Error Occured while decoding "); goto FINISH_OFF; } + ret = true; + FINISH_OFF: if (err) *err = error; @@ -2507,7 +2534,7 @@ FINISH_OFF: EM_DEBUG_FUNC_END(); - return true; + return ret; } @@ -2534,7 +2561,7 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int EM_DEBUG_FUNC_BEGIN("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 = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; FILE *fp = NULL; IMAPLOCAL *imaplocal = NULL; @@ -2554,7 +2581,7 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int if (!stream || !filepath || !section) { EM_DEBUG_EXCEPTION("stream[%p], filepath[%s], uid[%d], section[%s], encoding[%d], decoded_total[%p]", stream, filepath, uid, section, encoding, decoded_total); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2570,7 +2597,7 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int max_write_buffer_size *= 1024; /* KB -> byte */ if (!(write_buffer = em_malloc(sizeof(char) *max_write_buffer_size))) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } } @@ -2579,7 +2606,7 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int if (!(fp = fopen(filepath, "wb+"))) { EM_DEBUG_EXCEPTION("fopen failed - %s", filepath); - err = EMF_ERROR_SYSTEM_FAILURE; /* EMF_ERROR_UNKNOWN */ + err = EMAIL_ERROR_SYSTEM_FAILURE; /* EMAIL_ERROR_UNKNOWN */ goto FINISH_OFF; } @@ -2588,7 +2615,7 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int if (!imaplocal->netstream) { EM_DEBUG_EXCEPTION("invalid IMAP4 stream detected... %p", imaplocal->netstream); - err = EMF_ERROR_INVALID_STREAM; + err = EMAIL_ERROR_INVALID_STREAM; goto FINISH_OFF; } @@ -2606,7 +2633,7 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int /* send command : get msgno/uid for all messag */ if (!net_sout(imaplocal->netstream, command, (int)strlen(command))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; + err = EMAIL_ERROR_CONNECTION_BROKEN; goto FINISH_OFF; } @@ -2620,15 +2647,15 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int if (imaplocal->netstream) net_close (imaplocal->netstream); */ - imaplocal->netstream = NULL; - err = EMF_ERROR_CANCELLED; + imaplocal->netstream = NULL; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } /* receive respons */ if (!(response = net_getline(imaplocal->netstream))) { EM_DEBUG_EXCEPTION("net_getline failed..."); - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } #ifdef FEATURE_CORE_DEBUG @@ -2649,7 +2676,7 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int *s = '\0'; if (strcmp(section, p)) { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -2678,12 +2705,12 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int write_flag = true; } else { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } } else { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } } @@ -2733,12 +2760,10 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int 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 = EMF_ERROR_NO_RESPONSE; + err = EMAIL_ERROR_NO_RESPONSE; goto FINISH_OFF; } - mail_close(stream); /* TODO : remove this line */ - 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; @@ -2757,22 +2782,25 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int _imap4_received_body_size -= gap; _imap4_last_notified_body_size = _imap4_received_body_size; - EM_DEBUG_LOG("DOWNLOADING STATUS NOTIFY : Encoded[%d] / [%d] = %d %% Completed. -- Total Decoded[%d]", total, body_size, 100*total/body_size, total); - EM_DEBUG_LOG("DOWNLOADING STATUS NOTIFY : Total[%d] / [%d] = %d %% Completed.", _imap4_received_body_size, _imap4_total_body_size, 100*_imap4_received_body_size/_imap4_total_body_size); + if(body_size > 0) + EM_DEBUG_LOG("DOWNLOADING STATUS NOTIFY : Encoded[%d] / [%d] = %d %% Completed. -- Total Decoded[%d]", total, body_size, 100*total/body_size, total); + + if(_imap4_total_body_size > 0) + EM_DEBUG_LOG("DOWNLOADING STATUS NOTIFY : Total[%d] / [%d] = %d %% Completed.", _imap4_received_body_size, _imap4_total_body_size, 100*_imap4_received_body_size/_imap4_total_body_size); if (is_attachment) { - if (!emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, filename, is_attachment, 100 *_imap4_received_body_size / _imap4_total_body_size)) + if (_imap4_total_body_size && !emstorage_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, filename, is_attachment, 100 *_imap4_received_body_size / _imap4_total_body_size)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_DOWNLOAD_ATTACH_START] Failed >>>> "); } else { - if (multi_part_body_size) { - if (!emstorage_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, filename, _imap4_total_body_size, _imap4_received_body_size)) - EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>> "); - } - else { - if (!emstorage_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, filename, _imap4_total_body_size, _imap4_received_body_size)) - EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>>"); - } + if (multi_part_body_size) { + if (!emstorage_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, filename, _imap4_total_body_size, _imap4_received_body_size)) + EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>> "); + } + else { + if (!emstorage_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, filename, _imap4_total_body_size, _imap4_received_body_size)) + EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>>"); + } } /* if (is_attachment) .. else .. */ } } @@ -2794,7 +2822,7 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int if (net_getbuffer (imaplocal->netstream, (long)x, (char *)encoded) <= 0) { EM_DEBUG_EXCEPTION("net_getbuffer failed..."); - err = EMF_ERROR_NO_RESPONSE; + err = EMAIL_ERROR_NO_RESPONSE; goto FINISH_OFF; } @@ -2858,7 +2886,7 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int } else { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; } @@ -2868,7 +2896,7 @@ static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int EM_SAFE_FREE(response); } else { /* 'NO' or 'BAD */ - err = EMF_ERROR_IMAP4_FETCH_UID_FAILURE; + err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE; goto FINISH_OFF; } @@ -2913,7 +2941,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a { 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 = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char sections[IMAP_MAX_COMMAND_LENGTH] = { 0, }; IMAPLOCAL *imaplocal = NULL; char tag[16] = { 0, }, command[IMAP_MAX_COMMAND_LENGTH] = { 0, }; @@ -2936,7 +2964,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a if (!(imaplocal = stream->local) || !imaplocal->netstream || !section_list || !cnt_info) { EM_DEBUG_EXCEPTION("invalid IMAP4 stream detected..."); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; return_value = -1; goto FINISH_OFF; } @@ -2996,7 +3024,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a /* send command : get msgno/uid for all message */ if (!net_sout(imaplocal->netstream, command, (int)strlen(command))) { EM_DEBUG_EXCEPTION("net_sout failed..."); - err = EMF_ERROR_CONNECTION_BROKEN; + err = EMAIL_ERROR_CONNECTION_BROKEN; return_value = -1; goto FINISH_OFF; } @@ -3005,7 +3033,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a /* receive respons */ if (!(response = net_getline(imaplocal->netstream))) { EM_DEBUG_EXCEPTION("net_getline failed..."); - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; return_value = -1; goto FINISH_OFF; } @@ -3014,7 +3042,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a if (!server_response_yn) /* start of response */ { if (response[0] != '*') { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; EM_DEBUG_EXCEPTION("Start of response doesn't contain *"); return_value = -1; goto FINISH_OFF; @@ -3028,7 +3056,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a if (emcore_get_section_body_size(response, section, &body_size)<0) { EM_DEBUG_EXCEPTION("emcore_get_section_body_size failed [%d]", err); - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; return_value = -1; goto FINISH_OFF; } @@ -3037,7 +3065,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a /* 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 = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; return_value = -1; goto FINISH_OFF; } @@ -3079,7 +3107,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a } else if (body->id || body->location || body->disposition.type) { - if (emcore_get_file_pointer(body, filename, cnt_info , &err)<0) { + 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; } @@ -3087,17 +3115,16 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a /* Search info from attachment list followed by inline attachment list */ ai = cnt_info->file; - EM_DEBUG_LOG(" ai - %p ", (ai)); + 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->name != NULL && !strcmp(ai->name, filename))) { + if (ai->save == NULL && (ai->content_id != NULL && !strcmp(ai->content_id, body->id))) { EM_DEBUG_LOG("Found matching details "); ai->save = buf; + break; } - } - } FINISH_OFF_IF_CANCELED; @@ -3137,7 +3164,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a 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 = EMF_ERROR_NO_RESPONSE; + err = EMAIL_ERROR_NO_RESPONSE; return_value = -1; goto FINISH_OFF; } @@ -3219,7 +3246,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a if (net_getbuffer (imaplocal->netstream, (long)x, (char *)encoded) <= 0) { EM_DEBUG_EXCEPTION("net_getbuffer failed..."); - err = EMF_ERROR_NO_RESPONSE; + err = EMAIL_ERROR_NO_RESPONSE; return_value = -1; goto FINISH_OFF; } @@ -3295,7 +3322,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a goto FINISH_OFF; } } - EM_DEBUG_LOG("%d has been written", strlen((char *)test_buffer)); + EM_DEBUG_LOG("%d has been written", strlen((char *)test_buffer)); } } } @@ -3303,7 +3330,7 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a if (!strncmp(response + strlen(tag) + 1, "OK", 2)) EM_SAFE_FREE(response); else /* 'NO' or 'BAD */ { - err = EMF_ERROR_IMAP4_FETCH_UID_FAILURE; + err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE; return_value = -1; goto FINISH_OFF; } @@ -3330,31 +3357,94 @@ static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int a return return_value; } -static int emcore_get_file_pointer(BODY *body, char *buf, struct _m_content_info *cnt_info , int *err) +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 [%p], 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) { + 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 [%p], 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); + +FINISH_OFF: + + EM_SAFE_FREE(file_name); + EM_SAFE_FREE(extension); + + EM_DEBUG_FUNC_END("err [%d], temp_file_name [%s]", err, temp_file_name); + 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 = EMF_ERROR_NONE; + 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 = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (body->subtype[0] == 'H') { if (cnt_info->text.plain_charset != NULL) { - memcpy(buf, cnt_info->text.plain_charset, strlen(cnt_info->text.plain_charset)); - strcat(buf, HTML_EXTENSION_STRING); + memcpy(output_file_name_string, cnt_info->text.plain_charset, strlen(cnt_info->text.plain_charset)); + strcat(output_file_name_string, HTML_EXTENSION_STRING); } else { - memcpy(buf, "UTF-8.htm", strlen("UTF-8.htm")); + memcpy(output_file_name_string, "UTF-8.htm", strlen("UTF-8.htm")); } - cnt_info->text.html = EM_SAFE_STRDUP(buf); + cnt_info->text.html = EM_SAFE_STRDUP(output_file_name_string); } else { PARAMETER *param = body->parameter; @@ -3362,16 +3452,17 @@ static int emcore_get_file_pointer(BODY *body, char *buf, struct _m_content_info if (emcore_get_attribute_value_of_body_part(param, "CHARSET", charset_string, 512, false, &error)) { cnt_info->text.plain_charset = EM_SAFE_STRDUP(charset_string); - memcpy(buf, cnt_info->text.plain_charset, strlen(cnt_info->text.plain_charset)); + memcpy(output_file_name_string, cnt_info->text.plain_charset, strlen(cnt_info->text.plain_charset)); } else - memcpy(buf, "UTF-8", strlen("UTF-8")); + memcpy(output_file_name_string, "UTF-8", strlen("UTF-8")); - cnt_info->text.plain = EM_SAFE_STRDUP(buf); + 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 Inlin */ + 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; @@ -3382,7 +3473,7 @@ static int emcore_get_file_pointer(BODY *body, char *buf, struct _m_content_info goto FINISH_OFF; } } - else if (body->disposition.type) { + 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); @@ -3393,9 +3484,9 @@ static int emcore_get_file_pointer(BODY *body, char *buf, struct _m_content_info } else { /* body id is not null but disposition type is null */ if ((body->id[0] == '<')) - SNPRINTF(attachment_file_name, MAX_PATH, body->id+1); /* fname = em_parse_filename(body->id + 1 */ + SNPRINTF(attachment_file_name, MAX_PATH, "%s", body->id+1); /* fname = em_parse_filename(body->id + 1 */ else - SNPRINTF(attachment_file_name, MAX_PATH, body->id); /* fname = em_parse_filename(body->id */ + SNPRINTF(attachment_file_name, MAX_PATH, "%s", body->id); /* fname = em_parse_filename(body->id */ len = strlen(attachment_file_name); @@ -3405,24 +3496,40 @@ static int emcore_get_file_pointer(BODY *body, char *buf, struct _m_content_info } EM_DEBUG_LOG("attachment_file_name [%s]", attachment_file_name); if (decoded_filename != NULL) - memcpy(buf, decoded_filename, strlen(decoded_filename)); + memcpy(output_file_name_string, decoded_filename, strlen(decoded_filename)); else - memcpy(buf, attachment_file_name, strlen(attachment_file_name)); + memcpy(output_file_name_string, attachment_file_name, 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(buf, attachment_file_name, strlen(attachment_file_name)); + memcpy(output_file_name_string, attachment_file_name, 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_SAFE_FREE(decoded_filename); - EM_DEBUG_FUNC_END("buf[%s]", buf); + EM_DEBUG_FUNC_END("output_file_name_string[%s], error [%d]", output_file_name_string, error); return SUCCESS; } @@ -3488,7 +3595,7 @@ static int emcore_get_section_body_size(char *response, char *section, int *body strcpy(section, p); /* if (strcmp(section, p)) { - err = EMF_ERROR_INVALID_RESPONSE; + err = EMAIL_ERROR_INVALID_RESPONSE; goto FINISH_OFF; }*/ p = strstr(s+1, " {"); @@ -3560,7 +3667,7 @@ INTERNAL_FUNC int emcore_get_content_type_from_mime_string(char *input_mime_stri { EM_DEBUG_FUNC_BEGIN("input_mime_string [%p], output_content_type [%p]", input_mime_string, output_content_type); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int temp_mime_header_string_length = 0; char result_content_type[256] = { 0, }; char *temp_mime_header_string = NULL; @@ -3568,8 +3675,8 @@ INTERNAL_FUNC int emcore_get_content_type_from_mime_string(char *input_mime_stri char *temp_content_type_end = NULL; if(input_mime_string == NULL || output_content_type == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -3581,8 +3688,8 @@ INTERNAL_FUNC int emcore_get_content_type_from_mime_string(char *input_mime_stri temp_content_type_start = strcasestr(temp_mime_header_string, CONTENT_TYPE_STRING_IN_MIME_HEAEDER); if(temp_content_type_start == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_DATA"); - err = EMF_ERROR_INVALID_DATA; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_DATA"); + err = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } else { @@ -3602,7 +3709,7 @@ INTERNAL_FUNC int emcore_get_content_type_from_mime_string(char *input_mime_stri } else { EM_DEBUG_EXCEPTION("temp_content_type_end - temp_content_type_start [%d]", temp_content_type_end - temp_content_type_start); - err = EMF_ERROR_DATA_TOO_LONG; + err = EMAIL_ERROR_DATA_TOO_LONG; goto FINISH_OFF; } } @@ -3619,12 +3726,12 @@ FINISH_OFF: INTERNAL_FUNC int emcore_get_content_type_from_mail_bodystruct(BODY *input_body, int input_buffer_length, char *output_content_type) { EM_DEBUG_FUNC_BEGIN("input_body [%p], input_buffer_length [%d], output_content_type [%p]", input_body, input_buffer_length, output_content_type); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char subtype_string[SUBTYPE_STRING_LENGTH] = { 0 , }; if(input_body == NULL || output_content_type == NULL || input_buffer_length == 0) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -3660,8 +3767,8 @@ INTERNAL_FUNC int emcore_get_content_type_from_mail_bodystruct(BODY *input_body, SNPRINTF(output_content_type, input_buffer_length, "other/%s", subtype_string); break; default: - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; break; } @@ -3679,11 +3786,11 @@ INTERNAL_FUNC int emcore_get_attribute_value_of_body_part(PARAMETER *input_param EM_DEBUG_FUNC_BEGIN("input_param [%p], atribute_name [%s], output_buffer_length [%d], with_rfc2047_text [%d]", input_param, atribute_name, output_buffer_length, with_rfc2047_text); PARAMETER *temp_param = input_param; char *decoded_value = NULL, *result_value = NULL; - int ret = false, err = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; if(!output_value) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -3705,8 +3812,8 @@ INTERNAL_FUNC int emcore_get_attribute_value_of_body_part(PARAMETER *input_param result_value = temp_param->value; } else { - EM_DEBUG_EXCEPTION("EMF_ERROR_DATA_NOT_FOUND"); - err = EMF_ERROR_DATA_NOT_FOUND; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_DATA_NOT_FOUND"); + err = EMAIL_ERROR_DATA_NOT_FOUND; goto FINISH_OFF; } EM_DEBUG_LOG("result_value [%s]", result_value); @@ -3718,7 +3825,7 @@ INTERNAL_FUNC int emcore_get_attribute_value_of_body_part(PARAMETER *input_param } else { EM_DEBUG_EXCEPTION("buffer is too short"); - err = EMF_ERROR_DATA_TOO_LONG; + err = EMAIL_ERROR_DATA_TOO_LONG; goto FINISH_OFF; } } @@ -3746,7 +3853,7 @@ static int emcore_get_body_part_imap(MAILSTREAM *stream, int account_id, int mai { 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 = EMF_ERROR_NONE, ret = -1; + int err = EMAIL_ERROR_NONE, ret = -1; struct attachment_info **ai; struct attachment_info *prev_ai = NULL; struct attachment_info *next_ai = NULL; @@ -3775,14 +3882,14 @@ static int emcore_get_body_part_imap(MAILSTREAM *stream, int account_id, int mai /* unknown type */ if (body->type > TYPEOTHER) { /* unknown type */ EM_DEBUG_EXCEPTION("Unknown type."); - err = EMF_ERROR_NOT_SUPPORTED; + 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 = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return FAILURE; } @@ -3875,9 +3982,9 @@ static int emcore_get_body_part_imap(MAILSTREAM *stream, int account_id, int mai } else { if ((body->id[0] == '<')) - SNPRINTF(filename, MAX_PATH, body->id+1); + SNPRINTF(filename, MAX_PATH, "%s", body->id+1); else - SNPRINTF(filename, MAX_PATH, body->id); + SNPRINTF(filename, MAX_PATH, "%s", body->id); len = strlen(filename); @@ -4069,7 +4176,7 @@ static int emcore_get_body_part_imap(MAILSTREAM *stream, int account_id, int mai if (!(*ai = em_malloc(sizeof(struct attachment_info)))) { EM_DEBUG_EXCEPTION("em_malloc failed..."); if (err_code != NULL) - *err_code = EMF_ERROR_OUT_OF_MEMORY; + *err_code = EMAIL_ERROR_OUT_OF_MEMORY; return FAILURE; } @@ -4081,9 +4188,10 @@ static int emcore_get_body_part_imap(MAILSTREAM *stream, int account_id, int mai (*ai)->name = EM_SAFE_STRDUP(filename); (*ai)->size = body->size.bytes; (*ai)->save = o_data; + (*ai)->content_id = EM_SAFE_STRDUP(body->id); memset(content_type_buffer, 0, 512); - if ( (err = emcore_get_content_type_from_mail_bodystruct(body, 512, content_type_buffer) ) == EMF_ERROR_NONE) + 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("name[%s], size[%d], save[%s], content_id[%s], content_type_buffer [%s]", cnt_info->file->name, cnt_info->file->size, cnt_info->file->save, content_type_buffer); @@ -4098,12 +4206,12 @@ static int emcore_get_body_part_imap(MAILSTREAM *stream, int account_id, int mai case TYPEMESSAGE: /* RFC822 Message */ EM_DEBUG_EXCEPTION("MESSAGE/RFC822"); - err = EMF_ERROR_NOT_SUPPORTED; + err = EMAIL_ERROR_NOT_SUPPORTED; goto FINISH_OFF; default: EM_DEBUG_EXCEPTION("Unknown type. body->type [%d]", body->type); - err = EMF_ERROR_NOT_SUPPORTED; + err = EMAIL_ERROR_NOT_SUPPORTED; goto FINISH_OFF; } @@ -4180,7 +4288,7 @@ static int emcore_get_body_part_imap(MAILSTREAM *stream, int account_id, int mai /* add attachment info to content inf */ if (!(*ai = em_malloc(sizeof(struct attachment_info)))) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -4202,9 +4310,10 @@ static int emcore_get_body_part_imap(MAILSTREAM *stream, int account_id, int mai (*ai)->name = EM_SAFE_STRDUP(filename); (*ai)->size = dec_len; (*ai)->save = savefile; + (*ai)->content_id = EM_SAFE_STRDUP(body->id); memset(content_type_buffer, 0, 512); - if ( (err = emcore_get_content_type_from_mail_bodystruct(body, 512, content_type_buffer) ) == EMF_ERROR_NONE) + 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; @@ -4215,11 +4324,11 @@ static int emcore_get_body_part_imap(MAILSTREAM *stream, int account_id, int mai #endif if (body->type == TYPEAPPLICATION) { if (!strcasecmp(body->subtype, MIME_SUBTYPE_DRM_OBJECT)) - (*ai)->drm = EMF_ATTACHMENT_DRM_OBJECT; + (*ai)->drm = EMAIL_ATTACHMENT_DRM_OBJECT; else if (!strcasecmp(body->subtype, MIME_SUBTYPE_DRM_RIGHTS)) - (*ai)->drm = EMF_ATTACHMENT_DRM_RIGHTS; + (*ai)->drm = EMAIL_ATTACHMENT_DRM_RIGHTS; else if (!strcasecmp(body->subtype, MIME_SUBTYPE_DRM_DCF)) - (*ai)->drm = EMF_ATTACHMENT_DRM_DCF; + (*ai)->drm = EMAIL_ATTACHMENT_DRM_DCF; } /* All inline images information are stored at the end of list */ @@ -4315,7 +4424,7 @@ static int emcore_get_multi_part(MAILSTREAM *stream, int account_id, int mail_id if (!body) { EM_DEBUG_EXCEPTION("Invalid Parameter."); if (err_code) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return FAILURE; } @@ -4355,7 +4464,7 @@ INTERNAL_FUNC int emcore_get_body(MAILSTREAM *stream, int account_id, int mail_i EM_DEBUG_EXCEPTION("Invalid parameter"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return FAILURE; } @@ -4402,7 +4511,7 @@ INTERNAL_FUNC int emcore_get_body_structure(MAILSTREAM *stream, int msg_uid, BOD #endif if (!env) { if (err_code) - *err_code = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER; + *err_code = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER; EM_DEBUG_EXCEPTION("mail_fetch_structure failed"); return FAILURE; } @@ -4424,7 +4533,7 @@ INTERNAL_FUNC int emcore_set_fetch_body_section(BODY *body, int enable_inline_li if (!body) { EM_DEBUG_EXCEPTION("body [%p]", body); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return FAILURE; } @@ -4540,7 +4649,7 @@ static char *emcore_decode_rfc2047_word(char *encoded_word, int *err_code) { EM_DEBUG_FUNC_BEGIN("encoded_word[%s], err_code[%p]", encoded_word, err_code); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int base64_encoded = false, length = 0; SIZEDTEXT src = { NULL, 0 }; SIZEDTEXT dst = { NULL, 0 }; @@ -4551,7 +4660,7 @@ static char *emcore_decode_rfc2047_word(char *encoded_word, int *err_code) if (buffer == NULL) { EM_DEBUG_EXCEPTION("Memory allocation fail"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -4592,7 +4701,7 @@ static char *emcore_decode_rfc2047_word(char *encoded_word, int *err_code) else { EM_DEBUG_EXCEPTION("unknown encoding found..."); - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; goto FINISH_OFF; } } @@ -4611,7 +4720,7 @@ static char *emcore_decode_rfc2047_word(char *encoded_word, int *err_code) else { /* end flag is not found */ EM_DEBUG_EXCEPTION("emcore_decode_rfc2047_word decoding error : '?=' is not found..."); - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; goto FINISH_OFF; } } @@ -4721,12 +4830,12 @@ INTERNAL_FUNC char *emcore_decode_rfc2047_text(char *rfc2047_text, int *err_code EM_DEBUG_FUNC_BEGIN("rfc2047_text[%s], err_code[%p]", rfc2047_text, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!rfc2047_text) { EM_DEBUG_EXCEPTION("rfc2047_text[%p]", rfc2047_text); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return NULL; } @@ -4768,3 +4877,466 @@ FINISH_OFF: EM_DEBUG_FUNC_END(); return text; } + +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 ret = false; + int err = EMAIL_ERROR_NONE; + int local_attachment_count = 0; + int local_inline_content_count = 0; + int attachment_num = 0; + int i = 0; + int eml_mail_id = 0; + char buf[512]; + char html_body[MAX_PATH] = {0, }; + struct tm temp_time_info; + struct timeval tv; + struct attachment_info *ai = NULL; + email_attachment_data_t *attachment = NULL; + email_mail_data_t *p_mail_data = NULL; + MESSAGECACHE mail_cache_element = {0, }; + + if (!mmsg || !cnt_info || !output_mail_data || !output_attachment_data) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + p_mail_data = (email_mail_data_t *)em_malloc(sizeof(email_mail_data_t)); + if (p_mail_data == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + memset(&mail_cache_element, 0x00, sizeof(MESSAGECACHE)); + memset((void *)&temp_time_info, 0, sizeof(struct tm)); + + /* Create rand mail id of eml */ + gettimeofday(&tv, NULL); + srand(tv.tv_usec); + eml_mail_id = rand(); + + p_mail_data->mail_id = eml_mail_id; + p_mail_data->account_id = EML_FOLDER; + + if (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; + + 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; + + p_mail_data->date_time = timegm(&temp_time_info); + p_mail_data->full_address_return = EM_SAFE_STRDUP(mmsg->rfc822header->return_path); + p_mail_data->email_address_recipient = EM_SAFE_STRDUP(mmsg->rfc822header->received); + p_mail_data->full_address_from = EM_SAFE_STRDUP(mmsg->rfc822header->from); + p_mail_data->subject = EM_SAFE_STRDUP(mmsg->rfc822header->subject); + p_mail_data->email_address_sender = EM_SAFE_STRDUP(mmsg->rfc822header->sender); + p_mail_data->full_address_to = EM_SAFE_STRDUP(mmsg->rfc822header->to); + p_mail_data->full_address_cc = EM_SAFE_STRDUP(mmsg->rfc822header->cc); + p_mail_data->full_address_bcc = EM_SAFE_STRDUP(mmsg->rfc822header->bcc); + p_mail_data->full_address_reply = EM_SAFE_STRDUP(mmsg->rfc822header->reply_to); + p_mail_data->body_download_status = EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED; + + 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) { + EM_DEBUG_LOG("cnt_info->text.plain [%s]", cnt_info->text.plain); + if (!emstorage_create_dir(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 : "UTF-8", 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; + } + + p_mail_data->file_path_plain = EM_SAFE_STRDUP(buf); + EM_DEBUG_LOG("mail_data->file_path_plain [%s]", p_mail_data->file_path_plain); + } + + if (cnt_info->text.html) { + if (!emstorage_create_dir(EML_FOLDER, eml_mail_id, 0, &err)) { + EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err); + goto FINISH_OFF; + } + + if (cnt_info->text.plain_charset != NULL) { + memcpy(html_body, cnt_info->text.plain_charset, 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(EML_FOLDER, eml_mail_id, 0, html_body, 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; + } + p_mail_data->file_path_html = EM_SAFE_STRDUP(buf); + } + + + for (ai = cnt_info->file; ai; ai = ai->next, attachment_num++) {} + EM_DEBUG_LOG("attachment_num : [%d]", attachment_num); + + if (attachment_num > 0) { + attachment = (email_attachment_data_t *)em_malloc(sizeof(email_attachment_data_t) * attachment_num); + if (attachment == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + for (ai = cnt_info->file; ai; ai = ai->next, i++) { + attachment[i].attachment_id = i; + attachment[i].attachment_size = ai->size; + attachment[i].attachment_name = EM_SAFE_STRDUP(ai->name); + attachment[i].drm_status = ai->drm; + attachment[i].save_status = 0; + attachment[i].inline_content_status = ai->type == 1; + attachment[i].attachment_mime_type = ai->attachment_mime_type; +#ifdef __ATTACHMENT_OPTI__ + attachment[i].encoding = ai->encoding; + attachment[i].section = ai->section; +#endif + EM_DEBUG_LOG("attachment[%d].attachment_id[%d]", i, attachment[i].attachment_id); + EM_DEBUG_LOG("attachment[%d].attachment_size[%d]", i, attachment[i].attachment_size); + EM_DEBUG_LOG("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); + + if (ai->type == 1) + local_inline_content_count ++; + local_attachment_count++; + + if (ai->save) { + attachment[i].save_status = 1; + if (ai->type == 1) { /* it is inline content */ + if (!emstorage_create_dir(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, &err)) { + EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err); + goto FINISH_OFF; + } + } + else { + if (!emstorage_create_dir(EML_FOLDER, eml_mail_id, i, &err)) { + EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err); + goto FINISH_OFF; + } + + if (!emstorage_get_save_name(EML_FOLDER, eml_mail_id, i, attachment[i].attachment_name, 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(EML_FOLDER, eml_mail_id, 0, NULL, 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; + } + + attachment[i].attachment_path = EM_SAFE_STRDUP(buf); + + } + + EM_DEBUG_LOG("attachment[%d].attachment_path[%s]", i, attachment[i].attachment_path); + } + } + EM_DEBUG_LOG("Check #1"); + + p_mail_data->attachment_count = local_attachment_count; + p_mail_data->inline_content_count = local_inline_content_count; + + eml_data_count += 1; + ret = true; + +FINISH_OFF: + + if (ret) { + if (output_mail_data) + *output_mail_data = p_mail_data; + + if (output_attachment_data) + *output_attachment_data = attachment; + + if (output_attachment_count) + *output_attachment_count = local_attachment_count; + } else { + if (p_mail_data) + emcore_free_mail_data(p_mail_data); + + if (attachment) + emcore_free_attachment_data(&attachment, attachment_num, NULL); + } + + if (err_code) + *err_code = err; + + return ret; +} + +INTERNAL_FUNC int emcore_load_eml_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("eml_file_path : [%s], output_mail_data : [%p]", eml_file_path, output_mail_data); + + int err = EMAIL_ERROR_NONE; + int ret = false; + int is_file = 1; + FILE *eml_fp = NULL; + struct _m_content_info *cnt_info = NULL; + struct _m_mesg *mmsg = NULL; + + + if (!eml_file_path || !output_mail_data || !output_attachment_data || !output_attachment_count) { + EM_DEBUG_EXCEPTION("Invalid paramter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + cnt_info = (struct _m_content_info *)em_malloc(sizeof(struct _m_content_info)); + if (cnt_info == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed..."); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + cnt_info->grab_type = GRAB_TYPE_TEXT | GRAB_TYPE_ATTACHMENT; + + 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; + } + + eml_fp = fopen(eml_file_path, "r"); + if (eml_fp == NULL) { + EM_DEBUG_EXCEPTION("file open failed"); + err = EMAIL_ERROR_ON_PARSING; + goto FINISH_OFF; + } + + if (!emcore_mime_parse_header(eml_fp, is_file, &mmsg->rfc822header, &mmsg->header, &err)) { + EM_DEBUG_EXCEPTION("emcore_mime_parse_header failed : [%d]", err); + goto FINISH_OFF; + } + + if (emcore_mime_parse_body(eml_fp, is_file, mmsg, cnt_info, NULL, &err) < 0) { + EM_DEBUG_EXCEPTION("emcore_mime_parse_body failed : [%d]", err); + goto FINISH_OFF; + } + + if (!emcore_make_mail_data_from_mime_data(mmsg, cnt_info, output_mail_data, output_attachment_data, output_attachment_count, &err)) { + EM_DEBUG_EXCEPTION("emcore_make_mail_tbl_data_from_mime failed : [%d]", err); + goto FINISH_OFF; + + } + + ret = true; + +FINISH_OFF: + + if (eml_fp) + fclose(eml_fp); + + if (mmsg) + emcore_mime_free_mime(mmsg); + + if (cnt_info) + emcore_free_content_info(cnt_info); + + if (err_code) + *err_code = err; + + EM_DEBUG_FUNC_END("err : %d", err); + return ret; +} + +INTERNAL_FUNC int emcore_delete_eml_data(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]; + + if (!input_mail_data) { + EM_DEBUG_EXCEPTION("Invliad parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + if ((input_mail_data->account_id != EML_FOLDER) && (!input_mail_data->mail_id)) { + EM_DEBUG_EXCEPTION("Invliad parameter: account_id[%d], mail_id[%d]", input_mail_data->account_id, input_mail_data->mail_id); + err = EMAIL_ERROR_INVALID_PARAM; + 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); + } 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); + } + + EM_DEBUG_LOG("Directory : [%s]", buf); + + if (!emstorage_delete_dir(buf, &err)) { + EM_DEBUG_EXCEPTION("emstorage_delete_dir failed"); + goto FINISH_OFF; + } + + ret = true; + +FINISH_OFF: + + if (err_code) + *err_code = err; + + return ret; +} + +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; + char buf[MIME_LINE_LEN] = {0x00, }; + char *mime_entity_path = NULL; + char *content_type = NULL; + char boundary[BOUNDARY_LEN] = {0x00,}; + char *boundary_string = NULL; + FILE *fp_read = NULL; + FILE *fp_write = NULL; + struct _m_mesg *mmsg = NULL; + + if (!mime_path) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + 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; + } + + fp_read = fopen(mime_path, "r"); + if (fp_read == NULL) { + EM_DEBUG_EXCEPTION("File open(read) is failed : filename [%s]", mime_path); + err = EMAIL_ERROR_SYSTEM_FAILURE; + 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); + goto FINISH_OFF; + } + + /* Parsing the mime header */ + content_type = emcore_mime_get_header_value(mmsg->header->part_header, CONTENT_TYPE, NULL); + EM_DEBUG_LOG("Content_type : [%s]", content_type); + if (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); + + fp_write = fopen(mime_entity_path, "w"); + if (fp_write == NULL) { + EM_DEBUG_EXCEPTION("File open(write) is failed : filename [%s]", mime_entity_path); + err = EMAIL_ERROR_SYSTEM_FAILURE; + 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)) { + EM_DEBUG_EXCEPTION("emcore_mime_get_line_from_file failed [%d]", err); + break; + } + + if (!strcmp(buf, boundary)) { + search++; + } else if (search == 1) { + EM_DEBUG_LOG("Buf : [%s]", buf); + fprintf(fp_write, "%s", buf); + } else if (search == 2) { + break; + } + } + + 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 = mime_entity_path; + + if (err_code) + *err_code = err; + + EM_DEBUG_FUNC_END(); + return ret; +} diff --git a/email-core/email-core-mm-callbacks.c b/email-core/email-core-mm-callbacks.c index 746e282..5165572 100755 --- a/email-core/email-core-mm-callbacks.c +++ b/email-core/email-core-mm-callbacks.c @@ -49,13 +49,13 @@ static void mm_get_error(char *string, int *err_code); INTERNAL_FUNC void mm_lsub(MAILSTREAM *stream, int delimiter, char *mailbox, long attributes) { EM_DEBUG_FUNC_BEGIN(); - emf_callback_holder_t *p_holder = (emf_callback_holder_t *)stream->sparep; - emf_mailbox_t *p, *p_old = p_holder->data; + email_callback_holder_t *p_holder = (email_callback_holder_t *)stream->sparep; + email_mailbox_t *p, *p_old = p_holder->data; int count = p_holder->num; char *s, *enc_path; /* memory allocation */ - p = realloc(p_old, sizeof(emf_mailbox_t) * (count + 1)); + p = realloc(p_old, sizeof(email_mailbox_t) * (count + 1)); if (!p) return ; /* uw-imap mailbox name format (ex : "{mail.test.com...}inbox" or "{mail.test.com...}anybox/anysubbox") */ @@ -63,7 +63,7 @@ INTERNAL_FUNC void mm_lsub(MAILSTREAM *stream, int delimiter, char *mailbox, lon if (enc_path) enc_path += 1; else { - emcore_free_mailbox(&p, count+1, NULL); + emcore_free_mailbox_list(&p, count+1); return ; } @@ -77,10 +77,10 @@ INTERNAL_FUNC void mm_lsub(MAILSTREAM *stream, int delimiter, char *mailbox, lon } /* coyp string */ - p[count].name = cpystr(enc_path); - p[count].alias = cpystr(enc_path); - p[count].local = 0; - p[count].account_id = stream->spare8; + p[count].mailbox_name = cpystr(enc_path); + p[count].alias = cpystr(enc_path); + p[count].local = 0; + p[count].account_id = stream->spare8; p_holder->data = p; @@ -102,13 +102,13 @@ INTERNAL_FUNC void mm_lsub(MAILSTREAM *stream, int delimiter, char *mailbox, lon INTERNAL_FUNC void mm_list(MAILSTREAM *stream, int delimiter, char *mailbox, long attributes) { EM_DEBUG_FUNC_BEGIN(); - emf_callback_holder_t *p_holder = (emf_callback_holder_t *)stream->sparep; - emf_mailbox_t *p, *p_old = p_holder->data; + email_callback_holder_t *p_holder = (email_callback_holder_t *)stream->sparep; + email_internal_mailbox_t *p, *p_old = p_holder->data; int count = p_holder->num; char *s, *enc_path; /* memory allocation */ - p = realloc(p_old, sizeof(emf_mailbox_t) * (count + 1)); + p = realloc(p_old, sizeof(email_internal_mailbox_t) * (count + 1)); if (!p) return ; /* uw-imap mailbox name format (ex : "{mail.test.com...}inbox" or "{mail.test.com...}anybox/anysubbox") */ @@ -116,7 +116,7 @@ INTERNAL_FUNC void mm_list(MAILSTREAM *stream, int delimiter, char *mailbox, lon if (enc_path) enc_path += 1; else { - emcore_free_mailbox(&p, count+1, NULL); + emcore_free_internal_mailbox(&p, count+1, NULL); return ; } @@ -125,11 +125,36 @@ INTERNAL_FUNC void mm_list(MAILSTREAM *stream, int delimiter, char *mailbox, lon if (*s == (char)delimiter) *s = '/'; - /* coyp string */ - memset(p + count, 0x00, sizeof(emf_mailbox_t)); - p[count].name = cpystr(enc_path); - p[count].alias = cpystr(enc_path); + /* copy string */ + memset(p + count, 0x00, sizeof(email_internal_mailbox_t)); + +#ifdef __FEATURE_XLIST_SUPPORT__ + if(attributes & LATT_XLIST_INBOX) + p[count].mailbox_type = EMAIL_MAILBOX_TYPE_INBOX; + else if(attributes & LATT_XLIST_ALL) + p[count].mailbox_type = EMAIL_MAILBOX_TYPE_ALL_EMAILS; + else if(attributes & LATT_XLIST_DRAFTS) + p[count].mailbox_type = EMAIL_MAILBOX_TYPE_DRAFT; + else if(attributes & LATT_XLIST_SENT) + p[count].mailbox_type = EMAIL_MAILBOX_TYPE_SENTBOX; + else if(attributes & LATT_XLIST_JUNK) + p[count].mailbox_type = EMAIL_MAILBOX_TYPE_SPAMBOX; + else if(attributes & LATT_XLIST_FLAGGED) + p[count].mailbox_type = EMAIL_MAILBOX_TYPE_FLAGGED; + else if(attributes & LATT_XLIST_TRASH) + p[count].mailbox_type = EMAIL_MAILBOX_TYPE_TRASH; +#endif /* __FEATURE_XLIST_SUPPORT__ */ + + if(p[count].mailbox_type == EMAIL_MAILBOX_TYPE_INBOX) /* For exception handling of Gmail inbox*/ + p[count].mailbox_name = cpystr("INBOX"); + else + p[count].mailbox_name = cpystr(enc_path); + + EM_DEBUG_LOG("mm_list mailbox name is %s ", p[count].mailbox_name); + + p[count].alias = emcore_get_alias_of_mailbox((const char *)enc_path); p[count].local = 0; + EM_DEBUG_LOG("mm_list account_id %d", stream->spare8); char *tmp = NULL; @@ -141,8 +166,8 @@ INTERNAL_FUNC void mm_list(MAILSTREAM *stream, int delimiter, char *mailbox, lon *s = '\0'; p[count].account_id = atoi(tmp); } - EM_DEBUG_LOG("mm_list account_id1 %d ", p[count].account_id); - EM_DEBUG_LOG("mm_list mailbox name r %s ", p[count].name); + EM_DEBUG_LOG("mm_list account_id %d ", p[count].account_id); + p_holder->data = p; p_holder->num++; @@ -158,7 +183,7 @@ INTERNAL_FUNC void mm_list(MAILSTREAM *stream, int delimiter, char *mailbox, lon INTERNAL_FUNC void mm_status(MAILSTREAM *stream, char *mailbox, MAILSTATUS* status) { EM_DEBUG_FUNC_BEGIN(); - emf_callback_holder_t *p = stream->sparep; + email_callback_holder_t *p = stream->sparep; EM_DEBUG_FUNC_BEGIN(); if (status->flags & SA_MESSAGES) @@ -176,7 +201,7 @@ INTERNAL_FUNC void mm_login(NETMBX *mb, char *user, char *pwd, long trial) { EM_DEBUG_FUNC_BEGIN(); int account_id; - emf_account_t *ref_account; + email_account_t *ref_account; char *username = NULL; char *password = NULL; @@ -194,19 +219,19 @@ INTERNAL_FUNC void mm_login(NETMBX *mb, char *user, char *pwd, long trial) return; } - if (ref_account->user_name == NULL) { - EM_DEBUG_EXCEPTION("invalid user_name..."); + if (ref_account->incoming_server_user_name == NULL) { + EM_DEBUG_EXCEPTION("invalid incoming_server_user_name..."); return; } - username = EM_SAFE_STRDUP(ref_account->user_name); + username = EM_SAFE_STRDUP(ref_account->incoming_server_user_name); - if (ref_account->password == NULL) { + if (ref_account->incoming_server_password == NULL) { EM_SAFE_FREE(username); EM_DEBUG_EXCEPTION("invalid password..."); return; } - password = EM_SAFE_STRDUP(ref_account->password); + password = EM_SAFE_STRDUP(ref_account->incoming_server_password); if (username && password && strlen(username) > 0 && strlen(password) > 0) { strcpy(user, username); @@ -263,7 +288,7 @@ INTERNAL_FUNC void mm_log(char *string, long errflg) break; case ERROR: { - emf_session_t *session = NULL; + email_session_t *session = NULL; EM_DEBUG_EXCEPTION("IMAP_TOOLKIT_LOG ERROR [%s]", string); @@ -279,11 +304,11 @@ INTERNAL_FUNC void mm_log(char *string, long errflg) if (string) { if (strstr(string, "15 minute") != 0) { if (session) - session->error = EMF_ERROR_LOGIN_ALLOWED_EVERY_15_MINS; + session->error = EMAIL_ERROR_LOGIN_ALLOWED_EVERY_15_MINS; } else if (strstr(string, "Too many login failures") == 0) { if (session) - session->error = EMF_ERROR_TOO_MANY_LOGIN_FAILURE; + session->error = EMAIL_ERROR_TOO_MANY_LOGIN_FAILURE; } } */ @@ -361,52 +386,52 @@ INTERNAL_FUNC void mm_get_error(char *string, int *err_code) EM_DEBUG_LOG("string [%s]", string); if (strstr(string, "login failure") || strstr(string, "Login aborted") || strstr(string, "Can't login")) - *err_code = EMF_ERROR_LOGIN_FAILURE; + *err_code = EMAIL_ERROR_LOGIN_FAILURE; else if (strstr(string, "Scan not valid")) - *err_code = EMF_ERROR_MAILBOX_FAILURE; + *err_code = EMAIL_ERROR_MAILBOX_FAILURE; else if (strstr(string, "Authentication cancelled")) - *err_code = EMF_ERROR_AUTHENTICATE; + *err_code = EMAIL_ERROR_AUTHENTICATE; else if (strstr(string, "authuser")) - *err_code = EMF_ERROR_AUTH_NOT_SUPPORTED; + *err_code = EMAIL_ERROR_AUTH_NOT_SUPPORTED; else if (strstr(string, "negotiate TLS")) - *err_code = EMF_ERROR_CANNOT_NEGOTIATE_TLS; + *err_code = EMAIL_ERROR_CANNOT_NEGOTIATE_TLS; else if (strstr(string, "TLS/SSL failure")) - *err_code = EMF_ERROR_TLS_SSL_FAILURE; + *err_code = EMAIL_ERROR_TLS_SSL_FAILURE; else if (strstr(string, "STARTLS")) - *err_code = EMF_ERROR_STARTLS; + *err_code = EMAIL_ERROR_STARTLS; else if (strstr(string, "TLS unavailable")) - *err_code = EMF_ERROR_TLS_NOT_SUPPORTED; + *err_code = EMAIL_ERROR_TLS_NOT_SUPPORTED; else if (strstr(string, "Can't access")) - *err_code = EMF_ERROR_APPEND_FAILURE; + *err_code = EMAIL_ERROR_APPEND_FAILURE; else if (strstr(string, "Can not authenticate")) - *err_code = EMF_ERROR_AUTHENTICATE; + *err_code = EMAIL_ERROR_AUTHENTICATE; else if (strstr(string, "Unexpected IMAP response") || strstr(string, "hello")) - *err_code = EMF_ERROR_INVALID_RESPONSE; + *err_code = EMAIL_ERROR_INVALID_RESPONSE; else if (strstr(string, "NOTIMAP4REV1")) - *err_code = EMF_ERROR_COMMAND_NOT_SUPPORTED; + *err_code = EMAIL_ERROR_COMMAND_NOT_SUPPORTED; else if (strstr(string, "Anonymous")) - *err_code = EMF_ERROR_ANNONYM_NOT_SUPPORTED; + *err_code = EMAIL_ERROR_ANNONYM_NOT_SUPPORTED; else if (strstr(string, "connection broken")) - *err_code = EMF_ERROR_CONNECTION_BROKEN; + *err_code = EMAIL_ERROR_CONNECTION_BROKEN; else if (strstr(string, "SMTP greeting")) - *err_code = EMF_ERROR_NO_RESPONSE; + *err_code = EMAIL_ERROR_NO_RESPONSE; else if (strstr(string, "ESMTP failure")) - *err_code = EMF_ERROR_SMTP_SEND_FAILURE; + *err_code = EMAIL_ERROR_SMTP_SEND_FAILURE; else if (strstr(string, "socket") || strstr(string, "Socket")) - *err_code = EMF_ERROR_SOCKET_FAILURE; + *err_code = EMAIL_ERROR_SOCKET_FAILURE; else if (strstr(string, "connect to") || strstr(string, "Connection failed")) - *err_code = EMF_ERROR_CONNECTION_FAILURE; + *err_code = EMAIL_ERROR_CONNECTION_FAILURE; else if (strstr(string, "Certificate failure")) - *err_code = EMF_ERROR_CERTIFICATE_FAILURE; + *err_code = EMAIL_ERROR_CERTIFICATE_FAILURE; else if (strstr(string, "ESMTP failure")) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; else if (strstr(string, "No such host")) - *err_code = EMF_ERROR_NO_SUCH_HOST; + *err_code = EMAIL_ERROR_NO_SUCH_HOST; else if (strstr(string, "host") || strstr(string, "Host")) - *err_code = EMF_ERROR_INVALID_SERVER; + *err_code = EMAIL_ERROR_INVALID_SERVER; else if (strstr(string, "SELECT failed")) - *err_code = EMF_ERROR_MAILBOX_NOT_FOUND; + *err_code = EMAIL_ERROR_MAILBOX_NOT_FOUND; else - *err_code = EMF_ERROR_UNKNOWN; + *err_code = EMAIL_ERROR_UNKNOWN; } /* EOF */ diff --git a/email-core/email-core-smime.c b/email-core/email-core-smime.c new file mode 100755 index 0000000..9ec6d60 --- /dev/null +++ b/email-core/email-core-smime.c @@ -0,0 +1,1024 @@ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + + +/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *** + *File : email-core-smime.c + *Desc : MIME Operation + * + *Auth : + * + *History : + * 2011.04.14 : created + ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ***/ +#undef close + +#include +#include +#include +#include +#include + +#include "email-utilities.h" +#include "email-core-global.h" +#include "email-core-utils.h" +#include "email-core-mail.h" +#include "email-core-smtp.h" +#include "email-storage.h" +#include "email-core-smime.h" +#include "email-core-cert.h" +#include "email-debug-log.h" + +/* /opt/share/cert-svc/certs is a base path */ + +#define SMIME_SIGNED_FILE "smime.p7s" +#define SMIME_ENCRYPT_FILE "smime.p7m" + +#define OUTMODE "wb" +#define INMODE "rb" +#define READMODE "r" + +/* If not present then the default digest algorithm for signing key will be used SHA1 */ +static const EVP_MD *emcore_get_digest_algorithm(email_digest_type digest_type) +{ + const EVP_MD *digest_algo = NULL; + + switch (digest_type) { + case DIGEST_TYPE_MD5: + digest_algo = EVP_md5(); + break; + case DIGEST_TYPE_SHA1: + default: + digest_algo = EVP_sha1(); + break; + } + + return digest_algo; +} + +/* If not present then the default cipher algorithm for signing key will be used RC2(40) */ +static const EVP_CIPHER *emcore_get_cipher_algorithm(email_cipher_type cipher_type) +{ + const EVP_CIPHER *cipher = NULL; + + switch (cipher_type) { + case CIPHER_TYPE_RC2_128 : + cipher = EVP_rc2_cbc(); + break; + case CIPHER_TYPE_RC2_64 : + cipher = EVP_rc2_64_cbc(); + break; + case CIPHER_TYPE_DES3 : + cipher = EVP_des_ede3_cbc(); + break; + case CIPHER_TYPE_DES : + cipher = EVP_des_cbc(); + break; +#ifdef __FEATURE_USE_MORE_CIPHER_TYPE__ + case CIPHER_TYPE_SEED : + cipher = EVP_seed_cbc(); + break; + case CIPHER_TYPE_AES128 : + cipher = EVP_aes_128_cbc(); + break; + case CIPHER_TYPE_AES192 : + cipher = EVP_aes_192_cbc(); + break; + case CIPHER_TYPE_AES256 : + cipher = EVP_aes_256_cbc(); + break; +#ifndef OPENSSL_NO_CAMELLIA + case CIPHER_TYPE_CAMELLIA128 : + cipher = EVP_camellia_128_cbc(); + break; + case CIPHER_TYPE_CAMELLIA192 : + cipher = EVP_camellia_192_cbc(); + break; + case CIPHER_TYPE_CAMELLIA256 : + cipher = EVP_camellia_256_cbc(); + break; +#endif +#endif + case CIPHER_TYPE_RC2_40 : + default : + cipher = EVP_rc2_40_cbc(); + break; + } + + return cipher; +} + +static int get_x509_stack_of_recipient_certs(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); + + int err = EMAIL_ERROR_NONE; + int ret = false; + int cert_size = 0; + char *temp_recipients = NULL; + char *token = NULL; + char *str = NULL; + char file_name[512] = {0, }; + const unsigned char *in_cert = NULL; + + X509 *x509_cert = NULL; + STACK_OF(X509) *temp_recipient_certs = NULL; + + CERT_CONTEXT *context = NULL; + emstorage_certificate_tbl_t *cert = NULL; + + if (!recipients || !output_recipient_certs) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + /* Initialize the variable */ + context = cert_svc_cert_context_init(); + temp_recipient_certs = sk_X509_new_null(); + + temp_recipients = EM_SAFE_STRDUP(recipients); + token = strtok_r(temp_recipients, ";", &str); + + do { + if (!emstorage_get_certificate_by_email_address(token, &cert, false, 0, &err)) { + EM_DEBUG_EXCEPTION("emstorage_get_certificate_by_email_address failed : [%d]", err); + goto FINISH_OFF; + } + + SNPRINTF(file_name, sizeof(file_name), "%s", cert->filepath); + EM_DEBUG_LOG("file_name : [%s]", file_name); + err = cert_svc_load_file_to_context(context, file_name); + if (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; + } + + in_cert = context->certBuf->data; + cert_size = context->certBuf->size; + + if (d2i_X509(&x509_cert, &in_cert, cert_size) == NULL) { + EM_DEBUG_EXCEPTION("d2i_X509 failed"); + err = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } + + if (!sk_X509_push(temp_recipient_certs, x509_cert)) { + EM_DEBUG_EXCEPTION("sk_X509_push failed"); + err = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } + + x509_cert = NULL; + context = NULL; + emstorage_free_certificate(&cert, 1, NULL); + cert = NULL; + } while ((token = strtok_r(NULL, ";", &str))); + + *output_recipient_certs = temp_recipient_certs; + + ret = true; + +FINISH_OFF: + + if (!ret) { + if (x509_cert) + X509_free(x509_cert); + + if (temp_recipient_certs) + sk_X509_pop_free(temp_recipient_certs, X509_free); + } + + if (cert) + emstorage_free_certificate(&cert, 1, NULL); + + cert_svc_cert_context_final(context); + + EM_SAFE_FREE(temp_recipients); + + if (err_code) + *err_code = 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) +{ + EM_DEBUG_FUNC_BEGIN(); + int i = 0; + PKCS7 *pkcs7 = NULL; + BIO *p7bio = NULL; + X509 *x509; + + if (!(pkcs7 = PKCS7_new())) { + EM_DEBUG_EXCEPTION("PKCS7 malloc failed"); + return NULL; + } + + if (!PKCS7_set_type(pkcs7, NID_pkcs7_signedAndEnveloped)) { + EM_DEBUG_EXCEPTION("Set type failed"); + goto FINISH_OFF; + } + + if (!PKCS7_add_signature(pkcs7, signer, private_key, md)) { + EM_DEBUG_EXCEPTION("PKCS7_add_signature failed"); + goto FINISH_OFF; + } + + if (!PKCS7_add_certificate(pkcs7, signer)) { + EM_DEBUG_EXCEPTION("PKCS7_add_certificate failed"); + goto FINISH_OFF; + } + + for (i = 0; i < sk_X509_num(recipients_cert); i++) { + x509 = sk_X509_value(recipients_cert, i); + if (!PKCS7_add_recipient(pkcs7, x509)) { + EM_DEBUG_EXCEPTION("PKCS7_add_recipient failed"); + goto FINISH_OFF; + } + } + + if (!PKCS7_set_cipher(pkcs7, cipher)) { + EM_DEBUG_EXCEPTION("Cipher failed"); + goto FINISH_OFF; + } + + if (flags & PKCS7_STREAM) + return pkcs7; + + if (PKCS7_final(pkcs7, mime_entity, flags)) + return pkcs7; + +FINISH_OFF: + BIO_free_all(p7bio); + PKCS7_free(pkcs7); + return NULL; +} +*/ +#define SMIME_DEBUG 1 + +#ifdef SMIME_DEBUG +#define TEMP_PASSWORD_PATH "/opt/data/cert_password" +#endif + +INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate, char *password, char *mime_entity, email_digest_type digest_type, char **file_path, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("certificate path : [%s], password : [%s], mime_entity : [%s]", certificate, password, mime_entity); + int err, ret = false; + char temp_smime_filepath[512]; + X509 *cert = NULL; + STACK_OF(X509) *other_certs = NULL; + EVP_PKEY *private_key = NULL; + const EVP_MD *digest = NULL; + BIO *bio_mime_entity = NULL, *bio_cert = NULL, *bio_prikey = NULL; + BIO *smime_attachment = NULL; + PKCS7 *signed_message = NULL; + int flags = PKCS7_DETACHED | PKCS7_PARTIAL; + + OpenSSL_add_all_algorithms(); + ERR_load_crypto_strings(); + + SNPRINTF(temp_smime_filepath, sizeof(temp_smime_filepath), "%s%s%s%s%s", MAILHOME, DIR_SEPERATOR, MAILTEMP, DIR_SEPERATOR, SMIME_SIGNED_FILE); + EM_DEBUG_LOG("attachment file path of smime : [%s]", temp_smime_filepath); + + smime_attachment = BIO_new_file(temp_smime_filepath, OUTMODE); + if (!smime_attachment) { + EM_DEBUG_EXCEPTION("Cannot open output file %s", temp_smime_filepath); + err = EMAIL_ERROR_FILE_NOT_FOUND; + goto FINISH_OFF; + } + + /* Load certificate for getting the certificate and private key */ + if (!emcore_load_PFX_file(certificate, password, &private_key, &cert, &other_certs, &err)) { + EM_DEBUG_EXCEPTION("Load the private certificate failed : [%d]", err); + goto FINISH_OFF; + } + + bio_mime_entity = BIO_new_file(mime_entity, READMODE); + if (!bio_mime_entity) { + EM_DEBUG_EXCEPTION("Cannot open file[%s]", mime_entity); + goto FINISH_OFF; + } + + signed_message = PKCS7_sign(NULL, NULL, other_certs, bio_mime_entity, flags); + if (!signed_message) { + EM_DEBUG_EXCEPTION("Error creating PKCS#7 structure"); + goto FINISH_OFF; + } + + /* Get the digest algorithm */ + 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"); + goto FINISH_OFF; + } + + if (!PKCS7_final(signed_message, bio_mime_entity, flags)) { + EM_DEBUG_EXCEPTION("PKCS7_final failed"); + goto FINISH_OFF; + } + + if (!i2d_PKCS7_bio_stream(smime_attachment, signed_message, bio_mime_entity, flags)) { + EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed"); + err = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } + BIO_flush(smime_attachment); +#ifdef SMIME_DEBUG + BIO *out = NULL; + + out = BIO_new_file("/opt/data/email/.emfdata/tmp/smout.txt", "w"); + if (!out) + goto FINISH_OFF; + + if (!SMIME_write_PKCS7(out, signed_message, bio_mime_entity, flags)) + goto FINISH_OFF; + + if (out) + BIO_free(out); +#endif + ret = true; + +FINISH_OFF: + if (file_path) + *file_path = temp_smime_filepath; + + X509_free(cert); + EVP_PKEY_free(private_key); + PKCS7_free(signed_message); + + BIO_free(bio_mime_entity); + BIO_free(bio_cert); + BIO_free(bio_prikey); + BIO_free_all(smime_attachment); + + EVP_cleanup(); + if (err_code != NULL) + *err_code = err; + + EM_DEBUG_FUNC_END("err [%d]", err); + 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) +{ + EM_DEBUG_FUNC_BEGIN("certificate path : [%p], mime_entity : [%p]", recipient_list, mime_entity); + char temp_smime_filepath[512]; + int err = EMAIL_ERROR_NONE, ret = false; +// int flags = PKCS7_DETACHED | PKCS7_STREAM; + int flags = 0; + + CERT_CONTEXT *loaded_cert = NULL; + STACK_OF(X509) *recipient_certs = NULL; + X509 *cert = NULL; + BIO *bio_mime_entity = NULL, *bio_cert = NULL; + BIO *smime_attachment = NULL; + PKCS7 *encrypt_message = NULL; + const EVP_CIPHER *cipher = NULL; + + OpenSSL_add_all_algorithms(); + ERR_load_crypto_strings(); + + loaded_cert = cert_svc_cert_context_init(); + + SNPRINTF(temp_smime_filepath, sizeof(temp_smime_filepath), "%s%s%s%s%s", MAILHOME, DIR_SEPERATOR, MAILTEMP, DIR_SEPERATOR, SMIME_ENCRYPT_FILE); + EM_DEBUG_LOG("attachment file path of smime : [%s]", temp_smime_filepath); + + smime_attachment = BIO_new_file(temp_smime_filepath, OUTMODE); + if (!smime_attachment) { + EM_DEBUG_EXCEPTION("Cannot open output file %s", temp_smime_filepath); + err = EMAIL_ERROR_FILE_NOT_FOUND; + goto FINISH_OFF; + } + + if (!get_x509_stack_of_recipient_certs(recipient_list, &recipient_certs, &err)) { + EM_DEBUG_EXCEPTION("get_x509_stack_of_recipient_certs failed [%d]", err); + goto FINISH_OFF; + } + + bio_mime_entity = BIO_new_file(mime_entity, READMODE); + if (!bio_mime_entity) { + EM_DEBUG_EXCEPTION("Cannot open file[%s]", mime_entity); + goto FINISH_OFF; + } + + /* Get cipher algorithm */ + cipher = emcore_get_cipher_algorithm(cipher_type); + + 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()); + goto FINISH_OFF; + } + + if (!i2d_PKCS7_bio_stream(smime_attachment, encrypt_message, bio_mime_entity, flags)) { + EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed"); + err = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } + BIO_flush(smime_attachment); + +#ifdef SMIME_DEBUG + BIO *out = NULL; + + out = BIO_new_file("/opt/data/email/.emfdata/tmp/smout.txt", "w"); + if (!out) + goto FINISH_OFF; + + if (!SMIME_write_PKCS7(out, encrypt_message, bio_mime_entity, flags)) + goto FINISH_OFF; + + if (out) + BIO_free(out); +#endif + + ret = true; + +FINISH_OFF: + if (file_path) + *file_path = temp_smime_filepath; + + PKCS7_free(encrypt_message); + + X509_free(cert); + sk_X509_pop_free(recipient_certs, X509_free); + + BIO_free(bio_cert); + BIO_free(bio_mime_entity); + BIO_free_all(smime_attachment); + + cert_svc_cert_context_final(loaded_cert); + EVP_cleanup(); + if (err_code != NULL) + *err_code = err; + + EM_DEBUG_FUNC_END("err [%d]", err); + return ret; +} + +INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *recipient_list, char *certificate, char *password, char *mime_entity, email_cipher_type cipher_type, email_digest_type digest_type, char **file_path, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("certificate path : [%s], mime_entity : [%s]", recipient_list, mime_entity); + char temp_smime_filepath[512]; + int err = EMAIL_ERROR_NONE, ret = false; + int flags = PKCS7_DETACHED | PKCS7_PARTIAL | PKCS7_STREAM; + + STACK_OF(X509) *recipient_certs = NULL; + STACK_OF(X509) *other_certs = NULL; + BIO *bio_mime_entity = NULL, *bio_cert = NULL; + BIO *bio_signed_message = BIO_new(BIO_s_mem()); + BIO *smime_attachment = NULL; + PKCS7 *signed_message = NULL; + PKCS7 *encrypt_message = NULL; + const EVP_CIPHER *cipher = NULL; + const EVP_MD *digest = NULL; + +#ifdef SMIME_DEBUG + char *signed_string = NULL; + BUF_MEM *buf_mem = NULL; +#endif + /* Variable for private certificate */ + EVP_PKEY *private_key = NULL; + X509 *cert = NULL; + + OpenSSL_add_all_algorithms(); + ERR_load_crypto_strings(); + + SNPRINTF(temp_smime_filepath, sizeof(temp_smime_filepath), "%s%s%s%s%s", MAILHOME, DIR_SEPERATOR, MAILTEMP, DIR_SEPERATOR, SMIME_ENCRYPT_FILE); + EM_DEBUG_LOG("attachment file path of smime : [%s]", temp_smime_filepath); + + smime_attachment = BIO_new_file(temp_smime_filepath, OUTMODE); + if (!smime_attachment) { + EM_DEBUG_EXCEPTION("Cannot open output file %s", temp_smime_filepath); + err = EMAIL_ERROR_FILE_NOT_FOUND; + goto FINISH_OFF; + } + + /* Signing the mail */ + /* 1. Load the private certificate */ + if (!emcore_load_PFX_file(certificate, password, &private_key, &cert, &other_certs, &err)) { + EM_DEBUG_EXCEPTION("Load the certificate failed : [%d]", err); + goto FINISH_OFF; + } + + /* 2. Read mime entity */ + bio_mime_entity = BIO_new_file(mime_entity, READMODE); + if (!bio_mime_entity) { + EM_DEBUG_EXCEPTION("Cannot open file[%s]", mime_entity); + goto FINISH_OFF; + } + + /* 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"); + goto FINISH_OFF; + } + + /* 4. Get the digest algorithm */ + digest = emcore_get_digest_algorithm(digest_type); + + /* 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"); + goto FINISH_OFF; + } + + /* 6. Create signing message */ + if (!SMIME_write_PKCS7(bio_signed_message, signed_message, bio_mime_entity, flags | SMIME_OLDMIME | SMIME_CRLFEOL)) { + EM_DEBUG_EXCEPTION("SMIME_write_PKCS7 error"); + goto FINISH_OFF; + } + +#ifdef SMIME_DEBUG + BIO_get_mem_ptr(bio_signed_message, &buf_mem); + signed_string = em_malloc(buf_mem->length); + memcpy(signed_string, buf_mem->data, buf_mem->length-1); + EM_DEBUG_LOG("Signed message : [%d]", buf_mem->length); + EM_DEBUG_LOG("%s", signed_string); + EM_DEBUG_LOG("buf data: \n, %s", buf_mem->data); + EM_SAFE_FREE(signed_string); +#endif + + /* Encrypting the mail */ + /* 1. Get the recipient certs */ + if (!get_x509_stack_of_recipient_certs(recipient_list, &recipient_certs, &err)) { + EM_DEBUG_EXCEPTION("get_x509_stack_of_recipient_certs failed [%d]", err); + goto FINISH_OFF; + } + + /* 2. Get cipher algorithm */ + cipher = emcore_get_cipher_algorithm(cipher_type); + + flags = 0; + + /* 3. Encrypt the signing message */ + 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()); + 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"); + err = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } + BIO_flush(smime_attachment); + +#ifdef SMIME_DEBUG + BIO *out = NULL; + + out = BIO_new_file("/opt/data/email/.emfdata/tmp/smout.txt", "w"); + if (!out) + goto FINISH_OFF; + + if (!SMIME_write_PKCS7(out, encrypt_message, bio_mime_entity, flags)) + goto FINISH_OFF; + + if (out) + BIO_free(out); +#endif + + ret = true; + +FINISH_OFF: + if (file_path) + *file_path = temp_smime_filepath; + + PKCS7_free(signed_message); + PKCS7_free(encrypt_message); + + X509_free(cert); + sk_X509_pop_free(other_certs, X509_free); + sk_X509_pop_free(recipient_certs, X509_free); + + BIO_free(bio_cert); + BIO_free(bio_mime_entity); + BIO_free(bio_signed_message); + BIO_free_all(smime_attachment); + + EVP_cleanup(); + if (err_code != NULL) + *err_code = err; + + EM_DEBUG_FUNC_END("err [%d]", err); + return ret; +} + + + +INTERNAL_FUNC int emcore_smime_set_decrypt_message(char *encrypt_message, char *certificate, char *password, char **decrypt_message, int *err_code) +{ + int ret = false; + int err = EMAIL_ERROR_NONE; + long string_len = 0; + char *temp_decrypt_message; + FILE *fp = NULL; + + X509 *cert = NULL; + STACK_OF(X509) *ca = NULL; + EVP_PKEY *private_key = NULL; + BIO *bio_cert = NULL, *bio_prikey = NULL; + BIO *infile = NULL, *out_buf = NULL; + PKCS7 *p7_encrypt_message = NULL; + PKCS12 *p12 = NULL; + CERT_CONTEXT *loaded_cert = NULL; + + infile = BIO_new_file(encrypt_message, INMODE); + + p7_encrypt_message = d2i_PKCS7_bio(infile, NULL); + if (!p7_encrypt_message) { + EM_DEBUG_EXCEPTION("Error reading S/MIME message"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + loaded_cert = cert_svc_cert_context_init(); + + fp = fopen(certificate, INMODE); + if (!fp) { + EM_DEBUG_EXCEPTION("Certificate file open failed"); + goto FINISH_OFF; + } + + p12 = d2i_PKCS12_fp(fp, NULL); + fclose(fp); + + if (!p12) { + EM_DEBUG_EXCEPTION("Error reading PKCS#12 file\n"); + goto FINISH_OFF; + } + + if (!PKCS12_parse(p12, password, &private_key, &cert, &ca)) { + EM_DEBUG_EXCEPTION("PKCS12_parse failed"); + goto FINISH_OFF; + } + + out_buf = BIO_new(BIO_s_mem()); + if (!out_buf) { + EM_DEBUG_EXCEPTION("There is not enough memory."); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + PKCS7_decrypt(p7_encrypt_message, private_key, cert, out_buf, 0); + string_len = BIO_get_mem_data(out_buf, &temp_decrypt_message); + + ret = true; + +FINISH_OFF: + *decrypt_message = temp_decrypt_message; + + X509_free(cert); + BIO_free(out_buf); + BIO_free(bio_cert); + BIO_free(bio_prikey); + BIO_free_all(infile); + + if (err_code != NULL) + *err_code = err; + + cert_svc_cert_context_final(loaded_cert); + EM_DEBUG_FUNC_END("err [%d]", err); + return ret; +} + +/* +INTERNAL_FUNC int emcore_smime_verify_signed_message(char *signed_message, char *ca_file, char *ca_path, int *verify) +{ + int ret = false; + int temp_verify = 0; + BIO *indata = NULL; + BIO *content = NULL; + X509_STORE *store = NULL; + X509_LOOKUP *lookup = NULL; + PKCS7 *p7 = NULL; + + OpenSSL_add_all_algorithms(); + ERR_load_crypto_strings(); + + if (BIO_write(indata, signed_message, sizeof(signed_message)) <= 0) { + EM_DEBUG_EXCEPTION("Char to Bio failed"); + goto FINISH_OFF; + } + + p7 = SMIME_read_PKCS7(indata, &content); + if (!p7) { + EM_DEBUG_EXCEPTION("SMIME_read_PKCS7 failed"); + goto FINISH_OFF; + } + + if (!(store = X509_STORE_new())) { + EM_DEBUG_EXCEPTION("Initialize x509_store failed"); + goto FINISH_OFF; + } + + lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file()); + if (lookup == NULL) { + EM_DEBUG_EXCEPTION("Initialize lookup store failed"); + goto FINISH_OFF; + } + + if (ca_file) { + if (!X509_LOOKUP_load_file(lookup, ca_file, X509_FILETYPE_PEM)) { + EM_DEBUG_EXCEPTION("X509_LOOKUP_load_file failed"); + goto FINISH_OFF; + } + } else { + X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT); + } + + lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir()); + if (lookup == NULL) { + EM_DEBUG_EXCEPTION("X509_STORE_add_lookup failed"); + goto FINISH_OFF; + } + + if (ca_path) { + if (!X509_LOOKUP_add_dir(lookup, ca_path, X509_FILETYPE_PEM)) { + EM_DEBUG_EXCEPTION("CA path load failed"); + goto FINISH_OFF; + } + } else { + X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT); + } + + temp_verify = PKCS7_verify(p7, NULL, store, content, NULL, 0); + if (temp_verify) + EM_DEBUG_LOG("Verification Successful\n"); + + ret = true; + +FINISH_OFF: + if (store) + X509_STORE_free(store); + if (p7) + PKCS7_free(p7); + + if (indata) + BIO_free(indata); + + if (verify != NULL) + *verify = temp_verify; + + ERR_clear_error(); + EVP_cleanup(); + return ret; +} +*/ + +static char *emcore_get_mime_entity(char *mime_path) +{ + EM_DEBUG_FUNC_BEGIN("mime_path : [%s]", mime_path); + FILE *fp_read = NULL; + FILE *fp_write = NULL; + char *mime_entity = NULL; + char *mime_entity_path = NULL; + char temp_buffer[255] = {0,}; + int err; + int searched = 0; + + if (!emcore_get_temp_file_name(&mime_entity_path, &err)) { + EM_DEBUG_EXCEPTION(" em_core_get_temp_file_name failed[%d]", err); + goto FINISH_OFF; + } + + /* get mime entity */ + if (mime_path != NULL) { + fp_read = fopen(mime_path, "r"); + if (fp_read == NULL) { + EM_DEBUG_EXCEPTION("File open(read) is failed : filename [%s]", mime_path); + goto FINISH_OFF; + } + + fp_write = fopen(mime_entity_path, "w"); + if (fp_write == NULL) { + EM_DEBUG_EXCEPTION("File open(write) is failed : filename [%s]", mime_entity_path); + goto FINISH_OFF; + } + + fseek(fp_read, 0, SEEK_SET); + fseek(fp_write, 0, SEEK_SET); + + while (fgets(temp_buffer, 255, fp_read) != NULL) { + mime_entity = strcasestr(temp_buffer, "content-type"); + if (mime_entity != NULL && !searched) + searched = 1; + + if (searched) { + EM_DEBUG_LOG("temp_buffer : %s", temp_buffer); + fprintf(fp_write, "%s", temp_buffer); + } + } + } + +FINISH_OFF: + if (fp_read) + fclose(fp_read); + + if (fp_write) + fclose(fp_write); + + EM_SAFE_FREE(mime_entity); + EM_SAFE_FREE(mime_path); + + EM_DEBUG_FUNC_END(); + return mime_entity_path; +} + +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) +{ + 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 ret = false; + int err = EMAIL_ERROR_NONE; + int smime_type = EMAIL_SMIME_NONE; + int address_length = 0; + int attachment_count = input_attachment_count; + char *name = NULL; + char *rfc822_file = NULL; + char *mime_entity = NULL; + char *smime_file_path = NULL; + char *other_certificate_list = NULL; +#ifdef SMIME_DEBUG + char *buf_pointer = NULL; + char *password = NULL; + char buf[81] = {0, }; + FILE *fp = NULL; +#endif + email_attachment_data_t new_attachment_data = {0}; + email_attachment_data_t *temp_attachment_data = NULL; + + /* Validating parameters */ + + if (!input_mail_data || !(input_mail_data->account_id) || !(input_mail_data->mailbox_id)) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + goto FINISH_OFF; + } + + +#ifdef SMIME_DEBUG + fp = fopen(TEMP_PASSWORD_PATH, "r"); + if (fp == NULL) { + EM_DEBUG_EXCEPTION("Open failed"); + err = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } + + while (!feof(fp)) { + buf_pointer = fgets(buf, 80, fp); + } + + fclose(fp); + + EM_DEBUG_LOG("password : [%s], strlen : [%d]", buf, strlen(buf)-1); + password = em_malloc(sizeof(buf)); + memcpy(password, buf, strlen(buf) - 1); + +#endif + + if (!emcore_make_rfc822_file(input_mail_data, input_attachment_data_list, attachment_count, &rfc822_file, &err)) { + EM_DEBUG_EXCEPTION("emcore_make_rfc822_file_from_mail failed [%d]", err); + goto FINISH_OFF; + } + + mime_entity = emcore_get_mime_entity(rfc822_file); + + smime_type = input_mail_data->smime_type; + if (!smime_type) + smime_type = account_tbl_item->smime_type; + + /* 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, password, 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; + } + + EM_DEBUG_LOG("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_size = 1; + new_attachment_data.save_status = 1; + + attachment_count += 1; + + break; + case EMAIL_SMIME_ENCRYPTED: /* Encryption message */ + address_length = 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 + 3); + + SNPRINTF(other_certificate_list, address_length + 2, "%s;%s;%s", input_mail_data->full_address_to, input_mail_data->full_address_cc, input_mail_data->full_address_bcc); + + EM_DEBUG_LOG("to:[%s], cc:[%s], bcc:[%s]", input_mail_data->full_address_to, input_mail_data->full_address_cc, input_mail_data->full_address_bcc); + EM_DEBUG_LOG("length : [%d], email_address : [%s]", address_length, other_certificate_list); + + if (!emcore_smime_set_encrypt_message(other_certificate_list, 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; + } + + EM_DEBUG_LOG("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_size = 1; + new_attachment_data.save_status = 1; + + attachment_count += 1; + + break; + case EMAIL_SMIME_SIGNED_AND_ENCRYPTED: /* Signed and Encryption message */ + address_length = 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 + 3); + + SNPRINTF(other_certificate_list, address_length + 2, "%s;%s;%s", input_mail_data->full_address_to, input_mail_data->full_address_cc, input_mail_data->full_address_bcc); + + EM_DEBUG_LOG("to:[%s], cc:[%s], bcc:[%s]", input_mail_data->full_address_to, input_mail_data->full_address_cc, input_mail_data->full_address_bcc); + EM_DEBUG_LOG("length : [%d], email_address : [%s]", address_length, other_certificate_list); + + if (!emcore_smime_set_signed_and_encrypt_message(other_certificate_list, account_tbl_item->certificate_path, password, 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; + } + + EM_DEBUG_LOG("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_size = 1; + new_attachment_data.save_status = 1; + + attachment_count = 1; + + break; + default: + break; + } + + temp_attachment_data = (email_attachment_data_t *)em_malloc(sizeof(email_attachment_data_t) * attachment_count); + if (input_attachment_data_list != NULL) + temp_attachment_data = input_attachment_data_list; + + temp_attachment_data[attachment_count-1] = new_attachment_data; + + input_mail_data->smime_type = smime_type; + input_mail_data->file_path_mime_entity = EM_SAFE_STRDUP(mime_entity); + input_mail_data->digest_type = account_tbl_item->digest_type; + + ret = true; + +FINISH_OFF: + if (output_attachment_count) + *output_attachment_count = attachment_count; + + if (output_attachment_data_list) + *output_attachment_data_list = temp_attachment_data; + + + *output_mail_data = input_mail_data; + + if (!ret && temp_attachment_data) + emcore_free_attachment_data(&temp_attachment_data, attachment_count, NULL); + +#ifdef SMIME_DEBUG + if (password) + EM_SAFE_FREE(password); +#endif + + return ret; +} + + diff --git a/email-core/email-core-smtp.c b/email-core/email-core-smtp.c index 4d098f1..08fe465 100755 --- a/email-core/email-core-smtp.c +++ b/email-core/email-core-smtp.c @@ -37,6 +37,7 @@ #include "email-core-mailbox.h" #include "email-core-mail.h" #include "email-core-mime.h" +#include "email-core-smime.h" #include "email-core-account.h" #include "email-core-imap-mailbox.h" #include "email-core-mailbox-sync.h" @@ -47,8 +48,9 @@ #include #include "email-debug-log.h" - +#ifdef __FEATURE_SUPPORT_REPORT_MAIL__ static int emcore_get_report_mail_body(ENVELOPE *envelope, BODY **multipart_body, int *err_code); +#endif static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_file, int account_id, int mail_id, int *err_code); /* Functions from uw-imap-toolkit */ @@ -68,21 +70,21 @@ extern long smtp_soutr_test(void *stream, char *s); -void mail_send_notify(emf_send_status_t status, int total, int sent, int account_id, int mail_id, int err_code) +void mail_send_notify(email_send_status_t status, int total, int sent, int account_id, int mail_id, int err_code) { EM_DEBUG_FUNC_BEGIN("status[%d], total[%d], sent[%d], account_id[%d], mail_id[%d], err_code[%d]", status, total, sent, account_id, mail_id, err_code); switch (status) { - case EMF_SEND_CONNECTION_FAIL: - case EMF_SEND_FINISH: - case EMF_SEND_FAIL: + case EMAIL_SEND_CONNECTION_FAIL: + case EMAIL_SEND_FINISH: + case EMAIL_SEND_FAIL: break; - case EMF_SEND_PROGRESS: + case EMAIL_SEND_PROGRESS: default: break; } - emcore_execute_event_callback(EMF_ACTION_SEND_MAIL, total, sent, status, account_id, mail_id, -1, err_code); + emcore_execute_event_callback(EMAIL_ACTION_SEND_MAIL, total, sent, status, account_id, mail_id, -1, err_code); EM_DEBUG_FUNC_END(); } @@ -129,14 +131,14 @@ static char *emcore_replace_inline_image_path_with_content_id(char *source_strin { EM_DEBUG_FUNC_BEGIN("source_string[%p], html_body[%p], err_code[%p]", source_string, html_body, err_code); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char content_id_buffer[CONTENT_ID_BUFFER_SIZE], file_name_buffer[512], new_string[512], *result_string = NULL, *input_string = NULL; BODY *cur_body = NULL; PART *cur_part = NULL; if (!source_string || !html_body) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -189,7 +191,7 @@ static int emcore_write_rfc822_body(BODY *body, BODY *html_body, FILE *fp, int * PARAMETER *param = NULL; PART *part = NULL; char *p = NULL, *bndry = NULL, buf[1025], *replaced_string = NULL; - int fd, nread, nwrite, error = EMF_ERROR_NONE; + int fd, nread, nwrite, error = EMAIL_ERROR_NONE; switch (body->type) { case TYPEMULTIPART: @@ -332,12 +334,12 @@ static int emcore_write_rfc822_body(BODY *body, BODY *html_body, FILE *fp, int * return true; } -static int emcore_write_rfc822(ENVELOPE *env, BODY *body, BODY *html_body, emf_extra_flag_t flag, char **data, int *err_code) +static int emcore_write_rfc822(ENVELOPE *env, BODY *body, BODY *html_body, email_extra_flag_t flag, char **data, int *err_code) { EM_DEBUG_FUNC_BEGIN("env[%p], body[%p], data[%p], err_code[%p]", env, body, data, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; FILE *fp = NULL; char *fname = NULL; @@ -346,7 +348,7 @@ static int emcore_write_rfc822(ENVELOPE *env, BODY *body, BODY *html_body, emf_e if (!env || !data) { EM_DEBUG_EXCEPTION("Invalid Parameters"); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -359,7 +361,7 @@ static int emcore_write_rfc822(ENVELOPE *env, BODY *body, BODY *html_body, emf_e if (!(p = em_malloc(p_len))) { /* (env->subject ? strlen(env->subject) : 0) + 8192))) */ EM_DEBUG_EXCEPTION(" malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -417,20 +419,20 @@ static int emcore_write_rfc822(ENVELOPE *env, BODY *body, BODY *html_body, emf_e if (flag.report) { char buf[512] = {0x00, }; switch (flag.report) { - case EMF_MAIL_REPORT_DSN: /* DSN (delivery status) */ + case EMAIL_MAIL_REPORT_DSN: /* DSN (delivery status) */ /* change content-type */ /* Content-Type: multipart/report; */ /* report-type= delivery-status; */ /* boundary="----=_NextPart_000_004F_01C76EFF.54275C50" */ break; - case EMF_MAIL_REPORT_MDN: /* MDN (read receipt) */ + case EMAIL_MAIL_REPORT_MDN: /* MDN (read receipt) */ /* Content-Type: multipart/report; */ /* report-type= disposition-notification; */ /* boundary="----=_NextPart_000_004F_01C76EFF.54275C50" */ break; - case EMF_MAIL_REPORT_REQUEST: /* require read status */ + case EMAIL_MAIL_REPORT_REQUEST: /* require read status */ rfc822_address(buf, env->from); if (strlen(buf)) SNPRINTF(p + strlen(p), p_len-(strlen(p)), "Disposition-Notification-To: %s"CRLF_STRING, buf); @@ -445,13 +447,13 @@ static int emcore_write_rfc822(ENVELOPE *env, BODY *body, BODY *html_body, emf_e SNPRINTF(p + strlen(p), p_len-(strlen(p)), "X-Priority: %d"CRLF_STRING, flag.priority); switch (flag.priority) { - case EMF_MAIL_PRIORITY_HIGH: + case EMAIL_MAIL_PRIORITY_HIGH: SNPRINTF(p + strlen(p), p_len-(strlen(p)), "X-MSMail-Priority: HIgh"CRLF_STRING); break; - case EMF_MAIL_PRIORITY_NORMAL: + case EMAIL_MAIL_PRIORITY_NORMAL: SNPRINTF(p + strlen(p), p_len-(strlen(p)), "X-MSMail-Priority: Normal"CRLF_STRING); break; - case EMF_MAIL_PRIORITY_LOW: + case EMAIL_MAIL_PRIORITY_LOW: SNPRINTF(p + strlen(p), p_len-(strlen(p)), "X-MSMail-Priority: Low"CRLF_STRING); break; } @@ -466,7 +468,7 @@ static int emcore_write_rfc822(ENVELOPE *env, BODY *body, BODY *html_body, emf_e if (!(fp = fopen(fname, "w+"))) { EM_DEBUG_EXCEPTION("fopen failed[%s]", fname); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -505,81 +507,103 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emcore_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t *input_meeting_request, int input_from_eas) +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) { 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 = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int attachment_id = 0, thread_id = -1, thread_item_count = 0, latest_mail_id_in_thread = -1; int i = 0, rule_len, rule_matched = -1, local_attachment_count = 0, local_inline_content_count = 0; - char *ext = NULL, *mailbox_name_spam = NULL, *mailbox_name_target = NULL; + int mailbox_id_spam = 0, mailbox_id_target = 0; + char *ext = NULL; char name_buf[MAX_PATH] = {0x00, }, html_body[MAX_PATH] = {0x00, }; + + int attachment_count = 0; + email_mail_data_t *mail_data = NULL; + email_attachment_data_t *attachment_data_list = NULL; + emstorage_mail_tbl_t *converted_mail_tbl = NULL; emstorage_mailbox_tbl_t *mailbox_tbl = NULL; emstorage_attachment_tbl_t attachment_tbl = { 0 }; emstorage_account_tbl_t *account_tbl_item = NULL; emstorage_rule_tbl_t *rule = NULL; struct stat st_buf = { 0 }; + char mailbox_id_param_string[10] = {0,}; /* Validating parameters */ - - if (!input_mail_data || !(input_mail_data->account_id) || !(input_mail_data->mailbox_name)) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if (!input_mail_data || !(input_mail_data->account_id) || !(input_mail_data->mailbox_id)) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (!emstorage_get_account_by_id(input_mail_data->account_id, EMF_ACC_GET_OPT_DEFAULT | EMF_ACC_GET_OPT_OPTIONS, &account_tbl_item, true, &err)) { + if (emcore_is_storage_full(&err) == true) { + EM_DEBUG_EXCEPTION("Storage is full"); + 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)) { EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed. account_id[%d] err[%d]", input_mail_data->account_id, err); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } + + if (input_from_eas == 0 && input_mail_data->smime_type && input_mail_data->mailbox_type != EMAIL_MAILBOX_TYPE_DRAFT) { + if (!emcore_convert_mail_data_to_smime_data(account_tbl_item, input_mail_data, input_attachment_data_list, input_attachment_count, &mail_data, &attachment_data_list, &attachment_count)) { + EM_DEBUG_EXCEPTION("S/MIME failed"); + goto FINISH_OFF; + } + } else { + mail_data = input_mail_data; + attachment_data_list = input_attachment_data_list; + attachment_count = input_attachment_count; + } + + mailbox_id_target = mail_data->mailbox_id; - if(input_from_eas == 0) { - if (input_mail_data->file_path_plain) { - if (stat(input_mail_data->file_path_plain, &st_buf) < 0) { - EM_DEBUG_EXCEPTION("input_mail_data->file_path_plain, stat(\"%s\") failed...", input_mail_data->file_path_plain); - err = EMF_ERROR_INVALID_MAIL; + if (input_from_eas == 0) { + if (mail_data->file_path_plain) { + if (stat(mail_data->file_path_plain, &st_buf) < 0) { + EM_DEBUG_EXCEPTION("mail_data->file_path_plain, stat(\"%s\") failed...", mail_data->file_path_plain); + err = EMAIL_ERROR_INVALID_MAIL; goto FINISH_OFF; } } - if (input_mail_data->file_path_html) { - if (stat(input_mail_data->file_path_html, &st_buf) < 0) { - EM_DEBUG_EXCEPTION("input_mail_data->file_path_html, stat(\"%s\") failed...", input_mail_data->file_path_html); - err = EMF_ERROR_INVALID_MAIL; + if (mail_data->file_path_html) { + if (stat(mail_data->file_path_html, &st_buf) < 0) { + EM_DEBUG_EXCEPTION("mail_data->file_path_html, stat(\"%s\") failed...", mail_data->file_path_html); + err = EMAIL_ERROR_INVALID_MAIL; goto FINISH_OFF; } } - 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) { - EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_attachment_data_list[i].attachment_path); - err = EMF_ERROR_INVALID_ATTACHMENT; + 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) { + EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", attachment_data_list[i].attachment_path); + err = EMAIL_ERROR_INVALID_ATTACHMENT; goto FINISH_OFF; } } } } - } - if (input_from_eas == 0) { if (!input_mail_data->full_address_from) - input_mail_data->full_address_from = EM_SAFE_STRDUP(account_tbl_item->email_addr); + input_mail_data->full_address_from = EM_SAFE_STRDUP(account_tbl_item->user_email_address); /* check for email_address validation */ - if (!em_verify_email_address_of_mail_data(input_mail_data, false, &err)) { + if (!em_verify_email_address_of_mail_data(mail_data, false, &err)) { EM_DEBUG_EXCEPTION("em_verify_email_address_of_mail_data failed [%d]", err); goto FINISH_OFF; } - if (input_mail_data->report_status == EMF_MAIL_REPORT_MDN) { + if (mail_data->report_status == EMAIL_MAIL_REPORT_MDN) { /* check read-report mail */ - if(!input_mail_data->full_address_to) { /* A report mail should have 'to' address */ - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if(!mail_data->full_address_to) { /* A report mail should have 'to' address */ + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } /* Create report mail body */ @@ -590,11 +614,9 @@ INTERNAL_FUNC int emcore_add_mail(emf_mail_data_t *input_mail_data, emf_attachme } */ } - - mailbox_name_target = EM_SAFE_STRDUP(input_mail_data->mailbox_name); } else { /* For Spam handling */ - emf_option_t *opt = &account_tbl_item->options; + email_option_t *opt = &account_tbl_item->options; EM_DEBUG_LOG("block_address [%d], block_subject [%d]", opt->block_address, opt->block_subject); if (opt->block_address || opt->block_subject) { @@ -602,147 +624,158 @@ INTERNAL_FUNC int emcore_add_mail(emf_mail_data_t *input_mail_data, emf_attachme int type = 0; if (!opt->block_address) - type = EMF_FILTER_SUBJECT; + type = EMAIL_FILTER_SUBJECT; else if (!opt->block_subject) - type = EMF_FILTER_FROM; + 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) { - if (!emstorage_get_mailboxname_by_mailbox_type(input_mail_data->account_id, EMF_MAILBOX_TYPE_SPAMBOX, &mailbox_name_spam, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); - - mailbox_name_spam = NULL; + 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_name_spam && !emcore_check_rule(input_mail_data->full_address_from, input_mail_data->subject, rule, rule_len, &rule_matched, &err)) { + if (mailbox_id_spam && !emcore_check_rule(mail_data->full_address_from, mail_data->subject, rule, rule_len, &rule_matched, &err)) { EM_DEBUG_EXCEPTION("emcore_check_rule failed [%d]", err); goto FINISH_OFF; } } - if (rule_matched >= 0 && mailbox_name_spam) - mailbox_name_target = EM_SAFE_STRDUP(mailbox_name_spam); - else - mailbox_name_target = EM_SAFE_STRDUP(input_mail_data->mailbox_name); + if (rule_matched >= 0 && mailbox_id_spam) + mailbox_id_target = mailbox_id_spam; } - if (!emstorage_get_mailbox_by_name(input_mail_data->account_id, -1, mailbox_name_target, (emstorage_mailbox_tbl_t **)&mailbox_tbl, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); - + if ((err = emstorage_get_mailbox_by_id(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(&input_mail_data->mail_id, true, &err)) { + if (!emstorage_increase_mail_id(&mail_data->mail_id, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_increase_mail_id failed [%d]", err); goto FINISH_OFF; } - EM_DEBUG_LOG("input_mail_data->mail_size [%d]", input_mail_data->mail_size); + EM_DEBUG_LOG("mail_data->mail_size [%d]", mail_data->mail_size); - 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)); /* Getting file size before file moved. */ + 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. */ - if (input_from_eas == 0|| input_mail_data->body_download_status) { - if (!emstorage_create_dir(input_mail_data->account_id, input_mail_data->mail_id, 0, &err)) { + if (input_from_eas == 0|| mail_data->body_download_status) { + if (!emstorage_create_dir(mail_data->account_id, mail_data->mail_id, 0, &err)) { EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err); goto FINISH_OFF; } - if (input_mail_data->file_path_plain) { - EM_DEBUG_LOG("input_mail_data->file_path_plain [%s]", input_mail_data->file_path_plain); - /* if (!emstorage_get_save_name(account_id, mail_id, 0, input_mail_data->body->plain_charset ? input_mail_data->body->plain_charset : "UTF-8", name_buf, &err)) {*/ - if (!emstorage_get_save_name(input_mail_data->account_id, input_mail_data->mail_id, 0, "UTF-8", name_buf, &err)) { + if (mail_data->file_path_plain) { + EM_DEBUG_LOG("mail_data->file_path_plain [%s]", mail_data->file_path_plain); + if (!emstorage_get_save_name(mail_data->account_id, mail_data->mail_id, 0, "UTF-8", name_buf, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err); goto FINISH_OFF; } - if (!emstorage_move_file(input_mail_data->file_path_plain, name_buf, input_from_eas, &err)) { + if (!emstorage_move_file(mail_data->file_path_plain, name_buf, input_from_eas, &err)) { EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err); goto FINISH_OFF; } - if (input_mail_data->body_download_status == EMF_BODY_DOWNLOAD_STATUS_NONE) - input_mail_data->body_download_status = EMF_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED; + if (mail_data->body_download_status == EMAIL_BODY_DOWNLOAD_STATUS_NONE) + mail_data->body_download_status = EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED; - EM_SAFE_FREE(input_mail_data->file_path_plain); - input_mail_data->file_path_plain = EM_SAFE_STRDUP(name_buf); + EM_SAFE_FREE(mail_data->file_path_plain); + mail_data->file_path_plain = EM_SAFE_STRDUP(name_buf); } - if (input_mail_data->file_path_html) { - EM_DEBUG_LOG("input_mail_data->file_path_html [%s]", input_mail_data->file_path_html); + if (mail_data->file_path_html) { + EM_DEBUG_LOG("mail_data->file_path_html [%s]", mail_data->file_path_html); memcpy(html_body, "UTF-8.htm", strlen("UTF-8.htm")); - if (!emstorage_get_save_name(input_mail_data->account_id, input_mail_data->mail_id, 0, html_body, name_buf, &err)) { + if (!emstorage_get_save_name(mail_data->account_id, mail_data->mail_id, 0, html_body, name_buf, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err); goto FINISH_OFF; } - if (!emstorage_move_file(input_mail_data->file_path_html, name_buf, input_from_eas, &err)) { + if (!emstorage_move_file(mail_data->file_path_html, name_buf, input_from_eas, &err)) { EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err); goto FINISH_OFF; } - if (input_mail_data->body_download_status == EMF_BODY_DOWNLOAD_STATUS_NONE) - input_mail_data->body_download_status = EMF_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED; + if (mail_data->body_download_status == EMAIL_BODY_DOWNLOAD_STATUS_NONE) + mail_data->body_download_status = EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED; - EM_SAFE_FREE(input_mail_data->file_path_html); - input_mail_data->file_path_html = EM_SAFE_STRDUP(name_buf); + EM_SAFE_FREE(mail_data->file_path_html); + mail_data->file_path_html = EM_SAFE_STRDUP(name_buf); } } + if (mail_data->file_path_mime_entity) { + EM_DEBUG_LOG("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, &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)) { + 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); + } - if (!input_mail_data->date_time) { + if (!mail_data->date_time) { /* time isn't set */ - input_mail_data->date_time = time(NULL); + mail_data->date_time = time(NULL); } - EM_SAFE_FREE(input_mail_data->mailbox_name); - input_mail_data->mailbox_name = EM_SAFE_STRDUP(mailbox_name_target); - input_mail_data->mailbox_type = mailbox_tbl->mailbox_type; - input_mail_data->server_mail_status = !input_from_eas; - input_mail_data->save_status = EMF_MAIL_STATUS_SAVED; + mail_data->mailbox_id = mailbox_id_target; + mail_data->mailbox_type = mailbox_tbl->mailbox_type; + mail_data->server_mail_status = !input_from_eas; + mail_data->save_status = EMAIL_MAIL_STATUS_SAVED; /* Getting attachment count */ - for (i = 0; i < input_attachment_count; i++) { - if (input_attachment_data_list[i].inline_content_status== 1) + for (i = 0; i < attachment_count; i++) { + if (attachment_data_list[i].inline_content_status== 1) local_inline_content_count++; local_attachment_count++; } - input_mail_data->inline_content_count = local_inline_content_count; - input_mail_data->attachment_count = local_attachment_count; + mail_data->inline_content_count = local_inline_content_count; + mail_data->attachment_count = local_attachment_count; EM_DEBUG_LOG("inline_content_count [%d]", local_inline_content_count); - EM_DEBUG_LOG("input_attachment_count [%d]", local_attachment_count); + EM_DEBUG_LOG("attachment_count [%d]", local_attachment_count); - 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))) != EMF_ERROR_NONE) { + 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) { EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file failed[%d]", err); goto FINISH_OFF; } } - if (!em_convert_mail_data_to_mail_tbl(input_mail_data, 1, &converted_mail_tbl, &err)) { + if (!em_convert_mail_data_to_mail_tbl(mail_data, 1, &converted_mail_tbl, &err)) { EM_DEBUG_EXCEPTION("em_convert_mail_data_to_mail_tbl failed [%d]", err); goto FINISH_OFF; } converted_mail_tbl->mailbox_id = mailbox_tbl->mailbox_id; + converted_mail_tbl->mailbox_name = EM_SAFE_STRDUP(mailbox_tbl->mailbox_name); /* Fill address information */ emcore_fill_address_information_of_mail_tbl(converted_mail_tbl); /* Fill thread id */ - if(input_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) != EMF_ERROR_NONE) + 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) EM_DEBUG_LOG(" emstorage_get_thread_id_of_thread_mails is failed"); if (thread_id == -1) { - converted_mail_tbl->thread_id = input_mail_data->mail_id; + converted_mail_tbl->thread_id = mail_data->mail_id; converted_mail_tbl->thread_item_count = thread_item_count = 1; } else { @@ -754,7 +787,7 @@ INTERNAL_FUNC int emcore_add_mail(emf_mail_data_t *input_mail_data, emf_attachme thread_item_count = 2; } - input_mail_data->thread_id = converted_mail_tbl->thread_id; + mail_data->thread_id = converted_mail_tbl->thread_id; emstorage_begin_transaction(NULL, NULL, NULL); @@ -771,7 +804,7 @@ INTERNAL_FUNC int emcore_add_mail(emf_mail_data_t *input_mail_data, emf_attachme EM_DEBUG_LOG("thread_item_count [%d]", thread_item_count); if (thread_item_count > 1) { - if (!emstorage_update_latest_thread_mail(input_mail_data->account_id, converted_mail_tbl->thread_id, 0, 0, false, &err)) { + if (!emstorage_update_latest_thread_mail(mail_data->account_id, converted_mail_tbl->thread_id, 0, 0, false, &err)) { EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err); emstorage_rollback_transaction(NULL, NULL, NULL); @@ -781,14 +814,14 @@ INTERNAL_FUNC int emcore_add_mail(emf_mail_data_t *input_mail_data, emf_attachme /* Insert attachment information to DB */ - for (i = 0; i < input_attachment_count; i++) { - if (input_attachment_data_list[i].attachment_size == 0) { + for (i = 0; i < attachment_count; i++) { + if (attachment_data_list[i].attachment_size == 0) { /* set attachment size */ - if(input_attachment_data_list[i].attachment_path && stat(input_attachment_data_list[i].attachment_path, &st_buf) < 0) - input_attachment_data_list[i].attachment_size = st_buf.st_size; + if(attachment_data_list[i].attachment_path && stat(attachment_data_list[i].attachment_path, &st_buf) < 0) + attachment_data_list[i].attachment_size = st_buf.st_size; } - if (!input_attachment_data_list[i].inline_content_status) { + if (!attachment_data_list[i].inline_content_status) { if (!emstorage_get_new_attachment_no(&attachment_id, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_new_attachment_no failed [%d]", err); emstorage_rollback_transaction(NULL, NULL, NULL); @@ -796,45 +829,45 @@ INTERNAL_FUNC int emcore_add_mail(emf_mail_data_t *input_mail_data, emf_attachme } } - if (!emstorage_create_dir(input_mail_data->account_id, input_mail_data->mail_id, input_attachment_data_list[i].inline_content_status ? 0 : attachment_id, &err)) { + if (!emstorage_create_dir(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); goto FINISH_OFF; } - if (!emstorage_get_save_name(input_mail_data->account_id, input_mail_data->mail_id, input_attachment_data_list[i].inline_content_status ? 0 : attachment_id, input_attachment_data_list[i].attachment_name, name_buf, &err)) { + 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, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err); emstorage_rollback_transaction(NULL, NULL, NULL); goto FINISH_OFF; } - if (input_from_eas == 0|| input_attachment_data_list[i].save_status) { - if (!emstorage_copy_file(input_attachment_data_list[i].attachment_path, name_buf, input_from_eas, &err)) { + if (input_from_eas == 0|| attachment_data_list[i].save_status) { + if (!emstorage_copy_file(attachment_data_list[i].attachment_path, name_buf, input_from_eas, &err)) { EM_DEBUG_EXCEPTION("emstorage_copy_file failed [%d]", err); emstorage_rollback_transaction(NULL, NULL, NULL); goto FINISH_OFF; } - if ((ext = strrchr(input_attachment_data_list[i].attachment_name, '.'))) { + if ((ext = strrchr(attachment_data_list[i].attachment_name, '.'))) { if (!strncmp(ext, ".vcs", strlen(".vcs"))) - remove(input_attachment_data_list[i].attachment_path); + remove(attachment_data_list[i].attachment_path); else if (!strncmp(ext, ".vcf", strlen(".vcf"))) - remove(input_attachment_data_list[i].attachment_path); + remove(attachment_data_list[i].attachment_path); else if (!strncmp(ext, ".vnt", strlen(".vnt"))) - remove(input_attachment_data_list[i].attachment_path); + remove(attachment_data_list[i].attachment_path); } } memset(&attachment_tbl, 0, sizeof(emstorage_attachment_tbl_t)); - attachment_tbl.attachment_name = input_attachment_data_list[i].attachment_name; + attachment_tbl.attachment_name = attachment_data_list[i].attachment_name; attachment_tbl.attachment_path = name_buf; - attachment_tbl.attachment_size = input_attachment_data_list[i].attachment_size; - attachment_tbl.mail_id = input_mail_data->mail_id; - attachment_tbl.account_id = input_mail_data->account_id; - attachment_tbl.mailbox_name = input_mail_data->mailbox_name; - attachment_tbl.attachment_save_status = input_attachment_data_list[i].save_status; - attachment_tbl.attachment_drm_type = input_attachment_data_list[i].drm_status; - attachment_tbl.attachment_inline_content_status = input_attachment_data_list[i].inline_content_status; + 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; + attachment_tbl.mailbox_id = mail_data->mailbox_id; + attachment_tbl.attachment_save_status = attachment_data_list[i].save_status; + attachment_tbl.attachment_drm_type = attachment_data_list[i].drm_status; + attachment_tbl.attachment_inline_content_status = attachment_data_list[i].inline_content_status; if (!emstorage_add_attachment(&attachment_tbl, 0, false, &err)) { EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err); @@ -842,41 +875,42 @@ INTERNAL_FUNC int emcore_add_mail(emf_mail_data_t *input_mail_data, emf_attachme goto FINISH_OFF; } - input_attachment_data_list[i].attachment_id = attachment_tbl.attachment_id; + attachment_data_list[i].attachment_id = attachment_tbl.attachment_id; } /* Insert Meeting request to DB */ - if (input_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_REQUEST - || input_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_RESPONSE - || input_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { + if (mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST + || mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE + || mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { EM_DEBUG_LOG("This mail has the meeting request"); - input_meeting_request->mail_id = input_mail_data->mail_id; - if (!emstorage_add_meeting_request(input_mail_data->account_id, mailbox_name_target, input_meeting_request, false, &err)) { + 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)) { EM_DEBUG_EXCEPTION("emstorage_add_meeting_request failed [%d]", err); goto FINISH_OFF; - } + } } emstorage_commit_transaction(NULL, NULL, NULL); - if (!emstorage_notify_storage_event(NOTI_MAIL_ADD, converted_mail_tbl->account_id, converted_mail_tbl->mail_id, mailbox_name_target, converted_mail_tbl->thread_id)) + SNPRINTF(mailbox_id_param_string, 10, "%d", mailbox_tbl->mailbox_id); + if (!emstorage_notify_storage_event(NOTI_MAIL_ADD, converted_mail_tbl->account_id, converted_mail_tbl->mail_id, mailbox_id_param_string, converted_mail_tbl->thread_id)) EM_DEBUG_LOG("emstorage_notify_storage_event [NOTI_MAIL_ADD] failed."); - if (account_tbl_item->receiving_server_type != EMF_SERVER_TYPE_ACTIVE_SYNC) { + if (account_tbl_item->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) { if (!emcore_remove_overflowed_mails(mailbox_tbl, &err)) { - if (err == EMF_ERROR_MAIL_NOT_FOUND || err == EMF_ERROR_NOT_SUPPORTED) - err = EMF_ERROR_NONE; + if (err == EMAIL_ERROR_MAIL_NOT_FOUND || err == EMAIL_ERROR_NOT_SUPPORTED) + err = EMAIL_ERROR_NONE; else EM_DEBUG_LOG("emcore_remove_overflowed_mails failed [%d]", err); } } - if ( input_from_eas && (input_mail_data->flags_seen_field == 0) - && input_mail_data->mailbox_type != EMF_MAILBOX_TYPE_TRASH - && input_mail_data->mailbox_type != EMF_MAILBOX_TYPE_SPAMBOX) { - if (!emstorage_update_sync_status_of_account(input_mail_data->account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING | SYNC_STATUS_HAVE_NEW_MAILS, true, &err)) - EM_DEBUG_LOG("emstorage_update_sync_status_of_account failed [%d]", err); + 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) + EM_DEBUG_LOG("emcore_update_sync_status_of_account failed [%d]", err); emcore_add_notification_for_unread_mail(converted_mail_tbl); emcore_check_unread_mail(); } @@ -891,9 +925,6 @@ FINISH_OFF: if (converted_mail_tbl) emstorage_free_mail(&converted_mail_tbl, 1, NULL); - EM_SAFE_FREE(mailbox_name_spam); - EM_SAFE_FREE(mailbox_name_target); - EM_DEBUG_FUNC_END(); return err; } @@ -901,25 +932,25 @@ FINISH_OFF: INTERNAL_FUNC int emcore_add_read_receipt(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 = EMF_ERROR_NONE; - emf_mail_data_t *read_mail_data = NULL; - emf_mail_data_t *receipt_mail_data = NULL; - char *mailbox_name = NULL; + int err = EMAIL_ERROR_NONE; + email_mail_data_t *read_mail_data = NULL; + email_mail_data_t *receipt_mail_data = NULL; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; - if( (err = emcore_get_mail_data(input_read_mail_id, &read_mail_data)) != EMF_ERROR_NONE) { + if( (err = emcore_get_mail_data(input_read_mail_id, &read_mail_data)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err); goto FINISH_OFF; } - receipt_mail_data = em_malloc(sizeof(emf_mail_data_t)); + receipt_mail_data = em_malloc(sizeof(email_mail_data_t)); if (!receipt_mail_data) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - memcpy(receipt_mail_data, read_mail_data, sizeof(emf_mail_data_t)); + memcpy(receipt_mail_data, read_mail_data, sizeof(email_mail_data_t)); receipt_mail_data->full_address_to = EM_SAFE_STRDUP(read_mail_data->full_address_to); receipt_mail_data->message_id = EM_SAFE_STRDUP(read_mail_data->message_id); @@ -928,26 +959,26 @@ INTERNAL_FUNC int emcore_add_read_receipt(int input_read_mail_id, int *output_re receipt_mail_data->subject = em_malloc(strlen(read_mail_data->subject) + 7); if (!(receipt_mail_data->subject)) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } SNPRINTF(receipt_mail_data->subject, strlen(read_mail_data->subject) + 7 - 1, "Read: %s", read_mail_data->subject); } - if (!emstorage_get_mailboxname_by_mailbox_type(receipt_mail_data->account_id,EMF_MAILBOX_TYPE_OUTBOX, &mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); + if (!emstorage_get_mailbox_by_mailbox_type(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; } - receipt_mail_data->mailbox_name = EM_SAFE_STRDUP(mailbox_name); - receipt_mail_data->mailbox_type = EMF_MAILBOX_TYPE_OUTBOX; + receipt_mail_data->mailbox_id = mailbox_tbl->mailbox_id; + receipt_mail_data->mailbox_type = EMAIL_MAILBOX_TYPE_OUTBOX; receipt_mail_data->flags_draft_field = 1; - receipt_mail_data->save_status = (unsigned char)EMF_MAIL_STATUS_SENDING; - receipt_mail_data->report_status = (unsigned char)EMF_MAIL_REPORT_MDN; + receipt_mail_data->save_status = (unsigned char)EMAIL_MAIL_STATUS_SENDING; + receipt_mail_data->report_status = (unsigned char)EMAIL_MAIL_REPORT_MDN; - if ( (err = emcore_add_mail(receipt_mail_data, NULL, 0, NULL, 1)) != EMF_ERROR_NONE) { + if ( (err = emcore_add_mail(receipt_mail_data, NULL, 0, NULL, 1)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err); goto FINISH_OFF; } @@ -956,33 +987,35 @@ FINISH_OFF: 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->mailbox_name); EM_SAFE_FREE(receipt_mail_data->subject); EM_SAFE_FREE(receipt_mail_data); } + if(mailbox_tbl) + emstorage_free_mailbox(&mailbox_tbl, 1, NULL); + if(read_mail_data) - emcore_free_mail_data(&read_mail_data, 1, NULL); + emcore_free_mail_data_list(&read_mail_data, 1); EM_DEBUG_FUNC_END("err [%d]", err); return err; } -INTERNAL_FUNC int emcore_add_meeting_request(int account_id, char *mailbox_name, emf_meeting_request_t *meeting_req, int *err_code) +INTERNAL_FUNC int emcore_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%s], meeting_req[%p], err_code[%p]", account_id, mailbox_name, meeting_req, 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; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!meeting_req || meeting_req->mail_id <= 0) { if (meeting_req) EM_DEBUG_EXCEPTION("mail_id[%d]", meeting_req->mail_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (!emstorage_add_meeting_request(account_id, mailbox_name, meeting_req, 1, &err)) { + if (!emstorage_add_meeting_request(account_id, input_mailbox_id, meeting_req, 1, &err)) { EM_DEBUG_EXCEPTION(" emstorage_add_meeting_request failed [%d]", err); goto FINISH_OFF; @@ -1000,64 +1033,64 @@ FINISH_OFF: } /* send a mail */ -INTERNAL_FUNC int emcore_send_mail(int account_id, char *input_mailbox_name, int mail_id, emf_option_t *sending_option, int *err_code) +INTERNAL_FUNC int emcore_send_mail(int account_id, int input_mailbox_id, int mail_id, email_option_t *sending_option, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_name[%s], mail_id[%d], sending_option[%p], err_code[%p]", account_id, input_mailbox_name, mail_id, sending_option, err_code); + EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], mail_id[%d], sending_option[%p], err_code[%p]", account_id, input_mailbox_id, mail_id, sending_option, err_code); EM_PROFILE_BEGIN(profile_emcore_send_mail); int ret = false; - int err = EMF_ERROR_NONE, err2 = EMF_ERROR_NONE; - int status = EMF_SEND_FAIL; + int err = EMAIL_ERROR_NONE, err2 = EMAIL_ERROR_NONE; + int status = EMAIL_SEND_FAIL; int attachment_tbl_count = 0; SENDSTREAM *stream = NULL; ENVELOPE *envelope = NULL; sslstart_t stls = NULL; emstorage_mail_tbl_t *mail_tbl_data = NULL; emstorage_attachment_tbl_t *attachment_tbl_data = NULL; - emf_account_t *ref_account = NULL; - emf_option_t *opt = NULL; - emf_mailbox_t dest_mbox = {0}; + email_account_t *ref_account = NULL; + email_option_t *opt = NULL; void *tmp_stream = NULL; char *fpath = NULL; int sent_box = 0; - char *mailbox_name = NULL; + emstorage_mailbox_tbl_t* local_mailbox = NULL; + int dst_mailbox_id = 0; if (!account_id || !mail_id) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!(ref_account = emcore_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } /* get mail to send */ - if ( !emstorage_get_mail_by_id(mail_id, &mail_tbl_data, false, &err) || err != EMF_ERROR_NONE) { + if ( !emstorage_get_mail_by_id(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; } - if ( (err = emstorage_get_attachment_list(mail_id, false, &attachment_tbl_data, &attachment_tbl_count)) != EMF_ERROR_NONE) { + if ( (err = emstorage_get_attachment_list(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; } if (!emcore_check_send_mail_thread_status()) { EM_DEBUG_EXCEPTION("emcore_check_send_mail_thread_status failed..."); - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } if ((!mail_tbl_data->full_address_to) && (!mail_tbl_data->full_address_cc) && (!mail_tbl_data->full_address_bcc)) { - err = EMF_ERROR_NO_RECIPIENT; + err = EMAIL_ERROR_NO_RECIPIENT; EM_DEBUG_EXCEPTION("No Recipient information [%d]", err); goto FINISH_OFF; } else { - if ( (err = em_verify_email_address_of_mail_tbl(mail_tbl_data, false)) != EMF_ERROR_NONE ) { - err = EMF_ERROR_INVALID_ADDRESS; + if ( (err = em_verify_email_address_of_mail_tbl(mail_tbl_data, false)) != EMAIL_ERROR_NONE ) { + err = EMAIL_ERROR_INVALID_ADDRESS; EM_DEBUG_EXCEPTION("em_verify_email_address_of_mail_tbl failed [%d]", err); goto FINISH_OFF; } @@ -1065,7 +1098,7 @@ INTERNAL_FUNC int emcore_send_mail(int account_id, char *input_mailbox_name, int if (!emcore_check_send_mail_thread_status()) { EM_DEBUG_EXCEPTION("emcore_check_send_mail_thread_status failed..."); - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } @@ -1086,45 +1119,48 @@ INTERNAL_FUNC int emcore_send_mail(int account_id, char *input_mailbox_name, int if (!envelope || (!envelope->to && !envelope->cc && !envelope->bcc)) { EM_DEBUG_EXCEPTION(" no recipients found..."); - err = EMF_ERROR_NO_RECIPIENT; + err = EMAIL_ERROR_NO_RECIPIENT; goto FINISH_OFF; } /* if there is no security option, unset security. */ - if (!ref_account->sending_security) { + if (!ref_account->outgoing_server_secure_connection) { stls = (sslstart_t)mail_parameters(NULL, GET_SSLSTART, NULL); mail_parameters(NULL, SET_SSLSTART, NULL); } if (!emcore_check_send_mail_thread_status()) { EM_DEBUG_EXCEPTION("emcore_check_send_mail_thread_status failed..."); - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } if (ref_account->pop_before_smtp != FALSE) { - if (!emcore_connect_to_remote_mailbox(account_id, NULL, (void **)&tmp_stream, &err)) { + if (!emcore_connect_to_remote_mailbox(account_id, 0, (void **)&tmp_stream, &err)) { EM_DEBUG_EXCEPTION(" POP before SMTP Authentication failed [%d]", err); - status = EMF_LIST_CONNECTION_FAIL; - if (err == EMF_ERROR_CONNECTION_BROKEN) - err = EMF_ERROR_CANCELLED; + status = EMAIL_LIST_CONNECTION_FAIL; + if (err == EMAIL_ERROR_CONNECTION_BROKEN) + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } } - - - if (!emstorage_get_mailboxname_by_mailbox_type(account_id, EMF_MAILBOX_TYPE_DRAFT, &mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION(" emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); + if (!emstorage_get_mailbox_by_mailbox_type(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; + + if(local_mailbox) + emstorage_free_mailbox(&local_mailbox, 1, NULL); + - if (!emcore_connect_to_remote_mailbox(account_id, (char *)ENCODED_PATH_SMTP, (void **)&tmp_stream, &err)) { + if (!emcore_connect_to_remote_mailbox(account_id, EMAIL_CONNECT_FOR_SENDING, (void **)&tmp_stream, &err)) { EM_DEBUG_EXCEPTION(" emcore_connect_to_remote_mailbox failed [%d]", err); - if (err == EMF_ERROR_CONNECTION_BROKEN) - err = EMF_ERROR_CANCELLED; + if (err == EMAIL_ERROR_CONNECTION_BROKEN) + err = EMAIL_ERROR_CANCELLED; - status = EMF_SEND_CONNECTION_FAIL; + status = EMAIL_SEND_CONNECTION_FAIL; goto FINISH_OFF; } @@ -1132,20 +1168,20 @@ INTERNAL_FUNC int emcore_send_mail(int account_id, char *input_mailbox_name, int if (!emcore_check_send_mail_thread_status()) { EM_DEBUG_EXCEPTION(" emcore_check_send_mail_thread_status failed..."); - err = EMF_ERROR_CANCELLED; + err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; } /* set request of delivery status. */ - if (opt->req_delivery_receipt == EMF_OPTION_REQ_DELIVERY_RECEIPT_ON) { + if (opt->req_delivery_receipt == EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON) { stream->protocol.esmtp.dsn.want = 1; stream->protocol.esmtp.dsn.full = 0; stream->protocol.esmtp.dsn.notify.failure = 1; stream->protocol.esmtp.dsn.notify.success = 1; - EM_DEBUG_LOG("opt->req_delivery_receipt == EMF_OPTION_REQ_DELIVERY_RECEIPT_ON"); + EM_DEBUG_LOG("opt->req_delivery_receipt == EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON"); } - mail_tbl_data->save_status = EMF_MAIL_STATUS_SENDING; + mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENDING; /*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, false, &err)) @@ -1156,17 +1192,18 @@ INTERNAL_FUNC int emcore_send_mail(int account_id, char *input_mailbox_name, int EM_DEBUG_EXCEPTION(" emcore_send_mail_smtp failed [%d]", err); #ifndef __FEATURE_MOVE_TO_OUTBOX_FIRST__ - EM_SAFE_FREE(mailbox_name); - if (!emstorage_get_mailboxname_by_mailbox_type(account_id, EMF_MAILBOX_TYPE_OUTBOX, &mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION(" emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); + if (!emstorage_get_mailbox_by_mailbox_type(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; } - dest_mbox.name = mailbox_name; - dest_mbox.account_id = account_id; + dst_mailbox_id = local_mailbox->mailbox_id; + + if(local_mailbox) + emstorage_free_mailbox(&local_mailbox, 1, NULL); /* unsent mail is moved to 'OUTBOX'. */ - if (!emcore_mail_move(&mail_id, 1, dest_mbox.name, EMF_MOVED_BY_COMMAND, 0, NULL)) + if (!emcore_move_mail(&mail_id, 1, dst_mailbox_id, EMAIL_MOVED_BY_COMMAND, 0, NULL)) EM_DEBUG_EXCEPTION(" emcore_mail_move falied..."); goto FINISH_OFF; #endif @@ -1174,21 +1211,17 @@ INTERNAL_FUNC int emcore_send_mail(int account_id, char *input_mailbox_name, int /* sent mail is moved to 'SENT' box or deleted. */ if (opt->keep_local_copy) { - EM_SAFE_FREE(mailbox_name); - - if (!emstorage_get_mailboxname_by_mailbox_type(account_id, EMF_MAILBOX_TYPE_SENTBOX, &mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION(" emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); - + if (!emstorage_get_mailbox_by_mailbox_type(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; } - dest_mbox.name = mailbox_name; - dest_mbox.account_id = account_id; - - if (!emcore_mail_move(&mail_id, 1, dest_mbox.name, EMF_MOVED_AFTER_SENDING, 0, &err)) + dst_mailbox_id = local_mailbox->mailbox_id; + + if (!emcore_move_mail(&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__ - else if (ref_account->receiving_server_type == EMF_SERVER_TYPE_IMAP4) /* To be synced to Sent box only IMAP not for POP */ { + else if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) /* To be synced to Sent box only IMAP not for POP */ { emstorage_activity_tbl_t new_activity; int activityid = 0; @@ -1210,7 +1243,7 @@ INTERNAL_FUNC int emcore_send_mail(int account_id, char *input_mailbox_name, int EM_DEBUG_EXCEPTION(" emcore_add_activity Failed [%d] ", err); } - if (!emcore_move_mail_on_server(dest_mbox.account_id, mailbox_name, &mail_id, 1, dest_mbox.name, &err)) { + if (!emcore_move_mail_on_server(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 { @@ -1241,12 +1274,12 @@ INTERNAL_FUNC int emcore_send_mail(int account_id, char *input_mailbox_name, int sent_box = 1; } else { - if (!emcore_delete_mail(account_id, &mail_id, 1, 0, EMF_DELETED_AFTER_SENDING, false, &err)) + if (!emcore_delete_mail(account_id, &mail_id, 1, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_AFTER_SENDING, false, &err)) EM_DEBUG_EXCEPTION(" emcore_delete_mail failed [%d]", err); } /*Update status save_status to DB*/ - mail_tbl_data->save_status = EMF_MAIL_STATUS_SENT; + 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, false, &err)) EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err); @@ -1256,17 +1289,17 @@ INTERNAL_FUNC int emcore_send_mail(int account_id, char *input_mailbox_name, int ret = true; FINISH_OFF: - if (ret == false && err != EMF_ERROR_INVALID_PARAM && mail_tbl_data) { - if (err != EMF_ERROR_CANCELLED) { - mail_tbl_data->save_status = EMF_MAIL_STATUS_SEND_FAILURE; + 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, false, &err2)) EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err2); } else { - if (EMF_MAIL_STATUS_SEND_CANCELED == mail_tbl_data->save_status) - EM_DEBUG_LOG("EMF_MAIL_STATUS_SEND_CANCELED Already set for "); + if (EMAIL_MAIL_STATUS_SEND_CANCELED == mail_tbl_data->save_status) + EM_DEBUG_LOG("EMAIL_MAIL_STATUS_SEND_CANCELED Already set for "); else { - mail_tbl_data->save_status = EMF_MAIL_STATUS_SEND_CANCELED; + 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, false, &err2)) EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err2); } @@ -1295,6 +1328,9 @@ FINISH_OFF: free(fpath); } + if(local_mailbox) + emstorage_free_mailbox(&local_mailbox, 1, NULL); + if (ret == true) { if (!emstorage_notify_network_event(NOTI_SEND_FINISH, account_id, NULL, mail_id, 0)) EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_SEND_FINISH] Failed"); @@ -1302,11 +1338,9 @@ FINISH_OFF: else { if (!emstorage_notify_network_event(NOTI_SEND_FAIL, account_id, NULL, mail_id, err)) EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_SEND_FAIL] Failed"); - emcore_show_popup(mail_id, EMF_ACTION_SEND_MAIL, err); + emcore_show_user_message(mail_id, EMAIL_ACTION_SEND_MAIL, err); } - EM_SAFE_FREE(mailbox_name); - if (err_code != NULL) *err_code = err; EM_PROFILE_END(profile_emcore_send_mail); @@ -1315,42 +1349,42 @@ FINISH_OFF: } /* send a saved all mails */ -INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_name, emf_option_t *sending_option, int *err_code) +INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_name, email_option_t *sending_option, int *err_code) { EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_name[%p], sending_option[%p], err_code[%p]", account_id, input_mailbox_name, sending_option, err_code); int ret = false; - int err = EMF_ERROR_NONE; - int status = EMF_SEND_FAIL; + int err = EMAIL_ERROR_NONE; + int status = EMAIL_SEND_FAIL; int mail_id = 0; int handle = 0; int i = 0; int total = 0; int attachment_tbl_count = 0; - char *mailbox_name = NULL; char *fpath = NULL; SENDSTREAM *stream = NULL; ENVELOPE *envelope = NULL; - emf_mailbox_t dest_mbox = {0}; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; emstorage_mail_tbl_t *searched_mail_tbl_data = NULL; emstorage_attachment_tbl_t *attachment_tbl_data = NULL; - emf_option_t *opt = NULL; + email_option_t *opt = NULL; sslstart_t stls = NULL; void *tmp_stream = NULL; void *p = NULL; + emstorage_mailbox_tbl_t* local_mailbox = NULL; + int dst_mailbox_id = 0; if (!account_id || !input_mailbox_name) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - mail_send_notify(EMF_SEND_PREPARE, 0, 0, account_id, mail_id, err); + mail_send_notify(EMAIL_SEND_PREPARE, 0, 0, account_id, mail_id, err); if (!(ref_account = emcore_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } @@ -1383,27 +1417,27 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam goto FINISH_OFF; } - if ( (err = emstorage_get_attachment_list(mail_id, false, &attachment_tbl_data, &attachment_tbl_count)) != EMF_ERROR_NONE) { + if ( (err = emstorage_get_attachment_list(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; } /* check for email_address validation */ - if ( (err = em_verify_email_address_of_mail_tbl(searched_mail_tbl_data, false)) != EMF_ERROR_NONE ) { - err = EMF_ERROR_INVALID_ADDRESS; + if ( (err = em_verify_email_address_of_mail_tbl(searched_mail_tbl_data, false)) != EMAIL_ERROR_NONE ) { + err = EMAIL_ERROR_INVALID_ADDRESS; EM_DEBUG_EXCEPTION("em_verify_email_address_of_mail_tbl failed [%d]", err); goto FINISH_OFF; } /* check that this mail was saved in offline-mode. */ - if (searched_mail_tbl_data->save_status != EMF_MAIL_STATUS_SAVED_OFFLINE) { + if (searched_mail_tbl_data->save_status != EMAIL_MAIL_STATUS_SAVED_OFFLINE) { EM_DEBUG_EXCEPTION(" mail was not saved in offline mode..."); emstorage_free_mail(&searched_mail_tbl_data, 1, &err); searched_mail_tbl_data = NULL; continue; } - searched_mail_tbl_data->save_status = EMF_MAIL_STATUS_SENDING; + 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)) { EM_DEBUG_EXCEPTION("emcore_make_rfc822_file_from_mail falied [%d]", err); @@ -1415,19 +1449,19 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam /* connect mail server. */ if (!stream) { /* if there no security option, unset security. */ - if (!ref_account->sending_security) { + if (!ref_account->outgoing_server_secure_connection) { stls = (sslstart_t)mail_parameters(NULL, GET_SSLSTART, NULL); mail_parameters(NULL, SET_SSLSTART, NULL); } stream = NULL; - if (!emcore_connect_to_remote_mailbox(account_id, (char *)ENCODED_PATH_SMTP, &tmp_stream, &err) || !tmp_stream) { + if (!emcore_connect_to_remote_mailbox(account_id, EMAIL_CONNECT_FOR_SENDING, &tmp_stream, &err) || !tmp_stream) { EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err); - if (err == EMF_ERROR_CONNECTION_BROKEN) - err = EMF_ERROR_CANCELLED; + if (err == EMAIL_ERROR_CONNECTION_BROKEN) + err = EMAIL_ERROR_CANCELLED; - status = EMF_SEND_CONNECTION_FAIL; + status = EMAIL_SEND_CONNECTION_FAIL; goto FINISH_OFF; } @@ -1435,20 +1469,20 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam FINISH_OFF_IF_CANCELED; - mail_send_notify(EMF_SEND_CONNECTION_SUCCEED, 0, 0, account_id, mail_id, err); + mail_send_notify(EMAIL_SEND_CONNECTION_SUCCEED, 0, 0, account_id, mail_id, err); /* reqest of delivery status. */ - if (opt && opt->req_delivery_receipt == EMF_OPTION_REQ_DELIVERY_RECEIPT_ON) { + if (opt && opt->req_delivery_receipt == EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON) { stream->protocol.esmtp.dsn.want = 1; stream->protocol.esmtp.dsn.full = 0; stream->protocol.esmtp.dsn.notify.failure = 1; stream->protocol.esmtp.dsn.notify.success = 1; } - mail_send_notify(EMF_SEND_START, 0, 0, account_id, mail_id, err); + mail_send_notify(EMAIL_SEND_START, 0, 0, account_id, mail_id, err); } - searched_mail_tbl_data->save_status = EMF_MAIL_STATUS_SENDING; + searched_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENDING; /* update mail status to sending. */ if (!emstorage_change_mail_field(mail_id, UPDATE_EXTRA_FLAG, searched_mail_tbl_data, true, &err)) { @@ -1460,26 +1494,27 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam if (!emcore_send_mail_smtp(stream, envelope, fpath, account_id, mail_id, &err)) { EM_DEBUG_EXCEPTION("emcore_send_mail_smtp failed [%d]", err); - searched_mail_tbl_data->save_status = EMF_MAIL_STATUS_SEND_FAILURE; + searched_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SEND_FAILURE; /* update mail status to failure. */ if (!emstorage_change_mail_field(mail_id, UPDATE_EXTRA_FLAG, searched_mail_tbl_data, true, &err)) EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err); - if (!emstorage_get_mailboxname_by_mailbox_type(account_id, EMF_MAILBOX_TYPE_OUTBOX, &mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); - + if (!emstorage_get_mailbox_by_mailbox_type(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; - } - dest_mbox.name = mailbox_name; - dest_mbox.account_id = account_id; + } + dst_mailbox_id = local_mailbox->mailbox_id; - emcore_mail_move(&mail_id, 1, dest_mbox.name, EMF_MOVED_AFTER_SENDING, 0, NULL); + emcore_move_mail(&mail_id, 1, dst_mailbox_id, EMAIL_MOVED_AFTER_SENDING, 0, NULL); + if(local_mailbox) + emstorage_free_mailbox(&local_mailbox, 1, NULL); + goto FINISH_OFF; } - searched_mail_tbl_data->save_status = EMF_MAIL_STATUS_SENT; + searched_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENT; /* update mail status to sent mail. */ if (!emstorage_change_mail_field(mail_id, UPDATE_EXTRA_FLAG, searched_mail_tbl_data, true, &err)) { @@ -1489,20 +1524,20 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam /* sent mail is moved to 'SENT' box or deleted. */ if (opt->keep_local_copy) { - EM_SAFE_FREE(mailbox_name); - if (!emstorage_get_mailboxname_by_mailbox_type(account_id, EMF_MAILBOX_TYPE_SENTBOX, &mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); - + if (!emstorage_get_mailbox_by_mailbox_type(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; - } - dest_mbox.name = mailbox_name; - dest_mbox.account_id = account_id; + } + dst_mailbox_id = local_mailbox->mailbox_id; - if (!emcore_mail_move(&mail_id, 1, dest_mbox.name, EMF_MOVED_AFTER_SENDING, 0, &err)) + if (!emcore_move_mail(&mail_id, 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_id, 1, 0, EMF_DELETED_AFTER_SENDING, false, &err)) + if (!emcore_delete_mail(account_id, &mail_id, 1, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_AFTER_SENDING, false, &err)) EM_DEBUG_EXCEPTION("emcore_delete_mail falied [%d]", err); } @@ -1551,13 +1586,14 @@ FINISH_OFF: EM_SAFE_FREE(fpath); } - EM_SAFE_FREE(mailbox_name); + if(local_mailbox) + emstorage_free_mailbox(&local_mailbox, 1, NULL); if (ret == true) - mail_send_notify(EMF_SEND_FINISH, 0, 0, account_id, mail_id, err); + mail_send_notify(EMAIL_SEND_FINISH, 0, 0, account_id, mail_id, err); else { mail_send_notify(status, 0, 0, account_id, mail_id, err); - emcore_show_popup(account_id, EMF_ACTION_SEND_MAIL, err); + emcore_show_user_message(account_id, EMAIL_ACTION_SEND_MAIL, err); } if (err_code != NULL) @@ -1572,39 +1608,39 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f EM_PROFILE_BEGIN(profile_emcore_send_mail_smtp); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int recipients = 0; long total = 0, sent = 0, send_ret = 0, send_err = 0, sent_percent = 0, last_sent_percent = 0; char buf[2048] = { 0, }; - emf_account_t *ref_account = NULL; + email_account_t *ref_account = NULL; FILE *fp = NULL; if (!env || !env->from || (!env->to && !env->cc && !env->bcc)) { if (env != NULL) - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!env->from->mailbox || !env->from->host) { EM_DEBUG_EXCEPTION("env->from->mailbox[%p], env->from->host[%p]", env->from->mailbox, env->from->host); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!(ref_account = emcore_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } EM_DEBUG_LOG("Modifying - MAIL FROM "); - if (ref_account->email_addr == NULL) { - EM_DEBUG_LOG("ref_account->email_addr is null!!"); + if (ref_account->user_email_address == NULL) { + EM_DEBUG_LOG("ref_account->user_email_address is null!!"); SNPRINTF(buf, sizeof(buf), "FROM:<%s@%s>", env->from->mailbox, env->from->host); } else - SNPRINTF(buf, sizeof(buf), "FROM:<%s>", ref_account->email_addr); + SNPRINTF(buf, sizeof(buf), "FROM:<%s>", ref_account->user_email_address); /* set DSN for ESMTP */ if (stream->protocol.esmtp.ok) { @@ -1640,12 +1676,12 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f case SMTP_RESPONSE_WANT_AUTH : case SMTP_RESPONSE_WANT_AUTH2: EM_DEBUG_EXCEPTION("SMTP error : authentication required..."); - err = EMF_ERROR_AUTHENTICATE; + err = EMAIL_ERROR_AUTHENTICATE; goto FINISH_OFF; case SMTP_RESPONSE_UNAVAIL: EM_DEBUG_EXCEPTION("SMTP error : mailbox unavailable..."); - err = EMF_ERROR_MAILBOX_FAILURE; + err = EMAIL_ERROR_MAILBOX_FAILURE; goto FINISH_OFF; default: @@ -1692,7 +1728,7 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f if (send_err) { EM_DEBUG_EXCEPTION("One or more recipients failed..."); - err = EMF_ERROR_INVALID_ADDRESS; + err = EMAIL_ERROR_INVALID_ADDRESS; } if (!recipients) { @@ -1702,11 +1738,11 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f case SMTP_RESPONSE_UNAVAIL: case SMTP_RESPONSE_WANT_AUTH : case SMTP_RESPONSE_WANT_AUTH2: - err = EMF_ERROR_AUTH_REQUIRED; + err = EMAIL_ERROR_AUTH_REQUIRED; break; default: - err = EMF_ERROR_INVALID_ADDRESS; + err = EMAIL_ERROR_INVALID_ADDRESS; break; } goto FINISH_OFF; @@ -1725,7 +1761,7 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f EM_PROFILE_BEGIN(profile_open_file); if (!(fp = fopen(data_file, "r+"))) { EM_DEBUG_EXCEPTION("fopen(\"%s\") failed...", data_file); - err = EMF_ERROR_SYSTEM_FAILURE; + err = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } EM_PROFILE_END(profile_open_file); @@ -1753,7 +1789,7 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f EM_PROFILE_END(profile_allocation); if (NULL == data) { - err = EMF_ERROR_SMTP_SEND_FAILURE; + err = EMAIL_ERROR_SMTP_SEND_FAILURE; goto FINISH_OFF; } @@ -1770,7 +1806,7 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f /* read fail. */ EM_SAFE_FREE(data); EM_DEBUG_EXCEPTION("Read from file failed"); - err = EMF_ERROR_SMTP_SEND_FAILURE; + err = EMAIL_ERROR_SMTP_SEND_FAILURE; goto FINISH_OFF; } sent += read_size; @@ -1779,7 +1815,7 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f if (!(send_ret = smtp_soutr_test(stream->netstream, data))) { EM_SAFE_FREE(data); EM_DEBUG_EXCEPTION("Failed to send the data "); - err = EMF_ERROR_SMTP_SEND_FAILURE; + err = EMAIL_ERROR_SMTP_SEND_FAILURE; goto FINISH_OFF; } else { @@ -1823,7 +1859,7 @@ 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 = EMF_ERROR_SMTP_SEND_FAILURE; + err = EMAIL_ERROR_SMTP_SEND_FAILURE; goto FINISH_OFF; } } @@ -1860,9 +1896,9 @@ char *emcore_generate_content_id_string(const char *hostname, int *err) EM_DEBUG_FUNC_BEGIN("hostname[%p]", hostname); if (!hostname) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err) - *err = EMF_ERROR_INVALID_PARAM; + *err = EMAIL_ERROR_INVALID_PARAM; return NULL; } @@ -1873,7 +1909,7 @@ char *emcore_generate_content_id_string(const char *hostname, int *err) if (!cid_string) { if (err) - *err = EMF_ERROR_OUT_OF_MEMORY; + *err = EMAIL_ERROR_OUT_OF_MEMORY; return NULL; } @@ -1888,7 +1924,7 @@ char *emcore_generate_content_id_string(const char *hostname, int *err) SNPRINTF(cid_string, cid_length, "<%08x%08x%08x%08x@%s>", random_number_1, random_number_2, random_number_3, random_number_4, hostname); if (err) - *err = EMF_ERROR_NONE; + *err = EMAIL_ERROR_NONE; EM_DEBUG_FUNC_END("cid_string [%s]", cid_string); return cid_string; @@ -1905,7 +1941,7 @@ static int attach_part(BODY *body, const unsigned char *data, int data_len, char EM_DEBUG_FUNC_BEGIN("body[%p], data[%s], data_len[%d], filename[%s], content_sub_type[%s], err_code[%p]", body, data, data_len, filename, content_sub_type, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int has_special_character = 0; int base64_file_name_length = 0; int i= 0; @@ -1925,8 +1961,8 @@ static int attach_part(BODY *body, const unsigned char *data, int data_len, char CHARSET *result_charset = NULL; if (!body) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - error = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1943,7 +1979,7 @@ static int attach_part(BODY *body, const unsigned char *data, int data_len, char part = mail_newbody_part(); if (part == NULL) { EM_DEBUG_EXCEPTION("mail_newbody_part failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2037,7 +2073,7 @@ static int attach_part(BODY *body, const unsigned char *data, int data_len, char param = mail_newbody_parameter(); if (param == NULL) { EM_DEBUG_EXCEPTION("mail_newbody_parameter failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2049,7 +2085,7 @@ static int attach_part(BODY *body, const unsigned char *data, int data_len, char if (is_inline) { /* CONTENT-ID */ - part->body.id = emcore_generate_content_id_string("com.samsung.slp.email", &error); + part->body.id = emcore_generate_content_id_string("org.tizen.email", &error); part->body.type = TYPEIMAGE; /* EM_SAFE_FREE(part->body.subtype); */ /* part->body.subtype = EM_SAFE_STRDUP(content_sub_type); */ @@ -2059,7 +2095,7 @@ static int attach_part(BODY *body, const unsigned char *data, int data_len, char param = mail_newbody_parameter(); if (param == NULL) { EM_DEBUG_EXCEPTION("mail_newbody_parameter failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2098,7 +2134,7 @@ static int attach_part(BODY *body, const unsigned char *data, int data_len, char if (param == NULL) { EM_DEBUG_EXCEPTION("mail_newbody_parameter failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2139,7 +2175,7 @@ static int attach_part(BODY *body, const unsigned char *data, int data_len, char if (param == NULL) { EM_DEBUG_EXCEPTION("mail_newbody_parameter failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2193,14 +2229,14 @@ static PART *attach_mutipart_with_sub_type(BODY *parent_body, char *sub_type, in { EM_DEBUG_FUNC_BEGIN("parent_body[%p], sub_type [%s], err_code[%p]", parent_body, sub_type, err_code); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; PART *tail_part_cur = NULL; PART *new_part = NULL; if (!parent_body || !sub_type) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - error = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2216,8 +2252,8 @@ static PART *attach_mutipart_with_sub_type(BODY *parent_body, char *sub_type, in new_part = mail_newbody_part(); if (new_part == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_OUT_OF_MEMORY"); - error = EMF_ERROR_OUT_OF_MEMORY; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY"); + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2240,27 +2276,27 @@ 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) { 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); int ret = false; int i = 0; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; BODY *frame_body = NULL; /* make multipart body(multipart frame_body..) .. that has not content.. */ if (!multipart_body || !text_body || !input_attachment_tbl) { EM_DEBUG_EXCEPTION(" multipart_body[%p], text_body[%p], input_attachment_tbl[%p]", multipart_body, text_body, input_attachment_tbl); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } frame_body = mail_newbody(); if (frame_body == NULL) { EM_DEBUG_EXCEPTION("mail_newbody failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2315,14 +2351,14 @@ FINISH_OFF: EM_DEBUG_FUNC_END(); return ret; } - +#endif static char *emcore_encode_rfc2047_text(char *utf8_text, int *err_code) { EM_DEBUG_FUNC_BEGIN("utf8_text[%s], err_code[%p]", utf8_text, err_code); if (utf8_text == NULL) { if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return NULL; } @@ -2357,12 +2393,12 @@ static void emcore_encode_rfc2047_address(ADDRESS *address, int *err_code) /* 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, emf_option_t *sending_option, int *err_code) +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) { 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); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int is_incomplete = 0; int i = 0; ENVELOPE *envelope = NULL; @@ -2373,18 +2409,18 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ PART *part_for_text = NULL; char *pAdd = NULL; char *fname = NULL; - emf_extra_flag_t extra_flag; - emf_account_t *ref_account = NULL; + email_extra_flag_t extra_flag; + email_account_t *ref_account = NULL; if (!input_mail_tbl_data) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - error = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (input_mail_tbl_data->report_status != EMF_MAIL_REPORT_MDN && !input_mail_tbl_data->body_download_status) { + if (input_mail_tbl_data->report_status != EMAIL_MAIL_REPORT_MDN && !input_mail_tbl_data->body_download_status) { EM_DEBUG_EXCEPTION("input_mail_tbl_data->body_download_status[%p]", input_mail_tbl_data->body_download_status); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2392,25 +2428,25 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ if (!ref_account) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", input_mail_tbl_data->account_id); - error = EMF_ERROR_INVALID_ACCOUNT; + error = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } if (!(envelope = mail_newenvelope())) { EM_DEBUG_EXCEPTION("mail_newenvelope failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - is_incomplete = input_mail_tbl_data->flags_draft_field || (input_mail_tbl_data->save_status == EMF_MAIL_STATUS_SENDING); + is_incomplete = input_mail_tbl_data->flags_draft_field || (input_mail_tbl_data->save_status == EMAIL_MAIL_STATUS_SENDING); if (is_incomplete) { - if (ref_account->email_addr && ref_account->email_addr[0] != '\0') { - char *p = cpystr(ref_account->email_addr); + if (ref_account->user_email_address && ref_account->user_email_address[0] != '\0') { + char *p = cpystr(ref_account->user_email_address); if (p == NULL) { EM_DEBUG_EXCEPTION("cpystr failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2420,7 +2456,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ char *temp_address_string = NULL ; em_skip_whitespace(input_mail_tbl_data->full_address_from , &temp_address_string); EM_DEBUG_LOG("address[temp_address_string][%s]", temp_address_string); - rfc822_parse_adrlist(&envelope->from, temp_address_string, ref_account->sending_server_addr); + rfc822_parse_adrlist(&envelope->from, temp_address_string, ref_account->outgoing_server_address); EM_SAFE_FREE(temp_address_string); temp_address_string = NULL ; } @@ -2430,7 +2466,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ EM_SAFE_FREE(p); if (!envelope->from) { EM_DEBUG_EXCEPTION("rfc822_parse_mailbox failed..."); - error = EMF_ERROR_INVALID_ADDRESS; + error = EMAIL_ERROR_INVALID_ADDRESS; goto FINISH_OFF; } else { @@ -2439,18 +2475,20 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ if (sending_option && sending_option->display_name_from && sending_option->display_name_from[0] != '\0') envelope->from->personal = cpystr(sending_option->display_name_from); else - envelope->from->personal = (ref_account->display_name && ref_account->display_name[0] != '\0') ? cpystr(ref_account->display_name) : NULL; + envelope->from->personal = + (ref_account->user_display_name && ref_account->user_display_name[0] != '\0') ? + cpystr(ref_account->user_display_name) : NULL; } } } - if (ref_account->return_addr && ref_account->return_addr[0] != '\0') { - char *p = cpystr(ref_account->return_addr); + if (ref_account->return_address && ref_account->return_address[0] != '\0') { + char *p = cpystr(ref_account->return_address); if (p == NULL) { EM_DEBUG_EXCEPTION("cpystr failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } envelope->return_path = rfc822_parse_mailbox(&p, NULL); @@ -2460,7 +2498,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ else { if (!input_mail_tbl_data->full_address_from || !input_mail_tbl_data->full_address_to) { EM_DEBUG_EXCEPTION("input_mail_tbl_data->full_address_from[%p], input_mail_tbl_data->full_address_to[%p]", input_mail_tbl_data->full_address_from, input_mail_tbl_data->full_address_to); - error = EMF_ERROR_INVALID_MAIL; + error = EMAIL_ERROR_INVALID_MAIL; goto FINISH_OFF; } @@ -2482,14 +2520,14 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ em_skip_whitespace(input_mail_tbl_data->full_address_from , &pAdd); EM_DEBUG_LOG("address[pAdd][%s]", pAdd); - rfc822_parse_adrlist(&envelope->from, pAdd, ref_account->sending_server_addr); + rfc822_parse_adrlist(&envelope->from, pAdd, ref_account->outgoing_server_address); EM_SAFE_FREE(pAdd); pAdd = NULL ; em_skip_whitespace(input_mail_tbl_data->full_address_return , &pAdd); EM_DEBUG_LOG("address[pAdd][%s]", pAdd); - rfc822_parse_adrlist(&envelope->return_path, pAdd, ref_account->sending_server_addr); + rfc822_parse_adrlist(&envelope->return_path, pAdd, ref_account->outgoing_server_address); EM_SAFE_FREE(pAdd); pAdd = NULL ; } @@ -2522,7 +2560,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ em_skip_whitespace(input_mail_tbl_data->full_address_to , &pAdd); EM_DEBUG_LOG("address[pAdd][%s]", pAdd); - rfc822_parse_adrlist(&envelope->to, pAdd, ref_account->sending_server_addr); + rfc822_parse_adrlist(&envelope->to, pAdd, ref_account->outgoing_server_address); EM_SAFE_FREE(pAdd); pAdd = NULL ; @@ -2530,12 +2568,12 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ em_skip_whitespace(input_mail_tbl_data->full_address_cc , &pAdd); EM_DEBUG_LOG("address[pAdd][%s]", pAdd); - rfc822_parse_adrlist(&envelope->cc, pAdd, ref_account->sending_server_addr); + rfc822_parse_adrlist(&envelope->cc, pAdd, ref_account->outgoing_server_address); EM_SAFE_FREE(pAdd); pAdd = NULL ; em_skip_whitespace(input_mail_tbl_data->full_address_bcc , &pAdd); - rfc822_parse_adrlist(&envelope->bcc, pAdd, ref_account->sending_server_addr); + rfc822_parse_adrlist(&envelope->bcc, pAdd, ref_account->outgoing_server_address); EM_SAFE_FREE(pAdd); pAdd = NULL ; @@ -2550,24 +2588,24 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ if (input_mail_tbl_data->subject) envelope->subject = emcore_encode_rfc2047_text(input_mail_tbl_data->subject, &error); - char date_str[DATE_STR_LENGTH + 1] = { 0, }; - char buf[256] = {0, }; - - rfc822_date(date_str); + char rfc822_date_string[DATE_STR_LENGTH] = { 0, }; + rfc822_date(rfc822_date_string); if (!is_incomplete) { - strftime(buf, 128, "%a, %e %b %Y %H : %M : %S ", localtime(&input_mail_tbl_data->date_time)); + char localtime_string[DATE_STR_LENGTH] = { 0, }; + strftime(localtime_string, 128, "%a, %e %b %Y %H : %M : %S ", localtime(&input_mail_tbl_data->date_time)); /* append last 5byes("+0900") */ - strncat(buf, date_str + (strlen(date_str) - 5), DATE_STR_LENGTH); - strncpy(date_str, buf, DATE_STR_LENGTH); + g_strlcat(localtime_string, rfc822_date_string + (strlen(rfc822_date_string) - 5), DATE_STR_LENGTH); + envelope->date = (unsigned char *)cpystr((const char *)localtime_string); + } + else { + envelope->date = (unsigned char *)cpystr((const char *)rfc822_date_string); } - envelope->date = (unsigned char *)cpystr((const char *)date_str); - - /* memcpy(&extra_flag, &input_mail_tbl_data->info->extra_flags, sizeof(emf_extra_flag_t)); */ + /* memcpy(&extra_flag, &input_mail_tbl_data->info->extra_flags, sizeof(email_extra_flag_t)); */ /* check report input_mail_tbl_data */ - if (input_mail_tbl_data->report_status != EMF_MAIL_REPORT_MDN) { + if (input_mail_tbl_data->report_status != EMAIL_MAIL_REPORT_MDN) { /* Non-report input_mail_tbl_data */ EM_DEBUG_LOG("input_mail_tbl_data->file_path_plain[%s]", input_mail_tbl_data->file_path_plain); EM_DEBUG_LOG("input_mail_tbl_data->file_path_html[%s]", input_mail_tbl_data->file_path_html); @@ -2580,7 +2618,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ if (root_body == NULL) { EM_DEBUG_EXCEPTION("mail_newbody failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2662,7 +2700,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ if (text_body == NULL) { EM_DEBUG_EXCEPTION("mail_newbody failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2685,7 +2723,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ EM_DEBUG_LOG("REPORT MAIL"); envelope->references = cpystr(input_mail_tbl_data->message_id); /* Below codes should not be here. TODO : Move these to proper location. */ - /* +#ifdef __FEATURE_SUPPORT_REPORT_MAIL__ if (emcore_get_report_mail_body(envelope, &root_body, &error)) { if (!input_mail_tbl_data) { input_mail_tbl_data->file_path_plain = EM_SAFE_STRDUP(root_body->nested.part->body.sparep); @@ -2699,7 +2737,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ if (!input_attachment_tbl) { EM_DEBUG_EXCEPTION("malloc failed..."); EM_SAFE_FREE(input_mail_tbl_data->file_path_plain); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2716,7 +2754,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_ input_mail_tbl_data->body->attachment->name = cpystr(p); } } - */ +#endif } if (file_path) { @@ -2753,12 +2791,402 @@ 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, 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); + + int ret = false; + int error = EMAIL_ERROR_NONE; + int is_incomplete = 0; + int i = 0; + ENVELOPE *envelope = NULL; + BODY *text_body = NULL; + BODY *html_body = NULL; + BODY *root_body = NULL; + PART *part_for_html = NULL; + PART *part_for_text = NULL; + char temp_file_path_plain[512]; + char temp_file_path_html[512]; + char *pAdd = NULL; + char *fname = NULL; + email_extra_flag_t extra_flag; + email_account_t *ref_account = NULL; + + if (!input_mail_tbl_data) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + if (input_mail_tbl_data->report_status != EMAIL_MAIL_REPORT_MDN && !input_mail_tbl_data->body_download_status) { + EM_DEBUG_EXCEPTION("input_mail_tbl_data->body_download_status[%p]", input_mail_tbl_data->body_download_status); + error = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + ref_account = emcore_get_account_reference(input_mail_tbl_data->account_id); + + if (!ref_account) { + EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", input_mail_tbl_data->account_id); + error = EMAIL_ERROR_INVALID_ACCOUNT; + goto FINISH_OFF; + } + + if (!(envelope = mail_newenvelope())) { + EM_DEBUG_EXCEPTION("mail_newenvelope failed..."); + error = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + is_incomplete = input_mail_tbl_data->flags_draft_field || (input_mail_tbl_data->save_status == EMAIL_MAIL_STATUS_SENDING); + + if (is_incomplete) { + if (ref_account->user_email_address && ref_account->user_email_address[0] != '\0') { + char *p = cpystr(ref_account->user_email_address); + + if (p == NULL) { + EM_DEBUG_EXCEPTION("cpystr failed..."); + error = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + EM_DEBUG_LOG("Assign envelop->from"); + + if (input_mail_tbl_data->full_address_from) { + char *temp_address_string = NULL ; + em_skip_whitespace(input_mail_tbl_data->full_address_from , &temp_address_string); + EM_DEBUG_LOG("address[temp_address_string][%s]", temp_address_string); + rfc822_parse_adrlist(&envelope->from, temp_address_string, ref_account->outgoing_server_address); + EM_SAFE_FREE(temp_address_string); + temp_address_string = NULL ; + } + else + envelope->from = rfc822_parse_mailbox(&p, NULL); + + EM_SAFE_FREE(p); + if (!envelope->from) { + EM_DEBUG_EXCEPTION("rfc822_parse_mailbox failed..."); + error = EMAIL_ERROR_INVALID_ADDRESS; + goto FINISH_OFF; + } + else { + + if (envelope->from->personal == NULL) { + envelope->from->personal = + (ref_account->user_display_name && ref_account->user_display_name[0] != '\0')? + cpystr(ref_account->user_display_name) : NULL; + } + } + } + } + + if (ref_account->return_address && ref_account->return_address[0] != '\0') { + char *p = cpystr(ref_account->return_address); + + if (p == NULL) { + EM_DEBUG_EXCEPTION("cpystr failed..."); + + error = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + envelope->return_path = rfc822_parse_mailbox(&p, NULL); + EM_SAFE_FREE(p); + } + else { + if (!input_mail_tbl_data->full_address_from || !input_mail_tbl_data->full_address_to) { + EM_DEBUG_EXCEPTION("input_mail_tbl_data->full_address_from[%p], input_mail_tbl_data->full_address_to[%p]", input_mail_tbl_data->full_address_from, input_mail_tbl_data->full_address_to); + error = EMAIL_ERROR_INVALID_MAIL; + goto FINISH_OFF; + } + + int i, j; + + if (input_mail_tbl_data->full_address_from) { + for (i = 0, j = strlen(input_mail_tbl_data->full_address_from); i < j; i++) { + if (input_mail_tbl_data->full_address_from[i] == ';') + input_mail_tbl_data->full_address_from[i] = ','; + } + } + + if (input_mail_tbl_data->full_address_return) { + for (i = 0, j = strlen(input_mail_tbl_data->full_address_return); i < j; i++) { + if (input_mail_tbl_data->full_address_return[i] == ';') + input_mail_tbl_data->full_address_return[i] = ','; + } + } + em_skip_whitespace(input_mail_tbl_data->full_address_from , &pAdd); + EM_DEBUG_LOG("address[pAdd][%s]", pAdd); + + rfc822_parse_adrlist(&envelope->from, pAdd, ref_account->outgoing_server_address); + EM_SAFE_FREE(pAdd); + pAdd = NULL ; + + em_skip_whitespace(input_mail_tbl_data->full_address_return , &pAdd); + EM_DEBUG_LOG("address[pAdd][%s]", pAdd); + + rfc822_parse_adrlist(&envelope->return_path, pAdd, ref_account->outgoing_server_address); + EM_SAFE_FREE(pAdd); + pAdd = NULL ; + } + + { + int i, j; + + if (input_mail_tbl_data->full_address_to) { + for (i = 0, j = strlen(input_mail_tbl_data->full_address_to); i < j; i++) { + if (input_mail_tbl_data->full_address_to[i] == ';') + input_mail_tbl_data->full_address_to[i] = ','; + } + } + + if (input_mail_tbl_data->full_address_cc) { + for (i = 0, j = strlen(input_mail_tbl_data->full_address_cc); i < j; i++) { + if (input_mail_tbl_data->full_address_cc[i] == ';') + input_mail_tbl_data->full_address_cc[i] = ','; + } + } + + if (input_mail_tbl_data->full_address_bcc) { + for (i = 0, j = strlen(input_mail_tbl_data->full_address_bcc); i < j; i++) { + if (input_mail_tbl_data->full_address_bcc[i] == ';') + input_mail_tbl_data->full_address_bcc[i] = ','; + } + } + } + + em_skip_whitespace(input_mail_tbl_data->full_address_to , &pAdd); + EM_DEBUG_LOG("address[pAdd][%s]", pAdd); + + rfc822_parse_adrlist(&envelope->to, pAdd, ref_account->outgoing_server_address); + EM_SAFE_FREE(pAdd); + pAdd = NULL ; + + EM_DEBUG_LOG("address[input_mail_tbl_data->full_address_cc][%s]", input_mail_tbl_data->full_address_cc); + em_skip_whitespace(input_mail_tbl_data->full_address_cc , &pAdd); + EM_DEBUG_LOG("address[pAdd][%s]", pAdd); + + rfc822_parse_adrlist(&envelope->cc, pAdd, ref_account->outgoing_server_address); + EM_SAFE_FREE(pAdd); + pAdd = NULL ; + + em_skip_whitespace(input_mail_tbl_data->full_address_bcc , &pAdd); + rfc822_parse_adrlist(&envelope->bcc, pAdd, ref_account->outgoing_server_address); + EM_SAFE_FREE(pAdd); + pAdd = NULL ; + + emcore_encode_rfc2047_address(envelope->return_path, &error); + emcore_encode_rfc2047_address(envelope->from, &error); + emcore_encode_rfc2047_address(envelope->sender, &error); + emcore_encode_rfc2047_address(envelope->reply_to, &error); + emcore_encode_rfc2047_address(envelope->to, &error); + emcore_encode_rfc2047_address(envelope->cc, &error); + emcore_encode_rfc2047_address(envelope->bcc, &error); + + 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, }; + char localtime_string[DATE_STR_LENGTH] = {0, }; + + rfc822_date(rfc822_date_string); + + if (!is_incomplete) { + strftime(localtime_string, 128, "%a, %e %b %Y %H : %M : %S ", localtime(&input_mail_tbl_data->date_time)); + /* append last 5byes("+0900") */ + g_strlcat(localtime_string, rfc822_date_string + (strlen(rfc822_date_string) - 5), DATE_STR_LENGTH); + envelope->date = (unsigned char *)cpystr((const char *)localtime_string); + } + else { + envelope->date = (unsigned char *)cpystr((const char *)rfc822_date_string); + } + /* memcpy(&extra_flag, &input_mail_tbl_data->info->extra_flags, sizeof(email_extra_flag_t)); */ + /* check report input_mail_tbl_data */ + + /* Non-report input_mail_tbl_data */ + EM_DEBUG_LOG("input_mail_tbl_data->file_path_plain[%s]", input_mail_tbl_data->file_path_plain); + EM_DEBUG_LOG("input_mail_tbl_data->file_path_html[%s]", input_mail_tbl_data->file_path_html); + EM_DEBUG_LOG("input_mail_tbl_data->body->attachment_num[%d]", input_mail_tbl_data->attachment_count); + + if (input_mail_tbl_data->file_path_plain) { + memset(temp_file_path_plain, 0x00, sizeof(temp_file_path_plain)); + SNPRINTF(temp_file_path_plain, sizeof(temp_file_path_plain), "%s%s%s%s%s", MAILHOME, DIR_SEPERATOR, MAILTEMP, DIR_SEPERATOR, "UTF-8"); + + if (!emstorage_copy_file(input_mail_tbl_data->file_path_plain, temp_file_path_plain, 0, &error)) { + EM_DEBUG_EXCEPTION("emstorage_copy_file failed : [%d]", error); + goto FINISH_OFF; + } + } + + if (input_mail_tbl_data->file_path_html) { + memset(temp_file_path_html, 0x00, sizeof(temp_file_path_html)); + SNPRINTF(temp_file_path_html, sizeof(temp_file_path_html), "%s%s%s%s%s", MAILHOME, DIR_SEPERATOR, MAILTEMP, DIR_SEPERATOR, "UTF-8.htm"); + + if (!emstorage_copy_file(input_mail_tbl_data->file_path_plain, temp_file_path_html, 0, &error)) { + EM_DEBUG_EXCEPTION("emstorage_copy_file failed : [%d]", error); + goto FINISH_OFF; + } + } + + if ((input_mail_tbl_data->attachment_count > 0) || (input_mail_tbl_data->file_path_plain && input_mail_tbl_data->file_path_html)) { + EM_DEBUG_LOG("attachment_num : %d", input_mail_tbl_data->attachment_count); + root_body = mail_newbody(); + + if (root_body == NULL) { + EM_DEBUG_EXCEPTION("mail_newbody failed..."); + error = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + root_body->type = TYPEMULTIPART; + root_body->subtype = EM_SAFE_STRDUP("MIXED"); + root_body->contents.text.data = NULL; + root_body->contents.text.size = 0; + root_body->size.bytes = 0; + + part_for_text = attach_mutipart_with_sub_type(root_body, "ALTERNATIVE", &error); + + if (!part_for_text) { + EM_DEBUG_EXCEPTION("attach_mutipart_with_sub_type [part_for_text] failed [%d]", error); + goto FINISH_OFF; + } + + text_body = &part_for_text->body; + + if (input_mail_tbl_data->file_path_plain && strlen(input_mail_tbl_data->file_path_plain) > 0) { + EM_DEBUG_LOG("file_path_plain[%s]", input_mail_tbl_data->file_path_plain); + if (!attach_part(text_body, (unsigned char *)temp_file_path_plain, 0, NULL, NULL, false, &error)) { + EM_DEBUG_EXCEPTION("attach_part failed [%d]", error); + goto FINISH_OFF; + } + } + + if (input_mail_tbl_data->file_path_html && strlen(input_mail_tbl_data->file_path_html) > 0) { + EM_DEBUG_LOG("file_path_html[%s]", input_mail_tbl_data->file_path_html); + + part_for_html = attach_mutipart_with_sub_type(text_body, "RELATED", &error); + if (!part_for_html) { + EM_DEBUG_EXCEPTION("attach_mutipart_with_sub_type [part_for_html] failed [%d]", error); + goto FINISH_OFF; + } + + if (!attach_part(&(part_for_html->body) , (unsigned char *)temp_file_path_html, 0, NULL, "html", false, &error)) { + EM_DEBUG_EXCEPTION("attach_part failed [%d]", error); + goto FINISH_OFF; + } + } + + if (input_attachment_tbl && input_attachment_count) { + email_attachment_data_t *temp_attachment_tbl = NULL; + char *name = NULL; + BODY *body_to_attach = NULL; + struct stat st_buf; + + for(i = 0; i < input_attachment_count; i++) { + temp_attachment_tbl = input_attachment_tbl + i; + EM_DEBUG_LOG("attachment_name[%s], attachment_path[%s]", temp_attachment_tbl->attachment_name, 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)) { + EM_DEBUG_EXCEPTION("emcore_get_file_name failed [%d]", error); + continue; + } + } + else + name = temp_attachment_tbl->attachment_name; + EM_DEBUG_LOG("name[%s]", name); + + if (temp_attachment_tbl->inline_content_status && part_for_html) + body_to_attach = &(part_for_html->body); + else + body_to_attach = root_body; + + if (!attach_part(body_to_attach, (unsigned char *)temp_attachment_tbl->attachment_path, 0, name, NULL, temp_attachment_tbl->inline_content_status, &error)) { + EM_DEBUG_EXCEPTION("attach_part failed [%d]", error); + continue; + } + } + } + } + text_body = NULL; + } else { + text_body = mail_newbody(); + + if (text_body == NULL) { + EM_DEBUG_EXCEPTION("mail_newbody failed..."); + + error = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + text_body->type = TYPETEXT; + text_body->encoding = ENC8BIT; + if (input_mail_tbl_data->file_path_plain || input_mail_tbl_data->file_path_html) + text_body->sparep = EM_SAFE_STRDUP(input_mail_tbl_data->file_path_plain ? temp_file_path_plain : temp_file_path_html); + else + text_body->sparep = NULL; + + if (input_mail_tbl_data->file_path_html != NULL && input_mail_tbl_data->file_path_html[0] != '\0') + text_body->subtype = EM_SAFE_STRDUP("html"); + if (text_body->sparep) + text_body->size.bytes = strlen(text_body->sparep); + else + text_body->size.bytes = 0; + } + + if (file_path) { + EM_DEBUG_LOG("write rfc822 : file_path[%s]", file_path); + + if (part_for_html) + html_body = &(part_for_html->body); + + if (!emcore_write_rfc822(envelope, root_body ? root_body : text_body, html_body, extra_flag, &fname, &error)) { + EM_DEBUG_EXCEPTION("emcore_write_rfc822 failed [%d]", error); + goto FINISH_OFF; + } + + *file_path = fname; + } + + if (strlen(temp_file_path_plain) > 0) { + if (!emstorage_delete_file(temp_file_path_plain, &error)) { + EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", error); + goto FINISH_OFF; + } + } + + if (strlen(temp_file_path_html) > 0) { + if (!emstorage_delete_file(temp_file_path_html, &error)) { + EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", error); + goto FINISH_OFF; + } + } + + ret = true; + +FINISH_OFF: + if (envelope != NULL) + mail_free_envelope(&envelope); + + if (text_body != NULL) + mail_free_body(&text_body); + + if (root_body != NULL) + mail_free_body(&root_body); + + if (err_code != NULL) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} + +#ifdef __FEATURE_SUPPORT_REPORT_MAIL__ static int emcore_get_report_mail_body(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); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; BODY *m_body = NULL; BODY *p_body = NULL; @@ -2772,13 +3200,13 @@ static int emcore_get_report_mail_body(ENVELOPE *envelope, BODY **multipart_body if (!envelope || !multipart_body) { EM_DEBUG_EXCEPTION(" envelope[%p], mulitpart_body[%p]", envelope, multipart_body); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!(text_body = mail_newbody())) { EM_DEBUG_EXCEPTION(" mail_newbody failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2789,7 +3217,7 @@ static int emcore_get_report_mail_body(ENVELOPE *envelope, BODY **multipart_body if (!(fp = fopen(fname, "wb+"))) { EM_DEBUG_EXCEPTION(" fopen failed - %s", fname); - err = EMF_ERROR_SYSTEM_FAILURE; + err = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -2799,7 +3227,7 @@ static int emcore_get_report_mail_body(ENVELOPE *envelope, BODY **multipart_body else EM_DEBUG_LOG(" envelope->from->mailbox[%p], envelope->from->host[%p]", envelope->from->mailbox, envelope->from->host); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2830,13 +3258,13 @@ static int emcore_get_report_mail_body(ENVELOPE *envelope, BODY **multipart_body if (!(fp = fopen(fname, "wb+"))) { EM_DEBUG_EXCEPTION(" fopen failed - %s", fname); - err = EMF_ERROR_SYSTEM_FAILURE; /* EMF_ERROR_UNKNOWN; */ + err = EMAIL_ERROR_SYSTEM_FAILURE; /* EMAIL_ERROR_UNKNOWN; */ goto FINISH_OFF; } if (!envelope->references) { EM_DEBUG_EXCEPTION(" envelope->references[%p]", envelope->references); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2871,7 +3299,7 @@ static int emcore_get_report_mail_body(ENVELOPE *envelope, BODY **multipart_body param = em_malloc(sizeof(PARAMETER)); if (!param) { EM_DEBUG_EXCEPTION(" malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2922,6 +3350,7 @@ FINISH_OFF: return ret; } +#endif INTERNAL_FUNC int emcore_get_body_buff(char *file_path, char **buff) { diff --git a/email-core/email-core-sound.c b/email-core/email-core-sound.c index 0f5be70..92ad070 100755 --- a/email-core/email-core-sound.c +++ b/email-core/email-core-sound.c @@ -22,6 +22,7 @@ #include #include + #include "email-debug-log.h" #include "email-storage.h" #include "email-core-utils.h" @@ -29,10 +30,10 @@ #include "email-core-sound.h" #include "email-utilities.h" -#define TIMER 7000 +#define TIMER 30000 // 30 seconds #define HAPTIC_TEST_ITERATION 1 -static MMHandleType email_mmhandle = MM_PLAYER_STATE_NONE; +static MMHandleType email_mmhandle = 0; static alarm_id_t email_alarm_id = 0; static int email_vibe_handle = 0; @@ -212,6 +213,11 @@ bool emcore_sound_mp_player_create() EM_DEBUG_FUNC_BEGIN(); int err = 0; + if (email_mmhandle) { + EM_DEBUG_LOG("already create the handle"); + return false; + } + if ((err = mm_player_create(&email_mmhandle)) != MM_ERROR_NONE) { EM_DEBUG_EXCEPTION("mm_player create fail [%d]", err); return false; @@ -276,11 +282,11 @@ bool emcore_alert_create() } /* Set the music file in alert */ - if (!emcore_set_mp_filepath(VCONFKEY_SETAPPL_NOTI_EMAIL_RINGTONE_PATH_STR)) - if (!emcore_set_mp_filepath(VCONFKEY_SETAPPL_DEFAULT_NOTI_EMAIL_RINGTONE_PATH_STR)) { - EM_DEBUG_EXCEPTION("emcore_set_mp_filepath failed."); - return false; - } + if (!emcore_set_mp_filepath(VCONFKEY_SETAPPL_NOTI_EMAIL_RINGTONE_PATH_STR)) { + /* TODO : Add code to set default ringtone path */ + EM_DEBUG_EXCEPTION("emcore_set_mp_filepath failed."); + return false; + } EM_DEBUG_FUNC_END(); return true; @@ -322,7 +328,7 @@ gboolean mp_player_timeout_cb(void *data) EM_DEBUG_FUNC_BEGIN(); ENTER_CRITICAL_SECTION(mmhandle_mutex); - if (email_mmhandle == MM_PLAYER_STATE_PLAYING) + if (email_mmhandle) { emcore_sound_mp_player_stop(); emcore_sound_mp_player_destory(); @@ -471,6 +477,8 @@ bool emcore_sound_mp_player_destory() return false; } + email_mmhandle = 0; + EM_DEBUG_FUNC_END(); return true; } @@ -552,20 +560,20 @@ int emcore_get_alert_type() } -INTERNAL_FUNC int emcore_start_alert_thread(int *err_code) +INTERNAL_FUNC int emcore_start_thread_for_alerting_new_mails(int *err_code) { EM_DEBUG_FUNC_BEGIN(); int thread_error; if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; if (g_alert_thread) { EM_DEBUG_EXCEPTION("Alert service is already running..."); if (err_code != NULL) - *err_code = EMF_ERROR_UNKNOWN; + *err_code = EMAIL_ERROR_UNKNOWN; return 1; } @@ -575,13 +583,13 @@ INTERNAL_FUNC int emcore_start_alert_thread(int *err_code) { EM_DEBUG_EXCEPTION("Cannot create alert thread"); if (err_code != NULL) - *err_code = EMF_ERROR_SYSTEM_FAILURE; + *err_code = EMAIL_ERROR_SYSTEM_FAILURE; return -1; } if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; return 0; } @@ -590,15 +598,15 @@ int emcore_alarm_timeout_cb(int timer_id, void *user_parm) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int total_unread_count = 0; int total_mail_count = 0; - emf_mailbox_t mailbox; + email_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); + memset(&mailbox, 0x00, sizeof(email_mailbox_t)); mailbox.account_id = ALL_ACCOUNT; - mailbox.name = NULL; + mailbox.mailbox_name = NULL; if (!emcore_get_mail_count(&mailbox, &total_mail_count, &total_unread_count, &err)) { EM_DEBUG_EXCEPTION("emcore_get_mail_count failed - %d\n", err); @@ -729,7 +737,10 @@ void *start_alert_thread(void *arg) switch (emcore_get_alert_type()) { case EMAIL_ALERT_TYPE_MELODY: - emcore_sound_mp_player_create(); + if (!emcore_sound_mp_player_create()) { + EM_DEBUG_LOG("emcore_sound_mp_player_create failed : [%d]", email_mmhandle); + break; + } emcore_sound_mp_player_start(filename); break; case EMAIL_ALERT_TYPE_VIB: @@ -739,7 +750,10 @@ void *start_alert_thread(void *arg) case EMAIL_ALERT_TYPE_MELODY_AND_VIB: emcore_vibration_create(); emcore_vibration_start(level); - emcore_sound_mp_player_create(); + if (!emcore_sound_mp_player_create()) { + EM_DEBUG_LOG("emcore_sound_mp_player_create failed : [%d]", email_mmhandle); + break; + } emcore_sound_mp_player_start(filename); break; case EMAIL_ALERT_TYPE_MUTE: @@ -751,7 +765,7 @@ void *start_alert_thread(void *arg) break; } LEAVE_CRITICAL_SECTION(sound_mutex); - + EM_DEBUG_LOG("Start FINISH"); emcore_alarm_destory(); } return 0; diff --git a/email-core/email-core-timer.c b/email-core/email-core-timer.c index 7b98a6d..641c7b5 100755 --- a/email-core/email-core-timer.c +++ b/email-core/email-core-timer.c @@ -37,7 +37,7 @@ typedef struct { - EMF_TIMER_CALLBACK user_callback_function; + EMAIL_TIMER_CALLBACK user_callback_function; void *callback_user_data; int time_id; }em_timer_callback_data; @@ -55,7 +55,7 @@ INTERNAL_FUNC int emcore_timer_ex_callback(void *a_pData) em_timer_callback_data *pTimerData = (em_timer_callback_data *)a_pData; if (pTimerData != NULL) { - EMF_TIMER_CALLBACK pfn_UserCB = pTimerData->user_callback_function; + EMAIL_TIMER_CALLBACK pfn_UserCB = pTimerData->user_callback_function; pUserData = pTimerData->callback_user_data; if (pUserData) EM_DEBUG_LOG("emcore_timer_ex_callback >>> data : %s", (char *)pTimerData->callback_user_data); @@ -75,7 +75,7 @@ INTERNAL_FUNC int emcore_timer_ex_callback(void *a_pData) return 1; } -INTERNAL_FUNC int emcore_set_timer_ex(long a_nSetTimeValue, EMF_TIMER_CALLBACK a_pCallBack, void *a_pData) +INTERNAL_FUNC int emcore_set_timer_ex(long a_nSetTimeValue, EMAIL_TIMER_CALLBACK a_pCallBack, void *a_pData) { EM_DEBUG_LOG("emcore_set_timer_ex %d", a_nSetTimeValue); em_timer_callback_data *pTimerData = NULL; diff --git a/email-core/email-core-utils.c b/email-core/email-core-utils.c index e62c74a..91fda52 100755 --- a/email-core/email-core-utils.c +++ b/email-core/email-core-utils.c @@ -77,6 +77,7 @@ #define EMAIL_CH_SQUARE_BRACKET_S '[' #define EMAIL_CH_SQUARE_BRACKET_E ']' #define EMAIL_CH_SPACE ' ' +#define EMAIL_NOTI_ICON_PATH "/opt/data/email/res/image/Q02_Notification_email.png" static char _g_display[G_DISPLAY_LENGTH]; @@ -90,7 +91,7 @@ typedef struct _em_transaction_info_type_t { em_transaction_info_type_t *g_transaction_info_list; -static emf_option_t g_mail_option = +static email_option_t g_mail_option = { 0, /* priority */ 1, /* keep_local_copy */ @@ -102,12 +103,12 @@ static emf_option_t g_mail_option = NULL, /* diplay name */ }; -static emf_session_t g_session_list[SESSION_MAX] = { {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0},}; +static email_session_t g_session_list[SESSION_MAX] = { {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0},}; typedef struct emcore_account_list_t emcore_account_list_t; struct emcore_account_list_t { - emf_account_t *account; + email_account_t *account; emcore_account_list_t *next; }; @@ -125,25 +126,25 @@ INTERNAL_FUNC int emcore_set_account_reference(emcore_account_list_t **account_l return 1; } -emf_option_t *emcore_get_option(int *err_code) +email_option_t *emcore_get_option(int *err_code) { if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; return &g_mail_option; } -INTERNAL_FUNC int emcore_set_option(emf_option_t *opt, int *err_code) +INTERNAL_FUNC int emcore_set_option(email_option_t *opt, int *err_code) { EM_DEBUG_FUNC_BEGIN("opt[%p], err_code[%p]", opt, err_code); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!opt) { EM_DEBUG_EXCEPTION("opt[%p]", opt); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -168,33 +169,33 @@ INTERNAL_FUNC int emcore_set_option(emf_option_t *opt, int *err_code) /* in smtp case, path argument must be ENCODED_PATH_SMTP */ -int emcore_get_long_encoded_path_with_account_info(emf_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code) +int emcore_get_long_encoded_path_with_account_info(email_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code) { EM_PROFILE_BEGIN(emCorelongEncodedpath); EM_DEBUG_FUNC_BEGIN("account[%p], path[%s], delimiter[%d], long_enc_path[%p], err_code[%p]", account, path, delimiter, long_enc_path, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char *p = NULL; size_t long_enc_path_len = 0; if (path == NULL || (path && strncmp(path, ENCODED_PATH_SMTP, strlen(ENCODED_PATH_SMTP)) != 0)) { /* imap or pop3 */ - EM_DEBUG_LOG("account->receiving_server_addr[%p]", account->receiving_server_addr); - EM_DEBUG_LOG("account->receiving_server_addr[%s]", account->receiving_server_addr); + EM_DEBUG_LOG("account->incoming_server_address[%p]", account->incoming_server_address); + EM_DEBUG_LOG("account->incoming_server_address[%s]", account->incoming_server_address); - if (!account->receiving_server_addr) { - EM_DEBUG_EXCEPTION("account->receiving_server_addr is null"); - error = EMF_ERROR_INVALID_ACCOUNT; + if (!account->incoming_server_address) { + EM_DEBUG_EXCEPTION("account->incoming_server_address is null"); + error = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - long_enc_path_len = strlen(account->receiving_server_addr) + (path ? strlen(path) : 0) + 64; + long_enc_path_len = strlen(account->incoming_server_address) + (path ? strlen(path) : 0) + 64; *long_enc_path = em_malloc(long_enc_path_len); if (!*long_enc_path) { EM_DEBUG_EXCEPTION("malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -203,36 +204,36 @@ int emcore_get_long_encoded_path_with_account_info(emf_account_t *account, char /* 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->receiving_server_addr, - account->port_num, - account->receiving_server_type == EMF_SERVER_TYPE_POP3 ? "pop3" : "imap", account->account_id); + account->incoming_server_address, + account->incoming_server_port_number, + account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 ? "pop3" : "imap", account->account_id); - if (account->use_security & 0x01) { + if (account->incoming_server_secure_connection & 0x01) { strncat(p, "/ssl", long_enc_path_len-(strlen(p)+1)); /* strcat(p, "/tryssl"); */ } /* Currently, receiving servers doesn't require tls. - if (account->use_security & 0x02) + if (account->incoming_server_secure_connection & 0x02) strncat(p, "/tls", long_enc_path_len-(strlen(p)+1)); else strncat(p, "/notls", long_enc_path_len-(strlen(p)+1)); */ - if (account->apop) { - EM_DEBUG_LOG("emcore_get_long_encoded_path - apop - %d", account->apop); + if (account->incoming_server_requires_apop) { + EM_DEBUG_LOG("emcore_get_long_encoded_path - incoming_server_requires_apop - %d", account->incoming_server_requires_apop); strncat(p, "/apop", long_enc_path_len-(strlen(p)+1)); EM_DEBUG_LOG("long_enc_path - %s", p); } } else { /* smtp */ - long_enc_path_len = strlen(account->sending_server_addr) + 64; + long_enc_path_len = strlen(account->outgoing_server_address) + 64; - *long_enc_path = em_malloc(strlen(account->sending_server_addr) + 64); + *long_enc_path = em_malloc(strlen(account->outgoing_server_address) + 64); if (!*long_enc_path) { EM_DEBUG_EXCEPTION("\t malloc failed...\n"); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -241,19 +242,19 @@ int emcore_get_long_encoded_path_with_account_info(emf_account_t *account, char /* ex:"mail.test.com:25/smtp" */ SNPRINTF(p, long_enc_path_len, "%s:%d/%s", - account->sending_server_addr, - account->sending_port_num, + account->outgoing_server_address, + account->outgoing_server_port_number, "smtp"); - if (account->sending_auth) { + if (account->outgoing_server_need_authentication) { SNPRINTF(p + strlen(p), long_enc_path_len-(strlen(p)), "/user=%d", account->account_id); } - if (account->sending_security & 0x01) { + if (account->outgoing_server_secure_connection & 0x01) { strncat(p, "/ssl", long_enc_path_len-(strlen(p)+1)); /* strcat(p, "/tryssl"); */ } - if (account->sending_security & 0x02) + if (account->outgoing_server_secure_connection & 0x02) strncat(p, "/tls", long_enc_path_len-(strlen(p)+1)); else strncat(p, "/notls", long_enc_path_len-(strlen(p)+1)); @@ -296,12 +297,12 @@ int emcore_get_long_encoded_path(int account_id, char *path, int delimiter, char EM_DEBUG_FUNC_BEGIN("account_id[%d], delimiter[%d], long_enc_path[%p], err_code[%p]", account_id, delimiter, long_enc_path, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; - emf_account_t *ref_account = emcore_get_account_reference(account_id); + email_account_t *ref_account = emcore_get_account_reference(account_id); if (!ref_account) { EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - error = EMF_ERROR_INVALID_ACCOUNT; + error = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } @@ -325,7 +326,7 @@ int emcore_get_encoded_mailbox_name(char *name, char **enc_name, int *err_code) if (!name || !enc_name) { if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; EM_DEBUG_FUNC_END(); return false; } @@ -336,7 +337,7 @@ int emcore_get_encoded_mailbox_name(char *name, char **enc_name, int *err_code) if (*enc_name == NULL) { EM_DEBUG_EXCEPTION("malloc failed..."); if (err_code != NULL) - *err_code = EMF_ERROR_OUT_OF_MEMORY; + *err_code = EMAIL_ERROR_OUT_OF_MEMORY; EM_DEBUG_FUNC_END(); return false; } @@ -344,7 +345,7 @@ int emcore_get_encoded_mailbox_name(char *name, char **enc_name, int *err_code) strcpy(*enc_name, name); if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; EM_DEBUG_FUNC_END(); return true; @@ -355,11 +356,11 @@ int emcore_get_temp_file_name(char **filename, int *err_code) EM_DEBUG_FUNC_BEGIN("filename[%p], err_code[%p]", filename, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (filename == NULL) { EM_DEBUG_EXCEPTION("\t filename[%p]\n", filename); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -378,7 +379,7 @@ int emcore_get_temp_file_name(char **filename, int *err_code) char *p = EM_SAFE_STRDUP(tempname); if (p == NULL) { EM_DEBUG_EXCEPTION("\t strdup failed...\n"); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -398,12 +399,12 @@ int emcore_get_file_name(char *path, char **filename, int *err_code) EM_DEBUG_FUNC_BEGIN("path[%s], filename[%p], err_code[%p]", path, filename, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (!path || !filename) { EM_DEBUG_EXCEPTION("path[%p], filename[%p]", path, filename); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -430,12 +431,12 @@ int emcore_get_file_size(char *path, int *size, int *err_code) EM_DEBUG_FUNC_BEGIN("path[%s], size[%p], err_code[%p]", path, size, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if ((path == NULL) || (size == NULL)) { EM_DEBUG_EXCEPTION("\t path[%p], size[%p]\n", path, size); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -444,7 +445,7 @@ int emcore_get_file_size(char *path, int *size, int *err_code) if (stat(path, &st_buf) < 0) { EM_DEBUG_EXCEPTION("\t stat failed - %s\n", path); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -475,7 +476,7 @@ int emcore_get_address_count(char *addr_str, int *count, int *err_code) EM_DEBUG_FUNC_BEGIN("addr_str[%s], count[%p], err_code[%p]", addr_str, count, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; ADDRESS *addr = NULL; ADDRESS *p_addr = NULL; @@ -485,7 +486,7 @@ int emcore_get_address_count(char *addr_str, int *count, int *err_code) if (!count) { EM_DEBUG_EXCEPTION("addr_str[%s], count[%p]", addr_str, count); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -510,14 +511,14 @@ int emcore_get_address_count(char *addr_str, int *count, int *err_code) if ((!p_addr->mailbox) || (_emcore_check_host(p_addr->host) == 0)) { EM_DEBUG_EXCEPTION("\t invalid address : mailbox[%s], host[%s]\n", p_addr->mailbox, p_addr->host); - error = EMF_ERROR_INVALID_ADDRESS; + error = EMAIL_ERROR_INVALID_ADDRESS; /* goto FINISH_OFF; */ } } } *count = i; - if (error != EMF_ERROR_INVALID_ADDRESS) + if (error != EMAIL_ERROR_INVALID_ADDRESS) ret = true; FINISH_OFF: @@ -532,7 +533,7 @@ FINISH_OFF: INTERNAL_FUNC int emcore_set_network_error(int err_code) { - emf_session_t *session = NULL; + email_session_t *session = NULL; EM_DEBUG_FUNC_BEGIN(); @@ -546,7 +547,7 @@ INTERNAL_FUNC int emcore_set_network_error(int err_code) return true; } -int emcore_get_empty_session(emf_session_t **session) +int emcore_get_empty_session(email_session_t **session) { EM_DEBUG_FUNC_BEGIN("session[%p]", session); @@ -556,7 +557,7 @@ int emcore_get_empty_session(emf_session_t **session) for (i = 0; i < SESSION_MAX; i++) { if (!g_session_list[i].status) { - memset(g_session_list+i, 0x00, sizeof(emf_session_t)); + memset(g_session_list+i, 0x00, sizeof(email_session_t)); g_session_list[i].tid = GPOINTER_TO_INT(THREAD_SELF()); g_session_list[i].status = true; break; @@ -571,17 +572,17 @@ int emcore_get_empty_session(emf_session_t **session) return (i != SESSION_MAX) ? true : false; } -int emcore_clear_session(emf_session_t *session) +int emcore_clear_session(email_session_t *session) { EM_DEBUG_FUNC_BEGIN(); if (session) - memset(session, 0x00, sizeof(emf_session_t)); + memset(session, 0x00, sizeof(email_session_t)); EM_DEBUG_FUNC_END(); return true; } -int emcore_get_current_session(emf_session_t **session) +int emcore_get_current_session(email_session_t **session) { EM_DEBUG_FUNC_BEGIN("session[%p]", session); @@ -607,16 +608,16 @@ int emcore_check_unread_mail() EM_DEBUG_FUNC_BEGIN(); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int total_unread_count = 0; int total_mail_count = 0; - emf_mailbox_t mailbox; + email_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); + memset(&mailbox, 0x00, sizeof(email_mailbox_t)); - /* ALL_ACCOUNT used, so not calling emstorage_get_mailboxname_by_mailbox_type to get mailbox name */ + /* ALL_ACCOUNT used, so not calling emstorage_get_mailbox_name_by_mailbox_type to get mailbox name */ mailbox.account_id = ALL_ACCOUNT; - mailbox.name = NULL; + mailbox.mailbox_name = NULL; if (!emcore_get_mail_count(&mailbox, &total_mail_count, &total_unread_count, &err)) { EM_DEBUG_EXCEPTION("emcore_get_mail_count failed [%d]", err); @@ -625,33 +626,32 @@ int emcore_check_unread_mail() EM_DEBUG_LOG("total_unread_count [%d]", total_unread_count); - /* set unread count to badge */ + /* temporarily disable : set unread count to badge */ + /* if ( vconf_set_int(VCONF_KEY_UNREAD_MAIL_COUNT, total_unread_count) != 0 ) { EM_DEBUG_EXCEPTION("vconf_set_int failed"); - err = EMF_ERROR_GCONF_FAILURE; + err = EMAIL_ERROR_GCONF_FAILURE; goto FINISH_OFF; } - EM_DEBUG_LOG("db/badge/com.samsung.email - set[%d]", total_unread_count); - + */ ret = true; FINISH_OFF: return ret; } -static int emcore_add_notification(int account_id, int mail_id, char *title, char *content, time_t log_time) +static int emcore_add_notification_for_user_message(int account_id, int mail_id, char *title, char *content, time_t log_time) { EM_DEBUG_FUNC_BEGIN(); int ret = true; -#ifdef __FEATURE_NOTIFICATION_FOR_NEW_MAIL__ - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; notification_h noti = NULL; notification_error_e noti_err = NOTIFICATION_ERROR_NONE; emstorage_account_tbl_t *account_tbl = NULL; - if (!emstorage_get_account_by_id(account_id, EMF_ACC_GET_OPT_ACCOUNT_NAME, &account_tbl, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed - %d", err); + if (!emstorage_get_account_by_id(account_id, EMAIL_ACC_GET_OPT_ACCOUNT_NAME, &account_tbl, true, &err)) { + EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err); goto FINISH_OFF; } @@ -667,7 +667,7 @@ static int emcore_add_notification(int account_id, int mail_id, char *title, cha goto FINISH_OFF; } - if( (noti_err = notification_set_text_domain(noti, NATIVE_EMAIL_APPLICATION_PKG, "/opt/apps/com.samsung.email/res/locale/")) != NOTIFICATION_ERROR_NONE) { + if( (noti_err = notification_set_text_domain(noti, NATIVE_EMAIL_APPLICATION_PKG, "/opt/apps/org.tizen.email/res/locale/")) != NOTIFICATION_ERROR_NONE) { EM_DEBUG_EXCEPTION("notification_set_text_domain failed [%d]", noti_err); goto FINISH_OFF; } @@ -681,17 +681,22 @@ static int emcore_add_notification(int account_id, int mail_id, char *title, cha EM_DEBUG_EXCEPTION("notification_set_content failed [%d]", noti_err); goto FINISH_OFF; } - - if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_GROUP_TITLE, account_tbl->account_name, NULL, NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) { + + if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_GROUP_TITLE, title, NULL, NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) { EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err); goto FINISH_OFF; } - if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_GROUP_CONTENT, "unread mails", NULL, NOTIFICATION_VARIABLE_TYPE_COUNT, NOTIFICATION_COUNT_DISPLAY_TYPE_LEFT, NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) { + if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_GROUP_CONTENT, content, NULL, NOTIFICATION_VARIABLE_TYPE_STRING, NOTIFICATION_COUNT_DISPLAY_TYPE_LEFT, NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) { EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err); 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); + goto FINISH_OFF; + } + if ((noti_err = notification_set_pkgname(noti, NATIVE_EMAIL_APPLICATION_PKG)) != NOTIFICATION_ERROR_NONE) { EM_DEBUG_EXCEPTION("notification_set_pkgname failed [%d]", noti_err); goto FINISH_OFF; @@ -701,11 +706,6 @@ static int emcore_add_notification(int account_id, int mail_id, char *title, cha EM_DEBUG_EXCEPTION("notification_set_application failed [%d]", noti_err); goto FINISH_OFF; } - /* Settig property to disable visibility of notification */ - if( (noti_err = notification_set_property(noti, NOTIFICATION_PROP_DISABLE_UPDATE_ON_INSERT)) != NOTIFICATION_ERROR_NONE) { - EM_DEBUG_EXCEPTION("notification_set_property failed [%d]", noti_err); - goto FINISH_OFF; - } if( (noti_err = notification_insert(noti, NULL)) != NOTIFICATION_ERROR_NONE) { EM_DEBUG_EXCEPTION("notification_insert failed [%d]", noti_err); @@ -719,12 +719,12 @@ FINISH_OFF: if (noti_err != NOTIFICATION_ERROR_NONE) ret = false; -#endif /* __FEATURE_NOTIFICATION_FOR_NEW_MAIL__ */ - EM_DEBUG_FUNC_END(); + + EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; } -int emcore_show_popup(int id, emf_action_t action, int error) +INTERNAL_FUNC int emcore_show_user_message(int id, email_action_t action, int error) { EM_DEBUG_FUNC_BEGIN("id[%d], action[%d], error[%d]", id, action, error); @@ -738,7 +738,7 @@ int emcore_show_popup(int id, emf_action_t action, int error) EM_DEBUG_LOG("sec[%d], min[%d], hour[%d], day[%d], month[%d], year[%d]" ,log_time_tm->tm_sec, log_time_tm->tm_min, log_time_tm->tm_hour, log_time_tm->tm_mday, log_time_tm->tm_mon, log_time_tm->tm_year); - if (action == EMF_ACTION_SEND_MAIL && error != EMF_ERROR_CANCELLED) { + if (action == EMAIL_ACTION_SEND_MAIL && error != EMAIL_ERROR_CANCELLED) { /* In case email is cancelled using cancel button in Outbox there is no need to show Cancel/Retry Pop up */ emstorage_mail_tbl_t *mail_table_data = NULL; @@ -755,7 +755,7 @@ int emcore_show_popup(int id, emf_action_t action, int error) return false; } - if (!emcore_add_notification(mail_table_data->account_id + 1000, id, "Failed to send mail", mail_table_data->subject, log_time)) { + if (!emcore_add_notification_for_user_message(mail_table_data->account_id, id, "Failed to send a mail.", mail_table_data->subject, log_time)) { EM_DEBUG_EXCEPTION("emcore_notification_set error"); return false; } @@ -765,7 +765,7 @@ int emcore_show_popup(int id, emf_action_t action, int error) ret = true; } - EM_DEBUG_FUNC_END(); + EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; } @@ -796,12 +796,12 @@ int emcore_is_storage_full(int *err_code) EM_DEBUG_FUNC_BEGIN(); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; struct statfs buf = {0}; if (statfs(DATA_PATH, &buf) == -1) { EM_DEBUG_EXCEPTION("statfs(\"%s\") failed - %d", DATA_PATH, errno); - err = EMF_ERROR_SYSTEM_FAILURE; + err = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } else { @@ -809,10 +809,10 @@ int emcore_is_storage_full(int *err_code) EM_DEBUG_LOG("f_bfree[%d] f_bsize[%d]", buf.f_bfree, buf.f_bsize); EM_DEBUG_LOG("Free space of storage is[%ld] MB.", i_free); if (i_free < EMAIL_LIMITATION_FREE_SPACE) - err = EMF_ERROR_MAIL_MEMORY_FULL; + err = EMAIL_ERROR_MAIL_MEMORY_FULL; } - if (err == EMF_ERROR_MAIL_MEMORY_FULL) + if (err == EMAIL_ERROR_MAIL_MEMORY_FULL) ret = true; FINISH_OFF: @@ -822,25 +822,25 @@ FINISH_OFF: return ret; } -int emcore_calc_mail_size(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, int *output_size) +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) { 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); struct stat st_buf; int mail_size = 0; /* size of the plain text body and attachments */ - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int i = 0; if (!input_mail_data || (input_attachment_count && !input_attachment_data_list) || (!input_attachment_count &&input_attachment_data_list) || !output_size) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (input_mail_data->file_path_plain != NULL) { if (stat(input_mail_data->file_path_plain, &st_buf) < 0) { EM_DEBUG_EXCEPTION("input_mail_data->file_path_plain : stat(\"%s\") failed...", input_mail_data->file_path_plain); - err = EMF_ERROR_INVALID_MAIL; + err = EMAIL_ERROR_INVALID_MAIL; goto FINISH_OFF; } @@ -851,7 +851,7 @@ int emcore_calc_mail_size(emf_mail_data_t *input_mail_data, emf_attachment_data_ if (input_mail_data->file_path_html != NULL) { if (stat(input_mail_data->file_path_html, &st_buf) < 0) { EM_DEBUG_EXCEPTION("input_mail_data->file_path_html : stat(\"%s\") failed...", input_mail_data->file_path_html); - err = EMF_ERROR_INVALID_MAIL; + err = EMAIL_ERROR_INVALID_MAIL; goto FINISH_OFF; } @@ -861,7 +861,7 @@ int emcore_calc_mail_size(emf_mail_data_t *input_mail_data, emf_attachment_data_ for(i = 0; i < input_attachment_count; i++) { if (stat(input_attachment_data_list[i].attachment_path, &st_buf) < 0) { EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_attachment_data_list[i].attachment_path); - err = EMF_ERROR_INVALID_MAIL; + err = EMAIL_ERROR_INVALID_MAIL; goto FINISH_OFF; } mail_size += st_buf.st_size; @@ -1018,7 +1018,7 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char * { 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 = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; unsigned int byte_read = 0; unsigned int byte_written = 0; int result_strlen = 0; @@ -1031,64 +1031,64 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char * struct stat st_buf; if (!output_preview_buffer) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } local_preview_buffer_length = input_preview_buffer_length * 2; if (input_html_path != NULL) { - /* get preview text from html file */ - if( (err = em_get_encoding_type_from_file_path(input_html_path, &encoding_type)) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%s]", err); - goto FINISH_OFF; - } - - if (stat(input_html_path, &st_buf) < 0) { - EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_html_path); - err = EMF_ERROR_INVALID_MAIL; - goto FINISH_OFF; - } - - if (!(fp = fopen(input_html_path, "r"))) { - EM_DEBUG_EXCEPTION("fopen failed [%s]", input_html_path); - err = EMF_ERROR_SYSTEM_FAILURE; - goto FINISH_OFF; - } - - if (!(local_preview_text = (char*)em_malloc(sizeof(char) * (st_buf.st_size + 1)))) { - EM_DEBUG_EXCEPTION("em_malloc failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - byte_read = fread(local_preview_text, sizeof(char), st_buf.st_size, fp); - - if (ferror(fp)) { - EM_DEBUG_EXCEPTION("fread failed [%s]", input_plain_path); - err = EMF_ERROR_SYSTEM_FAILURE; - goto FINISH_OFF; - } - - if ( (err = emcore_strip_HTML(local_preview_text)) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emcore_strip_HTML failed"); - goto FINISH_OFF; - } - - result_strlen = EM_SAFE_STRLEN(local_preview_text); + /* get preview text from html file */ + 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 [%s]", err); + goto FINISH_OFF; + } + + if (stat(input_html_path, &st_buf) < 0) { + EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_html_path); + err = EMAIL_ERROR_INVALID_MAIL; + goto FINISH_OFF; + } + + if (!(fp = fopen(input_html_path, "r"))) { + EM_DEBUG_EXCEPTION("fopen failed [%s]", input_html_path); + err = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; } + if (!(local_preview_text = (char*)em_malloc(sizeof(char) * (st_buf.st_size + 1)))) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + byte_read = fread(local_preview_text, sizeof(char), st_buf.st_size, fp); + + if (ferror(fp)) { + EM_DEBUG_EXCEPTION("fread failed [%s]", input_plain_path); + err = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } + + if ( (err = emcore_strip_HTML(local_preview_text)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emcore_strip failed"); + goto FINISH_OFF; + } + + result_strlen = EM_SAFE_STRLEN(local_preview_text); + } + if (local_preview_text == NULL && input_plain_path != NULL) { /* get preview text from plain text file */ - if( (err = em_get_encoding_type_from_file_path(input_plain_path, &encoding_type)) != EMF_ERROR_NONE) { + 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 [%s]", err); goto FINISH_OFF; } if (!(fp = fopen(input_plain_path, "r"))) { EM_DEBUG_EXCEPTION("fopen failed [%s]", input_plain_path); - err = EMF_ERROR_SYSTEM_FAILURE; + err = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -1101,10 +1101,15 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char * if (ferror(fp)) { EM_DEBUG_EXCEPTION("fread failed [%s]", input_plain_path); - err = EMF_ERROR_SYSTEM_FAILURE; + err = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } - result_strlen = byte_read; + + reg_replace(local_preview_text, CR_STRING, ""); + reg_replace(local_preview_text, LF_STRING, ""); + reg_replace(local_preview_text, TAB_STRING, ""); + + result_strlen = EM_SAFE_STRLEN(local_preview_text); } @@ -1123,7 +1128,7 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char * if (!(*output_preview_buffer = (char*)em_malloc(sizeof(char) * (result_strlen + 1)))) { EM_DEBUG_EXCEPTION("em_malloc failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -1148,7 +1153,7 @@ INTERNAL_FUNC int emcore_add_transaction_info(int mail_id, int handle , int *err EM_DEBUG_FUNC_BEGIN("mail_id[%d], handle[%d]", mail_id, handle); int ret = false; - int err = EMF_ERROR_NONE ; + int err = EMAIL_ERROR_NONE ; em_transaction_info_type_t *pTransinfo = NULL ; em_transaction_info_type_t *pTemp = NULL; @@ -1157,7 +1162,7 @@ INTERNAL_FUNC int emcore_add_transaction_info(int mail_id, int handle , int *err if (!(pTemp = em_malloc(sizeof(em_transaction_info_type_t)))) { EM_DEBUG_EXCEPTION("malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } pTemp->mail_id = mail_id ; @@ -1257,15 +1262,15 @@ INTERNAL_FUNC int emcore_delete_transaction_info_by_mailId(int mail_id ) int reg_replace (char *input_source_text, char *input_old_pattern_string, char *input_new_string) { EM_DEBUG_FUNC_BEGIN("input_source_text [%p], input_old_pattern_string [%p], input_new_string [%p]", input_source_text, input_old_pattern_string, input_new_string); - int error_code = EMF_ERROR_NONE; + int error_code = EMAIL_ERROR_NONE; char *pos = NULL; int so, n, nmatch, source_text_length, n_count = 1; regmatch_t *pmatch = NULL; regex_t reg_pattern; if(!input_source_text || !input_old_pattern_string || !input_new_string) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - error_code = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1278,16 +1283,16 @@ int reg_replace (char *input_source_text, char *input_old_pattern_string, char * EM_DEBUG_LOG("nmatch [%d]", nmatch); if(nmatch < 1) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_DATA"); - error_code = EMF_ERROR_INVALID_DATA; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_DATA"); + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } pmatch = (regmatch_t*)em_malloc(sizeof(regmatch_t) * nmatch); if(pmatch == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_OUT_OF_MEMORY"); - error_code = EMF_ERROR_OUT_OF_MEMORY; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY"); + error_code = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -1332,16 +1337,17 @@ int emcore_strip_HTML(char *source_string) { EM_DEBUG_FUNC_BEGIN("source_string [%p]", source_string); - int result = EMF_ERROR_NONE; + int result = EMAIL_ERROR_NONE; - reg_replace(source_string, CR_STRING, ""); - reg_replace(source_string, LF_STRING, ""); - reg_replace(source_string, TAB_STRING, ""); + reg_replace(source_string, CR_STRING, " "); + reg_replace(source_string, LF_STRING, " "); + reg_replace(source_string, TAB_STRING, " "); reg_replace(source_string, "]*>", ""); /* "<()*head([^>])*>", "" */ reg_replace(source_string, "<*/head>", ""); /* "(<()*(/)()*head()*>)", "" */ reg_replace(source_string, ".*", ""); /* "().*()", "" */ - reg_replace(source_string, "<*/p>", LF_STRING); + reg_replace(source_string, "<*/p>", " "); + reg_replace(source_string, "
", " "); /* "<[^>]*>", " */ reg_replace(source_string, "<[^>]*>", ""); @@ -1377,8 +1383,7 @@ int emcore_strip_HTML(char *source_string) /* " ", " */ reg_replace(source_string, " ", " "); - reg_replace(source_string, "\n\n", ""); - reg_replace(source_string, " ", ""); + reg_replace(source_string, " ", " "); EM_DEBUG_FUNC_END(); @@ -1387,26 +1392,26 @@ int emcore_strip_HTML(char *source_string) #define MAX_NOTI_STRING_LENGTH 8096 -INTERNAL_FUNC int emcore_convert_structure_to_string(void *struct_var, char **encoded_string, emf_convert_struct_type_e type) +INTERNAL_FUNC int emcore_convert_structure_to_string(void *struct_var, char **encoded_string, email_convert_struct_type_e type) { EM_DEBUG_FUNC_BEGIN("Struct type[%d]", type); char *buf = NULL; char delimiter[] = {0x01, 0x00}; - int error_code = EMF_ERROR_NONE; + int error_code = EMAIL_ERROR_NONE; buf = (char *) malloc(MAX_NOTI_STRING_LENGTH * sizeof(char)); if (NULL == buf) { - error_code = EMF_ERROR_OUT_OF_MEMORY; + error_code = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } switch (type) { - case EMF_CONVERT_STRUCT_TYPE_MAIL_LIST_ITEM: { - emf_mail_list_item_t *item = (emf_mail_list_item_t *)struct_var; + case EMAIL_CONVERT_STRUCT_TYPE_MAIL_LIST_ITEM: { + email_mail_list_item_t *item = (email_mail_list_item_t *)struct_var; SNPRINTF(buf, MAX_NOTI_STRING_LENGTH, "%d%c" /* int mail_id ; */ "%d%c" /* int account_id ; */ - "%s%c" /* char mailbox_name[STRING_LENGTH_FOR_DISPLAY] ; */ + "%d%c" /* int mailbox_id ; */ "%s%c" /* char from[STRING_LENGTH_FOR_DISPLAY] ; */ "%s%c" /* char from_email_address[MAX_EMAIL_ADDRESS_LENGTH]; */ "%s%c" /* char recipients[STRING_LENGTH_FOR_DISPLAY] ; */ @@ -1427,7 +1432,7 @@ INTERNAL_FUNC int emcore_convert_structure_to_string(void *struct_var, char **en item->mail_id, delimiter[0], item->account_id, delimiter[0], - item->mailbox_name, delimiter[0], + item->mailbox_id, delimiter[0], item->from, delimiter[0], item->from_email_address, delimiter[0], item->recipients, delimiter[0], @@ -1457,7 +1462,7 @@ FINISH_OFF: return error_code; } -INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, void **struct_var, emf_convert_struct_type_e type) +INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, void **struct_var, email_convert_struct_type_e type) { EM_DEBUG_FUNC_BEGIN(); @@ -1467,21 +1472,21 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, char *current_pos = NULL; char *found_pos = NULL; char delimiter[] = {0x01, 0x00}; - int error_code = EMF_ERROR_NONE; + int error_code = EMAIL_ERROR_NONE; EM_DEBUG_LOG("Struct Type[%d], String:[%s]", type, encoded_string); buff = (char *)EM_SAFE_STRDUP(encoded_string); if (NULL == buff) { - error_code = EMF_ERROR_OUT_OF_MEMORY; + error_code = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } switch (type) { - case EMF_CONVERT_STRUCT_TYPE_MAIL_LIST_ITEM: { - emf_mail_list_item_t *item = (emf_mail_list_item_t *)malloc(sizeof(emf_mail_list_item_t)); + case EMAIL_CONVERT_STRUCT_TYPE_MAIL_LIST_ITEM: { + email_mail_list_item_t *item = (email_mail_list_item_t *)malloc(sizeof(email_mail_list_item_t)); if (NULL == item) { - error_code = EMF_ERROR_OUT_OF_MEMORY; + error_code = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } temp_struct = (void *)item; @@ -1491,7 +1496,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* mail_id */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1502,7 +1507,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* account_id */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1510,21 +1515,21 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, EM_DEBUG_LOG("account_id[%d]", item->account_id); current_pos = found_pos + 1; - /* mailbox_name */ + /* mailbox_id */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; - strncpy(item->mailbox_name, current_pos, STRING_LENGTH_FOR_DISPLAY-1); - EM_DEBUG_LOG("mailbox_name[%s]", item->mailbox_name); + item->mailbox_id = atoi(current_pos); + EM_DEBUG_LOG("mailbox_id[%s]", item->mailbox_id); current_pos = found_pos + 1; /* from */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1535,7 +1540,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* from_email_address */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1546,7 +1551,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* recipients */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1557,7 +1562,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* subject */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1568,7 +1573,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* is_text_downloaded */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1579,7 +1584,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* datatime */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1590,7 +1595,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* flags_seen_field */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1601,7 +1606,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* priority */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1612,7 +1617,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* save_status */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1623,7 +1628,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* is_locked */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1634,7 +1639,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* is_report_mail */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1645,7 +1650,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* recipients_count */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1656,7 +1661,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* has_attachment */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1667,7 +1672,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* has_drm_attachment */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1678,7 +1683,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* previewBodyText */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1689,7 +1694,7 @@ INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, /* thread_id */ found_pos = strstr(current_pos, delimiter); if (NULL == found_pos) { - error_code = EMF_ERROR_INVALID_DATA; + error_code = EMAIL_ERROR_INVALID_DATA; goto FINISH_OFF; } *found_pos = NULL_CHAR; @@ -1719,7 +1724,7 @@ FINISH_OFF: } else { switch (type) { - case EMF_CONVERT_STRUCT_TYPE_MAIL_LIST_ITEM: + case EMAIL_CONVERT_STRUCT_TYPE_MAIL_LIST_ITEM: EM_SAFE_FREE(temp_struct); break; default: @@ -1741,11 +1746,11 @@ FINISH_OFF: INTERNAL_FUNC int emcore_send_noti_for_new_mail(int account_id, char *mailbox_name, char *subject, char *from, char *uid, char *datetime) { EM_DEBUG_FUNC_BEGIN("mailbox_name(%s) subject(%s), from(%s), uid(%s), datetime(%s)", mailbox_name, subject, from, uid, datetime); - int error_code = EMF_ERROR_NONE; + int error_code = EMAIL_ERROR_NONE; char *param_string = NULL; if (mailbox_name == NULL || subject == NULL || from == NULL || uid == NULL || datetime == NULL) { - error_code = EMF_ERROR_INVALID_PARAM; + error_code = EMAIL_ERROR_INVALID_PARAM; EM_DEBUG_EXCEPTION("Invalid parameter, mailbox_name(%p), subject(%p), from(%p), uid(%p), datetime(%p)", mailbox_name, subject, from, uid, datetime); goto FINISH_OFF; } @@ -1753,7 +1758,7 @@ INTERNAL_FUNC int emcore_send_noti_for_new_mail(int account_id, char *mailbox_na param_string = malloc(strlen(mailbox_name) + strlen(subject) + strlen(from) + strlen(uid) + strlen(datetime) + 5); if (param_string == NULL) { - error_code = EMF_ERROR_OUT_OF_MEMORY; + error_code = EMAIL_ERROR_OUT_OF_MEMORY; EM_DEBUG_EXCEPTION("Memory allocation for 'param_string' is failed"); goto FINISH_OFF; } @@ -1763,7 +1768,7 @@ INTERNAL_FUNC int emcore_send_noti_for_new_mail(int account_id, char *mailbox_na SNPRINTF(param_string, sizeof(param_string), "%s%c%s%c%s%c%s%c%s", mailbox_name, 0x01, subject, 0x01, from, 0x01, uid, 0x01, datetime); if (emstorage_notify_network_event(NOTI_DOWNLOAD_NEW_MAIL, account_id, param_string, 0, 0) == 0) { /* failed */ - error_code = EMF_ERROR_UNKNOWN; + error_code = EMAIL_ERROR_UNKNOWN; EM_DEBUG_EXCEPTION("emstorage_notify_network_event is failed"); goto FINISH_OFF; } @@ -1781,7 +1786,7 @@ FINISH_OFF: int emcore_update_notification_for_unread_mail(int account_id) { EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id); - int error_code = EMF_ERROR_NONE; + int error_code = EMAIL_ERROR_NONE; notification_error_e noti_err = NOTIFICATION_ERROR_NONE; if((noti_err = notification_update(NULL)) != NOTIFICATION_ERROR_NONE) { @@ -1798,26 +1803,29 @@ FINISH_OFF: INTERNAL_FUNC int emcore_finalize_sync(int account_id, int *error) { EM_DEBUG_FUNC_BEGIN("account_id [%d], error [%p]", account_id, error); - int err = EMF_ERROR_NONE, ret = true, result_sync_status = SYNC_STATUS_FINISHED; + int err = EMAIL_ERROR_NONE, ret = true, result_sync_status = SYNC_STATUS_FINISHED; emstorage_account_tbl_t *account_tbl = NULL; - if (!emstorage_update_sync_status_of_account(account_id, SET_TYPE_MINUS, SYNC_STATUS_SYNCING, true, &err)) - EM_DEBUG_EXCEPTION("emstorage_update_sync_status_of_account failed [%d]", err); + if ((err = emcore_update_sync_status_of_account(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(ALL_ACCOUNT, &result_sync_status, &err)) EM_DEBUG_EXCEPTION("emstorage_get_sync_status_of_account failed [%d]", err); - if ( result_sync_status == SYNC_STATUS_HAVE_NEW_MAILS) { + if (result_sync_status == SYNC_STATUS_HAVE_NEW_MAILS) { if (!emcore_update_notification_for_unread_mail(ALL_ACCOUNT)) EM_DEBUG_EXCEPTION("emcore_update_notification_for_unread_mail failed"); emcore_check_unread_mail(); /* Temp.. exception for EAS */ if(account_id >= FIRST_ACCOUNT_ID) - emstorage_get_account_by_id(account_id, EMF_ACC_GET_OPT_DEFAULT, &account_tbl, true, &err); - if(account_tbl && account_tbl->receiving_server_type != EMF_SERVER_TYPE_ACTIVE_SYNC) + emstorage_get_account_by_id(account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account_tbl, true, &err); + if(account_tbl && account_tbl->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) emcore_start_alert(); - } + if ((err = emcore_update_sync_status_of_account(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); + + } EM_DEBUG_FUNC_END(); return ret; } @@ -1826,7 +1834,7 @@ INTERNAL_FUNC int emcore_clear_all_notifications() { int account_count = 0, i; emstorage_account_tbl_t *account_list; - int error_code = EMF_ERROR_NONE; + int error_code = EMAIL_ERROR_NONE; if(!emstorage_get_account_list(&account_count, &account_list, true, false, &error_code)) { EM_DEBUG_EXCEPTION("emstorage_get_account_list failed"); @@ -1850,37 +1858,23 @@ INTERNAL_FUNC int emcore_add_notification_for_unread_mail(emstorage_mail_tbl_t * { EM_DEBUG_FUNC_BEGIN("input_mail_tbl_data[%p]", input_mail_tbl_data); - int error_code = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (input_mail_tbl_data == NULL) { EM_DEBUG_EXCEPTION("input_mail_tbl_data is NULL"); - error_code = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; + return EMAIL_ERROR_INVALID_PARAM; } - if (!emcore_add_notification(input_mail_tbl_data->account_id, input_mail_tbl_data->mail_id, input_mail_tbl_data->full_address_from, input_mail_tbl_data->subject, input_mail_tbl_data->date_time)) { - EM_DEBUG_EXCEPTION("emcore_add_notification failed"); - goto FINISH_OFF; - } -FINISH_OFF: - - EM_DEBUG_FUNC_END("return[%d]", error_code); - return error_code; + EM_DEBUG_FUNC_END("err[%d]", err); + return err; } INTERNAL_FUNC int emcore_delete_notification_for_read_mail(int mail_id) { EM_DEBUG_FUNC_BEGIN(); - int error_code = EMF_ERROR_NONE; -#ifdef __FEATURE_NOTIFICATION_FOR_NEW_MAIL__ - notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + int error_code = EMAIL_ERROR_NONE; - if ((noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, mail_id)) != NOTIFICATION_ERROR_NONE) { - error_code = noti_err; - EM_DEBUG_EXCEPTION("notification_delete_by_priv_id failed [%d]", noti_err); - } -#endif /* __FEATURE_NOTIFICATION_FOR_NEW_MAIL__ */ EM_DEBUG_FUNC_END(); return error_code; } @@ -1890,15 +1884,7 @@ INTERNAL_FUNC int emcore_delete_notification_for_read_mail(int mail_id) INTERNAL_FUNC int emcore_delete_notification_by_account(int account_id) { EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id); - int error_code = EMF_ERROR_NONE; -#ifdef __FEATURE_NOTIFICATION_FOR_NEW_MAIL__ - notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - - if ((noti_err = notification_delete_group_by_group_id(NATIVE_EMAIL_APPLICATION_PKG, NOTIFICATION_TYPE_NOTI, account_id)) != NOTIFICATION_ERROR_NONE) { - error_code = noti_err; - EM_DEBUG_EXCEPTION("notification_delete_by_priv_id failed [%d]", noti_err); - } -#endif /* __FEATURE_NOTIFICATION_FOR_NEW_MAIL__ */ + int error_code = EMAIL_ERROR_NONE; EM_DEBUG_FUNC_END(); return error_code; } @@ -1906,7 +1892,7 @@ INTERNAL_FUNC int emcore_delete_notification_by_account(int account_id) #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__ /** - * @fn emcore_convert_to_uid_range_set(emf_id_set_t* id_set, int id_set_count, emf_uid_range_set **uid_range_set, int range_len, int *err_code) + * @fn emcore_convert_to_uid_range_set(email_id_set_t* id_set, int id_set_count, email_uid_range_set **uid_range_set, int range_len, int *err_code) * Prepare a linked list of uid ranges with each node having a uid_range and lowest and highest uid in it. * *@author h.gahlaut@samsung.com @@ -1920,16 +1906,16 @@ INTERNAL_FUNC int emcore_delete_notification_by_account(int account_id) * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emcore_convert_to_uid_range_set(emf_id_set_t *id_set, int id_set_count, emf_uid_range_set **uid_range_set, int range_len, int *err_code) +INTERNAL_FUNC int emcore_convert_to_uid_range_set(email_id_set_t *id_set, int id_set_count, email_uid_range_set **uid_range_set, int range_len, int *err_code) { EM_DEBUG_FUNC_BEGIN(); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (NULL == id_set || id_set_count <= 0 || NULL == uid_range_set) { EM_DEBUG_EXCEPTION(" Invalid Parameter id_set[%p] id_set_count[%d] uid_range_set[%p]", id_set, id_set_count, uid_range_set); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -1939,11 +1925,11 @@ INTERNAL_FUNC int emcore_convert_to_uid_range_set(emf_id_set_t *id_set, int id_s unsigned long last_uid = 0; const int max_subset_string_size = MAX_SUBSET_STRING_SIZE; char subset_string[MAX_SUBSET_STRING_SIZE] = {0,}; - emf_uid_range_set *current_node = NULL; /* current_node denotes the current node under processing in the linked list of uid_range_set that is to be formed*/ + email_uid_range_set *current_node = NULL; /* current_node denotes the current node under processing in the linked list of uid_range_set that is to be formed*/ if (range_len < (max_subset_string_size + 1)) /* 1 for ending NULL character */ { EM_DEBUG_EXCEPTION(" Invalid Parameter range_len[%d]", range_len); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2023,7 +2009,7 @@ FINISH_OFF: } /** - * @fn emcore_append_subset_string_to_uid_range(char *subset_string, emf_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid) + * @fn emcore_append_subset_string_to_uid_range(char *subset_string, email_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid) * Appends the subset_string to uid range if the uid range has not exceeded maximum length(range_len), otherwise creates a new node in linked list of uid range set * and stores the subset_string in its uid_range. Also sets the lowest and highest uids for the corresponsing uid_range * @@ -2038,14 +2024,14 @@ FINISH_OFF: * @return This function returns true on success or false on failure. */ -int emcore_append_subset_string_to_uid_range(char *subset_string, emf_uid_range_set **current_node_adr, emf_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid) +int emcore_append_subset_string_to_uid_range(char *subset_string, email_uid_range_set **current_node_adr, email_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid) { EM_DEBUG_FUNC_BEGIN(); - emf_uid_range_set *current_node = NULL; + email_uid_range_set *current_node = NULL; if (NULL == (*uid_range_set)) { /*This happens only once when list creation starts. Head Node is allocated */ - current_node = (emf_uid_range_set *)em_malloc(sizeof(emf_uid_range_set)); + current_node = (email_uid_range_set *)em_malloc(sizeof(email_uid_range_set)); if (NULL == current_node) { EM_DEBUG_EXCEPTION("em_malloc failed"); return false; @@ -2081,9 +2067,9 @@ int emcore_append_subset_string_to_uid_range(char *subset_string, emf_uid_range_ else { /* No more space left in uid_range string.If continued on it, it will exceeded max size of range_len */ /* Allocate new node in Uid Range set */ - emf_uid_range_set *new_node = NULL; + email_uid_range_set *new_node = NULL; - new_node = (emf_uid_range_set *)em_malloc(sizeof(emf_uid_range_set)); + new_node = (email_uid_range_set *)em_malloc(sizeof(email_uid_range_set)); if (NULL == new_node) { EM_DEBUG_EXCEPTION("em_malloc failed"); @@ -2115,7 +2101,7 @@ int emcore_append_subset_string_to_uid_range(char *subset_string, emf_uid_range_ } /** - * void emcore_free_uid_range_set(emf_uid_range_set **uid_range_head) + * void emcore_free_uid_range_set(email_uid_range_set **uid_range_head) * Frees the linked list of uid ranges * * @author h.gahlaut@samsung.com @@ -2125,12 +2111,12 @@ int emcore_append_subset_string_to_uid_range(char *subset_string, emf_uid_range_ */ INTERNAL_FUNC -void emcore_free_uid_range_set(emf_uid_range_set **uid_range_set) +void emcore_free_uid_range_set(email_uid_range_set **uid_range_set) { EM_DEBUG_FUNC_BEGIN(); - emf_uid_range_set *current_node = NULL; - emf_uid_range_set *uid_range_head = NULL; + email_uid_range_set *current_node = NULL; + email_uid_range_set *uid_range_head = NULL; current_node = uid_range_head = (*uid_range_set); /* Make the current node and head ptr point to starting of uid_range_set */ @@ -2170,7 +2156,7 @@ INTERNAL_FUNC int emcore_form_comma_separated_strings(int numbers[], int num_cou { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int ret = false; char **string_list = NULL; @@ -2186,7 +2172,7 @@ INTERNAL_FUNC int emcore_form_comma_separated_strings(int numbers[], int num_cou max_string_len < (MAX_INTEGER_LENGTH + 2)|| NULL == strings || NULL == string_count) /* 32767, is the highest integer possible in string.This requires 7 bytes of storage in character type array (1 byte for ending NULL and 1 byte for ending comma) so max_string_len should not be less than worst case possible. */ { EM_DEBUG_EXCEPTION("Invalid Parameter numbers[%p] num_count [%d] max_string_len [%d] strings [%p] string_count[%p]", \ numbers, num_count, max_string_len, strings, string_count); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2313,13 +2299,13 @@ INTERNAL_FUNC void emcore_free_comma_separated_strings(char *** string_list, int 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) { EM_DEBUG_FUNC_BEGIN("source_file_name[%s], sub_type[%s], result_file_name_buffer_length[%d] ", source_file_name, sub_type, result_file_name_buffer_length); - int ret = false, err = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; char *extcheck = NULL; char attachment_file_name[MAX_PATH + 1] = { 0, }; if (!source_file_name || !result_file_name) { EM_DEBUG_EXCEPTION("Invalid Parameter"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2350,15 +2336,6 @@ FINISH_OFF: return ret; } - - - - - - - - - #ifdef __FEATURE_LOCAL_ACTIVITY__ INTERNAL_FUNC int emcore_add_activity(emstorage_activity_tbl_t *new_activity, int *err_code) { @@ -2368,11 +2345,11 @@ INTERNAL_FUNC int emcore_add_activity(emstorage_activity_tbl_t *new_activity, in /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!new_activity) { EM_DEBUG_LOG("\t new_activity[%p]\n", new_activity); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!emstorage_add_activity(new_activity, false, &err)) { @@ -2397,11 +2374,11 @@ INTERNAL_FUNC int emcore_delete_activity(emstorage_activity_tbl_t *activity, int /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!activity) { EM_DEBUG_LOG("\t new_activity[%p]\n", activity); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (!emstorage_delete_local_activity(activity, true, &err)) { @@ -2423,13 +2400,13 @@ INTERNAL_FUNC int emcore_get_next_activity_id(int *activity_id, int *err_code) EM_DEBUG_FUNC_BEGIN(); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (NULL == activity_id) { EM_DEBUG_EXCEPTION("\t activity_id[%p]", activity_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2452,5 +2429,17 @@ INTERNAL_FUNC int emcore_get_next_activity_id(int *activity_id, int *err_code) #endif /* __FEATURE_LOCAL_ACTIVITY__ */ +INTERNAL_FUNC void emcore_free_rule(email_rule_t* rule) +{ + EM_DEBUG_FUNC_BEGIN(); + + if (!rule) + return; + + EM_SAFE_FREE(rule->value); + + EM_DEBUG_FUNC_END(); +} + /* EOF */ diff --git a/email-core/email-network/email-network.c b/email-core/email-network/email-network.c index dc07731..b71ba96 100755 --- a/email-core/email-network/email-network.c +++ b/email-core/email-network/email-network.c @@ -65,19 +65,19 @@ static int _get_network_status(int *network_status) int value = 0; if(!network_status) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &value)) { EM_DEBUG_EXCEPTION("Failed vconf_get_int [VCONFKEY_NETWORK_STATUS]"); - return EMF_ERROR_SYSTEM_FAILURE; + return EMAIL_ERROR_SYSTEM_FAILURE; } *network_status = value; EM_DEBUG_FUNC_END("network_status [%d]", value); - return EMF_ERROR_NONE; + return EMAIL_ERROR_NONE; } /* Check code for SIM status */ @@ -87,19 +87,19 @@ static int _get_sim_status(int *sim_status) int value; if(!sim_status) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } if (vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &value) != 0) { EM_DEBUG_EXCEPTION("Failed vconf_get_int [VCONFKEY_TELEPHONY_SIM_SLOT]"); - return EMF_ERROR_SYSTEM_FAILURE; + return EMAIL_ERROR_SYSTEM_FAILURE; } *sim_status = value; EM_DEBUG_FUNC_END("status[%d]", value); - return EMF_ERROR_NONE; + return EMAIL_ERROR_NONE; } static int _get_wifi_status(int *wifi_status) @@ -109,19 +109,19 @@ static int _get_wifi_status(int *wifi_status) int value; if(!wifi_status) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } if (vconf_get_int(VCONFKEY_WIFI_STATE, &value) != 0) { EM_DEBUG_EXCEPTION("vconf_get_int failed"); - return EMF_ERROR_SYSTEM_FAILURE; + return EMAIL_ERROR_SYSTEM_FAILURE; } *wifi_status = value; EM_DEBUG_FUNC_END("status[%d]", *wifi_status); - return EMF_ERROR_NONE; + return EMAIL_ERROR_NONE; } @@ -131,35 +131,35 @@ INTERNAL_FUNC int emnetwork_check_network_status(int *err_code) int network_status = 0; int sim_status = VCONFKEY_TELEPHONY_SIM_UNKNOWN; int wifi_status = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int ret = false; - if ( (err = _get_network_status(&network_status)) != EMF_ERROR_NONE) { + if ( (err = _get_network_status(&network_status)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("_get_network_status failed [%d]", err); goto FINISH_OFF; } if(network_status == 0) { - if ( (err = _get_sim_status(&sim_status)) != EMF_ERROR_NONE) { + if ( (err = _get_sim_status(&sim_status)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("_get_sim_status failed [%d]", err); goto FINISH_OFF; } if (sim_status != VCONFKEY_TELEPHONY_SIM_INSERTED) { - EM_DEBUG_LOG("EMF_ERROR_NO_SIM_INSERTED"); - if ( (err = _get_wifi_status(&wifi_status)) != EMF_ERROR_NONE) { + EM_DEBUG_LOG("EMAIL_ERROR_NO_SIM_INSERTED"); + if ( (err = _get_wifi_status(&wifi_status)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("_get_wifi_status failed [%d]", err); goto FINISH_OFF; } if (wifi_status == 0) { EM_DEBUG_EXCEPTION("Furthermore, WIFI is off"); - err = EMF_ERROR_NO_SIM_INSERTED; + err = EMAIL_ERROR_NO_SIM_INSERTED; goto FINISH_OFF; } } - EM_DEBUG_EXCEPTION("EMF_ERROR_NETWORK_NOT_AVAILABLE"); - err = EMF_ERROR_NETWORK_NOT_AVAILABLE; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_NETWORK_NOT_AVAILABLE"); + err = EMAIL_ERROR_NETWORK_NOT_AVAILABLE; goto FINISH_OFF; } @@ -263,7 +263,7 @@ INTERNAL_FUNC long tcp_getbuffer_lnx(TCPSTREAM *stream, unsigned long size, char else if (!sret) { if (max_timeout >= 5) { EM_DEBUG_EXCEPTION("max select timeout %d", max_timeout); - emcore_set_network_error(EMF_ERROR_NO_RESPONSE); + emcore_set_network_error(EMAIL_ERROR_NO_RESPONSE); return 0; } EM_DEBUG_EXCEPTION("%d select timeout", max_timeout); @@ -351,7 +351,7 @@ long tcp_getdata_lnx(TCPSTREAM *stream) if (max_timeout >= 50) { EM_DEBUG_EXCEPTION("max select timeout %d", max_timeout); - emcore_set_network_error(EMF_ERROR_NO_RESPONSE); + emcore_set_network_error(EMAIL_ERROR_NO_RESPONSE); return false; } @@ -364,7 +364,7 @@ long tcp_getdata_lnx(TCPSTREAM *stream) if ((nread = read(sockid, stream->ibuf, BUFLEN)) < 0) { EM_DEBUG_EXCEPTION("socket read failed..."); - emcore_set_network_error(EMF_ERROR_SOCKET_FAILURE); + emcore_set_network_error(EMAIL_ERROR_SOCKET_FAILURE); /* if (errno == EINTR) contine; */ tcp_abort(stream); @@ -374,7 +374,7 @@ long tcp_getdata_lnx(TCPSTREAM *stream) if (!nread) { EM_DEBUG_EXCEPTION("socket read no data..."); - emcore_set_network_error(EMF_ERROR_INVALID_RESPONSE); + emcore_set_network_error(EMAIL_ERROR_INVALID_RESPONSE); tcp_abort(stream); return false; @@ -440,7 +440,7 @@ INTERNAL_FUNC long tcp_sout_lnx(TCPSTREAM *stream, char *string, unsigned long s else if (!sret) { if (max_timeout >= 50) { EM_DEBUG_EXCEPTION("max select timeout %d", max_timeout); - emcore_set_network_error(EMF_ERROR_NO_RESPONSE); + emcore_set_network_error(EMAIL_ERROR_NO_RESPONSE); return 0; } EM_DEBUG_EXCEPTION("%d select timeout", max_timeout); diff --git a/email-core/email-storage/email-storage.c b/email-core/email-storage/email-storage.c index 89b4072..cbf7fb6 100755 --- a/email-core/email-storage/email-storage.c +++ b/email-core/email-storage/email-storage.c @@ -67,8 +67,9 @@ #define SETTING_MEMORY_TEMP_FILE_PATH "/tmp/email_tmp_file" -#define EMF_STORAGE_CHANGE_NOTI "User.Email.StorageChange" -#define EMF_NETOWRK_CHANGE_NOTI "User.Email.NetworkStatus" +#define EMAIL_STORAGE_CHANGE_NOTI "User.Email.StorageChange" +#define EMAIL_NETOWRK_CHANGE_NOTI "User.Email.NetworkStatus" +#define EMAIL_RESPONSE_TO_API_NOTI "User.Email.ResponseToAPI" #define CONTENT_DATA "data = 0; @@ -375,31 +385,31 @@ INTERNAL_FUNC int emstorage_shm_file_init(const char *shm_file_name) pthread_mutexattr_t mattr; pthread_mutexattr_init(&mattr); pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED); - pthread_mutexattr_setrobust_np(&mattr, PTHREAD_MUTEX_ROBUST_NP); + pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP); pthread_mutex_init(&(m->mutex), &mattr); pthread_mutexattr_destroy(&mattr); } else { EM_DEBUG_EXCEPTION("shm_open failed: %s", strerror(errno)); - return EMF_ERROR_SYSTEM_FAILURE; + return EMAIL_ERROR_SYSTEM_FAILURE; } close(fd); EM_DEBUG_FUNC_END(); - return EMF_ERROR_NONE; + return EMAIL_ERROR_NONE; } int emstorage_shm_file_destroy(const char *shm_file_name) { EM_DEBUG_FUNC_BEGIN("shm_file_name [%p]", shm_file_name); if(!shm_file_name) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } if (shm_unlink(shm_file_name) != 0) EM_DEBUG_EXCEPTION("shm_unlink failed: %s", strerror(errno)); EM_DEBUG_FUNC_END(); - return EMF_ERROR_NONE; + return EMAIL_ERROR_NONE; } static int _initialize_shm_mutex(const char *shm_file_name, int *param_shm_fd, mmapped_t **param_mapped) @@ -407,8 +417,8 @@ static int _initialize_shm_mutex(const char *shm_file_name, int *param_shm_fd, m EM_DEBUG_FUNC_BEGIN("shm_file_name [%p] param_shm_fd [%p], param_mapped [%p]", shm_file_name, param_shm_fd, param_mapped); if(!shm_file_name || !param_shm_fd || !param_mapped) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } if (!(*param_mapped)) { @@ -418,20 +428,20 @@ static int _initialize_shm_mutex(const char *shm_file_name, int *param_shm_fd, m *param_shm_fd = shm_open(shm_file_name, O_RDWR, 0); if ((*param_shm_fd) == -1) { EM_DEBUG_EXCEPTION("FAIL: shm_open(): %s", strerror(errno)); - return EMF_ERROR_SYSTEM_FAILURE; + 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", strerror(errno)); - return EMF_ERROR_SYSTEM_FAILURE; + return EMAIL_ERROR_SYSTEM_FAILURE; } *param_mapped = tmp; } EM_DEBUG_FUNC_END(); - return EMF_ERROR_NONE; + return EMAIL_ERROR_NONE; } static int _timedlock_shm_mutex(mmapped_t **param_mapped, int sec) @@ -439,8 +449,8 @@ static int _timedlock_shm_mutex(mmapped_t **param_mapped, int sec) EM_DEBUG_FUNC_BEGIN("param_mapped [%p], sec [%d]", param_mapped, sec); if(!param_mapped) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } struct timespec abs_time; @@ -450,7 +460,7 @@ static int _timedlock_shm_mutex(mmapped_t **param_mapped, int sec) int err = pthread_mutex_timedlock(&((*param_mapped)->mutex), &abs_time); if (err == EOWNERDEAD) { - err = pthread_mutex_consistent_np(&((*param_mapped)->mutex)); + err = pthread_mutex_consistent(&((*param_mapped)->mutex)); EM_DEBUG_EXCEPTION("Previous owner is dead with lock. Fix mutex : %s", EM_STRERROR(err)); } else if (err != 0) { @@ -459,7 +469,7 @@ static int _timedlock_shm_mutex(mmapped_t **param_mapped, int sec) } EM_DEBUG_FUNC_END(); - return EMF_ERROR_NONE; + return EMAIL_ERROR_NONE; } void _unlockshm_mutex(mmapped_t **param_mapped) @@ -477,13 +487,16 @@ static int g_transaction = false; static int _get_password_file_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__ +static int _get_cert_password_file_name(int index, char *cert_password_file_name); +#endif typedef struct { const char *object_name; unsigned int data_flag; -} emf_db_object_t; +} email_db_object_t; -static const emf_db_object_t _g_db_tables[] = +static const email_db_object_t _g_db_tables[] = { { "mail_read_mail_uid_tbl", 1}, { "mail_tbl", 1}, @@ -491,7 +504,7 @@ static const emf_db_object_t _g_db_tables[] = { NULL, 0}, }; -static const emf_db_object_t _g_db_indexes[] = +static const email_db_object_t _g_db_indexes[] = { { "mail_read_mail_uid_idx1", 1}, { "mail_idx1", 1}, @@ -514,6 +527,7 @@ enum #ifdef __FEATURE_LOCAL_ACTIVITY__ CREATE_TABLE_MAIL_LOCAL_ACTIVITY_TBL, #endif + CREATE_TABLE_MAIL_CERTIFICATE_TBL, CREATE_TABLE_MAX, }; @@ -524,56 +538,19 @@ enum FLAG_IDX_IN_MAIL_ACTIVITY_TBL, }; - -enum +enum { - ACCOUNT_BIND_TYPE_IDX_IN_MAIL_ACCOUNT_TBL = 0, - ACCOUNT_NAME_IDX_IN_MAIL_ACCOUNT_TBL, - RECEIVING_SERVER_TYPE_TYPE_IDX_IN_MAIL_ACCOUNT_TBL, - RECEIVING_SERVER_ADDR_IDX_IN_MAIL_ACCOUNT_TBL, - EMAIL_ADDR_IDX_IN_MAIL_ACCOUNT_TBL, - USER_NAME_IDX_IN_MAIL_ACCOUNT_TBL, - PASSWORD_IDX_IN_MAIL_ACCOUNT_TBL, - RETRIEVAL_MODE_IDX_IN_MAIL_ACCOUNT_TBL, - PORT_NUM_IDX_IN_MAIL_ACCOUNT_TBL, - USE_SECURITY_IDX_IN_MAIL_ACCOUNT_TBL, - SENDING_SERVER_TYPE_IDX_IN_MAIL_ACCOUNT_TBL, - SENDING_SERVER_ADDR_IDX_IN_MAIL_ACCOUNT_TBL, - SENDING_PORT_NUM_IDX_IN_MAIL_ACCOUNT_TBL, - SENDING_AUTH_IDX_IN_MAIL_ACCOUNT_TBL, - SENDING_SECURITY_IDX_IN_MAIL_ACCOUNT_TBL, - SENDING_USER_IDX_IN_MAIL_ACCOUNT_TBL, - SENDING_PASSWORD_IDX_IN_MAIL_ACCOUNT_TBL, - DISPLAY_NAME_IDX_IN_MAIL_ACCOUNT_TBL, - REPLY_TO_ADDR_IDX_IN_MAIL_ACCOUNT_TBL, - RETURN_ADDR_IDX_IN_MAIL_ACCOUNT_TBL, - ACCOUNT_ID_IDX_IN_MAIL_ACCOUNT_TBL, - KEEP_ON_SERVER_IDX_IN_MAIL_ACCOUNT_TBL, - FLAG1_IDX_IN_MAIL_ACCOUNT_TBL, - FLAG2_IDX_IN_MAIL_ACCOUNT_TBL, - POP_BEFORE_SMTP_IDX_IN_MAIL_ACCOUNT_TBL, - APOP_IDX_IN_MAIL_ACCOUNT_TBL, - LOGO_ICON_PATH_IDX_IN_MAIL_ACCOUNT_TBL, - PRESET_ACCOUNT_IDX_IN_MAIL_ACCOUNT_TBL, - TARGET_STORAGE_IDX_IN_MAIL_ACCOUNT_TBL, - CHECK_INTERVAL_IDX_IN_MAIL_ACCOUNT_TBL, - PRIORITY_IDX_IN_MAIL_ACCOUNT_TBL, - KEEP_LOCAL_COPY_IDX_IN_MAIL_ACCOUNT_TBL, - REQ_DELIVERY_RECEIPT_IDX_IN_MAIL_ACCOUNT_TBL, - REQ_READ_RECEIPT_IDX_IN_MAIL_ACCOUNT_TBL, - DOWNLOAD_LIMIT_IDX_IN_MAIL_ACCOUNT_TBL, - BLOCK_ADDRESS_IDX_IN_MAIL_ACCOUNT_TBL, - BLOCK_SUBJECT_IDX_IN_MAIL_ACCOUNT_TBL, - DISPLAY_NAME_FROM_IDX_IN_MAIL_ACCOUNT_TBL, - REPLY_WITH_BODY_IDX_IN_MAIL_ACCOUNT_TBL, - FORWARD_WITH_FILES_IDX_IN_MAIL_ACCOUNT_TBL, - ADD_MYNAME_CARD_IDX_IN_MAIL_ACCOUNT_TBL, - ADD_SIGNATURE_IDX_IN_MAIL_ACCOUNT_TBL, - SIGNATURE_IDX_IN_MAIL_ACCOUNT_TBL, - ADD_MY_ADDRESS_TO_BCC_IDX_IN_MAIL_ACCOUNT_TBL, - MY_ACCOUNT_ID_IDX_IN_MAIL_ACCOUNT_TBL, - INDEX_COLOR_IDX_IN_MAIL_ACCOUNT_TBL, - SYNC_STATUS_IDX_IN_MAIL_ACCOUNT_TBL, + CERTFICATE_BIND_TYPE_IDX_IN_MAIL_CERTIFICATE_TBL = 0, + ISSUE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL, + ISSUE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL, + ISSUE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL, + EXPIRE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL, + EXPIRE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL, + EXPIRE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL, + ISSUE_ORGANIZATION_IDX_IN_MAIL_CERTIFICATE_TBL, + EMAIL_ADDRESS_IDX_IN_MAIL_CERTIFICATE_TBL, + SUBJECT_STRING_IDX_IN_MAIL_CERTIFICATE_TBL, + FILE_PATH_IDX_IN_MAIL_CERTIFICATE_TBL, }; enum @@ -599,7 +576,7 @@ enum enum { ACCOUNT_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL = 0, - LOCAL_MBOX_IDX_IN_MAIL_READ_MAIL_UID_TBL, + LOCAL_MAILBOX_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL, LOCAL_UID_IDX_IN_MAIL_READ_MAIL_UID_TBL, MAILBOX_NAME_IDX_IN_MAIL_READ_MAIL_UID_TBL, S_UID_IDX_IN_MAIL_READ_MAIL_UID_TBL, @@ -616,7 +593,7 @@ enum TYPE_IDX_IN_MAIL_RULE_TBL, VALUE_IDX_IN_MAIL_RULE_TBL, ACTION_TYPE_IDX_IN_MAIL_RULE_TBL, - DEST_MAILBOX_IDX_IN_MAIL_RULE_TBL, + TARGET_MAILBOX_ID_IDX_IN_MAIL_RULE_TBL, FLAG1_IDX_IN_MAIL_RULE_TBL, FLAG2_IDX_IN_MAIL_RULE_TBL, }; @@ -647,6 +624,7 @@ enum BODY_DOWNLOAD_STATUS_IDX_IN_MAIL_TBL, FILE_PATH_PLAIN_IDX_IN_MAIL_TBL, FILE_PATH_HTML_IDX_IN_MAIL_TBL, + FILE_PATH_MIME_ENTITY_IDX_IN_MAIL_TBL, MAIL_SIZE_IDX_IN_MAIL_TBL, FLAGS_SEEN_FIELD_IDX_IN_MAIL_TBL, FLAGS_DELETED_FIELD_IDX_IN_MAIL_TBL, @@ -666,7 +644,10 @@ enum THREAD_ITEM_COUNT_IDX_IN_MAIL_TBL, PREVIEW_TEXT_IDX_IN_MAIL_TBL, MEETING_REQUEST_STATUS_IDX_IN_MAIL_TBL, - FIELD_COUNT_OF_EMF_MAIL_TBL, /* End of mail_tbl */ + MESSAGE_CLASS_IDX_IN_MAIL_TBL, + DIGEST_TYPE_IDX_IN_MAIL_TBL, + SMIME_TYPE_IDX_IN_MAIL_TBL, + FIELD_COUNT_OF_MAIL_TBL, /* End of mail_tbl */ }; enum @@ -677,7 +658,7 @@ enum ATTACHMENT_SIZE_IDX_IN_MAIL_ATTACHMENT_TBL, MAIL_ID_IDX_IN_MAIL_ATTACHMENT_TBL, ACCOUNT_ID_IDX_IN_MAIL_ATTACHMENT_TBL, - MAILBOX_NAME_IDX_IN_MAIL_ATTACHMENT_TBL, + MAILBOX_ID_IDX_IN_MAIL_ATTACHMENT_TBL, ATTACHMENT_SAVE_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL, ATTACHMENT_DRM_TYPE_IDX_IN_MAIL_ATTACHMENT_TBL, ATTACHMENT_DRM_METHOD_IDX_IN_MAIL_ATTACHMENT_TBL, @@ -716,35 +697,33 @@ typedef struct _em_mail_id_list { static char *g_test_query[] = { /* 1. select mail_account_tbl */ "SELECT" - " account_bind_type, " " account_name, " - " receiving_server_type, " - " receiving_server_addr, " - " email_addr, " - " user_name, " - " password, " + " incoming_server_type, " + " incoming_server_address, " + " user_email_address, " + " incoming_server_user_name, " + " incoming_server_password, " " retrieval_mode, " - " port_num, " - " use_security, " - " sending_server_type, " - " sending_server_addr, " - " sending_port_num, " - " sending_auth, " - " sending_security, " - " sending_user, " - " sending_password, " + " incoming_server_port_number, " + " incoming_server_secure_connection, " + " outgoing_server_type, " + " outgoing_server_address, " + " outgoing_server_port_number, " + " outgoing_server_need_authentication, " + " outgoing_server_secure_connection, " + " outgoing_server_user_name, " + " outgoing_server_password, " " display_name, " " reply_to_addr, " " return_addr, " " account_id, " - " keep_on_server, " + " keep_mails_on_pop_server_after_download, " " flag1, " " flag2, " " pop_before_smtp, " - " apop" + " incoming_server_requires_apop" ", logo_icon_path, " - " preset_account, " - " target_storage, " + " is_preset_account, " " check_interval, " " priority, " " keep_local_copy, " @@ -760,9 +739,14 @@ static char *g_test_query[] = { " add_signature, " " signature" ", add_my_address_to_bcc" - ", my_account_id " + ", account_svc_id " ", index_color " ", sync_status " + ", sync_disabled " + ", smime_type" + ", certificate_path" + ", cipher_type" + ", digest_type" " FROM mail_account_tbl", /* 2. select mail_box_tbl */ "SELECT " @@ -777,11 +761,12 @@ static char *g_test_query[] = { " total_mail_count_on_server, " " has_archived_mails, " " mail_slot_size " + " last_sync_time " " FROM mail_box_tbl ", /* 3. select mail_read_mail_uid_tbl */ "SELECT " " account_id, " - " local_mbox, " + " mailbox_id, " " local_uid, " " mailbox_name, " " s_uid, " @@ -797,7 +782,7 @@ static char *g_test_query[] = { " type, " " value, " " action_type, " - " dest_mailbox, " + " target_mailbox_id, " " flag1, " " flag2 " " FROM mail_rule_tbl ", @@ -827,6 +812,7 @@ static char *g_test_query[] = { " body_download_status, " " file_path_plain, " " file_path_html, " + " file_path_mime_entity, " " mail_size, " " flags_seen_field ," " flags_deleted_field ," @@ -844,8 +830,11 @@ static char *g_test_query[] = { " inline_content_count, " " thread_id, " " thread_item_count, " - " preview_text" + " preview_text, " " meeting_request_status, " + " message_class, " + " digest_type, " + " smime_type " " FROM mail_tbl", /* 6. select mail_attachment_tbl */ "SELECT " @@ -855,7 +844,7 @@ static char *g_test_query[] = { " attachment_size, " " mail_id, " " account_id, " - " mailbox_name, " + " mailbox_id, " " attachment_save_status, " " attachment_drm_type, " " attachment_drm_method, " @@ -870,6 +859,7 @@ static char *g_test_query[] = { " server_mail_id, " " activity_id, " " activity_type, " + " mailbox_id, " " mailbox_name " " FROM mail_partial_body_activity_tbl ", #endif @@ -877,7 +867,7 @@ static char *g_test_query[] = { "SELECT " " mail_id, " " account_id, " - " mailbox_name, " + " mailbox_id, " " meeting_response, " " start_time, " " end_time, " @@ -910,8 +900,9 @@ static char *g_test_query[] = { /* ----------- Notification Changes ----------- */ typedef enum { - _NOTI_TYPE_STORAGE, - _NOTI_TYPE_NETWORK + _NOTI_TYPE_STORAGE = 0, + _NOTI_TYPE_NETWORK = 1, + _NOTI_TYPE_RESPONSE_TO_API = 2, } enotitype_t; @@ -938,7 +929,7 @@ INTERNAL_FUNC int emstorage_send_noti(enotitype_t notiType, int subType, int dat } if (notiType == _NOTI_TYPE_STORAGE) { - signal = dbus_message_new_signal("/User/Email/StorageChange", EMF_STORAGE_CHANGE_NOTI, "email"); + signal = dbus_message_new_signal("/User/Email/StorageChange", EMAIL_STORAGE_CHANGE_NOTI, "email"); if (signal == NULL) { EM_DEBUG_EXCEPTION("dbus_message_new_signal is failed"); @@ -956,7 +947,7 @@ INTERNAL_FUNC int emstorage_send_noti(enotitype_t notiType, int subType, int dat dbus_message_append_args(signal, DBUS_TYPE_INT32, &data4, DBUS_TYPE_INVALID); } else if (notiType == _NOTI_TYPE_NETWORK) { - signal = dbus_message_new_signal("/User/Email/NetworkStatus", EMF_NETOWRK_CHANGE_NOTI, "email"); + signal = dbus_message_new_signal("/User/Email/NetworkStatus", EMAIL_NETOWRK_CHANGE_NOTI, "email"); if (signal == NULL) { EM_DEBUG_EXCEPTION("dbus_message_new_signal is failed"); @@ -974,9 +965,23 @@ INTERNAL_FUNC int emstorage_send_noti(enotitype_t notiType, int subType, int dat dbus_message_append_args(signal, DBUS_TYPE_INT32, &data2, DBUS_TYPE_INVALID); dbus_message_append_args(signal, DBUS_TYPE_INT32, &data4, DBUS_TYPE_INVALID); } + else if (notiType == _NOTI_TYPE_RESPONSE_TO_API) { + signal = dbus_message_new_signal("/User/Email/ResponseToAPI", EMAIL_RESPONSE_TO_API_NOTI, "email"); + + if (signal == NULL) { + EM_DEBUG_EXCEPTION("dbus_message_new_signal is failed"); + goto FINISH_OFF; + } + + EM_DEBUG_LOG("/User/Email/ResponseToAPI Signal is created by dbus_message_new_signal"); + + dbus_message_append_args(signal, DBUS_TYPE_INT32, &subType, DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &data1, DBUS_TYPE_INVALID); + dbus_message_append_args(signal, DBUS_TYPE_INT32, &data2, DBUS_TYPE_INVALID); + } else { EM_DEBUG_EXCEPTION("Wrong notification type [%d]", notiType); - error = EMF_ERROR_IPC_CRASH; + error = EMAIL_ERROR_IPC_CRASH; goto FINISH_OFF; } @@ -989,7 +994,7 @@ INTERNAL_FUNC int emstorage_send_noti(enotitype_t notiType, int subType, int dat } /* EM_DEBUG_LOG("Before dbus_connection_flush"); */ -/* dbus_connection_flush(connection); */ +/* dbus_connection_flush(connection); */ /* EM_DEBUG_LOG("After dbus_connection_flush"); */ ret = true; @@ -1004,18 +1009,24 @@ FINISH_OFF: } -INTERNAL_FUNC int emstorage_notify_storage_event(emf_noti_on_storage_event transaction_type, int data1, int data2 , char *data3, int data4) +INTERNAL_FUNC int emstorage_notify_storage_event(email_noti_on_storage_event transaction_type, int data1, int data2 , char *data3, int data4) { EM_DEBUG_FUNC_BEGIN("transaction_type[%d], data1[%d], data2[%d], data3[%p], data4[%d]", transaction_type, data1, data2, data3, data4); return emstorage_send_noti(_NOTI_TYPE_STORAGE, (int)transaction_type, data1, data2, data3, data4); } -INTERNAL_FUNC int emstorage_notify_network_event(emf_noti_on_network_event status_type, int data1, char *data2, int data3, int data4) +INTERNAL_FUNC int emstorage_notify_network_event(email_noti_on_network_event status_type, int data1, char *data2, int data3, int data4) { EM_DEBUG_FUNC_BEGIN("status_type[%d], data1[%d], data2[%p], data3[%d], data4[%d]", status_type, data1, data2, data3, data4); return emstorage_send_noti(_NOTI_TYPE_NETWORK, (int)status_type, data1, data3, data2, data4); } +INTERNAL_FUNC int emstorage_notify_response_to_api(email_event_type_t event_type, int data1, int data2) +{ + EM_DEBUG_FUNC_BEGIN("event_type[%d], data1[%d], data2[%p], data3[%d], data4[%d]", event_type, data1, data2); + return emstorage_send_noti(_NOTI_TYPE_RESPONSE_TO_API, (int)event_type, data1, data2, NULL, 0); +} + /* ----------- Notification Changes End----------- */ static int _get_table_field_data_char(char **table, char *buf, int index) { @@ -1223,6 +1234,29 @@ static int _get_stmt_field_data_string(DB_STMT hStmt, char **buf, int ucs2, int return false; } +static void _get_stmt_field_data_blob(DB_STMT hStmt, void **buf, int index) +{ + if ((hStmt < 0) || (buf == NULL) || (index < 0)) { + EM_DEBUG_EXCEPTION("hStmt[%d], buf[%p], index[%d]", hStmt, buf, index); + return; + } + + int sLen = 0; + sLen = sqlite3_column_bytes(hStmt, index); + +#ifdef _PRINT_STORAGE_LOG_ + EM_DEBUG_LOG("_get_stmt_field_data_blob sqlite3_column_bytes sLen[%d]", sLen); +#endif + + if (sLen > 0) { + *buf = (char *) em_malloc(sLen); + memcpy(*buf, (void *)sqlite3_column_blob(hStmt, index), sLen); + } + else + *buf = NULL; + +} + static int _get_stmt_field_data_string_without_allocation(DB_STMT hStmt, char *buf, int buffer_size, int ucs2, int index) { if ((hStmt < 0) || (buf == NULL) || (index < 0)) { @@ -1326,6 +1360,32 @@ static int _bind_stmt_field_data_string(DB_STMT hStmt, int index, char *value, i return true; } + +static int _bind_stmt_field_data_blob(DB_STMT hStmt, int index, void *blob, int blob_size) +{ + if ((hStmt == NULL) || (index < 0)) { + EM_DEBUG_EXCEPTION("index[%d], blob_size[%d]", index, blob_size); + return false; + } + +#ifdef _PRINT_STORAGE_LOG_ + EM_DEBUG_LOG("hStmt = %p, index = %d, blob_size = %d, blob = [%p]", hStmt, index, blob_size, blob); +#endif + + int ret = 0; + if (blob_size>0) + ret = sqlite3_bind_blob(hStmt, index+1, blob, blob_size, SQLITE_STATIC); + else + ret = sqlite3_bind_null(hStmt, index+1); + + if (ret != SQLITE_OK) { + EM_DEBUG_EXCEPTION("sqlite3_bind_blob fail [%d]", ret); + return false; + } + return true; +} + + static int _delete_temp_file(const char *path) { EM_DEBUG_FUNC_BEGIN("path[%p]", path); @@ -1380,7 +1440,7 @@ INTERNAL_FUNC int emstorage_close(int *err_code) EM_DEBUG_FUNC_BEGIN(); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; emstorage_db_close(&error); @@ -1400,7 +1460,7 @@ static void *_emstorage_open_once(int *err_code) { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; mkdir(EMAILPATH, DIRECTORY_PERMISSION); mkdir(DATA_PATH, DIRECTORY_PERMISSION); @@ -1414,7 +1474,7 @@ static void *_emstorage_open_once(int *err_code) g_transaction = false; - if (!emstorage_create_table(EMF_CREATE_DB_NORMAL, &error)) { + if (!emstorage_create_table(EMAIL_CREATE_DB_NORMAL, &error)) { EM_DEBUG_EXCEPTION(" emstorage_create_table failed - %d", error); goto FINISH_OFF; } @@ -1429,25 +1489,25 @@ FINISH_OFF: /* pData : a parameter which is registered when busy handler is registerd */ /* count : retry count */ -#define EMF_STORAGE_MAX_RETRY_COUNT 20 +#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 */ /* retry will be stopped if busy handler return 0 */ - return EMF_STORAGE_MAX_RETRY_COUNT - count; + return EMAIL_STORAGE_MAX_RETRY_COUNT - count; } static int _delete_all_files_and_directories(int *err_code) { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int ret = false; if (!emstorage_delete_file(EMAIL_SERVICE_DB_FILE_PATH, &error)) { - if (error != EMF_ERROR_FILE_NOT_FOUND) { + if (error != EMAIL_ERROR_FILE_NOT_FOUND) { EM_DEBUG_EXCEPTION("remove failed - %s", EMAIL_SERVICE_DB_FILE_PATH); goto FINISH_OFF; } @@ -1471,7 +1531,7 @@ static int _recovery_from_malformed_db_file(int *err_code) { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int ret = false; /* Delete all files and directories */ @@ -1499,7 +1559,7 @@ INTERNAL_FUNC int em_db_open(sqlite3 **sqlite_handle, int *err_code) { EM_DEBUG_FUNC_BEGIN(); int rc = 0; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int ret = false; EM_DEBUG_LOG("*sqlite_handle[%p]", *sqlite_handle); @@ -1510,7 +1570,7 @@ INTERNAL_FUNC int em_db_open(sqlite3 **sqlite_handle, int *err_code) EMSTORAGE_PROTECTED_FUNC_CALL(db_util_open(EMAIL_SERVICE_DB_FILE_PATH, sqlite_handle, DB_UTIL_REGISTER_HOOK_METHOD), rc); if (SQLITE_OK != rc) { EM_DEBUG_EXCEPTION("db_util_open fail:%d -%s", rc, sqlite3_errmsg(*sqlite_handle)); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; db_util_close(*sqlite_handle); *sqlite_handle = NULL; @@ -1525,7 +1585,7 @@ INTERNAL_FUNC int em_db_open(sqlite3 **sqlite_handle, int *err_code) EMSTORAGE_PROTECTED_FUNC_CALL(db_util_open(EMAIL_SERVICE_DB_FILE_PATH, sqlite_handle, DB_UTIL_REGISTER_HOOK_METHOD), rc); if (SQLITE_OK != rc) { EM_DEBUG_EXCEPTION("db_util_open fail:%d -%s", rc, sqlite3_errmsg(*sqlite_handle)); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; db_util_close(*sqlite_handle); *sqlite_handle = NULL; } @@ -1540,7 +1600,7 @@ INTERNAL_FUNC int em_db_open(sqlite3 **sqlite_handle, int *err_code) 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)); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; db_util_close(*sqlite_handle); *sqlite_handle = NULL; goto FINISH_OFF; @@ -1567,7 +1627,7 @@ INTERNAL_FUNC sqlite3* emstorage_db_open(int *err_code) sqlite3 *_db_handle = NULL; #endif - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; _initialize_shm_mutex(SHM_FILE_FOR_DB_LOCK, &shm_fd_for_db_lock, &mapped_for_db_lock); @@ -1599,7 +1659,7 @@ INTERNAL_FUNC int emstorage_db_close(int *err_code) sqlite3 *_db_handle = emstorage_get_db_handle(); #endif - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int ret = false; DELETE_CRITICAL_SECTION(_transactionBeginLock); @@ -1611,7 +1671,7 @@ INTERNAL_FUNC int emstorage_db_close(int *err_code) if (ret != SQLITE_OK) { EM_DEBUG_EXCEPTION(" db_util_close fail - %d", ret); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; ret = false; goto FINISH_OFF; } @@ -1637,7 +1697,7 @@ INTERNAL_FUNC int emstorage_open(int *err_code) EM_DEBUG_FUNC_BEGIN(); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int retValue; @@ -1670,7 +1730,7 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int rc = -1, ret = false; char sql_query_string[QUERY_SIZE] = {0, }; char *create_table_query[] = @@ -1678,54 +1738,58 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e /* 1. create mail_account_tbl */ "CREATE TABLE mail_account_tbl \n" "(\n" - " account_bind_type INTEGER \n" - ", account_name VARCHAR(51) \n" - ", receiving_server_type INTEGER \n" - ", receiving_server_addr VARCHAR(51) \n" - ", email_addr VARCHAR(129) \n" - ", user_name VARCHAR(51) \n" - ", password VARCHAR(51) \n" - ", retrieval_mode INTEGER \n" - ", port_num INTEGER \n" - ", use_security INTEGER \n" - ", sending_server_type INTEGER \n" - ", sending_server_addr VARCHAR(51) \n" - ", sending_port_num INTEGER \n" - ", sending_auth INTEGER \n" - ", sending_security INTEGER \n" - ", sending_user VARCHAR(51) \n" - ", sending_password VARCHAR(51) \n" - ", display_name VARCHAR(31) \n" - ", reply_to_addr VARCHAR(129) \n" - ", return_addr VARCHAR(129) \n" - ", account_id INTEGER PRIMARY KEY \n" - ", keep_on_server INTEGER \n" - ", flag1 INTEGER \n" - ", flag2 INTEGER \n" - ", pop_before_smtp INTEGER \n" /* POP before SMTP authentication */ - ", apop INTEGER \n" /* APOP authentication */ - ", logo_icon_path VARCHAR(256) \n" /* Receiving Option : Account logo icon */ - ", preset_account INTEGER \n" /* Receiving Option : Preset account or not */ - ", target_storage INTEGER \n" /* Receiving Option : Specifies the targetStorage. 0 is phone, 1 is MMC */ - ", check_interval INTEGER \n" /* Receiving Option : Specifies the check interval. Unit is minute */ - ", priority INTEGER \n" /* Sending Option : Specifies the prority. 1=high 3=normal 5=low */ - ", keep_local_copy INTEGER \n" /* Sending Option : */ - ", req_delivery_receipt INTEGER \n" /* Sending Option : */ - ", req_read_receipt INTEGER \n" /* Sending Option : */ - ", download_limit INTEGER \n" /* Sending Option : */ - ", block_address INTEGER \n" /* Sending Option : */ - ", block_subject INTEGER \n" /* Sending Option : */ - ", display_name_from VARCHAR(256) \n" /* Sending Option : */ - ", reply_with_body INTEGER \n" /* Sending Option : */ - ", forward_with_files INTEGER \n" /* Sending Option : */ - ", add_myname_card INTEGER \n" /* Sending Option : */ - ", add_signature INTEGER \n" /* Sending Option : */ - ", signature VARCHAR(256) \n" /* Sending Option : */ - ", add_my_address_to_bcc INTEGER \n" /* Sending Option : */ - ", my_account_id INTEGER \n" /* My Account Id */ - ", index_color INTEGER \n" /* Index color */ - ", sync_status INTEGER \n" /* Sync Status */ - ");", + "account_id INTEGER PRIMARY KEY,\n" + "account_name VARCHAR(51),\n" + "logo_icon_path VARCHAR(256),\n" + "user_data BLOB,\n" + "user_data_length INTEGER,\n" + "account_svc_id INTEGER,\n" + "sync_status INTEGER,\n" + "sync_disabled INTEGER,\n" + "default_mail_slot_size INTEGER,\n" + "user_display_name VARCHAR(31),\n" + "user_email_address VARCHAR(129),\n" + "reply_to_address VARCHAR(129),\n" + "return_address VARCHAR(129),\n" + "incoming_server_type INTEGER,\n" + "incoming_server_address VARCHAR(51),\n" + "incoming_server_port_number INTEGER,\n" + "incoming_server_user_name VARCHAR(51),\n" + "incoming_server_password VARCHAR(51),\n" + "incoming_server_secure_connection INTEGER,\n" + "retrieval_mode INTEGER,\n" + "keep_mails_on_pop_server_after_download INTEGER,\n" + "check_interval INTEGER,\n" + "auto_download_size INTEGER,\n" + "outgoing_server_type INTEGER,\n" + "outgoing_server_address VARCHAR(51),\n" + "outgoing_server_port_number INTEGER,\n" + "outgoing_server_user_name VARCHAR(51),\n" + "outgoing_server_password VARCHAR(51),\n" + "outgoing_server_secure_connection INTEGER,\n" + "outgoing_server_need_authentication INTEGER,\n" + "outgoing_server_use_same_authenticator INTEGER,\n" + "priority INTEGER,\n" + "keep_local_copy INTEGER,\n" + "req_delivery_receipt INTEGER,\n" + "req_read_receipt INTEGER,\n" + "download_limit INTEGER,\n" + "block_address INTEGER,\n" + "block_subject INTEGER,\n" + "display_name_from VARCHAR(256),\n" + "reply_with_body INTEGER,\n" + "forward_with_files INTEGER,\n" + "add_myname_card INTEGER,\n" + "add_signature INTEGER,\n" + "signature VARCHAR(256),\n" + "add_my_address_to_bcc INTEGER,\n" + "pop_before_smtp INTEGER,\n" + "incoming_server_requires_apop INTEGER,\n" + "smime_type INTEGER,\n" + "certificate_path VARCHAR(256),\n" + "cipher_type INTEGER,\n" + "digest_type INTEGER\n" + "); \n ", /* 2. create mail_box_tbl */ "CREATE TABLE mail_box_tbl \n" "(\n" @@ -1740,13 +1804,14 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e ", total_mail_count_on_server INTEGER \n" ", has_archived_mails INTEGER \n" ", mail_slot_size INTEGER \n" + ", last_sync_time DATETIME \n" "); \n ", /* 3. create mail_read_mail_uid_tbl */ "CREATE TABLE mail_read_mail_uid_tbl \n" "(\n" " account_id INTEGER \n" - ", local_mbox VARCHAR(129) \n" + ", mailbox_id VARCHAR(129) \n" ", local_uid INTEGER \n" ", mailbox_name VARCHAR(256) \n" ", s_uid VARCHAR(129) \n" @@ -1763,7 +1828,7 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e ", type INTEGER \n" ", value VARCHAR(257) \n" ", action_type INTEGER \n" - ", dest_mailbox VARCHAR(129) \n" + ", target_mailbox_id INTEGER \n" ", flag1 INTEGER \n" ", flag2 INTEGER \n" "); \n ", @@ -1794,6 +1859,7 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e ", body_download_status INTEGER \n" ", file_path_plain VARCHAR(257) \n" ", file_path_html VARCHAR(257) \n" + ", file_path_mime_entity VARCHAR(257) \n" ", mail_size INTEGER \n" ", flags_seen_field BOOLEAN \n" ", flags_deleted_field BOOLEAN \n" @@ -1813,6 +1879,9 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e ", thread_item_count INTEGER \n" ", preview_text TEXT \n" ", meeting_request_status INTEGER \n" + ", message_class INTEGER \n" + ", digest_type INTEGER \n" + ", smime_type INTEGER \n" ", FOREIGN KEY(account_id) REFERENCES mail_account_tbl(account_id) \n" "); \n ", @@ -1825,7 +1894,7 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e ", attachment_size INTEGER \n" ", mail_id INTEGER \n" ", account_id INTEGER \n" - ", mailbox_name VARCHAR(129) \n" + ", mailbox_id INTEGER \n" ", attachment_save_status INTEGER \n" ", attachment_drm_type INTEGER \n" ", attachment_drm_method INTEGER \n" @@ -1846,6 +1915,7 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e ", server_mail_id INTEGER \n" ", activity_id INTEGER PRIMARY KEY \n" ", activity_type INTEGER \n" + ", mailbox_id INTEGER \n" ", mailbox_name VARCHAR(4000) \n" "); \n ", #endif @@ -1854,7 +1924,7 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e "(\n" " mail_id INTEGER PRIMARY KEY \n" ", account_id INTEGER \n" - ", mailbox_name TEXT \n" + ", mailbox_id INTEGER \n" ", meeting_response INTEGER \n" ", start_time INTEGER \n" ", end_time INTEGER \n" @@ -1881,6 +1951,21 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e ", dest_mbox VARCHAR(129) \n" "); \n ", #endif + "CREATE TABLE mail_certificate_tbl \n" + "( \n" + " certificate_id INTEGER \n" + ", issue_year INTEGER \n" + ", issue_month INTEGER \n" + ", issue_day INTEGER \n" + ", expiration_year INTEGER \n" + ", expiration_month INTEGER \n" + ", expiration_day INTEGER \n" + ", issue_organization_name VARCHAR(256) \n" + ", email_address VARCHAR(129) \n" + ", subject_str VARCHAR(256) \n" + ", filepath VARCHAR(256) \n" + ", password VARCHAR(51) \n" + "); \n ", NULL, }; @@ -1908,20 +1993,20 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e EM_SAFE_STRNCPY(sql_query_string, create_table_query[CREATE_TABLE_MAIL_ACCOUNT_TBL], sizeof(sql_query_string)); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); /* create mail_account_tbl unique index */ - SNPRINTF(sql_query_string, sizeof(sql_query_string), "CREATE UNIQUE INDEX mail_account_idx1 ON mail_account_tbl (account_bind_type, account_id)"); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "CREATE UNIQUE INDEX mail_account_idx1 ON mail_account_tbl (account_id)"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc); } /* mail_account_tbl */ - else if (type == EMF_CREATE_DB_CHECK) { + else if (type == EMAIL_CREATE_DB_CHECK) { EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_ACCOUNT_TBL], NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_ACCOUNT_TBL], rc, sqlite3_errmsg(local_db_handle))); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_ACCOUNT_TBL], rc, sqlite3_errmsg(local_db_handle))); } sqlite3_free_table(result); @@ -1944,22 +2029,22 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e EM_SAFE_STRNCPY(sql_query_string, create_table_query[CREATE_TABLE_MAIL_BOX_TBL], sizeof(sql_query_string)); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); /* create mail_local_mailbox_tbl unique index */ SNPRINTF(sql_query_string, sizeof(sql_query_string), "CREATE UNIQUE INDEX mail_box_idx1 ON mail_box_tbl (account_id, local_yn, mailbox_name)"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc); } /* mail_box_tbl */ - else if (type == EMF_CREATE_DB_CHECK) { + else if (type == EMAIL_CREATE_DB_CHECK) { rc = sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_BOX_TBL], NULL, NULL, NULL); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_BOX_TBL], rc, sqlite3_errmsg(local_db_handle))); } sqlite3_free_table(result); @@ -1981,21 +2066,21 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e EM_SAFE_STRNCPY(sql_query_string, create_table_query[CREATE_TABLE_MAIL_READ_MAIL_UID_TBL], sizeof(sql_query_string)); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); /* create mail_read_mail_uid_tbl unique index */ - SNPRINTF(sql_query_string, sizeof(sql_query_string), "CREATE UNIQUE INDEX mail_read_mail_uid_idx1 ON mail_read_mail_uid_tbl (account_id, local_mbox, local_uid, mailbox_name, s_uid)"); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "CREATE UNIQUE INDEX mail_read_mail_uid_idx1 ON mail_read_mail_uid_tbl (account_id, mailbox_id, local_uid, mailbox_name, s_uid)"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc); } /* mail_read_mail_uid_tbl */ - else if (type == EMF_CREATE_DB_CHECK) { + else if (type == EMAIL_CREATE_DB_CHECK) { EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_READ_MAIL_UID_TBL], NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_READ_MAIL_UID_TBL], rc, sqlite3_errmsg(local_db_handle))); } sqlite3_free_table(result); @@ -2018,14 +2103,14 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e EM_SAFE_STRNCPY(sql_query_string, create_table_query[CREATE_TABLE_MAIL_RULE_TBL], sizeof(sql_query_string)); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc); } /* mail_rule_tbl */ - else if (type == EMF_CREATE_DB_CHECK) { + else if (type == EMAIL_CREATE_DB_CHECK) { EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_RULE_TBL], NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_RULE_TBL], rc, sqlite3_errmsg(local_db_handle))); } sqlite3_free_table(result); @@ -2046,25 +2131,25 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e EM_SAFE_STRNCPY(sql_query_string, create_table_query[CREATE_TABLE_MAIL_TBL], sizeof(sql_query_string)); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); /* create mail_tbl unique index */ SNPRINTF(sql_query_string, sizeof(sql_query_string), "CREATE UNIQUE INDEX mail_idx1 ON mail_tbl (mail_id, account_id)"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); /* create mail_tbl index for date_time */ SNPRINTF(sql_query_string, sizeof(sql_query_string), "CREATE INDEX mail_idx_date_time ON mail_tbl (date_time)"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); /* create mail_tbl index for thread_item_count */ SNPRINTF(sql_query_string, sizeof(sql_query_string), "CREATE INDEX mail_idx_thread_mail_count ON mail_tbl (thread_item_count)"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc); @@ -2072,9 +2157,9 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e /* just one time call */ /* EFTSInitFTSIndex(FTS_EMAIL_IDX); */ } /* mail_tbl */ - else if (type == EMF_CREATE_DB_CHECK) { + else if (type == EMAIL_CREATE_DB_CHECK) { EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_TBL], NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_TBL], rc, sqlite3_errmsg(local_db_handle))); } sqlite3_free_table(result); @@ -2095,21 +2180,21 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e EM_SAFE_STRNCPY(sql_query_string, create_table_query[CREATE_TABLE_MAIL_ATTACHMENT_TBL], sizeof(sql_query_string)); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); /* create mail_attachment_tbl unique index */ SNPRINTF(sql_query_string, sizeof(sql_query_string), "CREATE UNIQUE INDEX mail_attachment_idx1 ON mail_attachment_tbl (mail_id, attachment_id) "); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc); } /* mail_attachment_tbl */ - else if (type == EMF_CREATE_DB_CHECK) { + else if (type == EMAIL_CREATE_DB_CHECK) { EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_ATTACHMENT_TBL], NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_ATTACHMENT_TBL], rc, sqlite3_errmsg(local_db_handle))); } sqlite3_free_table(result); @@ -2132,14 +2217,14 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e EM_SAFE_STRNCPY(sql_query_string, create_table_query[CREATE_TABLE_MAIL_PARTIAL_BODY_ACTIVITY_TBL], sizeof(sql_query_string)); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc); } /* mail_rule_tbl */ - else if (type == EMF_CREATE_DB_CHECK) { + else if (type == EMAIL_CREATE_DB_CHECK) { EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_PARTIAL_BODY_ACTIVITY_TBL], NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_PARTIAL_BODY_ACTIVITY_TBL], rc, sqlite3_errmsg(local_db_handle))); } sqlite3_free_table(result); @@ -2162,19 +2247,19 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e EM_SAFE_STRNCPY(sql_query_string, create_table_query[CREATE_TABLE_MAIL_MEETING_TBL], sizeof(sql_query_string)); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); SNPRINTF(sql_query_string, sizeof(sql_query_string), "CREATE UNIQUE INDEX mail_meeting_idx1 ON mail_meeting_tbl (mail_id)"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc); } /* mail_contact_sync_tbl */ - else if (type == EMF_CREATE_DB_CHECK) { + else if (type == EMAIL_CREATE_DB_CHECK) { EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_MEETING_TBL], NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_MEETING_TBL], rc, sqlite3_errmsg(local_db_handle))); } sqlite3_free_table(result); @@ -2197,20 +2282,47 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e SNPRINTF(sql_query_string, sizeof(sql_query_string), create_table_query[CREATE_TABLE_MAIL_LOCAL_ACTIVITY_TBL]); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc); } /* mail_rule_tbl */ - else if (type == EMF_CREATE_DB_CHECK) { + else if (type == EMAIL_CREATE_DB_CHECK) { rc = sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_LOCAL_ACTIVITY_TBL], NULL, NULL, NULL); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_LOCAL_ACTIVITY_TBL], NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_LOCAL_ACTIVITY_TBL], rc, sqlite3_errmsg(local_db_handle))); } sqlite3_free_table(result); #endif /* __FEATURE_LOCAL_ACTIVITY__ */ + /* create mail_certificate_tbl */ + sql = "SELECT count(name) FROM sqlite_master WHERE name='mail_certificate_tbl';"; + /* rc = sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL); */ + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); + + if (atoi(result[1]) < 1) { + 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))); + + EM_DEBUG_LOG("CREATE TABLE mail_certificate_tbl"); + + EM_SAFE_STRNCPY(sql_query_string, create_table_query[CREATE_TABLE_MAIL_CERTIFICATE_TBL], sizeof(sql_query_string)); + + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "CREATE UNIQUE INDEX mail_certificate_idx1 ON mail_certificate_tbl (certificate_id)"); + + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc); + } /* mail_contact_sync_tbl */ + else if (type == EMAIL_CREATE_DB_CHECK) { + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_CERTIFICATE_TBL], NULL, NULL, NULL), rc); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_CERTIFICATE_TBL], rc, sqlite3_errmsg(local_db_handle))); + } + sqlite3_free_table(result); ret = true; @@ -2233,7 +2345,144 @@ FINISH_OFF: /* Query series --------------------------------------------------------------*/ -INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int transaction, emf_mail_list_item_t** result_mail_list, int *result_count, int *err_code) +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) +{ + 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; + int error = EMAIL_ERROR_NONE; + DB_STMT hStmt = NULL; + char sql_query_string[QUERY_SIZE] = {0, }; + char err_msg[1024]; + char **result; + sqlite3 *local_db_handle = NULL; + + if (!input_conditional_clause || (!output_total_mail_count && !output_unseen_mail_count)) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + memset(&sql_query_string, 0x00, sizeof(sql_query_string)); + local_db_handle = emstorage_get_db_connection(); + + EMSTORAGE_START_READ_TRANSACTION(input_transaction); + + SNPRINTF(sql_query_string, QUERY_SIZE, "SELECT COUNT(*) FROM mail_tbl"); + EM_SAFE_STRCAT(sql_query_string, (char*)input_conditional_clause); + + if (output_total_mail_count) { + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); + 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 && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("sqlite3_step fail:%d", rc)); + _get_stmt_field_data_int(hStmt, output_total_mail_count, 0); + } + + if (output_unseen_mail_count) { + EM_SAFE_STRCAT(sql_query_string, " AND flags_seen_field = 0 "); + + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + + *output_unseen_mail_count = atoi(result[1]); + sqlite3_free_table(result); + } + +FINISH_OFF: + + if (hStmt != NULL) { + rc = sqlite3_finalize(hStmt); + if (rc != SQLITE_OK) { + EM_DEBUG_LOG("sqlite3_finalize failed [%d] : %s", rc, err_msg); + error = EMAIL_ERROR_DB_FAILURE; + } + } + + EMSTORAGE_FINISH_READ_TRANSACTION(input_transaction); + _DISCONNECT_DB; + + EM_DEBUG_FUNC_END("error [%d]", error); + 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) +{ + 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); + + int i = 0; + int count = 0; + int rc = -1; + int cur_query = 0; + int col_index; + int error = EMAIL_ERROR_NONE; + int *result_mail_id_list = NULL; + char **result = NULL; + char sql_query_string[QUERY_SIZE] = {0, }; + sqlite3 *local_db_handle = emstorage_get_db_connection(); + + 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); + EM_IF_NULL_RETURN_VALUE(output_mail_id_count, EMAIL_ERROR_INVALID_PARAM); + + EMSTORAGE_START_READ_TRANSACTION(input_transaction); + + /* Composing query */ + SNPRINTF_OFFSET(sql_query_string, cur_query, QUERY_SIZE, "SELECT mail_id FROM mail_tbl "); + EM_SAFE_STRCAT(sql_query_string, (char*)input_conditional_clause); + + EM_DEBUG_LOG("query[%s].", sql_query_string); + + /* Performing query */ + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc); + EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + + col_index = 1; + + /* to get mail list */ + if (count == 0) { + EM_DEBUG_EXCEPTION("No mail found..."); + error = EMAIL_ERROR_MAIL_NOT_FOUND; + goto FINISH_OFF; + } + + EM_DEBUG_LOG("There are [%d] mails.", count); + + if (!(result_mail_id_list = (int*)em_malloc(sizeof(int) * count))) { + EM_DEBUG_EXCEPTION("malloc for result_mail_id_list failed..."); + error = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + EM_DEBUG_LOG(">>>> DATA ASSIGN START >> "); + + for (i = 0; i < count; i++) + _get_table_field_data_int(result, result_mail_id_list + i, col_index++); + + EM_DEBUG_LOG(">>>> DATA ASSIGN END [count : %d] >> ", count); + + *output_mail_id_list = result_mail_id_list; + *output_mail_id_count = count; + +FINISH_OFF: + + if(result) + sqlite3_free_table(result); + + EMSTORAGE_FINISH_READ_TRANSACTION(input_transaction); + _DISCONNECT_DB; + + if(error != EMAIL_ERROR_NONE) + EM_SAFE_FREE(result_mail_id_list); + + EM_DEBUG_FUNC_END("error [%d]", error); + 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) { EM_DEBUG_FUNC_BEGIN(); EM_PROFILE_BEGIN(emstorage_query_mail_list_func); @@ -2241,11 +2490,11 @@ INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int int i = 0, count = 0, rc = -1, to_get_count = (result_mail_list)?0:1; int local_inline_content_count = 0, local_attachment_count = 0; int cur_query = 0, base_count = 0, col_index; - int ret = false, error = EMF_ERROR_NONE; + int ret = false, error = EMAIL_ERROR_NONE; char *date_time_string = NULL; char **result = NULL, sql_query_string[QUERY_SIZE] = {0, }; - char *field_list = "mail_id, account_id, mailbox_name, full_address_from, email_address_sender, full_address_to, subject, body_download_status, flags_seen_field, flags_deleted_field, flags_flagged_field, flags_answered_field, flags_recent_field, flags_draft_field, flags_forwarded_field, DRM_status, priority, save_status, lock_status, attachment_count, inline_content_count, date_time, preview_text, thread_id, thread_item_count, meeting_request_status "; - emf_mail_list_item_t *mail_list_item_from_tbl = NULL; + char *field_list = "mail_id, account_id, mailbox_id, full_address_from, email_address_sender, full_address_to, subject, body_download_status, flags_seen_field, flags_deleted_field, flags_flagged_field, flags_answered_field, flags_recent_field, flags_draft_field, flags_forwarded_field, DRM_status, priority, save_status, lock_status, attachment_count, inline_content_count, date_time, preview_text, thread_id, thread_item_count, meeting_request_status, message_class, smime_type "; + email_mail_list_item_t *mail_list_item_from_tbl = NULL; sqlite3 *local_db_handle = emstorage_get_db_connection(); EM_IF_NULL_RETURN_VALUE(conditional_clause, false); @@ -2255,18 +2504,19 @@ INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int /* select clause */ if (to_get_count) /* count only */ - cur_query += SNPRINTF_OFFSET(sql_query_string, cur_query, QUERY_SIZE, "SELECT count(*) FROM mail_tbl"); + cur_query += SNPRINTF_OFFSET(sql_query_string, cur_query, QUERY_SIZE, "SELECT mail_id FROM mail_tbl"); else /* mail list in plain form */ cur_query += SNPRINTF_OFFSET(sql_query_string, cur_query, QUERY_SIZE, "SELECT %s FROM mail_tbl ", field_list); - cur_query += SNPRINTF_OFFSET(sql_query_string, cur_query, QUERY_SIZE, conditional_clause, 0); + /* cur_query += SNPRINTF_OFFSET(sql_query_string, cur_query, QUERY_SIZE, conditional_clause); This code caused some crashes.*/ + strncat(sql_query_string, conditional_clause, QUERY_SIZE - cur_query); EM_DEBUG_LOG("emstorage_query_mail_list : query[%s].", sql_query_string); /* performing query */ EM_PROFILE_BEGIN(emstorage_query_mail_list_performing_query); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EM_PROFILE_END(emstorage_query_mail_list_performing_query); @@ -2278,8 +2528,13 @@ INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int EM_DEBUG_LOG("base_count [%d]", base_count); if (to_get_count) { - /* to get mail count */ - count = atoi(result[1]); + /* to get count */ + if (!count) { + EM_DEBUG_EXCEPTION("No mail found..."); + ret = false; + error= EMAIL_ERROR_MAIL_NOT_FOUND; + goto FINISH_OFF; + } EM_DEBUG_LOG("There are [%d] mails.", count); } else { @@ -2287,14 +2542,14 @@ INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int if (!count) { EM_DEBUG_EXCEPTION("No mail found..."); ret = false; - error= EMF_ERROR_MAIL_NOT_FOUND; + error= EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } EM_DEBUG_LOG("There are [%d] mails.", count); - if (!(mail_list_item_from_tbl = (emf_mail_list_item_t*)em_malloc(sizeof(emf_mail_list_item_t) * count))) { + if (!(mail_list_item_from_tbl = (email_mail_list_item_t*)em_malloc(sizeof(email_mail_list_item_t) * count))) { EM_DEBUG_EXCEPTION("malloc for mail_list_item_from_tbl failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2303,7 +2558,7 @@ INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int for (i = 0; i < count; i++) { _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].mail_id), col_index++); _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].account_id), col_index++); - _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].mailbox_name, STRING_LENGTH_FOR_DISPLAY, 1, col_index++); + _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].mailbox_id), col_index++); _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].from, STRING_LENGTH_FOR_DISPLAY, 1, col_index++); _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].from_email_address, MAX_EMAIL_ADDRESS_LENGTH, 1, col_index++); _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].recipients, STRING_LENGTH_FOR_DISPLAY, 1, col_index++); @@ -2327,6 +2582,8 @@ INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].thread_id), col_index++); _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].thread_item_count), col_index++); _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].is_meeting_request), col_index++); + _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].message_class), col_index++); + _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].smime_type), col_index++); mail_list_item_from_tbl[i].has_attachment = ((local_attachment_count - local_inline_content_count)>0)?1:0; } @@ -2372,15 +2629,15 @@ INTERNAL_FUNC int emstorage_query_mail_tbl(const char *conditional_clause, int t 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); if (!conditional_clause) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - int i, col_index = FIELD_COUNT_OF_EMF_MAIL_TBL, rc, ret = false, count; - int error = EMF_ERROR_NONE; + int i, col_index = FIELD_COUNT_OF_MAIL_TBL, rc, ret = false, count; + 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(); @@ -2392,20 +2649,20 @@ INTERNAL_FUNC int emstorage_query_mail_tbl(const char *conditional_clause, int t EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); if (!count) { EM_DEBUG_EXCEPTION("No mail found..."); ret = false; - error= EMF_ERROR_MAIL_NOT_FOUND; + error= EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } EM_DEBUG_LOG("There are [%d] mails.", count); if (!(p_data_tbl = (emstorage_mail_tbl_t*)em_malloc(sizeof(emstorage_mail_tbl_t) * count))) { EM_DEBUG_EXCEPTION("malloc for emstorage_mail_tbl_t failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -2435,6 +2692,7 @@ INTERNAL_FUNC int emstorage_query_mail_tbl(const char *conditional_clause, int t _get_table_field_data_int (result, &(p_data_tbl[i].body_download_status), 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_int (result, &(p_data_tbl[i].mail_size), col_index++); _get_table_field_data_char (result, &(p_data_tbl[i].flags_seen_field), col_index++); _get_table_field_data_char (result, &(p_data_tbl[i].flags_deleted_field), col_index++); @@ -2454,6 +2712,9 @@ INTERNAL_FUNC int emstorage_query_mail_tbl(const char *conditional_clause, int t _get_table_field_data_int (result, &(p_data_tbl[i].thread_item_count), col_index++); _get_table_field_data_string(result, &(p_data_tbl[i].preview_text), 1, col_index++); _get_table_field_data_int (result, &(p_data_tbl[i].meeting_request_status), col_index++); + _get_table_field_data_int (result, &(p_data_tbl[i].message_class), col_index++); + _get_table_field_data_int (result, &(p_data_tbl[i].digest_type), col_index++); + _get_table_field_data_int (result, &(p_data_tbl[i].smime_type), col_index++); /* check real body file... */ if (p_data_tbl[i].body_download_status) { struct stat buf; @@ -2499,21 +2760,120 @@ FINISH_OFF: return ret; } +INTERNAL_FUNC int emstorage_query_mailbox_tbl(const char *input_conditional_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_get_mail_count[%d], input_transaction[%d], output_mailbox_list[%p], output_mailbox_count[%d]", input_conditional_clause, input_get_mail_count, input_transaction, output_mailbox_list, output_mailbox_count); + + int i = 0; + int rc; + int count = 0; + int col_index = 0; + int error = EMAIL_ERROR_NONE; + int read_count = 0; + int total_count = 0; + char **result; + char sql_query_string[QUERY_SIZE] = {0, }; + char *fields = "MBT.mailbox_id, MBT.account_id, local_yn, MBT.mailbox_name, MBT.mailbox_type, alias, sync_with_server_yn, modifiable_yn, total_mail_count_on_server, has_archived_mails, mail_slot_size, last_sync_time "; + emstorage_mailbox_tbl_t* p_data_tbl = NULL; + DB_STMT hStmt = NULL; + sqlite3 *local_db_handle = emstorage_get_db_connection(); + + EMSTORAGE_START_READ_TRANSACTION(input_transaction); + + if (input_get_mail_count == 0) { /* without mail count */ + col_index = 12; + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s FROM mail_box_tbl AS MBT %s", fields, input_conditional_clause); + } + else { /* with read count and total count */ + col_index = 14; + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s, total, read FROM mail_box_tbl AS MBT LEFT OUTER JOIN (SELECT mailbox_name, count(mail_id) AS total, SUM(flags_seen_field) AS read FROM mail_tbl GROUP BY mailbox_name) AS MT ON MBT.mailbox_name = MT.mailbox_name %s", fields, input_conditional_clause); + } + + EM_DEBUG_LOG("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; }, + ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))) + + EM_DEBUG_LOG("result count [%d]", count); + + if(count == 0) { + EM_DEBUG_EXCEPTION("Can't find mailbox"); + error = EMAIL_ERROR_MAILBOX_NOT_FOUND; + goto FINISH_OFF; + } + + if ((p_data_tbl = (emstorage_mailbox_tbl_t*)em_malloc(sizeof(emstorage_mailbox_tbl_t) * count)) == NULL) { + EM_DEBUG_EXCEPTION("malloc failed..."); + error = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + for (i = 0; i < count; i++) { + _get_table_field_data_int(result, &(p_data_tbl[i].mailbox_id), col_index++); + _get_table_field_data_int(result, &(p_data_tbl[i].account_id), col_index++); + _get_table_field_data_int(result, &(p_data_tbl[i].local_yn), col_index++); + _get_table_field_data_string(result, &(p_data_tbl[i].mailbox_name), 0, col_index++); + _get_table_field_data_int(result, (int*)&(p_data_tbl[i].mailbox_type), col_index++); + _get_table_field_data_string(result, &(p_data_tbl[i].alias), 0, col_index++); + _get_table_field_data_int(result, &(p_data_tbl[i].sync_with_server_yn), col_index++); + _get_table_field_data_int(result, &(p_data_tbl[i].modifiable_yn), col_index++); + _get_table_field_data_int(result, &(p_data_tbl[i].total_mail_count_on_server), col_index++); + _get_table_field_data_int(result, &(p_data_tbl[i].has_archived_mails), col_index++); + _get_table_field_data_int(result, &(p_data_tbl[i].mail_slot_size), col_index++); + _get_table_field_data_int(result, (int*)&(p_data_tbl[i].last_sync_time), col_index++); + + if (input_get_mail_count == 1) { + _get_table_field_data_int(result, &(total_count), col_index++); + p_data_tbl[i].total_mail_count_on_local = total_count; + _get_table_field_data_int(result, &(read_count), col_index++); + p_data_tbl[i].unread_count = total_count - read_count; /* return unread count, NOT */ + } + } + + +FINISH_OFF: + if (result) + sqlite3_free_table(result); + + if (error == EMAIL_ERROR_NONE) { + *output_mailbox_list = p_data_tbl; + *output_mailbox_count = count; + EM_DEBUG_LOG("Mailbox Count [ %d]", count); + } + else if (p_data_tbl != NULL) + emstorage_free_mailbox(&p_data_tbl, count, NULL); + + if (hStmt != NULL) { + rc = sqlite3_finalize(hStmt); + if (rc != SQLITE_OK) { + EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); + + error = EMAIL_ERROR_DB_FAILURE; + } + } + + EMSTORAGE_FINISH_READ_TRANSACTION(input_transaction); + _DISCONNECT_DB; + + EM_DEBUG_FUNC_END("error [%d]", error); + return error; +} /* Query series --------------------------------------------------------------*/ -INTERNAL_FUNC int emstorage_check_duplicated_account(emf_account_t* account, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_check_duplicated_account(email_account_t* account, int transaction, int *err_code) { EM_DEBUG_FUNC_BEGIN(); if (!account) { if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char **result; int count; char sql_query_string[QUERY_SIZE] = {0, }; @@ -2524,20 +2884,20 @@ INTERNAL_FUNC int emstorage_check_duplicated_account(emf_account_t* account, int SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_account_tbl " " WHERE " - " email_addr = '%s' AND " - " user_name = '%s' AND " - " receiving_server_type = %d AND " - " receiving_server_addr = '%s' AND " - " sending_user = '%s' AND " - " sending_server_type = %d AND " - " sending_server_addr = '%s'; ", - account->email_addr, - account->user_name, account->receiving_server_type, account->receiving_server_addr, - account->sending_user, account->sending_server_type, account->sending_server_addr + " user_email_address = '%s' AND " + " incoming_server_user_name = '%s' AND " + " incoming_server_type = %d AND " + " incoming_server_address = '%s' AND " + " outgoing_server_user_name = '%s' AND " + " outgoing_server_type = %d AND " + " outgoing_server_address = '%s'; ", + account->user_email_address, + account->incoming_server_user_name, account->incoming_server_type, account->incoming_server_address, + account->outgoing_server_user_name, account->outgoing_server_type, account->outgoing_server_address ); EM_DEBUG_LOG("Query[%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); count = atoi(result[1]); @@ -2547,12 +2907,12 @@ INTERNAL_FUNC int emstorage_check_duplicated_account(emf_account_t* account, int if (count == 0) { /* not duplicated account */ ret = true; - EM_DEBUG_LOG("NOT duplicated account: email_addr[%s]", account->email_addr); + EM_DEBUG_LOG("NOT duplicated account: user_email_address[%s]", account->user_email_address); } else { /* duplicated account */ ret = false; - EM_DEBUG_LOG("The same account already exists. Duplicated account: email_addr[%s]", account->email_addr); - error = EMF_ERROR_ALREADY_EXISTS; + EM_DEBUG_LOG("The same account already exists. Duplicated account: user_email_address[%s]", account->user_email_address); + error = EMAIL_ERROR_ALREADY_EXISTS; } FINISH_OFF: @@ -2574,12 +2934,12 @@ INTERNAL_FUNC int emstorage_get_account_count(int *count, int transaction, int * if (!count) { if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -2591,11 +2951,11 @@ INTERNAL_FUNC int emstorage_get_account_count(int *count, int transaction, int * EM_DEBUG_LOG("SQL STMT [ %s ]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG("Before sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); *count = sqlite3_column_int(hStmt, 0); @@ -2611,7 +2971,7 @@ FINISH_OFF: hStmt=NULL; if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d: %s", rc, err_msg); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } EM_DEBUG_LOG("sqlite3_finalize- %d", rc); } @@ -2632,54 +2992,55 @@ INTERNAL_FUNC int emstorage_get_account_list(int *select_num, emstorage_account_ EM_DEBUG_FUNC_BEGIN(); int i = 0, count = 0, rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int field_index = 0; + int error = EMAIL_ERROR_NONE; emstorage_account_tbl_t *p_data_tbl = NULL; - + char sql_query_string[QUERY_SIZE] = {0, }; + char *sql = "SELECT count(*) FROM mail_account_tbl;"; + char **result; + sqlite3 *local_db_handle = NULL; DB_STMT hStmt = NULL; if (!select_num || !account_list) { EM_DEBUG_EXCEPTION("select_num[%p], account_list[%p]", select_num, account_list); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - sqlite3 *local_db_handle = emstorage_get_db_connection(); + local_db_handle = emstorage_get_db_connection(); EMSTORAGE_START_READ_TRANSACTION(transaction); - - char sql_query_string[QUERY_SIZE] = {0, }; - char *sql = "SELECT count(*) FROM mail_account_tbl;"; - char **result; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); count = atoi(result[1]); sqlite3_free_table(result); - if (!count) { + EM_DEBUG_LOG("count = %d", rc); + + if (count == 0) { EM_DEBUG_EXCEPTION("no account found..."); - error = EMF_ERROR_ACCOUNT_NOT_FOUND; + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; ret = true; goto FINISH_OFF; } - EM_DEBUG_LOG("count = %d", rc); SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_account_tbl ORDER BY account_id"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG("After sqlite3_prepare_v2 hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION("no account found..."); - error = EMF_ERROR_ACCOUNT_NOT_FOUND; + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; count = 0; ret = true; goto FINISH_OFF; @@ -2687,89 +3048,99 @@ INTERNAL_FUNC int emstorage_get_account_list(int *select_num, emstorage_account_ if (!(p_data_tbl = (emstorage_account_tbl_t*)malloc(sizeof(emstorage_account_tbl_t) * count))) { EM_DEBUG_EXCEPTION("malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } memset(p_data_tbl, 0x00, sizeof(emstorage_account_tbl_t) * count); for (i = 0; i < count; i++) { /* get recordset */ - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].account_bind_type), ACCOUNT_BIND_TYPE_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].account_name), 0, ACCOUNT_NAME_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].receiving_server_type), RECEIVING_SERVER_TYPE_TYPE_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].receiving_server_addr), 0, RECEIVING_SERVER_ADDR_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].email_addr), 0, EMAIL_ADDR_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].user_name), 0, USER_NAME_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].password), 0, PASSWORD_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].retrieval_mode), RETRIEVAL_MODE_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].port_num), PORT_NUM_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].use_security), USE_SECURITY_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].sending_server_type), SENDING_SERVER_TYPE_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].sending_server_addr), 0, SENDING_SERVER_ADDR_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].sending_port_num), SENDING_PORT_NUM_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].sending_auth), SENDING_AUTH_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].sending_security), SENDING_SECURITY_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].sending_user), 0, SENDING_USER_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].sending_password), 0, SENDING_PASSWORD_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].display_name), 0, DISPLAY_NAME_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].reply_to_addr), 0, REPLY_TO_ADDR_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].return_addr), 0, RETURN_ADDR_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].account_id), ACCOUNT_ID_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].keep_on_server), KEEP_ON_SERVER_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].flag1), FLAG1_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].flag2), FLAG2_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].pop_before_smtp), POP_BEFORE_SMTP_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].apop), APOP_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].logo_icon_path), 0, LOGO_ICON_PATH_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].preset_account), PRESET_ACCOUNT_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].target_storage), TARGET_STORAGE_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].check_interval), CHECK_INTERVAL_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.priority), PRIORITY_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.keep_local_copy), KEEP_LOCAL_COPY_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.req_delivery_receipt), REQ_DELIVERY_RECEIPT_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.req_read_receipt), REQ_READ_RECEIPT_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.download_limit), DOWNLOAD_LIMIT_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.block_address), BLOCK_ADDRESS_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.block_subject), BLOCK_SUBJECT_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].options.display_name_from), 0, DISPLAY_NAME_FROM_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.reply_with_body), REPLY_WITH_BODY_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.forward_with_files), FORWARD_WITH_FILES_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.add_myname_card), ADD_MYNAME_CARD_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.add_signature), ADD_SIGNATURE_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].options.signature), 0, SIGNATURE_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.add_my_address_to_bcc), ADD_MY_ADDRESS_TO_BCC_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].my_account_id), MY_ACCOUNT_ID_IDX_IN_MAIL_ACCOUNT_TBL); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].index_color), INDEX_COLOR_IDX_IN_MAIL_ACCOUNT_TBL); + field_index = 0; + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl[i].account_id), field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].account_name), 0, field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].logo_icon_path), 0, field_index++); + _get_stmt_field_data_blob(hStmt, &(p_data_tbl[i].user_data), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].user_data_length), field_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl[i].account_svc_id), field_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl[i].sync_status), field_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl[i].sync_disabled), field_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl[i].default_mail_slot_size), field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].user_display_name), 0, field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].user_email_address), 0, field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].reply_to_address), 0, field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].return_address), 0, field_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl[i].incoming_server_type), field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].incoming_server_address), 0, field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].incoming_server_port_number), field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].incoming_server_user_name), 0, field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].incoming_server_password), 0, field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].incoming_server_secure_connection), field_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl[i].retrieval_mode), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].keep_mails_on_pop_server_after_download), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].check_interval), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].auto_download_size), field_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl[i].outgoing_server_type), field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].outgoing_server_address), 0, field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].outgoing_server_port_number), field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].outgoing_server_user_name), 0, field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].outgoing_server_password), 0, field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].outgoing_server_secure_connection), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].outgoing_server_need_authentication), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].outgoing_server_use_same_authenticator), field_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl[i].options.priority), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.keep_local_copy), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.req_delivery_receipt), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.req_read_receipt), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.download_limit), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.block_address), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.block_subject), field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].options.display_name_from), 0, field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.reply_with_body), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.forward_with_files), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.add_myname_card), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].options.add_signature), field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].options.signature), 0, field_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl[i].options.add_my_address_to_bcc), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].pop_before_smtp), field_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].incoming_server_requires_apop), field_index++); + _get_stmt_field_data_int(hStmt, (int *)&(p_data_tbl[i].smime_type), field_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].certificate_path), 0, field_index++); + _get_stmt_field_data_int(hStmt, (int *)&(p_data_tbl[i].cipher_type), field_index++); + _get_stmt_field_data_int(hStmt, (int *)&(p_data_tbl[i].digest_type), field_index++); + if (with_password == true) { /* get password from the secure storage */ - char recv_password_file_name[MAX_PW_FILE_NAME_LENGTH];/* = p_data_tbl[i].password; */ - char send_password_file_name[MAX_PW_FILE_NAME_LENGTH];;/* = p_data_tbl[i].sending_password; */ + char recv_password_file_name[MAX_PW_FILE_NAME_LENGTH]; + char send_password_file_name[MAX_PW_FILE_NAME_LENGTH]; - EM_SAFE_FREE(p_data_tbl[i].password); - EM_SAFE_FREE(p_data_tbl[i].sending_password); + EM_SAFE_FREE(p_data_tbl[i].incoming_server_password); + EM_SAFE_FREE(p_data_tbl[i].outgoing_server_password); /* get password file name */ - if ((error = _get_password_file_name(p_data_tbl[i].account_id, recv_password_file_name, send_password_file_name)) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("_get_password_file_name failed."); + if ((error = _get_password_file_name(p_data_tbl[i].account_id, recv_password_file_name, send_password_file_name)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("_get_password_file_name failed. [%d]", error); + error = EMAIL_ERROR_SECURED_STORAGE_FAILURE; goto FINISH_OFF; } /* read password from secure storage */ - if ((error = _read_password_from_secure_storage(recv_password_file_name, &(p_data_tbl[i].password))) < 0 ) { - EM_DEBUG_EXCEPTION("_read_password_from_secure_storage() failed..."); + if ((error = _read_password_from_secure_storage(recv_password_file_name, &(p_data_tbl[i].incoming_server_password))) < 0 ) { + EM_DEBUG_EXCEPTION("_read_password_from_secure_storage() failed. [%d]", error); + error = EMAIL_ERROR_SECURED_STORAGE_FAILURE; goto FINISH_OFF; } - EM_DEBUG_LOG("recv_password_file_name[%s], password[%s]", recv_password_file_name, p_data_tbl[i].password); + EM_DEBUG_LOG("recv_password_file_name[%s], incoming_server_password[%s]", recv_password_file_name, p_data_tbl[i].incoming_server_password); - if ((error = _read_password_from_secure_storage(send_password_file_name, &(p_data_tbl[i].sending_password))) < 0) { - EM_DEBUG_EXCEPTION("_read_password_from_secure_storage() failed..."); + if ((error = _read_password_from_secure_storage(send_password_file_name, &(p_data_tbl[i].outgoing_server_password))) < 0) { + EM_DEBUG_EXCEPTION("_read_password_from_secure_storage() failed. [%d]", error); + error = EMAIL_ERROR_SECURED_STORAGE_FAILURE; goto FINISH_OFF; } - EM_DEBUG_LOG("send_password_file_name[%s], password[%s]", send_password_file_name, p_data_tbl[i].sending_password); + EM_DEBUG_LOG("send_password_file_name[%s], password[%s]", send_password_file_name, p_data_tbl[i].outgoing_server_password); } EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); EM_DEBUG_LOG("after sqlite3_step(), i = %d, rc = %d.", i, rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); } @@ -2783,6 +3154,7 @@ FINISH_OFF: } else if (p_data_tbl != NULL) emstorage_free_account(&p_data_tbl, count, NULL); + if (hStmt != NULL) { EM_DEBUG_LOG("Before sqlite3_finalize hStmt = %p", hStmt); @@ -2790,13 +3162,13 @@ FINISH_OFF: hStmt = NULL; if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } EMSTORAGE_FINISH_READ_TRANSACTION(transaction); _DISCONNECT_DB; - + if (err_code != NULL) *err_code = error; @@ -2809,13 +3181,13 @@ INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(int account_id, char *s { EM_DEBUG_FUNC_BEGIN("account_id [%d], server_mail_id[%s], mail[%p], transaction[%d], err_code[%p]", account_id, server_mail_id, mail, transaction, err_code); - int ret = false, error = EMF_ERROR_NONE, result_count; + int ret = false, error = EMAIL_ERROR_NONE, result_count; char conditional_clause[QUERY_SIZE] = {0, }; emstorage_mail_tbl_t* p_data_tbl = NULL; if (!server_mail_id || !mail) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - error = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -2845,13 +3217,13 @@ FINISH_OFF: } -static int _write_conditional_clause_for_getting_mail_list(int account_id, const char *mailbox_name, emf_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, int search_type, const char *search_value, emf_sort_type_t sorting, char *conditional_clause_string, int buffer_size, int *err_code) +static int _write_conditional_clause_for_getting_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, bool input_except_delete_flagged_mails, char *conditional_clause_string, int buffer_size, int *err_code) { int cur_clause = 0, conditional_clause_count = 0, i = 0; if (account_id < ALL_ACCOUNT) { EM_DEBUG_EXCEPTION("Invalid account_id [%d]", account_id); - EM_RETURN_ERR_CODE(err_code, EMF_ERROR_INVALID_PARAM, false); + EM_RETURN_ERR_CODE(err_code, EMAIL_ERROR_INVALID_PARAM, false); } /* where clause */ @@ -2866,10 +3238,10 @@ static int _write_conditional_clause_for_getting_mail_list(int account_id, const SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND account_id = %d", account_id); } - if (mailbox_name) { + if (mailbox_id > 0) { cur_clause += (conditional_clause_count++ == 0)? - SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE UPPER(mailbox_name) = UPPER('%s')", mailbox_name): - SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND UPPER(mailbox_name) = UPPER('%s')", mailbox_name); + SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE mailbox_id = %d", mailbox_id): + SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND mailbox_id = %d", mailbox_id); } else if(account_id != ALL_ACCOUNT) { cur_clause += (conditional_clause_count++ == 0)? @@ -2882,17 +3254,17 @@ static int _write_conditional_clause_for_getting_mail_list(int account_id, const SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE thread_id = %d ", thread_id): SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND thread_id = %d ", thread_id); } - else if (thread_id == EMF_LIST_TYPE_THREAD) { + else if (thread_id == EMAIL_LIST_TYPE_THREAD) { cur_clause += (conditional_clause_count++ == 0)? SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE thread_item_count > 0"): SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND thread_item_count > 0"); } - else if (thread_id == EMF_LIST_TYPE_LOCAL) { + else if (thread_id == EMAIL_LIST_TYPE_LOCAL) { cur_clause += (conditional_clause_count++ == 0)? SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE server_mail_status = 0"): SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND server_mail_status = 0"); } - else if (thread_id == EMF_LIST_TYPE_UNREAD) { + else if (thread_id == EMAIL_LIST_TYPE_UNREAD) { cur_clause += (conditional_clause_count++ == 0)? SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE flags_seen_field == 0"): SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND flags_seen_field == 0"); @@ -2921,31 +3293,37 @@ static int _write_conditional_clause_for_getting_mail_list(int account_id, const } } + if (input_except_delete_flagged_mails) { + cur_clause += (conditional_clause_count++ == 0)? + SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE flags_deleted_field = 0"): + SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND flags_deleted_field = 0"); + } + if (search_value) { switch (search_type) { - case EMF_SEARCH_FILTER_SUBJECT: + case EMAIL_SEARCH_FILTER_SUBJECT: cur_clause += SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, - " %s (UPPER(subject) LIKE UPPER(\'%%%%%s%%%%\')) ", conditional_clause_count++ ? "AND" : "WHERE", search_value); + " %s (UPPER(subject) LIKE UPPER(\'%%%%%s%%%%\') ESCAPE '\\') ", conditional_clause_count++ ? "AND" : "WHERE", search_value); break; - case EMF_SEARCH_FILTER_SENDER: + case EMAIL_SEARCH_FILTER_SENDER: cur_clause += SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, - " %s ((UPPER(full_address_from) LIKE UPPER(\'%%%%%s%%%%\')) " + " %s ((UPPER(full_address_from) LIKE UPPER(\'%%%%%s%%%%\') ESCAPE '\\') " ") ", conditional_clause_count++ ? "AND" : "WHERE", search_value); break; - case EMF_SEARCH_FILTER_RECIPIENT: + case EMAIL_SEARCH_FILTER_RECIPIENT: cur_clause += SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, - " %s ((UPPER(full_address_to) LIKE UPPER(\'%%%%%s%%%%\')) " - " OR (UPPER(full_address_cc) LIKE UPPER(\'%%%%%s%%%%\')) " - " OR (UPPER(full_address_bcc) LIKE UPPER(\'%%%%%s%%%%\')) " + " %s ((UPPER(full_address_to) LIKE UPPER(\'%%%%%s%%%%\') ESCAPE '\\') " + " OR (UPPER(full_address_cc) LIKE UPPER(\'%%%%%s%%%%\') ESCAPE '\\') " + " OR (UPPER(full_address_bcc) LIKE UPPER(\'%%%%%s%%%%\') ESCAPE '\\') " ") ", conditional_clause_count++ ? "AND" : "WHERE", search_value, search_value, search_value); break; - case EMF_SEARCH_FILTER_ALL: + case EMAIL_SEARCH_FILTER_ALL: cur_clause += SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, - " %s (UPPER(subject) LIKE UPPER(\'%%%%%s%%%%\') " - " OR (((UPPER(full_address_from) LIKE UPPER(\'%%%%%s%%%%\')) " - " OR (UPPER(full_address_to) LIKE UPPER(\'%%%%%s%%%%\')) " - " OR (UPPER(full_address_cc) LIKE UPPER(\'%%%%%s%%%%\')) " - " OR (UPPER(full_address_bcc) LIKE UPPER(\'%%%%%s%%%%\')) " + " %s (UPPER(subject) LIKE UPPER(\'%%%%%s%%%%\') ESCAPE '\\' " + " OR (((UPPER(full_address_from) LIKE UPPER(\'%%%%%s%%%%\') ESCAPE '\\') " + " OR (UPPER(full_address_to) LIKE UPPER(\'%%%%%s%%%%\') ESCAPE '\\') " + " OR (UPPER(full_address_cc) LIKE UPPER(\'%%%%%s%%%%\') ESCAPE '\\') " + " OR (UPPER(full_address_bcc) LIKE UPPER(\'%%%%%s%%%%\') ESCAPE '\\') " " ) " " )" ")", conditional_clause_count++ ? "AND" : "WHERE", search_value, search_value, search_value, search_value, search_value); @@ -2955,25 +3333,25 @@ static int _write_conditional_clause_for_getting_mail_list(int account_id, const /* EM_DEBUG_LOG("where clause [%s]", conditional_clause_string); */ static char sorting_str[][50] = { - " ORDER BY date_time DESC", /* case EMF_SORT_DATETIME_HIGH: */ - " ORDER BY date_time ASC", /* case EMF_SORT_DATETIME_LOW: */ - " ORDER BY full_address_from DESC, date_time DESC", /* case EMF_SORT_SENDER_HIGH: */ - " ORDER BY full_address_from ASC, date_time DESC", /* case EMF_SORT_SENDER_LOW: */ - " ORDER BY full_address_to DESC, date_time DESC", /* case EMF_SORT_RCPT_HIGH: */ - " ORDER BY full_address_to ASC, date_time DESC", /* case EMF_SORT_RCPT_LOW: */ - " ORDER BY subject DESC, date_time DESC", /* case EMF_SORT_SUBJECT_HIGH: */ - " ORDER BY subject ASC, date_time DESC", /* case EMF_SORT_SUBJECT_LOW: */ - " ORDER BY priority DESC, date_time DESC", /* case EMF_SORT_PRIORITY_HIGH: */ - " ORDER BY priority ASC, date_time DESC", /* case EMF_SORT_PRIORITY_LOW: */ - " ORDER BY attachment_count DESC, date_time DESC", /* case EMF_SORT_ATTACHMENT_HIGH: */ - " ORDER BY attachment_count ASC, date_time DESC", /* case EMF_SORT_ATTACHMENT_LOW: */ - " ORDER BY lock_status DESC, date_time DESC", /* case EMF_SORT_FAVORITE_HIGH: */ - " ORDER BY lock_status ASC, date_time DESC", /* case EMF_SORT_FAVORITE_LOW: */ - " ORDER BY mailbox_name DESC, date_time DESC", /* case EMF_SORT_MAILBOX_NAME_HIGH: */ - " ORDER BY mailbox_name ASC, date_time DESC" /* case EMF_SORT_MAILBOX_NAME_LOW: */ + " ORDER BY date_time DESC", /* case EMAIL_SORT_DATETIME_HIGH: */ + " ORDER BY date_time ASC", /* case EMAIL_SORT_DATETIME_LOW: */ + " ORDER BY full_address_from DESC, date_time DESC", /* case EMAIL_SORT_SENDER_HIGH: */ + " ORDER BY full_address_from ASC, date_time DESC", /* case EMAIL_SORT_SENDER_LOW: */ + " ORDER BY full_address_to DESC, date_time DESC", /* case EMAIL_SORT_RCPT_HIGH: */ + " ORDER BY full_address_to ASC, date_time DESC", /* case EMAIL_SORT_RCPT_LOW: */ + " ORDER BY subject DESC, date_time DESC", /* case EMAIL_SORT_SUBJECT_HIGH: */ + " ORDER BY subject ASC, date_time DESC", /* case EMAIL_SORT_SUBJECT_LOW: */ + " ORDER BY priority DESC, date_time DESC", /* case EMAIL_SORT_PRIORITY_HIGH: */ + " ORDER BY priority ASC, date_time DESC", /* case EMAIL_SORT_PRIORITY_LOW: */ + " ORDER BY attachment_count DESC, date_time DESC", /* case EMAIL_SORT_ATTACHMENT_HIGH: */ + " ORDER BY attachment_count ASC, date_time DESC", /* case EMAIL_SORT_ATTACHMENT_LOW: */ + " ORDER BY lock_status DESC, date_time DESC", /* case EMAIL_SORT_FAVORITE_HIGH: */ + " ORDER BY lock_status ASC, date_time DESC", /* case EMAIL_SORT_FAVORITE_LOW: */ + " ORDER BY mailbox_name DESC, date_time DESC", /* case EMAIL_SORT_MAILBOX_NAME_HIGH: */ + " ORDER BY mailbox_name ASC, date_time DESC" /* case EMAIL_SORT_MAILBOX_NAME_LOW: */ }; - if (sorting < EMF_SORT_END && sorting >= 0) + if (sorting < EMAIL_SORT_END && sorting >= 0) cur_clause += SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size, " %s", sorting_str[sorting]); else EM_DEBUG_LOG(" Invalid Sorting order "); @@ -2991,21 +3369,21 @@ static int _write_conditional_clause_for_getting_mail_list(int account_id, const * * */ -INTERNAL_FUNC int emstorage_get_mail_list(int account_id, const char *mailbox_name, emf_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, int search_type, const char *search_value, emf_sort_type_t sorting, int transaction, emf_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) { EM_DEBUG_FUNC_BEGIN(); EM_PROFILE_BEGIN(emstorage_get_mail_list_func); - int ret = false, error = EMF_ERROR_NONE; + int ret = false, error = EMAIL_ERROR_NONE; char conditional_clause_string[QUERY_SIZE] = { 0, }; if (account_id < ALL_ACCOUNT) { EM_DEBUG_EXCEPTION("Invalid account_id [%d]", account_id); - EM_RETURN_ERR_CODE(err_code, EMF_ERROR_INVALID_PARAM, false); + EM_RETURN_ERR_CODE(err_code, EMAIL_ERROR_INVALID_PARAM, false); } EM_IF_NULL_RETURN_VALUE(result_count, false); - _write_conditional_clause_for_getting_mail_list(account_id, mailbox_name, addr_list, thread_id, start_index, limit_count, search_type, search_value, sorting, conditional_clause_string, QUERY_SIZE, &error); + _write_conditional_clause_for_getting_mail_list(account_id, mailbox_id, addr_list, thread_id, start_index, limit_count, search_type, search_value, sorting, true, conditional_clause_string, QUERY_SIZE, &error); EM_DEBUG_LOG("conditional_clause_string[%s].", conditional_clause_string); @@ -3031,12 +3409,12 @@ FINISH_OFF: * * */ -INTERNAL_FUNC int emstorage_get_mails(int account_id, const char *mailbox_name, emf_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, int transaction, emstorage_mail_tbl_t** mail_list, int *result_count, int *err_code) +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) { EM_DEBUG_FUNC_BEGIN(); EM_PROFILE_BEGIN(emStorageGetMails); - int count = 0, ret = false, error = EMF_ERROR_NONE; + int count = 0, ret = false, error = EMAIL_ERROR_NONE; emstorage_mail_tbl_t *p_data_tbl = NULL; char conditional_clause_string[QUERY_SIZE] = {0, }; @@ -3044,13 +3422,13 @@ INTERNAL_FUNC int emstorage_get_mails(int account_id, const char *mailbox_name, EM_IF_NULL_RETURN_VALUE(result_count, false); if (!result_count || !mail_list || account_id < ALL_ACCOUNT) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - _write_conditional_clause_for_getting_mail_list(account_id, mailbox_name, addr_list, thread_id, start_index, limit_count, 0, NULL, sorting, conditional_clause_string, QUERY_SIZE, &error); + _write_conditional_clause_for_getting_mail_list(account_id, mailbox_id, addr_list, thread_id, start_index, limit_count, 0, NULL, sorting, true, conditional_clause_string, QUERY_SIZE, &error); EM_DEBUG_LOG("conditional_clause_string [%s]", conditional_clause_string); @@ -3085,23 +3463,27 @@ FINISH_OFF: * * */ -INTERNAL_FUNC int emstorage_get_searched_mail_list(int account_id, const char *mailbox_name, int thread_id, int search_type, const char *search_value, int start_index, int limit_count, emf_sort_type_t sorting, int transaction, emf_mail_list_item_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) { EM_DEBUG_FUNC_BEGIN(); - int ret = false, error = EMF_ERROR_NONE; + int ret = false, error = EMAIL_ERROR_NONE; char conditional_clause[QUERY_SIZE] = {0, }; - + char *temp_search_value = (char *)search_value; + EM_IF_NULL_RETURN_VALUE(mail_list, false); EM_IF_NULL_RETURN_VALUE(result_count, false); if (!result_count || !mail_list || account_id < ALL_ACCOUNT) { EM_DEBUG_EXCEPTION("select_num[%p], Mail_list[%p]", result_count, mail_list); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - _write_conditional_clause_for_getting_mail_list(account_id, mailbox_name, NULL, thread_id, start_index, limit_count, search_type, search_value, sorting, conditional_clause, QUERY_SIZE, &error); + temp_search_value = em_replace_all_string(temp_search_value, "_", "\\_"); + temp_search_value = em_replace_all_string(temp_search_value, "%", "\\%"); + + _write_conditional_clause_for_getting_mail_list(account_id, mailbox_id, NULL, thread_id, start_index, limit_count, search_type, temp_search_value, sorting, true, conditional_clause, QUERY_SIZE, &error); EM_DEBUG_LOG("conditional_clause[%s]", conditional_clause); @@ -3129,13 +3511,13 @@ static int _get_password_file_name(int account_id, char *recv_password_file_name if (account_id <= 0 || !recv_password_file_name || !send_password_file_name) { EM_DEBUG_EXCEPTION("Invalid parameter"); - return EMF_ERROR_INVALID_PARAM; + 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_FUNC_END(); - return EMF_ERROR_NONE; + return EMAIL_ERROR_NONE; } static int _read_password_from_secure_storage(char *file_name, char **password) @@ -3144,17 +3526,18 @@ static int _read_password_from_secure_storage(char *file_name, char **password) if (!file_name || !password) { EM_DEBUG_EXCEPTION("Invalid Parameter"); - return EMF_ERROR_INVALID_PARAM; + return EMAIL_ERROR_INVALID_PARAM; } size_t buf_len = 0, read_len = 0; ssm_file_info_t sfi; char *temp_password = NULL; - int ret = EMF_ERROR_NONE; + int error_code_from_ssm = 0; + int ret = EMAIL_ERROR_NONE; - if (ssm_getinfo(file_name, &sfi, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { - EM_DEBUG_EXCEPTION("ssm_getinfo() failed."); - ret = EMF_ERROR_SYSTEM_FAILURE; + if ( (error_code_from_ssm = ssm_getinfo(file_name, &sfi, SSM_FLAG_SECRET_OPERATION, NULL)) < 0) { + EM_DEBUG_EXCEPTION("ssm_getinfo() failed. [%d]", error_code_from_ssm); + ret = EMAIL_ERROR_SECURED_STORAGE_FAILURE; goto FINISH_OFF; } @@ -3162,15 +3545,14 @@ static int _read_password_from_secure_storage(char *file_name, char **password) EM_DEBUG_LOG("password buf_len[%d]", buf_len); if ((temp_password = (char *)malloc(buf_len + 1)) == NULL) { EM_DEBUG_EXCEPTION("malloc failed..."); - - ret = EMF_ERROR_OUT_OF_MEMORY; + ret = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } memset(temp_password, 0x00, buf_len + 1); - if (ssm_read(file_name, temp_password, buf_len, &read_len, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { - EM_DEBUG_EXCEPTION("ssm_read() failed."); - ret = EMF_ERROR_SYSTEM_FAILURE; + if ( (error_code_from_ssm = ssm_read(file_name, temp_password, buf_len, &read_len, SSM_FLAG_SECRET_OPERATION, NULL)) < 0) { + EM_DEBUG_EXCEPTION("ssm_read() failed. [%d]", error_code_from_ssm); + ret = EMAIL_ERROR_SECURED_STORAGE_FAILURE; goto FINISH_OFF; } @@ -3194,12 +3576,12 @@ INTERNAL_FUNC int emstorage_get_account_by_id(int account_id, int pulloption, em if (!account) { EM_DEBUG_EXCEPTION("account_id[%d], account[%p]", account_id, account); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; emstorage_account_tbl_t* p_data_tbl = NULL; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -3215,24 +3597,71 @@ INTERNAL_FUNC int emstorage_get_account_by_id(int account_id, int pulloption, em SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT "); sql_len = strlen(sql_query_string); - if (pulloption & EMF_ACC_GET_OPT_DEFAULT) { - SNPRINTF(sql_query_string + sql_len, sizeof(sql_query_string) - sql_len, "account_bind_type, receiving_server_type, receiving_server_addr, email_addr, user_name, \ - retrieval_mode, port_num, use_security, sending_server_type, sending_server_addr, sending_port_num, sending_auth, sending_security, sending_user, \ - display_name, reply_to_addr, return_addr, account_id, keep_on_server, flag1, flag2, pop_before_smtp, apop, logo_icon_path, preset_account, target_storage, check_interval, index_color, sync_status, "); + if (pulloption & EMAIL_ACC_GET_OPT_DEFAULT) { + SNPRINTF(sql_query_string + sql_len, sizeof(sql_query_string) - sql_len, + "incoming_server_type," + "incoming_server_address," + "user_email_address," + "incoming_server_user_name," + "retrieval_mode," + "incoming_server_port_number," + "incoming_server_secure_connection," + "outgoing_server_type," + "outgoing_server_address," + "outgoing_server_port_number," + "outgoing_server_need_authentication," + "outgoing_server_secure_connection," + "outgoing_server_user_name," + "user_display_name," + "reply_to_address," + "return_address," + "account_id," + "keep_mails_on_pop_server_after_download," + "auto_download_size," + "outgoing_server_use_same_authenticator," + "pop_before_smtp," + "incoming_server_requires_apop," + "logo_icon_path," + "user_data," + "user_data_length," + "check_interval," + "sync_status,"); sql_len = strlen(sql_query_string); } - if (pulloption & EMF_ACC_GET_OPT_ACCOUNT_NAME) { + if (pulloption & EMAIL_ACC_GET_OPT_ACCOUNT_NAME) { SNPRINTF(sql_query_string + sql_len, sizeof(sql_query_string) - sql_len, " account_name, "); sql_len = strlen(sql_query_string); } /* get from secure storage, not from db */ - if (pulloption & EMF_ACC_GET_OPT_OPTIONS) { - SNPRINTF(sql_query_string + sql_len, sizeof(sql_query_string) - sql_len, " priority, keep_local_copy, req_delivery_receipt, req_read_receipt, download_limit, block_address, block_subject, display_name_from, \ - reply_with_body, forward_with_files, add_myname_card, add_signature, signature, add_my_address_to_bcc, my_account_id, "); + if (pulloption & EMAIL_ACC_GET_OPT_OPTIONS) { + SNPRINTF(sql_query_string + sql_len, sizeof(sql_query_string) - sql_len, + "priority," + "keep_local_copy," + "req_delivery_receipt," + "req_read_receipt," + "download_limit," + "block_address," + "block_subject," + "display_name_from," + "reply_with_body," + "forward_with_files," + "add_myname_card," + "add_signature," + "signature," + "add_my_address_to_bcc," + "account_svc_id," + "sync_disabled," + "default_mail_slot_size," + "smime_type," + "certificate_path," + "cipher_type," + "digest_type,"); + sql_len = strlen(sql_query_string); } + /* dummy value, FROM WHERE clause */ SNPRINTF(sql_query_string + sql_len, sizeof(sql_query_string) - sql_len, "0 FROM mail_account_tbl WHERE account_id = %d", account_id); @@ -3241,87 +3670,86 @@ INTERNAL_FUNC int emstorage_get_account_by_id(int account_id, int pulloption, em /* execute a sql and count rows */ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION("no matched account found..."); - error = EMF_ERROR_ACCOUNT_NOT_FOUND; + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; goto FINISH_OFF; } /* Assign query result to structure */ if (!(p_data_tbl = (emstorage_account_tbl_t *)malloc(sizeof(emstorage_account_tbl_t) * 1))) { EM_DEBUG_EXCEPTION("malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } memset(p_data_tbl, 0x00, sizeof(emstorage_account_tbl_t) * 1); int col_index = 0; - if (pulloption & EMF_ACC_GET_OPT_DEFAULT) { - _get_stmt_field_data_int(hStmt, &(p_data_tbl->account_bind_type), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->receiving_server_type), col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->receiving_server_addr), 0, col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->email_addr), 0, col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->user_name), 0, col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->retrieval_mode), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->port_num), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->use_security), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->sending_server_type), col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->sending_server_addr), 0, col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->sending_port_num), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->sending_auth), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->sending_security), col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->sending_user), 0, col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->display_name), 0, col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->reply_to_addr), 0, col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->return_addr), 0, col_index++); + if (pulloption & EMAIL_ACC_GET_OPT_DEFAULT) { + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->incoming_server_type), col_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->incoming_server_address), 0, col_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->user_email_address), 0, col_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->incoming_server_user_name), 0, col_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->retrieval_mode), col_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->incoming_server_port_number), col_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->incoming_server_secure_connection), col_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->outgoing_server_type), col_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->outgoing_server_address), 0, col_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->outgoing_server_port_number), col_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->outgoing_server_need_authentication), col_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->outgoing_server_secure_connection), col_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->outgoing_server_user_name), 0, col_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->user_display_name), 0, col_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->reply_to_address), 0, col_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->return_address), 0, col_index++); _get_stmt_field_data_int(hStmt, &(p_data_tbl->account_id), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->keep_on_server), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->flag1), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->flag2), col_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->keep_mails_on_pop_server_after_download), col_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->auto_download_size), col_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->outgoing_server_use_same_authenticator), col_index++); _get_stmt_field_data_int(hStmt, &(p_data_tbl->pop_before_smtp), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->apop), col_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->incoming_server_requires_apop), col_index++); _get_stmt_field_data_string(hStmt, &(p_data_tbl->logo_icon_path), 0, col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->preset_account), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->target_storage), col_index++); + _get_stmt_field_data_blob(hStmt, &p_data_tbl->user_data, col_index++); + _get_stmt_field_data_int(hStmt, &p_data_tbl->user_data_length, col_index++); _get_stmt_field_data_int(hStmt, &(p_data_tbl->check_interval), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->index_color), col_index++); _get_stmt_field_data_int(hStmt, &(p_data_tbl->sync_status), col_index++); } - if (pulloption & EMF_ACC_GET_OPT_ACCOUNT_NAME) + if (pulloption & EMAIL_ACC_GET_OPT_ACCOUNT_NAME) _get_stmt_field_data_string(hStmt, &(p_data_tbl->account_name), 0, col_index++); - if (pulloption & EMF_ACC_GET_OPT_PASSWORD) { + 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)) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("_get_password_file_name failed."); + if ((error = _get_password_file_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; } /* read password from secure storage */ - if ((error = _read_password_from_secure_storage(recv_password_file_name, &(p_data_tbl->password))) < 0) { - EM_DEBUG_EXCEPTION(" _read_password_from_secure_storage() failed..."); + if ((error = _read_password_from_secure_storage(recv_password_file_name, &(p_data_tbl->incoming_server_password))) < 0) { + EM_DEBUG_EXCEPTION(" _read_password_from_secure_storage() failed. [%d]", error); goto FINISH_OFF; } - EM_DEBUG_LOG("recv_password_file_name[%s], password[%s]", recv_password_file_name, p_data_tbl->password); + + EM_DEBUG_LOG("recv_password_file_name[%s], password[%s]", recv_password_file_name, p_data_tbl->incoming_server_password); - if ((error = _read_password_from_secure_storage(send_password_file_name, &(p_data_tbl->sending_password))) < 0) { - EM_DEBUG_EXCEPTION(" _read_password_from_secure_storage() failed..."); + if ((error = _read_password_from_secure_storage(send_password_file_name, &(p_data_tbl->outgoing_server_password))) < 0) { + EM_DEBUG_EXCEPTION(" _read_password_from_secure_storage() failed. [%d]", error); goto FINISH_OFF; } - EM_DEBUG_LOG("send_password_file_name[%s], password[%s]", send_password_file_name, p_data_tbl->sending_password); + EM_DEBUG_LOG("send_password_file_name[%s], password[%s]", send_password_file_name, p_data_tbl->outgoing_server_password); } - if (pulloption & EMF_ACC_GET_OPT_OPTIONS) { - _get_stmt_field_data_int(hStmt, &(p_data_tbl->options.priority), col_index++); + if (pulloption & EMAIL_ACC_GET_OPT_OPTIONS) { + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->options.priority), col_index++); _get_stmt_field_data_int(hStmt, &(p_data_tbl->options.keep_local_copy), col_index++); _get_stmt_field_data_int(hStmt, &(p_data_tbl->options.req_delivery_receipt), col_index++); _get_stmt_field_data_int(hStmt, &(p_data_tbl->options.req_read_receipt), col_index++); @@ -3334,8 +3762,14 @@ INTERNAL_FUNC int emstorage_get_account_by_id(int account_id, int pulloption, em _get_stmt_field_data_int(hStmt, &(p_data_tbl->options.add_myname_card), col_index++); _get_stmt_field_data_int(hStmt, &(p_data_tbl->options.add_signature), col_index++); _get_stmt_field_data_string(hStmt, &(p_data_tbl->options.signature), 0, col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->options.add_my_address_to_bcc), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->my_account_id), col_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->options.add_my_address_to_bcc), col_index++); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->account_svc_id), col_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->sync_disabled), col_index++); + _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->default_mail_slot_size), col_index++); + _get_stmt_field_data_int(hStmt, (int *)&(p_data_tbl->smime_type), col_index++); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->certificate_path), 0, col_index++); + _get_stmt_field_data_int(hStmt, (int *)&(p_data_tbl->cipher_type), col_index++); + _get_stmt_field_data_int(hStmt, (int *)&(p_data_tbl->digest_type), col_index++); } ret = true; @@ -3351,7 +3785,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -3370,21 +3804,21 @@ INTERNAL_FUNC int emstorage_get_password_length_of_account(int account_id, int * EM_DEBUG_FUNC_BEGIN("account_id[%d], password_length[%p], err_code[%p]", account_id, password_length, err_code); if (account_id <= 0 || password_length == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char recv_password_file_name[MAX_PW_FILE_NAME_LENGTH]; char send_password_file_name[MAX_PW_FILE_NAME_LENGTH]; char *temp_password = NULL; /* get password file name */ - if ((error = _get_password_file_name(account_id, recv_password_file_name, send_password_file_name)) != EMF_ERROR_NONE) { + if ((error = _get_password_file_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; } @@ -3411,18 +3845,18 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_update_account(int account_id, emstorage_account_tbl_t* account, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_update_account(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, transaction, err_code); + EM_DEBUG_FUNC_BEGIN("account_id[%d], account[%p], transaction[%d], err_code[%p]", account_id, account_tbl, transaction, err_code); - if (account_id < FIRST_ACCOUNT_ID || !account) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + if (account_id < FIRST_ACCOUNT_ID || !account_tbl) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int rc, ret = false; DB_STMT hStmt = NULL; @@ -3435,111 +3869,118 @@ INTERNAL_FUNC int emstorage_update_account(int account_id, emstorage_account_tbl SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_account_tbl SET" - " account_bind_type = ?" - ", account_name = ?" - ", receiving_server_type = ?" - ", receiving_server_addr = ?" - ", email_addr = ?" - ", user_name = ?" + " account_name = ?" + ", logo_icon_path = ?" + ", user_data = ?" + ", user_data_length = ?" + ", account_svc_id = ?" + ", sync_status = ?" + ", sync_disabled = ?" + ", default_mail_slot_size = ?" + ", user_display_name = ?" + ", user_email_address = ?" + ", reply_to_address = ?" + ", return_address = ?" + ", incoming_server_type = ?" + ", incoming_server_address = ?" + ", incoming_server_port_number = ?" + ", incoming_server_user_name = ?" + ", incoming_server_secure_connection = ?" ", retrieval_mode = ?" - ", port_num = ?" - ", use_security = ?" - ", sending_server_type = ?" - ", sending_server_addr = ?" - ", sending_port_num = ?" - ", sending_auth = ?" - ", sending_security = ?" - ", sending_user = ?" - ", display_name = ?" - ", reply_to_addr = ?" - ", return_addr = ?" - ", keep_on_server = ?" - ", flag1 = ?" - ", flag2 = ?" - ", pop_before_smtp = ?" /* POP before SMTP authentication */ - ", apop = ?" /* APOP authentication */ - ", logo_icon_path = ?" /* Receving Option : Account logo icon */ - ", preset_account = ?" /* Receving Option : Preset account or not */ - ", target_storage = ?" /* Receving Option : Specifies the targetStorage. 0 is phone, 1 is MMC */ - ", check_interval = ?" /* Receving Option : Specifies the check interval. Unit is minute */ - ", priority = ?" /* Sending Option : Specifies the prority. 1=high 3=normal 5=low */ - ", keep_local_copy = ?" /* Sending Option : */ - ", req_delivery_receipt = ?" /* Sending Option : */ - ", req_read_receipt = ?" /* Sending Option : */ - ", download_limit = ?" /* Sending Option : */ - ", block_address = ?" /* Sending Option : */ - ", block_subject = ?" /* Sending Option : */ - ", display_name_from = ?" /* Sending Option : */ - ", reply_with_body = ?" /* Sending Option : */ - ", forward_with_files = ?" /* Sending Option : */ - ", add_myname_card = ?" /* Sending Option : */ - ", add_signature = ?" /* Sending Option : */ - ", signature = ?" /* Sending Option : */ - ", add_my_address_to_bcc = ?" /* Sending Option : */ - ", my_account_id = ?" /* Support 'My Account' */ - ", index_color = ?" /* Index color */ - ", sync_status = ?" /* Sync Status */ + ", keep_mails_on_pop_server_after_download = ?" + ", check_interval = ?" + ", auto_download_size = ?" + ", outgoing_server_type = ?" + ", outgoing_server_address = ?" + ", outgoing_server_port_number = ?" + ", outgoing_server_user_name = ?" + ", outgoing_server_secure_connection = ?" + ", outgoing_server_need_authentication = ?" + ", outgoing_server_use_same_authenticator = ?" + ", priority = ?" + ", keep_local_copy = ?" + ", req_delivery_receipt = ?" + ", req_read_receipt = ?" + ", download_limit = ?" + ", block_address = ?" + ", block_subject = ?" + ", display_name_from = ?" + ", reply_with_body = ?" + ", forward_with_files = ?" + ", add_myname_card = ?" + ", add_signature = ?" + ", signature = ?" + ", add_my_address_to_bcc = ?" + ", pop_before_smtp = ?" + ", incoming_server_requires_apop = ?" + ", smime_type = ?" + ", certificate_path = ?" + ", cipher_type = ?" + ", digest_type = ?" " WHERE account_id = ?"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG("After sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, - ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + EM_DEBUG_LOG("SQL[%s]", sql_query_string); + EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("sqlite3_prepare fail:(%d) %s", rc, sqlite3_errmsg(local_db_handle))); int i = 0; - - _bind_stmt_field_data_int(hStmt, i++, account->account_bind_type); - _bind_stmt_field_data_string(hStmt, i++, (char *)account->account_name, 0, ACCOUNT_NAME_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, i++, account->receiving_server_type); - _bind_stmt_field_data_string(hStmt, i++, (char *)account->receiving_server_addr, 0, RECEIVING_SERVER_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, i++, (char *)account->email_addr, 0, EMAIL_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, i++, (char *)account->user_name, 0, USER_NAME_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, i++, account->retrieval_mode); - _bind_stmt_field_data_int(hStmt, i++, account->port_num); - _bind_stmt_field_data_int(hStmt, i++, account->use_security); - _bind_stmt_field_data_int(hStmt, i++, account->sending_server_type); - _bind_stmt_field_data_string(hStmt, i++, (char *)account->sending_server_addr, 0, SENDING_SERVER_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, i++, account->sending_port_num); - _bind_stmt_field_data_int(hStmt, i++, account->sending_auth); - _bind_stmt_field_data_int(hStmt, i++, account->sending_security); - _bind_stmt_field_data_string(hStmt, i++, (char *)account->sending_user, 0, SENDING_USER_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, i++, (char *)account->display_name, 0, DISPLAY_NAME_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, i++, (char *)account->reply_to_addr, 0, REPLY_TO_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, i++, (char *)account->return_addr, 0, RETURN_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, i++, account->keep_on_server); - _bind_stmt_field_data_int(hStmt, i++, account->flag1); - _bind_stmt_field_data_int(hStmt, i++, account->flag2); - _bind_stmt_field_data_int(hStmt, i++, account->pop_before_smtp); - _bind_stmt_field_data_int(hStmt, i++, account->apop); - _bind_stmt_field_data_string(hStmt, i++, account->logo_icon_path, 0, LOGO_ICON_PATH_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, i++, account->preset_account); - _bind_stmt_field_data_int(hStmt, i++, account->target_storage); - _bind_stmt_field_data_int(hStmt, i++, account->check_interval); - _bind_stmt_field_data_int(hStmt, i++, account->options.priority); - _bind_stmt_field_data_int(hStmt, i++, account->options.keep_local_copy); - _bind_stmt_field_data_int(hStmt, i++, account->options.req_delivery_receipt); - _bind_stmt_field_data_int(hStmt, i++, account->options.req_read_receipt); - _bind_stmt_field_data_int(hStmt, i++, account->options.download_limit); - _bind_stmt_field_data_int(hStmt, i++, account->options.block_address); - _bind_stmt_field_data_int(hStmt, i++, account->options.block_subject); - _bind_stmt_field_data_string(hStmt, i++, account->options.display_name_from, 0, DISPLAY_NAME_FROM_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, i++, account->options.reply_with_body); - _bind_stmt_field_data_int(hStmt, i++, account->options.forward_with_files); - _bind_stmt_field_data_int(hStmt, i++, account->options.add_myname_card); - _bind_stmt_field_data_int(hStmt, i++, account->options.add_signature); - _bind_stmt_field_data_string(hStmt, i++, account->options.signature, 0, SIGNATURE_LEN_IN_MAIL_ACCOUNT_TBL); - if (account->options.add_my_address_to_bcc != 0) - account->options.add_my_address_to_bcc = 1; - _bind_stmt_field_data_int(hStmt, i++, account->options.add_my_address_to_bcc); - _bind_stmt_field_data_int(hStmt, i++, account->my_account_id); - _bind_stmt_field_data_int(hStmt, i++, account->index_color); - _bind_stmt_field_data_int(hStmt, i++, account->sync_status); + + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->account_name, 0, ACCOUNT_NAME_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_string(hStmt, i++, account_tbl->logo_icon_path, 0, LOGO_ICON_PATH_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_blob(hStmt, i++, account_tbl->user_data, account_tbl->user_data_length); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->user_data_length); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->account_svc_id); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->sync_status); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->sync_disabled); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->default_mail_slot_size); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->user_display_name, 0, DISPLAY_NAME_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->user_email_address, 0, EMAIL_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->reply_to_address, 0, REPLY_TO_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->return_address, 0, RETURN_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->incoming_server_type); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->incoming_server_address, 0, RECEIVING_SERVER_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->incoming_server_port_number); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->incoming_server_user_name, 0, USER_NAME_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->incoming_server_secure_connection); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->retrieval_mode); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->keep_mails_on_pop_server_after_download); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->check_interval); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->auto_download_size); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->outgoing_server_type); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->outgoing_server_address, 0, SENDING_SERVER_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->outgoing_server_port_number); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->outgoing_server_user_name, 0, SENDING_USER_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->outgoing_server_secure_connection); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->outgoing_server_need_authentication); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->outgoing_server_use_same_authenticator); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.priority); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.keep_local_copy); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.req_delivery_receipt); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.req_read_receipt); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.download_limit); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.block_address); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.block_subject); + _bind_stmt_field_data_string(hStmt, i++, account_tbl->options.display_name_from, 0, DISPLAY_NAME_FROM_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.reply_with_body); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.forward_with_files); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.add_myname_card); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.add_signature); + _bind_stmt_field_data_string(hStmt, i++, account_tbl->options.signature, 0, SIGNATURE_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.add_my_address_to_bcc); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->pop_before_smtp); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->incoming_server_requires_apop); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->smime_type); + _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_int(hStmt, i++, account_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); /* validate account existence */ @@ -3547,35 +3988,35 @@ INTERNAL_FUNC int emstorage_update_account(int account_id, emstorage_account_tbl if (rc == 0) { EM_DEBUG_EXCEPTION(" no matched account found..."); - error = EMF_ERROR_ACCOUNT_NOT_FOUND; + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; goto FINISH_OFF; } /* get password file name */ - if ((error = _get_password_file_name(account_id, recv_password_file_name, send_password_file_name)) != EMF_ERROR_NONE) { + if ((error = _get_password_file_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; } /* save passwords to the secure storage */ - EM_DEBUG_LOG("save to the secure storage : recv_file[%s], recv_pass[%s], send_file[%s], send_pass[%s]", recv_password_file_name, account->password, send_password_file_name, account->sending_password); - if (account->password && (strlen(account->password) > 0)) { - if (ssm_write_buffer(account->password, strlen(account->password), recv_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { - EM_DEBUG_EXCEPTION(" ssm_write_buffer failed -recv password : file[%s]", recv_password_file_name); - error = EMF_ERROR_SYSTEM_FAILURE; + EM_DEBUG_LOG("save to the secure storage : recv_file[%s], recv_pass[%s], send_file[%s], send_pass[%s]", recv_password_file_name, account_tbl->incoming_server_password, send_password_file_name, account_tbl->outgoing_server_password); + if (account_tbl->incoming_server_password && (strlen(account_tbl->incoming_server_password) > 0)) { + if (ssm_write_buffer(account_tbl->incoming_server_password, strlen(account_tbl->incoming_server_password), recv_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { + EM_DEBUG_EXCEPTION(" ssm_write_buffer failed -recv incoming_server_password : file[%s]", recv_password_file_name); + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } } - if (account->sending_password && (strlen(account->sending_password) > 0)) { - if (ssm_write_buffer(account->sending_password, strlen(account->sending_password), send_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { + if (account_tbl->outgoing_server_password && (strlen(account_tbl->outgoing_server_password) > 0)) { + if (ssm_write_buffer(account_tbl->outgoing_server_password, strlen(account_tbl->outgoing_server_password), send_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { EM_DEBUG_EXCEPTION(" ssm_write_buffer failed -send password : file[%s]", send_password_file_name); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } } - if (!emstorage_notify_storage_event(NOTI_ACCOUNT_UPDATE, account->account_id, 0, NULL, 0)) + if (!emstorage_notify_storage_event(NOTI_ACCOUNT_UPDATE, account_tbl->account_id, 0, NULL, 0)) EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event[ NOTI_ACCOUNT_UPDATE] : Notification Failed >>> "); ret = true; @@ -3587,7 +4028,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -3602,18 +4043,60 @@ 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) +{ + EM_DEBUG_FUNC_BEGIN("account_id[%d], field_name[%s], value[%d], transaction[%d]", account_id, field_name, value, transaction); + int error = EMAIL_ERROR_NONE; + int rc = 0; + int result = 0; + char sql_query_string[QUERY_SIZE] = {0, }; + sqlite3 *local_db_handle = NULL; + + if (!account_id || !field_name) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + local_db_handle = emstorage_get_db_connection(); + + /* 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); + + EM_DEBUG_LOG("sql_query_string [%s]", sql_query_string); + + /* Execute query */ + EMSTORAGE_START_WRITE_TRANSACTION(transaction, error); + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + if (sqlite3_changes(local_db_handle) == 0) + EM_DEBUG_LOG("no mail matched..."); + + +FINISH_OFF: + result = (error == EMAIL_ERROR_NONE) ? true : false; + EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, result, error); + _DISCONNECT_DB; + + if (!emstorage_notify_storage_event(NOTI_ACCOUNT_UPDATE, account_id, 0, field_name, value)) + EM_DEBUG_EXCEPTION("emstorage_notify_storage_event failed : NOTI_ACCOUNT_UPDATE [%s,%d]", field_name, value); + + EM_DEBUG_FUNC_END("error [%d]", error); + return error; +} + INTERNAL_FUNC int emstorage_get_sync_status_of_account(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); if(!result_sync_status) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - int error = EMF_ERROR_NONE, rc, ret = false, sync_status, count, i, col_index; + 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(); @@ -3624,12 +4107,12 @@ INTERNAL_FUNC int emstorage_get_sync_status_of_account(int account_id, int *resu SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT sync_status FROM mail_account_tbl"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); if (!count) { EM_DEBUG_EXCEPTION("no matched account found..."); - error = EMF_ERROR_ACCOUNT_NOT_FOUND; + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; goto FINISH_OFF; } @@ -3658,11 +4141,11 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_update_sync_status_of_account(int account_id, emstorage_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) { 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 = EMF_ERROR_NONE, rc, ret = false, set_value = sync_status, result_sync_status; + 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(); @@ -3679,8 +4162,8 @@ INTERNAL_FUNC int emstorage_update_sync_status_of_account(int account_id, emstor set_value = result_sync_status & (~set_value); break; default: - EM_DEBUG_EXCEPTION("EMF_ERROR_NOT_SUPPORTED [%d]", set_operator); - error = EMF_ERROR_NOT_SUPPORTED; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_NOT_SUPPORTED [%d]", set_operator); + error = EMAIL_ERROR_NOT_SUPPORTED; break; } EM_DEBUG_LOG("set_value [%d]", set_value); @@ -3691,19 +4174,19 @@ INTERNAL_FUNC int emstorage_update_sync_status_of_account(int account_id, emstor 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); else - SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_account_tbl SET sync_status = %d WHERE receiving_server_type <> 5", set_value); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_account_tbl SET sync_status = %d WHERE incoming_server_type <> 5", set_value); EM_DEBUG_LOG("sql_query_string [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION("no matched account found..."); - error = EMF_ERROR_ACCOUNT_NOT_FOUND; + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; goto FINISH_OFF; } @@ -3724,19 +4207,20 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t* account, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t* account_tbl, int transaction, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account[%p], transaction[%d], err_code[%p]", account, transaction, err_code); + EM_DEBUG_FUNC_BEGIN("account[%p], transaction[%d], err_code[%p]", account_tbl, transaction, err_code); - if (!account) { - EM_DEBUG_EXCEPTION("account[%p], transaction[%d], err_code[%p]", account, transaction, err_code); + if (!account_tbl) { + EM_DEBUG_EXCEPTION("account[%p], transaction[%d], err_code[%p]", account_tbl, transaction, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; + int error_from_ssm = 0; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; char recv_password_file_name[MAX_PW_FILE_NAME_LENGTH]; @@ -3750,7 +4234,7 @@ INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t* account, int tr char **result = NULL; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); if (NULL==result[1]) rc = 1; @@ -3758,161 +4242,169 @@ INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t* account, int tr sqlite3_free_table(result); result = NULL; - account->account_id = rc; + account_tbl->account_id = rc; - if ((error = _get_password_file_name(account->account_id, recv_password_file_name, send_password_file_name)) != EMF_ERROR_NONE) { + if ((error = _get_password_file_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; } - EM_DEBUG_LOG(" >>>> ACCOUNT_ID [ %d ] ", account->account_id); + EM_DEBUG_LOG(" >>>> ACCOUNT_ID [ %d ] ", account_tbl->account_id); SNPRINTF(sql_query_string, sizeof(sql_query_string), "INSERT INTO mail_account_tbl VALUES " "( " - " ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " /* password - for receving */ - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " /* sending_password */ - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " /* POP before SMTP authentication */ - " , ? " /* APOP Authentication */ - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " - " , ? " /* add full_address_bcc */ - " , ? " /* my account id */ - " , ? " /* index_color */ - " , ? " /* Sync Status */ + " ? " /* account_id */ + " , ? " /* account_name */ + " , ? " /* logo_icon_path */ + " , ? " /* user_data */ + " , ? " /* user_data_length */ + " , ? " /* account_svc_id */ + " , ? " /* sync_status */ + " , ? " /* sync_disabled */ + " , ? " /* default_mail_slot_size */ + " , ? " /* user_display_name */ + " , ? " /* user_email_address */ + " , ? " /* reply_to_address */ + " , ? " /* return_address */ + " , ? " /* incoming_server_type */ + " , ? " /* incoming_server_address */ + " , ? " /* incoming_server_port_number */ + " , ? " /* incoming_server_user_name */ + " , ? " /* incoming_server_password */ + " , ? " /* incoming_server_secure_connection */ + " , ? " /* retrieval_mode */ + " , ? " /* keep_mails_on_pop_server_after_download */ + " , ? " /* check_interval */ + " , ? " /* auto_download_size */ + " , ? " /* outgoing_server_type */ + " , ? " /* outgoing_server_address */ + " , ? " /* outgoing_server_port_number */ + " , ? " /* outgoing_server_user_name */ + " , ? " /* outgoing_server_password */ + " , ? " /* outgoing_server_secure_connection */ + " , ? " /* outgoing_server_need_authentication */ + " , ? " /* outgoing_server_use_same_authenticator */ + " , ? " /* priority */ + " , ? " /* keep_local_copy */ + " , ? " /* req_delivery_receipt */ + " , ? " /* req_read_receipt */ + " , ? " /* download_limit */ + " , ? " /* block_address */ + " , ? " /* block_subject */ + " , ? " /* display_name_from */ + " , ? " /* reply_with_body */ + " , ? " /* forward_with_files */ + " , ? " /* add_myname_card */ + " , ? " /* add_signature */ + " , ? " /* signature */ + " , ? " /* add_my_address_to_bcc */ + " , ? " /* pop_before_smtp */ + " , ? " /* incoming_server_requires_apop */ + " , ? " /* smime_type */ + " , ? " /* certificate_path */ + " , ? " /* cipher_type */ + " , ? " /* digest_type */ ") "); - - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); EM_DEBUG_LOG(">>>> SQL STMT [ %s ] ", sql_query_string); - _bind_stmt_field_data_int(hStmt, ACCOUNT_BIND_TYPE_IDX_IN_MAIL_ACCOUNT_TBL, account->account_bind_type); - _bind_stmt_field_data_string(hStmt, ACCOUNT_NAME_IDX_IN_MAIL_ACCOUNT_TBL, (char *)account->account_name, 0, ACCOUNT_NAME_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, RECEIVING_SERVER_TYPE_TYPE_IDX_IN_MAIL_ACCOUNT_TBL, account->receiving_server_type); - _bind_stmt_field_data_string(hStmt, RECEIVING_SERVER_ADDR_IDX_IN_MAIL_ACCOUNT_TBL, (char *)account->receiving_server_addr, 0, RECEIVING_SERVER_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, EMAIL_ADDR_IDX_IN_MAIL_ACCOUNT_TBL, (char *)account->email_addr, 0, EMAIL_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, USER_NAME_IDX_IN_MAIL_ACCOUNT_TBL, (char *)account->user_name, 0, USER_NAME_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, PASSWORD_IDX_IN_MAIL_ACCOUNT_TBL, (char *)"", 0, PASSWORD_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, RETRIEVAL_MODE_IDX_IN_MAIL_ACCOUNT_TBL, account->retrieval_mode); - _bind_stmt_field_data_int(hStmt, PORT_NUM_IDX_IN_MAIL_ACCOUNT_TBL, account->port_num); - _bind_stmt_field_data_int(hStmt, USE_SECURITY_IDX_IN_MAIL_ACCOUNT_TBL, account->use_security); - _bind_stmt_field_data_int(hStmt, SENDING_SERVER_TYPE_IDX_IN_MAIL_ACCOUNT_TBL, account->sending_server_type); - _bind_stmt_field_data_string(hStmt, SENDING_SERVER_ADDR_IDX_IN_MAIL_ACCOUNT_TBL, (char *)account->sending_server_addr, 0, SENDING_SERVER_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, SENDING_PORT_NUM_IDX_IN_MAIL_ACCOUNT_TBL, account->sending_port_num); - _bind_stmt_field_data_int(hStmt, SENDING_AUTH_IDX_IN_MAIL_ACCOUNT_TBL, account->sending_auth); - _bind_stmt_field_data_int(hStmt, SENDING_SECURITY_IDX_IN_MAIL_ACCOUNT_TBL, account->sending_security); - _bind_stmt_field_data_string(hStmt, SENDING_USER_IDX_IN_MAIL_ACCOUNT_TBL, (char *)account->sending_user, 0, SENDING_USER_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, SENDING_PASSWORD_IDX_IN_MAIL_ACCOUNT_TBL, (char *)"", 0, SENDING_PASSWORD_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, DISPLAY_NAME_IDX_IN_MAIL_ACCOUNT_TBL, (char *)account->display_name, 0, DISPLAY_NAME_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, REPLY_TO_ADDR_IDX_IN_MAIL_ACCOUNT_TBL, (char *)account->reply_to_addr, 0, REPLY_TO_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_string(hStmt, RETURN_ADDR_IDX_IN_MAIL_ACCOUNT_TBL, (char *)account->return_addr, 0, RETURN_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, ACCOUNT_ID_IDX_IN_MAIL_ACCOUNT_TBL, account->account_id); - _bind_stmt_field_data_int(hStmt, KEEP_ON_SERVER_IDX_IN_MAIL_ACCOUNT_TBL, account->keep_on_server); - _bind_stmt_field_data_int(hStmt, FLAG1_IDX_IN_MAIL_ACCOUNT_TBL, account->flag1); - _bind_stmt_field_data_int(hStmt, FLAG2_IDX_IN_MAIL_ACCOUNT_TBL, account->flag2); - _bind_stmt_field_data_int(hStmt, POP_BEFORE_SMTP_IDX_IN_MAIL_ACCOUNT_TBL, account->pop_before_smtp); /* POP before SMTP authentication [deepam.p@siso.com] */ - _bind_stmt_field_data_int(hStmt, APOP_IDX_IN_MAIL_ACCOUNT_TBL, account->apop); /* APOP Support [deepam.p@siso.com] */ - _bind_stmt_field_data_string(hStmt, LOGO_ICON_PATH_IDX_IN_MAIL_ACCOUNT_TBL, account->logo_icon_path, 0, LOGO_ICON_PATH_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, PRESET_ACCOUNT_IDX_IN_MAIL_ACCOUNT_TBL, account->preset_account); - _bind_stmt_field_data_int(hStmt, TARGET_STORAGE_IDX_IN_MAIL_ACCOUNT_TBL, account->target_storage); - _bind_stmt_field_data_int(hStmt, CHECK_INTERVAL_IDX_IN_MAIL_ACCOUNT_TBL, account->check_interval); - _bind_stmt_field_data_int(hStmt, PRIORITY_IDX_IN_MAIL_ACCOUNT_TBL, account->options.priority); - _bind_stmt_field_data_int(hStmt, KEEP_LOCAL_COPY_IDX_IN_MAIL_ACCOUNT_TBL, account->options.keep_local_copy); - _bind_stmt_field_data_int(hStmt, REQ_DELIVERY_RECEIPT_IDX_IN_MAIL_ACCOUNT_TBL, account->options.req_delivery_receipt); - _bind_stmt_field_data_int(hStmt, REQ_READ_RECEIPT_IDX_IN_MAIL_ACCOUNT_TBL, account->options.req_read_receipt); - _bind_stmt_field_data_int(hStmt, DOWNLOAD_LIMIT_IDX_IN_MAIL_ACCOUNT_TBL, account->options.download_limit); - _bind_stmt_field_data_int(hStmt, BLOCK_ADDRESS_IDX_IN_MAIL_ACCOUNT_TBL, account->options.block_address); - _bind_stmt_field_data_int(hStmt, BLOCK_SUBJECT_IDX_IN_MAIL_ACCOUNT_TBL, account->options.block_subject); - _bind_stmt_field_data_string(hStmt, DISPLAY_NAME_FROM_IDX_IN_MAIL_ACCOUNT_TBL, account->options.display_name_from, 0, DISPLAY_NAME_FROM_LEN_IN_MAIL_ACCOUNT_TBL); - _bind_stmt_field_data_int(hStmt, REPLY_WITH_BODY_IDX_IN_MAIL_ACCOUNT_TBL, account->options.reply_with_body); - _bind_stmt_field_data_int(hStmt, FORWARD_WITH_FILES_IDX_IN_MAIL_ACCOUNT_TBL, account->options.forward_with_files); - _bind_stmt_field_data_int(hStmt, ADD_MYNAME_CARD_IDX_IN_MAIL_ACCOUNT_TBL, account->options.add_myname_card); - _bind_stmt_field_data_int(hStmt, ADD_SIGNATURE_IDX_IN_MAIL_ACCOUNT_TBL, account->options.add_signature); - _bind_stmt_field_data_string(hStmt, SIGNATURE_IDX_IN_MAIL_ACCOUNT_TBL, account->options.signature, 0, SIGNATURE_LEN_IN_MAIL_ACCOUNT_TBL); - if (account->options.add_my_address_to_bcc != 0) - account->options.add_my_address_to_bcc = 1; - _bind_stmt_field_data_int(hStmt, ADD_MY_ADDRESS_TO_BCC_IDX_IN_MAIL_ACCOUNT_TBL, account->options.add_my_address_to_bcc); - _bind_stmt_field_data_int(hStmt, MY_ACCOUNT_ID_IDX_IN_MAIL_ACCOUNT_TBL, account->my_account_id); - _bind_stmt_field_data_int(hStmt, INDEX_COLOR_IDX_IN_MAIL_ACCOUNT_TBL, account->index_color); - _bind_stmt_field_data_int(hStmt, SYNC_STATUS_IDX_IN_MAIL_ACCOUNT_TBL, account->sync_status); + int i = 0; + + _bind_stmt_field_data_int(hStmt, i++, account_tbl->account_id); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->account_name, 0, ACCOUNT_NAME_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_string(hStmt, i++, account_tbl->logo_icon_path, 0, LOGO_ICON_PATH_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_blob(hStmt, i++, account_tbl->user_data, account_tbl->user_data_length); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->user_data_length); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->account_svc_id); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->sync_status); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->sync_disabled); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->default_mail_slot_size); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->user_display_name, 0, DISPLAY_NAME_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->user_email_address, 0, EMAIL_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->reply_to_address, 0, REPLY_TO_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->return_address, 0, RETURN_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->incoming_server_type); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->incoming_server_address, 0, RECEIVING_SERVER_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->incoming_server_port_number); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->incoming_server_user_name, 0, USER_NAME_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char *)"", 0, PASSWORD_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->incoming_server_secure_connection); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->retrieval_mode); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->keep_mails_on_pop_server_after_download); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->check_interval); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->auto_download_size); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->outgoing_server_type); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->outgoing_server_address, 0, SENDING_SERVER_ADDR_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->outgoing_server_port_number); + _bind_stmt_field_data_string(hStmt, i++, (char *)account_tbl->outgoing_server_user_name, 0, SENDING_USER_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char *)"", 0, SENDING_PASSWORD_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->outgoing_server_secure_connection); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->outgoing_server_need_authentication); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->outgoing_server_use_same_authenticator); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.priority); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.keep_local_copy); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.req_delivery_receipt); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.req_read_receipt); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.download_limit); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.block_address); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.block_subject); + _bind_stmt_field_data_string(hStmt, i++, account_tbl->options.display_name_from, 0, DISPLAY_NAME_FROM_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.reply_with_body); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.forward_with_files); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.add_myname_card); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.add_signature); + _bind_stmt_field_data_string(hStmt, i++, account_tbl->options.signature, 0, SIGNATURE_LEN_IN_MAIL_ACCOUNT_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->options.add_my_address_to_bcc); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->pop_before_smtp); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->incoming_server_requires_apop); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->smime_type); + _bind_stmt_field_data_string(hStmt, i++, account_tbl->certificate_path, 0, FILE_NAME_LEN_IN_MAIL_CERTIFICATE_TBL); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->cipher_type); + _bind_stmt_field_data_int(hStmt, i++, account_tbl->digest_type); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d, errmsg = %s.", rc, sqlite3_errmsg(local_db_handle))); /* save passwords to the secure storage */ - EM_DEBUG_LOG("save to the secure storage : recv_file[%s], recv_pass[%s], send_file[%s], send_pass[%s]", recv_password_file_name, account->password, send_password_file_name, account->sending_password); - if (ssm_write_buffer(account->password, strlen(account->password), recv_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { - EM_DEBUG_EXCEPTION("ssm_write_buffer failed - recv password : file[%s]", recv_password_file_name); - error = EMF_ERROR_SYSTEM_FAILURE; + EM_DEBUG_LOG("save to the secure storage : recv_file[%s], send_file[%s]", recv_password_file_name, send_password_file_name); + if ( (error_from_ssm = ssm_write_buffer(account_tbl->incoming_server_password, strlen(account_tbl->incoming_server_password), recv_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL)) < 0) { + EM_DEBUG_EXCEPTION("ssm_write_buffer failed [%d] - recv password : file[%s]", error_from_ssm, recv_password_file_name); + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } - if (ssm_write_buffer(account->sending_password, strlen(account->sending_password), send_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { - EM_DEBUG_EXCEPTION("ssm_write_buffer failed - send password : file[%s]", send_password_file_name); - error = EMF_ERROR_SYSTEM_FAILURE; + if ( (error_from_ssm = ssm_write_buffer(account_tbl->outgoing_server_password, strlen(account_tbl->outgoing_server_password), send_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL)) < 0) { + EM_DEBUG_EXCEPTION("ssm_write_buffer failed [%d] - send password : file[%s]", error_from_ssm, send_password_file_name); + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } - if (!emstorage_notify_storage_event(NOTI_ACCOUNT_ADD, account->account_id, 0, NULL, 0)) - EM_DEBUG_EXCEPTION("emstorage_notify_storage_event[NOTI_ACCOUNT_ADD] : Notification failed"); ret = true; + + EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); + + if (!emstorage_notify_storage_event(NOTI_ACCOUNT_ADD, account_tbl->account_id, 0, NULL, 0)) + EM_DEBUG_EXCEPTION("emstorage_notify_storage_event[NOTI_ACCOUNT_ADD] : Notification failed"); FINISH_OFF: if (hStmt != NULL) { rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { - EM_DEBUG_LOG("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + EM_DEBUG_LOG("sqlite3_finalize failed [%d]", rc); + error = EMAIL_ERROR_DB_FAILURE; } } else EM_DEBUG_LOG("hStmt is NULL!!!"); - EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); _DISCONNECT_DB; if (err_code != NULL) @@ -3931,12 +4423,12 @@ INTERNAL_FUNC int emstorage_delete_account(int account_id, int transaction, int EM_DEBUG_EXCEPTION(" account_id[%d]", account_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; sqlite3 *local_db_handle = emstorage_get_db_connection(); EMSTORAGE_START_WRITE_TRANSACTION(transaction, error); @@ -3947,7 +4439,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)) != EMF_ERROR_NONE) { + if ((error = _get_password_file_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; } @@ -3957,28 +4449,28 @@ INTERNAL_FUNC int emstorage_delete_account(int account_id, int transaction, int SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_account_tbl WHERE account_id = %d", account_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_exec fail:%d", rc)); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); /* validate account existence */ rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION(" no matched account found..."); - error = EMF_ERROR_ACCOUNT_NOT_FOUND; + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; goto FINISH_OFF; } /* delete from secure storage */ if (ssm_delete_file(recv_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { EM_DEBUG_EXCEPTION(" ssm_delete_file failed -recv password : file[%s]", recv_password_file_name); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } if (ssm_delete_file(send_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { EM_DEBUG_EXCEPTION(" ssm_delete_file failed -send password : file[%s]", send_password_file_name); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } ret = true; @@ -3989,7 +4481,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -4009,12 +4501,12 @@ INTERNAL_FUNC int emstorage_free_account(emstorage_account_tbl_t** account_list, EM_DEBUG_FUNC_BEGIN("account_list[%p], count[%d], err_code[%p]", account_list, count, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (count > 0) { if (!account_list || !*account_list) { EM_DEBUG_EXCEPTION("account_list[%p], count[%d]", account_list, count); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -4023,19 +4515,21 @@ INTERNAL_FUNC int emstorage_free_account(emstorage_account_tbl_t** account_list, for (; i < count; i++) { EM_SAFE_FREE(p[i].account_name); - EM_SAFE_FREE(p[i].receiving_server_addr); - EM_SAFE_FREE(p[i].email_addr); - EM_SAFE_FREE(p[i].user_name); - EM_SAFE_FREE(p[i].password); - EM_SAFE_FREE(p[i].sending_server_addr); - EM_SAFE_FREE(p[i].sending_user); - EM_SAFE_FREE(p[i].sending_password); - EM_SAFE_FREE(p[i].display_name); - EM_SAFE_FREE(p[i].reply_to_addr); - EM_SAFE_FREE(p[i].return_addr); + EM_SAFE_FREE(p[i].incoming_server_address); + EM_SAFE_FREE(p[i].user_email_address); + EM_SAFE_FREE(p[i].user_data); + EM_SAFE_FREE(p[i].incoming_server_user_name); + EM_SAFE_FREE(p[i].incoming_server_password); + EM_SAFE_FREE(p[i].outgoing_server_address); + EM_SAFE_FREE(p[i].outgoing_server_user_name); + EM_SAFE_FREE(p[i].outgoing_server_password); + EM_SAFE_FREE(p[i].user_display_name); + EM_SAFE_FREE(p[i].reply_to_address); + EM_SAFE_FREE(p[i].return_address); EM_SAFE_FREE(p[i].logo_icon_path); EM_SAFE_FREE(p[i].options.display_name_from); EM_SAFE_FREE(p[i].options.signature); + EM_SAFE_FREE(p[i].certificate_path); } EM_SAFE_FREE(p); @@ -4060,12 +4554,12 @@ INTERNAL_FUNC int emstorage_get_mailbox_count(int account_id, int local_yn, int EM_DEBUG_EXCEPTION(" account_list[%d], local_yn[%d], count[%p]", account_id, local_yn, count); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -4076,7 +4570,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_count(int account_id, int local_yn, int char **result; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); *count = atoi(result[1]); @@ -4097,7 +4591,7 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_get_mailbox(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(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); @@ -4105,107 +4599,53 @@ INTERNAL_FUNC int emstorage_get_mailbox(int account_id, int local_yn, email_mail EM_DEBUG_EXCEPTION("Invalid parameters"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - int i = 0, rc, count = 0, ret = false, col_index; - int error = EMF_ERROR_NONE; - emstorage_mailbox_tbl_t* p_data_tbl = NULL; - char **result; - DB_STMT hStmt = NULL; - char sql_query_string[QUERY_SIZE] = {0, }; - char *fields = "mailbox_id, account_id, local_yn, mailbox_name, mailbox_type, alias, sync_with_server_yn, modifiable_yn, total_mail_count_on_server, has_archived_mails, mail_slot_size "; - - sqlite3 *local_db_handle = emstorage_get_db_connection(); - EMSTORAGE_START_READ_TRANSACTION(transaction); + int ret = false; + int error = EMAIL_ERROR_NONE; + char conditional_clause_string[QUERY_SIZE] = {0, }; if (account_id == ALL_ACCOUNT) { - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s FROM mail_box_tbl ", fields); - if (local_yn == EMF_MAILBOX_FROM_SERVER || local_yn == EMF_MAILBOX_FROM_LOCAL) - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " WHERE local_yn = %d ", local_yn); + if (local_yn == EMAIL_MAILBOX_FROM_SERVER || local_yn == EMAIL_MAILBOX_FROM_LOCAL) + SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " WHERE local_yn = %d ", local_yn); } else { - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s FROM mail_box_tbl WHERE account_id = %d ", fields, account_id); - if (local_yn == EMF_MAILBOX_FROM_SERVER || local_yn == EMF_MAILBOX_FROM_LOCAL) - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " AND local_yn = %d ", local_yn); + SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d ", account_id); + if (local_yn == EMAIL_MAILBOX_FROM_SERVER || local_yn == EMAIL_MAILBOX_FROM_LOCAL) + SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " AND local_yn = %d ", local_yn); } switch (sort_type) { case EMAIL_MAILBOX_SORT_BY_NAME_ASC : - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " ORDER BY mailbox_name ASC"); + SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " ORDER BY mailbox_name ASC"); break; case EMAIL_MAILBOX_SORT_BY_NAME_DSC : - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " ORDER BY mailbox_name DESC"); + SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " ORDER BY mailbox_name DESC"); break; case EMAIL_MAILBOX_SORT_BY_TYPE_ASC : - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " ORDER BY mailbox_type ASC"); + SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " ORDER BY mailbox_type ASC"); break; case EMAIL_MAILBOX_SORT_BY_TYPE_DSC : - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " ORDER BY mailbox_type DEC"); + SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " ORDER BY mailbox_type DEC"); break; } - EM_DEBUG_LOG("emstorage_get_mailbox : query[%s]", sql_query_string); + EM_DEBUG_LOG("conditional_clause_string[%s]", conditional_clause_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 = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, - ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))) - - if (!(p_data_tbl = (emstorage_mailbox_tbl_t*)malloc(sizeof(emstorage_mailbox_tbl_t) * count))) { - EM_DEBUG_EXCEPTION(" malloc failed..."); - - error = EMF_ERROR_OUT_OF_MEMORY; + if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error); goto FINISH_OFF; } - - memset(p_data_tbl, 0x00, sizeof(emstorage_mailbox_tbl_t)*count); - - col_index = 11; - - for (i = 0; i < count; i++) { - _get_table_field_data_int(result, &(p_data_tbl[i].mailbox_id), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].account_id), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].local_yn), col_index++); - _get_table_field_data_string(result, &(p_data_tbl[i].mailbox_name), 0, col_index++); - _get_table_field_data_int(result, (int *)&(p_data_tbl[i].mailbox_type), col_index++); - _get_table_field_data_string(result, &(p_data_tbl[i].alias), 0, col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].sync_with_server_yn), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].modifiable_yn), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].total_mail_count_on_server), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].has_archived_mails), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].mail_slot_size), col_index++); - } - + ret = true; FINISH_OFF: - if (result) - sqlite3_free_table(result); - - if (ret == true) { - *mailbox_list = p_data_tbl; - *select_num = count; - EM_DEBUG_LOG("Mailbox Count [ %d]", count); - } - else if (p_data_tbl != NULL) - emstorage_free_mailbox(&p_data_tbl, count, NULL); - - if (hStmt != NULL) { - rc = sqlite3_finalize(hStmt); - if (rc != SQLITE_OK) { - EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - - error = EMF_ERROR_DB_FAILURE; - } - } - - EMSTORAGE_FINISH_READ_TRANSACTION(transaction); - _DISCONNECT_DB; if (err_code != NULL) *err_code = error; @@ -4214,141 +4654,46 @@ FINISH_OFF: return ret; } - -INTERNAL_FUNC int emstorage_get_mailbox_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(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); - - if (!select_num || !mailbox_list) { - EM_DEBUG_EXCEPTION("Invalid parameters"); - - if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; - - return false; - } - int i = 0; - int rc; - int count = 0; int ret = false; - int col_index; - int error = EMF_ERROR_NONE; - emstorage_mailbox_tbl_t* p_data_tbl = NULL; - char **result; - DB_STMT hStmt = NULL; - char sql_query_string[QUERY_SIZE] = {0, }; - char *fields = "MBT.mailbox_id, MBT.account_id, local_yn, MBT.mailbox_name, MBT.mailbox_type, alias, sync_with_server_yn, modifiable_yn, total_mail_count_on_server, has_archived_mails, mail_slot_size "; - int add = 0; - int read_count = 0; - int total_count = 0; - - sqlite3 *local_db_handle = emstorage_get_db_connection(); - EMSTORAGE_START_READ_TRANSACTION(transaction); + int error = EMAIL_ERROR_NONE; + int where_clause_count = 0; + char conditional_clause_string[QUERY_SIZE] = {0, }; - add = 0; - if (with_count == 0) { /* without count */ - col_index = 11; - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s FROM mail_box_tbl AS MBT", fields); - if (account_id > ALL_ACCOUNT) { - add = 1; - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " WHERE account_id = %d ", account_id); - } - } - else { /* with read count and total count */ - col_index = 13; - if (account_id > ALL_ACCOUNT) { - add = 1; - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s, total, read FROM mail_box_tbl AS MBT LEFT OUTER JOIN (SELECT mailbox_name, count(mail_id) AS total, SUM(flags_seen_field) AS read FROM mail_tbl WHERE account_id = %d GROUP BY mailbox_name) AS MT ON MBT.mailbox_name = MT.mailbox_name WHERE account_id = %d ", fields, account_id, account_id); - } - else { - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s, total, read FROM mail_box_tbl AS MBT LEFT OUTER JOIN (SELECT mailbox_name, count(mail_id) AS total, SUM(flags_seen_field) AS read FROM mail_tbl GROUP BY mailbox_name) AS MT ON MBT.mailbox_name = MT.mailbox_name ", fields); - } + if (!select_num || !mailbox_list) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + error = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; } - if (local_yn == EMF_MAILBOX_FROM_SERVER || local_yn == EMF_MAILBOX_FROM_LOCAL) { - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " %s local_yn = %d ", (add ? "WHERE" : "AND"), local_yn); + if (local_yn == EMAIL_MAILBOX_FROM_SERVER || local_yn == EMAIL_MAILBOX_FROM_LOCAL) { + SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), "WHERE local_yn = %d ", local_yn); + where_clause_count++; } - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " ORDER BY MBT.mailbox_name "); - EM_DEBUG_LOG("query[%s]", sql_query_string); + if (account_id > 0) { + if (where_clause_count == 0) { + SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " WHERE "); + SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " account_id = %d ", account_id); + } + else + SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " AND account_id = %d ", account_id); + } - 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 = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, - ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))) - - EM_DEBUG_LOG("result count [%d]", count); + SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " ORDER BY MBT.mailbox_name "); + EM_DEBUG_LOG("conditional_clause_string[%s]", conditional_clause_string); - if (!(p_data_tbl = (emstorage_mailbox_tbl_t*)malloc(sizeof(emstorage_mailbox_tbl_t) * count))) { - EM_DEBUG_EXCEPTION("malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, 1, 1, mailbox_list, select_num)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error); goto FINISH_OFF; } - - memset(p_data_tbl, 0x00, sizeof(emstorage_mailbox_tbl_t)*count); - - for (i = 0; i < count; i++) { - _get_table_field_data_int(result, &(p_data_tbl[i].mailbox_id), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].account_id), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].local_yn), col_index++); - _get_table_field_data_string(result, &(p_data_tbl[i].mailbox_name), 0, col_index++); - _get_table_field_data_int(result, (int *)&(p_data_tbl[i].mailbox_type), col_index++); - _get_table_field_data_string(result, &(p_data_tbl[i].alias), 0, col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].sync_with_server_yn), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].modifiable_yn), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].total_mail_count_on_server), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].has_archived_mails), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].mail_slot_size), col_index++); - if (with_count == 1) { - _get_table_field_data_int(result, &(total_count), col_index++); - p_data_tbl[i].total_mail_count_on_local = total_count; - _get_table_field_data_int(result, &(read_count), col_index++); - p_data_tbl[i].unread_count = total_count - read_count; /* return unread count, NOT */ - } - /* - EM_DEBUG_LOG("[%d]", i); - EM_DEBUG_LOG("p_data_tbl[%d].mailbox_id[%d]", i, p_data_tbl[i].mailbox_id); - EM_DEBUG_LOG("p_data_tbl[%d].account_id[%d]", i, p_data_tbl[i].account_id); - EM_DEBUG_LOG("p_data_tbl[%d].local_yn[%d]", i, p_data_tbl[i].local_yn); - EM_DEBUG_LOG("p_data_tbl[%d].mailbox_name[%s]", i, p_data_tbl[i].mailbox_name); - EM_DEBUG_LOG("p_data_tbl[%d].mailbox_type[%d]", i, p_data_tbl[i].mailbox_type); - EM_DEBUG_LOG("p_data_tbl[%d].alias[%s]", i, p_data_tbl[i].alias); - EM_DEBUG_LOG("p_data_tbl[%d].sync_with_server_yn[%d]", i, p_data_tbl[i].sync_with_server_yn); - EM_DEBUG_LOG("p_data_tbl[%d].modifiable_yn[%d]", i, p_data_tbl[i].modifiable_yn); - EM_DEBUG_LOG("p_data_tbl[%d].has_archived_mails[%d]", i, p_data_tbl[i].has_archived_mails); - EM_DEBUG_LOG("p_data_tbl[%d].mail_slot_size[%d]", i, p_data_tbl[i].mail_slot_size); - EM_DEBUG_LOG("p_data_tbl[%d].unread_count[%d]", i, p_data_tbl[i].unread_count); - EM_DEBUG_LOG("p_data_tbl[%d].total_mail_count_on_local[%d]", i, p_data_tbl[i].total_mail_count_on_local); - EM_DEBUG_LOG("p_data_tbl[%d].total_mail_count_on_server[%d]", i, p_data_tbl[i].total_mail_count_on_server); - */ - } - ret = true; FINISH_OFF: - if (result) - sqlite3_free_table(result); - - if (ret == true) { - *mailbox_list = p_data_tbl; - *select_num = count; - EM_DEBUG_LOG("Mailbox Count [ %d]", count); - } - else if (p_data_tbl != NULL) - emstorage_free_mailbox(&p_data_tbl, count, NULL); - - if (hStmt != NULL) { - rc = sqlite3_finalize(hStmt); - if (rc != SQLITE_OK) { - EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - - error = EMF_ERROR_DB_FAILURE; - } - } - - EMSTORAGE_FINISH_READ_TRANSACTION(transaction); - _DISCONNECT_DB; if (err_code != NULL) *err_code = error; @@ -4364,71 +4709,29 @@ INTERNAL_FUNC int emstorage_get_child_mailbox_list(int account_id, char *parent_ EM_DEBUG_EXCEPTION("account_id[%d], parent_mailbox_name[%p], select_num[%p], mailbox_list[%p]", account_id, parent_mailbox_name, select_num, mailbox_list); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - int i = 0, rc, count = 0, ret = false, col_index; - int error = EMF_ERROR_NONE; - emstorage_mailbox_tbl_t* p_data_tbl = NULL; - char **result; - char sql_query_string[QUERY_SIZE] = {0, }; - char *fields = "mailbox_id, account_id, local_yn, mailbox_name, mailbox_type, alias, sync_with_server_yn, modifiable_yn, total_mail_count_on_server, has_archived_mails, mail_slot_size "; - - sqlite3 *local_db_handle = emstorage_get_db_connection(); - EMSTORAGE_START_READ_TRANSACTION(transaction); + int ret = false; + int error = EMAIL_ERROR_NONE; + char conditional_clause_string[QUERY_SIZE] = {0, }; if (parent_mailbox_name) - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s FROM mail_box_tbl WHERE account_id = %d AND UPPER(mailbox_name) LIKE UPPER('%s/%%') ORDER BY mailbox_name", fields, account_id, parent_mailbox_name); + SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND UPPER(mailbox_name) LIKE UPPER('%s/%%') ORDER BY mailbox_name", account_id, parent_mailbox_name); else - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s FROM mail_box_tbl WHERE account_id = %d AND (mailbox_name NOT LIKE '%%/%%') ORDER BY mailbox_name", fields, account_id); - - EM_DEBUG_LOG("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 = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, - ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND (mailbox_name NOT LIKE '%%/%%') ORDER BY mailbox_name", account_id); + EM_DEBUG_LOG("conditional_clause_string", conditional_clause_string); - if (!(p_data_tbl = (emstorage_mailbox_tbl_t*)malloc(sizeof(emstorage_mailbox_tbl_t) * count))) { - EM_DEBUG_EXCEPTION(" malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error); goto FINISH_OFF; } - - memset(p_data_tbl, 0x00, sizeof(emstorage_mailbox_tbl_t)*count); - col_index = 11; - - for (i = 0; i < count; i++) { - _get_table_field_data_int(result, &(p_data_tbl[i].mailbox_id), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].account_id), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].local_yn), col_index++); - _get_table_field_data_string(result, &(p_data_tbl[i].mailbox_name), 0, col_index++); - _get_table_field_data_int(result, (int *)&(p_data_tbl[i].mailbox_type), col_index++); - _get_table_field_data_string(result, &(p_data_tbl[i].alias), 0, col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].sync_with_server_yn), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].modifiable_yn), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].total_mail_count_on_server), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].has_archived_mails), col_index++); - _get_table_field_data_int(result, &(p_data_tbl[i].mail_slot_size), col_index++); - } - - if (result) - sqlite3_free_table(result); ret = true; FINISH_OFF: - if (ret == true) { - *mailbox_list = p_data_tbl; - *select_num = count; - EM_DEBUG_LOG(" Mailbox Count [ %d] ", count); - } - else if (p_data_tbl != NULL) - emstorage_free_mailbox(&p_data_tbl, count, NULL); - - EMSTORAGE_FINISH_READ_TRANSACTION(transaction); - _DISCONNECT_DB; if (err_code != NULL) *err_code = error; @@ -4441,100 +4744,29 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_modifiable_yn(int account_id, int loc { 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) { - EM_DEBUG_EXCEPTION("\account_id[%d], local_yn[%d], select_num[%p], mailbox_list[%p]", account_id, local_yn, select_num, mailbox_list); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; + return false; } - int i = 0, rc, count = 0, ret = false; - int error = EMF_ERROR_NONE; - emstorage_mailbox_tbl_t* p_data_tbl = NULL; - DB_STMT hStmt = NULL; - char sql_query_string[QUERY_SIZE] = {0, }; - char *fields = "mailbox_id, account_id, local_yn, mailbox_name, mailbox_type, alias, sync_with_server_yn, modifiable_yn, total_mail_count_on_server, has_archived_mails, mail_slot_size "; - - sqlite3 *local_db_handle = emstorage_get_db_connection(); - EMSTORAGE_START_READ_TRANSACTION(transaction); - - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s FROM mail_box_tbl WHERE account_id = %d AND modifiable_yn = 0 ORDER BY mailbox_name", fields, account_id); - EM_DEBUG_LOG("sql[%s]", sql_query_string); - + int ret = false; + int error = EMAIL_ERROR_NONE; + char conditional_clause_string[QUERY_SIZE] = {0, }; - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, - ("sqlite3_step fail:%d", rc)); - - char **result; - - 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 = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, - ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); - - sqlite3_free_table(result); - if (count == 0) { - EM_DEBUG_EXCEPTION(" no mailbox_name found..."); - - ret = true; - goto FINISH_OFF; - } + SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND modifiable_yn = 0 ORDER BY mailbox_name", account_id); + EM_DEBUG_LOG("conditional_clause_string [%s]", conditional_clause_string); - if (!(p_data_tbl = (emstorage_mailbox_tbl_t*)malloc(sizeof(emstorage_mailbox_tbl_t) * count))) { - EM_DEBUG_EXCEPTION(" malloc failed..."); - - error = EMF_ERROR_OUT_OF_MEMORY; + if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error); goto FINISH_OFF; } - memset(p_data_tbl, 0x00, sizeof(emstorage_mailbox_tbl_t)*count); - - int col_index = 0; - for (i = 0; i < count; i++) { - col_index = 0; - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].mailbox_id), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].account_id), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].local_yn), col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].mailbox_name), 0, col_index++); - _get_stmt_field_data_int(hStmt, (int *)&(p_data_tbl[i].mailbox_type), col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].alias), 0, col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].sync_with_server_yn), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].modifiable_yn), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].total_mail_count_on_server), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].has_archived_mails), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].mail_slot_size), col_index++); - - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, - ("sqlite3_step fail:%d", rc)); - } - ret = true; FINISH_OFF: - if (ret == true) { - *mailbox_list = p_data_tbl; - *select_num = count; - EM_DEBUG_LOG("Mailbox Count[%d]", count); - } - else if (p_data_tbl != NULL) - emstorage_free_mailbox(&p_data_tbl, count, NULL); - - if (hStmt != NULL) { - EM_DEBUG_LOG("Before sqlite3_finalize hStmt = %p", hStmt); - - rc = sqlite3_finalize(hStmt); - if (rc != SQLITE_OK) { - EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; - } - } - EMSTORAGE_FINISH_READ_TRANSACTION(transaction); - _DISCONNECT_DB; if (err_code != NULL) *err_code = error; @@ -4543,7 +4775,52 @@ FINISH_OFF: return ret; } +INTERNAL_FUNC int emstorage_stamp_last_sync_time_of_mailbox(int input_mailbox_id, int input_transaction) +{ + EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_transaction [%d]", input_mailbox_id, input_transaction); + + int result_code = false; + int error = EMAIL_ERROR_NONE; + int rc; + time_t current_time = 0; + char sql_query_string[QUERY_SIZE] = {0, }; + sqlite3 *local_db_handle = NULL; + + if (!input_mailbox_id ) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + time(¤t_time); + + local_db_handle = emstorage_get_db_connection(); + + EMSTORAGE_START_WRITE_TRANSACTION(input_transaction, error); + + SNPRINTF(sql_query_string, sizeof(sql_query_string), + "UPDATE mail_box_tbl SET" + " last_sync_time = %d" + " WHERE mailbox_id = %d" + , (int)current_time + , input_mailbox_id); + + EM_DEBUG_LOG("sql_query_string [%s]", sql_query_string); + + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + +FINISH_OFF: + + if(error == EMAIL_ERROR_NONE) + result_code = true; + + EMSTORAGE_FINISH_WRITE_TRANSACTION(input_transaction, result_code, error); + _DISCONNECT_DB; + 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) { @@ -4554,102 +4831,53 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_name(int account_id, int local_yn, ch EM_DEBUG_EXCEPTION(" account_id[%d], local_yn[%d], mailbox_name[%s], result_mailbox[%p]", account_id, local_yn, mailbox_name, result_mailbox); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - int rc, ret = false; - int error = EMF_ERROR_NONE; - int col_index = 0; - emstorage_mailbox_tbl_t* p_data_tbl = NULL; - DB_STMT hStmt = NULL; - char sql_query_string[QUERY_SIZE] = {0, }; - char *fields = "mailbox_id, account_id, local_yn, mailbox_name, mailbox_type, alias, sync_with_server_yn, modifiable_yn, total_mail_count_on_server, has_archived_mails, mail_slot_size "; - sqlite3 *local_db_handle = NULL; + int ret = false; + int error = EMAIL_ERROR_NONE; + int result_count = 0; + char conditional_clause_string[QUERY_SIZE] = {0, }; - if(strcmp(mailbox_name, EMF_SEARCH_RESULT_MAILBOX_NAME) == 0) { - if (!(p_data_tbl = (emstorage_mailbox_tbl_t*)em_malloc(sizeof(emstorage_mailbox_tbl_t)))) { + if(strcmp(mailbox_name, EMAIL_SEARCH_RESULT_MAILBOX_NAME) == 0) { + if (!(*result_mailbox = (emstorage_mailbox_tbl_t*)em_malloc(sizeof(emstorage_mailbox_tbl_t)))) { EM_DEBUG_EXCEPTION("malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - p_data_tbl->mailbox_id = 0; - p_data_tbl->account_id = account_id; - p_data_tbl->local_yn = 1; - p_data_tbl->mailbox_name = EM_SAFE_STRDUP(mailbox_name); - p_data_tbl->mailbox_type = EMF_MAILBOX_TYPE_SEARCH_RESULT; - p_data_tbl->alias = EM_SAFE_STRDUP(mailbox_name); - p_data_tbl->sync_with_server_yn = 0; - p_data_tbl->modifiable_yn = 1; - p_data_tbl->total_mail_count_on_server = 1; - p_data_tbl->has_archived_mails = 0; - p_data_tbl->mail_slot_size = 0x0FFFFFFF; + (*result_mailbox)->mailbox_id = 0; + (*result_mailbox)->account_id = account_id; + (*result_mailbox)->local_yn = 1; + (*result_mailbox)->mailbox_name = EM_SAFE_STRDUP(mailbox_name); + (*result_mailbox)->mailbox_type = EMAIL_MAILBOX_TYPE_SEARCH_RESULT; + (*result_mailbox)->alias = EM_SAFE_STRDUP(mailbox_name); + (*result_mailbox)->sync_with_server_yn = 0; + (*result_mailbox)->modifiable_yn = 1; + (*result_mailbox)->total_mail_count_on_server = 1; + (*result_mailbox)->has_archived_mails = 0; + (*result_mailbox)->mail_slot_size = 0x0FFFFFFF; } else { - local_db_handle = emstorage_get_db_connection(); - - EMSTORAGE_START_READ_TRANSACTION(transaction); if (local_yn == -1) - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s FROM mail_box_tbl WHERE account_id = %d AND mailbox_name = '%s'", fields, account_id, mailbox_name); + SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND mailbox_name = '%s'", account_id, mailbox_name); else - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s FROM mail_box_tbl WHERE account_id = %d AND local_yn = %d AND mailbox_name = '%s'", fields, account_id, local_yn, mailbox_name); - - EM_DEBUG_LOG("query = [%s]", sql_query_string); + SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND local_yn = %d AND mailbox_name = '%s'", account_id, local_yn, mailbox_name); + EM_DEBUG_LOG("conditional_clause_string = [%s]", conditional_clause_string); - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, - ("sqlite3_step fail:%d", rc)); - - if (rc == SQLITE_DONE) { - EM_DEBUG_EXCEPTION("no matched mailbox_name found..."); - error = EMF_ERROR_MAILBOX_NOT_FOUND; - goto FINISH_OFF; - } - - if (!(p_data_tbl = (emstorage_mailbox_tbl_t*)em_malloc(sizeof(emstorage_mailbox_tbl_t)))) { - EM_DEBUG_EXCEPTION("malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + if( (error = emstorage_query_mailbox_tbl(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; } - - _get_stmt_field_data_int(hStmt, &(p_data_tbl->mailbox_id), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->account_id), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->local_yn), col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->mailbox_name), 0, col_index++); - _get_stmt_field_data_int(hStmt, (int *)&(p_data_tbl->mailbox_type), col_index++); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->alias), 0, col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->sync_with_server_yn), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->modifiable_yn), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->total_mail_count_on_server), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->has_archived_mails), col_index++); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->mail_slot_size), col_index++); } ret = true; FINISH_OFF: - if (ret == true) - *result_mailbox = p_data_tbl; - else if (p_data_tbl != NULL) - emstorage_free_mailbox(&p_data_tbl, 1, NULL); - - if (hStmt != NULL) { - rc = sqlite3_finalize(hStmt); - if (rc != SQLITE_OK) { - EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; - } - } - - EMSTORAGE_FINISH_READ_TRANSACTION(transaction); - _DISCONNECT_DB; - + if (err_code != NULL) *err_code = error; @@ -4658,21 +4886,21 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_get_mailbox_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, emstorage_mailbox_tbl_t** mailbox_name, 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_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 < EMF_MAILBOX_TYPE_INBOX || mailbox_type > EMF_MAILBOX_TYPE_ALL_EMAILS) || !mailbox_name) { + if (account_id < FIRST_ACCOUNT_ID || (mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_ALL_EMAILS) || !mailbox_name) { EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_type[%d], mailbox_name[%p]", account_id, mailbox_type, mailbox_name); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; emstorage_mailbox_tbl_t *p_data_tbl = NULL; emstorage_account_tbl_t *account = NULL; DB_STMT hStmt = NULL; @@ -4684,7 +4912,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_mailbox_type(int account_id, emf_mail /* validate account */ /* Check whether the account exists. */ - if (!emstorage_get_account_by_id(account_id, EMF_ACC_GET_OPT_ACCOUNT_NAME, &account, true, &error) || !account) { + if (!emstorage_get_account_by_id(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; } @@ -4698,22 +4926,22 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_mailbox_type(int account_id, emf_mail EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE; goto FINISH_OFF; }, ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE; goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION(" no matched mailbox_name found..."); - error = EMF_ERROR_MAILBOX_NOT_FOUND; + error = EMAIL_ERROR_MAILBOX_NOT_FOUND; goto FINISH_OFF; } if (!(p_data_tbl = (emstorage_mailbox_tbl_t*)malloc(sizeof(emstorage_mailbox_tbl_t)))) { EM_DEBUG_EXCEPTION(" malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -4745,7 +4973,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -4759,19 +4987,46 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_get_mailboxname_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, char **mailbox_name, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_get_mailbox_by_id(int input_mailbox_id, emstorage_mailbox_tbl_t** output_mailbox) { - 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 < EMF_MAILBOX_TYPE_INBOX || mailbox_type > EMF_MAILBOX_TYPE_ALL_EMAILS) || !mailbox_name) { - EM_DEBUG_EXCEPTION("account_id[%d], mailbox_type[%d], mailbox_name[%p]", account_id, mailbox_type, mailbox_name); + EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], output_mailbox[%p]", input_mailbox_id, output_mailbox); + + if (input_mailbox_id <= 0 || !output_mailbox) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + int ret = EMAIL_ERROR_NONE; + int result_count = 0; + char conditional_clause_string[QUERY_SIZE] = {0, }; + + SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE mailbox_id = %d", input_mailbox_id); + + EM_DEBUG_LOG("conditional_clause_string = [%s]", conditional_clause_string); + + if( (ret = emstorage_query_mailbox_tbl(conditional_clause_string, false, false, output_mailbox, &result_count)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", ret); + goto FINISH_OFF; + } + +FINISH_OFF: + + EM_DEBUG_FUNC_END("ret [%d]", ret); + 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) +{ + 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) { + EM_DEBUG_EXCEPTION("account_id[%d], mailbox_type[%d], mailbox_id[%p]", account_id, mailbox_type, mailbox_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; - char *p_mailbox = NULL; + int error = EMAIL_ERROR_NONE; emstorage_account_tbl_t* account = NULL; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -4780,7 +5035,7 @@ INTERNAL_FUNC int emstorage_get_mailboxname_by_mailbox_type(int account_id, emf_ EMSTORAGE_START_READ_TRANSACTION(transaction); /* Check whether the account exists. */ - if (!emstorage_get_account_by_id(account_id, EMF_ACC_GET_OPT_ACCOUNT_NAME, &account, true, &error) || !account) { + if (!emstorage_get_account_by_id(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; } @@ -4788,6 +5043,78 @@ INTERNAL_FUNC int emstorage_get_mailboxname_by_mailbox_type(int account_id, emf_ 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); + + EM_DEBUG_LOG("query = [%s]", sql_query_string); + + + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); + + 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 && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("sqlite3_step fail:%d", rc)); + + if (rc == SQLITE_DONE) { + EM_DEBUG_EXCEPTION("no matched mailbox_name found..."); + error = EMAIL_ERROR_MAILBOX_NOT_FOUND; + goto FINISH_OFF; + } + + _get_stmt_field_data_int(hStmt, mailbox_id, 0); + + ret = true; + +FINISH_OFF: + if (hStmt != NULL) { + rc = sqlite3_finalize(hStmt); + if (rc != SQLITE_OK) { + EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); + error = EMAIL_ERROR_DB_FAILURE; + } + } + + EMSTORAGE_FINISH_READ_TRANSACTION(transaction); + _DISCONNECT_DB; + + if (err_code != NULL) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + 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) +{ + 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) { + EM_DEBUG_EXCEPTION("account_id[%d], mailbox_type[%d], mailbox_name[%p]", account_id, mailbox_type, mailbox_name); + if (err_code != NULL) + *err_code = EMAIL_ERROR_INVALID_PARAM; + return false; + } + + int rc, ret = false; + int error = EMAIL_ERROR_NONE; + emstorage_account_tbl_t* account = NULL; + DB_STMT hStmt = NULL; + char sql_query_string[QUERY_SIZE] = {0, }; + + sqlite3 *local_db_handle = emstorage_get_db_connection(); + 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) { + EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed - %d", error); + goto FINISH_OFF; + } + + 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); EM_DEBUG_LOG("query = [%s]", sql_query_string); @@ -4795,35 +5122,30 @@ INTERNAL_FUNC int emstorage_get_mailboxname_by_mailbox_type(int account_id, emf_ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION("no matched mailbox_name found..."); - error = EMF_ERROR_MAILBOX_NOT_FOUND; + error = EMAIL_ERROR_MAILBOX_NOT_FOUND; goto FINISH_OFF; } - _get_stmt_field_data_string(hStmt, &(p_mailbox), 0, 0); + _get_stmt_field_data_string(hStmt, mailbox_name, 0, 0); ret = true; FINISH_OFF: - if (ret == true) - *mailbox_name = p_mailbox; - else - EM_SAFE_FREE(p_mailbox); - if (hStmt != NULL) { rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -4841,7 +5163,7 @@ INTERNAL_FUNC int emstorage_update_mailbox_modifiable_yn(int account_id, int loc { 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 rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -4859,7 +5181,7 @@ INTERNAL_FUNC int emstorage_update_mailbox_modifiable_yn(int account_id, int loc , local_yn , mailbox_name); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -4877,18 +5199,18 @@ FINISH_OFF: } -INTERNAL_FUNC int emstorage_update_mailbox_total_count(int account_id, char *mailbox_name, int total_count_on_server, 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) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p], total_count_on_server[%d], transaction[%d], err_code[%p]", account_id, mailbox_name, 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 rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; - if (account_id <= 0 || !mailbox_name) { - EM_DEBUG_EXCEPTION("account_id[%d], mailbox_name[%p]", account_id, mailbox_name); + 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 = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -4899,13 +5221,13 @@ INTERNAL_FUNC int emstorage_update_mailbox_total_count(int account_id, char *mai "UPDATE mail_box_tbl SET" " total_mail_count_on_server = %d" " WHERE account_id = %d" - " AND mailbox_name = '%s'" + " AND mailbox_id = %d" , total_count_on_server , account_id - , mailbox_name); + , input_mailbox_id); EM_DEBUG_LOG("query[%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -4923,20 +5245,20 @@ FINISH_OFF: } -INTERNAL_FUNC int emstorage_update_mailbox(int account_id, int local_yn, char *mailbox_name, emstorage_mailbox_tbl_t* result_mailbox, int transaction, int *err_code) +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) { - EM_DEBUG_FUNC_BEGIN("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_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); - if (account_id < FIRST_ACCOUNT_ID || !mailbox_name || !result_mailbox) { - EM_DEBUG_EXCEPTION(" account_id[%d], local_yn[%d], mailbox_name[%s], result_mailbox[%p]", account_id, local_yn, mailbox_name, result_mailbox); + if (account_id < FIRST_ACCOUNT_ID || input_mailbox_id <= 0 || !result_mailbox) { + EM_DEBUG_EXCEPTION(" account_id[%d], local_yn[%d], input_mailbox_id[%d], result_mailbox[%p]", account_id, local_yn, input_mailbox_id, result_mailbox); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; DB_STMT hStmt = NULL; int i = 0; @@ -4957,10 +5279,10 @@ INTERNAL_FUNC int emstorage_update_mailbox(int account_id, int local_yn, char *m ", total_mail_count_on_server = ?" " WHERE account_id = %d" " AND local_yn = %d" - " AND mailbox_name = '%s'" + " AND mailbox_id = '%d'" , account_id , local_yn - , mailbox_name); + , input_mailbox_id); } else { SNPRINTF(sql_query_string, sizeof(sql_query_string), @@ -4974,15 +5296,15 @@ INTERNAL_FUNC int emstorage_update_mailbox(int account_id, int local_yn, char *m ", mail_slot_size= ?" ", total_mail_count_on_server = ?" " WHERE account_id = %d" - " AND mailbox_name = '%s'" + " AND mailbox_id = '%d'" , account_id - , mailbox_name); + , input_mailbox_id); } EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); _bind_stmt_field_data_int(hStmt, i++, result_mailbox->mailbox_id); @@ -4996,9 +5318,9 @@ INTERNAL_FUNC int emstorage_update_mailbox(int account_id, int local_yn, char *m EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); ret = true; @@ -5011,7 +5333,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -5023,20 +5345,20 @@ FINISH_OFF: } -INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, char *mailbox_name, emstorage_mailbox_tbl_t* target_mailbox, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, char *mailbox_name, email_mailbox_type_e new_mailbox_type, int transaction, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], mailbox_name[%s], target_mailbox[%p], transaction[%d], err_code[%p]", account_id, local_yn, mailbox_name, target_mailbox, transaction, err_code); + EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], mailbox_name[%s], new_mailbox_type[%d], transaction[%d], err_code[%p]", account_id, local_yn, mailbox_name, new_mailbox_type, transaction, err_code); - if (account_id < FIRST_ACCOUNT_ID || !mailbox_name || !target_mailbox) { - EM_DEBUG_EXCEPTION(" account_id[%d], local_yn[%d], mailbox_name[%s], target_mailbox[%p]", account_id, local_yn, mailbox_name, target_mailbox); + if (account_id < FIRST_ACCOUNT_ID || !mailbox_name) { + EM_DEBUG_EXCEPTION(" account_id[%d], local_yn[%d], mailbox_name[%s]", account_id, local_yn, mailbox_name); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -5072,23 +5394,23 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, ch EM_DEBUG_LOG("SQL(%s)", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); - _bind_stmt_field_data_int(hStmt, i++, target_mailbox->mailbox_type); + _bind_stmt_field_data_int(hStmt, i++, new_mailbox_type); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (hStmt != NULL) { rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } hStmt = NULL; } @@ -5097,7 +5419,6 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, ch i = 0; SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET" - " mailbox_id = ?" " mailbox_type = ?" " WHERE account_id = %d" " AND mailbox_name = '%s'" @@ -5107,17 +5428,16 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, ch EM_DEBUG_LOG("SQL[%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); - _bind_stmt_field_data_int(hStmt, i++, target_mailbox->mailbox_id); - _bind_stmt_field_data_int(hStmt, i++, target_mailbox->mailbox_type); + _bind_stmt_field_data_int(hStmt, i++, new_mailbox_type); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); ret = true; @@ -5130,7 +5450,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -5148,24 +5468,27 @@ INTERNAL_FUNC int emstorage_add_mailbox(emstorage_mailbox_tbl_t* mailbox_tbl, in if (!mailbox_tbl) { if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; 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); EM_SAFE_STRCPY(sql_query_string, "SELECT max(rowid) FROM mail_box_tbl;"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + time(¤t_time); + if (NULL == result[1]) rc = 1; else @@ -5178,22 +5501,23 @@ INTERNAL_FUNC int emstorage_add_mailbox(emstorage_mailbox_tbl_t* mailbox_tbl, in SNPRINTF(sql_query_string, sizeof(sql_query_string), "INSERT INTO mail_box_tbl VALUES " - "( ?" /* mailbox_id */ - ", ?" /* account_id */ - ", ?" /* local_yn */ - ", ?" /* mailbox_name */ - ", ?" /* mailbox_type */ - ", ?" /* alias */ - ", ?" /* sync_with_server_yn */ - ", ?" /* modifiable_yn */ - ", ?" /* total_mail_count_on_server */ - ", ?" /* has_archived_mails */ - ", ? )");/* mail_slot_size */ + "( ?" /* mailbox_id */ + ", ?" /* account_id */ + ", ?" /* local_yn */ + ", ?" /* mailbox_name */ + ", ?" /* mailbox_type */ + ", ?" /* alias */ + ", ?" /* sync_with_server_yn */ + ", ?" /* modifiable_yn */ + ", ?" /* total_mail_count_on_server */ + ", ?" /* has_archived_mails */ + ", ?" /* mail_slot_size */ + ", ? )");/* last_sync_time */ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG("After sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); int col_index = 0; @@ -5209,14 +5533,13 @@ INTERNAL_FUNC int emstorage_add_mailbox(emstorage_mailbox_tbl_t* mailbox_tbl, in _bind_stmt_field_data_int(hStmt, col_index++, mailbox_tbl->total_mail_count_on_server); _bind_stmt_field_data_int(hStmt, col_index++, 0); _bind_stmt_field_data_int(hStmt, col_index++, mailbox_tbl->mail_slot_size); + _bind_stmt_field_data_int(hStmt, col_index++, current_time); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%dn", rc)); - - if (!emstorage_notify_storage_event(NOTI_MAILBOX_ADD, mailbox_tbl->account_id, 0, mailbox_tbl->mailbox_name, 0)) - EM_DEBUG_EXCEPTION("emstorage_notify_storage_event[ NOTI_MAILBOX_ADD] : Notification Failed"); + ret = true; FINISH_OFF: @@ -5226,13 +5549,16 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); _DISCONNECT_DB; + if (error == EMAIL_ERROR_NONE && !emstorage_notify_storage_event(NOTI_MAILBOX_ADD, mailbox_tbl->account_id, mailbox_tbl->mailbox_id, mailbox_tbl->mailbox_name, 0)) + EM_DEBUG_EXCEPTION("emstorage_notify_storage_event[ NOTI_MAILBOX_ADD] : Notification Failed"); + if (err_code != NULL) *err_code = error; @@ -5249,11 +5575,11 @@ INTERNAL_FUNC int emstorage_set_all_mailbox_modifiable_yn(int account_id, int mo EM_DEBUG_EXCEPTION("account_id[%d]", account_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0,}; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -5263,7 +5589,7 @@ INTERNAL_FUNC int emstorage_set_all_mailbox_modifiable_yn(int account_id, int mo SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_box_tbl SET modifiable_yn = %d WHERE account_id = %d", modifiable_yn, account_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); @@ -5276,7 +5602,7 @@ INTERNAL_FUNC int emstorage_set_all_mailbox_modifiable_yn(int account_id, int mo FINISH_OFF: EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); _DISCONNECT_DB; - + if (err_code != NULL) *err_code = error; EM_DEBUG_FUNC_END("ret [%d]", ret); @@ -5285,20 +5611,20 @@ FINISH_OFF: } -INTERNAL_FUNC int emstorage_delete_mailbox(int account_id, int local_yn, char *mailbox_name, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_delete_mailbox(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], mailbox_name[%p], transaction[%d], err_code[%p]", account_id, local_yn, mailbox_name, transaction, 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); if (account_id < FIRST_ACCOUNT_ID) { - EM_DEBUG_EXCEPTION(" account_id[%d], local_yn[%d], mailbox_name[%p]", account_id, local_yn, mailbox_name); + EM_DEBUG_EXCEPTION(" account_id[%d], local_yn[%d], input_mailbox_id[%d]", account_id, local_yn, input_mailbox_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -5309,19 +5635,19 @@ INTERNAL_FUNC int emstorage_delete_mailbox(int account_id, int local_yn, char *m else SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_box_tbl WHERE account_id = %d AND local_yn = %d ", account_id, local_yn); - if (mailbox_name) { /* NULL means all mailbox_name */ - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(1+ strlen(sql_query_string)), "AND UPPER(mailbox_name) = UPPER('%s')", mailbox_name); + if (input_mailbox_id > 0) { /* 0 means all mailbox_name */ + SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(1+ strlen(sql_query_string)), "AND mailbox_id = %d", input_mailbox_id); } EM_DEBUG_LOG("mailbox sql_query_string [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION(" no (matched) mailbox_name found..."); - error = EMF_ERROR_MAILBOX_NOT_FOUND; + error = EMAIL_ERROR_MAILBOX_NOT_FOUND; ret = true; } ret = true; @@ -5331,6 +5657,11 @@ FINISH_OFF: EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); _DISCONNECT_DB; + if(error == EMAIL_ERROR_NONE) { + if (!emstorage_notify_storage_event(NOTI_MAILBOX_DELETE, account_id, input_mailbox_id, NULL, 0)) + EM_DEBUG_EXCEPTION("emstorage_notify_storage_event[ NOTI_MAILBOX_ADD] : Notification Failed"); + } + if (err_code != NULL) *err_code = error; @@ -5343,13 +5674,13 @@ INTERNAL_FUNC int emstorage_free_mailbox(emstorage_mailbox_tbl_t** mailbox_list, EM_DEBUG_FUNC_BEGIN("mailbox_list[%p], count[%d], err_code[%p]", mailbox_list, count, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (count > 0) { if (!mailbox_list || !*mailbox_list) { EM_DEBUG_EXCEPTION(" mailbox_list[%p], count[%d]", mailbox_list, count); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -5382,12 +5713,12 @@ INTERNAL_FUNC int emstorage_get_count_read_mail_uid(int account_id, char *mailbo EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_name[%p], count[%p], exist[%p]", account_id, mailbox_name, count); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -5398,7 +5729,7 @@ INTERNAL_FUNC int emstorage_get_count_read_mail_uid(int account_id, char *mailbo char **result; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); *count = atoi(result[1]); @@ -5427,12 +5758,12 @@ INTERNAL_FUNC int emstorage_check_read_mail_uid(int account_id, char *mailbox_na EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_name[%p], uid[%p], exist[%p]", account_id, mailbox_name , uid, exist); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); EMSTORAGE_START_READ_TRANSACTION(transaction); @@ -5447,7 +5778,7 @@ INTERNAL_FUNC int emstorage_check_read_mail_uid(int account_id, char *mailbox_na char **result; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); *exist = atoi(result[1]); @@ -5478,12 +5809,12 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail(int mail_id, emstorage_mail_tbl_ if (!mail) { EM_DEBUG_EXCEPTION(" mail_id[%d], mail[%p]", mail_id, mail); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false, temp_rule; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -5495,25 +5826,26 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail(int mail_id, emstorage_mail_tbl_ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG("sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); *mail = (emstorage_mail_tbl_t*)malloc(sizeof(emstorage_mail_tbl_t)); if (*mail == NULL) { - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; EM_DEBUG_EXCEPTION("Memory allocation for mail failed."); goto FINISH_OFF; } memset(*mail, 0x00, sizeof(emstorage_mail_tbl_t)); - + _get_stmt_field_data_int(hStmt, &((*mail)->account_id), ACCOUNT_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL); - _get_stmt_field_data_string(hStmt, &((*mail)->mailbox_name), 0, LOCAL_MBOX_IDX_IN_MAIL_READ_MAIL_UID_TBL); + _get_stmt_field_data_int(hStmt, &((*mail)->mailbox_id), LOCAL_MAILBOX_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL); + _get_stmt_field_data_string(hStmt, &((*mail)->mailbox_name), 0, MAILBOX_NAME_IDX_IN_MAIL_READ_MAIL_UID_TBL); _get_stmt_field_data_int(hStmt, &((*mail)->mail_id), LOCAL_UID_IDX_IN_MAIL_READ_MAIL_UID_TBL); _get_stmt_field_data_string(hStmt, &((*mail)->server_mailbox_name), 0, MAILBOX_NAME_IDX_IN_MAIL_READ_MAIL_UID_TBL); _get_stmt_field_data_string(hStmt, &((*mail)->server_mail_id), 0, S_UID_IDX_IN_MAIL_READ_MAIL_UID_TBL); @@ -5530,7 +5862,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -5544,20 +5876,20 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_get_downloaded_list(int account_id, char *local_mbox, emstorage_read_mail_uid_tbl_t** read_mail_uid, int *count, int transaction, int *err_code) +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) { EM_PROFILE_BEGIN(emStorageGetDownloadList); - EM_DEBUG_FUNC_BEGIN("account_id[%d], local_mbox[%s], read_mail_uid[%p], count[%p], transaction[%d], err_code[%p]", account_id, local_mbox, read_mail_uid, count, transaction, err_code); + 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); if (account_id < FIRST_ACCOUNT_ID || !read_mail_uid || !count) { - EM_DEBUG_EXCEPTION(" account_id[%d], local_mbox[%s], read_mail_uid[%p], count[%p]", account_id, local_mbox, read_mail_uid, count); + EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_id[%s], read_mail_uid[%p], count[%p]", account_id, mailbox_id, read_mail_uid, count); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -5568,8 +5900,8 @@ INTERNAL_FUNC int emstorage_get_downloaded_list(int account_id, char *local_mbox sqlite3 *local_db_handle = emstorage_get_db_connection(); EMSTORAGE_START_READ_TRANSACTION(transaction); - if (local_mbox) - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_read_mail_uid_tbl WHERE account_id = %d AND UPPER(local_mbox) = UPPER('%s')", account_id, local_mbox); + if (mailbox_id) + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_read_mail_uid_tbl WHERE account_id = %d AND mailbox_id = %d", account_id, mailbox_id); else SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_read_mail_uid_tbl WHERE account_id = %d", account_id); @@ -5579,18 +5911,18 @@ INTERNAL_FUNC int emstorage_get_downloaded_list(int account_id, char *local_mbox EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG("sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); char **result; /* rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, count, NULL, NULL); */ 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 = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); sqlite3_free_table(result); @@ -5603,7 +5935,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_list(int account_id, char *local_mbox if (!(p_data_tbl = (emstorage_read_mail_uid_tbl_t*)malloc(sizeof(emstorage_read_mail_uid_tbl_t) * *count))) { EM_DEBUG_EXCEPTION(" malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -5611,7 +5943,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_list(int account_id, char *local_mbox for (i = 0; i < *count; ++i) { _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].account_id), ACCOUNT_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].local_mbox), 0, LOCAL_MBOX_IDX_IN_MAIL_READ_MAIL_UID_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].mailbox_id),LOCAL_MAILBOX_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].local_uid), LOCAL_UID_IDX_IN_MAIL_READ_MAIL_UID_TBL); _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].mailbox_name), 0, MAILBOX_NAME_IDX_IN_MAIL_READ_MAIL_UID_TBL); _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].s_uid), 0, S_UID_IDX_IN_MAIL_READ_MAIL_UID_TBL); @@ -5620,7 +5952,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_list(int account_id, char *local_mbox _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].flag), FLAG_IDX_IN_MAIL_READ_MAIL_UID_TBL); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); } @@ -5638,7 +5970,7 @@ FINISH_OFF: if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -5653,20 +5985,20 @@ FINISH_OFF: return ret; } -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(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], local_mbox[%p], locacal_uid[%d], mailbox_name[%p], uid[%p], mail_size[%p], transaction[%d], err_code[%p]", account_id, local_mbox, local_uid, mailbox_name, uid, mail_size, transaction, 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); if (account_id < FIRST_ACCOUNT_ID || !mail_size) { - EM_DEBUG_EXCEPTION(" account_id[%d], local_mbox[%p], locacal_uid[%d], mailbox_name[%p], uid[%p], mail_size[%p]", account_id, local_mbox, local_uid, mailbox_name, uid, mail_size); + EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_id[%p], locacal_uid[%d], mailbox_name[%p], uid[%p], mail_size[%p]", account_id, mailbox_id, local_uid, mailbox_name, uid, mail_size); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -5678,35 +6010,35 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail_size(int account_id, char *local SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT IFNULL(MAX(data1), 0) FROM mail_read_mail_uid_tbl " "WHERE account_id = %d " - "AND local_mbox = '%s' " + "AND mailbox_id = '%s' " "AND local_uid = %d " "AND mailbox_name = '%s' " "AND s_uid = '%s'", - account_id, local_mbox, local_uid, mailbox_name, uid); + account_id, mailbox_id, local_uid, mailbox_name, uid); } else { SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT IFNULL(MAX(data1), 0) FROM mail_read_mail_uid_tbl " "WHERE account_id = %d " - "AND local_mbox = '%s' " + "AND mailbox_id = '%s' " "AND local_uid = %d " "AND s_uid = '%s'", - account_id, local_mbox, local_uid, uid); + account_id, mailbox_id, local_uid, uid); } EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION(" no matched mail found...."); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } @@ -5720,7 +6052,7 @@ FINISH_OFF: if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -5741,12 +6073,12 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(emstorage_read_mail_uid_tbl_t* r if (!read_mail_uid) { EM_DEBUG_EXCEPTION("read_mail_uid[%p]", read_mail_uid); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, rc2, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -5758,7 +6090,7 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(emstorage_read_mail_uid_tbl_t* r EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); if (NULL==result[1]) rc = 1; @@ -5783,12 +6115,12 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(emstorage_read_mail_uid_tbl_t* r EM_DEBUG_LOG("sqlite3_prepare hStmt = %p", hStmt); EM_DEBUG_EXCEPTION("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; } EM_DEBUG_LOG("account_id VALUE [%d] ", read_mail_uid->account_id); - EM_DEBUG_LOG("local_mbox VALUE [%s] ", read_mail_uid->local_mbox); + EM_DEBUG_LOG("mailbox_id VALUE [%d] ", read_mail_uid->mailbox_id); EM_DEBUG_LOG("local_uid VALUE [%d] ", read_mail_uid->local_uid); EM_DEBUG_LOG("mailbox_name VALUE [%s] ", read_mail_uid->mailbox_name); EM_DEBUG_LOG("s_uid VALUE [%s] ", read_mail_uid->s_uid); @@ -5798,7 +6130,7 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(emstorage_read_mail_uid_tbl_t* r EM_DEBUG_LOG("rc VALUE [%d] ", rc); _bind_stmt_field_data_int(hStmt, ACCOUNT_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL, read_mail_uid->account_id); - _bind_stmt_field_data_string(hStmt, LOCAL_MBOX_IDX_IN_MAIL_READ_MAIL_UID_TBL, (char *)read_mail_uid->local_mbox, 0, LOCAL_MBOX_LEN_IN_MAIL_READ_MAIL_UID_TBL); + _bind_stmt_field_data_int(hStmt, LOCAL_MAILBOX_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL, read_mail_uid->mailbox_id); _bind_stmt_field_data_int(hStmt, LOCAL_UID_IDX_IN_MAIL_READ_MAIL_UID_TBL, read_mail_uid->local_uid); _bind_stmt_field_data_string(hStmt, MAILBOX_NAME_IDX_IN_MAIL_READ_MAIL_UID_TBL, (char *)read_mail_uid->mailbox_name, 0, MAILBOX_NAME_LEN_IN_MAIL_READ_MAIL_UID_TBL); _bind_stmt_field_data_string(hStmt, S_UID_IDX_IN_MAIL_READ_MAIL_UID_TBL, (char *)read_mail_uid->s_uid, 0, S_UID_LEN_IN_MAIL_READ_MAIL_UID_TBL); @@ -5809,9 +6141,9 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(emstorage_read_mail_uid_tbl_t* r EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail[%d] [%s]", rc, sqlite3_errmsg(local_db_handle))); @@ -5824,7 +6156,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -5838,20 +6170,20 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_change_read_mail_uid(int account_id, char *local_mbox, 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(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], local_mbox[%p], local_uid[%d], mailbox_name[%p], uid[%p], read_mail_uid[%p], transaction[%d], err_code[%p]", account_id, local_mbox, local_uid, mailbox_name, uid, read_mail_uid, transaction, 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); if (account_id < FIRST_ACCOUNT_ID || !read_mail_uid) { - EM_DEBUG_EXCEPTION(" account_id[%d], local_mbox[%p], local_uid[%d], mailbox_name[%p], uid[%p], read_mail_uid[%p]", account_id, local_mbox, local_uid, mailbox_name, uid, read_mail_uid); + EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_id[%d], local_uid[%d], mailbox_name[%p], uid[%p], read_mail_uid[%p]", account_id, mailbox_id, local_uid, mailbox_name, uid, read_mail_uid); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -5862,7 +6194,7 @@ INTERNAL_FUNC int emstorage_change_read_mail_uid(int account_id, char *local_mbo SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_read_mail_uid_tbl SET" " account_id = ?" - ", local_mbox = ?" + ", mailbox_id = ?" ", local_uid = ?" ", mailbox_name = ?" ", s_uid = ?" @@ -5870,7 +6202,7 @@ INTERNAL_FUNC int emstorage_change_read_mail_uid(int account_id, char *local_mbo ", data2 = ?" ", flag = ?" " WHERE account_id = ?" - " AND local_mbox = ?" + " AND mailbox_id = ?" " AND local_uid = ?" " AND mailbox_name= ?" " AND s_uid = ?"); @@ -5878,29 +6210,29 @@ INTERNAL_FUNC int emstorage_change_read_mail_uid(int account_id, char *local_mbo EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG("sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); int i = 0; _bind_stmt_field_data_int(hStmt, i++, read_mail_uid->account_id); - _bind_stmt_field_data_string(hStmt, i++, (char *)read_mail_uid->local_mbox, 0, LOCAL_MBOX_LEN_IN_MAIL_READ_MAIL_UID_TBL); + _bind_stmt_field_data_int(hStmt, i++, read_mail_uid->mailbox_id); _bind_stmt_field_data_int(hStmt, i++, read_mail_uid->local_uid); - _bind_stmt_field_data_string(hStmt, i++, (char *)read_mail_uid->mailbox_name, 0, MAILBOX_NAME_LEN_IN_MAIL_READ_MAIL_UID_TBL); - _bind_stmt_field_data_string(hStmt, i++, (char *)read_mail_uid->s_uid, 0, S_UID_LEN_IN_MAIL_READ_MAIL_UID_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char*)read_mail_uid->mailbox_name, 0, MAILBOX_NAME_LEN_IN_MAIL_READ_MAIL_UID_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char*)read_mail_uid->s_uid, 0, S_UID_LEN_IN_MAIL_READ_MAIL_UID_TBL); _bind_stmt_field_data_int(hStmt, i++, read_mail_uid->data1); - _bind_stmt_field_data_string(hStmt, i++, (char *)read_mail_uid->data2, 0, DATA2_LEN_IN_MAIL_READ_MAIL_UID_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char*)read_mail_uid->data2, 0, DATA2_LEN_IN_MAIL_READ_MAIL_UID_TBL); _bind_stmt_field_data_int(hStmt, i++, read_mail_uid->flag); _bind_stmt_field_data_int(hStmt, i++, account_id); - _bind_stmt_field_data_string(hStmt, i++, (char *)local_mbox, 0, LOCAL_MBOX_LEN_IN_MAIL_READ_MAIL_UID_TBL); + _bind_stmt_field_data_int(hStmt, i++, mailbox_id); _bind_stmt_field_data_int(hStmt, i++, local_uid); - _bind_stmt_field_data_string(hStmt, i++, (char *)mailbox_name, 0, MAILBOX_NAME_LEN_IN_MAIL_READ_MAIL_UID_TBL); - _bind_stmt_field_data_string(hStmt, i++, (char *)uid, 0, S_UID_LEN_IN_MAIL_READ_MAIL_UID_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char*)mailbox_name, 0, MAILBOX_NAME_LEN_IN_MAIL_READ_MAIL_UID_TBL); + _bind_stmt_field_data_string(hStmt, i++, (char*)uid, 0, S_UID_LEN_IN_MAIL_READ_MAIL_UID_TBL); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); ret = true; @@ -5913,7 +6245,7 @@ FINISH_OFF: if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -5935,12 +6267,12 @@ INTERNAL_FUNC int emstorage_remove_downloaded_mail(int account_id, char *mailbox EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_name[%s], uid[%s]", account_id, mailbox_name, uid); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -5958,7 +6290,7 @@ INTERNAL_FUNC int emstorage_remove_downloaded_mail(int account_id, char *mailbox } EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); @@ -5981,13 +6313,13 @@ INTERNAL_FUNC int emstorage_free_read_mail_uid(emstorage_read_mail_uid_tbl_t** r EM_DEBUG_FUNC_BEGIN("read_mail_uid[%p], count[%d], err_code[%p]", read_mail_uid, count, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (count > 0) { if (!read_mail_uid || !*read_mail_uid) { EM_DEBUG_EXCEPTION(" read_mail_uid[%p], count[%d]", read_mail_uid, count); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -5995,7 +6327,6 @@ INTERNAL_FUNC int emstorage_free_read_mail_uid(emstorage_read_mail_uid_tbl_t** r int i; for (i = 0; i < count; i++) { - EM_SAFE_FREE(p[i].local_mbox); EM_SAFE_FREE(p[i].mailbox_name); EM_SAFE_FREE(p[i].s_uid); EM_SAFE_FREE(p[i].data2); @@ -6022,12 +6353,12 @@ INTERNAL_FUNC int emstorage_get_rule_count(int account_id, int *count, int trans EM_DEBUG_EXCEPTION(" account_id[%d], count[%p]", account_id, count); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -6038,7 +6369,7 @@ INTERNAL_FUNC int emstorage_get_rule_count(int account_id, int *count, int trans char **result; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); *count = atoi(result[1]); @@ -6065,12 +6396,12 @@ INTERNAL_FUNC int emstorage_get_rule(int account_id, int type, int start_idx, in EM_DEBUG_EXCEPTION(" account_id[%d], type[%d], start_idx[%d], select_num[%p], is_completed[%p], rule_list[%p]", account_id, type, start_idx, select_num, is_completed, rule_list); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; emstorage_rule_tbl_t* p_data_tbl = NULL; int i = 0, count = 0; @@ -6090,18 +6421,18 @@ INTERNAL_FUNC int emstorage_get_rule(int account_id, int type, int start_idx, in EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG("sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); char **result; /* rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, NULL, NULL); */ 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 = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); sqlite3_free_table(result); @@ -6116,7 +6447,7 @@ INTERNAL_FUNC int emstorage_get_rule(int account_id, int type, int start_idx, in if (!(p_data_tbl = (emstorage_rule_tbl_t*)malloc(sizeof(emstorage_rule_tbl_t) * count))) { EM_DEBUG_EXCEPTION(" malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -6128,12 +6459,12 @@ INTERNAL_FUNC int emstorage_get_rule(int account_id, int type, int start_idx, in _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].type), TYPE_IDX_IN_MAIL_RULE_TBL); _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].value), 0, VALUE_IDX_IN_MAIL_RULE_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].action_type), ACTION_TYPE_IDX_IN_MAIL_RULE_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].dest_mailbox), 0, DEST_MAILBOX_IDX_IN_MAIL_RULE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].target_mailbox_id), TARGET_MAILBOX_ID_IDX_IN_MAIL_RULE_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].flag1), FLAG1_IDX_IN_MAIL_RULE_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].flag2), FLAG2_IDX_IN_MAIL_RULE_TBL); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); } @@ -6156,7 +6487,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -6179,13 +6510,13 @@ INTERNAL_FUNC int emstorage_get_rule_by_id(int account_id, int rule_id, emstorag EM_DEBUG_EXCEPTION(" account_id[%d], rule_id[%d], rule[%p]", account_id, rule_id, rule); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } emstorage_rule_tbl_t* p_data_tbl = NULL; int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -6196,23 +6527,23 @@ INTERNAL_FUNC int emstorage_get_rule_by_id(int account_id, int rule_id, emstorag EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION(" no matched rule found..."); - error = EMF_ERROR_FILTER_NOT_FOUND; + error = EMAIL_ERROR_FILTER_NOT_FOUND; goto FINISH_OFF; } if (!(p_data_tbl = (emstorage_rule_tbl_t*)malloc(sizeof(emstorage_rule_tbl_t)))) { EM_DEBUG_EXCEPTION(" malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -6222,7 +6553,7 @@ INTERNAL_FUNC int emstorage_get_rule_by_id(int account_id, int rule_id, emstorag _get_stmt_field_data_int(hStmt, &(p_data_tbl->type), TYPE_IDX_IN_MAIL_RULE_TBL); _get_stmt_field_data_string(hStmt, &(p_data_tbl->value), 0, VALUE_IDX_IN_MAIL_RULE_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl->action_type), ACTION_TYPE_IDX_IN_MAIL_RULE_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->dest_mailbox), 0, DEST_MAILBOX_IDX_IN_MAIL_RULE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->target_mailbox_id), TARGET_MAILBOX_ID_IDX_IN_MAIL_RULE_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl->flag1), FLAG1_IDX_IN_MAIL_RULE_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl->flag2), FLAG2_IDX_IN_MAIL_RULE_TBL); @@ -6241,7 +6572,7 @@ FINISH_OFF: if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -6265,12 +6596,12 @@ INTERNAL_FUNC int emstorage_change_rule(int account_id, int rule_id, emstorage_r EM_DEBUG_EXCEPTION(" account_id[%d], rule_id[%d], new_rule[%p]", account_id, rule_id, new_rule); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -6282,7 +6613,7 @@ INTERNAL_FUNC int emstorage_change_rule(int account_id, int rule_id, emstorage_r " type = ?" ", value = ?" ", action_type = ?" - ", dest_mailbox = ?" + ", target_mailbox_id = ?" ", flag1 = ?" ", flag2 = ?" " WHERE account_id = ?" @@ -6291,7 +6622,7 @@ INTERNAL_FUNC int emstorage_change_rule(int account_id, int rule_id, emstorage_r EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG(" Before sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); int i = 0; @@ -6299,7 +6630,7 @@ INTERNAL_FUNC int emstorage_change_rule(int account_id, int rule_id, emstorage_r _bind_stmt_field_data_int(hStmt, i++, new_rule->type); _bind_stmt_field_data_string(hStmt, i++, (char *)new_rule->value, 0, VALUE_LEN_IN_MAIL_RULE_TBL); _bind_stmt_field_data_int(hStmt, i++, new_rule->action_type); - _bind_stmt_field_data_string(hStmt, i++, (char *)new_rule->dest_mailbox, 0, DEST_MAILBOX_LEN_IN_MAIL_RULE_TBL); + _bind_stmt_field_data_int(hStmt, i++, new_rule->target_mailbox_id); _bind_stmt_field_data_int(hStmt, i++, new_rule->flag1); _bind_stmt_field_data_int(hStmt, i++, new_rule->flag2); _bind_stmt_field_data_int(hStmt, i++, account_id); @@ -6307,7 +6638,7 @@ INTERNAL_FUNC int emstorage_change_rule(int account_id, int rule_id, emstorage_r EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); ret = true; @@ -6320,7 +6651,7 @@ FINISH_OFF: if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -6343,14 +6674,14 @@ INTERNAL_FUNC int emstorage_find_rule(emstorage_rule_tbl_t* rule, int transactio EM_DEBUG_EXCEPTION(" rule->account_id[%d]", rule->account_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int rc, ret = false; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -6362,17 +6693,17 @@ INTERNAL_FUNC int emstorage_find_rule(emstorage_rule_tbl_t* rule, int transactio EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION(" no matched rule found..."); - error = EMF_ERROR_FILTER_NOT_FOUND; + error = EMAIL_ERROR_FILTER_NOT_FOUND; goto FINISH_OFF; } @@ -6386,7 +6717,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -6410,12 +6741,12 @@ INTERNAL_FUNC int emstorage_add_rule(emstorage_rule_tbl_t* rule, int transaction EM_DEBUG_EXCEPTION(" rule->account_id[%d]", rule->account_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, rc_2, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -6429,7 +6760,7 @@ INTERNAL_FUNC int emstorage_add_rule(emstorage_rule_tbl_t* rule, int transaction sql = "SELECT max(rowid) FROM mail_rule_tbl;"; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); if (NULL==result[1]) @@ -6445,28 +6776,28 @@ INTERNAL_FUNC int emstorage_add_rule(emstorage_rule_tbl_t* rule, int transaction ", ?" /* type */ ", ?" /* value */ ", ?" /* action_type */ - ", ?" /* dest_mailbox */ + ", ?" /* target_mailbox_id */ ", ?" /* flag1 */ ", ?)"); /* flag2 */ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc_2); if (rc_2 != SQLITE_OK) { EM_DEBUG_EXCEPTION("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc_2, sqlite3_errmsg(local_db_handle)); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; } _bind_stmt_field_data_int(hStmt, ACCOUNT_ID_IDX_IN_MAIL_RULE_TBL, rule->account_id); _bind_stmt_field_data_int(hStmt, RULE_ID_IDX_IN_MAIL_RULE_TBL, rc); _bind_stmt_field_data_int(hStmt, TYPE_IDX_IN_MAIL_RULE_TBL, rule->type); - _bind_stmt_field_data_string(hStmt, VALUE_IDX_IN_MAIL_RULE_TBL, (char *)rule->value, 0, VALUE_LEN_IN_MAIL_RULE_TBL); + _bind_stmt_field_data_string(hStmt, VALUE_IDX_IN_MAIL_RULE_TBL, (char*)rule->value, 0, VALUE_LEN_IN_MAIL_RULE_TBL); _bind_stmt_field_data_int(hStmt, ACTION_TYPE_IDX_IN_MAIL_RULE_TBL, rule->action_type); - _bind_stmt_field_data_string(hStmt, DEST_MAILBOX_IDX_IN_MAIL_RULE_TBL, (char *)rule->dest_mailbox, 0, DEST_MAILBOX_LEN_IN_MAIL_RULE_TBL); + _bind_stmt_field_data_int(hStmt, TARGET_MAILBOX_ID_IDX_IN_MAIL_RULE_TBL, rule->target_mailbox_id); _bind_stmt_field_data_int(hStmt, FLAG1_IDX_IN_MAIL_RULE_TBL, rule->flag1); _bind_stmt_field_data_int(hStmt, FLAG2_IDX_IN_MAIL_RULE_TBL, rule->flag2); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); ret = true; @@ -6479,7 +6810,7 @@ FINISH_OFF: if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -6501,12 +6832,12 @@ INTERNAL_FUNC int emstorage_delete_rule(int account_id, int rule_id, int transac EM_DEBUG_EXCEPTION(" account_id[%d], rule_id[%d]", account_id, rule_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -6514,13 +6845,13 @@ INTERNAL_FUNC int emstorage_delete_rule(int account_id, int rule_id, int transac SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_rule_tbl WHERE account_id = %d AND rule_id = %d", account_id, rule_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION(" no matched rule found..."); - error = EMF_ERROR_FILTER_NOT_FOUND; + error = EMAIL_ERROR_FILTER_NOT_FOUND; goto FINISH_OFF; } @@ -6542,13 +6873,13 @@ INTERNAL_FUNC int emstorage_free_rule(emstorage_rule_tbl_t** rule_list, int coun EM_DEBUG_FUNC_BEGIN("rule_list[%p], conut[%d], err_code[%p]", rule_list, count, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (count > 0) { if (!rule_list || !*rule_list) { EM_DEBUG_EXCEPTION(" rule_list[%p], conut[%d]", rule_list, count); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -6557,7 +6888,6 @@ INTERNAL_FUNC int emstorage_free_rule(emstorage_rule_tbl_t** rule_list, int coun for (; i < count; i++) { EM_SAFE_FREE(p[i].value); - EM_SAFE_FREE(p[i].dest_mailbox); } EM_SAFE_FREE(p); *rule_list = NULL; @@ -6578,12 +6908,12 @@ INTERNAL_FUNC int emstorage_get_mail_count(int account_id, const char *mailbox_n if (!total && !unseen) { EM_DEBUG_EXCEPTION(" accoun_id[%d], mailbox_name[%s], total[%p], unseen[%p]", account_id, mailbox_name, total, unseen); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; char err_msg[1024]; @@ -6608,7 +6938,7 @@ INTERNAL_FUNC int emstorage_get_mail_count(int account_id, const char *mailbox_n char **result; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF2; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF2; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); *total = atoi(result[1]); @@ -6616,11 +6946,11 @@ INTERNAL_FUNC int emstorage_get_mail_count(int account_id, const char *mailbox_n #else EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF2; }, + EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF2; }, ("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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF2; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF2; }, ("sqlite3_step fail:%d", rc)); _get_stmt_field_data_int(hStmt, total, 0); #endif /* USE_GET_RECORD_COUNT_API */ @@ -6639,7 +6969,7 @@ INTERNAL_FUNC int emstorage_get_mail_count(int account_id, const char *mailbox_n char **result; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); *unseen = atoi(result[1]); @@ -6656,7 +6986,7 @@ FINISH_OFF2: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_LOG(" EDBStmtClearRow failed - %d: %s", rc, err_msg); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } #endif @@ -6678,7 +7008,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(int mail_id, int type, emstorag if (mail_id <= 0 || !mail) { EM_DEBUG_EXCEPTION("mail_id[%d], mail[%p]", mail_id, mail); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -6687,7 +7017,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(int mail_id, int type, emstorag if (p_data_tbl == NULL) { EM_DEBUG_EXCEPTION("malloc failed..."); if (err_code != NULL) - *err_code = EMF_ERROR_OUT_OF_MEMORY; + *err_code = EMAIL_ERROR_OUT_OF_MEMORY; return false; } @@ -6696,7 +7026,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(int mail_id, int type, emstorag char sql_query_string[QUERY_SIZE] = {0, }; int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; sqlite3 *local_db_handle = emstorage_get_db_connection(); EMSTORAGE_START_READ_TRANSACTION(transaction); @@ -6704,7 +7034,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(int mail_id, int type, emstorag switch (type) { case RETRIEVE_SUMMARY: SNPRINTF(sql_query_string, sizeof(sql_query_string), - "SELECT account_id, mail_id, mailbox_name, 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, mailbox_name, 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); break; case RETRIEVE_FIELDS_FOR_DELETE: @@ -6719,46 +7049,47 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(int mail_id, int type, emstorag case RETRIEVE_FLAG: SNPRINTF(sql_query_string, sizeof(sql_query_string), - "SELECT account_id, mailbox_name, flags_seen_field, thread_id FROM mail_tbl WHERE mail_id = %d", mail_id); + "SELECT account_id, mailbox_name, flags_seen_field, thread_id, mailbox_id FROM mail_tbl WHERE mail_id = %d", mail_id); break; default : - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM : type [%d]", type); - error = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM : type [%d]", type); + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION("no matched mail found..."); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } switch (type) { case RETRIEVE_SUMMARY: _get_stmt_field_data_int(hStmt, &(p_data_tbl->account_id), 0); _get_stmt_field_data_int(hStmt, &(p_data_tbl->mail_id), 1); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->mailbox_name), 0, 2); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->server_mail_status), 3); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->server_mailbox_name), 0, 4); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->server_mail_id), 0, 5); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_plain), 0, 6); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_html), 0, 7); - _get_stmt_field_data_char(hStmt, &(p_data_tbl->flags_seen_field), 8); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->save_status), 9); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->lock_status), 10); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->thread_id), 11); - _get_stmt_field_data_int(hStmt, &(p_data_tbl->thread_item_count), 12); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->mailbox_id), 2); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->mailbox_name), 0, 3); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->server_mail_status), 4); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->server_mailbox_name), 0, 5); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->server_mail_id), 0, 6); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_plain), 0, 7); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_html), 0, 8); + _get_stmt_field_data_char(hStmt, &(p_data_tbl->flags_seen_field), 9); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->save_status), 10); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->lock_status), 11); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->thread_id), 12); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->thread_item_count), 13); break; case RETRIEVE_FIELDS_FOR_DELETE: @@ -6778,6 +7109,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->mailbox_name), 0, 1); _get_stmt_field_data_char(hStmt, &(p_data_tbl->flags_seen_field), 2); _get_stmt_field_data_int(hStmt, &(p_data_tbl->thread_id), 3); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->mailbox_id), 4); break; } @@ -6795,7 +7127,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -6815,9 +7147,9 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(int mail_ids[], i 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); if (number_of_mails <= 0 || !mail_ids) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -6826,13 +7158,13 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(int mail_ids[], i if (p_data_tbl == NULL) { EM_DEBUG_EXCEPTION("malloc failed..."); if (err_code != NULL) - *err_code = EMF_ERROR_OUT_OF_MEMORY; + *err_code = EMAIL_ERROR_OUT_OF_MEMORY; return false; } DB_STMT hStmt = NULL; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int i = 0, item_count = 0, rc = -1, field_count, col_index, cur_sql_query_string = 0; char **result = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -6861,13 +7193,13 @@ 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, sizeof(sql_query_string), - "SELECT account_id, mailbox_name, flags_seen_field, thread_id FROM mail_tbl WHERE mail_id in ("); + "SELECT account_id, mailbox_id, flags_seen_field, thread_id FROM mail_tbl WHERE mail_id in ("); field_count = 4; break; default : - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM : type [%d]", type); - error = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM : type [%d]", type); + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -6878,12 +7210,12 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(int mail_ids[], i EM_DEBUG_LOG("Query [%s], Length [%d]", sql_query_string, strlen(sql_query_string)); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &item_count, 0, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION("no matched mail found..."); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } @@ -6891,7 +7223,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(int mail_ids[], i if(number_of_mails != item_count) { EM_DEBUG_EXCEPTION("Can't find all emails"); - /* error = EMF_ERROR_MAIL_NOT_FOUND; + /* error = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; */ /* removed temporarily */ } @@ -6929,7 +7261,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(int mail_ids[], i case RETRIEVE_FLAG: _get_table_field_data_int(result, &(p_data_tbl[i].account_id), col_index++); - _get_table_field_data_string(result, &(p_data_tbl[i].mailbox_name), 0, col_index++); + _get_table_field_data_int(result, &(p_data_tbl[i].mailbox_id), col_index++); _get_table_field_data_char(result, &(p_data_tbl[i].flags_seen_field), col_index++); _get_table_field_data_int(result, &(p_data_tbl[i].thread_id), col_index++); break; @@ -6952,7 +7284,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -6973,11 +7305,11 @@ INTERNAL_FUNC int emstorage_get_mail_by_id(int mail_id, emstorage_mail_tbl_t** m if (mail_id <= 0 || !mail) { EM_DEBUG_EXCEPTION("mail_id[%d], mail[%p]", mail_id, mail); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - int ret = false, error = EMF_ERROR_NONE, count; + int ret = false, error = EMAIL_ERROR_NONE, count; char conditional_clause[QUERY_SIZE] = {0, }; emstorage_mail_tbl_t* p_data_tbl = NULL; @@ -7010,14 +7342,14 @@ INTERNAL_FUNC int emstorage_mail_search_start(emstorage_search_filter_t* search, if (!search_handle || !searched) { if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + *err_code = EMAIL_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); EM_DEBUG_FUNC_END("false"); return false; } emstorage_search_filter_t* p = search; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; int rc, ret = false; @@ -7068,18 +7400,18 @@ INTERNAL_FUNC int emstorage_mail_search_start(emstorage_search_filter_t* search, EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); char **result; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &mail_count, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); sqlite3_free_table(result); @@ -7097,7 +7429,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -7120,14 +7452,14 @@ INTERNAL_FUNC int emstorage_mail_search_result(int search_handle, emstorage_mail EM_DEBUG_EXCEPTION(" search_handle[%d], type[%d], data[%p]", search_handle, type, data); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } emstorage_mail_tbl_t* p_data_tbl = NULL; DB_STMT hStmt = (DB_STMT)search_handle; int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; switch (type) { case RETRIEVE_ID: @@ -7139,7 +7471,7 @@ INTERNAL_FUNC int emstorage_mail_search_result(int search_handle, emstorage_mail if (!(p_data_tbl = em_malloc(sizeof(emstorage_mail_tbl_t)))) { EM_DEBUG_EXCEPTION(" em_malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -7154,6 +7486,7 @@ INTERNAL_FUNC int emstorage_mail_search_result(int search_handle, emstorage_mail _get_stmt_field_data_int (hStmt, &(p_data_tbl->body_download_status), BODY_DOWNLOAD_STATUS_IDX_IN_MAIL_TBL); _get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_plain), 0, FILE_PATH_PLAIN_IDX_IN_MAIL_TBL); _get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_html), 0, FILE_PATH_HTML_IDX_IN_MAIL_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_mime_entity), 0, FILE_PATH_HTML_IDX_IN_MAIL_TBL); _get_stmt_field_data_time_t(hStmt, &(p_data_tbl->date_time), DATETIME_IDX_IN_MAIL_TBL); _get_stmt_field_data_char (hStmt, &(p_data_tbl->flags_seen_field), FLAGS_SEEN_FIELD_IDX_IN_MAIL_TBL); _get_stmt_field_data_int (hStmt, &(p_data_tbl->DRM_status), DRM_STATUS_IDX_IN_MAIL_TBL); @@ -7163,6 +7496,9 @@ INTERNAL_FUNC int emstorage_mail_search_result(int search_handle, emstorage_mail _get_stmt_field_data_int (hStmt, &(p_data_tbl->report_status), REPORT_STATUS_IDX_IN_MAIL_TBL); _get_stmt_field_data_string(hStmt, &(p_data_tbl->preview_text), 1, PREVIEW_TEXT_IDX_IN_MAIL_TBL); _get_stmt_field_data_int (hStmt, &(p_data_tbl->meeting_request_status), MEETING_REQUEST_STATUS_IDX_IN_MAIL_TBL); + _get_stmt_field_data_int (hStmt, &(p_data_tbl->message_class), MESSAGE_CLASS_IDX_IN_MAIL_TBL); + _get_stmt_field_data_int (hStmt, &(p_data_tbl->digest_type), DIGEST_TYPE_IDX_IN_MAIL_TBL); + _get_stmt_field_data_int (hStmt, &(p_data_tbl->smime_type), SMIME_TYPE_IDX_IN_MAIL_TBL); if (type == RETRIEVE_ALL) { _get_stmt_field_data_int (hStmt, &(p_data_tbl->server_mail_status), SERVER_MAIL_STATUS_IDX_IN_MAIL_TBL); @@ -7201,7 +7537,7 @@ INTERNAL_FUNC int emstorage_mail_search_result(int search_handle, emstorage_mail if (!(p_data_tbl = malloc(sizeof(emstorage_mail_tbl_t)))) { EM_DEBUG_EXCEPTION(" malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -7220,7 +7556,7 @@ INTERNAL_FUNC int emstorage_mail_search_result(int search_handle, emstorage_mail case RETRIEVE_ADDRESS: if (!(p_data_tbl = malloc(sizeof(emstorage_mail_tbl_t)))) { EM_DEBUG_EXCEPTION(" malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -7237,7 +7573,7 @@ INTERNAL_FUNC int emstorage_mail_search_result(int search_handle, emstorage_mail EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); ret = true; @@ -7255,12 +7591,12 @@ INTERNAL_FUNC int emstorage_mail_search_end(int search_handle, int transaction, { EM_DEBUG_FUNC_BEGIN("search_handle[%d], transaction[%d], err_code[%p]", search_handle, transaction, err_code); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int rc, ret = false; if (search_handle < 0) { EM_DEBUG_EXCEPTION(" search_handle[%d]", search_handle); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -7271,7 +7607,7 @@ INTERNAL_FUNC int emstorage_mail_search_end(int search_handle, int transaction, rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } ret = true; @@ -7295,7 +7631,7 @@ INTERNAL_FUNC int emstorage_change_mail(int mail_id, emstorage_mail_tbl_t* mail, EM_DEBUG_EXCEPTION(" mail_id[%d], mail[%p]", mail_id, mail); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -7303,9 +7639,10 @@ INTERNAL_FUNC int emstorage_change_mail(int mail_id, emstorage_mail_tbl_t* mail, char sql_query_string[QUERY_SIZE] = {0, }; int rc = -1; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int i = 0; sqlite3 *local_db_handle = emstorage_get_db_connection(); + char mailbox_id_param_string[10] = {0,}; EMSTORAGE_START_WRITE_TRANSACTION(transaction, error); @@ -7344,12 +7681,13 @@ INTERNAL_FUNC int emstorage_change_mail(int mail_id, emstorage_mail_tbl_t* mail, ", message_id = ?" ", report_status = ?" ", preview_text = ?" + ", smime_type = ?" " WHERE mail_id = %d AND account_id != 0 " , mail_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); _bind_stmt_field_data_int (hStmt, i++, mail->mail_id); @@ -7385,19 +7723,20 @@ INTERNAL_FUNC int emstorage_change_mail(int mail_id, emstorage_mail_tbl_t* mail, _bind_stmt_field_data_string(hStmt, i++, (char *)mail->message_id, 0, MESSAGE_ID_LEN_IN_MAIL_TBL); _bind_stmt_field_data_int (hStmt, i++, mail->report_status); _bind_stmt_field_data_string(hStmt, i++, (char *)mail->preview_text, 1, PREVIEWBODY_LEN_IN_MAIL_TBL); + _bind_stmt_field_data_int (hStmt, i++, mail->smime_type); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION(" no matched mail found..."); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } - - if (!emstorage_notify_storage_event(NOTI_MAIL_UPDATE, mail->account_id, mail->mail_id, mail->mailbox_name, 0)) + SNPRINTF(mailbox_id_param_string, 10, "%d", mail->mailbox_id); + if (!emstorage_notify_storage_event(NOTI_MAIL_UPDATE, mail->account_id, mail->mail_id, mailbox_id_param_string, 0)) EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event Failed [ NOTI_MAIL_UPDATE ] >>>> "); ret = true; @@ -7408,7 +7747,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -7430,13 +7769,13 @@ INTERNAL_FUNC int emstorage_modify_mailbox_of_mails(char *old_mailbox_name, char EM_DEBUG_EXCEPTION(" old_mailbox_name[%p], new_mailbox_name[%p]", old_mailbox_name, new_mailbox_name); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -7448,14 +7787,14 @@ INTERNAL_FUNC int emstorage_modify_mailbox_of_mails(char *old_mailbox_name, char SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET mailbox_name = '%s' WHERE mailbox_name = '%s'", new_mailbox_name, old_mailbox_name); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION(" no matched mail found..."); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } @@ -7464,13 +7803,13 @@ INTERNAL_FUNC int emstorage_modify_mailbox_of_mails(char *old_mailbox_name, char SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_read_mail_uid_tbl SET mailbox_name = '%s' WHERE mailbox_name = '%s'", new_mailbox_name, old_mailbox_name); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION(" no matched mail found..."); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } @@ -7503,23 +7842,23 @@ INTERNAL_FUNC int emstorage_clean_save_status(int save_status, int *err_code) EM_IF_NULL_RETURN_VALUE(err_code, false); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int rc = 0; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); 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, EMF_MAIL_STATUS_SENDING); + 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); EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_LOG(" No Matched Mail Exists "); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; } ret = true; @@ -7536,14 +7875,29 @@ FINISH_OFF: 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) { EM_DEBUG_FUNC_BEGIN("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, error, rc, ret = false, cur_mail_id_string = 0, mail_id_string_buffer_length = 0; - char sql_query_string[QUERY_SIZE] = {0, }, *mail_id_string_buffer = NULL, *parameter_string = NULL; + int i = 0; + int error = EMAIL_ERROR_NONE; + int rc = 0; + int ret = false; + int cur_mail_id_string = 0; + int mail_id_string_buffer_length = 0; + char sql_query_string[QUERY_SIZE] = {0, }; + char *mail_id_string_buffer = NULL; + char *parameter_string = NULL; sqlite3 *local_db_handle = emstorage_get_db_connection(); + email_mail_attribute_type target_mail_attribute_type = 0; if (!mail_ids || !field_name || account_id == 0) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + if (err_code != NULL) + *err_code = EMAIL_ERROR_INVALID_PARAM; + return false; + } + + if( (error = _get_attribute_type_by_mail_field_name(field_name, &target_mail_attribute_type)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_get_attribute_type_by_mail_field_name failed [%d]", error); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = error; return false; } @@ -7554,7 +7908,7 @@ INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(int account_id if(!mail_id_string_buffer) { EM_DEBUG_EXCEPTION("em_malloc failed"); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -7569,7 +7923,7 @@ INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(int account_id if(!parameter_string) { EM_DEBUG_EXCEPTION("em_malloc failed"); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -7578,10 +7932,12 @@ INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(int account_id /* 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); + EM_DEBUG_LOG("sql_query_string [%s]", sql_query_string); + /* Execute query */ EMSTORAGE_START_WRITE_TRANSACTION(transaction, error); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); if (sqlite3_changes(local_db_handle) == 0) EM_DEBUG_LOG("no mail matched..."); @@ -7592,8 +7948,8 @@ FINISH_OFF: EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); _DISCONNECT_DB; - if (ret && parameter_string && !emstorage_notify_storage_event(NOTI_MAIL_FIELD_UPDATE, account_id, 0, parameter_string, value)) - EM_DEBUG_EXCEPTION("emstorage_notify_storage_event failed : NOTI_MAIL_FIELD_UPDATE [%s,%d]", field_name, value); + if (ret && parameter_string && !emstorage_notify_storage_event(NOTI_MAIL_FIELD_UPDATE, account_id, target_mail_attribute_type, parameter_string, value)) + EM_DEBUG_EXCEPTION("emstorage_notify_storage_event failed : NOTI_MAIL_FIELD_UPDATE [%s,%d]", field_name, value); EM_SAFE_FREE(mail_id_string_buffer); EM_SAFE_FREE(parameter_string); @@ -7601,23 +7957,23 @@ FINISH_OFF: if (err_code != NULL) *err_code = error; - EM_DEBUG_FUNC_END("ret [%d]", ret); + EM_DEBUG_FUNC_END("error [%d]", error); return ret; } -INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_t type, emstorage_mail_tbl_t* mail, int transaction, int *err_code) +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) { EM_DEBUG_FUNC_BEGIN("mail_id[%d], type[%d], mail[%p], transaction[%d], err_code[%p]", mail_id, type, mail, transaction, err_code); if (mail_id <= 0 || !mail) { EM_DEBUG_EXCEPTION(" mail_id[%d], type[%d], mail[%p]", mail_id, type, mail); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int move_flag = 0; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -7625,7 +7981,8 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ int rc = 0; int i = 0; - char *mailbox_name = NULL; + char *mailbox_name = NULL; + char mailbox_id_param_string[10] = {0,}; sqlite3 *local_db_handle = emstorage_get_db_connection(); EMSTORAGE_START_WRITE_TRANSACTION(transaction, error); @@ -7648,12 +8005,15 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ ", attachment_count = ?" ", preview_text= ?" ", meeting_request_status = ? " + ", message_class = ? " + ", digest_type = ? " + ", smime_type = ? " " WHERE mail_id = %d AND account_id != 0" , mail_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); i = 0; @@ -7671,6 +8031,9 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ _bind_stmt_field_data_int(hStmt, i++, mail->attachment_count); _bind_stmt_field_data_string(hStmt, i++, (char *)mail->preview_text, 0, PREVIEWBODY_LEN_IN_MAIL_TBL); _bind_stmt_field_data_int(hStmt, i++, mail->meeting_request_status); + _bind_stmt_field_data_int(hStmt, i++, mail->message_class); + _bind_stmt_field_data_int(hStmt, i++, mail->digest_type); + _bind_stmt_field_data_int(hStmt, i++, mail->smime_type); break; case UPDATE_MAILBOX: { @@ -7699,7 +8062,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); } break; @@ -7727,7 +8090,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); break; @@ -7751,7 +8114,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); break; @@ -7766,7 +8129,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); break; @@ -7801,13 +8164,16 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ ", attachment_count = ?" ", inline_content_count = ?" ", meeting_request_status = ?" + ", message_class = ?" + ", digest_type = ?" + ", smime_type = ?" " WHERE mail_id = %d AND account_id != 0" , mail_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG(" before sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); i = 0; _bind_stmt_field_data_string(hStmt, i++, (char*)mail->full_address_from, 1, FROM_LEN_IN_MAIL_TBL); @@ -7838,6 +8204,9 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ _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_int (hStmt, i++, mail->meeting_request_status); + _bind_stmt_field_data_int (hStmt, i++, mail->message_class); + _bind_stmt_field_data_int (hStmt, i++, mail->digest_type); + _bind_stmt_field_data_int (hStmt, i++, mail->smime_type); break; case UPDATE_DATETIME: { @@ -7851,7 +8220,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ , mail_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); break; } @@ -7867,7 +8236,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ hStmt = NULL; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); i = 0; _bind_stmt_field_data_string(hStmt, i++, (char *)mail->email_address_sender, 1, FROM_EMAIL_ADDRESS_LEN_IN_MAIL_TBL); @@ -7884,7 +8253,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ hStmt = NULL; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); i = 0; _bind_stmt_field_data_string(hStmt, i++, (char *)mail->email_address_recipient, 1, TO_EMAIL_ADDRESS_LEN_IN_MAIL_TBL); @@ -7902,7 +8271,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ hStmt = NULL; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); i = 0; _bind_stmt_field_data_string(hStmt, i++, (char *)mail->email_address_sender, 1, FROM_EMAIL_ADDRESS_LEN_IN_MAIL_TBL); @@ -7926,7 +8295,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); i = 0; @@ -7944,36 +8313,36 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_ default: EM_DEBUG_LOG(" type[%d]", type); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (hStmt != NULL) { EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION(" no matched mail found..."); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } } if (mail->account_id == 0) { - emstorage_mail_tbl_t* mail_for_account = NULL; - if (!emstorage_get_mail_field_by_id(mail_id, RETRIEVE_ACCOUNT, &mail_for_account, true, &error) || !mail_for_account) { + 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) { EM_DEBUG_EXCEPTION(" emstorage_get_mail_field_by_id failed - %d", error); /* */ goto FINISH_OFF; } - mail->account_id = mail_for_account->account_id; - if (mail_for_account) - emstorage_free_mail(&mail_for_account, 1, NULL); + mail->account_id = mail_for_account_tbl->account_id; + if (mail_for_account_tbl) + emstorage_free_mail(&mail_for_account_tbl, 1, NULL); } ret = true; @@ -7984,7 +8353,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } hStmt = NULL; } @@ -7995,12 +8364,13 @@ FINISH_OFF: /*h.gahlaut@samsung.com: Moving publication of notification after commiting transaction to DB */ if (ret == true && move_flag != 1) { - if (!emstorage_get_mailboxname_by_mailbox_type(mail->account_id, EMF_MAILBOX_TYPE_SENTBOX, &mailbox_name, false, &error)) - EM_DEBUG_EXCEPTION(" emstorage_get_mailboxname_by_mailbox_type failed - %d", error); + if (!emstorage_get_mailbox_name_by_mailbox_type(mail->account_id, EMAIL_MAILBOX_TYPE_SENTBOX, &mailbox_name, false, &error)) + EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_name_by_mailbox_type failed - %d", error); if (mail->mailbox_name && mailbox_name) { if (strcmp(mail->mailbox_name, mailbox_name) != 0) { - if (!emstorage_notify_storage_event(NOTI_MAIL_UPDATE, mail->account_id, mail_id, mail->mailbox_name, type)) + SNPRINTF(mailbox_id_param_string, 10, "%d", mail->mailbox_id); + if (!emstorage_notify_storage_event(NOTI_MAIL_UPDATE, mail->account_id, mail_id, mailbox_id_param_string, type)) EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event Failed [ NOTI_MAIL_UPDATE ] >>>> "); } } @@ -8019,171 +8389,16 @@ FINISH_OFF: EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; } - - -INTERNAL_FUNC int emstorage_get_mail_count_with_draft_flag(int account_id, const char *mailbox_name, int *total, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_increase_mail_id(int *mail_id, int transaction, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%s], total[%p], transaction[%d], err_code[%p]", account_id, mailbox_name, total, transaction, err_code); - - if (!total) { - EM_DEBUG_EXCEPTION("accoun_id[%d], mailbox_name[%s], total[%p]", account_id, mailbox_name, total); - if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; - return false; - } + EM_DEBUG_FUNC_BEGIN("mail_id[%p], transaction[%d], err_code[%p]", mail_id, transaction, err_code); - int rc = -1, ret = false; - int error = EMF_ERROR_NONE; - DB_STMT hStmt = NULL; - char sql_query_string[QUERY_SIZE] = {0, }; - - memset(&sql_query_string, 0x00, sizeof(sql_query_string)); - sqlite3 *local_db_handle = emstorage_get_db_connection(); - EMSTORAGE_START_READ_TRANSACTION(transaction); - - if (total) { - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_tbl WHERE flags_draft_field = 1"); - - if (account_id != ALL_ACCOUNT) - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " AND account_id = %d", account_id); - - if (mailbox_name) - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " AND mailbox_name = '%s'", mailbox_name); - -#ifdef USE_GET_RECORD_COUNT_API - EM_DEBUG_LOG("Query : [%s]", sql_query_string); - char **result; - - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, - ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); - - *total = atoi(result[1]); - sqlite3_free_table(result); -#else - - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, - ("sqlite3_step fail:%d", rc)); - - _get_stmt_field_data_int(hStmt, total, 0); -#endif /* USE_GET_RECORD_COUNT_API */ - } - ret = true; - -FINISH_OFF: -#ifndef USE_GET_RECORD_COUNT_API - if (hStmt != NULL) { - rc = sqlite3_finalize(hStmt); - if (rc != SQLITE_OK) { - EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; - } - } -#endif - - EMSTORAGE_FINISH_READ_TRANSACTION(transaction); - _DISCONNECT_DB; - - if (err_code != NULL) - *err_code = error; - - EM_DEBUG_FUNC_END("ret [%d]", ret); - return ret; -} - -INTERNAL_FUNC int emstorage_get_mail_count_on_sending(int account_id, const char *mailbox_name, int *total, int transaction, int *err_code) -{ - EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%s], total[%p], transaction[%d], err_code[%p]", account_id, mailbox_name, total, transaction, err_code); - - if (!total) { - EM_DEBUG_EXCEPTION(" accoun_id[%d], mailbox_name[%s], total[%p]", account_id, mailbox_name, total); - if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; - return false; - } - - int rc = -1, ret = false; - int error = EMF_ERROR_NONE; - DB_STMT hStmt = NULL; - char sql_query_string[QUERY_SIZE] = {0, }; - - memset(&sql_query_string, 0x00, sizeof(sql_query_string)); - sqlite3 *local_db_handle = emstorage_get_db_connection(); - EMSTORAGE_START_READ_TRANSACTION(transaction); - - if (total) { - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_tbl WHERE save_status = %d ", EMF_MAIL_STATUS_SENDING); - - if (account_id != ALL_ACCOUNT) - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " AND account_id = %d", account_id); - - if (mailbox_name) - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " AND mailbox_name = '%s'", mailbox_name); - -#ifdef USE_GET_RECORD_COUNT_API - char **result; - - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, - ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); - - *total = atoi(result[1]); - sqlite3_free_table(result); -#else - - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, - ("sqlite3_step fail:%d", rc)); - - _get_stmt_field_data_int(hStmt, total, 0); -#endif /* USE_GET_RECORD_COUNT_API */ - } - ret = true; - -FINISH_OFF: -#ifndef USE_GET_RECORD_COUNT_API - if (hStmt != NULL) { - rc = sqlite3_finalize(hStmt); - if (rc != SQLITE_OK) { - EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - - error = EMF_ERROR_DB_FAILURE; - } - } -#endif - - EMSTORAGE_FINISH_READ_TRANSACTION(transaction); - _DISCONNECT_DB; - - if (err_code != NULL) - *err_code = error; - - EM_DEBUG_FUNC_END("ret [%d]", ret); - return ret; - -} - -INTERNAL_FUNC int emstorage_increase_mail_id(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); - - int rc, ret = false; - int error = EMF_ERROR_NONE; - int latest_mail_id = 0; - sqlite3 *local_db_handle = NULL; - char *sql = "SELECT MAX(mail_id) FROM mail_tbl;"; - char **result = NULL; + int rc, ret = false; + int error = EMAIL_ERROR_NONE; + int latest_mail_id = 0; + sqlite3 *local_db_handle = NULL; + char *sql = "SELECT MAX(mail_id) FROM mail_tbl;"; + char **result = NULL; #ifdef __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__ _timedlock_shm_mutex(&mapped_for_generating_mail_id, 2); @@ -8196,7 +8411,7 @@ INTERNAL_FUNC int emstorage_increase_mail_id(int *mail_id, int transaction, int local_db_handle = emstorage_get_db_connection(); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); if (NULL == result[1]) rc = 1; @@ -8239,12 +8454,12 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int ge if (!mail_tbl_data) { EM_DEBUG_EXCEPTION("mail_tbl_data[%p], get_id[%d]", mail_tbl_data, get_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; DB_STMT hStmt = NULL; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -8257,7 +8472,7 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int ge char **result; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL[%s] sqlite3_get_table fail[%d] [%s]", sql, rc, sqlite3_errmsg(local_db_handle))); if (NULL == result[1]) @@ -8300,6 +8515,7 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int ge ", ?" /* body_download_status */ ", ?" /* file_path_plain */ ", ?" /* file_path_html */ + ", ?" /* file_path_mime_entity */ ", ?" /* mail_size */ ", ?" /* flags_seen_field */ ", ?" /* flags_deleted_field */ @@ -8319,10 +8535,13 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int ge ", ?" /* thread_item_count */ ", ?" /* preview_text */ ", ?" /* meeting_request_status */ + ", ?" /* message_class */ + ", ?" /* digest_type */ + ", ?" /* smime_type */ ")"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); _bind_stmt_field_data_int (hStmt, MAIL_ID_IDX_IN_MAIL_TBL, mail_tbl_data->mail_id); @@ -8349,6 +8568,7 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int ge _bind_stmt_field_data_int (hStmt, BODY_DOWNLOAD_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->body_download_status); _bind_stmt_field_data_string(hStmt, FILE_PATH_PLAIN_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->file_path_plain, 0, TEXT_1_LEN_IN_MAIL_TBL); _bind_stmt_field_data_string(hStmt, FILE_PATH_HTML_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->file_path_html, 0, TEXT_2_LEN_IN_MAIL_TBL); + _bind_stmt_field_data_string(hStmt, FILE_PATH_MIME_ENTITY_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->file_path_mime_entity, 0, MIME_ENTITY_LEN_IN_MAIL_TBL); _bind_stmt_field_data_int (hStmt, MAIL_SIZE_IDX_IN_MAIL_TBL, mail_tbl_data->mail_size); _bind_stmt_field_data_int (hStmt, FLAGS_SEEN_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_seen_field); _bind_stmt_field_data_int (hStmt, FLAGS_DELETED_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_deleted_field); @@ -8368,10 +8588,13 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int ge _bind_stmt_field_data_int (hStmt, THREAD_ITEM_COUNT_IDX_IN_MAIL_TBL, mail_tbl_data->thread_item_count); _bind_stmt_field_data_string(hStmt, PREVIEW_TEXT_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->preview_text, 1, PREVIEWBODY_LEN_IN_MAIL_TBL); _bind_stmt_field_data_int (hStmt, MEETING_REQUEST_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->meeting_request_status); + _bind_stmt_field_data_int (hStmt, MESSAGE_CLASS_IDX_IN_MAIL_TBL, mail_tbl_data->message_class); + _bind_stmt_field_data_int (hStmt, DIGEST_TYPE_IDX_IN_MAIL_TBL, mail_tbl_data->digest_type); + _bind_stmt_field_data_int (hStmt, SMIME_TYPE_IDX_IN_MAIL_TBL, mail_tbl_data->smime_type); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); ret = true; FINISH_OFF: @@ -8380,7 +8603,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_LOG("sqlite3_finalize failed [%d]", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -8396,34 +8619,34 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_move_multiple_mails(int account_id, char *target_mailbox_name, int mail_ids[], int number_of_mails, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_move_multiple_mails(int account_id, int input_mailbox_id, int mail_ids[], int number_of_mails, int transaction, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id [%d], target_mailbox_name [%s], mail_ids[%p], number_of_mails [%d], transaction[%d], err_code[%p]", account_id, target_mailbox_name, mail_ids, number_of_mails, transaction, err_code); + EM_DEBUG_FUNC_BEGIN("account_id [%d], input_mailbox_id [%d], mail_ids[%p], number_of_mails [%d], transaction[%d], err_code[%p]", account_id, input_mailbox_id, mail_ids, number_of_mails, transaction, err_code); int rc, ret = false, i, cur_conditional_clause = 0; - int error = EMF_ERROR_NONE; - int target_mailbox_id = 0; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }, conditional_clause[QUERY_SIZE] = {0, }; emstorage_mailbox_tbl_t *result_mailbox = NULL; - emf_mailbox_type_e target_mailbox_type = EMF_MAILBOX_TYPE_USER_DEFINED; + email_mailbox_type_e target_mailbox_type = EMAIL_MAILBOX_TYPE_USER_DEFINED; + char* target_mailbox_name = NULL; - if (!mail_ids || !target_mailbox_name) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + if (!mail_ids || input_mailbox_id <= 0) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } sqlite3 *local_db_handle = emstorage_get_db_connection(); - if(!emstorage_get_mailbox_by_name(account_id, -1, target_mailbox_name, &result_mailbox, true, &error)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d]", error); + if ((error = emstorage_get_mailbox_by_id(input_mailbox_id, &result_mailbox)) != EMAIL_ERROR_NONE || !result_mailbox) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", error); goto FINISH_OFF; } if(result_mailbox) { + target_mailbox_name = EM_SAFE_STRDUP(result_mailbox->mailbox_name); target_mailbox_type = result_mailbox->mailbox_type; - target_mailbox_id = result_mailbox->mailbox_id; emstorage_free_mailbox(&result_mailbox, 1, NULL); } @@ -8439,7 +8662,7 @@ INTERNAL_FUNC int emstorage_move_multiple_mails(int account_id, char *target_mai /* Updating a mail_tbl */ memset(sql_query_string, 0x00, QUERY_SIZE); - SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_tbl SET mailbox_name = '%s', mailbox_type = %d, mailbox_id = %d %s", target_mailbox_name, target_mailbox_type, target_mailbox_id, conditional_clause); + SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_tbl SET mailbox_name = '%s', mailbox_type = %d, mailbox_id = %d %s", target_mailbox_name, target_mailbox_type, input_mailbox_id, conditional_clause); EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); @@ -8449,7 +8672,7 @@ INTERNAL_FUNC int emstorage_move_multiple_mails(int account_id, char *target_mai /* Updating a mail_attachment_tbl */ memset(sql_query_string, 0x00, QUERY_SIZE); - SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_attachment_tbl SET mailbox_name = '%s' %s", target_mailbox_name, conditional_clause); + SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_attachment_tbl SET mailbox_id = '%d' %s", input_mailbox_id, conditional_clause); EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); @@ -8458,7 +8681,7 @@ INTERNAL_FUNC int emstorage_move_multiple_mails(int account_id, char *target_mai /* Updating a mail_meeting_tbl */ memset(sql_query_string, 0x00, QUERY_SIZE); - SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_meeting_tbl SET mailbox_name = '%s' %s", target_mailbox_name, conditional_clause); + SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_meeting_tbl SET mailbox_id = %d %s", input_mailbox_id, conditional_clause); EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); @@ -8475,7 +8698,7 @@ INTERNAL_FUNC int emstorage_move_multiple_mails(int account_id, char *target_mai conditional_clause[strlen(conditional_clause) - 1] = ')'; memset(sql_query_string, 0x00, QUERY_SIZE); - SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_read_mail_uid_tbl SET mailbox_name = '%s', local_mbox = '%s' %s", target_mailbox_name, target_mailbox_name, conditional_clause); + SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_read_mail_uid_tbl SET mailbox_name = '%s', mailbox_id = %d %s", target_mailbox_name, input_mailbox_id, conditional_clause); EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); @@ -8488,6 +8711,8 @@ FINISH_OFF: EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); _DISCONNECT_DB; + EM_SAFE_FREE(target_mailbox_name); + if (err_code != NULL) *err_code = error; @@ -8502,12 +8727,12 @@ INTERNAL_FUNC int emstorage_delete_mail(int mail_id, int from_server, int transa if (!mail_id) { EM_DEBUG_EXCEPTION("mail_id[%d]", mail_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -8541,13 +8766,13 @@ INTERNAL_FUNC int emstorage_delete_multiple_mails(int mail_ids[], int number_of_ 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 rc, ret = false, i, cur_sql_query_string = 0; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; if (!mail_ids) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -8588,12 +8813,12 @@ INTERNAL_FUNC int emstorage_delete_mail_by_account(int account_id, int transacti EM_DEBUG_EXCEPTION("account_id[%d]", account_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -8603,13 +8828,13 @@ INTERNAL_FUNC int emstorage_delete_mail_by_account(int account_id, int transacti EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION(" no mail found..."); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; } /* Delete all mails mail_read_mail_uid_tbl table based on account id */ @@ -8617,13 +8842,13 @@ INTERNAL_FUNC int emstorage_delete_mail_by_account(int account_id, int transacti EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION("no mail found..."); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; } if (!emstorage_notify_storage_event(NOTI_MAIL_DELETE_WITH_ACCOUNT, account_id, 0 , NULL, 0)) @@ -8643,42 +8868,42 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(int account_id, char *mbox, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(int account_id, char *mailbox, int transaction, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mbox[%p], transaction[%d], err_code[%p]", account_id, mbox, transaction, err_code); + EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox[%p], transaction[%d], err_code[%p]", account_id, mailbox, transaction, err_code); - if (account_id < FIRST_ACCOUNT_ID || !mbox) { - EM_DEBUG_EXCEPTION(" account_id[%d], mbox[%p]", account_id, mbox); + if (account_id < FIRST_ACCOUNT_ID || !mailbox) { + EM_DEBUG_EXCEPTION(" account_id[%d], mailbox[%p]", account_id, mailbox); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + 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); - SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_tbl WHERE account_id = %d AND mailbox_name = '%s'", account_id, mbox); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_tbl WHERE account_id = %d AND mailbox_name = '%s'", account_id, mailbox); EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); /* Delete Mails from mail_read_mail_uid_tbl */ - SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_read_mail_uid_tbl WHERE account_id = %d AND mailbox_name = '%s'", account_id, mbox); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_read_mail_uid_tbl WHERE account_id = %d AND mailbox_name = '%s'", account_id, mailbox); EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); - if (!emstorage_notify_storage_event(NOTI_MAIL_DELETE_ALL, account_id, 0 , mbox, 0)) + if (!emstorage_notify_storage_event(NOTI_MAIL_DELETE_ALL, account_id, 0 , mailbox, 0)) EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event Failed [ NOTI_MAIL_DELETE_ALL ] >>>> "); ret = true; @@ -8703,7 +8928,7 @@ INTERNAL_FUNC int emstorage_free_mail(emstorage_mail_tbl_t** mail_list, int coun EM_DEBUG_EXCEPTION("mail_ilst[%p], count[%d]", mail_list, count); if (err_code) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -8723,6 +8948,7 @@ INTERNAL_FUNC int emstorage_free_mail(emstorage_mail_tbl_t** mail_list, int coun EM_SAFE_FREE(p->subject); EM_SAFE_FREE(p->file_path_plain); EM_SAFE_FREE(p->file_path_html); + EM_SAFE_FREE(p->file_path_mime_entity); EM_SAFE_FREE(p->message_id); EM_SAFE_FREE(p->email_address_sender); EM_SAFE_FREE(p->email_address_recipient); @@ -8734,7 +8960,7 @@ INTERNAL_FUNC int emstorage_free_mail(emstorage_mail_tbl_t** mail_list, int coun } if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; EM_DEBUG_FUNC_END(); return true; @@ -8747,12 +8973,12 @@ INTERNAL_FUNC int emstorage_get_attachment_count(int mail_id, int *count, int tr if (mail_id <= 0 || !count) { EM_DEBUG_EXCEPTION("mail_id[%d], count[%p]", mail_id, count); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -8763,7 +8989,7 @@ INTERNAL_FUNC int emstorage_get_attachment_count(int mail_id, int *count, int tr char **result; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); *count = atoi(result[1]); @@ -8788,11 +9014,11 @@ INTERNAL_FUNC int emstorage_get_attachment_list(int input_mail_id, int input_tra EM_DEBUG_FUNC_BEGIN("input_mail_id[%d], input_transaction[%d], output_attachment_list[%p], output_attachment_count[%p]", input_mail_id, output_attachment_list, input_transaction, output_attachment_count); if (input_mail_id <= 0 || !output_attachment_list || !output_attachment_count) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int i = 0; int rc = -1; char **result = NULL; @@ -8804,14 +9030,14 @@ INTERNAL_FUNC int emstorage_get_attachment_list(int input_mail_id, int input_tra 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); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); *output_attachment_count = atoi(result[1]); sqlite3_free_table(result); if(*output_attachment_count == 0) { - error = EMF_ERROR_NONE; + error = EMAIL_ERROR_NONE; goto FINISH_OFF; } @@ -8819,7 +9045,7 @@ INTERNAL_FUNC int emstorage_get_attachment_list(int input_mail_id, int input_tra if (!p_data_tbl) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -8827,14 +9053,14 @@ INTERNAL_FUNC int emstorage_get_attachment_list(int input_mail_id, int input_tra EM_DEBUG_LOG("sql_query_string [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION("no matched attachment found..."); - error = EMF_ERROR_ATTACHMENT_NOT_FOUND; + error = EMAIL_ERROR_ATTACHMENT_NOT_FOUND; goto FINISH_OFF; } for (i = 0; i < *output_attachment_count; i++) { @@ -8844,7 +9070,7 @@ INTERNAL_FUNC int emstorage_get_attachment_list(int input_mail_id, int input_tra _get_stmt_field_data_int (hStmt, &(p_data_tbl[i].attachment_size), ATTACHMENT_SIZE_IDX_IN_MAIL_ATTACHMENT_TBL); _get_stmt_field_data_int (hStmt, &(p_data_tbl[i].mail_id), MAIL_ID_IDX_IN_MAIL_ATTACHMENT_TBL); _get_stmt_field_data_int (hStmt, &(p_data_tbl[i].account_id), ACCOUNT_ID_IDX_IN_MAIL_ATTACHMENT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].mailbox_name), 0, MAILBOX_NAME_IDX_IN_MAIL_ATTACHMENT_TBL); + _get_stmt_field_data_int (hStmt, &(p_data_tbl[i].mailbox_id), MAILBOX_ID_IDX_IN_MAIL_ATTACHMENT_TBL); _get_stmt_field_data_int (hStmt, &(p_data_tbl[i].attachment_save_status), ATTACHMENT_SAVE_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL); _get_stmt_field_data_int (hStmt, &(p_data_tbl[i].attachment_drm_type), ATTACHMENT_DRM_TYPE_IDX_IN_MAIL_ATTACHMENT_TBL); _get_stmt_field_data_int (hStmt, &(p_data_tbl[i].attachment_drm_method), ATTACHMENT_DRM_METHOD_IDX_IN_MAIL_ATTACHMENT_TBL); @@ -8853,12 +9079,12 @@ INTERNAL_FUNC int emstorage_get_attachment_list(int input_mail_id, int input_tra EM_DEBUG_LOG("attachment[%d].attachment_id : %d", i, p_data_tbl[i].attachment_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); } FINISH_OFF: - if (error == EMF_ERROR_NONE) + if (error == EMAIL_ERROR_NONE) *output_attachment_list = p_data_tbl; else if (p_data_tbl != NULL) emstorage_free_attachment(&p_data_tbl, *output_attachment_count, NULL); @@ -8867,7 +9093,7 @@ FINISH_OFF: if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed [%d]", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } EMSTORAGE_FINISH_READ_TRANSACTION(input_transaction); @@ -8878,49 +9104,49 @@ FINISH_OFF: return error; } -INTERNAL_FUNC int emstorage_get_attachment(int mail_id, int attachment_id, emstorage_attachment_tbl_t** attachment, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_get_attachment(int attachment_id, emstorage_attachment_tbl_t** attachment, int transaction, int *err_code) { - EM_DEBUG_FUNC_BEGIN("mail_id[%d], attachment_id[%d], attachment[%p], transaction[%d], err_code[%p]", mail_id, attachment_id, attachment, transaction, err_code); + EM_DEBUG_FUNC_BEGIN("attachment_id[%d], attachment[%p], transaction[%d], err_code[%p]", attachment_id, attachment, transaction, err_code); - if (mail_id <= 0 || attachment_id <= 0 || !attachment) { - EM_DEBUG_EXCEPTION("mail_id[%d], attachment_id[%d], attachment[%p]", mail_id, attachment_id, attachment); + if (attachment_id <= 0 || !attachment) { + EM_DEBUG_EXCEPTION("attachment_id[%d], attachment[%p]", attachment_id, attachment); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } emstorage_attachment_tbl_t* p_data_tbl = NULL; int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); EMSTORAGE_START_READ_TRANSACTION(transaction); - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_attachment_tbl WHERE mail_id = %d AND attachment_id = %d", mail_id, attachment_id); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_attachment_tbl WHERE attachment_id = %d", attachment_id); sqlite3_stmt* hStmt = NULL; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG(" before sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION("no matched attachment found..."); - error = EMF_ERROR_ATTACHMENT_NOT_FOUND; + error = EMAIL_ERROR_ATTACHMENT_NOT_FOUND; goto FINISH_OFF; } if (!(p_data_tbl = (emstorage_attachment_tbl_t*)em_malloc(sizeof(emstorage_attachment_tbl_t) * 1))) { EM_DEBUG_EXCEPTION("malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -8930,7 +9156,7 @@ INTERNAL_FUNC int emstorage_get_attachment(int mail_id, int attachment_id, emsto _get_stmt_field_data_int(hStmt, &(p_data_tbl->attachment_size), ATTACHMENT_SIZE_IDX_IN_MAIL_ATTACHMENT_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl->mail_id), MAIL_ID_IDX_IN_MAIL_ATTACHMENT_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl->account_id), ACCOUNT_ID_IDX_IN_MAIL_ATTACHMENT_TBL); - _get_stmt_field_data_string(hStmt, &(p_data_tbl->mailbox_name), 0, MAILBOX_NAME_IDX_IN_MAIL_ATTACHMENT_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->mailbox_id), MAILBOX_ID_IDX_IN_MAIL_ATTACHMENT_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl->attachment_save_status), ATTACHMENT_SAVE_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl->attachment_drm_type), ATTACHMENT_DRM_TYPE_IDX_IN_MAIL_ATTACHMENT_TBL); _get_stmt_field_data_int(hStmt, &(p_data_tbl->attachment_drm_method), ATTACHMENT_DRM_METHOD_IDX_IN_MAIL_ATTACHMENT_TBL); @@ -8954,7 +9180,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -8976,14 +9202,14 @@ INTERNAL_FUNC int emstorage_get_attachment_nth(int mail_id, int nth, emstorage_a EM_DEBUG_EXCEPTION(" mail_id[%d], nth[%d], attachment[%p]", mail_id, nth, attachment_tbl); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } emstorage_attachment_tbl_t* p_data_tbl = NULL; char *p = NULL; int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -8995,23 +9221,23 @@ INTERNAL_FUNC int emstorage_get_attachment_nth(int mail_id, int nth, emstorage_a DB_STMT hStmt = NULL; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION(" no matched attachment found..."); - error = EMF_ERROR_ATTACHMENT_NOT_FOUND; + error = EMAIL_ERROR_ATTACHMENT_NOT_FOUND; goto FINISH_OFF; } if (!(p_data_tbl = (emstorage_attachment_tbl_t*)em_malloc(sizeof(emstorage_attachment_tbl_t) * 1))) { EM_DEBUG_EXCEPTION(" malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -9023,8 +9249,7 @@ INTERNAL_FUNC int emstorage_get_attachment_nth(int mail_id, int nth, emstorage_a p_data_tbl->attachment_size = sqlite3_column_int(hStmt, ATTACHMENT_SIZE_IDX_IN_MAIL_ATTACHMENT_TBL); p_data_tbl->mail_id = sqlite3_column_int(hStmt, MAIL_ID_IDX_IN_MAIL_ATTACHMENT_TBL); p_data_tbl->account_id = sqlite3_column_int(hStmt, ACCOUNT_ID_IDX_IN_MAIL_ATTACHMENT_TBL); - if ((p = (char *)sqlite3_column_text(hStmt, MAILBOX_NAME_IDX_IN_MAIL_ATTACHMENT_TBL)) && (int)strlen(p)) - p_data_tbl->mailbox_name = cpy_str(p); + p_data_tbl->mailbox_id = sqlite3_column_int(hStmt, MAILBOX_ID_IDX_IN_MAIL_ATTACHMENT_TBL); p_data_tbl->attachment_save_status = sqlite3_column_int(hStmt, ATTACHMENT_SAVE_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL); p_data_tbl->attachment_drm_type = sqlite3_column_int(hStmt, ATTACHMENT_DRM_TYPE_IDX_IN_MAIL_ATTACHMENT_TBL); p_data_tbl->attachment_drm_method = sqlite3_column_int(hStmt, ATTACHMENT_DRM_METHOD_IDX_IN_MAIL_ATTACHMENT_TBL); @@ -9050,7 +9275,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -9064,19 +9289,19 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_change_attachment_field(int mail_id, emf_mail_change_type_t type, emstorage_attachment_tbl_t* attachment, int transaction, int *err_code) +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) { EM_DEBUG_FUNC_BEGIN("mail_id[%d], type[%d], attachment[%p], transaction[%d], err_code[%p]", mail_id, type, attachment, transaction, err_code); if (mail_id <= 0 || !attachment) { EM_DEBUG_EXCEPTION(" mail_id[%d], type[%d], attachment[%p]", mail_id, type, attachment); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false;; } int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -9089,28 +9314,27 @@ INTERNAL_FUNC int emstorage_change_attachment_field(int mail_id, emf_mail_change switch (type) { case UPDATE_MAILBOX: EM_DEBUG_LOG("UPDATE_MAILBOX"); - if (!attachment->mailbox_name) { - EM_DEBUG_EXCEPTION(" attachment->mailbox_name[%p]", attachment->mailbox_name); - error = EMF_ERROR_INVALID_PARAM; + if (!attachment->mailbox_id) { + EM_DEBUG_EXCEPTION(" attachment->mailbox_id[%d]", attachment->mailbox_id); + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } SNPRINTF(sql_query_string, sizeof(sql_query_string), - "UPDATE mail_attachment_tbl SET mailbox_name = ? WHERE mail_id = %d", mail_id); - - + "UPDATE mail_attachment_tbl SET mailbox_id = ? WHERE mail_id = %d", mail_id); + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG(" Before sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); - _bind_stmt_field_data_string(hStmt, i++, (char *)attachment->mailbox_name, 0, MAILBOX_NAME_LEN_IN_MAIL_ATTACHMENT_TBL); + _bind_stmt_field_data_int(hStmt, i++, attachment->mailbox_id); break; case UPDATE_SAVENAME: EM_DEBUG_LOG("UPDATE_SAVENAME"); if (!attachment->attachment_path) { EM_DEBUG_EXCEPTION(" attachment->attachment_path[%p]", attachment->attachment_path); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -9127,7 +9351,7 @@ INTERNAL_FUNC int emstorage_change_attachment_field(int mail_id, emf_mail_change EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG(" Before sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); _bind_stmt_field_data_int(hStmt, i++, attachment->attachment_size); @@ -9136,13 +9360,13 @@ INTERNAL_FUNC int emstorage_change_attachment_field(int mail_id, emf_mail_change default: EM_DEBUG_LOG("type[%d]", type); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } EM_DEBUG_LOG("query = [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); ret = true; @@ -9152,7 +9376,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -9166,158 +9390,101 @@ FINISH_OFF: } -INTERNAL_FUNC int emstorage_rename_mailbox(int account_id, char *old_mailbox_name, char *new_mailbox_name, 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, int input_transaction) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], old_mailbox_name[%p], new_mailbox_name[%p], transaction[%d], err_code[%p]", account_id, old_mailbox_name, new_mailbox_name, transaction, err_code); + EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], input_new_mailbox_name[%p], input_new_mailbox_alias [%p], input_transaction[%d]", input_mailbox_id, input_new_mailbox_name, input_new_mailbox_alias, input_transaction); - if (account_id < FIRST_ACCOUNT_ID ||!old_mailbox_name || !new_mailbox_name) { - EM_DEBUG_EXCEPTION("Invalid Parameters"); - if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; - return false; - } - - int rc, ret = true; - int error = EMF_ERROR_NONE; + int rc = 0; + 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 = NULL; + int account_id = 0; + emstorage_mailbox_tbl_t *old_mailbox_data = NULL; - SNPRINTF(sql_query_string, sizeof(sql_query_string), - "UPDATE mail_tbl SET" - " mailbox_name = '%s'" - " WHERE account_id = %d" - " AND mailbox_name = '%s'" - , new_mailbox_name - , account_id - , old_mailbox_name); + if (input_mailbox_id <= 0 || !input_new_mailbox_name || !input_new_mailbox_alias) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); + local_db_handle = emstorage_get_db_connection(); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, - ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + if ((error = emstorage_get_mailbox_by_id(input_mailbox_id, &old_mailbox_data)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", error); + goto FINISH_OFF; + } + account_id = old_mailbox_data->account_id; - if (sqlite3_changes(local_db_handle) == 0) - EM_DEBUG_LOG("no mail matched..."); + EMSTORAGE_START_WRITE_TRANSACTION(input_transaction, error); - SNPRINTF(sql_query_string, sizeof(sql_query_string), - "UPDATE mail_attachment_tbl SET" + "UPDATE mail_box_tbl SET" " mailbox_name = '%s'" - " WHERE account_id = %d" - " AND mailbox_name = '%s'" - , new_mailbox_name - , account_id - , old_mailbox_name); + ",alias = '%s'" + " WHERE mailbox_id = %d" + , input_new_mailbox_name + , input_new_mailbox_alias + , input_mailbox_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); - if (sqlite3_changes(local_db_handle) == 0) - EM_DEBUG_LOG("no attachment matched..."); + if (sqlite3_changes(local_db_handle) == 0) + EM_DEBUG_LOG("no mail_meeting_tbl matched..."); + /* Update mail_tbl */ SNPRINTF(sql_query_string, sizeof(sql_query_string), - "UPDATE mail_meeting_tbl SET" + "UPDATE mail_tbl SET" " mailbox_name = '%s'" - " WHERE account_id = %d" - " AND mailbox_name = '%s'" - , new_mailbox_name - , account_id - , old_mailbox_name); + " WHERE mailbox_id = %d" + , input_new_mailbox_name + , input_mailbox_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); if (sqlite3_changes(local_db_handle) == 0) - EM_DEBUG_LOG("no mail_meeting_tbl matched..."); + EM_DEBUG_LOG("no mail matched..."); ret = true; FINISH_OFF: - EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); - _DISCONNECT_DB; - - if (err_code != NULL) - *err_code = error; - - EM_DEBUG_FUNC_END("ret [%d]", ret); - return ret; -} - - -INTERNAL_FUNC int emstorage_change_attachment_mbox(int account_id, char *old_mailbox_name, char *new_mailbox_name, int transaction, int *err_code) -{ - EM_DEBUG_FUNC_BEGIN("account_id[%d], old_mailbox_name[%p], new_mailbox_name[%p], transaction[%d], err_code[%p]", account_id, old_mailbox_name, new_mailbox_name, transaction, err_code); + EMSTORAGE_FINISH_WRITE_TRANSACTION(input_transaction, ret, error); - if (account_id < FIRST_ACCOUNT_ID || !old_mailbox_name || !new_mailbox_name) { - EM_DEBUG_EXCEPTION(" account_id[%d], old_mailbox_name[%p], new_mailbox_name[%p]", account_id, old_mailbox_name, new_mailbox_name); - - if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; - return false; + if (ret) { + if (!emstorage_notify_storage_event(NOTI_MAILBOX_RENAME, account_id, input_mailbox_id, input_new_mailbox_name, 0)) + EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event Failed [ NOTI_MAILBOX_RENAME ] >>>> "); } - - int rc, ret = true; - int error = EMF_ERROR_NONE; - char sql_query_string[QUERY_SIZE] = {0, }; - - sqlite3 *local_db_handle = emstorage_get_db_connection(); - - EMSTORAGE_START_WRITE_TRANSACTION(transaction, error); - - SNPRINTF(sql_query_string, sizeof(sql_query_string), - "UPDATE mail_attachment_tbl SET" - " mailbox_name = '%s'" - " WHERE account_id = %d" - " AND mailbox_name = '%s'" - , new_mailbox_name - , account_id - , old_mailbox_name); - - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, - ("sqlite3_exec fail:%d", rc)); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, - ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); - - rc = sqlite3_changes(local_db_handle); - if (rc == 0) { - EM_DEBUG_EXCEPTION(" no attachment found..."); + else { + if (!emstorage_notify_storage_event(NOTI_MAILBOX_RENAME_FAIL, account_id, input_mailbox_id, input_new_mailbox_name, 0)) + EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event Failed [ NOTI_MAILBOX_RENAME_FAIL ] >>>> "); } - ret = true; - -FINISH_OFF: + if (old_mailbox_data) + emstorage_free_mailbox(&old_mailbox_data, 1, NULL); - EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); _DISCONNECT_DB; - - if (err_code != NULL) - *err_code = error; - EM_DEBUG_FUNC_END("ret [%d]", ret); - return ret; + EM_DEBUG_FUNC_END("error [%d]", error); + return error; } - INTERNAL_FUNC int emstorage_get_new_attachment_no(int *attachment_no, int *err_code) { EM_DEBUG_FUNC_BEGIN("attachment_no [%p], err_code[%p]", attachment_no, err_code); int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char *sql = "SELECT max(rowid) FROM mail_attachment_tbl;"; char **result; if (!attachment_no) { EM_DEBUG_EXCEPTION("Invalid attachment"); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -9327,7 +9494,7 @@ INTERNAL_FUNC int emstorage_get_new_attachment_no(int *attachment_no, int *err_c EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); if (NULL == result[1]) @@ -9358,7 +9525,7 @@ INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachmen char *sql = NULL; char **result; int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -9366,7 +9533,7 @@ INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachmen if (!attachment_tbl) { EM_DEBUG_EXCEPTION("attachment_tbl[%p], iscopy[%d]", attachment_tbl, iscopy); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -9375,7 +9542,7 @@ INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachmen sql = "SELECT max(rowid) FROM mail_attachment_tbl;"; EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); if (NULL==result[1]) rc = 1; @@ -9392,7 +9559,7 @@ INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachmen ", ?" /* attachment_size */ ", ?" /* mail_id */ ", ?" /* account_id */ - ", ?" /* mailbox_name */ + ", ?" /* mailbox_id */ ", ?" /* attachment_save_status */ ", ?" /* attachment_drm_type */ ", ?" /* attachment_drm_method */ @@ -9406,7 +9573,7 @@ INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachmen EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); _bind_stmt_field_data_int (hStmt, ATTACHMENT_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_id); @@ -9415,7 +9582,7 @@ INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachmen _bind_stmt_field_data_int (hStmt, ATTACHMENT_SIZE_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_size); _bind_stmt_field_data_int (hStmt, MAIL_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->mail_id); _bind_stmt_field_data_int (hStmt, ACCOUNT_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->account_id); - _bind_stmt_field_data_string(hStmt, MAILBOX_NAME_IDX_IN_MAIL_ATTACHMENT_TBL, (char*)attachment_tbl->mailbox_name, 0, MAILBOX_NAME_LEN_IN_MAIL_ATTACHMENT_TBL); + _bind_stmt_field_data_int (hStmt, MAILBOX_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->mailbox_id); _bind_stmt_field_data_int (hStmt, ATTACHMENT_SAVE_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_save_status); _bind_stmt_field_data_int (hStmt, ATTACHMENT_DRM_TYPE_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_drm_type); _bind_stmt_field_data_int (hStmt, ATTACHMENT_DRM_METHOD_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_drm_method); @@ -9428,9 +9595,9 @@ INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachmen EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); /* SNPRINTF(sql_query_string, sizeof(sql_query_string), @@ -9438,15 +9605,15 @@ INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachmen EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_exec fail:%d", rc)); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); */ rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION(" no matched mail found..."); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } @@ -9457,7 +9624,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -9476,13 +9643,13 @@ INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t* attach EM_DEBUG_FUNC_BEGIN("attachment_tbl[%p], transaction[%d], err_code[%p]", attachment_tbl, transaction, err_code); int rc, ret = false, field_idx = 0; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; if (!attachment_tbl) { EM_DEBUG_EXCEPTION(" attachment_tbl[%p] ", attachment_tbl); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -9497,7 +9664,7 @@ INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t* attach ", attachment_size = ?" ", mail_id = ?" ", account_id = ?" - ", mailbox_name = ?" + ", mailbox_id = ?" ", attachment_save_status = ?" ", attachment_drm_type = ?" ", attachment_drm_method = ?" @@ -9508,7 +9675,7 @@ INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t* attach EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); _bind_stmt_field_data_string(hStmt, field_idx++ , (char*)attachment_tbl->attachment_name, 0, ATTACHMENT_NAME_LEN_IN_MAIL_ATTACHMENT_TBL); @@ -9516,7 +9683,7 @@ INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t* attach _bind_stmt_field_data_int (hStmt, field_idx++ , attachment_tbl->attachment_size); _bind_stmt_field_data_int (hStmt, field_idx++ , attachment_tbl->mail_id); _bind_stmt_field_data_int (hStmt, field_idx++ , attachment_tbl->account_id); - _bind_stmt_field_data_string(hStmt, field_idx++ , (char*)attachment_tbl->mailbox_name, 0, MAILBOX_NAME_LEN_IN_MAIL_ATTACHMENT_TBL); + _bind_stmt_field_data_int (hStmt, field_idx++ , attachment_tbl->mailbox_id); _bind_stmt_field_data_int (hStmt, field_idx++ , attachment_tbl->attachment_save_status); _bind_stmt_field_data_int (hStmt, field_idx++ , attachment_tbl->attachment_drm_type); _bind_stmt_field_data_int (hStmt, field_idx++ , attachment_tbl->attachment_drm_method); @@ -9526,9 +9693,9 @@ INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t* attach EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); /* SNPRINTF(sql_query_string, sizeof(sql_query_string), @@ -9536,15 +9703,15 @@ INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t* attach EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_exec fail:%d", rc)); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); */ rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION(" no matched mail found..."); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } @@ -9555,7 +9722,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -9569,34 +9736,67 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_delete_attachment_on_db(int mail_id, int attachment_id, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_delete_attachment_on_db(int attachment_id, int transaction, int *err_code) { - EM_DEBUG_FUNC_BEGIN("mail_id[%d], attachment_id[%d], transaction[%d], err_code[%p]", mail_id, attachment_id, transaction, err_code); + EM_DEBUG_FUNC_BEGIN("attachment_id[%d], transaction[%d], err_code[%p]", attachment_id, transaction, err_code); - if (mail_id < 0 || attachment_id < 0) { - EM_DEBUG_EXCEPTION("mail_id[%d], attachment_id[%d]", mail_id, attachment_id); + if (attachment_id < 0) { + EM_DEBUG_EXCEPTION("attachment_id[%d]", attachment_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc, ret = false; - int error = EMF_ERROR_NONE; + 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); - SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_attachment_tbl"); - - if (mail_id) /* '0' means all mail */ - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " WHERE mail_id = %d", mail_id); - if (attachment_id) /* '0' means all attachment */ - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " AND attachment_id = %d", attachment_id); - + SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_attachment_tbl WHERE attachment_id = %d", attachment_id); + + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + + ret = true; + +FINISH_OFF: + EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); + _DISCONNECT_DB; + + if (err_code) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} + +INTERNAL_FUNC int emstorage_delete_all_attachments_of_mail(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); + + if (mail_id < 0) { + EM_DEBUG_EXCEPTION("mail_id[%d]", mail_id); + if (err_code != NULL) + *err_code = EMAIL_ERROR_INVALID_PARAM; + return false; + } + + 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); + + SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_attachment_tbl WHERE mail_id = %d", mail_id); + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -9612,11 +9812,11 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(int account_id, char *mbox, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(int account_id, char *mailbox, int transaction, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mbox[%p], transaction[%d], err_code[%p]", account_id, mbox, transaction, err_code); + EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox[%p], transaction[%d], err_code[%p]", account_id, mailbox, transaction, err_code); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int rc, ret = false; char sql_query_string[QUERY_SIZE] = {0, }; @@ -9629,11 +9829,11 @@ INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(int account_id, char *mb if (account_id != ALL_ACCOUNT) /* '0' means all account */ SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " WHERE account_id = %d", account_id); - if (mbox) /* NULL means all mailbox_name */ - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " %s mailbox_name = '%s'", account_id != ALL_ACCOUNT ? "AND" : "WHERE", mbox); + if (mailbox) /* NULL means all mailbox_name */ + SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " %s mailbox_name = '%s'", account_id != ALL_ACCOUNT ? "AND" : "WHERE", mailbox); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -9657,7 +9857,7 @@ INTERNAL_FUNC int emstorage_free_attachment(emstorage_attachment_tbl_t** attachm if ((attachment_tbl_list == NULL) || (*attachment_tbl_list == NULL)) { EM_DEBUG_EXCEPTION(" attachment_tbl_list[%p], count[%d]", attachment_tbl_list, count); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -9665,7 +9865,6 @@ INTERNAL_FUNC int emstorage_free_attachment(emstorage_attachment_tbl_t** attachm int i; for (i = 0; i < count; i++) { - EM_SAFE_FREE(p[i].mailbox_name); EM_SAFE_FREE(p[i].attachment_name); EM_SAFE_FREE(p[i].attachment_path); #ifdef __ATTACHMENT_OPTI__ @@ -9678,7 +9877,7 @@ INTERNAL_FUNC int emstorage_free_attachment(emstorage_attachment_tbl_t** attachm } if (err_code != NULL) - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; EM_DEBUG_FUNC_END(); return true; } @@ -9709,7 +9908,7 @@ INTERNAL_FUNC int emstorage_begin_transaction(void *d1, void *d2, int *err_code) EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {ret = false; }, ("SQL(BEGIN) exec error:%d -%s", rc, sqlite3_errmsg(local_db_handle))); if (ret == false && err_code != NULL) - *err_code = EMF_ERROR_DB_FAILURE; + *err_code = EMAIL_ERROR_DB_FAILURE; EM_PROFILE_END(emStorageBeginTransaction); EM_DEBUG_FUNC_END("ret [%d]", ret); @@ -9732,7 +9931,7 @@ INTERNAL_FUNC int emstorage_commit_transaction(void *d1, void *d2, int *err_code LEAVE_CRITICAL_SECTION(_transactionEndLock); if (ret == false && err_code != NULL) - *err_code = EMF_ERROR_DB_FAILURE; + *err_code = EMAIL_ERROR_DB_FAILURE; EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; @@ -9757,38 +9956,38 @@ INTERNAL_FUNC int emstorage_rollback_transaction(void *d1, void *d2, int *err_co LEAVE_CRITICAL_SECTION(_transactionEndLock); if (ret == false && err_code != NULL) - *err_code = EMF_ERROR_DB_FAILURE; + *err_code = EMAIL_ERROR_DB_FAILURE; EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; } -INTERNAL_FUNC int emstorage_is_mailbox_full(int account_id, emf_mailbox_t* mailbox_name, int *result, int *err_code) +INTERNAL_FUNC int emstorage_is_mailbox_full(int account_id, email_mailbox_t *mailbox, int *result, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p], result[%p], err_code[%p]", account_id, mailbox_name, result, err_code); + EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox[%p], result[%p], err_code[%p]", account_id, mailbox, result, err_code); - if (account_id < FIRST_ACCOUNT_ID || !mailbox_name || !result) { - if (mailbox_name) - EM_DEBUG_EXCEPTION("Invalid Parameter. accoun_id[%d], mailbox_name[%p]", account_id, mailbox_name); + if (account_id < FIRST_ACCOUNT_ID || !mailbox || !result) { + if (mailbox) + EM_DEBUG_EXCEPTION("Invalid Parameter. accoun_id[%d], mailbox[%p]", account_id, mailbox); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int mail_count = 0; - if (!emstorage_get_mail_count(account_id, mailbox_name->name, &mail_count, NULL, true, &error)) { + if (!emstorage_get_mail_count(account_id, mailbox->mailbox_name, &mail_count, NULL, true, &error)) { EM_DEBUG_EXCEPTION("emstorage_get_mail_count failed [%d]", error); goto FINISH_OFF; } - if (mailbox_name) { - EM_DEBUG_LOG("mail_count[%d] mail_slot_size[%d]", mail_count, mailbox_name->mail_slot_size); - if (mail_count >= mailbox_name->mail_slot_size) + if (mailbox) { + EM_DEBUG_LOG("mail_count[%d] mail_slot_size[%d]", mail_count, mailbox->mail_slot_size); + if (mail_count >= mailbox->mail_slot_size) *result = true; else *result = false; @@ -9811,11 +10010,11 @@ INTERNAL_FUNC int emstorage_clear_mail_data(int transaction, int *err_code) EM_DEBUG_FUNC_BEGIN("transaction[%d], err_code[%p]", transaction, err_code); int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; - const emf_db_object_t* tables = _g_db_tables; - const emf_db_object_t* indexes = _g_db_indexes; + const email_db_object_t* tables = _g_db_tables; + const email_db_object_t* indexes = _g_db_indexes; char data_path[256]; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -9837,7 +10036,7 @@ INTERNAL_FUNC int emstorage_clear_mail_data(int transaction, int *err_code) if (indexes->data_flag) { SNPRINTF(sql_query_string, sizeof(sql_query_string), "DROP index %s", indexes->object_name); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); } indexes++; @@ -9847,7 +10046,7 @@ INTERNAL_FUNC int emstorage_clear_mail_data(int transaction, int *err_code) if (tables->data_flag) { SNPRINTF(sql_query_string, sizeof(sql_query_string), "DROP table %s", tables->object_name); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); } @@ -9892,14 +10091,14 @@ INTERNAL_FUNC int emstorage_get_save_name(int account_id, int mail_id, int atch_ EM_PROFILE_BEGIN(profile_emstorage_get_save_name); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char *dir_name = NULL; char create_dir[1024]={0}; char *temp_file = 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); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -9955,7 +10154,7 @@ INTERNAL_FUNC int emstorage_get_dele_name(int account_id, int mail_id, int atch_ if (!name_buf || account_id < FIRST_ACCOUNT_ID) { 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 (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -9983,7 +10182,7 @@ INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id, 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); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char buf[512]; struct stat sbuf; @@ -9993,7 +10192,7 @@ INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_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 = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } } @@ -10001,7 +10200,7 @@ INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id, if (mkdir(buf, DIRECTORY_PERMISSION) != 0) { EM_DEBUG_EXCEPTION(" mkdir failed [%s]", buf); EM_DEBUG_EXCEPTION("mkdir failed l(Errno=%d)][ErrStr=%s]", errno, strerror(errno)); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } } @@ -10010,7 +10209,7 @@ INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id, if (mail_id > 0) { 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 = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -10020,7 +10219,7 @@ INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id, if ((sbuf.st_mode & S_IFMT) != S_IFDIR) { EM_DEBUG_EXCEPTION(" a object which isn't directory aleady exists"); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } } @@ -10028,7 +10227,7 @@ INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id, if (mkdir(buf, DIRECTORY_PERMISSION) != 0) { EM_DEBUG_EXCEPTION(" mkdir failed [%s]", buf); EM_DEBUG_EXCEPTION("mkdir failed l (Errno=%d)][ErrStr=%s]", errno, strerror(errno)); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } } @@ -10038,7 +10237,7 @@ INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id, if (account_id < FIRST_ACCOUNT_ID || mail_id <= 0) { EM_DEBUG_EXCEPTION(" account_id[%d], mail_id[%d], atch_id[%d]", account_id, mail_id, atch_id); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -10048,14 +10247,14 @@ INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id, if ((sbuf.st_mode & S_IFMT) != S_IFDIR) { EM_DEBUG_EXCEPTION(" a object which isn't directory aleady exists"); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } } else { if (mkdir(buf, DIRECTORY_PERMISSION) != 0) { EM_DEBUG_EXCEPTION(" mkdir failed [%s]", buf); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } } @@ -10077,7 +10276,7 @@ INTERNAL_FUNC int emstorage_copy_file(char *src_file, char *dst_file, int sync_s EM_DEBUG_FUNC_BEGIN("src_file[%s], dst_file[%s], err_code[%p]", src_file, dst_file, err_code); EM_DEBUG_LOG("Using the fsync function"); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; struct stat st_buf; int fp_src = 0; @@ -10090,14 +10289,14 @@ INTERNAL_FUNC int emstorage_copy_file(char *src_file, char *dst_file, int sync_s if (!src_file || !dst_file) { EM_DEBUG_EXCEPTION("src_file[%p], dst_file[%p]", src_file, dst_file); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (stat(src_file, &st_buf) < 0) { EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", src_file); - error = EMF_ERROR_SYSTEM_FAILURE; /* EMF_ERROR_INVALID_PATH; */ + error = EMAIL_ERROR_SYSTEM_FAILURE; /* EMAIL_ERROR_INVALID_PATH; */ goto FINISH_OFF; } @@ -10107,20 +10306,20 @@ INTERNAL_FUNC int emstorage_copy_file(char *src_file, char *dst_file, int sync_s if (!buf) { EM_DEBUG_EXCEPTION(">>> Memory cannot be allocated"); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } if (buf) { if (!(fp_src = open(src_file, O_RDONLY))) { EM_DEBUG_EXCEPTION(">>>> Source Fail open %s Failed [ %d ] - Error [ %s ]", src_file, errno, strerror(errno)); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } if (!(fp_dst = open(dst_file, O_CREAT | O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH))) { EM_DEBUG_EXCEPTION(">>>> Destination Fail open %s Failed [ %d ] - Error [ %s ]", dst_file, errno, strerror(errno)); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -10129,7 +10328,7 @@ INTERNAL_FUNC int emstorage_copy_file(char *src_file, char *dst_file, int sync_s EM_DEBUG_LOG("Nread Value [%d]", nread); if ((nwritten = write(fp_dst, buf, nread)) != nread) { EM_DEBUG_EXCEPTION("fwrite failed..."); - error = EMF_ERROR_UNKNOWN; + error = EMAIL_ERROR_UNKNOWN; goto FINISH_OFF; } EM_DEBUG_LOG("NWRITTEN [%d]", nwritten); @@ -10151,7 +10350,7 @@ FINISH_OFF: close(fp_dst); } EM_SAFE_FREE(buf); - if (nread < 0 || error == EMF_ERROR_UNKNOWN) + if (nread < 0 || error == EMAIL_ERROR_UNKNOWN) remove(dst_file); if (err_code != NULL) @@ -10180,11 +10379,11 @@ static int _get_temp_file_name(char **filename, int *err_code) EM_DEBUG_FUNC_BEGIN("filename[%p], err_code[%p]", filename, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (filename == NULL) { EM_DEBUG_EXCEPTION(" filename[%p]", filename); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -10199,7 +10398,7 @@ static int _get_temp_file_name(char **filename, int *err_code) char *p = EM_SAFE_STRDUP(tempname); if (p == NULL) { EM_DEBUG_EXCEPTION(" strdup failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -10231,7 +10430,7 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in char *match_str = NULL; int nwritten = 0; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int data_count_to_written = 0; char *temp_file_name = NULL; int err = 0; @@ -10244,7 +10443,7 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in if (stat(file_path, &st_buf) < 0) { EM_DEBUG_EXCEPTION(" stat(\"%s\") failed...", file_path); - error = EMF_ERROR_SYSTEM_FAILURE; /* EMF_ERROR_INVALID_PATH; */ + error = EMAIL_ERROR_SYSTEM_FAILURE; /* EMAIL_ERROR_INVALID_PATH; */ goto FINISH_OFF; } @@ -10262,7 +10461,7 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in if (!(fp_src = fopen(file_path, "rb"))) { EM_DEBUG_EXCEPTION(" file_path fopen failed - %s", file_path); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -10323,7 +10522,7 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in /* Open the Temp file in Append mode */ if (!(fp_dest = fopen(temp_file_name, "ab"))) { EM_DEBUG_EXCEPTION(" fopen failed - %s", temp_file_name); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -10338,7 +10537,7 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in if (nwritten <= 0) { EM_DEBUG_EXCEPTION(" Error Occured while writing Old data : [%d ] bytes written ", nwritten); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } else { @@ -10353,7 +10552,7 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in } else { EM_DEBUG_EXCEPTION(" Error Occured while writing New data : [%d ] bytes written ", nwritten); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -10392,11 +10591,11 @@ INTERNAL_FUNC int emstorage_move_file(char *src_file, char *dst_file, int sync_s EM_DEBUG_FUNC_BEGIN("src_file[%p], dst_file[%p], err_code[%p]", src_file, dst_file, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (src_file == NULL || dst_file == NULL) { EM_DEBUG_EXCEPTION("src_file[%p], dst_file[%p]", src_file, dst_file); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -10424,13 +10623,13 @@ INTERNAL_FUNC int emstorage_move_file(char *src_file, char *dst_file, int sync_s EM_DEBUG_EXCEPTION("no dst file found [%s]", src_file); EM_DEBUG_EXCEPTION("no file found [%d]", errno); - error = EMF_ERROR_FILE_NOT_FOUND; + error = EMAIL_ERROR_FILE_NOT_FOUND; goto FINISH_OFF; } else { EM_DEBUG_EXCEPTION("rename failed [%d]", errno); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } } @@ -10455,12 +10654,12 @@ INTERNAL_FUNC int emstorage_delete_file(char *src_file, int *err_code) EM_DEBUG_FUNC_BEGIN("src_file[%p], err_code[%p]", src_file, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (src_file == NULL) { EM_DEBUG_EXCEPTION(" src_file[%p]", src_file); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -10468,13 +10667,13 @@ INTERNAL_FUNC int emstorage_delete_file(char *src_file, int *err_code) if (errno != ENOENT) { EM_DEBUG_EXCEPTION(" remove failed - %d", errno); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } else { EM_DEBUG_EXCEPTION(" no file found..."); - error = EMF_ERROR_FILE_NOT_FOUND; + error = EMAIL_ERROR_FILE_NOT_FOUND; } } @@ -10497,11 +10696,11 @@ INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code) EM_DEBUG_EXCEPTION(" src_dir[%p]", src_dir); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DIR *dirp; struct dirent *dp; @@ -10514,13 +10713,13 @@ INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code) if (errno == ENOENT) { EM_DEBUG_EXCEPTION("directory[%s] does not exist...", src_dir); if (err_code != NULL) - *err_code = EMF_ERROR_SYSTEM_FAILURE; + *err_code = EMAIL_ERROR_SYSTEM_FAILURE; return true; } else { EM_DEBUG_EXCEPTION("opendir failed - %d", errno); if (err_code != NULL) - *err_code = EMF_ERROR_SYSTEM_FAILURE; + *err_code = EMAIL_ERROR_SYSTEM_FAILURE; return false; } } @@ -10547,7 +10746,7 @@ INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code) EM_DEBUG_EXCEPTION("remove failed - %s", buf); closedir(dirp); if (err_code != NULL) - *err_code = EMF_ERROR_SYSTEM_FAILURE; + *err_code = EMAIL_ERROR_SYSTEM_FAILURE; return false; } } @@ -10565,7 +10764,7 @@ INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code) if (remove(src_dir) < 0) { EM_DEBUG_EXCEPTION("remove failed [%s]", src_dir); if (err_code != NULL) - *err_code = EMF_ERROR_SYSTEM_FAILURE; + *err_code = EMAIL_ERROR_SYSTEM_FAILURE; return false; } @@ -10580,14 +10779,14 @@ INTERNAL_FUNC int emstorage_update_server_uid(char *old_server_uid, char *new_se { EM_DEBUG_FUNC_BEGIN("new_server_uid[%s], old_server_uid[%s]", new_server_uid, old_server_uid); int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; int transaction = true; if (!old_server_uid || !new_server_uid) { EM_DEBUG_EXCEPTION("Invalid parameters"); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; return false; } sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -10598,9 +10797,9 @@ INTERNAL_FUNC int emstorage_update_server_uid(char *old_server_uid, char *new_se "UPDATE mail_tbl SET server_mail_id=\'%s\' WHERE server_mail_id=%s ", new_server_uid, old_server_uid); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_exec fail:%d", rc)); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -10622,14 +10821,14 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid(int mail_id, char *new_server_u EM_DEBUG_FUNC_BEGIN("mail_id[%d], new_server_uid[%s], mbox_name[%s]", mail_id, new_server_uid, mbox_name); int rc, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; int transaction = true; if (!mail_id || !new_server_uid || !mbox_name) { EM_DEBUG_EXCEPTION("Invalid parameters"); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; return false; } sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -10637,9 +10836,9 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid(int mail_id, char *new_server_u SNPRINTF(sql_query_string, sizeof(sql_query_string), - "UPDATE mail_read_mail_uid_tbl SET s_uid=\'%s\', local_mbox=\'%s\', mailbox_name=\'%s\' WHERE local_uid=%d ", new_server_uid, mbox_name, mbox_name, mail_id); + "UPDATE mail_read_mail_uid_tbl SET s_uid=\'%s\', mailbox_id=\'%s\', mailbox_name=\'%s\' WHERE local_uid=%d ", new_server_uid, mbox_name, mbox_name, mail_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -10664,13 +10863,13 @@ int emstorage_get_latest_unread_mailid(int account_id, int *mail_id, int *err_co if ((!mail_id) ||(account_id <= 0 && account_id != -1)) { EM_DEBUG_EXCEPTION(" mail_id[%p], account_id[%d] ", mail_id, account_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; int rc = -1; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; int count = 0; int mailid = 0; @@ -10689,24 +10888,24 @@ int emstorage_get_latest_unread_mailid(int account_id, int *mail_id, int *err_co EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG(" sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); char **result; 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 = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); sqlite3_free_table(result); if (count == 0) { EM_DEBUG_EXCEPTION("no Mails found..."); ret = false; - error= EMF_ERROR_MAIL_NOT_FOUND; + error= EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } @@ -10722,7 +10921,7 @@ FINISH_OFF: if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } EMSTORAGE_FINISH_READ_TRANSACTION(transaction); @@ -10782,12 +10981,12 @@ INTERNAL_FUNC int emstorage_mail_get_total_diskspace_usage(unsigned long *total_ EM_DEBUG_EXCEPTION("total_usage[%p]", total_usage); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char syscmd[256] = {0, }; char line[256] = {0, }; char *line_from_file = NULL; @@ -10798,7 +10997,7 @@ INTERNAL_FUNC int emstorage_mail_get_total_diskspace_usage(unsigned long *total_ if (setting_system_command(syscmd) == -1) { EM_DEBUG_EXCEPTION("emstorage_mail_get_total_diskspace_usage : [Setting > Memory] System Command [%s] is failed", syscmd); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -10807,7 +11006,7 @@ INTERNAL_FUNC int emstorage_mail_get_total_diskspace_usage(unsigned long *total_ if (setting_system_command(syscmd) == -1) { EM_DEBUG_EXCEPTION("emstorage_mail_get_total_diskspace_usage : Setting > Memory] System Command [%s] is failed", syscmd); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -10815,7 +11014,7 @@ INTERNAL_FUNC int emstorage_mail_get_total_diskspace_usage(unsigned long *total_ if (fp == NULL) { perror(SETTING_MEMORY_TEMP_FILE_PATH); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -10823,7 +11022,7 @@ INTERNAL_FUNC int emstorage_mail_get_total_diskspace_usage(unsigned long *total_ if(line_from_file == NULL) { EM_DEBUG_EXCEPTION("fgets failed"); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } total_diskusage = strtoul(line, NULL, 10); @@ -10834,7 +11033,7 @@ INTERNAL_FUNC int emstorage_mail_get_total_diskspace_usage(unsigned long *total_ SNPRINTF(syscmd, sizeof(syscmd), "rm -f %s", SETTING_MEMORY_TEMP_FILE_PATH); if (setting_system_command(syscmd) == -1) { EM_DEBUG_EXCEPTION("emstorage_mail_get_total_diskspace_usage : [Setting > Memory] System Command [%s] is failed", syscmd); - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } @@ -10860,7 +11059,7 @@ INTERNAL_FUNC int emstorage_test(int mail_id, int account_id, char *full_address { DB_STMT hStmt = NULL; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int rc = 0; char sql_query_string[QUERY_SIZE] = {0, }; @@ -10907,7 +11106,10 @@ INTERNAL_FUNC int emstorage_test(int mail_id, int account_id, char *full_address ", ?" /* alias_sender */ ", ?" /* alias_recipient */ ", ?" /* thread_item_count */ - ", ?" /* meeting_request_status */ + ", ?" /* meeting_request_status */ + ", ?" /* message_class */ + ", ?" /* digest_type */ + ", ?" /* smime_type */ ")"); int transaction = true; @@ -10917,13 +11119,13 @@ INTERNAL_FUNC int emstorage_test(int mail_id, int account_id, char *full_address EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); _bind_stmt_field_data_int(hStmt, MAIL_ID_IDX_IN_MAIL_TBL, mail_id); _bind_stmt_field_data_int(hStmt, ACCOUNT_ID_IDX_IN_MAIL_TBL, account_id); _bind_stmt_field_data_string(hStmt, MAILBOX_NAME_IDX_IN_MAIL_TBL, "OUTBOX", 0, MAILBOX_LEN_IN_MAIL_TBL); - _bind_stmt_field_data_int(hStmt, MAILBOX_TYPE_IDX_IN_MAIL_TBL, EMF_MAILBOX_TYPE_OUTBOX); + _bind_stmt_field_data_int(hStmt, MAILBOX_TYPE_IDX_IN_MAIL_TBL, EMAIL_MAILBOX_TYPE_OUTBOX); _bind_stmt_field_data_string(hStmt, SUBJECT_IDX_IN_MAIL_TBL, "save test - long", 1, SUBJECT_LEN_IN_MAIL_TBL); _bind_stmt_field_data_string(hStmt, DATETIME_IDX_IN_MAIL_TBL, "20100316052908", 0, DATETIME_LEN_IN_MAIL_TBL); _bind_stmt_field_data_int(hStmt, SERVER_MAIL_STATUS_IDX_IN_MAIL_TBL, 0); @@ -10963,11 +11165,14 @@ INTERNAL_FUNC int emstorage_test(int mail_id, int account_id, char *full_address _bind_stmt_field_data_int(hStmt, THREAD_ITEM_COUNT_IDX_IN_MAIL_TBL, 0); _bind_stmt_field_data_string(hStmt, PREVIEW_TEXT_IDX_IN_MAIL_TBL, "preview body", 1, PREVIEWBODY_LEN_IN_MAIL_TBL); _bind_stmt_field_data_int(hStmt, MEETING_REQUEST_STATUS_IDX_IN_MAIL_TBL, 0); + _bind_stmt_field_data_int(hStmt, MESSAGE_CLASS_IDX_IN_MAIL_TBL, 0); + _bind_stmt_field_data_int(hStmt, DIGEST_TYPE_IDX_IN_MAIL_TBL, 0); + _bind_stmt_field_data_int(hStmt, SMIME_TYPE_IDX_IN_MAIL_TBL, 0); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); ret = true; @@ -10976,7 +11181,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -11002,7 +11207,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(emstorage_mail_tbl_t * 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 = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; int count = 0, result_thread_id = -1, latest_mail_id_in_thread = -1; time_t latest_date_time = 0; time_t date_time = 0; @@ -11015,14 +11220,14 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(emstorage_mail_tbl_t * char stripped_subject[1025]; sqlite3 *local_db_handle = emstorage_get_db_connection(); - EM_IF_NULL_RETURN_VALUE(mail_tbl, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(thread_id, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(result_latest_mail_id_in_thread, EMF_ERROR_INVALID_PARAM); - EM_IF_NULL_RETURN_VALUE(thread_item_count, EMF_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(mail_tbl, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(thread_id, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(result_latest_mail_id_in_thread, EMAIL_ERROR_INVALID_PARAM); + EM_IF_NULL_RETURN_VALUE(thread_item_count, EMAIL_ERROR_INVALID_PARAM); - if (mail_tbl->mailbox_type == EMF_MAILBOX_TYPE_TRASH || - mail_tbl->mailbox_type == EMF_MAILBOX_TYPE_SPAMBOX || - mail_tbl->mailbox_type == EMF_MAILBOX_TYPE_ALL_EMAILS) { + if (mail_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH || + mail_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX || + mail_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_ALL_EMAILS) { EM_DEBUG_LOG("the mail in trash, spambox, all email could not be thread mail."); goto FINISH_OFF; } @@ -11034,9 +11239,9 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(emstorage_mail_tbl_t * EM_DEBUG_LOG("subject : %s", subject); - if (em_find_pos_stripped_subject_for_thread_view(subject, stripped_subject) != EMF_ERROR_NONE) { + if (em_find_pos_stripped_subject_for_thread_view(subject, stripped_subject) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("em_find_pos_stripped_subject_for_thread_view is failed"); - err_code = EMF_ERROR_UNKNOWN; + err_code = EMAIL_ERROR_UNKNOWN; result_thread_id = -1; goto FINISH_OFF; } @@ -11053,7 +11258,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(emstorage_mail_tbl_t * sql_account = malloc(query_size_account); if (sql_account == NULL) { EM_DEBUG_EXCEPTION("malloc for sql_account is failed %d", query_size_account); - err_code = EMF_ERROR_OUT_OF_MEMORY; + err_code = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } snprintf(sql_account, query_size_account, sql_format_account, account_id); @@ -11065,7 +11270,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(emstorage_mail_tbl_t * if (sql_query_string == NULL) { EM_DEBUG_EXCEPTION("malloc for sql is failed %d", query_size); - err_code = EMF_ERROR_OUT_OF_MEMORY; + err_code = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -11081,7 +11286,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(emstorage_mail_tbl_t * 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, {err_code = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err_code = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EM_DEBUG_LOG("Result rows count : %d", count); @@ -11124,7 +11329,7 @@ INTERNAL_FUNC int emstorage_get_thread_information(int thread_id, emstorage_mail EM_DEBUG_FUNC_BEGIN(); int count = 0, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; emstorage_mail_tbl_t *p_data_tbl = NULL; char conditional_clause[QUERY_SIZE] = {0, }; @@ -11157,24 +11362,24 @@ FINISH_OFF: } -INTERNAL_FUNC int emstorage_get_sender_list(int account_id, const char *mailbox_name, int search_type, const char *search_value, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count, int *err_code) +INTERNAL_FUNC int emstorage_get_sender_list(int account_id, const char *mailbox_name, 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("account_id [%d], mailbox_name [%p], search_type [%d], search_value [%p], sorting [%d], sender_list[%p], sender_count[%p] err_code[%p]" , account_id , mailbox_name , search_type , search_value , sorting , sender_list, sender_count, err_code); if ((!sender_list) ||(!sender_count)) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int count = 0; int i, col_index = 0; int read_count = 0; - emf_sender_list_t *p_sender_list = NULL; + 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(); @@ -11196,23 +11401,23 @@ INTERNAL_FUNC int emstorage_get_sender_list(int account_id, const char *mailbox_ if (search_value) { switch (search_type) { - case EMF_SEARCH_FILTER_SUBJECT: + case EMAIL_SEARCH_FILTER_SUBJECT: SNPRINTF(sql_query_string + strlen(sql_query_string), QUERY_SIZE-(strlen(sql_query_string)+1), " AND (UPPER(subject) LIKE UPPER(\'%%%%%s%%%%\')) ", search_value); break; - case EMF_SEARCH_FILTER_SENDER: + case EMAIL_SEARCH_FILTER_SENDER: SNPRINTF(sql_query_string + strlen(sql_query_string), QUERY_SIZE-(strlen(sql_query_string)+1), " AND ((UPPER(full_address_from) LIKE UPPER(\'%%%%%s%%%%\')) " ") ", search_value); break; - case EMF_SEARCH_FILTER_RECIPIENT: + case EMAIL_SEARCH_FILTER_RECIPIENT: SNPRINTF(sql_query_string + strlen(sql_query_string), QUERY_SIZE-(strlen(sql_query_string)+1), " AND ((UPPER(full_address_to) LIKE UPPER(\'%%%%%s%%%%\')) " " OR (UPPER(full_address_cc) LIKE UPPER(\'%%%%%s%%%%\')) " " OR (UPPER(full_address_bcc) LIKE UPPER(\'%%%%%s%%%%\')) " ") ", search_value, search_value, search_value); break; - case EMF_SEARCH_FILTER_ALL: + case EMAIL_SEARCH_FILTER_ALL: SNPRINTF(sql_query_string + strlen(sql_query_string), QUERY_SIZE-(strlen(sql_query_string)+1), " AND (UPPER(subject) LIKE UPPER(\'%%%%%s%%%%\') " " OR (((UPPER(full_address_from) LIKE UPPER(\'%%%%%s%%%%\')) " @@ -11235,14 +11440,14 @@ INTERNAL_FUNC int emstorage_get_sender_list(int account_id, const char *mailbox_ EM_DEBUG_LOG("query[%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EM_DEBUG_LOG("Count of Sender [%d]", count); - if (!(p_sender_list = (emf_sender_list_t*)em_malloc(sizeof(emf_sender_list_t) * count))) { + if (!(p_sender_list = (email_sender_list_t*)em_malloc(sizeof(email_sender_list_t) * count))) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -11281,20 +11486,20 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_free_sender_list(emf_sender_list_t **sender_list, int count) +INTERNAL_FUNC int emstorage_free_sender_list(email_sender_list_t **sender_list, int count) { EM_DEBUG_FUNC_BEGIN("sender_list[%p], count[%d]", sender_list, count); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (count > 0) { if (!sender_list || !*sender_list) { EM_DEBUG_EXCEPTION("sender_list[%p], count[%d]", sender_list, count); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; return err; } - emf_sender_list_t* p = *sender_list; + email_sender_list_t* p = *sender_list; int i = 0; for (; i < count; i++) { @@ -11310,35 +11515,35 @@ INTERNAL_FUNC int emstorage_free_sender_list(emf_sender_list_t **sender_list, in } -INTERNAL_FUNC int emstorage_free_address_info_list(emf_address_info_list_t **address_info_list) +INTERNAL_FUNC int emstorage_free_address_info_list(email_address_info_list_t **address_info_list) { EM_DEBUG_FUNC_BEGIN("address_info_list[%p]", address_info_list); - int err = EMF_ERROR_NONE; - emf_address_info_t *p_address_info = NULL; + int err = EMAIL_ERROR_NONE; + email_address_info_t *p_address_info = NULL; GList *list = NULL; GList *node = NULL; int i = 0; if (!address_info_list || !*address_info_list) { EM_DEBUG_EXCEPTION("address_info_list[%p]", address_info_list); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; return err; } /* delete GLists */ - for (i = EMF_ADDRESS_TYPE_FROM; i <= EMF_ADDRESS_TYPE_BCC; i++) { + for (i = EMAIL_ADDRESS_TYPE_FROM; i <= EMAIL_ADDRESS_TYPE_BCC; i++) { switch (i) { - case EMF_ADDRESS_TYPE_FROM: + case EMAIL_ADDRESS_TYPE_FROM: list = (*address_info_list)->from; break; - case EMF_ADDRESS_TYPE_TO: + case EMAIL_ADDRESS_TYPE_TO: list = (*address_info_list)->to; break; - case EMF_ADDRESS_TYPE_CC: + case EMAIL_ADDRESS_TYPE_CC: list = (*address_info_list)->cc; break; - case EMF_ADDRESS_TYPE_BCC: + case EMAIL_ADDRESS_TYPE_BCC: list = (*address_info_list)->bcc; break; } @@ -11346,7 +11551,7 @@ INTERNAL_FUNC int emstorage_free_address_info_list(emf_address_info_list_t **add /* delete dynamic-allocated memory for each item */ node = g_list_first(list); while (node != NULL) { - p_address_info = (emf_address_info_t*)node->data; + p_address_info = (email_address_info_t*)node->data; EM_SAFE_FREE(p_address_info->address); EM_SAFE_FREE(p_address_info->display_name); EM_SAFE_FREE(node->data); @@ -11363,20 +11568,20 @@ INTERNAL_FUNC int emstorage_free_address_info_list(emf_address_info_list_t **add } #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__ -INTERNAL_FUNC int emstorage_add_pbd_activity(emf_event_partial_body_thd* local_activity, int *activity_id, 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) { EM_DEBUG_FUNC_BEGIN("local_activity[%p], activity_id[%p], transaction[%d], err_code[%p]", local_activity, activity_id, transaction, err_code); if (!local_activity || !activity_id) { EM_DEBUG_EXCEPTION("local_activity[%p], transaction[%d], activity_id[%p], err_code[%p]", local_activity, activity_id, transaction, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int i = 0; char sql_query_string[QUERY_SIZE] = {0, }; @@ -11392,6 +11597,7 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(emf_event_partial_body_thd* local_a ",?" /* Server mail ID */ ",?" /* Activity ID */ ",?" /* Activity type*/ + ",?" /* Mailbox ID*/ ",?" /* Mailbox name*/ ") "); @@ -11401,7 +11607,7 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(emf_event_partial_body_thd* local_a EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); if (NULL==result[1]) rc = 1; @@ -11414,12 +11620,12 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(emf_event_partial_body_thd* local_a EM_DEBUG_LOG(">>>>> ACTIVITY ID [ %d ], MAIL ID [ %d ], ACTIVITY TYPE [ %d ], SERVER MAIL ID [ %lu ]", \ local_activity->activity_id, local_activity->mail_id, local_activity->activity_type, local_activity->server_mail_id); - if (local_activity->mailbox_name) - EM_DEBUG_LOG(" MAILBOX NAME [ %s ]", local_activity->mailbox_name); + if (local_activity->mailbox_id) + EM_DEBUG_LOG(" MAILBOX ID [ %d ]", local_activity->mailbox_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); EM_DEBUG_LOG(">>>> SQL STMT [ %s ]", sql_query_string); @@ -11429,14 +11635,15 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(emf_event_partial_body_thd* local_a _bind_stmt_field_data_int(hStmt, i++, local_activity->server_mail_id); _bind_stmt_field_data_int(hStmt, i++, local_activity->activity_id); _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); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d, errmsg = %s.", rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -11450,7 +11657,7 @@ FINISH_OFF: hStmt = NULL; if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -11464,22 +11671,22 @@ FINISH_OFF: } -INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(int account_id, char *** mailbox_list, int *count, 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) { EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], count[%p] err_code[%p]", account_id, mailbox_list, count, err_code); if (account_id < FIRST_ACCOUNT_ID || NULL == &mailbox_list || NULL == count) { EM_DEBUG_EXCEPTION("account_id[%d], mailbox_list[%p], count[%p] err_code[%p]", account_id, mailbox_list, count, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char **result; int i = 0, rc = -1; - char **mbox_list = NULL; + int *mbox_list = NULL; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -11488,11 +11695,11 @@ INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(int account_id, char *** mailbo EMSTORAGE_START_READ_TRANSACTION(transaction); memset(sql_query_string, 0x00, sizeof(sql_query_string)); - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT count(distinct mailbox_name) FROM mail_partial_body_activity_tbl WHERE account_id = %d order by mailbox_name", account_id); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT count(distinct mailbox_id) FROM mail_partial_body_activity_tbl WHERE account_id = %d order by mailbox_id", account_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); *count = atoi(result[1]); @@ -11500,7 +11707,7 @@ INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(int account_id, char *** mailbo if (!*count) { EM_DEBUG_EXCEPTION(" no mailbox_name found..."); - error = EMF_ERROR_MAILBOX_NOT_FOUND; + error = EMAIL_ERROR_MAILBOX_NOT_FOUND; ret = true; goto FINISH_OFF; } @@ -11509,7 +11716,7 @@ INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(int account_id, char *** mailbo memset(sql_query_string, 0x00, sizeof(sql_query_string)); /* SNPRINTF(g_sql_query, sizeof(g_sql_query), "SELECT distinct mailbox_name FROM mail_partial_body_activity_tbl WHERE account_id = %d order by activity_id", account_id); */ - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT distinct mailbox_name FROM mail_partial_body_activity_tbl WHERE account_id = %d order by mailbox_name", account_id); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT distinct mailbox_id FROM mail_partial_body_activity_tbl WHERE account_id = %d order by mailbox_id", account_id); EM_DEBUG_LOG(" Query [%s]", sql_query_string); @@ -11517,30 +11724,29 @@ INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(int account_id, char *** mailbo EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG(" Bbefore sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - if (NULL == (mbox_list = (char **)em_malloc(sizeof(char *) * (*count)))) { + if (NULL == (mbox_list = (int *)em_malloc(sizeof(int *) * (*count)))) { EM_DEBUG_EXCEPTION(" em_malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - memset(mbox_list, 0x00, sizeof(char *) * (*count)); + memset(mbox_list, 0x00, sizeof(int) * (*count)); for (i = 0; i < (*count); i++) { - _get_stmt_field_data_string(hStmt, &mbox_list[i], 0, ACCOUNT_IDX_MAIL_PARTIAL_BODY_ACTIVITY_TBL); - + _get_stmt_field_data_int(hStmt, mbox_list + i, 0); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); /* EM_DEBUG_LOG("In emstorage_get_pdb_mailbox_list() loop, After sqlite3_step(), , i = %d, rc = %d.", i, rc); */ - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_LOG("mbox_list %s", mbox_list[i]); + EM_DEBUG_LOG("mbox_list %d", mbox_list + i); } ret = true; @@ -11556,7 +11762,7 @@ FINISH_OFF: hStmt = NULL; if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -11576,12 +11782,12 @@ INTERNAL_FUNC int emstorage_get_pbd_account_list(int **account_list, int *count, if (NULL == &account_list || NULL == count) { EM_DEBUG_EXCEPTION("mailbox_list[%p], count[%p] err_code[%p]", account_list, count, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char *sql; char **result; int i = 0, rc = -1; @@ -11598,7 +11804,7 @@ INTERNAL_FUNC int emstorage_get_pbd_account_list(int **account_list, int *count, EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); *count = atoi(result[1]); @@ -11606,7 +11812,7 @@ INTERNAL_FUNC int emstorage_get_pbd_account_list(int **account_list, int *count, if (!*count) { EM_DEBUG_EXCEPTION("no account found..."); - error = EMF_ERROR_MAILBOX_NOT_FOUND; + error = EMAIL_ERROR_MAILBOX_NOT_FOUND; ret = true; goto FINISH_OFF; } @@ -11623,17 +11829,17 @@ INTERNAL_FUNC int emstorage_get_pbd_account_list(int **account_list, int *count, EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG("Before sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (NULL == (result_account_list = (int *)em_malloc(sizeof(int) * (*count)))) { EM_DEBUG_EXCEPTION(" em_malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -11643,7 +11849,7 @@ INTERNAL_FUNC int emstorage_get_pbd_account_list(int **account_list, int *count, _get_stmt_field_data_int(hStmt, result_account_list + i, 0); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); EM_DEBUG_LOG("account id -> %d", result_account_list[i]); } @@ -11661,7 +11867,7 @@ FINISH_OFF: hStmt = NULL; if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -11675,25 +11881,25 @@ FINISH_OFF: -INTERNAL_FUNC int emstorage_get_pbd_activity_data(int account_id, char *mailbox_name, emf_event_partial_body_thd** event_start, int *count, int transaction, 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) { EM_DEBUG_FUNC_BEGIN("account_id[%d], event_start[%p], err_code[%p]", account_id, event_start, err_code); - if (account_id < FIRST_ACCOUNT_ID || NULL == event_start || NULL == mailbox_name || NULL == count) { - EM_DEBUG_EXCEPTION("account_id[%d], emf_event_partial_body_thd[%p], mailbox_name[%p], count[%p], err_code[%p]", account_id, event_start, mailbox_name, count, err_code); + if (account_id < FIRST_ACCOUNT_ID || NULL == event_start || 0 == input_mailbox_id || NULL == count) { + EM_DEBUG_EXCEPTION("account_id[%d], email_event_partial_body_thd[%p], input_mailbox_id[%d], count[%p], err_code[%p]", account_id, event_start, input_mailbox_id, count, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1; int ret = false; char **result; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int i = 0; DB_STMT hStmt = NULL; - emf_event_partial_body_thd* event_list = NULL; + email_event_partial_body_thd* event_list = NULL; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -11701,11 +11907,11 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_data(int account_id, char *mailbox_ EMSTORAGE_START_READ_TRANSACTION(transaction); memset(sql_query_string, 0x00, sizeof(sql_query_string)); - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT count(*) FROM mail_partial_body_activity_tbl WHERE account_id = %d AND mailbox_name = '%s' order by activity_id", account_id, mailbox_name); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT count(*) FROM mail_partial_body_activity_tbl WHERE account_id = %d AND mailbox_id = '%d' order by activity_id", account_id, input_mailbox_id); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); *count = atoi(result[1]); @@ -11716,14 +11922,14 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_data(int account_id, char *mailbox_ if (!*count) { EM_DEBUG_EXCEPTION("No matched activity found in mail_partial_body_activity_tbl"); - error = EMF_ERROR_MAIL_NOT_FOUND; + error = EMAIL_ERROR_MAIL_NOT_FOUND; ret = true; goto FINISH_OFF; } EM_DEBUG_LOG("Activity Count = %d", *count); memset(sql_query_string, 0x00, sizeof(sql_query_string)); - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_partial_body_activity_tbl WHERE account_id = %d AND mailbox_name = '%s' order by activity_id", account_id, mailbox_name); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_partial_body_activity_tbl WHERE account_id = %d AND mailbox_id = '%d' order by activity_id", account_id, input_mailbox_id); EM_DEBUG_LOG("Query [%s]", sql_query_string); @@ -11731,21 +11937,21 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_data(int account_id, char *mailbox_ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG(" Bbefore sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - if (!(event_list = (emf_event_partial_body_thd*)em_malloc(sizeof(emf_event_partial_body_thd) * (*count)))) { + if (!(event_list = (email_event_partial_body_thd*)em_malloc(sizeof(email_event_partial_body_thd) * (*count)))) { EM_DEBUG_EXCEPTION("Malloc failed"); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - memset(event_list, 0x00, sizeof(emf_event_partial_body_thd) * (*count)); + memset(event_list, 0x00, sizeof(email_event_partial_body_thd) * (*count)); for (i=0; i < (*count); i++) { _get_stmt_field_data_int(hStmt, &(event_list[i].account_id), ACCOUNT_IDX_MAIL_PARTIAL_BODY_ACTIVITY_TBL); @@ -11753,12 +11959,12 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_data(int account_id, char *mailbox_ _get_stmt_field_data_int(hStmt, (int *)&(event_list[i].server_mail_id), SERVER_MAIL_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL); _get_stmt_field_data_int(hStmt, &(event_list[i].activity_id), ACTIVITY_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL); _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); - 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); */ - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); event_list[i].event_type = 0; @@ -11770,11 +11976,7 @@ FINISH_OFF: if (true == ret) *event_start = event_list; else { - if (event_list) { - for (i=0; i < (*count); i++) - EM_SAFE_FREE(event_list[i].mailbox_name); - EM_SAFE_FREE(event_list); - } + EM_SAFE_FREE(event_list); } if (hStmt != NULL) { @@ -11784,7 +11986,7 @@ FINISH_OFF: hStmt = NULL; if (rc != SQLITE_OK) { EM_DEBUG_LOG("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -11808,13 +12010,13 @@ INTERNAL_FUNC int emstorage_delete_pbd_activity(int account_id, int mail_id, int EM_DEBUG_EXCEPTION("account_id[%d], mail_id[%d], activity_id[%d], transaction[%d], err_code[%p]", account_id, mail_id, activity_id, transaction, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -11830,16 +12032,16 @@ INTERNAL_FUNC int emstorage_delete_pbd_activity(int account_id, int mail_id, int EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_exec fail:%d", rc)); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); /* validate activity existence */ rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION("No matching activity found"); - error = EMF_ERROR_DATA_NOT_FOUND; + error = EMAIL_ERROR_DATA_NOT_FOUND; ret = true; goto FINISH_OFF; } @@ -11858,19 +12060,19 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_get_mailbox_pbd_activity_count(int account_id, char *mailbox_name, int *activity_count, 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) { EM_DEBUG_FUNC_BEGIN("account_id[%d], activity_count[%p], err_code[%p]", account_id, activity_count, err_code); if (account_id < FIRST_ACCOUNT_ID || NULL == activity_count || NULL == err_code) { EM_DEBUG_EXCEPTION("account_id[%d], activity_count[%p], err_code[%p]", account_id, activity_count, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; DB_STMT hStmt = NULL; @@ -11880,19 +12082,19 @@ INTERNAL_FUNC int emstorage_get_mailbox_pbd_activity_count(int account_id, char EMSTORAGE_START_READ_TRANSACTION(transaction); memset(sql_query_string, 0x00, sizeof(sql_query_string)); - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT count(*) FROM mail_partial_body_activity_tbl WHERE account_id = %d and mailbox_name = '%s'", account_id, mailbox_name); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT count(*) FROM mail_partial_body_activity_tbl WHERE account_id = %d and mailbox_id = '%d'", account_id, input_mailbox_id); EM_DEBUG_LOG(" Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG("before sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); _get_stmt_field_data_int(hStmt, activity_count, 0); @@ -11909,7 +12111,7 @@ FINISH_OFF: hStmt=NULL; if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } EM_DEBUG_LOG("sqlite3_finalize- %d", rc); } @@ -11932,12 +12134,12 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_count(int *activity_count, int tran if (NULL == activity_count || NULL == err_code) { EM_DEBUG_EXCEPTION("activity_count[%p], err_code[%p]", activity_count, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -11953,12 +12155,12 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_count(int *activity_count, int tran EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); EM_DEBUG_LOG(" before sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); _get_stmt_field_data_int(hStmt, activity_count, 0); @@ -11977,7 +12179,7 @@ FINISH_OFF: hStmt=NULL; if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } EM_DEBUG_LOG("sqlite3_finalize- %d", rc); } @@ -11997,13 +12199,13 @@ INTERNAL_FUNC int emstorage_delete_full_pbd_activity_data(int account_id, int tr if (account_id < FIRST_ACCOUNT_ID) { EM_DEBUG_EXCEPTION("account_id[%d], transaction[%d], err_code[%p]", account_id, transaction, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -12014,16 +12216,16 @@ INTERNAL_FUNC int emstorage_delete_full_pbd_activity_data(int account_id, int tr EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_exec fail:%d", rc)); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION("No matching activities found in mail_partial_body_activity_tbl"); - error = EMF_ERROR_DATA_NOT_FOUND; + error = EMAIL_ERROR_DATA_NOT_FOUND; ret = true; goto FINISH_OFF; } @@ -12049,14 +12251,14 @@ INTERNAL_FUNC int emstorage_update_pbd_activity(char *old_server_uid, char *new_ EM_DEBUG_FUNC_BEGIN("old_server_uid[%s], new_server_uid[%s], mbox_name[%s]", old_server_uid, new_server_uid, mbox_name); int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; int transaction = true; if (!old_server_uid || !new_server_uid || !mbox_name) { EM_DEBUG_EXCEPTION("Invalid parameters"); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -12069,15 +12271,15 @@ INTERNAL_FUNC int emstorage_update_pbd_activity(char *old_server_uid, char *new_ EM_DEBUG_LOG("Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_exec fail:%d", rc)); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION("No matching found in mail_partial_body_activity_tbl"); - error = EMF_ERROR_DATA_NOT_FOUND; + error = EMAIL_ERROR_DATA_NOT_FOUND; goto FINISH_OFF; } @@ -12100,13 +12302,13 @@ INTERNAL_FUNC int emstorage_create_file(char *data_string, size_t file_size, cha EM_DEBUG_FUNC_BEGIN("file_size[%d] , dst_file_name[%s], err_code[%p]", file_size, dst_file_name, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; FILE* fp_dst = NULL; if (!data_string || !dst_file_name) { EM_DEBUG_EXCEPTION("data_string[%p], dst_file_name[%p]", data_string, dst_file_name); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -12115,15 +12317,15 @@ INTERNAL_FUNC int emstorage_create_file(char *data_string, size_t file_size, cha if (!fp_dst) { EM_DEBUG_EXCEPTION("fopen failed - %s", dst_file_name); if (errno == 28) - error = EMF_ERROR_MAIL_MEMORY_FULL; + error = EMAIL_ERROR_MAIL_MEMORY_FULL; else - error = EMF_ERROR_SYSTEM_FAILURE; + error = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; } if (fwrite(data_string, 1, file_size, fp_dst) < 0) { EM_DEBUG_EXCEPTION("fwrite failed..."); - error = EMF_ERROR_UNKNOWN; + error = EMAIL_ERROR_UNKNOWN; goto FINISH_OFF; } @@ -12152,14 +12354,14 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *old_server_ EM_DEBUG_FUNC_BEGIN(); int rc = -1; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; int transaction = true; if (!old_server_uid || !new_server_uid || !mbox_name) { EM_DEBUG_EXCEPTION("Invalid parameters"); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -12170,14 +12372,14 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *old_server_ SNPRINTF(sql_query_string, sizeof(sql_query_string), - "UPDATE mail_read_mail_uid_tbl SET s_uid=\'%s\' , local_mbox=\'%s\', mailbox_name=\'%s\' WHERE s_uid=%s ", new_server_uid, mbox_name, mbox_name, old_server_uid); + "UPDATE mail_read_mail_uid_tbl SET s_uid=\'%s\' , mailbox_id=\'%s\', mailbox_name=\'%s\' WHERE s_uid=%s ", new_server_uid, mbox_name, mbox_name, old_server_uid); EM_DEBUG_LOG(" Query [%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_exec fail:%d", rc)); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); @@ -12185,7 +12387,7 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *old_server_ if (rc == 0) { EM_DEBUG_EXCEPTION("No matching found in mail_partial_body_activity_tbl"); - error = EMF_ERROR_DATA_NOT_FOUND; + error = EMAIL_ERROR_DATA_NOT_FOUND; goto FINISH_OFF; } @@ -12207,7 +12409,7 @@ FINISH_OFF: /** - * @fn emstorage_get_id_set_from_mail_ids(int mail_ids[], int mail_id_count, emf_id_set_t** server_uids, int *id_set_count, 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); * Prepare an array of mail_id and corresponding server mail id. * *@author h.gahlaut@samsung.com @@ -12221,14 +12423,14 @@ FINISH_OFF: * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *mail_ids, emf_id_set_t** idset, int *id_set_count, int *err_code) +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) { EM_DEBUG_FUNC_BEGIN(); EM_PROFILE_BEGIN(EmStorageGetIdSetFromMailIds); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int ret = false; - emf_id_set_t* p_id_set = NULL; + email_id_set_t* p_id_set = NULL; int count = 0; const int buf_size = QUERY_SIZE; char sql_query_string[QUERY_SIZE] = {0, }; @@ -12242,7 +12444,7 @@ INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *mail_ids, emf_id_set_ if (NULL == mail_ids || NULL == idset || NULL == id_set_count) { EM_DEBUG_EXCEPTION("Invalid Parameters mail_ids[%p] idset[%p] id_set_count [%p]", mail_ids, idset, id_set_count); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -12254,21 +12456,21 @@ INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *mail_ids, emf_id_set_ /* rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL); */ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EM_DEBUG_LOG(" Count of mails [%d ]", count); if (count <= 0) { EM_DEBUG_EXCEPTION("Can't find proper mail"); - error = EMF_ERROR_DATA_NOT_FOUND; + error = EMAIL_ERROR_DATA_NOT_FOUND; goto FINISH_OFF; } - if (NULL == (p_id_set = (emf_id_set_t*)em_malloc(sizeof(emf_id_set_t) * count))) { + if (NULL == (p_id_set = (email_id_set_t*)em_malloc(sizeof(email_id_set_t) * count))) { EM_DEBUG_EXCEPTION(" em_malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -12319,7 +12521,7 @@ INTERNAL_FUNC int emstorage_delete_triggers_from_lucene() { EM_DEBUG_FUNC_BEGIN(); int rc, ret = true, transaction = true; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; sqlite3 *local_db_handle = emstorage_get_db_connection(); @@ -12328,20 +12530,20 @@ INTERNAL_FUNC int emstorage_delete_triggers_from_lucene() SNPRINTF(sql_query_string, sizeof(sql_query_string), "DROP TRIGGER triggerDelete;"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); SNPRINTF(sql_query_string, sizeof(sql_query_string), "DROP TRIGGER triggerInsert;"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); SNPRINTF(sql_query_string, sizeof(sql_query_string), "DROP TRIGGER triggerUpdate;"); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -12356,19 +12558,19 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_filter_mails_by_rule(int account_id, char *dest_mailbox_name, 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(int account_id, int dest_mailbox_id, 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_name[%p] rule[%p], filtered_mail_id_list[%p], count_of_mails[%p], err_code[%p]", account_id, dest_mailbox_name, rule, filtered_mail_id_list, count_of_mails, 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); - if ((account_id <= 0) || (!dest_mailbox_name) || (!rule) || (!rule->value)|| (!filtered_mail_id_list) || (!count_of_mails)) { + if ((account_id <= 0) || (dest_mailbox_id <= 0) || (!rule) || (!rule->value)|| (!filtered_mail_id_list) || (!count_of_mails)) { EM_DEBUG_EXCEPTION("Invalid Parameter"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - int rc = -1, ret = false, error = EMF_ERROR_NONE; + int rc = -1, ret = false, error = EMAIL_ERROR_NONE; int count = 0, col_index = 0, i = 0, where_pararaph_length = 0, *mail_list = NULL; char **result = NULL, *where_pararaph = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -12384,7 +12586,7 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(int account_id, char *dest_mail if (where_pararaph == NULL) { EM_DEBUG_EXCEPTION("malloc failed for where_pararaph."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -12392,20 +12594,20 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(int account_id, char *dest_mail EM_DEBUG_LOG("rule->type [%d], rule->flag2[%d]", rule->type, rule->flag2); - if (rule->type == EMF_FILTER_FROM) { + if (rule->type == EMAIL_FILTER_FROM) { if (rule->flag2 == RULE_TYPE_INCLUDES) SNPRINTF(where_pararaph, where_pararaph_length, "WHERE account_id = %d AND mailbox_type NOT in (3,5) AND full_address_from like \'%%%s%%\'", account_id, rule->value); else /* RULE_TYPE_EXACTLY */ SNPRINTF(where_pararaph, where_pararaph_length, "WHERE account_id = %d AND mailbox_type NOT in (3,5) AND full_address_from = \'%s\'", account_id, rule->value); } - else if (rule->type == EMF_FILTER_SUBJECT) { + else if (rule->type == EMAIL_FILTER_SUBJECT) { if (rule->flag2 == RULE_TYPE_INCLUDES) SNPRINTF(where_pararaph, where_pararaph_length, "WHERE account_id = %d AND mailbox_type NOT in (3,5) AND subject like \'%%%s%%\'", account_id, rule->value); else /* RULE_TYPE_EXACTLY */ SNPRINTF(where_pararaph, where_pararaph_length, "WHERE account_id = %d AND mailbox_type NOT in (3,5) AND subject = \'%s\'", account_id, rule->value); } else { - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; EM_DEBUG_EXCEPTION("rule->type is invald"); goto FINISH_OFF; } @@ -12417,7 +12619,7 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(int account_id, char *dest_mail /* rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL); */ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EM_DEBUG_LOG("Count of mails [%d]", count); @@ -12426,7 +12628,7 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(int account_id, char *dest_mail mail_list = malloc(sizeof(int) * count); if (mail_list == NULL) { EM_DEBUG_EXCEPTION("malloc failed for mail_list."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -12435,13 +12637,13 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(int account_id, char *dest_mail for (i = 0; i < count; i++) _get_table_field_data_int(result, &(mail_list[i]), col_index++); - SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET mailbox_name = \'%s\', mailbox_type = 5 ", dest_mailbox_name); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET mailbox_id = %d, mailbox_type = 5 ", dest_mailbox_id); if (strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE) strcat(sql_query_string, where_pararaph); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); } @@ -12468,12 +12670,12 @@ FINISH_OFF: return ret; } -#define EMF_SLOT_UNIT 25 +#define EMAIL_SLOT_UNIT 25 -INTERNAL_FUNC int emstorage_set_mail_slot_size(int account_id, char *mailbox_name, int new_slot_size, 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) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p] new_slot_size[%d], err_code[%p]", account_id, mailbox_name, new_slot_size, err_code); - int rc = -1, ret = false, err = EMF_ERROR_NONE; + 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 rc = -1, ret = false, err = EMAIL_ERROR_NONE; int where_pararaph_length = 0; char *where_pararaph = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -12485,13 +12687,13 @@ INTERNAL_FUNC int emstorage_set_mail_slot_size(int account_id, char *mailbox_nam 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); else if (new_slot_size == 0) - SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_box_tbl SET mail_slot_size = mail_slot_size + %d ", EMF_SLOT_UNIT); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_box_tbl SET mail_slot_size = mail_slot_size + %d ", EMAIL_SLOT_UNIT); else SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_box_tbl SET mail_slot_size = mail_slot_size + %d ", new_slot_size * -1); - if (mailbox_name) - where_pararaph_length = strlen(mailbox_name) + 80; + if (mailbox_id) + where_pararaph_length = 80; else where_pararaph_length = 50; @@ -12501,15 +12703,15 @@ INTERNAL_FUNC int emstorage_set_mail_slot_size(int account_id, char *mailbox_nam where_pararaph = malloc(sizeof(char) * where_pararaph_length); if (where_pararaph == NULL) { EM_DEBUG_EXCEPTION("Memory allocation failed for where_pararaph"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } memset(where_pararaph, 0x00, where_pararaph_length); if (account_id > ALL_ACCOUNT) { and = 1; - if (mailbox_name) - SNPRINTF(where_pararaph, where_pararaph_length, "WHERE account_id = %d AND mailbox_name = '%s' ", account_id, mailbox_name); + if (mailbox_id) + SNPRINTF(where_pararaph, where_pararaph_length, "WHERE mailbox_id = %d ", mailbox_id); else SNPRINTF(where_pararaph, where_pararaph_length, "WHERE account_id = %d ", account_id); } @@ -12521,14 +12723,14 @@ INTERNAL_FUNC int emstorage_set_mail_slot_size(int account_id, char *mailbox_nam strcat(sql_query_string, where_pararaph); else { EM_DEBUG_EXCEPTION("Query buffer overflowed !!!"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } EM_DEBUG_LOG("query[%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -12548,23 +12750,23 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_add_meeting_request(int account_id, char *mailbox_name, emf_meeting_request_t* meeting_req, int transaction, 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) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%s], meeting_req[%p], transaction[%d], err_code[%p]", account_id, mailbox_name, meeting_req, transaction, 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); if (!meeting_req || meeting_req->mail_id <= 0) { if (meeting_req) EM_DEBUG_EXCEPTION("mail_id[%]d", meeting_req->mail_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; int col_index = 0; @@ -12577,7 +12779,7 @@ INTERNAL_FUNC int emstorage_add_meeting_request(int account_id, char *mailbox_na "INSERT INTO mail_meeting_tbl VALUES " "( ?" /* mail_id */ ", ?" /* account_id */ - ", ?" /* mailbox_name */ + ", ?" /* mailbox_id */ ", ?" /* meeting_response */ ", ?" /* start_time */ ", ?" /* end_time */ @@ -12597,7 +12799,7 @@ INTERNAL_FUNC int emstorage_add_meeting_request(int account_id, char *mailbox_na EM_DEBUG_LOG(" before sqlite3_prepare hStmt = %p", hStmt); EM_DEBUG_EXCEPTION("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; } @@ -12621,7 +12823,7 @@ INTERNAL_FUNC int emstorage_add_meeting_request(int account_id, char *mailbox_na */ _bind_stmt_field_data_int(hStmt, col_index++, meeting_req->mail_id); _bind_stmt_field_data_int(hStmt, col_index++, account_id); - _bind_stmt_field_data_string(hStmt, col_index++, (char *)mailbox_name, 0, MAILBOX_LEN_IN_MAIL_MEETING_TBL); + _bind_stmt_field_data_int(hStmt, col_index++, input_mailbox_id); _bind_stmt_field_data_int(hStmt, col_index++, meeting_req->meeting_response); temp_unix_time = timegm(&(meeting_req->start_time)); @@ -12645,9 +12847,9 @@ INTERNAL_FUNC int emstorage_add_meeting_request(int account_id, char *mailbox_na EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); ret = true; @@ -12659,7 +12861,7 @@ FINISH_OFF: rc = sqlite3_finalize(hStmt); if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -12673,15 +12875,15 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_get_meeting_request(int mail_id, emf_meeting_request_t ** meeting_req, int transaction, int *err_code) +INTERNAL_FUNC int emstorage_get_meeting_request(int mail_id, email_meeting_request_t ** meeting_req, int transaction, int *err_code) { EM_DEBUG_FUNC_BEGIN(); int count = 0; int rc = -1; int ret = false; - int error = EMF_ERROR_NONE; - emf_meeting_request_t *p_temp_meeting_req = NULL; + int error = EMAIL_ERROR_NONE; + email_meeting_request_t *p_temp_meeting_req = NULL; int col_index = 0; time_t temp_unix_time; @@ -12702,29 +12904,29 @@ INTERNAL_FUNC int emstorage_get_meeting_request(int mail_id, emf_meeting_request EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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 && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); if (rc == SQLITE_DONE) { EM_DEBUG_EXCEPTION(" no Meeting request found..."); count = 0; ret = false; - error= EMF_ERROR_DATA_NOT_FOUND; + error= EMAIL_ERROR_DATA_NOT_FOUND; goto FINISH_OFF; } - if (!(p_temp_meeting_req = (emf_meeting_request_t*)malloc(sizeof(emf_meeting_request_t)))) { + if (!(p_temp_meeting_req = (email_meeting_request_t*)malloc(sizeof(email_meeting_request_t)))) { EM_DEBUG_EXCEPTION(" malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - memset(p_temp_meeting_req, 0x00, sizeof(emf_meeting_request_t)); + memset(p_temp_meeting_req, 0x00, sizeof(email_meeting_request_t)); col_index = 0; @@ -12779,7 +12981,7 @@ FINISH_OFF: hStmt = NULL; if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -12794,12 +12996,12 @@ FINISH_OFF: } -INTERNAL_FUNC int emstorage_update_meeting_request(emf_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) { EM_DEBUG_FUNC_BEGIN("meeting_req[%p], transaction[%d], err_code[%p]", meeting_req, transaction, err_code); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int rc; DB_STMT hStmt = NULL; char sql_query_string[QUERY_SIZE] = {0, }; @@ -12807,7 +13009,7 @@ INTERNAL_FUNC int emstorage_update_meeting_request(emf_meeting_request_t* meetin if (!meeting_req) { EM_DEBUG_EXCEPTION("Invalid Parameter!"); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -12838,7 +13040,7 @@ INTERNAL_FUNC int emstorage_update_meeting_request(emf_meeting_request_t* meetin EM_DEBUG_LOG("SQL(%s)", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); /* EM_DEBUG_LOG(">>>>> meeting_req->mail_id[%d]", meeting_req->mail_id); @@ -12876,7 +13078,7 @@ INTERNAL_FUNC int emstorage_update_meeting_request(emf_meeting_request_t* meetin EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); ret = true; @@ -12891,7 +13093,7 @@ FINISH_OFF: if (rc != SQLITE_OK) { EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } @@ -12904,158 +13106,21 @@ FINISH_OFF: return ret; } - -INTERNAL_FUNC int emstorage_change_meeting_request_field(int account_id, char *mailbox_name, emf_mail_change_type_t type, emf_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) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%s], type[%d], meeting_req[%p], transaction[%d], err_code[%p]", account_id, mailbox_name, type, meeting_req, transaction, 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); - if (account_id <= 0 || !meeting_req || meeting_req->mail_id <= 0) { - if (meeting_req) - EM_DEBUG_EXCEPTION("mail_id[%d]", meeting_req->mail_id); + if (account_id < ALL_ACCOUNT || mail_id < 0) { + EM_DEBUG_EXCEPTION(" account_id[%d], mail_id[%d]", account_id, mail_id); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; - return false;; - } - - int rc; - int ret = false; - int error = EMF_ERROR_NONE; - DB_STMT hStmt = NULL; - char sql_query_string[QUERY_SIZE] = {0, }; - - int col_index = 0; - - sqlite3 *local_db_handle = emstorage_get_db_connection(); - - EMSTORAGE_START_WRITE_TRANSACTION(transaction, error); - - switch (type) { - case UPDATE_MAILBOX: - EM_DEBUG_LOG(">>>>> UPDATE_MAILBOX : Move"); - if (!mailbox_name) { - EM_DEBUG_EXCEPTION(" mailbox_name[%p]", mailbox_name); - error = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } - SNPRINTF(sql_query_string, sizeof(sql_query_string), - "UPDATE mail_meeting_tbl SET mailbox_name = ? WHERE mail_id = %d", meeting_req->mail_id); - - - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_LOG(" Before sqlite3_prepare hStmt = %p", hStmt); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, - ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); - - _bind_stmt_field_data_string(hStmt, col_index++, (char *)mailbox_name, 0, MAILBOX_LEN_IN_MAIL_MEETING_TBL); - break; - - default: - EM_DEBUG_LOG("type[%d]", type); - - error = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } - EM_DEBUG_LOG("Query = [%s]", sql_query_string); - - - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, - ("sqlite3_step fail:%d", rc)); - - ret = true; - -FINISH_OFF: - if (hStmt != NULL) { - EM_DEBUG_LOG(" Before sqlite3_finalize hStmt = %p", hStmt); - rc = sqlite3_finalize(hStmt); - if (rc != SQLITE_OK) { - EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; - } - } - - EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); - _DISCONNECT_DB; - - if (err_code != NULL) - *err_code = error; - EM_DEBUG_FUNC_END("ret [%d]", ret); - return ret; -} - - -INTERNAL_FUNC int emstorage_change_meeting_request_mailbox(int account_id, char *old_mailbox_name, char *new_mailbox_name, int transaction, int *err_code) -{ - EM_DEBUG_FUNC_BEGIN("account_id[%d], old_mailbox_name[%p], new_mailbox_name[%p], transaction[%d], err_code[%p]", account_id, old_mailbox_name, new_mailbox_name, transaction, err_code); - - if (account_id < FIRST_ACCOUNT_ID || !old_mailbox_name || !new_mailbox_name) { - EM_DEBUG_EXCEPTION("account_id[%d], old_mailbox_name[%p], new_mailbox_name[%p]", account_id, old_mailbox_name, new_mailbox_name); - - if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; - return false; - } - - int rc; - int ret = true; - int error = EMF_ERROR_NONE; - char sql_query_string[QUERY_SIZE] = {0, }; - - sqlite3 *local_db_handle = emstorage_get_db_connection(); - - EMSTORAGE_START_WRITE_TRANSACTION(transaction, error); - - EM_DEBUG_LOG("Update mailbox_name - searching by mailbox_name name"); - SNPRINTF(sql_query_string, sizeof(sql_query_string), - "UPDATE mail_meeting_tbl SET" - " mailbox_name = '%s'" - " WHERE account_id = %d" - " AND mailbox_name = '%s'" - , new_mailbox_name - , account_id - , old_mailbox_name); - - EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, - ("sqlite3_exec fail:%d", rc)); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, - ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); - - rc = sqlite3_changes(local_db_handle); - if (rc == 0) - EM_DEBUG_EXCEPTION("NO meetring request found..."); - - ret = true; - -FINISH_OFF: - - EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); - _DISCONNECT_DB; - - if (err_code != NULL) - *err_code = error; - - EM_DEBUG_FUNC_END("ret [%d]", ret); - return ret; -} - - -INTERNAL_FUNC int emstorage_delete_meeting_request(int account_id, int mail_id, char *mailbox_name, int transaction, int *err_code) -{ - EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], mailbox_name[%s], transaction[%d], err_code[%p]", account_id, mail_id, mailbox_name, transaction, err_code); - - if (account_id < ALL_ACCOUNT || mail_id < 0) { - EM_DEBUG_EXCEPTION(" account_id[%d], mail_id[%d]", account_id, mail_id); - - if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc; int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int and = false; char sql_query_string[QUERY_SIZE] = {0, }; @@ -13072,12 +13137,12 @@ INTERNAL_FUNC int emstorage_delete_meeting_request(int account_id, int mail_id, SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " %s mail_id = %d", (and ? "AND" : "WHERE"), mail_id); and = true; } - if (mailbox_name) { /* NULL means all mailbox_name */ - SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " %s mailbox_name = '%s'", (and ? "AND" : "WHERE"), mailbox_name); + if (input_mailbox_id > 0) { /* 0 means all mailbox_id */ + SNPRINTF(sql_query_string + strlen(sql_query_string), sizeof(sql_query_string)-(strlen(sql_query_string)+1), " %s mailbox_id = '%d'", (and ? "AND" : "WHERE"), input_mailbox_id); } EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -13093,61 +13158,42 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emstorage_free_meeting_request(emf_meeting_request_t **meeting_req, int count, int *err_code) + +INTERNAL_FUNC void emstorage_free_meeting_request(email_meeting_request_t *meeting_req) { - EM_DEBUG_FUNC_BEGIN("meeting_req[%p], count[%d], err_code[%p]", meeting_req, count, err_code); + EM_DEBUG_FUNC_BEGIN(); - int ret = false; - int error = EMF_ERROR_NONE; - int i = 0; - emf_meeting_request_t *cursor; - - if (count > 0) { - if (!meeting_req || !*meeting_req) { - EM_DEBUG_EXCEPTION("meeting_req[%p], count[%d]", meeting_req, count); - error = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; + if (!meeting_req ) { + EM_DEBUG_EXCEPTION("NULL PARAM"); + return; } - for (i = 0; i < count; i++) { - cursor = (*meeting_req) + i; - EM_SAFE_FREE(cursor->location); - EM_SAFE_FREE(cursor->global_object_id); - } - EM_SAFE_FREE(*meeting_req); - } - - ret = true; - -FINISH_OFF: - if (err_code != NULL) - *err_code = error; - - EM_DEBUG_FUNC_END("ret [%d]", ret); - return ret; + EM_SAFE_FREE(meeting_req->location); + EM_SAFE_FREE(meeting_req->global_object_id); + EM_DEBUG_FUNC_END(); } -INTERNAL_FUNC int emstorage_get_overflowed_mail_id_list(int account_id, char *mailbox_name, 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(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], mailbox_name [%p], mail_slot_size [%d], mail_id_list [%p], mail_id_count [%p], transaction [%d], err_code [%p]", account_id, mailbox_name, mail_slot_size, mail_id_list, mail_id_count, transaction, 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); char sql_query_string[QUERY_SIZE] = {0, }; char **result = NULL; int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int counter = 0, col_index = 0; int result_mail_id_count = 0; int *result_mail_id_list = NULL; - if (!mailbox_name || !mail_id_list || !mail_id_count || account_id < 1) { + if (input_mailbox_id <= 0 || !mail_id_list || !mail_id_count || account_id < 1) { EM_DEBUG_EXCEPTION("Invalid Parameter"); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT mail_id FROM mail_tbl WHERE account_id = %d AND mailbox_name = '%s' ORDER BY date_time DESC LIMIT %d, 10000", account_id, mailbox_name, 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("query[%s].", sql_query_string); @@ -13155,21 +13201,21 @@ INTERNAL_FUNC int emstorage_get_overflowed_mail_id_list(int account_id, char *ma 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); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); if (!result_mail_id_count) { EM_DEBUG_LOG("No mail found..."); ret = false; - error= EMF_ERROR_MAIL_NOT_FOUND; + error= EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } - EM_DEBUG_LOG("There are [%d] overflowed mails in mailbox_name [%s]", result_mail_id_count, mailbox_name); + EM_DEBUG_LOG("There are [%d] overflowed mails in mailbox_id [%d]", result_mail_id_count, input_mailbox_id); if (!(result_mail_id_list = (int *)malloc(sizeof(int) * result_mail_id_count))) { EM_DEBUG_EXCEPTION("malloc for result_mail_id_list failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; sqlite3_free_table(result); goto FINISH_OFF; } @@ -13213,7 +13259,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_by_mail_id(int mail_id, int *thread_id EM_DEBUG_FUNC_BEGIN("mail_id[%d], thread_id[%p], err_code[%p]", mail_id, thread_id, err_code); int rc = -1, ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; char **result; int result_count = 0; @@ -13221,7 +13267,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_by_mail_id(int mail_id, int *thread_id if (mail_id == 0 || thread_id == NULL) { EM_DEBUG_EXCEPTION("Invalid Parameter"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -13232,13 +13278,13 @@ INTERNAL_FUNC int emstorage_get_thread_id_by_mail_id(int mail_id, int *thread_id /* rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, &result_count, 0, NULL); */ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &result_count, 0, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); if (!result_count) { EM_DEBUG_EXCEPTION("No mail found..."); ret = false; - err= EMF_ERROR_MAIL_NOT_FOUND; + err= EMAIL_ERROR_MAIL_NOT_FOUND; /* sqlite3_free_table(result); */ goto FINISH_OFF; } @@ -13266,7 +13312,7 @@ INTERNAL_FUNC int emstorage_update_latest_thread_mail(int account_id, int thread EM_DEBUG_FUNC_BEGIN("account_id [%d], thread_id[%d], latest_mail_id [%d], thread_item_count[%d], err_code[%p]", account_id, thread_id, latest_mail_id, thread_item_count, err_code); int rc = -1, ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char sql_query_string[QUERY_SIZE] = {0, }; char **result; int result_count = 0; @@ -13274,7 +13320,7 @@ INTERNAL_FUNC int emstorage_update_latest_thread_mail(int account_id, int thread if (thread_id == 0) { EM_DEBUG_EXCEPTION("Invalid Parameter"); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -13286,13 +13332,13 @@ INTERNAL_FUNC int emstorage_update_latest_thread_mail(int account_id, int thread /* rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, &result_count, 0, NULL); */ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &result_count, 0, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); EM_DEBUG_LOG("result_count[%d]", result_count); if (result_count == 0) { EM_DEBUG_EXCEPTION("No mail found..."); ret = false; - err= EMF_ERROR_MAIL_NOT_FOUND; + err= EMAIL_ERROR_MAIL_NOT_FOUND; sqlite3_free_table(result); goto FINISH_OFF; } @@ -13315,7 +13361,7 @@ INTERNAL_FUNC int emstorage_update_latest_thread_mail(int account_id, int thread EM_DEBUG_LOG("query[%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); /* } */ @@ -13324,7 +13370,7 @@ INTERNAL_FUNC int emstorage_update_latest_thread_mail(int account_id, int thread EM_DEBUG_LOG("query[%s]", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -13343,8 +13389,7 @@ FINISH_OFF: } -INTERNAL_FUNC void -emstorage_flush_db_cache() +INTERNAL_FUNC void emstorage_flush_db_cache() { sqlite3_release_memory(-1); } @@ -13361,7 +13406,7 @@ INTERNAL_FUNC int emstorage_add_activity(emstorage_activity_tbl_t* local_activit EM_DEBUG_LOG(" local_activity[%p], transaction[%d], err_code[%p]", local_activity, transaction, err_code); int rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; DB_STMT hStmt = NULL; char sql_query_string[8192] = { 0x00, }; int i = 0; @@ -13369,7 +13414,7 @@ INTERNAL_FUNC int emstorage_add_activity(emstorage_activity_tbl_t* local_activit if (!local_activity) { EM_DEBUG_EXCEPTION(" local_activity[%p], transaction[%d], err_code[%p]", local_activity, transaction, err_code); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -13391,7 +13436,7 @@ INTERNAL_FUNC int emstorage_add_activity(emstorage_activity_tbl_t* local_activit EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); - EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + 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))); EM_DEBUG_LOG(">>>> SQL STMT [ %s ] ", sql_query_string); @@ -13410,9 +13455,9 @@ INTERNAL_FUNC int emstorage_add_activity(emstorage_activity_tbl_t* local_activit EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); - EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMF_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc)); - EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d, errmsg = %s.", rc, sqlite3_errmsg(local_db_handle))); ret = true; @@ -13424,7 +13469,7 @@ FINISH_OFF: if (rc != SQLITE_OK) { EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); - error = EMF_ERROR_DB_FAILURE; + error = EMAIL_ERROR_DB_FAILURE; } } else { @@ -13452,7 +13497,7 @@ INTERNAL_FUNC int emstorage_get_activity(int account_id, int activityid, emstora EM_DEBUG_FUNC_BEGIN(); int i = 0, count = 0, rc = -1, ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; emstorage_activity_tbl_t *p_activity_tbl = NULL; char sql_query_string[1024] = {0x00, }; char **result = NULL; @@ -13465,7 +13510,7 @@ INTERNAL_FUNC int emstorage_get_activity(int account_id, int activityid, emstora if (!select_num || !activity_list || account_id <= 0 || activityid < 0) { EM_DEBUG_LOG(" select_num[%p], activity_list[%p] account_id [%d] activityid [%d] ", select_num, activity_list, account_id, activityid); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } @@ -13485,7 +13530,7 @@ INTERNAL_FUNC int emstorage_get_activity(int account_id, int activityid, emstora 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 = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); @@ -13494,7 +13539,7 @@ INTERNAL_FUNC int emstorage_get_activity(int account_id, int activityid, emstora if (!(p_activity_tbl = (emstorage_activity_tbl_t*)em_malloc(sizeof(emstorage_activity_tbl_t) * count))) { EM_DEBUG_EXCEPTION(" em_malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -13569,7 +13614,7 @@ INTERNAL_FUNC int emstorage_get_next_activity_id(int *activity_id, int *err_code EM_DEBUG_FUNC_BEGIN(); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int rc = -1; char *sql = NULL; char **result = NULL; @@ -13578,7 +13623,7 @@ INTERNAL_FUNC int emstorage_get_next_activity_id(int *activity_id, int *err_code { EM_DEBUG_EXCEPTION(" activity_id[%p]", activity_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -13587,7 +13632,7 @@ INTERNAL_FUNC int emstorage_get_next_activity_id(int *activity_id, int *err_code sql = "SELECT max(rowid) FROM mail_local_activity_tbl;"; /* rc = sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL); n EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); */ - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); if (NULL==result[1]) @@ -13622,12 +13667,12 @@ INTERNAL_FUNC int emstorage_get_activity_id_list(int account_id, int ** activity if (account_id <= 0|| NULL == activity_id_list || NULL == activity_id_count ||lowest_activity_type <=0 || highest_activity_type <= 0) { if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int i = 0, rc = -1, count = 0; char sql_query_string[1024] = {0x00, }; int *activity_ids = NULL; @@ -13644,7 +13689,7 @@ INTERNAL_FUNC int emstorage_get_activity_id_list(int account_id, int ** activity 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 = EMF_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; }, ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); col_index = 1; @@ -13653,7 +13698,7 @@ INTERNAL_FUNC int emstorage_get_activity_id_list(int account_id, int ** activity if (NULL == (activity_ids = (int *)em_malloc(sizeof(int) * count))) { EM_DEBUG_EXCEPTION(" em_malloc failed..."); - error = EMF_ERROR_OUT_OF_MEMORY; + error = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -13690,13 +13735,13 @@ INTERNAL_FUNC int emstorage_free_activity_id_list(int *activity_id_list, int *er { EM_DEBUG_FUNC_BEGIN(); - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int ret = false; EM_DEBUG_LOG(" activity_id_list [%p]", activity_id_list); if (NULL == activity_id_list) { - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } else { @@ -13732,12 +13777,12 @@ INTERNAL_FUNC int emstorage_delete_local_activity(emstorage_activity_tbl_t* loca if (!local_activity) { EM_DEBUG_EXCEPTION(" local_activity[%p] ", local_activity); if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } int rc = -1, ret = false; /* Prevent_FIX */ - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int query_and = 0; int query_where = 0; char sql_query_string[8192] = { 0x00, }; @@ -13789,13 +13834,13 @@ INTERNAL_FUNC int emstorage_delete_local_activity(emstorage_activity_tbl_t* loca EM_DEBUG_LOG(">>>>> Query [ %s ] ", sql_query_string); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); - EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMF_ERROR_DB_FAILURE;goto FINISH_OFF; }, + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); rc = sqlite3_changes(local_db_handle); if (rc == 0) { EM_DEBUG_EXCEPTION(" no (matched) mailbox_name found..."); - err = EMF_ERROR_MAILBOX_NOT_FOUND; + err = EMAIL_ERROR_MAILBOX_NOT_FOUND; } ret = true; @@ -13818,13 +13863,13 @@ INTERNAL_FUNC int emstorage_free_local_activity(emstorage_activity_tbl_t **local EM_DEBUG_LOG(" local_activity_list[%p], count[%d], err_code[%p]", local_activity_list, count, err_code); int ret = false; - int error = EMF_ERROR_INVALID_PARAM; + int error = EMAIL_ERROR_INVALID_PARAM; if (count > 0) { if (!local_activity_list || !*local_activity_list) { EM_DEBUG_EXCEPTION(" local_activity_list[%p], count[%d]", local_activity_list, count); - error = EMF_ERROR_INVALID_PARAM; + error = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -13853,5 +13898,1179 @@ FINISH_OFF: } #endif /* __FEATURE_LOCAL_ACTIVITY__ */ +static char *_mail_field_name_list[] = { + "mail_id", + "account_id", + "mailbox_id", + "mailbox_name", + "mailbox_type", + "subject", + "date_time", + "server_mail_status", + "server_mailbox_name", + "server_mail_id", + "message_id", + "full_address_from", + "full_address_to", + "full_address_cc", + "full_address_bcc", + "body_download_status", + "file_path_plain", + "file_path_html", + "file_size", + "flags_seen_field", + "flags_deleted_field", + "flags_flagged_field", + "flags_answered_field", + "flags_recent_field", + "flags_draft_field", + "flags_forwarded_field", + "drm_status", + "priority", + "save_status", + "lock_status", + "report_status", + "attachment_count", + "inline_content_count", + "thread_id", + "thread_item_count", + "preview_text", + "meeting_request_status", + "message_class", + "digest_type", + "smime_type" +}; + +static char*_get_mail_field_name_by_attribute_type(email_mail_attribute_type input_attribute_type) +{ + EM_DEBUG_FUNC_BEGIN("input_attribute_type [%d]", input_attribute_type); + + if(input_attribute_type > EMAIL_MAIL_ATTRIBUTE_MEETING_REQUEST_STATUS || input_attribute_type < 0) { + EM_DEBUG_EXCEPTION("Invalid input_attribute_type [%d]", input_attribute_type); + return NULL; + } + + EM_DEBUG_FUNC_END("return [%s]", _mail_field_name_list[input_attribute_type]); + return _mail_field_name_list[input_attribute_type]; +} + +static int _get_attribute_type_by_mail_field_name(char *input_mail_field_name, email_mail_attribute_type *output_mail_attribute_type) +{ + EM_DEBUG_FUNC_BEGIN("input_mail_field_name [%p], output_mail_attribute_type [%p]", input_mail_field_name, output_mail_attribute_type); + int i = 0; + int err = EMAIL_ERROR_DATA_NOT_FOUND; + + if(!input_mail_field_name || !output_mail_attribute_type) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + for (i = 0; i < EMAIL_MAIL_ATTRIBUTE_END; i++) { + if (EM_SAFE_STRCMP(input_mail_field_name, _mail_field_name_list[i]) == 0) { + *output_mail_attribute_type = i; + err = EMAIL_ERROR_NONE; + break; + } + } + + EM_DEBUG_FUNC_END("found mail attribute type [%d]", (int)*output_mail_attribute_type); + return err; +} + +static int _get_key_value_string_for_list_filter_rule(email_list_filter_rule_t *input_list_filter_rule,char **output_key_value_string) +{ + EM_DEBUG_FUNC_BEGIN("input_list_filter_rule [%p], output_key_value_string [%p]", input_list_filter_rule, output_key_value_string); + + int ret = EMAIL_ERROR_NONE; + char key_value_string[QUERY_SIZE] = { 0, }; + char *temp_key_value_1 = NULL; + char *temp_key_value_2 = NULL; + + if(input_list_filter_rule == NULL || output_key_value_string == NULL) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + switch(input_list_filter_rule->target_attribute) { + case EMAIL_MAIL_ATTRIBUTE_MAIL_ID : + case EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID : + case EMAIL_MAIL_ATTRIBUTE_MAILBOX_ID : + case EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE : + case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_STATUS : + case EMAIL_MAIL_ATTRIBUTE_BODY_DOWNLOAD_STATUS : + case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN : + case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML : + case EMAIL_MAIL_ATTRIBUTE_FILE_SIZE : + case EMAIL_MAIL_ATTRIBUTE_FLAGS_SEEN_FIELD : + case EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD : + case EMAIL_MAIL_ATTRIBUTE_FLAGS_FLAGGED_FIELD : + case EMAIL_MAIL_ATTRIBUTE_FLAGS_ANSWERED_FIELD : + case EMAIL_MAIL_ATTRIBUTE_FLAGS_RECENT_FIELD : + case EMAIL_MAIL_ATTRIBUTE_FLAGS_DRAFT_FIELD : + case EMAIL_MAIL_ATTRIBUTE_FLAGS_FORWARDED_FIELD : + case EMAIL_MAIL_ATTRIBUTE_DRM_STATUS : + case EMAIL_MAIL_ATTRIBUTE_PRIORITY : + case EMAIL_MAIL_ATTRIBUTE_SAVE_STATUS : + case EMAIL_MAIL_ATTRIBUTE_LOCK_STATUS : + case EMAIL_MAIL_ATTRIBUTE_REPORT_STATUS : + case EMAIL_MAIL_ATTRIBUTE_ATTACHMENT_COUNT : + case EMAIL_MAIL_ATTRIBUTE_INLINE_CONTENT_COUNT : + case EMAIL_MAIL_ATTRIBUTE_THREAD_ID : + case EMAIL_MAIL_ATTRIBUTE_THREAD_ITEM_COUNT : + case EMAIL_MAIL_ATTRIBUTE_MEETING_REQUEST_STATUS : + case EMAIL_MAIL_ATTRIBUTE_MESSAGE_CLASS : + case EMAIL_MAIL_ATTRIBUTE_DIGEST_TYPE : + case EMAIL_MAIL_ATTRIBUTE_SMIME_TYPE : + SNPRINTF(key_value_string, QUERY_SIZE, "%d", input_list_filter_rule->key_value.integer_type_value); + break; + + case EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME : + case EMAIL_MAIL_ATTRIBUTE_SUBJECT : + case EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME : + case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID : + case EMAIL_MAIL_ATTRIBUTE_MESSAGE_ID : + case EMAIL_MAIL_ATTRIBUTE_FROM : + case EMAIL_MAIL_ATTRIBUTE_TO : + case EMAIL_MAIL_ATTRIBUTE_CC : + case EMAIL_MAIL_ATTRIBUTE_BCC : + case EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT : + if(input_list_filter_rule->key_value.string_type_value == NULL) { + EM_DEBUG_EXCEPTION("Invalid string_type_value [%p]", input_list_filter_rule->key_value.string_type_value); + ret = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + temp_key_value_1 = input_list_filter_rule->key_value.string_type_value; + + temp_key_value_2 = em_replace_all_string(temp_key_value_1, "_", "\\_"); + temp_key_value_1 = em_replace_all_string(temp_key_value_2, "%", "\\%"); + + if(input_list_filter_rule->rule_type == EMAIL_LIST_FILTER_RULE_INCLUDE) + SNPRINTF(key_value_string, QUERY_SIZE, "\'%%%s%%\'", temp_key_value_1); + else + SNPRINTF(key_value_string, QUERY_SIZE, "\'%s\'", temp_key_value_1); + break; + + case EMAIL_MAIL_ATTRIBUTE_DATE_TIME : + SNPRINTF(key_value_string, QUERY_SIZE, "%d", (int)input_list_filter_rule->key_value.datetime_type_value); + break; + + default : + ret = EMAIL_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("Invalid target_attribute [%d]", input_list_filter_rule->target_attribute); + break; + } + + if(ret == EMAIL_ERROR_NONE && strlen(key_value_string) > 0) { + *output_key_value_string = strdup(key_value_string); + } + +FINISH_OFF: + + EM_SAFE_FREE(temp_key_value_1); + EM_SAFE_FREE(temp_key_value_2); + + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} + +#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__ +static int _get_cert_password_file_name(int index, char *cert_password_file_name) +{ + EM_DEBUG_FUNC_BEGIN("index : [%d]", index); + + if (index <= 0 || !cert_password_file_name) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + return EMAIL_ERROR_INVALID_PARAM; + } + + sprintf(cert_password_file_name, ".email_cert_%d", index); + + EM_DEBUG_FUNC_END(); + return EMAIL_ERROR_NONE; +} +#endif + +static int _make_filter_rule_string(email_list_filter_rule_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); + + int ret = EMAIL_ERROR_NONE; + int is_alpha = 0; + int length_field_name = 0; + int length_value = 0; + char result_rule_string[QUERY_SIZE] = { 0 , }; + char *mod_field_name_string = NULL; + char *mod_value_string = NULL; + char *temp_field_name_string = NULL; + char *temp_key_value_string = NULL; + + if(input_list_filter_rule == NULL || output_string == NULL) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + temp_field_name_string = _get_mail_field_name_by_attribute_type(input_list_filter_rule->target_attribute); + + if(temp_field_name_string == NULL) { + EM_DEBUG_EXCEPTION("Invalid target_attribute [%d]", input_list_filter_rule->target_attribute); + return EMAIL_ERROR_INVALID_PARAM; + } + + if( _get_key_value_string_for_list_filter_rule(input_list_filter_rule, &temp_key_value_string) != EMAIL_ERROR_NONE || temp_key_value_string == NULL) { + EM_DEBUG_EXCEPTION("_get_key_value_string_for_list_filter_rule failed"); + return EMAIL_ERROR_INVALID_PARAM; + } + + length_field_name = strlen(temp_field_name_string); + length_value = strlen(temp_key_value_string); + + switch(input_list_filter_rule->target_attribute) { + case EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME : + case EMAIL_MAIL_ATTRIBUTE_SUBJECT : + case EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME : + case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID : + case EMAIL_MAIL_ATTRIBUTE_MESSAGE_ID : + case EMAIL_MAIL_ATTRIBUTE_FROM : + case EMAIL_MAIL_ATTRIBUTE_TO : + case EMAIL_MAIL_ATTRIBUTE_CC : + case EMAIL_MAIL_ATTRIBUTE_BCC : + case EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT : + is_alpha = 1; + break; + default : + is_alpha = 0; + break; + } + + if(is_alpha == 1 && input_list_filter_rule->case_sensitivity == false) { + length_field_name += strlen("UPPER() "); + length_value += strlen("UPPER() "); + mod_field_name_string = em_malloc(sizeof(char) * length_field_name); + mod_value_string = em_malloc(sizeof(char) * length_value); + SNPRINTF(mod_field_name_string, length_field_name, "UPPER(%s)", temp_field_name_string); + SNPRINTF(mod_value_string, length_value, "UPPER(%s)", temp_key_value_string); + EM_SAFE_FREE(temp_key_value_string); + } + else { + mod_field_name_string = strdup(temp_field_name_string); + mod_value_string = temp_key_value_string; + } + + switch (input_list_filter_rule->rule_type) { + case EMAIL_LIST_FILTER_RULE_EQUAL : + SNPRINTF(result_rule_string, QUERY_SIZE, "%s = %s ", mod_field_name_string, mod_value_string); + break; + case EMAIL_LIST_FILTER_RULE_NOT_EQUAL : + SNPRINTF(result_rule_string, QUERY_SIZE, "%s = %s ", mod_field_name_string, mod_value_string); + break; + case EMAIL_LIST_FILTER_RULE_LESS_THAN : + SNPRINTF(result_rule_string, QUERY_SIZE, "%s < %s ", mod_field_name_string, mod_value_string); + break; + case EMAIL_LIST_FILTER_RULE_GREATER_THAN : + SNPRINTF(result_rule_string, QUERY_SIZE, "%s > %s ", mod_field_name_string, mod_value_string); + break; + case EMAIL_LIST_FILTER_RULE_LESS_THAN_OR_EQUAL : + SNPRINTF(result_rule_string, QUERY_SIZE, "%s <= %s ", mod_field_name_string, mod_value_string); + break; + case EMAIL_LIST_FILTER_RULE_GREATER_THAN_OR_EQUAL : + SNPRINTF(result_rule_string, QUERY_SIZE, "%s >= %s ", mod_field_name_string, mod_value_string); + break; + case EMAIL_LIST_FILTER_RULE_INCLUDE : + SNPRINTF(result_rule_string, QUERY_SIZE, "%s LIKE %s ", mod_field_name_string, mod_value_string); + break; + case EMAIL_LIST_FILTER_RULE_IN : + SNPRINTF(result_rule_string, QUERY_SIZE, "%s IN (%s) ", mod_field_name_string, mod_value_string); + break; + case EMAIL_LIST_FILTER_RULE_NOT_IN : + SNPRINTF(result_rule_string, QUERY_SIZE, "%s NOT IN (%s) ", mod_field_name_string, mod_value_string); + break; + default : + EM_DEBUG_EXCEPTION("Invalid rule_type [%d]", input_list_filter_rule->rule_type); + ret = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + *output_string = strdup(result_rule_string); + +FINISH_OFF: + EM_SAFE_FREE(mod_field_name_string); + EM_SAFE_FREE(mod_value_string); + + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} + +static int _make_order_rule_string(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 , }; + int ret = EMAIL_ERROR_NONE; + + if(input_sorting_rule->force_boolean_check) { + SNPRINTF(result_rule_string, QUERY_SIZE, "%s = 0 ", _get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute)); + } + else + EM_SAFE_STRCPY(result_rule_string, _get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute)); + + switch (input_sorting_rule->sort_order) { + case EMAIL_SORT_ORDER_ASCEND : + EM_SAFE_STRCAT(result_rule_string, " ASC "); + break; + + case EMAIL_SORT_ORDER_DESCEND : + EM_SAFE_STRCAT(result_rule_string, " DESC "); + break; + + default : + EM_DEBUG_EXCEPTION("Invalid sort_order [%d]", input_sorting_rule->sort_order); + ret = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + *output_string = strdup(result_rule_string); + +FINISH_OFF: + EM_DEBUG_FUNC_END("ret [%d]", ret); + 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) +{ + 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; + int i = 0; + char conditional_clause_string[QUERY_SIZE] = {0, }; + char *result_string_for_a_item = NULL; + + if ( (input_filter_count > 0 && !input_filter_list) || (input_sorting_rule_count > 0 && !input_sorting_rule_list) || output_conditional_clause == NULL) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + if(input_filter_count > 0) { + strcpy(conditional_clause_string, " WHERE "); + + for ( i = 0; i < input_filter_count; i++) { + switch (input_filter_list[i].list_filter_item_type) { + case EMAIL_LIST_FILTER_ITEM_RULE : + EM_DEBUG_LOG("[%d]list_filter_item_type is EMAIL_LIST_FILTER_ITEM_RULE", i); + _make_filter_rule_string(&(input_filter_list[i].list_filter_item.rule), &result_string_for_a_item); + break; + + case EMAIL_LIST_FILTER_ITEM_OPERATOR : + EM_DEBUG_LOG("[%d]list_filter_item_type is EMAIL_LIST_FILTER_ITEM_OPERATOR", i); + switch(input_filter_list[i].list_filter_item.operator_type) { + case EMAIL_LIST_FILTER_OPERATOR_AND : + result_string_for_a_item = strdup("AND "); + break; + case EMAIL_LIST_FILTER_OPERATOR_OR : + result_string_for_a_item = strdup("OR "); + break; + case EMAIL_LIST_FILTER_OPERATOR_LEFT_PARENTHESIS : + result_string_for_a_item = strdup(" ("); + break; + case EMAIL_LIST_FILTER_OPERATOR_RIGHT_PARENTHESIS : + result_string_for_a_item = strdup(") "); + break; + } + break; + + default : + EM_DEBUG_EXCEPTION("Invalid list_filter_item_type [%d]", input_filter_list[i].list_filter_item_type); + ret = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + if(result_string_for_a_item == NULL) { + EM_DEBUG_EXCEPTION("result_string_for_a_item is null"); + ret = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + if(strlen(conditional_clause_string) + strlen(result_string_for_a_item) >= QUERY_SIZE) { + EM_DEBUG_EXCEPTION("Query is too long"); + ret = EMAIL_ERROR_DATA_TOO_LONG; + goto FINISH_OFF; + } + strcat(conditional_clause_string, result_string_for_a_item); + EM_SAFE_FREE(result_string_for_a_item); + } + } + + if(input_sorting_rule_count > 0) { + 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) { + EM_DEBUG_EXCEPTION("_make_order_rule_string failed. [%d]", ret); + goto FINISH_OFF; + } + if(i > 0) + strcat(conditional_clause_string, ", "); + strcat(conditional_clause_string, result_string_for_a_item); + EM_SAFE_FREE(result_string_for_a_item); + } + } + + *output_conditional_clause = strdup(conditional_clause_string); + +FINISH_OFF: + EM_SAFE_FREE(result_string_for_a_item); + + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} + +INTERNAL_FUNC int emstorage_free_list_filter(email_list_filter_t **input_filter_list, int input_filter_count) +{ + EM_DEBUG_FUNC_BEGIN("input_filter_list [%p], input_filter_count[%d]", input_filter_list, input_filter_count); + int err = EMAIL_ERROR_NONE; + int i = 0; + email_list_filter_t *temp_filter_list = NULL; + + EM_IF_NULL_RETURN_VALUE(input_filter_list, EMAIL_ERROR_INVALID_PARAM); + + for ( i = 0; i < input_filter_count; i++) { + temp_filter_list = (*input_filter_list) + i; + if(temp_filter_list && temp_filter_list->list_filter_item_type == EMAIL_LIST_FILTER_ITEM_RULE) { + switch(temp_filter_list->list_filter_item.rule.target_attribute) { + case EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME : + case EMAIL_MAIL_ATTRIBUTE_SUBJECT : + case EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME : + case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID : + case EMAIL_MAIL_ATTRIBUTE_MESSAGE_ID : + case EMAIL_MAIL_ATTRIBUTE_FROM : + case EMAIL_MAIL_ATTRIBUTE_TO : + case EMAIL_MAIL_ATTRIBUTE_CC : + case EMAIL_MAIL_ATTRIBUTE_BCC : + case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN : + case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML : + case EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT : + EM_SAFE_FREE(temp_filter_list->list_filter_item.rule.key_value.string_type_value); + break; + default : + break; + } + } + } + + free(*input_filter_list); + *input_filter_list = NULL; + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + +INTERNAL_FUNC int emstorage_add_certificate(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); + + if (!certificate) { + EM_DEBUG_EXCEPTION("certificate:[%p], transaction:[%d], err_code:[%p]", certificate, transaction, err_code); + if (err_code != NULL) + *err_code = EMAIL_ERROR_INVALID_PARAM; + + return false; + } + + int rc = -1, ret = false; + int error = EMAIL_ERROR_NONE; + DB_STMT hStmt = NULL; + char sql_query_string[QUERY_SIZE] = {0, }; +#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); + + char *sql = "SELECT max(rowid) FROM mail_certificate_tbl;"; + char **result = NULL; + + /* rc = sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL); */ + 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; }, + ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); + + if (NULL==result[1]) rc = 1; + else rc = atoi(result[1])+1; + sqlite3_free_table(result); + + certificate->certificate_id = rc; +#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__ + if ((error = _get_cert_password_file_name(certificate->certificate_id, cert_password_file_name)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("em_storage_get_password_file_name failed."); + goto FINISH_OFF; + } +#endif + SNPRINTF(sql_query_string, sizeof(sql_query_string), + "INSERT INTO mail_certificate_tbl VALUES " + "( " + " ? " /* Index of certificate */ + " , ? " /* Select the account */ + " , ? " /* Year of issue */ + " , ? " /* Month of issue */ + " , ? " /* Day of issue */ + " , ? " /* Year of expiration */ + " , ? " /* Month of expiration */ + " , ? " /* Day of expiration */ + " , ? " /* Organization of issue */ + " , ? " /* Email address */ + " , ? " /* Subject of certificate */ + " , ? " /* Name of saved certificate */ + ") "); + + + /* rc = sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL); */ + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); + 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))); + + EM_DEBUG_LOG(">>>> SQL STMT [ %s ] ", sql_query_string); + _bind_stmt_field_data_int(hStmt, CERTFICATE_BIND_TYPE_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->certificate_id); + _bind_stmt_field_data_int(hStmt, ISSUE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->issue_year); + _bind_stmt_field_data_int(hStmt, ISSUE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->issue_month); + _bind_stmt_field_data_int(hStmt, ISSUE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->issue_day); + _bind_stmt_field_data_int(hStmt, EXPIRE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->expiration_year); + _bind_stmt_field_data_int(hStmt, EXPIRE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->expiration_month); + _bind_stmt_field_data_int(hStmt, EXPIRE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->expiration_day); + _bind_stmt_field_data_string(hStmt, ISSUE_ORGANIZATION_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->issue_organization_name, 0, ISSUE_ORGANIZATION_LEN_IN_MAIL_CERTIFICATE_TBL); + _bind_stmt_field_data_string(hStmt, EMAIL_ADDRESS_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->email_address, 0, EMAIL_ADDRESS_LEN_IN_MAIL_CERTIFICATE_TBL); + _bind_stmt_field_data_string(hStmt, SUBJECT_STRING_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->subject_str, 0, SUBJECT_STRING_LEN_IN_MAIL_CERTIFICATE_TBL); + _bind_stmt_field_data_string(hStmt, FILE_PATH_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->filepath, 0, FILE_NAME_LEN_IN_MAIL_CERTIFICATE_TBL); + /* rc = sqlite3_step(hStmt); */ + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); + + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + ("sqlite3_step fail:%d", rc)); + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("sqlite3_step fail:%d, errmsg = %s.", rc, sqlite3_errmsg(local_db_handle))); +#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__ + if (ssm_write_buffer(certificate->password, strlen(certificate->password), cert_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { + EM_DEBUG_EXCEPTION("ssm_write_buffer failed - Private certificate password : [%s]", cert_password_file_name); + error = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } +#endif + ret = true; + + EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); + + if (!emstorage_notify_storage_event(NOTI_CERTIFICATE_ADD, certificate->certificate_id, 0, NULL, 0)) + EM_DEBUG_EXCEPTION("emstorage_notify_storage_event(NOTI_CERTIFICATE_ADD] : Notification failed"); + +FINISH_OFF: + + if (hStmt != NULL) { + rc = sqlite3_finalize(hStmt); + if (rc != SQLITE_OK) { + EM_DEBUG_LOG("sqlite3_finalize failed - %d", rc); + error = EMAIL_ERROR_DB_FAILURE; + } + } + else + EM_DEBUG_LOG("hStmt is NULL!!!"); + + EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); + _DISCONNECT_DB; + + if (err_code != NULL) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} + +INTERNAL_FUNC int emstorage_free_certificate(emstorage_certificate_tbl_t **certificate_list, int count, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("certificate_list[%p], count[%d], err_code[%p]", certificate_list, count, err_code); + + int ret = false; + int error = EMAIL_ERROR_NONE; + + if (count > 0) { + if (!certificate_list || !*certificate_list) { + EM_DEBUG_EXCEPTION("certificate_list[%p], count[%d]", certificate_list, count); + error = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + emstorage_certificate_tbl_t *p = *certificate_list; + int i = 0; + + for (; i < count; i++) { + EM_SAFE_FREE(p[i].issue_organization_name); + EM_SAFE_FREE(p[i].email_address); + EM_SAFE_FREE(p[i].subject_str); + EM_SAFE_FREE(p[i].filepath); + EM_SAFE_FREE(p[i].password); + } + + EM_SAFE_FREE(p); + *certificate_list = NULL; + } + + ret = true; + +FINISH_OFF: + if (err_code != NULL) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + 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) +{ + EM_DEBUG_FUNC_BEGIN(); + + int i = 0, count = 0, rc = -1, ret = false; + int error = EMAIL_ERROR_NONE; + emstorage_certificate_tbl_t *p_data_tbl = NULL; + + DB_STMT hStmt = NULL; + + if (!select_num || !certificate_list) { + EM_DEBUG_EXCEPTION("select_num[%p], account_list[%p]", select_num, certificate_list); + if (err_code != NULL) + *err_code = EMAIL_ERROR_INVALID_PARAM; + return false; + } + + sqlite3 *local_db_handle = emstorage_get_db_connection(); + EMSTORAGE_START_READ_TRANSACTION(transaction); + + char sql_query_string[QUERY_SIZE] = {0, }; + char *sql = "SELECT count(*) FROM mail_certificate_tbl;"; + char **result; + + /* rc = sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL); */ + 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; }, + ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle))); + + count = atoi(result[1]); + sqlite3_free_table(result); + + if (!count) { + EM_DEBUG_EXCEPTION("no account found..."); + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; + ret = true; + goto FINISH_OFF; + } + EM_DEBUG_LOG("count = %d", rc); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_certificate_tbl ORDER BY account_id"); + + /* rc = sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL); */ + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); + + EM_DEBUG_LOG("After sqlite3_prepare_v2 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))); + + /* rc = sqlite3_step(hStmt); */ + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("sqlite3_step fail:%d", rc)); + if (rc == SQLITE_DONE) { + EM_DEBUG_EXCEPTION("no account found..."); + + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; + count = 0; + ret = true; + goto FINISH_OFF; + } + + if (!(p_data_tbl = (emstorage_certificate_tbl_t *)malloc(sizeof(emstorage_certificate_tbl_t) * count))) { + EM_DEBUG_EXCEPTION("malloc failed..."); + error = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + memset(p_data_tbl, 0x00, sizeof(emstorage_certificate_tbl_t) * count); + for (i = 0; i < count; i++) { + /* get recordset */ + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].certificate_id), CERTFICATE_BIND_TYPE_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].issue_year), ISSUE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].issue_month), ISSUE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].issue_day), ISSUE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].expiration_year), EXPIRE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].expiration_month), EXPIRE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].expiration_day), EXPIRE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].issue_organization_name), 0, ISSUE_ORGANIZATION_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].email_address), 0, EMAIL_ADDRESS_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].subject_str), 0, SUBJECT_STRING_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].filepath), 0, FILE_PATH_IDX_IN_MAIL_CERTIFICATE_TBL); + if (with_password == true) { +#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__ + /* get password from the secure storage */ + char cert_password_file_name[MAX_PW_FILE_NAME_LENGTH]; + + EM_SAFE_FREE(p_data_tbl[i].password); + + /* get password file name */ + if ((error = _get_cert_password_file_name(p_data_tbl[i].certificate_id, cert_password_file_name)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("em_storage_get_password_file_name failed."); + goto FINISH_OFF; + } + + /* read password from secure storage */ + if ((error = _read_password_from_secure_storage(cert_password_file_name, &(p_data_tbl[i].password))) < 0) { + EM_DEBUG_EXCEPTION("_read_password_from_secure_storage() failed..."); + goto FINISH_OFF; + } + EM_DEBUG_LOG("recv_password_file_name[%s], password[%s]", cert_password_file_name, p_data_tbl[i].password); +#endif + } + + /* rc = sqlite3_step(hStmt); */ + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); + EM_DEBUG_LOG("after sqlite3_step(), i = %d, rc = %d.", i, rc); + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("sqlite3_step fail:%d", rc)); + } + + ret = true; + +FINISH_OFF: + if (ret == true) { + *certificate_list = p_data_tbl; + *select_num = count; + EM_DEBUG_LOG("COUNT : %d", count); + } + else if (p_data_tbl != NULL) + emstorage_free_certificate(&p_data_tbl, count, NULL); + if (hStmt != NULL) { + EM_DEBUG_LOG("Before sqlite3_finalize hStmt = %p", hStmt); + + rc = sqlite3_finalize(hStmt); + hStmt = NULL; + if (rc != SQLITE_OK) { + EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); + error = EMAIL_ERROR_DB_FAILURE; + } + } + + EMSTORAGE_FINISH_READ_TRANSACTION(transaction); + _DISCONNECT_DB; + + if (err_code != NULL) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + 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) +{ + EM_DEBUG_FUNC_BEGIN("email_address[%s], certificate[%p], transaction[%d], err_code[%p]", email_address, certificate, transaction, err_code); + + if (!certificate) { + EM_DEBUG_EXCEPTION("email_address[%s], certificate[%p]", email_address, certificate); + if (err_code != NULL) + *err_code = EMAIL_ERROR_INVALID_PARAM; + return false; + } + + int ret = false; + int error = EMAIL_ERROR_NONE; + emstorage_certificate_tbl_t *p_data_tbl = NULL; + DB_STMT hStmt = NULL; + char sql_query_string[QUERY_SIZE] = {0, }; + int rc = -1; + int sql_len = 0; +#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_READ_TRANSACTION(transaction); + + /* Make query string */ + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT "); + sql_len = strlen(sql_query_string); + + /* dummy value, FROM WHERE clause */ + SNPRINTF(sql_query_string + sql_len, sizeof(sql_query_string) - sql_len, "* FROM mail_certificate_tbl WHERE email_address = '%s'", email_address); + + /* FROM clause */ + EM_DEBUG_LOG("query = [%s]", sql_query_string); + + /* execute a sql and count rows */ + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); + 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 && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("sqlite3_step fail:%d", rc)); + + if (rc == SQLITE_DONE) { + EM_DEBUG_EXCEPTION("no matched certificate found..."); + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; + goto FINISH_OFF; + } + + /* Assign query result to structure */ + if (!(p_data_tbl = (emstorage_certificate_tbl_t *)malloc(sizeof(emstorage_certificate_tbl_t)))) { + EM_DEBUG_EXCEPTION("malloc failed..."); + error = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + memset(p_data_tbl, 0x00, sizeof(emstorage_certificate_tbl_t)); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->certificate_id), CERTFICATE_BIND_TYPE_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->issue_year), ISSUE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->issue_month), ISSUE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->issue_day), ISSUE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->expiration_year), EXPIRE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->expiration_month), EXPIRE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->expiration_day), EXPIRE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->issue_organization_name), 0, ISSUE_ORGANIZATION_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->email_address), 0, EMAIL_ADDRESS_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->subject_str), 0, SUBJECT_STRING_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->filepath), 0, FILE_PATH_IDX_IN_MAIL_CERTIFICATE_TBL); + + if (with_password) { +#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__ + /* get password file name */ + if ((error = _get_cert_password_file_name(p_data_tbl->certificate_id, cert_password_file_name)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("em_storage_get_password_file_name failed."); + goto FINISH_OFF; + } + + /* read password from secure storage */ + if ((error = _read_password_from_secure_storage(cert_password_file_name, &(p_data_tbl->password))) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION(" _read_password_from_secure_storage() failed..."); + goto FINISH_OFF; + } + EM_DEBUG_LOG("cert_password_file_name[%s], password[%s]", cert_password_file_name, p_data_tbl->password); +#endif + } + ret = true; + +FINISH_OFF: + if (ret == true) + *certificate = p_data_tbl; + else { + if (p_data_tbl) + emstorage_free_certificate((emstorage_certificate_tbl_t **)&p_data_tbl, 1, NULL); + } + if (hStmt != NULL) { + rc = sqlite3_finalize(hStmt); + if (rc != SQLITE_OK) { + EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); + error = EMAIL_ERROR_DB_FAILURE; + } + } + + EMSTORAGE_FINISH_READ_TRANSACTION(transaction); + _DISCONNECT_DB; + + if (err_code != NULL) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + 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) +{ + EM_DEBUG_FUNC_BEGIN("index[%d], certificate[%p], transaction[%d], err_code[%p]", index, certificate, transaction, err_code); + + if (!certificate) { + EM_DEBUG_EXCEPTION("index[%d], account[%p]", index, certificate); + if (err_code != NULL) + *err_code = EMAIL_ERROR_INVALID_PARAM; + return false; + } + + int ret = false; + int error = EMAIL_ERROR_NONE; + emstorage_certificate_tbl_t *p_data_tbl = NULL; + DB_STMT hStmt = NULL; + char sql_query_string[QUERY_SIZE] = {0, }; + int rc = -1; + int sql_len = 0; +#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_READ_TRANSACTION(transaction); + + /* Make query string */ + SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT "); + sql_len = strlen(sql_query_string); + + /* dummy value, FROM WHERE clause */ + SNPRINTF(sql_query_string + sql_len, sizeof(sql_query_string) - sql_len, "* FROM mail_certificate_tbl WHERE certificate_id = %d", index); + + /* FROM clause */ + EM_DEBUG_LOG("query = [%s]", sql_query_string); + + /* execute a sql and count rows */ + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); + 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 && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("sqlite3_step fail:%d", rc)); + + if (rc == SQLITE_DONE) { + EM_DEBUG_EXCEPTION("no matched certificate found..."); + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; + goto FINISH_OFF; + } + + /* Assign query result to structure */ + if (!(p_data_tbl = (emstorage_certificate_tbl_t *)malloc(sizeof(emstorage_certificate_tbl_t)))) { + EM_DEBUG_EXCEPTION("malloc failed..."); + error = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + memset(p_data_tbl, 0x00, sizeof(emstorage_certificate_tbl_t)); + + _get_stmt_field_data_int(hStmt, &(p_data_tbl->certificate_id), CERTFICATE_BIND_TYPE_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->issue_year), ISSUE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->issue_month), ISSUE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->issue_day), ISSUE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->expiration_year), EXPIRE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->expiration_month), EXPIRE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_int(hStmt, &(p_data_tbl->expiration_day), EXPIRE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->issue_organization_name), 0, ISSUE_ORGANIZATION_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->email_address), 0, EMAIL_ADDRESS_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->subject_str), 0, SUBJECT_STRING_IDX_IN_MAIL_CERTIFICATE_TBL); + _get_stmt_field_data_string(hStmt, &(p_data_tbl->filepath), 0, FILE_PATH_IDX_IN_MAIL_CERTIFICATE_TBL); + + if (with_password) { +#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__ + /* get password file name */ + if ((error = _get_cert_password_file_name(p_data_tbl->certificate_id, cert_password_file_name)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("em_storage_get_password_file_name failed."); + goto FINISH_OFF; + } + + /* read password from secure storage */ + if ((error = _read_password_from_secure_storage(cert_password_file_name, &(p_data_tbl->password))) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION(" _read_password_from_secure_storage() failed..."); + goto FINISH_OFF; + } + EM_DEBUG_LOG("cert_password_file_name[%s], password[%s]", cert_password_file_name, p_data_tbl->password); +#endif + } + ret = true; + +FINISH_OFF: + if (ret == true) + *certificate = p_data_tbl; + else { + if (p_data_tbl) + emstorage_free_certificate((emstorage_certificate_tbl_t **)&p_data_tbl, 1, NULL); + } + if (hStmt != NULL) { + rc = sqlite3_finalize(hStmt); + if (rc != SQLITE_OK) { + EM_DEBUG_EXCEPTION("sqlite3_finalize failed - %d", rc); + error = EMAIL_ERROR_DB_FAILURE; + } + } + + EMSTORAGE_FINISH_READ_TRANSACTION(transaction); + _DISCONNECT_DB; + + if (err_code != NULL) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} + +INTERNAL_FUNC int emstorage_delete_certificate(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); + + if (certificate_id < 1) { + EM_DEBUG_EXCEPTION(" certificate_id[%d]", certificate_id); + + if (err_code != NULL) + *err_code = EMAIL_ERROR_INVALID_PARAM; + return false; + } + + int rc = -1, ret = false; + int error = EMAIL_ERROR_NONE; + sqlite3 *local_db_handle = emstorage_get_db_connection(); + EMSTORAGE_START_WRITE_TRANSACTION(transaction, error); + + /* TODO : delete password files - file names can be obtained from db or a rule that makes a name */ + DB_STMT hStmt = NULL; + char sql_query_string[QUERY_SIZE] = {0, }; +#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__ + char cert_password_file_name[MAX_PW_FILE_NAME_LENGTH]; + /* get password file name */ + if ((error = _get_cert_password_file_name(certificate_id, cert_password_file_name)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("em_storage_get_password_file_name failed."); + goto FINISH_OFF; + } +#endif + /* delete from db */ + memset(sql_query_string, 0x00, sizeof(sql_query_string)); + SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_certificate_tbl WHERE certificate_id = %d", certificate_id); + + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, sql_query_string, NULL, NULL, NULL), rc); + EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + ("sqlite3_exec fail:%d", rc)); + EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("SQL(%s) exec fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle))); + + /* validate account existence */ + rc = sqlite3_changes(local_db_handle); + if (rc == 0) { + EM_DEBUG_EXCEPTION(" no matched certificate found..."); + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; + goto FINISH_OFF; + } +#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__ + /* delete from secure storage */ + if (ssm_delete_file(cert_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { + EM_DEBUG_EXCEPTION(" ssm_delete_file failed -cert password : file[%s]", cert_password_file_name); + error = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } +#endif + ret = true; + +FINISH_OFF: + + if (hStmt != NULL) { + rc = sqlite3_finalize(hStmt); + if (rc != SQLITE_OK) { + EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); + error = EMAIL_ERROR_DB_FAILURE; + } + } + + EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); + _DISCONNECT_DB; + + if (err_code != NULL) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} + +INTERNAL_FUNC int emstorage_update_certificate(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); + + if (certificate_id < 1) { + EM_DEBUG_EXCEPTION(" certificate_id[%d]", certificate_id); + + if (err_code != NULL) + *err_code = EMAIL_ERROR_INVALID_PARAM; + return false; + } + + int error = EMAIL_ERROR_NONE; + int rc, ret = false; + + DB_STMT hStmt = NULL; + char sql_query_string[QUERY_SIZE] = {0, }; +#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); + + SNPRINTF(sql_query_string, sizeof(sql_query_string), + "UPDATE mail_certificate_tbl SET" + " issue_year = ?" + ", issue_month = ?" /* Index of certificate */ + ", issue_day = ?" /* Select the account */ + ", expiration_year = ?" /* Year of issue */ + ", expiration_month = ?" /* Month of issue */ + ", expiration_day = ?" /* Day of issue */ + ", issue_organization_name = ?" /* Year of expiration */ + ", email_address = ?" /* Month of expiration */ + ", subject_str = ?" /* Day of expiration */ + ", filepath = ?" /* Organization of issue */ + ", password = ?" + " WHERE certificate_id = ?"); + + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc); + EM_DEBUG_LOG("After 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))); + + _bind_stmt_field_data_int(hStmt, ISSUE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->issue_year); + _bind_stmt_field_data_int(hStmt, ISSUE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->issue_month); + _bind_stmt_field_data_int(hStmt, ISSUE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->issue_day); + _bind_stmt_field_data_int(hStmt, EXPIRE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->expiration_year); + _bind_stmt_field_data_int(hStmt, EXPIRE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->expiration_month); + _bind_stmt_field_data_int(hStmt, EXPIRE_DAY_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->expiration_day); + _bind_stmt_field_data_string(hStmt, ISSUE_ORGANIZATION_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->issue_organization_name, 0, ISSUE_ORGANIZATION_LEN_IN_MAIL_CERTIFICATE_TBL); + _bind_stmt_field_data_string(hStmt, EMAIL_ADDRESS_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->email_address, 0, EMAIL_ADDRESS_LEN_IN_MAIL_CERTIFICATE_TBL); + _bind_stmt_field_data_string(hStmt, SUBJECT_STRING_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->subject_str, 0, SUBJECT_STRING_LEN_IN_MAIL_CERTIFICATE_TBL); + _bind_stmt_field_data_string(hStmt, FILE_PATH_IDX_IN_MAIL_CERTIFICATE_TBL, certificate->filepath, 0, FILE_NAME_LEN_IN_MAIL_CERTIFICATE_TBL); + + /* rc = sqlite3_step(hStmt); */ + EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc); + EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; }, + ("sqlite3_step fail:%d", rc)); + EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, + ("sqlite3_step fail:%d", rc)); + + /* validate account existence */ + rc = sqlite3_changes(local_db_handle); + if (rc == 0) { + EM_DEBUG_EXCEPTION(" no matched account found..."); + + error = EMAIL_ERROR_ACCOUNT_NOT_FOUND; + goto FINISH_OFF; + } + +#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__ + /* get password file name */ + if ((error = _get_cert_password_file_name(certificate->certificate_id, cert_password_file_name)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("em_storage_get_password_file_name failed."); + goto FINISH_OFF; + } + + /* save passwords to the secure storage */ + if (ssm_write_buffer(certificate->password, strlen(certificate->password), cert_password_file_name, SSM_FLAG_SECRET_OPERATION, NULL) < 0) { + EM_DEBUG_EXCEPTION("ssm_write_buffer failed - Private certificate password : [%s]", cert_password_file_name); + error = EMAIL_ERROR_SYSTEM_FAILURE; + goto FINISH_OFF; + } +#endif + if (!emstorage_notify_storage_event(NOTI_CERTIFICATE_UPDATE, certificate->certificate_id, 0, NULL, 0)) + EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event[ NOTI_CERTIFICATE_UPDATE] : Notification Failed >>> "); + + ret = true; + +FINISH_OFF: + + if (hStmt != NULL) { + EM_DEBUG_LOG(" Before sqlite3_finalize hStmt = %p", hStmt); + + rc = sqlite3_finalize(hStmt); + if (rc != SQLITE_OK) { + EM_DEBUG_LOG(" sqlite3_finalize failed - %d", rc); + error = EMAIL_ERROR_DB_FAILURE; + } + } + + EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error); + + _DISCONNECT_DB; + + if (err_code != NULL) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} /*EOF*/ diff --git a/email-core/email-storage/include/email-storage.h b/email-core/email-storage/include/email-storage.h index a1a5aa7..2843bd9 100755 --- a/email-core/email-storage/include/email-storage.h +++ b/email-core/email-storage/include/email-storage.h @@ -55,57 +55,93 @@ typedef struct { int mail_id; unsigned long server_mail_id; -} emf_id_set_t; +} email_id_set_t; #endif /* __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__ */ typedef struct { - int account_bind_type; - char *account_name; - int receiving_server_type; - char *receiving_server_addr; - char *email_addr; - char *user_name; - char *password; - int retrieval_mode; - int port_num; - int use_security; - int sending_server_type; - char *sending_server_addr; - int sending_port_num; - int sending_auth; - int sending_security; - char *sending_user; - char *sending_password; - char *display_name; - char *reply_to_addr; - char *return_addr; - int account_id; - int keep_on_server; - int flag1; /* Specifies the downloading option 0 is subject only, 1 is text body, 2 is normal. */ - int flag2; - int pop_before_smtp; /* POP before SMTP Authentication */ - int apop; /* APOP authentication */ - char *logo_icon_path; /* Account logo icon */ - int preset_account; /* Preset account or not */ - emf_option_t options; /* Specifies the Sending options */ - int target_storage; /* Specifies the targetStorage. 0 is phone, 1 is MMC */ - int check_interval; /* Specifies the check interval */ - int my_account_id; /* Specifies accout id of my account */ - int index_color; /* index color in RGB */ - int sync_status; /* Sync Status */ + /* Account information */ + int account_id; /* Account id */ + char *account_name; /* Account name */ + char *logo_icon_path; /* Account logo icon path */ + int account_svc_id; /* Specifies id from account-svc */ + int sync_status; /* Sync Status. SYNC_STATUS_FINISHED, SYNC_STATUS_SYNCING, SYNC_STATUS_HAVE_NEW_MAILS */ + int sync_disabled; /* If this attriube is set as true, email-service will not synchronize this account. */ + int default_mail_slot_size; + + void *user_data; /* binary user data */ + int user_data_length; /* user data length */ + + /* User information */ + char *user_display_name; /* User's display name */ + char *user_email_address; /* User's email address */ + char *reply_to_address; /* Email address for reply */ + char *return_address; /* Email address for error from server*/ + + /* Configuration for incoming server */ + email_account_server_t incoming_server_type; /* Incoming server type */ + char *incoming_server_address; /* Incoming server address */ + int incoming_server_port_number; /* Incoming server port number */ + char *incoming_server_user_name; /* Incoming server user name */ + char *incoming_server_password; /* Incoming server password */ + int incoming_server_secure_connection; /* Does incoming server requires secured connection? */ + + /* Options for incoming server */ + email_imap4_retrieval_mode_t retrieval_mode; /* Retrieval mode : EMAIL_IMAP4_RETRIEVAL_MODE_NEW or EMAIL_IMAP4_RETRIEVAL_MODE_ALL */ + int keep_mails_on_pop_server_after_download; /* Keep mails on POP server after download */ + int check_interval; /* Specifies the interval for checking new mail periodically */ + int auto_download_size; /* Specifies the size for auto download in bytes. -1 means entire mails body */ + + /* Configuration for outgoing server */ + email_account_server_t outgoing_server_type; + char *outgoing_server_address; + int outgoing_server_port_number; + char *outgoing_server_user_name; + char *outgoing_server_password; + int outgoing_server_secure_connection; /* Does outgoing server requires secured connection? */ + int outgoing_server_need_authentication; /* Does outgoing server requires authentication? */ + int outgoing_server_use_same_authenticator; /* Use same authenticator for outgoing server */ /* flag2 */ + + /* Options for outgoing server */ + email_option_t options; + + /* Authentication Options */ + int pop_before_smtp; /* POP before SMTP Authentication */ + int incoming_server_requires_apop; /* APOP authentication */ + + /* S/MIME Options */ + email_smime_type smime_type; /* Sepeifies the smime type 0=Normal 1=Clear signed 2=encrypted 3=Signed + encrypted */ + 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*/ } emstorage_account_tbl_t; typedef struct { + int certificate_id; + int issue_year; + int issue_month; + int issue_day; + int expiration_year; + int expiration_month; + int expiration_day; + char *issue_organization_name; + char *email_address; + char *subject_str; + char *filepath; + char *password; +} emstorage_certificate_tbl_t; + +typedef struct +{ int account_id; /* MUST BE '0' : currently, only global rule supported. */ int rule_id; int type; /* from/subject/body */ char *value; int action_type; /* move/block/delete */ - char *dest_mailbox; /* destination mailbox */ + int target_mailbox_id; /* destination mailbox */ int flag1; /* for rule ON/OFF */ int flag2; /* For rule type INCLUDE/Exactly SAME AS */ } emstorage_rule_tbl_t; @@ -117,22 +153,23 @@ typedef struct int account_id; int local_yn; char *mailbox_name; - emf_mailbox_type_e mailbox_type; + email_mailbox_type_e mailbox_type; char *alias; - int sync_with_server_yn; /* whether mailbox is a sync IMAP mailbox */ + int sync_with_server_yn; /* whether mailbox is a sync IMAP mailbox */ int modifiable_yn; /* whether mailbox is able to be deleted/modified */ - int unread_count; /* Removed. 16-Dec-2010, count unread mails at the moment it is required. not store in the DB */ + int unread_count; /* Removed. 16-Dec-2010, count unread mails at the moment it is required. not store in the DB */ int total_mail_count_on_local; /* Specifies the total number of mails in the mailbox in the local DB. count unread mails at the moment it is required. not store in the DB */ - int total_mail_count_on_server; /* Specifies the total number of mails in the mailbox in the mail server */ + int total_mail_count_on_server; /* Specifies the total number of mails in the mailbox in the mail server */ int has_archived_mails; int mail_slot_size; + time_t last_sync_time; /* The last synchronization time */ } emstorage_mailbox_tbl_t; /* mail_read_uid_tbl table entity */ typedef struct { int account_id; - char *local_mbox; + int mailbox_id; int local_uid; char *mailbox_name; /* server mailbox */ char *s_uid; /* uid on server */ @@ -146,7 +183,7 @@ typedef struct { int mail_id; int account_id; - int mailbox_id; /* For internal use. Currently, account_id and mailbox name is primary key of the table. */ + int mailbox_id; char *mailbox_name; int mailbox_type; char *subject; @@ -168,6 +205,7 @@ typedef struct int body_download_status; char *file_path_plain; char *file_path_html; + char *file_path_mime_entity; int mail_size; char flags_seen_field; char flags_deleted_field; @@ -187,6 +225,9 @@ typedef struct int thread_item_count; char *preview_text; int meeting_request_status; + int message_class; + int digest_type; + int smime_type; } emstorage_mail_tbl_t; /* mail_attachment_tbl entity */ @@ -198,7 +239,7 @@ typedef struct int attachment_size; int mail_id; int account_id; - char *mailbox_name; + int mailbox_id; int attachment_save_status; /* 1 : existing, 0 : not existing */ int attachment_drm_type; /* 0 : none, 1 : object, 2 : rights, 3 : dcf */ int attachment_drm_method; /* 0 : none, 1 : FL, 2 : CD, 3 : SSD, 4 : SD */ @@ -229,17 +270,10 @@ typedef struct _emstorage_search_filter_t { } emstorage_search_filter_t; typedef enum { - EMF_CREATE_DB_NORMAL = 0, - EMF_CREATE_DB_CHECK, + EMAIL_CREATE_DB_NORMAL = 0, + EMAIL_CREATE_DB_CHECK, } emstorage_create_db_type_t; -typedef enum { - SET_TYPE_SET = 1, - SET_TYPE_UNION = 2, - SET_TYPE_MINUS = 3, - SET_TYPE_INTERSECT = 4 /* Not supported */ -} emstorage_set_type_t; - /***************************************************************************** etc @@ -345,7 +379,7 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e * @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(emf_account_t *account, int transaction, int *err_code); +INTERNAL_FUNC int emstorage_check_duplicated_account(email_account_t *account, int transaction, int *err_code); /** @@ -382,7 +416,7 @@ INTERNAL_FUNC int emstorage_get_account_list(int *select_num, emstorage_account_ * this buffer must be free after it has been used. * return : */ -/* sowmya.kr, 281209 Adding signature to options in emf_account_t changes */ +/* 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); @@ -410,6 +444,9 @@ INTERNAL_FUNC int emstorage_get_password_length_of_account(int account_id, int * */ 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); + /* * emstorage_get_sync_status_of_account * @@ -428,12 +465,12 @@ INTERNAL_FUNC int emstorage_get_sync_status_of_account(int account_id, int *resu * description : update a sync status field from account table * arguments : * account_id : account id - * set_operator : set operater. refer emstorage_set_type_t + * set_operator : set operater. refer email_set_type_t * sync_status : sync status value * return : */ -INTERNAL_FUNC int emstorage_update_sync_status_of_account(int account_id, emstorage_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 @@ -493,7 +530,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(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(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 @@ -523,12 +560,13 @@ INTERNAL_FUNC int emstorage_get_child_mailbox_list(int account_id, char *parent_ * 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_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_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, emstorage_mailbox_tbl_t **mailbox, int transaction, int *err_code); -INTERNAL_FUNC int emstorage_get_mailboxname_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, char **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_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, char *mailbox_name, int total_count_on_server, 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); /* @@ -541,7 +579,7 @@ INTERNAL_FUNC int emstorage_update_mailbox_total_count(int account_id, char *mai * mailbox : buffer to hold selected local mailbox * return : */ -INTERNAL_FUNC int emstorage_update_mailbox(int account_id, int local_yn, char *mailbox_name, emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code); +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); /* * emstorage_update_mailbox_type @@ -550,7 +588,7 @@ INTERNAL_FUNC int emstorage_update_mailbox(int account_id, int local_yn, char *m * arguments : * return : */ -INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, char *mailbox_name, emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code); +INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, char *mailbox_name, email_mailbox_type_e new_mailbox_type, int transaction, int *err_code); /* * emstorage_add_mailbox @@ -570,14 +608,15 @@ 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, char *mailbox_name, int transaction, int *err_code); +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_rename_mailbox(int account_id, char *old_mailbox_name, char *new_mailbox_name, int transaction, int *err_code); -INTERNAL_FUNC int emstorage_get_overflowed_mail_id_list(int account_id, char *mailbox_name, 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, char *mailbox_name, int new_slot_size, int transaction, int *err_code); +INTERNAL_FUNC int emstorage_rename_mailbox(int input_mailbox_id, char *input_new_mailbox_path, char *input_new_mailbox_alias, int input_transaction); +INTERNAL_FUNC int emstorage_get_overflowed_mail_id_list(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(int account_id, int mailbox_id, int new_slot_size, 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); /* * emstorage_free_mailbox @@ -617,14 +656,14 @@ INTERNAL_FUNC int emstorage_check_read_mail_uid(int account_id, char *mailbox_na * description : get mail size from read mail uid * arguments : * db : database pointer - * local_mbox : local mailbox name + * mailbox_id : local mailbox id * local_uid : mail uid of local mailbox * mailbox_name : server mailbox name * uid : mail uid string of server mail * read_mail_uid : variable to hold read mail uid information * return : */ -INTERNAL_FUNC int emstorage_get_downloaded_list(int account_id, char *local_mbox, emstorage_read_mail_uid_tbl_t **read_mail_uid, int *count, int transaction, int *err_code); +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_mail(int mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code); @@ -657,7 +696,7 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(emstorage_read_mail_uid_tbl_t *r * arguments : * return : */ -INTERNAL_FUNC int emstorage_change_read_mail_uid(int account_id, char *local_mbox, int local_uid, char *mailbox_name, char *uid, +INTERNAL_FUNC int emstorage_change_read_mail_uid(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); /* @@ -767,8 +806,6 @@ INTERNAL_FUNC int emstorage_delete_rule(int account_id, int rule_id, int transac INTERNAL_FUNC int emstorage_free_rule(emstorage_rule_tbl_t **rule_list, int count, int *err_code); -INTERNAL_FUNC int emstorage_filter_mails_by_rule(int account_id, char *dest_mailbox_name, emstorage_rule_tbl_t *rule, int **filtered_mail_id_list, int *count_of_mails, int *err_code); - /************** Mail Management ******************/ /* @@ -822,11 +859,25 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(int mail_id, int type, emstorag 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); /* + * 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); + +/* + * 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); + +/* * emstorage_query_mail_list * * description : query mail list information */ -INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int transaction, emf_mail_list_item_t** result_mail_list, int *result_count, int *err_code); +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); /* * emstorage_query_mail_tbl @@ -836,18 +887,27 @@ INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int 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); /* + * emstorage_query_mailbox_tbl + * + * description : query mail box table information + */ + +INTERNAL_FUNC int emstorage_query_mailbox_tbl(const char *input_conditional_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(int account_id, const char *mailbox_name, emf_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, int search_type, const char *search_value, emf_sort_type_t sorting, int transaction, emf_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, const char *mailbox_name, emf_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, emf_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, const char *mailbox_name, int thread_id, int search_type, const char *search_value, int start_index, int limit_count, emf_sort_type_t sorting, int transaction, emf_mail_list_item_t **mail_list, int *result_count, int *err_code); +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_latest_unread_mailid(int account_id, int *mail_id, int *err_code); @@ -913,7 +973,7 @@ INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(int account_id * mail : mail pointer * return : */ -INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, emf_mail_change_type_t type, emstorage_mail_tbl_t *mail, int transaction, int *err_code); +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); /* * emstorage_increase_mail_id @@ -957,14 +1017,14 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail, int get_id, int * description : * arguments : * account_id : - * target_mailbox_name : + * input_mailbox_id : * mail_ids : * number_of_mails : * transaction : * err_code : * return : */ -INTERNAL_FUNC int emstorage_move_multiple_mails(int account_id, char *target_mailbox_name, int mail_ids[], int number_of_mails, int transaction, int *err_code); +INTERNAL_FUNC int emstorage_move_multiple_mails(int account_id, int input_mailbox_id, int mail_ids[], int number_of_mails, int transaction, int *err_code); /* * emstorage_delete_mail @@ -993,10 +1053,10 @@ INTERNAL_FUNC int emstorage_delete_mail_by_account(int account_id, int transacti * description : delete mail from mail table * arguments : * account_id : account id. - * mbox : mail box + * mailbox : mail box * return : */ -INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(int account_id, char *mbox, int transaction, int *err_code); +INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(int account_id, char *mailbox, int transaction, int *err_code); /* * emstorage_delete_multiple_mails @@ -1043,7 +1103,7 @@ INTERNAL_FUNC int emstorage_get_attachment_count(int mail_id, int *count, int tr * input_transaction : transaction option * attachment_list : result attachment list * output_attachment_count : result attachment count - * return : This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR__XXX) on failure. + * 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); @@ -1054,12 +1114,11 @@ INTERNAL_FUNC int emstorage_get_attachment_list(int input_mail_id, int input_tra * * description : get attachment from attachment table * arguments : - * mail_id : mail id - * no : attachment id + * attachment_id : attachment id * attachment : double pointer to hold attachment data * return : */ -INTERNAL_FUNC int emstorage_get_attachment(int mail_id, int no, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code); +INTERNAL_FUNC int emstorage_get_attachment(int attachment_id, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code); /* * emstorage_get_attachment @@ -1083,19 +1142,7 @@ INTERNAL_FUNC int emstorage_get_attachment_nth(int mail_id, int nth, emstorage_a * mail : mail pointer * return : */ -INTERNAL_FUNC int emstorage_change_attachment_field(int mail_id, emf_mail_change_type_t type, emstorage_attachment_tbl_t *attachment, int transaction, int *err_code); - -/* - * emstorage_change_attachment_mbox - * - * description : update mailbox from attahcment table - * arguments : - * account_id : account id - * old_mailbox_name : old mail box - * new_mailbox_name : new mail box - * return : - */ -INTERNAL_FUNC int emstorage_change_attachment_mbox(int account_id, char *old_mailbox_name, char *new_mailbox_name, int transaction, int *err_code); +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); /* Get new attachment id */ /* @@ -1129,11 +1176,12 @@ INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t *attach * * description : delete attachment from attachment table * arguments : - * mail_id : mail id to contain attachment - * no : attachment sequence number + * attachment_id : attachment id * return : */ -INTERNAL_FUNC int emstorage_delete_attachment_on_db(int mail_id, int no, int transaction, int *err_code); +INTERNAL_FUNC int emstorage_delete_attachment_on_db(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); /* * emstorage_delete_attachment_all_on_db @@ -1141,10 +1189,10 @@ INTERNAL_FUNC int emstorage_delete_attachment_on_db(int mail_id, int no, int tra * description : delete attachment from mail table * arguments : * account_id : account id. - * mbox : mail box + * mailbox : mail box * return : */ -INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(int account_id, char *mbox, int transaction, int *err_code); +INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(int account_id, char *mailbox, int transaction, int *err_code); /* * emstorage_free_attachment @@ -1157,13 +1205,7 @@ INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(int account_id, char *mb */ INTERNAL_FUNC int emstorage_free_attachment(emstorage_attachment_tbl_t **attachment_list, int count, int *err_code); -/* emstorage_get_mail_count_with_draft_flag - Send number of mails in a mailbox with draft flag enabled */ -INTERNAL_FUNC int emstorage_get_mail_count_with_draft_flag(int account_id, const char *mailbox, int *total, int transaction, int *err_code); - -/* emstorage_get_mail_count_on_sending - Send number of mails being sent in a mailbox (status == EMF_MAIL_STATUS_SENDING) */ -INTERNAL_FUNC int emstorage_get_mail_count_on_sending(int account_id, const char *mailbox, int *total, int transaction, int * err_code); - -INTERNAL_FUNC int emstorage_is_mailbox_full(int account_id, emf_mailbox_t *mailbox, int *result, 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_get_max_mail_count(); @@ -1299,17 +1341,21 @@ 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); /** * emstorage_notify_storage_event - Notification for storage related operations - * */ -INTERNAL_FUNC int emstorage_notify_storage_event(emf_noti_on_storage_event event_type, int data1, int data2 , char *data3, int data4); +INTERNAL_FUNC int emstorage_notify_storage_event(email_noti_on_storage_event event_type, int data1, int data2 , char *data3, int data4); /** * emstorage_notify_network_event - Notification for network related operations - * */ -INTERNAL_FUNC int emstorage_notify_network_event(emf_noti_on_network_event event_type, int data1, char *data2, int data3, int data4); -INTERNAL_FUNC int emstorage_get_sender_list(int account_id, const char *mailbox_name, int search_type, const char *search_value, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count, int *err_code); -INTERNAL_FUNC int emstorage_free_sender_list(emf_sender_list_t **sender_list, int count); +INTERNAL_FUNC int emstorage_notify_network_event(email_noti_on_network_event event_type, int data1, char *data2, int data3, int data4); + +/** + * emstorage_notify_response_to_api - Notification for response to API + */ +INTERNAL_FUNC int emstorage_notify_response_to_api(email_event_type_t event_type, int data1, int data2); + +INTERNAL_FUNC int emstorage_get_sender_list(int account_id, const char *mailbox_name, 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); @@ -1327,25 +1373,25 @@ enum SERVER_MAIL_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL, ACTIVITY_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL, ACTIVITY_TYPE_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL, - MAILBOX_NAME_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, }; -INTERNAL_FUNC int emstorage_get_pbd_activity_data(int account_id, char *mailbox_name, emf_event_partial_body_thd** event_start, int *count, int transaction, int *err_code); -INTERNAL_FUNC int emstorage_add_pbd_activity(emf_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, char ***mailbox_list, int *count, int transaction, 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, char *mailbox_name, int *activity_count, 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 -INTERNAL_FUNC int emstorage_free_address_info_list(emf_address_info_list_t **address_info_list); - +INTERNAL_FUNC int emstorage_free_address_info_list(email_address_info_list_t **address_info_list); INTERNAL_FUNC void emstorage_create_dir_if_delete(); @@ -1353,7 +1399,7 @@ INTERNAL_FUNC void emstorage_create_dir_if_delete(); 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); /** - * @fn emstorage_get_id_set_from_mail_ids(int mail_ids[], int mail_id_count, emf_id_set_t **server_uids, int *id_set_count, 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); * Prepare an array of mail_id and corresponding server mail id. * *@author h.gahlaut@samsung.com @@ -1367,12 +1413,12 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *old_server_ * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *mail_ids, emf_id_set_t **idset, int *id_set_count, int *err_code); +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); #endif /** - * @fn emstorage_filter_mails_by_rule(int account_id, char dest_mailbox_name, emf_rule_t *rule, int **filtered_mail_id_list, int *count_of_mails, int err_code) + * @fn emstorage_filter_mails_by_rule(int account_id, char dest_mailbox_name, email_rule_t *rule, int **filtered_mail_id_list, int *count_of_mails, int err_code) * Move mails by specified rule for spam filtering. * * @author kyuho.jo@samsung.com @@ -1386,14 +1432,16 @@ INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *mail_ids, emf_id_set_ * @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, emstorage_rule_tbl_t *rule, int **filtered_mail_id_list, int *count_of_mails, 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_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_add_meeting_request(int account_id, char *mailbox_name, emf_meeting_request_t *meeting_req, int transaction, int *err_code); -INTERNAL_FUNC int emstorage_get_meeting_request(int mail_id, emf_meeting_request_t **meeting_req, int transaction, int *err_code); -INTERNAL_FUNC int emstorage_update_meeting_request(emf_meeting_request_t *meeting_req, int transaction, int *err_code); -INTERNAL_FUNC int emstorage_change_meeting_request_field(int account_id, char *mailbox_name, emf_mail_change_type_t type, emf_meeting_request_t *meeting_req, int transaction, int *err_code); -INTERNAL_FUNC int emstorage_change_meeting_request_mailbox(int account_id, char *old_mailbox_name, char *new_mailbox_name, int transaction, int *err_code); -INTERNAL_FUNC int emstorage_delete_meeting_request(int account_id, int mail_id, char *mailbox_name, int transaction, int *err_code); -INTERNAL_FUNC int emstorage_free_meeting_request(emf_meeting_request_t **meeting_req, int count, int *err_code); +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_free_list_filter(email_list_filter_t **input_filter_list, int input_filter_count); #ifdef __FEATURE_LOCAL_ACTIVITY__ /* @@ -1410,7 +1458,7 @@ INTERNAL_FUNC int emstorage_get_next_activity_id(int *activity_id, int *err_code *return : * */ - INTERNAL_FUNC int emstorage_get_activity_id_list(int account_id, int **activity_id_list, int *activity_count, int lowest_activity_type, int highest_activity_type, int transaction, int*err_code); +INTERNAL_FUNC int emstorage_get_activity_id_list(int account_id, int **activity_id_list, int *activity_count, int lowest_activity_type, int highest_activity_type, int transaction, int*err_code); /* * emstorage_add_activity * @@ -1449,6 +1497,18 @@ 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_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_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_index(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); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/email-core/include/email-core-account.h b/email-core/include/email-core-account.h index 4eba963..1ed302d 100755 --- a/email-core/include/email-core-account.h +++ b/email-core/include/email-core-account.h @@ -42,13 +42,17 @@ extern "C" INTERNAL_FUNC int emcore_validate_account(int account_id, int *err_code); -INTERNAL_FUNC int emcore_validate_account_with_account_info(emf_account_t *account, int *err_code); +INTERNAL_FUNC int emcore_validate_account_with_account_info(email_account_t *account, int *err_code); -INTERNAL_FUNC int emcore_create_account(emf_account_t *account, int *err_code); +INTERNAL_FUNC int emcore_create_account(email_account_t *account, int *err_code); -INTERNAL_FUNC int emcore_delete_account_(int account_id, int *err_code); +INTERNAL_FUNC int emcore_delete_account(int account_id, int *err_code); -INTERNAL_FUNC int emcore_free_account(emf_account_t **account_list, int count, int *err_code); +INTERNAL_FUNC int emcore_free_account_list(email_account_t **account_list, int count, int *err_code); + +INTERNAL_FUNC void emcore_free_option(email_option_t *option); + +INTERNAL_FUNC void emcore_free_account(email_account_t *account_list); INTERNAL_FUNC int emcore_init_account_reference(); @@ -56,18 +60,22 @@ INTERNAL_FUNC int emcore_refresh_account_reference(); INTERNAL_FUNC int emcore_free_account_reference(); -INTERNAL_FUNC emf_account_t *emcore_get_account_reference(int account_id); +INTERNAL_FUNC email_account_t *emcore_get_account_reference(int account_id); -INTERNAL_FUNC int emcore_get_account_reference_list(emf_account_t **account_list, int *count, int *err_code); +INTERNAL_FUNC int emcore_get_account_reference_list(email_account_t **account_list, int *count, int *err_code); -INTERNAL_FUNC int emcore_query_server_info(const char* domain_name, emf_server_info_t **result_server_info); +INTERNAL_FUNC int emcore_query_server_info(const char* domain_name, email_server_info_t **result_server_info); -INTERNAL_FUNC int emcore_free_server_info(emf_server_info_t **target_server_info); +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_load_default_account_id(int *output_account_id); +INTERNAL_FUNC int emcore_recover_from_secured_storage_failure(); + +INTERNAL_FUNC int emcore_update_sync_status_of_account(int input_account_id, email_set_type_t input_set_operator, int input_sync_status); + #ifdef __FEATURE_BACKUP_ACCOUNT__ INTERNAL_FUNC int emcore_backup_accounts(const char *file_path, int *error_code); diff --git a/email-core/include/email-core-cert.h b/email-core/include/email-core-cert.h new file mode 100644 index 0000000..78222c5 --- /dev/null +++ b/email-core/include/email-core-cert.h @@ -0,0 +1,54 @@ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +/****************************************************************************** + * File : email-core-cert.h + * Desc : Certificate operation Header + * + * Auth : + * + * History : + * 2011.04.14 : created + *****************************************************************************/ + +#ifndef EM_CORE_CERT_H_ +#define EM_CORE_CERT_H_ + +#include +#include + +#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_delete_public_certificate(char *email_address, int *err_code); + +INTERNAL_FUNC int emcore_verify_signature(char *p7s_file_path, char *mime_entity, int *validity, int *err_code); + +INTERNAL_FUNC int emcore_verify_certificate(char *certificate, int *validity, int *err_code); + +INTERNAL_FUNC int emcore_free_certificate(email_certificate_t **certificate, int count, int *err_code); + +INTERNAL_FUNC int emcore_load_PFX_file(char *certificate, char *password, EVP_PKEY **pri_key, X509 **cert, STACK_OF(X509) **ca, int *err_code); + +#endif diff --git a/email-core/include/email-core-event.h b/email-core/include/email-core-event.h index 6ee7a28..5476d2b 100755 --- a/email-core/include/email-core-event.h +++ b/email-core/include/email-core-event.h @@ -40,36 +40,36 @@ extern "C" { #endif /* __cplusplus */ -void emcore_execute_event_callback(emf_action_t action, int total, int done, int status, int account_id, int mail_id, int handle, int error); +void emcore_execute_event_callback(email_action_t action, int total, int done, int status, int account_id, int mail_id, int handle, int error); int emcore_get_active_queue_idx(void); int emcore_check_send_mail_thread_status(); INTERNAL_FUNC int emcore_get_current_thread_type(); -INTERNAL_FUNC int emcore_register_event_callback(emf_action_t action, emf_event_callback callback, void *event_data); -INTERNAL_FUNC int emcore_unregister_event_callback(emf_action_t action, emf_event_callback callback); -INTERNAL_FUNC int emcore_get_pending_event(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t *status); +INTERNAL_FUNC int emcore_register_event_callback(email_action_t action, email_event_callback callback, void *event_data); +INTERNAL_FUNC int emcore_unregister_event_callback(email_action_t action, email_event_callback callback); +INTERNAL_FUNC int emcore_get_pending_event(email_action_t action, int account_id, int mail_id, email_event_status_type_t *status); INTERNAL_FUNC int emcore_start_event_loop(int *err_code); INTERNAL_FUNC int emcore_stop_event_loop(int *err_code); -INTERNAL_FUNC int emcore_insert_event(emf_event_t *event_data, int *handle, int *err_code); +INTERNAL_FUNC int emcore_insert_event(email_event_t *event_data, int *handle, int *err_code); INTERNAL_FUNC int emcore_cancel_thread(int handle, void *arg, int *err_code); -INTERNAL_FUNC int emcore_send_event_loop_start(int *err_code); +INTERNAL_FUNC int emcore_start_event_loop_for_sending_mails(int *err_code); INTERNAL_FUNC int emcore_send_event_loop_stop(int *err_code); INTERNAL_FUNC int emcore_cancel_send_mail_thread(int handle, void *arg, int *err_code); INTERNAL_FUNC int emcore_check_thread_status(void); INTERNAL_FUNC void emcore_get_event_queue_status(int *on_sending, int *on_receiving); -INTERNAL_FUNC int emcore_insert_send_event(emf_event_t *event_data, int *handle, int *err_code); -INTERNAL_FUNC int emcore_get_receiving_event_queue(emf_event_t **event_queue, int *event_count, int *err); +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_free_event(emf_event_t *event_data); +INTERNAL_FUNC int emcore_free_event(email_event_t *event_data); #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__ /* Please contact -> Himanshu [h.gahlaut@samsung.com] for any explanation in code here under this MACRO */ -INTERNAL_FUNC int emcore_insert_partial_body_thread_event(emf_event_partial_body_thd *partial_body_thd_event, int *error_code); +INTERNAL_FUNC int emcore_insert_partial_body_thread_event(email_event_partial_body_thd *partial_body_thd_event, int *error_code); INTERNAL_FUNC int emcore_is_partial_body_thd_que_empty(); INTERNAL_FUNC int emcore_is_partial_body_thd_que_full(); -INTERNAL_FUNC int emcore_partial_body_thread_loop_start(int *err_code); +INTERNAL_FUNC int emcore_start_thread_for_downloading_partial_body(int *err_code); INTERNAL_FUNC int emcore_clear_partial_body_thd_event_que(int *err_code); -INTERNAL_FUNC int emcore_free_partial_body_thd_event(emf_event_partial_body_thd *partial_body_thd_event, int *error_code); +INTERNAL_FUNC int emcore_free_partial_body_thd_event(email_event_partial_body_thd *partial_body_thd_event, int *error_code); INTERNAL_FUNC unsigned int emcore_get_partial_body_thd_id(); INTERNAL_FUNC int emcore_get_pbd_thd_state(); unsigned int emcore_get_receiving_thd_id(); diff --git a/email-core/include/email-core-global.h b/email-core/include/email-core-global.h index 2588aad..8626d0b 100755 --- a/email-core/include/email-core-global.h +++ b/email-core/include/email-core-global.h @@ -38,11 +38,11 @@ extern "C" #include "email-internal-types.h" -extern emf_account_list_t *g_account_list; +extern email_account_list_t *g_account_list; extern int g_account_num; extern int g_account_retrieved; -INTERNAL_FUNC emf_account_t *emcore_get_new_account_reference(); +INTERNAL_FUNC email_account_t *emcore_get_new_account_reference(); #ifdef __cplusplus } diff --git a/email-core/include/email-core-imap-mailbox.h b/email-core/include/email-core-imap-mailbox.h index e643e38..bedb8b6 100755 --- a/email-core/include/email-core-imap-mailbox.h +++ b/email-core/include/email-core-imap-mailbox.h @@ -39,7 +39,7 @@ extern "C" { #endif /* __cplusplus */ -INTERNAL_FUNC int emcore_check_sync_imap_mailbox(emf_mailbox_t *mailbox, int *synchronous, int *err_code); +INTERNAL_FUNC int emcore_check_sync_imap_mailbox(email_mailbox_t *mailbox, int *synchronous, int *err_code); /** * Get mailbox list from imap server. * @@ -63,12 +63,12 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox, int *e * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emcore_download_mailbox_list(void *mail_stream, char *mailbox, emf_mailbox_t **mailbox_list, int *count, int *err_code); -INTERNAL_FUNC int emcore_delete_imap_mailbox(emf_mailbox_t *mailbox, int *err_code); -INTERNAL_FUNC int emcore_create_imap_mailbox(emf_mailbox_t *mailbox, int *err_code); -INTERNAL_FUNC int emcore_modify_imap_mailbox(emf_mailbox_t *old_mailbox, emf_mailbox_t *new_mailbox, int *err_code); -INTERNAL_FUNC int emcore_set_sync_imap_mailbox(emf_mailbox_t *mailbox, int synchronous, int *err_code); -INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, char *mailbox_name, int new_slot_size, int *err_code); +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_move_mailbox_on_imap_server(int input_account_id, char *input_old_mailbox_path, char *input_new_mailbox_path); +INTERNAL_FUNC int emcore_set_sync_imap_mailbox(email_internal_mailbox_t *mailbox, int synchronous, int *err_code); +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 *output_count, int *err_code); diff --git a/email-core/include/email-core-mail.h b/email-core/include/email-core-mail.h index af5760c..4170ad9 100755 --- a/email-core/include/email-core-mail.h +++ b/email-core/include/email-core-mail.h @@ -54,7 +54,7 @@ typedef struct _emf_uid_range_set struct _emf_uid_range_set *next; -} emf_uid_range_set; +} email_uid_range_set; #endif @@ -82,6 +82,7 @@ struct _m_content_info int drm; /* 0 : none 1 : object 2 : rights 3 : dcf */ int drm2; /* 0 : none 1 : FL 2 : CD 3 : SSD 4 : SD */ char *attachment_mime_type; /* attachment mime type */ + char *content_id; /* mime content id */ #ifdef __ATTACHMENT_OPTI__ int encoding; /* encoding */ char *section; /* section number */ @@ -121,32 +122,38 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, in * @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, char *nth, int *err_code); +INTERNAL_FUNC int emcore_download_attachment(int acconut_id, int mail_id, int nth, int *err_code); +INTERNAL_FUNC int emcore_mail_add_attachment(int mail_id, email_attachment_data_t *attachment, int *err_code); /* TODO : Remove duplicated function */ +INTERNAL_FUNC int emcore_mail_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_free_attachment_data(email_attachment_data_t **attachment_data_list, int attachment_data_count, int *err_code); -INTERNAL_FUNC int emcore_mail_move(int mail_ids[], int num, char *dst_mailbox_name, int noti_param_1, int noti_param_2, int *err_code); -INTERNAL_FUNC int emcore_mail_add_attachment(int mail_id, emf_attachment_info_t *attachment, int *err_code); -INTERNAL_FUNC int emcore_delete_mail_attachment(int mail_id, char *attachment_id, int *err_code); -INTERNAL_FUNC int emcore_mail_add_attachment_data(int input_mail_id, emf_attachment_data_t *input_attachment_data); + +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); #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__ -INTERNAL_FUNC int emcore_insert_pbd_activity(emf_event_partial_body_thd *local_activity, int *activity_id, int *err_code) ; +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); #endif -INTERNAL_FUNC int emcore_get_mail_contact_info(emf_mail_contact_info_t *contact_info, char *full_address, int *err_code); -INTERNAL_FUNC int emcore_get_mail_contact_info_with_update(emf_mail_contact_info_t *contact_info, char *full_address, int mail_id, int *err_code); -INTERNAL_FUNC int emcore_free_contact_info(emf_mail_contact_info_t *contact_info, int *err_code); +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_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, emf_address_info_list_t **address_info_list, 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_get_mail_display_name(CTSvalue *contact_name_value, char **contact_display_name); -INTERNAL_FUNC int emcore_get_mail_data(int input_mail_id, emf_mail_data_t **output_mail_data); +INTERNAL_FUNC int emcore_get_mail_data(int input_mail_id, email_mail_data_t **output_mail_data); -INTERNAL_FUNC int emcore_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int sync_server); +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_fetch_flags(int account_id, int mail_id, emf_mail_flag_t *mail_flag, int *err_code); -INTERNAL_FUNC int emcore_delete_mail_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_get_mail_msgno_by_uid(emf_account_t *account, emf_mailbox_t *mailbox, char *uid, int *msgno, int *err_code); +INTERNAL_FUNC int emcore_fetch_flags(int account_id, int mail_id, email_mail_flag_t *mail_flag, int *err_code); +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_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); /** * Delete mails. @@ -167,40 +174,38 @@ INTERNAL_FUNC int emcore_delete_mail(int account_id, int mail_id[], int num, int /** * Delete mails. * - * @param[in] mailbox Specifies the mailbox. this argument is for account id or mailbox name. - * @param[in] with_server Specifies whether mails is also deleted from server. - * @param[in] callback Specifies the callback function for delivering status during deleting. + * @param[in] input_mailbox_id Specifies the id of mailbox. + * @param[in] input_from_server Specifies whether mails is also deleted from server. * @param[out] err_code Specifies the error code returned. * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emcore_delete_mail_all(emf_mailbox_t *mailbox, int with_server, int *err_code); +INTERNAL_FUNC int emcore_delete_all_mails_of_acount(int input_account_id); +INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(int input_mailbox_id, int input_from_server, int *err_code); -INTERNAL_FUNC int emcore_free_mail_data(emf_mail_data_t **mail_list, int count, 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 int emcore_free_attachment_info(emf_attachment_info_t **atch_info, int *err_code); -INTERNAL_FUNC int emcore_free_attachment_data(emf_attachment_data_t **attachment_data_list, int attachment_data_count, int *err_code); -INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, char *src_mailbox, int mail_ids[], int num, char *dest_mailbox, int *error_code); +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_sync_flag_with_server(int mail_id, int *err_code); INTERNAL_FUNC int emcore_sync_seen_flag_with_server(int mail_ids[], int num, int *err_code); -INTERNAL_FUNC int emcore_get_attachment_info(int mail_id, char *attachment_no, emf_attachment_info_t **attachment, int *err_code); -INTERNAL_FUNC int emcore_get_attachment_data_list(int input_mail_id, emf_attachment_data_t **output_attachment_data, int *output_attachment_count); -INTERNAL_FUNC int emcore_modify_extra_flag(int mail_id, emf_extra_flag_t new_flag, int *err_code); -INTERNAL_FUNC int emcore_modify_flag(int mail_id, emf_mail_flag_t new_flag, int sticky_flag, int *err_code); -INTERNAL_FUNC int emcore_set_flags_field(int account_id, int mail_ids[], int num, emf_flags_field_type field_type, int value, int *err_code); + +INTERNAL_FUNC int emcore_modify_extra_flag(int mail_id, email_extra_flag_t new_flag, int *err_code); +INTERNAL_FUNC int emcore_modify_flag(int mail_id, email_mail_flag_t new_flag, int sticky_flag, 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_convert_string_to_structure(const char *encoded_string, void **struct_var, emf_convert_struct_type_e type); +INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, void **struct_var, email_convert_struct_type_e type); #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__ -INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, emf_flags_field_type field_type, int value, int *err_code); -INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, char *src_mailbox, int mail_ids[], int num, char *dest_mailbox, int *error_code); +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); #endif #ifdef __ATTACHMENT_OPTI__ -INTERNAL_FUNC int emcore_download_attachment_bulk(/*emf_mailbox_t *mailbox, */ int account_id, int mail_id, char *nth, int *err_code); +INTERNAL_FUNC int emcore_download_attachment_bulk(/*email_mailbox_t *mailbox, */ int account_id, int mail_id, char *nth, int *err_code); #endif -INTERNAL_FUNC int emcore_mail_filter_by_rule(emf_rule_t *filter_info, int *err_code); +INTERNAL_FUNC int emcore_mail_filter_by_rule(email_rule_t *filter_info, int *err_code); #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 d0858ca..945a759 100755 --- a/email-core/include/email-core-mailbox-sync.h +++ b/email-core/include/email-core-mailbox-sync.h @@ -50,20 +50,20 @@ typedef struct char *content_id; int dec_len; char *mime_type; -} emf_image_data; +} email_image_data; typedef struct { char *buffer; int buflen; -} emf_partial_buffer; +} email_partial_buffer; #endif typedef struct emcore_uid_elem { int msgno; char *uid; - emf_mail_flag_t flag; + email_mail_flag_t flag; struct emcore_uid_elem *next; } emcore_uid_list; @@ -75,6 +75,10 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int * int emcore_check_rule(const char *input_full_address_from, const char *input_subject, emstorage_rule_tbl_t *rule, int rule_len, int *matched, int *err_code); +int emcore_make_mail_tbl_data_from_envelope(MAILSTREAM *mail_stream, ENVELOPE *input_envelope, emcore_uid_list *input_uid_elem, emstorage_mail_tbl_t **output_mail_tbl_data, int *err_code); + +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); + /** * Download unread all headers from mail server. * @@ -108,7 +112,7 @@ typedef enum * @remarks N/A * @return This function returns true on success or false on failure. */ -int emcore_download_uid_all(emf_mailbox_t *mailbox, +int emcore_download_uid_all(email_internal_mailbox_t *mailbox, emcore_uid_list **uid_list, int *total, emstorage_read_mail_uid_tbl_t *read_mail_uids, @@ -128,7 +132,7 @@ int emcore_download_uid_all(emf_mailbox_t *mailbox, * @remarks N/A * @return This function returns true on success or false on failure. */ -int emcore_download_imap_msgno(emf_mailbox_t *mailbox, char *uid, int *msgno, int *err_code); +int emcore_download_imap_msgno(email_internal_mailbox_t *mailbox, char *uid, int *msgno, int *err_code); /** * Get a message number to be related to uid. @@ -166,7 +170,7 @@ int emcore_free_uids(emcore_uid_list *uid_list, int *err_code); INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int account_id, int mail_id, int *err_code); #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__ -INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream, emf_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); #endif /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ */ diff --git a/email-core/include/email-core-mailbox.h b/email-core/include/email-core-mailbox.h index 7be9255..bca0b09 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(emf_account_t *ref_account, char *mailbox, void **mail_stream, int *err_code); -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_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_close_mailbox(int account_id, void *mail_stream); #ifdef __FEATURE_KEEP_CONNECTION__ INTERNAL_FUNC void emcore_close_mailbox_receiving_stream(); @@ -62,19 +62,25 @@ INTERNAL_FUNC void emcore_close_mailbox_partial_body_stream(); INTERNAL_FUNC void emcore_reset_streams(); #endif -INTERNAL_FUNC int emcore_get_list_to_be_sync(int account_id, emf_mailbox_t **mailbox_list, int *p_count, int *err_code); -INTERNAL_FUNC int emcore_get_list(int account_id, emf_mailbox_t **mailbox_list, int *p_count, int *err_code); -INTERNAL_FUNC int emcore_free_mailbox(emf_mailbox_t **mailbox_list, int count, int *err_code); -INTERNAL_FUNC int emcore_get_mail_count(emf_mailbox_t *mailbox, int *total, int *unseen, int *err_code); -INTERNAL_FUNC int emcore_create_mailbox(emf_mailbox_t *new_mailbox, int on_server, int *err_code); -INTERNAL_FUNC int emcore_delete_mailbox(emf_mailbox_t *mailbox, int on_server, int *err_code); -INTERNAL_FUNC int emcore_delete_mailbox_all(emf_mailbox_t *mailbox, int *err_code); -INTERNAL_FUNC int emcore_update_mailbox(emf_mailbox_t *old_mailbox, emf_mailbox_t *new_mailbox, int *err_code); +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_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 *err_code); +INTERNAL_FUNC int emcore_delete_mailbox(int input_mailbox_id, int on_server, int *err_code); +INTERNAL_FUNC int emcore_delete_mailbox_all(email_mailbox_t *mailbox, int *err_code); +INTERNAL_FUNC int emcore_update_mailbox(email_mailbox_t *old_mailbox, email_mailbox_t *new_mailbox, int *err_code); INTERNAL_FUNC int emcore_save_local_activity_sync(int account_id, int *err_code); -INTERNAL_FUNC void emcore_bind_mailbox_type(emf_mailbox_t *mailbox_list); -INTERNAL_FUNC int emcore_send_mail_event(emf_mailbox_t *mailbox, int mail_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, emf_mailbox_type_e mailbox_type, emf_mailbox_t *spam_mailbox, 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 void emcore_free_mailbox_list(email_mailbox_t **mailbox_list, int count); +INTERNAL_FUNC void emcore_free_mailbox(email_mailbox_t *mailbox); + +INTERNAL_FUNC void emcore_bind_mailbox_type(email_internal_mailbox_t *mailbox_list); +INTERNAL_FUNC int emcore_free_internal_mailbox(email_internal_mailbox_t **mailbox_list, int count, int *err_code); + + + #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 726c7f6..3af71d7 100755 --- a/email-core/include/email-core-mime.h +++ b/email-core/include/email-core-mime.h @@ -51,6 +51,9 @@ INTERNAL_FUNC int emcore_get_body_structure(MAILSTREAM *stream, int msg_uid, B 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 *err_code); +INTERNAL_FUNC int emcore_load_eml_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_eml_data(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); #ifdef __cplusplus } diff --git a/email-core/include/email-core-smime.h b/email-core/include/email-core-smime.h new file mode 100755 index 0000000..76c45a3 --- /dev/null +++ b/email-core/include/email-core-smime.h @@ -0,0 +1,53 @@ +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + + +/****************************************************************************** + * File : email-core-smime.h + * Desc : Mail Operation Header + * + * Auth : + * + * History : + * 2006.08.16 : created + *****************************************************************************/ + +#ifndef EM_CORE_SMIME_H_ +#define EM_CORE_SMIME_H_ + +#include + +#include "email-types.h" + +INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate, char *password, 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_signed_and_encrypt_message(char *recipient_list, char *certificate, char *password, 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_set_decrypt_message(char *encrypt_message, char *certifcate, char *password, 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); + + +#endif /* EM_CORE_SMIME_H_ */ diff --git a/email-core/include/email-core-smtp.h b/email-core/include/email-core-smtp.h index 1c71665..5b3e02a 100755 --- a/email-core/include/email-core-smtp.h +++ b/email-core/include/email-core-smtp.h @@ -42,17 +42,19 @@ extern "C" #include "c-client.h" #include "email-internal-types.h" -INTERNAL_FUNC int emcore_send_mail(int account_id, char *mailbox, int mail_id, emf_option_t *sending_option, int *err_code); +INTERNAL_FUNC int emcore_send_mail(int account_id, int input_mailbox_id, int mail_id, email_option_t *sending_option, int *err_code); -INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *mailbox, emf_option_t *sending_option, int *err_code); +INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *mailbox, email_option_t *sending_option, int *err_code); -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, emf_option_t *sending_option, int *err_code); +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_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t *input_meeting_request, int input_from_eas); +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, 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); INTERNAL_FUNC int emcore_add_read_receipt(int input_read_mail_id, int *output_receipt_mail_id); -INTERNAL_FUNC int emcore_add_meeting_request(int account_id, char *mailbox_name, emf_meeting_request_t *meeting_req, int *err_code); +INTERNAL_FUNC int emcore_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int *err_code); #ifdef __cplusplus } diff --git a/email-core/include/email-core-sound.h b/email-core/include/email-core-sound.h index a0dea59..7b1c620 100755 --- a/email-core/include/email-core-sound.h +++ b/email-core/include/email-core-sound.h @@ -57,5 +57,5 @@ typedef enum #undef Min #endif -INTERNAL_FUNC int emcore_start_alert_thread(int *err_code); +INTERNAL_FUNC int emcore_start_thread_for_alerting_new_mails(int *err_code); INTERNAL_FUNC void emcore_start_alert(); diff --git a/email-core/include/email-core-timer.h b/email-core/include/email-core-timer.h index 4bf4fe3..7704c34 100755 --- a/email-core/include/email-core-timer.h +++ b/email-core/include/email-core-timer.h @@ -21,7 +21,7 @@ #include "email-internal-types.h" -typedef void (*EMF_TIMER_CALLBACK)(void *a_pData); +typedef void (*EMAIL_TIMER_CALLBACK)(void *a_pData); /** * Callback for timeout action @@ -40,7 +40,7 @@ INTERNAL_FUNC int emcore_timer_ex_callback(void *a_pData); * @remarks N/A * @return This function returns the timer id. */ -INTERNAL_FUNC int emcore_set_timer_ex(long a_nSetTimeValue, EMF_TIMER_CALLBACK a_pCallBack, void *a_pData); +INTERNAL_FUNC int emcore_set_timer_ex(long a_nSetTimeValue, EMAIL_TIMER_CALLBACK a_pCallBack, void *a_pData); /** * Kill timer. diff --git a/email-core/include/email-core-utils.h b/email-core/include/email-core-utils.h index 62f2ce3..148635a 100755 --- a/email-core/include/email-core-utils.h +++ b/email-core/include/email-core-utils.h @@ -44,9 +44,10 @@ extern "C" #include "email-core-mail.h" /* This is used for emcore_get_long_encoded_path */ +#define EMAIL_CONNECT_FOR_SENDING -1 #define ENCODED_PATH_SMTP "UHDF_ENCODED_PATH_SMTP_EKJD" -typedef int (*emf_get_unread_email_count_cb)(int unread, int *err_code); +typedef int (*email_get_unread_email_count_cb)(int unread, int *err_code); /* parse the Full mailbox Path and get the Alias Name of the Mailbox */ char* emcore_get_alias_of_mailbox(const char *mailbox_path); @@ -58,26 +59,26 @@ 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); 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(emf_mail_data_t *mail_data_src, emf_attachment_data_t *attachment_data_src, int attachment_count, 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_get_address_count(char *addr_str, int *to_num, int *err_code); int emcore_is_storage_full(int *error); -int emcore_show_popup(int id, emf_action_t action, int error); -int emcore_get_long_encoded_path_with_account_info(emf_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code); +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_preview_text_from_file(const char *input_plain_path, const char *input_html_path, int input_preview_buffer_length, char **output_preview_buffer); +int reg_replace (char *input_source_text, char *input_old_pattern_string, char *input_new_string); int emcore_strip_HTML(char *source_string); 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); /* Session Handling */ -int emcore_get_empty_session(emf_session_t **session); -int emcore_clear_session(emf_session_t *session); -int emcore_get_current_session(emf_session_t **session); +int emcore_get_empty_session(email_session_t **session); +int emcore_clear_session(email_session_t *session); +int emcore_get_current_session(email_session_t **session); -INTERNAL_FUNC emf_option_t *emcore_get_option(int *err_code); -INTERNAL_FUNC int emcore_set_option(emf_option_t *opt, int *err_code); +INTERNAL_FUNC email_option_t *emcore_get_option(int *err_code); +INTERNAL_FUNC int emcore_set_option(email_option_t *opt, int *err_code); INTERNAL_FUNC int emcore_check_unread_mail(); INTERNAL_FUNC int emcore_set_network_error(int err_code); @@ -95,12 +96,12 @@ INTERNAL_FUNC int emcore_delete_notification_for_read_mail(int mail_id); INTERNAL_FUNC int emcore_delete_notification_by_account(int account_id); INTERNAL_FUNC int emcore_finalize_sync(int account_id, int *error); - +INTERNAL_FUNC int emcore_show_user_message(int id, email_action_t action, int error); #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__ /** - * @fn emcore_convert_to_uid_range_set(emf_id_set_t *id_set, int id_set_count, emf_uid_range_set **uid_range_set, int range_len, int *err_code) + * @fn emcore_convert_to_uid_range_set(email_id_set_t *id_set, int id_set_count, email_uid_range_set **uid_range_set, int range_len, int *err_code) * Prepare a linked list of uid ranges with each node having a uid_range and lowest and highest uid in it. * *@author h.gahlaut@samsung.com @@ -114,10 +115,10 @@ INTERNAL_FUNC int emcore_finalize_sync(int account_id, int *error); * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emcore_convert_to_uid_range_set(emf_id_set_t *id_set, int id_set_count, emf_uid_range_set **uid_range_set, int range_len, int *err_code); +INTERNAL_FUNC int emcore_convert_to_uid_range_set(email_id_set_t *id_set, int id_set_count, email_uid_range_set **uid_range_set, int range_len, int *err_code); /** - * void emcore_free_uid_range_set(emf_uid_range_set **uid_range_head) + * void emcore_free_uid_range_set(email_uid_range_set **uid_range_head) * Frees the linked list of uid ranges * * @author h.gahlaut@samsung.com @@ -125,10 +126,10 @@ INTERNAL_FUNC int emcore_convert_to_uid_range_set(emf_id_set_t *id_set, int id_s * @remarks * @return This function does not return anything. */ -INTERNAL_FUNC void emcore_free_uid_range_set(emf_uid_range_set **uid_range_set); +INTERNAL_FUNC void emcore_free_uid_range_set(email_uid_range_set **uid_range_set); /** - * @fn emcore_append_subset_string_to_uid_range(char *subset_string, emf_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid) + * @fn emcore_append_subset_string_to_uid_range(char *subset_string, email_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid) * Appends the subset_string to uid range if the uid range has not exceeded maximum length(range_len), otherwise creates a new node in linked list of uid range set * and stores the subset_string in its uid_range. Also sets the lowest and highest uids for the corresponsing uid_range * @@ -143,7 +144,7 @@ INTERNAL_FUNC void emcore_free_uid_range_set(emf_uid_range_set **uid_range_set); * @return This function returns true on success or false on failure. */ -int emcore_append_subset_string_to_uid_range(char *subset_string, emf_uid_range_set **current_node_adr, emf_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid); +int emcore_append_subset_string_to_uid_range(char *subset_string, email_uid_range_set **current_node_adr, email_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid); /** * @fn emcore_form_comma_separated_strings(int numbers[], int num_count, int max_string_len, char ***strings, int *string_count, int *err_code) @@ -186,6 +187,9 @@ INTERNAL_FUNC int emcore_add_activity(emstorage_activity_tbl_t *new_activity, in INTERNAL_FUNC int emcore_delete_activity(emstorage_activity_tbl_t *activity, int *err_code); #endif /* __FEATURE_LOCAL_ACTIVITY__ */ +INTERNAL_FUNC void emcore_free_rule(email_rule_t* rule); + + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/email-daemon/CMakeLists.txt b/email-daemon/CMakeLists.txt index 027c69d..bf43bf1 100755 --- a/email-daemon/CMakeLists.txt +++ b/email-daemon/CMakeLists.txt @@ -38,7 +38,7 @@ INCLUDE_DIRECTORIES( ) INCLUDE(FindPkgConfig) -pkg_check_modules(main_pkgs REQUIRED glib-2.0 drm-service dlog dbus-1 gthread-2.0 db-util openssl uw-imap-toolkit vconf contacts-service alarm-service mm-player devman_haptic heynoti) +pkg_check_modules(main_pkgs REQUIRED glib-2.0 dlog dbus-1 gthread-2.0 db-util openssl uw-imap-toolkit vconf contacts-service alarm-service mm-player devman_haptic heynoti) FOREACH(flag ${main_pkgs_CFLAGS}) diff --git a/email-daemon/email-daemon-account.c b/email-daemon/email-daemon-account.c index bbb3aad..a9cf863 100755 --- a/email-daemon/email-daemon-account.c +++ b/email-daemon/email-daemon-account.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Kyuho Jo , Sunghyun Kwon -* +* * 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 @@ -39,10 +39,11 @@ #include "c-client.h" #include "email-debug-log.h" #include "email-daemon-account.h" +#include "email-daemon-auto-poll.h" #include #include "email-types.h" -#include "email-core-account.h" -#include "email-core-event.h" +#include "email-core-account.h" +#include "email-core-event.h" #include "email-core-utils.h" #include "email-utilities.h" #include "email-convert.h" @@ -56,31 +57,31 @@ static int emdaemon_refresh_account_reference() static int emdaemon_check_filter_id(int account_id, int filter_id, int* err_code) { EM_DEBUG_FUNC_BEGIN("account_id[%d], filter_id[%d], err_code[%p]", account_id, filter_id, err_code); - + if (account_id != ALL_ACCOUNT) { /* only global rule supported. */ EM_DEBUG_EXCEPTION(" account_id[%d], filter_id[%d]", account_id, filter_id); - + if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - + int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_rule_tbl_t* filter = NULL; - + if (!emstorage_get_rule_by_id(account_id, filter_id, &filter, true, &err)) { EM_DEBUG_EXCEPTION(" emstorage_get_rule_by_id failed [%d]", err); - + goto FINISH_OFF; } - + ret = true; - + FINISH_OFF: if (filter != NULL) emstorage_free_rule(&filter, 1, NULL); - + if (err_code != NULL) *err_code = err; EM_DEBUG_FUNC_END(); @@ -88,32 +89,23 @@ FINISH_OFF: } -INTERNAL_FUNC int emdaemon_create_account(emf_account_t* account, int* err_code) +INTERNAL_FUNC int emdaemon_create_account(email_account_t* account, int* err_code) { int ret = false; - int err = EMF_ERROR_NONE; - - switch (account->account_bind_type) { - case EMF_BIND_TYPE_DISABLE: - case EMF_BIND_TYPE_EM_CORE: - if (!emcore_create_account(account, &err)) { - EM_DEBUG_EXCEPTION(" emcore_account_add failed [%d]", err); - goto FINISH_OFF; - } - emdaemon_refresh_account_reference(); - break; - default: - EM_DEBUG_EXCEPTION(" unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; - goto FINISH_OFF; + int err = EMAIL_ERROR_NONE; + + if (!emcore_create_account(account, &err)) { + EM_DEBUG_EXCEPTION(" emcore_account_add failed [%d]", err); + goto FINISH_OFF; } - - ret = true; + emdaemon_refresh_account_reference(); + + ret = true; FINISH_OFF: if (err_code) *err_code = err; EM_DEBUG_FUNC_END(); - return ret; + return ret; } @@ -121,56 +113,85 @@ INTERNAL_FUNC int emdaemon_delete_account(int account_id, int* err_code) { EM_DEBUG_FUNC_BEGIN(); int ret; - - ret = emcore_delete_account_(account_id, err_code); + + ret = emcore_delete_account(account_id, err_code); EM_DEBUG_FUNC_END(); return ret; } - - + +static email_account_t* duplicate_account(email_account_t *src) +{ + if(!src) { + EM_DEBUG_EXCEPTION("INVALID_PARAM"); + return NULL; + } + email_account_t *dst = (email_account_t *)em_malloc(sizeof(email_account_t)); + if (!dst) { + EM_DEBUG_EXCEPTION(" malloc failed..."); + return NULL; + } + + /* Need deep copy */ + memcpy(dst, src, sizeof(email_account_t)); + dst->account_name = EM_SAFE_STRDUP(src->account_name); + dst->incoming_server_address = EM_SAFE_STRDUP(src->incoming_server_address); + dst->user_email_address = EM_SAFE_STRDUP(src->user_email_address); + dst->incoming_server_user_name = EM_SAFE_STRDUP(src->user_email_address); + dst->incoming_server_password = EM_SAFE_STRDUP(src->incoming_server_password); + dst->outgoing_server_address = EM_SAFE_STRDUP(src->incoming_server_password); + dst->outgoing_server_user_name = EM_SAFE_STRDUP(src->outgoing_server_user_name); + dst->outgoing_server_password = EM_SAFE_STRDUP(src->outgoing_server_password); + dst->user_display_name = EM_SAFE_STRDUP(src->user_display_name); + 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->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); + if( !dst->user_data ) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + return NULL; + } + + memcpy(dst->user_data, src->user_data, src->user_data_length); + + return dst; +} + INTERNAL_FUNC int emdaemon_validate_account(int account_id, unsigned* handle, int* err_code) { EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%p], err_code[%p]", account_id, handle, err_code); - + int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (account_id < 1) { EM_DEBUG_EXCEPTION(" account_id[%d]", account_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - emf_event_t event_data = {0}; - emf_account_t* ref_account = NULL; - + email_event_t event_data = {0}; + email_account_t* ref_account = NULL; + if (!(ref_account = emdaemon_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION(" emdaemon_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - event_data.type = EMF_EVENT_VALIDATE_ACCOUNT; - event_data.event_param_data_1 = NULL; - event_data.event_param_data_3 = NULL; - event_data.account_id = account_id; - - if (!emcore_insert_event(&event_data, (int*)handle, &err)) { - EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err); - goto FINISH_OFF; - } - break; - - default: - EM_DEBUG_EXCEPTION(" unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; - 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; + + if (!emcore_insert_event(&event_data, (int*)handle, &err)) { + EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err); } ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -179,34 +200,26 @@ FINISH_OFF: } -INTERNAL_FUNC int emdaemon_validate_account_and_create(emf_account_t* new_account, unsigned* handle, int* err_code) +INTERNAL_FUNC int emdaemon_validate_account_and_create(email_account_t* new_account, unsigned* handle, int* err_code) { EM_DEBUG_FUNC_BEGIN("account[%p], handle[%p], err_code[%p]", new_account, handle, err_code); - + int ret = false; - int err = EMF_ERROR_NONE; - emf_event_t event_data = {0}; - - switch (new_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - event_data.type = EMF_EVENT_VALIDATE_AND_CREATE_ACCOUNT; - event_data.event_param_data_1 = NULL; - event_data.event_param_data_3 = NULL; - event_data.account_id = NEW_ACCOUNT_ID; - - if (!emcore_insert_event(&event_data, (int*)handle, &err)) { - EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err); - goto FINISH_OFF; - } - break; - default: - EM_DEBUG_EXCEPTION(" unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; + int err = EMAIL_ERROR_NONE; + email_event_t event_data = {0}; + + 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; + + if (!emcore_insert_event(&event_data, (int*)handle, &err)) { + EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err); goto FINISH_OFF; } - + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -215,24 +228,31 @@ FINISH_OFF: } -INTERNAL_FUNC int emdaemon_update_account(int account_id, emf_account_t* new_account, int* err_code) +INTERNAL_FUNC int emdaemon_update_account(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); - + /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_account_tbl_t *new_account_tbl = NULL; - + email_account_t old_account_info = {0}; + if ((account_id <= 0) || !new_account) { EM_DEBUG_EXCEPTION("Invalid Parameters."); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - EM_DEBUG_LOG("new_account->email_addr[%s]", new_account->email_addr); - if(new_account->email_addr) { - if (!em_verify_email_address(new_account->email_addr, true, &err)) { - err = EMF_ERROR_INVALID_ADDRESS; + + if(!emdaemon_get_account(account_id, GET_FULL_DATA, &old_account_info, &err)) { + EM_DEBUG_EXCEPTION("emdaemon_get_account failed "); + goto FINISH_OFF; + } + + EM_DEBUG_LOG("new_account->email_addr[%s]", new_account->user_email_address); + if(new_account->user_email_address) { + if (!em_verify_email_address(new_account->user_email_address, true, &err)) { + err = EMAIL_ERROR_INVALID_ADDRESS; EM_DEBUG_EXCEPTION("Invalid Email Address"); goto FINISH_OFF; } @@ -245,82 +265,119 @@ INTERNAL_FUNC int emdaemon_update_account(int account_id, emf_account_t* new_acc } em_convert_account_to_account_tbl(new_account, new_account_tbl); - + if (!emstorage_update_account(account_id, new_account_tbl, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_update_account falied [%d]", err); goto FINISH_OFF; } - + emdaemon_refresh_account_reference(); - + +#ifdef __FEATURE_AUTO_POLLING__ + int old_check_interval = old_account_info.check_interval; + if( old_check_interval < 0 && new_account->check_interval > 0) { + if(!emdaemon_add_polling_alarm(account_id, new_account->check_interval)) + EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm[ CHANGEACCOUNT] : start auto poll failed >>> "); + + } + else if( (old_check_interval > 0) && (new_account->check_interval < 0)) { + if(!emdaemon_remove_polling_alarm(account_id)) + EM_DEBUG_EXCEPTION("emdaemon_remove_polling_alarm[ CHANGEACCOUNT] : start auto poll failed >>> "); + } + else if(old_check_interval != new_account->check_interval && new_account->check_interval > 0) { + if(!emdaemon_remove_polling_alarm(account_id)) { + EM_DEBUG_EXCEPTION("emdaemon_remove_polling_alarm[ CHANGEACCOUNT] : start auto poll failed >>> "); + goto FINISH_OFF; + } + if(!emdaemon_add_polling_alarm(account_id, new_account->check_interval)) + EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm[ CHANGEACCOUNT] : start auto poll failed >>> "); + } +#endif + ret = true; - + FINISH_OFF: + + emcore_free_account(&old_account_info); + if(new_account_tbl) emstorage_free_account(&new_account_tbl, 1, NULL); + if (err_code) *err_code = err; + EM_DEBUG_FUNC_END(); return ret; } -INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, emf_account_t* new_account_info, unsigned* handle,int *err_code) +INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email_account_t* new_account_info, unsigned* 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); - - int ret = false; - int err = EMF_ERROR_NONE; - emf_event_t event_data = {0}; - - switch (new_account_info->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - event_data.type = EMF_EVENT_VALIDATE_AND_UPDATE_ACCOUNT; - event_data.event_param_data_3 = NULL; - event_data.account_id = old_account_id; - - emf_account_t *pAccount = (emf_account_t *)malloc(sizeof(emf_account_t)); - if (pAccount == NULL) { - EM_DEBUG_EXCEPTION(" malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - memcpy(pAccount, new_account_info, sizeof(emf_account_t)); - event_data.event_param_data_1 = (char *) pAccount; - - if (!emcore_insert_event(&event_data, (int*)handle, &err)) { - EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err); - goto FINISH_OFF; - } - break; - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; + int ret = false; + int err = EMAIL_ERROR_NONE; + email_event_t event_data = {0}; + + event_data.type = EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT; + 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; + +#if 0 + email_account_t *pAccount = (email_account_t *)em_malloc(sizeof(email_account_t)); + if (pAccount == NULL) { + EM_DEBUG_EXCEPTION(" malloc failed..."); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + /* Need deep copy */ + memcpy(pAccount, new_account_info, sizeof(email_account_t)); + pAccount->account_name = EM_SAFE_STRDUP(new_account_info->account_name); + pAccount->incoming_server_address = EM_SAFE_STRDUP(new_account_info->incoming_server_address); + pAccount->user_email_address = EM_SAFE_STRDUP(new_account_info->user_email_address); + pAccount->incoming_server_user_name = EM_SAFE_STRDUP(new_account_info->user_email_address); + pAccount->incoming_server_password = EM_SAFE_STRDUP(new_account_info->incoming_server_password); + pAccount->outgoing_server_address = EM_SAFE_STRDUP(new_account_info->incoming_server_password); + pAccount->outgoing_server_user_name = EM_SAFE_STRDUP(new_account_info->outgoing_server_user_name); + pAccount->outgoing_server_password = EM_SAFE_STRDUP(new_account_info->outgoing_server_password); + pAccount->user_display_name = EM_SAFE_STRDUP(new_account_info->user_display_name); + pAccount->reply_to_address = EM_SAFE_STRDUP(new_account_info->reply_to_address); + pAccount->return_address = EM_SAFE_STRDUP(new_account_info->return_address); + pAccount->logo_icon_path = EM_SAFE_STRDUP(new_account_info->logo_icon_path); + pAccount->certificate_path = EM_SAFE_STRDUP(new_account_info->certificate_path); + pAccount->options.display_name_from = EM_SAFE_STRDUP(new_account_info->options.display_name_from); + pAccount->options.signature = EM_SAFE_STRDUP(new_account_info->options.signature); + memcpy(pAccount->user_data, new_account_info->user_data, new_account_info->user_data_length); +#endif + + if (!emcore_insert_event(&event_data, (int*)handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err); goto FINISH_OFF; } - + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; EM_DEBUG_FUNC_END(); - return ret; + return ret; } -INTERNAL_FUNC int emdaemon_get_account(int account_id, int pulloption, emf_account_t** account, int* err_code) +INTERNAL_FUNC int emdaemon_get_account(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); - + /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_account_tbl_t *account_tbl = NULL; - + if (!account) { EM_DEBUG_EXCEPTION("account_id[%d], account[%p]", account_id, account); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -329,15 +386,10 @@ INTERNAL_FUNC int emdaemon_get_account(int account_id, int pulloption, emf_accou goto FINISH_OFF; } - *account = em_malloc(sizeof(emf_account_t)); - if(!*account) { - EM_DEBUG_EXCEPTION("allocation failed [%d]", err); - goto FINISH_OFF; - } - em_convert_account_tbl_to_account(account_tbl, *account); - + em_convert_account_tbl_to_account(account_tbl, account); + ret = true; - + FINISH_OFF: if(account_tbl) emstorage_free_account(&account_tbl, 1, NULL); @@ -347,28 +399,28 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_get_account_list(emf_account_t** account_list, int* count, int* err_code) +INTERNAL_FUNC int emdaemon_get_account_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 ret = false, err = EMF_ERROR_NONE, i = 0; + + int ret = false, err = EMAIL_ERROR_NONE, i = 0; emstorage_account_tbl_t *account_tbl_array = NULL; - + if (!account_list || !count) { EM_DEBUG_EXCEPTION("account_list[%p], count[%p]", account_list, (*count)); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - + *count = 1000; - + 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; } if(account_tbl_array && (*count) > 0) { - *account_list = (emf_account_t*)em_malloc(sizeof(emf_account_t) * (*count)); + *account_list = (email_account_t*)em_malloc(sizeof(email_account_t) * (*count)); if(!*account_list) { EM_DEBUG_EXCEPTION("allocation failed [%d]", err); goto FINISH_OFF; @@ -383,7 +435,7 @@ INTERNAL_FUNC int emdaemon_get_account_list(emf_account_t** account_list, int* c FINISH_OFF: if(account_tbl_array) emstorage_free_account(&account_tbl_array, (*count), NULL); - + if (err_code != NULL) *err_code = err; EM_DEBUG_FUNC_END("ret [%d]", ret); @@ -391,36 +443,36 @@ FINISH_OFF: } -INTERNAL_FUNC int emdaemon_free_account(emf_account_t** account_list, int count, int* err_code) +INTERNAL_FUNC int emdaemon_free_account(email_account_t** account_list, int count, int* err_code) { EM_DEBUG_FUNC_BEGIN(); - return emcore_free_account(account_list, count, err_code); + return emcore_free_account_list(account_list, count, err_code); } -INTERNAL_FUNC int emdaemon_get_filter(int filter_id, emf_rule_t** filter_info, int* err_code) +INTERNAL_FUNC int emdaemon_get_filter(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); - + if (!filter_info) { EM_DEBUG_EXCEPTION("filter_id[%d], filter_info[%p]", filter_id, filter_info); - + if (err_code != NULL) - *err_code = EMF_ERROR_INVALID_PARAM; + *err_code = EMAIL_ERROR_INVALID_PARAM; return false; } - + /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; - + int err = EMAIL_ERROR_NONE; + if (!emstorage_get_rule_by_id(ALL_ACCOUNT, filter_id, (emstorage_rule_tbl_t**)filter_info, true, &err)) { EM_DEBUG_EXCEPTION(" emstorage_get_rule_by_id failed [%d]", err); goto FINISH_OFF; } - + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -428,30 +480,30 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_get_filter_list(emf_rule_t** filter_info, int* count, int* err_code) +INTERNAL_FUNC int emdaemon_get_filter_list(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); - + /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int is_completed; - + if (!filter_info || !count) { EM_DEBUG_EXCEPTION(" filter_info[%p], count[%p]", filter_info, count); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - + *count = 1000; - + if (!emstorage_get_rule(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; } - + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -459,36 +511,36 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_find_filter(emf_rule_t* filter_info, int* err_code) +INTERNAL_FUNC int emdaemon_find_filter(email_rule_t* filter_info, int* err_code) { EM_DEBUG_FUNC_BEGIN("filter_info[%p], err_code[%p]", filter_info, err_code); - + /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!filter_info) { EM_DEBUG_EXCEPTION(" filter_info[%p]", filter_info); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (filter_info->faction == EMF_FILTER_MOVE && !filter_info->mailbox) { - EM_DEBUG_EXCEPTION(" filter_info->faction[%d], filter_info->mailbox[%p]", filter_info->faction, filter_info->mailbox); - err = EMF_ERROR_INVALID_FILTER; + if (filter_info->faction == EMAIL_FILTER_MOVE && !filter_info->target_mailbox_id) { + EM_DEBUG_EXCEPTION(" filter_info->faction[%d], filter_info->target_mailbox_id[%d]", filter_info->faction, filter_info->target_mailbox_id); + err = EMAIL_ERROR_INVALID_FILTER; goto FINISH_OFF; } filter_info->account_id = ALL_ACCOUNT; /* MUST BE */ - + if (!emstorage_find_rule((emstorage_rule_tbl_t*)filter_info, true, &err)) { EM_DEBUG_EXCEPTION(" emstorage_find_rule failed [%d]", err); - err = EMF_ERROR_FILTER_NOT_FOUND; + err = EMAIL_ERROR_FILTER_NOT_FOUND; goto FINISH_OFF; } - + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -496,52 +548,52 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_add_filter(emf_rule_t* filter_info, int* err_code) +INTERNAL_FUNC int emdaemon_add_filter(email_rule_t* filter_info, int* err_code) { EM_DEBUG_FUNC_BEGIN("filter_info[%p], err_code[%p]", filter_info, err_code); - + /* default variable */ - int ret = false, err = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; if (!filter_info || !(filter_info->value)) { EM_DEBUG_EXCEPTION("filter_info[%p]", filter_info); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - + /* - if (filter_info->faction != EMF_FILTER_BLOCK) { + if (filter_info->faction != EMAIL_FILTER_BLOCK) { EM_DEBUG_EXCEPTION("filter_info->faction[%d] is not supported", filter_info->faction); - err = EMF_ERROR_NOT_SUPPORTED; + err = EMAIL_ERROR_NOT_SUPPORTED; goto FINISH_OFF; } - - if (filter_info->faction == EMF_FILTER_MOVE && !filter_info->mailbox) { + + if (filter_info->faction == EMAIL_FILTER_MOVE && !filter_info->mailbox) { EM_DEBUG_EXCEPTION("filter_info->faction[%d], filter_info->mailbox[%p]", filter_info->faction, filter_info->mailbox); - err = EMF_ERROR_INVALID_FILTER; + err = EMAIL_ERROR_INVALID_FILTER; goto FINISH_OFF; } */ - + filter_info->account_id = ALL_ACCOUNT; - + if (emstorage_find_rule((emstorage_rule_tbl_t*)filter_info, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_find_rule failed [%d]", err); - err = EMF_ERROR_ALREADY_EXISTS; + err = EMAIL_ERROR_ALREADY_EXISTS; goto FINISH_OFF; } - + if (!emstorage_add_rule((emstorage_rule_tbl_t*)filter_info, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_add_rule failed [%d]", err); goto FINISH_OFF; } - if (!emcore_mail_filter_by_rule((emf_rule_t*)filter_info, &err)) { + if (!emcore_mail_filter_by_rule((email_rule_t*)filter_info, &err)) { EM_DEBUG_EXCEPTION("emcore_mail_filter_by_rule failed [%d]", err); goto FINISH_OFF; } ret = true; - + FINISH_OFF: if (err_code) @@ -550,32 +602,32 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_update_filter(int filter_id, emf_rule_t* filter_info, int* err_code) +INTERNAL_FUNC int emdaemon_update_filter(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); - + /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; - + int err = EMAIL_ERROR_NONE; + if ((filter_id <= 0) || !filter_info) { EM_DEBUG_EXCEPTION("filter_id[%d], filter_info[%p]", filter_id, filter_info); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - + if (!emdaemon_check_filter_id(ALL_ACCOUNT, filter_id, &err)) { EM_DEBUG_EXCEPTION("emdaemon_check_filter_id falied [%d]", err); goto FINISH_OFF; } - + if (!emstorage_change_rule(ALL_ACCOUNT, filter_id, (emstorage_rule_tbl_t*)filter_info, true, &err)) { EM_DEBUG_EXCEPTION("emstorage_change_rule falied [%d]", err); goto FINISH_OFF; } - + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -586,29 +638,29 @@ FINISH_OFF: INTERNAL_FUNC int emdaemon_delete_filter(int filter_id, int* err_code) { EM_DEBUG_FUNC_BEGIN("filter_id[%d, err_code[%p]", filter_id, err_code); - + /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; - + int err = EMAIL_ERROR_NONE; + if (filter_id <= 0) { EM_DEBUG_EXCEPTION(" fliter_id[%d]", filter_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - + if (!emdaemon_check_filter_id(ALL_ACCOUNT, filter_id, &err)) { EM_DEBUG_EXCEPTION(" emdaemon_check_filter_id failed [%d]", err); goto FINISH_OFF; } - + if (!emstorage_delete_rule(ALL_ACCOUNT, filter_id, true, &err)) { EM_DEBUG_EXCEPTION(" emstorage_delete_rule failed [%d]", err); goto FINISH_OFF; } ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -616,32 +668,31 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_free_filter(emf_rule_t** filter_info, int count, int* err_code) +INTERNAL_FUNC int emdaemon_free_filter(email_rule_t** filter_info, int count, int* err_code) { EM_DEBUG_FUNC_BEGIN("filter_info[%p], count[%d], err_code[%p]", filter_info, count, err_code); - + /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; - + int err = EMAIL_ERROR_NONE; + if (count > 0) { if (!filter_info || !*filter_info) { EM_DEBUG_EXCEPTION(" filter_info[%p], count[%d]", filter_info, count); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - - emf_rule_t* p = *filter_info; + + email_rule_t* p = *filter_info; int i; - + for (i = 0; i < count; i++) { EM_SAFE_FREE(p[i].value); - EM_SAFE_FREE(p[i].mailbox); } - + EM_SAFE_FREE(p); *filter_info = NULL; } - + ret = true; FINISH_OFF: @@ -656,10 +707,33 @@ FINISH_OFF: int emdaemon_initialize_account_reference() { EM_DEBUG_FUNC_BEGIN(); - return emcore_init_account_reference(); + int err = EMAIL_ERROR_NONE; + + if ((err = emcore_init_account_reference()) != EMAIL_ERROR_NONE) { + if (err == EMAIL_ERROR_SECURED_STORAGE_FAILURE) { + 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 { + EM_DEBUG_EXCEPTION("emcore_init_account_reference failed [%d]", err); + goto FINISH_OFF; + } + } + +FINISH_OFF: + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; } -emf_account_t* emdaemon_get_account_reference(int account_id) +email_account_t* emdaemon_get_account_reference(int account_id) { EM_DEBUG_FUNC_BEGIN(); return emcore_get_account_reference(account_id); @@ -671,7 +745,7 @@ int emdaemon_free_account_reference() return emcore_free_account_reference(); } -INTERNAL_FUNC int emdaemon_insert_accountinfo_to_contact(emf_account_t* account) +INTERNAL_FUNC int emdaemon_insert_accountinfo_to_contact(email_account_t* account) { EM_DEBUG_FUNC_BEGIN(); @@ -683,7 +757,7 @@ INTERNAL_FUNC int emdaemon_insert_accountinfo_to_contact(emf_account_t* account) return ret; } -INTERNAL_FUNC int emdaemon_update_accountinfo_to_contact(emf_account_t* old_account, emf_account_t* new_account) +INTERNAL_FUNC int emdaemon_update_accountinfo_to_contact(email_account_t* old_account, email_account_t* new_account) { EM_DEBUG_FUNC_BEGIN(); diff --git a/email-daemon/email-daemon-auto-poll.c b/email-daemon/email-daemon-auto-poll.c index 0d8de32..28872b1 100755 --- a/email-daemon/email-daemon-auto-poll.c +++ b/email-daemon/email-daemon-auto-poll.c @@ -44,23 +44,23 @@ typedef struct _emf_account_alarm_binder int account_id; alarm_id_t alarm_id; int timer_interval; -} emf_account_alarm_binder; +} email_account_alarm_binder; /* global list */ typedef struct _emf_account_alarm_binder_list_t { - emf_account_alarm_binder account_alarm_binder; + email_account_alarm_binder account_alarm_binder; struct _emf_account_alarm_binder_list_t *next; -}emf_account_alarm_binder_list_t; +}email_account_alarm_binder_list_t; /* sowmya.kr@samsung.com, 23022010, Implementation of auto-polling feature */ -emf_account_alarm_binder_list_t *g_account_alarm_binder_list = NULL; +email_account_alarm_binder_list_t *g_account_alarm_binder_list = NULL; static int _emdaemon_get_polling_alarm_and_timerinterval(int account_id, alarm_id_t *alarm_id, int *timer_interval); static int _emdaemon_get_polling_account_and_timeinterval(alarm_id_t alarm_id, int *account_id, int *timer_interval); static int _emdaemon_create_alarm(int alarm_interval, alarm_id_t *p_alarm_id); -static int _emdaemon_add_to_account_alarm_binder_list(emf_account_alarm_binder_list_t *p_account_alarm_binder); +static int _emdaemon_add_to_account_alarm_binder_list(email_account_alarm_binder_list_t *p_account_alarm_binder); static int _emdaemon_remove_from_account_alarm_binder_list(int account_id); static int _emdaemon_update_account_alarm_binder_list(int account_id, alarm_id_t alarm_id); @@ -79,14 +79,14 @@ INTERNAL_FUNC int emdaemon_add_polling_alarm(int account_id, int alarm_interval) } alarm_id_t alarmID = 0; - emf_account_alarm_binder_list_t *p_account_alarm_binder = NULL; + email_account_alarm_binder_list_t *p_account_alarm_binder = NULL; if(!_emdaemon_create_alarm(alarm_interval, &alarmID)) { EM_DEBUG_EXCEPTION("_emdaemon_create_alarm failed"); return false; } - p_account_alarm_binder = (emf_account_alarm_binder_list_t*)em_malloc(sizeof(emf_account_alarm_binder_list_t)); + p_account_alarm_binder = (email_account_alarm_binder_list_t*)em_malloc(sizeof(email_account_alarm_binder_list_t)); if(!p_account_alarm_binder) { EM_DEBUG_EXCEPTION("malloc Failed "); return false; @@ -147,7 +147,7 @@ INTERNAL_FUNC int emdaemon_check_auto_polling_started(int account_id) return false; } - emf_account_alarm_binder_list_t *p_temp = g_account_alarm_binder_list; + email_account_alarm_binder_list_t *p_temp = g_account_alarm_binder_list; int match_found = false; while(p_temp != NULL) { @@ -180,12 +180,12 @@ INTERNAL_FUNC int emdaemon_alarm_polling_cb(alarm_id_t alarm_id, void* user_par } - emf_mailbox_t mailbox = {0}; - int account_id = 0, err = EMF_ERROR_NONE, timer_interval =0, alarmID =0,ret = false; + email_mailbox_t mailbox = {0}; + int account_id = 0, err = EMAIL_ERROR_NONE, timer_interval =0, alarmID =0,ret = false; char* mailbox_name = NULL; if(!_emdaemon_get_polling_account_and_timeinterval(alarm_id,&account_id,&timer_interval)) { - EM_DEBUG_EXCEPTION("emf_get_polling_account failed"); + EM_DEBUG_EXCEPTION("email_get_polling_account failed"); return false; } @@ -203,18 +203,18 @@ INTERNAL_FUNC int emdaemon_alarm_polling_cb(alarm_id_t alarm_id, void* user_par return false; } - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); + memset(&mailbox, 0x00, sizeof(email_mailbox_t)); mailbox.account_id = account_id; - if (!emstorage_get_mailboxname_by_mailbox_type(mailbox.account_id,EMF_MAILBOX_TYPE_INBOX,&mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); + if (!emstorage_get_mailbox_name_by_mailbox_type(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; } - mailbox.name = mailbox_name; + mailbox.mailbox_name = mailbox_name; - if (!emdaemon_sync_header(&mailbox, NULL, &err)) { + if (!emdaemon_sync_header(account_id, mailbox.mailbox_id, NULL, &err)) { EM_DEBUG_EXCEPTION("emdaemon_sync_header falied [%d]", err); goto FINISH_OFF; } @@ -238,7 +238,7 @@ static int _emdaemon_get_polling_alarm_and_timerinterval(int account_id, alarm_i return false; } - emf_account_alarm_binder_list_t *p_temp = g_account_alarm_binder_list; + email_account_alarm_binder_list_t *p_temp = g_account_alarm_binder_list; int match_found = false; while(p_temp != NULL) { @@ -277,7 +277,7 @@ static int _emdaemon_get_polling_account_and_timeinterval(alarm_id_t alarm_id, return false; } - emf_account_alarm_binder_list_t *p_temp = g_account_alarm_binder_list; + email_account_alarm_binder_list_t *p_temp = g_account_alarm_binder_list; int match_found = false; while(p_temp != NULL) { @@ -303,7 +303,7 @@ static int _emdaemon_get_polling_account_and_timeinterval(alarm_id_t alarm_id, return true; } -#define AUTO_POLL_DESTINATION "com.samsung.email-service" +#define AUTO_POLL_DESTINATION "org.tizen.email-service" static int _emdaemon_create_alarm(int alarm_interval, alarm_id_t *p_alarm_id) { EM_DEBUG_FUNC_BEGIN(); @@ -363,7 +363,7 @@ INTERNAL_FUNC int emdaemon_free_account_alarm_binder_list() { EM_DEBUG_FUNC_BEGIN(); - emf_account_alarm_binder_list_t *p = g_account_alarm_binder_list, *p_next = NULL; + email_account_alarm_binder_list_t *p = g_account_alarm_binder_list, *p_next = NULL; int a_nErrorCode = 0; /* delete alarm as well */ @@ -383,9 +383,9 @@ INTERNAL_FUNC int emdaemon_free_account_alarm_binder_list() return true; } -static int _emdaemon_add_to_account_alarm_binder_list(emf_account_alarm_binder_list_t *p_account_alarm_binder) +static int _emdaemon_add_to_account_alarm_binder_list(email_account_alarm_binder_list_t *p_account_alarm_binder) { - emf_account_alarm_binder_list_t *p_temp = NULL; + email_account_alarm_binder_list_t *p_temp = NULL; if(!p_account_alarm_binder) { EM_DEBUG_EXCEPTION("Invalid param "); @@ -410,7 +410,7 @@ static int _emdaemon_add_to_account_alarm_binder_list(emf_account_alarm_binder_ static int _emdaemon_remove_from_account_alarm_binder_list(int account_id) { - emf_account_alarm_binder_list_t *p_temp = g_account_alarm_binder_list, *p_prev = NULL; + email_account_alarm_binder_list_t *p_temp = g_account_alarm_binder_list, *p_prev = NULL; int match_found = false; if(!account_id) { @@ -450,7 +450,7 @@ static int _emdaemon_remove_from_account_alarm_binder_list(int account_id) static int _emdaemon_update_account_alarm_binder_list(int account_id, alarm_id_t alarm_id) { - emf_account_alarm_binder_list_t *p_temp = g_account_alarm_binder_list; + email_account_alarm_binder_list_t *p_temp = g_account_alarm_binder_list; int match_found = false; if( !account_id || !alarm_id) { diff --git a/email-daemon/email-daemon-emn.c b/email-daemon/email-daemon-emn.c index 940ad51..6d69593 100755 --- a/email-daemon/email-daemon-emn.c +++ b/email-daemon/email-daemon-emn.c @@ -43,9 +43,9 @@ typedef struct { int account_id; - emf_emn_noti_cb callback; + email_emn_noti_cb callback; void* user_data; -} emf_emn_noti_pack_t; +} email_emn_noti_pack_t; /* Parse the Email address to Get the user Name for the account [deepam.p@samsung.com] */ @@ -162,7 +162,7 @@ static void _cb_parser_characters(void* ctx, WB_UTINY* ch, WB_ULONG start, WB_UL static int _get_addr_from_element(unsigned char* elm, int* type, - unsigned char** user_name, + unsigned char** incoming_server_user_name, unsigned char** host_addr, unsigned char** mbox_name, unsigned char** auth_type) @@ -171,7 +171,7 @@ static int _get_addr_from_element(unsigned char* elm, unsigned char* s; unsigned char* user = NULL; unsigned char* host = NULL; - unsigned char* mbox = NULL; + unsigned char* mailbox = NULL; unsigned char* auth = NULL; EM_DEBUG_FUNC_BEGIN(); @@ -198,7 +198,7 @@ static int _get_addr_from_element(unsigned char* elm, user = (unsigned char*)EM_SAFE_STRDUP((char *)p); s++; host = (unsigned char*)EM_SAFE_STRDUP((char *)s); - mbox = NULL; + mailbox = NULL; auth = NULL; break; @@ -229,7 +229,7 @@ static int _get_addr_from_element(unsigned char* elm, EM_DEBUG_LOG("PORT:%s\n", s); } host = (unsigned char*)EM_SAFE_STRDUP((char *)p); - mbox = NULL; + mailbox = NULL; break; case 'i':/* imap (RFC2192) */ @@ -262,7 +262,7 @@ static int _get_addr_from_element(unsigned char* elm, else s = p + strlen((char *)p); if (*(s - 1) == '/') *(s - 1) = '\0'; - if (strlen((char *)p)) mbox =(unsigned char*) EM_SAFE_STRDUP((char *)p); + if (strlen((char *)p)) mailbox =(unsigned char*) EM_SAFE_STRDUP((char *)p); break; case 'h': /* not supported */ @@ -273,9 +273,9 @@ static int _get_addr_from_element(unsigned char* elm, return 0; } - *user_name = user; + *incoming_server_user_name = user; *host_addr = host; - *mbox_name = mbox; + *mbox_name = mailbox; *auth_type = auth; return 1; @@ -321,7 +321,7 @@ static int _get_time_from_element(unsigned char* elm, /* */ static int _get_data_from_element(unsigned char* elm, int* type, - unsigned char** user_name, + unsigned char** incoming_server_user_name, unsigned char** host_addr, unsigned char** mbox_name, unsigned char** auth_type, @@ -335,7 +335,7 @@ static int _get_data_from_element(unsigned char* elm, } /* must call get_addr_from_element after calling _get_time_from_element */ - if (!_get_addr_from_element(elm, type, user_name, host_addr, mbox_name, auth_type)) + if (!_get_addr_from_element(elm, type, incoming_server_user_name, host_addr, mbox_name, auth_type)) { EM_SAFE_FREE*time_stamp) /* added acetrack.20080331.K8.4046 */ return 0; @@ -357,7 +357,7 @@ static int _get_data_from_element(unsigned char* elm, * succeed : 1 * fail : 0 */ -static int _get_emn_account(unsigned char* wbxml_b64, emf_account_t* account, char** mailbox, int* err_code) +static int _get_emn_account(unsigned char* wbxml_b64, email_account_t* account, char** mailbox, int* err_code) { EM_DEBUG_LOG("_get_emn_account Enter"); WBXMLContentHandler parse_handler = { @@ -375,8 +375,8 @@ static int _get_emn_account(unsigned char* wbxml_b64, emf_account_t* account, ch WB_ULONG wbxml_len = 0; WB_ULONG err_idx = 0; WBXMLError ret = WBXML_OK; - emf_account_t* accounts = NULL; - unsigned char* user_name = NULL; + email_account_t* accounts = NULL; + unsigned char* incoming_server_user_name = NULL; unsigned char* host_addr = NULL; unsigned char* mbox_name = NULL; unsigned char* auth_type = NULL; @@ -385,14 +385,14 @@ static int _get_emn_account(unsigned char* wbxml_b64, emf_account_t* account, ch int i = 0; int count = 0; int retr = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; EM_DEBUG_LOG(""); if (!wbxml_b64 || !account) { EM_DEBUG_EXCEPTION(">>>> Invalid Parameter >>>> \n"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -403,7 +403,7 @@ static int _get_emn_account(unsigned char* wbxml_b64, emf_account_t* account, ch /* create wbxml parser */ if (!(wbxml_parser = wbxml_parser_create())) { - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -417,7 +417,7 @@ static int _get_emn_account(unsigned char* wbxml_b64, emf_account_t* account, ch err_idx = wbxml_parser_get_current_byte_index(wbxml_parser); EM_DEBUG_LOG("Parsing failed at %u - Token %x - %s", err_idx, wbxml[err_idx], wbxml_errors_string(ret)); - err = EMF_ERROR_XML_PARSER_FAILURE; + err = EMAIL_ERROR_XML_PARSER_FAILURE; goto FINISH_OFF; } else @@ -437,17 +437,17 @@ static int _get_emn_account(unsigned char* wbxml_b64, emf_account_t* account, ch { EM_DEBUG_EXCEPTION("invalid elements\n"); - err = EMF_ERROR_XML_PARSER_FAILURE; + err = EMAIL_ERROR_XML_PARSER_FAILURE; goto FINISH_OFF; } EM_DEBUG_LOG("elements = [%s]\n", elm); - _get_data_from_element(elm, &type, &user_name, &host_addr, &mbox_name, &auth_type, &time_stamp); + _get_data_from_element(elm, &type, &incoming_server_user_name, &host_addr, &mbox_name, &auth_type, &time_stamp); EM_SAFE_FREE(elm); EM_DEBUG_LOG("user_type = [%d]\n", type); - EM_DEBUG_LOG("user_name = [%s]\n", (char *)user_name ? (char*)user_name : "NIL"); + EM_DEBUG_LOG("incoming_server_user_name = [%s]\n", (char *)incoming_server_user_name ? (char*)incoming_server_user_name : "NIL"); EM_DEBUG_LOG("host_addr = [%s]\n", (char *)host_addr ? (char*)host_addr : "NIL"); EM_DEBUG_LOG("mbox_name = [%s]\n", (char *)mbox_name ? (char*)mbox_name : "NIL"); EM_DEBUG_LOG("auth_type = [%s]\n", (char *)auth_type ? (char*)auth_type : "NIL"); @@ -456,7 +456,7 @@ static int _get_emn_account(unsigned char* wbxml_b64, emf_account_t* account, ch if (!emdaemon_get_account_list(&accounts, &count, &err)) { EM_DEBUG_EXCEPTION(" emdaemon_get_account_list error"); - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; } @@ -465,24 +465,24 @@ static int _get_emn_account(unsigned char* wbxml_b64, emf_account_t* account, ch /* sowmya.kr, 201009, Fix for EMN */ char* temp_account_name = NULL; char *s = NULL; - /* EM_DEBUG_LOG(">>>> Account Information UserName [ %s ] Email Addr [ %s], Account ID [ %d] >>> \n",accounts[i].user_name,accounts[i].email_addr, accounts[i].account_id); */ - temp_account_name =(char*) EM_SAFE_STRDUP((char *)accounts[i].user_name); + /* EM_DEBUG_LOG(">>>> Account Information UserName [ %s ] Email Addr [ %s], Account ID [ %d] >>> \n",accounts[i].incoming_server_user_name,accounts[i].user_email_address, accounts[i].account_id); */ + temp_account_name =(char*) EM_SAFE_STRDUP((char *)accounts[i].incoming_server_user_name); if ((s = (char*)strchr((char *)temp_account_name, '@'))) { *s = '\0'; - EM_SAFE_FREE(accounts[i].user_name); - accounts[i].user_name = (char*)EM_SAFE_STRDUP((char *)temp_account_name); + EM_SAFE_FREE(accounts[i].incoming_server_user_name); + accounts[i].incoming_server_user_name = (char*)EM_SAFE_STRDUP((char *)temp_account_name); } EM_SAFE_FREE(temp_account_name); - if (user_name) { - if (strcmp(accounts[i].user_name, (char *)user_name) == 0 && - strstr(accounts[i].email_addr, (char *)host_addr)) { + if (incoming_server_user_name) { + if (strcmp(accounts[i].incoming_server_user_name, (char *)incoming_server_user_name) == 0 && + strstr(accounts[i].user_email_address, (char *)host_addr)) { EM_DEBUG_LOG(">>>> Account Match >>> \n"); if ((type == 1) || - (type == 2 && accounts[i].receiving_server_type == EMF_SERVER_TYPE_POP3) || - (type == 3 && accounts[i].receiving_server_type == EMF_SERVER_TYPE_IMAP4)) { + (type == 2 && accounts[i].incoming_server_type == EMAIL_SERVER_TYPE_POP3) || + (type == 3 && accounts[i].incoming_server_type == EMAIL_SERVER_TYPE_IMAP4)) { accounts[i].flag2 = type; - EM_DEBUG_LOG("found target account id[%d] name[%s]", accounts[i].account_id, accounts[i].user_name); + EM_DEBUG_LOG("found target account id[%d] name[%s]", accounts[i].account_id, accounts[i].incoming_server_user_name); break; } } @@ -491,11 +491,10 @@ static int _get_emn_account(unsigned char* wbxml_b64, emf_account_t* account, ch if (i >= count) { EM_DEBUG_EXCEPTION("no account was found"); - err = EMF_ERROR_ACCOUNT_NOT_FOUND; + err = EMAIL_ERROR_ACCOUNT_NOT_FOUND; goto FINISH_OFF; } if (account) { - account->account_bind_type = accounts[i].account_bind_type; account->account_id = accounts[i].account_id; account->flag2 = accounts[i].flag2; } @@ -515,7 +514,7 @@ FINISH_OFF: if (wbxml_parser) wbxml_parser_destroy(wbxml_parser); EM_SAFE_FREE(elm); if (accounts) emdaemon_free_account(&accounts, count, NULL); - EM_SAFE_FREE(user_name); + EM_SAFE_FREE(incoming_server_user_name); EM_SAFE_FREE(mbox_name); EM_SAFE_FREE(auth_type); EM_SAFE_FREE(time_stamp); @@ -523,28 +522,28 @@ FINISH_OFF: return retr; } -INTERNAL_FUNC int emdaemon_handle_emn_notification(unsigned char* wbxml_b64, emf_emn_noti_cb callback, int* err_code) +INTERNAL_FUNC int emdaemon_handle_emn_notification(unsigned char* wbxml_b64, email_emn_noti_cb callback, int* err_code) { EM_DEBUG_FUNC_BEGIN("wbxml_b64[%p], callback[%p], err_code[%p]", wbxml_b64, callback, err_code); int ret = false; - int err = EMF_ERROR_NONE;; + int err = EMAIL_ERROR_NONE;; char* mailbox_name = NULL; - emf_mailbox_t mailbox = { 0 }; - emf_account_t account = { 0 }; - emf_emn_noti_pack_t* pack = NULL; + email_mailbox_t mailbox = { 0 }; + email_account_t account = { 0 }; + email_emn_noti_pack_t* pack = NULL; char* pmailbox = NULL; if (!wbxml_b64) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - pack = (emf_emn_noti_pack_t*)em_malloc(sizeof(emf_emn_noti_pack_t)); + pack = (email_emn_noti_pack_t*)em_malloc(sizeof(email_emn_noti_pack_t)); if (!pack) { EM_DEBUG_EXCEPTION("em_malloc failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -555,25 +554,25 @@ INTERNAL_FUNC int emdaemon_handle_emn_notification(unsigned char* wbxml_b64, emf mailbox.account_id = account.account_id; - if (!emstorage_get_mailboxname_by_mailbox_type(mailbox.account_id,EMF_MAILBOX_TYPE_INBOX,&pmailbox, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d", err); + if (!emstorage_get_mailbox_name_by_mailbox_type(mailbox.account_id,EMAIL_MAILBOX_TYPE_INBOX,&pmailbox, false, &err)) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d", err); goto FINISH_OFF; } - if ((account.receiving_server_type == EMF_SERVER_TYPE_IMAP4) && (account.flag2 == 3)) { + if ((account.incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) && (account.flag2 == 3)) { if (!mailbox_name || strncmp(pmailbox, mailbox_name, strlen(pmailbox)) != 0) { EM_DEBUG_EXCEPTION("invalid inbox name [%p]", mailbox_name); - err = EMF_ERROR_INVALID_MAILBOX; + err = EMAIL_ERROR_INVALID_MAILBOX; goto FINISH_OFF; } } /* sync header with mail server */ - mailbox.name = mailbox_tbl->mailbox_name; + mailbox.mailbox_name = mailbox_tbl->mailbox_name; - if (!emdaemon_sync_header(&mailbox, NULL, &err)) { + if (!emdaemon_sync_header(mailbox.account_id, mailbox.mailbox_id, NULL, &err)) { EM_DEBUG_EXCEPTION("emdaemon_sync_header falied [%d]", err); goto FINISH_OFF; } diff --git a/email-daemon/email-daemon-etc.c b/email-daemon/email-daemon-etc.c index 351dfc8..d6e6aa9 100755 --- a/email-daemon/email-daemon-etc.c +++ b/email-daemon/email-daemon-etc.c @@ -40,15 +40,16 @@ #include "email-internal-types.h" #include "email-core-event.h" #include "email-core-utils.h" +#include "email-utilities.h" #include "email-storage.h" -int emdaemon_register_event_callback(emf_action_t action, emf_event_callback callback, void* event_data) +int emdaemon_register_event_callback(email_action_t action, email_event_callback callback, void* event_data) { return emcore_register_event_callback(action, callback, event_data); } -int emdaemon_unregister_event_callback(emf_action_t action, emf_event_callback callback) +int emdaemon_unregister_event_callback(email_action_t action, email_event_callback callback) { return emcore_unregister_event_callback(action, callback); } @@ -58,7 +59,7 @@ INTERNAL_FUNC void emdaemon_get_event_queue_status(int* on_sending, int* on_rece emcore_get_event_queue_status(on_sending, on_receiving); } -INTERNAL_FUNC int emdaemon_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t* status) +INTERNAL_FUNC int emdaemon_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t* status) { EM_DEBUG_FUNC_BEGIN("action[%d], account_id[%d], mail_id[%d]", action, account_id, mail_id); @@ -70,7 +71,7 @@ INTERNAL_FUNC int emdaemon_cancel_job(int account_id, int handle, int* err_code) EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%d], err_code[%p]", account_id, handle, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!emcore_cancel_thread(handle, NULL, &err)) { @@ -93,19 +94,19 @@ INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id, EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], err_code[%p]", account_id, mail_id, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int handle = 0; - emf_account_t* ref_account = NULL; + email_account_t* ref_account = NULL; if (account_id <= 0) { EM_DEBUG_EXCEPTION("account_id[%d], mail_id[%d]", account_id, mail_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } #ifdef __FEATURE_PROGRESS_IN_OUTBOX__ - /* h.gahlaut@samsung.com: Moved this code from email_cancel_send_mail API to email-service engine + /* h.gahlaut@samsung.com: Moved this code from email_cancel_sending_mail API to email-service engine since this code has update DB operation which is failing in context of email application process with an sqlite error -> sqlite3_step fail:8 */ @@ -118,14 +119,14 @@ INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id, } if (mail_tbl_data) { - if (mail_tbl_data->save_status == EMF_MAIL_STATUS_SEND_CANCELED) { - EM_DEBUG_EXCEPTION(">>>> EMF_MAIL_STATUS_SEND_CANCELED Already set for Mail ID [ %d ]", mail_id); + if (mail_tbl_data->save_status == EMAIL_MAIL_STATUS_SEND_CANCELED) { + EM_DEBUG_EXCEPTION(">>>> EMAIL_MAIL_STATUS_SEND_CANCELED Already set for Mail ID [ %d ]", mail_id); goto FINISH_OFF; } else { - mail_tbl_data->save_status = EMF_MAIL_STATUS_SEND_CANCELED; + 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", EMF_MAIL_STATUS_SEND_CANCELED, true, &err)) { + 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)) { EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]",err); goto FINISH_OFF; } @@ -136,29 +137,20 @@ INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id, if(!emcore_get_handle_by_mailId_from_transaction_info(mail_id , &handle )) { EM_DEBUG_EXCEPTION("emcore_get_handle_by_mailId_from_transaction_info failed for mail_id[%d]", mail_id); - err = EMF_ERROR_HANDLE_NOT_FOUND; + err = EMAIL_ERROR_HANDLE_NOT_FOUND; goto FINISH_OFF; } if (!(ref_account = emdaemon_get_account_reference(account_id))) { EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE : - if (!emcore_cancel_send_mail_thread(handle, NULL, &err)) { - EM_DEBUG_EXCEPTION("emcore_cancel_send_mail_thread failed [%d]", err); - goto FINISH_OFF; - } - break; - - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; - goto FINISH_OFF; - } + if (!emcore_cancel_send_mail_thread(handle, NULL, &err)) { + EM_DEBUG_EXCEPTION("emcore_cancel_send_mail_thread failed [%d]", err); + goto FINISH_OFF; + } if(!emcore_delete_transaction_info_by_mailId(mail_id)) EM_DEBUG_EXCEPTION("emcore_delete_transaction_info_by_mailId failed for mail_id[%d]", mail_id); @@ -178,53 +170,153 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_search_mail_on_server(int input_account_id, const char *input_mailbox_name, email_search_filter_t *input_search_filter, int input_search_filter_count, unsigned int *output_handle) +static char *_make_criteria_to_search_filter(email_search_filter_t *search_filter, int search_filter_count, int *err_code) { - EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_mailbox_name [%p], input_search_filter [%p], input_search_filter_count [%d], output_handle [%p]", input_account_id, input_mailbox_name, input_search_filter, input_search_filter_count, output_handle); - int error = EMF_ERROR_NONE; + EM_DEBUG_FUNC_BEGIN("search_filter : [%p], search_filter_count : [%d]", search_filter, search_filter_count); + int i = 0; + int err = EMAIL_ERROR_NONE; + char *criteria = NULL; + char *temp_criteria = NULL; + + if (search_filter == NULL || search_filter_count < 0) { + EM_DEBUG_EXCEPTION("Invalid paramter"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + criteria = (char *)em_malloc(STRING_LENGTH_FOR_DISPLAY * search_filter_count); + if (criteria == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + temp_criteria = (char *)em_malloc(STRING_LENGTH_FOR_DISPLAY); + if (temp_criteria == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + 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, STRING_LENGTH_FOR_DISPLAY); + + switch (search_filter[i].search_filter_type) { + case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO : + case EMAIL_SEARCH_FILTER_TYPE_UID : + 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_DELETED : + 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 : + 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_BCC : + case EMAIL_SEARCH_FILTER_TYPE_CC : + case EMAIL_SEARCH_FILTER_TYPE_TO : + 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; + + case EMAIL_SEARCH_FILTER_TYPE_FROM : + 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, "from %s ", search_filter[i].search_filter_key_value.string_type_key_value); + strncat(criteria, temp_criteria, strlen(temp_criteria)); + break; + + case EMAIL_SEARCH_FILTER_TYPE_SUBJECT : + 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, "subject %s ", search_filter[i].search_filter_key_value.string_type_key_value); + strncat(criteria, temp_criteria, strlen(temp_criteria)); + break; + + case EMAIL_SEARCH_FILTER_TYPE_KEYWORD : + 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, "keyword %s ", search_filter[i].search_filter_key_value.string_type_key_value); + strncat(criteria, temp_criteria, strlen(temp_criteria)); + 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 : + EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value); + break; - for(i = 0; i < input_search_filter_count; i++) { - EM_DEBUG_LOG("search_filter_type [%d]", input_search_filter->search_filter_type); - - switch(input_search_filter->search_filter_type) { - case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO : - case EMAIL_SEARCH_FILTER_TYPE_UID : - 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_DELETED : - 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 : - EM_DEBUG_LOG("integer_type_key_value [%d]", input_search_filter->search_filter_key_value.integer_type_key_value); - break; - - case EMAIL_SEARCH_FILTER_TYPE_BCC : - case EMAIL_SEARCH_FILTER_TYPE_CC : - case EMAIL_SEARCH_FILTER_TYPE_FROM : - case EMAIL_SEARCH_FILTER_TYPE_KEYWORD : - case EMAIL_SEARCH_FILTER_TYPE_SUBJECT : - case EMAIL_SEARCH_FILTER_TYPE_TO : - case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID : - EM_DEBUG_LOG("string_type_key_value [%s]", input_search_filter->search_filter_key_value.string_type_key_value); - 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 : - /* EM_DEBUG_LOG("time_type_key_value [%d]", input_search_filter->search_filter_key_value.time_type_key_value.); */ - break; - default : - EM_DEBUG_LOG("not proper search_filter_type [%d]", input_search_filter->search_filter_type); - return FALSE; + default : + EM_DEBUG_EXCEPTION("Invalid list_filter_item_type [%d]", search_filter); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; } + } +FINISH_OFF: + + if (temp_criteria) + EM_SAFE_FREE(temp_criteria); + + if (err_code != NULL) + *err_code = err; + + EM_DEBUG_FUNC_END(); + return criteria; +} + +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) +{ + 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; + char *criteria = NULL; + + if (input_mailbox_id == 0 || input_account_id < 0) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + error = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + email_event_t event_data; + + memset(&event_data, 0x00, sizeof(email_event_t)); + + criteria = _make_criteria_to_search_filter(input_search_filter, input_search_filter_count, &error); + if (criteria == NULL) { + EM_DEBUG_EXCEPTION("_make_criteria_to_search_filter failed"); + goto FINISH_OFF; + } + + event_data.type = EMAIL_EVENT_SEARCH_ON_SERVER; + event_data.account_id = input_account_id; + event_data.event_param_data_1 = EM_SAFE_STRDUP(criteria); + event_data.event_param_data_4 = input_mailbox_id; + + 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) { + EM_SAFE_FREE(event_data.event_param_data_1); + EM_SAFE_FREE(event_data.event_param_data_2); + } + + EM_SAFE_FREE(criteria); + + if (err_code != NULL) + *err_code = error; EM_DEBUG_FUNC_END("error [%d]", error); - return error; + return ret; } INTERNAL_FUNC int emdaemon_clear_all_mail_data(int* err_code) @@ -232,7 +324,7 @@ INTERNAL_FUNC int emdaemon_clear_all_mail_data(int* err_code) EM_DEBUG_FUNC_BEGIN(); int ret = false; - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; if (emdaemon_initialize(&error)) { if (!emstorage_clear_mail_data(true, &error)) @@ -249,7 +341,7 @@ INTERNAL_FUNC int emdaemon_clear_all_mail_data(int* err_code) ret = true; - if (!emstorage_create_table(EMF_CREATE_DB_NORMAL, &error)) + if (!emstorage_create_table(EMAIL_CREATE_DB_NORMAL, &error)) EM_DEBUG_EXCEPTION("emstorage_create_table failed [%d]", error); emdaemon_finalize(&error); diff --git a/email-daemon/email-daemon-init.c b/email-daemon/email-daemon-init.c index f75ef47..7365a1b 100755 --- a/email-daemon/email-daemon-init.c +++ b/email-daemon/email-daemon-init.c @@ -36,8 +36,10 @@ #include #include #include +#include #include #include /* added for Disabling the Pthread flag log */ +#include #include "email-daemon.h" #include "email-storage.h" @@ -56,12 +58,14 @@ extern int g_client_count ; +int fd_HibernationNoti; + /* static functions */ static int _emdaemon_load_email_core() { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; /* initialize mail core */ if (!emcore_init(&err)) @@ -70,16 +74,16 @@ static int _emdaemon_load_email_core() if (emcore_start_event_loop(&err) < 0) goto FINISH_OFF; - if (emcore_send_event_loop_start(&err) < 0) + if (emcore_start_event_loop_for_sending_mails(&err) < 0) goto FINISH_OFF; #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__ - if (emcore_partial_body_thread_loop_start(&err) < 0) { - EM_DEBUG_EXCEPTION("emcore_partial_body_thread_loop_start failed [%d]",err); + if (emcore_start_thread_for_downloading_partial_body(&err) < 0) { + EM_DEBUG_EXCEPTION("emcore_start_thread_for_downloading_partial_body failed [%d]",err); goto FINISH_OFF; } #endif - if (emcore_start_alert_thread(&err) < 0) + if (emcore_start_thread_for_alerting_new_mails(&err) < 0) goto FINISH_OFF; FINISH_OFF: @@ -90,7 +94,7 @@ FINISH_OFF: static int _emdaemon_unload_email_core() { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; /* finish event loop */ emcore_stop_event_loop(&err); @@ -99,13 +103,110 @@ static int _emdaemon_unload_email_core() return err; } +static void hibernation_enter_callback() +{ + EM_DEBUG_FUNC_BEGIN(); + emstorage_db_close(NULL); + EM_DEBUG_FUNC_END(); +} + +static void hibernation_leave_callback() +{ + EM_DEBUG_FUNC_BEGIN(); + emstorage_db_open(NULL); + EM_DEBUG_FUNC_END(); +} + +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); + unsigned handle = 0; + int i = 0; + int err = EMAIL_ERROR_NONE; + int account_count = 0; + email_account_t *account_list = NULL; + emstorage_mailbox_tbl_t *mailbox_tbl_data = NULL; + + if (!emdaemon_get_account_list(&account_list, &account_count, &err)) { + EM_DEBUG_EXCEPTION("emdaemon_get_account_list failed [%d]", err); + goto FINISH_OFF; + } + + for(i = 0; i < account_count; i++) { + if(!emstorage_get_mailbox_by_mailbox_type(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)) { + EM_DEBUG_EXCEPTION("emdaemon_sync_header for [%d] failed [%d]", account_list[i].account_id, err); + } + if(mailbox_tbl_data) + emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL); + mailbox_tbl_data = NULL; + } + +FINISH_OFF: + if(account_list) + emdaemon_free_account(&account_list, account_count, NULL); + if(mailbox_tbl_data) + emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL); + + EM_DEBUG_FUNC_END(); +} + +static void callback_for_AUTO_SYNC_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); + int err = EMAIL_ERROR_NONE; + int i = 0; + int auto_sync_toggle = 0; + int account_count = 0; + email_account_t *account_list = NULL; + email_account_t *account_info = NULL; + + if (!emdaemon_get_account_list(&account_list, &account_count, &err)) { + EM_DEBUG_EXCEPTION("emdaemon_get_account_list failed [%d]", err); + goto FINISH_OFF; + } + + if(input_node) + auto_sync_toggle = vconf_keynode_get_int(input_node); + + for(i = 0; i < account_count; i++) { + account_info = account_list + i; + + if(auto_sync_toggle == 1) { /* on */ + /* start sync */ + if(account_info->check_interval < 0) + account_info->check_interval = ~account_info->check_interval + 1; + } + else { /* off */ + /* terminate sync */ + if(account_info->check_interval > 0) + account_info->check_interval = ~account_info->check_interval + 1; + } + + if(!emdaemon_update_account(account_info->account_id, account_info, &err)) { + EM_DEBUG_EXCEPTION("emdaemon_update_account failed [%d]", err); + goto FINISH_OFF; + } + } + +FINISH_OFF: + if(account_list) + emdaemon_free_account(&account_list, account_count, NULL); + + EM_DEBUG_FUNC_END(); +} + INTERNAL_FUNC int emdaemon_initialize(int* err_code) { EM_DEBUG_FUNC_BEGIN(); /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (g_client_count > 0) { EM_DEBUG_LOG("Initialization was already done. increased counter=[%d]", g_client_count); @@ -131,24 +232,42 @@ INTERNAL_FUNC int emdaemon_initialize(int* err_code) goto FINISH_OFF; } - if (!emstorage_clean_save_status(EMF_MAIL_STATUS_SAVED, &err)) + if (!emstorage_clean_save_status(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 = EMF_ERROR_DB_FAILURE; + 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()) != EMF_ERROR_NONE) { + if ((err = _emdaemon_load_email_core()) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("_emdaemon_load_email_core failed [%d]", err); goto FINISH_OFF; } - emcore_check_unread_mail(); + /* Subscribe Events */ + fd_HibernationNoti = heynoti_init(); + + if(fd_HibernationNoti == -1) + EM_DEBUG_EXCEPTION("heynoti_init failed"); + else { + EM_DEBUG_LOG("heynoti_init Success"); + ret = heynoti_subscribe(fd_HibernationNoti, "HIBERNATION_ENTER", hibernation_enter_callback, (void *)fd_HibernationNoti); + EM_DEBUG_LOG("heynoti_subscribe returns %d", ret); + ret = heynoti_subscribe(fd_HibernationNoti, "HIBERNATION_LEAVE", hibernation_leave_callback, (void *)fd_HibernationNoti); + EM_DEBUG_LOG("heynoti_subscribe returns %d", ret); + ret = heynoti_attach_handler(fd_HibernationNoti); + EM_DEBUG_LOG("heynoti_attach_handler returns %d", ret); + } + + vconf_notify_key_changed(VCONFKEY_ACCOUNT_SYNC_ALL_STATUS_INT, callback_for_SYNC_ALL_STATUS_from_account_svc, NULL); + vconf_notify_key_changed(VCONFKEY_ACCOUNT_AUTO_SYNC_STATUS_INT, callback_for_AUTO_SYNC_STATUS_from_account_svc, NULL); + + emcore_check_unread_mail(); ret = true; @@ -169,16 +288,16 @@ INTERNAL_FUNC int emdaemon_finalize(int* err_code) /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (g_client_count > 1) { EM_DEBUG_EXCEPTION("engine is still used by application. decreased counter=[%d]", g_client_count); g_client_count--; - err = EMF_ERROR_CLOSE_FAILURE; + err = EMAIL_ERROR_CLOSE_FAILURE; goto FINISH_OFF; } - if ( (err = _emdaemon_unload_email_core()) != EMF_ERROR_NONE) { + if ( (err = _emdaemon_unload_email_core()) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("_emdaemon_unload_email_core failed [%d]", err); goto FINISH_OFF; } @@ -192,6 +311,14 @@ INTERNAL_FUNC int emdaemon_finalize(int* err_code) goto FINISH_OFF; } + /* Unsubscribe Events */ + + if(fd_HibernationNoti != -1) { + heynoti_unsubscribe(fd_HibernationNoti, "HIBERNATION_ENTER", hibernation_enter_callback); + heynoti_unsubscribe(fd_HibernationNoti, "HIBERNATION_LEAVE", hibernation_leave_callback); + heynoti_close(fd_HibernationNoti); + } + g_client_count = 0; #ifdef __FEATURE_AUTO_POLLING__ @@ -214,7 +341,7 @@ INTERNAL_FUNC int emdaemon_start_auto_polling(int* err_code) /* default variable */ int ret = false, count = 0, i= 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_account_tbl_t* account_list = NULL; /* get account list */ diff --git a/email-daemon/email-daemon-mail.c b/email-daemon/email-daemon-mail.c index f8b65a2..a665de2 100755 --- a/email-daemon/email-daemon-mail.c +++ b/email-daemon/email-daemon-mail.c @@ -60,57 +60,66 @@ extern int g_save_local_activity_run; #endif static int _emdaemon_check_mail_id(int mail_id, int* err_code); -INTERNAL_FUNC int emdaemon_send_mail(emf_mailbox_t* mailbox, int mail_id, emf_option_t* sending_option, unsigned* handle, int* err_code) +INTERNAL_FUNC int emdaemon_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle, int* err_code) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], sending_option[%p], handle[%p], err_code[%p]", mailbox, mail_id, sending_option, handle, err_code); + EM_DEBUG_FUNC_BEGIN("mail_id[%d], sending_option[%p], handle[%p], err_code[%p]", mail_id, sending_option, handle, err_code); - int ret = false, err = EMF_ERROR_NONE, err_2 = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE, err_2 = EMAIL_ERROR_NONE; int result_handle = 0, account_id = 0; - emf_mailbox_t dest_mbox; - emf_option_t* option = NULL; - emf_event_t event_data; - char* mailbox_name = NULL; - - if (!mailbox || !mailbox->name || mailbox->account_id <= 0) { - if (mailbox != NULL) - EM_DEBUG_EXCEPTION(" mailbox->name[%s], mailbox->account_id[%d]", mailbox->name, mailbox->account_id); + email_option_t* option = NULL; + email_event_t event_data; + emstorage_mail_tbl_t* mail_table_data = NULL; + emstorage_mailbox_tbl_t* local_mailbox = NULL; + int dst_mailbox_id = 0; + + if(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(mail_id, &mail_table_data, true, &err)) { + EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err); + goto FINISH_OFF; + } + + if (!mail_table_data || mail_table_data->mailbox_id <= 0 || mail_table_data->account_id <= 0) { + if (mail_table_data != NULL) + EM_DEBUG_EXCEPTION(" mail_table_data->mailbox_id[%d], mail_table_data->account_id[%d]", mail_table_data->mailbox_id, mail_table_data->account_id); if (err_code) - *err_code = EMF_ERROR_INVALID_MAILBOX; + *err_code = EMAIL_ERROR_INVALID_MAILBOX; return false; } - account_id = mailbox->account_id; + account_id = mail_table_data->account_id; if (sending_option != NULL) { - if (!(option = (emf_option_t*)em_malloc(sizeof(emf_option_t)))) { + if (!(option = (email_option_t*)em_malloc(sizeof(email_option_t)))) { EM_DEBUG_EXCEPTION("em_malloc for sending_option failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - memcpy(option, sending_option, sizeof(emf_option_t)); + memcpy(option, sending_option, sizeof(email_option_t)); option->display_name_from = EM_SAFE_STRDUP(sending_option->display_name_from); } - emf_account_t* ref_account = emdaemon_get_account_reference(account_id); + email_account_t* ref_account = emdaemon_get_account_reference(account_id); if (!ref_account) { EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } #ifdef __FEATURE_MOVE_TO_OUTBOX_FIRST__ - if (!emstorage_get_mailboxname_by_mailbox_type(account_id,EMF_MAILBOX_TYPE_OUTBOX,&mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION(" emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); - + if (!emstorage_get_mailbox_by_mailbox_type(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; } - if (strcmp(mailbox->name, mailbox_name)) { - dest_mbox.name = mailbox_name; - dest_mbox.account_id = account_id; - - /* mail is moved to 'OUTBOX' first of all. */ - if (!emcore_mail_move(&mail_id, 1, dest_mbox.name, EMF_MOVED_AFTER_SENDING, 0, &err)) { + dst_mailbox_id = local_mailbox->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)) { EM_DEBUG_EXCEPTION("emcore_mail_move falied [%d]", err); goto FINISH_OFF; } @@ -120,38 +129,30 @@ INTERNAL_FUNC int emdaemon_send_mail(emf_mailbox_t* mailbox, int mail_id, emf_op if(!emstorage_notify_network_event(NOTI_SEND_START, account_id, NULL, mail_id, 0)) EM_DEBUG_EXCEPTION(" emstorage_notify_network_event [ NOTI_SEND_START] Failed >>>> "); - /* set EMF_MAIL_STATUS_SEND_WAIT status */ + /* set EMAIL_MAIL_STATUS_SEND_WAIT status */ - if(!emstorage_set_field_of_mails_with_integer_value(account_id, &mail_id, 1, "save_status", EMF_MAIL_STATUS_SEND_WAIT, true, &err)) { + if(!emstorage_set_field_of_mails_with_integer_value(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; } - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - memset(&event_data, 0x00, sizeof(emf_event_t)); - event_data.type = EMF_EVENT_SEND_MAIL; - event_data.account_id = account_id; - event_data.event_param_data_1 = (char*)option; - event_data.event_param_data_3 = EM_SAFE_STRDUP(mailbox->name); - event_data.event_param_data_4 = mail_id; - - if (!emcore_insert_send_event(&event_data, &result_handle, &err)) { - EM_DEBUG_EXCEPTION(" emcore_insert_event failed [%d]", err); - goto FINISH_OFF; - } + memset(&event_data, 0x00, sizeof(email_event_t)); + event_data.type = EMAIL_EVENT_SEND_MAIL; + event_data.account_id = account_id; + event_data.event_param_data_1 = (char*)option; + event_data.event_param_data_4 = mail_id; + event_data.event_param_data_5 = mail_table_data->mailbox_id; + + if (!emcore_insert_event_for_sending_mails(&event_data, &result_handle, &err)) { + EM_DEBUG_EXCEPTION(" emcore_insert_event failed [%d]", err); + goto FINISH_OFF; + } + #ifdef __FEATURE_LOCAL_ACTIVITY__ EM_DEBUG_LOG("Setting g_save_local_activity_run "); g_save_local_activity_run = 1; #endif - break; - - default: - EM_DEBUG_EXCEPTION("unsupported account binding type..."); - err = EMF_ERROR_NOT_SUPPORTED; - goto FINISH_OFF; - } if ( handle ) *handle = result_handle; @@ -162,7 +163,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", EMF_MAIL_STATUS_SAVED, true, &err)) + if(!emstorage_set_field_of_mails_with_integer_value(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); EM_SAFE_FREE(event_data.event_param_data_3); @@ -176,75 +177,71 @@ FINISH_OFF: if(!emcore_add_transaction_info(mail_id , result_handle , &err_2)) EM_DEBUG_EXCEPTION("emcore_add_transaction_info failed [%d]", err_2); - EM_SAFE_FREE(mailbox_name); + if(local_mailbox) + emstorage_free_mailbox(&local_mailbox, 1, NULL); if (err_code != NULL) *err_code = err; + if(mail_table_data) { + emstorage_free_mail(&mail_table_data, 1, &err); + + } EM_DEBUG_FUNC_END(); return ret; } -INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, emf_option_t* sending_option, unsigned* handle, int* err_code) +INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, email_option_t* sending_option, unsigned* handle, int* err_code) { EM_DEBUG_FUNC_BEGIN("account_id[%d], sending_option[%p], handle[%p], err_code[%p]", account_id, sending_option, handle, err_code); int ret = false; - int err = EMF_ERROR_NONE; - emf_option_t* option = NULL; - emf_event_t event_data; + int err = EMAIL_ERROR_NONE; + email_option_t* option = NULL; + email_event_t event_data; char *mailbox_name = NULL; - memset(&event_data, 0x00, sizeof(emf_event_t)); + memset(&event_data, 0x00, sizeof(email_event_t)); if (account_id <= 0) { EM_DEBUG_EXCEPTION("account_id = %d", account_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } if (sending_option) { - option = (emf_option_t*)em_malloc(sizeof(emf_option_t)); + option = (email_option_t*)em_malloc(sizeof(email_option_t)); if (!option) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - memcpy(option, sending_option, sizeof(emf_option_t)); + memcpy(option, sending_option, sizeof(email_option_t)); } - emf_account_t* ref_account = emdaemon_get_account_reference(account_id); + email_account_t* ref_account = emdaemon_get_account_reference(account_id); if (!ref_account) { EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - event_data.type = EMF_EVENT_SEND_MAIL_SAVED; - - if (!emstorage_get_mailboxname_by_mailbox_type(account_id,EMF_MAILBOX_TYPE_OUTBOX,&mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); - goto FINISH_OFF; - } - event_data.event_param_data_3 = EM_SAFE_STRDUP(mailbox_name); - event_data.account_id = account_id; - event_data.event_param_data_1 = (char*)option; - - if (!emcore_insert_event(&event_data, (int*)handle, &err)) { - EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); - goto FINISH_OFF; - } - break; - - default : - EM_DEBUG_EXCEPTION("unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; - goto FINISH_OFF; + event_data.type = EMAIL_EVENT_SEND_MAIL_SAVED; + + if (!emstorage_get_mailbox_name_by_mailbox_type(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.event_param_data_3 = EM_SAFE_STRDUP(mailbox_name); + event_data.account_id = account_id; + event_data.event_param_data_1 = (char*)option; + + if (!emcore_insert_event(&event_data, (int*)handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); + goto FINISH_OFF; } ret = true; @@ -264,77 +261,69 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t *input_meeting_request, int input_from_eas) +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) { 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 = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int handle = 0; - emf_event_t event_data = { 0 }; + email_event_t event_data = { 0 }; if (!input_mail_data || input_mail_data->account_id <= 0 || - (input_mail_data->report_status == EMF_MAIL_REPORT_MDN && !input_mail_data->full_address_to)) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + (input_mail_data->report_status == EMAIL_MAIL_REPORT_MDN && !input_mail_data->full_address_to)) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - emf_account_t* ref_account = emdaemon_get_account_reference(input_mail_data->account_id); + email_account_t* ref_account = emdaemon_get_account_reference(input_mail_data->account_id); if (!ref_account) { EM_DEBUG_LOG(" emdaemon_get_account_reference failed [%d]", input_mail_data->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE : - if ((err = emcore_add_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err); - goto FINISH_OFF; - } + if ((err = emcore_add_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err); + goto FINISH_OFF; + } #ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__ - if ( input_from_eas == 0) { - event_data.type = EMF_EVENT_SAVE_MAIL; - event_data.account_id = input_mail_data->account_id; - event_data.event_param_data_4 = input_mail_data->mail_id; - - if (!emcore_insert_send_event(&event_data, &handle, &err)) { - EM_DEBUG_EXCEPTION("emcore_insert_send_event failed [%d]", err); - goto FINISH_OFF; - } - } -#endif - break; + if ( input_from_eas == 0) { + 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; - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; + if (!emcore_insert_event_for_sending_mails(&event_data, &handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event_for_sending_mails failed [%d]", err); goto FINISH_OFF; + } } +#endif + FINISH_OFF: EM_DEBUG_FUNC_END("err [%d]", err); return err; } -INTERNAL_FUNC int emdaemon_add_meeting_request(int account_id, char *mailbox_name, emf_meeting_request_t *meeting_req, int* err_code) +INTERNAL_FUNC int emdaemon_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int* err_code) { - EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%s], meeting_req[%p], err_code[%p]", account_id, mailbox_name, meeting_req, 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); /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if ( account_id <= 0 || !meeting_req || meeting_req->mail_id <= 0 ) { if(meeting_req) EM_DEBUG_EXCEPTION("mail_id[%d]", meeting_req->mail_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (!emcore_add_meeting_request(account_id, mailbox_name, meeting_req, &err)) { + if (!emcore_add_meeting_request(account_id, input_mailbox_id, meeting_req, &err)) { EM_DEBUG_EXCEPTION(" emcore_save_mail_meeting_request failed [%d]", err); goto FINISH_OFF; } @@ -348,13 +337,13 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_download_body(emf_mailbox_t* mailbox, int mail_id, int verbose, int with_attachment, unsigned* handle, int* err_code) +INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbose, int with_attachment, unsigned* handle, int* err_code) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], verbose[%d], with_attachment[%d], handle[%p], err_code[%p]", mailbox, mail_id, verbose, with_attachment, handle, 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); /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; /* mpNewMail_StopAlertSound(); */ if (!_emdaemon_check_mail_id(mail_id, &err)) { @@ -362,19 +351,18 @@ INTERNAL_FUNC int emdaemon_download_body(emf_mailbox_t* mailbox, int mail_id, in goto FINISH_OFF; } - emf_event_t event_data; + email_event_t event_data; - memset(&event_data, 0x00, sizeof(emf_event_t)); + memset(&event_data, 0x00, sizeof(email_event_t)); - event_data.type = EMF_EVENT_DOWNLOAD_BODY; - event_data.event_param_data_1 = NULL; + event_data.type = EMAIL_EVENT_DOWNLOAD_BODY; event_data.event_param_data_4 = mail_id; - event_data.account_id = mailbox->account_id; + event_data.account_id = account_id; event_data.event_param_data_3 = GINT_TO_POINTER(verbose << 1 | with_attachment); if (!emcore_insert_event(&event_data, (int*)handle, &err)) { EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); - err = EMF_ERROR_DB_FAILURE; + err = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; } #ifdef __FEATURE_LOCAL_ACTIVITY__ @@ -390,26 +378,21 @@ FINISH_OFF: return ret; } -int emdaemon_get_attachment(emf_mailbox_t* mailbox, int mail_id, char* attachment_id, emf_attachment_info_t** attachment, int* err_code) +int emdaemon_get_attachment(int attachment_id, email_attachment_data_t** attachment, int* err_code) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment_id[%s], attachment[%p], err_code[%p]", mailbox, mail_id, attachment_id, attachment, err_code); + EM_DEBUG_FUNC_BEGIN("attachment_id[%d], attachment[%p], err_code[%p]", attachment_id, attachment, err_code); /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!attachment_id || !attachment) { - EM_DEBUG_EXCEPTION("mailbox[%p], mail_id[%d], attachment_id[%p], attachment[%p]\n", mailbox, mail_id, attachment_id, attachment); - err = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } - - if (!_emdaemon_check_mail_id(mail_id, &err)) { - EM_DEBUG_EXCEPTION("_emdaemon_check_mail_id failed [%d]", err); + EM_DEBUG_EXCEPTION("mail_id[%d], attachment_id[%d], attachment[%p]\n", attachment_id, attachment); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (!emcore_get_attachment_info(/*mailbox,*/ mail_id, attachment_id, attachment, &err) || !attachment) { + if (!emcore_get_attachment_info(attachment_id, attachment, &err) || !attachment) { EM_DEBUG_EXCEPTION("emcore_get_attachment_info failed [%d]", err); goto FINISH_OFF; } @@ -423,17 +406,17 @@ FINISH_OFF: return ret; } -int emdaemon_add_attachment(emf_mailbox_t* mailbox, int mail_id, emf_attachment_info_t* attachment, int* err_code) +int emdaemon_add_attachment(int mail_id, email_attachment_data_t* attachment, int* err_code) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment[%p], err_code[%p]", mailbox, mail_id, attachment, err_code); + EM_DEBUG_FUNC_BEGIN("mail_id[%d], attachment[%p], err_code[%p]", mail_id, attachment, err_code); /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!attachment) { - EM_DEBUG_EXCEPTION(" mailbox[%p], mail_id[%d], attachment[%p]", mailbox, mail_id, attachment); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION(" mailbox[%p], mail_id[%d], attachment[%p]", mail_id, attachment); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -442,7 +425,7 @@ int emdaemon_add_attachment(emf_mailbox_t* mailbox, int mail_id, emf_attachment_ goto FINISH_OFF; } - if (!emcore_mail_add_attachment(/*mailbox,*/ mail_id, attachment, &err)) { + if (!emcore_mail_add_attachment(mail_id, attachment, &err)) { EM_DEBUG_EXCEPTION(" emcore_mail_add_attachment failed [%d]", err); goto FINISH_OFF; } @@ -456,26 +439,21 @@ FINISH_OFF: return ret; } -int emdaemon_delete_mail_attachment(emf_mailbox_t* mailbox, int mail_id, char* attachment_id, int* err_code) +int emdaemon_delete_mail_attachment(int attachment_id, int* err_code) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment_id[%s], err_code[%p]", mailbox, mail_id, attachment_id, err_code); + EM_DEBUG_FUNC_BEGIN("attachment_id[%s], err_code[%p]", attachment_id, err_code); /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!attachment_id) { - EM_DEBUG_EXCEPTION(" mailbox[%p], mail_id[%d], attachment_id[%p]", mailbox, mail_id, attachment_id); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("attachment_id[%d]", attachment_id); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (!_emdaemon_check_mail_id(mail_id, &err)) { - EM_DEBUG_EXCEPTION(" _emdaemon_check_mail_id failed [%d]", err); - goto FINISH_OFF; - } - - if (!emcore_delete_mail_attachment(mail_id, attachment_id, &err)) { + if (!emcore_delete_mail_attachment(attachment_id, &err)) { EM_DEBUG_EXCEPTION(" emcore_delete_mail_attachment failed [%d]", err); goto FINISH_OFF; } @@ -489,16 +467,16 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_download_attachment(emf_mailbox_t* mailbox, int mail_id, char* attachment, unsigned* handle, int* err_code) +INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int nth, unsigned* handle, int* err_code) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment[%p], handle[%p], err_code[%p]", mailbox, mail_id, attachment, handle, 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); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (!attachment) { - EM_DEBUG_EXCEPTION("attachment[%p] is invalid", attachment); - err = EMF_ERROR_INVALID_PARAM; + if (!nth) { + EM_DEBUG_EXCEPTION("nth[%p] is invalid", nth); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } @@ -507,15 +485,14 @@ INTERNAL_FUNC int emdaemon_download_attachment(emf_mailbox_t* mailbox, int mail_ goto FINISH_OFF; } - emf_event_t event_data; + email_event_t event_data; - memset(&event_data, 0x00, sizeof(emf_event_t)); + memset(&event_data, 0x00, sizeof(email_event_t)); - event_data.type = EMF_EVENT_DOWNLOAD_ATTACHMENT; - event_data.event_param_data_1 = NULL; + event_data.type = EMAIL_EVENT_DOWNLOAD_ATTACHMENT; + event_data.account_id = account_id; event_data.event_param_data_4 = mail_id; - event_data.account_id = mailbox->account_id; - event_data.event_param_data_3 = EM_SAFE_STRDUP(attachment); + event_data.event_param_data_5 = nth; if (!emcore_insert_event(&event_data, (int*)handle, &err)) { EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); @@ -536,31 +513,38 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_free_attachment_info(emf_attachment_info_t** atch_info, int* err_code) +INTERNAL_FUNC int emdaemon_free_attachment_data(email_attachment_data_t** atch_data, int* err_code) { EM_DEBUG_FUNC_BEGIN(); - return emcore_free_attachment_info(atch_info, err_code); + return emcore_free_attachment_data(atch_data, 1, err_code); } void* thread_func_to_delete_mail(void *thread_argument) { EM_DEBUG_FUNC_BEGIN(); - int *mail_id_list = NULL, mail_id_count, account_id, err; + int err = EMAIL_ERROR_NONE; + int *mail_id_list = NULL; + int mail_id_count = 0; + int account_id = 0; + int from_server = 0; unsigned handle = 0; - emf_event_t *event_data = (emf_event_t*)thread_argument; + 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; - if (!emcore_delete_mail(account_id, mail_id_list, mail_id_count, EMF_DELETE_LOCALLY, EMF_DELETED_BY_COMMAND, false, &err)) { + if (!emcore_delete_mail(account_id, mail_id_list, mail_id_count, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_BY_COMMAND, false, &err)) { EM_DEBUG_EXCEPTION(" emcore_delete_mail falied [%d]", err); goto FINISH_OFF; } - if (!emcore_insert_event(event_data, (int*)handle, &err)) { - EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); - goto FINISH_OFF; + if (from_server != EMAIL_DELETE_LOCALLY) { + if (!emcore_insert_event(event_data, (int*)handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); + goto FINISH_OFF; + } } FINISH_OFF: @@ -571,56 +555,58 @@ FINISH_OFF: return SUCCESS; } -INTERNAL_FUNC int emdaemon_delete_mail(int account_id, emf_mailbox_t* mailbox, int mail_ids[], int mail_ids_count, int from_server, unsigned* handle, int* err_code) +INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_ids[], int mail_ids_count, int from_server, unsigned* handle, int* err_code) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_ids[%p], mail_ids_count[%d], from_server[%d], handle[%p], err_code[%p]", mailbox, mail_ids, mail_ids_count, from_server, handle, 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); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int* p = NULL, thread_error; - emf_event_t *event_data = NULL; - emf_account_t *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. */ if (mail_ids_count <= 0) { EM_DEBUG_EXCEPTION("mail_ids_count [%d]", mail_ids_count); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (!(account = emcore_get_account_reference(account_id))) { - EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + 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 = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } memcpy(p, mail_ids, sizeof(int) * mail_ids_count); - if ((event_data = em_malloc(sizeof(emf_event_t)) ) == NULL) { + if ((event_data = em_malloc(sizeof(email_event_t)) ) == NULL) { EM_DEBUG_EXCEPTION("em_malloc for event_data failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - event_data->type = EMF_EVENT_DELETE_MAIL; - event_data->account_id = account_id; - if(mailbox) - event_data->event_param_data_1 = mailbox->name; + event_data->type = EMAIL_EVENT_DELETE_MAIL; + event_data->account_id = mailbox_tbl_data->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; THREAD_CREATE(delete_thread, thread_func_to_delete_mail, (void*)event_data, thread_error); THREAD_DETACH(delete_thread); /* free resources used for new thread */ ret = true; FINISH_OFF: + + if (mailbox_tbl_data) + emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL); + if (ret == false) EM_SAFE_FREE(p); @@ -630,135 +616,190 @@ FINISH_OFF: return ret; } -int emdaemon_delete_mail_all(emf_mailbox_t* mailbox, int with_server, unsigned* handle, int* err_code) +int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, unsigned *output_handle, int *output_err_code) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], with_server[%d], handle[%p], err_code[%p]", mailbox, with_server, handle, 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); - int ret = false; - int err = EMF_ERROR_NONE; - emf_account_t *ref_account = NULL; - emf_event_t event_data = { 0 }; + int ret = false; + int err = EMAIL_ERROR_NONE; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; + email_event_t event_data = { 0 }; - if (!mailbox || mailbox->account_id <= 0) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if (!input_mailbox_id) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - ref_account = emdaemon_get_account_reference(mailbox->account_id); - if (!ref_account) { - EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed account_id [%d]", mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl) != EMAIL_ERROR_NONE)) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err); goto FINISH_OFF; } -#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__ - event_data.type = EMF_EVENT_DELETE_MAIL_ALL; - event_data.account_id = mailbox->account_id; - event_data.event_param_data_1 = EM_SAFE_STRDUP(mailbox->name); - event_data.event_param_data_3 = NULL; - event_data.event_param_data_4 = with_server; - - if (!emcore_insert_event(&event_data, (int*)handle, &err)) { - EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err); - EM_SAFE_FREE(event_data.event_param_data_1); + if(!emcore_delete_all_mails_of_mailbox(input_mailbox_id, EMAIL_DELETE_LOCALLY, &err)) { + EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err); goto FINISH_OFF; } - + +#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__ + if(input_from_server == EMAIL_DELETE_LOCAL_AND_SERVER || input_from_server == EMAIL_DELETE_FROM_SERVER) { + event_data.type = EMAIL_EVENT_DELETE_MAIL_ALL; + 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; + + if (!emcore_insert_event(&event_data, (int*)output_handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err); + goto FINISH_OFF; + } + #ifdef __FEATURE_LOCAL_ACTIVITY__ - int i, total = 0 , search_handle = 0; - int *mail_ids = NULL; - emstorage_activity_tbl_t new_activity; - int activityid = 0; - - if (false == emcore_get_next_activity_id(&activityid,&err)) { - EM_DEBUG_EXCEPTION(" emcore_get_next_activity_id Failed - %d ", err); - } - - if (!emstorage_mail_search_start(NULL, mailbox->account_id, mailbox->name, 0, &search_handle, &total, true, &err)) { - EM_DEBUG_EXCEPTION(" emstorage_mail_search_start failed [%d]", err); + int i, total = 0 , search_handle = 0; + int *mail_ids = NULL; + emstorage_activity_tbl_t new_activity; + int activityid = 0; - - goto FINISH_OFF; - } - - mail_ids = em_malloc(sizeof(int) * total); - if (mail_ids == NULL) { - EM_DEBUG_EXCEPTION(" mailloc failed..."); + if (false == emcore_get_next_activity_id(&activityid,&err)) { + EM_DEBUG_EXCEPTION(" emcore_get_next_activity_id Failed - %d ", err); + } - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - for (i = 0; i < total; i++) { - if (!emstorage_mail_search_result(search_handle, RETRIEVE_ID, (void**)&mail_ids[i], true, &err)) { - EM_DEBUG_EXCEPTION(" emstorage_mail_search_result failed [%d]", err); + if (!emstorage_mail_search_start(NULL, mailbox->account_id, mailbox->mailbox_name, 0, &search_handle, &total, true, &err)) { + EM_DEBUG_EXCEPTION(" emstorage_mail_search_start failed [%d]", err); - EM_SAFE_FREE(mail_ids); goto FINISH_OFF; } + + mail_ids = em_malloc(sizeof(int) * total); + if (mail_ids == NULL) { + EM_DEBUG_EXCEPTION(" mailloc failed..."); - new_activity.activity_id = activityid; - new_activity.activity_type = ACTIVITY_DELETEMAIL; - new_activity.mail_id = mail_ids[i]; - new_activity.server_mailid = NULL; - new_activity.src_mbox = mailbox->name; - new_activity.dest_mbox = NULL; - new_activity.account_id = mailbox->account_id; - - if (! emcore_add_activity(&new_activity, &err)) - EM_DEBUG_EXCEPTION(" emcore_add_activity Failed - %d ", err); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + for (i = 0; i < total; i++) { + if (!emstorage_mail_search_result(search_handle, RETRIEVE_ID, (void**)&mail_ids[i], true, &err)) { + EM_DEBUG_EXCEPTION(" emstorage_mail_search_result failed [%d]", err); + - } + EM_SAFE_FREE(mail_ids); + goto FINISH_OFF; + } - EM_SAFE_FREE(mail_ids); + new_activity.activity_id = activityid; + new_activity.activity_type = ACTIVITY_DELETEMAIL; + new_activity.mail_id = mail_ids[i]; + new_activity.server_mailid = NULL; + new_activity.src_mbox = mailbox->mailbox_name; + new_activity.dest_mbox = NULL; + new_activity.account_id = mailbox->account_id; - EM_DEBUG_LOG("Setting g_local_activity_run "); - g_local_activity_run = 1; + if (! emcore_add_activity(&new_activity, &err)) + EM_DEBUG_EXCEPTION(" emcore_add_activity Failed - %d ", err); + + } + + EM_SAFE_FREE(mail_ids); + + EM_DEBUG_LOG("Setting g_local_activity_run "); + g_local_activity_run = 1; #endif - + } #endif /* __FEATURE_SYNC_CLIENT_TO_SERVER__ */ ret = true; FINISH_OFF: - if (err_code) - *err_code = err; + + if (mailbox_tbl) + emstorage_free_mailbox(&mailbox_tbl, 1, NULL); + + if (output_err_code) + *output_err_code = err; return ret; } - +void* thread_func_to_move_mail(void *thread_argument) +{ + EM_DEBUG_FUNC_BEGIN(); + int *mail_ids = NULL, mail_ids_count, noti_param_1, noti_param_2, err; + unsigned handle = 0; + email_event_t *event_data = (email_event_t*)thread_argument; + char *dst_mailbox_name = NULL; + int dst_mailbox_id = 0; + + dst_mailbox_name = (char*)event_data->event_param_data_1; + mail_ids = (int*)event_data->event_param_data_3; + mail_ids_count = event_data->event_param_data_4; + 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; + -INTERNAL_FUNC int emdaemon_move_mail_all_mails(emf_mailbox_t* src_mailbox, emf_mailbox_t* dst_mailbox, int* err_code) + if (!emcore_move_mail(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; + } + + if (!emcore_insert_event(event_data, (int*)&handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); + goto FINISH_OFF; + } + +FINISH_OFF: + /* emcore_free_event(event_data); */ /* all of members will be freed after using in each event handler */ + EM_SAFE_FREE(event_data); + + EM_DEBUG_FUNC_END(); + return SUCCESS; +} + +INTERNAL_FUNC int emdaemon_move_mail_all_mails(int src_mailbox_id, int dst_mailbox_id, int* err_code) { - EM_DEBUG_FUNC_BEGIN("src_mailbox[%p], dst_mailbox[%p], err_code[%p]", src_mailbox, dst_mailbox, 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); int ret = false; - int err = EMF_ERROR_NONE; - emf_account_t *ref_account = NULL; - emf_mail_list_item_t *mail_list = NULL; + int err = EMAIL_ERROR_NONE; int select_num = 0; - int *mails = NULL; - int i=0; - int num =0; + int *mails = NULL; + int *p = NULL; + int i = 0; + int num = 0; + int thread_error; + email_account_t *ref_account = NULL; + email_mail_list_item_t *mail_list = NULL; + email_event_t *event_data = NULL; + thread_t move_thread; + emstorage_mailbox_tbl_t *dst_mailbox_tbl = NULL; + emstorage_mailbox_tbl_t *src_mailbox_tbl = NULL; - if (!dst_mailbox || dst_mailbox->account_id <= 0 || !src_mailbox || src_mailbox->account_id <= 0) { + if ( dst_mailbox_id <= 0|| src_mailbox_id <= 0) { EM_DEBUG_EXCEPTION("Invalid Parameter"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - ref_account = emdaemon_get_account_reference(dst_mailbox->account_id); + if ((err = emstorage_get_mailbox_by_id(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) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err); + goto FINISH_OFF; + } + + ref_account = emdaemon_get_account_reference(dst_mailbox_tbl->account_id); if (!ref_account) { - EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", dst_mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + EM_DEBUG_EXCEPTION("emdaemon_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->account_id, src_mailbox->name, NULL, EMF_LIST_TYPE_NORMAL, -1, -1, 0, NULL, EMF_SORT_DATETIME_HIGH, false, &mail_list, &select_num, &err)) { + 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)) { EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed"); goto FINISH_OFF; } @@ -767,14 +808,14 @@ INTERNAL_FUNC int emdaemon_move_mail_all_mails(emf_mailbox_t* src_mailbox, emf_m if( !mails ) { EM_DEBUG_EXCEPTION("Malloc failed...!"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } memset(mails, 0x00, sizeof(int) * select_num); for(i = 0 ; i < select_num ; i++) { - if( mail_list[i].save_status != EMF_MAIL_STATUS_SENDING ) { + if( mail_list[i].save_status != EMAIL_MAIL_STATUS_SENDING ) { mails[num] = mail_list[i].mail_id; num++; } @@ -782,87 +823,112 @@ INTERNAL_FUNC int emdaemon_move_mail_all_mails(emf_mailbox_t* src_mailbox, emf_m if( num <= 0) { EM_DEBUG_EXCEPTION("can't find avalable mails. num = %d", num); - err = EMF_ERROR_MAIL_NOT_FOUND; + err = EMAIL_ERROR_MAIL_NOT_FOUND; goto FINISH_OFF; } - if(!emcore_mail_move(mails, num, dst_mailbox->name, EMF_MOVED_BY_COMMAND, 0, &err)) { - EM_DEBUG_EXCEPTION("emcore_mail_move falied [%d]", err); + if ((event_data = em_malloc(sizeof(email_event_t)) ) == NULL) { + EM_DEBUG_EXCEPTION("em_malloc for event_data failed..."); + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - + if ((p = em_malloc(sizeof(int) * num)) == NULL) { + EM_DEBUG_EXCEPTION("em_malloc for p failed..."); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + + memcpy(p, mails, sizeof(int) * num); + + event_data->account_id = dst_mailbox_tbl->account_id; + event_data->type = EMAIL_EVENT_MOVE_MAIL; + event_data->event_param_data_3 = (char*)p; + 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; + +#ifdef __FEATURE_LOCAL_ACTIVITY__ + int i = 0, activityid = 0; + + if (false == emcore_get_next_activity_id(&activityid,&err)) + EM_DEBUG_EXCEPTION(" emcore_get_next_activity_id Failed - %d ", err); + + for (i =0; i < event_data.event_param_data_4; i++) { + emstorage_activity_tbl_t new_activity; + new_activity.activity_id = activityid; + new_activity.activity_type = ACTIVITY_MOVEMAIL; + new_activity.account_id = event_data.account_id; + new_activity.mail_id = mail_ids[i]; + new_activity.dest_mbox = event_data.event_param_data_1; + new_activity.server_mailid = NULL; + new_activity.src_mbox = event_data.event_param_data_2; + + if (!emcore_add_activity(&new_activity, &err)) + EM_DEBUG_EXCEPTION(" emcore_add_activity Failed - %d ", err); + } +#endif /* __FEATURE_LOCAL_ACTIVITY__ */ + THREAD_CREATE(move_thread, thread_func_to_move_mail, (void*)event_data, thread_error); + THREAD_DETACH(move_thread); /* free resources used for new thread */ ret = true; FINISH_OFF: + +#ifdef __FEATURE_LOCAL_ACTIVITY__ + EM_DEBUG_LOG("Setting g_local_activity_run "); + g_local_activity_run = 1; +#endif /* __FEATURE_LOCAL_ACTIVITY__ */ + if (err_code) *err_code = err; + if (dst_mailbox_tbl) + emstorage_free_mailbox(&dst_mailbox_tbl, 1, NULL); + + if (src_mailbox_tbl) + emstorage_free_mailbox(&src_mailbox_tbl, 1, NULL); + if(mail_list) EM_SAFE_FREE(mail_list); if(mails != NULL ) EM_SAFE_FREE(mails); - - return ret; -} -void* thread_func_to_move_mail(void *thread_argument) -{ - EM_DEBUG_FUNC_BEGIN(); - int *mail_ids = NULL, mail_ids_count, noti_param_1, noti_param_2, err; - unsigned handle = 0; - emf_event_t *event_data = (emf_event_t*)thread_argument; - char *dst_mailbox_name = NULL; - dst_mailbox_name = (char*)event_data->event_param_data_1; - mail_ids = (int*)event_data->event_param_data_3; - mail_ids_count = event_data->event_param_data_4; - noti_param_1 = event_data->event_param_data_6; - noti_param_2 = event_data->event_param_data_7; - - if (!emcore_mail_move(mail_ids, mail_ids_count, dst_mailbox_name, noti_param_1, noti_param_2, &err)) { - EM_DEBUG_EXCEPTION("emcore_mail_move failed [%d]", err); - goto FINISH_OFF; - } - - if (!emcore_insert_event(event_data, (int*)&handle, &err)) { - EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); - goto FINISH_OFF; - } - -FINISH_OFF: - /* emcore_free_event(event_data); */ /* all of members will be freed after using in each event handler */ - EM_SAFE_FREE(event_data); - - EM_DEBUG_FUNC_END(); - return SUCCESS; + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; } -INTERNAL_FUNC int emdaemon_move_mail(int mail_ids[], int num, emf_mailbox_t* dst_mailbox, int noti_param_1, int noti_param_2, int* err_code) +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) { - EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num[%d], dst_mailbox[%p], err_code[%p]", mail_ids, num, dst_mailbox, 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); /* default variable */ int mail_id = 0, *p = NULL, thread_error; - int ret = false, err = EMF_ERROR_NONE; - char *src_mailbox_name = NULL; + int ret = false, err = EMAIL_ERROR_NONE; emstorage_mail_tbl_t* mail_table_data = NULL; - emf_account_t* ref_account = NULL; - emf_event_t *event_data = NULL; + email_account_t* ref_account = NULL; + email_event_t *event_data = NULL; thread_t move_thread; + emstorage_mailbox_tbl_t *dest_mailbox_tbl = NULL; + int src_mailbox_id = 0; - if (num <= 0 || !dst_mailbox || dst_mailbox->account_id <= 0) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + if (num <= 0 || dst_mailbox_id <= 0) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - ref_account = emdaemon_get_account_reference(dst_mailbox->account_id); + if ((err = emstorage_get_mailbox_by_id(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 = emdaemon_get_account_reference(dest_mailbox_tbl->account_id); if (!ref_account) { - EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", dst_mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", dest_mailbox_tbl->account_id); + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } @@ -875,31 +941,31 @@ INTERNAL_FUNC int emdaemon_move_mail(int mail_ids[], int num, emf_mailbox_t* dst goto FINISH_OFF; } - if (src_mailbox_name == NULL) - src_mailbox_name = EM_SAFE_STRDUP(mail_table_data->mailbox_name); + if (src_mailbox_id == 0) + src_mailbox_id = mail_table_data->mailbox_id; emstorage_free_mail(&mail_table_data, 1, NULL); - if ((event_data = em_malloc(sizeof(emf_event_t)) ) == NULL) { + if ((event_data = em_malloc(sizeof(email_event_t)) ) == NULL) { EM_DEBUG_EXCEPTION("em_malloc for event_data failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } if ((p = em_malloc(sizeof(int) * num)) == NULL) { EM_DEBUG_EXCEPTION("em_malloc for p failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } memcpy(p, mail_ids, sizeof(int) * num); - event_data->account_id = dst_mailbox->account_id; - event_data->type = EMF_EVENT_MOVE_MAIL; - event_data->event_param_data_1 = EM_SAFE_STRDUP(dst_mailbox->name); - event_data->event_param_data_2 = EM_SAFE_STRDUP(src_mailbox_name); + event_data->account_id = dest_mailbox_tbl->account_id; + event_data->type = EMAIL_EVENT_MOVE_MAIL; event_data->event_param_data_3 = (char*)p; 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->event_param_data_6 = noti_param_1; event_data->event_param_data_7 = noti_param_2; @@ -937,19 +1003,20 @@ FINISH_OFF: if (err_code) *err_code = err; - EM_SAFE_FREE(src_mailbox_name); - + if (dest_mailbox_tbl) + emstorage_free_mailbox(&dest_mailbox_tbl, 1, NULL); + EM_DEBUG_FUNC_END("ret [%d]", ret); return ret; } -INTERNAL_FUNC int emdaemon_modify_flag(int mail_id, emf_mail_flag_t new_flag, int onserver, int sticky_flag, int* err_code) +INTERNAL_FUNC int emdaemon_modify_flag(int mail_id, email_mail_flag_t new_flag, int onserver, int sticky_flag, int* err_code) { EM_DEBUG_FUNC_BEGIN("mail_id[%d], new_flag[%d], onserver[%d], sticky_flag[%d], err_code[%p]", mail_id, new_flag, onserver, sticky_flag, err_code); /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!emcore_modify_flag(mail_id, new_flag, sticky_flag, &err)) { EM_DEBUG_EXCEPTION(" emcore_modify_flag falled [%d]", err); @@ -958,11 +1025,11 @@ INTERNAL_FUNC int emdaemon_modify_flag(int mail_id, emf_mail_flag_t new_flag, in #ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__ if( onserver == 1) { - emf_event_t event_data; + email_event_t event_data; unsigned handle = 0; - memset(&event_data, 0x00, sizeof(emf_event_t)); + memset(&event_data, 0x00, sizeof(email_event_t)); - event_data.type = EMF_EVENT_SYNC_MAIL_FLAG_TO_SERVER; + event_data.type = EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER; event_data.event_param_data_1 = NULL; event_data.event_param_data_4 = mail_id; event_data.account_id = 0; @@ -1013,12 +1080,12 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_modify_extra_flag(int mail_id, emf_extra_flag_t new_flag, int* err_code) +INTERNAL_FUNC int emdaemon_modify_extra_flag(int mail_id, email_extra_flag_t new_flag, int* err_code) { EM_DEBUG_FUNC_BEGIN("mail_id[%d], err_code[%p]", mail_id, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (!_emdaemon_check_mail_id(mail_id, &err)) { EM_DEBUG_EXCEPTION("_emdaemon_check_mail_id failed [%d]", err); @@ -1040,43 +1107,49 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_set_flags_field(int account_id, int mail_ids[], int num, emf_flags_field_type field_type, int value, int onserver, int* err_code) +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) { EM_DEBUG_FUNC_BEGIN("mail_ids[%d], num[%d], field_type [%d], value[%d], err_code[%p]", mail_ids[0], num, field_type, value, err_code); - int ret = false, err = EMF_ERROR_NONE; + int ret = false, err = EMAIL_ERROR_NONE; + emstorage_account_tbl_t *account_tbl = NULL; if(account_id <= 0 || !mail_ids || num <= 0) { - err = EMF_ERROR_INVALID_PARAM; - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - goto FINISH_OFF; - } + err = EMAIL_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + goto FINISH_OFF; + } + + if (!emstorage_get_account_by_id(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)) { EM_DEBUG_EXCEPTION("emcore_set_flags_field falled [%d]", err); goto FINISH_OFF; } - if( onserver ) { + if( onserver && account_tbl->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 ) { int *mail_id_array = NULL; - emf_event_t event_data = {0}; + email_event_t event_data = {0}; unsigned handle = 0; mail_id_array = em_malloc(sizeof(int) * num); if (mail_id_array == NULL) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } memcpy(mail_id_array, mail_ids, sizeof(int) * num); - event_data.type = EMF_EVENT_SYNC_FLAGS_FIELD_TO_SERVER; + event_data.type = EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER; event_data.account_id = account_id; event_data.event_param_data_1 = NULL; event_data.event_param_data_3 = (char*)mail_id_array; - event_data.event_param_data_4 = num; + event_data.event_param_data_4 = num; event_data.event_param_data_5 = field_type; event_data.event_param_data_6 = value; @@ -1089,6 +1162,10 @@ INTERNAL_FUNC int emdaemon_set_flags_field(int account_id, int mail_ids[], int n ret = true; FINISH_OFF: + + if (account_tbl) + emstorage_free_account(&account_tbl, 1, NULL); + if (err_code) *err_code = err; EM_DEBUG_FUNC_END(); @@ -1096,60 +1173,52 @@ FINISH_OFF: } -INTERNAL_FUNC int emdaemon_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t *input_meeting_request, int input_from_eas) +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) { 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 = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int handle = 0; - emf_event_t event_data = { 0 }; - emf_account_t *ref_account = NULL; + email_event_t event_data = { 0 }; + email_account_t *ref_account = NULL; if (!input_mail_data || input_mail_data->account_id <= 0 || input_mail_data->mail_id == 0 || - (input_mail_data->report_status == EMF_MAIL_REPORT_MDN && !input_mail_data->full_address_to)) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + (input_mail_data->report_status == EMAIL_MAIL_REPORT_MDN && !input_mail_data->full_address_to)) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } ref_account = emdaemon_get_account_reference(input_mail_data->account_id); if (!ref_account) { EM_DEBUG_LOG(" emdaemon_get_account_reference failed [%d]", input_mail_data->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE : - if ( (err = emcore_update_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err); - 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) { + EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err); + goto FINISH_OFF; + } #ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__ - if ( input_from_eas == 0) { - event_data.type = EMF_EVENT_UPDATE_MAIL; - event_data.account_id = input_mail_data->account_id; - event_data.event_param_data_1 = (char*)input_mail_data; - event_data.event_param_data_2 = (char*)input_attachment_data_list; - event_data.event_param_data_3 = (char*)input_meeting_request; - event_data.event_param_data_4 = input_attachment_count; - event_data.event_param_data_5 = input_from_eas; - - if (!emcore_insert_send_event(&event_data, &handle, &err)) { - EM_DEBUG_EXCEPTION("emcore_insert_send_event failed [%d]", err); - err = EMF_ERROR_NONE; - goto FINISH_OFF; - } - } -#endif - break; - - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; + if ( input_from_eas == 0) { + 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; + event_data.event_param_data_2 = (char*)input_attachment_data_list; + event_data.event_param_data_3 = (char*)input_meeting_request; + event_data.event_param_data_4 = input_attachment_count; + event_data.event_param_data_5 = input_from_eas; + + if (!emcore_insert_event_for_sending_mails(&event_data, &handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event_for_sending_mails failed [%d]", err); + err = EMAIL_ERROR_NONE; goto FINISH_OFF; + } } +#endif + FINISH_OFF: @@ -1163,7 +1232,7 @@ int _emdaemon_check_mail_id(int mail_id, int* err_code) EM_DEBUG_FUNC_BEGIN("mail_id[%d], err_code[%p]", mail_id, err_code); int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emstorage_mail_tbl_t* mail = NULL; @@ -1188,15 +1257,15 @@ FINISH_OFF: INTERNAL_FUNC int emdaemon_send_mail_retry( int mail_id, int timeout_in_sec, int* err_code) { int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; long nTimerValue = 0; char mail_id_string[10] = { 0, }; - emf_mailbox_t mailbox; + email_mailbox_t mailbox; emstorage_mail_tbl_t* mail_table_data = NULL; - emf_option_t opt; + email_option_t opt; - memset(&opt, 0x00, sizeof(emf_option_t)); - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); + memset(&opt, 0x00, sizeof(email_option_t)); + memset(&mailbox, 0x00, sizeof(email_mailbox_t)); if (!_emdaemon_check_mail_id(mail_id, &err)) { EM_DEBUG_EXCEPTION("_emdaemon_check_mail_id failed [%d]", err); @@ -1208,9 +1277,9 @@ INTERNAL_FUNC int emdaemon_send_mail_retry( int mail_id, int timeout_in_sec, in goto FINISH_OFF; } - mailbox.name = EM_SAFE_STRDUP(mail_table_data->mailbox_name); + mailbox.mailbox_name = EM_SAFE_STRDUP(mail_table_data->mailbox_name); - memcpy(&opt, emcore_get_option(&err), sizeof(emf_option_t)); + memcpy(&opt, emcore_get_option(&err), sizeof(email_option_t)); if( mail_table_data ) { mailbox.account_id = mail_table_data->account_id; @@ -1218,7 +1287,7 @@ INTERNAL_FUNC int emdaemon_send_mail_retry( int mail_id, int timeout_in_sec, in } if ( timeout_in_sec == 0 ) { - if(!emdaemon_send_mail(&mailbox, mail_id, &opt, NULL, &err)) { + if(!emdaemon_send_mail(mail_id, &opt, NULL, &err)) { EM_DEBUG_EXCEPTION("emdaemon_send_mail failed [%d]", err); goto FINISH_OFF; } @@ -1226,7 +1295,7 @@ INTERNAL_FUNC int emdaemon_send_mail_retry( int mail_id, int timeout_in_sec, in else if ( timeout_in_sec > 0 ) { sprintf(mail_id_string,"%d",mail_id); nTimerValue = timeout_in_sec * 1000; - if ( emcore_set_timer_ex(nTimerValue, (EMF_TIMER_CALLBACK) _OnMailSendRetryTimerCB, (void*)mail_id_string) <= 0) { + if ( emcore_set_timer_ex(nTimerValue, (EMAIL_TIMER_CALLBACK) _OnMailSendRetryTimerCB, (void*)mail_id_string) <= 0) { EM_DEBUG_EXCEPTION("Failed to start timer"); goto FINISH_OFF; } @@ -1240,7 +1309,7 @@ FINISH_OFF: if(mail_table_data) emstorage_free_mail(&mail_table_data, 1, NULL); - EM_SAFE_FREE(mailbox.name); + EM_SAFE_FREE(mailbox.mailbox_name); return ret; } @@ -1249,14 +1318,14 @@ FINISH_OFF: INTERNAL_FUNC void _OnMailSendRetryTimerCB( void* data ) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - emf_mailbox_t mailbox; + int err = EMAIL_ERROR_NONE; + email_mailbox_t mailbox; emstorage_mail_tbl_t* mail_table_data = NULL; int mail_id = 0 ; - emf_option_t opt; + email_option_t opt; - memset( &opt, 0x00, sizeof(emf_option_t)); - memset( &mailbox, 0x00, sizeof(emf_mailbox_t)); + memset( &opt, 0x00, sizeof(email_option_t)); + memset( &mailbox, 0x00, sizeof(email_mailbox_t)); if( !data ) { EM_DEBUG_LOG("Invalid param"); @@ -1276,15 +1345,15 @@ INTERNAL_FUNC void _OnMailSendRetryTimerCB( void* data ) goto FINISH_OFF; } - mailbox.name = EM_SAFE_STRDUP(mail_table_data->mailbox_name); - memcpy(&opt, emcore_get_option(&err), sizeof(emf_option_t)); + mailbox.mailbox_name = EM_SAFE_STRDUP(mail_table_data->mailbox_name); + memcpy(&opt, emcore_get_option(&err), sizeof(email_option_t)); if( mail_table_data ) { opt.priority = mail_table_data->priority; mailbox.account_id = mail_table_data->account_id; } - if(!emdaemon_send_mail(&mailbox, mail_id, &opt, NULL, &err)) { + if(!emdaemon_send_mail(mail_id, &opt, NULL, &err)) { EM_DEBUG_EXCEPTION("emdaemon_send_mail failed [%d]", err); goto FINISH_OFF; } @@ -1293,28 +1362,29 @@ FINISH_OFF: if(mail_table_data) emstorage_free_mail(&mail_table_data, 1, NULL); - EM_SAFE_FREE(mailbox.name); + EM_SAFE_FREE(mailbox.mailbox_name); EM_DEBUG_FUNC_END(); return; } -INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, char *target_mailbox_name, int move_always_flag, int *err_code) +INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, int target_mailbox_id, int move_always_flag, int *err_code) { - EM_DEBUG_FUNC_BEGIN("thread_id [%d], target_mailbox_name [%p], move_always_flag [%d], err_code [%p]", thread_id, target_mailbox_name, move_always_flag, 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; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int *mail_id_list = NULL, result_count = 0, i, mailbox_count = 0, account_id; - emf_mail_list_item_t *mail_list = NULL; - emf_mailbox_t *target_mailbox_list = NULL, *target_mailbox = NULL; + email_mail_list_item_t *mail_list = NULL; + email_mailbox_t *target_mailbox_list = NULL, *target_mailbox = NULL; + char mailbox_id_param_string[10] = {0,}; - if (!target_mailbox_name) { - EM_DEBUG_EXCEPTION("target_mailbox [%p]", target_mailbox_name); - err = EMF_ERROR_INVALID_PARAM; + if (target_mailbox_id == 0) { + EM_DEBUG_EXCEPTION("target_mailbox_id [%d]", target_mailbox_id); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - if (!emstorage_get_mail_list(0, NULL, NULL, thread_id, -1, -1, 0, NULL, EMF_SORT_DATETIME_HIGH, true, &mail_list, &result_count, &err) || !mail_list || !result_count) { + 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) { EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err); goto FINISH_OFF; @@ -1324,7 +1394,7 @@ INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, char *targ if (mail_id_list == NULL) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -1340,8 +1410,8 @@ INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, char *targ } for(i = 0; i < mailbox_count; i++) { - EM_DEBUG_LOG("%s %s", target_mailbox_list[i].name, target_mailbox_name); - if(strcmp(target_mailbox_list[i].name, target_mailbox_name) == 0) { + EM_DEBUG_LOG("%s %d", target_mailbox_list[i].mailbox_name, target_mailbox_id); + if(target_mailbox_list[i].mailbox_id == target_mailbox_id) { target_mailbox = (target_mailbox_list + i); break; } @@ -1352,19 +1422,19 @@ INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, char *targ goto FINISH_OFF; } - if (!emdaemon_move_mail(mail_id_list, result_count, target_mailbox, EMF_MOVED_BY_MOVING_THREAD, move_always_flag, &err)) { + if (!emdaemon_move_mail(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; } - - if (!emstorage_notify_storage_event(NOTI_THREAD_MOVE, account_id, thread_id, target_mailbox_name, move_always_flag)) + + SNPRINTF(mailbox_id_param_string, 10, "%d", target_mailbox->mailbox_id); + if (!emstorage_notify_storage_event(NOTI_THREAD_MOVE, account_id, thread_id, mailbox_id_param_string, move_always_flag)) EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event Failed [NOTI_MAIL_MOVE] >>>> "); ret = true; FINISH_OFF: - if (!emcore_free_mailbox(&target_mailbox_list, mailbox_count, &err)) - EM_DEBUG_EXCEPTION("target_mailbox_list failed [%d]", err); + emcore_free_mailbox_list(&target_mailbox_list, mailbox_count); EM_SAFE_FREE(mail_list); EM_SAFE_FREE(mail_id_list); @@ -1378,11 +1448,12 @@ INTERNAL_FUNC int emdaemon_delete_mail_thread(int thread_id, int delete_always_f { 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 = EMF_ERROR_NONE; - int account_id, *mail_id_list = NULL, result_count = 0, i; - emf_mail_list_item_t *mail_list = NULL; + int err = EMAIL_ERROR_NONE; + int account_id = 0; + int mailbox_id, *mail_id_list = NULL, result_count = 0, i; + email_mail_list_item_t *mail_list = NULL; - if (!emstorage_get_mail_list(0, NULL, NULL, thread_id, -1, -1, 0, NULL, EMF_SORT_MAILBOX_NAME_HIGH, true, &mail_list, &result_count, &err) || !mail_list || !result_count) { + if (!emstorage_get_mail_list(0, 0, NULL, thread_id, -1, -1, 0, NULL, EMAIL_SORT_MAILBOX_NAME_HIGH, true, &mail_list, &result_count, &err) || !mail_list || !result_count) { EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err); goto FINISH_OFF; @@ -1392,7 +1463,7 @@ INTERNAL_FUNC int emdaemon_delete_mail_thread(int thread_id, int delete_always_f if (mail_id_list == NULL) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -1401,16 +1472,17 @@ 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(account_id, NULL, mail_id_list, result_count, false, handle, &err)) { + if (!emdaemon_delete_mail(mailbox_id, mail_id_list, result_count, false, handle, &err)) { EM_DEBUG_EXCEPTION("emdaemon_delete_mail failed [%d]", err); goto FINISH_OFF; } if (!emstorage_notify_storage_event(NOTI_THREAD_DELETE, account_id, thread_id, NULL, delete_always_flag)) - EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event Failed [NOTI_MAIL_MOVE] >>>> "); + EM_DEBUG_EXCEPTION(" emstorage_notify_storage_event Failed [NOTI_THREAD_DELETE] >>>> "); ret = true; @@ -1428,11 +1500,11 @@ INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_fl { 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; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int account_id, *mail_id_list = NULL, result_count = 0, i; - emf_mail_list_item_t *mail_list = NULL; + email_mail_list_item_t *mail_list = NULL; - if (!emstorage_get_mail_list(0, NULL, NULL, thread_id, -1, -1, 0, NULL, EMF_SORT_MAILBOX_NAME_HIGH, true, &mail_list, &result_count, &err) || !mail_list || !result_count) { + if (!emstorage_get_mail_list(0, 0, NULL, thread_id, -1, -1, 0, NULL, EMAIL_SORT_MAILBOX_NAME_HIGH, true, &mail_list, &result_count, &err) || !mail_list || !result_count) { EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err); goto FINISH_OFF; @@ -1442,7 +1514,7 @@ INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_fl if (mail_id_list == NULL) { EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } @@ -1452,7 +1524,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, EMF_FLAGS_SEEN_FIELD, seen_flag, on_server, &err)) { + if (!emdaemon_set_flags_field(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; } @@ -1471,3 +1543,57 @@ FINISH_OFF: EM_DEBUG_FUNC_END(); return ret; } + +INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, unsigned *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; + int handle = 0; + email_event_t event_data = { 0 }; + email_account_t *ref_account = NULL; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; + + if (input_mailbox_id <= 0) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err); + goto FINISH_OFF; + } + + ref_account = emdaemon_get_account_reference(mailbox_tbl->account_id); + if (!ref_account) { + EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", mailbox_tbl->account_id); + err = EMAIL_ERROR_INVALID_ACCOUNT; + goto FINISH_OFF; + } + +#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__ + if(input_on_server) { + 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; + + if (!emcore_insert_event(&event_data, &handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); + goto FINISH_OFF; + } + } + else +#endif + if ( (err = emcore_expunge_mails_deleted_flagged_from_local_storage(input_mailbox_id)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emcore_expunge_mails_deleted_flagged_from_local_storage failed [%d]", err); + goto FINISH_OFF; + } + +FINISH_OFF: + + if(mailbox_tbl) + emstorage_free_mailbox(&mailbox_tbl, 1, NULL); + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} diff --git a/email-daemon/email-daemon-mailbox.c b/email-daemon/email-daemon-mailbox.c index 049c419..491477d 100755 --- a/email-daemon/email-daemon-mailbox.c +++ b/email-daemon/email-daemon-mailbox.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Kyuho Jo , Sunghyun Kwon -* +* * 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 @@ -25,7 +25,7 @@ * File: email-daemon-mailbox.c * Desc: email-daemon Mailbox Operation * - * Auth: + * Auth: * * History: * 2006.08.16 : created @@ -52,41 +52,32 @@ INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(int account_id, char* mailbox, /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (account_id <= 0 ||!mailbox) { EM_DEBUG_EXCEPTION("account_id[%d], mailbox[%p]", account_id, mailbox); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - emf_account_t* ref_account = emdaemon_get_account_reference(account_id); - + email_account_t* ref_account = emdaemon_get_account_reference(account_id); + if (!ref_account) { EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - emf_event_t event_data; - memset(&event_data, 0x00, sizeof(emf_event_t)); - - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - event_data.type = EMF_EVENT_SYNC_IMAP_MAILBOX; - event_data.account_id = account_id; - event_data.event_param_data_3 = EM_SAFE_STRDUP(mailbox); + email_event_t event_data; + memset(&event_data, 0x00, sizeof(email_event_t)); - if (!emcore_insert_event(&event_data, (int*)handle, &err)) { - EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); - goto FINISH_OFF; - } - break; + event_data.type = EMAIL_EVENT_SYNC_IMAP_MAILBOX; + event_data.account_id = account_id; + event_data.event_param_data_3 = EM_SAFE_STRDUP(mailbox); - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; - goto FINISH_OFF; + if (!emcore_insert_event(&event_data, (int*)handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); + goto FINISH_OFF; } ret = true; @@ -99,45 +90,36 @@ FINISH_OFF: } - -INTERNAL_FUNC int emdaemon_get_mailbox_list(int account_id, emf_mailbox_t** mailbox_list, int* count, int* err_code) + +INTERNAL_FUNC int emdaemon_get_mailbox_list(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); - + int ret = false; - int err = EMF_ERROR_NONE; - + int err = EMAIL_ERROR_NONE; + if (account_id <= 0 || !mailbox_list || !count) { EM_DEBUG_EXCEPTION("account_id[%d], mailbox_list[%p], count[%p]", account_id, mailbox_list, count); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - - emf_account_t* ref_account = emdaemon_get_account_reference(account_id); - + + email_account_t* ref_account = emdaemon_get_account_reference(account_id); + if (!ref_account) { EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - if (!emcore_get_list(account_id, mailbox_list, count, &err)) { - EM_DEBUG_EXCEPTION("emcore_get_list failed [%d]", err); - goto FINISH_OFF; - } - break; - - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; - goto FINISH_OFF; + + if (!emcore_get_list(account_id, mailbox_list, count, &err)) { + EM_DEBUG_EXCEPTION("emcore_get_list failed [%d]", err); + goto FINISH_OFF; } ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -146,43 +128,35 @@ FINISH_OFF: } -INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(emf_mailbox_t* mailbox, int* total, int* unseen, int* err_code) +INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(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); - + /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; - + int err = EMAIL_ERROR_NONE; + if (!mailbox || !total || !unseen) { EM_DEBUG_EXCEPTION("mailbox[%p], total[%p], unseen[%p]", mailbox, total, unseen); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - - emf_account_t* ref_account = emdaemon_get_account_reference(mailbox->account_id); - if (ref_account == NULL) { + + email_account_t* ref_account = emdaemon_get_account_reference(mailbox->account_id); + if (ref_account == NULL) { EM_DEBUG_EXCEPTION(" emdaemon_get_account_reference failed [%d]", mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - if (!emcore_get_mail_count(mailbox, total, unseen, &err)) { - EM_DEBUG_EXCEPTION("emcore_get_mail_count failed [%d]", err); - goto FINISH_OFF; - } - break; - - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; - goto FINISH_OFF; + + if (!emcore_get_mail_count(mailbox, total, unseen, &err)) { + EM_DEBUG_EXCEPTION("emcore_get_mail_count failed [%d]", err); + goto FINISH_OFF; } - + + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -190,66 +164,57 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_add_mailbox(emf_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code) +INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code) { EM_DEBUG_FUNC_BEGIN("new_mailbox[%p], err_code[%p]", new_mailbox, err_code); - + int ret = false;; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (!new_mailbox || new_mailbox->account_id <= 0 || !new_mailbox->name) { + if (!new_mailbox || new_mailbox->account_id <= 0 || !new_mailbox->mailbox_name) { if (new_mailbox != NULL) - EM_DEBUG_EXCEPTION("new_mailbox->account_id[%d], new_mailbox->name[%p]", new_mailbox->account_id, new_mailbox->name); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("new_mailbox->account_id[%d], new_mailbox->mailbox_name[%p]", new_mailbox->account_id, new_mailbox->mailbox_name); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - emf_account_t* ref_account = emdaemon_get_account_reference(new_mailbox->account_id); + email_account_t* ref_account = emdaemon_get_account_reference(new_mailbox->account_id); if (!ref_account) { EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", new_mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - emf_event_t event_data; - memset(&event_data, 0x00, sizeof(emf_event_t)); - - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - /* on_server is allowed to be only 0 when server_type is EMF_SERVER_TYPE_ACTIVE_SYNC */ - if ( ref_account->receiving_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) - on_server = 0; - - if ( on_server ) { /* async */ - event_data.type = EMF_EVENT_CREATE_MAILBOX; - event_data.account_id = new_mailbox->account_id; - event_data.event_param_data_1 = EM_SAFE_STRDUP(new_mailbox->name); - event_data.event_param_data_2 = EM_SAFE_STRDUP(new_mailbox->alias); - event_data.event_param_data_4 = on_server; - event_data.event_param_data_3 = GINT_TO_POINTER(new_mailbox->mailbox_type); - 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, &err)) { - EM_DEBUG_EXCEPTION("emcore_create failed [%d]", err); - goto FINISH_OFF; - } - } - break; - - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - - err = EMF_ERROR_INVALID_ACCOUNT; + email_event_t event_data; + memset(&event_data, 0x00, sizeof(email_event_t)); + + + /* on_server is allowed to be only 0 when server_type is EMAIL_SERVER_TYPE_ACTIVE_SYNC */ + if ( ref_account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) + on_server = 0; + + if ( on_server ) { /* async */ + event_data.type = EMAIL_EVENT_CREATE_MAILBOX; + event_data.account_id = new_mailbox->account_id; + event_data.event_param_data_1 = EM_SAFE_STRDUP(new_mailbox->mailbox_name); + event_data.event_param_data_2 = EM_SAFE_STRDUP(new_mailbox->alias); + event_data.event_param_data_4 = on_server; + event_data.event_param_data_3 = GINT_TO_POINTER(new_mailbox->mailbox_type); + 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, &err)) { + EM_DEBUG_EXCEPTION("emcore_create failed [%d]", err); + goto FINISH_OFF; + } + } + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -258,80 +223,71 @@ FINISH_OFF: } -INTERNAL_FUNC int emdaemon_update_mailbox(emf_mailbox_t* old_mailbox, emf_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code) +INTERNAL_FUNC int emdaemon_update_mailbox(email_mailbox_t* old_mailbox, email_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code) { EM_DEBUG_FUNC_BEGIN("old_mailbox[%p], new_mailbox[%p], on_server[%d], handle[%p], err_code[%p]", old_mailbox, new_mailbox, on_server, handle, err_code); - + /* default variable */ int ret = false;; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (!old_mailbox || old_mailbox->account_id <= 0 || !old_mailbox->name - || !new_mailbox || new_mailbox->account_id <= 0 || !new_mailbox->name) { + if (!old_mailbox || old_mailbox->account_id <= 0 || !old_mailbox->mailbox_name + || !new_mailbox || new_mailbox->account_id <= 0 || !new_mailbox->mailbox_name) { EM_DEBUG_EXCEPTION("INVALID PARAM"); if (old_mailbox != NULL) - EM_DEBUG_EXCEPTION("old_mailbox->account_id[%d], old_mailbox->name[%p]", old_mailbox->account_id, old_mailbox->name); + EM_DEBUG_EXCEPTION("old_mailbox->account_id[%d], old_mailbox->mailbox_name[%p]", old_mailbox->account_id, old_mailbox->mailbox_name); if (new_mailbox != NULL) - EM_DEBUG_EXCEPTION("new_mailbox->account_id[%d], new_mailbox->name[%p]", new_mailbox->account_id, new_mailbox->name); + EM_DEBUG_EXCEPTION("new_mailbox->account_id[%d], new_mailbox->mailbox_name[%p]", new_mailbox->account_id, new_mailbox->mailbox_name); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - - emf_account_t* ref_account = emdaemon_get_account_reference(old_mailbox->account_id); - + + email_account_t* ref_account = emdaemon_get_account_reference(old_mailbox->account_id); + if (!ref_account) { EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", old_mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; /* instead of EMF_ERROR_INVALID_PARAM; */ + err = EMAIL_ERROR_INVALID_ACCOUNT; /* instead of EMAIL_ERROR_INVALID_PARAM; */ goto FINISH_OFF; } - emf_event_t event_data; - memset(&event_data, 0x00, sizeof(emf_event_t)); - - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - /* Unsupport sync with server */ - /* on_server is allowed to be only 0 when server_type is EMF_SERVER_TYPE_ACTIVE_SYNC */ - /* - if ( ref_account->receiving_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) { - on_server = 0; - } - if ( on_server ) { - event_data.type = EMF_EVENT_UPDATE_MAILBOX; - event_data.account_id = new_mailbox->account_id; - event_data.event_param_data_1 = ; - event_data.event_param_data_2 = ; - event_data.event_param_data_4 = on_server; - event_data.event_param_data_3 = GINT_TO_POINTER(new_mailbox->mailbox_type); - if(!emcore_insert_event(&event_data, handle, &err)) { - EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); - goto FINISH_OFF; - } - } - else { - if (!emcore_modify(old_mailbox, new_mailbox, on_server, &err)) { - EM_DEBUG_EXCEPTION("emcore_create failed [%d]", err); - goto FINISH_OFF; - } - } - */ - /* Update mailbox information only on local db */ - if (!emcore_update_mailbox(old_mailbox, new_mailbox, &err)) { - EM_DEBUG_EXCEPTION("emcore_modify failed [%d]", err); - goto FINISH_OFF; - } - break; - - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - - err = EMF_ERROR_INVALID_ACCOUNT; + email_event_t event_data; + memset(&event_data, 0x00, sizeof(email_event_t)); + + + /* Unsupport sync with server */ + /* on_server is allowed to be only 0 when server_type is EMAIL_SERVER_TYPE_ACTIVE_SYNC */ + /* + if ( ref_account->receiving_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) { + on_server = 0; + } + if ( on_server ) { + event_data.type = EMAIL_EVENT_UPDATE_MAILBOX; + event_data.account_id = new_mailbox->account_id; + event_data.event_param_data_1 = ; + event_data.event_param_data_2 = ; + event_data.event_param_data_4 = on_server; + event_data.event_param_data_3 = GINT_TO_POINTER(new_mailbox->mailbox_type); + if(!emcore_insert_event(&event_data, handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); goto FINISH_OFF; + } } - + else { + if (!emcore_modify(old_mailbox, new_mailbox, on_server, &err)) { + EM_DEBUG_EXCEPTION("emcore_create failed [%d]", err); + goto FINISH_OFF; + } + } + */ + /* Update mailbox information only on local db */ + if (!emcore_update_mailbox(old_mailbox, new_mailbox, &err)) { + EM_DEBUG_EXCEPTION("emcore_modify failed [%d]", err); + goto FINISH_OFF; + } + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -339,68 +295,97 @@ FINISH_OFF: return ret; } +INTERNAL_FUNC int emdaemon_set_mailbox_type(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); + + /* default variable */ + int err = EMAIL_ERROR_NONE; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; + + if (!input_mailbox_id) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + if ( (err = emstorage_get_mailbox_by_id(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, mailbox_tbl->mailbox_name, 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); + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} + -INTERNAL_FUNC int emdaemon_delete_mailbox(emf_mailbox_t* mailbox, int on_server, unsigned* handle, int* err_code) +INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, unsigned* handle, int* err_code) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], err_code[%p]", mailbox, err_code); + EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], err_code[%p]", input_mailbox_id, err_code); /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + emstorage_mailbox_tbl_t *mailbox_tbl = NULL; - if (!mailbox || mailbox->account_id <= 0) { - if (mailbox != NULL) - EM_DEBUG_EXCEPTION("mailbox->account_id[%d]", mailbox->account_id); - err = EMF_ERROR_INVALID_PARAM; + if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err); + goto FINISH_OFF; + } + + if (!input_mailbox_id || mailbox_tbl->account_id <= 0) { + if (input_mailbox_id != 0) + EM_DEBUG_EXCEPTION("mailbox_tbl->account_id[%d]", mailbox_tbl->account_id); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - emf_account_t* ref_account = emdaemon_get_account_reference(mailbox->account_id); + email_account_t* ref_account = emdaemon_get_account_reference(mailbox_tbl->account_id); if (!ref_account) { - EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", mailbox_tbl->account_id); + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - emf_event_t event_data; - memset(&event_data, 0x00, sizeof(emf_event_t)); - - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - /* on_server is allowed to be only 0 when server_type is EMF_SERVER_TYPE_ACTIVE_SYNC */ - if ( ref_account->receiving_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) { - on_server = 0; - } - if ( on_server ) { /* async */ - event_data.type = EMF_EVENT_DELETE_MAILBOX; - event_data.account_id = mailbox->account_id; - event_data.event_param_data_1 = EM_SAFE_STRDUP(mailbox->name); - event_data.event_param_data_4 = on_server; - if(!emcore_insert_event(&event_data, (int*)handle, &err)) { - EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err); - goto FINISH_OFF; - } - } + email_event_t event_data; + memset(&event_data, 0x00, sizeof(email_event_t)); - else { - if (!emcore_delete_mailbox(mailbox, on_server, &err)) { - EM_DEBUG_EXCEPTION("emcore_delete failed [%d]", err); - goto FINISH_OFF; - } - } - break; - - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; + /* on_server is allowed to be only 0 when server_type is EMAIL_SERVER_TYPE_ACTIVE_SYNC */ + if ( ref_account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) { + on_server = 0; + } + if ( on_server ) { /* async */ + event_data.type = EMAIL_EVENT_DELETE_MAILBOX; + event_data.account_id = mailbox_tbl->account_id; + event_data.event_param_data_4 = input_mailbox_id; + event_data.event_param_data_5 = on_server; + 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, &err)) { + EM_DEBUG_EXCEPTION("emcore_delete failed [%d]", err); + goto FINISH_OFF; + } + } + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -408,46 +393,37 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_delete_mailbox_all(emf_mailbox_t* mailbox, int* err_code) +INTERNAL_FUNC int emdaemon_delete_mailbox_all(email_mailbox_t* mailbox, int* err_code) { EM_DEBUG_FUNC_BEGIN("malibox[%p], err_code[%p]", mailbox, err_code); - + /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; - + int err = EMAIL_ERROR_NONE; + if (!mailbox || mailbox->account_id <= 0) { if (mailbox == NULL) EM_DEBUG_EXCEPTION("malibox->account_id[%d]", mailbox->account_id); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - - emf_account_t* ref_account = emdaemon_get_account_reference(mailbox->account_id); - + + email_account_t* ref_account = emdaemon_get_account_reference(mailbox->account_id); + if (!ref_account) { EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - if (!emcore_delete_mailbox_all(mailbox, &err)) { - EM_DEBUG_EXCEPTION("emcore_delete_all failed [%d]", err); - goto FINISH_OFF; - } - break; - - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; - goto FINISH_OFF; + + if (!emcore_delete_mailbox_all(mailbox, &err)) { + EM_DEBUG_EXCEPTION("emcore_delete_all failed [%d]", err); + goto FINISH_OFF; } - + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -455,42 +431,34 @@ FINISH_OFF: return ret; } - - -INTERNAL_FUNC int emdaemon_free_mailbox(emf_mailbox_t** mailbox_list, int count, int* err_code) -{ - EM_DEBUG_FUNC_BEGIN(); - return emcore_free_mailbox(mailbox_list, count, err_code); -} - -INTERNAL_FUNC int emdaemon_sync_header(emf_mailbox_t* mailbox, unsigned* handle, int* err_code) +INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle, int* err_code) { - EM_DEBUG_FUNC_BEGIN("mailbox[%p], handle[%p], err_code[%p]", mailbox, handle, 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); /* default variable */ int ret = false; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - if (!mailbox ) { - EM_DEBUG_EXCEPTION("mailbox[%p]", mailbox); - err = EMF_ERROR_INVALID_PARAM; + email_event_t event_data; + email_account_t* ref_account = NULL; + + memset(&event_data, 0x00, sizeof(email_event_t)); + + if (input_mailbox_id < 0) { + EM_DEBUG_EXCEPTION("parameter is invalid"); + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } - emf_event_t event_data; - emf_account_t* ref_account = NULL; - - memset(&event_data, 0x00, sizeof(emf_event_t)); - if(mailbox->account_id == ALL_ACCOUNT) { + if(input_account_id == ALL_ACCOUNT) { EM_DEBUG_LOG(">>>> emdaemon_sync_header for all account event_data.event_param_data_4 [%d]", event_data.event_param_data_4); - event_data.type = EMF_EVENT_SYNC_HEADER; - event_data.event_param_data_1 = mailbox ? EM_SAFE_STRDUP(mailbox->name) : NULL; - event_data.event_param_data_3 = NULL; - event_data.account_id = mailbox->account_id; - /* In case of Mailbox NULL, we need to set arg as EMF_SYNC_ALL_MAILBOX */ - if (!event_data.event_param_data_1) - event_data.event_param_data_4 = EMF_SYNC_ALL_MAILBOX; + event_data.type = EMAIL_EVENT_SYNC_HEADER; + event_data.account_id = input_account_id; + event_data.event_param_data_5 = input_mailbox_id; + /* 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; if (!emcore_insert_event(&event_data, (int*)handle, &err)) { EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err); @@ -499,44 +467,34 @@ INTERNAL_FUNC int emdaemon_sync_header(emf_mailbox_t* mailbox, unsigned* handle } else { - if (!(ref_account = emdaemon_get_account_reference(mailbox->account_id))) { - EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", mailbox->account_id); - err = EMF_ERROR_INVALID_ACCOUNT; + if (!(ref_account = emdaemon_get_account_reference(input_account_id))) { + EM_DEBUG_EXCEPTION("emdaemon_get_account_reference failed [%d]", input_account_id); + err = EMAIL_ERROR_INVALID_ACCOUNT; goto FINISH_OFF; } /* Modified the code to sync all mailbox in a Single Event */ - switch (ref_account->account_bind_type) { - case EMF_BIND_TYPE_EM_CORE: - event_data.type = EMF_EVENT_SYNC_HEADER; - event_data.event_param_data_1 = mailbox ? EM_SAFE_STRDUP(mailbox->name) : NULL; - event_data.event_param_data_3 = NULL; - event_data.account_id = mailbox->account_id; - /* In case of Mailbox NULL, we need to set arg as EMF_SYNC_ALL_MAILBOX */ - if (!event_data.event_param_data_1) - event_data.event_param_data_4 = EMF_SYNC_ALL_MAILBOX; - EM_DEBUG_LOG(">>>> EVENT ARG [ %d ] ", event_data.event_param_data_4); - - if (!emcore_insert_event(&event_data, (int*)handle, &err)) { - EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err); - goto FINISH_OFF; - } - break; - - default: - EM_DEBUG_EXCEPTION("unknown account bind type..."); - err = EMF_ERROR_INVALID_ACCOUNT; - goto FINISH_OFF; + event_data.type = EMAIL_EVENT_SYNC_HEADER; + event_data.account_id = input_account_id; + event_data.event_param_data_5 = input_mailbox_id; + /* 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; + EM_DEBUG_LOG(">>>> EVENT ARG [ %d ] ", event_data.event_param_data_4); + + if (!emcore_insert_event(&event_data, (int*)handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err); + goto FINISH_OFF; } } - -#ifdef __FEATURE_LOCAL_ACTIVITY__ + +#ifdef __FEATURE_LOCAL_ACTIVITY__ EM_DEBUG_LOG("Setting g_local_activity_run "); - g_local_activity_run = 1; + g_local_activity_run = 1; #endif - + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -544,34 +502,34 @@ FINISH_OFF: return ret; } -INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, char* mailbox_name, int new_slot_size, unsigned* handle, int *err_code) +INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, int mailbox_id, int new_slot_size, unsigned* handle, int *err_code) { - EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_name[%p], handle[%p], err_code[%p]", account_id, mailbox_name, handle, err_code); + EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_id[%d], handle[%p], err_code[%p]", account_id, mailbox_id, handle, err_code); int ret = false; - int err = EMF_ERROR_NONE; - emf_event_t event_data; + int err = EMAIL_ERROR_NONE; + email_event_t event_data; if(handle == NULL) { EM_DEBUG_EXCEPTION("handle is required"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - memset(&event_data, 0x00, sizeof(emf_event_t)); + memset(&event_data, 0x00, sizeof(email_event_t)); - event_data.type = EMF_EVENT_SET_MAIL_SLOT_SIZE; - event_data.event_param_data_4 = new_slot_size; - event_data.event_param_data_3 = EM_SAFE_STRDUP(mailbox_name); + event_data.type = EMAIL_EVENT_SET_MAIL_SLOT_SIZE; event_data.account_id = account_id; - + event_data.event_param_data_4 = mailbox_id; + event_data.event_param_data_5 = new_slot_size; + if (!emcore_insert_event(&event_data, (int*)handle, &err)) { EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err); goto FINISH_OFF; } - + ret = true; - + FINISH_OFF: if (err_code) *err_code = err; @@ -579,3 +537,62 @@ FINISH_OFF: return ret; } +INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mailbox_path, char *input_mailbox_alias, int input_on_server, unsigned *output_handle) +{ + EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_mailbox_path [%p], input_mailbox_alias[%p], input_on_server [%d], output_handle[%p]", input_mailbox_id, input_mailbox_path, input_mailbox_alias, input_on_server, output_handle); + + int err = EMAIL_ERROR_NONE; + emstorage_account_tbl_t *account_data = NULL; + emstorage_mailbox_tbl_t *old_mailbox_data = NULL; + email_event_t event_data; + + if(input_mailbox_id <= 0 || output_handle == NULL) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + if (input_on_server) { + if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &old_mailbox_data)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err); + goto FINISH_OFF; + } + } + + if ((err = emstorage_rename_mailbox(input_mailbox_id, input_mailbox_path, input_mailbox_alias, true)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emstorage_rename_mailbox failed [%d]", err); + goto FINISH_OFF; + } + + if (input_on_server) { + if (!emstorage_get_account_by_id(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; + } + + if (account_data->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) { + memset(&event_data, 0x00, sizeof(email_event_t)); + + event_data.type = EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER; + event_data.event_param_data_1 = EM_SAFE_STRDUP(old_mailbox_data->mailbox_name); + event_data.event_param_data_2 = EM_SAFE_STRDUP(input_mailbox_path); + event_data.event_param_data_4 = input_mailbox_id; + event_data.account_id = old_mailbox_data->account_id; + + if (!emcore_insert_event(&event_data, (int*)output_handle, &err)) { + EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err); + goto FINISH_OFF; + } + } + } + +FINISH_OFF: + if (old_mailbox_data) + emstorage_free_mailbox(&old_mailbox_data, 1, NULL); + + if (account_data) + emstorage_free_account(&account_data, 1, NULL); + + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} diff --git a/email-daemon/include/.gitignore b/email-daemon/include/.gitignore new file mode 100644 index 0000000..f42dfd4 --- /dev/null +++ b/email-daemon/include/.gitignore @@ -0,0 +1,2 @@ +contact-engine-h +filemanager-service-h diff --git a/email-daemon/include/email-daemon-account.h b/email-daemon/include/email-daemon-account.h index c6ea1d3..04f5836 100755 --- a/email-daemon/include/email-daemon-account.h +++ b/email-daemon/include/email-daemon-account.h @@ -40,7 +40,7 @@ extern "C" #include "email-daemon.h" int emdaemon_initialize_account_reference(); -emf_account_t* emdaemon_get_account_reference(int account_id); +email_account_t* emdaemon_get_account_reference(int account_id); int emdaemon_free_account_reference(void); #ifdef __cplusplus diff --git a/email-daemon/include/email-daemon-emn.h b/email-daemon/include/email-daemon-emn.h index 3607cf7..b11dc4d 100755 --- a/email-daemon/include/email-daemon-emn.h +++ b/email-daemon/include/email-daemon-emn.h @@ -83,7 +83,7 @@ int emdaemon_finalize_emn(int bExtDest); * @remarks N/A * @return This function returns true on success or false on failure. */ -typedef int (*emf_emn_noti_cb)( +typedef int (*email_emn_noti_cb)( void* user_data, int err_code ); @@ -98,7 +98,7 @@ typedef int (*emf_emn_noti_cb)( * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_handle_emn_notification(unsigned char* wbxml_b64, emf_emn_noti_cb callback, int* err_code); +INTERNAL_FUNC int emdaemon_handle_emn_notification(unsigned char* wbxml_b64, email_emn_noti_cb callback, int* err_code); #endif #ifdef __cplusplus diff --git a/email-daemon/include/email-daemon.h b/email-daemon/include/email-daemon.h index 4f3f213..d54ab1d 100755 --- a/email-daemon/include/email-daemon.h +++ b/email-daemon/include/email-daemon.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Kyuho Jo , Sunghyun Kwon -* +* * 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 @@ -48,7 +48,7 @@ #include #ifdef __cplusplus -extern "C" +extern "C" { #endif /* __cplusplus */ @@ -80,12 +80,12 @@ INTERNAL_FUNC int emdaemon_finalize(int* err_code); /** * Create a new email account. * - * @param[in] account Specifies the structure pointer of account. + * @param[in] account Specifies the structure pointer of account. * @param[out] err_code Specifies the error code returned. * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_create_account(emf_account_t* account, int* err_code); +INTERNAL_FUNC int emdaemon_create_account(email_account_t* account, int* err_code); /** * Delete a email account. @@ -116,7 +116,7 @@ INTERNAL_FUNC int emdaemon_validate_account(int account_id, unsigned* handle, in * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_update_account(int account_id, emf_account_t* new_account, int* err_code); +INTERNAL_FUNC int emdaemon_update_account(int account_id, email_account_t* new_account, int* err_code); /** * Change the information of a email account after validation @@ -128,7 +128,7 @@ INTERNAL_FUNC int emdaemon_update_account(int account_id, emf_account_t* new_acc * @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, emf_account_t* new_account_info, unsigned* handle,int *err_code); +INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email_account_t* new_account_info, unsigned* handle,int *err_code); /** * Get a email account by ID. @@ -140,7 +140,7 @@ INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, emf_a * @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, emf_account_t** acount, int* err_code); +INTERNAL_FUNC int emdaemon_get_account(int account_id, int pulloption, email_account_t* acount, int* err_code); /** * Get all emails. @@ -151,7 +151,7 @@ INTERNAL_FUNC int emdaemon_get_account(int account_id, int pulloption, emf_accou * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_get_account_list(emf_account_t** acount_list, int* count, int* err_code); +INTERNAL_FUNC int emdaemon_get_account_list(email_account_t** acount_list, int* count, int* err_code); /** * Free allocated memory. @@ -162,7 +162,7 @@ INTERNAL_FUNC int emdaemon_get_account_list(emf_account_t** acount_list, int* co * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_free_account(emf_account_t** account_list, int count, int* err_code); +INTERNAL_FUNC int emdaemon_free_account(email_account_t** account_list, int count, int* err_code); /** * Get a information of filtering. @@ -173,7 +173,7 @@ INTERNAL_FUNC int emdaemon_free_account(emf_account_t** account_list, int count, * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_get_filter(int filter_id, emf_rule_t** filtering_set, int* err_code); +INTERNAL_FUNC int emdaemon_get_filter(int filter_id, email_rule_t** filtering_set, int* err_code); /** * Get all filterings. @@ -184,7 +184,7 @@ INTERNAL_FUNC int emdaemon_get_filter(int filter_id, emf_rule_t** filtering_set, * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_get_filter_list(emf_rule_t** filtering_set, int* count, int* err_code); +INTERNAL_FUNC int emdaemon_get_filter_list(email_rule_t** filtering_set, int* count, int* err_code); /** * find a filter already exists. @@ -194,7 +194,7 @@ INTERNAL_FUNC int emdaemon_get_filter_list(emf_rule_t** filtering_set, int* coun * @remarks N/A * @return This function returns true if enable add filter, else returns false. */ -INTERNAL_FUNC int emdaemon_find_filter(emf_rule_t* filter_info, int* err_code); +INTERNAL_FUNC int emdaemon_find_filter(email_rule_t* filter_info, int* err_code); /** * Add a filter information. @@ -202,9 +202,9 @@ INTERNAL_FUNC int emdaemon_find_filter(emf_rule_t* filter_info, int* err_code); * @param[in] filtering_set Specifies the pointer of adding filter structure. * @param[out] err_code Specifies the error code returned. * @remarks N/A - * @return This function returns true on success or false on failure.(only EMF_FILTER_BLOCK supported.) + * @return This function returns true on success or false on failure.(only EMAIL_FILTER_BLOCK supported.) */ -INTERNAL_FUNC int emdaemon_add_filter(emf_rule_t* filtering_set, int* err_code); +INTERNAL_FUNC int emdaemon_add_filter(email_rule_t* filtering_set, int* err_code); /** * Change a filter information. @@ -215,7 +215,7 @@ INTERNAL_FUNC int emdaemon_add_filter(emf_rule_t* filtering_set, int* err_code); * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_update_filter(int filter_id, emf_rule_t* new_set, int* err_code); +INTERNAL_FUNC int emdaemon_update_filter(int filter_id, email_rule_t* new_set, int* err_code); /** * Delete a filter information. @@ -236,7 +236,7 @@ INTERNAL_FUNC int emdaemon_delete_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_free_filter (emf_rule_t** filtering_set, int count, int* err_code); +INTERNAL_FUNC int emdaemon_free_filter (email_rule_t** filtering_set, int count, int* err_code); /*****************************************************************************/ @@ -246,7 +246,6 @@ INTERNAL_FUNC int emdaemon_free_filter (emf_rule_t** filtering_set, int count, i /** * Send a mail. * - * @param[in] mailbox Specifies the mailbox to consist a sending email. * @param[in] mail_id Specifies the mail ID. * @param[in] sending_option Specifies the sending option. * @param[in] callback Specifies the callback function for retrieving sending information. @@ -255,7 +254,7 @@ INTERNAL_FUNC int emdaemon_free_filter (emf_rule_t** filtering_set, int count, i * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_send_mail(emf_mailbox_t* mailbox, int mail_id, emf_option_t* sending_option, unsigned* handle, int* err_code); +INTERNAL_FUNC int emdaemon_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle, int* err_code); /** * Send all mails to been saved in Offline-mode. @@ -268,17 +267,16 @@ INTERNAL_FUNC int emdaemon_send_mail(emf_mailbox_t* mailbox, int mail_id, emf_op * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, emf_option_t* sending_option, unsigned* handle, int* err_code); +INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, email_option_t* sending_option, unsigned* handle, int* err_code); -INTERNAL_FUNC int emdaemon_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t *input_meeting_request, int input_from_eas); +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_meeting_request(int account_id, char *mailbox_name, emf_meeting_request_t *meeting_req, int* err_code); +INTERNAL_FUNC int emdaemon_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int* err_code); /** * Delete a mail or multiple mails. * - * @param[in] account_id Specifies the account id. - * @param[in] mailbox Specifies the mailbox. + * @param[in] mailbox_id Specifies the mailbox. * @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. @@ -289,46 +287,45 @@ INTERNAL_FUNC int emdaemon_add_meeting_request(int account_id, char *mailbox_nam * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_delete_mail(int account_id, emf_mailbox_t* mailbox, int mail_id[], int num, int from_server, unsigned* handle, int* err_code); +INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_id[], int num, int from_server, unsigned* handle, int* err_code); /** * Delete all mail from a mailbox. * - * @param[in] mailbox Specifies the structure of mailbox. - * @param[in] with_server Specifies whether mails are also deleted from server. - * @param[in] callback Specifies the callback function for delivering status during deleting. - * @param[in] handle Reserved. - * @param[out] err_code Specifies the error code returned. + * @param[in] input_mailbox_id Specifies the id of target mailbox. + * @param[in] input_from_server Specifies whether mails are also deleted from server. + * @param[in] output_handle Reserved. + * @param[out] output_err_code Specifies the error code returned. * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_delete_mail_all(emf_mailbox_t* mailbox, int with_server, unsigned* handle, int* err_code); +INTERNAL_FUNC int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, unsigned *output_handle, int *output_err_code); /** * Move a email to another mailbox. * - * - * @param[in] mail_id Specifies the mail ID. - * @param[in] dst_mailbox Specifies the mailbox structure for moving email. - * @param[in] noti_param_1 Specifies first parameter of result notification. - * @param[in] noti_param_2 Specifies second parameter of result notification. - * @param[out] err_code Specifies the error code returned. + * + * @param[in] mail_id Specifies the mail ID. + * @param[in] dst_mailbox_id Specifies the mailbox ID for moving email. + * @param[in] noti_param_1 Specifies first parameter of result notification. + * @param[in] noti_param_2 Specifies second parameter of result notification. + * @param[out] err_code Specifies the error code returned. * @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, emf_mailbox_t* dst_mailbox, int noti_param_1, int noti_param_2, int* err_code); +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); /** * Move all email to another mailbox. * - * - * @param[in] src_mailbox Specifies the source mailbox structure for moving email. - * @param[in] dst_mailbox Specifies the destination mailbox structure for moving email. - * @param[out] err_code Specifies the error code returned. + * + * @param[in] src_mailbox_id Specifies the source mailbox ID for moving email. + * @param[in] dst_mailbox_id Specifies the destination mailbox ID for moving email. + * @param[out] err_code Specifies the error code returned. * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_move_mail_all_mails(emf_mailbox_t* src_mailbox, emf_mailbox_t* dst_mailbox, int* err_code); +INTERNAL_FUNC int emdaemon_move_mail_all_mails(int src_mailbox_id, int dst_mailbox_id, int* err_code); /** @@ -340,9 +337,9 @@ INTERNAL_FUNC int emdaemon_move_mail_all_mails(emf_mailbox_t* src_mailbox, emf_m * @param[in] input_meeting_request Specifies the number of attachment data. * @param[in] input_from_eas Specifies whether the mail is from EAS. * @remarks N/A - * @return This function returns EMF_ERROR_NONE on success or error code on failure. + * @return This function returns EMAIL_ERROR_NONE on success or error code on failure. */ -INTERNAL_FUNC int emdaemon_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t *input_meeting_request, int input_from_eas); +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); /** @@ -357,7 +354,7 @@ INTERNAL_FUNC void _OnMailSendRetryTimerCB( void* data ); /** * Download email body from server. * - * @param[in] mailbox Reserved. + * @param[in] account_id Specifies the account ID. * @param[in] mail_id Specifies the mail ID. * @param[in] callback Specifies the callback function for retrieving download status. * @param[in] handle Specifies the handle for stopping downloading. @@ -365,25 +362,24 @@ 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(emf_mailbox_t* mailbox, int mail_id, int verbose, int with_attachment, unsigned* handle, int* err_code); +INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbose, int with_attachment, unsigned* handle, int* err_code); /** * Get a mail attachment. * - * @param[in] mailbox Reserved. * @param[in] mail_id Specifies the mail ID. - * @param[in] attachment_id Specifies the buffer that a attachment ID been saved. + * @param[in] attachment_id Specifies the attachment ID. * @param[out] attachment The returned attachment is save here. * @param[out] err_code Specifies the error code returned. * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_get_attachment(emf_mailbox_t* mailbox, int mail_id, char* attachment_id, emf_attachment_info_t** attachment, int* err_code); +INTERNAL_FUNC int emdaemon_get_attachment(int attachment_id, email_attachment_data_t** attachment, int* err_code); /** * Download a email nth-attachment from server. * - * @param[in] mailbox Reserved. + * @param[in] account_id Specifies the account ID. * @param[in] mail_id Specifies the mail ID. * @param[in] nth Specifies the buffer that a attachment number been saved. the minimum number is "1". * @param[in] callback Specifies the callback function for retrieving download status. @@ -392,32 +388,30 @@ INTERNAL_FUNC int emdaemon_get_attachment(emf_mailbox_t* mailbox, int mail_id, c * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_download_attachment(emf_mailbox_t* mailbox, int mail_id, char* nth, unsigned* handle, int* err_code); +INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int nth, unsigned* handle, int* err_code); /** * Append a attachment to email. * - * @param[in] mailbox Reserved. * @param[in] mail_id Specifies the mail ID. * @param[in] attachment Specifies the structure of attachment. * @param[out] err_code Specifies the error code returned. * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_add_attachment(emf_mailbox_t* mailbox, int mail_id, emf_attachment_info_t* attachment, int* err_code); +INTERNAL_FUNC int emdaemon_add_attachment(int mail_id, email_attachment_data_t* attachment, int* err_code); /** * Delete a attachment from email. * - * @param[in] mailbox Reserved. - * @param[in] mail_id Specifies the mail ID. - * @param[in] attachment_id Specifies the buffer that a attachment ID been saved. - * @param[out] err_code Specifies the error code returned. + * @param[in] mail_id Specifies the mail id. + * @param[in] attachment_id Specifies the attachment id. + * @param[out] err_code Specifies the error code returned. * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_delete_mail_attachment(emf_mailbox_t* mailbox, int mail_id, char* attachment_id, int* err_code); +INTERNAL_FUNC int emdaemon_delete_mail_attachment(int attachment_id, int* err_code); /** * Free allocated memroy for email attachment. @@ -427,7 +421,7 @@ INTERNAL_FUNC int emdaemon_delete_mail_attachment(emf_mailbox_t* mailbox, int ma * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_free_attachment_info(emf_attachment_info_t** atch_info, int* err_code); +INTERNAL_FUNC int emdaemon_free_attachment_data(email_attachment_data_t** atch_info, int* err_code); /** * Change email flag. @@ -439,7 +433,7 @@ INTERNAL_FUNC int emdaemon_free_attachment_info(emf_attachment_info_t** atch_inf * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_modify_flag(int mail_id, emf_mail_flag_t new_flag, int onserver, int sticky_flag, int* err_code); +INTERNAL_FUNC int emdaemon_modify_flag(int mail_id, email_mail_flag_t new_flag, int onserver, int sticky_flag, int* err_code); /** * Change email extra flag. @@ -451,21 +445,21 @@ INTERNAL_FUNC int emdaemon_modify_flag(int mail_id, emf_mail_flag_t new_flag, in * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_modify_extra_flag(int mail_id, emf_extra_flag_t new_flag, int* err_code); +INTERNAL_FUNC int emdaemon_modify_extra_flag(int mail_id, email_extra_flag_t new_flag, int* err_code); /** * Change email read/unread flag. * @param[in] account_id Specifies the account id. * @param[in] mail_ids Specifies the array of mail ID. * @param[in] num Specifies the numbers of mail ID. - * @param[in] field_type Specifies the field type what you want to set. Refer emf_flags_field_type. - * @param[in] value Specifies the value what you want to set. + * @param[in] field_type Specifies the field type what you want to set. Refer email_flags_field_type. + * @param[in] value Specifies the value what you want to set. * @param[in] onserver Specifies the mail on server. * @param[out] err_code Specifies the error code returned. * @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, emf_flags_field_type field_type, int value, int onserver, int* err_code); +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); /*****************************************************************************/ /* Mailbox */ @@ -473,16 +467,16 @@ INTERNAL_FUNC int emdaemon_set_flags_field(int account_id, int mail_ids[], int n INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(int account_id, char* mailbox, unsigned* handle, int* err_code); /** - * Download header of new emails from mail server. + * Download header of new emails from mail server. * - * @param[in] mailbox Specifies the structure of mailbox. - * @param[in] callback Specifies the callback function for retrieving download status. + * @param[in] input_account_id Specifies the account ID. + * @param[in] input_mailbox_id Specifies the mailbox ID. * @param[out] handle Specifies the handle for stopping downloading. * @param[out] err_code Specifies the error code returned. * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_sync_header(emf_mailbox_t* mailbox, unsigned* handle, int* err_code); +INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle, int* err_code); /** @@ -495,7 +489,7 @@ INTERNAL_FUNC int emdaemon_sync_header(emf_mailbox_t* mailbox, unsigned* handle, * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(emf_mailbox_t* mailbox, int* total, int* unseen, int* err_code); +INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(email_mailbox_t* mailbox, int* total, int* unseen, int* err_code); /** * Get all mailboxes from account. @@ -507,7 +501,7 @@ INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(emf_mailbox_t* mailbox, int * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_get_mailbox_list(int account_id, emf_mailbox_t** mailbox_list, int* count, int* err_code); +INTERNAL_FUNC int emdaemon_get_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count, int* err_code); /** * Create a new mailbox. @@ -518,18 +512,18 @@ INTERNAL_FUNC int emdaemon_get_mailbox_list(int account_id, emf_mailbox_t** mail * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_add_mailbox(emf_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code); +INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code); /** * Delete a mailbox. * - * @param[in] mailbox Specifies the pointer of deleting mailbox information. - * @param[out] handle Specifies the handle for stopping creating mailbox. - * @param[out] err_code Specifies the error code returned. + * @param[in] input_mailbox_id Specifies the input_mailbox_id of deleting mailbox information. + * @param[out] handle Specifies the handle for stopping creating mailbox. + * @param[out] err_code Specifies the error code returned. * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_delete_mailbox(emf_mailbox_t* mailbox, int on_server, unsigned* handle, int* err_code); +INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, unsigned* handle, int* err_code); /** * Delete all sub-mailboxes from a specific mailbox. @@ -539,7 +533,7 @@ INTERNAL_FUNC int emdaemon_delete_mailbox(emf_mailbox_t* mailbox, int on_server, * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_delete_mailbox_all(emf_mailbox_t* mailbox, int* err_code); +INTERNAL_FUNC int emdaemon_delete_mailbox_all(email_mailbox_t* mailbox, int* err_code); /** * Free allocated memory for mailbox information. @@ -550,7 +544,7 @@ INTERNAL_FUNC int emdaemon_delete_mailbox_all(emf_mailbox_t* mailbox, int* err_c * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_free_mailbox(emf_mailbox_t** mailbox_list, int count, int* err_code); +INTERNAL_FUNC int emdaemon_free_mailbox(email_mailbox_t** mailbox_list, int count, int* err_code); /*****************************************************************************/ /* Etc */ @@ -566,7 +560,7 @@ INTERNAL_FUNC int emdaemon_free_mailbox(emf_mailbox_t** mailbox_list, int count, * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_register_event_callback(emf_action_t action, emf_event_callback callback, void* event_data); +INTERNAL_FUNC int emdaemon_register_event_callback(email_action_t action, email_event_callback callback, void* event_data); /** * Unregister a callback for event processing. @@ -576,7 +570,7 @@ INTERNAL_FUNC int emdaemon_register_event_callback(emf_action_t action, emf_even * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_unregister_event_callback(emf_action_t action, emf_event_callback callback); +INTERNAL_FUNC int emdaemon_unregister_event_callback(email_action_t action, email_event_callback callback); /** * Get current event queue status. @@ -596,7 +590,7 @@ INTERNAL_FUNC void emdaemon_get_event_queue_status(int* on_sending, int* on_rece * @remarks N/A * @return This function return its handle if a pending job exists, otherwise -1. */ -INTERNAL_FUNC int emdaemon_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t* status); +INTERNAL_FUNC int emdaemon_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t* status); /** * Cancel a progressive work. @@ -630,7 +624,7 @@ INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id, * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_set_option(emf_option_t* option, int* err_code); +INTERNAL_FUNC int emdaemon_set_option(email_option_t* option, int* err_code); /** * get email options. @@ -640,12 +634,12 @@ INTERNAL_FUNC int emdaemon_set_option(emf_option_t* option, int* err_code); * @remarks N/A * @return This function returns true on success or false on failure. */ -INTERNAL_FUNC int emdaemon_get_option(emf_option_t* option, int* err_code); +INTERNAL_FUNC int emdaemon_get_option(email_option_t* option, int* err_code); /** - * Sync the Local activity + * Sync the Local activity + * * - * * @param[in] account_id Specifies the Account ID. * @param[out] err_code Specifies the error code returned. * @remarks N/A @@ -658,28 +652,34 @@ INTERNAL_FUNC int emdaemon_sync_local_activity(int account_id, int *err_code); INTERNAL_FUNC int emdaemon_start_auto_polling(int* err_code); #endif /* __FEATURE_AUTO_POLLING__ */ -INTERNAL_FUNC int emdaemon_insert_accountinfo_to_contact(emf_account_t* account); +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_update_accountinfo_to_contact(emf_account_t* old_account, emf_account_t* new_account); +INTERNAL_FUNC int emdaemon_update_mailbox(email_mailbox_t* old_mailbox, email_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code); -INTERNAL_FUNC int emdaemon_update_mailbox(emf_mailbox_t* old_mailbox, emf_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code); +INTERNAL_FUNC int emdaemon_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type); -INTERNAL_FUNC int emdaemon_search_mail_on_server(int input_account_id, const char *input_mailbox_name, email_search_filter_t *input_search_filter, int input_search_filter_count, unsigned int *output_handle); +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_clear_all_mail_data(int* err_code); INTERNAL_FUNC int emdaemon_send_mail_retry( int mail_id, int timeout_in_sec, int* err_code); -INTERNAL_FUNC int emdaemon_validate_account_and_create(emf_account_t* new_account, unsigned* handle, int* err_code); +INTERNAL_FUNC int emdaemon_validate_account_and_create(email_account_t* new_account, unsigned* handle, int* err_code); -INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, char* mailbox_name, int new_slot_size, unsigned* handle, int *err_code); +INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, int mailbox_id, int new_slot_size, unsigned* handle, int *err_code); -INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, char *target_mailbox_name, int move_always_flag, int *err_code); +INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mailbox_path, char *input_mailbox_alias, int input_on_server, unsigned *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_delete_mail_thread(int thread_id, int delete_always_flag, unsigned* handle, int *err_code); INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server, unsigned* handle, int *err_code); +INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, unsigned *output_handle); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/email-daemon/main.c b/email-daemon/main.c index e8997b1..97fda37 100755 --- a/email-daemon/main.c +++ b/email-daemon/main.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Kyuho Jo , Sunghyun Kwon -* +* * 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 @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -37,19 +36,21 @@ #include "email-ipc.h" #include "email-utilities.h" #include "email-debug-log.h" -#include "email-daemon-auto-poll.h" +#include "email-daemon-auto-poll.h" #include "email-daemon-account.h" #include "email-convert.h" -#include "email-internal-types.h" +#include "email-internal-types.h" #include "email-types.h" -#include "email-core-account.h" -#include "email-core-mail.h" +#include "email-core-account.h" +#include "email-core-mail.h" #include "email-core-smtp.h" -#include "email-core-event.h" -#include "email-core-global.h" -#include "email-core-mailbox.h" +#include "email-core-event.h" +#include "email-core-global.h" +#include "email-core-mailbox.h" #include "email-core-utils.h" -#include "email-storage.h" +#include "email-core-smime.h" +#include "email-core-cert.h" +#include "email-storage.h" void stb_create_account(HIPC_API a_hAPI) { @@ -57,39 +58,29 @@ void stb_create_account(HIPC_API a_hAPI) int buffer_size = 0; int local_result = 0; char* local_account_stream = NULL; - emf_account_t account; - int err = EMF_ERROR_NONE; + email_account_t account; + int err = EMAIL_ERROR_NONE; - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0); EM_DEBUG_LOG("size [%d]", buffer_size); - if(buffer_size <= 0) { - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } + 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); - local_account_stream = (char*)em_malloc(buffer_size+1); - if(!local_account_stream) { - err = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_account_stream); - /* Convert account stream to structure */ - EM_DEBUG_LOG("Before Convert_ByteStream_To_Account"); - em_convert_byte_stream_to_account(local_account_stream, &account); - EM_SAFE_FREE(local_account_stream); - - if (account.account_name) - EM_DEBUG_LOG("Account name - %s", account.account_name); - if(account.email_addr) - EM_DEBUG_LOG("Email Address - %s", account.email_addr); - + EM_DEBUG_LOG("Account name - %s", account.account_name); + EM_DEBUG_LOG("Email Address - %s", account.user_email_address); + if(!emdaemon_create_account(&account, &err)) { EM_DEBUG_EXCEPTION("emdaemon_create_account fail "); goto FINISH_OFF; } + #ifdef __FEATURE_AUTO_POLLING__ /* start auto polling, if check_interval not zero */ if(account.check_interval > 0) { @@ -97,22 +88,26 @@ void stb_create_account(HIPC_API a_hAPI) EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm[NOTI_ACCOUNT_ADD] : start auto poll failed >>> "); } #endif + /* add account details to contact DB */ emdaemon_insert_accountinfo_to_contact(&account); + local_result = 1; if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - + EM_DEBUG_LOG("[3] APPID[%d], APIID [%d]", emipc_get_app_id(a_hAPI), emipc_get_api_id(a_hAPI)); EM_DEBUG_LOG("account id[%d]", account.account_id); - + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(account.account_id), sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); + + /* pass result to app */ if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); FINISH_OFF: - if ( local_result == 0 ) { + if ( local_result == 0 ) { if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed : local_result "); if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) @@ -128,16 +123,16 @@ void stb_delete_account(HIPC_API a_hAPI) EM_DEBUG_FUNC_BEGIN(); int account_id = 0; int local_result = 0; - int err = EMF_ERROR_NONE; - + int err = EMAIL_ERROR_NONE; + /* account_id */ - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); + account_id = *((int*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0)); if(!emdaemon_delete_account(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"); - + if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); goto FINISH_OFF; @@ -154,7 +149,7 @@ void stb_delete_account(HIPC_API a_hAPI) if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - + if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed"); @@ -168,114 +163,69 @@ void stb_update_account(HIPC_API a_hAPI) EM_DEBUG_FUNC_BEGIN(); int account_id = 0, buffer_size = 0, local_result = 0, with_validation = 0; char* local_account_stream = NULL; - emf_account_t *new_account_info = NULL; - int err = EMF_ERROR_NONE; - unsigned int handle = 0; + email_account_t new_account_info = {0}; + email_account_t old_account_info = {0}; + int err = EMAIL_ERROR_NONE; + unsigned int handle = 0; - /* filter_id */ - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); - - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1); + account_id = *((int*)emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0)); + + /* get account structure from stream */ + buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 1); EM_DEBUG_LOG("size [%d]", buffer_size); - - if(buffer_size > 0) { - local_account_stream = (char*)em_malloc(buffer_size+1); - if(local_account_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, local_account_stream); - /* Convert Byte stream to account structure */ - EM_DEBUG_LOG("Before Convert_ByteStream_To_account"); - new_account_info = (emf_account_t*)em_malloc(sizeof(emf_account_t)); - - if(NULL == new_account_info) { - EM_SAFE_FREE(local_account_stream); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - em_convert_byte_stream_to_account(local_account_stream, new_account_info); - EM_SAFE_FREE(local_account_stream); - } - else { - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &with_validation); - } + local_account_stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 1); + em_convert_byte_stream_to_account(local_account_stream, buffer_size, &new_account_info); - if ( NULL == new_account_info ) { - err = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } + /*get validation flag */ + with_validation = *((int*)emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 2)); - emf_account_t *old_account_info = NULL; - - if(!emdaemon_get_account(account_id, GET_FULL_DATA, &old_account_info, &err)) { + + if(!emdaemon_get_account(account_id, EMAIL_ACC_GET_OPT_FULL_DATA, &old_account_info, &err)) { EM_DEBUG_EXCEPTION("emdaemon_get_account failed "); goto FINISH_OFF; } - if(new_account_info->password == NULL || (new_account_info->password != NULL && strlen(new_account_info->password) == 0) ) { - EM_SAFE_FREE(new_account_info->password); - if(old_account_info->password) { - new_account_info->password = strdup(old_account_info->password); - if(new_account_info->password == NULL) { + + if( EM_SAFE_STRLEN (new_account_info.incoming_server_password) == 0 ) { + EM_SAFE_FREE(new_account_info.incoming_server_password); /* be allocated but has zero length */ + EM_DEBUG_LOG("old_account_info->incoming_server_password [%s]", old_account_info.incoming_server_password); + new_account_info.incoming_server_password = EM_SAFE_STRDUP(old_account_info.incoming_server_password); + if(new_account_info.incoming_server_password == NULL) { EM_DEBUG_EXCEPTION("allocation for new_account_info->password failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } } - } - - if(new_account_info->sending_password == NULL || (new_account_info->sending_password != NULL && strlen(new_account_info->sending_password) == 0) ) { - if(new_account_info->sending_password != NULL) - free(new_account_info->sending_password); - if(old_account_info->sending_password) { - new_account_info->sending_password = strdup(old_account_info->sending_password); - if(new_account_info->sending_password == NULL) { - EM_DEBUG_EXCEPTION("allocation for new_account_info->sending_password failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + + + if( EM_SAFE_STRLEN (new_account_info.outgoing_server_password) == 0 ) { + EM_SAFE_FREE(new_account_info.outgoing_server_password); + if(old_account_info.outgoing_server_password) { + new_account_info.outgoing_server_password = strdup (old_account_info.outgoing_server_password); + if(new_account_info.outgoing_server_password == NULL) { + EM_DEBUG_EXCEPTION("allocation for new_account_info->outgoing_server_password failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } } } - if(with_validation) { - emdaemon_validate_account_and_update(account_id, new_account_info, &handle, &err); + emdaemon_validate_account_and_update(account_id, &new_account_info, &handle, &err); local_result = 1; } else { - if(emdaemon_update_account(account_id, new_account_info, &err)) { -#ifdef __FEATURE_AUTO_POLLING__ - int old_check_interval = old_account_info->check_interval; - if( old_check_interval == 0 && new_account_info->check_interval > 0) { - if(!emdaemon_add_polling_alarm( account_id,new_account_info->check_interval)) - EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm[ CHANGEACCOUNT] : start auto poll failed >>> "); - - } - else if( (old_check_interval > 0) && (new_account_info->check_interval == 0)) { - if(!emdaemon_remove_polling_alarm(account_id)) - EM_DEBUG_EXCEPTION("emdaemon_remove_polling_alarm[ CHANGEACCOUNT] : start auto poll failed >>> "); - } - else if(old_check_interval != new_account_info->check_interval) { - if(!emdaemon_remove_polling_alarm(account_id)) { - EM_DEBUG_EXCEPTION("emdaemon_remove_polling_alarm[ CHANGEACCOUNT] : start auto poll failed >>> "); - goto FINISH_OFF; - } - if(!emdaemon_add_polling_alarm( account_id,new_account_info->check_interval)) - EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm[ CHANGEACCOUNT] : start auto poll failed >>> "); - } -#endif - emdaemon_update_accountinfo_to_contact(old_account_info,new_account_info); + if(emdaemon_update_account(account_id, &new_account_info, &err)) { + emdaemon_update_accountinfo_to_contact(&old_account_info, &new_account_info); local_result = 1; } else { EM_DEBUG_EXCEPTION("emdaemon_update_account failed [%d]", err); goto FINISH_OFF; } - + } - + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter for result failed"); @@ -283,7 +233,7 @@ void stb_update_account(HIPC_API a_hAPI) if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter for handle failed"); } - + if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed"); @@ -294,12 +244,15 @@ 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(new_account_info); - EM_SAFE_FREE(old_account_info); + + emcore_free_account(&old_account_info); + + emcore_free_account(&new_account_info); + EM_DEBUG_FUNC_END(); } @@ -311,7 +264,7 @@ void stb_validate_account(HIPC_API a_hAPI) int local_result = 0; int err_code = 0; int handle = 0; - + /* account_id */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); local_result = emdaemon_validate_account(account_id, (unsigned*)&handle,&err_code); @@ -321,81 +274,29 @@ void stb_validate_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_DEBUG_FUNC_END(); } -void stb_account_get_refer(HIPC_API a_hAPI) -{ - EM_DEBUG_FUNC_BEGIN(); - int local_result = 0; - int account_id = 0; - emf_account_t* account = NULL; - char* local_stream = NULL; - int size = 0; - - EM_DEBUG_LOG("account_id"); - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); - - account = emdaemon_get_account_reference(account_id); - if(account != NULL) { - EM_DEBUG_LOG("emdaemon_get_account_reference success"); - local_result = 1; - - /* result */ - if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int))) - EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed "); - - /* Address */ - local_stream = em_convert_account_to_byte_stream(account, &size); - - EM_NULL_CHECK_FOR_VOID(local_stream); - - if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, local_stream, size)) - 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(local_stream); - return; - } - - } - else { - EM_DEBUG_LOG("emdaemon_get_account_reference failed"); - if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, 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(local_stream); - return; - } - } - - EM_SAFE_FREE(local_stream); - EM_DEBUG_FUNC_END(); -} void stb_get_account_list(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - + int local_result = 0; - int counter = 0; + int i= 0; char* local_stream = NULL; - emf_account_t* account_list; + email_account_t* account_list; int count; int size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; - EM_DEBUG_LOG("begin"); - if(emdaemon_get_account_list(&account_list, &count, &err)) { EM_DEBUG_LOG("emdaemon_get_account_list success"); local_result = 1; @@ -406,10 +307,10 @@ void stb_get_account_list(HIPC_API a_hAPI) if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &count, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter count failed "); - for(counter=0; counter 0) { - local_stream = (char*)em_malloc(buffer_size+1); + local_stream = (char*)em_malloc(buffer_size); EM_NULL_CHECK_FOR_VOID(local_stream); if(local_stream) { emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, local_stream); @@ -503,26 +405,27 @@ void stb_modify_mail_extra_flag(HIPC_API a_hAPI) EM_SAFE_FREE(local_stream); } - if(emdaemon_modify_extra_flag(mail_id, new_flag, &err)) + if(emdaemon_modify_extra_flag(mail_id, new_flag, &err)) EM_DEBUG_LOG("emdaemon_modify_extra_flag - success"); - + 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_DEBUG_FUNC_END(); } + void stb_get_mail_count_of_mailbox(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); int buffer_size = 0; int local_result = 0; char* local_stream = NULL; - emf_mailbox_t mailbox; + email_mailbox_t mailbox; int total_count = 0; int unseen= 0; @@ -530,13 +433,13 @@ void stb_get_mail_count_of_mailbox(HIPC_API a_hAPI) buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); + local_stream = (char*)em_malloc(buffer_size); if(!local_stream) { - EM_DEBUG_EXCEPTION("EMF_ERROR_OUT_OF_MEMORY"); + EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY"); goto FINISH_OFF; } emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); - em_convert_byte_stream_to_mailbox(local_stream, &mailbox); + em_convert_byte_stream_to_mailbox(local_stream, buffer_size, &mailbox); EM_SAFE_FREE(local_stream); } @@ -574,41 +477,32 @@ FINISH_OFF: EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed"); } + emcore_free_mailbox(&mailbox); + EM_DEBUG_FUNC_END(); } - +#endif /* sowmya.kr, 10-May-2010, changes for API improvement */ void stb_sync_header(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int buffer_size = 0; - int err = EMF_ERROR_NONE; - char* local_stream = NULL; - emf_mailbox_t mailbox, *pointer_mailbox = NULL; + int err = EMAIL_ERROR_NONE; int handle = -1; - - EM_DEBUG_LOG("mailbox"); - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + int account_id = 0, maibox_id = 0; - if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(local_stream); - if(!local_stream) { - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); - em_convert_byte_stream_to_mailbox(local_stream, &mailbox); - EM_SAFE_FREE(local_stream); - pointer_mailbox = &mailbox; - } + /* account_id */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); + EM_DEBUG_LOG("account_id [%d]", account_id); + + /* maibox_id */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &maibox_id); + EM_DEBUG_LOG("maibox_id [%d]", maibox_id); - if(emdaemon_sync_header(pointer_mailbox, (unsigned*)&handle, &err)) { + if(emdaemon_sync_header(account_id, maibox_id, (unsigned*)&handle, &err)) { EM_DEBUG_LOG("emdaemon_sync_header success "); - } + } -FINISH_OFF: 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, &handle, sizeof(int))) @@ -621,25 +515,14 @@ FINISH_OFF: void stb_download_body(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int buffer_size = 0; - int err = EMF_ERROR_NONE; - char* local_stream = NULL; - emf_mailbox_t mailbox; + int err = EMAIL_ERROR_NONE; int mail_id = 0; int has_attachment = 0; unsigned int handle = 0; - - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + int account_id = 0; - if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(local_stream); - if(local_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); - em_convert_byte_stream_to_mailbox(local_stream, &mailbox); - EM_SAFE_FREE(local_stream); - } - } + /* Account Id */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); /* Mail Id */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mail_id); @@ -648,12 +531,12 @@ void stb_download_body(HIPC_API a_hAPI) emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &has_attachment); /*Download Body */ - if (!emdaemon_download_body(&mailbox, mail_id, 1, has_attachment, &handle, &err)) { + if (!emdaemon_download_body(account_id, mail_id, 1, has_attachment, &handle, &err)) { EM_DEBUG_EXCEPTION("emdaemon_download_body - failed"); goto FINISH_OFF; } - err = EMF_ERROR_NONE; + err = EMAIL_ERROR_NONE; FINISH_OFF: @@ -672,41 +555,75 @@ void stb_create_mailbox(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); int buffer_size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char *local_stream = NULL; int on_server = 0; - emf_mailbox_t mailbox; + email_mailbox_t mailbox = {0}; int handle = 0; /* Added for cancelling mailbox creating */ + buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0); + EM_DEBUG_LOG("size [%d]", buffer_size); + + if(buffer_size <= 0) { + EM_DEBUG_EXCEPTION("buffer_size(%d) should be greater than 0", buffer_size); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + + local_stream = emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0); + em_convert_byte_stream_to_mailbox(local_stream, buffer_size, &mailbox); + EM_DEBUG_LOG("Mailbox name - %s", mailbox.mailbox_name); + + on_server = *((int*)emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 1)); + + emdaemon_add_mailbox(&mailbox, on_server, (unsigned*)&handle, &err); + +FINISH_OFF: + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1"); + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter failed 2"); + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &mailbox.mailbox_id, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter failed 3"); + + if (!emipc_execute_stub_api(a_hAPI)) { + EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); + return; + } + +#if 0 buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); EM_DEBUG_LOG("size [%d]", buffer_size); if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); + local_stream = (char*)em_malloc(buffer_size); EM_NULL_CHECK_FOR_VOID(local_stream); if(local_stream) { emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &on_server); - em_convert_byte_stream_to_mailbox(local_stream, &mailbox); + em_convert_byte_stream_to_mailbox(local_stream, buffer_size, &mailbox); EM_SAFE_FREE(local_stream); - - if (mailbox.name) - EM_DEBUG_LOG("Mailbox name - %s", mailbox.name); - + + if (mailbox.mailbox_name) + EM_DEBUG_LOG("Mailbox name - %s", mailbox.mailbox_name); + if(emdaemon_add_mailbox(&mailbox, on_server, (unsigned*)&handle, &err)) - err = EMF_ERROR_NONE; - + err = EMAIL_ERROR_NONE; + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1"); if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed 2"); - + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &mailbox.mailbox_id, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter failed 3"); + if (!emipc_execute_stub_api(a_hAPI)) { EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); return; } } - } + } +#endif EM_DEBUG_FUNC_END(); } @@ -714,42 +631,33 @@ void stb_create_mailbox(HIPC_API a_hAPI) void stb_delete_mailbox(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int buffer_size = 0; - int err = EMF_ERROR_NONE; - char *local_stream = NULL; + int err = EMAIL_ERROR_NONE; int on_server = 0; - emf_mailbox_t mailbox; int handle = 0; /* Added for cancelling mailbox deleting */ + int input_mailbox_id = 0; - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); - - EM_DEBUG_LOG("size [%d]", buffer_size); + /* src_mailbox_id */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &input_mailbox_id); + EM_DEBUG_LOG("input_mailbox_id [%d]", input_mailbox_id); - if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(local_stream); - if(local_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &on_server); - - em_convert_byte_stream_to_mailbox(local_stream, &mailbox); - EM_SAFE_FREE(local_stream); + if (input_mailbox_id > 0) + EM_DEBUG_LOG("input_mailbox_id [%d]", input_mailbox_id); + else + EM_DEBUG_LOG("input_mailbox_id == 0"); + + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &on_server); + + if(emdaemon_delete_mailbox(input_mailbox_id, on_server, (unsigned*)&handle, &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_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"); - if (mailbox.name) - EM_DEBUG_LOG("Mailbox name - %s", mailbox.name); - if(emdaemon_delete_mailbox(&mailbox, on_server, (unsigned*)&handle, &err)) - err = EMF_ERROR_NONE; - - 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, &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_DEBUG_FUNC_END(); } @@ -757,180 +665,229 @@ void stb_update_mailbox(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); int buffer_size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char *old_mailbox_stream = NULL; char *new_mailbox_stream = NULL; int on_server = 0; - emf_mailbox_t *old_mailbox = NULL; - emf_mailbox_t *new_mailbox = NULL; + email_mailbox_t *old_mailbox = NULL; + email_mailbox_t *new_mailbox = NULL; int handle = 0; /* Added for cancelling mailbox updating */ buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); EM_DEBUG_LOG("size [%d]", buffer_size); if(buffer_size > 0) { - old_mailbox_stream = (char*)em_malloc(buffer_size+1); + old_mailbox_stream = (char*)em_malloc(buffer_size); EM_NULL_CHECK_FOR_VOID(old_mailbox_stream); if(old_mailbox_stream) { emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, old_mailbox_stream); - old_mailbox = (emf_mailbox_t*)em_malloc(sizeof(emf_mailbox_t)); + old_mailbox = (email_mailbox_t*)em_malloc(sizeof(email_mailbox_t)); if ( old_mailbox == NULL ) { EM_DEBUG_EXCEPTION("em_malloc failed."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - em_convert_byte_stream_to_mailbox(old_mailbox_stream, old_mailbox); + em_convert_byte_stream_to_mailbox(old_mailbox_stream, buffer_size, old_mailbox); EM_SAFE_FREE(old_mailbox_stream); } } else { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1); EM_DEBUG_LOG("size [%d]", buffer_size); if(buffer_size > 0) { - new_mailbox_stream = (char*)em_malloc(buffer_size+1); + new_mailbox_stream = (char*)em_malloc(buffer_size); EM_NULL_CHECK_FOR_VOID(new_mailbox_stream); if(new_mailbox_stream) { emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, new_mailbox_stream); - new_mailbox = (emf_mailbox_t*)em_malloc(sizeof(emf_mailbox_t)); + new_mailbox = (email_mailbox_t*)em_malloc(sizeof(email_mailbox_t)); if ( new_mailbox == NULL ) { EM_DEBUG_EXCEPTION("em_malloc failed."); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - em_convert_byte_stream_to_mailbox(new_mailbox_stream, new_mailbox); + em_convert_byte_stream_to_mailbox(new_mailbox_stream, buffer_size, new_mailbox); EM_SAFE_FREE(new_mailbox_stream); } } else { EM_DEBUG_EXCEPTION("INVALID PARAM : old mailbox"); - err = EMF_ERROR_INVALID_PARAM; + err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &on_server); - + if(emdaemon_update_mailbox(old_mailbox, new_mailbox, on_server, (unsigned*)&handle, &err)) - err = EMF_ERROR_NONE; + err = EMAIL_ERROR_NONE; 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, &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"); - + FINISH_OFF: EM_SAFE_FREE(old_mailbox_stream); EM_SAFE_FREE(new_mailbox_stream); - emdaemon_free_mailbox(&old_mailbox, 1, NULL); - emdaemon_free_mailbox(&new_mailbox, 1, NULL); + emcore_free_mailbox(old_mailbox); + EM_SAFE_FREE(old_mailbox); + emcore_free_mailbox(new_mailbox); + EM_SAFE_FREE(new_mailbox); + EM_DEBUG_FUNC_END(); } +void stb_set_mailbox_type(HIPC_API a_hAPI) +{ + EM_DEBUG_FUNC_BEGIN(); + int err = EMAIL_ERROR_NONE; + int mailbox_id = 0; + int mailbox_type = 0; + + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id); + EM_DEBUG_LOG("mailbox_id[%d]", mailbox_id); + + 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) + err = EMAIL_ERROR_NONE; + + 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_DEBUG_FUNC_END(); +} void stb_set_mail_slot_size_of_mailbox(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int buffer_size = 0; - int err = EMF_ERROR_NONE; - int handle = 0; - int account_id = 0, mail_slot_size = 0; - char *mailbox_name = NULL; - + int err = EMAIL_ERROR_NONE; + int handle = 0; + int account_id = 0; + int mailbox_id = 0; + int mail_slot_size = 0; 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), &mail_slot_size); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mailbox_id); EM_DEBUG_LOG("mail_slot_size[%d]", mail_slot_size); - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2); - EM_DEBUG_LOG("mailbox name string size[%d]", buffer_size); - if(buffer_size > 0) { - mailbox_name = (char*)em_malloc(buffer_size + 1); - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, mailbox_name); - EM_DEBUG_LOG("mailbox_name [%s]", mailbox_name); - } - - if(emdaemon_set_mail_slot_size_of_mailbox(account_id, mailbox_name, mail_slot_size, (unsigned*)&handle, &err)) - err = EMF_ERROR_NONE; + 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, (unsigned*)&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"); if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed 2"); - + if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); - EM_SAFE_FREE(mailbox_name); EM_DEBUG_FUNC_END(); } -void stb_send_mail(HIPC_API a_hAPI) +void stb_rename_mailbox(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int buffer_size = 0; - char* local_option_stream = NULL; - char* local_stream = NULL; - emf_mailbox_t* mailbox = NULL; - emf_option_t sending_option; - int mail_id; - int handle; - int err = EMF_ERROR_NONE; - char* mailbox_name = NULL; - - /* Mailbox */ - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + int buffer_size = 0; + int err = EMAIL_ERROR_NONE; + int handle = 0; + int mailbox_id = 0; + int on_server = 0; + char *mailbox_path = NULL; + char *mailbox_alias = NULL; - if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(local_stream); - if(local_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); - mailbox = (emf_mailbox_t*)em_malloc(sizeof(emf_mailbox_t)); - em_convert_byte_stream_to_mailbox(local_stream, mailbox); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id); + EM_DEBUG_LOG("mailbox_id[%d]", mailbox_id); - if (!emstorage_get_mailboxname_by_mailbox_type(mailbox->account_id,EMF_MAILBOX_TYPE_DRAFT,&mailbox_name, false, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d]", err); - - goto FINISH_OFF; - } - mailbox->name = mailbox_name; - } + buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1); + EM_DEBUG_LOG("mailbox_path string size[%d]", buffer_size); + if(buffer_size > 0) { + mailbox_path = (char*)em_malloc(buffer_size); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, mailbox_path); + EM_DEBUG_LOG("mailbox_path [%s]", mailbox_path); } - /* Mail_id */ - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mail_id); + buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2); + EM_DEBUG_LOG("mailbox_alias string size[%d]", buffer_size); + if(buffer_size > 0) { + mailbox_alias = (char*)em_malloc(buffer_size); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, mailbox_alias); + EM_DEBUG_LOG("mailbox_alias [%s]", mailbox_alias); + } + + 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, on_server, (unsigned*)&handle)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emdaemon_rename_mailbox failed [%d]", err); + } + + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1"); + + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter failed 2"); + + if (!emipc_execute_stub_api(a_hAPI)) + EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); + + EM_DEBUG_FUNC_END(); +} + +void stb_send_mail(HIPC_API a_hAPI) +{ + EM_DEBUG_FUNC_BEGIN(); + int buffer_size = 0; + char* local_option_stream = NULL; + char* local_stream = NULL; + email_mailbox_t* mailbox = NULL; + email_option_t sending_option; + int mail_id; + int handle; + int err = EMAIL_ERROR_NONE; + char* mailbox_name = NULL; + + /* Mail_id */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id); EM_DEBUG_LOG("mail_id [%d]", mail_id); /* Sending Option */ - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2); + buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1); if(buffer_size > 0) { - local_option_stream = (char*)em_malloc(buffer_size+1); - + local_option_stream = (char*)em_malloc(buffer_size); + if(NULL == local_option_stream) { - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - + if(local_option_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, local_option_stream); - em_convert_byte_stream_to_option(local_option_stream, &sending_option); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, local_option_stream); + em_convert_byte_stream_to_option(local_option_stream, buffer_size, &sending_option); } } - if(emdaemon_send_mail(mailbox, mail_id, &sending_option, (unsigned*)&handle, &err)) { - err = EMF_ERROR_NONE; + if(emdaemon_send_mail(mail_id, &sending_option, (unsigned*)&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 "); if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int))) @@ -945,23 +902,27 @@ void stb_send_mail(HIPC_API a_hAPI) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); } -FINISH_OFF: +FINISH_OFF: EM_SAFE_FREE(local_stream); EM_SAFE_FREE(local_option_stream); EM_SAFE_FREE(mailbox); EM_SAFE_FREE(mailbox_name); - + + emcore_free_option(&sending_option); + EM_DEBUG_FUNC_END(); } + +/* obsolete - there is no api calling this function */ void stb_get_mailbox_list(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int counter = 0; char* local_stream = NULL; int account_id; - emf_mailbox_t* mailbox_list = NULL; + email_mailbox_t* mailbox_list = NULL; int count = 0; int size = 0; @@ -969,17 +930,17 @@ void stb_get_mailbox_list(HIPC_API a_hAPI) if(emdaemon_get_mailbox_list(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))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - if(EMF_ERROR_NONE == err) { + if(EMAIL_ERROR_NONE == err) { EM_DEBUG_LOG("Count [%d]", count); if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &count, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); for(counter=0; counter 0) { - local_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(local_stream); - if(local_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); - mailbox = (emf_mailbox_t*)em_malloc(sizeof(emf_mailbox_t)); - em_convert_byte_stream_to_mailbox(local_stream, mailbox); - } - } + /* from_server */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &from_server); - /* with_server */ - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &with_server); + emdaemon_delete_mail_all(mailbox_id, from_server, NULL, &err); - emdaemon_delete_mail_all(mailbox, with_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(local_stream); - EM_SAFE_FREE(mailbox); - EM_DEBUG_FUNC_END(); } void stb_delete_mail(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int buffer_size = 0; - int err = EMF_ERROR_NONE; - char* local_stream = NULL; - emf_mailbox_t *mailbox = NULL; - int with_server = 0; + int err = EMAIL_ERROR_NONE; + int mailbox_id = 0; + int from_server = 0; int counter = 0; int num; + int *mail_ids = NULL; /* Mailbox */ - EM_DEBUG_LOG("mailbox"); - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id); - if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(local_stream); - if(local_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); - /* Memory is not yet allocated for mailbox */ - mailbox = (emf_mailbox_t*)em_malloc(sizeof(emf_mailbox_t)); - em_convert_byte_stream_to_mailbox(local_stream, mailbox); + EM_DEBUG_LOG("mailbox_id [%d]", mailbox_id); + + /* Number of mail_ids */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &num); + EM_DEBUG_LOG("number of mails [%d]", num); + + if (num > 0) { + mail_ids = em_malloc(sizeof(int) * num); + if (!mail_ids) { + EM_DEBUG_EXCEPTION("em_malloc failed"); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; } - EM_DEBUG_LOG("account_id [%d]", mailbox->account_id); - EM_DEBUG_LOG("mailbox name - %s", mailbox->name); + } - /* Number of mail_ids */ - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &num); - EM_DEBUG_LOG("number of mails [%d]", num); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, num * sizeof(int), mail_ids); - int mail_ids[num]; - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, num * sizeof(int), mail_ids); - for(counter = 0; counter < num; counter++) - EM_DEBUG_LOG("mail_ids [%d]", mail_ids[counter]); - - /* with_server */ - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 3, sizeof(int), &with_server); - EM_DEBUG_LOG("with_Server [%d]", with_server); + for(counter = 0; counter < num; counter++) + EM_DEBUG_LOG("mail_ids [%d]", mail_ids[counter]); - emdaemon_delete_mail(mailbox->account_id, mailbox, mail_ids, num, with_server, NULL, &err); - } - else - err = EMF_ERROR_IPC_CRASH; - + /* from_server */ + 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); + +FINISH_OFF: if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) - EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); + 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(local_stream); - EM_SAFE_FREE(mailbox); + EM_SAFE_FREE(mail_ids); - EM_DEBUG_FUNC_END(); + EM_DEBUG_FUNC_END(); } void stb_clear_mail_data (HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - + int err = EMAIL_ERROR_NONE; + if(emdaemon_clear_all_mail_data(&err)) { EM_DEBUG_LOG(">>> stb_clear_mail_data Success [ %d] >> ", err); } - + 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)) @@ -1111,269 +1052,260 @@ void stb_add_rule(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); int buffer_size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char* local_rule_stream = NULL; - emf_rule_t rule = { 0 }; + email_rule_t rule = { 0 }; - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0); + if(buffer_size <= 0) { + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } - if(buffer_size > 0) { - local_rule_stream = (char*)em_malloc(buffer_size + 1); - EM_NULL_CHECK_FOR_VOID(local_rule_stream); - 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, &rule); - EM_DEBUG_LOG("account ID [%d]", rule.account_id); + local_rule_stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0); + if(!local_rule_stream) { + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + em_convert_byte_stream_to_rule(local_rule_stream, buffer_size, &rule); + EM_DEBUG_LOG("account ID [%d]", rule.account_id); - if(emdaemon_add_filter(&rule, &err)) - err = EMF_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 "); - - } - } + /* call add_filter handler */ + emdaemon_add_filter(&rule, &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(local_rule_stream); + emcore_free_rule(&rule); EM_DEBUG_FUNC_END(); } + +/* obsolete - there is no api calling this function */ void stb_get_rule(HIPC_API a_hAPI) { - int err = EMF_ERROR_NONE; + EM_DEBUG_FUNC_BEGIN(); + int err = EMAIL_ERROR_NONE; int filter_id = 0; - emf_rule_t* rule = NULL; + email_rule_t* rule = NULL; int size =0; char* local_rule_stream = NULL; - EM_DEBUG_LOG(" filter_id"); - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &filter_id); + filter_id = *((int*)emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0)); - if(emdaemon_get_filter(filter_id, &rule, &err)) { - err = EMF_ERROR_NONE; - if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) - EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - - /* Rule */ - local_rule_stream = em_convert_rule_to_byte_stream(rule, &size); + emdaemon_get_filter(filter_id, &rule, &err); - EM_NULL_CHECK_FOR_VOID(local_rule_stream); + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); + /* insert a rule if there exists a rule */ + if ( rule ) { + local_rule_stream = em_convert_rule_to_byte_stream(rule, &size); + EM_NULL_CHECK_FOR_VOID(local_rule_stream); 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 "); - EM_SAFE_FREE( local_rule_stream ); - return; - } + EM_SAFE_FREE( local_rule_stream ); } - else { - 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( local_rule_stream ); - return; - } + if (!emipc_execute_stub_api(a_hAPI)) { + EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); + return; } - EM_SAFE_FREE( local_rule_stream ); + EM_DEBUG_FUNC_END(); } +/* obsolete - there is no api calling this function */ void stb_get_rule_list(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - /* int buffer_size = 0; */ - int err = EMF_ERROR_NONE; - int counter = 0; + int err = EMAIL_ERROR_NONE; + int i = 0; char* local_stream = NULL; int count = 0; int size = 0; + email_rule_t* filtering_list = NULL; - emf_rule_t* filtering_list = NULL; + emdaemon_get_filter_list(&filtering_list, &count, &err); - if(emdaemon_get_filter_list(&filtering_list, &count, &err)) { - EM_DEBUG_LOG("emdaemon_get_filter_list - success"); - err = EMF_ERROR_NONE; - 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, &err, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - EM_DEBUG_LOG("Count [%d]", count); + /* insert rules if there exist rules*/ + if( count > 0 ) { + EM_DEBUG_LOG("num of rules [%d]", count); if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &count, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - for(counter=0; counter 0) { - local_rule_stream = (char*)em_malloc(buffer_size+1); + local_rule_stream = (char*)em_malloc(buffer_size); EM_NULL_CHECK_FOR_VOID(local_rule_stream); 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, &rule); + 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 = EMF_ERROR_NONE; - + 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 "); - + } - } + } EM_DEBUG_FUNC_END(); } -void stb_update_change(HIPC_API a_hAPI) +void stb_update_rule(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - + int filter_id = 0; int buffer_size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char* rule_stream = NULL; - emf_rule_t *rule = NULL; + email_rule_t rule = {0}; + + + /* get filter_id */ + filter_id = *((int*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0)); + + /* get rule */ + buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 1); + EM_DEBUG_LOG("size [%d]", buffer_size); + if(buffer_size <= 0) { + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + rule_stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 1); + if(!rule_stream) { + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } + em_convert_byte_stream_to_rule(rule_stream, buffer_size, &rule); + + /* call update handler */ + emdaemon_update_filter(filter_id, &rule, &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"); + + emcore_free_rule(&rule); + +#if 0 /* filter_id */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &filter_id); - + buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1); EM_DEBUG_LOG("size [%d]", buffer_size); - + if(buffer_size > 0) { - rule_stream = (char*)em_malloc(buffer_size+1); + rule_stream = (char*)em_malloc(buffer_size); EM_NULL_CHECK_FOR_VOID(rule_stream); if(rule_stream) { emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, rule_stream); - rule = (emf_rule_t*)em_malloc(sizeof(emf_rule_t)); + rule = (email_rule_t*)em_malloc(sizeof(email_rule_t)); if(NULL == rule) { EM_SAFE_FREE(rule_stream); return; } - - em_convert_byte_stream_to_rule(rule_stream, rule); + + em_convert_byte_stream_to_rule(rule_stream, buffer_size, rule); EM_SAFE_FREE(rule_stream); } } if(emdaemon_update_filter(filter_id, rule, &err)) - err = EMF_ERROR_NONE; + 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"); - EM_SAFE_FREE(rule); - EM_DEBUG_FUNC_END(); + EM_SAFE_FREE(rule); +#endif + + EM_DEBUG_FUNC_END(); } void stb_move_all_mails(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int buffer_size = 0; - int err = EMF_ERROR_NONE; - char* src_mailbox_stream = NULL; - char* dst_mailbox_stream = NULL; - emf_mailbox_t dst_mailbox; - emf_mailbox_t src_mailbox; + int err = EMAIL_ERROR_NONE; + int src_mailbox_id = 0, dst_mailbox_id = 0; - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); - EM_DEBUG_LOG("buffer_size [%d]", buffer_size); - - if(buffer_size > 0) { - src_mailbox_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(src_mailbox_stream); - if(src_mailbox_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, src_mailbox_stream); - /* Convert Byte stream to mailbox structure */ - EM_DEBUG_LOG("Before em_convert_byte_stream_to_mailbox"); - em_convert_byte_stream_to_mailbox(src_mailbox_stream, &src_mailbox); - EM_SAFE_FREE(src_mailbox_stream); - if (src_mailbox.name) - EM_DEBUG_LOG("Mailbox name - %s", src_mailbox.name); - else - EM_DEBUG_EXCEPTION(">>>> Mailbox Information is NULL >> "); - - } - } + /* src_mailbox_id */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &src_mailbox_id); + EM_DEBUG_LOG("src_mailbox_id [%d]", src_mailbox_id); - buffer_size =0; - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1); - EM_DEBUG_LOG(" size [%d]", buffer_size); - - if(buffer_size > 0) { - dst_mailbox_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(dst_mailbox_stream); - if(dst_mailbox_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, dst_mailbox_stream); - em_convert_byte_stream_to_mailbox(dst_mailbox_stream, &dst_mailbox); - EM_SAFE_FREE(dst_mailbox_stream); - if (dst_mailbox.name) - EM_DEBUG_LOG("Mailbox name - %s", dst_mailbox.name); - else - EM_DEBUG_EXCEPTION(">>>> Mailbox Information is NULL >> "); - } - } - - if(emdaemon_move_mail_all_mails(&src_mailbox, &dst_mailbox, &err)) + if (src_mailbox_id > 0) + EM_DEBUG_LOG("src_mailbox_id [%d]", src_mailbox_id); + else + EM_DEBUG_LOG("src_mailbox_id == 0"); + + /* dst_mailbox_id */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &dst_mailbox_id); + EM_DEBUG_LOG("dst_mailbox_id [%d]", dst_mailbox_id); + + if (dst_mailbox_id > 0) + EM_DEBUG_LOG("dst_mailbox_id [%d]", dst_mailbox_id); + else + EM_DEBUG_LOG("dst_mailbox_id == 0"); + + if(emdaemon_move_mail_all_mails(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; @@ -1384,8 +1316,8 @@ void stb_move_all_mails(HIPC_API a_hAPI) void stb_set_flags_field(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; - emf_flags_field_type field_type = 0; + int err = EMAIL_ERROR_NONE; + email_flags_field_type field_type = 0; int account_id; int value = 0; int onserver = 0; @@ -1400,18 +1332,18 @@ void stb_set_flags_field(HIPC_API a_hAPI) /* Number of mail_ids */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &num); EM_DEBUG_LOG("number of mails [%d]", num); - + /* mail_id */ mail_ids = em_malloc(sizeof(int) * num); - + if(!mail_ids) { EM_DEBUG_EXCEPTION("em_malloc failed "); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, num * sizeof(int), mail_ids); - + for(counter=0; counter < num; counter++) EM_DEBUG_LOG("mailids [%d]", mail_ids[counter]); @@ -1422,19 +1354,19 @@ void stb_set_flags_field(HIPC_API a_hAPI) /* value */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 4, sizeof(int), &value); EM_DEBUG_LOG("value [%d]", value); - + /* on server */ 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(account_id, mail_ids, num, field_type, value, onserver, &err)) EM_DEBUG_LOG("emdaemon_set_flags_field - success"); FINISH_OFF: 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_DEBUG_FUNC_END(); @@ -1445,84 +1377,161 @@ void stb_add_mail(HIPC_API a_hAPI) EM_DEBUG_FUNC_BEGIN(); int buffer_size = 0; int local_result = 0; - int result_mail_data_count = 0; int result_attachment_data_count = 0; - int parameter_index = 0; + int param_index = 0; int sync_server = 0; - int err = EMF_ERROR_NONE; - char *mail_data_stream = NULL; - char *attachment_data_list_stream = NULL; - char *meeting_request_stream = NULL; - emf_mail_data_t *result_mail_data = NULL; - emf_attachment_data_t *result_attachment_data = NULL; - emf_meeting_request_t *result_meeting_request = NULL; - - EM_DEBUG_LOG("emf_mail_data_t"); - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, parameter_index); + int err = EMAIL_ERROR_NONE; + email_mail_data_t result_mail_data = {0}; + email_attachment_data_t *result_attachment_data = NULL; + email_meeting_request_t result_meeting_request = {0}; + + + /* 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); + /* mail_data */ if(buffer_size > 0) { - mail_data_stream = (char*)em_malloc(buffer_size + 1); + char *stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++); + em_convert_byte_stream_to_mail_data(stream, buffer_size, &result_mail_data); + } + + /* attachment */ + 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); + + if(buffer_size > 0) { + char *stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index); + em_convert_byte_stream_to_attachment_data(stream, buffer_size, &result_attachment_data, &result_attachment_data_count); + + EM_DEBUG_LOG("result_attachment_data_count[%d]", result_attachment_data_count); + + if(result_attachment_data_count && !result_attachment_data) { + EM_DEBUG_EXCEPTION("em_convert_byte_stream_to_attachment_data failed"); + err = EMAIL_ERROR_ON_PARSING; + goto FINISH_OFF; + } + } + + param_index++; + + /* meeting request */ + EM_DEBUG_LOG("email_meeting_request_t"); + if ( result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST + || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE + || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { + buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index); + + if(buffer_size > 0) { + char* stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++); + em_convert_byte_stream_to_meeting_req(stream, buffer_size, &result_meeting_request); + } + } + + 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) { + EM_DEBUG_EXCEPTION("emdaemon_add_mail failed [%d]", err); + goto FINISH_OFF; + } + + local_result = 1; + 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, &result_mail_data.mail_id, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.thread_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"); + +FINISH_OFF: + if ( local_result == 0 ) { + 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"); + } + + emcore_free_mail_data(&result_mail_data); + + 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(); + +#if 0 + EM_DEBUG_LOG("email_mail_data_t"); + buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index); + + /* mail_data */ + if(buffer_size > 0) { + mail_data_stream = (char*)em_malloc(buffer_size); if(!mail_data_stream) { - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - emipc_get_parameter(a_hAPI, ePARAMETER_IN, parameter_index++, buffer_size, mail_data_stream); - em_convert_byte_stream_to_mail_data(mail_data_stream, &result_mail_data, &result_mail_data_count); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, param_index++, buffer_size, mail_data_stream); + em_convert_byte_stream_to_mail_data(mail_data_stream, buffer_size, &result_mail_data); if(!result_mail_data) { EM_DEBUG_EXCEPTION("em_convert_byte_stream_to_mail_data failed"); - err = EMF_ERROR_ON_PARSING; + err = EMAIL_ERROR_ON_PARSING; goto FINISH_OFF; } } - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, parameter_index); - EM_DEBUG_LOG("emf_attachment_data_t buffer_size[%d]", buffer_size); + /* attachment */ + buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, param_index); + EM_DEBUG_LOG("email_attachment_data_t buffer_size[%d]", buffer_size); if(buffer_size > 0) { - attachment_data_list_stream = (char*)em_malloc(buffer_size + 1); + attachment_data_list_stream = (char*) em_malloc(buffer_size); if(!attachment_data_list_stream) { EM_DEBUG_EXCEPTION("em_malloc failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - emipc_get_parameter(a_hAPI, ePARAMETER_IN, parameter_index++, buffer_size, attachment_data_list_stream); - em_convert_byte_stream_to_attachment_data(attachment_data_list_stream, &result_attachment_data, &result_attachment_data_count); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, param_index++, buffer_size, attachment_data_list_stream); + em_convert_byte_stream_to_attachment_data(attachment_data_list_stream, buffer_size, &result_attachment_data, &result_attachment_data_count); EM_DEBUG_LOG("result_attachment_data_count[%d]", result_attachment_data_count); if(result_attachment_data_count && !result_attachment_data) { EM_DEBUG_EXCEPTION("em_convert_byte_stream_to_attachment_data failed"); - err = EMF_ERROR_ON_PARSING; + err = EMAIL_ERROR_ON_PARSING; goto FINISH_OFF; } } - EM_DEBUG_LOG("emf_meeting_request_t"); - - if ( result_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_REQUEST - || result_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_RESPONSE - || result_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, parameter_index); + /* meeting request */ + EM_DEBUG_LOG("email_meeting_request_t"); + if ( result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST + || result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE + || result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { + buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, param_index); if(buffer_size > 0) { - meeting_request_stream = (char*)em_malloc(buffer_size + 1); + meeting_request_stream = (char*)em_malloc(buffer_size); if(!meeting_request_stream) { EM_DEBUG_EXCEPTION("em_convert_byte_stream_to_mail_data failed"); - err = EMF_ERROR_OUT_OF_MEMORY; + err = EMAIL_ERROR_OUT_OF_MEMORY; goto FINISH_OFF; } - emipc_get_parameter(a_hAPI, ePARAMETER_IN, parameter_index++, buffer_size, meeting_request_stream); - result_meeting_request = (emf_meeting_request_t*)em_malloc(sizeof(emf_meeting_request_t)); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, param_index++, buffer_size, meeting_request_stream); + result_meeting_request = (email_meeting_request_t*)em_malloc(sizeof(email_meeting_request_t)); if(result_meeting_request) - em_convert_byte_stream_to_meeting_req(meeting_request_stream, result_meeting_request); + em_convert_byte_stream_to_meeting_req(meeting_request_stream, buffer_size, result_meeting_request); } } EM_DEBUG_LOG("sync_server"); - emipc_get_parameter(a_hAPI, ePARAMETER_IN, parameter_index++, sizeof(int), &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)) != EMF_ERROR_NONE) { + if( (err = emdaemon_add_mail(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; } @@ -1547,7 +1556,7 @@ FINISH_OFF: EM_SAFE_FREE(mail_data_stream); EM_SAFE_FREE(attachment_data_list_stream); - EM_SAFE_FREE(meeting_request_stream); + EM_SAFE_FREE(meeting_request_stream); if(result_mail_data) emcore_free_mail_data(&result_mail_data, 1, NULL); @@ -1559,6 +1568,7 @@ FINISH_OFF: emstorage_free_meeting_request(&result_meeting_request, 1, NULL); em_flush_memory(); +#endif EM_DEBUG_FUNC_END(); } @@ -1568,84 +1578,67 @@ void stb_update_mail(HIPC_API a_hAPI) EM_DEBUG_FUNC_BEGIN(); int buffer_size = 0; int local_result = 0; - int result_mail_data_count = 0; int result_attachment_data_count = 0; - int parameter_index = 0; + int param_index = 0; int sync_server = 0; - int err = EMF_ERROR_NONE; - char *mail_data_stream = NULL; - char *attachment_data_list_stream = NULL; - char *meeting_request_stream = NULL; - emf_mail_data_t *result_mail_data = NULL; - emf_attachment_data_t *result_attachment_data = NULL; - emf_meeting_request_t *result_meeting_request = NULL; + int *temp_buffer = NULL; + int err = EMAIL_ERROR_NONE; + email_mail_data_t result_mail_data = {0}; + email_attachment_data_t *result_attachment_data = NULL; + email_meeting_request_t result_meeting_request = {0}; - EM_DEBUG_LOG("emf_mail_data_t"); - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, parameter_index); + EM_DEBUG_LOG("email_mail_data_t"); + buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index); if(buffer_size > 0) { - mail_data_stream = (char*)em_malloc(buffer_size + 1); - if(!mail_data_stream) { - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - emipc_get_parameter(a_hAPI, ePARAMETER_IN, parameter_index++, buffer_size,mail_data_stream); - em_convert_byte_stream_to_mail_data(mail_data_stream, &result_mail_data, &result_mail_data_count); - if(!result_mail_data) { - EM_DEBUG_EXCEPTION("em_convert_byte_stream_to_mail_data failed"); - err = EMF_ERROR_ON_PARSING; - goto FINISH_OFF; - } + char* stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++); + em_convert_byte_stream_to_mail_data(stream, buffer_size, &result_mail_data); } - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, parameter_index); - EM_DEBUG_LOG("emf_attachment_data_t buffer_size[%d]", buffer_size); + 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); if(buffer_size > 0) { - attachment_data_list_stream = (char*)em_malloc(buffer_size + 1); - if(!attachment_data_list_stream) { - EM_DEBUG_EXCEPTION("em_malloc failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - - emipc_get_parameter(a_hAPI, ePARAMETER_IN, parameter_index++, buffer_size, attachment_data_list_stream); - em_convert_byte_stream_to_attachment_data(attachment_data_list_stream, &result_attachment_data, &result_attachment_data_count); + char *stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index); + em_convert_byte_stream_to_attachment_data(stream, buffer_size, &result_attachment_data, &result_attachment_data_count); EM_DEBUG_LOG("result_attachment_data_count[%d]", result_attachment_data_count); if(result_attachment_data_count && !result_attachment_data) { EM_DEBUG_EXCEPTION("em_convert_byte_stream_to_attachment_data failed"); - err = EMF_ERROR_ON_PARSING; + err = EMAIL_ERROR_ON_PARSING; goto FINISH_OFF; } } - EM_DEBUG_LOG("emf_meeting_request_t"); + param_index++; - if ( result_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_REQUEST - || result_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_RESPONSE - || result_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, parameter_index); + EM_DEBUG_LOG("email_meeting_request_t"); + + if ( result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST + || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE + || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { + buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index); if(buffer_size > 0) { - meeting_request_stream = (char*)em_malloc(buffer_size + 1); - if(!meeting_request_stream) { - EM_DEBUG_EXCEPTION("em_convert_byte_stream_to_mail_data failed"); - err = EMF_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - } - emipc_get_parameter(a_hAPI, ePARAMETER_IN, parameter_index++, buffer_size, meeting_request_stream); - result_meeting_request = (emf_meeting_request_t*)em_malloc(sizeof(emf_meeting_request_t)); - if(result_meeting_request) - em_convert_byte_stream_to_meeting_req(meeting_request_stream, result_meeting_request); + char* stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++); + em_convert_byte_stream_to_meeting_req(stream, buffer_size, &result_meeting_request); } } EM_DEBUG_LOG("sync_server"); - emipc_get_parameter(a_hAPI, ePARAMETER_IN, parameter_index++, sizeof(int), &sync_server); - if( (err = emdaemon_update_mail(result_mail_data, result_attachment_data, result_attachment_data_count, result_meeting_request, sync_server)) != EMF_ERROR_NONE) { + temp_buffer = emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++); + + if (!temp_buffer) { + EM_DEBUG_EXCEPTION("emipc_get_nth_parameter_data[%d] failed ", param_index - 1); + goto FINISH_OFF; + } + + sync_server = *temp_buffer; + + if( (err = emdaemon_update_mail(&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; } @@ -1653,9 +1646,9 @@ void stb_update_mail(HIPC_API a_hAPI) local_result = 1; 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, &(result_mail_data->mail_id), sizeof(int))) + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.mail_id, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(result_mail_data->thread_id), sizeof(int))) + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.thread_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"); @@ -1668,18 +1661,12 @@ FINISH_OFF: EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed"); } - EM_SAFE_FREE(mail_data_stream); - EM_SAFE_FREE(attachment_data_list_stream); - EM_SAFE_FREE(meeting_request_stream); - - if(result_mail_data) - emcore_free_mail_data(&result_mail_data, 1, NULL); + emcore_free_mail_data(&result_mail_data); if(result_attachment_data) emcore_free_attachment_data(&result_attachment_data, result_attachment_data_count, NULL); - if(result_meeting_request) - emstorage_free_meeting_request(&result_meeting_request, 1, NULL); + emstorage_free_meeting_request(&result_meeting_request); em_flush_memory(); EM_DEBUG_FUNC_END(); @@ -1689,33 +1676,20 @@ FINISH_OFF: void stb_move_thread_to_mailbox(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int buffer_size = 0, thread_id = 0, move_always_flag = 0; - int err = EMF_ERROR_NONE; + int mailbox_id = 0, thread_id = 0, move_always_flag = 0; + int err = EMAIL_ERROR_NONE; char *target_mailbox_name = NULL; emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &thread_id); EM_DEBUG_LOG("thread_id [%d]", thread_id); - - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1); - EM_DEBUG_LOG("mailbox stream size [%d]", buffer_size); - - if(buffer_size > 0) { - target_mailbox_name = (char*)em_malloc(buffer_size + 1); - EM_NULL_CHECK_FOR_VOID(target_mailbox_name); - if(target_mailbox_name) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, target_mailbox_name); - /* Convert Byte stream to mailbox structure */ - if (target_mailbox_name) - EM_DEBUG_LOG("Mailbox name - %s", target_mailbox_name); - else - EM_DEBUG_EXCEPTION("Mailbox name is NULL"); - } - } + + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mailbox_id); + EM_DEBUG_LOG("mailbox_id [%d]", mailbox_id); 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, target_mailbox_name, move_always_flag, &err)) + + if(emdaemon_move_mail_thread_to_mailbox(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))) { @@ -1737,17 +1711,17 @@ void stb_move_thread_to_mailbox(HIPC_API a_hAPI) void stb_delete_thread(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - + int thread_id = 0, delete_always_flag = 0; unsigned int handle = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &thread_id); EM_DEBUG_LOG("thread_id [%d]", thread_id); 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)) EM_DEBUG_LOG("emdaemon_delete_mail_thread success"); @@ -1766,10 +1740,10 @@ void stb_delete_thread(HIPC_API a_hAPI) void stb_modify_seen_flag_of_thread(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - + int thread_id = 0, seen_flag = 0, on_server = 0; unsigned int handle = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &thread_id); EM_DEBUG_LOG("thread_id [%d]", thread_id); @@ -1779,7 +1753,7 @@ 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)) EM_DEBUG_LOG("emdaemon_modify_seen_flag_of_thread success"); @@ -1795,49 +1769,71 @@ void stb_modify_seen_flag_of_thread(HIPC_API a_hAPI) EM_DEBUG_FUNC_END(); } +void stb_expunge_mails_deleted_flagged(HIPC_API a_hAPI) +{ + EM_DEBUG_FUNC_BEGIN(); + + int mailbox_id = 0, on_server = 0; + unsigned int handle = 0; + int err = EMAIL_ERROR_NONE; + + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), (void*)&mailbox_id); + EM_DEBUG_LOG("mailbox_id [%d]", mailbox_id); + + 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) + 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_DEBUG_FUNC_END(); +} void stb_move_mail(HIPC_API a_hAPI) { - int err = EMF_ERROR_NONE; - int buffer_size = 0, num = 0, counter = 0; - char *local_stream = NULL; - emf_mailbox_t mailbox; + int err = EMAIL_ERROR_NONE; + int num = 0, counter = 0, mailbox_id = 0; /* Number of mail_ids */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &num); EM_DEBUG_LOG("number of mails [%d]", num); /* mail_id */ - int mail_ids[num]; + int mail_ids[num]; emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, num * sizeof(int), mail_ids); - + for(counter = 0; counter < num; counter++) EM_DEBUG_LOG("mailids [%d]", mail_ids[counter]); - - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2); - EM_DEBUG_LOG("size [%d]", buffer_size); - - if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(local_stream); - if(local_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, local_stream); - em_convert_byte_stream_to_mailbox(local_stream, &mailbox); - EM_SAFE_FREE(local_stream); - - if (mailbox.name) - EM_DEBUG_LOG("mailbox.name [%s]", mailbox.name); - else - EM_DEBUG_EXCEPTION("mailbox.name is NULL"); - - if(emdaemon_move_mail(mail_ids, num, &mailbox, EMF_MOVED_BY_COMMAND, 0, &err)) - EM_DEBUG_LOG("emdaemon_move_mail success"); - } - } - + + /* target_mailbox_id */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &mailbox_id); + EM_DEBUG_LOG("target_mailbox_id [%d]", mailbox_id); + + if (mailbox_id > 0) + EM_DEBUG_LOG("mailbox_id [%d]", mailbox_id); + else + EM_DEBUG_LOG("mailbox_id == 0"); + + if(emdaemon_move_mail(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))) EM_DEBUG_EXCEPTION("emipc_add_parameter fail"); - + if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api fail"); EM_DEBUG_FUNC_END(); @@ -1846,19 +1842,19 @@ void stb_move_mail(HIPC_API a_hAPI) void stb_delete_rule(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - + int filter_id = 0; - int err = EMF_ERROR_NONE; - + int err = EMAIL_ERROR_NONE; + /* filter_id */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &filter_id); - + if(emdaemon_delete_filter(filter_id, &err)) - err = EMF_ERROR_NONE; + 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 "); EM_DEBUG_FUNC_END(); @@ -1868,137 +1864,95 @@ void stb_add_attachment(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); int buffer_size = 0; - int err = EMF_ERROR_NONE; - char* local_stream = NULL; - emf_mailbox_t mailbox; + int err = EMAIL_ERROR_NONE; int mail_id = -1; + int attachment_count = 0; char* attachment_stream = NULL; - emf_attachment_info_t* attachment = NULL; - - /* mailbox */ - EM_DEBUG_LOG("mailbox"); - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); - - if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(local_stream); - if(local_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); - em_convert_byte_stream_to_mailbox(local_stream, &mailbox); - EM_SAFE_FREE(local_stream); - } - } + email_attachment_data_t* attachment = NULL; /* mail_id */ - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mail_id); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id); /* attachment */ - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2); + buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1); if(buffer_size > 0) { - attachment_stream = (char*)em_malloc(buffer_size+1); + attachment_stream = (char*)em_malloc(buffer_size); EM_NULL_CHECK_FOR_VOID(attachment_stream); if(attachment_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, attachment_stream); - em_convert_byte_stream_to_attachment_info(attachment_stream, 1, &attachment); + 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); } } - emdaemon_add_attachment(&mailbox, mail_id, attachment, &err); - + emdaemon_add_attachment(mail_id, attachment, &err); + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed "); - if(EMF_ERROR_NONE == err) { + if(EMAIL_ERROR_NONE == err) { EM_DEBUG_LOG("emdaemon_add_attachment -Success"); - + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(attachment->attachment_id), sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter attachment_id failed "); } if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); - EM_SAFE_FREE(attachment); + EM_SAFE_FREE(attachment); EM_DEBUG_FUNC_END(); } void stb_get_attachment(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int buffer_size = 0; - int err = EMF_ERROR_NONE; - char* local_stream = NULL; - emf_mailbox_t mailbox; - int mail_id = -1; - char* attachment_no = NULL; + int err = EMAIL_ERROR_NONE; + int attachment_id; char* attachment_stream = NULL; - emf_attachment_info_t* attachment = NULL; + email_attachment_data_t* attachment = NULL; int size = 0; - /* mailbox */ - EM_DEBUG_LOG("mailbox"); - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); - - if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(local_stream); - if(local_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); - em_convert_byte_stream_to_mailbox(local_stream, &mailbox); - EM_SAFE_FREE(local_stream); - } - } - - /* mail_id */ - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mail_id); + /* attachment_id */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &attachment_id); - /* attachment_no */ - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2); - if(buffer_size > 0) { - attachment_no = (char*)em_malloc(buffer_size+1); - if(attachment_no) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, attachment_no); - } - } - emdaemon_get_attachment(&mailbox, mail_id, attachment_no, &attachment, &err); + emdaemon_get_attachment(attachment_id, &attachment, &err); if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed "); - if(EMF_ERROR_NONE == err) { + + if(EMAIL_ERROR_NONE == err) { EM_DEBUG_LOG("emdaemon_get_attachment - Success"); /* attachment */ - attachment_stream = em_convert_attachment_info_to_byte_stream(attachment, &size); + attachment_stream = em_convert_attachment_data_to_byte_stream(attachment, 1, &size); EM_NULL_CHECK_FOR_VOID(attachment_stream); - + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, attachment_stream, size)) 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(attachment_no); - EM_SAFE_FREE(attachment_stream); + EM_SAFE_FREE(attachment_stream); return; } - EM_SAFE_FREE(attachment_no); - EM_SAFE_FREE(attachment_stream); + EM_SAFE_FREE(attachment_stream); EM_DEBUG_FUNC_END(); } void stb_get_imap_mailbox_list(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int account_id = 0; - unsigned int handle = 0; + unsigned int handle = 0; /* account_id */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); if(emdaemon_get_imap_mailbox_list(account_id, "", &handle, &err)) - err = EMF_ERROR_NONE; - + err = EMAIL_ERROR_NONE; + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) EM_DEBUG_LOG("ipcAPI_AddParameter local_result failed "); if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int))) @@ -2011,96 +1965,49 @@ void stb_get_imap_mailbox_list(HIPC_API a_hAPI) void stb_delete_attachment(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - int buffer_size = 0; - int err = EMF_ERROR_NONE; - char* local_stream = NULL; - emf_mailbox_t mailbox; - int mail_id = -1; - char* attachment_no = NULL; - - /* mailbox */ - EM_DEBUG_LOG("mailbox"); - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); - - if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(local_stream); - if(local_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); - em_convert_byte_stream_to_mailbox(local_stream, &mailbox); - EM_SAFE_FREE(local_stream); - } - } + int err = EMAIL_ERROR_NONE; + int attachment_id = 0; - /* mail_id */ - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mail_id); + /* attachment_index */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &attachment_id); - /* attachment_no */ - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2); - if(buffer_size > 0) { - attachment_no = (char*)em_malloc(buffer_size+1); - if(attachment_no) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, attachment_no); - } - } + emdaemon_delete_mail_attachment(attachment_id, &err); - emdaemon_delete_mail_attachment(&mailbox, mail_id, attachment_no, &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(attachment_no); EM_DEBUG_FUNC_END(); } void stb_download_attachment(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - - int buffer_size = 0; - int err = EMF_ERROR_NONE; - char* local_stream = NULL; - emf_mailbox_t mailbox; + + int err = EMAIL_ERROR_NONE; int mail_id = 0; - char *nth = NULL; - unsigned int handle = 0; - - EM_DEBUG_LOG("mailbox"); - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + int nth = 0; + unsigned int handle = 0; + int account_id = 0; - if(buffer_size > 0) { - local_stream = (char*)em_malloc(buffer_size+1); - EM_NULL_CHECK_FOR_VOID(local_stream); - if(local_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream); - em_convert_byte_stream_to_mailbox(local_stream, &mailbox); - EM_SAFE_FREE(local_stream); - } - } + EM_DEBUG_LOG("account_id"); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); EM_DEBUG_LOG("mail_id"); emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mail_id); - /* nth */ EM_DEBUG_LOG("nth"); - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2); - if(buffer_size > 0) { - nth = (char*)em_malloc(buffer_size+1); - if(nth) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, nth); - } - } + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &nth); - if(emdaemon_download_attachment(&mailbox, mail_id, nth, &handle, &err)) { - err = EMF_ERROR_NONE; + if(emdaemon_download_attachment(account_id, mail_id, nth, &handle, &err)) { + err = EMAIL_ERROR_NONE; if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); EM_DEBUG_LOG(">>>>>>>>>> HANDLE = %d", handle); if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int))) - EM_DEBUG_EXCEPTION("emipc_add_parameter handle failed "); + EM_DEBUG_EXCEPTION("emipc_add_parameter handle failed "); if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); } @@ -2110,12 +2017,11 @@ void stb_download_attachment(HIPC_API a_hAPI) /* Download handle - 17-Apr-09 */ EM_DEBUG_LOG(">>>>>>>>>> HANDLE = %d", handle); if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int))) - EM_DEBUG_EXCEPTION("emipc_add_parameter handle failed "); + EM_DEBUG_EXCEPTION("emipc_add_parameter handle failed "); if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); } - EM_SAFE_FREE(nth); EM_DEBUG_FUNC_END(); } @@ -2123,58 +2029,61 @@ void stb_mail_send_saved(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); int buffer_size = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char* local_option_stream = NULL; - emf_option_t sending_option; + email_option_t sending_option; int account_id = 0; /* unsigned *handle = NULL; */ - + /* account_id */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); - + /* Sending Option */ EM_DEBUG_LOG("Sending option"); buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1); if(buffer_size > 0) { - local_option_stream = (char*)em_malloc(buffer_size+1); + local_option_stream = (char*)em_malloc(buffer_size); EM_NULL_CHECK_FOR_VOID(local_option_stream); if(local_option_stream) { emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, local_option_stream); - em_convert_byte_stream_to_option(local_option_stream, &sending_option); + em_convert_byte_stream_to_option(local_option_stream, buffer_size, &sending_option); /* EM_SAFE_FREE(local_option_stream); */ } } EM_DEBUG_LOG("calling emdaemon_send_mail_saved"); if(emdaemon_send_mail_saved(account_id, &sending_option, NULL, &err)) - err = EMF_ERROR_NONE; - + err = EMAIL_ERROR_NONE; + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, 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 "); + + emcore_free_option(&sending_option); + EM_DEBUG_FUNC_END(); -} +} void stb_add_read_receipt(HIPC_API a_hAPI){ EM_DEBUG_FUNC_BEGIN(); int read_mail_id = 0; int receipt_mail_id = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; /* 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)) != EMF_ERROR_NONE ) + if( (err = emcore_add_read_receipt(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))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - if (err == EMF_ERROR_NONE) { + if (err == EMAIL_ERROR_NONE) { if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &receipt_mail_id, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); } @@ -2191,7 +2100,7 @@ void stb_retry_sending_mail(HIPC_API a_hAPI) EM_DEBUG_FUNC_BEGIN(); int mail_id = 0; int timeout_in_sec = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; /* Mail_id */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id); @@ -2202,11 +2111,11 @@ void stb_retry_sending_mail(HIPC_API a_hAPI) EM_DEBUG_LOG("timeout_in_sec [%d]", timeout_in_sec); if(emdaemon_send_mail_retry(mail_id, timeout_in_sec,&err)) - EM_DEBUG_LOG("emdaemon_get_mailbox_list - success"); + 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 "); EM_DEBUG_FUNC_END(); @@ -2217,10 +2126,10 @@ void stb_get_event_queue_status(HIPC_API a_hAPI) EM_DEBUG_FUNC_BEGIN(); int on_sending = 0; int on_receiving = 0; - + /*get the network status */ emdaemon_get_event_queue_status(&on_sending, &on_receiving); - + /* on_sending */ if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &on_sending, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); @@ -2241,32 +2150,32 @@ void stb_cancel_job(HIPC_API a_hAPI) EM_DEBUG_FUNC_BEGIN(); int account_id = 0; int handle = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; 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), &handle); - EM_DEBUG_LOG("handle [%d]", handle); + EM_DEBUG_LOG("handle [%d]", handle); if(emdaemon_cancel_job(account_id, handle, &err)) - err = EMF_ERROR_NONE; + err = EMAIL_ERROR_NONE; 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_DEBUG_EXCEPTION("emipc_execute_stub_api failed"); EM_DEBUG_FUNC_END(); } void stb_get_pending_job(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); - emf_action_t action = -1; + email_action_t action = -1; int account_id = 0; int mail_id = -1; - int err = EMF_ERROR_NONE; - emf_event_status_type_t status = 0; + int err = EMAIL_ERROR_NONE; + email_event_status_type_t status = 0; emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &action); EM_DEBUG_LOG("action [%d]", action); @@ -2278,9 +2187,9 @@ void stb_get_pending_job(HIPC_API a_hAPI) EM_DEBUG_LOG("mail_id [%d]", mail_id); if(emdaemon_get_pending_job(action, account_id, mail_id, &status)) - err = EMF_ERROR_NONE; + err = EMAIL_ERROR_NONE; else - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed "); @@ -2293,10 +2202,10 @@ void stb_get_pending_job(HIPC_API a_hAPI) void stb_print_receiving_event_queue_via_debug_msg(HIPC_API a_hAPI) { - emf_event_t *event_queue = NULL; + email_event_t *event_queue = NULL; int event_active_queue = 0, err, i; - emcore_get_receiving_event_queue(&event_queue, &event_active_queue, &err); + emcore_get_receiving_event_queue(&event_queue, &event_active_queue, &err); EM_DEBUG_LOG("======================================================================"); EM_DEBUG_LOG("Event active index [%d]", event_active_queue); @@ -2305,7 +2214,7 @@ void stb_print_receiving_event_queue_via_debug_msg(HIPC_API a_hAPI) EM_DEBUG_LOG("event[%d] : type[%d], account_id[%d], arg[%d], status[%d]", i, event_queue[i].type, event_queue[i].account_id, event_queue[i].event_param_data_4, event_queue[i].status); EM_DEBUG_LOG("======================================================================"); EM_DEBUG_LOG("======================================================================"); - + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); @@ -2318,23 +2227,23 @@ void stb_cancel_send_mail_job(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); int mail_id = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int account_id = 0; /* account_id */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); EM_DEBUG_LOG("account_id [%d]", account_id); - + /* Mail_id */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mail_id); EM_DEBUG_LOG("mail_id [%d]", mail_id); if(emdaemon_cancel_sending_mail_job(account_id,mail_id,&err)) - EM_DEBUG_LOG("success"); + EM_DEBUG_LOG("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"); EM_DEBUG_FUNC_END(); @@ -2344,11 +2253,11 @@ void stb_search_mail_on_server(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); int i = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int account_id = 0; + int mailbox_id = 0; int buffer_size = 0; int search_filter_count = 0; - char *mailbox_name = NULL; char *stream_for_search_filter_list = NULL; unsigned int job_handle = 0; email_search_filter_t *search_filter_list = NULL; @@ -2357,27 +2266,22 @@ void stb_search_mail_on_server(HIPC_API a_hAPI) emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); EM_DEBUG_LOG("account_id [%d]", account_id); - /* mailbox_name */ - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1); - if(buffer_size > 0) { - mailbox_name = (char*)em_malloc(buffer_size + 1); - EM_NULL_CHECK_FOR_VOID(mailbox_name); - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, mailbox_name); - EM_DEBUG_LOG("mailbox_name [%s]", mailbox_name); - } + /* 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+1); + stream_for_search_filter_list = (char*)em_malloc(buffer_size); EM_NULL_CHECK_FOR_VOID(stream_for_search_filter_list); 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( (err = emdaemon_search_mail_on_server(account_id ,mailbox_name, search_filter_list, search_filter_count, &job_handle)) == EMF_ERROR_NONE) + if(!emdaemon_search_mail_on_server(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))) @@ -2407,79 +2311,98 @@ void stb_search_mail_on_server(HIPC_API a_hAPI) } } - EM_SAFE_FREE(mailbox_name); EM_SAFE_FREE(search_filter_list); 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; + emstorage_mailbox_tbl_t *search_result_mailbox = 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_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_SEARCH_RESULT, &search_result_mailbox, true, &err)) { + EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_by_mailbox_type failed [%d]", err); + goto FINISH_OFF; + } + + if ((err = emcore_delete_all_mails_of_mailbox(search_result_mailbox->mailbox_id, false, &err)) == EMAIL_ERROR_NONE) + EM_DEBUG_EXCEPTION(" emcore_delete_all_mails_of_mailbox 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_DEBUG_FUNC_END(); +} + + + void stb_create_account_with_validation(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); int buffer_size = 0; int local_result = 0; - unsigned int handle = 0; - char* local_account_stream = NULL; - emf_account_t *account; - int err = EMF_ERROR_NONE; + unsigned int handle = 0; + char* stream = NULL; + email_account_t *account = NULL; + int err = EMAIL_ERROR_NONE; - buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + /* get account info */ + buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0); EM_DEBUG_LOG("size [%d]", buffer_size); + if(buffer_size <= 0) { + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } - if(buffer_size > 0) { - local_account_stream = (char*)em_malloc(buffer_size+1); - if(local_account_stream) { - emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_account_stream); - /* Convert account stream to structure */ - EM_DEBUG_LOG("Before Convert_ByteStream_To_Account"); - - account = emcore_get_new_account_reference(); - em_convert_byte_stream_to_account(local_account_stream, account); - EM_SAFE_FREE(local_account_stream); - - account->account_id = NEW_ACCOUNT_ID; + stream =(char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0); + if(!stream) { + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + } - if (account->account_name) + account = emcore_get_new_account_reference(); + em_convert_byte_stream_to_account(stream, buffer_size, account); + account->account_id = NEW_ACCOUNT_ID; EM_DEBUG_LOG("Account name - %s", account->account_name); - if(account->email_addr) - EM_DEBUG_LOG("Email Address - %s", account->email_addr); - - if(emdaemon_validate_account_and_create(account, &handle, &err)) { - -#ifdef __FEATURE_AUTO_POLLING__ - /* start auto polling, if check_interval not zero */ - if(account->check_interval > 0) { - if(!emdaemon_add_polling_alarm( account->account_id,account->check_interval)) - EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm[NOTI_ACCOUNT_ADD] : start auto poll failed >>> "); - } -#endif /* __FEATURE_AUTO_POLLING__ */ - /* add account details to contact DB */ - /* emdaemon_insert_accountinfo_to_contact(account); */ - - local_result = 1; - 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))) - EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); - if (!emipc_execute_stub_api(a_hAPI)) - EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); - } - else { - EM_DEBUG_EXCEPTION("emdaemon_validate_account_and_create fail "); - goto FINISH_OFF; - } - } - else { - err = EMF_ERROR_INVALID_PARAM; - goto FINISH_OFF; - } - } - else { - err = EMF_ERROR_INVALID_PARAM; + EM_DEBUG_LOG("Email Address - %s", account->user_email_address); + + if(!emdaemon_validate_account_and_create(account, &handle, &err)) { + EM_DEBUG_EXCEPTION("emdaemon_validate_account_and_create fail "); goto FINISH_OFF; } +#ifdef __FEATURE_AUTO_POLLING__ + /* start auto polling, if check_interval not zero */ + if(account->check_interval > 0) { + if(!emdaemon_add_polling_alarm( account->account_id, account->check_interval)) + EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm[NOTI_ACCOUNT_ADD] : start auto poll failed >>> "); + } +#endif /* __FEATURE_AUTO_POLLING__ */ + /* add account details to contact DB */ + /* emdaemon_insert_accountinfo_to_contact(account); */ + + local_result = 1; + 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))) + EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); + if (!emipc_execute_stub_api(a_hAPI)) + EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); + FINISH_OFF: - if ( local_result == 0 ) { + if ( local_result == 0 ) { /* there is an error */ if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed : local_result "); if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) @@ -2487,6 +2410,9 @@ FINISH_OFF: if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); } +/* note: account is freed in thread_func_branch_command, which is run by other thread */ +/* emcore_free_account(account); */ + EM_DEBUG_FUNC_END(); } @@ -2494,15 +2420,15 @@ void stb_backup_account(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); -#ifdef __FEATURE_BACKUP_ACCOUNT__ +#ifdef __FEATURE_BACKUP_ACCOUNT__ char *file_path = NULL; int local_result = 0, err_code = 0, handle = 0, file_path_length = 0; - + /* file_path_length */ file_path_length = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); if(file_path_length > 0) { EM_DEBUG_LOG("file_path_length [%d]", file_path_length); - file_path = em_malloc(file_path_length + 1); + file_path = em_malloc(file_path_length); emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, file_path_length, file_path); EM_DEBUG_LOG("file_path [%s]", file_path); local_result = emcore_backup_accounts((const char*)file_path, &err_code); @@ -2513,10 +2439,10 @@ 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 "); @@ -2531,12 +2457,12 @@ void stb_restore_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; - + /* file_path_length */ file_path_length = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); if(file_path_length > 0) { EM_DEBUG_LOG("file_path_length [%d]", file_path_length); - file_path = em_malloc(file_path_length + 1); + file_path = em_malloc(file_path_length); emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, file_path_length, file_path); EM_DEBUG_LOG("file_path [%s]", file_path); local_result = emcore_restore_accounts((const char*)file_path, &err_code); @@ -2547,10 +2473,10 @@ 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 "); @@ -2567,7 +2493,7 @@ void stb_get_password_length(HIPC_API a_hAPI) int local_result = 0; int err_code = 0; int password_length = 0; - + /* account_id */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); local_result = emstorage_get_password_length_of_account(account_id, &password_length,&err_code); @@ -2579,19 +2505,164 @@ void stb_get_password_length(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, &password_length, 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_DEBUG_FUNC_END(); } +void stb_add_certificate(HIPC_API a_hAPI) +{ + int err = EMAIL_ERROR_NONE; + int cert_file_len = 0; + int email_address_len = 0; + char *cert_file_path = NULL; + char *email_address = NULL; + + cert_file_len = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + if (cert_file_len > 0) { + cert_file_path = em_malloc(cert_file_len + 1); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, cert_file_len, cert_file_path); + } + + email_address_len = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1); + if (email_address_len > 0) { + email_address = em_malloc(email_address_len + 1); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, email_address_len, email_address); + } + + if (!emcore_add_public_certificate(cert_file_path, email_address, &err)) { + EM_DEBUG_EXCEPTION("em_core_smime_add_certificate failed"); + } + + if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed "); + + if (EMAIL_ERROR_NONE == err) { + EM_DEBUG_LOG("email_mail_add_attachment -Success"); + } + + if (!emipc_execute_stub_api(a_hAPI)) + EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); + + EM_SAFE_FREE(cert_file_path); + EM_SAFE_FREE(email_address); + EM_DEBUG_FUNC_END(); +} + +void stb_delete_certificate(HIPC_API a_hAPI) +{ + int err = EMAIL_ERROR_NONE; + int email_address_len = 0; + char *email_address = NULL; + char temp_email_address[130] = {0, }; + + email_address_len = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + if (email_address_len > 0) { + EM_DEBUG_LOG("email address string length [%d]", email_address_len); + email_address = em_malloc(email_address_len + 1); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, email_address_len, email_address); + EM_DEBUG_LOG("email address [%s]", email_address); + } + + SNPRINTF(temp_email_address, sizeof(temp_email_address), "<%s>", email_address); + if (!emcore_delete_public_certificate(temp_email_address, &err)) { + EM_DEBUG_EXCEPTION("em_core_smime_add_certificate failed"); + } + + if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed "); + + if (EMAIL_ERROR_NONE == err) { + EM_DEBUG_LOG("email_mail_add_attachment -Success"); + } + + if (!emipc_execute_stub_api(a_hAPI)) + EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed"); + + EM_DEBUG_FUNC_END(); +} + +void stb_verify_signature(HIPC_API a_hAPI) +{ + int err = EMAIL_ERROR_NONE; + int verify = 0; + int mail_id = 0; + int cert_file_len = 0; + char *cert_file_path = 0; + email_mail_data_t *mail_data = NULL; + + cert_file_len = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + if (cert_file_len > 0) { + cert_file_path = em_malloc(cert_file_len + 1); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, cert_file_len, cert_file_path); + } + + err = emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mail_id); + if (err != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emipc_get_parameter failed"); + } + + if (!emcore_get_mail_data(mail_id, &mail_data)) { + EM_DEBUG_EXCEPTION("emcore_get_mail_data failed"); + } + + if (!emcore_verify_signature(cert_file_path, mail_data->file_path_mime_entity, &verify, &err)) { + EM_DEBUG_EXCEPTION("em_core_smime_add_certificate failed"); + } + + if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &verify, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed "); + + if (verify) { + EM_DEBUG_LOG("Verify S/MIME signed mail-Success"); + } + + 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(); +} + +void stb_verify_certificate(HIPC_API a_hAPI) +{ + int err = EMAIL_ERROR_NONE; + int verify = 0; + int cert_file_len = 0; + char *cert_file_path = 0; + + cert_file_len = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0); + if (cert_file_len > 0) { + cert_file_path = em_malloc(cert_file_len + 1); + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, cert_file_len, cert_file_path); + } + + if (!emcore_verify_certificate(cert_file_path, &verify, &err)) { + EM_DEBUG_EXCEPTION("em_core_smime_add_certificate failed"); + } + + if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &verify, sizeof(int))) + EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed "); + + if (verify) { + EM_DEBUG_LOG("Verify S/MIME signed mail-Success"); + } + + 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(); +} void stb_ping_service(HIPC_API a_hAPI) { - int err = EMF_ERROR_NONE; + EM_DEBUG_FUNC_BEGIN(); + int err = EMAIL_ERROR_NONE; if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed "); @@ -2602,7 +2673,8 @@ void stb_ping_service(HIPC_API a_hAPI) void stb_update_notification_bar_for_unread_mail(HIPC_API a_hAPI) { - int err = EMF_ERROR_NONE, account_id; + EM_DEBUG_FUNC_BEGIN(); + int err = EMAIL_ERROR_NONE, account_id; /* account_id */ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id); @@ -2616,16 +2688,48 @@ void stb_update_notification_bar_for_unread_mail(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_DEBUG_EXCEPTION("emipc_execute_stub_api failed "); EM_DEBUG_FUNC_END(); } +void stb_show_user_message(HIPC_API a_hAPI) +{ + EM_DEBUG_FUNC_BEGIN(); + int err = EMAIL_ERROR_NONE; + int param_id = 0; + int param_error = 0; + email_action_t param_action = 0; + + /* param_id */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), ¶m_id); + EM_DEBUG_LOG("param_id [%d]", param_id); + + /* param_action */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), ¶m_action); + EM_DEBUG_LOG("param_action [%d]", param_action); + + /* param_error */ + emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), ¶m_error); + EM_DEBUG_LOG("param_error [%d]", param_error); + + if( (err = emcore_show_user_message(param_id, param_action, param_error)) != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("emcore_show_user_message 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_DEBUG_FUNC_END("err [%d]", err); +} void stb_API_mapper(HIPC_API a_hAPI) { EM_DEBUG_FUNC_BEGIN(); int nAPIID = emipc_get_api_id(a_hAPI); - + switch(nAPIID) { case _EMAIL_API_ADD_ACCOUNT: stb_create_account(a_hAPI); @@ -2638,30 +2742,41 @@ void stb_API_mapper(HIPC_API a_hAPI) case _EMAIL_API_DELETE_MAILBOX: stb_delete_mailbox(a_hAPI); break; + case _EMAIL_API_UPDATE_MAILBOX: stb_update_mailbox(a_hAPI); break; + case _EMAIL_API_SET_MAILBOX_TYPE: + stb_set_mailbox_type(a_hAPI); + break; + case _EMAIL_API_SET_MAIL_SLOT_SIZE: stb_set_mail_slot_size_of_mailbox(a_hAPI); break; + case _EMAIL_API_RENAME_MAILBOX: + stb_rename_mailbox(a_hAPI); + break; + case _EMAIL_API_SEND_MAIL: stb_send_mail(a_hAPI); break; - + +#if 0 case _EMAIL_API_GET_MAILBOX_COUNT: stb_get_mail_count_of_mailbox(a_hAPI); break; +#endif case _EMAIL_API_GET_MAILBOX_LIST: stb_get_mailbox_list(a_hAPI); break; - + case _EMAIL_API_SYNC_HEADER: stb_sync_header(a_hAPI); break; - + case _EMAIL_API_DOWNLOAD_BODY: stb_download_body(a_hAPI); break; @@ -2669,11 +2784,11 @@ void stb_API_mapper(HIPC_API a_hAPI) case _EMAIL_API_CLEAR_DATA: stb_clear_mail_data (a_hAPI); break; - + case _EMAIL_API_DELETE_ALL_MAIL: stb_delete_all_mails(a_hAPI); break; - + case _EMAIL_API_DELETE_MAIL: stb_delete_mail(a_hAPI); break; @@ -2681,10 +2796,11 @@ void stb_API_mapper(HIPC_API a_hAPI) case _EMAIL_API_MODIFY_MAIL_FLAG: stb_modify_mail_flag(a_hAPI); break; - +#if 0 case _EMAIL_API_MODIFY_MAIL_EXTRA_FLAG: stb_modify_mail_extra_flag(a_hAPI); - break; + break; +#endif case _EMAIL_API_ADD_RULE: stb_add_rule(a_hAPI); @@ -2703,9 +2819,9 @@ void stb_API_mapper(HIPC_API a_hAPI) break; case _EMAIL_API_UPDATE_RULE: - stb_update_change(a_hAPI); + stb_update_rule(a_hAPI); break; - + case _EMAIL_API_DELETE_RULE: stb_delete_rule(a_hAPI); break; @@ -2716,7 +2832,7 @@ void stb_API_mapper(HIPC_API a_hAPI) case _EMAIL_API_MOVE_ALL_MAIL: stb_move_all_mails(a_hAPI); - break; + break; case _EMAIL_API_SET_FLAGS_FIELD: stb_set_flags_field(a_hAPI); @@ -2742,6 +2858,10 @@ void stb_API_mapper(HIPC_API a_hAPI) stb_modify_seen_flag_of_thread(a_hAPI); break; + case _EMAIL_API_EXPUNGE_MAILS_DELETED_FLAGGED: + stb_expunge_mails_deleted_flagged(a_hAPI); + break; + case _EMAIL_API_DELETE_ACCOUNT: stb_delete_account(a_hAPI); break; @@ -2757,7 +2877,7 @@ void stb_API_mapper(HIPC_API a_hAPI) case _EMAIL_API_GET_IMAP_MAILBOX_LIST: stb_get_imap_mailbox_list(a_hAPI); break; - + case _EMAIL_API_GET_ATTACHMENT: stb_get_attachment(a_hAPI); break; @@ -2810,6 +2930,10 @@ void stb_API_mapper(HIPC_API a_hAPI) 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_create_account_with_validation(a_hAPI); break; @@ -2821,7 +2945,7 @@ void stb_API_mapper(HIPC_API a_hAPI) case _EMAIL_API_RESTORE_ACCOUNTS: stb_restore_account(a_hAPI); break; - + case _EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT: stb_get_password_length(a_hAPI); break; @@ -2829,7 +2953,23 @@ void stb_API_mapper(HIPC_API a_hAPI) case _EMAIL_API_PRINT_RECEIVING_EVENT_QUEUE : stb_print_receiving_event_queue_via_debug_msg(a_hAPI); break; - + + case _EMAIL_API_ADD_CERTIFICATE: + stb_add_certificate(a_hAPI); + break; + + case _EMAIL_API_DELETE_CERTIFICATE: + stb_delete_certificate(a_hAPI); + break; + + case _EMAIL_API_VERIFY_SIGNATURE: + stb_verify_signature(a_hAPI); + break; + + case _EMAIL_API_VERIFY_CERTIFICATE: + stb_verify_certificate(a_hAPI); + break; + case _EMAIL_API_PING_SERVICE : stb_ping_service(a_hAPI); break; @@ -2837,24 +2977,23 @@ void stb_API_mapper(HIPC_API a_hAPI) case _EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL : stb_update_notification_bar_for_unread_mail(a_hAPI); break; + + case _EMAIL_API_SHOW_USER_MESSAGE : + stb_show_user_message(a_hAPI); + break; } EM_DEBUG_FUNC_END(); } +GMainLoop *g_mainloop = NULL; - - -void hibernation_enter_callback() +static void callback_for_sigterm(int signum) { - EM_DEBUG_FUNC_BEGIN(); - emstorage_db_close(NULL); - EM_DEBUG_FUNC_END(); -} + EM_DEBUG_FUNC_BEGIN("signum [%d]", signum); + + if (g_mainloop) + g_main_loop_quit(g_mainloop); -void hibernation_leave_callback() -{ - EM_DEBUG_FUNC_BEGIN(); - emstorage_db_open(NULL); EM_DEBUG_FUNC_END(); } @@ -2864,8 +3003,10 @@ INTERNAL_FUNC int main(int argc, char *argv[]) 1. Create all DB tables and load the email engine */ EM_DEBUG_LOG("Email service begin"); int err = 0, ret; + GMainLoop *mainloop; - signal(SIGPIPE, SIG_IGN); /* to ignore signal 13(SIGPIPE) */ + signal(SIGPIPE, SIG_IGN); /* to ignore signal 13(SIGPIPE) */ + signal(SIGTERM, callback_for_sigterm); /* to handle signal 15(SIGTERM) - power off case*/ emdaemon_initialize(&err); @@ -2888,36 +3029,22 @@ INTERNAL_FUNC int main(int argc, char *argv[]) emdaemon_start_auto_polling(&err); #endif - int fd_HibernationNoti; + mainloop = g_main_loop_new(NULL, 0); + g_mainloop = mainloop; - fd_HibernationNoti = heynoti_init(); + g_type_init(); - if(fd_HibernationNoti == -1) - EM_DEBUG_EXCEPTION("heynoti_init failed"); - else { - EM_DEBUG_LOG("heynoti_init Success"); - ret = heynoti_subscribe(fd_HibernationNoti, "HIBERNATION_ENTER", hibernation_enter_callback, (void *)fd_HibernationNoti); - EM_DEBUG_LOG("heynoti_subscribe returns %d", ret); - ret = heynoti_subscribe(fd_HibernationNoti, "HIBERNATION_LEAVE", hibernation_leave_callback, (void *)fd_HibernationNoti); - EM_DEBUG_LOG("heynoti_subscribe returns %d", ret); - ret = heynoti_attach_handler(fd_HibernationNoti); - EM_DEBUG_LOG("heynoti_attach_handler returns %d", ret); - } + g_main_loop_run(mainloop); - GMainLoop *mainloop; + /* Clean up resources */ + g_main_loop_unref(mainloop); - mainloop = g_main_loop_new (NULL, 0); + g_mainloop = NULL; - g_type_init(); + emipc_finalize_stub(); - g_main_loop_run (mainloop); + emdaemon_finalize(NULL); - if(fd_HibernationNoti != -1) { - heynoti_unsubscribe(fd_HibernationNoti, "HIBERNATION_ENTER", hibernation_enter_callback); - heynoti_unsubscribe(fd_HibernationNoti, "HIBERNATION_LEAVE", hibernation_leave_callback); - heynoti_close(fd_HibernationNoti); - } - EM_DEBUG_FUNC_END(); return 0; } diff --git a/email-ipc/CMakeLists.txt b/email-ipc/CMakeLists.txt index 2962ba5..42f9e22 100755 --- a/email-ipc/CMakeLists.txt +++ b/email-ipc/CMakeLists.txt @@ -16,7 +16,7 @@ MESSAGE(">>> Build type: ${CMAKE_BUILD_TYPE}") #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden") SET(IPC-LIB "email-ipc") -SET(IPC-SRCS +SET(IPC-SRCS ${CMAKE_SOURCE_DIR}/email-ipc/email-ipc-api.c ${CMAKE_SOURCE_DIR}/email-ipc/email-ipc-build.c ${CMAKE_SOURCE_DIR}/email-ipc/email-ipc-proxy.c @@ -24,14 +24,10 @@ SET(IPC-SRCS ${CMAKE_SOURCE_DIR}/email-ipc/email-ipc-api/email-ipc-api-info.c ${CMAKE_SOURCE_DIR}/email-ipc/email-ipc-api/email-ipc-param.c ${CMAKE_SOURCE_DIR}/email-ipc/email-ipc-api/email-ipc-param-list.c -# ${CMAKE_SOURCE_DIR}/email-ipc/email-common/email-common-list.c -# ${CMAKE_SOURCE_DIR}/email-ipc/email-common/email-common-msg-queue.c ${CMAKE_SOURCE_DIR}/email-ipc/email-proxy/email-proxy-callback-info.c ${CMAKE_SOURCE_DIR}/email-ipc/email-proxy/email-proxy-main.c ${CMAKE_SOURCE_DIR}/email-ipc/email-proxy/email-proxy-socket.c ${CMAKE_SOURCE_DIR}/email-ipc/email-socket/email-ipc-socket.c - ${CMAKE_SOURCE_DIR}/email-ipc/email-stub/email-stub-queue.c - ${CMAKE_SOURCE_DIR}/email-ipc/email-stub/email-stub-response-info.c ${CMAKE_SOURCE_DIR}/email-ipc/email-stub/email-stub-main.c ${CMAKE_SOURCE_DIR}/email-ipc/email-stub/email-stub-socket.c ${CMAKE_SOURCE_DIR}/email-ipc/email-stub/email-stub-task.c @@ -48,6 +44,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/email-ipc/email-ipc-api/include ${CMAKE_SOURCE_DIR}/email-common-use/include ${CMAKE_SOURCE_DIR}/email-api/include + ${CMAKE_SOURCE_DIR}/email-core/email-storage/include/ ) INCLUDE(FindPkgConfig) diff --git a/email-ipc/cscope.files b/email-ipc/cscope.files deleted file mode 100644 index 23443ab..0000000 --- a/email-ipc/cscope.files +++ /dev/null @@ -1,36 +0,0 @@ -./email-socket/include/email-ipc-socket.h -./email-socket/email-ipc-socket.c -./include/email-ipc-build.h -./include/email-ipc.h -./email-stub/email-stub-main.c -./email-stub/include/email-stub-task-manager.h -./email-stub/include/email-stub-task.h -./email-stub/include/email-stub-queue.h -./email-stub/include/email-stub-response-info.h -./email-stub/include/email-stub-socket.h -./email-stub/include/email-stub-main.h -./email-stub/email-stub-queue.c -./email-stub/email-stub-task-manager.c -./email-stub/email-stub-response-info.c -./email-stub/email-stub-socket.c -./email-stub/email-stub-task.c -./email-ipc-build.c -./email-common/include/email-common-msg-queue.h -./email-common/include/email-common-list.h -./email-common/email-common-list.c -./email-common/email-common-msg-queue.c -./email-proxy/email-proxy-callback-info.c -./email-proxy/include/email-proxy-main.h -./email-proxy/include/email-proxy-callback-info.h -./email-proxy/include/email-proxy-socket.h -./email-proxy/email-proxy-main.c -./email-proxy/email-proxy-socket.c -./email-ipc-stub.c -./email-ipc-api/email-ipc-param.c -./email-ipc-api/include/email-ipc-api-info.h -./email-ipc-api/include/email-ipc-param-list.h -./email-ipc-api/include/email-ipc-param.h -./email-ipc-api/email-ipc-api-info.c -./email-ipc-api/email-ipc-param-list.c -./email-ipc-api.c -./email-ipc-proxy.c diff --git a/email-ipc/cscope.out b/email-ipc/cscope.out deleted file mode 100644 index 2e25b91..0000000 --- a/email-ipc/cscope.out +++ /dev/null @@ -1,78905 +0,0 @@ -cscope 15 $HOME/myfolder/git/private/api/email-service/email-ipc 0000459104 - @email-common/email-common-list.c - -23  - ~<¡dio.h -> - -24  - ~ - -26  - ~"emaž-commÚ-li¡.h -" - -27  - ~"emaž-¡ub-queue.h -" - -28  - ~"emaž-c-bužd.h -" - -30  - ~"emaž-debug-log.h -" - -32  -emc_emaž_queue_™em - * - gh—d -; - -33  -emc_emaž_queue_™em - * - gž -; - -34  - gcouÁ - = -1; - -36 -EXPORT_API - -boÞ - - $emcm_š™_li¡ -() - -38 -h—d - = ( -emc_emaž_queue_™em - *) - `m®loc -((emipc_email_queue_item)); - -39 ià( -h—d - =ð -NULL -) { - -40 - `EM_DEBUG_EXCEPTION -("Malloc failed."); - -41  -çl£ -; - -43 - `mem£t -( -h—d -, 0x00, ( -emc_emaž_queue_™em -)); - -45 -ž - = ( -emc_emaž_queue_™em - *) - `m®loc -((emipc_email_queue_item)); - -46 ià( -ž - =ð -NULL -) { - -47 - `EM_DEBUG_EXCEPTION -("Malloc failed."); - -48  -çl£ -; - -50 - `mem£t -( -ž -, 0x00, ( -emc_emaž_queue_™em -)); - -52 -couÁ - = 0; - -54  -Œue -; - -55 - } -} - -57 -EXPORT_API -  - $emcm_ä“_li¡ -() - -59 - `EM_SAFE_FREE -( -h—d -); - -60 - `EM_SAFE_FREE -( -ž -); - -61 - } -} - -63 -EXPORT_API - -boÞ - - $emcm_add_ž_of_li¡ -(* -d©a -) - -65 -emc_emaž_queue_™em - * -Ãw_™em - = -NULL -; - -67 ià(! -d©a -) - -68  -çl£ -; - -70 -Ãw_™em - = ( -emc_emaž_queue_™em - *) - `m®loc -((emipc_email_queue_item)); - -71 ià( -Ãw_™em - =ð -NULL -) { - -72 - `EM_DEBUG_EXCEPTION -("Malloc failed."); - -73  -çl£ -; - -75 - `mem£t -( -Ãw_™em -, 0x00, ( -emc_emaž_queue_™em -)); - -77 -Ãw_™em --> -d©a - = data; - -79 ià( -ž -) { - -80 -ž --> -Ãxt - = -Ãw_™em -; - -81 -ž - = -Ãw_™em -; - -83 -h—d - = -ž - = -Ãw_™em -; - -86 -couÁ -++; - -88  -Œue -; - -89 - } -} - -91 -EXPORT_API - -boÞ - - $emcm_»move_™em_of_li¡ -(* -d©a -) - -93  -šdex - = 0; - -94 -emc_emaž_queue_™em - * -tmp_™em - = -h—d -; - -95 -emc_emaž_queue_™em - * -´e_™em - = -NULL -; - -97 ià( -h—d -) { - -98  -šdex - = 0; index < -couÁ -; index++) { - -99 ià( -tmp_™em --> -d©a - == data) { - -100 ià( -´e_™em -) { - -101 -´e_™em --> -Ãxt - = -tmp_™em -->next; - -103 ià( -tmp_™em --> -Ãxt - =ð -NULL -) - -104 -ž - = -´e_™em -; - -106 -h—d - = h—d-> -Ãxt -; - -108 ià( -h—d - =ð -NULL -) - -109 -ž - = -NULL -; - -112 - `EM_SAFE_FREE -( -tmp_™em -); - -113 -couÁ ---; - -114  -Œue -; - -116 -´e_™em - = -tmp_™em -; - -117 -tmp_™em - =mp_™em-> -Ãxt -; - -120  -çl£ -; - -121 - } -} - -123 -EXPORT_API - * - $emcm_g‘_©_of_li¡ -( -šdex -) - -125 -emc_emaž_queue_™em - * -tmp_™em - = -h—d -; - -127 ià( -h—d -) { - -128  -šdex - = 0; index < 0; index++) { - -129 -tmp_™em - =mp_™em-> -Ãxt -; - -132 ià( -tmp_™em -) - -133  -tmp_™em --> -d©a -; - -135  -NULL -; - -136 - } -} - -138 -EXPORT_API -  - $emcm_g‘_couÁ_of_li¡ -() - -140  -couÁ -; - -141 - } -} - - @email-common/email-common-msg-queue.c - -22  - ~<¡ršg.h -> - -23  - ~ - -24  - ~<¡dlib.h -> - -25  - ~<”ºo.h -> - -27  - ~ - -28  - ~ - -30  - ~"emaž-commÚ-msg-queue.h -" - -31  - ~"emaž-c-bužd.h -" - -33  - ~"emaž-debug-log.h -" - -35  - gcm_msg_ty³ - = 0; - -36  - gcm_msg_qid - = -1; - -37  -emc_msg_buf - * - gcm_£nd_buf - = -NULL -; - -38  -emc_msg_buf - * - gcm_»cv_buf - = -NULL -; - -40 -EXPORT_API - -boÞ - - $emcm_š™_msg_queue -( -msg_ty³ -) - -42 - `EM_DEBUG_FUNC_BEGIN -(); - -43 -cm_msg_ty³ - = -msg_ty³ -; - -44 -cm_£nd_buf - = ( -emc_msg_buf - *) - `m®loc -((emipc_msg_buf)); - -45 ià( -cm_£nd_buf - =ð -NULL -) { - -46 - `EM_DEBUG_EXCEPTION -("Malloc failed."); - -47  -çl£ -; - -49 - `mem£t -( -cm_£nd_buf -, 0x00, ( -emc_msg_buf -)); - -51 -cm_»cv_buf - = ( -emc_msg_buf - *) - `m®loc -((emipc_msg_buf)); - -52 ià( -cm_»cv_buf - =ð -NULL -) { - -53 - `EM_DEBUG_EXCEPTION -("Malloc failed."); - -54  -çl£ -; - -56 - `mem£t -( -cm_»cv_buf -, 0x00, ( -emc_msg_buf -)); - -58 - `EM_DEBUG_FUNC_END -(); - -59  -Œue -; - -60 - } -} - -62 -EXPORT_API -  - $emcm_ä“_msg_queue -() - -64 - `EM_DEBUG_FUNC_BEGIN -(); - -65 - `EM_SAFE_FREE -( -cm_£nd_buf -); - -66 - `EM_SAFE_FREE -( -cm_»cv_buf -); - -67 - `EM_DEBUG_FUNC_END -(); - -68 - } -} - -70 -EXPORT_API -  - $emcm_ü—‹_msg_qid -() - -72 - `EM_DEBUG_FUNC_BEGIN -(); - -73 -key_t - -key - = (key_t)640; - -75 ià(( -cm_msg_qid - = - `msgg‘ -( -key -, -IPC_CREAT - | -IPC_EXCL - | 0777)) == -1) { - -76 -cm_msg_qid - = - `msgg‘ -( -key -, 1); - -78 ià( -”ºo - =ð -EEXIST -) { - -79 - `EM_DEBUG_LOG -("Message Queue Exist"); - -80 - `EM_DEBUG_LOG -("===================================================== "); - -81 - `EM_DEBUG_LOG -("[emcm_msg_queue :ƒmcm_create_msg][Exist]"); - -82 - `EM_DEBUG_LOG -("===================================================== "); - -85 - `EM_DEBUG_LOG -("====================================================="); - -86 - `EM_DEBUG_LOG -("[emcm_msg_queue:emcm_ü—‹_msg][msg_qid = %d]", -cm_msg_qid -); - -87 - `EM_DEBUG_LOG -("====================================================="); - -88 - } -} - -90 -EXPORT_API -  - $emcm_£nd_msg -(* -msg -,  -size -,  -ty³ -) - -92 - `EM_DEBUG_FUNC_BEGIN -(); - -94  -»t - = 0; - -96 -cm_£nd_buf --> -mty³ - = -ty³ -; - -97 - `memýy -( -cm_£nd_buf --> -m‹xt -, -msg -, -size -); - -99 - `EM_DEBUG_LOG -("==========================================================="); - -100 - `EM_DEBUG_LOG -("[emcm_msg_queue:msg_£nd][Msgqid = %d]", -cm_msg_qid -); - -101 - `EM_DEBUG_LOG -("[emcm_msg_queue:msg_£nd][Sizð%d]", -size -); - -102 - `EM_DEBUG_LOG -("[emcm_msg_queue:msg_£nd][Ty³ = %d]", -ty³ -); - -103 - `EM_DEBUG_LOG -("==========================================================="); - -104 -»t - = - `msg¢d -( -cm_msg_qid -, -cm_£nd_buf -, -IPC_MSGQ_SIZE -, 0); - -106 - `EM_DEBUG_LOG -("====================================================="); - -107 - `EM_DEBUG_LOG -("[emcm_msg_queue:msg_£nd][»ˆð%d]", -»t -); - -108 - `EM_DEBUG_LOG -("====================================================="); - -109  -»t -; - -110 - } -} - -112 -EXPORT_API -  - $emcm_»cv_msg -(* -msg -,  -size -) - -114  -»t - = 0; - -115 - `EM_DEBUG_LOG -("==========================================================="); - -116 - `EM_DEBUG_LOG -("[emcm_msg_queue:msg_»cv][cm_msg_qid = %d]", -cm_msg_qid -); - -117 - `EM_DEBUG_LOG -("[emcm_msg_queue:msg_»cv][cm_msg_ty³ = %d]", -cm_msg_ty³ -); - -118 - `EM_DEBUG_LOG -("==========================================================="); - -119 -»t - = - `msgrcv -( -cm_msg_qid -, -cm_»cv_buf -, -IPC_MSGQ_SIZE -, -cm_msg_ty³ -, 0); - -120 ià( -»t - == -1) { - -121 - `EM_DEBUG_LOG -("==========================================================="); - -122 - `EM_DEBUG_LOG -("[emcm_msg_queue:msg_recv][FAIL]"); - -123 - `EM_DEBUG_LOG -("[emcm_msg_queue:msg_»cv][”rÜ:=%d][”rÜ¡¸=%s]", -”ºo -, - `¡»¼Ü -(errno)); - -124 - `EM_DEBUG_LOG -("==========================================================="); - -126 - `memýy -( -msg -, -cm_»cv_buf --> -m‹xt -, -size -); - -127 - `EM_DEBUG_LOG -("====================================================="); - -128 - `EM_DEBUG_LOG -("[emcm_msg_queue:msg_»cv][»ˆð%d][mty³ = %x][Sizð%d]", -»t -, -cm_msg_ty³ -, -size -); - -129 - `EM_DEBUG_LOG -("====================================================="); - -131  -»t -; - -132 - } -} - -134 -EXPORT_API - -boÞ - - $emcm_de¡roy_msg_qid -() - -136 if( - `msgùl -( -cm_msg_qid -, -IPC_RMID -, -NULL -) == -1) - -137  -çl£ -; - -139 - `EM_DEBUG_LOG -("====================================================="); - -140 - `EM_DEBUG_LOG -("[cmSysMsgQueue][MsgDestroy]"); - -141 - `EM_DEBUG_LOG -("====================================================="); - -142  -Œue -; - -143 - } -} - - @email-common/include/email-common-list.h - -23 #iâdeà -_IPC_LIST_H_ - - -24  - #_IPC_LIST_H_ - - - ) - -26  - ~"emaž-ty³s.h -" - -28 -EXPORT_API - -boÞ - -emcm_š™_li¡ -(); - -30 -EXPORT_API -  -emcm_ä“_li¡ -(); - -32 -EXPORT_API - -boÞ - -emcm_add_ž_of_li¡ -(* -d©a -); - -34 -EXPORT_API - -boÞ - -emcm_»move_™em_of_li¡ -(* -d©a -); - -36 -EXPORT_API - * -emcm_g‘_©_of_li¡ -( -šdex -); - -38 -EXPORT_API -  -emcm_g‘_couÁ_of_li¡ -(); - - @email-common/include/email-common-msg-queue.h - -23 #iâdeà -_IPC_MESSAGE_Q_H_ - - -24  - #_IPC_MESSAGE_Q_H_ - - - ) - -26  - ~"emaž-ty³s.h -" - -28  - #IPC_MSGQ_SIZE - 512 - - ) - -31  - mmty³ -; - -32  - mm‹xt -[ -IPC_MSGQ_SIZE -]; - -33 } - temc_msg_buf -; - -35 -EXPORT_API - -boÞ - -emcm_š™_msg_queue -( -msg_ty³ -); - -37 -EXPORT_API -  -emcm_ä“_msg_queue -(); - -39 -EXPORT_API -  -emcm_ü—‹_msg_qid -(); - -41 -EXPORT_API -  -emcm_£nd_msg -(* -msg -,  -size -,  -ty³ -); - -43 -EXPORT_API -  -emcm_»cv_msg -(* -msg -,  -size -); - -45 -EXPORT_API - -boÞ - -emcm_de¡roy_msg_qid -(); - - @email-ipc-api.c - -22  - ~ - -24  - ~"emaž-c.h -" - -25  - ~"emaž-c-bužd.h -" - -26  - ~"emaž-c-­i-šfo.h -" - -27  - ~"emaž-c-·¿m-li¡.h -" - -28  - ~"emaž-c-sock‘.h -" - -29  - ~"emaž-´oxy-maš.h -" - -31  - ~"emaž-debug-log.h -" - -32  - ~"emaž-”rÜs.h -" - -34 -EXPORT_API - -emc_·¿m_li¡ - * - $emc_g‘_­i_·¿m‘”s -( -HIPC_API - -­i -, -EPARAMETER_DIRECTION - -dœeùiÚ -) - -36 - `EM_DEBUG_FUNC_BEGIN -(); - -37 -emc_emaž_­i_šfo - * -­i_šfo - = (emc_emaž_­i_šfØ*) -­i -; - -39  ( -emc_·¿m_li¡ - *) - `emc_g‘_·¿m‘”s_of_­i_šfo -( -­i_šfo -, -dœeùiÚ -); - -40 - } -} - -42 -EXPORT_API - -HIPC_API - - $emc_ü—‹_emaž_­i -( -­i_id -) - -44 - `EM_DEBUG_FUNC_BEGIN -(); - -46 -emc_emaž_­i_šfo - * -­i_šfo - = -NULL -; - -48 -­i_šfo - = ( -emc_emaž_­i_šfo - *) - `m®loc -((emipc_email_api_info)); - -49 if( -­i_šfo - =ð -NULL -) { - -50 - `EM_DEBUG_EXCEPTION -("Malloc failed"); - -51  -NULL -; - -53 - `mem£t -( -­i_šfo -, 0x00, ( -emc_emaž_­i_šfo -)); - -55 - `emc_£t_­i_id_of_­i_šfo -( -­i_šfo -, -­i_id -); - -57  ( -HIPC_API -) -­i_šfo -; - -58 - } -} - -60 -EXPORT_API -  - $emc_de¡roy_emaž_­i -( -HIPC_API - -­i -) - -62 - `EM_DEBUG_FUNC_BEGIN -("API = %p", -­i -); - -63 -emc_emaž_­i_šfo - * -­i_šfo - = (emc_emaž_­i_šfØ*) -­i -; - -64 - `EM_SAFE_FREE -( -­i_šfo -); - -65 - } -} - -67 -EXPORT_API -  - $emc_g‘_­i_id -( -HIPC_API - -­i -) - -69 - `EM_DEBUG_FUNC_BEGIN -(); - -70 -emc_emaž_­i_šfo - * -­i_šfo - = (emc_emaž_­i_šfo*) -­i -; - -71  - `emc_g‘_­i_id_of_­i_šfo -( -­i_šfo -); - -72 - } -} - -74 -EXPORT_API -  - $emc_g‘_­p_id -( -HIPC_API - -­i -) - -76 - `EM_DEBUG_FUNC_BEGIN -(); - -77 -emc_emaž_­i_šfo - * -­i_šfo - = (emc_emaž_­i_šfØ*) -­i -; - -78  - `emc_g‘_­p_id_of_­i_šfo -( -­i_šfo -); - -79 - } -} - -81 -EXPORT_API - -boÞ - - $emc_add_·¿m‘” -( -HIPC_API - -­i -, -EPARAMETER_DIRECTION - -dœeùiÚ -, * -d©a -,  -d©a_Ëngth -) - -83 - `EM_DEBUG_FUNC_BEGIN -(); - -85 -emc_·¿m_li¡ - * -·¿m‘”s - = - `emc_g‘_­i_·¿m‘”s -( -­i -, -dœeùiÚ -); - -86 ià( -·¿m‘”s -) - -87  - `emc_add_·¿m_of_·¿m_li¡ -( -·¿m‘”s -, -d©a -, -d©a_Ëngth -); - -89  -çl£ -; - -90 - } -} - -92 -EXPORT_API -  - $emc_g‘_·¿m‘”_couÁ -( -HIPC_API - -­i -, -EPARAMETER_DIRECTION - -dœeùiÚ -) - -94 - `EM_DEBUG_FUNC_BEGIN -(); - -96 -emc_·¿m_li¡ - * -·¿m‘”s - = - `emc_g‘_­i_·¿m‘”s -( -­i -, -dœeùiÚ -); - -98 if( -·¿m‘”s -) - -99  - `emc_g‘_·¿m_couÁ_of_·¿m_li¡ -( -·¿m‘”s -); - -102 - } -} - -104 -EXPORT_API -  - $emc_g‘_·¿m‘” -( -HIPC_API - -šput_­i_hªdË -, -EPARAMETER_DIRECTION - -šput_·¿m‘”_dœeùiÚ -,  -šput_·¿m‘”_šdex -,  -šput_·¿m‘”_bufãr_size -, * -ouut_·¿m‘”_bufãr -) - -106 - `EM_DEBUG_FUNC_BEGIN -("šput_­i_hªdË [%d], iÅut_·¿m‘”_dœeùiÚ [%d], iÅut_·¿m‘”_šdex [%d], iÅut_·¿m‘”_bufãr_siz[%d], ouut_·¿m‘”_bufã¸[%p]", -šput_­i_hªdË - , -šput_·¿m‘”_dœeùiÚ - , -šput_·¿m‘”_šdex -, -šput_·¿m‘”_bufãr_size -, -ouut_·¿m‘”_bufãr -); - -107 -emc_·¿m_li¡ - * -·¿m‘”s - = -NULL -; - -108 * -loÿl_bufãr - = -NULL -; - -110 ià( -šput_·¿m‘”_bufãr_size - =ð0 || -ouut_·¿m‘”_bufãr - =ð -NULL -) { - -111 - `EM_DEBUG_EXCEPTION -("EMF_ERROR_INVALID_PARAM"); - -112  -EMF_ERROR_INVALID_PARAM -; - -115 -·¿m‘”s - = - `emc_g‘_­i_·¿m‘”s -( -šput_­i_hªdË -, -šput_·¿m‘”_dœeùiÚ -); - -117 ià( -·¿m‘”s - =ð -NULL -) { - -118 - `EM_DEBUG_EXCEPTION -("EMF_ERROR_IPC_PROTOCOL_FAILURE"); - -119  -EMF_ERROR_IPC_PROTOCOL_FAILURE -; - -122 -loÿl_bufãr - = - `emc_g‘_·¿m_of_·¿m_li¡ -( -·¿m‘”s -, -šput_·¿m‘”_šdex -); - -124 ià( -loÿl_bufãr - =ð -NULL -) { - -125 - `EM_DEBUG_EXCEPTION -("EMF_ERROR_IPC_PROTOCOL_FAILURE"); - -126  -EMF_ERROR_IPC_PROTOCOL_FAILURE -; - -129 ià( - `emc_g‘_·¿m_Ën_of_·¿m_li¡ -( -·¿m‘”s -, -šput_·¿m‘”_šdex -è!ð -šput_·¿m‘”_bufãr_size -) { - -130 - `EM_DEBUG_EXCEPTION -("EMF_ERROR_IPC_PROTOCOL_FAILURE"); - -131  -EMF_ERROR_IPC_PROTOCOL_FAILURE -; - -134 - `memýy -( -ouut_·¿m‘”_bufãr -, -loÿl_bufãr -, -šput_·¿m‘”_bufãr_size -); - -136 - `EM_DEBUG_FUNC_END -("Suceeded"); - -137  -EMF_ERROR_NONE -; - -138 - } -} - -140 -EXPORT_API -  - $emc_g‘_·¿m‘”_Ëngth -( -HIPC_API - -­i -, -EPARAMETER_DIRECTION - -dœeùiÚ -,  -·¿m‘”_šdex -) - -142 - `EM_DEBUG_FUNC_BEGIN -(); - -143 -emc_·¿m_li¡ - * -·¿m‘”s - = - `emc_g‘_­i_·¿m‘”s -( -­i -, -dœeùiÚ -); - -144 ià( -·¿m‘”s -) { - -145 - `EM_DEBUG_FUNC_END -("Suceeded"); - -146  - `emc_g‘_·¿m_Ën_of_·¿m_li¡ -( -·¿m‘”s -, -·¿m‘”_šdex -); - -148 - `EM_DEBUG_FUNC_END -("Failed"); - -150 - } -} - - @email-ipc-api/email-ipc-api-info.c - -23  - ~<¡ršg.h -> - -24  - ~ - -25  - ~ - -27  - ~"emaž-c-­i-šfo.h -" - -28  - ~"emaž-c-·¿m-li¡.h -" - -29  - ~"emaž-c-bužd.h -" - -31  - ~"emaž-debug-log.h -" - -33  -emc_·r£_­i_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, * -¡»am -); - -34  -emc_·r£_»¥Ú£_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, * -¡»am -); - -35  -emc_·r£_­p_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, * -¡»am -); - -37 -EXPORT_API - -boÞ - - $emc_£t_­i_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -,  -­i_id -) - -39 -­i_šfo --> -­i_id - =‡pi_id; - -40  -Œue -; - -41 - } -} - -43 -EXPORT_API -  - $emc_g‘_­i_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -) - -45  -­i_šfo --> -­i_id -; - -46 - } -} - -48 -EXPORT_API - -boÞ - - $emc_£t_­p_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -,  -­p_id -) - -50 -­i_šfo --> -­p_id - =‡pp_id; - -51  -Œue -; - -52 - } -} - -54 -EXPORT_API -  - $emc_g‘_­p_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -) - -56  -­i_šfo --> -­p_id -; - -57 - } -} - -59 -EXPORT_API - -boÞ - - $emc_£t_»¥Ú£_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -,  -»¥Ú£_id -) - -61 -­i_šfo --> -»¥Ú£_id - =„esponse_id; - -62  -Œue -; - -63 - } -} - -65 -EXPORT_API -  - $emc_g‘_»¥Ú£_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -) - -67  -­i_šfo --> -»¥Ú£_id -; - -68 - } -} - -70 -EXPORT_API - -boÞ - - $emc_·r£_¡»am_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, -EPARAMETER_DIRECTION - -dœeùiÚ -, * -¡»am -) - -72 -emc_·¿m_li¡ - * -Ãw_·¿m_li¡ - = -NULL -; - -74 ià( -­i_šfo --> -·¿ms -[ -dœeùiÚ -] =ð -NULL -) { - -75 -Ãw_·¿m_li¡ - = ( -emc_·¿m_li¡ - *) - `m®loc -((emipc_param_list)); - -76 ià( -Ãw_·¿m_li¡ - =ð -NULL -) { - -77 - `EM_DEBUG_EXCEPTION -("Memory‡llocation failed."); - -78  -çl£ -; - -80 - `mem£t -( -Ãw_·¿m_li¡ -, 0x00, ( -emc_·¿m_li¡ -)); - -81 -­i_šfo --> -·¿ms -[ -dœeùiÚ -] = -Ãw_·¿m_li¡ -; - -84 - `emc_·r£_­i_id_of_­i_šfo -( -­i_šfo -, -¡»am -); - -85 - `emc_·r£_­p_id_of_­i_šfo -( -­i_šfo -, -¡»am -); - -86 - `emc_·r£_»¥Ú£_id_of_­i_šfo -( -­i_šfo -, -¡»am -); - -87  - `emc_·r£_¡»am_of_·¿m_li¡ -( -­i_šfo --> -·¿ms -[ -dœeùiÚ -], -¡»am -); - -88 - } -} - -90 -EXPORT_API - * - $emc_g‘_¡»am_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, -EPARAMETER_DIRECTION - -dœeùiÚ -) - -92 -emc_·¿m_li¡ - * -Ãw_·¿m_li¡ - = -NULL -; - -93 * -¡»am - = -NULL -; - -95 ià( -­i_šfo --> -·¿ms -[ -dœeùiÚ -] =ð -NULL -) { - -96 -Ãw_·¿m_li¡ - = ( -emc_·¿m_li¡ - *) - `m®loc -((emipc_param_list)); - -97 ià( -Ãw_·¿m_li¡ - =ð -NULL -) { - -98 - `EM_DEBUG_EXCEPTION -("Memory‡llocation failed."); - -99  -çl£ -; - -101 - `mem£t -( -Ãw_·¿m_li¡ -, 0x00, ( -emc_·¿m_li¡ -)); - -102 -­i_šfo --> -·¿ms -[ -dœeùiÚ -] = -Ãw_·¿m_li¡ -; - -105 -¡»am - = - `emc_g‘_¡»am_of_·¿m_li¡ -( -­i_šfo --> -·¿ms -[ -dœeùiÚ -]); - -106 ià( -¡»am - !ð -NULL -) { - -107 - `memýy -( -¡»am -, (*)&( -­i_šfo --> -­i_id -), (api_info->api_id)); - -108 - `memýy -( -¡»am -+(()* -eSTREAM_RESID -), (*)&( -­i_šfo --> -»¥Ú£_id -), (api_info->response_id)); - -109 - `memýy -( -¡»am -+(()* -eSTREAM_APPID -), (*)&( -­i_šfo --> -­p_id -), (api_info->app_id)); - -111  (*) -¡»am -; - -112 - } -} - -114 -EXPORT_API -  - $emc_g‘_¡»am_Ëngth_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, -EPARAMETER_DIRECTION - -dœeùiÚ -) - -116 ià( -­i_šfo --> -·¿ms -[ -dœeùiÚ -] =ð -NULL -) - -119  - `emc_g‘_¡»am_Ëngth_of_·¿m_li¡ -( -­i_šfo --> -·¿ms -[ -dœeùiÚ -]); - -120 - } -} - -122 -EXPORT_API - * - $emc_g‘_·¿m‘”s_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, -EPARAMETER_DIRECTION - -dœeùiÚ -) - -124 -emc_·¿m_li¡ - * -Ãw_·¿m_li¡ - = -NULL -; - -126 ià( -­i_šfo --> -·¿ms -[ -dœeùiÚ -] =ð -NULL -) { - -127 -Ãw_·¿m_li¡ - = ( -emc_·¿m_li¡ - *) - `m®loc -((emipc_param_list)); - -128 ià( -Ãw_·¿m_li¡ - =ð -NULL -) { - -129 - `EM_DEBUG_EXCEPTION -("Memory‡llocation failed."); - -130  -çl£ -; - -132 - `mem£t -( -Ãw_·¿m_li¡ -, 0x00, ( -emc_·¿m_li¡ -)); - -133 -­i_šfo --> -·¿ms -[ -dœeùiÚ -] = -Ãw_·¿m_li¡ -; - -135  -­i_šfo --> -·¿ms -[ -dœeùiÚ -]; - -136 - } -} - -138  - $emc_·r£_­i_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, * -¡»am -) - -140 -­i_šfo --> -­i_id - = *((*) -¡»am - + -eSTREAM_APIID -); - -141  -­i_šfo --> -­i_id -; - -142 - } -} - -144  - $emc_·r£_»¥Ú£_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, * -¡»am -) - -146 -­i_šfo --> -»¥Ú£_id - = *((*) -¡»am - + -eSTREAM_RESID -); - -147  -­i_šfo --> -»¥Ú£_id -; - -148 - } -} - -150  - $emc_·r£_­p_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, * -¡»am -) - -152 -­i_šfo --> -­p_id - = *((*) -¡»am - + -eSTREAM_APPID -); - -153  -­i_šfo --> -­p_id -; - -155 - } -} - - @email-ipc-api/email-ipc-param-list.c - -23  - ~<¡ršg.h -> - -24  - ~<¡dlib.h -> - -26  - ~"emaž-c-bužd.h -" - -27  - ~"emaž-c-·¿m-li¡.h -" - -29  - ~"emaž-debug-log.h -" - -36  -emc_·r£_·¿m‘”_couÁ -(* -¡»am -); - -38 -EXPORT_API - -boÞ - - $emc_·r£_¡»am_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -, * -¡»am_d©a -) - -40 - `EM_DEBUG_FUNC_BEGIN -(); - -41  -·¿m‘”_couÁ - = - `emc_·r£_·¿m‘”_couÁ -( -¡»am_d©a -); - -42 if( -·¿m‘”_couÁ - <= 0) { - -43 - `EM_DEBUG_EXCEPTION -("There is‚o…arameter. "); - -44  -çl£ -; - -47 * -¡»am - = (*) -¡»am_d©a -; - -48  -šdex -, -·¿m_Ën -, -pos - = ()* -eSTREAM_DATA -; - -50  -šdex - = 0; index < -·¿m‘”_couÁ -; index++) { - -51  -Ën - =0; - -52 - `memýy -(& -Ën -, -¡»am -+ -pos -, ()); - -53 -·¿m_Ën - = -Ën -; - -54 - `EM_DEBUG_LOG -("P¬am‘” L’gth [%d] : %d ", -šdex -, -·¿m_Ën -); - -55 -pos - += (); - -57 - `emc_add_·¿m_of_·¿m_li¡ -( -·¿m_li¡ -, (*)( -¡»am -+ -pos -), -·¿m_Ën -); - -58 -pos - +ð -·¿m_Ën -; - -61  -Œue -; - -62 - } -} - -64 -EXPORT_API - * - $emc_g‘_¡»am_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -) - -66 - `EM_DEBUG_FUNC_BEGIN -(); - -67 if( -·¿m_li¡ --> -by‹_¡»am -) - -68  -·¿m_li¡ --> -by‹_¡»am -; - -70  -¡»am_Ën - = - `emc_g‘_¡»am_Ëngth_of_·¿m_li¡ -( -·¿m_li¡ -); - -72 ià( -¡»am_Ën - > 0) { - -73 -·¿m_li¡ --> -by‹_¡»am - = (*) - `ÿÎoc -(1, -¡»am_Ën -); - -74  -pos - = ()* -eSTREAM_COUNT -; - -76 ià( -pos - + ()( -·¿m_li¡ --> -·¿m_couÁ -è> -¡»am_Ën - ) { - -77 - `EM_DEBUG_EXCEPTION -("%d > sŒ—m_Ën", -pos - + ( -·¿m_li¡ --> -·¿m_couÁ -)); - -78 - `EM_SAFE_FREE -( -·¿m_li¡ --> -by‹_¡»am -); - -79  -NULL -; - -82 - `memýy -((*)( -·¿m_li¡ --> -by‹_¡»am -+ -pos -), (*)&·¿m_li¡-> -·¿m_couÁ -, (param_list->param_count)); - -84 -pos - += (); - -85  -šdex - = 0, -Ëngth - = 0; - -88  -šdex -=0; index< -·¿m_li¡ --> -·¿m_couÁ -; index++) { - -89 -Ëngth - = - `emc_g‘_Ëngth -( -·¿m_li¡ --> -·¿ms -[ -šdex -]); - -90 ià( -Ëngth - <= 0) { - -91 - `EM_DEBUG_EXCEPTION -("Ëngth = %d", -šdex -, -Ëngth -); - -92 - `EM_SAFE_FREE -( -·¿m_li¡ --> -by‹_¡»am -); - -93  -NULL -; - -96 ià( -pos - + ()(è> -¡»am_Ën -) { - -97 - `EM_DEBUG_EXCEPTION -("%d > sŒ—m_Ën", -pos - + ()); - -98 - `EM_SAFE_FREE -( -·¿m_li¡ --> -by‹_¡»am -); - -99  -NULL -; - -101 - `memýy -((*)( -·¿m_li¡ --> -by‹_¡»am -+ -pos -), (*)& -Ëngth -, ()); - -102 -pos - += (); - -104 ià( -pos - + -Ëngth - > -¡»am_Ën -) { - -105 - `EM_DEBUG_EXCEPTION -("%d > sŒ—m_Ën", -pos - + -Ëngth -); - -106 - `EM_SAFE_FREE -( -·¿m_li¡ --> -by‹_¡»am -); - -107  -NULL -; - -110 - `memýy -((*)( -·¿m_li¡ --> -by‹_¡»am -+ -pos -), - `emc_g‘_d©a -Õ¬am_li¡-> -·¿ms -[ -šdex -]), -Ëngth -); - -111 -pos - +ð -Ëngth -; - -113  (*) -·¿m_li¡ --> -by‹_¡»am -; - -116 - `EM_DEBUG_EXCEPTION -("failed."); - -117 - `EM_SAFE_FREE -( -·¿m_li¡ --> -by‹_¡»am -); - -119 - `EM_DEBUG_FUNC_END -(); - -120  -NULL -; - -121 - } -} - -123 -EXPORT_API -  - $emc_g‘_¡»am_Ëngth_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -) - -125  -Ëngth - = (è* -eSTREAM_DATA -; - -126  -šdex -; - -127  -šdex - = 0; index < -·¿m_li¡ --> -·¿m_couÁ -; index++) { - -128 -Ëngth - += (); - -129 -Ëngth - +ð - `emc_g‘_Ëngth -( -·¿m_li¡ --> -·¿ms -[ -šdex -]); - -131  -Ëngth -; - -132 - } -} - -134 -EXPORT_API - -boÞ - - $emc_add_·¿m_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -, * -d©a -,  -Ën -) - -136 - `EM_DEBUG_FUNC_BEGIN -(); - -137 ià( - `emc_£t_·¿m -(&( -·¿m_li¡ --> -·¿ms -[·¿m_li¡-> -·¿m_couÁ -]), -d©a -, -Ën -)) { - -138 -·¿m_li¡ --> -·¿m_couÁ -++; - -139 - `EM_SAFE_FREE -( -·¿m_li¡ --> -by‹_¡»am -); - -140  -Œue -; - -142  -çl£ -; - -143 - } -} - -145 -EXPORT_API - * - $emc_g‘_·¿m_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -,  -šdex -) - -147 - `EM_DEBUG_FUNC_BEGIN -("šdex [%d]", -šdex -); - -148 ià( -šdex - < 0 || index >ð -·¿m_li¡ --> -·¿m_couÁ -) { - -149 - `EM_DEBUG_EXCEPTION -("Index value is‚ot valid"); - -150  -NULL -; - -152  - `emc_g‘_d©a -( -·¿m_li¡ --> -·¿ms -[ -šdex -]); - -153 - } -} - -155 -EXPORT_API -  - $emc_g‘_·¿m_Ën_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -,  -šdex -) - -157 - `EM_DEBUG_FUNC_BEGIN -(); - -158 ià( -šdex - < 0 || index >ð -·¿m_li¡ --> -·¿m_couÁ -) { - -159 - `EM_DEBUG_EXCEPTION -("Index valud is‚ot valid"); - -162  - `emc_g‘_Ëngth -( -·¿m_li¡ --> -·¿ms -[ -šdex -]); - -163 - } -} - -165 -EXPORT_API -  - $emc_g‘_·¿m_couÁ_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -) - -167 - `EM_DEBUG_FUNC_BEGIN -("P¬am‘” couÁ [%d]", -·¿m_li¡ --> -·¿m_couÁ -); - -168  -·¿m_li¡ --> -·¿m_couÁ -; - -169 - } -} - -171  - $emc_·r£_·¿m‘”_couÁ -(* -¡»am -) - -173 - `EM_DEBUG_FUNC_BEGIN -(); - -174 * -·¿m‘”_couÁ_pos™iÚ - = (*) -¡»am - + -eSTREAM_COUNT -; - -176  * -·¿m‘”_couÁ_pos™iÚ -; - -177 - } -} - - @email-ipc-api/email-ipc-param.c - -23  - ~<¡ršg.h -> - -24  - ~<¡dlib.h -> - -26  - ~"emaž-c-·¿m.h -" - -27  - ~"emaž-debug-log.h -" - -29 -EXPORT_API - -boÞ - - $emc_£t_·¿m -( -emc_·¿m - * -·¿m -, * -d©a -,  -Ën -) - -31 - `EM_DEBUG_FUNC_BEGIN -(); - -33 ià(! -·¿m -) { - -34 - `EM_DEBUG_EXCEPTION -("Invalid…aramter"); - -35  -çl£ -; - -38 ià( -Ën - == 0) - -39  -Œue -; - -41 -·¿m --> -d©a - = (*) - `m®loc -( -Ën -); - -42 ià( -·¿m --> -d©a - =ð -NULL -) { - -43  -çl£ -; - -45 - `mem£t -( -·¿m --> -d©a -, 0x00, -Ën -); - -46 - `memýy -( -·¿m --> -d©a -, d©a, -Ën -); - -47 -·¿m --> -Ëngth - = -Ën -; - -48  -Œue -; - -49 - } -} - -51 -EXPORT_API -  - $emc_g‘_Ëngth -( -emc_·¿m - -·¿m -) - -53  -·¿m -. -Ëngth -; - -54 - } -} - -56 -EXPORT_API - * - $emc_g‘_d©a -( -emc_·¿m - -·¿m -) - -58  -·¿m -. -d©a -; - -59 - } -} - - @email-ipc-api/include/email-ipc-api-info.h - -23 #iâdeà -_IPC_APIINFO_H_ - - -24  - #_IPC_APIINFO_H_ - - - ) - -26  - ~<¡dio.h -> - -28  - ~"emaž-c.h -" - -29  - ~"emaž-c-­i-šfo.h -" - -30  - ~"emaž-c-·¿m-li¡.h -" - -33  - m­i_id -; - -34  - m»¥Ú£_id -; - -35  - m­p_id -; - -36 -emc_·¿m_li¡ - * - m·¿ms -[2]; - -37 } - temc_emaž_­i_šfo -; - -39 -EXPORT_API - -boÞ - -emc_£t_­i_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -,  -­i_id -); - -41 -EXPORT_API -  -emc_g‘_­i_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -); - -43 -EXPORT_API - -boÞ - -emc_£t_­p_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -,  -­p_id -); - -45 -EXPORT_API -  -emc_g‘_­p_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -); - -47 -EXPORT_API - -boÞ - -emc_£t_»¥Ú£_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -,  -»¥Ú£_id -); - -49 -EXPORT_API -  -emc_g‘_»¥Ú£_id_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -); - -51 -EXPORT_API - -boÞ - -emc_·r£_¡»am_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, -EPARAMETER_DIRECTION - -dœeùiÚ -, * -¡»am -); - -53 -EXPORT_API - * -emc_g‘_¡»am_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, -EPARAMETER_DIRECTION - -dœeùiÚ -); - -55 -EXPORT_API -  -emc_g‘_¡»am_Ëngth_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, -EPARAMETER_DIRECTION - -dœeùiÚ -); - -57 -EXPORT_API - * -emc_g‘_·¿m‘”s_of_­i_šfo -( -emc_emaž_­i_šfo - * -­i_šfo -, -EPARAMETER_DIRECTION - -dœeùiÚ -); - -62  - #EM_APIID_TO_STR -( -nAPIID -) \ - -64  -id -= -nAPIID -;\ - -65 cÚ¡ * -s -= -NULL -;\ - -66  -id -) {\ - -67  -_EMAIL_API_ADD_ACCOUNT -:\ - -68 -s - = "_EMAIL_API_ADD_ACCOUNT";\ - -70  -_EMAIL_API_ADD_MAILBOX -:\ - -71 -s - = "_EMAIL_API_ADD_MAILBOX";\ - -73  -_EMAIL_API_DELETE_MAILBOX -:\ - -74 -s - = "_EMAIL_API_DELETE_MAILBOX";\ - -76  -_EMAIL_API_UPDATE_MAILBOX -:\ - -77 -s - = "_EMAIL_API_UPDATE_MAILBOX";\ - -79  -_EMAIL_API_SET_MAIL_SLOT_SIZE -:\ - -80 -s - = "_EMAIL_API_SET_MAIL_SLOT_SIZE";\ - -82  -_EMAIL_API_SEND_MAIL -:\ - -83 -s - = "_EMAIL_API_SEND_MAIL";\ - -85  -_EMAIL_API_GET_MAILBOX_COUNT -:\ - -86 -s - = "_EMAIL_API_GET_MAILBOX_COUNT";\ - -88  -_EMAIL_API_GET_MAILBOX_LIST -:\ - -89 -s - = "_EMAIL_API_GET_MAILBOX_LIST";\ - -91  -_EMAIL_API_GET_SUBMAILBOX_LIST -:\ - -92 -s - = "_EMAIL_API_GET_SUBMAILBOX_LIST";\ - -94  -_EMAIL_API_SYNC_HEADER -:\ - -95 -s - = "_EMAIL_API_SYNC_HEADER";\ - -97  -_EMAIL_API_DOWNLOAD_BODY -:\ - -98 -s - = "_EMAIL_API_DOWNLOAD_BODY";\ - -100  -_EMAIL_API_CLEAR_DATA -:\ - -101 -s - = "_EMAIL_API_CLEAR_DATA";\ - -103  -_EMAIL_API_DELETE_ALL_MAIL -:\ - -104 -s - = "_EMAIL_API_DELETE_ALL_MAIL";\ - -106  -_EMAIL_API_DELETE_MAIL -:\ - -107 -s - = "_EMAIL_API_DELETE_MAIL";\ - -109  -_EMAIL_API_MODIFY_MAIL_FLAG -:\ - -110 -s - = "_EMAIL_API_MODIFY_MAIL_FLAG";\ - -112  -_EMAIL_API_MODIFY_MAIL_EXTRA_FLAG -:\ - -113 -s - = "_EMAIL_API_MODIFY_MAIL_EXTRA_FLAG";\ - -115  -_EMAIL_API_ADD_RULE -:\ - -116 -s - = "_EMAIL_API_ADD_RULE";\ - -118  -_EMAIL_API_GET_RULE -:\ - -119 -s - = "_EMAIL_API_GET_RULE";\ - -121  -_EMAIL_API_GET_RULE_LIST -:\ - -122 -s - = "_EMAIL_API_GET_RULE";\ - -124  -_EMAIL_API_FIND_RULE -:\ - -125 -s - = "_EMAIL_API_FIND_RULE";\ - -127  -_EMAIL_API_UPDATE_RULE -:\ - -128 -s - = "_EMAIL_API_UPDATE_RULE";\ - -130  -_EMAIL_API_DELETE_RULE -:\ - -131 -s - = "_EMAIL_API_DELETE_RULE";\ - -133  -_EMAIL_API_MOVE_MAIL -:\ - -134 -s - = "_EMAIL_API_MOVE_MAIL";\ - -136  -_EMAIL_API_MOVE_ALL_MAIL -:\ - -137 -s - = "_EMAIL_API_MOVE_ALL_MAIL";\ - -139  -_EMAIL_API_SET_FLAGS_FIELD -:\ - -140 -s - = "_EMAIL_API_SET_FLAGS_FIELD";\ - -142  -_EMAIL_API_ADD_MAIL -:\ - -143 -s - = "_EMAIL_API_ADD_MAIL";\ - -145  -_EMAIL_API_UPDATE_MAIL -:\ - -146 -s - = "_EMAIL_API_UPDATE_MAIL";\ - -148  -_EMAIL_API_MOVE_THREAD_TO_MAILBOX -:\ - -149 -s - = "_EMAIL_API_MOVE_THREAD_TO_MAILBOX";\ - -151  -_EMAIL_API_DELETE_THREAD -:\ - -152 -s - = "_EMAIL_API_DELETE_THREAD";\ - -154  -_EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD -:\ - -155 -s - = "_EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD";\ - -157  -_EMAIL_API_UPDATE_ACCOUNT -:\ - -158 -s - = "_EMAIL_API_UPDATE_ACCOUNT";\ - -160  -_EMAIL_API_ADD_ATTACHMENT -:\ - -161 -s - = "_EMAIL_API_ADD_ATTACHMENT";\ - -163  -_EMAIL_API_GET_IMAP_MAILBOX_LIST -:\ - -164 -s - = "_EMAIL_API_GET_IMAP_MAILBOX_LIST";\ - -166  -_EMAIL_API_GET_ATTACHMENT -:\ - -167 -s - = "_EMAIL_API_GET_ATTACHMENT";\ - -169  -_EMAIL_API_DELETE_ATTACHMENT -:\ - -170 -s - = "_EMAIL_API_DELETE_ATTACHMENT";\ - -172  -_EMAIL_API_DOWNLOAD_ATTACHMENT -:\ - -173 -s - = "_EMAIL_API_DOWNLOAD_ATTACHMENT";\ - -175  -_EMAIL_API_GET_ACCOUNT_LIST -:\ - -176 -s - = "_EMAIL_API_GET_ACCOUNT_LIST";\ - -178  -_EMAIL_API_SEND_SAVED -:\ - -179 -s - = "_EMAIL_API_SEND_SAVED";\ - -181  -_EMAIL_API_CANCEL_JOB -:\ - -182 -s - = "_EMAIL_API_CANCEL_JOB";\ - -184  -_EMAIL_API_GET_PENDING_JOB -:\ - -185 -s - = "_EMAIL_API_GET_PENDING_JOB";\ - -187  -_EMAIL_API_NETWORK_GET_STATUS -:\ - -188 -s - = "_EMAIL_API_NETWORK_GET_STATUS";\ - -190  -_EMAIL_API_SEND_RETRY -:\ - -191 -s - = "_EMAIL_API_SEND_RETRY";\ - -193  -_EMAIL_API_VALIDATE_ACCOUNT - :\ - -194 -s - = "_EMAIL_API_VALIDATE_ACCOUNT";\ - -196  -_EMAIL_API_SEND_MAIL_CANCEL_JOB - :\ - -197 -s - = "_EMAIL_API_SEND_MAIL_CANCEL_JOB";\ - -199  -_EMAIL_API_SEARCH_MAIL_ON_SERVER - :\ - -200 -s - = "_EMAIL_API_SEARCH_MAIL_ON_SERVER";\ - -202  -_EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION - :\ - -203 -s - = "_EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION";\ - -205  -_EMAIL_API_BACKUP_ACCOUNTS - :\ - -206 -s - = "_EMAIL_API_BACKUP_ACCOUNTS";\ - -208  -_EMAIL_API_RESTORE_ACCOUNTS - :\ - -209 -s - = "_EMAIL_API_RESTORE_ACCOUNTS";\ - -211  -_EMAIL_API_PRINT_RECEIVING_EVENT_QUEUE - :\ - -212 -s - = "_EMAIL_API_PRINT_RECEIVING_EVENT_QUEUE";\ - -214  -_EMAIL_API_PING_SERVICE - :\ - -215 -s - = "_EMAIL_API_PING_SERVICE";\ - -217  -_EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL - :\ - -218 -s - = "_EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL";\ - -220  -_EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT -:\ - -221 -s - = "_EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT";\ - -224 -s - = "UNKNOWN_APIID";\ - -226 -s -;\ - -227 }) - - ) - - @email-ipc-api/include/email-ipc-param-list.h - -23 #iâdeà -_IPC_PARAMLIST_H_ - - -24  - #_IPC_PARAMLIST_H_ - - - ) - -26  - ~"emaž-c-·¿m.h -" - -27  - ~"emaž-ty³s.h -" - -30 - meSTREAM_APIID -, - -31 - meSTREAM_RESID -, - -32 - meSTREAM_APPID -, - -33 - meSTREAM_COUNT -, - -34 - meSTREAM_DATA -, - -35 - meSTREAM_MAX - - -36 } - tIPC_STREAM_INFO -; - -39  - m·¿m_couÁ -; - -40 -emc_·¿m - - m·¿ms -[10]; - -41 * - mby‹_¡»am -; - -42 } - temc_·¿m_li¡ -; - -44 -EXPORT_API - -boÞ - -emc_·r£_¡»am_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -, * -¡»am_d©a -); - -46 -EXPORT_API - * -emc_g‘_¡»am_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -); - -48 -EXPORT_API -  -emc_g‘_¡»am_Ëngth_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -); - -50 -EXPORT_API - -boÞ - -emc_add_·¿m_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -, * -d©a -,  -Ën -); - -52 -EXPORT_API - * -emc_g‘_·¿m_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -,  -šdex -); - -54 -EXPORT_API -  -emc_g‘_·¿m_Ën_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -,  -šdex -); - -56 -EXPORT_API -  -emc_g‘_·¿m_couÁ_of_·¿m_li¡ -( -emc_·¿m_li¡ - * -·¿m_li¡ -); - - @email-ipc-api/include/email-ipc-param.h - -23 #iâdeà -_IPC_PARAM_H_ - - -24  - #_IPC_PARAM_H_ - - - ) - -26  - ~"emaž-ty³s.h -" - -29  - mËngth -; - -30 * - md©a -; - -31 } - temc_·¿m -; - -33 -EXPORT_API - -boÞ - -emc_£t_·¿m -( -emc_·¿m - * -·¿m -, * -d©a -,  -Ën -); - -35 -EXPORT_API -  -emc_g‘_Ëngth -( -emc_·¿m - -·¿m -); - -37 -EXPORT_API - * -emc_g‘_d©a -( -emc_·¿m - -·¿m -); - - @email-ipc-build.c - -23  - ~<¡dlib.h -> - -24  - ~<¡d¬g.h -> - -26  - ~"emaž-c-bužd.h -" - - @email-ipc-proxy.c - -18  - ~"emaž-c-bužd.h -" - -19  - ~"emaž-c.h -" - -20  - ~"emaž-c-­i-šfo.h -" - -21  - ~"emaž-c-·¿m-li¡.h -" - -22  - ~"emaž-c-sock‘.h -" - -23  - ~"emaž-´oxy-maš.h -" - -25  - ~"emaž-debug-log.h -" - -26  - ~"emaž-­i.h -" - -27  - ~"emaž-ty³s.h -" - -29 -EXPORT_API -  - $emc_š™Ÿlize_´oxy -() - -31 - `EM_DEBUG_FUNC_BEGIN -(); - -33  -”r - = - `emc_š™Ÿlize_´oxy_maš -(); - -37 - `EM_DEBUG_FUNC_END -(); - -38  -”r -; - -39 - } -} - -41 -EXPORT_API -  - $emc_fš®ize_´oxy -() - -43 - `EM_DEBUG_FUNC_BEGIN -(); - -44  - `emc_fš®ize_´oxy_maš -(); - -48 - } -} - -50 -EXPORT_API - -boÞ - - $emc_execu‹_´oxy_­i -( -HIPC_API - -­i -) - -52 - `EM_DEBUG_FUNC_BEGIN -(); - -53  -»t -; - -54  -”r - = -EMF_ERROR_NONE -; - -55 -emc_emaž_­i_šfo - * -­i_šfo - = (emc_emaž_­i_šfØ*) -­i -; - -57 - `EM_DEBUG_LOG -("API [%p]", -­i_šfo -); - -59 if( -­i_šfo - =ð -NULL -) { - -60 - `EM_DEBUG_EXCEPTION -("EMF_ERROR_INVALID_PARAM"); - -61  -EMF_ERROR_INVALID_PARAM -; - -64 - `EM_DEBUG_LOG -("APIID [%s], Re¥Ú£ID [%d], APPID[%d]", - `EM_APIID_TO_STR -( - `emc_g‘_­i_id_of_­i_šfo -( -­i_šfo -)), - `emc_g‘_»¥Ú£_id_of_­i_šfo -×pi_šfo), - `emc_g‘_­p_id_of_­i_šfo -(api_info)); - -66 -»t - = - `emc_execu‹_­i_of_´oxy_maš -( -­i_šfo -); - -72 ià(! -»t -) { - -73 - `emc_fš®ize_´oxy -(); - -75 -”r - = - `emc_š™Ÿlize_´oxy -(); - -76 ià( -”r - !ð -EMF_ERROR_NONE -) { - -77 - `EM_DEBUG_EXCEPTION -("FažedØݒhsock‘ : [%d]", -”r -); - -78  -EMF_ERROR_CONNECTION_FAILURE -; - -80 -»t - = - `emc_execu‹_­i_of_´oxy_maš -( -­i_šfo -); - -84 ià(! -»t -) { - -85 - `EM_DEBUG_EXCEPTION -("emc_´oxy_maš :ƒmc_execu‹_­˜çžed [%d]", -”r -); - -86  -EMF_ERROR_CONNECTION_FAILURE -; - -89 - `EM_DEBUG_FUNC_END -("”¸[%d]", -”r -); - -90  -”r -; - -91 - } -} - - @email-ipc-stub.c - -23  - ~"emaž-c.h -" - -24  - ~"emaž-c-bužd.h -" - -25  - ~"emaž-¡ub-maš.h -" - -27  - ~"emaž-debug-log.h -" - -29 -EXPORT_API - -boÞ - - $emc_š™Ÿlize_¡ub -( -PFN_EXECUTE_API - -­i_m­³r -) - -31 - `EM_DEBUG_LOG -("[IPCLib] ipcEmailStub_Initialize "); - -33  - `emc_š™Ÿlize_¡ub_maš -( -­i_m­³r -); - -37 - } -} - -39 -EXPORT_API - -boÞ - - $emc_fš®ize_¡ub -() - -41 - `emc_fš®ize_¡ub_maš -(); - -42  -Œue -; - -48 - } -} - -50 -EXPORT_API - -boÞ - - $emc_execu‹_¡ub_­i -( -HIPC_API - -­i -) - -52 - `EM_DEBUG_LOG -("cEmažStub_Execu‹API [%x]", -­i -); - -53 -emc_emaž_­i_šfo - * -­i_šfo - = (emc_emaž_­i_šfØ*) -­i -; - -54 ià( -­i_šfo - =ð -NULL -) - -55  -çl£ -; - -57  - `emc_execu‹_­i_¡ub_to_´oxy -( -­i_šfo -); - -64 - } -} - - @email-proxy/email-proxy-callback-info.c - -23  - ~"emaž-´oxy-ÿÎback-šfo.h -" - -25 -EXPORT_API - -boÞ - - $emc_£t_cb_šfo_v®ue -( -emc_emaž_cb_šfo - * -cb_šfo -,  -­i_id -, * -â_ÿÎback -) - -27 -cb_šfo --> -­i_id - =‡pi_id; - -28 -cb_šfo --> -â_ÿÎback - = fn_callback; - -29  -Œue -; - -30 - } -} - - @email-proxy/email-proxy-main.c - -23  - ~ - -24  - ~<±h»ad.h -> - -25  - ~ - -27  - ~"emaž-c.h -" - -28  - ~"emaž-c-bužd.h -" - -29  - ~"emaž-commÚ-li¡.h -" - -30  - ~"emaž-commÚ-msg-queue.h -" - -31  - ~"emaž-´oxy-maš.h -" - -32  - ~"emaž-´oxy-sock‘.h -" - -33  - ~"emaž-´oxy-ÿÎback-šfo.h -" - -35  - ~"emaž-š‹º®-ty³s.h -" - -36  - ~"emaž-debug-log.h -" - -38  - g»ã»nû - = 0; - -39  -boÞ - - g»cv_¡Ý_æag - = -çl£ -; - -41 -±h»ad_mu‹x_t - - gc_´oxy_mu‹x - = -PTHREAD_MUTEX_INITIALIZER -; - -42 -±h»ad_cÚd_t - - gc_´oxy_cÚd - = -PTHREAD_COND_INITIALIZER -; - -45 -EXPORT_API -  - $emc_š™Ÿlize_´oxy_maš -() - -47 - `EM_DEBUG_FUNC_BEGIN -(); - -49 ià( -»ã»nû - > 0) { - -50 - `EM_DEBUG_EXCEPTION -("A̗dy IÁŸlized„eã»nû[%d]", -»ã»nû -); - -51  -EMF_ERROR_NONE -; - -54 -»ã»nû -++; - -56 ià(! - `emc_¡¬t_´oxy_sock‘ -()) { - -57 - `EM_DEBUG_EXCEPTION -("Socket start failed"); - -58  -EMF_ERROR_IPC_CONNECTION_FAILURE -; - -61 - `EM_DEBUG_LOG -("Sock‘ ID : %d", - `emc_g‘_´oxy_sock‘_id -()); - -62 - `EM_DEBUG_FUNC_END -(); - -63  -EMF_ERROR_NONE -; - -64 - } -} - -66 -EXPORT_API -  - $emc_fš®ize_´oxy_maš -() - -68 - `EM_DEBUG_FUNC_BEGIN -(); - -70 ià(-- -»ã»nû - > 0) { - -71 - `EM_DEBUG_EXCEPTION -("Mܐthª oÄeã»nû[%d]", -»ã»nû -); - -72  -EMF_ERROR_NONE -; - -80 - `EM_DEBUG_FUNC_END -(); - -81  -EMF_ERROR_NONE -; - -82 - } -} - -84 -EXPORT_API - -boÞ - - $emc_execu‹_­i_of_´oxy_maš -( -emc_emaž_­i_šfo - * -­i_šfo -) - -86 - `EM_DEBUG_FUNC_BEGIN -(); - -88  -»t -; - -89 * -š_¡»am - = (*) - `emc_g‘_¡»am_of_­i_šfo -( -­i_šfo -, -ePARAMETER_IN -); - -90  -Ëngth - = - `emc_g‘_¡»am_Ëngth_of_­i_šfo -( -­i_šfo -, -ePARAMETER_IN -); - -91 -boÞ - -»suÉ - = -çl£ -; - -92  -£ndšg_by‹s -; - -94 ià(! -­i_šfo -) { - -95 - `EM_DEBUG_EXCEPTION -("Invalid Parameter"); - -96  -çl£ -; - -99 - `ENTER_CRITICAL_SECTION -( -c_´oxy_mu‹x -); - -100 -£ndšg_by‹s - = - `emc_£nd_´oxy_sock‘ -( -š_¡»am -, -Ëngth -); - -101 - `LEAVE_CRITICAL_SECTION -( -c_´oxy_mu‹x -); - -103 - `EM_DEBUG_LOG -("Proxy=>¡ub s’dšg %d by‹.", -£ndšg_by‹s -); - -105 ià( -£ndšg_by‹s - > 0) { - -106 #ifdeà -IPCLIB_STREAM_TRACE_ON - - -107  -šdex - = 0; - -108  -šdex -=0;šdex< -Ëngth -;index++) - -109 - `EM_DEBUG_LOG -("š_¡»am[šdex] : [%x]", -š_¡»am -[ -šdex -]); - -111 * -c_buf - = -NULL -; - -113 - `ENTER_CRITICAL_SECTION -( -c_´oxy_mu‹x -); - -114 -»t - = - `emc_»cv_´oxy_sock‘ -(& -c_buf -); - -115 - `LEAVE_CRITICAL_SECTION -( -c_´oxy_mu‹x -); - -117 - `EM_DEBUG_LOG -("Recv†’gth : %d", -»t -); - -119 ià( -»t - > 0) - -120 -»suÉ - = - `emc_·r£_¡»am_of_­i_šfo -( -­i_šfo -, -ePARAMETER_OUT -, -c_buf -); - -122 -»suÉ - = -çl£ -; - -124 - `EM_SAFE_FREE -( -c_buf -); - -127 - `EM_DEBUG_FUNC_END -(); - -128  -»suÉ -; - -129 - } -} - -131 -EXPORT_API - -boÞ - - $emc_di¥©ch_´oxy_maš -() - -133 - `EM_DEBUG_FUNC_BEGIN -(); - -135  -¡»am -[ -IPC_MSGQ_SIZE -]; - -136 -emc_emaž_­i_šfo - * -­i_šfo - = -NULL -; - -137  -­i_id - = 0; - -138  -¡»am_Ëngth - = 0; - -140 ! -»cv_¡Ý_æag -) { - -141 - `mem£t -( -¡»am -, 0x00, (stream)); - -143 ià( - `emcm_»cv_msg -( -¡»am -, (stream)) > 0) { - -144 -­i_šfo - = ( -emc_emaž_­i_šfo - *) - `m®loc -((emipc_email_api_info)); - -145 ià( -­i_šfo - =ð -NULL -) { - -146 - `EM_DEBUG_EXCEPTION -("Malloc failed."); - -147  -çl£ -; - -149 - `mem£t -( -­i_šfo -, 0x00, ( -emc_emaž_­i_šfo -)); - -151 -­i_id - = *((*) -¡»am -); - -153 - `emc_£t_­i_id_of_­i_šfo -( -­i_šfo -, -­i_id -); - -154 - `emc_·r£_¡»am_of_­i_šfo -( -­i_šfo -, -ePARAMETER_OUT -, -¡»am -); - -155 -¡»am_Ëngth - = - `emc_g‘_¡»am_Ëngth_of_­i_šfo -( -­i_šfo -, -ePARAMETER_OUT -); - -156 - `EM_DEBUG_LOG -("Proxy Mes§gQueuRecv [­i_id=%x], [Recv_Ën=%d]", -­i_id -, -¡»am_Ëngth -); - -158 #ifdeà -IPCLIB_STREAM_TRACE_ON - - -159  -šdex - = 0; - -160  -šdex - = 0; index< -¡»am_Ëngth -; index++) - -161 - `EM_DEBUG_LOG -("[%x]", -¡»am -[ -šdex -]); - -164 - `u¦“p -(1000); - -166 - `EM_DEBUG_FUNC_END -(); - -167  -çl£ -; - -168 - } -} - - @email-proxy/email-proxy-socket.c - -24  - ~ - -25  - ~ - -27  - ~"emaž-c-bužd.h -" - -28  - ~"emaž-´oxy-sock‘.h -" - -29  - ~"emaž-c-sock‘.h -" - -31  - ~"emaž-debug-log.h -" - -33  - g´oxy_sock‘_fd - = 0; - -35 -EXPORT_API - -boÞ - - $emc_¡¬t_´oxy_sock‘ -() - -37 - `EM_DEBUG_FUNC_BEGIN -(); - -38  -»t - = -Œue -; - -40 -»t - = - `emc_š™_emaž_sock‘ -(& -´oxy_sock‘_fd -); - -41 ià(! -»t -) - -42 -»t - = -çl£ -; - -44 -»t - = - `emc_cÚÃù_emaž_sock‘ -( -´oxy_sock‘_fd -); - -46  -»t -; - -47 - } -} - -49 -EXPORT_API - -boÞ - - $emc_’d_´oxy_sock‘ -() - -51 - `EM_DEBUG_FUNC_BEGIN -(); - -52 - `EM_DEBUG_LOG -("[IPCLib]ƒmipc_end_proxy_socket_fd"); - -54 ià( -´oxy_sock‘_fd -) { - -55 - `emc_þo£_emaž_sock‘ -( -´oxy_sock‘_fd -); - -58  -Œue -; - -59 - } -} - -61 -EXPORT_API -  - $emc_£nd_´oxy_sock‘ -(* -d©a -,  -Ën -) - -63 - `EM_DEBUG_FUNC_BEGIN -(); - -64 ià( -´oxy_sock‘_fd - && - `emc_is_cÚÃùed_emaž_sock‘ -(proxy_socket_fd)) { - -65  - `emc_£nd_emaž_sock‘ -( -´oxy_sock‘_fd -, -d©a -, -Ën -); - -67 - `EM_DEBUG_EXCEPTION -("[IPCLib]ƒmipc_send_proxy_socket_fd‚ot connect"); - -70 - } -} - -72 -EXPORT_API -  - $emc_g‘_´oxy_sock‘_id -() - -74 - `EM_DEBUG_FUNC_BEGIN -(); - -75  -´oxy_sock‘_fd -; - -76 - } -} - -78 -EXPORT_API -  - $emc_»cv_´oxy_sock‘ -(** -d©a -) - -80 - `EM_DEBUG_FUNC_BEGIN -(); - -82  -»cv_Ën - = 0; - -84 ià( -´oxy_sock‘_fd -) - -85 -»cv_Ën - = - `emc_»cv_emaž_sock‘ -( -´oxy_sock‘_fd -, -d©a -); - -87 - `EM_DEBUG_EXCEPTION -("[IPCLib]…roxy_sock‘_fd[%p] i nهvažabË o¸discÚÃùed", -´oxy_sock‘_fd -); - -91 ià( -»cv_Ën - == 0) { - -92 - `EM_DEBUG_EXCEPTION -("[IPCLib] Proxy„ecv d–‘%x", -´oxy_sock‘_fd -); - -93 - `emc_þo£_emaž_sock‘ -( -´oxy_sock‘_fd -); - -94 } ià( -»cv_Ën - == -1) { - -95 - `EM_DEBUG_EXCEPTION -("[IPCLib] Proxy„ecvƒrror"); - -98  -»cv_Ën -; - -99 - } -} - - @email-proxy/include/email-proxy-callback-info.h - -23 #iâdeà -_IPC_CALLBACK_INFO_H_ - - -24  - #_IPC_CALLBACK_INFO_H_ - - - ) - -26  - ~"emaž-ty³s.h -" - -29  - m­i_id -; - -30 * - mâ_ÿÎback -; - -31 } - temc_emaž_cb_šfo -; - - @email-proxy/include/email-proxy-main.h - -24 #iâdef -_IPC_PROXY_MAIN_H_ - - -25  - #_IPC_PROXY_MAIN_H_ - - - ) - -27  - ~"emaž-c-­i-šfo.h -" - -28  - ~"emaž-ty³s.h -" - -30 -EXPORT_API -  -emc_š™Ÿlize_´oxy_maš -(); - -32 -EXPORT_API -  -emc_fš®ize_´oxy_maš -(); - -34 -EXPORT_API - -boÞ - -emc_execu‹_­i_of_´oxy_maš -( -emc_emaž_­i_šfo - * -­i_šfo -); - -36 -EXPORT_API - -boÞ - -emc_di¥©ch_´oxy_maš -(); - - @email-proxy/include/email-proxy-socket.h - -24 #iâdef -_IPC_PROXY_SOCKET_H_ - - -25  - #_IPC_PROXY_SOCKET_H_ - - - ) - -27  - ~"emaž-ty³s.h -" - -29 -EXPORT_API - -boÞ - -emc_¡¬t_´oxy_sock‘ -(); - -31 -EXPORT_API - -boÞ - -emc_’d_´oxy_sock‘ -(); - -33 -EXPORT_API -  -emc_£nd_´oxy_sock‘ -(* -d©a -,  -Ën -); - -35 -EXPORT_API -  -emc_g‘_´oxy_sock‘_id -(); - -37 -EXPORT_API -  -emc_»cv_´oxy_sock‘ -(** -d©a -); - - @email-socket/email-ipc-socket.c - -23  - ~"emaž-c-sock‘.h -" - -24  - ~"emaž-c-bužd.h -" - -26  - ~"emaž-debug-log.h -" - -27  - ~"emaž-ty³s.h -" - -29  - ~ - -31  - ~ - -32  - ~ - -33  - ~ - -34  - ~ - -35  - ~ - -36  - ~ - -38  - ~<”ºo.h -> - -39  - ~ - -41  - ~"sd-d«mÚ.h -" - -43  -GHashTabË - * - ghash_bË - = -NULL -; - -44  -boÞ - - gcÚÃùed - = -çl£ -; - -46 -EXPORT_API - -boÞ - - $emc_š™_emaž_sock‘ -(* -fd -) - -48 -boÞ - -»t - = -Œue -; - -50 -hash_bË - = - `g_hash_bË_Ãw -( -g_št_hash -, -g_št_equ® -); - -52 * -fd - = - `sock‘ -( -AF_UNIX -, -SOCK_STREAM -, 0); - -54 ià(* -fd - < 0) { - -55 - `EM_DEBUG_EXCEPTION -("sock‘ c»©iÚ fažs!!!: %s", - `¡»¼Ü -( -”ºo -)); - -56 -»t - = -çl£ -; - -59 - `EM_DEBUG_LOG -("Sock‘ fd = %d", * -fd -); - -61  -»t -; - -62 - } -} - -65 -EXPORT_API - -boÞ - - $emc_þo£_emaž_sock‘ -( -fd -) - -67 - `EM_DEBUG_FUNC_BEGIN -("fd[%d]Øb»moved", -fd -); - -68  -»t - = -Œue -; - -70 ià(! - `g_hash_bË_»move -( -hash_bË -, - `GINT_TO_POINTER -( -fd -))) { - -71 - `EM_DEBUG_LOG -("NØm©chšg sock‘ fd [%d]", -fd -); - -72 -»t - = -çl£ -; - -75 - `EM_DEBUG_LOG -("fd %d„emov® dÚe", -fd -); - -76 - `þo£ -( -fd -); - -78 -cÚÃùed - = -çl£ -; - -79 - `EM_DEBUG_FUNC_END -(); - -80  -»t -; - -81 - } -} - -83 -EXPORT_API - -boÞ - - $emc_is_cÚÃùed_emaž_sock‘ -() - -85  -cÚÃùed -; - -86 - } -} - -88  - $emc_wr™’ -( -fd -, cÚ¡ * -buf -,  -Ën -) - -90  -Ëngth - = -Ën -; - -91  -·s£d_Ën - = 0; - -93  -Ëngth - > 0) { - -94 -·s£d_Ën - = - `£nd -( -fd -, (cÚ¡ *) -buf -, -Ëngth -, -MSG_NOSIGNAL -); - -95 ià( -·s£d_Ën - == -1) { - -96 - `EM_DEBUG_LOG -("wr™: %s", - `EM_STRERROR -( -”ºo -)); - -97 ià( -”ºo - =ð -EINTR -) ; - -98  -·s£d_Ën -; - -99 } ià( -·s£d_Ën - == 0) - -101 -Ëngth - -ð -·s£d_Ën -; - -102 -buf - +ð -·s£d_Ën -; - -104  ( -Ën - - -Ëngth -); - -105 - } -} - -107 -EXPORT_API -  - $emc_£nd_emaž_sock‘ -( -fd -, * -buf -,  -Ën -) - -109 - `EM_DEBUG_FUNC_BEGIN -("fd [%d], bufã¸[%p], buf_ËÀ[%d]", -fd -, -buf -, -Ën -); - -111  -£nd_by‹s - = ()+ -Ën -; - -112  -»t - = 0; - -113  -bufãr -[ -£nd_by‹s -]; - -114 - `mem£t -( -bufãr -, 0x00, -£nd_by‹s -); - -116 ià(! -buf -) { - -117 - `EM_DEBUG_EXCEPTION -("No datao send"); - -120 - `memýy -( -bufãr -, (*)& -Ën -, ()); - -121 - `memýy -( -bufãr - + (), -buf -, -Ën -); - -123 - `EM_DEBUG_LOG -("S’dšg %dB d©¨tØ[fd = %d]", -£nd_by‹s -, -fd -); - -125 -»t - = - `emc_wr™’ -( -fd -, -bufãr -, -£nd_by‹s -); - -127 - `EM_DEBUG_FUNC_END -(); - -128  -»t -; - -129 - } -} - -131  - $emc_»adn -( -fd -, * -buf -,  -Ën -) - -133  -Ëngth - = -Ën -; - -134  -»ad_Ën - = 0; - -136  -Ëngth - > 0) { - -137 -»ad_Ën - = - `»ad -( -fd -, (*) -buf -, -Ëngth -); - -138 ià( -»ad_Ën - < 0) { - -139 - `EM_DEBUG_EXCEPTION -("R—d : %s", - `EM_STRERROR -( -”ºo -)); - -140 ià( -”ºo - =ð -EINTR -) ; - -141  -»ad_Ën -; - -142 } ià( -»ad_Ën - == 0) - -145 -Ëngth - -ð -»ad_Ën -; - -146 -buf - +ð -»ad_Ën -; - -148  ( -Ën -- -Ëngth -); - -149 - } -} - -151 -EXPORT_API -  - $emc_»cv_emaž_sock‘ -( -fd -, ** -buf -) - -153 - `EM_DEBUG_FUNC_BEGIN -(); - -155  -Ën - = 0; - -156  -»ad_Ën - = 0; - -158 ià(! -buf -) { - -159 - `EM_DEBUG_LOG -("Buffer must‚ot‚ull"); - -160  -EMF_ERROR_INVALID_PARAM -; - -163 - `EM_DEBUG_LOG -("[IPC Socket] Receiving header begins"); - -164 -»ad_Ën - = - `emc_»adn -( -fd -, (*)& -Ën -, ()); - -165 - `EM_DEBUG_LOG -("[IPC Scok‘] Reûivšg h—d” %dB d©a", -Ën -); - -167 ià( -»ad_Ën - == 0) - -168  -»ad_Ën -; - -169 ià( -»ad_Ën - != ()) { - -170 - `EM_DEBUG_LOG -("WARNING: R—d h—d”_size[%d]‚Ù m©ched [%d]", -»ad_Ën -, ()); - -171  -EMF_ERROR_IPC_SOCKET_FAILURE -; - -174 * -buf - = (*) - `m®loc -( -Ën -); - -175 ià(* -buf - =ð -NULL -) { - -176 - `EM_DEBUG_EXCEPTION -("Malloc failed"); - -177  -EMF_ERROR_OUT_OF_MEMORY -; - -179 - `mem£t -(* -buf -, 0x00, -Ën -); - -181 - `EM_DEBUG_LOG -("[IPC Sock‘] Reûivšg Body begš fÜ [%d] by‹s", -Ën -); - -182 -»ad_Ën - = - `emc_»adn -( -fd -, * -buf -, -Ën -); - -183 ià( -»ad_Ën - !ð -Ën -) { - -184 - `EM_SAFE_FREE -(* -buf -); - -185 - `EM_DEBUG_LOG -("WARNING: R—d buf_siz[%d] !ð»ad_Ën[%d]", -»ad_Ën -, -Ën -); - -186  -EMF_ERROR_IPC_SOCKET_FAILURE -; - -188 - `EM_DEBUG_LOG -("[IPC Sock‘] Reûivšg [%d] by‹ Com¶‘ed", -Ën -); - -190  -»ad_Ën -; - -191 - } -} - -193 -EXPORT_API -  - $emc_acû±_emaž_sock‘ -( -fd -) - -195 - `EM_DEBUG_FUNC_BEGIN -(); - -197 ià( -fd - == -1) { - -198 - `EM_DEBUG_LOG -("Server_socket‚ot init"); - -199  -EMF_ERROR_INVALID_PARAM -; - -202  -sockaddr_un - -»mÙe -; - -203  -»mÙe_Ën - = ( -»mÙe -); - -204  -þ›Á_fd - = - `acû± -( -fd -, ( -sockaddr - *)& -»mÙe -, ( -sockËn_t -*è& -»mÙe_Ën -); - -205 ià( -þ›Á_fd - == -1) { - -206 - `EM_DEBUG_LOG -("acû±: %s", - `EM_STRERROR -( -”ºo -)); - -207  -EMF_ERROR_IPC_SOCKET_FAILURE -; - -210 - `emc_add_sock‘_fd -( -þ›Á_fd -); - -211 - `EM_DEBUG_LOG -("%d i added", -þ›Á_fd -); - -213 - `EM_DEBUG_FUNC_END -(); - -214  -þ›Á_fd -; - -215 - } -} - -217 -EXPORT_API -  - $emc_ݒ_emaž_sock‘ -( -fd -, cÚ¡ * -·th -) - -219 - `EM_DEBUG_FUNC_BEGIN -("·th [%s]", -·th -); - -220  -sock_fd - = 0; - -222 ià( - `¡rcmp -( -·th -, -EM_SOCKET_PATH -) == 0 && - -223 - `sd_li¡’_fds -(1) == 1 && - -224 - `sd_is_sock‘_unix -( -SD_LISTEN_FDS_START -, -SOCK_STREAM -, -1, -EM_SOCKET_PATH -, 0) > 0) { - -225 - `þo£ -( -fd -); - -226 -sock_fd - = -SD_LISTEN_FDS_START - + 0; - -227 - `emc_add_sock‘_fd -( -sock_fd -); - -228  -sock_fd -; - -231 ià(! -·th - || - `¡¾’ -(path) > 108) { - -232 - `EM_DEBUG_LOG -("Path is‚ull"); - -233  -EMF_ERROR_IPC_SOCKET_FAILURE -; - -236 ià( -fd - <= 0) { - -237 - `EM_DEBUG_LOG -("Sock‘‚Ù c»©ed %d", -fd -); - -238  -EMF_ERROR_IPC_SOCKET_FAILURE -; - -241  -sockaddr_un - -loÿl -; - -242 -loÿl -. -sun_çmžy - = -AF_UNIX -; - -243 - `¡rýy -( -loÿl -. -sun_·th -, -·th -); - -244 - `uƚk -( -loÿl -. -sun_·th -); - -246  -Ën - = - `¡¾’ -( -loÿl -. -sun_·th -è+ Öoÿl. -sun_çmžy -); - -248 ià( - `bšd -( -fd -, ( -sockaddr - *)& -loÿl -, -Ën -) == -1) { - -249 - `EM_DEBUG_LOG -("bšd: %s", - `EM_STRERROR -( -”ºo -)); - -250  -EMF_ERROR_IPC_SOCKET_FAILURE -; - -264 -mode_t - -sock_mode - = ( -S_IRWXU - | -S_IRWXG - | -S_IRWXO -); - -266 ià( - `chmod -( -·th -, -sock_mode -) == -1) { - -267 - `EM_DEBUG_LOG -("chmod: %s", - `EM_STRERROR -( -”ºo -)); - -268  -EMF_ERROR_IPC_SOCKET_FAILURE -; - -271 ià( - `li¡’ -( -fd -, 10) == -1) { - -272 - `EM_DEBUG_LOG -("li¡’: %s", - `EM_STRERROR -( -”ºo -)); - -273  -EMF_ERROR_IPC_SOCKET_FAILURE -; - -276 - `emc_add_sock‘_fd -( -fd -); - -278 - `EM_DEBUG_FUNC_END -(); - -279  -fd -; - -280 - } -} - -282 -EXPORT_API - -boÞ - - $emc_cÚÃù_emaž_sock‘ -( -fd -) - -284 - `EM_DEBUG_FUNC_BEGIN -(); - -285  -»t - = -Œue -; - -286  -sockaddr_un - -£rv” -; - -287 -£rv” -. -sun_çmžy - = -AF_UNIX -; - -288 - `¡rýy -( -£rv” -. -sun_·th -, -EM_SOCKET_PATH -); - -290  -Ën - = - `¡¾’ -( -£rv” -. -sun_·th -è+ (£rv”. -sun_çmžy -); - -292 ià( - `cÚÃù -( -fd -, ( -sockaddr - *)& -£rv” -, -Ën -) == -1) { - -293 - `EM_DEBUG_LOG -("CªnÙ cÚÃù s”v” %s", - `EM_STRERROR -( -”ºo -)); - -294 -»t - = -çl£ -; - -296 - `emc_add_sock‘_fd -( -fd -); - -297 -cÚÃùed - = -Œue -; - -300  -»t -; - -301 - } -} - -303 -EXPORT_API - -boÞ - - $emc_add_sock‘_fd -( -fd -) - -305 - `EM_DEBUG_LOG -("[%d]‡dded", -fd -); - -306  -»t - = -Œue -; - -307  -key - = -fd -; - -308  -šput_d©a - = -fd -; - -310 ià( - `g_hash_bË_lookup -( -hash_bË -, & -key -è!ð -NULL -) { - -311 - `EM_DEBUG_LOG -("Du¶iÿ‹ FD %d", -fd -); - -312 -»t - = -çl£ -; - -315 - `g_hash_bË_š£¹ -( -hash_bË -, & -key -, & -šput_d©a -); - -317  -»t -; - -318 - } -} - - @email-socket/include/email-ipc-socket.h - -23 #iâdeà -_IPC_SOCKET_H_ - - -24  - #_IPC_SOCKET_H_ - - - ) - -26  - ~"emaž-ty³s.h -" - -28  - #SOCKET_IP - "127.0.0.1" - - ) - -29  - #SOCKET_PORT - 9000 - - ) - -31  - #BUF_SIZE - 204800 - - ) - -32  - #OPT_USEC - 100000 - - ) - -35  - #EM_SOCKET_PATH - "/tmp/.emažfw_sock‘" - - ) - -37 -EXPORT_API - -boÞ - -emc_š™_emaž_sock‘ -(* -fd -); - -39 -EXPORT_API - -boÞ - -emc_þo£_emaž_sock‘ -( -fd -); - -41 -EXPORT_API - -boÞ - -emc_is_cÚÃùed_emaž_sock‘ -(); - -43 -EXPORT_API -  -emc_£nd_emaž_sock‘ -( -fd -, * -buf -,  -Ën -); - -45 -EXPORT_API -  -emc_»cv_emaž_sock‘ -( -fd -, ** -buf -); - -47 -EXPORT_API -  -emc_acû±_emaž_sock‘ -( -fd -); - -49 -EXPORT_API -  -emc_ݒ_emaž_sock‘ -( -fd -, cÚ¡ * -·th -); - -51 -EXPORT_API - -boÞ - -emc_cÚÃù_emaž_sock‘ -( -fd -); - -53 -EXPORT_API - -boÞ - -emc_add_sock‘_fd -( -fd -); - - @email-stub/email-stub-main.c - -24  - ~"emaž-¡ub-maš.h -" - -25  - ~"emaž-c.h -" - -26  - ~"emaž-¡ub-»¥Ú£-šfo.h -" - -27  - ~"emaž-c-·¿m-li¡.h -" - -28  - ~"emaž-c-bužd.h -" - -29  - ~"emaž-commÚ-li¡.h -" - -30  - ~"emaž-commÚ-msg-queue.h -" - -31  - ~"emaž-¡ub-sock‘.h -" - -33  - ~"emaž-­i.h -" - -34  - ~"emaž-debug-log.h -" - -36  -boÞ - - g¡ub_sock‘ - = -çl£ -; - -37  -boÞ - - g»¥Ú£_li¡ - = -çl£ -; - -38  -boÞ - - gmsg_£nd” - = -çl£ -; - -39  -PFN_EXECUTE_API - - gthis_â_­i_m­³r - = -NULL -; - -41 -EXPORT_API - -boÞ - - $emc_š™Ÿlize_¡ub_maš -( -PFN_EXECUTE_API - -â_­i_m­³r -) - -43 - `EM_DEBUG_FUNC_BEGIN -(); - -45 ià(! -â_­i_m­³r -) { - -46 - `EM_DEBUG_EXCEPTION -("Invalid Param"); - -47  -çl£ -; - -50 -this_â_­i_m­³r - = -â_­i_m­³r -; - -53 -»¥Ú£_li¡ - = - `emcm_š™_li¡ -(); - -54 ià(! -»¥Ú£_li¡ -) { - -55 - `EM_DEBUG_EXCEPTION -("response_list did‚ot create\n"); - -56  -çl£ -; - -60 -msg_£nd” - = - `emcm_š™_msg_queue -(0); - -61 ià(! -msg_£nd” -) { - -62 - `EM_DEBUG_EXCEPTION -("Queue initialize failed.\n"); - -63  -çl£ -; - -65 - `emcm_ü—‹_msg_qid -(); - -68 -¡ub_sock‘ - = - `emc_¡¬t_¡ub_sock‘ -(); - -69 ià(! -¡ub_sock‘ -) { - -70 - `EM_DEBUG_EXCEPTION -("Socket did‚ot create"); - -71  -çl£ -; - -74 - `EM_DEBUG_FUNC_END -(); - -75  -Œue -; - -76 - } -} - -78 -EXPORT_API - -boÞ - - $emc_fš®ize_¡ub_maš -() - -80 - `EM_DEBUG_FUNC_BEGIN -(); - -81  -šdex - = 0; - -83 ià( -»¥Ú£_li¡ -) { - -84  -šdex - = 0; index < - `emcm_g‘_couÁ_of_li¡ -() ; index++) { - -85 -emc_emaž_»¥Ú£_šfo - * -»¥Ú£_šfo - = (emc_emaž_»¥Ú£_šfØ*) - `emcm_g‘_©_of_li¡ -( -šdex -); - -87 ià( -»¥Ú£_šfo -) - -88 - `emcm_»move_™em_of_li¡ -( -»¥Ú£_šfo -); - -92 ià( -msg_£nd” -) { - -93 ià( - `emcm_de¡roy_msg_qid -()) - -94 -msg_£nd” - = -çl£ -; - -97 ià( -¡ub_sock‘ -) { - -98 - `emc_’d_¡ub_sock‘ -(); - -99 -¡ub_sock‘ - = -çl£ -; - -102 ià( -this_â_­i_m­³r -) - -103 -this_â_­i_m­³r - = -NULL -; - -105 - `EM_DEBUG_FUNC_END -(); - -106  -Œue -; - -107 - } -} - -109 -EXPORT_API - -boÞ - - $emc_execu‹_­i_´oxy_to_¡ub -( -emc_emaž_­i_šfo - * -­i_šfo -) - -111 - `EM_DEBUG_FUNC_BEGIN -(); - -112 ià(! -­i_šfo -) { - -113 - `EM_DEBUG_EXCEPTION -("Invalid Param"); - -114  -çl£ -; - -117 ià( -this_â_­i_m­³r -) { - -118 - `this_â_­i_m­³r -( -­i_šfo -); - -121 - `EM_DEBUG_FUNC_END -(); - -122  -Œue -; - -123 - } -} - -125 -EXPORT_API - -boÞ - - $emc_execu‹_­i_¡ub_to_´oxy -( -emc_emaž_­i_šfo - * -­i_šfo -) - -127 - `EM_DEBUG_FUNC_BEGIN -("­i_šfØ[%p]", -­i_šfo -); - -128 - `EM_IF_NULL_RETURN_VALUE -( -­i_šfo -, -çl£ -); - -129 - `EM_DEBUG_LOG -("APIID [%s],„e¥Ú£ Sock‘ ID [%d], APPID [%d]", - `EM_APIID_TO_STR -( - `emc_g‘_­i_id_of_­i_šfo -( -­i_šfo -)), - `emc_g‘_»¥Ú£_id_of_­i_šfo -×pi_šfo), - `emc_g‘_­p_id_of_­i_šfo -(api_info)); - -131 * -¡»am - = (*) - `emc_g‘_¡»am_of_­i_šfo -( -­i_šfo -, -ePARAMETER_OUT -); - -132  -¡»am_Ëngth - = - `emc_g‘_¡»am_Ëngth_of_­i_šfo -( -­i_šfo -, -ePARAMETER_OUT -); - -134 - `EM_DEBUG_LOG -("D©¨: %p, D©¨Ëngth : %dB", -¡»am -, -¡»am_Ëngth -); - -135 - `EM_DEBUG_LOG -("Stub => Proxy S’dšg %dB", -¡»am_Ëngth -); - -136 - `emc_£nd_¡ub_sock‘ -( - `emc_g‘_»¥Ú£_id_of_­i_šfo -( -­i_šfo -), -¡»am -, -¡»am_Ëngth -); - -138 #ifdeà -IPCLIB_STREAM_TRACE_ON - - -139  -šdex - = 0; - -140  -šdex - = 0; index < -¡»am_Ëngth -; index++) - -141 - `EM_DEBUG_LOG -("SŒ—m[šdex] : [%d]", -¡»am -[ -šdex -]); - -144 - `EM_DEBUG_FUNC_END -(); - -145  -Œue -; - -146 - } -} - -148 -EXPORT_API - -boÞ - - $emc_£t_»¥Ú£_šfo -( -­p_id -,  -­i_id -) - -150 - `EM_DEBUG_FUNC_BEGIN -("Re¥Ú£ ID [%d]", -­p_id -); - -152 ià( -­p_id - <= 0) - -153  -Œue -; - -155 -emc_emaž_»¥Ú£_šfo - * -»¥Ú£_šfo - = -NULL -; - -156 -»¥Ú£_šfo - = ( -emc_emaž_»¥Ú£_šfo - *) - `m®loc -((response_info)); - -157 ià( -»¥Ú£_šfo - =ð -NULL -) { - -158 - `EM_DEBUG_EXCEPTION -("Malloc failed"); - -159  -çl£ -; - -161 - `mem£t -( -»¥Ú£_šfo -, 0x00, (response_info)); - -163 ià( -»¥Ú£_šfo -) { - -164 - `emc_£t_v®ue_š_»¥Ú£_šfo -( -»¥Ú£_šfo -, -­p_id -, -­i_id -); - -165 - `emcm_add_ž_of_li¡ -( -»¥Ú£_šfo -); - -166  -Œue -; - -168 - `EM_DEBUG_FUNC_END -(); - -169  -çl£ -; - -170 - } -} - - @email-stub/email-stub-queue.c - -23  - ~<¡dio.h -> - -24  - ~ - -26  - ~"emaž-¡ub-queue.h -" - -27  - ~"emaž-c-bužd.h -" - -29  - ~"emaž-debug-log.h -" - -31  -emc_emaž_queue_™em - * - gh—d - = -NULL -; - -32  -emc_emaž_queue_™em - * - gž - = -NULL -; - -33  - gcouÁ - = 0; - -35 -EXPORT_API - * - $emc_pÝ_š_queue -() - -37 * -d©a - = -NULL -; - -39 ià( -h—d -) { - -40 -emc_emaž_queue_™em - * -pݳd - = -h—d -; - -41 -d©a - = -pݳd -->data; - -43 ià( -pݳd --> -Ãxt -) { - -44 -h—d - = -pݳd --> -Ãxt -; - -46 -h—d - = -ž - = -NULL -; - -49 - `EM_SAFE_FREE -( -pݳd -); - -50 -couÁ - = (count <= 0) ? 0 : count-1; - -52  -d©a -; - -54  -NULL -; - -55 - } -} - -57 -EXPORT_API - -boÞ - - $emc_push_š_queue -(* -d©a -) - -59 -emc_emaž_queue_™em - * -™em - = -NULL -; - -60 ià(! -d©a -) { - -61 - `EM_DEBUG_EXCEPTION -("[IPCLib]ƒmipc_push_in_queue - invalid input\n"); - -62  -çl£ -; - -65 -™em - = ( -emc_emaž_queue_™em - *) - `m®loc -((emipc_email_queue_item)); - -66 ià( -™em - =ð -NULL -) { - -67 - `EM_DEBUG_EXCEPTION -("Malloc failed."); - -68  -çl£ -; - -70 - `mem£t -( -™em -, 0x00, ( -emc_emaž_queue_™em -)); - -72 -™em --> -d©a - = data; - -73 -™em --> -Ãxt - = -NULL -; - -74 ià( -ž -) { - -75 -ž --> -Ãxt - = -™em -; - -76 -ž - = -™em -; - -78 -h—d - = -ž - = -™em -; - -81 -couÁ -++; - -83  -Œue -; - -84 - } -} - -86 -EXPORT_API -  - $emc_g‘_couÁ_of_™em -() - -88  -couÁ -; - -89 - } -} - - @email-stub/email-stub-response-info.c - -22  - ~"emaž-¡ub-»¥Ú£-šfo.h -" - -24 -EXPORT_API - -boÞ - - $emc_£t_v®ue_š_»¥Ú£_šfo -( -emc_emaž_»¥Ú£_šfo - * -»¥Ú£_šfo -,  -»¥Ú£_id -,  -­i_id -) - -26 -»¥Ú£_šfo --> -»¥Ú£_id - =„esponse_id; - -27 -»¥Ú£_šfo --> -­i_id - =‡pi_id; - -28  -Œue -; - -29 - } -} - -31 -EXPORT_API -  - $emc_g‘_»¥Ú£_id_š_»¥Ú£_šfo -( -emc_emaž_»¥Ú£_šfo - * -»¥Ú£_šfo -) - -33  -»¥Ú£_šfo --> -»¥Ú£_id -; - -34 - } -} - -36 -EXPORT_API -  - $emc_g‘_­i_id_š_»¥Ú£_šfo -( -emc_emaž_»¥Ú£_šfo - * -»¥Ú£_šfo -) - -38  -»¥Ú£_šfo --> -­i_id -; - -39 - } -} - - @email-stub/email-stub-socket.c - -24  - ~<¡dlib.h -> - -25  - ~ - -26  - ~<”ºo.h -> - -27  - ~ - -28  - ~ - -29  - ~<±h»ad.h -> - -31  - ~"emaž-c-bužd.h -" - -32  - ~"emaž-c-­i-šfo.h -" - -33  - ~"emaž-c-sock‘.h -" - -34  - ~"emaž-¡ub-sk.h -" - -35  - ~"emaž-¡ub-sk-mªag”.h -" - -36  - ~"emaž-¡ub-sock‘.h -" - -38  - ~"emaž-debug-log.h -" - -40  - #MAX_EPOLL_EVENT - 50 - - ) - -42  - g¡ub_sock‘ - = 0; - -43  -±h»ad_t - - g¡ub_sock‘_th»ad - = 0; - -44  -boÞ - - g¡Ý_th»ad - = -çl£ -; - -46 * -emc_¡ub_sock‘_th»ad_´oc -(); - -48 -EXPORT_API - -boÞ - - $emc_¡¬t_¡ub_sock‘ -() - -50 -boÞ - -»t - = -Œue -; - -52 -»t - = - `emc_š™_emaž_sock‘ -(& -¡ub_sock‘ -); - -53 ià(! -»t -) { - -54 - `EM_DEBUG_EXCEPTION -("emipc_init_email_socket failed"); - -55  -»t -; - -58 -»t - = - `emc_¡¬t_¡ub_sock‘_th»ad -(); - -59 ià(! -»t -) { - -60 - `EM_DEBUG_EXCEPTION -("emipc_start_stub_socket_thread failed"); - -61  -»t -; - -64 -»t - = - `emc_¡¬t_sk_th»ad -(); - -65 ià(! -»t -) { - -66 - `EM_DEBUG_EXCEPTION -("emipc_start_task_thread failed"); - -67  -»t -; - -70  -»t -; - -71 - } -} - -73 -EXPORT_API - -boÞ - - $emc_¡¬t_¡ub_sock‘_th»ad -() - -75 - `EM_DEBUG_LOG -("[IPCLib]ƒmipc_email_stub_socket_thread start"); - -76 ià( -¡ub_sock‘_th»ad -) - -77  -Œue -; - -79 -±h»ad_©Œ_t - -th»ad_©Œ -; - -80 - `±h»ad_©Œ_š™ -(& -th»ad_©Œ -); - -81 - `±h»ad_©Œ_£td‘ach¡©e -(& -th»ad_©Œ -, -PTHREAD_CREATE_DETACHED -); - -82 ià( - `±h»ad_ü—‹ -(& -¡ub_sock‘_th»ad -, & -th»ad_©Œ -, & -emc_¡ub_sock‘_th»ad_´oc -, -NULL -) != 0) { - -83 - `EM_DEBUG_EXCEPTION -("[IPCLib]ƒmipc_start_stub_socket_thread() - failo create‡hread"); - -84  -çl£ -; - -86  -Œue -; - -87 - } -} - -89 -EXPORT_API - -boÞ - - $emc_¡Ý_¡ub_sock‘_th»ad -() - -91 ià( -¡ub_sock‘_th»ad -) - -92 -¡Ý_th»ad - = -Œue -; - -94  -Œue -; - -95 - } -} - -97 * - $emc_¡ub_sock‘_th»ad_´oc -() - -99 - `emc_wa™_fÜ_c_»que¡ -(); - -100 -¡ub_sock‘_th»ad - = 0; - -101  -NULL -; - -102 - } -} - -104 -EXPORT_API -  - $emc_wa™_fÜ_c_»que¡ -() - -106  -•Þl_ev’t - -ev - = {0}; - -107  -•Þl_ev’t - -ev’ts -[ -MAX_EPOLL_EVENT -] = {{0}, }; - -108  -•fd - = 0; - -109  -ev’t_num - = 0; - -111 ià(! -¡ub_sock‘ -) { - -112 - `EM_DEBUG_EXCEPTION -("Server Socket is‚ot initialized"); - -116 - `emc_ݒ_emaž_sock‘ -( -¡ub_sock‘ -, -EM_SOCKET_PATH -); - -118 -•fd - = - `•Þl_ü—‹ -( -MAX_EPOLL_EVENT -); - -119 ià( -•fd - < 0) { - -120 - `EM_DEBUG_EXCEPTION -("•Þl_ùl: %s[%d]", - `¡»¼Ü -( -”ºo -),ƒrrno); - -121 - `EM_DEBUG_CRITICAL_EXCEPTION -("•Þl_ü—‹: %s[%d]", - `¡»¼Ü -( -”ºo -),ƒrrno); - -122 - `abÜt -(); - -125 -ev -. -ev’ts - = -EPOLLIN -; - -126 -ev -. -d©a -. -fd - = -¡ub_sock‘ -; - -128 ià( - `•Þl_ùl -( -•fd -, -EPOLL_CTL_ADD -, -¡ub_sock‘ -, & -ev -) == -1) { - -129 - `EM_DEBUG_EXCEPTION -("•Þl_ùl: %s[%d]", - `¡»¼Ü -( -”ºo -),ƒrrno); - -130 - `EM_DEBUG_CRITICAL_EXCEPTION -("•Þl_ùl:%s[%d]", - `¡»¼Ü -( -”ºo -),ƒrrno); - -133  -i - = 0; - -135 -ev’t_num - = - `•Þl_wa™ -( -•fd -, -ev’ts -, -MAX_EPOLL_EVENT -, -1); - -137 ià( -ev’t_num - == -1) { - -138 - `EM_DEBUG_EXCEPTION -("•Þl_wa™: %s[%d]", - `¡»¼Ü -( -”ºo -),ƒrrno); - -139 - `EM_DEBUG_CRITICAL_EXCEPTION -("•Þl_wa™: %s[%d]", - `¡»¼Ü -( -”ºo -),ƒrrno); - -140 ià( -”ºo - =ð -EINTR -) ; - -141 - `abÜt -(); - -143  -i - = 0; i < -ev’t_num -; i++) { - -144  -ev’t_fd - = -ev’ts -[ -i -]. -d©a -. -fd -; - -146 ià( -ev’t_fd - =ð -¡ub_sock‘ -) { - -147  -cfd - = - `emc_acû±_emaž_sock‘ -( -¡ub_sock‘ -); - -148 ià( -cfd - < 0) { - -149 - `EM_DEBUG_EXCEPTION -("acû±ƒ¼Ü: %s[%d]", - `¡»¼Ü -( -”ºo -),ƒrrno); - -150 - `EM_DEBUG_CRITICAL_EXCEPTION -("acû±ƒ¼Ü: %s[%d]", - `¡»¼Ü -( -”ºo -),ƒrrno); - -153 -ev -. -ev’ts - = -EPOLLIN -; - -154 -ev -. -d©a -. -fd - = -cfd -; - -155 - `•Þl_ùl -( -•fd -, -EPOLL_CTL_ADD -, -cfd -, & -ev -); - -157  -»cv_Ën -; - -158 * -sz_buf - = -NULL -; - -160 -»cv_Ën - = - `emc_»cv_emaž_sock‘ -( -ev’t_fd -, & -sz_buf -); - -162 if( -»cv_Ën - > 0) { - -163 - `EM_DEBUG_LOG -("===================================================================="); - -164 - `EM_DEBUG_LOG -("[IPCLib]Stub Sock‘ Recv [Sock‘ ID = %d], [»cv_ËÀð%d]", -ev’t_fd -, -»cv_Ën -); - -165 - `EM_DEBUG_LOG -("===================================================================="); - -166 - `emc_ü—‹_sk -((*) -sz_buf -, -ev’t_fd -); - -168 - `EM_DEBUG_LOG -("[IPCLib] Sock‘ [%d]„emoved - [%d] ", -ev’t_fd -, -»cv_Ën -); - -169 - `•Þl_ùl -( -•fd -, -EPOLL_CTL_DEL -, -ev’t_fd -, -ev’ts -); - -170 - `þo£ -( -ev’t_fd -); - -172 if( -sz_buf -) - -173 - `EM_SAFE_FREE -( -sz_buf -); - -178 - } -} - -180 -EXPORT_API - -boÞ - - $emc_’d_¡ub_sock‘ -() - -182 - `EM_DEBUG_FUNC_BEGIN -(); - -184 ià( -¡ub_sock‘ -) { - -185 - `emc_þo£_emaž_sock‘ -( -¡ub_sock‘ -); - -188 ià( -¡ub_sock‘_th»ad -) { - -189 - `emc_¡Ý_¡ub_sock‘_th»ad -( -¡ub_sock‘_th»ad -); - -190 - `±h»ad_ÿnûl -( -¡ub_sock‘_th»ad -); - -191 -¡ub_sock‘_th»ad - = 0; - -194 ià(! - `emc_¡Ý_sk_th»ad -()) { - -195 - `EM_DEBUG_EXCEPTION -("emipc_stop_task_thread failed"); - -196  -çl£ -; - -199  -Œue -; - -200 - } -} - -202 -EXPORT_API -  - $emc_£nd_¡ub_sock‘ -( -sock_fd -, * -d©a -,  -Ën -) - -204 - `EM_DEBUG_FUNC_BEGIN -("Stub sock‘ s’dšg %d by‹s", -Ën -); - -206  -£ndšg_by‹s - = - `emc_£nd_emaž_sock‘ -( -sock_fd -, -d©a -, -Ën -); - -208 - `EM_DEBUG_FUNC_END -("£ndšg_by‹ ð%d", -£ndšg_by‹s -); - -209  -£ndšg_by‹s -; - -210 - } -} - - @email-stub/email-stub-task-manager.c - -24  - ~<¡ršg.h -> - -25  - ~<±h»ad.h -> - -26  - ~<”ºo.h -> - -28  - ~"emaž-¡ub-sk-mªag”.h -" - -29  - ~"emaž-¡ub-sk.h -" - -30  - ~"emaž-¡ub-queue.h -" - -31  - ~"emaž-c-bužd.h -" - -33  - ~"emaž-debug-log.h -" - -34  - ~"emaž-­i.h -" - -35  - ~"emaž-š‹º®-ty³s.h -" - -37  -±h»ad_t - - gsk_th»ad - = 0; - -38  -boÞ - - g¡Ý_æag - = -çl£ -; - -40 -±h»ad_mu‹x_t - - gc_sk_mu‹x - = -PTHREAD_MUTEX_INITIALIZER -; - -41 -±h»ad_cÚd_t - - gc_sk_cÚd - = -PTHREAD_COND_INITIALIZER -; - -43 -EXPORT_API - -boÞ - - $emc_¡¬t_sk_th»ad -() - -45 - `EM_DEBUG_FUNC_BEGIN -(); - -46 ià( -sk_th»ad -) - -47  -Œue -; - -49 ià( - `±h»ad_ü—‹ -(& -sk_th»ad -, -NULL -, & -emc_do_sk_th»ad -, NULL) != 0) { - -50 - `EM_DEBUG_LOG -("WÜk”h»ad c»©iÚ fažed: %s", - `¡»¼Ü -( -”ºo -)); - -51  -çl£ -; - -54  -Œue -; - -55 - } -} - -57 -EXPORT_API -  - $emc_‹rmš©e_sk_th»ad -() - -59 - `emc_¡Ý_sk_th»ad -(); - -60 - `±h»ad_ÿnûl -( -sk_th»ad -); - -62 -emc_emaž_sk - * -sk - = (emc_emaž_sk *) - `emc_pÝ_š_queue -(); - -63  -sk -) { - -64 - `EM_SAFE_FREE -( -sk -); - -65 -sk - = ( -emc_emaž_sk - *) - `emc_pÝ_š_queue -(); - -67 - } -} - -69 -EXPORT_API - -boÞ - - $emc_¡Ý_sk_th»ad -() - -71 -¡Ý_æag - = -Œue -; - -72  -Œue -; - -73 - } -} - -76 -EXPORT_API - * - $emc_do_sk_th»ad -() - -78 - `EM_DEBUG_FUNC_BEGIN -(); - -80 -emc_emaž_sk - * -sk - = -NULL -; - -82 ! -¡Ý_æag -) { - -83 - `ENTER_CRITICAL_SECTION -( -c_sk_mu‹x -); - -84  - `emc_g‘_couÁ_of_™em -() == 0) { - -85 - `EM_DEBUG_LOG -("Blocked uÁž‚ewask‡¼iv” %p.", & -c_sk_cÚd -); - -86 - `SLEEP_CONDITION_VARIABLE -( -c_sk_cÚd -, -c_sk_mu‹x -); - -89 -sk - = ( -emc_emaž_sk - *) - `emc_pÝ_š_queue -(); - -90 - `LEAVE_CRITICAL_SECTION -( -c_sk_mu‹x -); - -92 ià( -sk -) { - -93 - `emc_run_sk -( -sk -); - -94 - `EM_SAFE_FREE -( -sk -); - -98  -NULL -; - -99 - } -} - -102 -EXPORT_API - -boÞ - - $emc_ü—‹_sk -(* -sk_¡»am -,  -»¥Ú£_chªÃl -) - -104 -emc_emaž_sk - * -sk - = -NULL -; - -105 -boÞ - -»t - = -Œue -; - -107 -sk - = ( -emc_emaž_sk - *) - `m®loc -((emipc_email_task)); - -108 ià( -sk - =ð -NULL -) { - -109 - `EM_DEBUG_EXCEPTION -("Malloc failed."); - -110 -»t - = -çl£ -; - -112 - `emc_·r£_¡»am_emaž_sk -( -sk -, -sk_¡»am -, -»¥Ú£_chªÃl -); - -114 - `EM_DEBUG_LOG -("[IPCLib] ======================================================"); - -115 - `EM_DEBUG_LOG -("[IPCLib] Regi¡”‚ewask : %p", -sk -); - -116 - `EM_DEBUG_LOG -("[IPCLib] Task API ID : %s", - `EM_APIID_TO_STR -( - `emc_g‘_­i_šfo -( -sk -)-> -­i_id -)); - -117 - `EM_DEBUG_LOG -("[IPCLib] Task Re¥Ú£ ID : %d", - `EM_APIID_TO_STR -( - `emc_g‘_­i_šfo -( -sk -)-> -»¥Ú£_id -)); - -118 - `EM_DEBUG_LOG -("[IPCLib] Task APP ID : %d", - `emc_g‘_­i_šfo -( -sk -)-> -­p_id -); - -119 - `EM_DEBUG_LOG -("[IPCLib] ======================================================"); - -121 - `ENTER_CRITICAL_SECTION -( -c_sk_mu‹x -); - -122 -»t - = - `emc_push_š_queue -((*) -sk -); - -124 - `WAKE_CONDITION_VARIABLE -( -c_sk_cÚd -); - -125 - `LEAVE_CRITICAL_SECTION -( -c_sk_mu‹x -); - -127  -»t -; - -128 - } -} - - @email-stub/email-stub-task.c - -24  - ~ - -25  - ~ - -27  - ~"emaž-c.h -" - -28  - ~"emaž-c-·¿m-li¡.h -" - -29  - ~"emaž-c-bužd.h -" - -30  - ~"emaž-¡ub-sk.h -" - -31  - ~"emaž-¡ub-maš.h -" - -33  - ~"emaž-­i.h -" - -34  - ~"emaž-debug-log.h -" - -36 -EXPORT_API - -boÞ - - $emc_·r£_¡»am_emaž_sk -( -emc_emaž_sk - * -sk -, * -¡»am -,  -»¥Ú£_id -) - -38 - `EM_DEBUG_FUNC_BEGIN -(); - -40 -sk --> -­i_šfo - = ( -emc_emaž_­i_šfo - *) - `m®loc -((emipc_email_api_info)); - -41 ià( -sk --> -­i_šfo - =ð -NULL -) { - -42 - `EM_DEBUG_EXCEPTION -("Malloc failed."); - -43  -çl£ -; - -45 - `mem£t -( -sk --> -­i_šfo -, 0x00, ( -emc_emaž_­i_šfo -)); - -47 ià( -sk --> -­i_šfo -) { - -48 - `emc_·r£_¡»am_of_­i_šfo -( -sk --> -­i_šfo -, -ePARAMETER_IN -, -¡»am -); - -49 - `emc_£t_»¥Ú£_id_of_­i_šfo -( -sk --> -­i_šfo -, -»¥Ú£_id -); - -50  -Œue -; - -52  -çl£ -; - -53 - } -} - -55 -EXPORT_API - -emc_emaž_­i_šfo - * - $emc_g‘_­i_šfo -( -emc_emaž_sk - * -sk -) - -57  -sk --> -­i_šfo -; - -58 - } -} - -60 -EXPORT_API -  - $emc_g‘_»¥Ú£_chªÃl -( -emc_emaž_sk - * -sk -) - -62  -sk --> -»¥Ú£_chªÃl -; - -63 - } -} - -65 -EXPORT_API - -boÞ - - $emc_run_sk -( -emc_emaž_sk - * -sk -) - -67 - `EM_DEBUG_LOG -("[IPCLib] starting‡‚ewask..."); - -69  -­p_id - = - `emc_g‘_­p_id_of_­i_šfo -( -sk --> -­i_šfo -); - -70  -­i_id - = - `emc_g‘_­i_id_of_­i_šfo -( -sk --> -­i_šfo -); - -72 ià( -­p_id - > 0) { - -73 - `EM_DEBUG_LOG -("[IPCLib] Thi sk (%sèi f܇sync. Re¥Ú£ ID [%d]", - `EM_APIID_TO_STR -( -­i_id -),‡pi_id); - -74 ià(! - `emc_£t_»¥Ú£_šfo -( -­p_id -, -­i_id -)) { - -75 - `EM_DEBUG_EXCEPTION -("emipc_set_response_info failed"); - -76  -çl£ -; - -79  - `emc_execu‹_­i_´oxy_to_¡ub -( -sk --> -­i_šfo -); - -80 - } -} - - @email-stub/include/email-stub-main.h - -24 #iâdef -_IPC_STUB_MAIN_H_ - - -25  - #_IPC_STUB_MAIN_H_ - - - ) - -27  - ~"emaž-c.h -" - -28  - ~"emaž-c-­i-šfo.h -" - -30 -EXPORT_API - -boÞ - -emc_š™Ÿlize_¡ub_maš -( -PFN_EXECUTE_API - -â_­i_m­³r -); - -32 -EXPORT_API - -boÞ - -emc_fš®ize_¡ub_maš -(); - -34 -EXPORT_API - -boÞ - -emc_execu‹_­i_´oxy_to_¡ub -( -emc_emaž_­i_šfo - * -­i_šfo -); - -36 -EXPORT_API - -boÞ - -emc_execu‹_­i_¡ub_to_´oxy -( -emc_emaž_­i_šfo - * -­i_šfo -); - -38 -EXPORT_API - -boÞ - -emc_£t_»¥Ú£_šfo -( -­p_id -,  -­i_id -); - - @email-stub/include/email-stub-queue.h - -24 #iâdeà -_IPC_QUEUE_H_ - - -25  - #_IPC_QUEUE_H_ - - - ) - -27  - ~"emaž-ty³s.h -" - -29  - semc_emaž_queue_™em - { - -30 * - md©a -; - -31  -emc_emaž_queue_™em - * - mÃxt -; - -32 } - temc_emaž_queue_™em -; - -35 -EXPORT_API - * -emc_pÝ_š_queue -(); - -37 -EXPORT_API - -boÞ - -emc_push_š_queue -(* -d©a -); - -39 -EXPORT_API -  -emc_g‘_couÁ_of_™em -(); - - @email-stub/include/email-stub-response-info.h - -24 #iâdeà -_IPC_RESPONSE_INFO_H_ - - -25  - #_IPC_RESPONSE_INFO_H_ - - - ) - -27  - ~"emaž-ty³s.h -" - -30  - m»¥Ú£_id -; - -31  - m­i_id -; - -32 } - temc_emaž_»¥Ú£_šfo -; - -34 -EXPORT_API - -boÞ - -emc_£t_v®ue_š_»¥Ú£_šfo -( -emc_emaž_»¥Ú£_šfo - * -»¥Ú£_šfo -,  -»¥Ú£_id -,  -­i_id -); - -36 -EXPORT_API -  -emc_g‘_»¥Ú£_id_š_»¥Ú£_šfo -( -emc_emaž_»¥Ú£_šfo - * -»¥Ú£_šfo -); - -38 -EXPORT_API -  -emc_g‘_­i_id_š_»¥Ú£_šfo -( -emc_emaž_»¥Ú£_šfo - * -»¥Ú£_šfo -); - - @email-stub/include/email-stub-socket.h - -24 #iâdef -_IPC_STUB_SOCKET_H_ - - -25  - #_IPC_STUB_SOCKET_H_ - - - ) - -27  - ~"emaž-ty³s.h -" - -37 -EXPORT_API - -boÞ - -emc_¡¬t_¡ub_sock‘ -(); - -39 -EXPORT_API - -boÞ - -emc_¡¬t_¡ub_sock‘_th»ad -(); - -41 -EXPORT_API - -boÞ - -emc_¡Ý_¡ub_sock‘ -(); - -43 -EXPORT_API -  -emc_wa™_fÜ_c_»que¡ -(); - -45 -EXPORT_API - -boÞ - -emc_’d_¡ub_sock‘ -(); - -47 -EXPORT_API -  -emc_£nd_¡ub_sock‘ -( -sock_fd -, * -d©a -,  -Ën -); - - @email-stub/include/email-stub-task-manager.h - -23 #iâdeà -_IPC_TASK_MANAGER_H_ - - -24  - #_IPC_TASK_MANAGER_H_ - - - ) - -26  - ~"emaž-ty³s.h -" - -28  - #IPC_TASK_MAX - 64 - - ) - -30 -EXPORT_API - -boÞ - -emc_¡¬t_sk_th»ad -(); - -32 -EXPORT_API -  -emc_‹rmš©e_sk_th»ad -(); - -34 -EXPORT_API - -boÞ - -emc_¡Ý_sk_th»ad -(); - -36 -EXPORT_API - * -emc_do_sk_th»ad -(); - -38 -EXPORT_API - -boÞ - -emc_ü—‹_sk -(* -sk_¡»am -,  -»¥Ú£_chªÃl -); - - @email-stub/include/email-stub-task.h - -23 #iâdeà -_IPC_TASK_H_ - - -24  - #_IPC_TASK_H_ - - - ) - -26  - ~"emaž-c-­i-šfo.h -" - -27  - ~"emaž-ty³s.h -" - -30  - m»¥Ú£_chªÃl -; - -31 -emc_emaž_­i_šfo - * - m­i_šfo -; - -32 } - temc_emaž_sk -; - -34 -EXPORT_API - -boÞ - -emc_·r£_¡»am_emaž_sk -( -emc_emaž_sk - * -sk -, * -¡»am -,  -»¥Ú£_id -); - -36 -EXPORT_API - -emc_emaž_­i_šfo - * -emc_g‘_­i_šfo -( -emc_emaž_sk - * -sk -); - -38 -EXPORT_API -  -emc_g‘_»¥Ú£_chªÃl -( -emc_emaž_sk - * -sk -); - -40 -EXPORT_API - -boÞ - -emc_run_sk -( -emc_emaž_sk - * -sk -); - - @include/email-ipc-build.h - -23 #iâdeà -__IPC_LIBRARY_BUILD_H_ - - -24  - #__IPC_LIBRARY_BUILD_H_ - - - ) - -26  - ~<¡dio.h -> - - @include/email-ipc.h - -23 #iâdeà -__IPC_LIBRARY_H - - -24  - #__IPC_LIBRARY_H - - - ) - -26  - ~"emaž-ty³s.h -" - -28 #ifdeà -__ýlu¥lus - - -32  - #EM_PROXY_IF_NULL_RETURN_VALUE -( -ex´1 -, -ex´2 -, -v® -) { \ - -33 ià(! -ex´1 -&& -ex´2 -) { \ - -34 - `EM_DEBUG_LOG - ("EM_PROXY_IF_NULL_RETURN_VALUE : PARAM IS NULL \n"); \ - -35 - `emc_de¡roy_emaž_­i -( -ex´2 -); \ - -36  -v® -; \ - -37 }; } - - ) - -44 -ePARAMETER_IN - = 0, - -45 -ePARAMETER_OUT -, - -46 } - tEPARAMETER_DIRECTION -; - -48 * - tHIPC_API -; - -49 * - tHIPC_PARAMETER -; - -50 (* -PFN_PROXY_CALLBACK -è( - tHIPC_API - - tšput_­i_hªdË -, * - tpP¬am1 -, * - tpP¬am2 -); - -51 (* -PFN_EXECUTE_API -è( - tHIPC_API - - tšput_­i_hªdË -); - -56 -EXPORT_API -  -emc_š™Ÿlize_´oxy -(); - -58 -EXPORT_API -  -emc_fš®ize_´oxy -(); - -60 -EXPORT_API - -boÞ - -emc_execu‹_´oxy_­i -( -HIPC_API - -šput_­i_hªdË -); - -65 -EXPORT_API - -boÞ - -emc_š™Ÿlize_¡ub -( -PFN_EXECUTE_API - -šput_­i_m­³r -); - -67 -EXPORT_API - -boÞ - -emc_fš®ize_¡ub -(); - -69 -EXPORT_API - -boÞ - -emc_execu‹_¡ub_­i -( -HIPC_API - -šput_­i_hªdË -); - -74 -EXPORT_API - -HIPC_API - -emc_ü—‹_emaž_­i -( -­i_id -); - -75 -EXPORT_API -  -emc_de¡roy_emaž_­i -( -HIPC_API - -šput_­i_hªdË -); - -77 -EXPORT_API -  -emc_g‘_­i_id -( -HIPC_API - -šput_­i_hªdË -); - -78 -EXPORT_API -  -emc_g‘_­p_id -( -HIPC_API - -šput_­i_hªdË -); - -80 -EXPORT_API - -boÞ - -emc_add_·¿m‘” -( -HIPC_API - -šput_­i_hªdË -, -EPARAMETER_DIRECTION - -šput_·¿m‘”_dœeùiÚ -, * -šput_·¿m‘”_d©a -,  -šput_d©a_Ëngth -); - -81 -EXPORT_API -  -emc_g‘_·¿m‘”_couÁ -( -HIPC_API - -šput_­i_hªdË -, -EPARAMETER_DIRECTION - -šput_·¿m‘”_dœeùiÚ -); - -82 -EXPORT_API -  -emc_g‘_·¿m‘” -( -HIPC_API - -šput_­i_hªdË -, -EPARAMETER_DIRECTION - -šput_·¿m‘”_dœeùiÚ -,  -šput_·¿m‘”_šdex -,  -šput_·¿m‘”_bufãr_size -, * -ouut_·¿m‘” -); - -83 -EXPORT_API -  -emc_g‘_·¿m‘”_Ëngth -( -HIPC_API - -šput_­i_hªdË -, -EPARAMETER_DIRECTION - -šput_·¿m‘”_dœeùiÚ -,  -šput_·¿m‘”_šdex -); - -86 #ifdeà -__ýlu¥lus - - - @/usr/include/errno.h - -23 #iâdef -_ERRNO_H - - -27 #iâdef -__Ãed_Em©h - - -28  - #_ERRNO_H - 1 - - ) - -29  - ~<ã©u»s.h -> - -32 - g__BEGIN_DECLS - - -36  - ~ - -37 #undeà -__Ãed_Em©h - - -39 #ifdef -_ERRNO_H - - -46 #iâdef -”ºo - - -47  -”ºo -; - -50 #ifdeà -__USE_GNU - - -55 * -´og¿m_švoÿtiÚ_Çme -, * -´og¿m_švoÿtiÚ_shÜt_Çme -; - -59 - g__END_DECLS - - -67 #ià -defšed - -__USE_GNU - || defšed -__Ãed_”rÜ_t - - -68 #iâdeà -__”rÜ_t_defšed - - -69  - t”rÜ_t -; - -70  - #__”rÜ_t_defšed - 1 - - ) - -72 #undeà -__Ãed_”rÜ_t - - - @/usr/include/malloc.h - -21 #iâdeà -_MALLOC_H - - -22  - #_MALLOC_H - 1 - - ) - -24  - ~<ã©u»s.h -> - -25  - ~<¡ddef.h -> - -26  - ~<¡dio.h -> - -27  - #__m®loc_±r_t - * - - ) - -30  - #__m®loc_size_t - -size_t - - - ) - -31  - #__m®loc_±rdiff_t - -±rdiff_t - - - ) - -33 #ifdeà -__GNUC__ - - -35  - #__MALLOC_P -( -¬gs -è¬g  -__THROW - - - ) - -38  - #__MALLOC_PMT -( -¬gs -è - ) -args - -42  - #__MALLOC_P -( -¬gs -è - ) -args - -43  - #__MALLOC_PMT -( -¬gs -è - ) -args - -48 -__BEGIN_DECLS - - -51 * -m®loc - -__MALLOC_P - (( -size_t - -__size -)è -__©Œibu‹_m®loc__ - -__wur -; - -54 * -ÿÎoc - -__MALLOC_P - (( -size_t - -__nmemb -, size_ˆ -__size -)) - -55 -__©Œibu‹_m®loc__ - -__wur -; - -62 * -»®loc - -__MALLOC_P - ((* -__±r -, -size_t - -__size -)) - -63 -__©Œibu‹_w¬n_unu£d_»suÉ__ -; - -66  -ä“ - -__MALLOC_P - ((* -__±r -)); - -69  -cä“ - -__MALLOC_P - ((* -__±r -)); - -72 * -mem®ign - -__MALLOC_P - (( -size_t - -__®ignm’t -, size_ˆ -__size -)) - -73 -__©Œibu‹_m®loc__ - -__wur -; - -76 * -v®loc - -__MALLOC_P - (( -size_t - -__size -)) - -77 -__©Œibu‹_m®loc__ - -__wur -; - -81 * -pv®loc - -__MALLOC_P - (( -size_t - -__size -)) - -82 -__©Œibu‹_m®loc__ - -__wur -; - -86 *(* -__mÜecÜe -è -__MALLOC_PMT - (( -±rdiff_t - -__size -)); - -89 * -__deçuÉ_mÜecÜe - -__MALLOC_P - (( -±rdiff_t - -__size -)) - -90 -__©Œibu‹_m®loc__ -; - -94  - sm®lšfo - { - -95  - m¬’a -; - -96  - mÜdblks -; - -97  - msmblks -; - -98  - mhblks -; - -99  - mhblkhd -; - -100  - musmblks -; - -101  - mfsmblks -; - -102  - muÜdblks -; - -103  - mfÜdblks -; - -104  - mk“pco¡ -; - -108  -m®lšfo - m®lšfØ -__MALLOC_P - (()); - -111 #iâdeà -M_MXFAST - - -112  - #M_MXFAST - 1 - - ) - -114 #iâdeà -M_NLBLKS - - -115  - #M_NLBLKS - 2 - - ) - -117 #iâdeà -M_GRAIN - - -118  - #M_GRAIN - 3 - - ) - -120 #iâdeà -M_KEEP - - -121  - #M_KEEP - 4 - - ) - -125  - #M_TRIM_THRESHOLD - -1 - - ) - -126  - #M_TOP_PAD - -2 - - ) - -127  - #M_MMAP_THRESHOLD - -3 - - ) - -128  - #M_MMAP_MAX - -4 - - ) - -129  - #M_CHECK_ACTION - -5 - - ) - -130  - #M_PERTURB - -6 - - ) - -131  - #M_ARENA_TEST - -7 - - ) - -132  - #M_ARENA_MAX - -8 - - ) - -135  -m®lÝt - -__MALLOC_P - (( -__·¿m -,  -__v® -)); - -139  -m®loc_Œim - -__MALLOC_P - (( -size_t - -__·d -)); - -143 -size_t - -m®loc_u§bË_size - -__MALLOC_P - ((* -__±r -)); - -146  -m®loc_¡©s - -__MALLOC_P - (()); - -149  -m®loc_šfo - ( -__ÝtiÚs -, -FILE - * -__å -); - -152 * -m®loc_g‘_¡©e - -__MALLOC_P - (()); - -156  -m®loc_£t_¡©e - -__MALLOC_P - ((* -__±r -)); - -161 (* -__m®loc_š™Ÿlize_hook -è - `__MALLOC_PMT - (()); - -163 (* -__ä“_hook -è - `__MALLOC_PMT - ((* -__±r -, - -164 -__cÚ¡ - -__m®loc_±r_t -)); - -165 *(* -__m®loc_hook -è - `__MALLOC_PMT - (( -size_t - -__size -, - -166 -__cÚ¡ - -__m®loc_±r_t -)); - -167 *(* -__»®loc_hook -è - `__MALLOC_PMT - ((* -__±r -, -size_t - -__size -, - -168 -__cÚ¡ - -__m®loc_±r_t -)); - -169 *(* -__mem®ign_hook -è - `__MALLOC_PMT - (( -size_t - -__®ignm’t -, - -170 -size_t - -__size -, - -171 -__cÚ¡ - -__m®loc_±r_t -)); - -172 (* -__aá”_mÜecÜe_hook -è - `__MALLOC_PMT - (()); - -175  -__m®loc_check_š™ - - `__MALLOC_P - (()); - -178 -__END_DECLS - - - @/usr/include/pthread.h - -20 #iâdeà -_PTHREAD_H - - -21  - #_PTHREAD_H - 1 - - ) - -23  - ~<ã©u»s.h -> - -24  - ~<’dŸn.h -> - -25  - ~ - -26  - ~ - -28  - ~ - -29  - ~ - -30  - ~ - -36 - mPTHREAD_CREATE_JOINABLE -, - -37  - #PTHREAD_CREATE_JOINABLE - -PTHREAD_CREATE_JOINABLE - - - ) - -38 - mPTHREAD_CREATE_DETACHED - - -39  - #PTHREAD_CREATE_DETACHED - -PTHREAD_CREATE_DETACHED - - - ) - -46 - mPTHREAD_MUTEX_TIMED_NP -, - -47 - mPTHREAD_MUTEX_RECURSIVE_NP -, - -48 - mPTHREAD_MUTEX_ERRORCHECK_NP -, - -49 - mPTHREAD_MUTEX_ADAPTIVE_NP - - -50 #ià -defšed - -__USE_UNIX98 - || defšed -__USE_XOPEN2K8 - - -52 - mPTHREAD_MUTEX_NORMAL - = -PTHREAD_MUTEX_TIMED_NP -, - -53 - mPTHREAD_MUTEX_RECURSIVE - = -PTHREAD_MUTEX_RECURSIVE_NP -, - -54 - mPTHREAD_MUTEX_ERRORCHECK - = -PTHREAD_MUTEX_ERRORCHECK_NP -, - -55 - mPTHREAD_MUTEX_DEFAULT - = -PTHREAD_MUTEX_NORMAL - - -57 #ifdeà -__USE_GNU - - -59 , - mPTHREAD_MUTEX_FAST_NP - = -PTHREAD_MUTEX_TIMED_NP - - -64 #ifdeà -__USE_XOPEN2K - - -68 - mPTHREAD_MUTEX_STALLED -, - -69 - mPTHREAD_MUTEX_STALLED_NP - = -PTHREAD_MUTEX_STALLED -, - -70 - mPTHREAD_MUTEX_ROBUST -, - -71 - mPTHREAD_MUTEX_ROBUST_NP - = -PTHREAD_MUTEX_ROBUST - - -76 #ifdeà -__USE_UNIX98 - - -80 - mPTHREAD_PRIO_NONE -, - -81 - mPTHREAD_PRIO_INHERIT -, - -82 - mPTHREAD_PRIO_PROTECT - - -88 #ià -__WORDSIZE - == 64 - -89  - #PTHREAD_MUTEX_INITIALIZER - \ - -90 { { 0, 0, 0, 0, 0, 0, { 0, 0 } } } - - ) - -91 #ifdeà -__USE_GNU - - -92  - #PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP - \ - -93 { { 0, 0, 0, 0, -PTHREAD_MUTEX_RECURSIVE_NP -, 0, { 0, 0 } } } - - ) - -94  - #PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - \ - -95 { { 0, 0, 0, 0, -PTHREAD_MUTEX_ERRORCHECK_NP -, 0, { 0, 0 } } } - - ) - -96  - #PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP - \ - -97 { { 0, 0, 0, 0, -PTHREAD_MUTEX_ADAPTIVE_NP -, 0, { 0, 0 } } } - - ) - -100  - #PTHREAD_MUTEX_INITIALIZER - \ - -101 { { 0, 0, 0, 0, 0, { 0 } } } - - ) - -102 #ifdeà -__USE_GNU - - -103  - #PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP - \ - -104 { { 0, 0, 0, -PTHREAD_MUTEX_RECURSIVE_NP -, 0, { 0 } } } - - ) - -105  - #PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - \ - -106 { { 0, 0, 0, -PTHREAD_MUTEX_ERRORCHECK_NP -, 0, { 0 } } } - - ) - -107  - #PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP - \ - -108 { { 0, 0, 0, -PTHREAD_MUTEX_ADAPTIVE_NP -, 0, { 0 } } } - - ) - -114 #ià -defšed - -__USE_UNIX98 - || defšed -__USE_XOPEN2K - - -117 - mPTHREAD_RWLOCK_PREFER_READER_NP -, - -118 - mPTHREAD_RWLOCK_PREFER_WRITER_NP -, - -119 - mPTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP -, - -120 - mPTHREAD_RWLOCK_DEFAULT_NP - = -PTHREAD_RWLOCK_PREFER_READER_NP - - -124  - #PTHREAD_RWLOCK_INITIALIZER - \ - -125 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } - - ) - -126 #ifdeà -__USE_GNU - - -127 #ià -__WORDSIZE - == 64 - -128  - #PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP - \ - -130 -PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP - } } - - ) - -132 #ià -__BYTE_ORDER - =ð -__LITTLE_ENDIAN - - -133  - #PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP - \ - -134 { { 0, 0, 0, 0, 0, 0, -PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP -, \ - -135 0, 0, 0, 0 } } - - ) - -137  - #PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP - \ - -138 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, -PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP -,\ - -139 0 } } - - ) - -149 - mPTHREAD_INHERIT_SCHED -, - -150  - #PTHREAD_INHERIT_SCHED - -PTHREAD_INHERIT_SCHED - - - ) - -151 - mPTHREAD_EXPLICIT_SCHED - - -152  - #PTHREAD_EXPLICIT_SCHED - -PTHREAD_EXPLICIT_SCHED - - - ) - -159 - mPTHREAD_SCOPE_SYSTEM -, - -160  - #PTHREAD_SCOPE_SYSTEM - -PTHREAD_SCOPE_SYSTEM - - - ) - -161 - mPTHREAD_SCOPE_PROCESS - - -162  - #PTHREAD_SCOPE_PROCESS - -PTHREAD_SCOPE_PROCESS - - - ) - -169 - mPTHREAD_PROCESS_PRIVATE -, - -170  - #PTHREAD_PROCESS_PRIVATE - -PTHREAD_PROCESS_PRIVATE - - - ) - -171 - mPTHREAD_PROCESS_SHARED - - -172  - #PTHREAD_PROCESS_SHARED - -PTHREAD_PROCESS_SHARED - - - ) - -178  - #PTHREAD_COND_INITIALIZER - { { 0, 0, 0, 0, 0, (*è0, 0, 0 } } - - ) - -182  - s_±h»ad_þ—nup_bufãr - - -184 (* - m__routše -) (*); - -185 * - m__¬g -; - -186  - m__ÿnûÉy³ -; - -187  -_±h»ad_þ—nup_bufãr - * - m__´ev -; - -193 - mPTHREAD_CANCEL_ENABLE -, - -194  - #PTHREAD_CANCEL_ENABLE - -PTHREAD_CANCEL_ENABLE - - - ) - -195 - mPTHREAD_CANCEL_DISABLE - - -196  - #PTHREAD_CANCEL_DISABLE - -PTHREAD_CANCEL_DISABLE - - - ) - -200 - mPTHREAD_CANCEL_DEFERRED -, - -201  - #PTHREAD_CANCEL_DEFERRED - -PTHREAD_CANCEL_DEFERRED - - - ) - -202 - mPTHREAD_CANCEL_ASYNCHRONOUS - - -203  - #PTHREAD_CANCEL_ASYNCHRONOUS - -PTHREAD_CANCEL_ASYNCHRONOUS - - - ) - -205  - #PTHREAD_CANCELED - ((*è-1) - - ) - -209  - #PTHREAD_ONCE_INIT - 0 - - ) - -212 #ifdeà -__USE_XOPEN2K - - -216  - #PTHREAD_BARRIER_SERIAL_THREAD - -1 - - ) - -220 -__BEGIN_DECLS - - -225  -±h»ad_ü—‹ - ( -±h»ad_t - * -__»¡riù - -__Ãwth»ad -, - -226 -__cÚ¡ - -±h»ad_©Œ_t - * -__»¡riù - -__©Œ -, - -227 *(* -__¡¬t_routše -) (*), - -228 * -__»¡riù - -__¬g -è -__THROW - -__nÚnuÎ - ((1, 3)); - -234  - $±h»ad_ex™ - (* -__»tv® -è - `__©Œibu‹__ - (( -__nܑuº__ -)); - -242  - `±h»ad_još - ( -±h»ad_t - -__th -, ** -__th»ad_»tuº -); - -244 #ifdeà -__USE_GNU - - -247  - $±h»ad_Œyjoš_Å - ( -±h»ad_t - -__th -, ** -__th»ad_»tuº -è -__THROW -; - -255  - `±h»ad_timedjoš_Å - ( -±h»ad_t - -__th -, ** -__th»ad_»tuº -, - -256 -__cÚ¡ -  -time¥ec - * -__ab¡ime -); - -263  - $±h»ad_d‘ach - ( -±h»ad_t - -__th -è -__THROW -; - -267 -±h»ad_t - - $±h»ad_£lf - (è -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)); - -270  - $±h»ad_equ® - ( -±h»ad_t - -__th»ad1 -,…th»ad_ˆ -__th»ad2 -è -__THROW -; - -278  - $±h»ad_©Œ_š™ - ( -±h»ad_©Œ_t - * -__©Œ -è -__THROW - - `__nÚnuÎ - ((1)); - -281  - $±h»ad_©Œ_de¡roy - ( -±h»ad_©Œ_t - * -__©Œ -) - -282 -__THROW - - `__nÚnuÎ - ((1)); - -285  - $±h»ad_©Œ_g‘d‘ach¡©e - ( -__cÚ¡ - -±h»ad_©Œ_t - * -__©Œ -, - -286 * -__d‘ach¡©e -) - -287 -__THROW - - `__nÚnuÎ - ((1, 2)); - -290  - $±h»ad_©Œ_£td‘ach¡©e - ( -±h»ad_©Œ_t - * -__©Œ -, - -291  -__d‘ach¡©e -) - -292 -__THROW - - `__nÚnuÎ - ((1)); - -296  - $±h»ad_©Œ_g‘gu¬dsize - ( -__cÚ¡ - -±h»ad_©Œ_t - * -__©Œ -, - -297 -size_t - * -__gu¬dsize -) - -298 -__THROW - - `__nÚnuÎ - ((1, 2)); - -301  - $±h»ad_©Œ_£tgu¬dsize - ( -±h»ad_©Œ_t - * -__©Œ -, - -302 -size_t - -__gu¬dsize -) - -303 -__THROW - - `__nÚnuÎ - ((1)); - -307  - $±h»ad_©Œ_g‘sched·¿m - ( -__cÚ¡ - -±h»ad_©Œ_t - * -__»¡riù - - -308 -__©Œ -, - -309  -sched_·¿m - * -__»¡riù - -__·¿m -) - -310 -__THROW - - `__nÚnuÎ - ((1, 2)); - -313  - $±h»ad_©Œ_£tsched·¿m - ( -±h»ad_©Œ_t - * -__»¡riù - -__©Œ -, - -314 -__cÚ¡ -  -sched_·¿m - * -__»¡riù - - -315 -__·¿m -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -318  - $±h»ad_©Œ_g‘schedpÞicy - ( -__cÚ¡ - -±h»ad_©Œ_t - * -__»¡riù - - -319 -__©Œ -, * -__»¡riù - -__pÞicy -) - -320 -__THROW - - `__nÚnuÎ - ((1, 2)); - -323  - $±h»ad_©Œ_£tschedpÞicy - ( -±h»ad_©Œ_t - * -__©Œ -,  -__pÞicy -) - -324 -__THROW - - `__nÚnuÎ - ((1)); - -327  - $±h»ad_©Œ_g‘šh”™sched - ( -__cÚ¡ - -±h»ad_©Œ_t - * -__»¡riù - - -328 -__©Œ -, * -__»¡riù - -__šh”™ -) - -329 -__THROW - - `__nÚnuÎ - ((1, 2)); - -332  - $±h»ad_©Œ_£tšh”™sched - ( -±h»ad_©Œ_t - * -__©Œ -, - -333  -__šh”™ -) - -334 -__THROW - - `__nÚnuÎ - ((1)); - -338  - $±h»ad_©Œ_g‘scÝe - ( -__cÚ¡ - -±h»ad_©Œ_t - * -__»¡riù - -__©Œ -, - -339 * -__»¡riù - -__scÝe -) - -340 -__THROW - - `__nÚnuÎ - ((1, 2)); - -343  - $±h»ad_©Œ_£tscÝe - ( -±h»ad_©Œ_t - * -__©Œ -,  -__scÝe -) - -344 -__THROW - - `__nÚnuÎ - ((1)); - -347  - $±h»ad_©Œ_g‘¡ackaddr - ( -__cÚ¡ - -±h»ad_©Œ_t - * -__»¡riù - - -348 -__©Œ -, ** -__»¡riù - -__¡ackaddr -) - -349 -__THROW - - `__nÚnuÎ - ((1, 2)è -__©Œibu‹_d•»ÿ‹d__ -; - -355  - $±h»ad_©Œ_£t¡ackaddr - ( -±h»ad_©Œ_t - * -__©Œ -, - -356 * -__¡ackaddr -) - -357 -__THROW - - `__nÚnuÎ - ((1)è -__©Œibu‹_d•»ÿ‹d__ -; - -360  - $±h»ad_©Œ_g‘¡acksize - ( -__cÚ¡ - -±h»ad_©Œ_t - * -__»¡riù - - -361 -__©Œ -, -size_t - * -__»¡riù - -__¡acksize -) - -362 -__THROW - - `__nÚnuÎ - ((1, 2)); - -367  - $±h»ad_©Œ_£t¡acksize - ( -±h»ad_©Œ_t - * -__©Œ -, - -368 -size_t - -__¡acksize -) - -369 -__THROW - - `__nÚnuÎ - ((1)); - -371 #ifdeà -__USE_XOPEN2K - - -373  - $±h»ad_©Œ_g‘¡ack - ( -__cÚ¡ - -±h»ad_©Œ_t - * -__»¡riù - -__©Œ -, - -374 ** -__»¡riù - -__¡ackaddr -, - -375 -size_t - * -__»¡riù - -__¡acksize -) - -376 -__THROW - - `__nÚnuÎ - ((1, 2, 3)); - -381  - $±h»ad_©Œ_£t¡ack - ( -±h»ad_©Œ_t - * -__©Œ -, * -__¡ackaddr -, - -382 -size_t - -__¡acksize -è -__THROW - - `__nÚnuÎ - ((1)); - -385 #ifdeà -__USE_GNU - - -388  - $±h»ad_©Œ_£ffš™y_Å - ( -±h»ad_©Œ_t - * -__©Œ -, - -389 -size_t - -__ýu£tsize -, - -390 -__cÚ¡ - -ýu_£t_t - * -__ýu£t -) - -391 -__THROW - - `__nÚnuÎ - ((1, 3)); - -395  - $±h»ad_©Œ_g‘affš™y_Å - ( -__cÚ¡ - -±h»ad_©Œ_t - * -__©Œ -, - -396 -size_t - -__ýu£tsize -, - -397 -ýu_£t_t - * -__ýu£t -) - -398 -__THROW - - `__nÚnuÎ - ((1, 3)); - -404  - $±h»ad_g‘©Œ_Å - ( -±h»ad_t - -__th -, -±h»ad_©Œ_t - * -__©Œ -) - -405 -__THROW - - `__nÚnuÎ - ((2)); - -413  - $±h»ad_£tsched·¿m - ( -±h»ad_t - -__rg‘_th»ad -,  -__pÞicy -, - -414 -__cÚ¡ -  -sched_·¿m - * -__·¿m -) - -415 -__THROW - - `__nÚnuÎ - ((3)); - -418  - $±h»ad_g‘sched·¿m - ( -±h»ad_t - -__rg‘_th»ad -, - -419 * -__»¡riù - -__pÞicy -, - -420  -sched_·¿m - * -__»¡riù - -__·¿m -) - -421 -__THROW - - `__nÚnuÎ - ((2, 3)); - -424  - $±h»ad_£tsched´io - ( -±h»ad_t - -__rg‘_th»ad -,  -__´io -) - -425 -__THROW -; - -428 #ifdeà -__USE_GNU - - -430  - $±h»ad_g‘Çme_Å - ( -±h»ad_t - -__rg‘_th»ad -, * -__buf -, - -431 -size_t - -__buæ’ -) - -432 -__THROW - - `__nÚnuÎ - ((2)); - -435  - $±h»ad_£Šame_Å - ( -±h»ad_t - -__rg‘_th»ad -, -__cÚ¡ - * -__Çme -) - -436 -__THROW - - `__nÚnuÎ - ((2)); - -440 #ifdeà -__USE_UNIX98 - - -442  - $±h»ad_g‘cÚcu¼’cy - (è -__THROW -; - -445  - $±h»ad_£tcÚcu¼’cy - ( -__Ëv– -è -__THROW -; - -448 #ifdeà -__USE_GNU - - -453  - $±h»ad_y›ld - (è -__THROW -; - -458  - $±h»ad_£ffš™y_Å - ( -±h»ad_t - -__th -, -size_t - -__ýu£tsize -, - -459 -__cÚ¡ - -ýu_£t_t - * -__ýu£t -) - -460 -__THROW - - `__nÚnuÎ - ((3)); - -463  - $±h»ad_g‘affš™y_Å - ( -±h»ad_t - -__th -, -size_t - -__ýu£tsize -, - -464 -ýu_£t_t - * -__ýu£t -) - -465 -__THROW - - `__nÚnuÎ - ((3)); - -478  - `±h»ad_Úû - ( -±h»ad_Úû_t - * -__Úû_cÚŒÞ -, - -479 (* -__š™_routše -è()è - `__nÚnuÎ - ((1, 2)); - -490  - `±h»ad_£tÿnûl¡©e - ( -__¡©e -, * -__Þd¡©e -); - -494  - `±h»ad_£tÿnûÉy³ - ( -__ty³ -, * -__Þdty³ -); - -497  - `±h»ad_ÿnûl - ( -±h»ad_t - -__th -); - -502  - `±h»ad_‹¡ÿnûl - (); - -511 -__jmp_buf - -__ÿnûl_jmp_buf -; - -512  -__mask_was_§ved -; - -513 } -__ÿnûl_jmp_buf -[1]; - -514 * -__·d -[4]; - -515 } - t__±h»ad_unwšd_buf_t - - t__©Œibu‹__ - (( - t__®igÃd__ -)); - -518 #iâdeà -__þ—nup_fù_©Œibu‹ - - -519  - #__þ—nup_fù_©Œibu‹ - - - ) - -524  - s__±h»ad_þ—nup_äame - - -526 (* -__ÿnûl_routše -) (*); - -527 * -__ÿnûl_¬g -; - -528  -__do_™ -; - -529  -__ÿnûl_ty³ -; - -532 #ià -defšed - -__GNUC__ - && defšed -__EXCEPTIONS - - -533 #ifdeà -__ýlu¥lus - - -535 þas  - c__±h»ad_þ—nup_þass - - -537 (* -__ÿnûl_routše -) (*); - -538 * -__ÿnûl_¬g -; - -539  -__do_™ -; - -540  -__ÿnûl_ty³ -; - -542 -public -: - -543 - `__±h»ad_þ—nup_þass - ((* -__fù -è(*), * -__¬g -) - -544 : - `__ÿnûl_routše - ( -__fù -), - `__ÿnûl_¬g - ( -__¬g -), - $__do_™ - (1) { } - -545 ~ - $__±h»ad_þ—nup_þass - (è{ ià( -__do_™ -è - `__ÿnûl_routše - ( -__ÿnûl_¬g -); - } -} - -546  - $__£tdo™ - ( -__Ãwv® -è{ -__do_™ - = __Ãwv®; - } -} - -547  - $__deãr - (è{ - `±h»ad_£tÿnûÉy³ - ( -PTHREAD_CANCEL_DEFERRED -, - -548 & -__ÿnûl_ty³ -); - } -} - -549  - $__»¡Üe - (ècÚ¡ { - `±h»ad_£tÿnûÉy³ - ( -__ÿnûl_ty³ -, 0); - } -} - -559  - #±h»ad_þ—nup_push -( -routše -, -¬g -) \ - -561 -__±h»ad_þ—nup_þass - - `__þäame - ( -routše -, -¬g -) - - ) - -565  - #±h»ad_þ—nup_pÝ -( -execu‹ -) \ - -566 -__þäame -. - `__£tdo™ - ( -execu‹ -); \ - -567 } 0) - - ) - -569 #ifdeà -__USE_GNU - - -573  - #±h»ad_þ—nup_push_deãr_Å -( -routše -, -¬g -) \ - -575 -__±h»ad_þ—nup_þass - - `__þäame - ( -routše -, -¬g -); \ - -576 -__þäame -. - `__deãr - () - - ) - -581  - #±h»ad_þ—nup_pÝ_»¡Üe_Å -( -execu‹ -) \ - -582 -__þäame -. - `__»¡Üe - (); \ - -583 -__þäame -. - `__£tdo™ - ( -execu‹ -); \ - -584 } 0) - - ) - -591 -__ex‹º_šlše -  - -592 - $__±h»ad_þ—nup_routše - ( -__±h»ad_þ—nup_äame - * -__äame -) - -594 ià( -__äame --> -__do_™ -) - -595 -__äame --> - `__ÿnûl_routše - (__äame-> -__ÿnûl_¬g -); - -596 - } -} - -605  - #±h»ad_þ—nup_push -( -routše -, -¬g -) \ - -607  -__±h»ad_þ—nup_äame - -__þäame - \ - -608 - `__©Œibu‹__ - (( - `__þ—nup__ - ( -__±h»ad_þ—nup_routše -))) \ - -609 ð{ . -__ÿnûl_routše - = ( -routše -), . -__ÿnûl_¬g - = ( -¬g -), \ - -610 . -__do_™ - = 1 }; - - ) - -614  - #±h»ad_þ—nup_pÝ -( -execu‹ -) \ - -615 -__þäame -. -__do_™ - = ( -execu‹ -); \ - -616 } 0) - - ) - -618 #ifdeà -__USE_GNU - - -622  - #±h»ad_þ—nup_push_deãr_Å -( -routše -, -¬g -) \ - -624  -__±h»ad_þ—nup_äame - -__þäame - \ - -625 - `__©Œibu‹__ - (( - `__þ—nup__ - ( -__±h»ad_þ—nup_routše -))) \ - -626 ð{ . -__ÿnûl_routše - = ( -routše -), . -__ÿnûl_¬g - = ( -¬g -), \ - -627 . -__do_™ - = 1 }; \ - -628 (è - `±h»ad_£tÿnûÉy³ - ( -PTHREAD_CANCEL_DEFERRED -, \ - -629 & -__þäame -. -__ÿnûl_ty³ -) - - ) - -634  - #±h»ad_þ—nup_pÝ_»¡Üe_Å -( -execu‹ -) \ - -635 (è - `±h»ad_£tÿnûÉy³ - ( -__þäame -. -__ÿnûl_ty³ -, -NULL -); \ - -636 -__þäame -. -__do_™ - = ( -execu‹ -); \ - -637 } 0) - - ) - -648  - #±h»ad_þ—nup_push -( -routše -, -¬g -) \ - -650 -__±h»ad_unwšd_buf_t - -__ÿnûl_buf -; \ - -651 (* -__ÿnûl_routše -è(*èð( -routše -); \ - -652 * -__ÿnûl_¬g - = ( -¬g -); \ - -653  -__nÙ_fœ¡_ÿÎ - = - `__sig£tjmp - (( -__jmp_buf_g - *) (*) \ - -654 -__ÿnûl_buf -. -__ÿnûl_jmp_buf -, 0); \ - -655 ià( - `__bužtš_ex³ù - ( -__nÙ_fœ¡_ÿÎ -, 0)) \ - -657 - `__ÿnûl_routše - ( -__ÿnûl_¬g -); \ - -658 - `__±h»ad_unwšd_Ãxt - (& -__ÿnûl_buf -); \ - -662 - `__±h»ad_»gi¡”_ÿnûl - (& -__ÿnûl_buf -); \ - -663 dØ{ - - ) - -664  -__±h»ad_»gi¡”_ÿnûl - ( -__±h»ad_unwšd_buf_t - * -__buf -) - -665 -__þ—nup_fù_©Œibu‹ -; - -669  - #±h»ad_þ—nup_pÝ -( -execu‹ -) \ - -672 - `__±h»ad_uÄegi¡”_ÿnûl - (& -__ÿnûl_buf -); \ - -673 ià( -execu‹ -) \ - -674 - `__ÿnûl_routše - ( -__ÿnûl_¬g -); \ - -675 } 0) - - ) - -676  - $__±h»ad_uÄegi¡”_ÿnûl - ( -__±h»ad_unwšd_buf_t - * -__buf -) - -677 -__þ—nup_fù_©Œibu‹ -; - -679 #ifdeà -__USE_GNU - - -683  - #±h»ad_þ—nup_push_deãr_Å -( -routše -, -¬g -) \ - -685 -__±h»ad_unwšd_buf_t - -__ÿnûl_buf -; \ - -686 (* -__ÿnûl_routše -è(*èð( -routše -); \ - -687 * -__ÿnûl_¬g - = ( -¬g -); \ - -688  -__nÙ_fœ¡_ÿÎ - = - `__sig£tjmp - (( -__jmp_buf_g - *) (*) \ - -689 -__ÿnûl_buf -. -__ÿnûl_jmp_buf -, 0); \ - -690 ià( - `__bužtš_ex³ù - ( -__nÙ_fœ¡_ÿÎ -, 0)) \ - -692 - `__ÿnûl_routše - ( -__ÿnûl_¬g -); \ - -693 - `__±h»ad_unwšd_Ãxt - (& -__ÿnûl_buf -); \ - -697 - `__±h»ad_»gi¡”_ÿnûl_deãr - (& -__ÿnûl_buf -); \ - -698 dØ{ - - ) - -699  - `__±h»ad_»gi¡”_ÿnûl_deãr - ( -__±h»ad_unwšd_buf_t - * -__buf -) - -700 -__þ—nup_fù_©Œibu‹ -; - -705  - #±h»ad_þ—nup_pÝ_»¡Üe_Å -( -execu‹ -) \ - -708 - `__±h»ad_uÄegi¡”_ÿnûl_»¡Üe - (& -__ÿnûl_buf -); \ - -709 ià( -execu‹ -) \ - -710 - `__ÿnûl_routše - ( -__ÿnûl_¬g -); \ - -711 - } -} 0) - - ) - -712  - $__±h»ad_uÄegi¡”_ÿnûl_»¡Üe - ( -__±h»ad_unwšd_buf_t - * -__buf -) - -713 -__þ—nup_fù_©Œibu‹ -; - -717  - $__±h»ad_unwšd_Ãxt - ( -__±h»ad_unwšd_buf_t - * -__buf -) - -718 -__þ—nup_fù_©Œibu‹ - - `__©Œibu‹__ - (( -__nܑuº__ -)) - -719 #iâdeà -SHARED - - -720 - `__©Œibu‹__ - (( -__w—k__ -)) - -726  -__jmp_buf_g -; - -727  - $__sig£tjmp - ( -__jmp_buf_g - * -__’v -,  -__§vemask -è -__THROW -; - -733  - $±h»ad_mu‹x_š™ - ( -±h»ad_mu‹x_t - * -__mu‹x -, - -734 -__cÚ¡ - -±h»ad_mu‹x©Œ_t - * -__mu‹x©Œ -) - -735 -__THROW - - `__nÚnuÎ - ((1)); - -738  - $±h»ad_mu‹x_de¡roy - ( -±h»ad_mu‹x_t - * -__mu‹x -) - -739 -__THROW - - `__nÚnuÎ - ((1)); - -742  - $±h»ad_mu‹x_Œylock - ( -±h»ad_mu‹x_t - * -__mu‹x -) - -743 -__THROW - - `__nÚnuÎ - ((1)); - -746  - $±h»ad_mu‹x_lock - ( -±h»ad_mu‹x_t - * -__mu‹x -) - -747 -__THROW - - `__nÚnuÎ - ((1)); - -749 #ifdeà -__USE_XOPEN2K - - -751  - $±h»ad_mu‹x_timedlock - ( -±h»ad_mu‹x_t - * -__»¡riù - -__mu‹x -, - -752 -__cÚ¡ -  -time¥ec - * -__»¡riù - - -753 -__ab¡ime -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -757  - $±h»ad_mu‹x_uÆock - ( -±h»ad_mu‹x_t - * -__mu‹x -) - -758 -__THROW - - `__nÚnuÎ - ((1)); - -762  - $±h»ad_mu‹x_g‘´ioûžšg - ( -__cÚ¡ - -±h»ad_mu‹x_t - * - -763 -__»¡riù - -__mu‹x -, - -764 * -__»¡riù - -__´ioûžšg -) - -765 -__THROW - - `__nÚnuÎ - ((1, 2)); - -769  - $±h»ad_mu‹x_£rioûžšg - ( -±h»ad_mu‹x_t - * -__»¡riù - -__mu‹x -, - -770  -__´ioûžšg -, - -771 * -__»¡riù - -__Þd_ûžšg -) - -772 -__THROW - - `__nÚnuÎ - ((1, 3)); - -775 #ifdeà -__USE_XOPEN2K8 - - -777  - $±h»ad_mu‹x_cÚsi¡’t - ( -±h»ad_mu‹x_t - * -__mu‹x -) - -778 -__THROW - - `__nÚnuÎ - ((1)); - -779 #ifdeà -__USE_GNU - - -780  - $±h»ad_mu‹x_cÚsi¡’t_Å - ( -±h»ad_mu‹x_t - * -__mu‹x -) - -781 -__THROW - - `__nÚnuÎ - ((1)); - -790  - $±h»ad_mu‹x©Œ_š™ - ( -±h»ad_mu‹x©Œ_t - * -__©Œ -) - -791 -__THROW - - `__nÚnuÎ - ((1)); - -794  - $±h»ad_mu‹x©Œ_de¡roy - ( -±h»ad_mu‹x©Œ_t - * -__©Œ -) - -795 -__THROW - - `__nÚnuÎ - ((1)); - -798  - $±h»ad_mu‹x©Œ_g‘psh¬ed - ( -__cÚ¡ - -±h»ad_mu‹x©Œ_t - * - -799 -__»¡riù - -__©Œ -, - -800 * -__»¡riù - -__psh¬ed -) - -801 -__THROW - - `__nÚnuÎ - ((1, 2)); - -804  - $±h»ad_mu‹x©Œ_£sh¬ed - ( -±h»ad_mu‹x©Œ_t - * -__©Œ -, - -805  -__psh¬ed -) - -806 -__THROW - - `__nÚnuÎ - ((1)); - -808 #ià -defšed - -__USE_UNIX98 - || defšed -__USE_XOPEN2K8 - - -810  - $±h»ad_mu‹x©Œ_g‘ty³ - ( -__cÚ¡ - -±h»ad_mu‹x©Œ_t - * -__»¡riù - - -811 -__©Œ -, * -__»¡riù - -__kšd -) - -812 -__THROW - - `__nÚnuÎ - ((1, 2)); - -817  - $±h»ad_mu‹x©Œ_£‰y³ - ( -±h»ad_mu‹x©Œ_t - * -__©Œ -,  -__kšd -) - -818 -__THROW - - `__nÚnuÎ - ((1)); - -822  - $±h»ad_mu‹x©Œ_g‘´ÙocÞ - ( -__cÚ¡ - -±h»ad_mu‹x©Œ_t - * - -823 -__»¡riù - -__©Œ -, - -824 * -__»¡riù - -__´ÙocÞ -) - -825 -__THROW - - `__nÚnuÎ - ((1, 2)); - -829  - $±h»ad_mu‹x©Œ_£rÙocÞ - ( -±h»ad_mu‹x©Œ_t - * -__©Œ -, - -830  -__´ÙocÞ -) - -831 -__THROW - - `__nÚnuÎ - ((1)); - -834  - $±h»ad_mu‹x©Œ_g‘´ioûžšg - ( -__cÚ¡ - -±h»ad_mu‹x©Œ_t - * - -835 -__»¡riù - -__©Œ -, - -836 * -__»¡riù - -__´ioûžšg -) - -837 -__THROW - - `__nÚnuÎ - ((1, 2)); - -840  - $±h»ad_mu‹x©Œ_£rioûžšg - ( -±h»ad_mu‹x©Œ_t - * -__©Œ -, - -841  -__´ioûžšg -) - -842 -__THROW - - `__nÚnuÎ - ((1)); - -844 #ifdeà -__USE_XOPEN2K - - -846  - $±h»ad_mu‹x©Œ_g‘robu¡ - ( -__cÚ¡ - -±h»ad_mu‹x©Œ_t - * -__©Œ -, - -847 * -__robu¡Ãss -) - -848 -__THROW - - `__nÚnuÎ - ((1, 2)); - -849 #ifdeà -__USE_GNU - - -850  - $±h»ad_mu‹x©Œ_g‘robu¡_Å - ( -__cÚ¡ - -±h»ad_mu‹x©Œ_t - * -__©Œ -, - -851 * -__robu¡Ãss -) - -852 -__THROW - - `__nÚnuÎ - ((1, 2)); - -856  - $±h»ad_mu‹x©Œ_£Œobu¡ - ( -±h»ad_mu‹x©Œ_t - * -__©Œ -, - -857  -__robu¡Ãss -) - -858 -__THROW - - `__nÚnuÎ - ((1)); - -859 #ifdeà -__USE_GNU - - -860  - $±h»ad_mu‹x©Œ_£Œobu¡_Å - ( -±h»ad_mu‹x©Œ_t - * -__©Œ -, - -861  -__robu¡Ãss -) - -862 -__THROW - - `__nÚnuÎ - ((1)); - -867 #ià -defšed - -__USE_UNIX98 - || defšed -__USE_XOPEN2K - - -872  - $±h»ad_rwlock_š™ - ( -±h»ad_rwlock_t - * -__»¡riù - -__rwlock -, - -873 -__cÚ¡ - -±h»ad_rwlock©Œ_t - * -__»¡riù - - -874 -__©Œ -è -__THROW - - `__nÚnuÎ - ((1)); - -877  - $±h»ad_rwlock_de¡roy - ( -±h»ad_rwlock_t - * -__rwlock -) - -878 -__THROW - - `__nÚnuÎ - ((1)); - -881  - $±h»ad_rwlock_rdlock - ( -±h»ad_rwlock_t - * -__rwlock -) - -882 -__THROW - - `__nÚnuÎ - ((1)); - -885  - $±h»ad_rwlock_Œyrdlock - ( -±h»ad_rwlock_t - * -__rwlock -) - -886 -__THROW - - `__nÚnuÎ - ((1)); - -888 #ifdeà -__USE_XOPEN2K - - -890  - $±h»ad_rwlock_timedrdlock - ( -±h»ad_rwlock_t - * -__»¡riù - -__rwlock -, - -891 -__cÚ¡ -  -time¥ec - * -__»¡riù - - -892 -__ab¡ime -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -896  - $±h»ad_rwlock_w¾ock - ( -±h»ad_rwlock_t - * -__rwlock -) - -897 -__THROW - - `__nÚnuÎ - ((1)); - -900  - $±h»ad_rwlock_Œyw¾ock - ( -±h»ad_rwlock_t - * -__rwlock -) - -901 -__THROW - - `__nÚnuÎ - ((1)); - -903 #ifdeà -__USE_XOPEN2K - - -905  - $±h»ad_rwlock_timedw¾ock - ( -±h»ad_rwlock_t - * -__»¡riù - -__rwlock -, - -906 -__cÚ¡ -  -time¥ec - * -__»¡riù - - -907 -__ab¡ime -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -911  - $±h»ad_rwlock_uÆock - ( -±h»ad_rwlock_t - * -__rwlock -) - -912 -__THROW - - `__nÚnuÎ - ((1)); - -918  - $±h»ad_rwlock©Œ_š™ - ( -±h»ad_rwlock©Œ_t - * -__©Œ -) - -919 -__THROW - - `__nÚnuÎ - ((1)); - -922  - $±h»ad_rwlock©Œ_de¡roy - ( -±h»ad_rwlock©Œ_t - * -__©Œ -) - -923 -__THROW - - `__nÚnuÎ - ((1)); - -926  - $±h»ad_rwlock©Œ_g‘psh¬ed - ( -__cÚ¡ - -±h»ad_rwlock©Œ_t - * - -927 -__»¡riù - -__©Œ -, - -928 * -__»¡riù - -__psh¬ed -) - -929 -__THROW - - `__nÚnuÎ - ((1, 2)); - -932  - $±h»ad_rwlock©Œ_£sh¬ed - ( -±h»ad_rwlock©Œ_t - * -__©Œ -, - -933  -__psh¬ed -) - -934 -__THROW - - `__nÚnuÎ - ((1)); - -937  - $±h»ad_rwlock©Œ_g‘kšd_Å - ( -__cÚ¡ - -±h»ad_rwlock©Œ_t - * - -938 -__»¡riù - -__©Œ -, - -939 * -__»¡riù - -__´ef -) - -940 -__THROW - - `__nÚnuÎ - ((1, 2)); - -943  - $±h»ad_rwlock©Œ_£tkšd_Å - ( -±h»ad_rwlock©Œ_t - * -__©Œ -, - -944  -__´ef -è -__THROW - - `__nÚnuÎ - ((1)); - -952  - $±h»ad_cÚd_š™ - ( -±h»ad_cÚd_t - * -__»¡riù - -__cÚd -, - -953 -__cÚ¡ - -±h»ad_cÚd©Œ_t - * -__»¡riù - - -954 -__cÚd_©Œ -è -__THROW - - `__nÚnuÎ - ((1)); - -957  - $±h»ad_cÚd_de¡roy - ( -±h»ad_cÚd_t - * -__cÚd -) - -958 -__THROW - - `__nÚnuÎ - ((1)); - -961  - $±h»ad_cÚd_sigÇl - ( -±h»ad_cÚd_t - * -__cÚd -) - -962 -__THROW - - `__nÚnuÎ - ((1)); - -965  - $±h»ad_cÚd_brßdÿ¡ - ( -±h»ad_cÚd_t - * -__cÚd -) - -966 -__THROW - - `__nÚnuÎ - ((1)); - -973  - $±h»ad_cÚd_wa™ - ( -±h»ad_cÚd_t - * -__»¡riù - -__cÚd -, - -974 -±h»ad_mu‹x_t - * -__»¡riù - -__mu‹x -) - -975 - `__nÚnuÎ - ((1, 2)); - -984  - $±h»ad_cÚd_timedwa™ - ( -±h»ad_cÚd_t - * -__»¡riù - -__cÚd -, - -985 -±h»ad_mu‹x_t - * -__»¡riù - -__mu‹x -, - -986 -__cÚ¡ -  -time¥ec - * -__»¡riù - - -987 -__ab¡ime -è - `__nÚnuÎ - ((1, 2, 3)); - -992  - $±h»ad_cÚd©Œ_š™ - ( -±h»ad_cÚd©Œ_t - * -__©Œ -) - -993 -__THROW - - `__nÚnuÎ - ((1)); - -996  - $±h»ad_cÚd©Œ_de¡roy - ( -±h»ad_cÚd©Œ_t - * -__©Œ -) - -997 -__THROW - - `__nÚnuÎ - ((1)); - -1000  - $±h»ad_cÚd©Œ_g‘psh¬ed - ( -__cÚ¡ - -±h»ad_cÚd©Œ_t - * - -1001 -__»¡riù - -__©Œ -, - -1002 * -__»¡riù - -__psh¬ed -) - -1003 -__THROW - - `__nÚnuÎ - ((1, 2)); - -1006  - $±h»ad_cÚd©Œ_£sh¬ed - ( -±h»ad_cÚd©Œ_t - * -__©Œ -, - -1007  -__psh¬ed -è -__THROW - - `__nÚnuÎ - ((1)); - -1009 #ifdeà -__USE_XOPEN2K - - -1011  - $±h»ad_cÚd©Œ_g‘þock - ( -__cÚ¡ - -±h»ad_cÚd©Œ_t - * - -1012 -__»¡riù - -__©Œ -, - -1013 -__þockid_t - * -__»¡riù - -__þock_id -) - -1014 -__THROW - - `__nÚnuÎ - ((1, 2)); - -1017  - $±h»ad_cÚd©Œ_£tþock - ( -±h»ad_cÚd©Œ_t - * -__©Œ -, - -1018 -__þockid_t - -__þock_id -) - -1019 -__THROW - - `__nÚnuÎ - ((1)); - -1023 #ifdeà -__USE_XOPEN2K - - -1028  - $±h»ad_¥š_š™ - ( -±h»ad_¥šlock_t - * -__lock -,  -__psh¬ed -) - -1029 -__THROW - - `__nÚnuÎ - ((1)); - -1032  - $±h»ad_¥š_de¡roy - ( -±h»ad_¥šlock_t - * -__lock -) - -1033 -__THROW - - `__nÚnuÎ - ((1)); - -1036  - $±h»ad_¥š_lock - ( -±h»ad_¥šlock_t - * -__lock -) - -1037 -__THROW - - `__nÚnuÎ - ((1)); - -1040  - $±h»ad_¥š_Œylock - ( -±h»ad_¥šlock_t - * -__lock -) - -1041 -__THROW - - `__nÚnuÎ - ((1)); - -1044  - $±h»ad_¥š_uÆock - ( -±h»ad_¥šlock_t - * -__lock -) - -1045 -__THROW - - `__nÚnuÎ - ((1)); - -1052  - $±h»ad_b¬r›r_š™ - ( -±h»ad_b¬r›r_t - * -__»¡riù - -__b¬r›r -, - -1053 -__cÚ¡ - -±h»ad_b¬r›¿‰r_t - * -__»¡riù - - -1054 -__©Œ -,  -__couÁ -) - -1055 -__THROW - - `__nÚnuÎ - ((1)); - -1058  - $±h»ad_b¬r›r_de¡roy - ( -±h»ad_b¬r›r_t - * -__b¬r›r -) - -1059 -__THROW - - `__nÚnuÎ - ((1)); - -1062  - $±h»ad_b¬r›r_wa™ - ( -±h»ad_b¬r›r_t - * -__b¬r›r -) - -1063 -__THROW - - `__nÚnuÎ - ((1)); - -1067  - $±h»ad_b¬r›¿‰r_š™ - ( -±h»ad_b¬r›¿‰r_t - * -__©Œ -) - -1068 -__THROW - - `__nÚnuÎ - ((1)); - -1071  - $±h»ad_b¬r›¿‰r_de¡roy - ( -±h»ad_b¬r›¿‰r_t - * -__©Œ -) - -1072 -__THROW - - `__nÚnuÎ - ((1)); - -1075  - $±h»ad_b¬r›¿‰r_g‘psh¬ed - ( -__cÚ¡ - -±h»ad_b¬r›¿‰r_t - * - -1076 -__»¡riù - -__©Œ -, - -1077 * -__»¡riù - -__psh¬ed -) - -1078 -__THROW - - `__nÚnuÎ - ((1, 2)); - -1081  - $±h»ad_b¬r›¿‰r_£sh¬ed - ( -±h»ad_b¬r›¿‰r_t - * -__©Œ -, - -1082  -__psh¬ed -) - -1083 -__THROW - - `__nÚnuÎ - ((1)); - -1095  - `±h»ad_key_ü—‹ - ( -±h»ad_key_t - * -__key -, - -1096 (* -__de¡r_funùiÚ -) (*)) - -1097 -__THROW - - `__nÚnuÎ - ((1)); - -1100  - $±h»ad_key_d–‘e - ( -±h»ad_key_t - -__key -è -__THROW -; - -1103 * - $±h»ad_g‘¥ecific - ( -±h»ad_key_t - -__key -è -__THROW -; - -1106  - $±h»ad_£t¥ecific - ( -±h»ad_key_t - -__key -, - -1107 -__cÚ¡ - * -__poš‹r -è -__THROW - ; - -1110 #ifdeà -__USE_XOPEN2K - - -1112  - $±h»ad_g‘ýuþockid - ( -±h»ad_t - -__th»ad_id -, - -1113 -__þockid_t - * -__þock_id -) - -1114 -__THROW - - `__nÚnuÎ - ((2)); - -1129  - `±h»ad_©fÜk - ((* -__´•¬e -) (), - -1130 (* -__·»Á -) (), - -1131 (* -__chžd -è()è -__THROW -; - -1134 #ifdeà -__USE_EXTERN_INLINES - - -1136 -__ex‹º_šlše -  - -1137 - `__NTH - ( - $±h»ad_equ® - ( -±h»ad_t - -__th»ad1 -,…th»ad_ˆ -__th»ad2 -)) - -1139  -__th»ad1 - =ð -__th»ad2 -; - -1140 - } -} - -1143 - g__END_DECLS - - - @/usr/include/stdio.h - -24 #iâdeà -_STDIO_H - - -26 #ià! -defšed - -__Ãed_FILE - && !defšed -__Ãed___FILE - - -27  - #_STDIO_H - 1 - - ) - -28  - ~<ã©u»s.h -> - -30 - g__BEGIN_DECLS - - -32  - #__Ãed_size_t - - - ) - -33  - #__Ãed_NULL - - - ) - -34  - ~<¡ddef.h -> - -36  - ~ - -37  - #__Ãed_FILE - - - ) - -38  - #__Ãed___FILE - - - ) - -42 #ià! -defšed - -__FILE_defšed - && defšed -__Ãed_FILE - - -45  - g_IO_FILE -; - -47 -__BEGIN_NAMESPACE_STD - - -49  -_IO_FILE - - tFILE -; - -50 - g__END_NAMESPACE_STD - - -51 #ià -defšed - -__USE_LARGEFILE64 - || defšed -__USE_SVID - || defšed -__USE_POSIX - \ - -52 || -defšed - - g__USE_BSD - || defšed - g__USE_ISOC99 - || defšed - g__USE_XOPEN - \ - -53 || -defšed - -__USE_POSIX2 - - -54 - $__USING_NAMESPACE_STD -( -FILE -) - -57  - #__FILE_defšed - 1 - - ) - -59 #undeà -__Ãed_FILE - - -62 #ià! -defšed - -____FILE_defšed - && defšed -__Ãed___FILE - - -65  -_IO_FILE - - t__FILE -; - -67  - #____FILE_defšed - 1 - - ) - -69 #undeà -__Ãed___FILE - - -72 #ifdef -_STDIO_H - - -73  - #_STDIO_USES_IOSTREAM - - - ) - -75  - ~ - -77 #ià -defšed - -__USE_XOPEN - || defšed -__USE_XOPEN2K8 - - -78 #ifdeà -__GNUC__ - - -79 #iâdeà -_VA_LIST_DEFINED - - -80  -_G_va_li¡ - - tva_li¡ -; - -81  - #_VA_LIST_DEFINED - - - ) - -84  - ~<¡d¬g.h -> - -88 #ifdeà -__USE_XOPEN2K8 - - -89 #iâdeà -__off_t_defšed - - -90 #iâdeà -__USE_FILE_OFFSET64 - - -91  -__off_t - - toff_t -; - -93  -__off64_t - - toff_t -; - -95  - #__off_t_defšed - - - ) - -97 #ià -defšed - -__USE_LARGEFILE64 - && !defšed -__off64_t_defšed - - -98  -__off64_t - - toff64_t -; - -99  - #__off64_t_defšed - - - ) - -102 #iâdeà -__ssize_t_defšed - - -103  -__ssize_t - - tssize_t -; - -104  - #__ssize_t_defšed - - - ) - -109 -__BEGIN_NAMESPACE_STD - - -110 #iâdeà -__USE_FILE_OFFSET64 - - -111  -_G_åos_t - - tåos_t -; - -113  -_G_åos64_t - - tåos_t -; - -115 -__END_NAMESPACE_STD - - -116 #ifdeà -__USE_LARGEFILE64 - - -117  -_G_åos64_t - - tåos64_t -; - -121  - #_IOFBF - 0 - - ) - -122  - #_IOLBF - 1 - - ) - -123  - #_IONBF - 2 - - ) - -127 #iâdeà -BUFSIZ - - -128  - #BUFSIZ - -_IO_BUFSIZ - - - ) - -134 #iâdeà -EOF - - -135  - #EOF - (-1) - - ) - -141  - #SEEK_SET - 0 - - ) - -142  - #SEEK_CUR - 1 - - ) - -143  - #SEEK_END - 2 - - ) - -146 #ià -defšed - -__USE_SVID - || defšed -__USE_XOPEN - - -148  - #P_tmpdœ - "/tmp" - - ) - -161  - ~ - -165  -_IO_FILE - * -¡dš -; - -166  -_IO_FILE - * -¡dout -; - -167  -_IO_FILE - * -¡d”r -; - -169  - #¡dš - -¡dš - - - ) - -170  - #¡dout - -¡dout - - - ) - -171  - #¡d”r - -¡d”r - - - ) - -173 -__BEGIN_NAMESPACE_STD - - -175  - $»move - ( -__cÚ¡ - * -__fž’ame -è -__THROW -; - -177  - $»Çme - ( -__cÚ¡ - * -__Þd -, __cÚ¡ * -__Ãw -è -__THROW -; - -178 -__END_NAMESPACE_STD - - -180 #ifdeà -__USE_ATFILE - - -182  - $»Çm—t - ( -__Þdfd -, -__cÚ¡ - * -__Þd -,  -__Ãwfd -, - -183 -__cÚ¡ - * -__Ãw -è -__THROW -; - -186 -__BEGIN_NAMESPACE_STD - - -191 #iâdeà -__USE_FILE_OFFSET64 - - -192 -FILE - * - $tmpfže - (è -__wur -; - -194 #ifdeà -__REDIRECT - - -195 -FILE - * - `__REDIRECT - ( -tmpfže -, (), -tmpfže64 -è -__wur -; - -197  - #tmpfže - -tmpfže64 - - - ) - -201 #ifdeà -__USE_LARGEFILE64 - - -202 -FILE - * - $tmpfže64 - (è -__wur -; - -206 * - $tm²am - (* -__s -è -__THROW - -__wur -; - -207 -__END_NAMESPACE_STD - - -209 #ifdeà -__USE_MISC - - -212 * - $tm²am_r - (* -__s -è -__THROW - -__wur -; - -216 #ià -defšed - -__USE_SVID - || defšed -__USE_XOPEN - - -224 * - $‹m²am - ( -__cÚ¡ - * -__dœ -, __cÚ¡ * -__pfx -) - -225 -__THROW - -__©Œibu‹_m®loc__ - -__wur -; - -229 -__BEGIN_NAMESPACE_STD - - -234  - `fþo£ - ( -FILE - * -__¡»am -); - -239  - `fæush - ( -FILE - * -__¡»am -); - -240 -__END_NAMESPACE_STD - - -242 #ifdeà -__USE_MISC - - -249  - `fæush_uÆocked - ( -FILE - * -__¡»am -); - -252 #ifdeà -__USE_GNU - - -259  - `fþo£®l - (); - -263 -__BEGIN_NAMESPACE_STD - - -264 #iâdeà -__USE_FILE_OFFSET64 - - -269 -FILE - * - $fݒ - ( -__cÚ¡ - * -__»¡riù - -__fž’ame -, - -270 -__cÚ¡ - * -__»¡riù - -__modes -è -__wur -; - -275 -FILE - * - $äeݒ - ( -__cÚ¡ - * -__»¡riù - -__fž’ame -, - -276 -__cÚ¡ - * -__»¡riù - -__modes -, - -277 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -279 #ifdeà -__REDIRECT - - -280 -FILE - * - `__REDIRECT - ( -fݒ -, ( -__cÚ¡ - * -__»¡riù - -__fž’ame -, - -281 -__cÚ¡ - * -__»¡riù - -__modes -), -fݒ64 -) - -282 -__wur -; - -283 -FILE - * - `__REDIRECT - ( -äeݒ -, ( -__cÚ¡ - * -__»¡riù - -__fž’ame -, - -284 -__cÚ¡ - * -__»¡riù - -__modes -, - -285 -FILE - * -__»¡riù - -__¡»am -), -äeݒ64 -) - -286 -__wur -; - -288  - #fݒ - -fݒ64 - - - ) - -289  - #äeݒ - -äeݒ64 - - - ) - -292 -__END_NAMESPACE_STD - - -293 #ifdeà -__USE_LARGEFILE64 - - -294 -FILE - * - $fݒ64 - ( -__cÚ¡ - * -__»¡riù - -__fž’ame -, - -295 -__cÚ¡ - * -__»¡riù - -__modes -è -__wur -; - -296 -FILE - * - $äeݒ64 - ( -__cÚ¡ - * -__»¡riù - -__fž’ame -, - -297 -__cÚ¡ - * -__»¡riù - -__modes -, - -298 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -301 #ifdef -__USE_POSIX - - -303 -FILE - * - $fdݒ - ( -__fd -, -__cÚ¡ - * -__modes -è -__THROW - -__wur -; - -306 #ifdef -__USE_GNU - - -309 -FILE - * - $fݒcook› - (* -__»¡riù - -__magic_cook› -, - -310 -__cÚ¡ - * -__»¡riù - -__modes -, - -311 -_IO_cook›_io_funùiÚs_t - -__io_funcs -è -__THROW - -__wur -; - -314 #ifdeà -__USE_XOPEN2K8 - - -316 -FILE - * - $fmemݒ - (* -__s -, -size_t - -__Ën -, -__cÚ¡ - * -__modes -) - -317 -__THROW - -__wur -; - -322 -FILE - * - $ݒ_mem¡»am - (** -__buæoc -, -size_t - * -__siz–oc -è -__THROW - -__wur -; - -326 -__BEGIN_NAMESPACE_STD - - -329  - $£tbuf - ( -FILE - * -__»¡riù - -__¡»am -, *__»¡riù -__buf -è -__THROW -; - -333  - $£tvbuf - ( -FILE - * -__»¡riù - -__¡»am -, *__»¡riù -__buf -, - -334  -__modes -, -size_t - -__n -è -__THROW -; - -335 -__END_NAMESPACE_STD - - -337 #ifdef -__USE_BSD - - -340  - $£tbufãr - ( -FILE - * -__»¡riù - -__¡»am -, *__»¡riù -__buf -, - -341 -size_t - -__size -è -__THROW -; - -344  - $£Žšebuf - ( -FILE - * -__¡»am -è -__THROW -; - -348 -__BEGIN_NAMESPACE_STD - - -353  - `årštf - ( -FILE - * -__»¡riù - -__¡»am -, - -354 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...); - -359  - `´štf - ( -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...); - -361  - $¥rštf - (* -__»¡riù - -__s -, - -362 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...è -__THROW -; - -368  - `vårštf - ( -FILE - * -__»¡riù - -__s -, -__cÚ¡ - *__»¡riù -__fÜm© -, - -369 -_G_va_li¡ - -__¬g -); - -374  - `v´štf - ( -__cÚ¡ - * -__»¡riù - -__fÜm© -, -_G_va_li¡ - -__¬g -); - -376  - $v¥rštf - (* -__»¡riù - -__s -, -__cÚ¡ - *__»¡riù -__fÜm© -, - -377 -_G_va_li¡ - -__¬g -è -__THROW -; - -378 -__END_NAMESPACE_STD - - -380 #ià -defšed - -__USE_BSD - || defšed -__USE_ISOC99 - || defšed -__USE_UNIX98 - - -381 -__BEGIN_NAMESPACE_C99 - - -383  - $¢´štf - (* -__»¡riù - -__s -, -size_t - -__maxËn -, - -384 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...) - -385 -__THROW - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 3, 4))); - -387  - $v¢´štf - (* -__»¡riù - -__s -, -size_t - -__maxËn -, - -388 -__cÚ¡ - * -__»¡riù - -__fÜm© -, -_G_va_li¡ - -__¬g -) - -389 -__THROW - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 3, 0))); - -390 -__END_NAMESPACE_C99 - - -393 #ifdeà -__USE_GNU - - -396  - $va¥rštf - (** -__»¡riù - -__±r -, -__cÚ¡ - *__»¡riù -__f -, - -397 -_G_va_li¡ - -__¬g -) - -398 -__THROW - - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__´štf__ -, 2, 0))è -__wur -; - -399  - $__a¥rštf - (** -__»¡riù - -__±r -, - -400 -__cÚ¡ - * -__»¡riù - -__fmt -, ...) - -401 -__THROW - - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__´štf__ -, 2, 3))è -__wur -; - -402  - $a¥rštf - (** -__»¡riù - -__±r -, - -403 -__cÚ¡ - * -__»¡riù - -__fmt -, ...) - -404 -__THROW - - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__´štf__ -, 2, 3))è -__wur -; - -407 #ifdeà -__USE_XOPEN2K8 - - -414  - $vd´štf - ( -__fd -, -__cÚ¡ - * -__»¡riù - -__fmt -, - -415 -_G_va_li¡ - -__¬g -) - -416 - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 2, 0))); - -417  - $d´štf - ( -__fd -, -__cÚ¡ - * -__»¡riù - -__fmt -, ...) - -418 - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 2, 3))); - -422 -__BEGIN_NAMESPACE_STD - - -427  - $fsÿnf - ( -FILE - * -__»¡riù - -__¡»am -, - -428 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...è -__wur -; - -433  - $sÿnf - ( -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...è -__wur -; - -435  - $ssÿnf - ( -__cÚ¡ - * -__»¡riù - -__s -, - -436 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...è -__THROW -; - -438 #ià -defšed - -__USE_ISOC99 - && !defšed -__USE_GNU - \ - -439 && (! -defšed - -__LDBL_COMPAT - || !defšed -__REDIRECT -) \ - -440 && ( -defšed - -__STRICT_ANSI__ - || defšed -__USE_XOPEN2K -) - -441 #ifdeà -__REDIRECT - - -445  - `__REDIRECT - ( -fsÿnf -, ( -FILE - * -__»¡riù - -__¡»am -, - -446 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...), - -447 -__isoc99_fsÿnf -è -__wur -; - -448  - `__REDIRECT - ( -sÿnf -, ( -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...), - -449 -__isoc99_sÿnf -è -__wur -; - -450  - `__REDIRECT_NTH - ( -ssÿnf -, ( -__cÚ¡ - * -__»¡riù - -__s -, - -451 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...), - -452 -__isoc99_ssÿnf -); - -454  - $__isoc99_fsÿnf - ( -FILE - * -__»¡riù - -__¡»am -, - -455 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...è -__wur -; - -456  - $__isoc99_sÿnf - ( -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...è -__wur -; - -457  - $__isoc99_ssÿnf - ( -__cÚ¡ - * -__»¡riù - -__s -, - -458 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...è -__THROW -; - -459  - #fsÿnf - -__isoc99_fsÿnf - - - ) - -460  - #sÿnf - -__isoc99_sÿnf - - - ) - -461  - #ssÿnf - -__isoc99_ssÿnf - - - ) - -465 -__END_NAMESPACE_STD - - -467 #ifdef -__USE_ISOC99 - - -468 -__BEGIN_NAMESPACE_C99 - - -473  - $vfsÿnf - ( -FILE - * -__»¡riù - -__s -, -__cÚ¡ - *__»¡riù -__fÜm© -, - -474 -_G_va_li¡ - -__¬g -) - -475 - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__sÿnf__ -, 2, 0))è -__wur -; - -481  - $vsÿnf - ( -__cÚ¡ - * -__»¡riù - -__fÜm© -, -_G_va_li¡ - -__¬g -) - -482 - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__sÿnf__ -, 1, 0))è -__wur -; - -485  - $vssÿnf - ( -__cÚ¡ - * -__»¡riù - -__s -, - -486 -__cÚ¡ - * -__»¡riù - -__fÜm© -, -_G_va_li¡ - -__¬g -) - -487 -__THROW - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__sÿnf__ -, 2, 0))); - -489 #ià! -defšed - -__USE_GNU - \ - -490 && (! -defšed - -__LDBL_COMPAT - || !defšed -__REDIRECT -) \ - -491 && ( -defšed - -__STRICT_ANSI__ - || defšed -__USE_XOPEN2K -) - -492 #ifdeà -__REDIRECT - - -496  - `__REDIRECT - ( -vfsÿnf -, - -497 ( -FILE - * -__»¡riù - -__s -, - -498 -__cÚ¡ - * -__»¡riù - -__fÜm© -, -_G_va_li¡ - -__¬g -), - -499 -__isoc99_vfsÿnf -) - -500 - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__sÿnf__ -, 2, 0))è -__wur -; - -501  - `__REDIRECT - ( -vsÿnf -, ( -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -502 -_G_va_li¡ - -__¬g -), -__isoc99_vsÿnf -) - -503 - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__sÿnf__ -, 1, 0))è -__wur -; - -504  - `__REDIRECT_NTH - ( -vssÿnf -, - -505 ( -__cÚ¡ - * -__»¡riù - -__s -, - -506 -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -507 -_G_va_li¡ - -__¬g -), -__isoc99_vssÿnf -) - -508 - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__sÿnf__ -, 2, 0))); - -510  - $__isoc99_vfsÿnf - ( -FILE - * -__»¡riù - -__s -, - -511 -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -512 -_G_va_li¡ - -__¬g -è -__wur -; - -513  - $__isoc99_vsÿnf - ( -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -514 -_G_va_li¡ - -__¬g -è -__wur -; - -515  - $__isoc99_vssÿnf - ( -__cÚ¡ - * -__»¡riù - -__s -, - -516 -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -517 -_G_va_li¡ - -__¬g -è -__THROW -; - -518  - #vfsÿnf - -__isoc99_vfsÿnf - - - ) - -519  - #vsÿnf - -__isoc99_vsÿnf - - - ) - -520  - #vssÿnf - -__isoc99_vssÿnf - - - ) - -524 -__END_NAMESPACE_C99 - - -528 -__BEGIN_NAMESPACE_STD - - -533  - `fg‘c - ( -FILE - * -__¡»am -); - -534  - `g‘c - ( -FILE - * -__¡»am -); - -540  - `g‘ch¬ - (); - -541 -__END_NAMESPACE_STD - - -545  - #g‘c -( -_å -è - `_IO_g‘c - (_å) - - ) - -547 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -552  - `g‘c_uÆocked - ( -FILE - * -__¡»am -); - -553  - `g‘ch¬_uÆocked - (); - -556 #ifdeà -__USE_MISC - - -563  - `fg‘c_uÆocked - ( -FILE - * -__¡»am -); - -567 -__BEGIN_NAMESPACE_STD - - -575  - `åutc - ( -__c -, -FILE - * -__¡»am -); - -576  - `putc - ( -__c -, -FILE - * -__¡»am -); - -582  - `putch¬ - ( -__c -); - -583 -__END_NAMESPACE_STD - - -587  - #putc -( -_ch -, -_å -è - `_IO_putc - (_ch, _å) - - ) - -589 #ifdeà -__USE_MISC - - -596  - `åutc_uÆocked - ( -__c -, -FILE - * -__¡»am -); - -599 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -604  - `putc_uÆocked - ( -__c -, -FILE - * -__¡»am -); - -605  - `putch¬_uÆocked - ( -__c -); - -609 #ià -defšed - -__USE_SVID - || defšed -__USE_MISC - \ - -610 || ( -defšed - -__USE_XOPEN - && !defšed -__USE_XOPEN2K -) - -612  - `g‘w - ( -FILE - * -__¡»am -); - -615  - `putw - ( -__w -, -FILE - * -__¡»am -); - -619 -__BEGIN_NAMESPACE_STD - - -624 * - $fg‘s - (* -__»¡riù - -__s -,  -__n -, -FILE - *__»¡riù -__¡»am -) - -625 -__wur -; - -632 * - $g‘s - (* -__s -è -__wur -; - -633 -__END_NAMESPACE_STD - - -635 #ifdeà -__USE_GNU - - -642 * - $fg‘s_uÆocked - (* -__»¡riù - -__s -,  -__n -, - -643 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -647 #ifdef -__USE_XOPEN2K8 - - -658 -_IO_ssize_t - - $__g‘d–im - (** -__»¡riù - -__lš•Œ -, - -659 -size_t - * -__»¡riù - -__n -,  -__d–im™” -, - -660 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -661 -_IO_ssize_t - - $g‘d–im - (** -__»¡riù - -__lš•Œ -, - -662 -size_t - * -__»¡riù - -__n -,  -__d–im™” -, - -663 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -671 -_IO_ssize_t - - $g‘lše - (** -__»¡riù - -__lš•Œ -, - -672 -size_t - * -__»¡riù - -__n -, - -673 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -677 -__BEGIN_NAMESPACE_STD - - -682  - `åuts - ( -__cÚ¡ - * -__»¡riù - -__s -, -FILE - *__»¡riù -__¡»am -); - -688  - `puts - ( -__cÚ¡ - * -__s -); - -695  - `ung‘c - ( -__c -, -FILE - * -__¡»am -); - -702 -size_t - - $ä—d - (* -__»¡riù - -__±r -, -size_t - -__size -, - -703 -size_t - -__n -, -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -708 -size_t - - `fwr™e - ( -__cÚ¡ - * -__»¡riù - -__±r -, size_ˆ -__size -, - -709 -size_t - -__n -, -FILE - * -__»¡riù - -__s -); - -710 -__END_NAMESPACE_STD - - -712 #ifdeà -__USE_GNU - - -719  - `åuts_uÆocked - ( -__cÚ¡ - * -__»¡riù - -__s -, - -720 -FILE - * -__»¡riù - -__¡»am -); - -723 #ifdeà -__USE_MISC - - -730 -size_t - - $ä—d_uÆocked - (* -__»¡riù - -__±r -, -size_t - -__size -, - -731 -size_t - -__n -, -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -732 -size_t - - `fwr™e_uÆocked - ( -__cÚ¡ - * -__»¡riù - -__±r -, size_ˆ -__size -, - -733 -size_t - -__n -, -FILE - * -__»¡riù - -__¡»am -); - -737 -__BEGIN_NAMESPACE_STD - - -742  - `f£ek - ( -FILE - * -__¡»am -,  -__off -,  -__wh’û -); - -747  - $á–l - ( -FILE - * -__¡»am -è -__wur -; - -752  - `»wšd - ( -FILE - * -__¡»am -); - -753 -__END_NAMESPACE_STD - - -760 #ià -defšed - -__USE_LARGEFILE - || defšed -__USE_XOPEN2K - - -761 #iâdeà -__USE_FILE_OFFSET64 - - -766  - `f£eko - ( -FILE - * -__¡»am -, -__off_t - -__off -,  -__wh’û -); - -771 -__off_t - - $á–lo - ( -FILE - * -__¡»am -è -__wur -; - -773 #ifdeà -__REDIRECT - - -774  - `__REDIRECT - ( -f£eko -, - -775 ( -FILE - * -__¡»am -, -__off64_t - -__off -,  -__wh’û -), - -776 -f£eko64 -); - -777 -__off64_t - - `__REDIRECT - ( -á–lo -, ( -FILE - * -__¡»am -), -á–lo64 -); - -779  - #f£eko - -f£eko64 - - - ) - -780  - #á–lo - -á–lo64 - - - ) - -785 -__BEGIN_NAMESPACE_STD - - -786 #iâdeà -__USE_FILE_OFFSET64 - - -791  - `fg‘pos - ( -FILE - * -__»¡riù - -__¡»am -, -åos_t - *__»¡riù -__pos -); - -796  - `f£os - ( -FILE - * -__¡»am -, -__cÚ¡ - -åos_t - * -__pos -); - -798 #ifdeà -__REDIRECT - - -799  - `__REDIRECT - ( -fg‘pos -, ( -FILE - * -__»¡riù - -__¡»am -, - -800 -åos_t - * -__»¡riù - -__pos -), -fg‘pos64 -); - -801  - `__REDIRECT - ( -f£os -, - -802 ( -FILE - * -__¡»am -, -__cÚ¡ - -åos_t - * -__pos -), -f£os64 -); - -804  - #fg‘pos - -fg‘pos64 - - - ) - -805  - #f£os - -f£os64 - - - ) - -808 -__END_NAMESPACE_STD - - -810 #ifdeà -__USE_LARGEFILE64 - - -811  - `f£eko64 - ( -FILE - * -__¡»am -, -__off64_t - -__off -,  -__wh’û -); - -812 -__off64_t - - $á–lo64 - ( -FILE - * -__¡»am -è -__wur -; - -813  - `fg‘pos64 - ( -FILE - * -__»¡riù - -__¡»am -, -åos64_t - *__»¡riù -__pos -); - -814  - `f£os64 - ( -FILE - * -__¡»am -, -__cÚ¡ - -åos64_t - * -__pos -); - -817 -__BEGIN_NAMESPACE_STD - - -819  - $þ—»¼ - ( -FILE - * -__¡»am -è -__THROW -; - -821  - $ãof - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -823  - $ã¼Ü - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -824 -__END_NAMESPACE_STD - - -826 #ifdeà -__USE_MISC - - -828  - $þ—»¼_uÆocked - ( -FILE - * -__¡»am -è -__THROW -; - -829  - $ãof_uÆocked - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -830  - $ã¼Ü_uÆocked - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -834 -__BEGIN_NAMESPACE_STD - - -839  - `³¼Ü - ( -__cÚ¡ - * -__s -); - -840 -__END_NAMESPACE_STD - - -846  - ~ - -849 #ifdef -__USE_POSIX - - -851  - $fž’o - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -854 #ifdeà -__USE_MISC - - -856  - $fž’o_uÆocked - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -860 #ià( -defšed - -__USE_POSIX2 - || defšed -__USE_SVID - || defšed -__USE_BSD - || \ - -861 -defšed - -__USE_MISC -) - -866 -FILE - * - $pݒ - ( -__cÚ¡ - * -__commªd -, __cÚ¡ * -__modes -è -__wur -; - -872  - `pþo£ - ( -FILE - * -__¡»am -); - -876 #ifdef -__USE_POSIX - - -878 * - $ù”mid - (* -__s -è -__THROW -; - -882 #ifdeà -__USE_XOPEN - - -884 * - `cu£rid - (* -__s -); - -888 #ifdef -__USE_GNU - - -889  -ob¡ack -; - -892  - $ob¡ack_´štf - ( -ob¡ack - * -__»¡riù - -__ob¡ack -, - -893 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...) - -894 -__THROW - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 2, 3))); - -895  - $ob¡ack_v´štf - ( -ob¡ack - * -__»¡riù - -__ob¡ack -, - -896 -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -897 -_G_va_li¡ - -__¬gs -) - -898 -__THROW - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 2, 0))); - -902 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -906  - $æockfže - ( -FILE - * -__¡»am -è -__THROW -; - -910  - $árylockfže - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -913  - $fuÆockfže - ( -FILE - * -__¡»am -è -__THROW -; - -916 #ià -defšed - -__USE_XOPEN - && !defšed -__USE_XOPEN2K - && !defšed -__USE_GNU - - -920  - #__Ãed_g‘Ýt - - - ) - -921  - ~ - -926 #ifdeà -__USE_EXTERN_INLINES - - -927  - ~ - -929 #ià -__USE_FORTIFY_LEVEL - > 0 && -defšed - -__ex‹º_®ways_šlše - - -930  - ~ - -932 #ifdeà -__LDBL_COMPAT - - -933  - ~ - -936 -__END_DECLS - - - @/usr/include/stdlib.h - -23 #iâdef -_STDLIB_H - - -25  - ~<ã©u»s.h -> - -28  - #__Ãed_size_t - - - ) - -29 #iâdeà -__Ãed_m®loc_ªd_ÿÎoc - - -30  - #__Ãed_wch¬_t - - - ) - -31  - #__Ãed_NULL - - - ) - -33  - ~<¡ddef.h -> - -35 - g__BEGIN_DECLS - - -37 #iâdeà -__Ãed_m®loc_ªd_ÿÎoc - - -38  - #_STDLIB_H - 1 - - ) - -40 #ià( -defšed - -__USE_XOPEN - || defšed -__USE_XOPEN2K8 -è&& !defšed -_SYS_WAIT_H - - -42  - ~ - -43  - ~ - -45 #ifdeà -__USE_BSD - - -50 #ià -defšed - -__GNUC__ - && !defšed -__ýlu¥lus - - -51  - #__WAIT_INT -( -¡©us -) \ - -52 ( - `__ex‹nsiÚ__ - (((uniÚ { - `__ty³of -( -¡©us -è -__š -;  -__i -; }) \ - -53 { . -__š - = ( -¡©us -è}). -__i -)) - - ) - -55  - #__WAIT_INT -( -¡©us -è(*(*è&(¡©us)) - - ) - -63 #ià! -defšed - -__GNUC__ - || __GNUC__ < 2 || defšed -__ýlu¥lus - - -64  - #__WAIT_STATUS - * - - ) - -65  - #__WAIT_STATUS_DEFN - * - - ) - -70  -wa™ - * - m__u±r -; - -71 * - m__Œ -; - -72 } - t__WAIT_STATUS - - t__©Œibu‹__ - (( - t__Œª¥¬’t_uniÚ__ -)); - -73  - #__WAIT_STATUS_DEFN - * - - ) - -78  - #__WAIT_INT -( -¡©us -è(¡©us) - - ) - -79  - #__WAIT_STATUS - * - - ) - -80  - #__WAIT_STATUS_DEFN - * - - ) - -85  - #WEXITSTATUS -( -¡©us -è - `__WEXITSTATUS - ( - `__WAIT_INT - (¡©us)) - - ) - -86  - #WTERMSIG -( -¡©us -è - `__WTERMSIG - ( - `__WAIT_INT - (¡©us)) - - ) - -87  - #WSTOPSIG -( -¡©us -è - `__WSTOPSIG - ( - `__WAIT_INT - (¡©us)) - - ) - -88  - #WIFEXITED -( -¡©us -è - `__WIFEXITED - ( - `__WAIT_INT - (¡©us)) - - ) - -89  - #WIFSIGNALED -( -¡©us -è - `__WIFSIGNALED - ( - `__WAIT_INT - (¡©us)) - - ) - -90  - #WIFSTOPPED -( -¡©us -è - `__WIFSTOPPED - ( - `__WAIT_INT - (¡©us)) - - ) - -91 #ifdeà -__WIFCONTINUED - - -92  - #WIFCONTINUED -( -¡©us -è - `__WIFCONTINUED - ( - `__WAIT_INT - (¡©us)) - - ) - -96 -__BEGIN_NAMESPACE_STD - - -100  - mquÙ -; - -101  - m»m -; - -102 } - tdiv_t -; - -105 #iâdeà -__ldiv_t_defšed - - -108  - mquÙ -; - -109  - m»m -; - -110 } - tldiv_t -; - -111  - #__ldiv_t_defšed - 1 - - ) - -113 - g__END_NAMESPACE_STD - - -115 #ià -defšed - -__USE_ISOC99 - && !defšed -__Îdiv_t_defšed - - -116 -__BEGIN_NAMESPACE_C99 - - -118 -__ex‹nsiÚ__ - struct - -120  - mquÙ -; - -121  - m»m -; - -122 } - tÎdiv_t -; - -123  - #__Îdiv_t_defšed - 1 - - ) - -124 - g__END_NAMESPACE_C99 - - -129  - #RAND_MAX - 2147483647 - - ) - -134  - #EXIT_FAILURE - 1 - - ) - -135  - #EXIT_SUCCESS - 0 - - ) - -139  - #MB_CUR_MAX - ( - `__ùy³_g‘_mb_cur_max - ()) - - ) - -140 -size_t - - $__ùy³_g‘_mb_cur_max - (è -__THROW - -__wur -; - -143 -__BEGIN_NAMESPACE_STD - - -145  - $©of - ( -__cÚ¡ - * -__Ō -) - -146 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)è -__wur -; - -148  - $©oi - ( -__cÚ¡ - * -__Ō -) - -149 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)è -__wur -; - -151  - $©Þ - ( -__cÚ¡ - * -__Ō -) - -152 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)è -__wur -; - -153 -__END_NAMESPACE_STD - - -155 #ià -defšed - -__USE_ISOC99 - || (defšed -__GLIBC_HAVE_LONG_LONG - && defšed -__USE_MISC -) - -156 -__BEGIN_NAMESPACE_C99 - - -158 -__ex‹nsiÚ__ -  - $©Þl - ( -__cÚ¡ - * -__Ō -) - -159 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)è -__wur -; - -160 -__END_NAMESPACE_C99 - - -163 -__BEGIN_NAMESPACE_STD - - -165  - $¡¹od - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -166 ** -__»¡riù - -__’d±r -) - -167 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -168 -__END_NAMESPACE_STD - - -170 #ifdef -__USE_ISOC99 - - -171 -__BEGIN_NAMESPACE_C99 - - -173  - $¡¹of - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -174 ** -__»¡riù - -__’d±r -è -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -176  - $¡¹Þd - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -177 ** -__»¡riù - -__’d±r -) - -178 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -179 -__END_NAMESPACE_C99 - - -182 -__BEGIN_NAMESPACE_STD - - -184  - $¡¹Þ - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -185 ** -__»¡riù - -__’d±r -,  -__ba£ -) - -186 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -188  - $¡¹oul - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -189 ** -__»¡riù - -__’d±r -,  -__ba£ -) - -190 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -191 -__END_NAMESPACE_STD - - -193 #ià -defšed - -__GLIBC_HAVE_LONG_LONG - && defšed -__USE_BSD - - -195 -__ex‹nsiÚ__ - - -196  - $¡¹oq - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -197 ** -__»¡riù - -__’d±r -,  -__ba£ -) - -198 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -200 -__ex‹nsiÚ__ - - -201  - $¡¹ouq - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -202 ** -__»¡riù - -__’d±r -,  -__ba£ -) - -203 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -206 #ià -defšed - -__USE_ISOC99 - || (defšed -__GLIBC_HAVE_LONG_LONG - && defšed -__USE_MISC -) - -207 -__BEGIN_NAMESPACE_C99 - - -209 -__ex‹nsiÚ__ - - -210  - $¡¹Þl - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -211 ** -__»¡riù - -__’d±r -,  -__ba£ -) - -212 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -214 -__ex‹nsiÚ__ - - -215  - $¡¹ouÎ - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -216 ** -__»¡riù - -__’d±r -,  -__ba£ -) - -217 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -218 -__END_NAMESPACE_C99 - - -222 #ifdeà -__USE_GNU - - -236  - ~ - -240  - $¡¹Þ_l - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -241 ** -__»¡riù - -__’d±r -,  -__ba£ -, - -242 -__loÿË_t - -__loc -è -__THROW - - `__nÚnuÎ - ((1, 4)è -__wur -; - -244  - $¡¹oul_l - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -245 ** -__»¡riù - -__’d±r -, - -246  -__ba£ -, -__loÿË_t - -__loc -) - -247 -__THROW - - `__nÚnuÎ - ((1, 4)è -__wur -; - -249 -__ex‹nsiÚ__ - - -250  - $¡¹Þl_l - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -251 ** -__»¡riù - -__’d±r -,  -__ba£ -, - -252 -__loÿË_t - -__loc -) - -253 -__THROW - - `__nÚnuÎ - ((1, 4)è -__wur -; - -255 -__ex‹nsiÚ__ - - -256  - $¡¹ouÎ_l - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -257 ** -__»¡riù - -__’d±r -, - -258  -__ba£ -, -__loÿË_t - -__loc -) - -259 -__THROW - - `__nÚnuÎ - ((1, 4)è -__wur -; - -261  - $¡¹od_l - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -262 ** -__»¡riù - -__’d±r -, -__loÿË_t - -__loc -) - -263 -__THROW - - `__nÚnuÎ - ((1, 3)è -__wur -; - -265  - $¡¹of_l - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -266 ** -__»¡riù - -__’d±r -, -__loÿË_t - -__loc -) - -267 -__THROW - - `__nÚnuÎ - ((1, 3)è -__wur -; - -269  - $¡¹Þd_l - ( -__cÚ¡ - * -__»¡riù - -__Ō -, - -270 ** -__»¡riù - -__’d±r -, - -271 -__loÿË_t - -__loc -) - -272 -__THROW - - `__nÚnuÎ - ((1, 3)è -__wur -; - -276 #ifdeà -__USE_EXTERN_INLINES - - -277 -__BEGIN_NAMESPACE_STD - - -278 -__ex‹º_šlše -  - -279 - `__NTH - ( - $©of - ( -__cÚ¡ - * -__Ō -)) - -281  - `¡¹od - ( -__Ō -, (**è -NULL -); - -282 - } -} - -283 -__ex‹º_šlše -  - -284 -__NTH - ( - $©oi - ( -__cÚ¡ - * -__Ō -)) - -286  (è - `¡¹Þ - ( -__Ō -, (**è -NULL -, 10); - -287 - } -} - -288 -__ex‹º_šlše -  - -289 -__NTH - ( - $©Þ - ( -__cÚ¡ - * -__Ō -)) - -291  - `¡¹Þ - ( -__Ō -, (**è -NULL -, 10); - -292 - } -} - -293 - g__END_NAMESPACE_STD - - -295 #ià -defšed - -__USE_MISC - || defšed -__USE_ISOC99 - - -296 -__BEGIN_NAMESPACE_C99 - - -297 -__ex‹nsiÚ__ - -__ex‹º_šlše -  - -298 -__NTH - ( - $©Þl - ( -__cÚ¡ - * -__Ō -)) - -300  - `¡¹Þl - ( -__Ō -, (**è -NULL -, 10); - -301 - } -} - -302 - g__END_NAMESPACE_C99 - - -307 #ià -defšed - -__USE_SVID - || defšed -__USE_XOPEN_EXTENDED - - -311 * - $l64a - ( -__n -è -__THROW - -__wur -; - -314  - $a64l - ( -__cÚ¡ - * -__s -) - -315 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)è -__wur -; - -319 #ià -defšed - -__USE_SVID - || defšed -__USE_XOPEN_EXTENDED - || defšed -__USE_BSD - - -320  - ~ - -327  - $¿ndom - (è -__THROW -; - -330  - $¤ªdom - ( -__£ed -è -__THROW -; - -336 * - $š™¡©e - ( -__£ed -, * -__¡©ebuf -, - -337 -size_t - -__¡©–’ -è -__THROW - - `__nÚnuÎ - ((2)); - -341 * - $£t¡©e - (* -__¡©ebuf -è -__THROW - - `__nÚnuÎ - ((1)); - -344 #ifdeà -__USE_MISC - - -349  - s¿ndom_d©a - - -351 -št32_t - * -åŒ -; - -352 -št32_t - * -½Œ -; - -353 -št32_t - * -¡©e -; - -354  -¿nd_ty³ -; - -355  -¿nd_deg -; - -356  -¿nd_£p -; - -357 -št32_t - * -’d_±r -; - -360  - $¿ndom_r - ( -¿ndom_d©a - * -__»¡riù - -__buf -, - -361 -št32_t - * -__»¡riù - -__»suÉ -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -363  - $¤ªdom_r - ( -__£ed -,  -¿ndom_d©a - * -__buf -) - -364 -__THROW - - `__nÚnuÎ - ((2)); - -366  - $š™¡©e_r - ( -__£ed -, * -__»¡riù - -__¡©ebuf -, - -367 -size_t - -__¡©–’ -, - -368  -¿ndom_d©a - * -__»¡riù - -__buf -) - -369 -__THROW - - `__nÚnuÎ - ((2, 4)); - -371  - $£t¡©e_r - (* -__»¡riù - -__¡©ebuf -, - -372  -¿ndom_d©a - * -__»¡riù - -__buf -) - -373 -__THROW - - `__nÚnuÎ - ((1, 2)); - -378 -__BEGIN_NAMESPACE_STD - - -380  - $¿nd - (è -__THROW -; - -382  - $¤ªd - ( -__£ed -è -__THROW -; - -383 -__END_NAMESPACE_STD - - -385 #ifdeà -__USE_POSIX - - -387  - $¿nd_r - (* -__£ed -è -__THROW -; - -391 #ià -defšed - -__USE_SVID - || defšed -__USE_XOPEN - - -395  - $d¿nd48 - (è -__THROW -; - -396  - $”ªd48 - ( -__xsubi -[3]è -__THROW - - `__nÚnuÎ - ((1)); - -399  - $̪d48 - (è -__THROW -; - -400  - $Īd48 - ( -__xsubi -[3]) - -401 -__THROW - - `__nÚnuÎ - ((1)); - -404  - $m¿nd48 - (è -__THROW -; - -405  - $j¿nd48 - ( -__xsubi -[3]) - -406 -__THROW - - `__nÚnuÎ - ((1)); - -409  - $¤ªd48 - ( -__£edv® -è -__THROW -; - -410 * - $£ed48 - ( -__£ed16v -[3]) - -411 -__THROW - - `__nÚnuÎ - ((1)); - -412  - $lcÚg48 - ( -__·¿m -[7]è -__THROW - - `__nÚnuÎ - ((1)); - -414 #ifdeà -__USE_MISC - - -418  - sd¿nd48_d©a - - -420  -__x -[3]; - -421  -__Þd_x -[3]; - -422  -__c -; - -423  -__š™ -; - -424  -__a -; - -428  - $d¿nd48_r - ( -d¿nd48_d©a - * -__»¡riù - -__bufãr -, - -429 * -__»¡riù - -__»suÉ -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -430  - $”ªd48_r - ( -__xsubi -[3], - -431  -d¿nd48_d©a - * -__»¡riù - -__bufãr -, - -432 * -__»¡riù - -__»suÉ -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -435  - $̪d48_r - ( -d¿nd48_d©a - * -__»¡riù - -__bufãr -, - -436 * -__»¡riù - -__»suÉ -) - -437 -__THROW - - `__nÚnuÎ - ((1, 2)); - -438  - $Īd48_r - ( -__xsubi -[3], - -439  -d¿nd48_d©a - * -__»¡riù - -__bufãr -, - -440 * -__»¡riù - -__»suÉ -) - -441 -__THROW - - `__nÚnuÎ - ((1, 2)); - -444  - $m¿nd48_r - ( -d¿nd48_d©a - * -__»¡riù - -__bufãr -, - -445 * -__»¡riù - -__»suÉ -) - -446 -__THROW - - `__nÚnuÎ - ((1, 2)); - -447  - $j¿nd48_r - ( -__xsubi -[3], - -448  -d¿nd48_d©a - * -__»¡riù - -__bufãr -, - -449 * -__»¡riù - -__»suÉ -) - -450 -__THROW - - `__nÚnuÎ - ((1, 2)); - -453  - $¤ªd48_r - ( -__£edv® -,  -d¿nd48_d©a - * -__bufãr -) - -454 -__THROW - - `__nÚnuÎ - ((2)); - -456  - $£ed48_r - ( -__£ed16v -[3], - -457  -d¿nd48_d©a - * -__bufãr -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -459  - $lcÚg48_r - ( -__·¿m -[7], - -460  -d¿nd48_d©a - * -__bufãr -) - -461 -__THROW - - `__nÚnuÎ - ((1, 2)); - -467 #iâdeà -__m®loc_ªd_ÿÎoc_defšed - - -468  - #__m®loc_ªd_ÿÎoc_defšed - - - ) - -469 -__BEGIN_NAMESPACE_STD - - -471 * - $m®loc - ( -size_t - -__size -è -__THROW - -__©Œibu‹_m®loc__ - -__wur -; - -473 * - $ÿÎoc - ( -size_t - -__nmemb -, size_ˆ -__size -) - -474 -__THROW - -__©Œibu‹_m®loc__ - -__wur -; - -475 -__END_NAMESPACE_STD - - -478 #iâdeà -__Ãed_m®loc_ªd_ÿÎoc - - -479 -__BEGIN_NAMESPACE_STD - - -485 * - $»®loc - (* -__±r -, -size_t - -__size -) - -486 -__THROW - -__©Œibu‹_w¬n_unu£d_»suÉ__ -; - -488  - $ä“ - (* -__±r -è -__THROW -; - -489 -__END_NAMESPACE_STD - - -491 #ifdef -__USE_MISC - - -493  - $cä“ - (* -__±r -è -__THROW -; - -496 #ià -defšed - -__USE_GNU - || defšed -__USE_BSD - || defšed -__USE_MISC - - -497  - ~<®loÿ.h -> - -500 #ià( -defšed - -__USE_XOPEN_EXTENDED - && !defšed -__USE_XOPEN2K -) \ - -501 || -defšed - -__USE_BSD - - -503 * - $v®loc - ( -size_t - -__size -è -__THROW - -__©Œibu‹_m®loc__ - -__wur -; - -506 #ifdeà -__USE_XOPEN2K - - -508  - $posix_mem®ign - (** -__mem±r -, -size_t - -__®ignm’t -, size_ˆ -__size -) - -509 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -512 -__BEGIN_NAMESPACE_STD - - -514  - $abÜt - (è -__THROW - - `__©Œibu‹__ - (( -__nܑuº__ -)); - -518  - `©ex™ - ((* -__func -è()è -__THROW - - `__nÚnuÎ - ((1)); - -520 #ifdeà -__USE_GNU - - -524 #ifdeà -__ýlu¥lus - - -525 "C++"  - `©_quick_ex™ - ((* -__func -) ()) - -526 -__THROW - - `__asm - ("©_quick_ex™"è - `__nÚnuÎ - ((1)); - -528  - `©_quick_ex™ - ((* -__func -è()è -__THROW - - `__nÚnuÎ - ((1)); - -531 -__END_NAMESPACE_STD - - -533 #ifdef -__USE_MISC - - -536  - `Ú_ex™ - ((* -__func -è( -__¡©us -, * -__¬g -), *__arg) - -537 -__THROW - - `__nÚnuÎ - ((1)); - -540 -__BEGIN_NAMESPACE_STD - - -544  - $ex™ - ( -__¡©us -è -__THROW - - `__©Œibu‹__ - (( -__nܑuº__ -)); - -546 #ifdeà -__USE_GNU - - -552  - $quick_ex™ - ( -__¡©us -è -__THROW - - `__©Œibu‹__ - (( -__nܑuº__ -)); - -554 -__END_NAMESPACE_STD - - -556 #ifdeà -__USE_ISOC99 - - -557 -__BEGIN_NAMESPACE_C99 - - -560  - $_Ex™ - ( -__¡©us -è -__THROW - - `__©Œibu‹__ - (( -__nܑuº__ -)); - -561 -__END_NAMESPACE_C99 - - -565 -__BEGIN_NAMESPACE_STD - - -567 * - $g‘’v - ( -__cÚ¡ - * -__Çme -è -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -568 -__END_NAMESPACE_STD - - -572 * - $__£cu»_g‘’v - ( -__cÚ¡ - * -__Çme -) - -573 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -575 #ià -defšed - -__USE_SVID - || defšed -__USE_XOPEN - - -579  - $pu‹nv - (* -__¡ršg -è -__THROW - - `__nÚnuÎ - ((1)); - -582 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN2K - - -585  - $£‹nv - ( -__cÚ¡ - * -__Çme -, __cÚ¡ * -__v®ue -,  -__»¶aû -) - -586 -__THROW - - `__nÚnuÎ - ((2)); - -589  - $un£‹nv - ( -__cÚ¡ - * -__Çme -è -__THROW - - `__nÚnuÎ - ((1)); - -592 #ifdef -__USE_MISC - - -596  - $þ—»nv - (è -__THROW -; - -600 #ià -defšed - -__USE_MISC - \ - -601 || ( -defšed - -__USE_XOPEN_EXTENDED - && !defšed -__USE_XOPEN2K -) - -606 * - $mk‹mp - (* -__‹m¶©e -è -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -609 #ià -defšed - -__USE_MISC - || defšed -__USE_XOPEN_EXTENDED - \ - -610 || -defšed - -__USE_XOPEN2K8 - - -619 #iâdeà -__USE_FILE_OFFSET64 - - -620  - $mk¡emp - (* -__‹m¶©e -è - `__nÚnuÎ - ((1)è -__wur -; - -622 #ifdeà -__REDIRECT - - -623  - `__REDIRECT - ( -mk¡emp -, (* -__‹m¶©e -), -mk¡emp64 -) - -624 - `__nÚnuÎ - ((1)è -__wur -; - -626  - #mk¡emp - -mk¡emp64 - - - ) - -629 #ifdeà -__USE_LARGEFILE64 - - -630  - $mk¡emp64 - (* -__‹m¶©e -è - `__nÚnuÎ - ((1)è -__wur -; - -634 #ifdeà -__USE_MISC - - -641 #iâdeà -__USE_FILE_OFFSET64 - - -642  - $mk¡emps - (* -__‹m¶©e -,  -__suffixËn -è - `__nÚnuÎ - ((1)è -__wur -; - -644 #ifdeà -__REDIRECT - - -645  - `__REDIRECT - ( -mk¡emps -, (* -__‹m¶©e -,  -__suffixËn -), - -646 -mk¡emps64 -è - `__nÚnuÎ - ((1)è -__wur -; - -648  - #mk¡emps - -mk¡emps64 - - - ) - -651 #ifdeà -__USE_LARGEFILE64 - - -652  - $mk¡emps64 - (* -__‹m¶©e -,  -__suffixËn -) - -653 - `__nÚnuÎ - ((1)è -__wur -; - -657 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN2K8 - - -663 * - $mkd‹mp - (* -__‹m¶©e -è -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -666 #ifdeà -__USE_GNU - - -673 #iâdeà -__USE_FILE_OFFSET64 - - -674  - $mko¡emp - (* -__‹m¶©e -,  -__æags -è - `__nÚnuÎ - ((1)è -__wur -; - -676 #ifdeà -__REDIRECT - - -677  - `__REDIRECT - ( -mko¡emp -, (* -__‹m¶©e -,  -__æags -), -mko¡emp64 -) - -678 - `__nÚnuÎ - ((1)è -__wur -; - -680  - #mko¡emp - -mko¡emp64 - - - ) - -683 #ifdeà -__USE_LARGEFILE64 - - -684  - $mko¡emp64 - (* -__‹m¶©e -,  -__æags -è - `__nÚnuÎ - ((1)è -__wur -; - -693 #iâdeà -__USE_FILE_OFFSET64 - - -694  - $mko¡emps - (* -__‹m¶©e -,  -__suffixËn -,  -__æags -) - -695 - `__nÚnuÎ - ((1)è -__wur -; - -697 #ifdeà -__REDIRECT - - -698  - `__REDIRECT - ( -mko¡emps -, (* -__‹m¶©e -,  -__suffixËn -, - -699  -__æags -), -mko¡emps64 -) - -700 - `__nÚnuÎ - ((1)è -__wur -; - -702  - #mko¡emps - -mko¡emps64 - - - ) - -705 #ifdeà -__USE_LARGEFILE64 - - -706  - $mko¡emps64 - (* -__‹m¶©e -,  -__suffixËn -,  -__æags -) - -707 - `__nÚnuÎ - ((1)è -__wur -; - -712 -__BEGIN_NAMESPACE_STD - - -717  - $sy¡em - ( -__cÚ¡ - * -__commªd -è -__wur -; - -718 -__END_NAMESPACE_STD - - -721 #ifdef -__USE_GNU - - -724 * - $ÿnÚiÿlize_fže_Çme - ( -__cÚ¡ - * -__Çme -) - -725 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -728 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - - -734 * - $»®·th - ( -__cÚ¡ - * -__»¡riù - -__Çme -, - -735 * -__»¡riù - -__»sÞved -è -__THROW - -__wur -; - -740 #iâdeà -__COMPAR_FN_T - - -741  - #__COMPAR_FN_T - - - ) - -742 (* - t__com·r_â_t -è( - t__cÚ¡ - *, __const *); - -744 #ifdef -__USE_GNU - - -745  -__com·r_â_t - - tcom·risÚ_â_t -; - -748 #ifdeà -__USE_GNU - - -749 (* - t__com·r_d_â_t -è( - t__cÚ¡ - *, __const *, *); - -752 -__BEGIN_NAMESPACE_STD - - -755 * - $b£¬ch - ( -__cÚ¡ - * -__key -, __cÚ¡ * -__ba£ -, - -756 -size_t - -__nmemb -, size_ˆ -__size -, -__com·r_â_t - -__com·r -) - -757 - `__nÚnuÎ - ((1, 2, 5)è -__wur -; - -761  - $qsÜt - (* -__ba£ -, -size_t - -__nmemb -, size_ˆ -__size -, - -762 -__com·r_â_t - -__com·r -è - `__nÚnuÎ - ((1, 4)); - -763 #ifdeà -__USE_GNU - - -764  - $qsÜt_r - (* -__ba£ -, -size_t - -__nmemb -, size_ˆ -__size -, - -765 -__com·r_d_â_t - -__com·r -, * -__¬g -) - -766 - `__nÚnuÎ - ((1, 4)); - -771  - $abs - ( -__x -è -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)è -__wur -; - -772  - $Ïbs - ( -__x -è -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)è -__wur -; - -773 -__END_NAMESPACE_STD - - -775 #ifdeà -__USE_ISOC99 - - -776 -__ex‹nsiÚ__ -  - $Îabs - ( -__x -) - -777 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)è -__wur -; - -781 -__BEGIN_NAMESPACE_STD - - -785 -div_t - - $div - ( -__num” -,  -__d’om -) - -786 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)è -__wur -; - -787 -ldiv_t - - $ldiv - ( -__num” -,  -__d’om -) - -788 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)è -__wur -; - -789 -__END_NAMESPACE_STD - - -791 #ifdeà -__USE_ISOC99 - - -792 -__BEGIN_NAMESPACE_C99 - - -793 -__ex‹nsiÚ__ - -Îdiv_t - - $Îdiv - ( -__num” -, - -794  -__d’om -) - -795 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)è -__wur -; - -796 -__END_NAMESPACE_C99 - - -800 #ià( -defšed - -__USE_XOPEN_EXTENDED - && !defšed -__USE_XOPEN2K -) \ - -801 || -defšed - -__USE_SVID - - -808 * - $ecvt - ( -__v®ue -,  -__ndig™ -, * -__»¡riù - -__deýt -, - -809 * -__»¡riù - -__sign -è -__THROW - - `__nÚnuÎ - ((3, 4)è -__wur -; - -814 * - $fcvt - ( -__v®ue -,  -__ndig™ -, * -__»¡riù - -__deýt -, - -815 * -__»¡riù - -__sign -è -__THROW - - `__nÚnuÎ - ((3, 4)è -__wur -; - -820 * - $gcvt - ( -__v®ue -,  -__ndig™ -, * -__buf -) - -821 -__THROW - - `__nÚnuÎ - ((3)è -__wur -; - -824 #ifdeà -__USE_MISC - - -826 * - $qecvt - ( -__v®ue -,  -__ndig™ -, - -827 * -__»¡riù - -__deýt -, *__»¡riù -__sign -) - -828 -__THROW - - `__nÚnuÎ - ((3, 4)è -__wur -; - -829 * - $qfcvt - ( -__v®ue -,  -__ndig™ -, - -830 * -__»¡riù - -__deýt -, *__»¡riù -__sign -) - -831 -__THROW - - `__nÚnuÎ - ((3, 4)è -__wur -; - -832 * - $qgcvt - ( -__v®ue -,  -__ndig™ -, * -__buf -) - -833 -__THROW - - `__nÚnuÎ - ((3)è -__wur -; - -838  - $ecvt_r - ( -__v®ue -,  -__ndig™ -, * -__»¡riù - -__deýt -, - -839 * -__»¡riù - -__sign -, *__»¡riù -__buf -, - -840 -size_t - -__Ën -è -__THROW - - `__nÚnuÎ - ((3, 4, 5)); - -841  - $fcvt_r - ( -__v®ue -,  -__ndig™ -, * -__»¡riù - -__deýt -, - -842 * -__»¡riù - -__sign -, *__»¡riù -__buf -, - -843 -size_t - -__Ën -è -__THROW - - `__nÚnuÎ - ((3, 4, 5)); - -845  - $qecvt_r - ( -__v®ue -,  -__ndig™ -, - -846 * -__»¡riù - -__deýt -, *__»¡riù -__sign -, - -847 * -__»¡riù - -__buf -, -size_t - -__Ën -) - -848 -__THROW - - `__nÚnuÎ - ((3, 4, 5)); - -849  - $qfcvt_r - ( -__v®ue -,  -__ndig™ -, - -850 * -__»¡riù - -__deýt -, *__»¡riù -__sign -, - -851 * -__»¡riù - -__buf -, -size_t - -__Ën -) - -852 -__THROW - - `__nÚnuÎ - ((3, 4, 5)); - -857 -__BEGIN_NAMESPACE_STD - - -860  - $mbËn - ( -__cÚ¡ - * -__s -, -size_t - -__n -è -__THROW - -__wur -; - -863  - $mbtowc - ( -wch¬_t - * -__»¡riù - -__pwc -, - -864 -__cÚ¡ - * -__»¡riù - -__s -, -size_t - -__n -è -__THROW - -__wur -; - -867  - $wùomb - (* -__s -, -wch¬_t - -__wch¬ -è -__THROW - -__wur -; - -871 -size_t - - $mb¡owcs - ( -wch¬_t - * -__»¡riù - -__pwcs -, - -872 -__cÚ¡ - * -__»¡riù - -__s -, -size_t - -__n -è -__THROW -; - -874 -size_t - - $wc¡ombs - (* -__»¡riù - -__s -, - -875 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__pwcs -, -size_t - -__n -) - -876 -__THROW -; - -877 -__END_NAMESPACE_STD - - -880 #ifdeà -__USE_SVID - - -885  - $½m©ch - ( -__cÚ¡ - * -__»¥Ú£ -è -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -889 #ià -defšed - -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K8 - - -896  - $g‘subÝt - (** -__»¡riù - -__ÝtiÚp -, - -897 * -__cÚ¡ - * -__»¡riù - -__tok’s -, - -898 ** -__»¡riù - -__v®u• -) - -899 -__THROW - - `__nÚnuÎ - ((1, 2, 3)è -__wur -; - -903 #ifdeà -__USE_XOPEN - - -905  - $£tkey - ( -__cÚ¡ - * -__key -è -__THROW - - `__nÚnuÎ - ((1)); - -911 #ifdeà -__USE_XOPEN2KXSI - - -913  - $posix_ݒ± - ( -__oæag -è -__wur -; - -916 #ifdeà -__USE_XOPEN - - -921  - $g¿Á± - ( -__fd -è -__THROW -; - -925  - $uÆock± - ( -__fd -è -__THROW -; - -930 * - $±¢ame - ( -__fd -è -__THROW - -__wur -; - -933 #ifdeà -__USE_GNU - - -937  - $±¢ame_r - ( -__fd -, * -__buf -, -size_t - -__buæ’ -) - -938 -__THROW - - `__nÚnuÎ - ((2)); - -941  - `g‘± - (); - -944 #ifdeà -__USE_BSD - - -948  - $g‘lßdavg - ( -__lßdavg -[],  -__ÃËm -) - -949 -__THROW - - `__nÚnuÎ - ((1)); - -954 #ià -__USE_FORTIFY_LEVEL - > 0 && -defšed - -__ex‹º_®ways_šlše - - -955  - ~ - -957 #ifdeà -__LDBL_COMPAT - - -958  - ~ - -962 #undeà -__Ãed_m®loc_ªd_ÿÎoc - - -964 -__END_DECLS - - - @/usr/include/string.h - -24 #iâdef -_STRING_H - - -25  - #_STRING_H - 1 - - ) - -27  - ~<ã©u»s.h -> - -29 - g__BEGIN_DECLS - - -32  - #__Ãed_size_t - - - ) - -33  - #__Ãed_NULL - - - ) - -34  - ~<¡ddef.h -> - -37 #ià -defšed - -__ýlu¥lus - && -__GNUC_PREREQ - (4, 4) - -38  - #__CORRECT_ISO_CPP_STRING_H_PROTO - - - ) - -42 -__BEGIN_NAMESPACE_STD - - -44 * - $memýy - (* -__»¡riù - -__de¡ -, - -45 -__cÚ¡ - * -__»¡riù - -__¤c -, -size_t - -__n -) - -46 -__THROW - - `__nÚnuÎ - ((1, 2)); - -49 * - $memmove - (* -__de¡ -, -__cÚ¡ - * -__¤c -, -size_t - -__n -) - -50 -__THROW - - `__nÚnuÎ - ((1, 2)); - -51 -__END_NAMESPACE_STD - - -56 #ià -defšed - -__USE_SVID - || defšed -__USE_BSD - || defšed -__USE_XOPEN - - -57 * - $memcýy - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -, - -58  -__c -, -size_t - -__n -) - -59 -__THROW - - `__nÚnuÎ - ((1, 2)); - -63 -__BEGIN_NAMESPACE_STD - - -65 * - $mem£t - (* -__s -,  -__c -, -size_t - -__n -è -__THROW - - `__nÚnuÎ - ((1)); - -68  - $memcmp - ( -__cÚ¡ - * -__s1 -, __cÚ¡ * -__s2 -, -size_t - -__n -) - -69 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -72 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -75 * - `memchr - (* -__s -,  -__c -, -size_t - -__n -) - -76 -__THROW - - `__asm - ("memchr"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -77 -__cÚ¡ - * - `memchr - (__cÚ¡ * -__s -,  -__c -, -size_t - -__n -) - -78 -__THROW - - `__asm - ("memchr"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -80 #ifdeà -__OPTIMIZE__ - - -81 -__ex‹º_®ways_šlše - * - -82 - `memchr - (* -__s -,  -__c -, -size_t - -__n -è -__THROW - - -84  - `__bužtš_memchr - ( -__s -, -__c -, -__n -); - -87 -__ex‹º_®ways_šlše - -__cÚ¡ - * - -88 - `memchr - ( -__cÚ¡ - * -__s -,  -__c -, -size_t - -__n -è -__THROW - - -90  - `__bužtš_memchr - ( -__s -, -__c -, -__n -); - -93 - } -} - -95 * - $memchr - ( -__cÚ¡ - * -__s -,  -__c -, -size_t - -__n -) - -96 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -98 -__END_NAMESPACE_STD - - -100 #ifdeà -__USE_GNU - - -103 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -104 "C++" * - $¿wmemchr - (* -__s -,  -__c -) - -105 -__THROW - - `__asm - ("¿wmemchr"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -106 "C++" -__cÚ¡ - * - $¿wmemchr - ( -__cÚ¡ - * -__s -,  -__c -) - -107 -__THROW - - `__asm - ("¿wmemchr"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -109 * - $¿wmemchr - ( -__cÚ¡ - * -__s -,  -__c -) - -110 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -114 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -115 "C++" * - $memrchr - (* -__s -,  -__c -, -size_t - -__n -) - -116 -__THROW - - `__asm - ("memrchr"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -117 "C++" -__cÚ¡ - * - $memrchr - ( -__cÚ¡ - * -__s -,  -__c -, -size_t - -__n -) - -118 -__THROW - - `__asm - ("memrchr"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -120 * - $memrchr - ( -__cÚ¡ - * -__s -,  -__c -, -size_t - -__n -) - -121 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -126 -__BEGIN_NAMESPACE_STD - - -128 * - $¡rýy - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -) - -129 -__THROW - - `__nÚnuÎ - ((1, 2)); - -131 * - $¡ºýy - (* -__»¡riù - -__de¡ -, - -132 -__cÚ¡ - * -__»¡riù - -__¤c -, -size_t - -__n -) - -133 -__THROW - - `__nÚnuÎ - ((1, 2)); - -136 * - $¡rÿt - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -) - -137 -__THROW - - `__nÚnuÎ - ((1, 2)); - -139 * - $¡ºÿt - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -, - -140 -size_t - -__n -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -143  - $¡rcmp - ( -__cÚ¡ - * -__s1 -, __cÚ¡ * -__s2 -) - -144 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -146  - $¡ºcmp - ( -__cÚ¡ - * -__s1 -, __cÚ¡ * -__s2 -, -size_t - -__n -) - -147 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -150  - $¡rcÞl - ( -__cÚ¡ - * -__s1 -, __cÚ¡ * -__s2 -) - -151 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -153 -size_t - - $¡rxäm - (* -__»¡riù - -__de¡ -, - -154 -__cÚ¡ - * -__»¡riù - -__¤c -, -size_t - -__n -) - -155 -__THROW - - `__nÚnuÎ - ((2)); - -156 -__END_NAMESPACE_STD - - -158 #ifdeà -__USE_XOPEN2K8 - - -162  - ~ - -165  - $¡rcÞl_l - ( -__cÚ¡ - * -__s1 -, __cÚ¡ * -__s2 -, -__loÿË_t - -__l -) - -166 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2, 3)); - -168 -size_t - - $¡rxäm_l - (* -__de¡ -, -__cÚ¡ - * -__¤c -, -size_t - -__n -, - -169 -__loÿË_t - -__l -è -__THROW - - `__nÚnuÎ - ((2, 4)); - -172 #ià -defšed - -__USE_SVID - || defšed -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - \ - -173 || -defšed - -__USE_XOPEN2K8 - - -175 * - $¡rdup - ( -__cÚ¡ - * -__s -) - -176 -__THROW - -__©Œibu‹_m®loc__ - - `__nÚnuÎ - ((1)); - -182 #ià -defšed - -__USE_XOPEN2K8 - - -183 * - $¡ºdup - ( -__cÚ¡ - * -__¡ršg -, -size_t - -__n -) - -184 -__THROW - -__©Œibu‹_m®loc__ - - `__nÚnuÎ - ((1)); - -187 #ià -defšed - -__USE_GNU - && defšed -__GNUC__ - - -189  - #¡rdu· -( -s -) \ - -190 ( -__ex‹nsiÚ__ - \ - -192 -__cÚ¡ - * -__Þd - = ( -s -); \ - -193 -size_t - -__Ën - = - `¡¾’ - ( -__Þd -) + 1; \ - -194 * -__Ãw - = (*è - `__bužtš_®loÿ - ( -__Ën -); \ - -195 (*è - `memýy - ( -__Ãw -, -__Þd -, -__Ën -); \ - -196 - } -})) - - ) - -199  - #¡ºdu· -( -s -, -n -) \ - -200 ( -__ex‹nsiÚ__ - \ - -202 -__cÚ¡ - * -__Þd - = ( -s -); \ - -203 -size_t - -__Ën - = - `¡ºËn - ( -__Þd -, ( -n -)); \ - -204 * -__Ãw - = (*è - `__bužtš_®loÿ - ( -__Ën - + 1); \ - -205 -__Ãw -[ -__Ën -] = '\0'; \ - -206 (*è - `memýy - ( -__Ãw -, -__Þd -, -__Ën -); \ - -207 })) - - ) - -210 - g__BEGIN_NAMESPACE_STD - - -212 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -215 * -¡rchr - (* -__s -,  -__c -) - -216 -__THROW - -__asm - ("¡rchr"è -__©Œibu‹_pu»__ - -__nÚnuÎ - ((1)); - -217 -__cÚ¡ - * -¡rchr - (__cÚ¡ * -__s -,  -__c -) - -218 -__THROW - -__asm - ("¡rchr"è -__©Œibu‹_pu»__ - -__nÚnuÎ - ((1)); - -220 #ifdeà -__OPTIMIZE__ - - -221 -__ex‹º_®ways_šlše - * - -222 -¡rchr - (* -__s -,  -__c -è - g__THROW - - -224  -__bužtš_¡rchr - ( -__s -, -__c -); - -227 -__ex‹º_®ways_šlše - -__cÚ¡ - * - -228 -¡rchr - ( -__cÚ¡ - * -__s -,  -__c -è - g__THROW - - -230  -__bužtš_¡rchr - ( -__s -, -__c -); - -235 * - $¡rchr - ( -__cÚ¡ - * -__s -,  -__c -) - -236 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -239 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -242 * - `¡¼chr - (* -__s -,  -__c -) - -243 -__THROW - - `__asm - ("¡¼chr"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -244 -__cÚ¡ - * - `¡¼chr - (__cÚ¡ * -__s -,  -__c -) - -245 -__THROW - - `__asm - ("¡¼chr"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -247 #ifdeà -__OPTIMIZE__ - - -248 -__ex‹º_®ways_šlše - * - -249 - `¡¼chr - (* -__s -,  -__c -è -__THROW - - -251  - `__bužtš_¡¼chr - ( -__s -, -__c -); - -254 -__ex‹º_®ways_šlše - -__cÚ¡ - * - -255 - `¡¼chr - ( -__cÚ¡ - * -__s -,  -__c -è -__THROW - - -257  - `__bužtš_¡¼chr - ( -__s -, -__c -); - -260 - } -} - -262 * - $¡¼chr - ( -__cÚ¡ - * -__s -,  -__c -) - -263 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -265 -__END_NAMESPACE_STD - - -267 #ifdeà -__USE_GNU - - -270 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -271 "C++" * - $¡rchºul - (* -__s -,  -__c -) - -272 -__THROW - - `__asm - ("¡rchºul"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -273 "C++" -__cÚ¡ - * - $¡rchºul - ( -__cÚ¡ - * -__s -,  -__c -) - -274 -__THROW - - `__asm - ("¡rchºul"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -276 * - $¡rchºul - ( -__cÚ¡ - * -__s -,  -__c -) - -277 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -281 -__BEGIN_NAMESPACE_STD - - -284 -size_t - - $¡rc¥n - ( -__cÚ¡ - * -__s -, __cÚ¡ * -__»jeù -) - -285 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -288 -size_t - - $¡r¥n - ( -__cÚ¡ - * -__s -, __cÚ¡ * -__acû± -) - -289 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -291 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -294 * - `¡½brk - (* -__s -, -__cÚ¡ - * -__acû± -) - -295 -__THROW - - `__asm - ("¡½brk"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -296 -__cÚ¡ - * - `¡½brk - (__cÚ¡ * -__s -, __cÚ¡ * -__acû± -) - -297 -__THROW - - `__asm - ("¡½brk"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -299 #ifdeà -__OPTIMIZE__ - - -300 -__ex‹º_®ways_šlše - * - -301 - `¡½brk - (* -__s -, -__cÚ¡ - * -__acû± -è -__THROW - - -303  - `__bužtš_¡½brk - ( -__s -, -__acû± -); - -306 -__ex‹º_®ways_šlše - -__cÚ¡ - * - -307 - `¡½brk - ( -__cÚ¡ - * -__s -, __cÚ¡ * -__acû± -è -__THROW - - -309  - `__bužtš_¡½brk - ( -__s -, -__acû± -); - -312 - } -} - -314 * - $¡½brk - ( -__cÚ¡ - * -__s -, __cÚ¡ * -__acû± -) - -315 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -318 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -321 * - `¡r¡r - (* -__hay¡ack -, -__cÚ¡ - * -__ÃedË -) - -322 -__THROW - - `__asm - ("¡r¡r"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -323 -__cÚ¡ - * - `¡r¡r - (__cÚ¡ * -__hay¡ack -, - -324 -__cÚ¡ - * -__ÃedË -) - -325 -__THROW - - `__asm - ("¡r¡r"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -327 #ifdeà -__OPTIMIZE__ - - -328 -__ex‹º_®ways_šlše - * - -329 - `¡r¡r - (* -__hay¡ack -, -__cÚ¡ - * -__ÃedË -è -__THROW - - -331  - `__bužtš_¡r¡r - ( -__hay¡ack -, -__ÃedË -); - -334 -__ex‹º_®ways_šlše - -__cÚ¡ - * - -335 - `¡r¡r - ( -__cÚ¡ - * -__hay¡ack -, __cÚ¡ * -__ÃedË -è -__THROW - - -337  - `__bužtš_¡r¡r - ( -__hay¡ack -, -__ÃedË -); - -340 - } -} - -342 * - $¡r¡r - ( -__cÚ¡ - * -__hay¡ack -, __cÚ¡ * -__ÃedË -) - -343 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -348 * - $¡¹ok - (* -__»¡riù - -__s -, -__cÚ¡ - *__»¡riù -__d–im -) - -349 -__THROW - - `__nÚnuÎ - ((2)); - -350 -__END_NAMESPACE_STD - - -354 * - $__¡¹ok_r - (* -__»¡riù - -__s -, - -355 -__cÚ¡ - * -__»¡riù - -__d–im -, - -356 ** -__»¡riù - -__§ve_±r -) - -357 -__THROW - - `__nÚnuÎ - ((2, 3)); - -358 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -359 * - $¡¹ok_r - (* -__»¡riù - -__s -, -__cÚ¡ - *__»¡riù -__d–im -, - -360 ** -__»¡riù - -__§ve_±r -) - -361 -__THROW - - `__nÚnuÎ - ((2, 3)); - -364 #ifdeà -__USE_GNU - - -366 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -367 "C++" * - $¡rÿ£¡r - (* -__hay¡ack -, -__cÚ¡ - * -__ÃedË -) - -368 -__THROW - - `__asm - ("¡rÿ£¡r"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -369 "C++" -__cÚ¡ - * - $¡rÿ£¡r - ( -__cÚ¡ - * -__hay¡ack -, - -370 -__cÚ¡ - * -__ÃedË -) - -371 -__THROW - - `__asm - ("¡rÿ£¡r"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -373 * - $¡rÿ£¡r - ( -__cÚ¡ - * -__hay¡ack -, __cÚ¡ * -__ÃedË -) - -374 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -378 #ifdeà -__USE_GNU - - -382 * - $memmem - ( -__cÚ¡ - * -__hay¡ack -, -size_t - -__hay¡ackËn -, - -383 -__cÚ¡ - * -__ÃedË -, -size_t - -__ÃedËËn -) - -384 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 3)); - -388 * - $__mempýy - (* -__»¡riù - -__de¡ -, - -389 -__cÚ¡ - * -__»¡riù - -__¤c -, -size_t - -__n -) - -390 -__THROW - - `__nÚnuÎ - ((1, 2)); - -391 * - $mempýy - (* -__»¡riù - -__de¡ -, - -392 -__cÚ¡ - * -__»¡riù - -__¤c -, -size_t - -__n -) - -393 -__THROW - - `__nÚnuÎ - ((1, 2)); - -397 -__BEGIN_NAMESPACE_STD - - -399 -size_t - - $¡¾’ - ( -__cÚ¡ - * -__s -) - -400 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -401 -__END_NAMESPACE_STD - - -403 #ifdef -__USE_XOPEN2K8 - - -406 -size_t - - $¡ºËn - ( -__cÚ¡ - * -__¡ršg -, -size_t - -__maxËn -) - -407 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -411 -__BEGIN_NAMESPACE_STD - - -413 * - $¡»¼Ü - ( -__”ºum -è -__THROW -; - -414 -__END_NAMESPACE_STD - - -415 #ià -defšed - -__USE_XOPEN2K - || defšed -__USE_MISC - - -423 #ià -defšed - -__USE_XOPEN2K - && !defšed -__USE_GNU - - -426 #ifdeà -__REDIRECT_NTH - - -427  - `__REDIRECT_NTH - ( -¡»¼Ü_r -, - -428 ( -__”ºum -, * -__buf -, -size_t - -__buæ’ -), - -429 -__xpg_¡»¼Ü_r -è - `__nÚnuÎ - ((2)); - -431  - $__xpg_¡»¼Ü_r - ( -__”ºum -, * -__buf -, -size_t - -__buæ’ -) - -432 -__THROW - - `__nÚnuÎ - ((2)); - -433  - #¡»¼Ü_r - -__xpg_¡»¼Ü_r - - - ) - -438 * - $¡»¼Ü_r - ( -__”ºum -, * -__buf -, -size_t - -__buæ’ -) - -439 -__THROW - - `__nÚnuÎ - ((2)); - -443 #ifdeà -__USE_XOPEN2K8 - - -445 * - $¡»¼Ü_l - ( -__”ºum -, -__loÿË_t - -__l -è -__THROW -; - -451  - $__bz”o - (* -__s -, -size_t - -__n -è -__THROW - - `__nÚnuÎ - ((1)); - -453 #ifdeà -__USE_BSD - - -455  - $bcÝy - ( -__cÚ¡ - * -__¤c -, * -__de¡ -, -size_t - -__n -) - -456 -__THROW - - `__nÚnuÎ - ((1, 2)); - -459  - $bz”o - (* -__s -, -size_t - -__n -è -__THROW - - `__nÚnuÎ - ((1)); - -462  - $bcmp - ( -__cÚ¡ - * -__s1 -, __cÚ¡ * -__s2 -, -size_t - -__n -) - -463 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -466 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -469 * - `šdex - (* -__s -,  -__c -) - -470 -__THROW - - `__asm - ("šdex"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -471 -__cÚ¡ - * - `šdex - (__cÚ¡ * -__s -,  -__c -) - -472 -__THROW - - `__asm - ("šdex"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -474 #ià -defšed - -__OPTIMIZE__ - && !defšed -__CORRECT_ISO_CPP_STRINGS_H_PROTO - - -475 -__ex‹º_®ways_šlše - * - -476 - `šdex - (* -__s -,  -__c -è -__THROW - - -478  - `__bužtš_šdex - ( -__s -, -__c -); - -481 -__ex‹º_®ways_šlše - -__cÚ¡ - * - -482 - `šdex - ( -__cÚ¡ - * -__s -,  -__c -è -__THROW - - -484  - `__bužtš_šdex - ( -__s -, -__c -); - -487 - } -} - -489 * - $šdex - ( -__cÚ¡ - * -__s -,  -__c -) - -490 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -494 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -497 * - `ršdex - (* -__s -,  -__c -) - -498 -__THROW - - `__asm - ("ršdex"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -499 -__cÚ¡ - * - `ršdex - (__cÚ¡ * -__s -,  -__c -) - -500 -__THROW - - `__asm - ("ršdex"è -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -502 #ià -defšed - -__OPTIMIZE__ - && !defšed -__CORRECT_ISO_CPP_STRINGS_H_PROTO - - -503 -__ex‹º_®ways_šlše - * - -504 - `ršdex - (* -__s -,  -__c -è -__THROW - - -506  - `__bužtš_ršdex - ( -__s -, -__c -); - -509 -__ex‹º_®ways_šlše - -__cÚ¡ - * - -510 - `ršdex - ( -__cÚ¡ - * -__s -,  -__c -è -__THROW - - -512  - `__bužtš_ršdex - ( -__s -, -__c -); - -515 - } -} - -517 * - $ršdex - ( -__cÚ¡ - * -__s -,  -__c -) - -518 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1)); - -523  - $ffs - ( -__i -è -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)); - -527 #ifdef -__USE_GNU - - -528  - $ff¦ - ( -__l -è -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)); - -529 #ifdeà -__GNUC__ - - -530 -__ex‹nsiÚ__ -  - $ff¦l - ( -__Î -) - -531 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)); - -536  - $¡rÿ£cmp - ( -__cÚ¡ - * -__s1 -, __cÚ¡ * -__s2 -) - -537 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -540  - $¡ºÿ£cmp - ( -__cÚ¡ - * -__s1 -, __cÚ¡ * -__s2 -, -size_t - -__n -) - -541 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -544 #ifdef -__USE_GNU - - -547  - $¡rÿ£cmp_l - ( -__cÚ¡ - * -__s1 -, __cÚ¡ * -__s2 -, - -548 -__loÿË_t - -__loc -) - -549 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2, 3)); - -551  - $¡ºÿ£cmp_l - ( -__cÚ¡ - * -__s1 -, __cÚ¡ * -__s2 -, - -552 -size_t - -__n -, -__loÿË_t - -__loc -) - -553 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2, 4)); - -556 #ifdef -__USE_BSD - - -559 * - $¡r£p - (** -__»¡riù - -__¡ršgp -, - -560 -__cÚ¡ - * -__»¡riù - -__d–im -) - -561 -__THROW - - `__nÚnuÎ - ((1, 2)); - -564 #ifdef -__USE_XOPEN2K8 - - -566 * - $¡rsigÇl - ( -__sig -è -__THROW -; - -569 * - $__¡pýy - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -) - -570 -__THROW - - `__nÚnuÎ - ((1, 2)); - -571 * - $¡pýy - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -) - -572 -__THROW - - `__nÚnuÎ - ((1, 2)); - -576 * - $__¡²ýy - (* -__»¡riù - -__de¡ -, - -577 -__cÚ¡ - * -__»¡riù - -__¤c -, -size_t - -__n -) - -578 -__THROW - - `__nÚnuÎ - ((1, 2)); - -579 * - $¡²ýy - (* -__»¡riù - -__de¡ -, - -580 -__cÚ¡ - * -__»¡riù - -__¤c -, -size_t - -__n -) - -581 -__THROW - - `__nÚnuÎ - ((1, 2)); - -584 #ifdef -__USE_GNU - - -586  - $¡rv”scmp - ( -__cÚ¡ - * -__s1 -, __cÚ¡ * -__s2 -) - -587 -__THROW - -__©Œibu‹_pu»__ - - `__nÚnuÎ - ((1, 2)); - -590 * - $¡räy - (* -__¡ršg -è -__THROW - - `__nÚnuÎ - ((1)); - -593 * - $memäob - (* -__s -, -size_t - -__n -è -__THROW - - `__nÚnuÎ - ((1)); - -595 #iâdeà -ba£Çme - - -600 #ifdeà -__CORRECT_ISO_CPP_STRING_H_PROTO - - -601 "C++" * - $ba£Çme - (* -__fž’ame -) - -602 -__THROW - - `__asm - ("ba£Çme"è - `__nÚnuÎ - ((1)); - -603 "C++" -__cÚ¡ - * - $ba£Çme - ( -__cÚ¡ - * -__fž’ame -) - -604 -__THROW - - `__asm - ("ba£Çme"è - `__nÚnuÎ - ((1)); - -606 * - $ba£Çme - ( -__cÚ¡ - * -__fž’ame -è -__THROW - - `__nÚnuÎ - ((1)); - -612 #ià -defšed - -__GNUC__ - && __GNUC__ >= 2 - -613 #ià -defšed - -__OPTIMIZE__ - && !defšed -__OPTIMIZE_SIZE__ - \ - -614 && ! -defšed - -__NO_INLINE__ - && !defšed -__ýlu¥lus - - -634  - ~ - -637  - ~ - -640 #ià -__USE_FORTIFY_LEVEL - > 0 && -defšed - -__ex‹º_®ways_šlše - - -642  - ~ - -646 -__END_DECLS - - - @/usr/include/sys/epoll.h - -19 #iâdef -_SYS_EPOLL_H - - -20  - #_SYS_EPOLL_H - 1 - - ) - -22  - ~<¡dšt.h -> - -23  - ~ - -26  - ~ - -28 #iâdeà -__sig£t_t_defšed - - -29  - #__sig£t_t_defšed - - - ) - -30  -__sig£t_t - - tsig£t_t -; - -37 - mEPOLL_CLOEXEC - = 02000000, - -38  - #EPOLL_CLOEXEC - -EPOLL_CLOEXEC - - - ) - -39 - mEPOLL_NONBLOCK - = 04000 - -40  - #EPOLL_NONBLOCK - -EPOLL_NONBLOCK - - - ) - -44 - eEPOLL_EVENTS - - -46 - mEPOLLIN - = 0x001, - -47  - #EPOLLIN - -EPOLLIN - - - ) - -48 - mEPOLLPRI - = 0x002, - -49  - #EPOLLPRI - -EPOLLPRI - - - ) - -50 - mEPOLLOUT - = 0x004, - -51  - #EPOLLOUT - -EPOLLOUT - - - ) - -52 - mEPOLLRDNORM - = 0x040, - -53  - #EPOLLRDNORM - -EPOLLRDNORM - - - ) - -54 - mEPOLLRDBAND - = 0x080, - -55  - #EPOLLRDBAND - -EPOLLRDBAND - - - ) - -56 - mEPOLLWRNORM - = 0x100, - -57  - #EPOLLWRNORM - -EPOLLWRNORM - - - ) - -58 - mEPOLLWRBAND - = 0x200, - -59  - #EPOLLWRBAND - -EPOLLWRBAND - - - ) - -60 - mEPOLLMSG - = 0x400, - -61  - #EPOLLMSG - -EPOLLMSG - - - ) - -62 - mEPOLLERR - = 0x008, - -63  - #EPOLLERR - -EPOLLERR - - - ) - -64 - mEPOLLHUP - = 0x010, - -65  - #EPOLLHUP - -EPOLLHUP - - - ) - -66 - mEPOLLRDHUP - = 0x2000, - -67  - #EPOLLRDHUP - -EPOLLRDHUP - - - ) - -68 - mEPOLLONESHOT - = (1 << 30), - -69  - #EPOLLONESHOT - -EPOLLONESHOT - - - ) - -70 - mEPOLLET - = (1 << 31) - -71  - #EPOLLET - -EPOLLET - - - ) - -76  - #EPOLL_CTL_ADD - 1 - - ) - -77  - #EPOLL_CTL_DEL - 2 - - ) - -78  - #EPOLL_CTL_MOD - 3 - - ) - -81  - u•Þl_d©a - - -83 * - m±r -; - -84  - mfd -; - -85 -ušt32_t - - mu32 -; - -86 -ušt64_t - - mu64 -; - -87 } - t•Þl_d©a_t -; - -89  - s•Þl_ev’t - - -91 -ušt32_t - - mev’ts -; - -92 -•Þl_d©a_t - - md©a -; - -93 } -__©Œibu‹__ - (( -__·cked__ -)); - -96 -__BEGIN_DECLS - - -102  - $•Þl_ü—‹ - ( -__size -è -__THROW -; - -106  - $•Þl_ü—‹1 - ( -__æags -è -__THROW -; - -115  - $•Þl_ùl - ( -__•fd -,  -__Ý -,  -__fd -, - -116  -•Þl_ev’t - * -__ev’t -è -__THROW -; - -129  - `•Þl_wa™ - ( -__•fd -,  -•Þl_ev’t - * -__ev’ts -, - -130  -__maxev’ts -,  -__timeout -); - -138  - `•Þl_pwa™ - ( -__•fd -,  -•Þl_ev’t - * -__ev’ts -, - -139  -__maxev’ts -,  -__timeout -, - -140 -__cÚ¡ - -__sig£t_t - * -__ss -); - -142 -__END_DECLS - - - @/usr/include/sys/ioctl.h - -19 #iâdef -_SYS_IOCTL_H - - -20  - #_SYS_IOCTL_H - 1 - - ) - -22  - ~<ã©u»s.h -> - -24 - g__BEGIN_DECLS - - -27  - ~ - -30  - ~ - -37  - ~ - -42  - $ioùl - ( -__fd -,  -__»que¡ -, ...è -__THROW -; - -44 -__END_DECLS - - - @/usr/include/sys/ipc.h - -19 #iâdeà -_SYS_IPC_H - - -20  - #_SYS_IPC_H - 1 - - ) - -22  - ~<ã©u»s.h -> - -24 #ià! -defšed - -__USE_SVID - && !defšed -__USE_XOPEN - && -__GNUC__ - >= 2 - -29  - ~ - -30  - ~ - -32 #iâdeà -__uid_t_defšed - - -33  -__uid_t - - tuid_t -; - -34  - #__uid_t_defšed - - - ) - -37 #iâdeà -__gid_t_defšed - - -38  -__gid_t - - tgid_t -; - -39  - #__gid_t_defšed - - - ) - -42 #iâdeà -__mode_t_defšed - - -43  -__mode_t - - tmode_t -; - -44  - #__mode_t_defšed - - - ) - -47 #iâdeà -__key_t_defšed - - -48  -__key_t - - tkey_t -; - -49  - #__key_t_defšed - - - ) - -52 -__BEGIN_DECLS - - -55 -key_t - - $áok - ( -__cÚ¡ - * -__·thÇme -,  -__´oj_id -è -__THROW -; - -57 -__END_DECLS - - - @/usr/include/sys/msg.h - -20 #iâdeà -_SYS_MSG_H - - -21  - #_SYS_MSG_H - - - ) - -23  - ~<ã©u»s.h -> - -25  - #__Ãed_size_t - - - ) - -26  - ~<¡ddef.h -> - -29  - ~ - -32  - ~ - -35  - #__Ãed_time_t - - - ) - -36  - ~ - -38 #iâdeà -__pid_t_defšed - - -39  -__pid_t - - tpid_t -; - -40  - #__pid_t_defšed - - - ) - -43 #iâdeà -__ssize_t_defšed - - -44  -__ssize_t - - tssize_t -; - -45  - #__ssize_t_defšed - - - ) - -51 #ifdeà -__USE_GNU - - -53  - smsgbuf - - -55  - mmty³ -; - -56  - mm‹xt -[1]; - -61 -__BEGIN_DECLS - - -64  - $msgùl - ( -__msqid -,  -__cmd -,  -msqid_ds - * -__buf -è -__THROW -; - -67  - $msgg‘ - ( -key_t - -__key -,  -__msgæg -è -__THROW -; - -73 -ssize_t - - `msgrcv - ( -__msqid -, * -__msgp -, -size_t - -__msgsz -, - -74  -__msgtyp -,  -__msgæg -); - -80  - `msg¢d - ( -__msqid -, -__cÚ¡ - * -__msgp -, -size_t - -__msgsz -, - -81  -__msgæg -); - -83 -__END_DECLS - - - @/usr/include/sys/select.h - -22 #iâdeà -_SYS_SELECT_H - - -23  - #_SYS_SELECT_H - 1 - - ) - -25  - ~<ã©u»s.h -> - -28  - ~ - -31  - ~ - -34  - ~ - -36 #iâdeà -__sig£t_t_defšed - - -37  - #__sig£t_t_defšed - - - ) - -38  -__sig£t_t - - tsig£t_t -; - -42  - #__Ãed_time_t - - - ) - -43  - #__Ãed_time¥ec - - - ) - -44  - ~ - -45  - #__Ãed_timev® - - - ) - -46  - ~ - -48 #iâdeà -__su£cÚds_t_defšed - - -49  -__su£cÚds_t - - tsu£cÚds_t -; - -50  - #__su£cÚds_t_defšed - - - ) - -55  - t__fd_mask -; - -58 #undeà -__NFDBITS - - -59 #undeà -__FDELT - - -60 #undeà -__FDMASK - - -62  - #__NFDBITS - (8 * (è ( -__fd_mask -)) - - ) - -63  - #__FDELT -( -d -è((dè/ -__NFDBITS -) - - ) - -64  - #__FDMASK -( -d -è(( -__fd_mask -è1 << ((dè% -__NFDBITS -)) - - ) - -71 #ifdeà -__USE_XOPEN - - -72 -__fd_mask - - mfds_b™s -[ -__FD_SETSIZE - / -__NFDBITS -]; - -73  - #__FDS_BITS -( -£t -è((£t)-> -fds_b™s -) - - ) - -75 -__fd_mask - - m__fds_b™s -[ -__FD_SETSIZE - / -__NFDBITS -]; - -76  - #__FDS_BITS -( -£t -è((£t)-> -__fds_b™s -) - - ) - -78 } - tfd_£t -; - -81  - #FD_SETSIZE - -__FD_SETSIZE - - - ) - -83 #ifdeà -__USE_MISC - - -85  -__fd_mask - - tfd_mask -; - -88  - #NFDBITS - -__NFDBITS - - - ) - -93  - #FD_SET -( -fd -, -fd£ -è - `__FD_SET - (fd, fd£) - - ) - -94  - #FD_CLR -( -fd -, -fd£ -è - `__FD_CLR - (fd, fd£) - - ) - -95  - #FD_ISSET -( -fd -, -fd£ -è - `__FD_ISSET - (fd, fd£) - - ) - -96  - #FD_ZERO -( -fd£ -è - `__FD_ZERO - (fd£) - - ) - -99 -__BEGIN_DECLS - - -109  -£Ëù - ( -__nfds -, -fd_£t - * -__»¡riù - -__»adfds -, - -110 -fd_£t - * -__»¡riù - -__wr™efds -, - -111 -fd_£t - * -__»¡riù - -__exû±fds -, - -112  -timev® - * -__»¡riù - -__timeout -); - -114 #ifdeà -__USE_XOPEN2K - - -121  -p£Ëù - ( -__nfds -, -fd_£t - * -__»¡riù - -__»adfds -, - -122 -fd_£t - * -__»¡riù - -__wr™efds -, - -123 -fd_£t - * -__»¡riù - -__exû±fds -, - -124 cÚ¡  -time¥ec - * -__»¡riù - -__timeout -, - -125 cÚ¡ -__sig£t_t - * -__»¡riù - -__sigmask -); - -128 - g__END_DECLS - - - @/usr/include/sys/socket.h - -21 #iâdef -_SYS_SOCKET_H - - -22  - #_SYS_SOCKET_H - 1 - - ) - -24  - ~<ã©u»s.h -> - -26 - g__BEGIN_DECLS - - -28  - ~ - -29  - #__Ãed_size_t - - - ) - -30  - ~<¡ddef.h -> - -31 #ifdeà -__USE_GNU - - -33  - ~ - -40  - ~ - -42 #ifdeà -__USE_BSD - - -45  - sosockaddr - - -47  - m§_çmžy -; - -48  - m§_d©a -[14]; - -56 - mSHUT_RD - = 0, - -57  - #SHUT_RD - -SHUT_RD - - - ) - -58 - mSHUT_WR -, - -59  - #SHUT_WR - -SHUT_WR - - - ) - -60 - mSHUT_RDWR - - -61  - #SHUT_RDWR - -SHUT_RDWR - - - ) - -70 #ià -defšed - -__ýlu¥lus - || ! -__GNUC_PREREQ - (2, 7è|| !defšed -__USE_GNU - - -71  - #__SOCKADDR_ARG -  -sockaddr - * -__»¡riù - - - ) - -72  - #__CONST_SOCKADDR_ARG - -__cÚ¡ -  -sockaddr - * - - ) - -76  - #__SOCKADDR_ALLTYPES - \ - -77 - `__SOCKADDR_ONETYPE - ( -sockaddr -) \ - -78 - `__SOCKADDR_ONETYPE - ( -sockaddr_© -) \ - -79 - `__SOCKADDR_ONETYPE - ( -sockaddr_ax25 -) \ - -80 - `__SOCKADDR_ONETYPE - ( -sockaddr_dl -) \ - -81 - `__SOCKADDR_ONETYPE - ( -sockaddr_eÚ -) \ - -82 - `__SOCKADDR_ONETYPE - ( -sockaddr_š -) \ - -83 - `__SOCKADDR_ONETYPE - ( -sockaddr_š6 -) \ - -84 - `__SOCKADDR_ONETYPE - ( -sockaddr_š¬p -) \ - -85 - `__SOCKADDR_ONETYPE - ( -sockaddr_x -) \ - -86 - `__SOCKADDR_ONETYPE - ( -sockaddr_iso -) \ - -87 - `__SOCKADDR_ONETYPE - ( -sockaddr_ns -) \ - -88 - `__SOCKADDR_ONETYPE - ( -sockaddr_un -) \ - -89 - `__SOCKADDR_ONETYPE - ( -sockaddr_x25 -) - - ) - -91  - #__SOCKADDR_ONETYPE -( -ty³ -èty³ * -__»¡riù - -__ -##ty³##__; - - ) - -92 uniÚ { - m__SOCKADDR_ALLTYPES - - -93 } - t__SOCKADDR_ARG - - t__©Œibu‹__ - (( - t__Œª¥¬’t_uniÚ__ -)); - -94 #undeà -__SOCKADDR_ONETYPE - - -95  - #__SOCKADDR_ONETYPE -( -ty³ -è -__cÚ¡ - ty³ * -__»¡riù - -__ -##ty³##__; - - ) - -96 uniÚ { - m__SOCKADDR_ALLTYPES - - -97 } - t__CONST_SOCKADDR_ARG - - t__©Œibu‹__ - (( - t__Œª¥¬’t_uniÚ__ -)); - -98 #undeà -__SOCKADDR_ONETYPE - - -105  - $sock‘ - ( -__domaš -,  -__ty³ -,  -__´ÙocÞ -è -__THROW -; - -111  - $sock‘·œ - ( -__domaš -,  -__ty³ -,  -__´ÙocÞ -, - -112  -__fds -[2]è -__THROW -; - -115  - $bšd - ( -__fd -, -__CONST_SOCKADDR_ARG - -__addr -, -sockËn_t - -__Ën -) - -116 -__THROW -; - -119  - $g‘sockÇme - ( -__fd -, -__SOCKADDR_ARG - -__addr -, - -120 -sockËn_t - * -__»¡riù - -__Ën -è -__THROW -; - -129  - `cÚÃù - ( -__fd -, -__CONST_SOCKADDR_ARG - -__addr -, -sockËn_t - -__Ën -); - -133  - $g‘³”Çme - ( -__fd -, -__SOCKADDR_ARG - -__addr -, - -134 -sockËn_t - * -__»¡riù - -__Ën -è -__THROW -; - -141 -ssize_t - - `£nd - ( -__fd -, -__cÚ¡ - * -__buf -, -size_t - -__n -,  -__æags -); - -148 -ssize_t - - `»cv - ( -__fd -, * -__buf -, -size_t - -__n -,  -__æags -); - -155 -ssize_t - - `£ndto - ( -__fd -, -__cÚ¡ - * -__buf -, -size_t - -__n -, - -156  -__æags -, -__CONST_SOCKADDR_ARG - -__addr -, - -157 -sockËn_t - -__addr_Ën -); - -166 -ssize_t - - `»cväom - ( -__fd -, * -__»¡riù - -__buf -, -size_t - -__n -, - -167  -__æags -, -__SOCKADDR_ARG - -__addr -, - -168 -sockËn_t - * -__»¡riù - -__addr_Ën -); - -176 -ssize_t - - `£ndmsg - ( -__fd -, -__cÚ¡ -  -msghdr - * -__mes§ge -, - -177  -__æags -); - -184 -ssize_t - - `»cvmsg - ( -__fd -,  -msghdr - * -__mes§ge -,  -__æags -); - -190  - $g‘sockÝt - ( -__fd -,  -__Ëv– -,  -__݊ame -, - -191 * -__»¡riù - -__Ýtv® -, - -192 -sockËn_t - * -__»¡riù - -__ݎ’ -è -__THROW -; - -197  - $£tsockÝt - ( -__fd -,  -__Ëv– -,  -__݊ame -, - -198 -__cÚ¡ - * -__Ýtv® -, -sockËn_t - -__ݎ’ -è -__THROW -; - -204  - $li¡’ - ( -__fd -,  -__n -è -__THROW -; - -214  - `acû± - ( -__fd -, -__SOCKADDR_ARG - -__addr -, - -215 -sockËn_t - * -__»¡riù - -__addr_Ën -); - -217 #ifdeà -__USE_GNU - - -222  - `acû±4 - ( -__fd -, -__SOCKADDR_ARG - -__addr -, - -223 -sockËn_t - * -__»¡riù - -__addr_Ën -,  -__æags -); - -232  - $shutdown - ( -__fd -,  -__how -è -__THROW -; - -235 #ifdeà -__USE_XOPEN2K - - -237  - $sock©m¬k - ( -__fd -è -__THROW -; - -241 #ifdeà -__USE_MISC - - -245  - $isfdty³ - ( -__fd -,  -__fdty³ -è -__THROW -; - -250 #ià -__USE_FORTIFY_LEVEL - > 0 && -defšed - -__ex‹º_®ways_šlše - - -251  - ~ - -254 -__END_DECLS - - - @/usr/include/sys/stat.h - -24 #iâdef -_SYS_STAT_H - - -25  - #_SYS_STAT_H - 1 - - ) - -27  - ~<ã©u»s.h -> - -29  - ~ - -31 #ià -defšed - -__USE_XOPEN - || defšed -__USE_XOPEN2K - || defšed -__USE_MISC - \ - -32 || -defšed - - g__USE_ATFILE - - -33 #ià -defšed - -__USE_XOPEN - || defšed -__USE_XOPEN2K - - -34  - #__Ãed_time_t - - - ) - -36 #ià -defšed - -__USE_MISC - || defšed -__USE_ATFILE - - -37  - #__Ãed_time¥ec - - - ) - -39  - ~ - -42 #ià -defšed - -__USE_XOPEN - || defšed -__USE_XOPEN2K - - -45 #iâdeà -__dev_t_defšed - - -46  -__dev_t - - tdev_t -; - -47  - #__dev_t_defšed - - - ) - -50 #iâdeà -__gid_t_defšed - - -51  -__gid_t - - tgid_t -; - -52  - #__gid_t_defšed - - - ) - -55 #iâdeà -__šo_t_defšed - - -56 #iâdeà -__USE_FILE_OFFSET64 - - -57  -__šo_t - - tšo_t -; - -59  -__šo64_t - - tšo_t -; - -61  - #__šo_t_defšed - - - ) - -64 #iâdeà -__mode_t_defšed - - -65  -__mode_t - - tmode_t -; - -66  - #__mode_t_defšed - - - ) - -69 #iâdeà -__ƚk_t_defšed - - -70  -__ƚk_t - - tƚk_t -; - -71  - #__ƚk_t_defšed - - - ) - -74 #iâdeà -__off_t_defšed - - -75 #iâdeà -__USE_FILE_OFFSET64 - - -76  -__off_t - - toff_t -; - -78  -__off64_t - - toff_t -; - -80  - #__off_t_defšed - - - ) - -83 #iâdeà -__uid_t_defšed - - -84  -__uid_t - - tuid_t -; - -85  - #__uid_t_defšed - - - ) - -89 #ifdeà -__USE_UNIX98 - - -90 #iâdeà -__blkút_t_defšed - - -91 #iâdeà -__USE_FILE_OFFSET64 - - -92  -__blkút_t - - tblkút_t -; - -94  -__blkút64_t - - tblkút_t -; - -96  - #__blkút_t_defšed - - - ) - -99 #iâdeà -__blksize_t_defšed - - -100  -__blksize_t - - tblksize_t -; - -101  - #__blksize_t_defšed - - - ) - -105 - g__BEGIN_DECLS - - -107  - ~ - -109 #ià -defšed - -__USE_BSD - || defšed -__USE_MISC - || defšed -__USE_XOPEN - - -110  - #S_IFMT - -__S_IFMT - - - ) - -111  - #S_IFDIR - -__S_IFDIR - - - ) - -112  - #S_IFCHR - -__S_IFCHR - - - ) - -113  - #S_IFBLK - -__S_IFBLK - - - ) - -114  - #S_IFREG - -__S_IFREG - - - ) - -115 #ifdeà -__S_IFIFO - - -116  - #S_IFIFO - -__S_IFIFO - - - ) - -118 #ifdeà -__S_IFLNK - - -119  - #S_IFLNK - -__S_IFLNK - - - ) - -121 #ià( -defšed - -__USE_BSD - || defšed -__USE_MISC - || defšed -__USE_UNIX98 -) \ - -122 && -defšed - - g__S_IFSOCK - - -123  - #S_IFSOCK - -__S_IFSOCK - - - ) - -129  - #__S_ISTYPE -( -mode -, -mask -è(((modeè& -__S_IFMT -è=ð(mask)) - - ) - -131  - #S_ISDIR -( -mode -è - `__S_ISTYPE -((mode), -__S_IFDIR -) - - ) - -132  - #S_ISCHR -( -mode -è - `__S_ISTYPE -((mode), -__S_IFCHR -) - - ) - -133  - #S_ISBLK -( -mode -è - `__S_ISTYPE -((mode), -__S_IFBLK -) - - ) - -134  - #S_ISREG -( -mode -è - `__S_ISTYPE -((mode), -__S_IFREG -) - - ) - -135 #ifdeà -__S_IFIFO - - -136  - #S_ISFIFO -( -mode -è - `__S_ISTYPE -((mode), -__S_IFIFO -) - - ) - -138 #ifdeà -__S_IFLNK - - -139  - #S_ISLNK -( -mode -è - `__S_ISTYPE -((mode), -__S_IFLNK -) - - ) - -142 #ià -defšed - -__USE_BSD - && !defšed -__S_IFLNK - - -143  - #S_ISLNK -( -mode -è0 - - ) - -146 #ià( -defšed - -__USE_BSD - || defšed -__USE_UNIX98 - || defšed -__USE_XOPEN2K -) \ - -147 && -defšed - - g__S_IFSOCK - - -148  - #S_ISSOCK -( -mode -è - `__S_ISTYPE -((mode), -__S_IFSOCK -) - - ) - -149 #–ià -defšed - -__USE_XOPEN2K - - -150  - #S_ISSOCK -( -mode -è0 - - ) - -157 #ifdef -__USE_POSIX199309 - - -158  - #S_TYPEISMQ -( -buf -è - `__S_TYPEISMQ -(buf) - - ) - -159  - #S_TYPEISSEM -( -buf -è - `__S_TYPEISSEM -(buf) - - ) - -160  - #S_TYPEISSHM -( -buf -è - `__S_TYPEISSHM -(buf) - - ) - -166  - #S_ISUID - -__S_ISUID - - - ) - -167  - #S_ISGID - -__S_ISGID - - - ) - -169 #ià -defšed - -__USE_BSD - || defšed -__USE_MISC - || defšed -__USE_XOPEN - - -171  - #S_ISVTX - -__S_ISVTX - - - ) - -174  - #S_IRUSR - -__S_IREAD - - - ) - -175  - #S_IWUSR - -__S_IWRITE - - - ) - -176  - #S_IXUSR - -__S_IEXEC - - - ) - -178  - #S_IRWXU - ( -__S_IREAD -| -__S_IWRITE -| -__S_IEXEC -) - - ) - -180 #ià -defšed - -__USE_MISC - && defšed -__USE_BSD - - -181  - #S_IREAD - -S_IRUSR - - - ) - -182  - #S_IWRITE - -S_IWUSR - - - ) - -183  - #S_IEXEC - -S_IXUSR - - - ) - -186  - #S_IRGRP - ( -S_IRUSR - >> 3è - - ) - -187  - #S_IWGRP - ( -S_IWUSR - >> 3è - - ) - -188  - #S_IXGRP - ( -S_IXUSR - >> 3è - - ) - -190  - #S_IRWXG - ( -S_IRWXU - >> 3) - - ) - -192  - #S_IROTH - ( -S_IRGRP - >> 3è - - ) - -193  - #S_IWOTH - ( -S_IWGRP - >> 3è - - ) - -194  - #S_IXOTH - ( -S_IXGRP - >> 3è - - ) - -196  - #S_IRWXO - ( -S_IRWXG - >> 3) - - ) - -199 #ifdef -__USE_BSD - - -201  - #ACCESSPERMS - ( -S_IRWXU -| -S_IRWXG -| -S_IRWXO -è - - ) - -202  - #ALLPERMS - ( -S_ISUID -| -S_ISGID -| -S_ISVTX -| -S_IRWXU -| -S_IRWXG -| -S_IRWXO -) - - ) - -203  - #DEFFILEMODE - ( -S_IRUSR -| -S_IWUSR -| -S_IRGRP -| -S_IWGRP -| -S_IROTH -| -S_IWOTH -) - - ) - -205  - #S_BLKSIZE - 512 - - ) - -209 #iâdeà -__USE_FILE_OFFSET64 - - -211  - $¡© - ( -__cÚ¡ - * -__»¡riù - -__fže -, - -212  -¡© - * -__»¡riù - -__buf -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -216  - $f¡© - ( -__fd -,  -¡© - * -__buf -è -__THROW - - `__nÚnuÎ - ((2)); - -218 #ifdeà -__REDIRECT_NTH - - -219  - `__REDIRECT_NTH - ( -¡© -, ( -__cÚ¡ - * -__»¡riù - -__fže -, - -220  -¡© - * -__»¡riù - -__buf -), -¡©64 -) - -221 - `__nÚnuÎ - ((1, 2)); - -222  - `__REDIRECT_NTH - ( -f¡© -, ( -__fd -,  -¡© - * -__buf -), -f¡©64 -) - -223 - `__nÚnuÎ - ((2)); - -225  - #¡© - -¡©64 - - - ) - -226  - #f¡© - -f¡©64 - - - ) - -229 #ifdeà -__USE_LARGEFILE64 - - -230  - $¡©64 - ( -__cÚ¡ - * -__»¡riù - -__fže -, - -231  -¡©64 - * -__»¡riù - -__buf -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -232  - $f¡©64 - ( -__fd -,  -¡©64 - * -__buf -è -__THROW - - `__nÚnuÎ - ((2)); - -235 #ifdeà -__USE_ATFILE - - -239 #iâdeà -__USE_FILE_OFFSET64 - - -240  - $f¡©© - ( -__fd -, -__cÚ¡ - * -__»¡riù - -__fže -, - -241  -¡© - * -__»¡riù - -__buf -,  -__æag -) - -242 -__THROW - - `__nÚnuÎ - ((2, 3)); - -244 #ifdeà -__REDIRECT_NTH - - -245  - `__REDIRECT_NTH - ( -f¡©© -, ( -__fd -, -__cÚ¡ - * -__»¡riù - -__fže -, - -246  -¡© - * -__»¡riù - -__buf -, - -247  -__æag -), - -248 -f¡©©64 -è - `__nÚnuÎ - ((2, 3)); - -250  - #f¡©© - -f¡©©64 - - - ) - -254 #ifdeà -__USE_LARGEFILE64 - - -255  - $f¡©©64 - ( -__fd -, -__cÚ¡ - * -__»¡riù - -__fže -, - -256  -¡©64 - * -__»¡riù - -__buf -,  -__æag -) - -257 -__THROW - - `__nÚnuÎ - ((2, 3)); - -261 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K - - -262 #iâdeà -__USE_FILE_OFFSET64 - - -265  - $l¡© - ( -__cÚ¡ - * -__»¡riù - -__fže -, - -266  -¡© - * -__»¡riù - -__buf -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -268 #ifdeà -__REDIRECT_NTH - - -269  - `__REDIRECT_NTH - ( -l¡© -, - -270 ( -__cÚ¡ - * -__»¡riù - -__fže -, - -271  -¡© - * -__»¡riù - -__buf -), -l¡©64 -) - -272 - `__nÚnuÎ - ((1, 2)); - -274  - #l¡© - -l¡©64 - - - ) - -277 #ifdeà -__USE_LARGEFILE64 - - -278  - $l¡©64 - ( -__cÚ¡ - * -__»¡riù - -__fže -, - -279  -¡©64 - * -__»¡riù - -__buf -) - -280 -__THROW - - `__nÚnuÎ - ((1, 2)); - -286  - $chmod - ( -__cÚ¡ - * -__fže -, -__mode_t - -__mode -) - -287 -__THROW - - `__nÚnuÎ - ((1)); - -289 #ifdeà -__USE_BSD - - -293  - $lchmod - ( -__cÚ¡ - * -__fže -, -__mode_t - -__mode -) - -294 -__THROW - - `__nÚnuÎ - ((1)); - -298 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K8 - - -299  - $fchmod - ( -__fd -, -__mode_t - -__mode -è -__THROW -; - -302 #ifdeà -__USE_ATFILE - - -305  - $fchmod© - ( -__fd -, -__cÚ¡ - * -__fže -, -__mode_t - -__mode -, - -306  -__æag -) - -307 -__THROW - - `__nÚnuÎ - ((2)è -__wur -; - -314 -__mode_t - - $umask - ( -__mode_t - -__mask -è -__THROW -; - -316 #ifdef -__USE_GNU - - -319 -__mode_t - - $g‘umask - (è -__THROW -; - -323  - $mkdœ - ( -__cÚ¡ - * -__·th -, -__mode_t - -__mode -) - -324 -__THROW - - `__nÚnuÎ - ((1)); - -326 #ifdeà -__USE_ATFILE - - -330  - $mkdœ© - ( -__fd -, -__cÚ¡ - * -__·th -, -__mode_t - -__mode -) - -331 -__THROW - - `__nÚnuÎ - ((2)); - -337 #ià -defšed - -__USE_MISC - || defšed -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - - -338  - $mknod - ( -__cÚ¡ - * -__·th -, -__mode_t - -__mode -, -__dev_t - -__dev -) - -339 -__THROW - - `__nÚnuÎ - ((1)); - -341 #ifdeà -__USE_ATFILE - - -345  - $mknod© - ( -__fd -, -__cÚ¡ - * -__·th -, -__mode_t - -__mode -, - -346 -__dev_t - -__dev -è -__THROW - - `__nÚnuÎ - ((2)); - -352  - $mkfifo - ( -__cÚ¡ - * -__·th -, -__mode_t - -__mode -) - -353 -__THROW - - `__nÚnuÎ - ((1)); - -355 #ifdeà -__USE_ATFILE - - -359  - $mkfifßt - ( -__fd -, -__cÚ¡ - * -__·th -, -__mode_t - -__mode -) - -360 -__THROW - - `__nÚnuÎ - ((2)); - -363 #ifdeà -__USE_ATFILE - - -366  - $utim’§t - ( -__fd -, -__cÚ¡ - * -__·th -, - -367 -__cÚ¡ -  -time¥ec - -__times -[2], - -368  -__æags -) - -369 -__THROW - - `__nÚnuÎ - ((2)); - -372 #ifdeà -__USE_XOPEN2K8 - - -374  - $futim’s - ( -__fd -, -__cÚ¡ -  -time¥ec - -__times -[2]è -__THROW -; - -392 #iâdeà -_STAT_VER - - -393  - #_STAT_VER - 0 - - ) - -395 #iâdeà -_MKNOD_VER - - -396  - #_MKNOD_VER - 0 - - ) - -400 #iâdeà -__USE_FILE_OFFSET64 - - -401  - $__fx¡© - ( -__v” -,  -__fždes -,  -¡© - * -__¡©_buf -) - -402 -__THROW - - `__nÚnuÎ - ((3)); - -403  - $__x¡© - ( -__v” -, -__cÚ¡ - * -__fž’ame -, - -404  -¡© - * -__¡©_buf -è -__THROW - - `__nÚnuÎ - ((2, 3)); - -405  - $__lx¡© - ( -__v” -, -__cÚ¡ - * -__fž’ame -, - -406  -¡© - * -__¡©_buf -è -__THROW - - `__nÚnuÎ - ((2, 3)); - -407  - $__fx¡©© - ( -__v” -,  -__fždes -, -__cÚ¡ - * -__fž’ame -, - -408  -¡© - * -__¡©_buf -,  -__æag -) - -409 -__THROW - - `__nÚnuÎ - ((3, 4)); - -411 #ifdeà -__REDIRECT_NTH - - -412  - `__REDIRECT_NTH - ( -__fx¡© -, ( -__v” -,  -__fždes -, - -413  -¡© - * -__¡©_buf -), -__fx¡©64 -) - -414 - `__nÚnuÎ - ((3)); - -415  - `__REDIRECT_NTH - ( -__x¡© -, ( -__v” -, -__cÚ¡ - * -__fž’ame -, - -416  -¡© - * -__¡©_buf -), -__x¡©64 -) - -417 - `__nÚnuÎ - ((2, 3)); - -418  - `__REDIRECT_NTH - ( -__lx¡© -, ( -__v” -, -__cÚ¡ - * -__fž’ame -, - -419  -¡© - * -__¡©_buf -), -__lx¡©64 -) - -420 - `__nÚnuÎ - ((2, 3)); - -421  - `__REDIRECT_NTH - ( -__fx¡©© -, ( -__v” -,  -__fždes -, - -422 -__cÚ¡ - * -__fž’ame -, - -423  -¡© - * -__¡©_buf -,  -__æag -), - -424 -__fx¡©©64 -è - `__nÚnuÎ - ((3, 4)); - -427  - #__fx¡© - -__fx¡©64 - - - ) - -428  - #__x¡© - -__x¡©64 - - - ) - -429  - #__lx¡© - -__lx¡©64 - - - ) - -433 #ifdeà -__USE_LARGEFILE64 - - -434  - $__fx¡©64 - ( -__v” -,  -__fždes -,  -¡©64 - * -__¡©_buf -) - -435 -__THROW - - `__nÚnuÎ - ((3)); - -436  - $__x¡©64 - ( -__v” -, -__cÚ¡ - * -__fž’ame -, - -437  -¡©64 - * -__¡©_buf -è -__THROW - - `__nÚnuÎ - ((2, 3)); - -438  - $__lx¡©64 - ( -__v” -, -__cÚ¡ - * -__fž’ame -, - -439  -¡©64 - * -__¡©_buf -è -__THROW - - `__nÚnuÎ - ((2, 3)); - -440  - $__fx¡©©64 - ( -__v” -,  -__fždes -, -__cÚ¡ - * -__fž’ame -, - -441  -¡©64 - * -__¡©_buf -,  -__æag -) - -442 -__THROW - - `__nÚnuÎ - ((3, 4)); - -444  - $__xmknod - ( -__v” -, -__cÚ¡ - * -__·th -, -__mode_t - -__mode -, - -445 -__dev_t - * -__dev -è -__THROW - - `__nÚnuÎ - ((2, 4)); - -447  - $__xmknod© - ( -__v” -,  -__fd -, -__cÚ¡ - * -__·th -, - -448 -__mode_t - -__mode -, -__dev_t - * -__dev -) - -449 -__THROW - - `__nÚnuÎ - ((3, 5)); - -451 #ià -defšed - -__GNUC__ - && __GNUC__ >ð2 && defšed -__USE_EXTERN_INLINES_IN_LIBC - - -454 -__ex‹º_šlše -  - -455 - `__NTH - ( - $¡© - ( -__cÚ¡ - * -__·th -,  -¡© - * -__¡©buf -)) - -457  - `__x¡© - ( -_STAT_VER -, -__·th -, -__¡©buf -); - -458 - } -} - -460 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - - -461 -__ex‹º_šlše -  - -462 -__NTH - ( - $l¡© - ( -__cÚ¡ - * -__·th -,  -¡© - * -__¡©buf -)) - -464  - `__lx¡© - ( -_STAT_VER -, -__·th -, -__¡©buf -); - -465 - } -} - -468 -__ex‹º_šlše -  - -469 -__NTH - ( - $f¡© - ( -__fd -,  -¡© - * -__¡©buf -)) - -471  - `__fx¡© - ( -_STAT_VER -, -__fd -, -__¡©buf -); - -472 - } -} - -474 #ifdeà -__USE_ATFILE - - -475 -__ex‹º_šlše -  - -476 -__NTH - ( - $f¡©© - ( -__fd -, -__cÚ¡ - * -__fž’ame -,  -¡© - * -__¡©buf -, - -477  -__æag -)) - -479  - `__fx¡©© - ( -_STAT_VER -, -__fd -, -__fž’ame -, -__¡©buf -, -__æag -); - -480 - } -} - -483 #ià -defšed - -__USE_MISC - || defšed -__USE_BSD - - -484 -__ex‹º_šlše -  - -485 -__NTH - ( - $mknod - ( -__cÚ¡ - * -__·th -, -__mode_t - -__mode -, -__dev_t - -__dev -)) - -487  - `__xmknod - ( -_MKNOD_VER -, -__·th -, -__mode -, & -__dev -); - -488 - } -} - -491 #ifdeà -__USE_ATFILE - - -492 -__ex‹º_šlše -  - -493 -__NTH - ( - $mknod© - ( -__fd -, -__cÚ¡ - * -__·th -, -__mode_t - -__mode -, - -494 -__dev_t - -__dev -)) - -496  - `__xmknod© - ( -_MKNOD_VER -, -__fd -, -__·th -, -__mode -, & -__dev -); - -497 - } -} - -500 #ià -defšed - -__USE_LARGEFILE64 - \ - -501 && (! -defšed - - g__USE_FILE_OFFSET64 - \ - -502 || ( -defšed - - g__REDIRECT_NTH - && defšed - g__OPTIMIZE__ -)) - -503 -__ex‹º_šlše -  - -504 -__NTH - ( - $¡©64 - ( -__cÚ¡ - * -__·th -,  -¡©64 - * -__¡©buf -)) - -506  - `__x¡©64 - ( -_STAT_VER -, -__·th -, -__¡©buf -); - -507 - } -} - -509 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - - -510 -__ex‹º_šlše -  - -511 -__NTH - ( - $l¡©64 - ( -__cÚ¡ - * -__·th -,  -¡©64 - * -__¡©buf -)) - -513  - `__lx¡©64 - ( -_STAT_VER -, -__·th -, -__¡©buf -); - -514 - } -} - -517 -__ex‹º_šlše -  - -518 -__NTH - ( - $f¡©64 - ( -__fd -,  -¡©64 - * -__¡©buf -)) - -520  - `__fx¡©64 - ( -_STAT_VER -, -__fd -, -__¡©buf -); - -521 - } -} - -523 #ifdeà -__USE_ATFILE - - -524 -__ex‹º_šlše -  - -525 -__NTH - ( - $f¡©©64 - ( -__fd -, -__cÚ¡ - * -__fž’ame -,  -¡©64 - * -__¡©buf -, - -526  -__æag -)) - -528  - `__fx¡©©64 - ( -_STAT_VER -, -__fd -, -__fž’ame -, -__¡©buf -, -__æag -); - -529 - } -} - -536 - g__END_DECLS - - - @/usr/include/sys/types.h - -23 #iâdef -_SYS_TYPES_H - - -24  - #_SYS_TYPES_H - 1 - - ) - -26  - ~<ã©u»s.h -> - -28 - g__BEGIN_DECLS - - -30  - ~ - -32 #ifdef -__USE_BSD - - -33 #iâdeà -__u_ch¬_defšed - - -34  -__u_ch¬ - - tu_ch¬ -; - -35  -__u_shÜt - - tu_shÜt -; - -36  -__u_št - - tu_št -; - -37  -__u_lÚg - - tu_lÚg -; - -38  -__quad_t - - tquad_t -; - -39  -__u_quad_t - - tu_quad_t -; - -40  -__fsid_t - - tfsid_t -; - -41  - #__u_ch¬_defšed - - - ) - -45  -__loff_t - - tloff_t -; - -47 #iâdeà -__šo_t_defšed - - -48 #iâdeà -__USE_FILE_OFFSET64 - - -49  -__šo_t - - tšo_t -; - -51  -__šo64_t - - tšo_t -; - -53  - #__šo_t_defšed - - - ) - -55 #ià -defšed - -__USE_LARGEFILE64 - && !defšed -__šo64_t_defšed - - -56  -__šo64_t - - tšo64_t -; - -57  - #__šo64_t_defšed - - - ) - -60 #iâdeà -__dev_t_defšed - - -61  -__dev_t - - tdev_t -; - -62  - #__dev_t_defšed - - - ) - -65 #iâdeà -__gid_t_defšed - - -66  -__gid_t - - tgid_t -; - -67  - #__gid_t_defšed - - - ) - -70 #iâdeà -__mode_t_defšed - - -71  -__mode_t - - tmode_t -; - -72  - #__mode_t_defšed - - - ) - -75 #iâdeà -__ƚk_t_defšed - - -76  -__ƚk_t - - tƚk_t -; - -77  - #__ƚk_t_defšed - - - ) - -80 #iâdeà -__uid_t_defšed - - -81  -__uid_t - - tuid_t -; - -82  - #__uid_t_defšed - - - ) - -85 #iâdeà -__off_t_defšed - - -86 #iâdeà -__USE_FILE_OFFSET64 - - -87  -__off_t - - toff_t -; - -89  -__off64_t - - toff_t -; - -91  - #__off_t_defšed - - - ) - -93 #ià -defšed - -__USE_LARGEFILE64 - && !defšed -__off64_t_defšed - - -94  -__off64_t - - toff64_t -; - -95  - #__off64_t_defšed - - - ) - -98 #iâdeà -__pid_t_defšed - - -99  -__pid_t - - tpid_t -; - -100  - #__pid_t_defšed - - - ) - -103 #ià( -defšed - -__USE_SVID - || defšed -__USE_XOPEN - || defšed -__USE_XOPEN2K8 -) \ - -104 && ! -defšed - -__id_t_defšed - - -105  -__id_t - - tid_t -; - -106  - #__id_t_defšed - - - ) - -109 #iâdeà -__ssize_t_defšed - - -110  -__ssize_t - - tssize_t -; - -111  - #__ssize_t_defšed - - - ) - -114 #ifdef -__USE_BSD - - -115 #iâdeà -__daddr_t_defšed - - -116  -__daddr_t - - tdaddr_t -; - -117  -__ÿddr_t - - tÿddr_t -; - -118  - #__daddr_t_defšed - - - ) - -122 #ià( -defšed - -__USE_SVID - || defšed -__USE_XOPEN -è&& !defšed -__key_t_defšed - - -123  -__key_t - - tkey_t -; - -124  - #__key_t_defšed - - - ) - -127 #ià -defšed - -__USE_XOPEN - || defšed -__USE_XOPEN2K8 - - -128  - #__Ãed_þock_t - - - ) - -130  - #__Ãed_time_t - - - ) - -131  - #__Ãed_tim”_t - - - ) - -132  - #__Ãed_þockid_t - - - ) - -133  - ~ - -135 #ifdeà -__USE_XOPEN - - -136 #iâdeà -__u£cÚds_t_defšed - - -137  -__u£cÚds_t - - tu£cÚds_t -; - -138  - #__u£cÚds_t_defšed - - - ) - -140 #iâdeà -__su£cÚds_t_defšed - - -141  -__su£cÚds_t - - tsu£cÚds_t -; - -142  - #__su£cÚds_t_defšed - - - ) - -146  - #__Ãed_size_t - - - ) - -147  - ~<¡ddef.h -> - -149 #ifdeà -__USE_MISC - - -151  - tulÚg -; - -152  - tushÜt -; - -153  - tušt -; - -158 #ià! -__GNUC_PREREQ - (2, 7) - -161 #iâdeà -__št8_t_defšed - - -162  - #__št8_t_defšed - - - ) - -163  - tšt8_t -; - -164  - tšt16_t -; - -165  - tšt32_t -; - -166 #ià -__WORDSIZE - == 64 - -167  - tšt64_t -; - -168 #–ià -__GLIBC_HAVE_LONG_LONG - - -169 -__ex‹nsiÚ__ -  - tšt64_t -; - -174  - tu_št8_t -; - -175  - tu_št16_t -; - -176  - tu_št32_t -; - -177 #ià -__WORDSIZE - == 64 - -178  - tu_št64_t -; - -179 #–ià -__GLIBC_HAVE_LONG_LONG - - -180 -__ex‹nsiÚ__ -  - tu_št64_t -; - -183  - t»gi¡”_t -; - -188  - #__štN_t -( -N -, -MODE -) \ - -189 ## - tN -## - t_t - - t__©Œibu‹__ - (( - t__mode__ - ( - tMODE -))) - - ) - -190  - t__u_štN_t -( - tN -, - tMODE -) \ - -191  - tu_št -## - tN -## - t_t - - t__©Œibu‹__ - (( - t__mode__ - ( - tMODE -))) - - ) - -193 #iâdeà - t__št8_t_defšed - - -194  - t__št8_t_defšed - - - ) - -195 - t__štN_t - (8, - t__QI__ -); - -196 -__štN_t - (16, -__HI__ -); - -197 -__štN_t - (32, -__SI__ -); - -198 -__štN_t - (64, -__DI__ -); - -201 -__u_štN_t - (8, -__QI__ -); - -202 -__u_štN_t - (16, -__HI__ -); - -203 -__u_štN_t - (32, -__SI__ -); - -204 -__u_štN_t - (64, -__DI__ -); - -206  - t»gi¡”_t - - t__©Œibu‹__ - (( - t__mode__ - ( - t__wÜd__ -))); - -212  - #__BIT_TYPES_DEFINED__ - 1 - - ) - -215 #ifdef -__USE_BSD - - -217  - ~<’dŸn.h -> - -220  - ~ - -223  - ~ - -227 #ià( -defšed - -__USE_UNIX98 - || defšed -__USE_XOPEN2K8 -) \ - -228 && ! -defšed - -__blksize_t_defšed - - -229  -__blksize_t - - tblksize_t -; - -230  - #__blksize_t_defšed - - - ) - -234 #iâdeà -__USE_FILE_OFFSET64 - - -235 #iâdeà -__blkút_t_defšed - - -236  -__blkút_t - - tblkút_t -; - -237  - #__blkút_t_defšed - - - ) - -239 #iâdeà -__fsblkút_t_defšed - - -240  -__fsblkút_t - - tfsblkút_t -; - -241  - #__fsblkút_t_defšed - - - ) - -243 #iâdeà -__fsfžút_t_defšed - - -244  -__fsfžút_t - - tfsfžút_t -; - -245  - #__fsfžút_t_defšed - - - ) - -248 #iâdeà -__blkút_t_defšed - - -249  -__blkút64_t - - tblkút_t -; - -250  - #__blkút_t_defšed - - - ) - -252 #iâdeà -__fsblkút_t_defšed - - -253  -__fsblkút64_t - - tfsblkút_t -; - -254  - #__fsblkút_t_defšed - - - ) - -256 #iâdeà -__fsfžút_t_defšed - - -257  -__fsfžút64_t - - tfsfžút_t -; - -258  - #__fsfžút_t_defšed - - - ) - -262 #ifdeà -__USE_LARGEFILE64 - - -263  -__blkút64_t - - tblkút64_t -; - -264  -__fsblkút64_t - - tfsblkút64_t -; - -265  -__fsfžút64_t - - tfsfžút64_t -; - -270 #ià -defšed - -__USE_POSIX199506 - || defšed -__USE_UNIX98 - - -271  - ~ - -274 - g__END_DECLS - - - @/usr/include/sys/un.h - -19 #iâdef -_SYS_UN_H - - -20  - #_SYS_UN_H - 1 - - ) - -22  - ~ - -25  - ~ - -27 -__BEGIN_DECLS - - -30  - ssockaddr_un - - -32 -__SOCKADDR_COMMON - ( -sun_ -); - -33  - msun_·th -[108]; - -37 #ifdeà -__USE_MISC - - -38  - ~<¡ršg.h -> - -41  - #SUN_LEN -( -±r -è(( -size_t -è((( -sockaddr_un - *è0)-> -sun_·th -) \ - -42 + - `¡¾’ - (( -±r -)-> -sun_·th -)) - - ) - -45 - g__END_DECLS - - - @/usr/include/unistd.h - -23 #iâdef -_UNISTD_H - - -24  - #_UNISTD_H - 1 - - ) - -26  - ~<ã©u»s.h -> - -28 - g__BEGIN_DECLS - - -33 #ifdeà -__USE_XOPEN2K8 - - -35  - #_POSIX_VERSION - 200809L - - ) - -36 #–ià -defšed - -__USE_XOPEN2K - - -38  - #_POSIX_VERSION - 200112L - - ) - -39 #–ià -defšed - -__USE_POSIX199506 - - -41  - #_POSIX_VERSION - 199506L - - ) - -42 #–ià -defšed - -__USE_POSIX199309 - - -44  - #_POSIX_VERSION - 199309L - - ) - -47  - #_POSIX_VERSION - 199009L - - ) - -53 #ifdeà -__USE_XOPEN2K8 - - -54  - #__POSIX2_THIS_VERSION - 200809L - - ) - -56 #–ià -defšed - -__USE_XOPEN2K - - -58  - #__POSIX2_THIS_VERSION - 200112L - - ) - -59 #–ià -defšed - -__USE_POSIX199506 - - -61  - #__POSIX2_THIS_VERSION - 199506L - - ) - -64  - #__POSIX2_THIS_VERSION - 199209L - - ) - -68  - #_POSIX2_VERSION - -__POSIX2_THIS_VERSION - - - ) - -72  - #_POSIX2_C_BIND - -__POSIX2_THIS_VERSION - - - ) - -76  - #_POSIX2_C_DEV - -__POSIX2_THIS_VERSION - - - ) - -80  - #_POSIX2_SW_DEV - -__POSIX2_THIS_VERSION - - - ) - -84  - #_POSIX2_LOCALEDEF - -__POSIX2_THIS_VERSION - - - ) - -87 #ifdeà -__USE_XOPEN2K8 - - -88  - #_XOPEN_VERSION - 700 - - ) - -89 #–ià -defšed - -__USE_XOPEN2K - - -90  - #_XOPEN_VERSION - 600 - - ) - -91 #–ià -defšed - -__USE_UNIX98 - - -92  - #_XOPEN_VERSION - 500 - - ) - -94  - #_XOPEN_VERSION - 4 - - ) - -98  - #_XOPEN_XCU_VERSION - 4 - - ) - -101  - #_XOPEN_XPG2 - 1 - - ) - -102  - #_XOPEN_XPG3 - 1 - - ) - -103  - #_XOPEN_XPG4 - 1 - - ) - -106  - #_XOPEN_UNIX - 1 - - ) - -109  - #_XOPEN_CRYPT - 1 - - ) - -113  - #_XOPEN_ENH_I18N - 1 - - ) - -116  - #_XOPEN_LEGACY - 1 - - ) - -203  - ~ - -206 #ià -defšed - -__USE_UNIX98 - || defšed -__USE_XOPEN2K - - -207  - ~ - -211  - #STDIN_FILENO - 0 - - ) - -212  - #STDOUT_FILENO - 1 - - ) - -213  - #STDERR_FILENO - 2 - - ) - -218  - ~ - -220 #iâdef -__ssize_t_defšed - - -221  -__ssize_t - - tssize_t -; - -222  - #__ssize_t_defšed - - - ) - -225  - #__Ãed_size_t - - - ) - -226  - #__Ãed_NULL - - - ) - -227  - ~<¡ddef.h -> - -229 #ià -defšed - -__USE_XOPEN - || defšed -__USE_XOPEN2K - - -232 #iâdeà -__gid_t_defšed - - -233  -__gid_t - - tgid_t -; - -234  - #__gid_t_defšed - - - ) - -237 #iâdeà -__uid_t_defšed - - -238  -__uid_t - - tuid_t -; - -239  - #__uid_t_defšed - - - ) - -242 #iâdeà -__off_t_defšed - - -243 #iâdeà -__USE_FILE_OFFSET64 - - -244  -__off_t - - toff_t -; - -246  -__off64_t - - toff_t -; - -248  - #__off_t_defšed - - - ) - -250 #ià -defšed - -__USE_LARGEFILE64 - && !defšed -__off64_t_defšed - - -251  -__off64_t - - toff64_t -; - -252  - #__off64_t_defšed - - - ) - -255 #iâdeà -__u£cÚds_t_defšed - - -256  -__u£cÚds_t - - tu£cÚds_t -; - -257  - #__u£cÚds_t_defšed - - - ) - -260 #iâdeà -__pid_t_defšed - - -261  -__pid_t - - tpid_t -; - -262  - #__pid_t_defšed - - - ) - -266 #ià -defšed - -__USE_MISC - || defšed -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K - - -267 #iâdeà -__šŒ_t_defšed - - -268  -__šŒ_t - - tšŒ_t -; - -269  - #__šŒ_t_defšed - - - ) - -273 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN - - -274 #iâdeà -__sockËn_t_defšed - - -275  -__sockËn_t - - tsockËn_t -; - -276  - #__sockËn_t_defšed - - - ) - -282  - #R_OK - 4 - - ) - -283  - #W_OK - 2 - - ) - -284  - #X_OK - 1 - - ) - -285  - #F_OK - 0 - - ) - -288  - $acûss - ( -__cÚ¡ - * -__Çme -,  -__ty³ -è -__THROW - - `__nÚnuÎ - ((1)); - -290 #ifdeà -__USE_GNU - - -293  - $euidacûss - ( -__cÚ¡ - * -__Çme -,  -__ty³ -) - -294 -__THROW - - `__nÚnuÎ - ((1)); - -297  - $—cûss - ( -__cÚ¡ - * -__Çme -,  -__ty³ -) - -298 -__THROW - - `__nÚnuÎ - ((1)); - -301 #ifdeà -__USE_ATFILE - - -305  - $çcûs§t - ( -__fd -, -__cÚ¡ - * -__fže -,  -__ty³ -,  -__æag -) - -306 -__THROW - - `__nÚnuÎ - ((2)è -__wur -; - -311 #iâdef -_STDIO_H - - -312  - #SEEK_SET - 0 - - ) - -313  - #SEEK_CUR - 1 - - ) - -314  - #SEEK_END - 2 - - ) - -317 #ià -defšed - -__USE_BSD - && !defšed -L_SET - - -319  - #L_SET - -SEEK_SET - - - ) - -320  - #L_INCR - -SEEK_CUR - - - ) - -321  - #L_XTND - -SEEK_END - - - ) - -330 #iâdeà -__USE_FILE_OFFSET64 - - -331 -__off_t - - $l£ek - ( -__fd -, -__off_t - -__off£t -,  -__wh’û -è -__THROW -; - -333 #ifdeà -__REDIRECT_NTH - - -334 -__off64_t - - `__REDIRECT_NTH - ( -l£ek -, - -335 ( -__fd -, -__off64_t - -__off£t -,  -__wh’û -), - -336 -l£ek64 -); - -338  - #l£ek - -l£ek64 - - - ) - -341 #ifdeà -__USE_LARGEFILE64 - - -342 -__off64_t - - $l£ek64 - ( -__fd -, -__off64_t - -__off£t -,  -__wh’û -) - -343 -__THROW -; - -350  - `þo£ - ( -__fd -); - -357 -ssize_t - - $»ad - ( -__fd -, * -__buf -, -size_t - -__nby‹s -è -__wur -; - -363 -ssize_t - - $wr™e - ( -__fd -, -__cÚ¡ - * -__buf -, -size_t - -__n -è -__wur -; - -365 #ià -defšed - -__USE_UNIX98 - || defšed -__USE_XOPEN2K8 - - -366 #iâdeà -__USE_FILE_OFFSET64 - - -373 -ssize_t - - $´—d - ( -__fd -, * -__buf -, -size_t - -__nby‹s -, - -374 -__off_t - -__off£t -è -__wur -; - -381 -ssize_t - - $pwr™e - ( -__fd -, -__cÚ¡ - * -__buf -, -size_t - -__n -, - -382 -__off_t - -__off£t -è -__wur -; - -384 #ifdeà -__REDIRECT - - -385 -ssize_t - - `__REDIRECT - ( -´—d -, ( -__fd -, * -__buf -, -size_t - -__nby‹s -, - -386 -__off64_t - -__off£t -), - -387 -´—d64 -è -__wur -; - -388 -ssize_t - - `__REDIRECT - ( -pwr™e -, ( -__fd -, -__cÚ¡ - * -__buf -, - -389 -size_t - -__nby‹s -, -__off64_t - -__off£t -), - -390 -pwr™e64 -è -__wur -; - -392  - #´—d - -´—d64 - - - ) - -393  - #pwr™e - -pwr™e64 - - - ) - -397 #ifdeà -__USE_LARGEFILE64 - - -401 -ssize_t - - $´—d64 - ( -__fd -, * -__buf -, -size_t - -__nby‹s -, - -402 -__off64_t - -__off£t -è -__wur -; - -405 -ssize_t - - $pwr™e64 - ( -__fd -, -__cÚ¡ - * -__buf -, -size_t - -__n -, - -406 -__off64_t - -__off£t -è -__wur -; - -414  - $pe - ( -__pedes -[2]è -__THROW - -__wur -; - -416 #ifdeà -__USE_GNU - - -419  - $pe2 - ( -__pedes -[2],  -__æags -è -__THROW - -__wur -; - -429  - $®¬m - ( -__£cÚds -è -__THROW -; - -441  - `¦“p - ( -__£cÚds -); - -443 #ià( -defšed - -__USE_XOPEN_EXTENDED - && !defšed -__USE_XOPEN2K8 -) \ - -444 || -defšed - -__USE_BSD - - -449 -__u£cÚds_t - - $u®¬m - ( -__u£cÚds_t - -__v®ue -, __u£cÚds_ˆ -__š‹rv® -) - -450 -__THROW -; - -457  - `u¦“p - ( -__u£cÚds_t - -__u£cÚds -); - -466  - `·u£ - (); - -470  - $chown - ( -__cÚ¡ - * -__fže -, -__uid_t - -__owÃr -, -__gid_t - -__group -) - -471 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -473 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K8 - - -475  - $fchown - ( -__fd -, -__uid_t - -__owÃr -, -__gid_t - -__group -è -__THROW - -__wur -; - -480  - $lchown - ( -__cÚ¡ - * -__fže -, -__uid_t - -__owÃr -, -__gid_t - -__group -) - -481 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -485 #ifdeà -__USE_ATFILE - - -488  - $fchowÇt - ( -__fd -, -__cÚ¡ - * -__fže -, -__uid_t - -__owÃr -, - -489 -__gid_t - -__group -,  -__æag -) - -490 -__THROW - - `__nÚnuÎ - ((2)è -__wur -; - -494  - $chdœ - ( -__cÚ¡ - * -__·th -è -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -496 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K8 - - -498  - $fchdœ - ( -__fd -è -__THROW - -__wur -; - -508 * - $g‘cwd - (* -__buf -, -size_t - -__size -è -__THROW - -__wur -; - -510 #ifdef -__USE_GNU - - -514 * - $g‘_cu¼’t_dœ_Çme - (è -__THROW -; - -517 #ià( -defšed - -__USE_XOPEN_EXTENDED - && !defšed -__USE_XOPEN2K8 -) \ - -518 || -defšed - -__USE_BSD - - -522 * - $g‘wd - (* -__buf -) - -523 -__THROW - - `__nÚnuÎ - ((1)è -__©Œibu‹_d•»ÿ‹d__ - -__wur -; - -528  - $dup - ( -__fd -è -__THROW - -__wur -; - -531  - $dup2 - ( -__fd -,  -__fd2 -è -__THROW -; - -533 #ifdeà -__USE_GNU - - -536  - $dup3 - ( -__fd -,  -__fd2 -,  -__æags -è -__THROW -; - -540 ** -__’vœÚ -; - -541 #ifdeà -__USE_GNU - - -542 ** -’vœÚ -; - -548  - $execve - ( -__cÚ¡ - * -__·th -, *__cÚ¡ -__¬gv -[], - -549 * -__cÚ¡ - -__’vp -[]è -__THROW - - `__nÚnuÎ - ((1, 2)); - -551 #ifdeà -__USE_XOPEN2K8 - - -554  - $ãxecve - ( -__fd -, * -__cÚ¡ - -__¬gv -[], *__cÚ¡ -__’vp -[]) - -555 -__THROW - - `__nÚnuÎ - ((2)); - -560  - $execv - ( -__cÚ¡ - * -__·th -, *__cÚ¡ -__¬gv -[]) - -561 -__THROW - - `__nÚnuÎ - ((1, 2)); - -565  - $exeþe - ( -__cÚ¡ - * -__·th -, __cÚ¡ * -__¬g -, ...) - -566 -__THROW - - `__nÚnuÎ - ((1, 2)); - -570  - $exeþ - ( -__cÚ¡ - * -__·th -, __cÚ¡ * -__¬g -, ...) - -571 -__THROW - - `__nÚnuÎ - ((1, 2)); - -575  - $execvp - ( -__cÚ¡ - * -__fže -, *__cÚ¡ -__¬gv -[]) - -576 -__THROW - - `__nÚnuÎ - ((1, 2)); - -581  - $exeþp - ( -__cÚ¡ - * -__fže -, __cÚ¡ * -__¬g -, ...) - -582 -__THROW - - `__nÚnuÎ - ((1, 2)); - -584 #ifdeà -__USE_GNU - - -587  - $execv³ - ( -__cÚ¡ - * -__fže -, *__cÚ¡ -__¬gv -[], - -588 * -__cÚ¡ - -__’vp -[]) - -589 -__THROW - - `__nÚnuÎ - ((1, 2)); - -593 #ià -defšed - -__USE_MISC - || defšed -__USE_XOPEN - - -595  - $niû - ( -__šc -è -__THROW - -__wur -; - -600  - $_ex™ - ( -__¡©us -è - `__©Œibu‹__ - (( -__nܑuº__ -)); - -606  - ~ - -609  - $·thcÚf - ( -__cÚ¡ - * -__·th -,  -__Çme -) - -610 -__THROW - - `__nÚnuÎ - ((1)); - -613  - $å©hcÚf - ( -__fd -,  -__Çme -è -__THROW -; - -616  - $syscÚf - ( -__Çme -è -__THROW -; - -618 #ifdef -__USE_POSIX2 - - -620 -size_t - - $cÚf¡r - ( -__Çme -, * -__buf -, -size_t - -__Ën -è -__THROW -; - -625 -__pid_t - - $g‘pid - (è -__THROW -; - -628 -__pid_t - - $g‘µid - (è -__THROW -; - -632 #iâdeà -__FAVOR_BSD - - -633 -__pid_t - - $g‘pg½ - (è -__THROW -; - -635 #ifdeà -__REDIRECT_NTH - - -636 -__pid_t - - `__REDIRECT_NTH - ( -g‘pg½ -, (__pid_ˆ -__pid -), -__g‘pgid -); - -638  - #g‘pg½ - -__g‘pgid - - - ) - -643 -__pid_t - - $__g‘pgid - ( -__pid_t - -__pid -è -__THROW -; - -644 #ià -defšed - -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K8 - - -645 -__pid_t - - $g‘pgid - ( -__pid_t - -__pid -è -__THROW -; - -652  - $£gid - ( -__pid_t - -__pid -, __pid_ˆ -__pgid -è -__THROW -; - -654 #ià -defšed - -__USE_SVID - || defšed -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - - -665 #iâdeà -__FAVOR_BSD - - -669  - $£g½ - (è -__THROW -; - -674 #ifdeà -__REDIRECT_NTH - - -675  - `__REDIRECT_NTH - ( -£g½ -, ( -__pid_t - -__pid -, __pid_ˆ -__pg½ -), -£gid -); - -677  - #£g½ - -£gid - - - ) - -686 -__pid_t - - $£tsid - (è -__THROW -; - -688 #ià -defšed - -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K8 - - -690 -__pid_t - - $g‘sid - ( -__pid_t - -__pid -è -__THROW -; - -694 -__uid_t - - $g‘uid - (è -__THROW -; - -697 -__uid_t - - $g‘euid - (è -__THROW -; - -700 -__gid_t - - $g‘gid - (è -__THROW -; - -703 -__gid_t - - $g‘egid - (è -__THROW -; - -708  - $g‘groups - ( -__size -, -__gid_t - -__li¡ -[]è -__THROW - -__wur -; - -710 #ifdef -__USE_GNU - - -712  - $group_memb” - ( -__gid_t - -__gid -è -__THROW -; - -719  - $£tuid - ( -__uid_t - -__uid -è -__THROW -; - -721 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - - -724  - $£Œeuid - ( -__uid_t - -__ruid -, __uid_ˆ -__euid -è -__THROW -; - -727 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN2K - - -729  - $£‹uid - ( -__uid_t - -__uid -è -__THROW -; - -736  - $£tgid - ( -__gid_t - -__gid -è -__THROW -; - -738 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - - -741  - $£Œegid - ( -__gid_t - -__rgid -, __gid_ˆ -__egid -è -__THROW -; - -744 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN2K - - -746  - $£‹gid - ( -__gid_t - -__gid -è -__THROW -; - -749 #ifdeà -__USE_GNU - - -752  - $g‘»suid - ( -__uid_t - * -__ruid -, __uid_ˆ* -__euid -, __uid_ˆ* -__suid -) - -753 -__THROW -; - -757  - $g‘»sgid - ( -__gid_t - * -__rgid -, __gid_ˆ* -__egid -, __gid_ˆ* -__sgid -) - -758 -__THROW -; - -762  - $£Œesuid - ( -__uid_t - -__ruid -, __uid_ˆ -__euid -, __uid_ˆ -__suid -) - -763 -__THROW -; - -767  - $£Œesgid - ( -__gid_t - -__rgid -, __gid_ˆ -__egid -, __gid_ˆ -__sgid -) - -768 -__THROW -; - -775 -__pid_t - - $fÜk - (è -__THROW -; - -777 #ià( -defšed - -__USE_XOPEN_EXTENDED - && !defšed -__USE_XOPEN2K8 -) \ - -778 || -defšed - -__USE_BSD - - -783 -__pid_t - - $vfÜk - (è -__THROW -; - -789 * - $‰yÇme - ( -__fd -è -__THROW -; - -793  - $‰yÇme_r - ( -__fd -, * -__buf -, -size_t - -__buæ’ -) - -794 -__THROW - - `__nÚnuÎ - ((2)è -__wur -; - -798  - $i§‰y - ( -__fd -è -__THROW -; - -800 #ià -defšed - -__USE_BSD - \ - -801 || ( -defšed - -__USE_XOPEN_EXTENDED - && !defšed -__USE_UNIX98 -) - -804  - $‰y¦Ù - (è -__THROW -; - -809  - $lšk - ( -__cÚ¡ - * -__äom -, __cÚ¡ * -__to -) - -810 -__THROW - - `__nÚnuÎ - ((1, 2)è -__wur -; - -812 #ifdeà -__USE_ATFILE - - -815  - $lšk© - ( -__äomfd -, -__cÚ¡ - * -__äom -,  -__tofd -, - -816 -__cÚ¡ - * -__to -,  -__æags -) - -817 -__THROW - - `__nÚnuÎ - ((2, 4)è -__wur -; - -820 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K - - -822  - $symlšk - ( -__cÚ¡ - * -__äom -, __cÚ¡ * -__to -) - -823 -__THROW - - `__nÚnuÎ - ((1, 2)è -__wur -; - -828 -ssize_t - - $»adlšk - ( -__cÚ¡ - * -__»¡riù - -__·th -, - -829 * -__»¡riù - -__buf -, -size_t - -__Ën -) - -830 -__THROW - - `__nÚnuÎ - ((1, 2)è -__wur -; - -833 #ifdeà -__USE_ATFILE - - -835  - $symlšk© - ( -__cÚ¡ - * -__äom -,  -__tofd -, - -836 -__cÚ¡ - * -__to -è -__THROW - - `__nÚnuÎ - ((1, 3)è -__wur -; - -839 -ssize_t - - $»adlšk© - ( -__fd -, -__cÚ¡ - * -__»¡riù - -__·th -, - -840 * -__»¡riù - -__buf -, -size_t - -__Ën -) - -841 -__THROW - - `__nÚnuÎ - ((2, 3)è -__wur -; - -845  - $uƚk - ( -__cÚ¡ - * -__Çme -è -__THROW - - `__nÚnuÎ - ((1)); - -847 #ifdeà -__USE_ATFILE - - -849  - $uƚk© - ( -__fd -, -__cÚ¡ - * -__Çme -,  -__æag -) - -850 -__THROW - - `__nÚnuÎ - ((2)); - -854  - $rmdœ - ( -__cÚ¡ - * -__·th -è -__THROW - - `__nÚnuÎ - ((1)); - -858 -__pid_t - - $tcg‘pg½ - ( -__fd -è -__THROW -; - -861  - $tc£g½ - ( -__fd -, -__pid_t - -__pg½_id -è -__THROW -; - -868 * - `g‘logš - (); - -869 #ià -defšed - -__USE_REENTRANT - || defšed -__USE_POSIX199506 - - -876  - $g‘logš_r - (* -__Çme -, -size_t - -__Çme_Ën -è - `__nÚnuÎ - ((1)); - -879 #ifdef -__USE_BSD - - -881  - $£Žogš - ( -__cÚ¡ - * -__Çme -è -__THROW - - `__nÚnuÎ - ((1)); - -885 #ifdef -__USE_POSIX2 - - -889  - #__Ãed_g‘Ýt - - - ) - -890  - ~ - -894 #ià -defšed - -__USE_BSD - || defšed -__USE_UNIX98 - || defšed -__USE_XOPEN2K - - -898  - $g‘ho¡Çme - (* -__Çme -, -size_t - -__Ën -è -__THROW - - `__nÚnuÎ - ((1)); - -902 #ià -defšed - -__USE_BSD - || (defšed -__USE_XOPEN - && !defšed -__USE_UNIX98 -) - -905  - $£tho¡Çme - ( -__cÚ¡ - * -__Çme -, -size_t - -__Ën -) - -906 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -910  - $£tho¡id - ( -__id -è -__THROW - -__wur -; - -916  - $g‘domašÇme - (* -__Çme -, -size_t - -__Ën -) - -917 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -918  - $£tdomašÇme - ( -__cÚ¡ - * -__Çme -, -size_t - -__Ën -) - -919 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -925  - $vhªgup - (è -__THROW -; - -928  - $»voke - ( -__cÚ¡ - * -__fže -è -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -936  - $´ofž - (* -__§m¶e_bufãr -, -size_t - -__size -, - -937 -size_t - -__off£t -,  -__sÿË -) - -938 -__THROW - - `__nÚnuÎ - ((1)); - -944  - $acù - ( -__cÚ¡ - * -__Çme -è -__THROW -; - -948 * - $g‘u£rsh–l - (è -__THROW -; - -949  - $’du£rsh–l - (è -__THROW -; - -950  - $£tu£rsh–l - (è -__THROW -; - -956  - $d«mÚ - ( -__nochdœ -,  -__noþo£ -è -__THROW - -__wur -; - -960 #ià -defšed - -__USE_BSD - || (defšed -__USE_XOPEN - && !defšed -__USE_XOPEN2K -) - -963  - $chroÙ - ( -__cÚ¡ - * -__·th -è -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -967 * - $g‘·ss - ( -__cÚ¡ - * -__´om± -è - `__nÚnuÎ - ((1)); - -971 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN - || defšed -__USE_XOPEN2K - - -976  - `fsync - ( -__fd -); - -980 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - - -983  - `g‘ho¡id - (); - -986  - $sync - (è -__THROW -; - -989 #ià -defšed - -__USE_BSD - || !defšed -__USE_XOPEN2K - - -992  - $g‘·gesize - (è -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)); - -997  - $g‘dbËsize - (è -__THROW -; - -1003 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K8 - - -1006 #iâdeà -__USE_FILE_OFFSET64 - - -1007  - $Œunÿ‹ - ( -__cÚ¡ - * -__fže -, -__off_t - -__Ëngth -) - -1008 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -1010 #ifdeà -__REDIRECT_NTH - - -1011  - `__REDIRECT_NTH - ( -Œunÿ‹ -, - -1012 ( -__cÚ¡ - * -__fže -, -__off64_t - -__Ëngth -), - -1013 -Œunÿ‹64 -è - `__nÚnuÎ - ((1)è -__wur -; - -1015  - #Œunÿ‹ - -Œunÿ‹64 - - - ) - -1018 #ifdeà -__USE_LARGEFILE64 - - -1019  - $Œunÿ‹64 - ( -__cÚ¡ - * -__fže -, -__off64_t - -__Ëngth -) - -1020 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -1025 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K - - -1028 #iâdeà -__USE_FILE_OFFSET64 - - -1029  - $árunÿ‹ - ( -__fd -, -__off_t - -__Ëngth -è -__THROW - -__wur -; - -1031 #ifdeà -__REDIRECT_NTH - - -1032  - `__REDIRECT_NTH - ( -árunÿ‹ -, ( -__fd -, -__off64_t - -__Ëngth -), - -1033 -árunÿ‹64 -è -__wur -; - -1035  - #árunÿ‹ - -árunÿ‹64 - - - ) - -1038 #ifdeà -__USE_LARGEFILE64 - - -1039  - $árunÿ‹64 - ( -__fd -, -__off64_t - -__Ëngth -è -__THROW - -__wur -; - -1045 #ià( -defšed - -__USE_XOPEN_EXTENDED - && !defšed -__USE_XOPEN2K -) \ - -1046 || -defšed - -__USE_MISC - - -1050  - $brk - (* -__addr -è -__THROW - -__wur -; - -1056 * - $sbrk - ( -šŒ_t - -__d– -è -__THROW -; - -1060 #ifdeà -__USE_MISC - - -1071  - $sysÿÎ - ( -__sy¢o -, ...è -__THROW -; - -1076 #ià( -defšed - -__USE_MISC - || defšed -__USE_XOPEN_EXTENDED -è&& !defšed -F_LOCK - - -1088  - #F_ULOCK - 0 - - ) - -1089  - #F_LOCK - 1 - - ) - -1090  - #F_TLOCK - 2 - - ) - -1091  - #F_TEST - 3 - - ) - -1093 #iâdeà -__USE_FILE_OFFSET64 - - -1094  - $lockf - ( -__fd -,  -__cmd -, -__off_t - -__Ën -è -__wur -; - -1096 #ifdeà -__REDIRECT - - -1097  - `__REDIRECT - ( -lockf -, ( -__fd -,  -__cmd -, -__off64_t - -__Ën -), - -1098 -lockf64 -è -__wur -; - -1100  - #lockf - -lockf64 - - - ) - -1103 #ifdeà -__USE_LARGEFILE64 - - -1104  - $lockf64 - ( -__fd -,  -__cmd -, -__off64_t - -__Ën -è -__wur -; - -1109 #ifdeà -__USE_GNU - - -1114  - #TEMP_FAILURE_RETRY -( -ex´essiÚ -) \ - -1115 ( -__ex‹nsiÚ__ - \ - -1116 ({  -__»suÉ -; \ - -1117 dØ -__»suÉ - = (è( -ex´essiÚ -); \ - -1118  -__»suÉ - =ð-1L && -”ºo - =ð -EINTR -); \ - -1119 -__»suÉ -; - } -})) - - ) - -1122 #ià -defšed - -__USE_POSIX199309 - || defšed -__USE_UNIX98 - - -1125  -fd©async - ( -__fždes -); - -1131 #ifdef -__USE_XOPEN - - -1133 * - $üy± - ( -__cÚ¡ - * -__key -, __cÚ¡ * -__§É -) - -1134 -__THROW - - `__nÚnuÎ - ((1, 2)); - -1138  - $’üy± - (* -__libc_block -,  -__edæag -è -__THROW - - `__nÚnuÎ - ((1)); - -1145  - $swab - ( -__cÚ¡ - * -__»¡riù - -__äom -, *__»¡riù -__to -, - -1146 -ssize_t - -__n -è -__THROW - - `__nÚnuÎ - ((1, 2)); - -1152 #ià -defšed - -__USE_XOPEN - || defšed -__USE_XOPEN2K8 - - -1154 * - $ù”mid - (* -__s -è -__THROW -; - -1159 #ià -__USE_FORTIFY_LEVEL - > 0 && -defšed - -__ex‹º_®ways_šlše - - -1160  - ~ - -1163 -__END_DECLS - - - @/usr/include/alloca.h - -19 #iâdef -_ALLOCA_H - - -20  - #_ALLOCA_H - 1 - - ) - -22  - ~<ã©u»s.h -> - -24  - #__Ãed_size_t - - - ) - -25  - ~<¡ddef.h -> - -27 - g__BEGIN_DECLS - - -30 #undeà -®loÿ - - -33 * - $®loÿ - ( -size_t - -__size -è -__THROW -; - -35 #ifdef -__GNUC__ - - -36  - #®loÿ -( -size -è - `__bužtš_®loÿ - (size) - - ) - -39 -__END_DECLS - - - @/usr/include/bits/confname.h - -21 #iâdeà -_UNISTD_H - - -28 - m_PC_LINK_MAX -, - -29  - #_PC_LINK_MAX - -_PC_LINK_MAX - - - ) - -30 - m_PC_MAX_CANON -, - -31  - #_PC_MAX_CANON - -_PC_MAX_CANON - - - ) - -32 - m_PC_MAX_INPUT -, - -33  - #_PC_MAX_INPUT - -_PC_MAX_INPUT - - - ) - -34 - m_PC_NAME_MAX -, - -35  - #_PC_NAME_MAX - -_PC_NAME_MAX - - - ) - -36 - m_PC_PATH_MAX -, - -37  - #_PC_PATH_MAX - -_PC_PATH_MAX - - - ) - -38 - m_PC_PIPE_BUF -, - -39  - #_PC_PIPE_BUF - -_PC_PIPE_BUF - - - ) - -40 - m_PC_CHOWN_RESTRICTED -, - -41  - #_PC_CHOWN_RESTRICTED - -_PC_CHOWN_RESTRICTED - - - ) - -42 - m_PC_NO_TRUNC -, - -43  - #_PC_NO_TRUNC - -_PC_NO_TRUNC - - - ) - -44 - m_PC_VDISABLE -, - -45  - #_PC_VDISABLE - -_PC_VDISABLE - - - ) - -46 - m_PC_SYNC_IO -, - -47  - #_PC_SYNC_IO - -_PC_SYNC_IO - - - ) - -48 - m_PC_ASYNC_IO -, - -49  - #_PC_ASYNC_IO - -_PC_ASYNC_IO - - - ) - -50 - m_PC_PRIO_IO -, - -51  - #_PC_PRIO_IO - -_PC_PRIO_IO - - - ) - -52 - m_PC_SOCK_MAXBUF -, - -53  - #_PC_SOCK_MAXBUF - -_PC_SOCK_MAXBUF - - - ) - -54 - m_PC_FILESIZEBITS -, - -55  - #_PC_FILESIZEBITS - -_PC_FILESIZEBITS - - - ) - -56 - m_PC_REC_INCR_XFER_SIZE -, - -57  - #_PC_REC_INCR_XFER_SIZE - -_PC_REC_INCR_XFER_SIZE - - - ) - -58 - m_PC_REC_MAX_XFER_SIZE -, - -59  - #_PC_REC_MAX_XFER_SIZE - -_PC_REC_MAX_XFER_SIZE - - - ) - -60 - m_PC_REC_MIN_XFER_SIZE -, - -61  - #_PC_REC_MIN_XFER_SIZE - -_PC_REC_MIN_XFER_SIZE - - - ) - -62 - m_PC_REC_XFER_ALIGN -, - -63  - #_PC_REC_XFER_ALIGN - -_PC_REC_XFER_ALIGN - - - ) - -64 - m_PC_ALLOC_SIZE_MIN -, - -65  - #_PC_ALLOC_SIZE_MIN - -_PC_ALLOC_SIZE_MIN - - - ) - -66 - m_PC_SYMLINK_MAX -, - -67  - #_PC_SYMLINK_MAX - -_PC_SYMLINK_MAX - - - ) - -68 - m_PC_2_SYMLINKS - - -69  - #_PC_2_SYMLINKS - -_PC_2_SYMLINKS - - - ) - -75 - m_SC_ARG_MAX -, - -76  - #_SC_ARG_MAX - -_SC_ARG_MAX - - - ) - -77 - m_SC_CHILD_MAX -, - -78  - #_SC_CHILD_MAX - -_SC_CHILD_MAX - - - ) - -79 - m_SC_CLK_TCK -, - -80  - #_SC_CLK_TCK - -_SC_CLK_TCK - - - ) - -81 - m_SC_NGROUPS_MAX -, - -82  - #_SC_NGROUPS_MAX - -_SC_NGROUPS_MAX - - - ) - -83 - m_SC_OPEN_MAX -, - -84  - #_SC_OPEN_MAX - -_SC_OPEN_MAX - - - ) - -85 - m_SC_STREAM_MAX -, - -86  - #_SC_STREAM_MAX - -_SC_STREAM_MAX - - - ) - -87 - m_SC_TZNAME_MAX -, - -88  - #_SC_TZNAME_MAX - -_SC_TZNAME_MAX - - - ) - -89 - m_SC_JOB_CONTROL -, - -90  - #_SC_JOB_CONTROL - -_SC_JOB_CONTROL - - - ) - -91 - m_SC_SAVED_IDS -, - -92  - #_SC_SAVED_IDS - -_SC_SAVED_IDS - - - ) - -93 - m_SC_REALTIME_SIGNALS -, - -94  - #_SC_REALTIME_SIGNALS - -_SC_REALTIME_SIGNALS - - - ) - -95 - m_SC_PRIORITY_SCHEDULING -, - -96  - #_SC_PRIORITY_SCHEDULING - -_SC_PRIORITY_SCHEDULING - - - ) - -97 - m_SC_TIMERS -, - -98  - #_SC_TIMERS - -_SC_TIMERS - - - ) - -99 - m_SC_ASYNCHRONOUS_IO -, - -100  - #_SC_ASYNCHRONOUS_IO - -_SC_ASYNCHRONOUS_IO - - - ) - -101 - m_SC_PRIORITIZED_IO -, - -102  - #_SC_PRIORITIZED_IO - -_SC_PRIORITIZED_IO - - - ) - -103 - m_SC_SYNCHRONIZED_IO -, - -104  - #_SC_SYNCHRONIZED_IO - -_SC_SYNCHRONIZED_IO - - - ) - -105 - m_SC_FSYNC -, - -106  - #_SC_FSYNC - -_SC_FSYNC - - - ) - -107 - m_SC_MAPPED_FILES -, - -108  - #_SC_MAPPED_FILES - -_SC_MAPPED_FILES - - - ) - -109 - m_SC_MEMLOCK -, - -110  - #_SC_MEMLOCK - -_SC_MEMLOCK - - - ) - -111 - m_SC_MEMLOCK_RANGE -, - -112  - #_SC_MEMLOCK_RANGE - -_SC_MEMLOCK_RANGE - - - ) - -113 - m_SC_MEMORY_PROTECTION -, - -114  - #_SC_MEMORY_PROTECTION - -_SC_MEMORY_PROTECTION - - - ) - -115 - m_SC_MESSAGE_PASSING -, - -116  - #_SC_MESSAGE_PASSING - -_SC_MESSAGE_PASSING - - - ) - -117 - m_SC_SEMAPHORES -, - -118  - #_SC_SEMAPHORES - -_SC_SEMAPHORES - - - ) - -119 - m_SC_SHARED_MEMORY_OBJECTS -, - -120  - #_SC_SHARED_MEMORY_OBJECTS - -_SC_SHARED_MEMORY_OBJECTS - - - ) - -121 - m_SC_AIO_LISTIO_MAX -, - -122  - #_SC_AIO_LISTIO_MAX - -_SC_AIO_LISTIO_MAX - - - ) - -123 - m_SC_AIO_MAX -, - -124  - #_SC_AIO_MAX - -_SC_AIO_MAX - - - ) - -125 - m_SC_AIO_PRIO_DELTA_MAX -, - -126  - #_SC_AIO_PRIO_DELTA_MAX - -_SC_AIO_PRIO_DELTA_MAX - - - ) - -127 - m_SC_DELAYTIMER_MAX -, - -128  - #_SC_DELAYTIMER_MAX - -_SC_DELAYTIMER_MAX - - - ) - -129 - m_SC_MQ_OPEN_MAX -, - -130  - #_SC_MQ_OPEN_MAX - -_SC_MQ_OPEN_MAX - - - ) - -131 - m_SC_MQ_PRIO_MAX -, - -132  - #_SC_MQ_PRIO_MAX - -_SC_MQ_PRIO_MAX - - - ) - -133 - m_SC_VERSION -, - -134  - #_SC_VERSION - -_SC_VERSION - - - ) - -135 - m_SC_PAGESIZE -, - -136  - #_SC_PAGESIZE - -_SC_PAGESIZE - - - ) - -137  - #_SC_PAGE_SIZE - -_SC_PAGESIZE - - - ) - -138 - m_SC_RTSIG_MAX -, - -139  - #_SC_RTSIG_MAX - -_SC_RTSIG_MAX - - - ) - -140 - m_SC_SEM_NSEMS_MAX -, - -141  - #_SC_SEM_NSEMS_MAX - -_SC_SEM_NSEMS_MAX - - - ) - -142 - m_SC_SEM_VALUE_MAX -, - -143  - #_SC_SEM_VALUE_MAX - -_SC_SEM_VALUE_MAX - - - ) - -144 - m_SC_SIGQUEUE_MAX -, - -145  - #_SC_SIGQUEUE_MAX - -_SC_SIGQUEUE_MAX - - - ) - -146 - m_SC_TIMER_MAX -, - -147  - #_SC_TIMER_MAX - -_SC_TIMER_MAX - - - ) - -151 - m_SC_BC_BASE_MAX -, - -152  - #_SC_BC_BASE_MAX - -_SC_BC_BASE_MAX - - - ) - -153 - m_SC_BC_DIM_MAX -, - -154  - #_SC_BC_DIM_MAX - -_SC_BC_DIM_MAX - - - ) - -155 - m_SC_BC_SCALE_MAX -, - -156  - #_SC_BC_SCALE_MAX - -_SC_BC_SCALE_MAX - - - ) - -157 - m_SC_BC_STRING_MAX -, - -158  - #_SC_BC_STRING_MAX - -_SC_BC_STRING_MAX - - - ) - -159 - m_SC_COLL_WEIGHTS_MAX -, - -160  - #_SC_COLL_WEIGHTS_MAX - -_SC_COLL_WEIGHTS_MAX - - - ) - -161 - m_SC_EQUIV_CLASS_MAX -, - -162  - #_SC_EQUIV_CLASS_MAX - -_SC_EQUIV_CLASS_MAX - - - ) - -163 - m_SC_EXPR_NEST_MAX -, - -164  - #_SC_EXPR_NEST_MAX - -_SC_EXPR_NEST_MAX - - - ) - -165 - m_SC_LINE_MAX -, - -166  - #_SC_LINE_MAX - -_SC_LINE_MAX - - - ) - -167 - m_SC_RE_DUP_MAX -, - -168  - #_SC_RE_DUP_MAX - -_SC_RE_DUP_MAX - - - ) - -169 - m_SC_CHARCLASS_NAME_MAX -, - -170  - #_SC_CHARCLASS_NAME_MAX - -_SC_CHARCLASS_NAME_MAX - - - ) - -172 - m_SC_2_VERSION -, - -173  - #_SC_2_VERSION - -_SC_2_VERSION - - - ) - -174 - m_SC_2_C_BIND -, - -175  - #_SC_2_C_BIND - -_SC_2_C_BIND - - - ) - -176 - m_SC_2_C_DEV -, - -177  - #_SC_2_C_DEV - -_SC_2_C_DEV - - - ) - -178 - m_SC_2_FORT_DEV -, - -179  - #_SC_2_FORT_DEV - -_SC_2_FORT_DEV - - - ) - -180 - m_SC_2_FORT_RUN -, - -181  - #_SC_2_FORT_RUN - -_SC_2_FORT_RUN - - - ) - -182 - m_SC_2_SW_DEV -, - -183  - #_SC_2_SW_DEV - -_SC_2_SW_DEV - - - ) - -184 - m_SC_2_LOCALEDEF -, - -185  - #_SC_2_LOCALEDEF - -_SC_2_LOCALEDEF - - - ) - -187 - m_SC_PII -, - -188  - #_SC_PII - -_SC_PII - - - ) - -189 - m_SC_PII_XTI -, - -190  - #_SC_PII_XTI - -_SC_PII_XTI - - - ) - -191 - m_SC_PII_SOCKET -, - -192  - #_SC_PII_SOCKET - -_SC_PII_SOCKET - - - ) - -193 - m_SC_PII_INTERNET -, - -194  - #_SC_PII_INTERNET - -_SC_PII_INTERNET - - - ) - -195 - m_SC_PII_OSI -, - -196  - #_SC_PII_OSI - -_SC_PII_OSI - - - ) - -197 - m_SC_POLL -, - -198  - #_SC_POLL - -_SC_POLL - - - ) - -199 - m_SC_SELECT -, - -200  - #_SC_SELECT - -_SC_SELECT - - - ) - -201 - m_SC_UIO_MAXIOV -, - -202  - #_SC_UIO_MAXIOV - -_SC_UIO_MAXIOV - - - ) - -203 - m_SC_IOV_MAX - = -_SC_UIO_MAXIOV -, - -204  - #_SC_IOV_MAX - -_SC_IOV_MAX - - - ) - -205 - m_SC_PII_INTERNET_STREAM -, - -206  - #_SC_PII_INTERNET_STREAM - -_SC_PII_INTERNET_STREAM - - - ) - -207 - m_SC_PII_INTERNET_DGRAM -, - -208  - #_SC_PII_INTERNET_DGRAM - -_SC_PII_INTERNET_DGRAM - - - ) - -209 - m_SC_PII_OSI_COTS -, - -210  - #_SC_PII_OSI_COTS - -_SC_PII_OSI_COTS - - - ) - -211 - m_SC_PII_OSI_CLTS -, - -212  - #_SC_PII_OSI_CLTS - -_SC_PII_OSI_CLTS - - - ) - -213 - m_SC_PII_OSI_M -, - -214  - #_SC_PII_OSI_M - -_SC_PII_OSI_M - - - ) - -215 - m_SC_T_IOV_MAX -, - -216  - #_SC_T_IOV_MAX - -_SC_T_IOV_MAX - - - ) - -219 - m_SC_THREADS -, - -220  - #_SC_THREADS - -_SC_THREADS - - - ) - -221 - m_SC_THREAD_SAFE_FUNCTIONS -, - -222  - #_SC_THREAD_SAFE_FUNCTIONS - -_SC_THREAD_SAFE_FUNCTIONS - - - ) - -223 - m_SC_GETGR_R_SIZE_MAX -, - -224  - #_SC_GETGR_R_SIZE_MAX - -_SC_GETGR_R_SIZE_MAX - - - ) - -225 - m_SC_GETPW_R_SIZE_MAX -, - -226  - #_SC_GETPW_R_SIZE_MAX - -_SC_GETPW_R_SIZE_MAX - - - ) - -227 - m_SC_LOGIN_NAME_MAX -, - -228  - #_SC_LOGIN_NAME_MAX - -_SC_LOGIN_NAME_MAX - - - ) - -229 - m_SC_TTY_NAME_MAX -, - -230  - #_SC_TTY_NAME_MAX - -_SC_TTY_NAME_MAX - - - ) - -231 - m_SC_THREAD_DESTRUCTOR_ITERATIONS -, - -232  - #_SC_THREAD_DESTRUCTOR_ITERATIONS - -_SC_THREAD_DESTRUCTOR_ITERATIONS - - - ) - -233 - m_SC_THREAD_KEYS_MAX -, - -234  - #_SC_THREAD_KEYS_MAX - -_SC_THREAD_KEYS_MAX - - - ) - -235 - m_SC_THREAD_STACK_MIN -, - -236  - #_SC_THREAD_STACK_MIN - -_SC_THREAD_STACK_MIN - - - ) - -237 - m_SC_THREAD_THREADS_MAX -, - -238  - #_SC_THREAD_THREADS_MAX - -_SC_THREAD_THREADS_MAX - - - ) - -239 - m_SC_THREAD_ATTR_STACKADDR -, - -240  - #_SC_THREAD_ATTR_STACKADDR - -_SC_THREAD_ATTR_STACKADDR - - - ) - -241 - m_SC_THREAD_ATTR_STACKSIZE -, - -242  - #_SC_THREAD_ATTR_STACKSIZE - -_SC_THREAD_ATTR_STACKSIZE - - - ) - -243 - m_SC_THREAD_PRIORITY_SCHEDULING -, - -244  - #_SC_THREAD_PRIORITY_SCHEDULING - -_SC_THREAD_PRIORITY_SCHEDULING - - - ) - -245 - m_SC_THREAD_PRIO_INHERIT -, - -246  - #_SC_THREAD_PRIO_INHERIT - -_SC_THREAD_PRIO_INHERIT - - - ) - -247 - m_SC_THREAD_PRIO_PROTECT -, - -248  - #_SC_THREAD_PRIO_PROTECT - -_SC_THREAD_PRIO_PROTECT - - - ) - -249 - m_SC_THREAD_PROCESS_SHARED -, - -250  - #_SC_THREAD_PROCESS_SHARED - -_SC_THREAD_PROCESS_SHARED - - - ) - -252 - m_SC_NPROCESSORS_CONF -, - -253  - #_SC_NPROCESSORS_CONF - -_SC_NPROCESSORS_CONF - - - ) - -254 - m_SC_NPROCESSORS_ONLN -, - -255  - #_SC_NPROCESSORS_ONLN - -_SC_NPROCESSORS_ONLN - - - ) - -256 - m_SC_PHYS_PAGES -, - -257  - #_SC_PHYS_PAGES - -_SC_PHYS_PAGES - - - ) - -258 - m_SC_AVPHYS_PAGES -, - -259  - #_SC_AVPHYS_PAGES - -_SC_AVPHYS_PAGES - - - ) - -260 - m_SC_ATEXIT_MAX -, - -261  - #_SC_ATEXIT_MAX - -_SC_ATEXIT_MAX - - - ) - -262 - m_SC_PASS_MAX -, - -263  - #_SC_PASS_MAX - -_SC_PASS_MAX - - - ) - -265 - m_SC_XOPEN_VERSION -, - -266  - #_SC_XOPEN_VERSION - -_SC_XOPEN_VERSION - - - ) - -267 - m_SC_XOPEN_XCU_VERSION -, - -268  - #_SC_XOPEN_XCU_VERSION - -_SC_XOPEN_XCU_VERSION - - - ) - -269 - m_SC_XOPEN_UNIX -, - -270  - #_SC_XOPEN_UNIX - -_SC_XOPEN_UNIX - - - ) - -271 - m_SC_XOPEN_CRYPT -, - -272  - #_SC_XOPEN_CRYPT - -_SC_XOPEN_CRYPT - - - ) - -273 - m_SC_XOPEN_ENH_I18N -, - -274  - #_SC_XOPEN_ENH_I18N - -_SC_XOPEN_ENH_I18N - - - ) - -275 - m_SC_XOPEN_SHM -, - -276  - #_SC_XOPEN_SHM - -_SC_XOPEN_SHM - - - ) - -278 - m_SC_2_CHAR_TERM -, - -279  - #_SC_2_CHAR_TERM - -_SC_2_CHAR_TERM - - - ) - -280 - m_SC_2_C_VERSION -, - -281  - #_SC_2_C_VERSION - -_SC_2_C_VERSION - - - ) - -282 - m_SC_2_UPE -, - -283  - #_SC_2_UPE - -_SC_2_UPE - - - ) - -285 - m_SC_XOPEN_XPG2 -, - -286  - #_SC_XOPEN_XPG2 - -_SC_XOPEN_XPG2 - - - ) - -287 - m_SC_XOPEN_XPG3 -, - -288  - #_SC_XOPEN_XPG3 - -_SC_XOPEN_XPG3 - - - ) - -289 - m_SC_XOPEN_XPG4 -, - -290  - #_SC_XOPEN_XPG4 - -_SC_XOPEN_XPG4 - - - ) - -292 - m_SC_CHAR_BIT -, - -293  - #_SC_CHAR_BIT - -_SC_CHAR_BIT - - - ) - -294 - m_SC_CHAR_MAX -, - -295  - #_SC_CHAR_MAX - -_SC_CHAR_MAX - - - ) - -296 - m_SC_CHAR_MIN -, - -297  - #_SC_CHAR_MIN - -_SC_CHAR_MIN - - - ) - -298 - m_SC_INT_MAX -, - -299  - #_SC_INT_MAX - -_SC_INT_MAX - - - ) - -300 - m_SC_INT_MIN -, - -301  - #_SC_INT_MIN - -_SC_INT_MIN - - - ) - -302 - m_SC_LONG_BIT -, - -303  - #_SC_LONG_BIT - -_SC_LONG_BIT - - - ) - -304 - m_SC_WORD_BIT -, - -305  - #_SC_WORD_BIT - -_SC_WORD_BIT - - - ) - -306 - m_SC_MB_LEN_MAX -, - -307  - #_SC_MB_LEN_MAX - -_SC_MB_LEN_MAX - - - ) - -308 - m_SC_NZERO -, - -309  - #_SC_NZERO - -_SC_NZERO - - - ) - -310 - m_SC_SSIZE_MAX -, - -311  - #_SC_SSIZE_MAX - -_SC_SSIZE_MAX - - - ) - -312 - m_SC_SCHAR_MAX -, - -313  - #_SC_SCHAR_MAX - -_SC_SCHAR_MAX - - - ) - -314 - m_SC_SCHAR_MIN -, - -315  - #_SC_SCHAR_MIN - -_SC_SCHAR_MIN - - - ) - -316 - m_SC_SHRT_MAX -, - -317  - #_SC_SHRT_MAX - -_SC_SHRT_MAX - - - ) - -318 - m_SC_SHRT_MIN -, - -319  - #_SC_SHRT_MIN - -_SC_SHRT_MIN - - - ) - -320 - m_SC_UCHAR_MAX -, - -321  - #_SC_UCHAR_MAX - -_SC_UCHAR_MAX - - - ) - -322 - m_SC_UINT_MAX -, - -323  - #_SC_UINT_MAX - -_SC_UINT_MAX - - - ) - -324 - m_SC_ULONG_MAX -, - -325  - #_SC_ULONG_MAX - -_SC_ULONG_MAX - - - ) - -326 - m_SC_USHRT_MAX -, - -327  - #_SC_USHRT_MAX - -_SC_USHRT_MAX - - - ) - -329 - m_SC_NL_ARGMAX -, - -330  - #_SC_NL_ARGMAX - -_SC_NL_ARGMAX - - - ) - -331 - m_SC_NL_LANGMAX -, - -332  - #_SC_NL_LANGMAX - -_SC_NL_LANGMAX - - - ) - -333 - m_SC_NL_MSGMAX -, - -334  - #_SC_NL_MSGMAX - -_SC_NL_MSGMAX - - - ) - -335 - m_SC_NL_NMAX -, - -336  - #_SC_NL_NMAX - -_SC_NL_NMAX - - - ) - -337 - m_SC_NL_SETMAX -, - -338  - #_SC_NL_SETMAX - -_SC_NL_SETMAX - - - ) - -339 - m_SC_NL_TEXTMAX -, - -340  - #_SC_NL_TEXTMAX - -_SC_NL_TEXTMAX - - - ) - -342 - m_SC_XBS5_ILP32_OFF32 -, - -343  - #_SC_XBS5_ILP32_OFF32 - -_SC_XBS5_ILP32_OFF32 - - - ) - -344 - m_SC_XBS5_ILP32_OFFBIG -, - -345  - #_SC_XBS5_ILP32_OFFBIG - -_SC_XBS5_ILP32_OFFBIG - - - ) - -346 - m_SC_XBS5_LP64_OFF64 -, - -347  - #_SC_XBS5_LP64_OFF64 - -_SC_XBS5_LP64_OFF64 - - - ) - -348 - m_SC_XBS5_LPBIG_OFFBIG -, - -349  - #_SC_XBS5_LPBIG_OFFBIG - -_SC_XBS5_LPBIG_OFFBIG - - - ) - -351 - m_SC_XOPEN_LEGACY -, - -352  - #_SC_XOPEN_LEGACY - -_SC_XOPEN_LEGACY - - - ) - -353 - m_SC_XOPEN_REALTIME -, - -354  - #_SC_XOPEN_REALTIME - -_SC_XOPEN_REALTIME - - - ) - -355 - m_SC_XOPEN_REALTIME_THREADS -, - -356  - #_SC_XOPEN_REALTIME_THREADS - -_SC_XOPEN_REALTIME_THREADS - - - ) - -358 - m_SC_ADVISORY_INFO -, - -359  - #_SC_ADVISORY_INFO - -_SC_ADVISORY_INFO - - - ) - -360 - m_SC_BARRIERS -, - -361  - #_SC_BARRIERS - -_SC_BARRIERS - - - ) - -362 - m_SC_BASE -, - -363  - #_SC_BASE - -_SC_BASE - - - ) - -364 - m_SC_C_LANG_SUPPORT -, - -365  - #_SC_C_LANG_SUPPORT - -_SC_C_LANG_SUPPORT - - - ) - -366 - m_SC_C_LANG_SUPPORT_R -, - -367  - #_SC_C_LANG_SUPPORT_R - -_SC_C_LANG_SUPPORT_R - - - ) - -368 - m_SC_CLOCK_SELECTION -, - -369  - #_SC_CLOCK_SELECTION - -_SC_CLOCK_SELECTION - - - ) - -370 - m_SC_CPUTIME -, - -371  - #_SC_CPUTIME - -_SC_CPUTIME - - - ) - -372 - m_SC_THREAD_CPUTIME -, - -373  - #_SC_THREAD_CPUTIME - -_SC_THREAD_CPUTIME - - - ) - -374 - m_SC_DEVICE_IO -, - -375  - #_SC_DEVICE_IO - -_SC_DEVICE_IO - - - ) - -376 - m_SC_DEVICE_SPECIFIC -, - -377  - #_SC_DEVICE_SPECIFIC - -_SC_DEVICE_SPECIFIC - - - ) - -378 - m_SC_DEVICE_SPECIFIC_R -, - -379  - #_SC_DEVICE_SPECIFIC_R - -_SC_DEVICE_SPECIFIC_R - - - ) - -380 - m_SC_FD_MGMT -, - -381  - #_SC_FD_MGMT - -_SC_FD_MGMT - - - ) - -382 - m_SC_FIFO -, - -383  - #_SC_FIFO - -_SC_FIFO - - - ) - -384 - m_SC_PIPE -, - -385  - #_SC_PIPE - -_SC_PIPE - - - ) - -386 - m_SC_FILE_ATTRIBUTES -, - -387  - #_SC_FILE_ATTRIBUTES - -_SC_FILE_ATTRIBUTES - - - ) - -388 - m_SC_FILE_LOCKING -, - -389  - #_SC_FILE_LOCKING - -_SC_FILE_LOCKING - - - ) - -390 - m_SC_FILE_SYSTEM -, - -391  - #_SC_FILE_SYSTEM - -_SC_FILE_SYSTEM - - - ) - -392 - m_SC_MONOTONIC_CLOCK -, - -393  - #_SC_MONOTONIC_CLOCK - -_SC_MONOTONIC_CLOCK - - - ) - -394 - m_SC_MULTI_PROCESS -, - -395  - #_SC_MULTI_PROCESS - -_SC_MULTI_PROCESS - - - ) - -396 - m_SC_SINGLE_PROCESS -, - -397  - #_SC_SINGLE_PROCESS - -_SC_SINGLE_PROCESS - - - ) - -398 - m_SC_NETWORKING -, - -399  - #_SC_NETWORKING - -_SC_NETWORKING - - - ) - -400 - m_SC_READER_WRITER_LOCKS -, - -401  - #_SC_READER_WRITER_LOCKS - -_SC_READER_WRITER_LOCKS - - - ) - -402 - m_SC_SPIN_LOCKS -, - -403  - #_SC_SPIN_LOCKS - -_SC_SPIN_LOCKS - - - ) - -404 - m_SC_REGEXP -, - -405  - #_SC_REGEXP - -_SC_REGEXP - - - ) - -406 - m_SC_REGEX_VERSION -, - -407  - #_SC_REGEX_VERSION - -_SC_REGEX_VERSION - - - ) - -408 - m_SC_SHELL -, - -409  - #_SC_SHELL - -_SC_SHELL - - - ) - -410 - m_SC_SIGNALS -, - -411  - #_SC_SIGNALS - -_SC_SIGNALS - - - ) - -412 - m_SC_SPAWN -, - -413  - #_SC_SPAWN - -_SC_SPAWN - - - ) - -414 - m_SC_SPORADIC_SERVER -, - -415  - #_SC_SPORADIC_SERVER - -_SC_SPORADIC_SERVER - - - ) - -416 - m_SC_THREAD_SPORADIC_SERVER -, - -417  - #_SC_THREAD_SPORADIC_SERVER - -_SC_THREAD_SPORADIC_SERVER - - - ) - -418 - m_SC_SYSTEM_DATABASE -, - -419  - #_SC_SYSTEM_DATABASE - -_SC_SYSTEM_DATABASE - - - ) - -420 - m_SC_SYSTEM_DATABASE_R -, - -421  - #_SC_SYSTEM_DATABASE_R - -_SC_SYSTEM_DATABASE_R - - - ) - -422 - m_SC_TIMEOUTS -, - -423  - #_SC_TIMEOUTS - -_SC_TIMEOUTS - - - ) - -424 - m_SC_TYPED_MEMORY_OBJECTS -, - -425  - #_SC_TYPED_MEMORY_OBJECTS - -_SC_TYPED_MEMORY_OBJECTS - - - ) - -426 - m_SC_USER_GROUPS -, - -427  - #_SC_USER_GROUPS - -_SC_USER_GROUPS - - - ) - -428 - m_SC_USER_GROUPS_R -, - -429  - #_SC_USER_GROUPS_R - -_SC_USER_GROUPS_R - - - ) - -430 - m_SC_2_PBS -, - -431  - #_SC_2_PBS - -_SC_2_PBS - - - ) - -432 - m_SC_2_PBS_ACCOUNTING -, - -433  - #_SC_2_PBS_ACCOUNTING - -_SC_2_PBS_ACCOUNTING - - - ) - -434 - m_SC_2_PBS_LOCATE -, - -435  - #_SC_2_PBS_LOCATE - -_SC_2_PBS_LOCATE - - - ) - -436 - m_SC_2_PBS_MESSAGE -, - -437  - #_SC_2_PBS_MESSAGE - -_SC_2_PBS_MESSAGE - - - ) - -438 - m_SC_2_PBS_TRACK -, - -439  - #_SC_2_PBS_TRACK - -_SC_2_PBS_TRACK - - - ) - -440 - m_SC_SYMLOOP_MAX -, - -441  - #_SC_SYMLOOP_MAX - -_SC_SYMLOOP_MAX - - - ) - -442 - m_SC_STREAMS -, - -443  - #_SC_STREAMS - -_SC_STREAMS - - - ) - -444 - m_SC_2_PBS_CHECKPOINT -, - -445  - #_SC_2_PBS_CHECKPOINT - -_SC_2_PBS_CHECKPOINT - - - ) - -447 - m_SC_V6_ILP32_OFF32 -, - -448  - #_SC_V6_ILP32_OFF32 - -_SC_V6_ILP32_OFF32 - - - ) - -449 - m_SC_V6_ILP32_OFFBIG -, - -450  - #_SC_V6_ILP32_OFFBIG - -_SC_V6_ILP32_OFFBIG - - - ) - -451 - m_SC_V6_LP64_OFF64 -, - -452  - #_SC_V6_LP64_OFF64 - -_SC_V6_LP64_OFF64 - - - ) - -453 - m_SC_V6_LPBIG_OFFBIG -, - -454  - #_SC_V6_LPBIG_OFFBIG - -_SC_V6_LPBIG_OFFBIG - - - ) - -456 - m_SC_HOST_NAME_MAX -, - -457  - #_SC_HOST_NAME_MAX - -_SC_HOST_NAME_MAX - - - ) - -458 - m_SC_TRACE -, - -459  - #_SC_TRACE - -_SC_TRACE - - - ) - -460 - m_SC_TRACE_EVENT_FILTER -, - -461  - #_SC_TRACE_EVENT_FILTER - -_SC_TRACE_EVENT_FILTER - - - ) - -462 - m_SC_TRACE_INHERIT -, - -463  - #_SC_TRACE_INHERIT - -_SC_TRACE_INHERIT - - - ) - -464 - m_SC_TRACE_LOG -, - -465  - #_SC_TRACE_LOG - -_SC_TRACE_LOG - - - ) - -467 - m_SC_LEVEL1_ICACHE_SIZE -, - -468  - #_SC_LEVEL1_ICACHE_SIZE - -_SC_LEVEL1_ICACHE_SIZE - - - ) - -469 - m_SC_LEVEL1_ICACHE_ASSOC -, - -470  - #_SC_LEVEL1_ICACHE_ASSOC - -_SC_LEVEL1_ICACHE_ASSOC - - - ) - -471 - m_SC_LEVEL1_ICACHE_LINESIZE -, - -472  - #_SC_LEVEL1_ICACHE_LINESIZE - -_SC_LEVEL1_ICACHE_LINESIZE - - - ) - -473 - m_SC_LEVEL1_DCACHE_SIZE -, - -474  - #_SC_LEVEL1_DCACHE_SIZE - -_SC_LEVEL1_DCACHE_SIZE - - - ) - -475 - m_SC_LEVEL1_DCACHE_ASSOC -, - -476  - #_SC_LEVEL1_DCACHE_ASSOC - -_SC_LEVEL1_DCACHE_ASSOC - - - ) - -477 - m_SC_LEVEL1_DCACHE_LINESIZE -, - -478  - #_SC_LEVEL1_DCACHE_LINESIZE - -_SC_LEVEL1_DCACHE_LINESIZE - - - ) - -479 - m_SC_LEVEL2_CACHE_SIZE -, - -480  - #_SC_LEVEL2_CACHE_SIZE - -_SC_LEVEL2_CACHE_SIZE - - - ) - -481 - m_SC_LEVEL2_CACHE_ASSOC -, - -482  - #_SC_LEVEL2_CACHE_ASSOC - -_SC_LEVEL2_CACHE_ASSOC - - - ) - -483 - m_SC_LEVEL2_CACHE_LINESIZE -, - -484  - #_SC_LEVEL2_CACHE_LINESIZE - -_SC_LEVEL2_CACHE_LINESIZE - - - ) - -485 - m_SC_LEVEL3_CACHE_SIZE -, - -486  - #_SC_LEVEL3_CACHE_SIZE - -_SC_LEVEL3_CACHE_SIZE - - - ) - -487 - m_SC_LEVEL3_CACHE_ASSOC -, - -488  - #_SC_LEVEL3_CACHE_ASSOC - -_SC_LEVEL3_CACHE_ASSOC - - - ) - -489 - m_SC_LEVEL3_CACHE_LINESIZE -, - -490  - #_SC_LEVEL3_CACHE_LINESIZE - -_SC_LEVEL3_CACHE_LINESIZE - - - ) - -491 - m_SC_LEVEL4_CACHE_SIZE -, - -492  - #_SC_LEVEL4_CACHE_SIZE - -_SC_LEVEL4_CACHE_SIZE - - - ) - -493 - m_SC_LEVEL4_CACHE_ASSOC -, - -494  - #_SC_LEVEL4_CACHE_ASSOC - -_SC_LEVEL4_CACHE_ASSOC - - - ) - -495 - m_SC_LEVEL4_CACHE_LINESIZE -, - -496  - #_SC_LEVEL4_CACHE_LINESIZE - -_SC_LEVEL4_CACHE_LINESIZE - - - ) - -499 - m_SC_IPV6 - = -_SC_LEVEL1_ICACHE_SIZE - + 50, - -500  - #_SC_IPV6 - -_SC_IPV6 - - - ) - -501 - m_SC_RAW_SOCKETS -, - -502  - #_SC_RAW_SOCKETS - -_SC_RAW_SOCKETS - - - ) - -504 - m_SC_V7_ILP32_OFF32 -, - -505  - #_SC_V7_ILP32_OFF32 - -_SC_V7_ILP32_OFF32 - - - ) - -506 - m_SC_V7_ILP32_OFFBIG -, - -507  - #_SC_V7_ILP32_OFFBIG - -_SC_V7_ILP32_OFFBIG - - - ) - -508 - m_SC_V7_LP64_OFF64 -, - -509  - #_SC_V7_LP64_OFF64 - -_SC_V7_LP64_OFF64 - - - ) - -510 - m_SC_V7_LPBIG_OFFBIG -, - -511  - #_SC_V7_LPBIG_OFFBIG - -_SC_V7_LPBIG_OFFBIG - - - ) - -513 - m_SC_SS_REPL_MAX -, - -514  - #_SC_SS_REPL_MAX - -_SC_SS_REPL_MAX - - - ) - -516 - m_SC_TRACE_EVENT_NAME_MAX -, - -517  - #_SC_TRACE_EVENT_NAME_MAX - -_SC_TRACE_EVENT_NAME_MAX - - - ) - -518 - m_SC_TRACE_NAME_MAX -, - -519  - #_SC_TRACE_NAME_MAX - -_SC_TRACE_NAME_MAX - - - ) - -520 - m_SC_TRACE_SYS_MAX -, - -521  - #_SC_TRACE_SYS_MAX - -_SC_TRACE_SYS_MAX - - - ) - -522 - m_SC_TRACE_USER_EVENT_MAX -, - -523  - #_SC_TRACE_USER_EVENT_MAX - -_SC_TRACE_USER_EVENT_MAX - - - ) - -525 - m_SC_XOPEN_STREAMS -, - -526  - #_SC_XOPEN_STREAMS - -_SC_XOPEN_STREAMS - - - ) - -528 - m_SC_THREAD_ROBUST_PRIO_INHERIT -, - -529  - #_SC_THREAD_ROBUST_PRIO_INHERIT - -_SC_THREAD_ROBUST_PRIO_INHERIT - - - ) - -530 - m_SC_THREAD_ROBUST_PRIO_PROTECT - - -531  - #_SC_THREAD_ROBUST_PRIO_PROTECT - -_SC_THREAD_ROBUST_PRIO_PROTECT - - - ) - -537 - m_CS_PATH -, - -538  - #_CS_PATH - -_CS_PATH - - - ) - -540 - m_CS_V6_WIDTH_RESTRICTED_ENVS -, - -541  - #_CS_V6_WIDTH_RESTRICTED_ENVS - -_CS_V6_WIDTH_RESTRICTED_ENVS - - - ) - -542  - #_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS - -_CS_V6_WIDTH_RESTRICTED_ENVS - - - ) - -544 - m_CS_GNU_LIBC_VERSION -, - -545  - #_CS_GNU_LIBC_VERSION - -_CS_GNU_LIBC_VERSION - - - ) - -546 - m_CS_GNU_LIBPTHREAD_VERSION -, - -547  - #_CS_GNU_LIBPTHREAD_VERSION - -_CS_GNU_LIBPTHREAD_VERSION - - - ) - -549 - m_CS_V5_WIDTH_RESTRICTED_ENVS -, - -550  - #_CS_V5_WIDTH_RESTRICTED_ENVS - -_CS_V5_WIDTH_RESTRICTED_ENVS - - - ) - -551  - #_CS_POSIX_V5_WIDTH_RESTRICTED_ENVS - -_CS_V5_WIDTH_RESTRICTED_ENVS - - - ) - -553 - m_CS_V7_WIDTH_RESTRICTED_ENVS -, - -554  - #_CS_V7_WIDTH_RESTRICTED_ENVS - -_CS_V7_WIDTH_RESTRICTED_ENVS - - - ) - -555  - #_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS - -_CS_V7_WIDTH_RESTRICTED_ENVS - - - ) - -557 - m_CS_LFS_CFLAGS - = 1000, - -558  - #_CS_LFS_CFLAGS - -_CS_LFS_CFLAGS - - - ) - -559 - m_CS_LFS_LDFLAGS -, - -560  - #_CS_LFS_LDFLAGS - -_CS_LFS_LDFLAGS - - - ) - -561 - m_CS_LFS_LIBS -, - -562  - #_CS_LFS_LIBS - -_CS_LFS_LIBS - - - ) - -563 - m_CS_LFS_LINTFLAGS -, - -564  - #_CS_LFS_LINTFLAGS - -_CS_LFS_LINTFLAGS - - - ) - -565 - m_CS_LFS64_CFLAGS -, - -566  - #_CS_LFS64_CFLAGS - -_CS_LFS64_CFLAGS - - - ) - -567 - m_CS_LFS64_LDFLAGS -, - -568  - #_CS_LFS64_LDFLAGS - -_CS_LFS64_LDFLAGS - - - ) - -569 - m_CS_LFS64_LIBS -, - -570  - #_CS_LFS64_LIBS - -_CS_LFS64_LIBS - - - ) - -571 - m_CS_LFS64_LINTFLAGS -, - -572  - #_CS_LFS64_LINTFLAGS - -_CS_LFS64_LINTFLAGS - - - ) - -574 - m_CS_XBS5_ILP32_OFF32_CFLAGS - = 1100, - -575  - #_CS_XBS5_ILP32_OFF32_CFLAGS - -_CS_XBS5_ILP32_OFF32_CFLAGS - - - ) - -576 - m_CS_XBS5_ILP32_OFF32_LDFLAGS -, - -577  - #_CS_XBS5_ILP32_OFF32_LDFLAGS - -_CS_XBS5_ILP32_OFF32_LDFLAGS - - - ) - -578 - m_CS_XBS5_ILP32_OFF32_LIBS -, - -579  - #_CS_XBS5_ILP32_OFF32_LIBS - -_CS_XBS5_ILP32_OFF32_LIBS - - - ) - -580 - m_CS_XBS5_ILP32_OFF32_LINTFLAGS -, - -581  - #_CS_XBS5_ILP32_OFF32_LINTFLAGS - -_CS_XBS5_ILP32_OFF32_LINTFLAGS - - - ) - -582 - m_CS_XBS5_ILP32_OFFBIG_CFLAGS -, - -583  - #_CS_XBS5_ILP32_OFFBIG_CFLAGS - -_CS_XBS5_ILP32_OFFBIG_CFLAGS - - - ) - -584 - m_CS_XBS5_ILP32_OFFBIG_LDFLAGS -, - -585  - #_CS_XBS5_ILP32_OFFBIG_LDFLAGS - -_CS_XBS5_ILP32_OFFBIG_LDFLAGS - - - ) - -586 - m_CS_XBS5_ILP32_OFFBIG_LIBS -, - -587  - #_CS_XBS5_ILP32_OFFBIG_LIBS - -_CS_XBS5_ILP32_OFFBIG_LIBS - - - ) - -588 - m_CS_XBS5_ILP32_OFFBIG_LINTFLAGS -, - -589  - #_CS_XBS5_ILP32_OFFBIG_LINTFLAGS - -_CS_XBS5_ILP32_OFFBIG_LINTFLAGS - - - ) - -590 - m_CS_XBS5_LP64_OFF64_CFLAGS -, - -591  - #_CS_XBS5_LP64_OFF64_CFLAGS - -_CS_XBS5_LP64_OFF64_CFLAGS - - - ) - -592 - m_CS_XBS5_LP64_OFF64_LDFLAGS -, - -593  - #_CS_XBS5_LP64_OFF64_LDFLAGS - -_CS_XBS5_LP64_OFF64_LDFLAGS - - - ) - -594 - m_CS_XBS5_LP64_OFF64_LIBS -, - -595  - #_CS_XBS5_LP64_OFF64_LIBS - -_CS_XBS5_LP64_OFF64_LIBS - - - ) - -596 - m_CS_XBS5_LP64_OFF64_LINTFLAGS -, - -597  - #_CS_XBS5_LP64_OFF64_LINTFLAGS - -_CS_XBS5_LP64_OFF64_LINTFLAGS - - - ) - -598 - m_CS_XBS5_LPBIG_OFFBIG_CFLAGS -, - -599  - #_CS_XBS5_LPBIG_OFFBIG_CFLAGS - -_CS_XBS5_LPBIG_OFFBIG_CFLAGS - - - ) - -600 - m_CS_XBS5_LPBIG_OFFBIG_LDFLAGS -, - -601  - #_CS_XBS5_LPBIG_OFFBIG_LDFLAGS - -_CS_XBS5_LPBIG_OFFBIG_LDFLAGS - - - ) - -602 - m_CS_XBS5_LPBIG_OFFBIG_LIBS -, - -603  - #_CS_XBS5_LPBIG_OFFBIG_LIBS - -_CS_XBS5_LPBIG_OFFBIG_LIBS - - - ) - -604 - m_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS -, - -605  - #_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS - -_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS - - - ) - -607 - m_CS_POSIX_V6_ILP32_OFF32_CFLAGS -, - -608  - #_CS_POSIX_V6_ILP32_OFF32_CFLAGS - -_CS_POSIX_V6_ILP32_OFF32_CFLAGS - - - ) - -609 - m_CS_POSIX_V6_ILP32_OFF32_LDFLAGS -, - -610  - #_CS_POSIX_V6_ILP32_OFF32_LDFLAGS - -_CS_POSIX_V6_ILP32_OFF32_LDFLAGS - - - ) - -611 - m_CS_POSIX_V6_ILP32_OFF32_LIBS -, - -612  - #_CS_POSIX_V6_ILP32_OFF32_LIBS - -_CS_POSIX_V6_ILP32_OFF32_LIBS - - - ) - -613 - m_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS -, - -614  - #_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS - -_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS - - - ) - -615 - m_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS -, - -616  - #_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS - -_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS - - - ) - -617 - m_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS -, - -618  - #_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS - -_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS - - - ) - -619 - m_CS_POSIX_V6_ILP32_OFFBIG_LIBS -, - -620  - #_CS_POSIX_V6_ILP32_OFFBIG_LIBS - -_CS_POSIX_V6_ILP32_OFFBIG_LIBS - - - ) - -621 - m_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS -, - -622  - #_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS - -_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS - - - ) - -623 - m_CS_POSIX_V6_LP64_OFF64_CFLAGS -, - -624  - #_CS_POSIX_V6_LP64_OFF64_CFLAGS - -_CS_POSIX_V6_LP64_OFF64_CFLAGS - - - ) - -625 - m_CS_POSIX_V6_LP64_OFF64_LDFLAGS -, - -626  - #_CS_POSIX_V6_LP64_OFF64_LDFLAGS - -_CS_POSIX_V6_LP64_OFF64_LDFLAGS - - - ) - -627 - m_CS_POSIX_V6_LP64_OFF64_LIBS -, - -628  - #_CS_POSIX_V6_LP64_OFF64_LIBS - -_CS_POSIX_V6_LP64_OFF64_LIBS - - - ) - -629 - m_CS_POSIX_V6_LP64_OFF64_LINTFLAGS -, - -630  - #_CS_POSIX_V6_LP64_OFF64_LINTFLAGS - -_CS_POSIX_V6_LP64_OFF64_LINTFLAGS - - - ) - -631 - m_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS -, - -632  - #_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS - -_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS - - - ) - -633 - m_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS -, - -634  - #_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS - -_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS - - - ) - -635 - m_CS_POSIX_V6_LPBIG_OFFBIG_LIBS -, - -636  - #_CS_POSIX_V6_LPBIG_OFFBIG_LIBS - -_CS_POSIX_V6_LPBIG_OFFBIG_LIBS - - - ) - -637 - m_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS -, - -638  - #_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS - -_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS - - - ) - -640 - m_CS_POSIX_V7_ILP32_OFF32_CFLAGS -, - -641  - #_CS_POSIX_V7_ILP32_OFF32_CFLAGS - -_CS_POSIX_V7_ILP32_OFF32_CFLAGS - - - ) - -642 - m_CS_POSIX_V7_ILP32_OFF32_LDFLAGS -, - -643  - #_CS_POSIX_V7_ILP32_OFF32_LDFLAGS - -_CS_POSIX_V7_ILP32_OFF32_LDFLAGS - - - ) - -644 - m_CS_POSIX_V7_ILP32_OFF32_LIBS -, - -645  - #_CS_POSIX_V7_ILP32_OFF32_LIBS - -_CS_POSIX_V7_ILP32_OFF32_LIBS - - - ) - -646 - m_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS -, - -647  - #_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS - -_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS - - - ) - -648 - m_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS -, - -649  - #_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS - -_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS - - - ) - -650 - m_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS -, - -651  - #_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS - -_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS - - - ) - -652 - m_CS_POSIX_V7_ILP32_OFFBIG_LIBS -, - -653  - #_CS_POSIX_V7_ILP32_OFFBIG_LIBS - -_CS_POSIX_V7_ILP32_OFFBIG_LIBS - - - ) - -654 - m_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS -, - -655  - #_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS - -_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS - - - ) - -656 - m_CS_POSIX_V7_LP64_OFF64_CFLAGS -, - -657  - #_CS_POSIX_V7_LP64_OFF64_CFLAGS - -_CS_POSIX_V7_LP64_OFF64_CFLAGS - - - ) - -658 - m_CS_POSIX_V7_LP64_OFF64_LDFLAGS -, - -659  - #_CS_POSIX_V7_LP64_OFF64_LDFLAGS - -_CS_POSIX_V7_LP64_OFF64_LDFLAGS - - - ) - -660 - m_CS_POSIX_V7_LP64_OFF64_LIBS -, - -661  - #_CS_POSIX_V7_LP64_OFF64_LIBS - -_CS_POSIX_V7_LP64_OFF64_LIBS - - - ) - -662 - m_CS_POSIX_V7_LP64_OFF64_LINTFLAGS -, - -663  - #_CS_POSIX_V7_LP64_OFF64_LINTFLAGS - -_CS_POSIX_V7_LP64_OFF64_LINTFLAGS - - - ) - -664 - m_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS -, - -665  - #_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS - -_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS - - - ) - -666 - m_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS -, - -667  - #_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS - -_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS - - - ) - -668 - m_CS_POSIX_V7_LPBIG_OFFBIG_LIBS -, - -669  - #_CS_POSIX_V7_LPBIG_OFFBIG_LIBS - -_CS_POSIX_V7_LPBIG_OFFBIG_LIBS - - - ) - -670 - m_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS -, - -671  - #_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS - -_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS - - - ) - -673 - m_CS_V6_ENV -, - -674  - #_CS_V6_ENV - -_CS_V6_ENV - - - ) - -675 - m_CS_V7_ENV - - -676  - #_CS_V7_ENV - -_CS_V7_ENV - - - ) - - @/usr/include/bits/environments.h - -19 #iâdeà -_UNISTD_H - - -23  - ~ - -43 #ià -__WORDSIZE - == 64 - -57  - #_POSIX_V7_LPBIG_OFFBIG - -1 - - ) - -58  - #_POSIX_V6_LPBIG_OFFBIG - -1 - - ) - -59  - #_XBS5_LPBIG_OFFBIG - -1 - - ) - -62  - #_POSIX_V7_LP64_OFF64 - 1 - - ) - -63  - #_POSIX_V6_LP64_OFF64 - 1 - - ) - -64  - #_XBS5_LP64_OFF64 - 1 - - ) - -70  - #_POSIX_V7_ILP32_OFF32 - 1 - - ) - -71  - #_POSIX_V7_ILP32_OFFBIG - 1 - - ) - -72  - #_POSIX_V6_ILP32_OFF32 - 1 - - ) - -73  - #_POSIX_V6_ILP32_OFFBIG - 1 - - ) - -74  - #_XBS5_ILP32_OFF32 - 1 - - ) - -75  - #_XBS5_ILP32_OFFBIG - 1 - - ) - -92  - #__ILP32_OFF32_CFLAGS - "-m32" - - ) - -93  - #__ILP32_OFFBIG_CFLAGS - "-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" - - ) - -94  - #__ILP32_OFF32_LDFLAGS - "-m32" - - ) - -95  - #__ILP32_OFFBIG_LDFLAGS - "-m32" - - ) - -96  - #__LP64_OFF64_CFLAGS - "-m64" - - ) - -97  - #__LP64_OFF64_LDFLAGS - "-m64" - - ) - - @/usr/include/bits/errno.h - -20 #ifdeà -_ERRNO_H - - -22 #undeà -EDOM - - -23 #undeà -EILSEQ - - -24 #undeà -ERANGE - - -25  - ~ - -28  - #ENOTSUP - -EOPNOTSUPP - - - ) - -31 #iâdeà -ECANCELED - - -32  - #ECANCELED - 125 - - ) - -36 #iâdeà -EOWNERDEAD - - -37  - #EOWNERDEAD - 130 - - ) - -38  - #ENOTRECOVERABLE - 131 - - ) - -41 #iâdeà -ERFKILL - - -42  - #ERFKILL - 132 - - ) - -45 #iâdeà -__ASSEMBLER__ - - -47 * - $__”ºo_loÿtiÚ - (è -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)); - -49 #ià! -defšed - -_LIBC - || defšed -_LIBC_REENTRANT - - -51  - #”ºo - (* - `__”ºo_loÿtiÚ - ()) - - ) - -56 #ià! -defšed - -_ERRNO_H - && defšed -__Ãed_Em©h - - -60  - #EDOM - 33 - - ) - -61  - #EILSEQ - 84 - - ) - -62  - #ERANGE - 34 - - ) - - @/usr/include/bits/ioctl-types.h - -20 #iâdeà -_SYS_IOCTL_H - - -25  - ~ - -28  - swšsize - - -30  - mws_row -; - -31  - mws_cÞ -; - -32  - mws_xpix– -; - -33  - mws_ypix– -; - -36  - #NCC - 8 - - ) - -37  - s‹rmio - - -39  - mc_iæag -; - -40  - mc_oæag -; - -41  - mc_cæag -; - -42  - mc_læag -; - -43  - mc_lše -; - -44  - mc_cc -[ -NCC -]; - -48  - #TIOCM_LE - 0x001 - - ) - -49  - #TIOCM_DTR - 0x002 - - ) - -50  - #TIOCM_RTS - 0x004 - - ) - -51  - #TIOCM_ST - 0x008 - - ) - -52  - #TIOCM_SR - 0x010 - - ) - -53  - #TIOCM_CTS - 0x020 - - ) - -54  - #TIOCM_CAR - 0x040 - - ) - -55  - #TIOCM_RNG - 0x080 - - ) - -56  - #TIOCM_DSR - 0x100 - - ) - -57  - #TIOCM_CD - -TIOCM_CAR - - - ) - -58  - #TIOCM_RI - -TIOCM_RNG - - - ) - -63  - #N_TTY - 0 - - ) - -64  - #N_SLIP - 1 - - ) - -65  - #N_MOUSE - 2 - - ) - -66  - #N_PPP - 3 - - ) - -67  - #N_STRIP - 4 - - ) - -68  - #N_AX25 - 5 - - ) - -69  - #N_X25 - 6 - - ) - -70  - #N_6PACK - 7 - - ) - -71  - #N_MASC - 8 - - ) - -72  - #N_R3964 - 9 - - ) - -73  - #N_PROFIBUS_FDL - 10 - - ) - -74  - #N_IRDA - 11 - - ) - -75  - #N_SMSBLOCK - 12 - - ) - -76  - #N_HDLC - 13 - - ) - -77  - #N_SYNC_PPP - 14 - - ) - -78  - #N_HCI - 15 - - ) - - @/usr/include/bits/ioctls.h - -19 #iâdeà -_SYS_IOCTL_H - - -24  - ~ - -27  - #SIOCADDRT - 0x890B - - ) - -28  - #SIOCDELRT - 0x890C - - ) - -29  - #SIOCRTMSG - 0x890D - - ) - -32  - #SIOCGIFNAME - 0x8910 - - ) - -33  - #SIOCSIFLINK - 0x8911 - - ) - -34  - #SIOCGIFCONF - 0x8912 - - ) - -35  - #SIOCGIFFLAGS - 0x8913 - - ) - -36  - #SIOCSIFFLAGS - 0x8914 - - ) - -37  - #SIOCGIFADDR - 0x8915 - - ) - -38  - #SIOCSIFADDR - 0x8916 - - ) - -39  - #SIOCGIFDSTADDR - 0x8917 - - ) - -40  - #SIOCSIFDSTADDR - 0x8918 - - ) - -41  - #SIOCGIFBRDADDR - 0x8919 - - ) - -42  - #SIOCSIFBRDADDR - 0x891¨ - - ) - -43  - #SIOCGIFNETMASK - 0x891b - - ) - -44  - #SIOCSIFNETMASK - 0x891ø - - ) - -45  - #SIOCGIFMETRIC - 0x891d - - ) - -46  - #SIOCSIFMETRIC - 0x891 - - ) - -47  - #SIOCGIFMEM - 0x891à - - ) - -48  - #SIOCSIFMEM - 0x8920 - - ) - -49  - #SIOCGIFMTU - 0x8921 - - ) - -50  - #SIOCSIFMTU - 0x8922 - - ) - -51  - #SIOCSIFNAME - 0x8923 - - ) - -52  - #SIOCSIFHWADDR - 0x8924 - - ) - -53  - #SIOCGIFENCAP - 0x8925 - - ) - -54  - #SIOCSIFENCAP - 0x8926 - - ) - -55  - #SIOCGIFHWADDR - 0x8927 - - ) - -56  - #SIOCGIFSLAVE - 0x8929 - - ) - -57  - #SIOCSIFSLAVE - 0x8930 - - ) - -58  - #SIOCADDMULTI - 0x8931 - - ) - -59  - #SIOCDELMULTI - 0x8932 - - ) - -60  - #SIOCGIFINDEX - 0x8933 - - ) - -61  - #SIOGIFINDEX - -SIOCGIFINDEX - - - ) - -62  - #SIOCSIFPFLAGS - 0x8934 - - ) - -63  - #SIOCGIFPFLAGS - 0x8935 - - ) - -64  - #SIOCDIFADDR - 0x8936 - - ) - -65  - #SIOCSIFHWBROADCAST - 0x8937 - - ) - -66  - #SIOCGIFCOUNT - 0x8938 - - ) - -68  - #SIOCGIFBR - 0x8940 - - ) - -69  - #SIOCSIFBR - 0x8941 - - ) - -71  - #SIOCGIFTXQLEN - 0x8942 - - ) - -72  - #SIOCSIFTXQLEN - 0x8943 - - ) - -77  - #SIOCDARP - 0x8953 - - ) - -78  - #SIOCGARP - 0x8954 - - ) - -79  - #SIOCSARP - 0x8955 - - ) - -82  - #SIOCDRARP - 0x8960 - - ) - -83  - #SIOCGRARP - 0x8961 - - ) - -84  - #SIOCSRARP - 0x8962 - - ) - -88  - #SIOCGIFMAP - 0x8970 - - ) - -89  - #SIOCSIFMAP - 0x8971 - - ) - -93  - #SIOCADDDLCI - 0x8980 - - ) - -94  - #SIOCDELDLCI - 0x8981 - - ) - -103  - #SIOCDEVPRIVATE - 0x89F0 - - ) - -109  - #SIOCPROTOPRIVATE - 0x89E0 - - ) - - @/usr/include/bits/ipc.h - -19 #iâdeà -_SYS_IPC_H - - -23  - ~ - -26  - #IPC_CREAT - 01000 - - ) - -27  - #IPC_EXCL - 02000 - - ) - -28  - #IPC_NOWAIT - 04000 - - ) - -31  - #IPC_RMID - 0 - - ) - -32  - #IPC_SET - 1 - - ) - -33  - #IPC_STAT - 2 - - ) - -34 #ifdeà -__USE_GNU - - -35  - #IPC_INFO - 3 - - ) - -39  - #IPC_PRIVATE - (( -__key_t -è0è - - ) - -43  - sc_³rm - - -45 -__key_t - - m__key -; - -46 -__uid_t - - muid -; - -47 -__gid_t - - mgid -; - -48 -__uid_t - - mcuid -; - -49 -__gid_t - - mcgid -; - -50  - mmode -; - -51  - m__·d1 -; - -52  - m__£q -; - -53  - m__·d2 -; - -54  - m__unu£d1 -; - -55  - m__unu£d2 -; - - @/usr/include/bits/ipctypes.h - -24 #iâdeà -_BITS_IPCTYPES_H - - -25  - #_BITS_IPCTYPES_H - 1 - - ) - -27  - ~ - -30 #ià -__WORDSIZE - == 32 - -31  - t__c_pid_t -; - -33  - t__c_pid_t -; - - @/usr/include/bits/msq.h - -19 #iâdeà -_SYS_MSG_H - - -23  - ~ - -24  - ~ - -27  - #MSG_NOERROR - 010000 - - ) - -28 #ifdeà -__USE_GNU - - -29  - #MSG_EXCEPT - 020000 - - ) - -33  - tmsgqnum_t -; - -34  - tmsgËn_t -; - -38  - smsqid_ds - - -40  -c_³rm - - mmsg_³rm -; - -41 -__time_t - - mmsg_¡ime -; - -42 #ià -__WORDSIZE - == 32 - -43  - m__unu£d1 -; - -45 -__time_t - - mmsg_¹ime -; - -46 #ià -__WORDSIZE - == 32 - -47  - m__unu£d2 -; - -49 -__time_t - - mmsg_ùime -; - -50 #ià -__WORDSIZE - == 32 - -51  - m__unu£d3 -; - -53  - m__msg_cby‹s -; - -54 -msgqnum_t - - mmsg_qnum -; - -55 -msgËn_t - - mmsg_qby‹s -; - -56 -__pid_t - - mmsg_l¥id -; - -57 -__pid_t - - mmsg_Ìpid -; - -58  - m__unu£d4 -; - -59  - m__unu£d5 -; - -62 #ifdeà -__USE_MISC - - -64  - #msg_cby‹s - -__msg_cby‹s - - - ) - -67  - #MSG_STAT - 11 - - ) - -68  - #MSG_INFO - 12 - - ) - -71  - smsgšfo - - -73  - mmsgpoÞ -; - -74  - mmsgm­ -; - -75  - mmsgmax -; - -76  - mmsgmnb -; - -77  - mmsgmni -; - -78  - mmsgssz -; - -79  - mmsgtql -; - -80  - mmsg£g -; - - @/usr/include/bits/posix_opt.h - -20 #iâdef -_BITS_POSIX_OPT_H - - -21  - #_BITS_POSIX_OPT_H - 1 - - ) - -24  - #_POSIX_JOB_CONTROL - 1 - - ) - -27  - #_POSIX_SAVED_IDS - 1 - - ) - -30  - #_POSIX_PRIORITY_SCHEDULING - 200809L - - ) - -33  - #_POSIX_SYNCHRONIZED_IO - 200809L - - ) - -36  - #_POSIX_FSYNC - 200809L - - ) - -39  - #_POSIX_MAPPED_FILES - 200809L - - ) - -42  - #_POSIX_MEMLOCK - 200809L - - ) - -45  - #_POSIX_MEMLOCK_RANGE - 200809L - - ) - -48  - #_POSIX_MEMORY_PROTECTION - 200809L - - ) - -51  - #_POSIX_CHOWN_RESTRICTED - 0 - - ) - -55  - #_POSIX_VDISABLE - '\0' - - ) - -58  - #_POSIX_NO_TRUNC - 1 - - ) - -61  - #_XOPEN_REALTIME - 1 - - ) - -64  - #_XOPEN_REALTIME_THREADS - 1 - - ) - -67  - #_XOPEN_SHM - 1 - - ) - -70  - #_POSIX_THREADS - 200809L - - ) - -73  - #_POSIX_REENTRANT_FUNCTIONS - 1 - - ) - -74  - #_POSIX_THREAD_SAFE_FUNCTIONS - 200809L - - ) - -77  - #_POSIX_THREAD_PRIORITY_SCHEDULING - 200809L - - ) - -80  - #_POSIX_THREAD_ATTR_STACKSIZE - 200809L - - ) - -83  - #_POSIX_THREAD_ATTR_STACKADDR - 200809L - - ) - -86  - #_POSIX_THREAD_PRIO_INHERIT - 200809L - - ) - -90  - #_POSIX_THREAD_PRIO_PROTECT - 200809L - - ) - -92 #ifdeà -__USE_XOPEN2K8 - - -94  - #_POSIX_THREAD_ROBUST_PRIO_INHERIT - 200809L - - ) - -97  - #_POSIX_THREAD_ROBUST_PRIO_PROTECT - -1 - - ) - -101  - #_POSIX_SEMAPHORES - 200809L - - ) - -104  - #_POSIX_REALTIME_SIGNALS - 200809L - - ) - -107  - #_POSIX_ASYNCHRONOUS_IO - 200809L - - ) - -108  - #_POSIX_ASYNC_IO - 1 - - ) - -110  - #_LFS_ASYNCHRONOUS_IO - 1 - - ) - -112  - #_POSIX_PRIORITIZED_IO - 200809L - - ) - -115  - #_LFS64_ASYNCHRONOUS_IO - 1 - - ) - -118  - #_LFS_LARGEFILE - 1 - - ) - -119  - #_LFS64_LARGEFILE - 1 - - ) - -120  - #_LFS64_STDIO - 1 - - ) - -123  - #_POSIX_SHARED_MEMORY_OBJECTS - 200809L - - ) - -126  - #_POSIX_CPUTIME - 0 - - ) - -129  - #_POSIX_THREAD_CPUTIME - 0 - - ) - -132  - #_POSIX_REGEXP - 1 - - ) - -135  - #_POSIX_READER_WRITER_LOCKS - 200809L - - ) - -138  - #_POSIX_SHELL - 1 - - ) - -141  - #_POSIX_TIMEOUTS - 200809L - - ) - -144  - #_POSIX_SPIN_LOCKS - 200809L - - ) - -147  - #_POSIX_SPAWN - 200809L - - ) - -150  - #_POSIX_TIMERS - 200809L - - ) - -153  - #_POSIX_BARRIERS - 200809L - - ) - -156  - #_POSIX_MESSAGE_PASSING - 200809L - - ) - -159  - #_POSIX_THREAD_PROCESS_SHARED - 200809L - - ) - -162  - #_POSIX_MONOTONIC_CLOCK - 0 - - ) - -165  - #_POSIX_CLOCK_SELECTION - 200809L - - ) - -168  - #_POSIX_ADVISORY_INFO - 200809L - - ) - -171  - #_POSIX_IPV6 - 200809L - - ) - -174  - #_POSIX_RAW_SOCKETS - 200809L - - ) - -177  - #_POSIX2_CHAR_TERM - 200809L - - ) - -180  - #_POSIX_SPORADIC_SERVER - -1 - - ) - -181  - #_POSIX_THREAD_SPORADIC_SERVER - -1 - - ) - -184  - #_POSIX_TRACE - -1 - - ) - -185  - #_POSIX_TRACE_EVENT_FILTER - -1 - - ) - -186  - #_POSIX_TRACE_INHERIT - -1 - - ) - -187  - #_POSIX_TRACE_LOG - -1 - - ) - -190  - #_POSIX_TYPED_MEMORY_OBJECTS - -1 - - ) - - @/usr/include/bits/pthreadtypes.h - -20 #iâdeà -_BITS_PTHREADTYPES_H - - -21  - #_BITS_PTHREADTYPES_H - 1 - - ) - -23  - ~ - -25 #ià -__WORDSIZE - == 64 - -26  - #__SIZEOF_PTHREAD_ATTR_T - 56 - - ) - -27  - #__SIZEOF_PTHREAD_MUTEX_T - 40 - - ) - -28  - #__SIZEOF_PTHREAD_MUTEXATTR_T - 4 - - ) - -29  - #__SIZEOF_PTHREAD_COND_T - 48 - - ) - -30  - #__SIZEOF_PTHREAD_CONDATTR_T - 4 - - ) - -31  - #__SIZEOF_PTHREAD_RWLOCK_T - 56 - - ) - -32  - #__SIZEOF_PTHREAD_RWLOCKATTR_T - 8 - - ) - -33  - #__SIZEOF_PTHREAD_BARRIER_T - 32 - - ) - -34  - #__SIZEOF_PTHREAD_BARRIERATTR_T - 4 - - ) - -36  - #__SIZEOF_PTHREAD_ATTR_T - 36 - - ) - -37  - #__SIZEOF_PTHREAD_MUTEX_T - 24 - - ) - -38  - #__SIZEOF_PTHREAD_MUTEXATTR_T - 4 - - ) - -39  - #__SIZEOF_PTHREAD_COND_T - 48 - - ) - -40  - #__SIZEOF_PTHREAD_CONDATTR_T - 4 - - ) - -41  - #__SIZEOF_PTHREAD_RWLOCK_T - 32 - - ) - -42  - #__SIZEOF_PTHREAD_RWLOCKATTR_T - 8 - - ) - -43  - #__SIZEOF_PTHREAD_BARRIER_T - 20 - - ) - -44  - #__SIZEOF_PTHREAD_BARRIERATTR_T - 4 - - ) - -50  - t±h»ad_t -; - -55  - m__size -[ -__SIZEOF_PTHREAD_ATTR_T -]; - -56  - m__®ign -; - -57 } - t±h»ad_©Œ_t -; - -60 #ià -__WORDSIZE - == 64 - -61  - s__±h»ad_š‹º®_li¡ - - -63  -__±h»ad_š‹º®_li¡ - * - m__´ev -; - -64  -__±h»ad_š‹º®_li¡ - * - m__Ãxt -; - -65 } - t__±h»ad_li¡_t -; - -67  - s__±h»ad_š‹º®_¦i¡ - - -69  -__±h»ad_š‹º®_¦i¡ - * - m__Ãxt -; - -70 } - t__±h»ad_¦i¡_t -; - -78  - s__±h»ad_mu‹x_s - - -80  - m__lock -; - -81  - m__couÁ -; - -82  - m__owÃr -; - -83 #ià -__WORDSIZE - == 64 - -84  - m__nu£rs -; - -88  - m__kšd -; - -89 #ià -__WORDSIZE - == 64 - -90  - m__¥šs -; - -91 -__±h»ad_li¡_t - - m__li¡ -; - -92  - #__PTHREAD_MUTEX_HAVE_PREV - 1 - - ) - -94  - m__nu£rs -; - -95 -__ex‹nsiÚ__ - union - -97  - m__¥šs -; - -98 -__±h»ad_¦i¡_t - - m__li¡ -; - -101 } - m__d©a -; - -102  - m__size -[ -__SIZEOF_PTHREAD_MUTEX_T -]; - -103  - m__®ign -; - -104 } - t±h»ad_mu‹x_t -; - -108  - m__size -[ -__SIZEOF_PTHREAD_MUTEXATTR_T -]; - -109  - m__®ign -; - -110 } - t±h»ad_mu‹x©Œ_t -; - -119  - m__lock -; - -120  - m__fu‹x -; - -121 -__ex‹nsiÚ__ -  - m__tÙ®_£q -; - -122 -__ex‹nsiÚ__ -  - m__wakeup_£q -; - -123 -__ex‹nsiÚ__ -  - m__wok’_£q -; - -124 * - m__mu‹x -; - -125  - m__nwa™”s -; - -126  - m__brßdÿ¡_£q -; - -127 } - m__d©a -; - -128  - m__size -[ -__SIZEOF_PTHREAD_COND_T -]; - -129 -__ex‹nsiÚ__ -  - m__®ign -; - -130 } - t±h»ad_cÚd_t -; - -134  - m__size -[ -__SIZEOF_PTHREAD_CONDATTR_T -]; - -135  - m__®ign -; - -136 } - t±h»ad_cÚd©Œ_t -; - -140  - t±h»ad_key_t -; - -144  - t±h»ad_Úû_t -; - -147 #ià -defšed - -__USE_UNIX98 - || defšed -__USE_XOPEN2K - - -152 #ià -__WORDSIZE - == 64 - -155  - m__lock -; - -156  - m__Ä_»ad”s -; - -157  - m__»ad”s_wakeup -; - -158  - m__wr™”_wakeup -; - -159  - m__Ä_»ad”s_queued -; - -160  - m__Ä_wr™”s_queued -; - -161  - m__wr™” -; - -162  - m__sh¬ed -; - -163  - m__·d1 -; - -164  - m__·d2 -; - -167  - m__æags -; - -168 } - m__d©a -; - -172  - m__lock -; - -173  - m__Ä_»ad”s -; - -174  - m__»ad”s_wakeup -; - -175  - m__wr™”_wakeup -; - -176  - m__Ä_»ad”s_queued -; - -177  - m__Ä_wr™”s_queued -; - -180  - m__æags -; - -181  - m__sh¬ed -; - -182  - m__·d1 -; - -183  - m__·d2 -; - -184  - m__wr™” -; - -185 } - m__d©a -; - -187  - m__size -[ -__SIZEOF_PTHREAD_RWLOCK_T -]; - -188  - m__®ign -; - -189 } - t±h»ad_rwlock_t -; - -193  - m__size -[ -__SIZEOF_PTHREAD_RWLOCKATTR_T -]; - -194  - m__®ign -; - -195 } - t±h»ad_rwlock©Œ_t -; - -199 #ifdeà -__USE_XOPEN2K - - -201 vÞ©ž - t±h»ad_¥šlock_t -; - -208  - m__size -[ -__SIZEOF_PTHREAD_BARRIER_T -]; - -209  - m__®ign -; - -210 } - t±h»ad_b¬r›r_t -; - -214  - m__size -[ -__SIZEOF_PTHREAD_BARRIERATTR_T -]; - -215  - m__®ign -; - -216 } - t±h»ad_b¬r›¿‰r_t -; - -220 #ià -__WORDSIZE - == 32 - -222  - #__þ—nup_fù_©Œibu‹ - - `__©Œibu‹__ - (( - `__»g·rm__ - (1))) - - ) - - @/usr/include/bits/select.h - -19 #iâdeà -_SYS_SELECT_H - - -23  - ~ - -26 #ià -defšed - -__GNUC__ - && __GNUC__ >= 2 - -28 #ià -__WORDSIZE - == 64 - -29  - #__FD_ZERO_STOS - "¡osq" - - ) - -31  - #__FD_ZERO_STOS - "¡o¦" - - ) - -34  - #__FD_ZERO -( -fd¥ -) \ - -36  -__d0 -, -__d1 -; \ - -37 -__asm__ - - `__vÞ©že__ - ("þd;„•; " -__FD_ZERO_STOS - \ - -38 : "=c" ( -__d0 -), "=D" ( -__d1 -) \ - -39 : "a" (0), "0" ( ( -fd_£t -) \ - -40 /  ( -__fd_mask -)), \ - -41 "1" (& - `__FDS_BITS - ( -fd¥ -)[0]) \ - -43 } 0) - - ) - -49  - #__FD_ZERO -( -£t -) \ - -51  -__i -; \ - -52 -fd_£t - * -__¬r - = ( -£t -); \ - -53  -__i - = 0; __˜<  ( -fd_£t -è/  ( -__fd_mask -); ++__i) \ - -54 - `__FDS_BITS - ( -__¬r -)[ -__i -] = 0; \ - -55 } 0) - - ) - -59  - #__FD_SET -( -d -, -£t -) \ - -60 ((è( - `__FDS_BITS - ( -£t -)[ - `__FDELT - ( -d -)] |ð - `__FDMASK - (d))) - - ) - -61  - #__FD_CLR -( -d -, -£t -) \ - -62 ((è( - `__FDS_BITS - ( -£t -)[ - `__FDELT - ( -d -)] &ð~ - `__FDMASK - (d))) - - ) - -63  - #__FD_ISSET -( -d -, -£t -) \ - -64 (( - `__FDS_BITS - ( -£t -)[ - `__FDELT - ( -d -)] & - `__FDMASK - (d)è!ð0) - - ) - - @/usr/include/bits/setjmp.h - -20 #iâdeà -_BITS_SETJMP_H - - -21  - #_BITS_SETJMP_H - 1 - - ) - -23 #ià! -defšed - -_SETJMP_H - && !defšed -_PTHREAD_H - - -27  - ~ - -29 #iâdeà -_ASM - - -31 #ià -__WORDSIZE - == 64 - -32  - t__jmp_buf -[8]; - -34  - t__jmp_buf -[6]; - - @/usr/include/bits/sigset.h - -21 #iâdef -_SIGSET_H_ty³s - - -22  - #_SIGSET_H_ty³s - 1 - - ) - -24  - t__sig_©omic_t -; - -28  - #_SIGSET_NWORDS - (1024 / (8 *  ())) - - ) - -31  - m__v® -[ -_SIGSET_NWORDS -]; - -32 } - t__sig£t_t -; - -43 #ià! -defšed - -_SIGSET_H_âs - && defšed -_SIGNAL_H - - -44  - #_SIGSET_H_âs - 1 - - ) - -46 #iâdeà -_EXTERN_INLINE - - -47  - #_EXTERN_INLINE - -__ex‹º_šlše - - - ) - -51  - #__sigmask -( -sig -) \ - -52 (((è1è<< ((( -sig -è- 1è% (8 *  ()))) - - ) - -55  - #__sigwÜd -( -sig -è(((sigè- 1è/ (8 *  ())) - - ) - -57 #ià -defšed - -__GNUC__ - && __GNUC__ >= 2 - -58  - #__sigem±y£t -( -£t -) \ - -59 ( - `__ex‹nsiÚ__ - ({  -__út - = -_SIGSET_NWORDS -; \ - -60 -sig£t_t - * -__£t - = ( -£t -); \ - -61 -- -__út - >ð0è -__£t --> -__v® -[__cnt] = 0; \ - -62 0; })) - - ) - -63  - #__sigfžl£t -( -£t -) \ - -64 ( - `__ex‹nsiÚ__ - ({  -__út - = -_SIGSET_NWORDS -; \ - -65 -sig£t_t - * -__£t - = ( -£t -); \ - -66 -- -__út - >ð0è -__£t --> -__v® -[__cnt] = ~0UL; \ - -67 0; })) - - ) - -69 #ifdeà -__USE_GNU - - -73  - #__sigi£m±y£t -( -£t -) \ - -74 ( - `__ex‹nsiÚ__ - ({  -__út - = -_SIGSET_NWORDS -; \ - -75 cÚ¡ -sig£t_t - * -__£t - = ( -£t -); \ - -76  -__»t - = -__£t --> -__v® -[-- -__út -]; \ - -77 ! -__»t - && -- -__út - >= 0) \ - -78 -__»t - = -__£t --> -__v® -[ -__út -]; \ - -79 -__»t - =ð0; })) - - ) - -80  - #__sigªd£t -( -de¡ -, -Ëá -, -right -) \ - -81 ( - `__ex‹nsiÚ__ - ({  -__út - = -_SIGSET_NWORDS -; \ - -82 -sig£t_t - * -__de¡ - = ( -de¡ -); \ - -83 cÚ¡ -sig£t_t - * -__Ëá - = ( -Ëá -); \ - -84 cÚ¡ -sig£t_t - * -__right - = ( -right -); \ - -85 -- -__út - >= 0) \ - -86 -__de¡ --> -__v® -[ -__út -] = ( -__Ëá -->__val[__cnt] \ - -87 & -__right --> -__v® -[ -__út -]); \ - -88 0; })) - - ) - -89  - #__sigÜ£t -( -de¡ -, -Ëá -, -right -) \ - -90 ( - `__ex‹nsiÚ__ - ({  -__út - = -_SIGSET_NWORDS -; \ - -91 -sig£t_t - * -__de¡ - = ( -de¡ -); \ - -92 cÚ¡ -sig£t_t - * -__Ëá - = ( -Ëá -); \ - -93 cÚ¡ -sig£t_t - * -__right - = ( -right -); \ - -94 -- -__út - >= 0) \ - -95 -__de¡ --> -__v® -[ -__út -] = ( -__Ëá -->__val[__cnt] \ - -96 | -__right --> -__v® -[ -__út -]); \ - -97 0; })) - - ) - -104  -__sigismemb” - ( -__cÚ¡ - -__sig£t_t - *, ); - -105  -__sigadd£t - ( -__sig£t_t - *, ); - -106  -__sigd–£t - ( -__sig£t_t - *, ); - -108 #ifdeà -__USE_EXTERN_INLINES - - -109  - #__SIGSETFN -( -NAME -, -BODY -, -CONST -) \ - -110 -_EXTERN_INLINE - \ - -111 - `NAME - ( -CONST - -__sig£t_t - * -__£t -,  -__sig -) \ - -113  -__mask - = - `__sigmask - ( -__sig -); \ - -114  -__wÜd - = - `__sigwÜd - ( -__sig -); \ - -115  -BODY -; \ - -116 } - - ) - -118 -__SIGSETFN - ( -__sigismemb” -, ( -__£t --> -__v® -[ -__wÜd -] & -__mask -è? 1 : 0, -__cÚ¡ -) - -119 -__SIGSETFN - ( -__sigadd£t -, (( -__£t --> -__v® -[ -__wÜd -] |ð -__mask -), 0), ) - -120 -__SIGSETFN - ( -__sigd–£t -, (( -__£t --> -__v® -[ -__wÜd -] &ð~ -__mask -), 0), ) - -122 #undeà -__SIGSETFN - - - @/usr/include/bits/sockaddr.h - -24 #iâdeà -_BITS_SOCKADDR_H - - -25  - #_BITS_SOCKADDR_H - 1 - - ) - -29  - t§_çmžy_t -; - -35  - #__SOCKADDR_COMMON -( -§_´efix -) \ - -36 -§_çmžy_t - -§_´efix -## -çmžy - - - ) - -38  - #__SOCKADDR_COMMON_SIZE - ( ()) - - ) - - @/usr/include/bits/socket.h - -21 #iâdeà -__BITS_SOCKET_H - - -22  - #__BITS_SOCKET_H - - - ) - -24 #iâdeà -_SYS_SOCKET_H - - -28  - #__Ãed_size_t - - - ) - -29  - ~<¡ddef.h -> - -31  - ~ - -34 #iâdeà -__sockËn_t_defšed - - -35  -__sockËn_t - - tsockËn_t -; - -36  - #__sockËn_t_defšed - - - ) - -40 - e__sock‘_ty³ - - -42 - mSOCK_STREAM - = 1, - -44  - #SOCK_STREAM - -SOCK_STREAM - - - ) - -45 - mSOCK_DGRAM - = 2, - -47  - #SOCK_DGRAM - -SOCK_DGRAM - - - ) - -48 - mSOCK_RAW - = 3, - -49  - #SOCK_RAW - -SOCK_RAW - - - ) - -50 - mSOCK_RDM - = 4, - -51  - #SOCK_RDM - -SOCK_RDM - - - ) - -52 - mSOCK_SEQPACKET - = 5, - -54  - #SOCK_SEQPACKET - -SOCK_SEQPACKET - - - ) - -55 - mSOCK_DCCP - = 6, - -56  - #SOCK_DCCP - -SOCK_DCCP - - - ) - -57 - mSOCK_PACKET - = 10, - -60  - #SOCK_PACKET - -SOCK_PACKET - - - ) - -65 - mSOCK_CLOEXEC - = 02000000, - -67  - #SOCK_CLOEXEC - -SOCK_CLOEXEC - - - ) - -68 - mSOCK_NONBLOCK - = 04000 - -70  - #SOCK_NONBLOCK - -SOCK_NONBLOCK - - - ) - -74  - #PF_UNSPEC - 0 - - ) - -75  - #PF_LOCAL - 1 - - ) - -76  - #PF_UNIX - -PF_LOCAL - - - ) - -77  - #PF_FILE - -PF_LOCAL - - - ) - -78  - #PF_INET - 2 - - ) - -79  - #PF_AX25 - 3 - - ) - -80  - #PF_IPX - 4 - - ) - -81  - #PF_APPLETALK - 5 - - ) - -82  - #PF_NETROM - 6 - - ) - -83  - #PF_BRIDGE - 7 - - ) - -84  - #PF_ATMPVC - 8 - - ) - -85  - #PF_X25 - 9 - - ) - -86  - #PF_INET6 - 10 - - ) - -87  - #PF_ROSE - 11 - - ) - -88  - #PF_DECÃt - 12 - - ) - -89  - #PF_NETBEUI - 13 - - ) - -90  - #PF_SECURITY - 14 - - ) - -91  - #PF_KEY - 15 - - ) - -92  - #PF_NETLINK - 16 - - ) - -93  - #PF_ROUTE - -PF_NETLINK - - - ) - -94  - #PF_PACKET - 17 - - ) - -95  - #PF_ASH - 18 - - ) - -96  - #PF_ECONET - 19 - - ) - -97  - #PF_ATMSVC - 20 - - ) - -98  - #PF_RDS - 21 - - ) - -99  - #PF_SNA - 22 - - ) - -100  - #PF_IRDA - 23 - - ) - -101  - #PF_PPPOX - 24 - - ) - -102  - #PF_WANPIPE - 25 - - ) - -103  - #PF_LLC - 26 - - ) - -104  - #PF_CAN - 29 - - ) - -105  - #PF_TIPC - 30 - - ) - -106  - #PF_BLUETOOTH - 31 - - ) - -107  - #PF_IUCV - 32 - - ) - -108  - #PF_RXRPC - 33 - - ) - -109  - #PF_ISDN - 34 - - ) - -110  - #PF_PHONET - 35 - - ) - -111  - #PF_IEEE802154 - 36 - - ) - -112  - #PF_CAIF - 37 - - ) - -113  - #PF_ALG - 38 - - ) - -114  - #PF_MAX - 39 - - ) - -117  - #AF_UNSPEC - -PF_UNSPEC - - - ) - -118  - #AF_LOCAL - -PF_LOCAL - - - ) - -119  - #AF_UNIX - -PF_UNIX - - - ) - -120  - #AF_FILE - -PF_FILE - - - ) - -121  - #AF_INET - -PF_INET - - - ) - -122  - #AF_AX25 - -PF_AX25 - - - ) - -123  - #AF_IPX - -PF_IPX - - - ) - -124  - #AF_APPLETALK - -PF_APPLETALK - - - ) - -125  - #AF_NETROM - -PF_NETROM - - - ) - -126  - #AF_BRIDGE - -PF_BRIDGE - - - ) - -127  - #AF_ATMPVC - -PF_ATMPVC - - - ) - -128  - #AF_X25 - -PF_X25 - - - ) - -129  - #AF_INET6 - -PF_INET6 - - - ) - -130  - #AF_ROSE - -PF_ROSE - - - ) - -131  - #AF_DECÃt - -PF_DECÃt - - - ) - -132  - #AF_NETBEUI - -PF_NETBEUI - - - ) - -133  - #AF_SECURITY - -PF_SECURITY - - - ) - -134  - #AF_KEY - -PF_KEY - - - ) - -135  - #AF_NETLINK - -PF_NETLINK - - - ) - -136  - #AF_ROUTE - -PF_ROUTE - - - ) - -137  - #AF_PACKET - -PF_PACKET - - - ) - -138  - #AF_ASH - -PF_ASH - - - ) - -139  - #AF_ECONET - -PF_ECONET - - - ) - -140  - #AF_ATMSVC - -PF_ATMSVC - - - ) - -141  - #AF_RDS - -PF_RDS - - - ) - -142  - #AF_SNA - -PF_SNA - - - ) - -143  - #AF_IRDA - -PF_IRDA - - - ) - -144  - #AF_PPPOX - -PF_PPPOX - - - ) - -145  - #AF_WANPIPE - -PF_WANPIPE - - - ) - -146  - #AF_LLC - -PF_LLC - - - ) - -147  - #AF_CAN - -PF_CAN - - - ) - -148  - #AF_TIPC - -PF_TIPC - - - ) - -149  - #AF_BLUETOOTH - -PF_BLUETOOTH - - - ) - -150  - #AF_IUCV - -PF_IUCV - - - ) - -151  - #AF_RXRPC - -PF_RXRPC - - - ) - -152  - #AF_ISDN - -PF_ISDN - - - ) - -153  - #AF_PHONET - -PF_PHONET - - - ) - -154  - #AF_IEEE802154 - -PF_IEEE802154 - - - ) - -155  - #AF_CAIF - -PF_CAIF - - - ) - -156  - #AF_ALG - -PF_ALG - - - ) - -157  - #AF_MAX - -PF_MAX - - - ) - -163  - #SOL_RAW - 255 - - ) - -164  - #SOL_DECNET - 261 - - ) - -165  - #SOL_X25 - 262 - - ) - -166  - #SOL_PACKET - 263 - - ) - -167  - #SOL_ATM - 264 - - ) - -168  - #SOL_AAL - 265 - - ) - -169  - #SOL_IRDA - 266 - - ) - -172  - #SOMAXCONN - 128 - - ) - -175  - ~ - -178  - ssockaddr - - -180 -__SOCKADDR_COMMON - ( -§_ -); - -181  - m§_d©a -[14]; - -187  - #__ss_®igÁy³ -  - - ) - -188  - #_SS_SIZE - 128 - - ) - -189  - #_SS_PADSIZE - ( -_SS_SIZE - - (2 *  ( -__ss_®igÁy³ -))) - - ) - -191  - ssockaddr_¡Üage - - -193 -__SOCKADDR_COMMON - ( -ss_ -); - -194 -__ss_®igÁy³ - - m__ss_®ign -; - -195  - m__ss_·ddšg -[ -_SS_PADSIZE -]; - -202 - mMSG_OOB - = 0x01, - -203  - #MSG_OOB - -MSG_OOB - - - ) - -204 - mMSG_PEEK - = 0x02, - -205  - #MSG_PEEK - -MSG_PEEK - - - ) - -206 - mMSG_DONTROUTE - = 0x04, - -207  - #MSG_DONTROUTE - -MSG_DONTROUTE - - - ) - -208 #ifdeà -__USE_GNU - - -210 - mMSG_TRYHARD - = -MSG_DONTROUTE -, - -211  - #MSG_TRYHARD - -MSG_DONTROUTE - - - ) - -213 - mMSG_CTRUNC - = 0x08, - -214  - #MSG_CTRUNC - -MSG_CTRUNC - - - ) - -215 - mMSG_PROXY - = 0x10, - -216  - #MSG_PROXY - -MSG_PROXY - - - ) - -217 - mMSG_TRUNC - = 0x20, - -218  - #MSG_TRUNC - -MSG_TRUNC - - - ) - -219 - mMSG_DONTWAIT - = 0x40, - -220  - #MSG_DONTWAIT - -MSG_DONTWAIT - - - ) - -221 - mMSG_EOR - = 0x80, - -222  - #MSG_EOR - -MSG_EOR - - - ) - -223 - mMSG_WAITALL - = 0x100, - -224  - #MSG_WAITALL - -MSG_WAITALL - - - ) - -225 - mMSG_FIN - = 0x200, - -226  - #MSG_FIN - -MSG_FIN - - - ) - -227 - mMSG_SYN - = 0x400, - -228  - #MSG_SYN - -MSG_SYN - - - ) - -229 - mMSG_CONFIRM - = 0x800, - -230  - #MSG_CONFIRM - -MSG_CONFIRM - - - ) - -231 - mMSG_RST - = 0x1000, - -232  - #MSG_RST - -MSG_RST - - - ) - -233 - mMSG_ERRQUEUE - = 0x2000, - -234  - #MSG_ERRQUEUE - -MSG_ERRQUEUE - - - ) - -235 - mMSG_NOSIGNAL - = 0x4000, - -236  - #MSG_NOSIGNAL - -MSG_NOSIGNAL - - - ) - -237 - mMSG_MORE - = 0x8000, - -238  - #MSG_MORE - -MSG_MORE - - - ) - -239 - mMSG_WAITFORONE - = 0x10000, - -240  - #MSG_WAITFORONE - -MSG_WAITFORONE - - - ) - -242 - mMSG_CMSG_CLOEXEC - = 0x40000000 - -245  - #MSG_CMSG_CLOEXEC - -MSG_CMSG_CLOEXEC - - - ) - -251  - smsghdr - - -253 * - mmsg_Çme -; - -254 -sockËn_t - - mmsg_Çm–’ -; - -256  -iovec - * - mmsg_iov -; - -257 -size_t - - mmsg_iovËn -; - -259 * - mmsg_cÚŒÞ -; - -260 -size_t - - mmsg_cڌÞËn -; - -265  - mmsg_æags -; - -268 #ifdeà -__USE_GNU - - -270  - smmsghdr - - -272  -msghdr - - mmsg_hdr -; - -273  - mmsg_Ën -; - -278  - scmsghdr - - -280 -size_t - - mcmsg_Ën -; - -285  - mcmsg_Ëv– -; - -286  - mcmsg_ty³ -; - -287 #ià(! -defšed - -__STRICT_ANSI__ - && -__GNUC__ - >ð2è|| -__STDC_VERSION__ - >= 199901L - -288 -__ex‹nsiÚ__ -  -__cmsg_d©a - - m__æex¬r -; - -293 #ià(! -defšed - -__STRICT_ANSI__ - && -__GNUC__ - >ð2è|| -__STDC_VERSION__ - >= 199901L - -294  - #CMSG_DATA -( -cmsg -è((cmsg)-> -__cmsg_d©a -) - - ) - -296  - #CMSG_DATA -( -cmsg -è((*è(( -cmsghdr - *è(cmsgè+ 1)) - - ) - -298  - #CMSG_NXTHDR -( -mhdr -, -cmsg -è - `__cmsg_nxthdr - (mhdr, cmsg) - - ) - -299  - #CMSG_FIRSTHDR -( -mhdr -) \ - -300 (( -size_t -è( -mhdr -)-> -msg_cڌÞËn - >ð ( -cmsghdr -) \ - -301 ? ( -cmsghdr - *è( -mhdr -)-> -msg_cÚŒÞ - : (cmsghd¸*è0) - - ) - -302  - #CMSG_ALIGN -( -Ën -è((֒è+  ( -size_t -) - 1) \ - -303 & ( -size_t -è~( (size_tè- 1)) - - ) - -304  - #CMSG_SPACE -( -Ën -è( - `CMSG_ALIGN - (len) \ - -305 + - `CMSG_ALIGN - ( ( -cmsghdr -))) - - ) - -306  - #CMSG_LEN -( -Ën -è( - `CMSG_ALIGN - ( ( -cmsghdr -)è+ (Ën)) - - ) - -308  -cmsghdr - * - $__cmsg_nxthdr - ( -msghdr - * -__mhdr -, - -309  -cmsghdr - * -__cmsg -è -__THROW -; - -310 #ifdeà -__USE_EXTERN_INLINES - - -311 #iâdeà -_EXTERN_INLINE - - -312  - #_EXTERN_INLINE - -__ex‹º_šlše - - - ) - -314 -_EXTERN_INLINE -  -cmsghdr - * - -315 - `__NTH - ( - $__cmsg_nxthdr - ( -msghdr - * -__mhdr -,  -cmsghdr - * -__cmsg -)) - -317 ià(( -size_t -è -__cmsg --> -cmsg_Ën - <  ( -cmsghdr -)) - -321 -__cmsg - = ( -cmsghdr - *) ((*) __cmsg - -322 + - `CMSG_ALIGN - ( -__cmsg --> -cmsg_Ën -)); - -323 ià((*è( -__cmsg - + 1è> ((*è -__mhdr --> -msg_cÚŒÞ - - -324 + -__mhdr --> -msg_cڌÞËn -) - -325 || ((*è -__cmsg - + - `CMSG_ALIGN - (__cmsg-> -cmsg_Ën -) - -326 > ((*è -__mhdr --> -msg_cÚŒÞ - + __mhdr-> -msg_cڌÞËn -))) - -329  -__cmsg -; - -330 - } -} - -337 - mSCM_RIGHTS - = 0x01 - -338  - #SCM_RIGHTS - -SCM_RIGHTS - - - ) - -339 #ifdeà -__USE_GNU - - -340 , - mSCM_CREDENTIALS - = 0x02 - -341  - #SCM_CREDENTIALS - -SCM_CREDENTIALS - - - ) - -345 #ifdeà -__USE_GNU - - -347  - suüed - - -349 -pid_t - - mpid -; - -350 -uid_t - - muid -; - -351 -gid_t - - mgid -; - -356 #ià! -defšed - -__USE_MISC - && !defšed -__USE_GNU - - -357 #iâdeà -FIOGETOWN - - -358  - #__SYS_SOCKET_H_undef_FIOGETOWN - - - ) - -360 #iâdeà -FIOSETOWN - - -361  - #__SYS_SOCKET_H_undef_FIOSETOWN - - - ) - -363 #iâdeà -SIOCATMARK - - -364  - #__SYS_SOCKET_H_undef_SIOCATMARK - - - ) - -366 #iâdeà -SIOCGPGRP - - -367  - #__SYS_SOCKET_H_undef_SIOCGPGRP - - - ) - -369 #iâdeà -SIOCGSTAMP - - -370  - #__SYS_SOCKET_H_undef_SIOCGSTAMP - - - ) - -372 #iâdeà -SIOCGSTAMPNS - - -373  - #__SYS_SOCKET_H_undef_SIOCGSTAMPNS - - - ) - -375 #iâdeà -SIOCSPGRP - - -376  - #__SYS_SOCKET_H_undef_SIOCSPGRP - - - ) - -381  - ~ - -383 #ià! -defšed - -__USE_MISC - && !defšed -__USE_GNU - - -384 #ifdeà -__SYS_SOCKET_H_undef_FIOGETOWN - - -385 #undeà -__SYS_SOCKET_H_undef_FIOGETOWN - - -386 #undeà -FIOGETOWN - - -388 #ifdeà -__SYS_SOCKET_H_undef_FIOSETOWN - - -389 #undeà -__SYS_SOCKET_H_undef_FIOSETOWN - - -390 #undeà -FIOSETOWN - - -392 #ifdeà -__SYS_SOCKET_H_undef_SIOCATMARK - - -393 #undeà -__SYS_SOCKET_H_undef_SIOCATMARK - - -394 #undeà -SIOCATMARK - - -396 #ifdeà -__SYS_SOCKET_H_undef_SIOCGPGRP - - -397 #undeà -__SYS_SOCKET_H_undef_SIOCGPGRP - - -398 #undeà -SIOCGPGRP - - -400 #ifdeà -__SYS_SOCKET_H_undef_SIOCGSTAMP - - -401 #undeà -__SYS_SOCKET_H_undef_SIOCGSTAMP - - -402 #undeà -SIOCGSTAMP - - -404 #ifdeà -__SYS_SOCKET_H_undef_SIOCGSTAMPNS - - -405 #undeà -__SYS_SOCKET_H_undef_SIOCGSTAMPNS - - -406 #undeà -SIOCGSTAMPNS - - -408 #ifdeà -__SYS_SOCKET_H_undef_SIOCSPGRP - - -409 #undeà -__SYS_SOCKET_H_undef_SIOCSPGRP - - -410 #undeà -SIOCSPGRP - - -415  - slšg” - - -417  - ml_Úoff -; - -418  - ml_lšg” -; - -422 -__BEGIN_DECLS - - -429  -»cvmmsg - ( -__fd -,  -mmsghdr - * -__vmes§ges -, - -430  -__vËn -,  -__æags -, - -431 -__cÚ¡ -  -time¥ec - * -__tmo -); - -433 - g__END_DECLS - - - @/usr/include/bits/socket2.h - -20 #iâdeà -_SYS_SOCKET_H - - -24 -ssize_t - -__»cv_chk - ( -__fd -, * -__buf -, -size_t - -__n -, size_ˆ -__buæ’ -, - -25  -__æags -); - -26 -ssize_t - -__REDIRECT - ( -__»cv_®Ÿs -, ( -__fd -, * -__buf -, -size_t - -__n -, - -27  -__æags -), -»cv -); - -28 -ssize_t - -__REDIRECT - ( -__»cv_chk_w¬n -, - -29 ( -__fd -, * -__buf -, -size_t - -__n -, size_ˆ -__buæ’ -, - -30  -__æags -), -__»cv_chk -) - -31 -__w¬Ç‰r - ("recv called with bigger†engthhan size of destination " - -34 -__ex‹º_®ways_šlše - -ssize_t - - -35 - $»cv - ( -__fd -, * -__buf -, -size_t - -__n -,  -__æags -) - -37 ià( - `__bos0 - ( -__buf -è!ð( -size_t -) -1) - -39 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -)) - -40  - `__»cv_chk - ( -__fd -, -__buf -, -__n -, - `__bos0 - (__buf), -__æags -); - -42 ià( -__n - > - `__bos0 - ( -__buf -)) - -43  - `__»cv_chk_w¬n - ( -__fd -, -__buf -, -__n -, - `__bos0 - (__buf), -__æags -); - -45  - `__»cv_®Ÿs - ( -__fd -, -__buf -, -__n -, -__æags -); - -46 - } -} - -48 -ssize_t - -__»cväom_chk - ( -__fd -, * -__»¡riù - -__buf -, -size_t - -__n -, - -49 -size_t - -__buæ’ -,  -__æags -, - -50 -__SOCKADDR_ARG - -__addr -, - -51 -sockËn_t - * -__»¡riù - -__addr_Ën -); - -52 -ssize_t - -__REDIRECT - ( -__»cväom_®Ÿs -, - -53 ( -__fd -, * -__»¡riù - -__buf -, -size_t - -__n -, - -54  -__æags -, -__SOCKADDR_ARG - -__addr -, - -55 -sockËn_t - * -__»¡riù - -__addr_Ën -), -»cväom -); - -56 -ssize_t - -__REDIRECT - ( -__»cväom_chk_w¬n -, - -57 ( -__fd -, * -__»¡riù - -__buf -, -size_t - -__n -, - -58 -size_t - -__buæ’ -,  -__æags -, - -59 -__SOCKADDR_ARG - -__addr -, - -60 -sockËn_t - * -__»¡riù - -__addr_Ën -), -__»cväom_chk -) - -61 -__w¬Ç‰r - ("recvfrom called with bigger†engthhan size of " - -64 -__ex‹º_®ways_šlše - -ssize_t - - -65 - $»cväom - ( -__fd -, * -__»¡riù - -__buf -, -size_t - -__n -,  -__æags -, - -66 -__SOCKADDR_ARG - -__addr -, -sockËn_t - * -__»¡riù - -__addr_Ën -) - -68 ià( - `__bos0 - ( -__buf -è!ð( -size_t -) -1) - -70 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -)) - -71  - `__»cväom_chk - ( -__fd -, -__buf -, -__n -, - `__bos0 - (__buf), -__æags -, - -72 -__addr -, -__addr_Ën -); - -73 ià( -__n - > - `__bos0 - ( -__buf -)) - -74  - `__»cväom_chk_w¬n - ( -__fd -, -__buf -, -__n -, - `__bos0 - (__buf), -__æags -, - -75 -__addr -, -__addr_Ën -); - -77  - `__»cväom_®Ÿs - ( -__fd -, -__buf -, -__n -, -__æags -, -__addr -, -__addr_Ën -); - -78 - } -} - - @/usr/include/bits/stat.h - -19 #ià! -defšed - -_SYS_STAT_H - && !defšed -_FCNTL_H - - -23 #iâdeà -_BITS_STAT_H - - -24  - #_BITS_STAT_H - 1 - - ) - -27  - #_STAT_VER_KERNEL - 0 - - ) - -29 #ià -__WORDSIZE - == 32 - -30  - #_STAT_VER_SVR4 - 2 - - ) - -31  - #_STAT_VER_LINUX - 3 - - ) - -34  - #_MKNOD_VER_LINUX - 1 - - ) - -35  - #_MKNOD_VER_SVR4 - 2 - - ) - -36  - #_MKNOD_VER - -_MKNOD_VER_LINUX - - - ) - -38  - #_STAT_VER_LINUX - 1 - - ) - -41  - #_MKNOD_VER_LINUX - 0 - - ) - -44  - #_STAT_VER - -_STAT_VER_LINUX - - - ) - -46  - s¡© - - -48 -__dev_t - - m¡_dev -; - -49 #ià -__WORDSIZE - == 32 - -50  - m__·d1 -; - -52 #ià -__WORDSIZE - =ð64 || ! -defšed - -__USE_FILE_OFFSET64 - - -53 -__šo_t - - m¡_šo -; - -55 -__šo_t - - m__¡_šo -; - -57 #ià -__WORDSIZE - == 32 - -58 -__mode_t - - m¡_mode -; - -59 -__ƚk_t - - m¡_ƚk -; - -61 -__ƚk_t - - m¡_ƚk -; - -62 -__mode_t - - m¡_mode -; - -64 -__uid_t - - m¡_uid -; - -65 -__gid_t - - m¡_gid -; - -66 #ià -__WORDSIZE - == 64 - -67  - m__·d0 -; - -69 -__dev_t - - m¡_rdev -; - -70 #ià -__WORDSIZE - == 32 - -71  - m__·d2 -; - -73 #ià -__WORDSIZE - =ð64 || ! -defšed - -__USE_FILE_OFFSET64 - - -74 -__off_t - - m¡_size -; - -76 -__off64_t - - m¡_size -; - -78 -__blksize_t - - m¡_blksize -; - -79 #ià -__WORDSIZE - =ð64 || ! -defšed - -__USE_FILE_OFFSET64 - - -80 -__blkút_t - - m¡_blocks -; - -82 -__blkút64_t - - m¡_blocks -; - -84 #ià -defšed - -__USE_MISC - || defšed -__USE_XOPEN2K8 - - -91  -time¥ec - - m¡_©im -; - -92  -time¥ec - - m¡_mtim -; - -93  -time¥ec - - m¡_ùim -; - -94  - #¡_©ime - -¡_©im -. -tv_£c - - - ) - -95  - #¡_mtime - -¡_mtim -. -tv_£c - - - ) - -96  - #¡_ùime - -¡_ùim -. -tv_£c - - - ) - -98 -__time_t - - m¡_©ime -; - -99  - m¡_©im’£c -; - -100 -__time_t - - m¡_mtime -; - -101  - m¡_mtim’£c -; - -102 -__time_t - - m¡_ùime -; - -103  - m¡_ùim’£c -; - -105 #ià -__WORDSIZE - == 64 - -106  - m__unu£d -[3]; - -108 #iâdeà -__USE_FILE_OFFSET64 - - -109  - m__unu£d4 -; - -110  - m__unu£d5 -; - -112 -__šo64_t - - m¡_šo -; - -117 #ifdeà -__USE_LARGEFILE64 - - -119  - s¡©64 - - -121 -__dev_t - - m¡_dev -; - -122 #ià -__WORDSIZE - == 64 - -123 -__šo64_t - - m¡_šo -; - -124 -__ƚk_t - - m¡_ƚk -; - -125 -__mode_t - - m¡_mode -; - -127  - m__·d1 -; - -128 -__šo_t - - m__¡_šo -; - -129 -__mode_t - - m¡_mode -; - -130 -__ƚk_t - - m¡_ƚk -; - -132 -__uid_t - - m¡_uid -; - -133 -__gid_t - - m¡_gid -; - -134 #ià -__WORDSIZE - == 64 - -135  - m__·d0 -; - -136 -__dev_t - - m¡_rdev -; - -137 -__off_t - - m¡_size -; - -139 -__dev_t - - m¡_rdev -; - -140  - m__·d2 -; - -141 -__off64_t - - m¡_size -; - -143 -__blksize_t - - m¡_blksize -; - -144 -__blkút64_t - - m¡_blocks -; - -145 #ià -defšed - -__USE_MISC - || defšed -__USE_XOPEN2K8 - - -152  -time¥ec - - m¡_©im -; - -153  -time¥ec - - m¡_mtim -; - -154  -time¥ec - - m¡_ùim -; - -155  - #¡_©ime - -¡_©im -. -tv_£c - - - ) - -156  - #¡_mtime - -¡_mtim -. -tv_£c - - - ) - -157  - #¡_ùime - -¡_ùim -. -tv_£c - - - ) - -159 -__time_t - - m¡_©ime -; - -160  - m¡_©im’£c -; - -161 -__time_t - - m¡_mtime -; - -162  - m¡_mtim’£c -; - -163 -__time_t - - m¡_ùime -; - -164  - m¡_ùim’£c -; - -166 #ià -__WORDSIZE - == 64 - -167  - m__unu£d -[3]; - -169 -__šo64_t - - m¡_šo -; - -175  - #_STATBUF_ST_BLKSIZE - - - ) - -176  - #_STATBUF_ST_RDEV - - - ) - -178  - #_STATBUF_ST_NSEC - - - ) - -182  - #__S_IFMT - 0170000 - - ) - -185  - #__S_IFDIR - 0040000 - - ) - -186  - #__S_IFCHR - 0020000 - - ) - -187  - #__S_IFBLK - 0060000 - - ) - -188  - #__S_IFREG - 0100000 - - ) - -189  - #__S_IFIFO - 0010000 - - ) - -190  - #__S_IFLNK - 0120000 - - ) - -191  - #__S_IFSOCK - 0140000 - - ) - -195  - #__S_TYPEISMQ -( -buf -è((buf)-> -¡_mode - - (buf)->¡_mode) - - ) - -196  - #__S_TYPEISSEM -( -buf -è((buf)-> -¡_mode - - (buf)->¡_mode) - - ) - -197  - #__S_TYPEISSHM -( -buf -è((buf)-> -¡_mode - - (buf)->¡_mode) - - ) - -201  - #__S_ISUID - 04000 - - ) - -202  - #__S_ISGID - 02000 - - ) - -203  - #__S_ISVTX - 01000 - - ) - -204  - #__S_IREAD - 0400 - - ) - -205  - #__S_IWRITE - 0200 - - ) - -206  - #__S_IEXEC - 0100 - - ) - -208 #ifdeà -__USE_ATFILE - - -209  - #UTIME_NOW - ((1È<< 30è- 1l) - - ) - -210  - #UTIME_OMIT - ((1È<< 30è- 2l) - - ) - - @/usr/include/bits/stdio-ldbl.h - -20 #iâdeà -_STDIO_H - - -24 -__BEGIN_NAMESPACE_STD - - -25 - $__LDBL_REDIR_DECL - ( -årštf -) - -26 - $__LDBL_REDIR_DECL - ( -´štf -) - -27 - $__LDBL_REDIR_DECL - ( -¥rštf -) - -28 - $__LDBL_REDIR_DECL - ( -vårštf -) - -29 - $__LDBL_REDIR_DECL - ( -v´štf -) - -30 - $__LDBL_REDIR_DECL - ( -v¥rštf -) - -31 #ià -defšed - -__USE_ISOC99 - && !defšed -__USE_GNU - \ - -32 && ! -defšed - -__REDIRECT - \ - -33 && ( -defšed - -__STRICT_ANSI__ - || defšed -__USE_XOPEN2K -) - -34 - $__LDBL_REDIR1_DECL - ( -fsÿnf -, -__Ædbl___isoc99_fsÿnf -) - -35 - $__LDBL_REDIR1_DECL - ( -sÿnf -, -__Ædbl___isoc99_sÿnf -) - -36 - $__LDBL_REDIR1_DECL - ( -ssÿnf -, -__Ædbl___isoc99_ssÿnf -) - -38 - $__LDBL_REDIR_DECL - ( -fsÿnf -) - -39 - $__LDBL_REDIR_DECL - ( -sÿnf -) - -40 - $__LDBL_REDIR_DECL - ( -ssÿnf -) - -42 -__END_NAMESPACE_STD - - -44 #ià -defšed - -__USE_BSD - || defšed -__USE_ISOC99 - || defšed -__USE_UNIX98 - - -45 -__BEGIN_NAMESPACE_C99 - - -46 - $__LDBL_REDIR_DECL - ( -¢´štf -) - -47 - $__LDBL_REDIR_DECL - ( -v¢´štf -) - -48 -__END_NAMESPACE_C99 - - -51 #ifdef -__USE_ISOC99 - - -52 -__BEGIN_NAMESPACE_C99 - - -53 #ià! -defšed - -__USE_GNU - && !defšed -__REDIRECT - \ - -54 && ( -defšed - -__STRICT_ANSI__ - || defšed -__USE_XOPEN2K -) - -55 - $__LDBL_REDIR1_DECL - ( -vfsÿnf -, -__Ædbl___isoc99_vfsÿnf -) - -56 - $__LDBL_REDIR1_DECL - ( -vsÿnf -, -__Ædbl___isoc99_vsÿnf -) - -57 - $__LDBL_REDIR1_DECL - ( -vssÿnf -, -__Ædbl___isoc99_vssÿnf -) - -59 - $__LDBL_REDIR_DECL - ( -vfsÿnf -) - -60 - $__LDBL_REDIR_DECL - ( -vssÿnf -) - -61 - $__LDBL_REDIR_DECL - ( -vsÿnf -) - -63 -__END_NAMESPACE_C99 - - -66 #ifdeà -__USE_GNU - - -67 - $__LDBL_REDIR_DECL - ( -vd´štf -) - -68 - $__LDBL_REDIR_DECL - ( -d´štf -) - -69 - $__LDBL_REDIR_DECL - ( -va¥rštf -) - -70 - $__LDBL_REDIR_DECL - ( -__a¥rštf -) - -71 - $__LDBL_REDIR_DECL - ( -a¥rštf -) - -72 - $__LDBL_REDIR_DECL - ( -ob¡ack_´štf -) - -73 - $__LDBL_REDIR_DECL - ( -ob¡ack_v´štf -) - -76 #ià -__USE_FORTIFY_LEVEL - > 0 && -defšed - -__ex‹º_®ways_šlše - - -77 - $__LDBL_REDIR_DECL - ( -__¥rštf_chk -) - -78 - $__LDBL_REDIR_DECL - ( -__v¥rštf_chk -) - -79 #ià -defšed - -__USE_BSD - || defšed -__USE_ISOC99 - || defšed -__USE_UNIX98 - - -80 - $__LDBL_REDIR_DECL - ( -__¢´štf_chk -) - -81 - $__LDBL_REDIR_DECL - ( -__v¢´štf_chk -) - -83 #ià -__USE_FORTIFY_LEVEL - > 1 - -84 - $__LDBL_REDIR_DECL - ( -__årštf_chk -) - -85 - $__LDBL_REDIR_DECL - ( -__´štf_chk -) - -86 - $__LDBL_REDIR_DECL - ( -__vårštf_chk -) - -87 - $__LDBL_REDIR_DECL - ( -__v´štf_chk -) - -88 #ifdeà -__USE_GNU - - -89 - $__LDBL_REDIR_DECL - ( -__a¥rštf_chk -) - -90 - $__LDBL_REDIR_DECL - ( -__va¥rštf_chk -) - -91 - $__LDBL_REDIR_DECL - ( -__d´štf_chk -) - -92 - $__LDBL_REDIR_DECL - ( -__vd´štf_chk -) - -93 - $__LDBL_REDIR_DECL - ( -__ob¡ack_´štf_chk -) - -94 - $__LDBL_REDIR_DECL - ( -__ob¡ack_v´štf_chk -) - - @/usr/include/bits/stdio.h - -20 #iâdeà -_STDIO_H - - -24 #iâdeà -__ex‹º_šlše - - -25  - #__STDIO_INLINE - -šlše - - - ) - -27  - #__STDIO_INLINE - -__ex‹º_šlše - - - ) - -31 #ifdeà -__USE_EXTERN_INLINES - - -34 #ià!( -__USE_FORTIFY_LEVEL - > 0 && -defšed - -__ex‹º_®ways_šlše -) - -36 -__STDIO_INLINE -  - -37 - $v´štf - ( -__cÚ¡ - * -__»¡riù - -__fmt -, -_G_va_li¡ - -__¬g -) - -39  - `vårštf - ( -¡dout -, -__fmt -, -__¬g -); - -40 - } -} - -44 -__STDIO_INLINE -  - -45 - $g‘ch¬ - () - -47  - `_IO_g‘c - ( -¡dš -); - -48 - } -} - -51 #ifdeà -__USE_MISC - - -53 -__STDIO_INLINE -  - -54 - $fg‘c_uÆocked - ( -FILE - * -__å -) - -56  - `_IO_g‘c_uÆocked - ( -__å -); - -57 - } -} - -61 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -63 -__STDIO_INLINE -  - -64 - $g‘c_uÆocked - ( -FILE - * -__å -) - -66  - `_IO_g‘c_uÆocked - ( -__å -); - -67 - } -} - -70 -__STDIO_INLINE -  - -71 - $g‘ch¬_uÆocked - () - -73  - `_IO_g‘c_uÆocked - ( -¡dš -); - -74 - } -} - -79 -__STDIO_INLINE -  - -80 - $putch¬ - ( -__c -) - -82  - `_IO_putc - ( -__c -, -¡dout -); - -83 - } -} - -86 #ifdeà -__USE_MISC - - -88 -__STDIO_INLINE -  - -89 - $åutc_uÆocked - ( -__c -, -FILE - * -__¡»am -) - -91  - `_IO_putc_uÆocked - ( -__c -, -__¡»am -); - -92 - } -} - -96 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -98 -__STDIO_INLINE -  - -99 - $putc_uÆocked - ( -__c -, -FILE - * -__¡»am -) - -101  - `_IO_putc_uÆocked - ( -__c -, -__¡»am -); - -102 - } -} - -105 -__STDIO_INLINE -  - -106 - $putch¬_uÆocked - ( -__c -) - -108  - `_IO_putc_uÆocked - ( -__c -, -¡dout -); - -109 - } -} - -113 #ifdef -__USE_GNU - - -115 -__STDIO_INLINE - -_IO_ssize_t - - -116 - $g‘lše - (** -__lš•Œ -, -size_t - * -__n -, -FILE - * -__¡»am -) - -118  - `__g‘d–im - ( -__lš•Œ -, -__n -, '\n', -__¡»am -); - -119 - } -} - -123 #ifdeà -__USE_MISC - - -125 -__STDIO_INLINE -  - -126 -__NTH - ( - $ãof_uÆocked - ( -FILE - * -__¡»am -)) - -128  - `_IO_ãof_uÆocked - ( -__¡»am -); - -129 - } -} - -132 -__STDIO_INLINE -  - -133 -__NTH - ( - $ã¼Ü_uÆocked - ( -FILE - * -__¡»am -)) - -135  - `_IO_ã¼Ü_uÆocked - ( -__¡»am -); - -136 - } -} - -142 #ià -defšed - -__USE_MISC - && defšed -__GNUC__ - && defšed -__OPTIMIZE__ - \ - -143 && ! -defšed - - g__ýlu¥lus - - -145  - #ä—d_uÆocked -( -±r -, -size -, -n -, -¡»am -) \ - -146 ( - `__ex‹nsiÚ__ - (( - `__bužtš_cÚ¡ªt_p - ( -size -è&& __bužtš_cÚ¡ªt_°( -n -) \ - -147 && ( -size_t -è( -size -è* (size_tè( -n -) <= 8 \ - -148 && ( -size_t -è( -size -) != 0) \ - -149 ? ({ * -__±r - = (*è( -±r -); \ - -150 -FILE - * -__¡»am - = ( -¡»am -); \ - -151 -size_t - -__út -; \ - -152  -__út - = ( -size_t -è( -size -è* (size_tè( -n -); \ - -153 -__út - > 0; --__cnt) \ - -155  -__c - = - `_IO_g‘c_uÆocked - ( -__¡»am -); \ - -156 ià( -__c - =ð -EOF -) \ - -158 * -__±r -++ = -__c -; \ - -160 (( -size_t -è( -size -è* (size_tè( -n -è- -__út -) \ - -161 / ( -size_t -è( -size -); }) \ - -162 : ((( - `__bužtš_cÚ¡ªt_p - ( -size -è&& ( -size_t -) (size) == 0) \ - -163 || ( - `__bužtš_cÚ¡ªt_p - ( -n -è&& ( -size_t -) (n) == 0)) \ - -165 ? ((è( -±r -), (è( -¡»am -), (è( -size -), \ - -166 (è( -n -), ( -size_t -) 0) \ - -167 : - `ä—d_uÆocked - ( -±r -, -size -, -n -, -¡»am -)))) - - ) - -169  - #fwr™e_uÆocked -( -±r -, -size -, -n -, -¡»am -) \ - -170 ( - `__ex‹nsiÚ__ - (( - `__bužtš_cÚ¡ªt_p - ( -size -è&& __bužtš_cÚ¡ªt_°( -n -) \ - -171 && ( -size_t -è( -size -è* (size_tè( -n -) <= 8 \ - -172 && ( -size_t -è( -size -) != 0) \ - -173 ? ({ cÚ¡ * -__±r - = (cÚ¡ *è( -±r -); \ - -174 -FILE - * -__¡»am - = ( -¡»am -); \ - -175 -size_t - -__út -; \ - -176  -__út - = ( -size_t -è( -size -è* (size_tè( -n -); \ - -177 -__út - > 0; --__cnt) \ - -178 ià( - `_IO_putc_uÆocked - (* -__±r -++, -__¡»am -è=ð -EOF -) \ - -180 (( -size_t -è( -size -è* (size_tè( -n -è- -__út -) \ - -181 / ( -size_t -è( -size -); }) \ - -182 : ((( - `__bužtš_cÚ¡ªt_p - ( -size -è&& ( -size_t -) (size) == 0) \ - -183 || ( - `__bužtš_cÚ¡ªt_p - ( -n -è&& ( -size_t -) (n) == 0)) \ - -185 ? ((è( -±r -), (è( -¡»am -), (è( -size -), \ - -186 (è( -n -), ( -size_t -) 0) \ - -187 : - `fwr™e_uÆocked - ( -±r -, -size -, -n -, -¡»am -)))) - - ) - -191 #undeà -__STDIO_INLINE - - - @/usr/include/bits/stdio2.h - -20 #iâdeà -_STDIO_H - - -24  - $__¥rštf_chk - (* -__»¡riù - -__s -,  -__æag -, -size_t - -__¦’ -, - -25 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...è -__THROW -; - -26  - $__v¥rštf_chk - (* -__»¡riù - -__s -,  -__æag -, -size_t - -__¦’ -, - -27 -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -28 -_G_va_li¡ - -__­ -è -__THROW -; - -30 #ifdeà -__va_¬g_·ck - - -31 -__ex‹º_®ways_šlše -  - -32 - `__NTH - ( - $¥rštf - (* -__»¡riù - -__s -, -__cÚ¡ - *__»¡riù -__fmt -, ...)) - -34  - `__bužtš___¥rštf_chk - ( -__s -, -__USE_FORTIFY_LEVEL - - 1, - -35 - `__bos - ( -__s -), -__fmt -, - `__va_¬g_·ck - ()); - -36 - } -} - -37 #–ià! -defšed - -__ýlu¥lus - - -38  - #¥rštf -( -¡r -, ...) \ - -39 - `__bužtš___¥rštf_chk - ( -¡r -, -__USE_FORTIFY_LEVEL - - 1, - `__bos - (str), \ - -40 -__VA_ARGS__ -) - - ) - -43 -__ex‹º_®ways_šlše -  - -44 -__NTH - ( - $v¥rštf - (* -__»¡riù - -__s -, -__cÚ¡ - *__»¡riù -__fmt -, - -45 -_G_va_li¡ - -__­ -)) - -47  - `__bužtš___v¥rštf_chk - ( -__s -, -__USE_FORTIFY_LEVEL - - 1, - -48 - `__bos - ( -__s -), -__fmt -, -__­ -); - -49 - } -} - -51 #ià -defšed - -__USE_BSD - || defšed -__USE_ISOC99 - || defšed -__USE_UNIX98 - - -53  - $__¢´štf_chk - (* -__»¡riù - -__s -, -size_t - -__n -,  -__æag -, - -54 -size_t - -__¦’ -, -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -55 ...è -__THROW -; - -56  - $__v¢´štf_chk - (* -__»¡riù - -__s -, -size_t - -__n -,  -__æag -, - -57 -size_t - -__¦’ -, -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -58 -_G_va_li¡ - -__­ -è -__THROW -; - -60 #ifdeà -__va_¬g_·ck - - -61 -__ex‹º_®ways_šlše -  - -62 - `__NTH - ( - $¢´štf - (* -__»¡riù - -__s -, -size_t - -__n -, - -63 -__cÚ¡ - * -__»¡riù - -__fmt -, ...)) - -65  - `__bužtš___¢´štf_chk - ( -__s -, -__n -, -__USE_FORTIFY_LEVEL - - 1, - -66 - `__bos - ( -__s -), -__fmt -, - `__va_¬g_·ck - ()); - -67 - } -} - -68 #–ià! -defšed - -__ýlu¥lus - - -69  - #¢´štf -( -¡r -, -Ën -, ...) \ - -70 - `__bužtš___¢´štf_chk - ( -¡r -, -Ën -, -__USE_FORTIFY_LEVEL - - 1, - `__bos - (str), \ - -71 -__VA_ARGS__ -) - - ) - -74 -__ex‹º_®ways_šlše -  - -75 -__NTH - ( - $v¢´štf - (* -__»¡riù - -__s -, -size_t - -__n -, - -76 -__cÚ¡ - * -__»¡riù - -__fmt -, -_G_va_li¡ - -__­ -)) - -78  - `__bužtš___v¢´štf_chk - ( -__s -, -__n -, -__USE_FORTIFY_LEVEL - - 1, - -79 - `__bos - ( -__s -), -__fmt -, -__­ -); - -80 - } -} - -84 #ià -__USE_FORTIFY_LEVEL - > 1 - -86  -__årštf_chk - ( -FILE - * -__»¡riù - -__¡»am -,  -__æag -, - -87 -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...); - -88  -__´štf_chk - ( -__æag -, -__cÚ¡ - * -__»¡riù - -__fÜm© -, ...); - -89  -__vårštf_chk - ( -FILE - * -__»¡riù - -__¡»am -,  -__æag -, - -90 -__cÚ¡ - * -__»¡riù - -__fÜm© -, -_G_va_li¡ - -__­ -); - -91  -__v´štf_chk - ( -__æag -, -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -92 -_G_va_li¡ - -__­ -); - -94 #ifdeà -__va_¬g_·ck - - -95 -__ex‹º_®ways_šlše -  - -96 - $årštf - ( -FILE - * -__»¡riù - -__¡»am -, -__cÚ¡ - *__»¡riù -__fmt -, ...) - -98  - `__årštf_chk - ( -__¡»am -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, - -99 - `__va_¬g_·ck - ()); - -100 - } -} - -102 -__ex‹º_®ways_šlše -  - -103 - $´štf - ( -__cÚ¡ - * -__»¡riù - -__fmt -, ...) - -105  - `__´štf_chk - ( -__USE_FORTIFY_LEVEL - - 1, -__fmt -, - `__va_¬g_·ck - ()); - -106 - } -} - -107 #–ià! -defšed - -__ýlu¥lus - - -108  - #´štf -(...) \ - -109 - `__´štf_chk - ( -__USE_FORTIFY_LEVEL - - 1, -__VA_ARGS__ -) - - ) - -110  - #årštf -( -¡»am -, ...) \ - -111 - `__årštf_chk - ( -¡»am -, -__USE_FORTIFY_LEVEL - - 1, -__VA_ARGS__ -) - - ) - -114 -__ex‹º_®ways_šlše -  - -115 - $v´štf - ( -__cÚ¡ - * -__»¡riù - -__fmt -, -_G_va_li¡ - -__­ -) - -117 #ifdeà -__USE_EXTERN_INLINES - - -118  - `__vårštf_chk - ( -¡dout -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, -__­ -); - -120  - `__v´štf_chk - ( -__USE_FORTIFY_LEVEL - - 1, -__fmt -, -__­ -); - -122 - } -} - -124 -__ex‹º_®ways_šlše -  - -125 - $vårštf - ( -FILE - * -__»¡riù - -__¡»am -, - -126 -__cÚ¡ - * -__»¡riù - -__fmt -, -_G_va_li¡ - -__­ -) - -128  - `__vårštf_chk - ( -__¡»am -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, -__­ -); - -129 - } -} - -131 #ifdeà -__USE_GNU - - -133  - $__a¥rštf_chk - (** -__»¡riù - -__±r -,  -__æag -, - -134 -__cÚ¡ - * -__»¡riù - -__fmt -, ...) - -135 -__THROW - - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__´štf__ -, 3, 4))è -__wur -; - -136  - $__va¥rštf_chk - (** -__»¡riù - -__±r -,  -__æag -, - -137 -__cÚ¡ - * -__»¡riù - -__fmt -, -_G_va_li¡ - -__¬g -) - -138 -__THROW - - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__´štf__ -, 3, 0))è -__wur -; - -139  - $__d´štf_chk - ( -__fd -,  -__æag -, -__cÚ¡ - * -__»¡riù - -__fmt -, - -140 ...è - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 3, 4))); - -141  - $__vd´štf_chk - ( -__fd -,  -__æag -, - -142 -__cÚ¡ - * -__»¡riù - -__fmt -, -_G_va_li¡ - -__¬g -) - -143 - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 3, 0))); - -144  - $__ob¡ack_´štf_chk - ( -ob¡ack - * -__»¡riù - -__ob¡ack -, - -145  -__æag -, -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -147 -__THROW - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 3, 4))); - -148  - $__ob¡ack_v´štf_chk - ( -ob¡ack - * -__»¡riù - -__ob¡ack -, - -149  -__æag -, - -150 -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -151 -_G_va_li¡ - -__¬gs -) - -152 -__THROW - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 3, 0))); - -154 #ifdeà -__va_¬g_·ck - - -155 -__ex‹º_®ways_šlše -  - -156 - `__NTH - ( - $a¥rštf - (** -__»¡riù - -__±r -, -__cÚ¡ - *__»¡riù -__fmt -, ...)) - -158  - `__a¥rštf_chk - ( -__±r -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, - -159 - `__va_¬g_·ck - ()); - -160 - } -} - -162 -__ex‹º_®ways_šlše -  - -163 -__NTH - ( - $__a¥rštf - (** -__»¡riù - -__±r -, -__cÚ¡ - *__»¡riù -__fmt -, - -166  - `__a¥rštf_chk - ( -__±r -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, - -167 - `__va_¬g_·ck - ()); - -168 - } -} - -170 -__ex‹º_®ways_šlše -  - -171 - $d´štf - ( -__fd -, -__cÚ¡ - * -__»¡riù - -__fmt -, ...) - -173  - `__d´štf_chk - ( -__fd -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, - -174 - `__va_¬g_·ck - ()); - -175 - } -} - -177 -__ex‹º_®ways_šlše -  - -178 -__NTH - ( - $ob¡ack_´štf - ( -ob¡ack - * -__»¡riù - -__ob¡ack -, - -179 -__cÚ¡ - * -__»¡riù - -__fmt -, ...)) - -181  - `__ob¡ack_´štf_chk - ( -__ob¡ack -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, - -182 - `__va_¬g_·ck - ()); - -183 - } -} - -184 #–ià! -defšed - -__ýlu¥lus - - -185  - #a¥rštf -( -±r -, ...) \ - -186 - `__a¥rštf_chk - ( -±r -, -__USE_FORTIFY_LEVEL - - 1, -__VA_ARGS__ -) - - ) - -187  - #__a¥rštf -( -±r -, ...) \ - -188 - `__a¥rštf_chk - ( -±r -, -__USE_FORTIFY_LEVEL - - 1, -__VA_ARGS__ -) - - ) - -189  - #d´štf -( -fd -, ...) \ - -190 - `__d´štf_chk - ( -fd -, -__USE_FORTIFY_LEVEL - - 1, -__VA_ARGS__ -) - - ) - -191  - #ob¡ack_´štf -( -ob¡ack -, ...) \ - -192 - `__ob¡ack_´štf_chk - ( -ob¡ack -, -__USE_FORTIFY_LEVEL - - 1, -__VA_ARGS__ -) - - ) - -195 -__ex‹º_®ways_šlše -  - -196 -__NTH - ( - $va¥rštf - (** -__»¡riù - -__±r -, -__cÚ¡ - *__»¡riù -__fmt -, - -197 -_G_va_li¡ - -__­ -)) - -199  - `__va¥rštf_chk - ( -__±r -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, -__­ -); - -200 - } -} - -202 -__ex‹º_®ways_šlše -  - -203 - $vd´štf - ( -__fd -, -__cÚ¡ - * -__»¡riù - -__fmt -, -_G_va_li¡ - -__­ -) - -205  - `__vd´štf_chk - ( -__fd -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, -__­ -); - -206 - } -} - -208 -__ex‹º_®ways_šlše -  - -209 -__NTH - ( - $ob¡ack_v´štf - ( -ob¡ack - * -__»¡riù - -__ob¡ack -, - -210 -__cÚ¡ - * -__»¡riù - -__fmt -, -_G_va_li¡ - -__­ -)) - -212  - `__ob¡ack_v´štf_chk - ( -__ob¡ack -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, - -213 -__­ -); - -214 - } -} - -220 * - $__g‘s_chk - (* -__¡r -, -size_t -è -__wur -; - -221 * - `__REDIRECT - ( -__g‘s_w¬n -, (* -__¡r -), -g‘s -) - -222 -__wur - - `__w¬Ç‰r - ("please use fgets or getline instead, gets can't " - -225 -__ex‹º_®ways_šlše - -__wur - * - -226 - $g‘s - (* -__¡r -) - -228 ià( - `__bos - ( -__¡r -è!ð( -size_t -) -1) - -229  - `__g‘s_chk - ( -__¡r -, - `__bos - (__str)); - -230  - `__g‘s_w¬n - ( -__¡r -); - -231 - } -} - -233 * - $__fg‘s_chk - (* -__»¡riù - -__s -, -size_t - -__size -,  -__n -, - -234 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -235 * - `__REDIRECT - ( -__fg‘s_®Ÿs -, - -236 (* -__»¡riù - -__s -,  -__n -, - -237 -FILE - * -__»¡riù - -__¡»am -), -fg‘s -è -__wur -; - -238 * - `__REDIRECT - ( -__fg‘s_chk_w¬n -, - -239 (* -__»¡riù - -__s -, -size_t - -__size -,  -__n -, - -240 -FILE - * -__»¡riù - -__¡»am -), -__fg‘s_chk -) - -241 -__wur - - `__w¬Ç‰r - ("fgets called with bigger sizehan†ength " - -244 -__ex‹º_®ways_šlše - -__wur - * - -245 - $fg‘s - (* -__»¡riù - -__s -,  -__n -, -FILE - *__»¡riù -__¡»am -) - -247 ià( - `__bos - ( -__s -è!ð( -size_t -) -1) - -249 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -) || __n <= 0) - -250  - `__fg‘s_chk - ( -__s -, - `__bos - (__s), -__n -, -__¡»am -); - -252 ià(( -size_t -è -__n - > - `__bos - ( -__s -)) - -253  - `__fg‘s_chk_w¬n - ( -__s -, - `__bos - (__s), -__n -, -__¡»am -); - -255  - `__fg‘s_®Ÿs - ( -__s -, -__n -, -__¡»am -); - -256 - } -} - -258 -size_t - - $__ä—d_chk - (* -__»¡riù - -__±r -, -size_t - -__±¾’ -, - -259 -size_t - -__size -, size_ˆ -__n -, - -260 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -261 -size_t - - `__REDIRECT - ( -__ä—d_®Ÿs -, - -262 (* -__»¡riù - -__±r -, -size_t - -__size -, - -263 -size_t - -__n -, -FILE - * -__»¡riù - -__¡»am -), - -264 -ä—d -è -__wur -; - -265 -size_t - - `__REDIRECT - ( -__ä—d_chk_w¬n -, - -266 (* -__»¡riù - -__±r -, -size_t - -__±¾’ -, - -267 -size_t - -__size -, size_ˆ -__n -, - -268 -FILE - * -__»¡riù - -__¡»am -), - -269 -__ä—d_chk -) - -270 -__wur - - `__w¬Ç‰r - ("fread called with bigger size *‚membhan†ength " - -273 -__ex‹º_®ways_šlše - -__wur - -size_t - - -274 - $ä—d - (* -__»¡riù - -__±r -, -size_t - -__size -, size_ˆ -__n -, - -275 -FILE - * -__»¡riù - -__¡»am -) - -277 ià( - `__bos0 - ( -__±r -è!ð( -size_t -) -1) - -279 ià(! - `__bužtš_cÚ¡ªt_p - ( -__size -) - -280 || ! - `__bužtš_cÚ¡ªt_p - ( -__n -) - -281 || ( -__size - | -__n -è>ð((( -size_t -) 1) << (8 *  (size_t) / 2))) - -282  - `__ä—d_chk - ( -__±r -, - `__bos0 - (__±r), -__size -, -__n -, -__¡»am -); - -284 ià( -__size - * -__n - > - `__bos0 - ( -__±r -)) - -285  - `__ä—d_chk_w¬n - ( -__±r -, - `__bos0 - (__±r), -__size -, -__n -, -__¡»am -); - -287  - `__ä—d_®Ÿs - ( -__±r -, -__size -, -__n -, -__¡»am -); - -288 - } -} - -290 #ifdeà -__USE_GNU - - -291 * - $__fg‘s_uÆocked_chk - (* -__»¡riù - -__s -, -size_t - -__size -, - -292  -__n -, -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -293 * - `__REDIRECT - ( -__fg‘s_uÆocked_®Ÿs -, - -294 (* -__»¡riù - -__s -,  -__n -, - -295 -FILE - * -__»¡riù - -__¡»am -), -fg‘s_uÆocked -è -__wur -; - -296 * - `__REDIRECT - ( -__fg‘s_uÆocked_chk_w¬n -, - -297 (* -__»¡riù - -__s -, -size_t - -__size -,  -__n -, - -298 -FILE - * -__»¡riù - -__¡»am -), -__fg‘s_uÆocked_chk -) - -299 -__wur - - `__w¬Ç‰r - ("fgets_unlocked called with bigger sizehan†ength " - -302 -__ex‹º_®ways_šlše - -__wur - * - -303 - $fg‘s_uÆocked - (* -__»¡riù - -__s -,  -__n -, -FILE - *__»¡riù -__¡»am -) - -305 ià( - `__bos - ( -__s -è!ð( -size_t -) -1) - -307 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -) || __n <= 0) - -308  - `__fg‘s_uÆocked_chk - ( -__s -, - `__bos - (__s), -__n -, -__¡»am -); - -310 ià(( -size_t -è -__n - > - `__bos - ( -__s -)) - -311  - `__fg‘s_uÆocked_chk_w¬n - ( -__s -, - `__bos - (__s), -__n -, -__¡»am -); - -313  - `__fg‘s_uÆocked_®Ÿs - ( -__s -, -__n -, -__¡»am -); - -314 - } -} - -317 #ifdeà -__USE_MISC - - -318 #undeà -ä—d_uÆocked - - -319 -size_t - - $__ä—d_uÆocked_chk - (* -__»¡riù - -__±r -, -size_t - -__±¾’ -, - -320 -size_t - -__size -, size_ˆ -__n -, - -321 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -322 -size_t - - `__REDIRECT - ( -__ä—d_uÆocked_®Ÿs -, - -323 (* -__»¡riù - -__±r -, -size_t - -__size -, - -324 -size_t - -__n -, -FILE - * -__»¡riù - -__¡»am -), - -325 -ä—d_uÆocked -è -__wur -; - -326 -size_t - - `__REDIRECT - ( -__ä—d_uÆocked_chk_w¬n -, - -327 (* -__»¡riù - -__±r -, -size_t - -__±¾’ -, - -328 -size_t - -__size -, size_ˆ -__n -, - -329 -FILE - * -__»¡riù - -__¡»am -), - -330 -__ä—d_uÆocked_chk -) - -331 -__wur - - `__w¬Ç‰r - ("fread_unlocked called with bigger size *‚membhan " - -334 -__ex‹º_®ways_šlše - -__wur - -size_t - - -335 - $ä—d_uÆocked - (* -__»¡riù - -__±r -, -size_t - -__size -, size_ˆ -__n -, - -336 -FILE - * -__»¡riù - -__¡»am -) - -338 ià( - `__bos0 - ( -__±r -è!ð( -size_t -) -1) - -340 ià(! - `__bužtš_cÚ¡ªt_p - ( -__size -) - -341 || ! - `__bužtš_cÚ¡ªt_p - ( -__n -) - -342 || ( -__size - | -__n -è>ð((( -size_t -) 1) << (8 *  (size_t) / 2))) - -343  - `__ä—d_uÆocked_chk - ( -__±r -, - `__bos0 - (__±r), -__size -, -__n -, - -344 -__¡»am -); - -346 ià( -__size - * -__n - > - `__bos0 - ( -__±r -)) - -347  - `__ä—d_uÆocked_chk_w¬n - ( -__±r -, - `__bos0 - (__±r), -__size -, -__n -, - -348 -__¡»am -); - -351 #ifdeà -__USE_EXTERN_INLINES - - -352 ià( - `__bužtš_cÚ¡ªt_p - ( -__size -) - -353 && - `__bužtš_cÚ¡ªt_p - ( -__n -) - -354 && ( -__size - | -__n -è< ((( -size_t -) 1) << (8 *  (size_t) / 2)) - -355 && -__size - * -__n - <= 8) - -357 -size_t - -__út - = -__size - * -__n -; - -358 * -__ýŒ - = (*è -__±r -; - -359 ià( -__út - == 0) - -362 ; -__út - > 0; --__cnt) - -364  -__c - = - `_IO_g‘c_uÆocked - ( -__¡»am -); - -365 ià( -__c - =ð -EOF -) - -367 * -__ýŒ -++ = -__c -; - -369  ( -__ýŒ - - (*è -__±r -è/ -__size -; - -372  - `__ä—d_uÆocked_®Ÿs - ( -__±r -, -__size -, -__n -, -__¡»am -); - -373 - } -} - - @/usr/include/bits/stdio_lim.h - -19 #ià! -defšed - -_STDIO_H - && !defšed -__Ãed_FOPEN_MAX - && !defšed -__Ãed_IOV_MAX - - -23 #ifdeà -_STDIO_H - - -24  - #L_tm²am - 20 - - ) - -25  - #TMP_MAX - 238328 - - ) - -26  - #FILENAME_MAX - 4096 - - ) - -28 #ifdeà -__USE_POSIX - - -29  - #L_ù”mid - 9 - - ) - -30 #ià! -defšed - -__USE_XOPEN2K - || defšed -__USE_GNU - - -31  - #L_cu£rid - 9 - - ) - -36 #ià -defšed - -__Ãed_FOPEN_MAX - || defšed -_STDIO_H - - -37 #undeà -FOPEN_MAX - - -38  - #FOPEN_MAX - 16 - - ) - -41 #ià -defšed - -__Ãed_IOV_MAX - && !defšed -IOV_MAX - - -42  - #IOV_MAX - 1024 - - ) - - @/usr/include/bits/stdlib-ldbl.h - -20 #iâdeà -_STDLIB_H - - -24 #ifdef -__USE_ISOC99 - - -25 -__BEGIN_NAMESPACE_C99 - - -26 - $__LDBL_REDIR1_DECL - ( -¡¹Þd -, -¡¹od -) - -27 -__END_NAMESPACE_C99 - - -30 #ifdeà -__USE_GNU - - -31 - $__LDBL_REDIR1_DECL - ( -¡¹Þd_l -, -¡¹od_l -) - -34 #ià -defšed - -__USE_SVID - || defšed -__USE_XOPEN_EXTENDED - - -35 #ifdeà -__USE_MISC - - -36 - $__LDBL_REDIR1_DECL - ( -qecvt -, -ecvt -) - -37 - $__LDBL_REDIR1_DECL - ( -qfcvt -, -fcvt -) - -38 - $__LDBL_REDIR1_DECL - ( -qgcvt -, -gcvt -) - -39 - $__LDBL_REDIR1_DECL - ( -qecvt_r -, -ecvt_r -) - -40 - $__LDBL_REDIR1_DECL - ( -qfcvt_r -, -fcvt_r -) - - @/usr/include/bits/stdlib.h - -20 #iâdeà -_STDLIB_H - - -24 * - $__»®·th_chk - ( -__cÚ¡ - * -__»¡riù - -__Çme -, - -25 * -__»¡riù - -__»sÞved -, - -26 -size_t - -__»sÞvedËn -è -__THROW - -__wur -; - -27 * - `__REDIRECT_NTH - ( -__»®·th_®Ÿs -, - -28 ( -__cÚ¡ - * -__»¡riù - -__Çme -, - -29 * -__»¡riù - -__»sÞved -), -»®·th -è -__wur -; - -30 * - `__REDIRECT_NTH - ( -__»®·th_chk_w¬n -, - -31 ( -__cÚ¡ - * -__»¡riù - -__Çme -, - -32 * -__»¡riù - -__»sÞved -, - -33 -size_t - -__»sÞvedËn -), -__»®·th_chk -è -__wur - - -34 - `__w¬Ç‰r - ("second‡rgument of„ealpath must beƒither NULL or‡t " - -37 -__ex‹º_®ways_šlše - -__wur - * - -38 - `__NTH - ( - $»®·th - ( -__cÚ¡ - * -__»¡riù - -__Çme -, *__»¡riù -__»sÞved -)) - -40 ià( - `__bos - ( -__»sÞved -è!ð( -size_t -) -1) - -42 #ià -defšed - -_LIBC_LIMITS_H_ - && defšed -PATH_MAX - - -43 ià( - `__bos - ( -__»sÞved -è< -PATH_MAX -) - -44  - `__»®·th_chk_w¬n - ( -__Çme -, -__»sÞved -, - `__bos - (__resolved)); - -46  - `__»®·th_chk - ( -__Çme -, -__»sÞved -, - `__bos - (__resolved)); - -49  - `__»®·th_®Ÿs - ( -__Çme -, -__»sÞved -); - -50 - } -} - -53  - $__±¢ame_r_chk - ( -__fd -, * -__buf -, -size_t - -__buæ’ -, - -54 -size_t - -__ėl -è -__THROW - - `__nÚnuÎ - ((2)); - -55  - `__REDIRECT_NTH - ( -__±¢ame_r_®Ÿs -, ( -__fd -, * -__buf -, - -56 -size_t - -__buæ’ -), -±¢ame_r -) - -57 - `__nÚnuÎ - ((2)); - -58  - `__REDIRECT_NTH - ( -__±¢ame_r_chk_w¬n -, - -59 ( -__fd -, * -__buf -, -size_t - -__buæ’ -, - -60 -size_t - -__ėl -), -__±¢ame_r_chk -) - -61 - `__nÚnuÎ - ((2)è - `__w¬Ç‰r - ("ptsname_r called with buflen biggerhan " - -64 -__ex‹º_®ways_šlše -  - -65 - `__NTH - ( - $±¢ame_r - ( -__fd -, * -__buf -, -size_t - -__buæ’ -)) - -67 ià( - `__bos - ( -__buf -è!ð( -size_t -) -1) - -69 ià(! - `__bužtš_cÚ¡ªt_p - ( -__buæ’ -)) - -70  - `__±¢ame_r_chk - ( -__fd -, -__buf -, -__buæ’ -, - `__bos - (__buf)); - -71 ià( -__buæ’ - > - `__bos - ( -__buf -)) - -72  - `__±¢ame_r_chk_w¬n - ( -__fd -, -__buf -, -__buæ’ -, - `__bos - (__buf)); - -74  - `__±¢ame_r_®Ÿs - ( -__fd -, -__buf -, -__buæ’ -); - -75 - } -} - -78  - $__wùomb_chk - (* -__s -, -wch¬_t - -__wch¬ -, -size_t - -__buæ’ -) - -79 -__THROW - -__wur -; - -80  - `__REDIRECT_NTH - ( -__wùomb_®Ÿs -, (* -__s -, -wch¬_t - -__wch¬ -), - -81 -wùomb -è -__wur -; - -83 -__ex‹º_®ways_šlše - -__wur -  - -84 - `__NTH - ( - $wùomb - (* -__s -, -wch¬_t - -__wch¬ -)) - -89  - #__STDLIB_MB_LEN_MAX - 16 - - ) - -90 #ià -defšed - -MB_LEN_MAX - && MB_LEN_MAX !ð -__STDLIB_MB_LEN_MAX - - -93 ià( - `__bos - ( -__s -è!ð( -size_t -è-1 && -__STDLIB_MB_LEN_MAX - > __bos (__s)) - -94  - `__wùomb_chk - ( -__s -, -__wch¬ -, - `__bos - (__s)); - -95  - `__wùomb_®Ÿs - ( -__s -, -__wch¬ -); - -96 - } -} - -99 -size_t - - $__mb¡owcs_chk - ( -wch¬_t - * -__»¡riù - -__d¡ -, - -100 -__cÚ¡ - * -__»¡riù - -__¤c -, - -101 -size_t - -__Ën -, size_ˆ -__d¡Ën -è -__THROW -; - -102 -size_t - - `__REDIRECT_NTH - ( -__mb¡owcs_®Ÿs -, - -103 ( -wch¬_t - * -__»¡riù - -__d¡ -, - -104 -__cÚ¡ - * -__»¡riù - -__¤c -, - -105 -size_t - -__Ën -), -mb¡owcs -); - -106 -size_t - - `__REDIRECT_NTH - ( -__mb¡owcs_chk_w¬n -, - -107 ( -wch¬_t - * -__»¡riù - -__d¡ -, - -108 -__cÚ¡ - * -__»¡riù - -__¤c -, - -109 -size_t - -__Ën -, size_ˆ -__d¡Ën -), -__mb¡owcs_chk -) - -110 - `__w¬Ç‰r - ("mbstowcs called with dst buffer smallerhan†en " - -113 -__ex‹º_®ways_šlše - -size_t - - -114 - `__NTH - ( - $mb¡owcs - ( -wch¬_t - * -__»¡riù - -__d¡ -, -__cÚ¡ - *__»¡riù -__¤c -, - -115 -size_t - -__Ën -)) - -117 ià( - `__bos - ( -__d¡ -è!ð( -size_t -) -1) - -119 ià(! - `__bužtš_cÚ¡ªt_p - ( -__Ën -)) - -120  - `__mb¡owcs_chk - ( -__d¡ -, -__¤c -, -__Ën -, - -121 - `__bos - ( -__d¡ -è/  ( -wch¬_t -)); - -123 ià( -__Ën - > - `__bos - ( -__d¡ -è/  ( -wch¬_t -)) - -124  - `__mb¡owcs_chk_w¬n - ( -__d¡ -, -__¤c -, -__Ën -, - -125 - `__bos - ( -__d¡ -è/  ( -wch¬_t -)); - -127  - `__mb¡owcs_®Ÿs - ( -__d¡ -, -__¤c -, -__Ën -); - -128 - } -} - -131 -size_t - - $__wc¡ombs_chk - (* -__»¡riù - -__d¡ -, - -132 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -133 -size_t - -__Ën -, size_ˆ -__d¡Ën -è -__THROW -; - -134 -size_t - - `__REDIRECT_NTH - ( -__wc¡ombs_®Ÿs -, - -135 (* -__»¡riù - -__d¡ -, - -136 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -137 -size_t - -__Ën -), -wc¡ombs -); - -138 -size_t - - `__REDIRECT_NTH - ( -__wc¡ombs_chk_w¬n -, - -139 (* -__»¡riù - -__d¡ -, - -140 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -141 -size_t - -__Ën -, size_ˆ -__d¡Ën -), -__wc¡ombs_chk -) - -142 - `__w¬Ç‰r - ("wcstombs called with dst buffer smallerhan†en"); - -144 -__ex‹º_®ways_šlše - -size_t - - -145 - `__NTH - ( - $wc¡ombs - (* -__»¡riù - -__d¡ -, -__cÚ¡ - -wch¬_t - *__»¡riù -__¤c -, - -146 -size_t - -__Ën -)) - -148 ià( - `__bos - ( -__d¡ -è!ð( -size_t -) -1) - -150 ià(! - `__bužtš_cÚ¡ªt_p - ( -__Ën -)) - -151  - `__wc¡ombs_chk - ( -__d¡ -, -__¤c -, -__Ën -, - `__bos - (__dst)); - -152 ià( -__Ën - > - `__bos - ( -__d¡ -)) - -153  - `__wc¡ombs_chk_w¬n - ( -__d¡ -, -__¤c -, -__Ën -, - `__bos - (__dst)); - -155  - `__wc¡ombs_®Ÿs - ( -__d¡ -, -__¤c -, -__Ën -); - -156 - } -} - - @/usr/include/bits/string.h - -20 #iâdeà -_STRING_H - - -26  - #_STRING_ARCH_uÇligÃd - 1 - - ) - - @/usr/include/bits/string2.h - -21 #iâdeà -_STRING_H - - -25 #ià! -defšed - -__NO_STRING_INLINES - && !defšed -__BOUNDED_POINTERS__ - - -42 #iâdeà -__STRING_INLINE - - -43 #ifdeà -__ýlu¥lus - - -44  - #__STRING_INLINE - -šlše - - - ) - -46  - #__STRING_INLINE - -__ex‹º_šlše - - - ) - -50 #ià -_STRING_ARCH_uÇligÃd - - -52  - ~<’dŸn.h -> - -53  - ~ - -55 #ià -__BYTE_ORDER - =ð -__LITTLE_ENDIAN - - -56  - #__STRING2_SMALL_GET16 -( -¤c -, -idx -) \ - -57 ((( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx - + 1] << 8 \ - -58 | (( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx -]) - - ) - -59  - #__STRING2_SMALL_GET32 -( -¤c -, -idx -) \ - -60 ((((( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx - + 3] << 8 \ - -61 | (( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx - + 2]) << 8 \ - -62 | (( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx - + 1]) << 8 \ - -63 | (( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx -]) - - ) - -65  - #__STRING2_SMALL_GET16 -( -¤c -, -idx -) \ - -66 ((( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx -] << 8 \ - -67 | (( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx - + 1]) - - ) - -68  - #__STRING2_SMALL_GET32 -( -¤c -, -idx -) \ - -69 ((((( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx -] << 8 \ - -70 | (( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx - + 1]) << 8 \ - -71 | (( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx - + 2]) << 8 \ - -72 | (( -__cÚ¡ - *è(__cÚ¡ *è( -¤c -))[ -idx - + 3]) - - ) - -77  - #__STRING2_COPY_TYPE -( -N -) \ - -78 ¡ruù {  -__¬r -[ -N -]; } \ - -79 - t__©Œibu‹__ - (( - t__·cked__ -)è - t__STRING2_COPY_ARR -## - tN - - - ) - -80 - t__STRING2_COPY_TYPE - (2); - -81 -__STRING2_COPY_TYPE - (3); - -82 -__STRING2_COPY_TYPE - (4); - -83 -__STRING2_COPY_TYPE - (5); - -84 -__STRING2_COPY_TYPE - (6); - -85 -__STRING2_COPY_TYPE - (7); - -86 -__STRING2_COPY_TYPE - (8); - -87 #undeà -__STRING2_COPY_TYPE - - -93  - #__¡ršg2_1b±r_p -( -__x -) \ - -94 (( -size_t -)(cÚ¡ *)(( -__x -è+ 1è- (size_t)(cÚ¡ *)(__xè=ð1) - - ) - -97 #ià! -defšed - -_HAVE_STRING_ARCH_mem£t - - -98 #ià! -__GNUC_PREREQ - (3, 0) - -99 #ià -_STRING_ARCH_uÇligÃd - - -100  - #mem£t -( -s -, -c -, -n -) \ - -101 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -n -) && (n) <= 16 \ - -102 ? (( -n -) == 1 \ - -103 ? - `__mem£t_1 - ( -s -, -c -) \ - -104 : - `__mem£t_gc - ( -s -, -c -, -n -)) \ - -105 : ( - `__bužtš_cÚ¡ªt_p - ( -c -) && (c) == '\0' \ - -106 ? ({ * -__s - = ( -s -); - `__bz”o - (__s, -n -); __s; }) \ - -107 : - `mem£t - ( -s -, -c -, -n -)))) - - ) - -109  - #__mem£t_1 -( -s -, -c -è({ * -__s - = (s); \ - -110 *(( -__ušt8_t - *è -__s -èð(__ušt8_tè -c -; __s; }) - - ) - -112  - #__mem£t_gc -( -s -, -c -, -n -) \ - -113 ({ * -__s - = ( -s -); \ - -115  -__ui -; \ - -116  -__usi -; \ - -117  -__uc -; \ - -118 } * -__u - = -__s -; \ - -119 -__ušt8_t - -__c - = (__ušt8_tè( -c -); \ - -122 (è( -n -)) \ - -125 -__u --> -__ui - = -__c - * 0x01010101; \ - -126 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -128 -__u --> -__ui - = -__c - * 0x01010101; \ - -129 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -131 -__u --> -__ui - = -__c - * 0x01010101; \ - -132 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -134 -__u --> -__usi - = (è -__c - * 0x0101; \ - -135 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 2); \ - -136 -__u --> -__uc - = (è -__c -; \ - -140 -__u --> -__ui - = -__c - * 0x01010101; \ - -141 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -143 -__u --> -__ui - = -__c - * 0x01010101; \ - -144 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -146 -__u --> -__ui - = -__c - * 0x01010101; \ - -147 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -149 -__u --> -__usi - = (è -__c - * 0x0101; \ - -153 -__u --> -__ui - = -__c - * 0x01010101; \ - -154 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -156 -__u --> -__ui - = -__c - * 0x01010101; \ - -157 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -159 -__u --> -__ui - = -__c - * 0x01010101; \ - -160 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -162 -__u --> -__uc - = (è -__c -; \ - -166 -__u --> -__ui - = -__c - * 0x01010101; \ - -167 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -169 -__u --> -__ui - = -__c - * 0x01010101; \ - -170 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -172 -__u --> -__ui - = -__c - * 0x01010101; \ - -173 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); \ - -175 -__u --> -__ui - = -__c - * 0x01010101; \ - -180 -__s -; }) - - ) - -182  - #mem£t -( -s -, -c -, -n -) \ - -183 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -c -) && (c) == '\0' \ - -184 ? ({ * -__s - = ( -s -); - `__bz”o - (__s, -n -); __s; }) \ - -185 : - `mem£t - ( -s -, -c -, -n -))) - - ) - -194 #ià -__GNUC_PREREQ - (2, 91) - -195  - #__bz”o -( -s -, -n -è - `__bužtš_mem£t - (s, '\0',‚) - - ) - -203 #ifdeà -__USE_GNU - - -204 #ià! -defšed - -_HAVE_STRING_ARCH_mempýy - || defšed -_FORCE_INLINES - - -205 #iâdeà -_HAVE_STRING_ARCH_mempýy - - -206 #ià -__GNUC_PREREQ - (3, 4) - -207  - #__mempýy -( -de¡ -, -¤c -, -n -è - `__bužtš_mempýy - (de¡, src,‚) - - ) - -208 #–ià -__GNUC_PREREQ - (3, 0) - -209  - #__mempýy -( -de¡ -, -¤c -, -n -) \ - -210 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -¤c -è&& __bužtš_cÚ¡ªt_°( -n -) \ - -211 && - `__¡ršg2_1b±r_p - ( -¤c -è&& -n - <= 8 \ - -212 ? - `__bužtš_memýy - ( -de¡ -, -¤c -, -n -) + (n) \ - -213 : - `__mempýy - ( -de¡ -, -¤c -, -n -))) - - ) - -215  - #__mempýy -( -de¡ -, -¤c -, -n -) \ - -216 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -¤c -è&& __bužtš_cÚ¡ªt_°( -n -) \ - -217 && - `__¡ršg2_1b±r_p - ( -¤c -è&& -n - <= 8 \ - -218 ? - `__mempýy_sm®l - ( -de¡ -, - `__mempýy_¬gs - ( -¤c -), -n -) \ - -219 : - `__mempýy - ( -de¡ -, -¤c -, -n -))) - - ) - -223  - #mempýy -( -de¡ -, -¤c -, -n -è - `__mempýy - (de¡, src,‚) - - ) - -226 #ià! -__GNUC_PREREQ - (3, 0è|| -defšed - -_FORCE_INLINES - - -227 #ià -_STRING_ARCH_uÇligÃd - - -228 #iâdeà -_FORCE_INLINES - - -229  - #__mempýy_¬gs -( -¤c -) \ - -230 (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[2], \ - -231 (( -__cÚ¡ - *è( -¤c -))[4], ((__const *) (src))[6], \ - -232 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET16 - ( -¤c -, 0), \ - -233 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET16 - ( -¤c -, 4), \ - -234 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET32 - ( -¤c -, 0), \ - -235 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET32 - ( -¤c -, 4) - - ) - -237 -__STRING_INLINE - * -__mempýy_sm®l - (*, , , , , - -238 -__ušt16_t -, __ušt16_t, -__ušt32_t -, - -239 -__ušt32_t -, -size_t -); - -240 -__STRING_INLINE - * - -241 - $__mempýy_sm®l - (* -__de¡1 -, - -242  -__¤c0_1 -,  -__¤c2_1 -,  -__¤c4_1 -,  -__¤c6_1 -, - -243 -__ušt16_t - -__¤c0_2 -, __ušt16_ˆ -__¤c4_2 -, - -244 -__ušt32_t - -__¤c0_4 -, __ušt32_ˆ -__¤c4_4 -, - -245 -size_t - -__¤þ’ -) - -248 -__ušt32_t - -__ui -; - -249 -__ušt16_t - -__usi -; - -250  -__uc -; - -251  -__c -; - -252 } * -__u - = -__de¡1 -; - -253 (è -__¤þ’ -) - -256 -__u --> -__c - = -__¤c0_1 -; - -257 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 1); - -260 -__u --> -__usi - = -__¤c0_2 -; - -261 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 2); - -264 -__u --> -__usi - = -__¤c0_2 -; - -265 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 2); - -266 -__u --> -__c - = -__¤c2_1 -; - -267 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 1); - -270 -__u --> -__ui - = -__¤c0_4 -; - -271 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -274 -__u --> -__ui - = -__¤c0_4 -; - -275 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -276 -__u --> -__c - = -__¤c4_1 -; - -277 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 1); - -280 -__u --> -__ui - = -__¤c0_4 -; - -281 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -282 -__u --> -__usi - = -__¤c4_2 -; - -283 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 2); - -286 -__u --> -__ui - = -__¤c0_4 -; - -287 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -288 -__u --> -__usi - = -__¤c4_2 -; - -289 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 2); - -290 -__u --> -__c - = -__¤c6_1 -; - -291 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 1); - -294 -__u --> -__ui - = -__¤c0_4 -; - -295 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -296 -__u --> -__ui - = -__¤c4_4 -; - -297 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -300  (*è -__u -; - -301 - } -} - -303 #iâdeà -_FORCE_INLINES - - -304  - #__mempýy_¬gs -( -¤c -) \ - -305 (( -__cÚ¡ - *è( -¤c -))[0], \ - -306 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR2 -) \ - -307 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1] } }), \ - -308 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR3 -) \ - -309 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -310 (( -__cÚ¡ - *è( -¤c -))[2] } }), \ - -311 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR4 -) \ - -312 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -313 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3] } }), \ - -314 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR5 -) \ - -315 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -316 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -317 (( -__cÚ¡ - *è( -¤c -))[4] } }), \ - -318 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR6 -) \ - -319 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -320 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -321 (( -__cÚ¡ - *è( -¤c -))[4], ((__const *) (src))[5] } }), \ - -322 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR7 -) \ - -323 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -324 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -325 (( -__cÚ¡ - *è( -¤c -))[4], ((__const *) (src))[5], \ - -326 (( -__cÚ¡ - *è( -¤c -))[6] } }), \ - -327 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR8 -) \ - -328 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -329 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -330 (( -__cÚ¡ - *è( -¤c -))[4], ((__const *) (src))[5], \ - -331 (( -__cÚ¡ - *è( -¤c -))[6], ((__cÚ¡ *è(¤c))[7] } }) - - ) - -333 -__STRING_INLINE - * -__mempýy_sm®l - (*, , -__STRING2_COPY_ARR2 -, - -334 -__STRING2_COPY_ARR3 -, - -335 -__STRING2_COPY_ARR4 -, - -336 -__STRING2_COPY_ARR5 -, - -337 -__STRING2_COPY_ARR6 -, - -338 -__STRING2_COPY_ARR7 -, - -339 -__STRING2_COPY_ARR8 -, -size_t -); - -340 -__STRING_INLINE - * - -341 - $__mempýy_sm®l - (* -__de¡ -,  -__¤c1 -, - -342 -__STRING2_COPY_ARR2 - -__¤c2 -, -__STRING2_COPY_ARR3 - -__¤c3 -, - -343 -__STRING2_COPY_ARR4 - -__¤c4 -, -__STRING2_COPY_ARR5 - -__¤c5 -, - -344 -__STRING2_COPY_ARR6 - -__¤c6 -, -__STRING2_COPY_ARR7 - -__¤c7 -, - -345 -__STRING2_COPY_ARR8 - -__¤c8 -, -size_t - -__¤þ’ -) - -348  -__c -; - -349 -__STRING2_COPY_ARR2 - -__sÿ2 -; - -350 -__STRING2_COPY_ARR3 - -__sÿ3 -; - -351 -__STRING2_COPY_ARR4 - -__sÿ4 -; - -352 -__STRING2_COPY_ARR5 - -__sÿ5 -; - -353 -__STRING2_COPY_ARR6 - -__sÿ6 -; - -354 -__STRING2_COPY_ARR7 - -__sÿ7 -; - -355 -__STRING2_COPY_ARR8 - -__sÿ8 -; - -356 } * -__u - = -__de¡ -; - -357 (è -__¤þ’ -) - -360 -__u --> -__c - = -__¤c1 -; - -363 -__ex‹nsiÚ__ - -__u --> -__sÿ2 - = -__¤c2 -; - -366 -__ex‹nsiÚ__ - -__u --> -__sÿ3 - = -__¤c3 -; - -369 -__ex‹nsiÚ__ - -__u --> -__sÿ4 - = -__¤c4 -; - -372 -__ex‹nsiÚ__ - -__u --> -__sÿ5 - = -__¤c5 -; - -375 -__ex‹nsiÚ__ - -__u --> -__sÿ6 - = -__¤c6 -; - -378 -__ex‹nsiÚ__ - -__u --> -__sÿ7 - = -__¤c7 -; - -381 -__ex‹nsiÚ__ - -__u --> -__sÿ8 - = -__¤c8 -; - -384  - `__ex‹nsiÚ__ - ((*è -__u - + -__¤þ’ -); - -385 - } -} - -393 #iâdeà -_HAVE_STRING_ARCH_¡rchr - - -394 * -__¿wmemchr - (cÚ¡ * -__s -,  -__c -); - -395 #ià -__GNUC_PREREQ - (3, 2) - -396  - #¡rchr -( -s -, -c -) \ - -397 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -c -è&& !__bužtš_cÚ¡ªt_°( -s -) \ - -398 && ( -c -) == '\0' \ - -399 ? (*è - `__¿wmemchr - ( -s -, -c -) \ - -400 : - `__bužtš_¡rchr - ( -s -, -c -))) - - ) - -402  - #¡rchr -( -s -, -c -) \ - -403 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -c -) && (c) == '\0' \ - -404 ? (*è - `__¿wmemchr - ( -s -, -c -) \ - -405 : - `¡rchr - ( -s -, -c -))) - - ) - -411 #ià(! -defšed - -_HAVE_STRING_ARCH_¡rýy - && ! -__GNUC_PREREQ - (3, 0)) \ - -412 || -defšed - - g_FORCE_INLINES - - -413 #ià! -defšed - -_HAVE_STRING_ARCH_¡rýy - && ! -__GNUC_PREREQ - (3, 0) - -414  - #¡rýy -( -de¡ -, -¤c -) \ - -415 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -¤c -) \ - -416 ? ( - `__¡ršg2_1b±r_p - ( -¤c -è&& - `¡¾’ - (src) + 1 <= 8 \ - -417 ? - `__¡rýy_sm®l - ( -de¡ -, - `__¡rýy_¬gs - ( -¤c -), \ - -418 - `¡¾’ - ( -¤c -) + 1) \ - -419 : (*è - `memýy - ( -de¡ -, -¤c -, - `¡¾’ - (src) + 1)) \ - -420 : - `¡rýy - ( -de¡ -, -¤c -))) - - ) - -423 #ià -_STRING_ARCH_uÇligÃd - - -424 #iâdeà -_FORCE_INLINES - - -425  - #__¡rýy_¬gs -( -¤c -) \ - -426 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET16 - ( -¤c -, 0), \ - -427 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET16 - ( -¤c -, 4), \ - -428 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET32 - ( -¤c -, 0), \ - -429 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET32 - ( -¤c -, 4) - - ) - -431 -__STRING_INLINE - * -__¡rýy_sm®l - (*, -__ušt16_t -, __uint16_t, - -432 -__ušt32_t -, __ušt32_t, -size_t -); - -433 -__STRING_INLINE - * - -434 - $__¡rýy_sm®l - (* -__de¡ -, - -435 -__ušt16_t - -__¤c0_2 -, __ušt16_ˆ -__¤c4_2 -, - -436 -__ušt32_t - -__¤c0_4 -, __ušt32_ˆ -__¤c4_4 -, - -437 -size_t - -__¤þ’ -) - -440 -__ušt32_t - -__ui -; - -441 -__ušt16_t - -__usi -; - -442  -__uc -; - -443 } * -__u - = (*è -__de¡ -; - -444 (è -__¤þ’ -) - -447 -__u --> -__uc - = '\0'; - -450 -__u --> -__usi - = -__¤c0_2 -; - -453 -__u --> -__usi - = -__¤c0_2 -; - -454 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 2); - -455 -__u --> -__uc - = '\0'; - -458 -__u --> -__ui - = -__¤c0_4 -; - -461 -__u --> -__ui - = -__¤c0_4 -; - -462 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -463 -__u --> -__uc - = '\0'; - -466 -__u --> -__ui - = -__¤c0_4 -; - -467 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -468 -__u --> -__usi - = -__¤c4_2 -; - -471 -__u --> -__ui - = -__¤c0_4 -; - -472 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -473 -__u --> -__usi - = -__¤c4_2 -; - -474 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 2); - -475 -__u --> -__uc - = '\0'; - -478 -__u --> -__ui - = -__¤c0_4 -; - -479 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -480 -__u --> -__ui - = -__¤c4_4 -; - -483  -__de¡ -; - -484 - } -} - -486 #iâdeà -_FORCE_INLINES - - -487  - #__¡rýy_¬gs -( -¤c -) \ - -488 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR2 -) \ - -489 { { (( -__cÚ¡ - *è( -¤c -))[0], '\0' } }), \ - -490 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR3 -) \ - -491 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -493 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR4 -) \ - -494 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -495 (( -__cÚ¡ - *è( -¤c -))[2], '\0' } }), \ - -496 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR5 -) \ - -497 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -498 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -500 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR6 -) \ - -501 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -502 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -503 (( -__cÚ¡ - *è( -¤c -))[4], '\0' } }), \ - -504 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR7 -) \ - -505 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -506 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -507 (( -__cÚ¡ - *è( -¤c -))[4], ((__const *) (src))[5], \ - -509 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR8 -) \ - -510 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -511 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -512 (( -__cÚ¡ - *è( -¤c -))[4], ((__const *) (src))[5], \ - -513 (( -__cÚ¡ - *è( -¤c -))[6], '\0' } }) - - ) - -515 -__STRING_INLINE - * -__¡rýy_sm®l - (*, -__STRING2_COPY_ARR2 -, - -516 -__STRING2_COPY_ARR3 -, - -517 -__STRING2_COPY_ARR4 -, - -518 -__STRING2_COPY_ARR5 -, - -519 -__STRING2_COPY_ARR6 -, - -520 -__STRING2_COPY_ARR7 -, - -521 -__STRING2_COPY_ARR8 -, -size_t -); - -522 -__STRING_INLINE - * - -523 - $__¡rýy_sm®l - (* -__de¡ -, - -524 -__STRING2_COPY_ARR2 - -__¤c2 -, -__STRING2_COPY_ARR3 - -__¤c3 -, - -525 -__STRING2_COPY_ARR4 - -__¤c4 -, -__STRING2_COPY_ARR5 - -__¤c5 -, - -526 -__STRING2_COPY_ARR6 - -__¤c6 -, -__STRING2_COPY_ARR7 - -__¤c7 -, - -527 -__STRING2_COPY_ARR8 - -__¤c8 -, -size_t - -__¤þ’ -) - -530  -__c -; - -531 -__STRING2_COPY_ARR2 - -__sÿ2 -; - -532 -__STRING2_COPY_ARR3 - -__sÿ3 -; - -533 -__STRING2_COPY_ARR4 - -__sÿ4 -; - -534 -__STRING2_COPY_ARR5 - -__sÿ5 -; - -535 -__STRING2_COPY_ARR6 - -__sÿ6 -; - -536 -__STRING2_COPY_ARR7 - -__sÿ7 -; - -537 -__STRING2_COPY_ARR8 - -__sÿ8 -; - -538 } * -__u - = (*è -__de¡ -; - -539 (è -__¤þ’ -) - -542 -__u --> -__c - = '\0'; - -545 -__ex‹nsiÚ__ - -__u --> -__sÿ2 - = -__¤c2 -; - -548 -__ex‹nsiÚ__ - -__u --> -__sÿ3 - = -__¤c3 -; - -551 -__ex‹nsiÚ__ - -__u --> -__sÿ4 - = -__¤c4 -; - -554 -__ex‹nsiÚ__ - -__u --> -__sÿ5 - = -__¤c5 -; - -557 -__ex‹nsiÚ__ - -__u --> -__sÿ6 - = -__¤c6 -; - -560 -__ex‹nsiÚ__ - -__u --> -__sÿ7 - = -__¤c7 -; - -563 -__ex‹nsiÚ__ - -__u --> -__sÿ8 - = -__¤c8 -; - -566  -__de¡ -; - -567 - } -} - -573 #ifdeà -__USE_GNU - - -574 #ià! -defšed - -_HAVE_STRING_ARCH_¡pýy - || defšed -_FORCE_INLINES - - -575 #iâdeà -_HAVE_STRING_ARCH_¡pýy - - -576 #ià -__GNUC_PREREQ - (3, 4) - -577  - #__¡pýy -( -de¡ -, -¤c -è - `__bužtš_¡pýy - (de¡, src) - - ) - -578 #–ià -__GNUC_PREREQ - (3, 0) - -579  - #__¡pýy -( -de¡ -, -¤c -) \ - -580 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -¤c -) \ - -581 ? ( - `__¡ršg2_1b±r_p - ( -¤c -è&& - `¡¾’ - (src) + 1 <= 8 \ - -582 ? - `__bužtš_¡rýy - ( -de¡ -, -¤c -è+ - `¡¾’ - (src) \ - -583 : ((*è( -__mempýy -è( -de¡ -, -¤c -, - `¡¾’ - (src) + 1) \ - -585 : - `__¡pýy - ( -de¡ -, -¤c -))) - - ) - -587  - #__¡pýy -( -de¡ -, -¤c -) \ - -588 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -¤c -) \ - -589 ? ( - `__¡ršg2_1b±r_p - ( -¤c -è&& - `¡¾’ - (src) + 1 <= 8 \ - -590 ? - `__¡pýy_sm®l - ( -de¡ -, - `__¡pýy_¬gs - ( -¤c -), \ - -591 - `¡¾’ - ( -¤c -) + 1) \ - -592 : ((*è( -__mempýy -è( -de¡ -, -¤c -, - `¡¾’ - (src) + 1) \ - -594 : - `__¡pýy - ( -de¡ -, -¤c -))) - - ) - -598  - #¡pýy -( -de¡ -, -¤c -è - `__¡pýy - (de¡, src) - - ) - -601 #ià! -__GNUC_PREREQ - (3, 0è|| -defšed - -_FORCE_INLINES - - -602 #ià -_STRING_ARCH_uÇligÃd - - -603 #iâdeà -_FORCE_INLINES - - -604  - #__¡pýy_¬gs -( -¤c -) \ - -605 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET16 - ( -¤c -, 0), \ - -606 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET16 - ( -¤c -, 4), \ - -607 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET32 - ( -¤c -, 0), \ - -608 -__ex‹nsiÚ__ - - `__STRING2_SMALL_GET32 - ( -¤c -, 4) - - ) - -610 -__STRING_INLINE - * -__¡pýy_sm®l - (*, -__ušt16_t -, __uint16_t, - -611 -__ušt32_t -, __ušt32_t, -size_t -); - -612 -__STRING_INLINE - * - -613 - $__¡pýy_sm®l - (* -__de¡ -, - -614 -__ušt16_t - -__¤c0_2 -, __ušt16_ˆ -__¤c4_2 -, - -615 -__ušt32_t - -__¤c0_4 -, __ušt32_ˆ -__¤c4_4 -, - -616 -size_t - -__¤þ’ -) - -619  -__ui -; - -620  -__usi -; - -621  -__uc -; - -622  -__c -; - -623 } * -__u - = (*è -__de¡ -; - -624 (è -__¤þ’ -) - -627 -__u --> -__uc - = '\0'; - -630 -__u --> -__usi - = -__¤c0_2 -; - -631 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 1); - -634 -__u --> -__usi - = -__¤c0_2 -; - -635 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 2); - -636 -__u --> -__uc - = '\0'; - -639 -__u --> -__ui - = -__¤c0_4 -; - -640 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 3); - -643 -__u --> -__ui - = -__¤c0_4 -; - -644 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -645 -__u --> -__uc - = '\0'; - -648 -__u --> -__ui - = -__¤c0_4 -; - -649 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -650 -__u --> -__usi - = -__¤c4_2 -; - -651 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 1); - -654 -__u --> -__ui - = -__¤c0_4 -; - -655 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -656 -__u --> -__usi - = -__¤c4_2 -; - -657 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 2); - -658 -__u --> -__uc - = '\0'; - -661 -__u --> -__ui - = -__¤c0_4 -; - -662 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 4); - -663 -__u --> -__ui - = -__¤c4_4 -; - -664 -__u - = - `__ex‹nsiÚ__ - ((*) __u + 3); - -667  & -__u --> -__c -; - -668 - } -} - -670 #iâdeà -_FORCE_INLINES - - -671  - #__¡pýy_¬gs -( -¤c -) \ - -672 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR2 -) \ - -673 { { (( -__cÚ¡ - *è( -¤c -))[0], '\0' } }), \ - -674 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR3 -) \ - -675 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -677 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR4 -) \ - -678 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -679 (( -__cÚ¡ - *è( -¤c -))[2], '\0' } }), \ - -680 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR5 -) \ - -681 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -682 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -684 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR6 -) \ - -685 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -686 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -687 (( -__cÚ¡ - *è( -¤c -))[4], '\0' } }), \ - -688 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR7 -) \ - -689 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -690 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -691 (( -__cÚ¡ - *è( -¤c -))[4], ((__const *) (src))[5], \ - -693 - `__ex‹nsiÚ__ - (( -__STRING2_COPY_ARR8 -) \ - -694 { { (( -__cÚ¡ - *è( -¤c -))[0], ((__const *) (src))[1], \ - -695 (( -__cÚ¡ - *è( -¤c -))[2], ((__const *) (src))[3], \ - -696 (( -__cÚ¡ - *è( -¤c -))[4], ((__const *) (src))[5], \ - -697 (( -__cÚ¡ - *è( -¤c -))[6], '\0' } }) - - ) - -699 -__STRING_INLINE - * -__¡pýy_sm®l - (*, -__STRING2_COPY_ARR2 -, - -700 -__STRING2_COPY_ARR3 -, - -701 -__STRING2_COPY_ARR4 -, - -702 -__STRING2_COPY_ARR5 -, - -703 -__STRING2_COPY_ARR6 -, - -704 -__STRING2_COPY_ARR7 -, - -705 -__STRING2_COPY_ARR8 -, -size_t -); - -706 -__STRING_INLINE - * - -707 - $__¡pýy_sm®l - (* -__de¡ -, - -708 -__STRING2_COPY_ARR2 - -__¤c2 -, -__STRING2_COPY_ARR3 - -__¤c3 -, - -709 -__STRING2_COPY_ARR4 - -__¤c4 -, -__STRING2_COPY_ARR5 - -__¤c5 -, - -710 -__STRING2_COPY_ARR6 - -__¤c6 -, -__STRING2_COPY_ARR7 - -__¤c7 -, - -711 -__STRING2_COPY_ARR8 - -__¤c8 -, -size_t - -__¤þ’ -) - -714  -__c -; - -715 -__STRING2_COPY_ARR2 - -__sÿ2 -; - -716 -__STRING2_COPY_ARR3 - -__sÿ3 -; - -717 -__STRING2_COPY_ARR4 - -__sÿ4 -; - -718 -__STRING2_COPY_ARR5 - -__sÿ5 -; - -719 -__STRING2_COPY_ARR6 - -__sÿ6 -; - -720 -__STRING2_COPY_ARR7 - -__sÿ7 -; - -721 -__STRING2_COPY_ARR8 - -__sÿ8 -; - -722 } * -__u - = (*è -__de¡ -; - -723 (è -__¤þ’ -) - -726 -__u --> -__c - = '\0'; - -729 -__ex‹nsiÚ__ - -__u --> -__sÿ2 - = -__¤c2 -; - -732 -__ex‹nsiÚ__ - -__u --> -__sÿ3 - = -__¤c3 -; - -735 -__ex‹nsiÚ__ - -__u --> -__sÿ4 - = -__¤c4 -; - -738 -__ex‹nsiÚ__ - -__u --> -__sÿ5 - = -__¤c5 -; - -741 -__ex‹nsiÚ__ - -__u --> -__sÿ6 - = -__¤c6 -; - -744 -__ex‹nsiÚ__ - -__u --> -__sÿ7 - = -__¤c7 -; - -747 -__ex‹nsiÚ__ - -__u --> -__sÿ8 - = -__¤c8 -; - -750  -__de¡ - + -__¤þ’ - - 1; - -751 - } -} - -759 #iâdeà -_HAVE_STRING_ARCH_¡ºýy - - -760 #ià -__GNUC_PREREQ - (3, 2) - -761  - #¡ºýy -( -de¡ -, -¤c -, -n -è - `__bužtš_¡ºýy - (de¡, src,‚) - - ) - -763  - #¡ºýy -( -de¡ -, -¤c -, -n -) \ - -764 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -¤c -è&& __bužtš_cÚ¡ªt_°( -n -) \ - -765 ? ( - `¡¾’ - ( -¤c -è+ 1 >ð(( -size_t -è( -n -)) \ - -766 ? (*è - `memýy - ( -de¡ -, -¤c -, -n -) \ - -767 : - `¡ºýy - ( -de¡ -, -¤c -, -n -)) \ - -768 : - `¡ºýy - ( -de¡ -, -¤c -, -n -))) - - ) - -774 #iâdeà -_HAVE_STRING_ARCH_¡ºÿt - - -775 #ifdeà -_USE_STRING_ARCH_¡rchr - - -776  - #¡ºÿt -( -de¡ -, -¤c -, -n -) \ - -777 ( - `__ex‹nsiÚ__ - ({ * -__de¡ - = ( -de¡ -); \ - -778 - `__bužtš_cÚ¡ªt_p - ( -¤c -è&& __bužtš_cÚ¡ªt_°( -n -) \ - -779 ? ( - `¡¾’ - ( -¤c -è< (( -size_t -è( -n -)) \ - -780 ? - `¡rÿt - ( -__de¡ -, -¤c -) \ - -781 : (*((*è - `__mempýy - ( - `¡rchr - ( -__de¡ -, '\0'), \ - -782 -¤c -, -n -)èð'\0', -__de¡ -)) \ - -783 : - `¡ºÿt - ( -de¡ -, -¤c -, -n -); })) - - ) - -784 #–ià -__GNUC_PREREQ - (3, 2) - -785  - #¡ºÿt -( -de¡ -, -¤c -, -n -è - `__bužtš_¡ºÿt - (de¡, src,‚) - - ) - -787  - #¡ºÿt -( -de¡ -, -¤c -, -n -) \ - -788 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -¤c -è&& __bužtš_cÚ¡ªt_°( -n -) \ - -789 ? ( - `¡¾’ - ( -¤c -è< (( -size_t -è( -n -)) \ - -790 ? - `¡rÿt - ( -de¡ -, -¤c -) \ - -791 : - `¡ºÿt - ( -de¡ -, -¤c -, -n -)) \ - -792 : - `¡ºÿt - ( -de¡ -, -¤c -, -n -))) - - ) - -798 #iâdeà -_HAVE_STRING_ARCH_¡rcmp - - -799 #ià -__GNUC_PREREQ - (3, 2) - -800  - #¡rcmp -( -s1 -, -s2 -) \ - -801 -__ex‹nsiÚ__ - \ - -802 ({ -size_t - -__s1_Ën -, -__s2_Ën -; \ - -803 ( - `__bužtš_cÚ¡ªt_p - ( -s1 -è&& __bužtš_cÚ¡ªt_°( -s2 -) \ - -804 && ( -__s1_Ën - = - `__bužtš_¡¾’ - ( -s1 -), -__s2_Ën - = __bužtš_¡¾’ ( -s2 -), \ - -805 (! - `__¡ršg2_1b±r_p - ( -s1 -è|| -__s1_Ën - >= 4) \ - -806 && (! - `__¡ršg2_1b±r_p - ( -s2 -è|| -__s2_Ën - >= 4)) \ - -807 ? - `__bužtš_¡rcmp - ( -s1 -, -s2 -) \ - -808 : ( - `__bužtš_cÚ¡ªt_p - ( -s1 -è&& - `__¡ršg2_1b±r_p - (s1) \ - -809 && ( -__s1_Ën - = - `__bužtš_¡¾’ - ( -s1 -), __s1_len < 4) \ - -810 ? ( - `__bužtš_cÚ¡ªt_p - ( -s2 -è&& - `__¡ršg2_1b±r_p - (s2) \ - -811 ? - `__bužtš_¡rcmp - ( -s1 -, -s2 -) \ - -812 : - `__¡rcmp_cg - ( -s1 -, -s2 -, -__s1_Ën -)) \ - -813 : ( - `__bužtš_cÚ¡ªt_p - ( -s2 -è&& - `__¡ršg2_1b±r_p - (s2) \ - -814 && ( -__s2_Ën - = - `__bužtš_¡¾’ - ( -s2 -), __s2_len < 4) \ - -815 ? ( - `__bužtš_cÚ¡ªt_p - ( -s1 -è&& - `__¡ršg2_1b±r_p - (s1) \ - -816 ? - `__bužtš_¡rcmp - ( -s1 -, -s2 -) \ - -817 : - `__¡rcmp_gc - ( -s1 -, -s2 -, -__s2_Ën -)) \ - -818 : - `__bužtš_¡rcmp - ( -s1 -, -s2 -)))); }) - - ) - -820  - #¡rcmp -( -s1 -, -s2 -) \ - -821 -__ex‹nsiÚ__ - \ - -822 ({ -size_t - -__s1_Ën -, -__s2_Ën -; \ - -823 ( - `__bužtš_cÚ¡ªt_p - ( -s1 -è&& __bužtš_cÚ¡ªt_°( -s2 -) \ - -824 && ( -__s1_Ën - = - `¡¾’ - ( -s1 -), -__s2_Ën - = sŒËÀ( -s2 -), \ - -825 (! - `__¡ršg2_1b±r_p - ( -s1 -è|| -__s1_Ën - >= 4) \ - -826 && (! - `__¡ršg2_1b±r_p - ( -s2 -è|| -__s2_Ën - >= 4)) \ - -827 ? - `memcmp - (( -__cÚ¡ - *è( -s1 -), (__cÚ¡ *è( -s2 -), \ - -828 ( -__s1_Ën - < -__s2_Ën - ? __s1_len : __s2_len) + 1) \ - -829 : ( - `__bužtš_cÚ¡ªt_p - ( -s1 -è&& - `__¡ršg2_1b±r_p - (s1) \ - -830 && ( -__s1_Ën - = - `¡¾’ - ( -s1 -), __s1_len < 4) \ - -831 ? ( - `__bužtš_cÚ¡ªt_p - ( -s2 -è&& - `__¡ršg2_1b±r_p - (s2) \ - -832 ? - `__¡rcmp_cc - ( -s1 -, -s2 -, -__s1_Ën -) \ - -833 : - `__¡rcmp_cg - ( -s1 -, -s2 -, -__s1_Ën -)) \ - -834 : ( - `__bužtš_cÚ¡ªt_p - ( -s2 -è&& - `__¡ršg2_1b±r_p - (s2) \ - -835 && ( -__s2_Ën - = - `¡¾’ - ( -s2 -), __s2_len < 4) \ - -836 ? ( - `__bužtš_cÚ¡ªt_p - ( -s1 -è&& - `__¡ršg2_1b±r_p - (s1) \ - -837 ? - `__¡rcmp_cc - ( -s1 -, -s2 -, -__s2_Ën -) \ - -838 : - `__¡rcmp_gc - ( -s1 -, -s2 -, -__s2_Ën -)) \ - -839 : - `¡rcmp - ( -s1 -, -s2 -)))); }) - - ) - -842  - #__¡rcmp_cc -( -s1 -, -s2 -, -l -) \ - -843 ( - `__ex‹nsiÚ__ - ({  -__»suÉ - = \ - -844 ((( -__cÚ¡ - *è(__cÚ¡ *è( -s1 -))[0] \ - -845 - (( -__cÚ¡ - *è(__cÚ¡ *)( -s2 -))[0]);\ - -846 ià( -l - > 0 && -__»suÉ - == 0) \ - -848 -__»suÉ - = ((( -__cÚ¡ - *) \ - -849 ( -__cÚ¡ - *è( -s1 -))[1] \ - -850 - (( -__cÚ¡ - *) \ - -851 ( -__cÚ¡ - *è( -s2 -))[1]); \ - -852 ià( -l - > 1 && -__»suÉ - == 0) \ - -854 -__»suÉ - = \ - -855 ((( -__cÚ¡ - *) \ - -856 ( -__cÚ¡ - *è( -s1 -))[2] \ - -857 - (( -__cÚ¡ - *) \ - -858 ( -__cÚ¡ - *è( -s2 -))[2]); \ - -859 ià( -l - > 2 && -__»suÉ - == 0) \ - -860 -__»suÉ - = \ - -861 ((( -__cÚ¡ - *) \ - -862 ( -__cÚ¡ - *è( -s1 -))[3] \ - -863 - (( -__cÚ¡ - *) \ - -864 ( -__cÚ¡ - *è( -s2 -))[3]); \ - -867 -__»suÉ -; })) - - ) - -869  - #__¡rcmp_cg -( -s1 -, -s2 -, -l1 -) \ - -870 ( - `__ex‹nsiÚ__ - ({ -__cÚ¡ - * -__s2 - = \ - -871 ( -__cÚ¡ - *è(__cÚ¡ *è( -s2 -); \ - -872  -__»suÉ - = \ - -873 ((( -__cÚ¡ - *è(__cÚ¡ *è( -s1 -))[0] \ - -874 - -__s2 -[0]); \ - -875 ià( -l1 - > 0 && -__»suÉ - == 0) \ - -877 -__»suÉ - = ((( -__cÚ¡ - *) \ - -878 ( -__cÚ¡ - *è( -s1 -))[1] - -__s2 -[1]); \ - -879 ià( -l1 - > 1 && -__»suÉ - == 0) \ - -881 -__»suÉ - = ((( -__cÚ¡ - *) \ - -882 ( -__cÚ¡ - *è( -s1 -))[2] - -__s2 -[2]);\ - -883 ià( -l1 - > 2 && -__»suÉ - == 0) \ - -884 -__»suÉ - = ((( -__cÚ¡ - *) \ - -885 ( -__cÚ¡ - *è( -s1 -))[3] \ - -886 - -__s2 -[3]); \ - -889 -__»suÉ -; })) - - ) - -891  - #__¡rcmp_gc -( -s1 -, -s2 -, -l2 -) \ - -892 ( - `__ex‹nsiÚ__ - ({ -__cÚ¡ - * -__s1 - = \ - -893 ( -__cÚ¡ - *è(__cÚ¡ *è( -s1 -); \ - -894  -__»suÉ - = \ - -895 -__s1 -[0] - (( -__cÚ¡ - *) \ - -896 ( -__cÚ¡ - *è( -s2 -))[0]; \ - -897 ià( -l2 - > 0 && -__»suÉ - == 0) \ - -899 -__»suÉ - = ( -__s1 -[1] \ - -900 - (( -__cÚ¡ - *) \ - -901 ( -__cÚ¡ - *è( -s2 -))[1]); \ - -902 ià( -l2 - > 1 && -__»suÉ - == 0) \ - -904 -__»suÉ - = \ - -905 ( -__s1 -[2] - (( -__cÚ¡ - *) \ - -906 ( -__cÚ¡ - *è( -s2 -))[2]); \ - -907 ià( -l2 - > 2 && -__»suÉ - == 0) \ - -908 -__»suÉ - = \ - -909 ( -__s1 -[3] \ - -910 - (( -__cÚ¡ - *) \ - -911 ( -__cÚ¡ - *è( -s2 -))[3]); \ - -914 -__»suÉ -; })) - - ) - -919 #iâdeà -_HAVE_STRING_ARCH_¡ºcmp - - -920  - #¡ºcmp -( -s1 -, -s2 -, -n -) \ - -921 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -n -) \ - -922 && (( - `__bužtš_cÚ¡ªt_p - ( -s1 -) \ - -923 && - `¡¾’ - ( -s1 -è< (( -size_t -è( -n -))) \ - -924 || ( - `__bužtš_cÚ¡ªt_p - ( -s2 -) \ - -925 && - `¡¾’ - ( -s2 -è< (( -size_t -è( -n -)))) \ - -926 ? - `¡rcmp - ( -s1 -, -s2 -è: - `¡ºcmp - (s1, s2, -n -))) - - ) - -932 #ià! -defšed - -_HAVE_STRING_ARCH_¡rc¥n - || defšed -_FORCE_INLINES - - -933 #iâdeà -_HAVE_STRING_ARCH_¡rc¥n - - -934 #ià -__GNUC_PREREQ - (3, 2) - -935  - #¡rc¥n -( -s -, -»jeù -) \ - -936 -__ex‹nsiÚ__ - \ - -937 ({  -__r0 -, -__r1 -, -__r2 -; \ - -938 ( - `__bužtš_cÚ¡ªt_p - ( -»jeù -è&& - `__¡ršg2_1b±r_p - (reject) \ - -939 ? (( - `__bužtš_cÚ¡ªt_p - ( -s -è&& - `__¡ršg2_1b±r_p - (s)) \ - -940 ? - `__bužtš_¡rc¥n - ( -s -, -»jeù -) \ - -941 : (( -__r0 - = (( -__cÚ¡ - *è( -»jeù -))[0], __r0 == '\0') \ - -942 ? - `¡¾’ - ( -s -) \ - -943 : (( -__r1 - = (( -__cÚ¡ - *è( -»jeù -))[1], __r1 == '\0') \ - -944 ? - `__¡rc¥n_c1 - ( -s -, -__r0 -) \ - -945 : (( -__r2 - = (( -__cÚ¡ - *è( -»jeù -))[2], __r2 == '\0') \ - -946 ? - `__¡rc¥n_c2 - ( -s -, -__r0 -, -__r1 -) \ - -947 : ((( -__cÚ¡ - *è( -»jeù -))[3] == '\0' \ - -948 ? - `__¡rc¥n_c3 - ( -s -, -__r0 -, -__r1 -, -__r2 -) \ - -949 : - `__bužtš_¡rc¥n - ( -s -, -»jeù -)))))) \ - -950 : - `__bužtš_¡rc¥n - ( -s -, -»jeù -)); }) - - ) - -952  - #¡rc¥n -( -s -, -»jeù -) \ - -953 -__ex‹nsiÚ__ - \ - -954 ({  -__r0 -, -__r1 -, -__r2 -; \ - -955 ( - `__bužtš_cÚ¡ªt_p - ( -»jeù -è&& - `__¡ršg2_1b±r_p - (reject) \ - -956 ? (( -__r0 - = (( -__cÚ¡ - *è( -»jeù -))[0], __r0 == '\0') \ - -957 ? - `¡¾’ - ( -s -) \ - -958 : (( -__r1 - = (( -__cÚ¡ - *è( -»jeù -))[1], __r1 == '\0') \ - -959 ? - `__¡rc¥n_c1 - ( -s -, -__r0 -) \ - -960 : (( -__r2 - = (( -__cÚ¡ - *è( -»jeù -))[2], __r2 == '\0') \ - -961 ? - `__¡rc¥n_c2 - ( -s -, -__r0 -, -__r1 -) \ - -962 : ((( -__cÚ¡ - *è( -»jeù -))[3] == '\0' \ - -963 ? - `__¡rc¥n_c3 - ( -s -, -__r0 -, -__r1 -, -__r2 -) \ - -964 : - `¡rc¥n - ( -s -, -»jeù -))))) \ - -965 : - `¡rc¥n - ( -s -, -»jeù -)); }) - - ) - -969 -__STRING_INLINE - -size_t - -__¡rc¥n_c1 - ( -__cÚ¡ - * -__s -,  -__»jeù -); - -970 -__STRING_INLINE - -size_t - - -971 - $__¡rc¥n_c1 - ( -__cÚ¡ - * -__s -,  -__»jeù -) - -973  -size_t - -__»suÉ - = 0; - -974  -__s -[ -__»suÉ -] !ð'\0' && __s[__»suÉ] !ð -__»jeù -) - -975 ++ -__»suÉ -; - -976  -__»suÉ -; - -977 - } -} - -979 -__STRING_INLINE - -size_t - -__¡rc¥n_c2 - ( -__cÚ¡ - * -__s -,  -__»jeù1 -, - -980  -__»jeù2 -); - -981 -__STRING_INLINE - -size_t - - -982 - $__¡rc¥n_c2 - ( -__cÚ¡ - * -__s -,  -__»jeù1 -,  -__»jeù2 -) - -984  -size_t - -__»suÉ - = 0; - -985  -__s -[ -__»suÉ -] !ð'\0' && __s[__»suÉ] !ð -__»jeù1 - - -986 && -__s -[ -__»suÉ -] !ð -__»jeù2 -) - -987 ++ -__»suÉ -; - -988  -__»suÉ -; - -989 - } -} - -991 -__STRING_INLINE - -size_t - -__¡rc¥n_c3 - ( -__cÚ¡ - * -__s -,  -__»jeù1 -, - -992  -__»jeù2 -,  -__»jeù3 -); - -993 -__STRING_INLINE - -size_t - - -994 - $__¡rc¥n_c3 - ( -__cÚ¡ - * -__s -,  -__»jeù1 -,  -__»jeù2 -, - -995  -__»jeù3 -) - -997  -size_t - -__»suÉ - = 0; - -998  -__s -[ -__»suÉ -] !ð'\0' && __s[__»suÉ] !ð -__»jeù1 - - -999 && -__s -[ -__»suÉ -] !ð -__»jeù2 - && __s[__»suÉ] !ð -__»jeù3 -) - -1000 ++ -__»suÉ -; - -1001  -__»suÉ -; - -1002 - } -} - -1008 #ià! -defšed - -_HAVE_STRING_ARCH_¡r¥n - || defšed -_FORCE_INLINES - - -1009 #iâdeà -_HAVE_STRING_ARCH_¡r¥n - - -1010 #ià -__GNUC_PREREQ - (3, 2) - -1011  - #¡r¥n -( -s -, -acû± -) \ - -1012 -__ex‹nsiÚ__ - \ - -1013 ({  -__a0 -, -__a1 -, -__a2 -; \ - -1014 ( - `__bužtš_cÚ¡ªt_p - ( -acû± -è&& - `__¡ršg2_1b±r_p - (accept) \ - -1015 ? (( - `__bužtš_cÚ¡ªt_p - ( -s -è&& - `__¡ršg2_1b±r_p - (s)) \ - -1016 ? - `__bužtš_¡r¥n - ( -s -, -acû± -) \ - -1017 : (( -__a0 - = (( -__cÚ¡ - *è( -acû± -))[0], __a0 == '\0') \ - -1018 ? ((è( -s -), 0) \ - -1019 : (( -__a1 - = (( -__cÚ¡ - *è( -acû± -))[1], __a1 == '\0') \ - -1020 ? - `__¡r¥n_c1 - ( -s -, -__a0 -) \ - -1021 : (( -__a2 - = (( -__cÚ¡ - *è( -acû± -))[2], __a2 == '\0') \ - -1022 ? - `__¡r¥n_c2 - ( -s -, -__a0 -, -__a1 -) \ - -1023 : ((( -__cÚ¡ - *è( -acû± -))[3] == '\0' \ - -1024 ? - `__¡r¥n_c3 - ( -s -, -__a0 -, -__a1 -, -__a2 -) \ - -1025 : - `__bužtš_¡r¥n - ( -s -, -acû± -)))))) \ - -1026 : - `__bužtš_¡r¥n - ( -s -, -acû± -)); }) - - ) - -1028  - #¡r¥n -( -s -, -acû± -) \ - -1029 -__ex‹nsiÚ__ - \ - -1030 ({  -__a0 -, -__a1 -, -__a2 -; \ - -1031 ( - `__bužtš_cÚ¡ªt_p - ( -acû± -è&& - `__¡ršg2_1b±r_p - (accept) \ - -1032 ? (( -__a0 - = (( -__cÚ¡ - *è( -acû± -))[0], __a0 == '\0') \ - -1033 ? ((è( -s -), 0) \ - -1034 : (( -__a1 - = (( -__cÚ¡ - *è( -acû± -))[1], __a1 == '\0') \ - -1035 ? - `__¡r¥n_c1 - ( -s -, -__a0 -) \ - -1036 : (( -__a2 - = (( -__cÚ¡ - *è( -acû± -))[2], __a2 == '\0') \ - -1037 ? - `__¡r¥n_c2 - ( -s -, -__a0 -, -__a1 -) \ - -1038 : ((( -__cÚ¡ - *è( -acû± -))[3] == '\0' \ - -1039 ? - `__¡r¥n_c3 - ( -s -, -__a0 -, -__a1 -, -__a2 -) \ - -1040 : - `¡r¥n - ( -s -, -acû± -))))) \ - -1041 : - `¡r¥n - ( -s -, -acû± -)); }) - - ) - -1045 -__STRING_INLINE - -size_t - -__¡r¥n_c1 - ( -__cÚ¡ - * -__s -,  -__acû± -); - -1046 -__STRING_INLINE - -size_t - - -1047 - $__¡r¥n_c1 - ( -__cÚ¡ - * -__s -,  -__acû± -) - -1049  -size_t - -__»suÉ - = 0; - -1051  -__s -[ -__»suÉ -] =ð -__acû± -) - -1052 ++ -__»suÉ -; - -1053  -__»suÉ -; - -1054 - } -} - -1056 -__STRING_INLINE - -size_t - -__¡r¥n_c2 - ( -__cÚ¡ - * -__s -,  -__acû±1 -, - -1057  -__acû±2 -); - -1058 -__STRING_INLINE - -size_t - - -1059 - $__¡r¥n_c2 - ( -__cÚ¡ - * -__s -,  -__acû±1 -,  -__acû±2 -) - -1061  -size_t - -__»suÉ - = 0; - -1063  -__s -[ -__»suÉ -] =ð -__acû±1 - || __s[__»suÉ] =ð -__acû±2 -) - -1064 ++ -__»suÉ -; - -1065  -__»suÉ -; - -1066 - } -} - -1068 -__STRING_INLINE - -size_t - -__¡r¥n_c3 - ( -__cÚ¡ - * -__s -,  -__acû±1 -, - -1069  -__acû±2 -,  -__acû±3 -); - -1070 -__STRING_INLINE - -size_t - - -1071 - $__¡r¥n_c3 - ( -__cÚ¡ - * -__s -,  -__acû±1 -,  -__acû±2 -,  -__acû±3 -) - -1073  -size_t - -__»suÉ - = 0; - -1075  -__s -[ -__»suÉ -] =ð -__acû±1 - || __s[__»suÉ] =ð -__acû±2 - - -1076 || -__s -[ -__»suÉ -] =ð -__acû±3 -) - -1077 ++ -__»suÉ -; - -1078  -__»suÉ -; - -1079 - } -} - -1084 #ià! -defšed - -_HAVE_STRING_ARCH_¡½brk - || defšed -_FORCE_INLINES - - -1085 #iâdeà -_HAVE_STRING_ARCH_¡½brk - - -1086 #ià -__GNUC_PREREQ - (3, 2) - -1087  - #¡½brk -( -s -, -acû± -) \ - -1088 -__ex‹nsiÚ__ - \ - -1089 ({  -__a0 -, -__a1 -, -__a2 -; \ - -1090 ( - `__bužtš_cÚ¡ªt_p - ( -acû± -è&& - `__¡ršg2_1b±r_p - (accept) \ - -1091 ? (( - `__bužtš_cÚ¡ªt_p - ( -s -è&& - `__¡ršg2_1b±r_p - (s)) \ - -1092 ? - `__bužtš_¡½brk - ( -s -, -acû± -) \ - -1093 : (( -__a0 - = (( -__cÚ¡ - *è( -acû± -))[0], __a0 == '\0') \ - -1094 ? ((è( -s -), (*è -NULL -) \ - -1095 : (( -__a1 - = (( -__cÚ¡ - *è( -acû± -))[1], __a1 == '\0') \ - -1096 ? - `__bužtš_¡rchr - ( -s -, -__a0 -) \ - -1097 : (( -__a2 - = (( -__cÚ¡ - *è( -acû± -))[2], __a2 == '\0') \ - -1098 ? - `__¡½brk_c2 - ( -s -, -__a0 -, -__a1 -) \ - -1099 : ((( -__cÚ¡ - *è( -acû± -))[3] == '\0' \ - -1100 ? - `__¡½brk_c3 - ( -s -, -__a0 -, -__a1 -, -__a2 -) \ - -1101 : - `__bužtš_¡½brk - ( -s -, -acû± -)))))) \ - -1102 : - `__bužtš_¡½brk - ( -s -, -acû± -)); }) - - ) - -1104  - #¡½brk -( -s -, -acû± -) \ - -1105 -__ex‹nsiÚ__ - \ - -1106 ({  -__a0 -, -__a1 -, -__a2 -; \ - -1107 ( - `__bužtš_cÚ¡ªt_p - ( -acû± -è&& - `__¡ršg2_1b±r_p - (accept) \ - -1108 ? (( -__a0 - = (( -__cÚ¡ - *è( -acû± -))[0], __a0 == '\0') \ - -1109 ? ((è( -s -), (*è -NULL -) \ - -1110 : (( -__a1 - = (( -__cÚ¡ - *è( -acû± -))[1], __a1 == '\0') \ - -1111 ? - `¡rchr - ( -s -, -__a0 -) \ - -1112 : (( -__a2 - = (( -__cÚ¡ - *è( -acû± -))[2], __a2 == '\0') \ - -1113 ? - `__¡½brk_c2 - ( -s -, -__a0 -, -__a1 -) \ - -1114 : ((( -__cÚ¡ - *è( -acû± -))[3] == '\0' \ - -1115 ? - `__¡½brk_c3 - ( -s -, -__a0 -, -__a1 -, -__a2 -) \ - -1116 : - `¡½brk - ( -s -, -acû± -))))) \ - -1117 : - `¡½brk - ( -s -, -acû± -)); }) - - ) - -1121 -__STRING_INLINE - * -__¡½brk_c2 - ( -__cÚ¡ - * -__s -,  -__acû±1 -, - -1122  -__acû±2 -); - -1123 -__STRING_INLINE - * - -1124 - $__¡½brk_c2 - ( -__cÚ¡ - * -__s -,  -__acû±1 -,  -__acû±2 -) - -1127 * -__s - !ð'\0' && *__ !ð -__acû±1 - && *__ !ð -__acû±2 -) - -1128 ++ -__s -; - -1129  * -__s - =ð'\0' ? -NULL - : (*è( -size_t -) __s; - -1130 - } -} - -1132 -__STRING_INLINE - * -__¡½brk_c3 - ( -__cÚ¡ - * -__s -,  -__acû±1 -, - -1133  -__acû±2 -,  -__acû±3 -); - -1134 -__STRING_INLINE - * - -1135 - $__¡½brk_c3 - ( -__cÚ¡ - * -__s -,  -__acû±1 -,  -__acû±2 -, - -1136  -__acû±3 -) - -1139 * -__s - !ð'\0' && *__ !ð -__acû±1 - && *__ !ð -__acû±2 - - -1140 && * -__s - !ð -__acû±3 -) - -1141 ++ -__s -; - -1142  * -__s - =ð'\0' ? -NULL - : (*è( -size_t -) __s; - -1143 - } -} - -1149 #ià! -defšed - -_HAVE_STRING_ARCH_¡r¡r - && ! -__GNUC_PREREQ - (2, 97) - -1150  - #¡r¡r -( -hay¡ack -, -ÃedË -) \ - -1151 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -ÃedË -è&& - `__¡ršg2_1b±r_p - (needle) \ - -1152 ? ((( -__cÚ¡ - *è( -ÃedË -))[0] == '\0' \ - -1153 ? (*è( -size_t -è( -hay¡ack -) \ - -1154 : ((( -__cÚ¡ - *è( -ÃedË -))[1] == '\0' \ - -1155 ? - `¡rchr - ( -hay¡ack -, \ - -1156 (( -__cÚ¡ - *è( -ÃedË -))[0]) \ - -1157 : - `¡r¡r - ( -hay¡ack -, -ÃedË -))) \ - -1158 : - `¡r¡r - ( -hay¡ack -, -ÃedË -))) - - ) - -1162 #ià! -defšed - -_HAVE_STRING_ARCH_¡¹ok_r - || defšed -_FORCE_INLINES - - -1163 #iâdeà -_HAVE_STRING_ARCH_¡¹ok_r - - -1164  - #__¡¹ok_r -( -s -, -£p -, -Ãx -) \ - -1165 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -£p -è&& - `__¡ršg2_1b±r_p - (sep) \ - -1166 && (( -__cÚ¡ - *è( -£p -))[0] != '\0' \ - -1167 && (( -__cÚ¡ - *è( -£p -))[1] == '\0' \ - -1168 ? - `__¡¹ok_r_1c - ( -s -, (( -__cÚ¡ - *è( -£p -))[0], -Ãx -) \ - -1169 : - `__¡¹ok_r - ( -s -, -£p -, -Ãx -))) - - ) - -1172 -__STRING_INLINE - * -__¡¹ok_r_1c - (* -__s -,  -__£p -, ** -__Ãx -); - -1173 -__STRING_INLINE - * - -1174 - $__¡¹ok_r_1c - (* -__s -,  -__£p -, ** -__Ãx -) - -1176 * -__»suÉ -; - -1177 ià( -__s - =ð -NULL -) - -1178 -__s - = * -__Ãx -; - -1179 * -__s - =ð -__£p -) - -1180 ++ -__s -; - -1181 -__»suÉ - = -NULL -; - -1182 ià(* -__s - != '\0') - -1184 -__»suÉ - = -__s -++; - -1185 * -__s - != '\0') - -1186 ià(* -__s -++ =ð -__£p -) - -1188 -__s -[-1] = '\0'; - -1192 * -__Ãx - = -__s -; - -1193  -__»suÉ -; - -1194 - } -} - -1195 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -1196  - #¡¹ok_r -( -s -, -£p -, -Ãx -è - `__¡¹ok_r - (s, s•,‚ex) - - ) - -1201 #ià! -defšed - -_HAVE_STRING_ARCH_¡r£p - || defšed -_FORCE_INLINES - - -1202 #iâdeà -_HAVE_STRING_ARCH_¡r£p - - -1204 * -__¡r£p_g - (** -__¡ršgp -, -__cÚ¡ - * -__d–im -); - -1205  - #__¡r£p -( -s -, -»jeù -) \ - -1206 -__ex‹nsiÚ__ - \ - -1207 ({  -__r0 -, -__r1 -, -__r2 -; \ - -1208 ( - `__bužtš_cÚ¡ªt_p - ( -»jeù -è&& - `__¡ršg2_1b±r_p - (reject) \ - -1209 && ( -__r0 - = (( -__cÚ¡ - *è( -»jeù -))[0], \ - -1210 (( -__cÚ¡ - *è( -»jeù -))[0] != '\0') \ - -1211 ? (( -__r1 - = (( -__cÚ¡ - *è( -»jeù -))[1], \ - -1212 (( -__cÚ¡ - *è( -»jeù -))[1] == '\0') \ - -1213 ? - `__¡r£p_1c - ( -s -, -__r0 -) \ - -1214 : (( -__r2 - = (( -__cÚ¡ - *è( -»jeù -))[2], __r2 == '\0') \ - -1215 ? - `__¡r£p_2c - ( -s -, -__r0 -, -__r1 -) \ - -1216 : ((( -__cÚ¡ - *è( -»jeù -))[3] == '\0' \ - -1217 ? - `__¡r£p_3c - ( -s -, -__r0 -, -__r1 -, -__r2 -) \ - -1218 : - `__¡r£p_g - ( -s -, -»jeù -)))) \ - -1219 : - `__¡r£p_g - ( -s -, -»jeù -)); }) - - ) - -1222 -__STRING_INLINE - * -__¡r£p_1c - (** -__s -,  -__»jeù -); - -1223 -__STRING_INLINE - * - -1224 - $__¡r£p_1c - (** -__s -,  -__»jeù -) - -1226 * -__»tv® - = * -__s -; - -1227 ià( -__»tv® - !ð -NULL - && (* -__s - = - `¡rchr - (__»tv®, -__»jeù -)) != NULL) - -1228 *(* -__s -)++ = '\0'; - -1229  -__»tv® -; - -1230 - } -} - -1232 -__STRING_INLINE - * -__¡r£p_2c - (** -__s -,  -__»jeù1 -,  -__»jeù2 -); - -1233 -__STRING_INLINE - * - -1234 - $__¡r£p_2c - (** -__s -,  -__»jeù1 -,  -__»jeù2 -) - -1236 * -__»tv® - = * -__s -; - -1237 ià( -__»tv® - !ð -NULL -) - -1239 * -__ý - = -__»tv® -; - -1242 ià(* -__ý - == '\0') - -1244 -__ý - = -NULL -; - -1247 ià(* -__ý - =ð -__»jeù1 - || *__ý =ð -__»jeù2 -) - -1249 * -__ý -++ = '\0'; - -1252 ++ -__ý -; - -1254 * -__s - = -__ý -; - -1256  -__»tv® -; - -1257 - } -} - -1259 -__STRING_INLINE - * -__¡r£p_3c - (** -__s -,  -__»jeù1 -,  -__»jeù2 -, - -1260  -__»jeù3 -); - -1261 -__STRING_INLINE - * - -1262 - $__¡r£p_3c - (** -__s -,  -__»jeù1 -,  -__»jeù2 -,  -__»jeù3 -) - -1264 * -__»tv® - = * -__s -; - -1265 ià( -__»tv® - !ð -NULL -) - -1267 * -__ý - = -__»tv® -; - -1270 ià(* -__ý - == '\0') - -1272 -__ý - = -NULL -; - -1275 ià(* -__ý - =ð -__»jeù1 - || *__ý =ð -__»jeù2 - || *__ý =ð -__»jeù3 -) - -1277 * -__ý -++ = '\0'; - -1280 ++ -__ý -; - -1282 * -__s - = -__ý -; - -1284  -__»tv® -; - -1285 - } -} - -1286 #ifdeà -__USE_BSD - - -1287  - #¡r£p -( -s -, -»jeù -è - `__¡r£p - (s,„ejeù) - - ) - -1294 #ifdeà -__USE_MISC - - -1296 #ià! -defšed - -_HAVE_STRING_ARCH_¡rdup - || !defšed -_HAVE_STRING_ARCH_¡ºdup - - -1297  - #__Ãed_m®loc_ªd_ÿÎoc - - - ) - -1298  - ~<¡dlib.h -> - -1301 #iâdeà -_HAVE_STRING_ARCH_¡rdup - - -1303 * - $__¡rdup - ( -__cÚ¡ - * -__¡ršg -è -__THROW - -__©Œibu‹_m®loc__ -; - -1304  - #__¡rdup -( -s -) \ - -1305 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -s -è&& - `__¡ršg2_1b±r_p - (s) \ - -1306 ? ((( -__cÚ¡ - *è( -s -))[0] == '\0' \ - -1307 ? (*è - `ÿÎoc - (( -size_t -) 1, (size_t) 1) \ - -1308 : ({ -size_t - -__Ën - = - `¡¾’ - ( -s -) + 1; \ - -1309 * -__»tv® - = (*è - `m®loc - ( -__Ën -); \ - -1310 ià( -__»tv® - !ð -NULL -) \ - -1311 -__»tv® - = (*è - `memýy - (__»tv®, -s -, -__Ën -); \ - -1312 -__»tv® -; - } -})) \ - -1313 : - `__¡rdup - ( -s -))) - - ) - -1315 #ià -defšed - -__USE_SVID - || defšed -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - - -1316  - #¡rdup -( -s -è - `__¡rdup - (s) - - ) - -1320 #iâdeà -_HAVE_STRING_ARCH_¡ºdup - - -1322 * - $__¡ºdup - ( -__cÚ¡ - * -__¡ršg -, -size_t - -__n -) - -1323 -__THROW - -__©Œibu‹_m®loc__ -; - -1324  - #__¡ºdup -( -s -, -n -) \ - -1325 ( - `__ex‹nsiÚ__ - ( - `__bužtš_cÚ¡ªt_p - ( -s -è&& - `__¡ršg2_1b±r_p - (s) \ - -1326 ? ((( -__cÚ¡ - *è( -s -))[0] == '\0' \ - -1327 ? (*è - `ÿÎoc - (( -size_t -) 1, (size_t) 1) \ - -1328 : ({ -size_t - -__Ën - = - `¡¾’ - ( -s -) + 1; \ - -1329 -size_t - -__n - = ( -n -); \ - -1330 * -__»tv® -; \ - -1331 ià( -__n - < -__Ën -) \ - -1332 -__Ën - = -__n - + 1; \ - -1333 -__»tv® - = (*è - `m®loc - ( -__Ën -); \ - -1334 ià( -__»tv® - !ð -NULL -) \ - -1336 -__»tv® -[ -__Ën - - 1] = '\0'; \ - -1337 -__»tv® - = (*è - `memýy - (__»tv®, -s -, \ - -1338 -__Ën - - 1); \ - -1340 -__»tv® -; - } -})) \ - -1341 : - `__¡ºdup - ( -s -, -n -))) - - ) - -1343 #ifdeà -__USE_GNU - - -1344  - #¡ºdup -( -s -, -n -è - `__¡ºdup - (s,‚) - - ) - -1350 #iâdeà -_FORCE_INLINES - - -1351 #undeà -__STRING_INLINE - - - @/usr/include/bits/string3.h - -19 #iâdeà -_STRING_H - - -23 -__w¬ndeþ - ( -__w¬n_mem£t_z”o_Ën -, - -26 #iâdeà -__ýlu¥lus - - -30 #undeà -memýy - - -31 #undeà -memmove - - -32 #undeà -mem£t - - -33 #undeà -¡rÿt - - -34 #undeà -¡rýy - - -35 #undeà -¡ºÿt - - -36 #undeà -¡ºýy - - -37 #ifdeà -__USE_GNU - - -38 #undeà -mempýy - - -39 #undeà -¡pýy - - -41 #ifdeà -__USE_BSD - - -42 #undeà -bcÝy - - -43 #undeà -bz”o - - -48 -__ex‹º_®ways_šlše - * - -49 -__NTH - ( - $memýy - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -, - -50 -size_t - -__Ën -)) - -52  - `__bužtš___memýy_chk - ( -__de¡ -, -__¤c -, -__Ën -, - `__bos0 - (__dest)); - -53 - } -} - -55 -__ex‹º_®ways_šlše - * - -56 -__NTH - ( - $memmove - (* -__de¡ -, -__cÚ¡ - * -__¤c -, -size_t - -__Ën -)) - -58  - `__bužtš___memmove_chk - ( -__de¡ -, -__¤c -, -__Ën -, - `__bos0 - (__dest)); - -59 - } -} - -61 #ifdeà -__USE_GNU - - -62 -__ex‹º_®ways_šlše - * - -63 -__NTH - ( - $mempýy - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -, - -64 -size_t - -__Ën -)) - -66  - `__bužtš___mempýy_chk - ( -__de¡ -, -__¤c -, -__Ën -, - `__bos0 - (__dest)); - -67 - } -} - -76 -__ex‹º_®ways_šlše - * - -77 -__NTH - ( - $mem£t - (* -__de¡ -,  -__ch -, -size_t - -__Ën -)) - -79 ià( - `__bužtš_cÚ¡ªt_p - ( -__Ën -) && __len == 0 - -80 && (! - `__bužtš_cÚ¡ªt_p - ( -__ch -) || __ch != 0)) - -82 - `__w¬n_mem£t_z”o_Ën - (); - -83  -__de¡ -; - -85  - `__bužtš___mem£t_chk - ( -__de¡ -, -__ch -, -__Ën -, - `__bos0 - (__dest)); - -86 - } -} - -88 #ifdeà -__USE_BSD - - -89 -__ex‹º_®ways_šlše -  - -90 -__NTH - ( - $bcÝy - ( -__cÚ¡ - * -__¤c -, * -__de¡ -, -size_t - -__Ën -)) - -92 (è - `__bužtš___memmove_chk - ( -__de¡ -, -__¤c -, -__Ën -, - `__bos0 - (__dest)); - -93 - } -} - -95 -__ex‹º_®ways_šlše -  - -96 -__NTH - ( - $bz”o - (* -__de¡ -, -size_t - -__Ën -)) - -98 (è - `__bužtš___mem£t_chk - ( -__de¡ -, '\0', -__Ën -, - `__bos0 - (__dest)); - -99 - } -} - -102 -__ex‹º_®ways_šlše - * - -103 -__NTH - ( - $¡rýy - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -)) - -105  - `__bužtš___¡rýy_chk - ( -__de¡ -, -__¤c -, - `__bos - (__dest)); - -106 - } -} - -108 #ifdeà -__USE_GNU - - -109 -__ex‹º_®ways_šlše - * - -110 -__NTH - ( - $¡pýy - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -)) - -112  - `__bužtš___¡pýy_chk - ( -__de¡ -, -__¤c -, - `__bos - (__dest)); - -113 - } -} - -117 -__ex‹º_®ways_šlše - * - -118 -__NTH - ( - $¡ºýy - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -, - -119 -size_t - -__Ën -)) - -121  - `__bužtš___¡ºýy_chk - ( -__de¡ -, -__¤c -, -__Ën -, - `__bos - (__dest)); - -122 - } -} - -125 * - $__¡²ýy_chk - (* -__de¡ -, -__cÚ¡ - * -__¤c -, -size_t - -__n -, - -126 -size_t - -__de¡Ën -è -__THROW -; - -127 * - `__REDIRECT_NTH - ( -__¡²ýy_®Ÿs -, (* -__de¡ -, - -128 -__cÚ¡ - * -__¤c -, - -129 -size_t - -__n -), -¡²ýy -); - -131 -__ex‹º_®ways_šlše - * - -132 - `__NTH - ( - $¡²ýy - (* -__de¡ -, -__cÚ¡ - * -__¤c -, -size_t - -__n -)) - -134 ià( - `__bos - ( -__de¡ -è!ð( -size_t -) -1 - -135 && (! - `__bužtš_cÚ¡ªt_p - ( -__n -è|| __À<ð - `__bos - ( -__de¡ -))) - -136  - `__¡²ýy_chk - ( -__de¡ -, -__¤c -, -__n -, - `__bos - (__dest)); - -137  - `__¡²ýy_®Ÿs - ( -__de¡ -, -__¤c -, -__n -); - -138 - } -} - -141 -__ex‹º_®ways_šlše - * - -142 -__NTH - ( - $¡rÿt - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -)) - -144  - `__bužtš___¡rÿt_chk - ( -__de¡ -, -__¤c -, - `__bos - (__dest)); - -145 - } -} - -148 -__ex‹º_®ways_šlše - * - -149 -__NTH - ( - $¡ºÿt - (* -__»¡riù - -__de¡ -, -__cÚ¡ - *__»¡riù -__¤c -, - -150 -size_t - -__Ën -)) - -152  - `__bužtš___¡ºÿt_chk - ( -__de¡ -, -__¤c -, -__Ën -, - `__bos - (__dest)); - -153 - } -} - - @/usr/include/bits/sys_errlist.h - -20 #iâdeà -_STDIO_H - - -26 #ifdeà -__USE_BSD - - -27  -sys_ü -; - -28 -__cÚ¡ - *__cÚ¡ -sys_”¾i¡ -[]; - -30 #ifdeà -__USE_GNU - - -31  -_sys_ü -; - -32 -__cÚ¡ - *__cÚ¡ -_sys_”¾i¡ -[]; - - @/usr/include/bits/time.h - -24 #iâdeà -__Ãed_timev® - - -25 #iâdeà -_BITS_TIME_H - - -26  - #_BITS_TIME_H - 1 - - ) - -34  - #CLOCKS_PER_SEC - 1000000l - - ) - -36 #ià! -defšed - -__STRICT_ANSI__ - && !defšed -__USE_XOPEN2K - - -39  - ~ - -40  -__syscÚf - (); - -41  - #CLK_TCK - (( -__þock_t -è - `__syscÚf - (2)è - - ) - -44 #ifdeà -__USE_POSIX199309 - - -46  - #CLOCK_REALTIME - 0 - - ) - -48  - #CLOCK_MONOTONIC - 1 - - ) - -50  - #CLOCK_PROCESS_CPUTIME_ID - 2 - - ) - -52  - #CLOCK_THREAD_CPUTIME_ID - 3 - - ) - -54  - #CLOCK_MONOTONIC_RAW - 4 - - ) - -56  - #CLOCK_REALTIME_COARSE - 5 - - ) - -58  - #CLOCK_MONOTONIC_COARSE - 6 - - ) - -61  - #TIMER_ABSTIME - 1 - - ) - -67 #ifdeà -__Ãed_timev® - - -68 #undeà -__Ãed_timev® - - -69 #iâdeà -_STRUCT_TIMEVAL - - -70  - #_STRUCT_TIMEVAL - 1 - - ) - -71  - ~ - -75  - stimev® - - -77 -__time_t - - mtv_£c -; - -78 -__su£cÚds_t - - mtv_u£c -; - - @/usr/include/bits/types.h - -24 #iâdef -_BITS_TYPES_H - - -25  - #_BITS_TYPES_H - 1 - - ) - -27  - ~<ã©u»s.h -> - -28  - ~ - -31  - t__u_ch¬ -; - -32  - t__u_shÜt -; - -33  - t__u_št -; - -34  - t__u_lÚg -; - -37 sigÃd  - t__št8_t -; - -38  - t__ušt8_t -; - -39 sigÃd  - t__št16_t -; - -40  - t__ušt16_t -; - -41 sigÃd  - t__št32_t -; - -42  - t__ušt32_t -; - -43 #ià -__WORDSIZE - == 64 - -44 sigÃd  - t__št64_t -; - -45  - t__ušt64_t -; - -46 #–ià -defšed - -__GLIBC_HAVE_LONG_LONG - - -47 -__ex‹nsiÚ__ - sigÃd  - t__št64_t -; - -48 -__ex‹nsiÚ__ -  - t__ušt64_t -; - -52 #ià -__WORDSIZE - == 64 - -53  - t__quad_t -; - -54  - t__u_quad_t -; - -55 #–ià -defšed - -__GLIBC_HAVE_LONG_LONG - - -56 -__ex‹nsiÚ__ -  - t__quad_t -; - -57 -__ex‹nsiÚ__ -  - t__u_quad_t -; - -61  - m__v® -[2]; - -62 } - t__quad_t -; - -65 -__u_lÚg - - m__v® -[2]; - -66 } - t__u_quad_t -; - -99  - #__S16_TYPE -  - - ) - -100  - #__U16_TYPE -  - - ) - -101  - #__S32_TYPE -  - - ) - -102  - #__U32_TYPE -  - - ) - -103  - #__SLONGWORD_TYPE -  - - ) - -104  - #__ULONGWORD_TYPE -  - - ) - -105 #ià -__WORDSIZE - == 32 - -106  - #__SQUAD_TYPE - -__quad_t - - - ) - -107  - #__UQUAD_TYPE - -__u_quad_t - - - ) - -108  - #__SWORD_TYPE -  - - ) - -109  - #__UWORD_TYPE -  - - ) - -110  - #__SLONG32_TYPE -  - - ) - -111  - #__ULONG32_TYPE -  - - ) - -112  - #__S64_TYPE - -__quad_t - - - ) - -113  - #__U64_TYPE - -__u_quad_t - - - ) - -116  - #__STD_TYPE - -__ex‹nsiÚ__ -  - - ) - -117 #–ià -__WORDSIZE - == 64 - -118  - t__SQUAD_TYPE -  - - ) - -119  - t__UQUAD_TYPE -  - - ) - -120  - t__SWORD_TYPE -  - - ) - -121  - t__UWORD_TYPE -  - - ) - -122  - t__SLONG32_TYPE -  - - ) - -123  - t__ULONG32_TYPE -  - - ) - -124  - t__S64_TYPE -  - - ) - -125  - t__U64_TYPE -  - - ) - -127  - t__STD_TYPE -  - - ) - -131  - ~ - -134 -__STD_TYPE - - t__DEV_T_TYPE - - t__dev_t -; - -135 -__STD_TYPE - -__UID_T_TYPE - - g__uid_t -; - -136 -__STD_TYPE - -__GID_T_TYPE - - g__gid_t -; - -137 -__STD_TYPE - -__INO_T_TYPE - - g__šo_t -; - -138 -__STD_TYPE - -__INO64_T_TYPE - - g__šo64_t -; - -139 -__STD_TYPE - -__MODE_T_TYPE - - g__mode_t -; - -140 -__STD_TYPE - -__NLINK_T_TYPE - - g__ƚk_t -; - -141 -__STD_TYPE - -__OFF_T_TYPE - - g__off_t -; - -142 -__STD_TYPE - -__OFF64_T_TYPE - - g__off64_t -; - -143 -__STD_TYPE - -__PID_T_TYPE - - g__pid_t -; - -144 -__STD_TYPE - -__FSID_T_TYPE - - g__fsid_t -; - -145 -__STD_TYPE - -__CLOCK_T_TYPE - - g__þock_t -; - -146 -__STD_TYPE - -__RLIM_T_TYPE - - g__¾im_t -; - -147 -__STD_TYPE - -__RLIM64_T_TYPE - - g__¾im64_t -; - -148 -__STD_TYPE - -__ID_T_TYPE - - g__id_t -; - -149 -__STD_TYPE - -__TIME_T_TYPE - - g__time_t -; - -150 -__STD_TYPE - -__USECONDS_T_TYPE - - g__u£cÚds_t -; - -151 -__STD_TYPE - -__SUSECONDS_T_TYPE - - g__su£cÚds_t -; - -153 -__STD_TYPE - -__DADDR_T_TYPE - - g__daddr_t -; - -154 -__STD_TYPE - -__SWBLK_T_TYPE - - g__swblk_t -; - -155 -__STD_TYPE - -__KEY_T_TYPE - - g__key_t -; - -158 -__STD_TYPE - -__CLOCKID_T_TYPE - - g__þockid_t -; - -161 -__STD_TYPE - -__TIMER_T_TYPE - - g__tim”_t -; - -164 -__STD_TYPE - -__BLKSIZE_T_TYPE - - g__blksize_t -; - -169 -__STD_TYPE - -__BLKCNT_T_TYPE - - g__blkút_t -; - -170 -__STD_TYPE - -__BLKCNT64_T_TYPE - - g__blkút64_t -; - -173 -__STD_TYPE - -__FSBLKCNT_T_TYPE - - g__fsblkút_t -; - -174 -__STD_TYPE - -__FSBLKCNT64_T_TYPE - - g__fsblkút64_t -; - -177 -__STD_TYPE - -__FSFILCNT_T_TYPE - - g__fsfžút_t -; - -178 -__STD_TYPE - -__FSFILCNT64_T_TYPE - - g__fsfžút64_t -; - -180 -__STD_TYPE - -__SSIZE_T_TYPE - - g__ssize_t -; - -184  -__off64_t - - t__loff_t -; - -185  -__quad_t - * - t__qaddr_t -; - -186 * - t__ÿddr_t -; - -189 -__STD_TYPE - -__SWORD_TYPE - - g__šŒ_t -; - -192 -__STD_TYPE - -__U32_TYPE - - g__sockËn_t -; - -195 #undeà -__STD_TYPE - - - @/usr/include/bits/unistd.h - -20 #iâdeà -_UNISTD_H - - -24 -ssize_t - - $__»ad_chk - ( -__fd -, * -__buf -, -size_t - -__nby‹s -, - -25 -size_t - -__buæ’ -è -__wur -; - -26 -ssize_t - - `__REDIRECT - ( -__»ad_®Ÿs -, ( -__fd -, * -__buf -, - -27 -size_t - -__nby‹s -), -»ad -è -__wur -; - -28 -ssize_t - - `__REDIRECT - ( -__»ad_chk_w¬n -, - -29 ( -__fd -, * -__buf -, -size_t - -__nby‹s -, - -30 -size_t - -__buæ’ -), -__»ad_chk -) - -31 -__wur - - `__w¬Ç‰r - ("read called with bigger†engthhan size of " - -34 -__ex‹º_®ways_šlše - -__wur - -ssize_t - - -35 - $»ad - ( -__fd -, * -__buf -, -size_t - -__nby‹s -) - -37 ià( - `__bos0 - ( -__buf -è!ð( -size_t -) -1) - -39 ià(! - `__bužtš_cÚ¡ªt_p - ( -__nby‹s -)) - -40  - `__»ad_chk - ( -__fd -, -__buf -, -__nby‹s -, - `__bos0 - (__buf)); - -42 ià( -__nby‹s - > - `__bos0 - ( -__buf -)) - -43  - `__»ad_chk_w¬n - ( -__fd -, -__buf -, -__nby‹s -, - `__bos0 - (__buf)); - -45  - `__»ad_®Ÿs - ( -__fd -, -__buf -, -__nby‹s -); - -46 - } -} - -48 #ifdeà -__USE_UNIX98 - - -49 -ssize_t - - $__´—d_chk - ( -__fd -, * -__buf -, -size_t - -__nby‹s -, - -50 -__off_t - -__off£t -, -size_t - -__bufsize -è -__wur -; - -51 -ssize_t - - $__´—d64_chk - ( -__fd -, * -__buf -, -size_t - -__nby‹s -, - -52 -__off64_t - -__off£t -, -size_t - -__bufsize -è -__wur -; - -53 -ssize_t - - `__REDIRECT - ( -__´—d_®Ÿs -, - -54 ( -__fd -, * -__buf -, -size_t - -__nby‹s -, - -55 -__off_t - -__off£t -), -´—d -è -__wur -; - -56 -ssize_t - - `__REDIRECT - ( -__´—d64_®Ÿs -, - -57 ( -__fd -, * -__buf -, -size_t - -__nby‹s -, - -58 -__off64_t - -__off£t -), -´—d64 -è -__wur -; - -59 -ssize_t - - `__REDIRECT - ( -__´—d_chk_w¬n -, - -60 ( -__fd -, * -__buf -, -size_t - -__nby‹s -, - -61 -__off_t - -__off£t -, -size_t - -__bufsize -), -__´—d_chk -) - -62 -__wur - - `__w¬Ç‰r - ("pread called with bigger†engthhan size of " - -64 -ssize_t - - `__REDIRECT - ( -__´—d64_chk_w¬n -, - -65 ( -__fd -, * -__buf -, -size_t - -__nby‹s -, - -66 -__off64_t - -__off£t -, -size_t - -__bufsize -), - -67 -__´—d64_chk -) - -68 -__wur - - `__w¬Ç‰r - ("pread64 called with bigger†engthhan size of " - -71 #iâdeà -__USE_FILE_OFFSET64 - - -72 -__ex‹º_®ways_šlše - -__wur - -ssize_t - - -73 - $´—d - ( -__fd -, * -__buf -, -size_t - -__nby‹s -, -__off_t - -__off£t -) - -75 ià( - `__bos0 - ( -__buf -è!ð( -size_t -) -1) - -77 ià(! - `__bužtš_cÚ¡ªt_p - ( -__nby‹s -)) - -78  - `__´—d_chk - ( -__fd -, -__buf -, -__nby‹s -, -__off£t -, - `__bos0 - (__buf)); - -80 iàÐ -__nby‹s - > - `__bos0 - ( -__buf -)) - -81  - `__´—d_chk_w¬n - ( -__fd -, -__buf -, -__nby‹s -, -__off£t -, - -82 - `__bos0 - ( -__buf -)); - -84  - `__´—d_®Ÿs - ( -__fd -, -__buf -, -__nby‹s -, -__off£t -); - -85 - } -} - -87 -__ex‹º_®ways_šlše - -__wur - -ssize_t - - -88 - $´—d - ( -__fd -, * -__buf -, -size_t - -__nby‹s -, -__off64_t - -__off£t -) - -90 ià( - `__bos0 - ( -__buf -è!ð( -size_t -) -1) - -92 ià(! - `__bužtš_cÚ¡ªt_p - ( -__nby‹s -)) - -93  - `__´—d64_chk - ( -__fd -, -__buf -, -__nby‹s -, -__off£t -, - `__bos0 - (__buf)); - -95 iàÐ -__nby‹s - > - `__bos0 - ( -__buf -)) - -96  - `__´—d64_chk_w¬n - ( -__fd -, -__buf -, -__nby‹s -, -__off£t -, - -97 - `__bos0 - ( -__buf -)); - -100  - `__´—d64_®Ÿs - ( -__fd -, -__buf -, -__nby‹s -, -__off£t -); - -101 - } -} - -104 #ifdeà -__USE_LARGEFILE64 - - -105 -__ex‹º_®ways_šlše - -__wur - -ssize_t - - -106 - $´—d64 - ( -__fd -, * -__buf -, -size_t - -__nby‹s -, -__off64_t - -__off£t -) - -108 ià( - `__bos0 - ( -__buf -è!ð( -size_t -) -1) - -110 ià(! - `__bužtš_cÚ¡ªt_p - ( -__nby‹s -)) - -111  - `__´—d64_chk - ( -__fd -, -__buf -, -__nby‹s -, -__off£t -, - `__bos0 - (__buf)); - -113 iàÐ -__nby‹s - > - `__bos0 - ( -__buf -)) - -114  - `__´—d64_chk_w¬n - ( -__fd -, -__buf -, -__nby‹s -, -__off£t -, - -115 - `__bos0 - ( -__buf -)); - -118  - `__´—d64_®Ÿs - ( -__fd -, -__buf -, -__nby‹s -, -__off£t -); - -119 - } -} - -123 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - || defšed -__USE_XOPEN2K - - -124 -ssize_t - - $__»adlšk_chk - ( -__cÚ¡ - * -__»¡riù - -__·th -, - -125 * -__»¡riù - -__buf -, -size_t - -__Ën -, - -126 -size_t - -__buæ’ -) - -127 -__THROW - - `__nÚnuÎ - ((1, 2)è -__wur -; - -128 -ssize_t - - `__REDIRECT_NTH - ( -__»adlšk_®Ÿs -, - -129 ( -__cÚ¡ - * -__»¡riù - -__·th -, - -130 * -__»¡riù - -__buf -, -size_t - -__Ën -), -»adlšk -) - -131 - `__nÚnuÎ - ((1, 2)è -__wur -; - -132 -ssize_t - - `__REDIRECT_NTH - ( -__»adlšk_chk_w¬n -, - -133 ( -__cÚ¡ - * -__»¡riù - -__·th -, - -134 * -__»¡riù - -__buf -, -size_t - -__Ën -, - -135 -size_t - -__buæ’ -), -__»adlšk_chk -) - -136 - `__nÚnuÎ - ((1, 2)è -__wur - - `__w¬Ç‰r - ("readlink called with bigger†ength " - -139 -__ex‹º_®ways_šlše - - `__nÚnuÎ - ((1, 2)è -__wur - -ssize_t - - -140 - `__NTH - ( - $»adlšk - ( -__cÚ¡ - * -__»¡riù - -__·th -, *__»¡riù -__buf -, - -141 -size_t - -__Ën -)) - -143 ià( - `__bos - ( -__buf -è!ð( -size_t -) -1) - -145 ià(! - `__bužtš_cÚ¡ªt_p - ( -__Ën -)) - -146  - `__»adlšk_chk - ( -__·th -, -__buf -, -__Ën -, - `__bos - (__buf)); - -148 iàÐ -__Ën - > - `__bos - ( -__buf -)) - -149  - `__»adlšk_chk_w¬n - ( -__·th -, -__buf -, -__Ën -, - `__bos - (__buf)); - -151  - `__»adlšk_®Ÿs - ( -__·th -, -__buf -, -__Ën -); - -152 - } -} - -155 #ifdeà -__USE_ATFILE - - -156 -ssize_t - - $__»adlšk©_chk - ( -__fd -, -__cÚ¡ - * -__»¡riù - -__·th -, - -157 * -__»¡riù - -__buf -, -size_t - -__Ën -, - -158 -size_t - -__buæ’ -) - -159 -__THROW - - `__nÚnuÎ - ((2, 3)è -__wur -; - -160 -ssize_t - - `__REDIRECT_NTH - ( -__»adlšk©_®Ÿs -, - -161 ( -__fd -, -__cÚ¡ - * -__»¡riù - -__·th -, - -162 * -__»¡riù - -__buf -, -size_t - -__Ën -), - -163 -»adlšk© -) - -164 - `__nÚnuÎ - ((2, 3)è -__wur -; - -165 -ssize_t - - `__REDIRECT_NTH - ( -__»adlšk©_chk_w¬n -, - -166 ( -__fd -, -__cÚ¡ - * -__»¡riù - -__·th -, - -167 * -__»¡riù - -__buf -, -size_t - -__Ën -, - -168 -size_t - -__buæ’ -), -__»adlšk©_chk -) - -169 - `__nÚnuÎ - ((2, 3)è -__wur - - `__w¬Ç‰r - ("readlinkat called with bigger " - -173 -__ex‹º_®ways_šlše - - `__nÚnuÎ - ((2, 3)è -__wur - -ssize_t - - -174 - `__NTH - ( - $»adlšk© - ( -__fd -, -__cÚ¡ - * -__»¡riù - -__·th -, - -175 * -__»¡riù - -__buf -, -size_t - -__Ën -)) - -177 ià( - `__bos - ( -__buf -è!ð( -size_t -) -1) - -179 ià(! - `__bužtš_cÚ¡ªt_p - ( -__Ën -)) - -180  - `__»adlšk©_chk - ( -__fd -, -__·th -, -__buf -, -__Ën -, - `__bos - (__buf)); - -182 ià( -__Ën - > - `__bos - ( -__buf -)) - -183  - `__»adlšk©_chk_w¬n - ( -__fd -, -__·th -, -__buf -, -__Ën -, - -184 - `__bos - ( -__buf -)); - -186  - `__»adlšk©_®Ÿs - ( -__fd -, -__·th -, -__buf -, -__Ën -); - -187 - } -} - -190 * - $__g‘cwd_chk - (* -__buf -, -size_t - -__size -, size_ˆ -__buæ’ -) - -191 -__THROW - -__wur -; - -192 * - `__REDIRECT_NTH - ( -__g‘cwd_®Ÿs -, - -193 (* -__buf -, -size_t - -__size -), -g‘cwd -è -__wur -; - -194 * - `__REDIRECT_NTH - ( -__g‘cwd_chk_w¬n -, - -195 (* -__buf -, -size_t - -__size -, size_ˆ -__buæ’ -), - -196 -__g‘cwd_chk -) - -197 -__wur - - `__w¬Ç‰r - ("getcwd caller with bigger†engthhan size of " - -200 -__ex‹º_®ways_šlše - -__wur - * - -201 - `__NTH - ( - $g‘cwd - (* -__buf -, -size_t - -__size -)) - -203 ià( - `__bos - ( -__buf -è!ð( -size_t -) -1) - -205 ià(! - `__bužtš_cÚ¡ªt_p - ( -__size -)) - -206  - `__g‘cwd_chk - ( -__buf -, -__size -, - `__bos - (__buf)); - -208 ià( -__size - > - `__bos - ( -__buf -)) - -209  - `__g‘cwd_chk_w¬n - ( -__buf -, -__size -, - `__bos - (__buf)); - -211  - `__g‘cwd_®Ÿs - ( -__buf -, -__size -); - -212 - } -} - -214 #ià -defšed - -__USE_BSD - || defšed -__USE_XOPEN_EXTENDED - - -215 * - $__g‘wd_chk - (* -__buf -, -size_t - -buæ’ -) - -216 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -217 * - `__REDIRECT_NTH - ( -__g‘wd_w¬n -, (* -__buf -), -g‘wd -) - -218 - `__nÚnuÎ - ((1)è -__wur - - `__w¬Ç‰r - ("please use getcwd instead,‡s getwd " - -221 -__ex‹º_®ways_šlše - - `__nÚnuÎ - ((1)è -__©Œibu‹_d•»ÿ‹d__ - -__wur - * - -222 - `__NTH - ( - $g‘wd - (* -__buf -)) - -224 ià( - `__bos - ( -__buf -è!ð( -size_t -) -1) - -225  - `__g‘wd_chk - ( -__buf -, - `__bos - (__buf)); - -226  - `__g‘wd_w¬n - ( -__buf -); - -227 - } -} - -230 -size_t - - $__cÚf¡r_chk - ( -__Çme -, * -__buf -, -size_t - -__Ën -, - -231 -size_t - -__buæ’ -è -__THROW -; - -232 -size_t - - `__REDIRECT_NTH - ( -__cÚf¡r_®Ÿs -, ( -__Çme -, * -__buf -, - -233 -size_t - -__Ën -), -cÚf¡r -); - -234 -size_t - - `__REDIRECT_NTH - ( -__cÚf¡r_chk_w¬n -, - -235 ( -__Çme -, * -__buf -, -size_t - -__Ën -, - -236 -size_t - -__buæ’ -), -__cÚf¡r_chk -) - -237 - `__w¬Ç‰r - ("confstr called with bigger†engthhan size of destination " - -240 -__ex‹º_®ways_šlše - -size_t - - -241 - `__NTH - ( - $cÚf¡r - ( -__Çme -, * -__buf -, -size_t - -__Ën -)) - -243 ià( - `__bos - ( -__buf -è!ð( -size_t -) -1) - -245 ià(! - `__bužtš_cÚ¡ªt_p - ( -__Ën -)) - -246  - `__cÚf¡r_chk - ( -__Çme -, -__buf -, -__Ën -, - `__bos - (__buf)); - -248 ià( - `__bos - ( -__buf -è< -__Ën -) - -249  - `__cÚf¡r_chk_w¬n - ( -__Çme -, -__buf -, -__Ën -, - `__bos - (__buf)); - -251  - `__cÚf¡r_®Ÿs - ( -__Çme -, -__buf -, -__Ën -); - -252 - } -} - -255  - $__g‘groups_chk - ( -__size -, -__gid_t - -__li¡ -[], -size_t - -__li¡Ën -) - -256 -__THROW - -__wur -; - -257  - `__REDIRECT_NTH - ( -__g‘groups_®Ÿs -, ( -__size -, -__gid_t - -__li¡ -[]), - -258 -g‘groups -è -__wur -; - -259  - `__REDIRECT_NTH - ( -__g‘groups_chk_w¬n -, - -260 ( -__size -, -__gid_t - -__li¡ -[], -size_t - -__li¡Ën -), - -261 -__g‘groups_chk -) - -262 -__wur - - `__w¬Ç‰r - ("getgroups called with bigger group counthan what " - -265 -__ex‹º_®ways_šlše -  - -266 - `__NTH - ( - $g‘groups - ( -__size -, -__gid_t - -__li¡ -[])) - -268 ià( - `__bos - ( -__li¡ -è!ð( -size_t -) -1) - -270 ià(! - `__bužtš_cÚ¡ªt_p - ( -__size -) || __size < 0) - -271  - `__g‘groups_chk - ( -__size -, -__li¡ -, - `__bos - (__list)); - -273 ià( -__size - *  ( -__gid_t -è> - `__bos - ( -__li¡ -)) - -274  - `__g‘groups_chk_w¬n - ( -__size -, -__li¡ -, - `__bos - (__list)); - -276  - `__g‘groups_®Ÿs - ( -__size -, -__li¡ -); - -277 - } -} - -280  - $__‰yÇme_r_chk - ( -__fd -, * -__buf -, -size_t - -__buæ’ -, - -281 -size_t - -__ėl -è -__THROW - - `__nÚnuÎ - ((2)); - -282  - `__REDIRECT_NTH - ( -__‰yÇme_r_®Ÿs -, ( -__fd -, * -__buf -, - -283 -size_t - -__buæ’ -), -‰yÇme_r -) - -284 - `__nÚnuÎ - ((2)); - -285  - `__REDIRECT_NTH - ( -__‰yÇme_r_chk_w¬n -, - -286 ( -__fd -, * -__buf -, -size_t - -__buæ’ -, - -287 -size_t - -__ėl -), -__‰yÇme_r_chk -) - -288 - `__nÚnuÎ - ((2)è - `__w¬Ç‰r - ("ttyname_r called with bigger buflenhan " - -291 -__ex‹º_®ways_šlše -  - -292 - `__NTH - ( - $‰yÇme_r - ( -__fd -, * -__buf -, -size_t - -__buæ’ -)) - -294 ià( - `__bos - ( -__buf -è!ð( -size_t -) -1) - -296 ià(! - `__bužtš_cÚ¡ªt_p - ( -__buæ’ -)) - -297  - `__‰yÇme_r_chk - ( -__fd -, -__buf -, -__buæ’ -, - `__bos - (__buf)); - -299 ià( -__buæ’ - > - `__bos - ( -__buf -)) - -300  - `__‰yÇme_r_chk_w¬n - ( -__fd -, -__buf -, -__buæ’ -, - `__bos - (__buf)); - -302  - `__‰yÇme_r_®Ÿs - ( -__fd -, -__buf -, -__buæ’ -); - -303 - } -} - -306 #ià -defšed - -__USE_REENTRANT - || defšed -__USE_POSIX199506 - - -307  - $__g‘logš_r_chk - (* -__buf -, -size_t - -__buæ’ -, size_ˆ -__ėl -) - -308 - `__nÚnuÎ - ((1)); - -309  - `__REDIRECT - ( -__g‘logš_r_®Ÿs -, (* -__buf -, -size_t - -__buæ’ -), - -310 -g‘logš_r -è - `__nÚnuÎ - ((1)); - -311  - `__REDIRECT - ( -__g‘logš_r_chk_w¬n -, - -312 (* -__buf -, -size_t - -__buæ’ -, size_ˆ -__ėl -), - -313 -__g‘logš_r_chk -) - -314 - `__nÚnuÎ - ((1)è - `__w¬Ç‰r - ("getlogin_r called with bigger buflenhan " - -317 -__ex‹º_®ways_šlše -  - -318 - $g‘logš_r - (* -__buf -, -size_t - -__buæ’ -) - -320 ià( - `__bos - ( -__buf -è!ð( -size_t -) -1) - -322 ià(! - `__bužtš_cÚ¡ªt_p - ( -__buæ’ -)) - -323  - `__g‘logš_r_chk - ( -__buf -, -__buæ’ -, - `__bos - (__buf)); - -325 ià( -__buæ’ - > - `__bos - ( -__buf -)) - -326  - `__g‘logš_r_chk_w¬n - ( -__buf -, -__buæ’ -, - `__bos - (__buf)); - -328  - `__g‘logš_r_®Ÿs - ( -__buf -, -__buæ’ -); - -329 - } -} - -333 #ià -defšed - -__USE_BSD - || defšed -__USE_UNIX98 - - -334  - $__g‘ho¡Çme_chk - (* -__buf -, -size_t - -__buæ’ -, size_ˆ -__ėl -) - -335 -__THROW - - `__nÚnuÎ - ((1)); - -336  - `__REDIRECT_NTH - ( -__g‘ho¡Çme_®Ÿs -, (* -__buf -, -size_t - -__buæ’ -), - -337 -g‘ho¡Çme -è - `__nÚnuÎ - ((1)); - -338  - `__REDIRECT_NTH - ( -__g‘ho¡Çme_chk_w¬n -, - -339 (* -__buf -, -size_t - -__buæ’ -, size_ˆ -__ėl -), - -340 -__g‘ho¡Çme_chk -) - -341 - `__nÚnuÎ - ((1)è - `__w¬Ç‰r - ("gethostname called with bigger buflenhan " - -344 -__ex‹º_®ways_šlše -  - -345 - `__NTH - ( - $g‘ho¡Çme - (* -__buf -, -size_t - -__buæ’ -)) - -347 ià( - `__bos - ( -__buf -è!ð( -size_t -) -1) - -349 ià(! - `__bužtš_cÚ¡ªt_p - ( -__buæ’ -)) - -350  - `__g‘ho¡Çme_chk - ( -__buf -, -__buæ’ -, - `__bos - (__buf)); - -352 ià( -__buæ’ - > - `__bos - ( -__buf -)) - -353  - `__g‘ho¡Çme_chk_w¬n - ( -__buf -, -__buæ’ -, - `__bos - (__buf)); - -355  - `__g‘ho¡Çme_®Ÿs - ( -__buf -, -__buæ’ -); - -356 - } -} - -360 #ià -defšed - -__USE_BSD - || (defšed -__USE_XOPEN - && !defšed -__USE_UNIX98 -) - -361  - $__g‘domašÇme_chk - (* -__buf -, -size_t - -__buæ’ -, size_ˆ -__ėl -) - -362 -__THROW - - `__nÚnuÎ - ((1)è -__wur -; - -363  - `__REDIRECT_NTH - ( -__g‘domašÇme_®Ÿs -, (* -__buf -, - -364 -size_t - -__buæ’ -), - -365 -g‘domašÇme -è - `__nÚnuÎ - ((1)è -__wur -; - -366  - `__REDIRECT_NTH - ( -__g‘domašÇme_chk_w¬n -, - -367 (* -__buf -, -size_t - -__buæ’ -, size_ˆ -__ėl -), - -368 -__g‘domašÇme_chk -) - -369 - `__nÚnuÎ - ((1)è -__wur - - `__w¬Ç‰r - ("getdomainname called with bigger " - -373 -__ex‹º_®ways_šlše -  - -374 - `__NTH - ( - $g‘domašÇme - (* -__buf -, -size_t - -__buæ’ -)) - -376 ià( - `__bos - ( -__buf -è!ð( -size_t -) -1) - -378 ià(! - `__bužtš_cÚ¡ªt_p - ( -__buæ’ -)) - -379  - `__g‘domašÇme_chk - ( -__buf -, -__buæ’ -, - `__bos - (__buf)); - -381 ià( -__buæ’ - > - `__bos - ( -__buf -)) - -382  - `__g‘domašÇme_chk_w¬n - ( -__buf -, -__buæ’ -, - `__bos - (__buf)); - -384  - `__g‘domašÇme_®Ÿs - ( -__buf -, -__buæ’ -); - -385 - } -} - - @/usr/include/bits/waitflags.h - -20 #ià! -defšed - -_SYS_WAIT_H - && !defšed -_STDLIB_H - - -26  - #WNOHANG - 1 - - ) - -27  - #WUNTRACED - 2 - - ) - -30  - #WSTOPPED - 2 - - ) - -31  - #WEXITED - 4 - - ) - -32  - #WCONTINUED - 8 - - ) - -33  - #WNOWAIT - 0x01000000 - - ) - -35  - #__WNOTHREAD - 0x20000000 - - ) - -37  - #__WALL - 0x40000000 - - ) - -38  - #__WCLONE - 0x80000000 - - ) - - @/usr/include/bits/waitstatus.h - -20 #ià! -defšed - -_SYS_WAIT_H - && !defšed -_STDLIB_H - - -29  - #__WEXITSTATUS -( -¡©us -è(((¡©usè& 0xff00è>> 8) - - ) - -32  - #__WTERMSIG -( -¡©us -è((¡©usè& 0x7f) - - ) - -35  - #__WSTOPSIG -( -¡©us -è - `__WEXITSTATUS -(¡©us) - - ) - -38  - #__WIFEXITED -( -¡©us -è( - `__WTERMSIG -(¡©usè=ð0) - - ) - -41  - #__WIFSIGNALED -( -¡©us -) \ - -42 (((sigÃd è((( -¡©us -è& 0x7fè+ 1è>> 1è> 0) - - ) - -45  - #__WIFSTOPPED -( -¡©us -è(((¡©usè& 0xffè=ð0x7f) - - ) - -49 #ifdeà -WCONTINUED - - -50  - #__WIFCONTINUED -( -¡©us -è((¡©usè=ð -__W_CONTINUED -) - - ) - -54  - #__WCOREDUMP -( -¡©us -è((¡©usè& -__WCOREFLAG -) - - ) - -57  - #__W_EXITCODE -( -»t -, -sig -è(ԑè<< 8 | (sig)) - - ) - -58  - #__W_STOPCODE -( -sig -è((sigè<< 8 | 0x7f) - - ) - -59  - #__W_CONTINUED - 0xffff - - ) - -60  - #__WCOREFLAG - 0x80 - - ) - -63 #ifdef -__USE_BSD - - -65  - ~<’dŸn.h -> - -67  - uwa™ - - -69  - mw_¡©us -; - -72 #if -__BYTE_ORDER - =ð -__LITTLE_ENDIAN - - -73  - m__w_‹rmsig -:7; - -74  - m__w_cÜedump -:1; - -75  - m__w_»tcode -:8; - -78 #if -__BYTE_ORDER - =ð -__BIG_ENDIAN - - -80  - m__w_»tcode -:8; - -81  - m__w_cÜedump -:1; - -82  - m__w_‹rmsig -:7; - -84 } - m__wa™_‹rmš©ed -; - -87 #if -__BYTE_ORDER - =ð -__LITTLE_ENDIAN - - -88  - m__w_¡Ýv® -:8; - -89  - m__w_¡Ýsig -:8; - -92 #if -__BYTE_ORDER - =ð -__BIG_ENDIAN - - -94  - m__w_¡Ýsig -:8; - -95  - m__w_¡Ýv® -:8; - -97 } - m__wa™_¡Ý³d -; - -100  - #w_‹rmsig - -__wa™_‹rmš©ed -. -__w_‹rmsig - - - ) - -101  - #w_cÜedump - -__wa™_‹rmš©ed -. -__w_cÜedump - - - ) - -102  - #w_»tcode - -__wa™_‹rmš©ed -. -__w_»tcode - - - ) - -103  - #w_¡Ýsig - -__wa™_¡Ý³d -. -__w_¡Ýsig - - - ) - -104  - #w_¡Ýv® - -__wa™_¡Ý³d -. -__w_¡Ýv® - - - ) - - @/usr/include/bits/wordsize.h - -3 #ià -defšed - -__x86_64__ - - -4  - #__WORDSIZE - 64 - - ) - -5  - #__WORDSIZE_COMPAT32 - 1 - - ) - -7  - #__WORDSIZE - 32 - - ) - - @/usr/include/endian.h - -19 #iâdef -_ENDIAN_H - - -20  - #_ENDIAN_H - 1 - - ) - -22  - ~<ã©u»s.h -> - -32  - #__LITTLE_ENDIAN - 1234 - - ) - -33  - #__BIG_ENDIAN - 4321 - - ) - -34  - #__PDP_ENDIAN - 3412 - - ) - -37  - ~ - -41 #iâdeà -__FLOAT_WORD_ORDER - - -42  - #__FLOAT_WORD_ORDER - -__BYTE_ORDER - - - ) - -45 #ifdef -__USE_BSD - - -46  - #LITTLE_ENDIAN - -__LITTLE_ENDIAN - - - ) - -47  - #BIG_ENDIAN - -__BIG_ENDIAN - - - ) - -48  - #PDP_ENDIAN - -__PDP_ENDIAN - - - ) - -49  - #BYTE_ORDER - -__BYTE_ORDER - - - ) - -52 #ià -__BYTE_ORDER - =ð -__LITTLE_ENDIAN - - -53  - #__LONG_LONG_PAIR -( -HI -, -LO -èLO, - ) -HI - -54 #–ià -__BYTE_ORDER - =ð -__BIG_ENDIAN - - -55  - #__LONG_LONG_PAIR -( -HI -, -LO -èHI, - ) -LO - -59 #ifdeà -__USE_BSD - - -61  - ~ - -63 #ià -__BYTE_ORDER - =ð -__LITTLE_ENDIAN - - -64  - #htobe16 -( -x -è - `__bsw­_16 - (x) - - ) - -65  - #htÞe16 -( -x -è(x) - - ) - -66  - #be16toh -( -x -è - `__bsw­_16 - (x) - - ) - -67  - #Ë16toh -( -x -è(x) - - ) - -69  - #htobe32 -( -x -è - `__bsw­_32 - (x) - - ) - -70  - #htÞe32 -( -x -è(x) - - ) - -71  - #be32toh -( -x -è - `__bsw­_32 - (x) - - ) - -72  - #Ë32toh -( -x -è(x) - - ) - -74  - #htobe64 -( -x -è - `__bsw­_64 - (x) - - ) - -75  - #htÞe64 -( -x -è(x) - - ) - -76  - #be64toh -( -x -è - `__bsw­_64 - (x) - - ) - -77  - #Ë64toh -( -x -è(x) - - ) - -79  - #htobe16 -( -x -è(x) - - ) - -80  - #htÞe16 -( -x -è - `__bsw­_16 - (x) - - ) - -81  - #be16toh -( -x -è(x) - - ) - -82  - #Ë16toh -( -x -è - `__bsw­_16 - (x) - - ) - -84  - #htobe32 -( -x -è(x) - - ) - -85  - #htÞe32 -( -x -è - `__bsw­_32 - (x) - - ) - -86  - #be32toh -( -x -è(x) - - ) - -87  - #Ë32toh -( -x -è - `__bsw­_32 - (x) - - ) - -89  - #htobe64 -( -x -è(x) - - ) - -90  - #htÞe64 -( -x -è - `__bsw­_64 - (x) - - ) - -91  - #be64toh -( -x -è(x) - - ) - -92  - #Ë64toh -( -x -è - `__bsw­_64 - (x) - - ) - - @/usr/include/features.h - -20 #iâdef -_FEATURES_H - - -21  - #_FEATURES_H - 1 - - ) - -97 #undeà -__USE_ISOC99 - - -98 #undeà -__USE_ISOC95 - - -99 #undeà -__USE_POSIX - - -100 #undeà -__USE_POSIX2 - - -101 #undeà -__USE_POSIX199309 - - -102 #undeà -__USE_POSIX199506 - - -103 #undeà -__USE_XOPEN - - -104 #undeà -__USE_XOPEN_EXTENDED - - -105 #undeà -__USE_UNIX98 - - -106 #undeà -__USE_XOPEN2K - - -107 #undeà -__USE_XOPEN2KXSI - - -108 #undeà -__USE_XOPEN2K8 - - -109 #undeà -__USE_XOPEN2K8XSI - - -110 #undeà -__USE_LARGEFILE - - -111 #undeà -__USE_LARGEFILE64 - - -112 #undeà -__USE_FILE_OFFSET64 - - -113 #undeà -__USE_BSD - - -114 #undeà -__USE_SVID - - -115 #undeà -__USE_MISC - - -116 #undeà -__USE_ATFILE - - -117 #undeà -__USE_GNU - - -118 #undeà -__USE_REENTRANT - - -119 #undeà -__USE_FORTIFY_LEVEL - - -120 #undeà -__FAVOR_BSD - - -121 #undeà -__KERNEL_STRICT_NAMES - - -125 #iâdeà -_LOOSE_KERNEL_NAMES - - -126  - #__KERNEL_STRICT_NAMES - - - ) - -130  - #__USE_ANSI - 1 - - ) - -139 #ià -defšed - -__GNUC__ - && defšed -__GNUC_MINOR__ - - -140  - #__GNUC_PREREQ -( -maj -, -mš -) \ - -141 (( -__GNUC__ - << 16è+ -__GNUC_MINOR__ - >ð(( -maj -è<< 16è+ ( -mš -)) - - ) - -143  - #__GNUC_PREREQ -( -maj -, -mš -è0 - - ) - -148 #ià -defšed - -_BSD_SOURCE - && \ - -149 !( -defšed - - g_POSIX_SOURCE - || defšed - g_POSIX_C_SOURCE - || \ - -150 -defšed - - g_XOPEN_SOURCE - || defšed - g_GNU_SOURCE - || defšed - g_SVID_SOURCE -) - -151  - #__FAVOR_BSD - 1 - - ) - -155 #ifdeà -_GNU_SOURCE - - -156 #undeà -_ISOC95_SOURCE - - -157  - #_ISOC95_SOURCE - 1 - - ) - -158 #undeà -_ISOC99_SOURCE - - -159  - #_ISOC99_SOURCE - 1 - - ) - -160 #undeà -_POSIX_SOURCE - - -161  - #_POSIX_SOURCE - 1 - - ) - -162 #undeà -_POSIX_C_SOURCE - - -163  - #_POSIX_C_SOURCE - 200809L - - ) - -164 #undeà -_XOPEN_SOURCE - - -165  - #_XOPEN_SOURCE - 700 - - ) - -166 #undeà -_XOPEN_SOURCE_EXTENDED - - -167  - #_XOPEN_SOURCE_EXTENDED - 1 - - ) - -168 #undeà -_LARGEFILE64_SOURCE - - -169  - #_LARGEFILE64_SOURCE - 1 - - ) - -170 #undeà -_BSD_SOURCE - - -171  - #_BSD_SOURCE - 1 - - ) - -172 #undeà -_SVID_SOURCE - - -173  - #_SVID_SOURCE - 1 - - ) - -174 #undeà -_ATFILE_SOURCE - - -175  - #_ATFILE_SOURCE - 1 - - ) - -180 #ià(! -defšed - -__STRICT_ANSI__ - && !defšed -_ISOC99_SOURCE - && \ - -181 ! -defšed - - g_POSIX_SOURCE - && !defšed - g_POSIX_C_SOURCE - && \ - -182 ! -defšed - - g_XOPEN_SOURCE - && !defšed - g_BSD_SOURCE - && !defšed - g_SVID_SOURCE -) - -183  - #_BSD_SOURCE - 1 - - ) - -184  - #_SVID_SOURCE - 1 - - ) - -191 #ià( -defšed - -_ISOC99_SOURCE - || defšed -_ISOC9X_SOURCE - \ - -192 || ( -defšed - - g__STDC_VERSION__ - && __STDC_VERSION__ >= 199901L)) - -193  - #__USE_ISOC99 - 1 - - ) - -197 #ià( -defšed - -_ISOC99_SOURCE - || defšed -_ISOC9X_SOURCE - \ - -198 || ( -defšed - -__STDC_VERSION__ - && __STDC_VERSION__ >= 199409L)) - -199  - #__USE_ISOC95 - 1 - - ) - -204 #ià((! -defšed - -__STRICT_ANSI__ - || ( -_XOPEN_SOURCE - - 0) >= 500) && \ - -205 ! -defšed - -_POSIX_SOURCE - && !defšed -_POSIX_C_SOURCE -) - -206  - #_POSIX_SOURCE - 1 - - ) - -207 #ià -defšed - -_XOPEN_SOURCE - && (_XOPEN_SOURCE - 0) < 500 - -208  - #_POSIX_C_SOURCE - 2 - - ) - -209 #–ià -defšed - -_XOPEN_SOURCE - && (_XOPEN_SOURCE - 0) < 600 - -210  - #_POSIX_C_SOURCE - 199506L - - ) - -211 #–ià -defšed - -_XOPEN_SOURCE - && (_XOPEN_SOURCE - 0) < 700 - -212  - #_POSIX_C_SOURCE - 200112L - - ) - -214  - #_POSIX_C_SOURCE - 200809L - - ) - -216  - #__USE_POSIX_IMPLICITLY - 1 - - ) - -219 #ià -defšed - -_POSIX_SOURCE - || -_POSIX_C_SOURCE - >ð1 || defšed -_XOPEN_SOURCE - - -220  - #__USE_POSIX - 1 - - ) - -223 #ià -defšed - -_POSIX_C_SOURCE - && _POSIX_C_SOURCE >ð2 || defšed -_XOPEN_SOURCE - - -224  - #__USE_POSIX2 - 1 - - ) - -227 #ià( -_POSIX_C_SOURCE - - 0) >= 199309L - -228  - #__USE_POSIX199309 - 1 - - ) - -231 #ià( -_POSIX_C_SOURCE - - 0) >= 199506L - -232  - #__USE_POSIX199506 - 1 - - ) - -235 #ià( -_POSIX_C_SOURCE - - 0) >= 200112L - -236  - #__USE_XOPEN2K - 1 - - ) - -237 #undeà -__USE_ISOC95 - - -238  - #__USE_ISOC95 - 1 - - ) - -239 #undeà -__USE_ISOC99 - - -240  - #__USE_ISOC99 - 1 - - ) - -243 #ià( -_POSIX_C_SOURCE - - 0) >= 200809L - -244  - #__USE_XOPEN2K8 - 1 - - ) - -245 #undeà -_ATFILE_SOURCE - - -246  - #_ATFILE_SOURCE - 1 - - ) - -249 #ifdef -_XOPEN_SOURCE - - -250  - #__USE_XOPEN - 1 - - ) - -251 #ià( -_XOPEN_SOURCE - - 0) >= 500 - -252  - #__USE_XOPEN_EXTENDED - 1 - - ) - -253  - #__USE_UNIX98 - 1 - - ) - -254 #undeà -_LARGEFILE_SOURCE - - -255  - #_LARGEFILE_SOURCE - 1 - - ) - -256 #ià( -_XOPEN_SOURCE - - 0) >= 600 - -257 #ià( -_XOPEN_SOURCE - - 0) >= 700 - -258  - #__USE_XOPEN2K8 - 1 - - ) - -259  - #__USE_XOPEN2K8XSI - 1 - - ) - -261  - #__USE_XOPEN2K - 1 - - ) - -262  - #__USE_XOPEN2KXSI - 1 - - ) - -263 #undeà -__USE_ISOC95 - - -264  - #__USE_ISOC95 - 1 - - ) - -265 #undeà -__USE_ISOC99 - - -266  - #__USE_ISOC99 - 1 - - ) - -269 #ifdeà -_XOPEN_SOURCE_EXTENDED - - -270  - #__USE_XOPEN_EXTENDED - 1 - - ) - -275 #ifdeà -_LARGEFILE_SOURCE - - -276  - #__USE_LARGEFILE - 1 - - ) - -279 #ifdeà -_LARGEFILE64_SOURCE - - -280  - #__USE_LARGEFILE64 - 1 - - ) - -283 #ià -defšed - -_FILE_OFFSET_BITS - && _FILE_OFFSET_BITS == 64 - -284  - #__USE_FILE_OFFSET64 - 1 - - ) - -287 #ià -defšed - -_BSD_SOURCE - || defšed -_SVID_SOURCE - - -288  - #__USE_MISC - 1 - - ) - -291 #ifdef -_BSD_SOURCE - - -292  - #__USE_BSD - 1 - - ) - -295 #ifdef -_SVID_SOURCE - - -296  - #__USE_SVID - 1 - - ) - -299 #ifdef -_ATFILE_SOURCE - - -300  - #__USE_ATFILE - 1 - - ) - -303 #ifdef -_GNU_SOURCE - - -304  - #__USE_GNU - 1 - - ) - -307 #ià -defšed - -_REENTRANT - || defšed -_THREAD_SAFE - - -308  - #__USE_REENTRANT - 1 - - ) - -311 #ià -defšed - -_FORTIFY_SOURCE - && _FORTIFY_SOURCE > 0 \ - -312 && -__GNUC_PREREQ - (4, 1è&& -defšed - - g__OPTIMIZE__ - && __OPTIMIZE__ > 0 - -313 #ià -_FORTIFY_SOURCE - > 1 - -314  - #__USE_FORTIFY_LEVEL - 2 - - ) - -316  - #__USE_FORTIFY_LEVEL - 1 - - ) - -319  - #__USE_FORTIFY_LEVEL - 0 - - ) - -323  - ~ - -326  - #__STDC_ISO_10646__ - 200009L - - ) - -334 #undeà -__GNU_LIBRARY__ - - -335  - #__GNU_LIBRARY__ - 6 - - ) - -339  - #__GLIBC__ - 2 - - ) - -340  - #__GLIBC_MINOR__ - 13 - - ) - -342  - #__GLIBC_PREREQ -( -maj -, -mš -) \ - -343 (( -__GLIBC__ - << 16è+ -__GLIBC_MINOR__ - >ð(( -maj -è<< 16è+ ( -mš -)) - - ) - -346 #ià -defšed - -__GNUC__ - \ - -347 || ( -defšed - - g__PGI - && defšed - g__i386__ - ) \ - -348 || ( -defšed - - g__INTEL_COMPILER - && (defšed - g__i386__ - || defšed - g__Ÿ64__ -)) \ - -349 || ( -defšed - - g__STDC_VERSION__ - && __STDC_VERSION__ >= 199901L) - -350  - #__GLIBC_HAVE_LONG_LONG - 1 - - ) - -354 #iâdeà -__ASSEMBLER__ - - -355 #iâdeà -_SYS_CDEFS_H - - -356  - ~ - -361 #ià -defšed - -__USE_FILE_OFFSET64 - && !defšed -__REDIRECT - - -362  - #__USE_LARGEFILE - 1 - - ) - -363  - #__USE_LARGEFILE64 - 1 - - ) - -369 #ià -__GNUC_PREREQ - (2, 7è&& -defšed - -__OPTIMIZE__ - \ - -370 && ! -defšed - - g__OPTIMIZE_SIZE__ - && !defšed - g__NO_INLINE__ - \ - -371 && -defšed - - g__ex‹º_šlše - - -372  - #__USE_EXTERN_INLINES - 1 - - ) - -377 #ià -__GNUC_PREREQ - (2, 7è&& -defšed - -__OPTIMIZE__ - \ - -378 && ( -defšed - - g_LIBC - || !defšed - g__OPTIMIZE_SIZE__ -è&& !defšed - g__NO_INLINE__ - \ - -379 && -defšed - - g__ex‹º_šlše - - -380  - #__USE_EXTERN_INLINES_IN_LIBC - 1 - - ) - -388  - ~ - - @/usr/include/getopt.h - -21 #iâdeà -_GETOPT_H - - -23 #iâdeà -__Ãed_g‘Ýt - - -24  - #_GETOPT_H - 1 - - ) - -34 #ià! -defšed - -__GNU_LIBRARY__ - - -35  - ~<ùy³.h -> - -38 #iâdeà -__THROW - - -39 #iâdeà -__GNUC_PREREQ - - -40  - #__GNUC_PREREQ -( -maj -, -mš -è(0) - - ) - -42 #ià -defšed - -__ýlu¥lus - && -__GNUC_PREREQ - (2,8) - -43  - #__THROW - - `throw - () - - ) - -45  - #__THROW - - - ) - -49 #ifdef -__ýlu¥lus - - -59 * -ݏrg -; - -73  -Ýtšd -; - -78  -݋¼ -; - -82  -ÝtÝt -; - -84 #iâdeà -__Ãed_g‘Ýt - - -106  - sÝtiÚ - - -108 cÚ¡ * - gÇme -; - -111  - ghas_¬g -; - -112 * - gæag -; - -113  - gv® -; - -118  - #no_¬gum’t - 0 - - ) - -119  - #»quœed_¬gum’t - 1 - - ) - -120  - #ÝtiÚ®_¬gum’t - 2 - - ) - -148 #ifdeà -__GNU_LIBRARY__ - - -152  -g‘Ýt - ( -___¬gc -, *cÚ¡ * -___¬gv -, cÚ¡ * -__shÜtÝts -) - -153 -__THROW -; - -155 #ià -defšed - -__Ãed_g‘Ýt - && defšed -__USE_POSIX2 - \ - -156 && ! -defšed - - g__USE_POSIX_IMPLICITLY - && !defšed - g__USE_GNU - - -160 #ifdeà -__REDIRECT - - -161  -__REDIRECT_NTH - ( -g‘Ýt -, ( -___¬gc -, *cÚ¡ * -___¬gv -, - -162 cÚ¡ * -__shÜtÝts -), - -163 -__posix_g‘Ýt -); - -165  -__posix_g‘Ýt - ( -___¬gc -, *cÚ¡ * -___¬gv -, - -166 cÚ¡ * -__shÜtÝts -è -__THROW -; - -167  - #g‘Ýt - -__posix_g‘Ýt - - - ) - -171  -g‘Ýt - (); - -174 #iâdeà -__Ãed_g‘Ýt - - -175  -g‘Ýt_lÚg - ( -___¬gc -, *cÚ¡ * -___¬gv -, - -176 cÚ¡ * -__shÜtÝts -, - -177 cÚ¡  -ÝtiÚ - * -__lÚgÝts -, * -__lÚgšd -) - -178 -__THROW -; - -179  -g‘Ýt_lÚg_Úly - ( -___¬gc -, *cÚ¡ * -___¬gv -, - -180 cÚ¡ * -__shÜtÝts -, - -181 cÚ¡  -ÝtiÚ - * -__lÚgÝts -, * -__lÚgšd -) - -182 -__THROW -; - -186 #ifdef -__ýlu¥lus - - -191 #undeà -__Ãed_g‘Ýt - - - @/usr/include/libio.h - -29 #iâdeà -_IO_STDIO_H - - -30  - #_IO_STDIO_H - - - ) - -32  - ~<_G_cÚfig.h -> - -34  - #_IO_pos_t - -_G_åos_t - - - ) - -35  - #_IO_åos_t - -_G_åos_t - - - ) - -36  - #_IO_åos64_t - -_G_åos64_t - - - ) - -37  - #_IO_size_t - -_G_size_t - - - ) - -38  - #_IO_ssize_t - -_G_ssize_t - - - ) - -39  - #_IO_off_t - -_G_off_t - - - ) - -40  - #_IO_off64_t - -_G_off64_t - - - ) - -41  - #_IO_pid_t - -_G_pid_t - - - ) - -42  - #_IO_uid_t - -_G_uid_t - - - ) - -43  - #_IO_icÚv_t - -_G_icÚv_t - - - ) - -44  - #_IO_HAVE_SYS_WAIT - -_G_HAVE_SYS_WAIT - - - ) - -45  - #_IO_HAVE_ST_BLKSIZE - -_G_HAVE_ST_BLKSIZE - - - ) - -46  - #_IO_BUFSIZ - -_G_BUFSIZ - - - ) - -47  - #_IO_va_li¡ - -_G_va_li¡ - - - ) - -48  - #_IO_wšt_t - -_G_wšt_t - - - ) - -50 #ifdeà -_G_NEED_STDARG_H - - -52  - #__Ãed___va_li¡ - - - ) - -53  - ~<¡d¬g.h -> - -54 #ifdeà -__GNUC_VA_LIST - - -55 #undeà -_IO_va_li¡ - - -56  - #_IO_va_li¡ - -__gnuc_va_li¡ - - - ) - -60 #iâdeà -__P - - -61 #ià -_G_HAVE_SYS_CDEFS - - -62  - ~ - -64 #ifdeà -__STDC__ - - -65  - #__P -( -p -è - ) -p - -66  - #__PMT -( -p -è - ) -p - -68  - #__P -( -p -è() - - ) - -69  - #__PMT -( -p -è() - - ) - -75 #iâdeà -_PARAMS - - -76  - #_PARAMS -( -´Ùos -è - `__P -ÕrÙos) - - ) - -79 #iâdeà -__STDC__ - - -81 cÚ¡ - - ) - -84  - #_IO_UNIFIED_JUMPTABLES - 1 - - ) - -85 #iâdeà -_G_HAVE_PRINTF_FP - - -86  - #_IO_USE_DTOA - 1 - - ) - -89 #iâdeà -EOF - - -90  - #EOF - (-1) - - ) - -92 #iâdeà -NULL - - -93 #ià -defšed - -__GNUG__ - && \ - -94 ( - g__GNUC__ - > 2 || (__GNUC__ =ð2 && -__GNUC_MINOR__ - >= 8)) - -95  - #NULL - ( -__nuÎ -) - - ) - -97 #ià! -defšed -( -__ýlu¥lus -) - -98  - #NULL - ((*)0) - - ) - -100  - #NULL - (0) - - ) - -105  - #_IOS_INPUT - 1 - - ) - -106  - #_IOS_OUTPUT - 2 - - ) - -107  - #_IOS_ATEND - 4 - - ) - -108  - #_IOS_APPEND - 8 - - ) - -109  - #_IOS_TRUNC - 16 - - ) - -110  - #_IOS_NOCREATE - 32 - - ) - -111  - #_IOS_NOREPLACE - 64 - - ) - -112  - #_IOS_BIN - 128 - - ) - -120  - #_IO_MAGIC - 0xFBAD0000 - - ) - -121  - #_OLD_STDIO_MAGIC - 0xFABC0000 - - ) - -122  - #_IO_MAGIC_MASK - 0xFFFF0000 - - ) - -123  - #_IO_USER_BUF - 1 - - ) - -124  - #_IO_UNBUFFERED - 2 - - ) - -125  - #_IO_NO_READS - 4 - - ) - -126  - #_IO_NO_WRITES - 8 - - ) - -127  - #_IO_EOF_SEEN - 0x10 - - ) - -128  - #_IO_ERR_SEEN - 0x20 - - ) - -129  - #_IO_DELETE_DONT_CLOSE - 0x40 - - ) - -130  - #_IO_LINKED - 0x80 - - ) - -131  - #_IO_IN_BACKUP - 0x100 - - ) - -132  - #_IO_LINE_BUF - 0x200 - - ) - -133  - #_IO_TIED_PUT_GET - 0x400 - - ) - -134  - #_IO_CURRENTLY_PUTTING - 0x800 - - ) - -135  - #_IO_IS_APPENDING - 0x1000 - - ) - -136  - #_IO_IS_FILEBUF - 0x2000 - - ) - -137  - #_IO_BAD_SEEN - 0x4000 - - ) - -138  - #_IO_USER_LOCK - 0x8000 - - ) - -140  - #_IO_FLAGS2_MMAP - 1 - - ) - -141  - #_IO_FLAGS2_NOTCANCEL - 2 - - ) - -142 #ifdeà -_LIBC - - -143  - #_IO_FLAGS2_FORTIFY - 4 - - ) - -145  - #_IO_FLAGS2_USER_WBUF - 8 - - ) - -146 #ifdeà -_LIBC - - -147  - #_IO_FLAGS2_SCANF_STD - 16 - - ) - -151  - #_IO_SKIPWS - 01 - - ) - -152  - #_IO_LEFT - 02 - - ) - -153  - #_IO_RIGHT - 04 - - ) - -154  - #_IO_INTERNAL - 010 - - ) - -155  - #_IO_DEC - 020 - - ) - -156  - #_IO_OCT - 040 - - ) - -157  - #_IO_HEX - 0100 - - ) - -158  - #_IO_SHOWBASE - 0200 - - ) - -159  - #_IO_SHOWPOINT - 0400 - - ) - -160  - #_IO_UPPERCASE - 01000 - - ) - -161  - #_IO_SHOWPOS - 02000 - - ) - -162  - #_IO_SCIENTIFIC - 04000 - - ) - -163  - #_IO_FIXED - 010000 - - ) - -164  - #_IO_UNITBUF - 020000 - - ) - -165  - #_IO_STDIO - 040000 - - ) - -166  - #_IO_DONT_CLOSE - 0100000 - - ) - -167  - #_IO_BOOLALPHA - 0200000 - - ) - -170  -_IO_jump_t -;  - g_IO_FILE -; - -173 #ifdeà -_IO_MTSAFE_IO - - -174 #ià -defšed - -__GLIBC__ - && __GLIBC__ >= 2 - -175  - ~ - -180  - t_IO_lock_t -; - -186  - s_IO_m¬k” - { - -187  -_IO_m¬k” - * - m_Ãxt -; - -188  -_IO_FILE - * - m_sbuf -; - -192  - m_pos -; - -194  -£t_¡»ampos -( -¡»ampos - -¥ -è{ - m_¥os - = sp; } - -195  -£t_off£t -( -off£t -è{ - m_pos - = off£t; - m_¥os - = ( -¡»ampos -)(-2); } - -196 - mpublic -: - -197 -¡»amm¬k” -( -¡»ambuf - * -sb -); - -198 ~ -¡»amm¬k” -(); - -199  -§všg -(è{  - m_¥os - == -2; } - -200  -d– -( -¡»amm¬k” -&); - -201  -d– -(); - -206 - e__codecvt_»suÉ - - -208 - m__codecvt_ok -, - -209 - m__codecvt_·¹Ÿl -, - -210 - m__codecvt_”rÜ -, - -211 - m__codecvt_nocÚv - - -214 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -217  - s_IO_codecvt - - -219 (* - m__codecvt_de¡r -è( - m_IO_codecvt - *); - -220 -__codecvt_»suÉ - (* -__codecvt_do_out -è( - m_IO_codecvt - *, - -221 - m__mb¡©e_t - *, - -222 cÚ¡ - mwch¬_t - *, - -223 cÚ¡ - mwch¬_t - *, - -224 cÚ¡ - mwch¬_t - **, *, - -226 -__codecvt_»suÉ - (* -__codecvt_do_unshiá -è( - m_IO_codecvt - *, - -227 - m__mb¡©e_t - *, *, - -229 -__codecvt_»suÉ - (* -__codecvt_do_š -è( - m_IO_codecvt - *, - -230 - m__mb¡©e_t - *, - -232 cÚ¡ **, - mwch¬_t - *, - -233 - mwch¬_t - *, wchar_t **); - -234 (* - m__codecvt_do_’codšg -è( - m_IO_codecvt - *); - -235 (* - m__codecvt_do_®ways_nocÚv -è( - m_IO_codecvt - *); - -236 (* - m__codecvt_do_Ëngth -è( - m_IO_codecvt - *, - m__mb¡©e_t - *, - -237 cÚ¡ *, cÚ¡ *, - m_IO_size_t -); - -238 (* - m__codecvt_do_max_Ëngth -è( - m_IO_codecvt - *); - -240 -_IO_icÚv_t - - m__cd_š -; - -241 -_IO_icÚv_t - - m__cd_out -; - -245  - s_IO_wide_d©a - - -247 -wch¬_t - * - m_IO_»ad_±r -; - -248 -wch¬_t - * - m_IO_»ad_’d -; - -249 -wch¬_t - * - m_IO_»ad_ba£ -; - -250 -wch¬_t - * - m_IO_wr™e_ba£ -; - -251 -wch¬_t - * - m_IO_wr™e_±r -; - -252 -wch¬_t - * - m_IO_wr™e_’d -; - -253 -wch¬_t - * - m_IO_buf_ba£ -; - -254 -wch¬_t - * - m_IO_buf_’d -; - -256 -wch¬_t - * - m_IO_§ve_ba£ -; - -257 -wch¬_t - * - m_IO_backup_ba£ -; - -259 -wch¬_t - * - m_IO_§ve_’d -; - -261 -__mb¡©e_t - - m_IO_¡©e -; - -262 -__mb¡©e_t - - m_IO_Ï¡_¡©e -; - -263  -_IO_codecvt - - m_codecvt -; - -265 -wch¬_t - - m_shÜtbuf -[1]; - -267 cÚ¡  -_IO_jump_t - * - m_wide_vbË -; - -271  - s_IO_FILE - { - -272  - m_æags -; - -273  - #_IO_fže_æags - -_æags - - - ) - -277 * - m_IO_»ad_±r -; - -278 * - m_IO_»ad_’d -; - -279 * - m_IO_»ad_ba£ -; - -280 * - m_IO_wr™e_ba£ -; - -281 * - m_IO_wr™e_±r -; - -282 * - m_IO_wr™e_’d -; - -283 * - m_IO_buf_ba£ -; - -284 * - m_IO_buf_’d -; - -286 * - m_IO_§ve_ba£ -; - -287 * - m_IO_backup_ba£ -; - -288 * - m_IO_§ve_’d -; - -290  -_IO_m¬k” - * - m_m¬k”s -; - -292  -_IO_FILE - * - m_chaš -; - -294  - m_fž’o -; - -296  - m_blksize -; - -298  - m_æags2 -; - -300 -_IO_off_t - - m_Þd_off£t -; - -302  - #__HAVE_COLUMN - - - ) - -304  - m_cur_cÞumn -; - -305 sigÃd  - m_vbË_off£t -; - -306  - m_shÜtbuf -[1]; - -310 -_IO_lock_t - * - m_lock -; - -311 #ifdeà -_IO_USE_OLD_IO_FILE - - -314  - s_IO_FILE_com¶‘e - - -316  -_IO_FILE - - m_fže -; - -318 #ià -defšed - -_G_IO_IO_FILE_VERSION - && _G_IO_IO_FILE_VERSION == 0x20001 - -319 -_IO_off64_t - - m_off£t -; - -320 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -322  -_IO_codecvt - * - m_codecvt -; - -323  -_IO_wide_d©a - * - m_wide_d©a -; - -324  -_IO_FILE - * - m_䓻s_li¡ -; - -325 * - m_䓻s_buf -; - -326 -size_t - - m_䓻s_size -; - -328 * - m__·d1 -; - -329 * - m__·d2 -; - -330 * - m__·d3 -; - -331 * - m__·d4 -; - -332 -size_t - - m__·d5 -; - -334  - m_mode -; - -336  - m_unu£d2 -[15 *  (è- 4 *  (*è-  ( -size_t -)]; - -340 #iâdeà -__ýlu¥lus - - -341  -_IO_FILE - - t_IO_FILE -; - -344  - g_IO_FILE_¶us -; - -346  -_IO_FILE_¶us - -_IO_2_1_¡dš_ -; - -347  -_IO_FILE_¶us - -_IO_2_1_¡dout_ -; - -348  -_IO_FILE_¶us - -_IO_2_1_¡d”r_ -; - -349 #iâdeà -_LIBC - - -350  - #_IO_¡dš - (( -_IO_FILE -*)(& -_IO_2_1_¡dš_ -)) - - ) - -351  - #_IO_¡dout - (( -_IO_FILE -*)(& -_IO_2_1_¡dout_ -)) - - ) - -352  - #_IO_¡d”r - (( -_IO_FILE -*)(& -_IO_2_1_¡d”r_ -)) - - ) - -354 -_IO_FILE - * -_IO_¡dš - -©Œibu‹_hidd’ -; - -355 -_IO_FILE - * -_IO_¡dout - -©Œibu‹_hidd’ -; - -356 -_IO_FILE - * -_IO_¡d”r - -©Œibu‹_hidd’ -; - -364  -__ssize_t - - t__io_»ad_â - (* - t__cook› -, * - t__buf -, - tsize_t - - t__nby‹s -); - -372  -__ssize_t - - t__io_wr™e_â - (* - t__cook› -, - t__cÚ¡ - * - t__buf -, - -373 - tsize_t - - t__n -); - -381  - t__io_£ek_â - (* - t__cook› -, - t_IO_off64_t - * - t__pos -,  - t__w -); - -384  - t__io_þo£_â - (* - t__cook› -); - -387 #ifdeà -_GNU_SOURCE - - -389  -__io_»ad_â - - tcook›_»ad_funùiÚ_t -; - -390  -__io_wr™e_â - - tcook›_wr™e_funùiÚ_t -; - -391  -__io_£ek_â - - tcook›_£ek_funùiÚ_t -; - -392  -__io_þo£_â - - tcook›_þo£_funùiÚ_t -; - -397 -__io_»ad_â - * - m»ad -; - -398 -__io_wr™e_â - * - mwr™e -; - -399 -__io_£ek_â - * - m£ek -; - -400 -__io_þo£_â - * - mþo£ -; - -401 } - t_IO_cook›_io_funùiÚs_t -; - -402  -_IO_cook›_io_funùiÚs_t - - tcook›_io_funùiÚs_t -; - -404  - g_IO_cook›_fže -; - -407  -_IO_cook›_š™ - ( -_IO_cook›_fže - * -__cfže -,  -__»ad_wr™e -, - -408 * -__cook› -, -_IO_cook›_io_funùiÚs_t - -__âs -); - -412 #ifdeà -__ýlu¥lus - - -416  -__und”æow - ( -_IO_FILE - *); - -417  -__uæow - ( -_IO_FILE - *); - -418  -__ov”æow - ( -_IO_FILE - *, ); - -419 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -420 -_IO_wšt_t - -__wund”æow - ( -_IO_FILE - *); - -421 -_IO_wšt_t - -__wuæow - ( -_IO_FILE - *); - -422 -_IO_wšt_t - -__wov”æow - ( -_IO_FILE - *, _IO_wint_t); - -425 #ià -__GNUC__ - >= 3 - -426  - #_IO_BE -( -ex´ -, -»s -è - `__bužtš_ex³ù - (Óx´),„es) - - ) - -428  - #_IO_BE -( -ex´ -, -»s -èÓx´) - - ) - -431  - #_IO_g‘c_uÆocked -( -_å -) \ - -432 ( - `_IO_BE - (( -_å -)-> -_IO_»ad_±r - >ð(_å)-> -_IO_»ad_’d -, 0) \ - -433 ? - `__uæow - ( -_å -è: *(*è(_å)-> -_IO_»ad_±r -++) - - ) - -434  - #_IO_³ekc_uÆocked -( -_å -) \ - -435 ( - `_IO_BE - (( -_å -)-> -_IO_»ad_±r - >ð(_å)-> -_IO_»ad_’d -, 0) \ - -436 && - `__und”æow - ( -_å -è=ð -EOF - ? EOF \ - -437 : *(*è( -_å -)-> -_IO_»ad_±r -) - - ) - -438  - #_IO_putc_uÆocked -( -_ch -, -_å -) \ - -439 ( - `_IO_BE - (( -_å -)-> -_IO_wr™e_±r - >ð(_å)-> -_IO_wr™e_’d -, 0) \ - -440 ? - `__ov”æow - ( -_å -, (è( -_ch -)) \ - -441 : (è(*( -_å -)-> -_IO_wr™e_±r -++ = ( -_ch -))) - - ) - -443 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -444  - #_IO_g‘wc_uÆocked -( -_å -) \ - -445 ( - `_IO_BE - (( -_å -)-> -_wide_d©a - =ð -NULL - \ - -446 || (( -_å -)-> -_wide_d©a --> -_IO_»ad_±r - \ - -447 >ð( -_å -)-> -_wide_d©a --> -_IO_»ad_’d -), 0) \ - -448 ? - `__wuæow - ( -_å -è: ( -_IO_wšt_t -è*(_å)-> -_wide_d©a --> -_IO_»ad_±r -++) - - ) - -449  - #_IO_putwc_uÆocked -( -_wch -, -_å -) \ - -450 ( - `_IO_BE - (( -_å -)-> -_wide_d©a - =ð -NULL - \ - -451 || (( -_å -)-> -_wide_d©a --> -_IO_wr™e_±r - \ - -452 >ð( -_å -)-> -_wide_d©a --> -_IO_wr™e_’d -), 0) \ - -453 ? - `__wov”æow - ( -_å -, -_wch -) \ - -454 : ( -_IO_wšt_t -è(*( -_å -)-> -_wide_d©a --> -_IO_wr™e_±r -++ = ( -_wch -))) - - ) - -457  - #_IO_ãof_uÆocked -( -__å -è(((__å)-> -_æags - & -_IO_EOF_SEEN -è!ð0) - - ) - -458  - #_IO_ã¼Ü_uÆocked -( -__å -è(((__å)-> -_æags - & -_IO_ERR_SEEN -è!ð0) - - ) - -460  -_IO_g‘c - ( -_IO_FILE - * -__å -); - -461  -_IO_putc - ( -__c -, -_IO_FILE - * -__å -); - -462  -_IO_ãof - ( -_IO_FILE - * -__å -è -__THROW -; - -463  -_IO_ã¼Ü - ( -_IO_FILE - * -__å -è -__THROW -; - -465  -_IO_³ekc_locked - ( -_IO_FILE - * -__å -); - -468  - #_IO_PENDING_OUTPUT_COUNT -( -_å -) \ - -469 (( -_å -)-> -_IO_wr™e_±r - - (_å)-> -_IO_wr™e_ba£ -) - - ) - -471  -_IO_æockfže - ( -_IO_FILE - *è -__THROW -; - -472  -_IO_fuÆockfže - ( -_IO_FILE - *è -__THROW -; - -473  -_IO_árylockfže - ( -_IO_FILE - *è -__THROW -; - -475 #ifdeà -_IO_MTSAFE_IO - - -476  - #_IO_³ekc -( -_å -è - `_IO_³ekc_locked - (_å) - - ) - -477  - #_IO_æockfže -( -_å -) \ - -478 ià((( -_å -)-> -_æags - & -_IO_USER_LOCK -è=ð0è - `_IO_æockfže - (_å) - - ) - -479  - #_IO_fuÆockfže -( -_å -) \ - -480 ià((( -_å -)-> -_æags - & -_IO_USER_LOCK -è=ð0è - `_IO_fuÆockfže - (_å) - - ) - -482  - #_IO_³ekc -( -_å -è - `_IO_³ekc_uÆocked - (_å) - - ) - -483  - #_IO_æockfže -( -_å -è - - ) - -484  - #_IO_fuÆockfže -( -_å -è - - ) - -485  - #_IO_árylockfže -( -_å -è - - ) - -486  - #_IO_þ—nup_»giÚ_¡¬t -( -_fù -, -_å -è - - ) - -487  - #_IO_þ—nup_»giÚ_’d -( -_Do™ -è - - ) - -490  -_IO_vfsÿnf - ( -_IO_FILE - * -__»¡riù -, const * __restrict, - -491 -_IO_va_li¡ -, * -__»¡riù -); - -492  -_IO_vårštf - ( -_IO_FILE - * -__»¡riù -, const *__restrict, - -493 -_IO_va_li¡ -); - -494 -_IO_ssize_t - -_IO_·dn - ( -_IO_FILE - *, , _IO_ssize_t); - -495 -_IO_size_t - -_IO_sg‘n - ( -_IO_FILE - *, *, _IO_size_t); - -497 -_IO_off64_t - -_IO_£ekoff - ( -_IO_FILE - *, _IO_off64_t, , ); - -498 -_IO_off64_t - -_IO_£ekpos - ( -_IO_FILE - *, _IO_off64_t, ); - -500  -_IO_ä“_backup_¬— - ( -_IO_FILE - *è -__THROW -; - -502 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -503 -_IO_wšt_t - -_IO_g‘wc - ( -_IO_FILE - * -__å -); - -504 -_IO_wšt_t - -_IO_putwc - ( -wch¬_t - -__wc -, -_IO_FILE - * -__å -); - -505  -_IO_fwide - ( -_IO_FILE - * -__å -,  -__mode -è -__THROW -; - -506 #ià -__GNUC__ - >= 2 - -509 #ià -defšed - -_LIBC - && defšed -SHARED - - -510  - ~ - -511 #ià -SHLIB_COMPAT - ( -libc -, -GLIBC_2_0 -, -GLIBC_2_1 -) - -512  - #_IO_fwide_maybe_šcom·tibË - \ - -513 ( - `__bužtš_ex³ù - (& -_IO_¡dš_u£d - =ð -NULL -, 0)) - - ) - -514 cÚ¡  -_IO_¡dš_u£d -; - -515 -w—k_ex‹º - ( -_IO_¡dš_u£d -); - -518 #iâdeà -_IO_fwide_maybe_šcom·tibË - - -519  - #_IO_fwide_maybe_šcom·tibË - (0) - - ) - -523  - #_IO_fwide -( -__å -, -__mode -) \ - -524 ({  -__»suÉ - = ( -__mode -); \ - -525 ià( -__»suÉ - < 0 && ! -_IO_fwide_maybe_šcom·tibË -) \ - -527 ià(( -__å -)-> -_mode - == 0) \ - -529 ( -__å -)-> -_mode - = -1; \ - -530 -__»suÉ - = ( -__å -)-> -_mode -; \ - -532 ià( - `__bužtš_cÚ¡ªt_p - ( -__mode -) && (__mode) == 0) \ - -533 -__»suÉ - = -_IO_fwide_maybe_šcom·tibË - ? -1 : ( -__å -)-> -_mode -; \ - -535 -__»suÉ - = - `_IO_fwide - ( -__å -, __result); \ - -536 -__»suÉ -; }) - - ) - -539  -_IO_vfwsÿnf - ( -_IO_FILE - * -__»¡riù -, cÚ¡ -wch¬_t - * __restrict, - -540 -_IO_va_li¡ -, * -__»¡riù -); - -541  -_IO_vfw´štf - ( -_IO_FILE - * -__»¡riù -, cÚ¡ -wch¬_t - *__restrict, - -542 -_IO_va_li¡ -); - -543 -_IO_ssize_t - -_IO_w·dn - ( -_IO_FILE - *, -wšt_t -, _IO_ssize_t); - -544  -_IO_ä“_wbackup_¬— - ( -_IO_FILE - *è -__THROW -; - -547 #ifdeà -__LDBL_COMPAT - - -548  - ~ - -551 #ifdeà -__ýlu¥lus - - - @/usr/include/sched.h - -21 #iâdef -_SCHED_H - - -22  - #_SCHED_H - 1 - - ) - -24  - ~<ã©u»s.h -> - -27  - ~ - -29  - #__Ãed_size_t - - - ) - -30  - ~<¡ddef.h -> - -32  - #__Ãed_time_t - - - ) - -33  - #__Ãed_time¥ec - - - ) - -34  - ~ - -36 #iâdeà -__pid_t_defšed - - -37  -__pid_t - - tpid_t -; - -38  - #__pid_t_defšed - - - ) - -43  - ~ - -45  - #sched_´iܙy - -__sched_´iܙy - - - ) - -48 -__BEGIN_DECLS - - -51  - $sched_£¬am - ( -__pid_t - -__pid -, -__cÚ¡ -  -sched_·¿m - * -__·¿m -) - -52 -__THROW -; - -55  - $sched_g‘·¿m - ( -__pid_t - -__pid -,  -sched_·¿m - * -__·¿m -è -__THROW -; - -58  - $sched_£tscheduËr - ( -__pid_t - -__pid -,  -__pÞicy -, - -59 -__cÚ¡ -  -sched_·¿m - * -__·¿m -è -__THROW -; - -62  - $sched_g‘scheduËr - ( -__pid_t - -__pid -è -__THROW -; - -65  - $sched_y›ld - (è -__THROW -; - -68  - $sched_g‘_´iܙy_max - ( -__®gܙhm -è -__THROW -; - -71  - $sched_g‘_´iܙy_mš - ( -__®gܙhm -è -__THROW -; - -74  - $sched_¼_g‘_š‹rv® - ( -__pid_t - -__pid -,  -time¥ec - * -__t -è -__THROW -; - -77 #ifdeà -__USE_GNU - - -79  - #CPU_SETSIZE - -__CPU_SETSIZE - - - ) - -80  - #CPU_SET -( -ýu -, -ýu£ -è - `__CPU_SET_S - (ýu,  ( -ýu_£t_t -), cpu£) - - ) - -81  - #CPU_CLR -( -ýu -, -ýu£ -è - `__CPU_CLR_S - (ýu,  ( -ýu_£t_t -), cpu£) - - ) - -82  - #CPU_ISSET -( -ýu -, -ýu£ -è - `__CPU_ISSET_S - (ýu,  ( -ýu_£t_t -), \ - -83 -ýu£ -) - - ) - -84  - #CPU_ZERO -( -ýu£ -è - `__CPU_ZERO_S - ( ( -ýu_£t_t -), cpu£) - - ) - -85  - #CPU_COUNT -( -ýu£ -è - `__CPU_COUNT_S - ( ( -ýu_£t_t -), cpu£) - - ) - -87  - #CPU_SET_S -( -ýu -, -£tsize -, -ýu£ -è - `__CPU_SET_S - (ýu, s‘size, cpu£) - - ) - -88  - #CPU_CLR_S -( -ýu -, -£tsize -, -ýu£ -è - `__CPU_CLR_S - (ýu, s‘size, cpu£) - - ) - -89  - #CPU_ISSET_S -( -ýu -, -£tsize -, -ýu£ -è - `__CPU_ISSET_S - (cpu, setsize, \ - -90 -ýu£ -) - - ) - -91  - #CPU_ZERO_S -( -£tsize -, -ýu£ -è - `__CPU_ZERO_S - (£tsize, cpu£) - - ) - -92  - #CPU_COUNT_S -( -£tsize -, -ýu£ -è - `__CPU_COUNT_S - (£tsize, cpu£) - - ) - -94  - #CPU_EQUAL -( -ýu£1 -, -ýu£2 -) \ - -95 - `__CPU_EQUAL_S - ( ( -ýu_£t_t -), -ýu£1 -, -ýu£2 -) - - ) - -96  - #CPU_EQUAL_S -( -£tsize -, -ýu£1 -, -ýu£2 -) \ - -97 - `__CPU_EQUAL_S - ( -£tsize -, -ýu£1 -, -ýu£2 -) - - ) - -99  - #CPU_AND -( -de¡£t -, -¤c£t1 -, -¤c£t2 -) \ - -100 - `__CPU_OP_S - ( ( -ýu_£t_t -), -de¡£t -, -¤c£t1 -, -¤c£t2 -, &) - - ) - -101  - #CPU_OR -( -de¡£t -, -¤c£t1 -, -¤c£t2 -) \ - -102 - `__CPU_OP_S - ( ( -ýu_£t_t -), -de¡£t -, -¤c£t1 -, -¤c£t2 -, |) - - ) - -103  - #CPU_XOR -( -de¡£t -, -¤c£t1 -, -¤c£t2 -) \ - -104 - `__CPU_OP_S - ( ( -ýu_£t_t -), -de¡£t -, -¤c£t1 -, -¤c£t2 -, ^) - - ) - -105  - #CPU_AND_S -( -£tsize -, -de¡£t -, -¤c£t1 -, -¤c£t2 -) \ - -106 - `__CPU_OP_S - ( -£tsize -, -de¡£t -, -¤c£t1 -, -¤c£t2 -, &) - - ) - -107  - #CPU_OR_S -( -£tsize -, -de¡£t -, -¤c£t1 -, -¤c£t2 -) \ - -108 - `__CPU_OP_S - ( -£tsize -, -de¡£t -, -¤c£t1 -, -¤c£t2 -, |) - - ) - -109  - #CPU_XOR_S -( -£tsize -, -de¡£t -, -¤c£t1 -, -¤c£t2 -) \ - -110 - `__CPU_OP_S - ( -£tsize -, -de¡£t -, -¤c£t1 -, -¤c£t2 -, ^) - - ) - -112  - #CPU_ALLOC_SIZE -( -couÁ -è - `__CPU_ALLOC_SIZE - (couÁ) - - ) - -113  - #CPU_ALLOC -( -couÁ -è - `__CPU_ALLOC - (couÁ) - - ) - -114  - #CPU_FREE -( -ýu£t -è - `__CPU_FREE - (ýu£t) - - ) - -118  - $sched_£ffš™y - ( -__pid_t - -__pid -, -size_t - -__ýu£tsize -, - -119 -__cÚ¡ - -ýu_£t_t - * -__ýu£t -è -__THROW -; - -122  - $sched_g‘affš™y - ( -__pid_t - -__pid -, -size_t - -__ýu£tsize -, - -123 -ýu_£t_t - * -__ýu£t -è -__THROW -; - -126 -__END_DECLS - - - @/usr/include/stdint.h - -23 #iâdeà -_STDINT_H - - -24  - #_STDINT_H - 1 - - ) - -26  - ~<ã©u»s.h -> - -27  - ~ - -28  - ~ - -35 #iâdeà -__št8_t_defšed - - -36  - #__št8_t_defšed - - - ) - -37 sigÃd  - tšt8_t -; - -38  - tšt16_t -; - -39  - tšt32_t -; - -40 #ià -__WORDSIZE - == 64 - -41  - tšt64_t -; - -43 -__ex‹nsiÚ__ - - -44  - tšt64_t -; - -49  - tušt8_t -; - -50  - tušt16_t -; - -51 #iâdeà -__ušt32_t_defšed - - -52  - tušt32_t -; - -53  - #__ušt32_t_defšed - - - ) - -55 #ià -__WORDSIZE - == 64 - -56  - tušt64_t -; - -58 -__ex‹nsiÚ__ - - -59  - tušt64_t -; - -66 sigÃd  - tšt_Ëa¡8_t -; - -67  - tšt_Ëa¡16_t -; - -68  - tšt_Ëa¡32_t -; - -69 #ià -__WORDSIZE - == 64 - -70  - tšt_Ëa¡64_t -; - -72 -__ex‹nsiÚ__ - - -73  - tšt_Ëa¡64_t -; - -77  - tušt_Ëa¡8_t -; - -78  - tušt_Ëa¡16_t -; - -79  - tušt_Ëa¡32_t -; - -80 #ià -__WORDSIZE - == 64 - -81  - tušt_Ëa¡64_t -; - -83 -__ex‹nsiÚ__ - - -84  - tušt_Ëa¡64_t -; - -91 sigÃd  - tšt_ç¡8_t -; - -92 #ià -__WORDSIZE - == 64 - -93  - tšt_ç¡16_t -; - -94  - tšt_ç¡32_t -; - -95  - tšt_ç¡64_t -; - -97  - tšt_ç¡16_t -; - -98  - tšt_ç¡32_t -; - -99 -__ex‹nsiÚ__ - - -100  - tšt_ç¡64_t -; - -104  - tušt_ç¡8_t -; - -105 #ià -__WORDSIZE - == 64 - -106  - tušt_ç¡16_t -; - -107  - tušt_ç¡32_t -; - -108  - tušt_ç¡64_t -; - -110  - tušt_ç¡16_t -; - -111  - tušt_ç¡32_t -; - -112 -__ex‹nsiÚ__ - - -113  - tušt_ç¡64_t -; - -118 #ià -__WORDSIZE - == 64 - -119 #iâdeà -__šŒ_t_defšed - - -120  - tšŒ_t -; - -121  - #__šŒ_t_defšed - - - ) - -123  - tušŒ_t -; - -125 #iâdeà -__šŒ_t_defšed - - -126  - tšŒ_t -; - -127  - #__šŒ_t_defšed - - - ) - -129  - tušŒ_t -; - -134 #ià -__WORDSIZE - == 64 - -135  - tštmax_t -; - -136  - tuštmax_t -; - -138 -__ex‹nsiÚ__ - - -139  - tštmax_t -; - -140 -__ex‹nsiÚ__ - - -141  - tuštmax_t -; - -147 #ià! -defšed - -__ýlu¥lus - || defšed -__STDC_LIMIT_MACROS - - -149 #ià -__WORDSIZE - == 64 - -150  - #__INT64_C -( -c -èø## -L - - - ) - -151  - #__UINT64_C -( -c -èø## -UL - - - ) - -153  - #__INT64_C -( -c -èø## -LL - - - ) - -154  - #__UINT64_C -( -c -èø## -ULL - - - ) - -160  - #INT8_MIN - (-128) - - ) - -161  - #INT16_MIN - (-32767-1) - - ) - -162  - #INT32_MIN - (-2147483647-1) - - ) - -163  - #INT64_MIN - (- - `__INT64_C -(9223372036854775807)-1) - - ) - -165  - #INT8_MAX - (127) - - ) - -166  - #INT16_MAX - (32767) - - ) - -167  - #INT32_MAX - (2147483647) - - ) - -168  - #INT64_MAX - ( - `__INT64_C -(9223372036854775807)) - - ) - -171  - #UINT8_MAX - (255) - - ) - -172  - #UINT16_MAX - (65535) - - ) - -173  - #UINT32_MAX - (4294967295U) - - ) - -174  - #UINT64_MAX - ( - `__UINT64_C -(18446744073709551615)) - - ) - -178  - #INT_LEAST8_MIN - (-128) - - ) - -179  - #INT_LEAST16_MIN - (-32767-1) - - ) - -180  - #INT_LEAST32_MIN - (-2147483647-1) - - ) - -181  - #INT_LEAST64_MIN - (- - `__INT64_C -(9223372036854775807)-1) - - ) - -183  - #INT_LEAST8_MAX - (127) - - ) - -184  - #INT_LEAST16_MAX - (32767) - - ) - -185  - #INT_LEAST32_MAX - (2147483647) - - ) - -186  - #INT_LEAST64_MAX - ( - `__INT64_C -(9223372036854775807)) - - ) - -189  - #UINT_LEAST8_MAX - (255) - - ) - -190  - #UINT_LEAST16_MAX - (65535) - - ) - -191  - #UINT_LEAST32_MAX - (4294967295U) - - ) - -192  - #UINT_LEAST64_MAX - ( - `__UINT64_C -(18446744073709551615)) - - ) - -196  - #INT_FAST8_MIN - (-128) - - ) - -197 #ià -__WORDSIZE - == 64 - -198  - #INT_FAST16_MIN - (-9223372036854775807L-1) - - ) - -199  - #INT_FAST32_MIN - (-9223372036854775807L-1) - - ) - -201  - #INT_FAST16_MIN - (-2147483647-1) - - ) - -202  - #INT_FAST32_MIN - (-2147483647-1) - - ) - -204  - #INT_FAST64_MIN - (- - `__INT64_C -(9223372036854775807)-1) - - ) - -206  - #INT_FAST8_MAX - (127) - - ) - -207 #ià -__WORDSIZE - == 64 - -208  - #INT_FAST16_MAX - (9223372036854775807L) - - ) - -209  - #INT_FAST32_MAX - (9223372036854775807L) - - ) - -211  - #INT_FAST16_MAX - (2147483647) - - ) - -212  - #INT_FAST32_MAX - (2147483647) - - ) - -214  - #INT_FAST64_MAX - ( - `__INT64_C -(9223372036854775807)) - - ) - -217  - #UINT_FAST8_MAX - (255) - - ) - -218 #ià -__WORDSIZE - == 64 - -219  - #UINT_FAST16_MAX - (18446744073709551615UL) - - ) - -220  - #UINT_FAST32_MAX - (18446744073709551615UL) - - ) - -222  - #UINT_FAST16_MAX - (4294967295U) - - ) - -223  - #UINT_FAST32_MAX - (4294967295U) - - ) - -225  - #UINT_FAST64_MAX - ( - `__UINT64_C -(18446744073709551615)) - - ) - -229 #ià -__WORDSIZE - == 64 - -230  - #INTPTR_MIN - (-9223372036854775807L-1) - - ) - -231  - #INTPTR_MAX - (9223372036854775807L) - - ) - -232  - #UINTPTR_MAX - (18446744073709551615UL) - - ) - -234  - #INTPTR_MIN - (-2147483647-1) - - ) - -235  - #INTPTR_MAX - (2147483647) - - ) - -236  - #UINTPTR_MAX - (4294967295U) - - ) - -241  - #INTMAX_MIN - (- - `__INT64_C -(9223372036854775807)-1) - - ) - -243  - #INTMAX_MAX - ( - `__INT64_C -(9223372036854775807)) - - ) - -246  - #UINTMAX_MAX - ( - `__UINT64_C -(18446744073709551615)) - - ) - -252 #ià -__WORDSIZE - == 64 - -253  - #PTRDIFF_MIN - (-9223372036854775807L-1) - - ) - -254  - #PTRDIFF_MAX - (9223372036854775807L) - - ) - -256  - #PTRDIFF_MIN - (-2147483647-1) - - ) - -257  - #PTRDIFF_MAX - (2147483647) - - ) - -261  - #SIG_ATOMIC_MIN - (-2147483647-1) - - ) - -262  - #SIG_ATOMIC_MAX - (2147483647) - - ) - -265 #ià -__WORDSIZE - == 64 - -266  - #SIZE_MAX - (18446744073709551615UL) - - ) - -268  - #SIZE_MAX - (4294967295U) - - ) - -272 #iâdeà -WCHAR_MIN - - -274  - #WCHAR_MIN - -__WCHAR_MIN - - - ) - -275  - #WCHAR_MAX - -__WCHAR_MAX - - - ) - -279  - #WINT_MIN - (0u) - - ) - -280  - #WINT_MAX - (4294967295u) - - ) - -287 #ià! -defšed - -__ýlu¥lus - || defšed -__STDC_CONSTANT_MACROS - - -290  - #INT8_C -( -c -è - ) -c - -291  - #INT16_C -( -c -è - ) -c - -292  - #INT32_C -( -c -è - ) -c - -293 #ià -__WORDSIZE - == 64 - -294  - #INT64_C -( -c -èø## -L - - - ) - -296  - #INT64_C -( -c -èø## -LL - - - ) - -300  - #UINT8_C -( -c -è - ) -c - -301  - #UINT16_C -( -c -è - ) -c - -302  - #UINT32_C -( -c -èø## -U - - - ) - -303 #ià -__WORDSIZE - == 64 - -304  - #UINT64_C -( -c -èø## -UL - - - ) - -306  - #UINT64_C -( -c -èø## -ULL - - - ) - -310 #ià -__WORDSIZE - == 64 - -311  - #INTMAX_C -( -c -èø## -L - - - ) - -312  - #UINTMAX_C -( -c -èø## -UL - - - ) - -314  - #INTMAX_C -( -c -èø## -LL - - - ) - -315  - #UINTMAX_C -( -c -èø## -ULL - - - ) - - @/usr/include/sys/cdefs.h - -20 #iâdef -_SYS_CDEFS_H - - -21  - #_SYS_CDEFS_H - 1 - - ) - -24 #iâdeà -_FEATURES_H - - -25  - ~<ã©u»s.h -> - -31 #ià -defšed - -__GNUC__ - && !defšed -__STDC__ - - -36 #undeà -__P - - -37 #undeà -__PMT - - -39 #ifdeà -__GNUC__ - - -46 #ià! -defšed - -__ýlu¥lus - && -__GNUC_PREREQ - (3, 3) - -47  - #__THROW - - `__©Œibu‹__ - (( -__nÙhrow__ -)) - - ) - -48  - #__NTH -( -fù -è - `__©Œibu‹__ - (( -__nÙhrow__ -)è - ) -fct - -50 #ià -defšed - -__ýlu¥lus - && -__GNUC_PREREQ - (2,8) - -51  - #__THROW - - `throw - () - - ) - -52  - #__NTH -( -fù -èfù - `throw - () - - ) - -54  - #__THROW - - - ) - -55  - #__NTH -( -fù -è - ) -fct - -61  - #__šlše - - - ) - -63  - #__THROW - - - ) - -64  - #__NTH -( -fù -è - ) -fct - -66  - #__cÚ¡ - cÚ¡ - - ) - -67  - #__sigÃd - sigÃd - - ) - -68  - #__vÞ©že - vÞ©že - - ) - -74  - #__P -( -¬gs -è - ) -args - -75  - #__PMT -( -¬gs -è - ) -args - -80  - #__CONCAT -( -x -, -y -èx ## - ) -y - -81  - #__STRING -( -x -è#x - - ) - -84  - #__±r_t - * - - ) - -85  - #__lÚg_doubË_t -  - - ) - -89 #ifdef -__ýlu¥lus - - -90  - #__BEGIN_DECLS - "C" { - - ) - -91  - #__END_DECLS - } - - ) - -93  - #__BEGIN_DECLS - - - ) - -94  - #__END_DECLS - - - ) - -103 #ià -defšed - -__ýlu¥lus - && defšed -_GLIBCPP_USE_NAMESPACES - - -104  - #__BEGIN_NAMESPACE_STD - -Çme¥aû - -¡d - { - - ) - -105  - #__END_NAMESPACE_STD - } - - ) - -106  - #__USING_NAMESPACE_STD -( -Çme -è -usšg - -¡d -::Çme; - - ) - -107  - #__BEGIN_NAMESPACE_C99 - -Çme¥aû - -__c99 - { - - ) - -108  - #__END_NAMESPACE_C99 - } - - ) - -109  - #__USING_NAMESPACE_C99 -( -Çme -è -usšg - -__c99 -::Çme; - - ) - -114  - #__BEGIN_NAMESPACE_STD - - - ) - -115  - #__END_NAMESPACE_STD - - - ) - -116  - #__USING_NAMESPACE_STD -( -Çme -) - - ) - -117  - #__BEGIN_NAMESPACE_C99 - - - ) - -118  - #__END_NAMESPACE_C99 - - - ) - -119  - #__USING_NAMESPACE_C99 -( -Çme -) - - ) - -124 #iâdeà -__BOUNDED_POINTERS__ - - -125  - #__bounded - - - ) - -126  - #__unbounded - - - ) - -127  - #__±rv®ue - - - ) - -132  - #__bos -( -±r -è - `__bužtš_objeù_size - (±r, -__USE_FORTIFY_LEVEL - > 1) - - ) - -133  - #__bos0 -( -±r -è - `__bužtš_objeù_size - (±r, 0) - - ) - -135 #ià -__GNUC_PREREQ - (4,3) - -136  - #__w¬ndeþ -( -Çme -, -msg -) \ - -137  - `Çme - (è - `__©Œibu‹__ -(( - `__w¬nšg__ - ( -msg -))) - - ) - -138  - #__w¬Ç‰r -( -msg -è - `__©Œibu‹__ -(( - `__w¬nšg__ - (msg))) - - ) - -139  - #__”rÜdeþ -( -Çme -, -msg -) \ - -140  - `Çme - (è - `__©Œibu‹__ -(( - `__”rÜ__ - ( -msg -))) - - ) - -142  - #__w¬ndeþ -( -Çme -, -msg -è  - `Çme - () - - ) - -143  - #__w¬Ç‰r -( -msg -) - - ) - -144  - #__”rÜdeþ -( -Çme -, -msg -è  - `Çme - () - - ) - -148 #ià -__GNUC_PREREQ - (2,97) - -150  - #__æex¬r - [] - - ) - -152 #ifdeà -__GNUC__ - - -153  - #__æex¬r - [0] - - ) - -155 #ià -defšed - -__STDC_VERSION__ - && __STDC_VERSION__ >= 199901L - -156  - #__æex¬r - [] - - ) - -159  - #__æex¬r - [1] - - ) - -175 #ià -defšed - -__GNUC__ - && __GNUC__ >= 2 - -177  - #__REDIRECT -( -Çme -, -´Ùo -, -®Ÿs -èÇm´ÙØ - `__asm__ - ( - `__ASMNAME - (#®Ÿs)) - - ) - -178 #ifdeà -__ýlu¥lus - - -179  - #__REDIRECT_NTH -( -Çme -, -´Ùo -, -®Ÿs -) \ - -180 -Çme - -´Ùo - -__THROW - - `__asm__ - ( - `__ASMNAME - (#®Ÿs)) - - ) - -182  - #__REDIRECT_NTH -( -Çme -, -´Ùo -, -®Ÿs -) \ - -183 -Çme - -´Ùo - - `__asm__ - ( - `__ASMNAME - (#®Ÿs)è -__THROW - - - ) - -185  - #__ASMNAME -( -úame -è - `__ASMNAME2 - ( -__USER_LABEL_PREFIX__ -, cÇme) - - ) - -186  - #__ASMNAME2 -( -´efix -, -úame -è - `__STRING - (´efixè - ) -cname - -199 #ià! -defšed - -__GNUC__ - || __GNUC__ < 2 - -200  - #__©Œibu‹__ -( -xyz -è - - ) - -206 #ià -__GNUC_PREREQ - (2,96) - -207  - #__©Œibu‹_m®loc__ - - `__©Œibu‹__ - (( -__m®loc__ -)) - - ) - -209  - #__©Œibu‹_m®loc__ - - - ) - -215 #ià -__GNUC_PREREQ - (2,96) - -216  - #__©Œibu‹_pu»__ - - `__©Œibu‹__ - (( -__pu»__ -)) - - ) - -218  - #__©Œibu‹_pu»__ - - - ) - -224 #ià -__GNUC_PREREQ - (3,1) - -225  - #__©Œibu‹_u£d__ - - `__©Œibu‹__ - (( -__u£d__ -)) - - ) - -226  - #__©Œibu‹_nošlše__ - - `__©Œibu‹__ - (( -__nošlše__ -)) - - ) - -228  - #__©Œibu‹_u£d__ - - `__©Œibu‹__ - (( -__unu£d__ -)) - - ) - -229  - #__©Œibu‹_nošlše__ - - - ) - -233 #ià -__GNUC_PREREQ - (3,2) - -234  - #__©Œibu‹_d•»ÿ‹d__ - - `__©Œibu‹__ - (( -__d•»ÿ‹d__ -)) - - ) - -236  - #__©Œibu‹_d•»ÿ‹d__ - - - ) - -245 #ià -__GNUC_PREREQ - (2,8) - -246  - #__©Œibu‹_fÜm©_¬g__ -( -x -è - `__©Œibu‹__ - (( - `__fÜm©_¬g__ - (x))) - - ) - -248  - #__©Œibu‹_fÜm©_¬g__ -( -x -è - - ) - -255 #ià -__GNUC_PREREQ - (2,97) - -256  - #__©Œibu‹_fÜm©_¡rfmÚ__ -( -a -, -b -) \ - -257 - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__¡rfmÚ__ -, -a -, -b -))) - - ) - -259  - #__©Œibu‹_fÜm©_¡rfmÚ__ -( -a -, -b -è - - ) - -264 #ià -__GNUC_PREREQ - (3,3) - -265  - #__nÚnuÎ -( -·¿ms -è - `__©Œibu‹__ - (( -__nÚnuÎ__ -…¬ams)) - - ) - -267  - #__nÚnuÎ -( -·¿ms -) - - ) - -272 #ià -__GNUC_PREREQ - (3,4) - -273  - #__©Œibu‹_w¬n_unu£d_»suÉ__ - \ - -274 - `__©Œibu‹__ - (( -__w¬n_unu£d_»suÉ__ -)) - - ) - -275 #ià -__USE_FORTIFY_LEVEL - > 0 - -276  - #__wur - -__©Œibu‹_w¬n_unu£d_»suÉ__ - - - ) - -279  - #__©Œibu‹_w¬n_unu£d_»suÉ__ - - - ) - -281 #iâdeà -__wur - - -282  - #__wur - - - ) - -286 #ià -__GNUC_PREREQ - (3,2) - -287  - #__®ways_šlše - -__šlše - - `__©Œibu‹__ - (( -__®ways_šlše__ -)) - - ) - -289  - #__®ways_šlše - -__šlše - - - ) - -294 #ià! -defšed - -__ýlu¥lus - || -__GNUC_PREREQ - (4,3) - -295 #ià -defšed - -__GNUC_STDC_INLINE__ - || defšed -__ýlu¥lus - - -296  - #__ex‹º_šlše - -__šlše - - `__©Œibu‹__ - (( -__gnu_šlše__ -)) - - ) - -297 #ià -__GNUC_PREREQ - (4,3) - -298  - #__ex‹º_®ways_šlše - \ - -299 -__®ways_šlše - - `__©Œibu‹__ - (( -__gnu_šlše__ -, -__¬tificŸl__ -)) - - ) - -301  - #__ex‹º_®ways_šlše - \ - -302 -__®ways_šlše - - `__©Œibu‹__ - (( -__gnu_šlše__ -)) - - ) - -305  - #__ex‹º_šlše - -__šlše - - - ) - -306 #ià -__GNUC_PREREQ - (4,3) - -307  - #__ex‹º_®ways_šlše - \ - -308 -__®ways_šlše - - `__©Œibu‹__ - (( -__¬tificŸl__ -)) - - ) - -310  - #__ex‹º_®ways_šlše - -__®ways_šlše - - - ) - -317 #ià -__GNUC_PREREQ - (4,3) - -318  - #__va_¬g_·ck -(è - `__bužtš_va_¬g_·ck - () - - ) - -319  - #__va_¬g_·ck_Ën -(è - `__bužtš_va_¬g_·ck_Ën - () - - ) - -326 #ià! -__GNUC_PREREQ - (2,8) - -327  - #__ex‹nsiÚ__ - - - ) - -331 #ià! -__GNUC_PREREQ - (2,92) - -332  - #__»¡riù - - - ) - -338 #ià -__GNUC_PREREQ - (3,1è&& ! -defšed - -__GNUG__ - - -339  - #__»¡riù_¬r - -__»¡riù - - - ) - -341 #ifdeà -__GNUC__ - - -342  - #__»¡riù_¬r - - - ) - -344 #ià -defšed - -__STDC_VERSION__ - && __STDC_VERSION__ >= 199901L - -345  - #__»¡riù_¬r - -»¡riù - - - ) - -348  - #__»¡riù_¬r - - - ) - -353  - ~ - -355 #ià -defšed - -__LONG_DOUBLE_MATH_OPTIONAL - && defšed -__NO_LONG_DOUBLE_MATH - - -356  - #__LDBL_COMPAT - 1 - - ) - -357 #ifdeà -__REDIRECT - - -358  - #__LDBL_REDIR1 -( -Çme -, -´Ùo -, -®Ÿs -è - `__REDIRECT - (Çme,…rÙo,‡lŸs) - - ) - -359  - #__LDBL_REDIR -( -Çme -, -´Ùo -) \ - -360 - `__LDBL_REDIR1 - ( -Çme -, -´Ùo -, -__Ædbl_ -##Çme) - - ) - -361  - #__LDBL_REDIR1_NTH -( -Çme -, -´Ùo -, -®Ÿs -è - `__REDIRECT_NTH - (Çme,…rÙo,‡lŸs) - - ) - -362  - #__LDBL_REDIR_NTH -( -Çme -, -´Ùo -) \ - -363 - `__LDBL_REDIR1_NTH - ( -Çme -, -´Ùo -, -__Ædbl_ -##Çme) - - ) - -364  - #__LDBL_REDIR1_DECL -( -Çme -, -®Ÿs -) \ - -365 - `__ty³of - ( -Çme -èÇm - `__asm - ( - `__ASMNAME - (#®Ÿs)); - - ) - -366  - #__LDBL_REDIR_DECL -( -Çme -) \ - -367 - `__ty³of - ( -Çme -èÇm - `__asm - ( - `__ASMNAME - ("__Ædbl_" #Çme)); - - ) - -368  - #__REDIRECT_LDBL -( -Çme -, -´Ùo -, -®Ÿs -) \ - -369 - `__LDBL_REDIR1 - ( -Çme -, -´Ùo -, -__Ædbl_ -## -®Ÿs -) - - ) - -370  - #__REDIRECT_NTH_LDBL -( -Çme -, -´Ùo -, -®Ÿs -) \ - -371 - `__LDBL_REDIR1_NTH - ( -Çme -, -´Ùo -, -__Ædbl_ -## -®Ÿs -) - - ) - -374 #ià! -defšed - -__LDBL_COMPAT - || !defšed -__REDIRECT - - -375  - #__LDBL_REDIR1 -( -Çme -, -´Ùo -, -®Ÿs -èÇm - ) -proto - -376  - #__LDBL_REDIR -( -Çme -, -´Ùo -èÇm - ) -proto - -377  - #__LDBL_REDIR1_NTH -( -Çme -, -´Ùo -, -®Ÿs -èÇm´ÙØ -__THROW - - - ) - -378  - #__LDBL_REDIR_NTH -( -Çme -, -´Ùo -èÇm´ÙØ -__THROW - - - ) - -379  - #__LDBL_REDIR_DECL -( -Çme -) - - ) - -380 #ifdeà -__REDIRECT - - -381  - #__REDIRECT_LDBL -( -Çme -, -´Ùo -, -®Ÿs -è - `__REDIRECT - (Çme,…rÙo,‡lŸs) - - ) - -382  - #__REDIRECT_NTH_LDBL -( -Çme -, -´Ùo -, -®Ÿs -) \ - -383 - `__REDIRECT_NTH - ( -Çme -, -´Ùo -, -®Ÿs -) - - ) - - @/usr/include/sys/sysmacros.h - -21 #iâdeà -_SYS_SYSMACROS_H - - -22  - #_SYS_SYSMACROS_H - 1 - - ) - -24  - ~<ã©u»s.h -> - -29 #ifdeà -__GLIBC_HAVE_LONG_LONG - - -30 -__ex‹nsiÚ__ - - -31  - $gnu_dev_majÜ - ( -__dev -) - -32 -__THROW -; - -33 -__ex‹nsiÚ__ - - -34  - $gnu_dev_mšÜ - ( -__dev -) - -35 -__THROW -; - -36 -__ex‹nsiÚ__ - - -37  - $gnu_dev_makedev - ( -__majÜ -, - -38  -__mšÜ -) - -39 -__THROW -; - -41 #ià -defšed - -__GNUC__ - && __GNUC__ >ð2 && defšed -__USE_EXTERN_INLINES - - -42 -__ex‹nsiÚ__ - -__ex‹º_šlše -  - -43 - `__NTH - ( - $gnu_dev_majÜ - ( -__dev -)) - -45  (( -__dev - >> 8) & 0xfff) | (() (__dev >> 32) & ~0xfff); - -46 - } -} - -48 -__ex‹nsiÚ__ - -__ex‹º_šlše -  - -49 -__NTH - ( - $gnu_dev_mšÜ - ( -__dev -)) - -51  ( -__dev - & 0xff) | (() (__dev >> 12) & ~0xff); - -52 - } -} - -54 -__ex‹nsiÚ__ - -__ex‹º_šlše -  - -55 -__NTH - ( - $gnu_dev_makedev - ( -__majÜ -,  -__mšÜ -)) - -57  (( -__mšÜ - & 0xffè| (( -__majÜ - & 0xfff) << 8) - -58 | (((è( -__mšÜ - & ~0xff)) << 12) - -59 | (((è( -__majÜ - & ~0xfff)) << 32)); - -60 - } -} - -65  - #majÜ -( -dev -è - `gnu_dev_majÜ - (dev) - - ) - -66  - #mšÜ -( -dev -è - `gnu_dev_mšÜ - (dev) - - ) - -67  - #makedev -( -maj -, -mš -è - `gnu_dev_makedev - (maj, mš) - - ) - - @/usr/include/sys/ttydefaults.h - -40 #iâdeà -_SYS_TTYDEFAULTS_H_ - - -41  - #_SYS_TTYDEFAULTS_H_ - - - ) - -46  - #TTYDEF_IFLAG - ( -BRKINT - | -ISTRIP - | -ICRNL - | -IMAXBEL - | -IXON - | -IXANY -) - - ) - -47  - #TTYDEF_OFLAG - ( -OPOST - | -ONLCR - | -XTABS -) - - ) - -48  - #TTYDEF_LFLAG - ( -ECHO - | -ICANON - | -ISIG - | -IEXTEN - | -ECHOE -| -ECHOKE -| -ECHOCTL -) - - ) - -49  - #TTYDEF_CFLAG - ( -CREAD - | -CS7 - | -PARENB - | -HUPCL -) - - ) - -50  - #TTYDEF_SPEED - ( -B9600 -) - - ) - -55  - #CTRL -( -x -è(x&037) - - ) - -56  - #CEOF - - `CTRL -('d') - - ) - -57 #ifdeà -_POSIX_VDISABLE - - -58  - #CEOL - -_POSIX_VDISABLE - - - ) - -60  - #CEOL - '\0' - - ) - -62  - #CERASE - 0177 - - ) - -63  - #CINTR - - `CTRL -('c') - - ) - -64 #ifdeà -_POSIX_VDISABLE - - -65  - #CSTATUS - -_POSIX_VDISABLE - - - ) - -67  - #CSTATUS - '\0' - - ) - -69  - #CKILL - - `CTRL -('u') - - ) - -70  - #CMIN - 1 - - ) - -71  - #CQUIT - 034 - - ) - -72  - #CSUSP - - `CTRL -('z') - - ) - -73  - #CTIME - 0 - - ) - -74  - #CDSUSP - - `CTRL -('y') - - ) - -75  - #CSTART - - `CTRL -('q') - - ) - -76  - #CSTOP - - `CTRL -('s') - - ) - -77  - #CLNEXT - - `CTRL -('v') - - ) - -78  - #CDISCARD - - `CTRL -('o') - - ) - -79  - #CWERASE - - `CTRL -('w') - - ) - -80  - #CREPRINT - - `CTRL -('r') - - ) - -81  - #CEOT - -CEOF - - - ) - -83  - #CBRK - -CEOL - - - ) - -84  - #CRPRNT - -CREPRINT - - - ) - -85  - #CFLUSH - -CDISCARD - - - ) - -93 #ifdeà -TTYDEFCHARS - - -94 -cc_t - - g‰ydefch¬s -[ -NCCS -] = { - -95 -CEOF -, -CEOL -, CEOL, -CERASE -, -CWERASE -, -CKILL -, -CREPRINT -, - -96 -_POSIX_VDISABLE -, -CINTR -, -CQUIT -, -CSUSP -, -CDSUSP -, -CSTART -, -CSTOP -, -CLNEXT -, - -97 -CDISCARD -, -CMIN -, -CTIME -, -CSTATUS -, -_POSIX_VDISABLE - - -99 #undeà -TTYDEFCHARS - - - @/usr/include/sys/uio.h - -19 #iâdeà -_SYS_UIO_H - - -20  - #_SYS_UIO_H - 1 - - ) - -22  - ~<ã©u»s.h -> - -24  - ~ - -26 - g__BEGIN_DECLS - - -29  - ~ - -40 -ssize_t - - $»adv - ( -__fd -, -__cÚ¡ -  -iovec - * -__iovec -,  -__couÁ -) - -41 -__wur -; - -51 -ssize_t - - $wr™ev - ( -__fd -, -__cÚ¡ -  -iovec - * -__iovec -,  -__couÁ -) - -52 -__wur -; - -55 #ifdeà -__USE_BSD - - -56 #iâdeà -__USE_FILE_OFFSET64 - - -66 -ssize_t - - $´—dv - ( -__fd -, -__cÚ¡ -  -iovec - * -__iovec -,  -__couÁ -, - -67 -__off_t - -__off£t -è -__wur -; - -78 -ssize_t - - $pwr™ev - ( -__fd -, -__cÚ¡ -  -iovec - * -__iovec -,  -__couÁ -, - -79 -__off_t - -__off£t -è -__wur -; - -81 #ifdeà -__REDIRECT - - -82 -ssize_t - - `__REDIRECT - ( -´—dv -, ( -__fd -, -__cÚ¡ -  -iovec - * -__iovec -, - -83  -__couÁ -, -__off64_t - -__off£t -), - -84 -´—dv64 -è -__wur -; - -85 -ssize_t - - `__REDIRECT - ( -pwr™ev -, ( -__fd -, -__cÚ¡ -  -iovec - * -__iovec -, - -86  -__couÁ -, -__off64_t - -__off£t -), - -87 -pwr™ev64 -è -__wur -; - -89  - #´—dv - -´—dv64 - - - ) - -90  - #pwr™ev - -pwr™ev64 - - - ) - -94 #ifdeà -__USE_LARGEFILE64 - - -104 -ssize_t - - $´—dv64 - ( -__fd -, -__cÚ¡ -  -iovec - * -__iovec -,  -__couÁ -, - -105 -__off64_t - -__off£t -è -__wur -; - -116 -ssize_t - - $pwr™ev64 - ( -__fd -, -__cÚ¡ -  -iovec - * -__iovec -,  -__couÁ -, - -117 -__off64_t - -__off£t -è -__wur -; - -121 -__END_DECLS - - - @/usr/include/time.h - -23 #iâdef -_TIME_H - - -25 #ià(! -defšed - -__Ãed_time_t - && !defšed -__Ãed_þock_t - && \ - -26 ! -defšed - - g__Ãed_time¥ec -) - -27  - #_TIME_H - 1 - - ) - -28  - ~<ã©u»s.h -> - -30 - g__BEGIN_DECLS - - -34 #ifdef -_TIME_H - - -36  - #__Ãed_size_t - - - ) - -37  - #__Ãed_NULL - - - ) - -38  - ~<¡ddef.h -> - -42  - ~ - -45 #ià! -defšed - -__STRICT_ANSI__ - && !defšed -__USE_XOPEN2K - - -46 #iâdeà -CLK_TCK - - -47  - #CLK_TCK - -CLOCKS_PER_SEC - - - ) - -53 #ià! -defšed - -__þock_t_defšed - && (defšed -_TIME_H - || defšed -__Ãed_þock_t -) - -54  - #__þock_t_defšed - 1 - - ) - -56  - ~ - -58 -__BEGIN_NAMESPACE_STD - - -60  -__þock_t - - tþock_t -; - -61 - g__END_NAMESPACE_STD - - -62 #ià -defšed - -__USE_XOPEN - || defšed -__USE_POSIX - || defšed -__USE_MISC - - -63 - $__USING_NAMESPACE_STD -( -þock_t -) - -67 #undeà -__Ãed_þock_t - - -69 #ià! -defšed - -__time_t_defšed - && (defšed -_TIME_H - || defšed -__Ãed_time_t -) - -70  - #__time_t_defšed - 1 - - ) - -72  - ~ - -74 -__BEGIN_NAMESPACE_STD - - -76  -__time_t - - ttime_t -; - -77 -__END_NAMESPACE_STD - - -78 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - || defšed -__USE_SVID - - -79 - $__USING_NAMESPACE_STD -( -time_t -) - -83 #undeà -__Ãed_time_t - - -85 #ià! -defšed - -__þockid_t_defšed - && \ - -86 (( -defšed - -_TIME_H - && defšed -__USE_POSIX199309 -è|| defšed -__Ãed_þockid_t -) - -87  - #__þockid_t_defšed - 1 - - ) - -89  - ~ - -92  -__þockid_t - - tþockid_t -; - -95 #undeà -__þockid_time_t - - -97 #ià! -defšed - -__tim”_t_defšed - && \ - -98 (( -defšed - -_TIME_H - && defšed -__USE_POSIX199309 -è|| defšed -__Ãed_tim”_t -) - -99  - #__tim”_t_defšed - 1 - - ) - -101  - ~ - -104  -__tim”_t - - ttim”_t -; - -107 #undeà -__Ãed_tim”_t - - -110 #ià! -defšed - -__time¥ec_defšed - && \ - -111 (( -defšed - -_TIME_H - && \ - -112 ( -defšed - -__USE_POSIX199309 - || defšed -__USE_MISC -)) || \ - -113 -defšed - -__Ãed_time¥ec -) - -114  - #__time¥ec_defšed - 1 - - ) - -116  - ~ - -120  - stime¥ec - - -122 -__time_t - -tv_£c -; - -123  -tv_n£c -; - -127 #undeà -__Ãed_time¥ec - - -130 #ifdef -_TIME_H - - -131 -__BEGIN_NAMESPACE_STD - - -133  - stm - - -135  -tm_£c -; - -136  -tm_mš -; - -137  -tm_hour -; - -138  -tm_mday -; - -139  -tm_mÚ -; - -140  -tm_y—r -; - -141  -tm_wday -; - -142  -tm_yday -; - -143  -tm_isd¡ -; - -145 #ifdef -__USE_BSD - - -146  -tm_gmtoff -; - -147 -__cÚ¡ - * -tm_zÚe -; - -149  -__tm_gmtoff -; - -150 -__cÚ¡ - * -__tm_zÚe -; - -153 -__END_NAMESPACE_STD - - -154 #ià -defšed - -__USE_XOPEN - || defšed -__USE_POSIX - || defšed -__USE_MISC - - -155 - $__USING_NAMESPACE_STD -( -tm -) - -159 #ifdeà -__USE_POSIX199309 - - -161  - s™im”¥ec - - -163  -time¥ec - -™_š‹rv® -; - -164  -time¥ec - -™_v®ue -; - -168  -sigev’t -; - -172 #ifdeà -__USE_XOPEN2K - - -173 #iâdeà -__pid_t_defšed - - -174  -__pid_t - - tpid_t -; - -175  - #__pid_t_defšed - - - ) - -180 -__BEGIN_NAMESPACE_STD - - -183 -þock_t - - $þock - (è -__THROW -; - -186 -time_t - - $time - ( -time_t - * -__tim” -è -__THROW -; - -189  - $difáime - ( -time_t - -__time1 -,ime_ˆ -__time0 -) - -190 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)); - -193 -time_t - - $mktime - ( -tm - * -__ -è -__THROW -; - -199 -size_t - - $¡ráime - (* -__»¡riù - -__s -, -size_t - -__maxsize -, - -200 -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -201 -__cÚ¡ -  -tm - * -__»¡riù - -__ -è -__THROW -; - -202 -__END_NAMESPACE_STD - - -204 #ifdeà -__USE_XOPEN - - -207 * - $¡½time - ( -__cÚ¡ - * -__»¡riù - -__s -, - -208 -__cÚ¡ - * -__»¡riù - -__fmt -,  -tm - * -__ -) - -209 -__THROW -; - -212 #ifdeà -__USE_XOPEN2K8 - - -215  - ~ - -217 -size_t - - $¡ráime_l - (* -__»¡riù - -__s -, -size_t - -__maxsize -, - -218 -__cÚ¡ - * -__»¡riù - -__fÜm© -, - -219 -__cÚ¡ -  -tm - * -__»¡riù - -__ -, - -220 -__loÿË_t - -__loc -è -__THROW -; - -223 #ifdeà -__USE_GNU - - -224 * - $¡½time_l - ( -__cÚ¡ - * -__»¡riù - -__s -, - -225 -__cÚ¡ - * -__»¡riù - -__fmt -,  -tm - * -__ -, - -226 -__loÿË_t - -__loc -è -__THROW -; - -230 -__BEGIN_NAMESPACE_STD - - -233  -tm - * - $gmtime - ( -__cÚ¡ - -time_t - * -__tim” -è -__THROW -; - -237  -tm - * - $loÿÉime - ( -__cÚ¡ - -time_t - * -__tim” -è -__THROW -; - -238 -__END_NAMESPACE_STD - - -240 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -243  -tm - * - $gmtime_r - ( -__cÚ¡ - -time_t - * -__»¡riù - -__tim” -, - -244  -tm - * -__»¡riù - -__ -è -__THROW -; - -248  -tm - * - $loÿÉime_r - ( -__cÚ¡ - -time_t - * -__»¡riù - -__tim” -, - -249  -tm - * -__»¡riù - -__ -è -__THROW -; - -252 -__BEGIN_NAMESPACE_STD - - -255 * - $asùime - ( -__cÚ¡ -  -tm - * -__ -è -__THROW -; - -258 * - $ùime - ( -__cÚ¡ - -time_t - * -__tim” -è -__THROW -; - -259 -__END_NAMESPACE_STD - - -261 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -266 * - $asùime_r - ( -__cÚ¡ -  -tm - * -__»¡riù - -__ -, - -267 * -__»¡riù - -__buf -è -__THROW -; - -270 * - $ùime_r - ( -__cÚ¡ - -time_t - * -__»¡riù - -__tim” -, - -271 * -__»¡riù - -__buf -è -__THROW -; - -276 * -__tzÇme -[2]; - -277  -__daylight -; - -278  -__timezÚe -; - -281 #ifdef -__USE_POSIX - - -283 * -tzÇme -[2]; - -287  - $tz£t - (è -__THROW -; - -290 #ià -defšed - -__USE_SVID - || defšed -__USE_XOPEN - - -291  -daylight -; - -292  -timezÚe -; - -295 #ifdeà -__USE_SVID - - -298  - $¡ime - ( -__cÚ¡ - -time_t - * -__wh’ -è -__THROW -; - -304  - #__i¦—p -( -y—r -) \ - -305 (( -y—r -è% 4 =ð0 && ((y—rè% 100 !ð0 || (y—rè% 400 =ð0)) - - ) - -308 #ifdeà -__USE_MISC - - -313 -time_t - - $timegm - ( -tm - * -__ -è -__THROW -; - -316 -time_t - - $tim–oÿl - ( -tm - * -__ -è -__THROW -; - -319  - $dysize - ( -__y—r -è -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)); - -323 #ifdeà -__USE_POSIX199309 - - -328  - `Çno¦“p - ( -__cÚ¡ -  -time¥ec - * -__»que¡ed_time -, - -329  -time¥ec - * -__»maššg -); - -333  - $þock_g‘»s - ( -þockid_t - -__þock_id -,  -time¥ec - * -__»s -è -__THROW -; - -336  - $þock_g‘time - ( -þockid_t - -__þock_id -,  -time¥ec - * -__ -è -__THROW -; - -339  - $þock_£‰ime - ( -þockid_t - -__þock_id -, -__cÚ¡ -  -time¥ec - * -__ -) - -340 -__THROW -; - -342 #ifdeà -__USE_XOPEN2K - - -347  - `þock_Çno¦“p - ( -þockid_t - -__þock_id -,  -__æags -, - -348 -__cÚ¡ -  -time¥ec - * -__»q -, - -349  -time¥ec - * -__»m -); - -352  - $þock_g‘ýuþockid - ( -pid_t - -__pid -, -þockid_t - * -__þock_id -è -__THROW -; - -357  - $tim”_ü—‹ - ( -þockid_t - -__þock_id -, - -358  -sigev’t - * -__»¡riù - -__evp -, - -359 -tim”_t - * -__»¡riù - -__tim”id -è -__THROW -; - -362  - $tim”_d–‘e - ( -tim”_t - -__tim”id -è -__THROW -; - -365  - $tim”_£‰ime - ( -tim”_t - -__tim”id -,  -__æags -, - -366 -__cÚ¡ -  -™im”¥ec - * -__»¡riù - -__v®ue -, - -367  -™im”¥ec - * -__»¡riù - -__ov®ue -è -__THROW -; - -370  - $tim”_g‘time - ( -tim”_t - -__tim”id -,  -™im”¥ec - * -__v®ue -) - -371 -__THROW -; - -374  - $tim”_g‘ov”run - ( -tim”_t - -__tim”id -è -__THROW -; - -378 #ifdeà -__USE_XOPEN_EXTENDED - - -390  -g‘d©e_”r -; - -399  -tm - * - `g‘d©e - ( -__cÚ¡ - * -__¡ršg -); - -402 #ifdeà -__USE_GNU - - -413  - `g‘d©e_r - ( -__cÚ¡ - * -__»¡riù - -__¡ršg -, - -414  -tm - * -__»¡riù - -__»sbuå -); - -417 -__END_DECLS - - - @/usr/include/xlocale.h - -21 #iâdeà -_XLOCALE_H - - -22  - #_XLOCALE_H - 1 - - ) - -28  - s__loÿË_¡ruù - - -31  -__loÿË_d©a - * - m__loÿËs -[13]; - -34 cÚ¡ * - m__ùy³_b -; - -35 cÚ¡ * - m__ùy³_tÞow” -; - -36 cÚ¡ * - m__ùy³_touµ” -; - -39 cÚ¡ * - m__Çmes -[13]; - -40 } * - t__loÿË_t -; - -43  -__loÿË_t - - tloÿË_t -; - - @/usr/include/_G_config.h - -4 #iâdeà -_G_cÚfig_h - - -5  - #_G_cÚfig_h - 1 - - ) - -9  - ~ - -10  - #__Ãed_size_t - - - ) - -11 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -12  - #__Ãed_wch¬_t - - - ) - -14  - #__Ãed_NULL - - - ) - -15  - ~<¡ddef.h -> - -16  - #__Ãed_mb¡©e_t - - - ) - -17 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -18  - #__Ãed_wšt_t - - - ) - -20  - ~ - -21  - #_G_size_t - -size_t - - - ) - -24 -__off_t - - m__pos -; - -25 -__mb¡©e_t - - m__¡©e -; - -26 } - t_G_åos_t -; - -29 -__off64_t - - m__pos -; - -30 -__mb¡©e_t - - m__¡©e -; - -31 } - t_G_åos64_t -; - -32  - #_G_ssize_t - -__ssize_t - - - ) - -33  - #_G_off_t - -__off_t - - - ) - -34  - #_G_off64_t - -__off64_t - - - ) - -35  - #_G_pid_t - -__pid_t - - - ) - -36  - #_G_uid_t - -__uid_t - - - ) - -37  - #_G_wch¬_t - -wch¬_t - - - ) - -38  - #_G_wšt_t - -wšt_t - - - ) - -39  - #_G_¡©64 - -¡©64 - - - ) - -40 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -41  - ~ - -44  -__gcÚv_šfo - - m__cd -; - -47  -__gcÚv_šfo - - m__cd -; - -48  -__gcÚv_¡•_d©a - - m__d©a -; - -49 } - m__combšed -; - -50 } - t_G_icÚv_t -; - -53  - t_G_št16_t - - t__©Œibu‹__ - (( - t__mode__ - ( - t__HI__ -))); - -54  - t_G_št32_t - - t__©Œibu‹__ - (( - t__mode__ - ( - t__SI__ -))); - -55  - t_G_ušt16_t - - t__©Œibu‹__ - (( - t__mode__ - ( - t__HI__ -))); - -56  - t_G_ušt32_t - - t__©Œibu‹__ - (( - t__mode__ - ( - t__SI__ -))); - -58  - #_G_HAVE_BOOL - 1 - - ) - -62  - #_G_HAVE_ATEXIT - 1 - - ) - -63  - #_G_HAVE_SYS_CDEFS - 1 - - ) - -64  - #_G_HAVE_SYS_WAIT - 1 - - ) - -65  - #_G_NEED_STDARG_H - 1 - - ) - -66  - #_G_va_li¡ - -__gnuc_va_li¡ - - - ) - -68  - #_G_HAVE_PRINTF_FP - 1 - - ) - -69  - #_G_HAVE_MMAP - 1 - - ) - -70  - #_G_HAVE_MREMAP - 1 - - ) - -71  - #_G_HAVE_LONG_DOUBLE_IO - 1 - - ) - -72  - #_G_HAVE_IO_FILE_OPEN - 1 - - ) - -73  - #_G_HAVE_IO_GETLINE_INFO - 1 - - ) - -75  - #_G_IO_IO_FILE_VERSION - 0x20001 - - ) - -77  - #_G_OPEN64 - -__ݒ64 - - - ) - -78  - #_G_LSEEK64 - -__l£ek64 - - - ) - -79  - #_G_MMAP64 - -__mm­64 - - - ) - -80  - #_G_FSTAT64 -( -fd -, -buf -è - `__fx¡©64 - ( -_STAT_VER -, fd, buf) - - ) - -83  - #_G_HAVE_ST_BLKSIZE - - `defšed - ( -_STATBUF_ST_BLKSIZE -) - - ) - -85  - #_G_BUFSIZ - 8192 - - ) - -88  - #_G_NAMES_HAVE_UNDERSCORE - 0 - - ) - -89  - #_G_VTABLE_LABEL_HAS_LENGTH - 1 - - ) - -90  - #_G_USING_THUNKS - 1 - - ) - -91  - #_G_VTABLE_LABEL_PREFIX - "__vt_" - - ) - -92  - #_G_VTABLE_LABEL_PREFIX_ID - -__vt_ - - - ) - -95 #ià -defšed - -__ýlu¥lus - || defšed -__STDC__ - - -96  - #_G_ARGS -( -ARGLIST -è - ) -ARGLIST - -98  - #_G_ARGS -( -ARGLIST -è() - - ) - - @/usr/include/bits/byteswap.h - -21 #ià! -defšed - -_BYTESWAP_H - && !defšed -_NETINET_IN_H - && !defšed -_ENDIAN_H - - -25 #iâdeà -_BITS_BYTESWAP_H - - -26  - #_BITS_BYTESWAP_H - 1 - - ) - -28  - ~ - -31  - #__bsw­_cÚ¡ªt_16 -( -x -) \ - -32 ((è(((( -x -è>> 8è& 0xffè| (((xè& 0xffè<< 8))) - - ) - -34 #ià -defšed - -__GNUC__ - && __GNUC__ >= 2 - -35  - #__bsw­_16 -( -x -) \ - -36 ( -__ex‹nsiÚ__ - \ - -37 ({  -__v -, -__x - = (è( -x -); \ - -38 ià( - `__bužtš_cÚ¡ªt_p - ( -__x -)) \ - -39 -__v - = - `__bsw­_cÚ¡ªt_16 - ( -__x -); \ - -41 - `__asm__ - ("rorw $8, %w0" \ - -42 : "ô" ( -__v -) \ - -43 : "0" ( -__x -) \ - -45 -__v -; })) - - ) - -48  - #__bsw­_16 -( -x -) \ - -49 ( -__ex‹nsiÚ__ - \ - -50 ({  -__x - = (è( -x -); \ - -51 - `__bsw­_cÚ¡ªt_16 - ( -__x -); })) - - ) - -56  - #__bsw­_cÚ¡ªt_32 -( -x -) \ - -57 (((( -x -) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ - -58 ((( -x -è& 0x0000ff00è<< 8è| (((xè& 0x000000ffè<< 24)) - - ) - -60 #ià -defšed - -__GNUC__ - && __GNUC__ >= 2 - -61 #ià -__WORDSIZE - =ð64 || ( -defšed - -__i486__ - || defšed -__³Áium__ - \ - -62 || -defšed - - g__³Áium´o__ - || defšed - g__³Áium4__ - \ - -63 || -defšed - - g__k8__ - || defšed - g__©hlÚ__ - \ - -64 || -defšed - - g__k6__ - || defšed - g__nocÚa__ - \ - -65 || -defšed - - g__cÜe2__ - || defšed - g__geode__ - \ - -66 || -defšed - - g__amdçm10__ -) - -69  - #__bsw­_32 -( -x -) \ - -70 ( -__ex‹nsiÚ__ - \ - -71 ({  -__v -, -__x - = ( -x -); \ - -72 ià( - `__bužtš_cÚ¡ªt_p - ( -__x -)) \ - -73 -__v - = - `__bsw­_cÚ¡ªt_32 - ( -__x -); \ - -75 - `__asm__ - ("bsw­ %0" : "ô" ( -__v -è: "0" ( -__x -)); \ - -76 -__v -; })) - - ) - -78  - #__bsw­_32 -( -x -) \ - -79 ( -__ex‹nsiÚ__ - \ - -80 ({  -__v -, -__x - = ( -x -); \ - -81 ià( - `__bužtš_cÚ¡ªt_p - ( -__x -)) \ - -82 -__v - = - `__bsw­_cÚ¡ªt_32 - ( -__x -); \ - -84 - `__asm__ - ("rorw $8, %w0;" \ - -87 : "ô" ( -__v -) \ - -88 : "0" ( -__x -) \ - -90 -__v -; })) - - ) - -93  - #__bsw­_32 -( -x -) \ - -94 ( -__ex‹nsiÚ__ - \ - -95 ({  -__x - = ( -x -); - `__bsw­_cÚ¡ªt_32 - (__x); })) - - ) - -99 #ià -defšed - -__GNUC__ - && __GNUC__ >= 2 - -101  - #__bsw­_cÚ¡ªt_64 -( -x -) \ - -102 (((( -x -) & 0xff00000000000000ull) >> 56) \ - -103 | ((( -x -) & 0x00ff000000000000ull) >> 40) \ - -104 | ((( -x -) & 0x0000ff0000000000ull) >> 24) \ - -105 | ((( -x -) & 0x000000ff00000000ull) >> 8) \ - -106 | ((( -x -) & 0x00000000ff000000ull) << 8) \ - -107 | ((( -x -) & 0x0000000000ff0000ull) << 24) \ - -108 | ((( -x -) & 0x000000000000ff00ull) << 40) \ - -109 | ((( -x -è& 0x00000000000000ffuÎè<< 56)) - - ) - -111 #ià -__WORDSIZE - == 64 - -112  - #__bsw­_64 -( -x -) \ - -113 ( -__ex‹nsiÚ__ - \ - -114 ({  -__v -, -__x - = ( -x -); \ - -115 ià( - `__bužtš_cÚ¡ªt_p - ( -__x -)) \ - -116 -__v - = - `__bsw­_cÚ¡ªt_64 - ( -__x -); \ - -118 - `__asm__ - ("bsw­ %q0" : "ô" ( -__v -è: "0" ( -__x -)); \ - -119 -__v -; })) - - ) - -121  - #__bsw­_64 -( -x -) \ - -122 ( -__ex‹nsiÚ__ - \ - -123 ({ uniÚ { -__ex‹nsiÚ__ -  -__Î -; \ - -124  -__l -[2]; } -__w -, -__r -; \ - -125 ià( - `__bužtš_cÚ¡ªt_p - ( -x -)) \ - -126 -__r -. -__Î - = - `__bsw­_cÚ¡ªt_64 - ( -x -); \ - -129 -__w -. -__Î - = ( -x -); \ - -130 -__r -. -__l -[0] = - `__bsw­_32 - ( -__w -.__l[1]); \ - -131 -__r -. -__l -[1] = - `__bsw­_32 - ( -__w -.__l[0]); \ - -133 -__r -. -__Î -; })) - - ) - - @/usr/include/bits/endian.h - -3 #iâdeà -_ENDIAN_H - - -7  - #__BYTE_ORDER - -__LITTLE_ENDIAN - - - ) - - @/usr/include/bits/libio-ldbl.h - -20 #iâdeà -_IO_STDIO_H - - -24 - $__LDBL_REDIR_DECL - ( -_IO_vfsÿnf -) - -25 - `__LDBL_REDIR_DECL - ( -_IO_vårštf -) - - @/usr/include/bits/predefs.h - -19 #iâdeà -_FEATURES_H - - -23 #iâdeà -_PREDEFS_H - - -24  - #_PREDEFS_H - - - ) - -27  - #__STDC_IEC_559__ - 1 - - ) - -28  - #__STDC_IEC_559_COMPLEX__ - 1 - - ) - - @/usr/include/bits/sched.h - -22 #iâdeà -__Ãed_sched·¿m - - -24 #iâdeà -_SCHED_H - - -30  - #SCHED_OTHER - 0 - - ) - -31  - #SCHED_FIFO - 1 - - ) - -32  - #SCHED_RR - 2 - - ) - -33 #ifdeà -__USE_GNU - - -34  - #SCHED_BATCH - 3 - - ) - -35  - #SCHED_IDLE - 5 - - ) - -37  - #SCHED_RESET_ON_FORK - 0x40000000 - - ) - -40 #ifdeà -__USE_MISC - - -42  - #CSIGNAL - 0x000000fà - - ) - -43  - #CLONE_VM - 0x00000100 - - ) - -44  - #CLONE_FS - 0x00000200 - - ) - -45  - #CLONE_FILES - 0x00000400 - - ) - -46  - #CLONE_SIGHAND - 0x00000800 - - ) - -47  - #CLONE_PTRACE - 0x00002000 - - ) - -48  - #CLONE_VFORK - 0x00004000 - - ) - -50  - #CLONE_PARENT - 0x00008000 - - ) - -52  - #CLONE_THREAD - 0x00010000 - - ) - -53  - #CLONE_NEWNS - 0x00020000 - - ) - -54  - #CLONE_SYSVSEM - 0x00040000 - - ) - -55  - #CLONE_SETTLS - 0x00080000 - - ) - -56  - #CLONE_PARENT_SETTID - 0x00100000 - - ) - -58  - #CLONE_CHILD_CLEARTID - 0x00200000 - - ) - -60  - #CLONE_DETACHED - 0x00400000 - - ) - -61  - #CLONE_UNTRACED - 0x00800000 - - ) - -63  - #CLONE_CHILD_SETTID - 0x01000000 - - ) - -65  - #CLONE_NEWUTS - 0x04000000 - - ) - -66  - #CLONE_NEWIPC - 0x08000000 - - ) - -67  - #CLONE_NEWUSER - 0x10000000 - - ) - -68  - #CLONE_NEWPID - 0x20000000 - - ) - -69  - #CLONE_NEWNET - 0x40000000 - - ) - -70  - #CLONE_IO - 0x80000000 - - ) - -74  - ssched_·¿m - - -76  - m__sched_´iܙy -; - -79 - g__BEGIN_DECLS - - -81 #ifdeà -__USE_MISC - - -83  -þÚe - ((* -__â -è(* -__¬g -), * -__chžd_¡ack -, - -84  -__æags -, * -__¬g -, ...è -__THROW -; - -87  - $unsh¬e - ( -__æags -è -__THROW -; - -90  - $sched_g‘ýu - (è -__THROW -; - -93 -__END_DECLS - - -97 #ià! -defšed - -__defšed_sched·¿m - \ - -98 && ( -defšed - -__Ãed_sched·¿m - || defšed -_SCHED_H -) - -99  - #__defšed_sched·¿m - 1 - - ) - -101  - s__sched_·¿m - - -103  -__sched_´iܙy -; - -105 #undeà -__Ãed_sched·¿m - - -109 #ià -defšed - -_SCHED_H - && !defšed -__ýu_£t_t_defšed - - -110  - #__ýu_£t_t_defšed - - - ) - -112  - #__CPU_SETSIZE - 1024 - - ) - -113  - #__NCPUBITS - (8 *  ( -__ýu_mask -)) - - ) - -116  - t__ýu_mask -; - -119  - #__CPUELT -( -ýu -è((ýuè/ -__NCPUBITS -) - - ) - -120  - #__CPUMASK -( -ýu -è(( -__ýu_mask -è1 << ((ýuè% -__NCPUBITS -)) - - ) - -125 -__ýu_mask - -__b™s -[ -__CPU_SETSIZE - / -__NCPUBITS -]; - -126 } - týu_£t_t -; - -129 #ià - `__GNUC_PREREQ - (2, 91) - -130  - #__CPU_ZERO_S -( -£tsize -, -ýu£ -) \ - -131 dØ - `__bužtš_mem£t - ( -ýu£ -, '\0', -£tsize -); 0) - - ) - -133  - #__CPU_ZERO_S -( -£tsize -, -ýu£ -) \ - -135 -size_t - -__i -; \ - -136 -size_t - -__imax - = ( -£tsize -è/  ( -__ýu_mask -); \ - -137 -__ýu_mask - * -__b™s - = ( -ýu£ -)->__bits; \ - -138  -__i - = 0; __˜< -__imax -; ++__i) \ - -139 -__b™s -[ -__i -] = 0; \ - -140 - } -} 0) - - ) - -142  - #__CPU_SET_S -( -ýu -, -£tsize -, -ýu£ -) \ - -143 ( -__ex‹nsiÚ__ - \ - -144 ({ -size_t - -__ýu - = ( -ýu -); \ - -145 -__ýu - < 8 * ( -£tsize -) \ - -146 ? ((( -__ýu_mask - *è(( -ýu£ -)-> -__b™s -))[ - `__CPUELT - ( -__ýu -)] \ - -147 |ð - `__CPUMASK - ( -__ýu -)) \ - -148 : 0; })) - - ) - -149  - #__CPU_CLR_S -( -ýu -, -£tsize -, -ýu£ -) \ - -150 ( -__ex‹nsiÚ__ - \ - -151 ({ -size_t - -__ýu - = ( -ýu -); \ - -152 -__ýu - < 8 * ( -£tsize -) \ - -153 ? ((( -__ýu_mask - *è(( -ýu£ -)-> -__b™s -))[ - `__CPUELT - ( -__ýu -)] \ - -154 &ð~ - `__CPUMASK - ( -__ýu -)) \ - -155 : 0; })) - - ) - -156  - #__CPU_ISSET_S -( -ýu -, -£tsize -, -ýu£ -) \ - -157 ( -__ex‹nsiÚ__ - \ - -158 ({ -size_t - -__ýu - = ( -ýu -); \ - -159 -__ýu - < 8 * ( -£tsize -) \ - -160 ? (((( -__cÚ¡ - -__ýu_mask - *è(( -ýu£ -)-> -__b™s -))[ - `__CPUELT - ( -__ýu -)] \ - -161 & - `__CPUMASK - ( -__ýu -))) != 0 \ - -162 : 0; })) - - ) - -164  - #__CPU_COUNT_S -( -£tsize -, -ýu£ -) \ - -165 - `__sched_ýucouÁ - ( -£tsize -, -ýu£ -) - - ) - -167 #ià -__GNUC_PREREQ - (2, 91) - -168  - #__CPU_EQUAL_S -( -£tsize -, -ýu£1 -, -ýu£2 -) \ - -169 ( - `__bužtš_memcmp - ( -ýu£1 -, -ýu£2 -, -£tsize -è=ð0) - - ) - -171  - #__CPU_EQUAL_S -( -£tsize -, -ýu£1 -, -ýu£2 -) \ - -172 ( -__ex‹nsiÚ__ - \ - -173 ({ -__cÚ¡ - -__ýu_mask - * -__¬r1 - = ( -ýu£1 -)-> -__b™s -; \ - -174 -__cÚ¡ - -__ýu_mask - * -__¬r2 - = ( -ýu£2 -)-> -__b™s -; \ - -175 -size_t - -__imax - = ( -£tsize -è/  ( -__ýu_mask -); \ - -176 -size_t - -__i -; \ - -177  -__i - = 0; __˜< -__imax -; ++__i) \ - -178 ià( -__b™s -[ -__i -] != __bits[__i]) \ - -180 -__i - =ð -__imax -; })) - - ) - -183  - #__CPU_OP_S -( -£tsize -, -de¡£t -, -¤c£t1 -, -¤c£t2 -, -Ý -) \ - -184 ( -__ex‹nsiÚ__ - \ - -185 ({ -ýu_£t_t - * -__de¡ - = ( -de¡£t -); \ - -186 -__cÚ¡ - -__ýu_mask - * -__¬r1 - = ( -¤c£t1 -)-> -__b™s -; \ - -187 -__cÚ¡ - -__ýu_mask - * -__¬r2 - = ( -¤c£t2 -)-> -__b™s -; \ - -188 -size_t - -__imax - = ( -£tsize -è/  ( -__ýu_mask -); \ - -189 -size_t - -__i -; \ - -190  -__i - = 0; __˜< -__imax -; ++__i) \ - -191 (( -__ýu_mask - *è -__de¡ --> -__b™s -)[ -__i -] = -__¬r1 -[__i] -Ý - -__¬r2 -[__i]; \ - -192 -__de¡ -; })) - - ) - -194  - #__CPU_ALLOC_SIZE -( -couÁ -) \ - -195 (((( -couÁ -è+ -__NCPUBITS - - 1è/ __NCPUBITSè*  ( -__ýu_mask -)) - - ) - -196  - #__CPU_ALLOC -( -couÁ -è - `__sched_ýu®loc - (couÁ) - - ) - -197  - #__CPU_FREE -( -ýu£t -è - `__sched_ýuä“ - (ýu£t) - - ) - -199 -__BEGIN_DECLS - - -201  - $__sched_ýucouÁ - ( -size_t - -__£tsize -, cÚ¡ -ýu_£t_t - * -__£ -) - -202 -__THROW -; - -203 -ýu_£t_t - * - $__sched_ýu®loc - ( -size_t - -__couÁ -è -__THROW - -__wur -; - -204  - $__sched_ýuä“ - ( -ýu_£t_t - * -__£t -è -__THROW -; - -206 -__END_DECLS - - - @/usr/include/bits/stdio-lock.h - -20 #iâdeà -_BITS_STDIO_LOCK_H - - -21  - #_BITS_STDIO_LOCK_H - 1 - - ) - -23  - ~ - -24  - ~ - -28  - #_IO_lock_šex³nsive - 1 - - ) - -30 ¡ruù {  - mlock -;  - mút -; * - mowÃr -; } - t_IO_lock_t -; - -32  - #_IO_lock_š™Ÿliz” - { -LLL_LOCK_INITIALIZER -, 0, -NULL - } - - ) - -34  - #_IO_lock_š™ -( -_Çme -) \ - -35 (( -_Çme -èð( -_IO_lock_t -è -_IO_lock_š™Ÿliz” - , 0) - - ) - -37  - #_IO_lock_fši -( -_Çme -) \ - -38 ((è0) - - ) - -40  - #_IO_lock_lock -( -_Çme -) \ - -42 * -__£lf - = -THREAD_SELF -; \ - -43 ià(( -_Çme -). -owÃr - !ð -__£lf -) \ - -45 - `Îl_lock - (( -_Çme -). -lock -, -LLL_PRIVATE -); \ - -46 ( -_Çme -). -owÃr - = -__£lf -; \ - -48 ++( -_Çme -). -út -; \ - -49 } 0) - - ) - -51  - #_IO_lock_Œylock -( -_Çme -) \ - -53  -__»suÉ - = 0; \ - -54 * -__£lf - = -THREAD_SELF -; \ - -55 ià(( -_Çme -). -owÃr - !ð -__£lf -) \ - -57 ià( - `Îl_Œylock - (( -_Çme -). -lock -) == 0) \ - -59 ( -_Çme -). -owÃr - = -__£lf -; \ - -60 ( -_Çme -). -út - = 1; \ - -63 -__»suÉ - = -EBUSY -; \ - -66 ++( -_Çme -). -út -; \ - -67 -__»suÉ -; \ - -68 }) - - ) - -70  - #_IO_lock_uÆock -( -_Çme -) \ - -72 ià(--( -_Çme -). -út - == 0) \ - -74 ( -_Çme -). -owÃr - = -NULL -; \ - -75 - `Îl_uÆock - (( -_Çme -). -lock -, -LLL_PRIVATE -); \ - -77 } 0) - - ) - -81  - #_IO_þ—nup_»giÚ_¡¬t -( -_fù -, -_å -) \ - -82 - `__libc_þ—nup_»giÚ_¡¬t - ((( -_å -)-> -_æags - & -_IO_USER_LOCK -è=ð0, -_fù -, _å) - - ) - -83  - #_IO_þ—nup_»giÚ_¡¬t_nßrg -( -_fù -) \ - -84 - `__libc_þ—nup_»giÚ_¡¬t - (1, -_fù -, -NULL -) - - ) - -85  - #_IO_þ—nup_»giÚ_’d -( -_do™ -) \ - -86 - `__libc_þ—nup_»giÚ_’d - ( -_do™ -) - - ) - -88 #ià -defšed - -_LIBC - && !defšed -NOT_IN_libc - - -90 #ifdeà -__EXCEPTIONS - - -91  - #_IO_acquœe_lock -( -_å -) \ - -93 -_IO_FILE - * -_IO_acquœe_lock_fže - \ - -94 - `__©Œibu‹__ -(( - `þ—nup - ( -_IO_acquœe_lock_fù -))) \ - -95 ð( -_å -); \ - -96 - `_IO_æockfže - ( -_IO_acquœe_lock_fže -); - - ) - -97  - #_IO_acquœe_lock_þ—r_æags2 -( -_å -) \ - -99 -_IO_FILE - * -_IO_acquœe_lock_fže - \ - -100 - `__©Œibu‹__ -(( - `þ—nup - ( -_IO_acquœe_lock_þ—r_æags2_fù -))) \ - -101 ð( -_å -); \ - -102 - `_IO_æockfže - ( -_IO_acquœe_lock_fže -); - - ) - -104  - #_IO_acquœe_lock -( -_å -è -_IO_acquœe_lock_Ãeds_exû±iÚs_’abËd - - - ) - -105  - #_IO_acquœe_lock_þ—r_æags2 -( -_å -è - `_IO_acquœe_lock - (_å) - - ) - -107  - #_IO_»Ëa£_lock -( -_å -è; } 0) - - ) - - @/usr/include/bits/typesizes.h - -20 #iâdeà -_BITS_TYPES_H - - -24 #iâdef -_BITS_TYPESIZES_H - - -25  - #_BITS_TYPESIZES_H - 1 - - ) - -30  - #__DEV_T_TYPE - -__UQUAD_TYPE - - - ) - -31  - #__UID_T_TYPE - -__U32_TYPE - - - ) - -32  - #__GID_T_TYPE - -__U32_TYPE - - - ) - -33  - #__INO_T_TYPE - -__ULONGWORD_TYPE - - - ) - -34  - #__INO64_T_TYPE - -__UQUAD_TYPE - - - ) - -35  - #__MODE_T_TYPE - -__U32_TYPE - - - ) - -36  - #__NLINK_T_TYPE - -__UWORD_TYPE - - - ) - -37  - #__OFF_T_TYPE - -__SLONGWORD_TYPE - - - ) - -38  - #__OFF64_T_TYPE - -__SQUAD_TYPE - - - ) - -39  - #__PID_T_TYPE - -__S32_TYPE - - - ) - -40  - #__RLIM_T_TYPE - -__ULONGWORD_TYPE - - - ) - -41  - #__RLIM64_T_TYPE - -__UQUAD_TYPE - - - ) - -42  - #__BLKCNT_T_TYPE - -__SLONGWORD_TYPE - - - ) - -43  - #__BLKCNT64_T_TYPE - -__SQUAD_TYPE - - - ) - -44  - #__FSBLKCNT_T_TYPE - -__ULONGWORD_TYPE - - - ) - -45  - #__FSBLKCNT64_T_TYPE - -__UQUAD_TYPE - - - ) - -46  - #__FSFILCNT_T_TYPE - -__ULONGWORD_TYPE - - - ) - -47  - #__FSFILCNT64_T_TYPE - -__UQUAD_TYPE - - - ) - -48  - #__ID_T_TYPE - -__U32_TYPE - - - ) - -49  - #__CLOCK_T_TYPE - -__SLONGWORD_TYPE - - - ) - -50  - #__TIME_T_TYPE - -__SLONGWORD_TYPE - - - ) - -51  - #__USECONDS_T_TYPE - -__U32_TYPE - - - ) - -52  - #__SUSECONDS_T_TYPE - -__SLONGWORD_TYPE - - - ) - -53  - #__DADDR_T_TYPE - -__S32_TYPE - - - ) - -54  - #__SWBLK_T_TYPE - -__SLONGWORD_TYPE - - - ) - -55  - #__KEY_T_TYPE - -__S32_TYPE - - - ) - -56  - #__CLOCKID_T_TYPE - -__S32_TYPE - - - ) - -57  - #__TIMER_T_TYPE - * - - ) - -58  - #__BLKSIZE_T_TYPE - -__SLONGWORD_TYPE - - - ) - -59  - #__FSID_T_TYPE - sŒuù {  -__v® -[2]; } - - ) - -60  - #__SSIZE_T_TYPE - -__SWORD_TYPE - - - ) - -63  - #__FD_SETSIZE - 1024 - - ) - - @/usr/include/bits/uio.h - -19 #ià! -defšed - -_SYS_UIO_H - && !defšed -_FCNTL_H - - -23 #iâdeà -_BITS_UIO_H - - -24  - #_BITS_UIO_H - 1 - - ) - -26  - ~ - -40  - #UIO_MAXIOV - 1024 - - ) - -44  - siovec - - -46 * - miov_ba£ -; - -47 -size_t - - miov_Ën -; - - @/usr/include/bits/wchar.h - -20 #iâdeà -_BITS_WCHAR_H - - -21  - #_BITS_WCHAR_H - 1 - - ) - -24 #ifdeà -__WCHAR_MAX__ - - -25  - #__WCHAR_MAX - -__WCHAR_MAX__ - - - ) - -27  - #__WCHAR_MAX - (2147483647) - - ) - -32 #ifdeà -__WCHAR_UNSIGNED__ - - -33  - #__WCHAR_MIN - -L -'\0' - - ) - -37 #–ià -L -'\0' - 1 > 0 - -38  - #__WCHAR_MIN - -L -'\0' - - ) - -40  - #__WCHAR_MIN - (- -__WCHAR_MAX - - 1) - - ) - - @/usr/include/ctype.h - -24 #iâdef -_CTYPE_H - - -25  - #_CTYPE_H - 1 - - ) - -27  - ~<ã©u»s.h -> - -28  - ~ - -30 - g__BEGIN_DECLS - - -32 #iâdeà -_ISb™ - - -41  - ~<’dŸn.h -> - -42 #ià -__BYTE_ORDER - =ð -__BIG_ENDIAN - - -43  - #_ISb™ -( -b™ -è(1 << (b™)) - - ) - -45  - #_ISb™ -( -b™ -è((b™è< 8 ? ((1 << (b™)è<< 8è: ((1 << (b™)è>> 8)) - - ) - -50 - m_ISuµ” - = -_ISb™ - (0), - -51 - m_ISlow” - = -_ISb™ - (1), - -52 - m_IS®pha - = -_ISb™ - (2), - -53 - m_ISdig™ - = -_ISb™ - (3), - -54 - m_ISxdig™ - = -_ISb™ - (4), - -55 - m_IS¥aû - = -_ISb™ - (5), - -56 - m_IS´št - = -_ISb™ - (6), - -57 - m_ISg¿ph - = -_ISb™ - (7), - -58 - m_ISbÏnk - = -_ISb™ - (8), - -59 - m_ISúŒl - = -_ISb™ - (9), - -60 - m_ISpunù - = -_ISb™ - (10), - -61 - m_IS®num - = -_ISb™ - (11) - -81 -__cÚ¡ - ** - $__ùy³_b_loc - () - -82 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡ -)); - -83 -__cÚ¡ - -__št32_t - ** - $__ùy³_tÞow”_loc - () - -84 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡ -)); - -85 -__cÚ¡ - -__št32_t - ** - $__ùy³_touµ”_loc - () - -86 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡ -)); - -88  - #__isùy³ -( -c -, -ty³ -) \ - -89 ((* - `__ùy³_b_loc - ())[(è( -c -)] & (è -ty³ -) - - ) - -91  - #__i§scii -( -c -è(((cè& ~0x7fè=ð0è - - ) - -92  - #__tßscii -( -c -è((cè& 0x7fè - - ) - -94  - #__exùy³ -( -Çme -è  - `Çme - (è -__THROW - - - ) - -96 -__BEGIN_NAMESPACE_STD - - -102 - `__exùy³ - ( -i§Êum -); - -103 - `__exùy³ - ( -i§Íha -); - -104 - `__exùy³ - ( -isúŒl -); - -105 - `__exùy³ - ( -isdig™ -); - -106 - `__exùy³ - ( -i¦ow” -); - -107 - `__exùy³ - ( -isg¿ph -); - -108 - `__exùy³ - ( -i¥ršt -); - -109 - `__exùy³ - ( -i¥unù -); - -110 - `__exùy³ - ( -is¥aû -); - -111 - `__exùy³ - ( -isuµ” -); - -112 - `__exùy³ - ( -isxdig™ -); - -116  - $tÞow” - ( -__c -è -__THROW -; - -119  - $touµ” - ( -__c -è -__THROW -; - -121 -__END_NAMESPACE_STD - - -125 #ifdef -__USE_ISOC99 - - -126 -__BEGIN_NAMESPACE_C99 - - -128 - `__exùy³ - ( -isbÏnk -); - -130 -__END_NAMESPACE_C99 - - -133 #ifdeà -__USE_GNU - - -135  - $isùy³ - ( -__c -,  -__mask -è -__THROW -; - -138 #ià -defšed - -__USE_SVID - || defšed -__USE_MISC - || defšed -__USE_XOPEN - - -142  - $i§scii - ( -__c -è -__THROW -; - -146  - $tßscii - ( -__c -è -__THROW -; - -150 - `__exùy³ - ( -_touµ” -); - -151 - `__exùy³ - ( -_tÞow” -); - -155  - #__tobody -( -c -, -f -, -a -, -¬gs -) \ - -156 ( -__ex‹nsiÚ__ - \ - -157 ({  -__»s -; \ - -158 ià( ( -c -) > 1) \ - -160 ià( - `__bužtš_cÚ¡ªt_p - ( -c -)) \ - -162  -__c - = ( -c -); \ - -163 -__»s - = -__c - < -128 || __ø> 255 ? __ø: ( -a -)[__c]; \ - -166 -__»s - = -f - -¬gs -; \ - -169 -__»s - = ( -a -)[(è( -c -)]; \ - -170 -__»s -; - } -})) - - ) - -172 #ià! -defšed - -__NO_CTYPE - && !defšed -__ýlu¥lus - - -173  - #i§Êum -( -c -è - `__isùy³ -((c), -_IS®num -) - - ) - -174  - #i§Íha -( -c -è - `__isùy³ -((c), -_IS®pha -) - - ) - -175  - #isúŒl -( -c -è - `__isùy³ -((c), -_ISúŒl -) - - ) - -176  - #isdig™ -( -c -è - `__isùy³ -((c), -_ISdig™ -) - - ) - -177  - #i¦ow” -( -c -è - `__isùy³ -((c), -_ISlow” -) - - ) - -178  - #isg¿ph -( -c -è - `__isùy³ -((c), -_ISg¿ph -) - - ) - -179  - #i¥ršt -( -c -è - `__isùy³ -((c), -_IS´št -) - - ) - -180  - #i¥unù -( -c -è - `__isùy³ -((c), -_ISpunù -) - - ) - -181  - #is¥aû -( -c -è - `__isùy³ -((c), -_IS¥aû -) - - ) - -182  - #isuµ” -( -c -è - `__isùy³ -((c), -_ISuµ” -) - - ) - -183  - #isxdig™ -( -c -è - `__isùy³ -((c), -_ISxdig™ -) - - ) - -185 #ifdeà -__USE_ISOC99 - - -186  - #isbÏnk -( -c -è - `__isùy³ -((c), -_ISbÏnk -) - - ) - -189 #ifdeà -__USE_EXTERN_INLINES - - -190 -__ex‹º_šlše -  - -191 -__NTH - ( - $tÞow” - ( -__c -)) - -193  -__c - >ð-128 && __ø< 256 ? (* - `__ùy³_tÞow”_loc - ())[__c] : __c; - -194 - } -} - -196 -__ex‹º_šlše -  - -197 -__NTH - ( - $touµ” - ( -__c -)) - -199  -__c - >ð-128 && __ø< 256 ? (* - `__ùy³_touµ”_loc - ())[__c] : __c; - -200 - } -} - -203 #ià -__GNUC__ - >ð2 && -defšed - -__OPTIMIZE__ - && !defšed -__ýlu¥lus - - -204  - #tÞow” -( -c -è - `__tobody - (c, -tÞow” -, * - `__ùy³_tÞow”_loc - (), (c)) - - ) - -205  - #touµ” -( -c -è - `__tobody - (c, -touµ” -, * - `__ùy³_touµ”_loc - (), (c)) - - ) - -208 #ià -defšed - -__USE_SVID - || defšed -__USE_MISC - || defšed -__USE_XOPEN - - -209  - #i§scii -( -c -è - `__i§scii - (c) - - ) - -210  - #tßscii -( -c -è - `__tßscii - (c) - - ) - -212  - #_tÞow” -( -c -è((è(* - `__ùy³_tÞow”_loc - ())[(è(c)]) - - ) - -213  - #_touµ” -( -c -è((è(* - `__ùy³_touµ”_loc - ())[(è(c)]) - - ) - -219 #ifdeà -__USE_XOPEN2K8 - - -233  - ~ - -237  - #__isùy³_l -( -c -, -ty³ -, -loÿË -) \ - -238 (( -loÿË -)-> -__ùy³_b -[(è( -c -)] & (è -ty³ -) - - ) - -240  - #__exùy³_l -( -Çme -) \ - -241  - `Çme - (, -__loÿË_t -è -__THROW - - - ) - -247 -__exùy³_l - ( -i§Êum_l -); - -248 -__exùy³_l - ( -i§Íha_l -); - -249 -__exùy³_l - ( -isúŒl_l -); - -250 -__exùy³_l - ( -isdig™_l -); - -251 -__exùy³_l - ( -i¦ow”_l -); - -252 -__exùy³_l - ( -isg¿ph_l -); - -253 -__exùy³_l - ( -i¥ršt_l -); - -254 -__exùy³_l - ( -i¥unù_l -); - -255 -__exùy³_l - ( -is¥aû_l -); - -256 -__exùy³_l - ( -isuµ”_l -); - -257 -__exùy³_l - ( -isxdig™_l -); - -259 -__exùy³_l - ( -isbÏnk_l -); - -263  - $__tÞow”_l - ( -__c -, -__loÿË_t - -__l -è -__THROW -; - -264  - $tÞow”_l - ( -__c -, -__loÿË_t - -__l -è -__THROW -; - -267  - $__touµ”_l - ( -__c -, -__loÿË_t - -__l -è -__THROW -; - -268  - $touµ”_l - ( -__c -, -__loÿË_t - -__l -è -__THROW -; - -270 #ià -__GNUC__ - >ð2 && -defšed - -__OPTIMIZE__ - && !defšed -__ýlu¥lus - - -271  - #__tÞow”_l -( -c -, -loÿË -) \ - -272 - `__tobody - ( -c -, -__tÞow”_l -, ( -loÿË -)-> -__ùy³_tÞow” -, (c,†oÿË)) - - ) - -273  - #__touµ”_l -( -c -, -loÿË -) \ - -274 - `__tobody - ( -c -, -__touµ”_l -, ( -loÿË -)-> -__ùy³_touµ” -, (c,†oÿË)) - - ) - -275  - #tÞow”_l -( -c -, -loÿË -è - `__tÞow”_l - ((c), (loÿË)) - - ) - -276  - #touµ”_l -( -c -, -loÿË -è - `__touµ”_l - ((c), (loÿË)) - - ) - -280 #iâdeà -__NO_CTYPE - - -281  - #__i§Êum_l -( -c -, -l -è - `__isùy³_l -((c), -_IS®num -, (l)) - - ) - -282  - #__i§Íha_l -( -c -, -l -è - `__isùy³_l -((c), -_IS®pha -, (l)) - - ) - -283  - #__isúŒl_l -( -c -, -l -è - `__isùy³_l -((c), -_ISúŒl -, (l)) - - ) - -284  - #__isdig™_l -( -c -, -l -è - `__isùy³_l -((c), -_ISdig™ -, (l)) - - ) - -285  - #__i¦ow”_l -( -c -, -l -è - `__isùy³_l -((c), -_ISlow” -, (l)) - - ) - -286  - #__isg¿ph_l -( -c -, -l -è - `__isùy³_l -((c), -_ISg¿ph -, (l)) - - ) - -287  - #__i¥ršt_l -( -c -, -l -è - `__isùy³_l -((c), -_IS´št -, (l)) - - ) - -288  - #__i¥unù_l -( -c -, -l -è - `__isùy³_l -((c), -_ISpunù -, (l)) - - ) - -289  - #__is¥aû_l -( -c -, -l -è - `__isùy³_l -((c), -_IS¥aû -, (l)) - - ) - -290  - #__isuµ”_l -( -c -, -l -è - `__isùy³_l -((c), -_ISuµ” -, (l)) - - ) - -291  - #__isxdig™_l -( -c -, -l -è - `__isùy³_l -((c), -_ISxdig™ -, (l)) - - ) - -293  - #__isbÏnk_l -( -c -, -l -è - `__isùy³_l -((c), -_ISbÏnk -, (l)) - - ) - -295 #ià -defšed - -__USE_SVID - || defšed -__USE_MISC - - -296  - #__i§scii_l -( -c -, -l -è(Ö), - `__i§scii - (c)) - - ) - -297  - #__tßscii_l -( -c -, -l -è(Ö), - `__tßscii - (c)) - - ) - -300  - #i§Êum_l -( -c -, -l -è - `__i§Êum_l - ((c), (l)) - - ) - -301  - #i§Íha_l -( -c -, -l -è - `__i§Íha_l - ((c), (l)) - - ) - -302  - #isúŒl_l -( -c -, -l -è - `__isúŒl_l - ((c), (l)) - - ) - -303  - #isdig™_l -( -c -, -l -è - `__isdig™_l - ((c), (l)) - - ) - -304  - #i¦ow”_l -( -c -, -l -è - `__i¦ow”_l - ((c), (l)) - - ) - -305  - #isg¿ph_l -( -c -, -l -è - `__isg¿ph_l - ((c), (l)) - - ) - -306  - #i¥ršt_l -( -c -, -l -è - `__i¥ršt_l - ((c), (l)) - - ) - -307  - #i¥unù_l -( -c -, -l -è - `__i¥unù_l - ((c), (l)) - - ) - -308  - #is¥aû_l -( -c -, -l -è - `__is¥aû_l - ((c), (l)) - - ) - -309  - #isuµ”_l -( -c -, -l -è - `__isuµ”_l - ((c), (l)) - - ) - -310  - #isxdig™_l -( -c -, -l -è - `__isxdig™_l - ((c), (l)) - - ) - -312  - #isbÏnk_l -( -c -, -l -è - `__isbÏnk_l - ((c), (l)) - - ) - -314 #ià -defšed - -__USE_SVID - || defšed -__USE_MISC - - -315  - #i§scii_l -( -c -, -l -è - `__i§scii_l - ((c), (l)) - - ) - -316  - #tßscii_l -( -c -, -l -è - `__tßscii_l - ((c), (l)) - - ) - -323 -__END_DECLS - - - @/usr/include/gnu/stubs.h - -4  - ~ - -6 #ià -__WORDSIZE - == 32 - -7  - ~ - -8 #–ià -__WORDSIZE - == 64 - -9  - ~ - - @/usr/include/linux/errno.h - -1 #iâdeà -_LINUX_ERRNO_H - - -2  - #_LINUX_ERRNO_H - - - ) - -4  - ~ - - @/usr/include/bits/libc-lock.h - -20 #iâdeà -_BITS_LIBC_LOCK_H - - -21  - #_BITS_LIBC_LOCK_H - 1 - - ) - -23  - ~<±h»ad.h -> - -24  - #__Ãed_NULL - - - ) - -25  - ~<¡ddef.h -> - -34 #ifdeà -_LIBC - - -35  - ~ - -36  - ~<Žs.h -> - -37  - ~<±h»ad-funùiÚs.h -> - -38  - ~<”ºo.h -> - -39  - ~ - -43 #ià -defšed - -_LIBC - || defšed -_IO_MTSAFE_IO - - -44 #ià( -defšed - -NOT_IN_libc - && !defšed -IS_IN_lib±h»ad -è|| !defšed -_LIBC - - -45  -±h»ad_mu‹x_t - - t__libc_lock_t -; - -46 ¡ruù { -±h»ad_mu‹x_t - - mmu‹x -; } - t__libc_lock_»cursive_t -; - -48  - t__libc_lock_t -; - -49 ¡ruù {  - mlock -;  - mút -; * - mowÃr -; } - t__libc_lock_»cursive_t -; - -51 ¡ruù { -±h»ad_mu‹x_t - - mmu‹x -; } - t__¹ld_lock_»cursive_t -; - -52 #ifdeà -__USE_UNIX98 - - -53  -±h»ad_rwlock_t - - t__libc_rwlock_t -; - -55  -__libc_rwlock_Ýaque__ - - t__libc_rwlock_t -; - -58  -__libc_lock_Ýaque__ - - t__libc_lock_t -; - -59  -__libc_lock_»cursive_Ýaque__ - - t__libc_lock_»cursive_t -; - -60  -__libc_rwlock_Ýaque__ - - t__libc_rwlock_t -; - -64  -±h»ad_key_t - - t__libc_key_t -; - -73  - #__libc_lock_defše -( -CLASS -, -NAME -) \ - -74 -CLASS - -__libc_lock_t - -NAME -; - - ) - -75  - #__libc_rwlock_defše -( -CLASS -, -NAME -) \ - -76 -CLASS - -__libc_rwlock_t - -NAME -; - - ) - -77  - #__libc_lock_defše_»cursive -( -CLASS -, -NAME -) \ - -78 -CLASS - -__libc_lock_»cursive_t - -NAME -; - - ) - -79  - #__¹ld_lock_defše_»cursive -( -CLASS -, -NAME -) \ - -80 -CLASS - -__¹ld_lock_»cursive_t - -NAME -; - - ) - -91 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -92 #ià -LLL_LOCK_INITIALIZER - == 0 - -93  - #__libc_lock_defše_š™Ÿlized -( -CLASS -, -NAME -) \ - -94 -CLASS - -__libc_lock_t - -NAME -; - - ) - -96  - #__libc_lock_defše_š™Ÿlized -( -CLASS -, -NAME -) \ - -97 -CLASS - -__libc_lock_t - -NAME - = -LLL_LOCK_INITIALIZER -; - - ) - -100 #ià -__LT_SPINLOCK_INIT - == 0 - -101  - #__libc_lock_defše_š™Ÿlized -( -CLASS -, -NAME -) \ - -102 -CLASS - -__libc_lock_t - -NAME -; - - ) - -104  - #__libc_lock_defše_š™Ÿlized -( -CLASS -, -NAME -) \ - -105 -CLASS - -__libc_lock_t - -NAME - = -PTHREAD_MUTEX_INITIALIZER -; - - ) - -109  - #__libc_rwlock_defše_š™Ÿlized -( -CLASS -, -NAME -) \ - -110 -CLASS - -__libc_rwlock_t - -NAME - = -PTHREAD_RWLOCK_INITIALIZER -; - - ) - -114 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -115 #ià -LLL_LOCK_INITIALIZER - == 0 - -116  - #__libc_lock_defše_š™Ÿlized_»cursive -( -CLASS -, -NAME -) \ - -117 -CLASS - -__libc_lock_»cursive_t - -NAME -; - - ) - -119  - #__libc_lock_defše_š™Ÿlized_»cursive -( -CLASS -, -NAME -) \ - -120 -CLASS - -__libc_lock_»cursive_t - -NAME - = -_LIBC_LOCK_RECURSIVE_INITIALIZER -; - - ) - -122  - #_LIBC_LOCK_RECURSIVE_INITIALIZER - \ - -123 { -LLL_LOCK_INITIALIZER -, 0, -NULL - } - - ) - -125  - #__libc_lock_defše_š™Ÿlized_»cursive -( -CLASS -, -NAME -) \ - -126 -CLASS - -__libc_lock_»cursive_t - -NAME - = -_LIBC_LOCK_RECURSIVE_INITIALIZER -; - - ) - -127  - #_LIBC_LOCK_RECURSIVE_INITIALIZER - \ - -128 { -PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP -} - - ) - -131  - #__¹ld_lock_defše_š™Ÿlized_»cursive -( -CLASS -, -NAME -) \ - -132 -CLASS - -__¹ld_lock_»cursive_t - -NAME - = -_RTLD_LOCK_RECURSIVE_INITIALIZER -; - - ) - -133  - #_RTLD_LOCK_RECURSIVE_INITIALIZER - \ - -134 { -PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP -} - - ) - -136  - #__¹ld_lock_š™Ÿlize -( -NAME -) \ - -137 (è(( -NAME -èð( -__¹ld_lock_»cursive_t -è -_RTLD_LOCK_RECURSIVE_INITIALIZER -) - - ) - -144 #ifdeà -__PIC__ - - -145  - #__libc_maybe_ÿÎ -( -FUNC -, -ARGS -, -ELSE -) \ - -146 ( - `__ex‹nsiÚ__ - ({ - `__ty³of - ( -FUNC -è* -_â - = (FUNC); \ - -147 -_â - !ð -NULL - ? (*_âè -ARGS - : -ELSE -; })) - - ) - -149  - #__libc_maybe_ÿÎ -( -FUNC -, -ARGS -, -ELSE -) \ - -150 ( -FUNC - !ð -NULL - ? FUNC -ARGS - : -ELSE -) - - ) - -154 #ià -defšed - -SHARED - && !defšed -NOT_IN_libc - - -155  - #PTFAVAIL -( -NAME -è -__libc_±h»ad_funùiÚs_š™ - - - ) - -156  - #__libc_±f_ÿÎ -( -FUNC -, -ARGS -, -ELSE -) \ - -157 ( -__libc_±h»ad_funùiÚs_š™ - ? - `PTHFCT_CALL - ( -±r_ -## -FUNC -, -ARGS -è: -ELSE -) - - ) - -158  - #__libc_±f_ÿÎ_®ways -( -FUNC -, -ARGS -) \ - -159 - `PTHFCT_CALL - ( -±r_ -## -FUNC -, -ARGS -) - - ) - -161  - #PTFAVAIL -( -NAME -è(NAME !ð -NULL -) - - ) - -162  - #__libc_±f_ÿÎ -( -FUNC -, -ARGS -, -ELSE -) \ - -163 - `__libc_maybe_ÿÎ - ( -FUNC -, -ARGS -, -ELSE -) - - ) - -164  - #__libc_±f_ÿÎ_®ways -( -FUNC -, -ARGS -) \ - -165 -FUNC - -ARGS - - - ) - -171 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -172  - #__libc_lock_š™ -( -NAME -è((NAMEèð -LLL_LOCK_INITIALIZER -, 0) - - ) - -174  - #__libc_lock_š™ -( -NAME -) \ - -175 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_š™ -, (&( -NAME -), -NULL -), 0) - - ) - -177 #ià -defšed - -SHARED - && !defšed -NOT_IN_libc - - -180  - #__libc_rwlock_š™ -( -NAME -) \ - -181 ( - `__bužtš_mem£t - (&( -NAME -), '\0',  (NAME)), 0) - - ) - -183  - #__libc_rwlock_š™ -( -NAME -) \ - -184 - `__libc_maybe_ÿÎ - ( -__±h»ad_rwlock_š™ -, (&( -NAME -), -NULL -), 0) - - ) - -188 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -189  - #__libc_lock_š™_»cursive -( -NAME -) \ - -190 (( -NAME -èð( -__libc_lock_»cursive_t -è -_LIBC_LOCK_RECURSIVE_INITIALIZER -, 0) - - ) - -192  - #__libc_lock_š™_»cursive -( -NAME -) \ - -194 ià( -__±h»ad_mu‹x_š™ - !ð -NULL -) \ - -196 -±h»ad_mu‹x©Œ_t - -__©Œ -; \ - -197 - `__±h»ad_mu‹x©Œ_š™ - (& -__©Œ -); \ - -198 - `__±h»ad_mu‹x©Œ_£‰y³ - (& -__©Œ -, -PTHREAD_MUTEX_RECURSIVE_NP -); \ - -199 - `__±h»ad_mu‹x_š™ - (&( -NAME -). -mu‹x -, & -__©Œ -); \ - -200 - `__±h»ad_mu‹x©Œ_de¡roy - (& -__©Œ -); \ - -202 } 0) - - ) - -205  - #__¹ld_lock_š™_»cursive -( -NAME -) \ - -207 ià( -__±h»ad_mu‹x_š™ - !ð -NULL -) \ - -209 -±h»ad_mu‹x©Œ_t - -__©Œ -; \ - -210 - `__±h»ad_mu‹x©Œ_š™ - (& -__©Œ -); \ - -211 - `__±h»ad_mu‹x©Œ_£‰y³ - (& -__©Œ -, -PTHREAD_MUTEX_RECURSIVE_NP -); \ - -212 - `__±h»ad_mu‹x_š™ - (&( -NAME -). -mu‹x -, & -__©Œ -); \ - -213 - `__±h»ad_mu‹x©Œ_de¡roy - (& -__©Œ -); \ - -215 } 0) - - ) - -220 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -221  - #__libc_lock_fši -( -NAME -è((è0) - - ) - -223  - #__libc_lock_fši -( -NAME -) \ - -224 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_de¡roy -, (&( -NAME -)), 0) - - ) - -226 #ià -defšed - -SHARED - && !defšed -NOT_IN_libc - - -227  - #__libc_rwlock_fši -( -NAME -è((è0) - - ) - -229  - #__libc_rwlock_fši -( -NAME -) \ - -230 - `__libc_maybe_ÿÎ - ( -__±h»ad_rwlock_de¡roy -, (&( -NAME -)), 0) - - ) - -234 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -235  - #__libc_lock_fši_»cursive -( -NAME -è((è0) - - ) - -237  - #__libc_lock_fši_»cursive -( -NAME -) \ - -238 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_de¡roy -, (&( -NAME -)), 0) - - ) - -242 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -243 #ià -__OPTION_EGLIBC_BIG_MACROS - != 1 - -247  -__libc_lock_lock_â - ( -__libc_lock_t - *); - -248 -libc_hidd’_´Ùo - ( -__libc_lock_lock_â -); - -250 #ià -__OPTION_EGLIBC_BIG_MACROS - - -251  - #__libc_lock_lock -( -NAME -) \ - -252 ({ - `Îl_lock - ( -NAME -, -LLL_PRIVATE -); 0; }) - - ) - -254  - #__libc_lock_lock -( -NAME -) \ - -255 - `__libc_lock_lock_â - (&( -NAME -)) - - ) - -258  - #__libc_lock_lock -( -NAME -) \ - -259 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_lock -, (&( -NAME -)), 0) - - ) - -261  - #__libc_rwlock_rdlock -( -NAME -) \ - -262 - `__libc_±f_ÿÎ - ( -__±h»ad_rwlock_rdlock -, (&( -NAME -)), 0) - - ) - -263  - #__libc_rwlock_w¾ock -( -NAME -) \ - -264 - `__libc_±f_ÿÎ - ( -__±h»ad_rwlock_w¾ock -, (&( -NAME -)), 0) - - ) - -267 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -268 #ià -__OPTION_EGLIBC_BIG_MACROS - != 1 - -272  -__libc_lock_lock_»cursive_â - ( -__libc_lock_»cursive_t - *); - -273 -libc_hidd’_´Ùo - ( -__libc_lock_lock_»cursive_â -); - -275 #ià -__OPTION_EGLIBC_BIG_MACROS - - -276  - #__libc_lock_lock_»cursive -( -NAME -) \ - -278 * -£lf - = -THREAD_SELF -; \ - -279 ià(( -NAME -). -owÃr - !ð -£lf -) \ - -281 - `Îl_lock - (( -NAME -). -lock -, -LLL_PRIVATE -); \ - -282 ( -NAME -). -owÃr - = -£lf -; \ - -284 ++( -NAME -). -út -; \ - -285 } 0) - - ) - -287  - #__libc_lock_lock_»cursive -( -NAME -) \ - -288 - `__libc_lock_lock_»cursive_â - (&( -NAME -)) - - ) - -291  - #__libc_lock_lock_»cursive -( -NAME -) \ - -292 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_lock -, (&( -NAME -). -mu‹x -), 0) - - ) - -296 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -297 #ià -__OPTION_EGLIBC_BIG_MACROS - != 1 - -301  -__libc_lock_Œylock_â - ( -__libc_lock_t - *); - -302 -libc_hidd’_´Ùo - ( -__libc_lock_Œylock_â -); - -304 #ià -__OPTION_EGLIBC_BIG_MACROS - - -305  - #__libc_lock_Œylock -( -NAME -) \ - -306 - `Îl_Œylock - ( -NAME -) - - ) - -308  - #__libc_lock_Œylock -( -NAME -) \ - -309 - `__libc_lock_Œylock_â - (&( -NAME -)) - - ) - -312  - #__libc_lock_Œylock -( -NAME -) \ - -313 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_Œylock -, (&( -NAME -)), 0) - - ) - -315  - #__libc_rwlock_Œyrdlock -( -NAME -) \ - -316 - `__libc_maybe_ÿÎ - ( -__±h»ad_rwlock_Œyrdlock -, (&( -NAME -)), 0) - - ) - -317  - #__libc_rwlock_Œyw¾ock -( -NAME -) \ - -318 - `__libc_maybe_ÿÎ - ( -__±h»ad_rwlock_Œyw¾ock -, (&( -NAME -)), 0) - - ) - -321 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -322 #ià -__OPTION_EGLIBC_BIG_MACROS - != 1 - -326  -__libc_lock_Œylock_»cursive_â - ( -__libc_lock_»cursive_t - *); - -327 -libc_hidd’_´Ùo - ( -__libc_lock_Œylock_»cursive_â -); - -329 #ià -__OPTION_EGLIBC_BIG_MACROS - - -330  - #__libc_lock_Œylock_»cursive -( -NAME -) \ - -332  -»suÉ - = 0; \ - -333 * -£lf - = -THREAD_SELF -; \ - -334 ià(( -NAME -). -owÃr - !ð -£lf -) \ - -336 ià( - `Îl_Œylock - (( -NAME -). -lock -) == 0) \ - -338 ( -NAME -). -owÃr - = -£lf -; \ - -339 ( -NAME -). -út - = 1; \ - -342 -»suÉ - = -EBUSY -; \ - -345 ++( -NAME -). -út -; \ - -346 -»suÉ -; \ - -347 }) - - ) - -349  - #__libc_lock_Œylock_»cursive -( -NAME -) \ - -350 - `__libc_lock_Œylock_»cursive_â - (&( -NAME -)) - - ) - -353  - #__libc_lock_Œylock_»cursive -( -NAME -) \ - -354 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_Œylock -, (&( -NAME -)), 0) - - ) - -357  - #__¹ld_lock_Œylock_»cursive -( -NAME -) \ - -358 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_Œylock -, (&( -NAME -). -mu‹x -), 0) - - ) - -361 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -362 #ià -__OPTION_EGLIBC_BIG_MACROS - != 1 - -366  -__libc_lock_uÆock_â - ( -__libc_lock_t - *); - -367 -libc_hidd’_´Ùo - ( -__libc_lock_uÆock_â -); - -369 #ià -__OPTION_EGLIBC_BIG_MACROS - - -370  - #__libc_lock_uÆock -( -NAME -) \ - -371 - `Îl_uÆock - ( -NAME -, -LLL_PRIVATE -) - - ) - -373  - #__libc_lock_uÆock -( -NAME -) \ - -374 - `__libc_lock_uÆock_â - (&( -NAME -)) - - ) - -377  - #__libc_lock_uÆock -( -NAME -) \ - -378 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_uÆock -, (&( -NAME -)), 0) - - ) - -380  - #__libc_rwlock_uÆock -( -NAME -) \ - -381 - `__libc_±f_ÿÎ - ( -__±h»ad_rwlock_uÆock -, (&( -NAME -)), 0) - - ) - -384 #ià -defšed - -_LIBC - && (!defšed -NOT_IN_libc - || defšed -IS_IN_lib±h»ad -) - -385 #ià -__OPTION_EGLIBC_BIG_MACROS - != 1 - -389  -__libc_lock_uÆock_»cursive_â - ( -__libc_lock_»cursive_t - *); - -390 -libc_hidd’_´Ùo - ( -__libc_lock_uÆock_»cursive_â -); - -392 #ià -__OPTION_EGLIBC_BIG_MACROS - - -394  - #__libc_lock_uÆock_»cursive -( -NAME -) \ - -396 ià(--( -NAME -). -út - == 0) \ - -398 ( -NAME -). -owÃr - = -NULL -; \ - -399 - `Îl_uÆock - (( -NAME -). -lock -, -LLL_PRIVATE -); \ - -401 } 0) - - ) - -403  - #__libc_lock_uÆock_»cursive -( -NAME -) \ - -404 - `__libc_lock_uÆock_»cursive_â - (&( -NAME -)) - - ) - -407  - #__libc_lock_uÆock_»cursive -( -NAME -) \ - -408 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_uÆock -, (&( -NAME -)), 0) - - ) - -411 #ià -defšed - -_LIBC - && defšed -SHARED - - -412  - #__¹ld_lock_deçuÉ_lock_»cursive -( -lock -) \ - -413 ++(( -±h»ad_mu‹x_t - *)( -lock -))-> -__d©a -. -__couÁ -; - - ) - -415  - #__¹ld_lock_deçuÉ_uÆock_»cursive -( -lock -) \ - -416 --(( -±h»ad_mu‹x_t - *)( -lock -))-> -__d©a -. -__couÁ -; - - ) - -418  - #__¹ld_lock_lock_»cursive -( -NAME -) \ - -419 - `GL -( -dl_¹ld_lock_»cursive -è(&( -NAME -). -mu‹x -) - - ) - -421  - #__¹ld_lock_uÆock_»cursive -( -NAME -) \ - -422 - `GL -( -dl_¹ld_uÆock_»cursive -è(&( -NAME -). -mu‹x -) - - ) - -424  - #__¹ld_lock_lock_»cursive -( -NAME -) \ - -425 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_lock -, (&( -NAME -). -mu‹x -), 0) - - ) - -427  - #__¹ld_lock_uÆock_»cursive -( -NAME -) \ - -428 - `__libc_maybe_ÿÎ - ( -__±h»ad_mu‹x_uÆock -, (&( -NAME -). -mu‹x -), 0) - - ) - -432 #ià -PTHREAD_ONCE_INIT - == 0 - -435  - #__libc_Úû_defše -( -CLASS -, -NAME -) \ - -436 -CLASS - -±h»ad_Úû_t - -NAME - - - ) - -438  - #__libc_Úû_defše -( -CLASS -, -NAME -) \ - -439 -CLASS - -±h»ad_Úû_t - -NAME - = -PTHREAD_ONCE_INIT - - - ) - -443  - #__libc_Úû -( -ONCE_CONTROL -, -INIT_FUNCTION -) \ - -445 ià( - `PTFAVAIL - ( -__±h»ad_Úû -)) \ - -446 - `__libc_±f_ÿÎ_®ways - ( -__±h»ad_Úû -, (&( -ONCE_CONTROL -), \ - -447 -INIT_FUNCTION -)); \ - -448 ià(( -ONCE_CONTROL -è=ð -PTHREAD_ONCE_INIT -) { \ - -449 - `INIT_FUNCTION - (); \ - -450 ( -ONCE_CONTROL -) |= 2; \ - -452 } 0) - - ) - -459  -_±h»ad_þ—nup_push - ( -_±h»ad_þ—nup_bufãr - * -bufãr -, - -460 (* -routše -è(*), * -¬g -); - -461  - `_±h»ad_þ—nup_pÝ - ( -_±h»ad_þ—nup_bufãr - * -bufãr -, - -462  -execu‹ -); - -463  - `_±h»ad_þ—nup_push_deãr - ( -_±h»ad_þ—nup_bufãr - * -bufãr -, - -464 (* -routše -è(*), * -¬g -); - -465  - `_±h»ad_þ—nup_pÝ_»¡Üe - ( -_±h»ad_þ—nup_bufãr - * -bufãr -, - -466  -execu‹ -); - -469  - #__libc_þ—nup_»giÚ_¡¬t -( -DOIT -, -FCT -, -ARG -) \ - -470 {  -_±h»ad_þ—nup_bufãr - -_bufãr -; \ - -471  -_avaž -; \ - -472 ià( -DOIT -) { \ - -473 -_avaž - = - `PTFAVAIL - ( -_±h»ad_þ—nup_push_deãr -); \ - -474 ià( -_avaž -) { \ - -475 - `__libc_±f_ÿÎ_®ways - ( -_±h»ad_þ—nup_push_deãr -, (& -_bufãr -, -FCT -, \ - -476 -ARG -)); \ - -478 -_bufãr -. -__routše - = ( -FCT -); \ - -479 -_bufãr -. -__¬g - = ( -ARG -); \ - -482 -_avaž - = 0; \ - -483 } - - ) - -486  - #__libc_þ—nup_»giÚ_’d -( -DOIT -) \ - -487 ià( -_avaž -) { \ - -488 - `__libc_±f_ÿÎ_®ways - ( -_±h»ad_þ—nup_pÝ_»¡Üe -, (& -_bufãr -, -DOIT -));\ - -489 } ià( -DOIT -) \ - -490 -_bufãr -. - `__routše - (_bufãr. -__¬g -); \ - -491 - } - - ) -} - -494  - #__libc_þ—nup_’d -( -DOIT -) \ - -495 ià( -_avaž -) { \ - -496 - `__libc_±f_ÿÎ_®ways - ( -_±h»ad_þ—nup_pÝ_»¡Üe -, (& -_bufãr -, -DOIT -));\ - -497 } ià( -DOIT -) \ - -498 -_bufãr -. - `__routše - (_bufãr. -__¬g -) - - ) - -502 -__ex‹º_šlše -  - -503 - $__libc_þ—nup_routše - ( -__±h»ad_þ—nup_äame - * -f -) - -505 ià( -f --> -__do_™ -) - -506 -f --> - `__ÿnûl_routše - (f-> -__ÿnûl_¬g -); - -507 - } -} - -509  - #__libc_þ—nup_push -( -fù -, -¬g -) \ - -511  -__±h»ad_þ—nup_äame - -__þäame - \ - -512 - `__©Œibu‹__ - (( - `__þ—nup__ - ( -__libc_þ—nup_routše -))) \ - -513 ð{ . -__ÿnûl_routše - = ( -fù -), . -__ÿnûl_¬g - = ( -¬g -), \ - -514 . -__do_™ - = 1 }; - - ) - -516  - #__libc_þ—nup_pÝ -( -execu‹ -) \ - -517 -__þäame -. -__do_™ - = ( -execu‹ -); \ - -518 } 0) - - ) - -522  - #__libc_key_ü—‹ -( -KEY -, -DESTRUCTOR -) \ - -523 - `__libc_±f_ÿÎ - ( -__±h»ad_key_ü—‹ -, ( -KEY -, -DESTRUCTOR -), 1) - - ) - -526  - #__libc_g‘¥ecific -( -KEY -) \ - -527 - `__libc_±f_ÿÎ - ( -__±h»ad_g‘¥ecific -, ( -KEY -), -NULL -) - - ) - -530  - #__libc_£t¥ecific -( -KEY -, -VALUE -) \ - -531 - `__libc_±f_ÿÎ - ( -__±h»ad_£t¥ecific -, ( -KEY -, -VALUE -), 0) - - ) - -537  - #__libc_©fÜk -( -PREPARE -, -PARENT -, -CHILD -) \ - -538 - `__»gi¡”_©fÜk - ( -PREPARE -, -PARENT -, -CHILD -, -NULL -) - - ) - -539  -__»gi¡”_©fÜk - ((* -__´•¬e -) (), - -540 (* -__·»Á -) (), - -541 (* -__chžd -) (), - -542 * -__dso_hªdË -); - -547  - `__±h»ad_mu‹x_š™ - ( -±h»ad_mu‹x_t - * -__mu‹x -, - -548 -__cÚ¡ - -±h»ad_mu‹x©Œ_t - * -__mu‹x_©Œ -); - -550  - `__±h»ad_mu‹x_de¡roy - ( -±h»ad_mu‹x_t - * -__mu‹x -); - -552  - `__±h»ad_mu‹x_Œylock - ( -±h»ad_mu‹x_t - * -__mu‹x -); - -554  - `__±h»ad_mu‹x_lock - ( -±h»ad_mu‹x_t - * -__mu‹x -); - -556  - `__±h»ad_mu‹x_uÆock - ( -±h»ad_mu‹x_t - * -__mu‹x -); - -558  - `__±h»ad_mu‹x©Œ_š™ - ( -±h»ad_mu‹x©Œ_t - * -__©Œ -); - -560  - `__±h»ad_mu‹x©Œ_de¡roy - ( -±h»ad_mu‹x©Œ_t - * -__©Œ -); - -562  - `__±h»ad_mu‹x©Œ_£‰y³ - ( -±h»ad_mu‹x©Œ_t - * -__©Œ -, - -563  -__kšd -); - -565 #ifdeà -__USE_UNIX98 - - -566  - `__±h»ad_rwlock_š™ - ( -±h»ad_rwlock_t - * -__rwlock -, - -567 -__cÚ¡ - -±h»ad_rwlock©Œ_t - * -__©Œ -); - -569  - `__±h»ad_rwlock_de¡roy - ( -±h»ad_rwlock_t - * -__rwlock -); - -571  - `__±h»ad_rwlock_rdlock - ( -±h»ad_rwlock_t - * -__rwlock -); - -573  - `__±h»ad_rwlock_Œyrdlock - ( -±h»ad_rwlock_t - * -__rwlock -); - -575  - `__±h»ad_rwlock_w¾ock - ( -±h»ad_rwlock_t - * -__rwlock -); - -577  - `__±h»ad_rwlock_Œyw¾ock - ( -±h»ad_rwlock_t - * -__rwlock -); - -579  - `__±h»ad_rwlock_uÆock - ( -±h»ad_rwlock_t - * -__rwlock -); - -582  - `__±h»ad_key_ü—‹ - ( -±h»ad_key_t - * -__key -, - -583 (* -__de¡r_funùiÚ -) (*)); - -585  - `__±h»ad_£t¥ecific - ( -±h»ad_key_t - -__key -, - -586 -__cÚ¡ - * -__poš‹r -); - -588 * - `__±h»ad_g‘¥ecific - ( -±h»ad_key_t - -__key -); - -590  - `__±h»ad_Úû - ( -±h»ad_Úû_t - * -__Úû_cÚŒÞ -, - -591 (* -__š™_routše -) ()); - -593  - `__±h»ad_©fÜk - ((* -__´•¬e -) (), - -594 (* -__·»Á -) (), - -595 (* -__chžd -) ()); - -601 #iâdeà -__NO_WEAK_PTHREAD_ALIASES - - -602 #ifdeà -w—k_ex‹º - - -603 #ià -_LIBC - - -604  - ~ - -606  - #BP_SYM -( -sym -è - ) -sym - -608 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_mu‹x_š™ -)) - -609 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_mu‹x_de¡roy -)) - -610 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_mu‹x_lock -)) - -611 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_mu‹x_Œylock -)) - -612 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_mu‹x_uÆock -)) - -613 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_mu‹x©Œ_š™ -)) - -614 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_mu‹x©Œ_de¡roy -)) - -615 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_mu‹x©Œ_£‰y³ -)) - -616 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_rwlock_š™ -)) - -617 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_rwlock_de¡roy -)) - -618 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_rwlock_rdlock -)) - -619 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_rwlock_Œyrdlock -)) - -620 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_rwlock_w¾ock -)) - -621 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_rwlock_Œyw¾ock -)) - -622 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_rwlock_uÆock -)) - -623 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_key_ü—‹ -)) - -624 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_£t¥ecific -)) - -625 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_g‘¥ecific -)) - -626 - `w—k_ex‹º - ( - $BP_SYM - ( -__±h»ad_Úû -)) - -627 - $w—k_ex‹º - ( -__±h»ad_š™Ÿlize -) - -628 - $w—k_ex‹º - ( -__±h»ad_©fÜk -) - -629 - `w—k_ex‹º - ( - $BP_SYM - ( -_±h»ad_þ—nup_push_deãr -)) - -630 - `w—k_ex‹º - ( - $BP_SYM - ( -_±h»ad_þ—nup_pÝ_»¡Üe -)) - -631 - `w—k_ex‹º - ( - $BP_SYM - ( -±h»ad_£tÿnûl¡©e -)) - -633 #´agm¨ -w—k - -__±h»ad_mu‹x_š™ - - -634 #´agm¨ -w—k - -__±h»ad_mu‹x_de¡roy - - -635 #´agm¨ -w—k - -__±h»ad_mu‹x_lock - - -636 #´agm¨ -w—k - -__±h»ad_mu‹x_Œylock - - -637 #´agm¨ -w—k - -__±h»ad_mu‹x_uÆock - - -638 #´agm¨ -w—k - -__±h»ad_mu‹x©Œ_š™ - - -639 #´agm¨ -w—k - -__±h»ad_mu‹x©Œ_de¡roy - - -640 #´agm¨ -w—k - -__±h»ad_mu‹x©Œ_£‰y³ - - -641 #´agm¨ -w—k - -__±h»ad_rwlock_de¡roy - - -642 #´agm¨ -w—k - -__±h»ad_rwlock_rdlock - - -643 #´agm¨ -w—k - -__±h»ad_rwlock_Œyrdlock - - -644 #´agm¨ -w—k - -__±h»ad_rwlock_w¾ock - - -645 #´agm¨ -w—k - -__±h»ad_rwlock_Œyw¾ock - - -646 #´agm¨ -w—k - -__±h»ad_rwlock_uÆock - - -647 #´agm¨ -w—k - -__±h»ad_key_ü—‹ - - -648 #´agm¨ -w—k - -__±h»ad_£t¥ecific - - -649 #´agm¨ -w—k - -__±h»ad_g‘¥ecific - - -650 #´agm¨ -w—k - -__±h»ad_Úû - - -651 #´agm¨ -w—k - -__±h»ad_š™Ÿlize - - -652 #´agm¨ -w—k - -__±h»ad_©fÜk - - -653 #´agm¨ -w—k - -_±h»ad_þ—nup_push_deãr - - -654 #´agm¨ -w—k - -_±h»ad_þ—nup_pÝ_»¡Üe - - -655 #´agm¨ -w—k - -±h»ad_£tÿnûl¡©e - - - @/usr/include/gconv.h - -23 #iâdeà -_GCONV_H - - -24  - #_GCONV_H - 1 - - ) - -26  - ~<ã©u»s.h -> - -27  - #__Ãed_mb¡©e_t - - - ) - -28  - #__Ãed_wšt_t - - - ) - -29  - ~ - -30  - #__Ãed_size_t - - - ) - -31  - #__Ãed_wch¬_t - - - ) - -32  - ~<¡ddef.h -> - -35  - #__UNKNOWN_10646_CHAR - (( -wch¬_t -è0xfffd) - - ) - -40 - m__GCONV_OK - = 0, - -41 - m__GCONV_NOCONV -, - -42 - m__GCONV_NODB -, - -43 - m__GCONV_NOMEM -, - -45 - m__GCONV_EMPTY_INPUT -, - -46 - m__GCONV_FULL_OUTPUT -, - -47 - m__GCONV_ILLEGAL_INPUT -, - -48 - m__GCONV_INCOMPLETE_INPUT -, - -50 - m__GCONV_ILLEGAL_DESCRIPTOR -, - -51 - m__GCONV_INTERNAL_ERROR - - -58 - m__GCONV_IS_LAST - = 0x0001, - -59 - m__GCONV_IGNORE_ERRORS - = 0x0002 - -64  - g__gcÚv_¡• -; - -65  - g__gcÚv_¡•_d©a -; - -66  - g__gcÚv_lßded_objeù -; - -67  - g__gcÚv_Œªs_d©a -; - -71 (* - t__gcÚv_fù -è( - t__gcÚv_¡• - *,  - t__gcÚv_¡•_d©a - *, - -72 - t__cÚ¡ - **, __const *, - -73 **, - tsize_t - *, , ); - -76  - $wšt_t - (* - t__gcÚv_btowc_fù -è( - t__gcÚv_¡• - *, ); - -79 (* - t__gcÚv_š™_fù -è( - t__gcÚv_¡• - *); - -80 (* - t__gcÚv_’d_fù -è( - t__gcÚv_¡• - *); - -84 (* - t__gcÚv_Œªs_fù -è( - t__gcÚv_¡• - *, - -85  - t__gcÚv_¡•_d©a - *, *, - -86 - t__cÚ¡ - *, - -87 - t__cÚ¡ - **, - -88 - t__cÚ¡ - *, **, - -89 - tsize_t - *); - -92 (* - t__gcÚv_Œªs_cڋxt_fù -è(*, - t__cÚ¡ - *, - -93 - t__cÚ¡ - *, - -97 (* - t__gcÚv_Œªs_qu”y_fù -è( - t__cÚ¡ - *, __const ***, - -98 - tsize_t - *); - -101 (* - t__gcÚv_Œªs_š™_fù -) (**, const *); - -102 (* - t__gcÚv_Œªs_’d_fù -) (*); - -104  - s__gcÚv_Œªs_d©a - - -107 -__gcÚv_Œªs_fù - -__Œªs_fù -; - -108 -__gcÚv_Œªs_cڋxt_fù - -__Œªs_cڋxt_fù -; - -109 -__gcÚv_Œªs_’d_fù - -__Œªs_’d_fù -; - -110 * -__d©a -; - -111  -__gcÚv_Œªs_d©a - * -__Ãxt -; - -116  - s__gcÚv_¡• - - -118  -__gcÚv_lßded_objeù - * -__shlib_hªdË -; - -119 -__cÚ¡ - * -__modÇme -; - -121  -__couÁ” -; - -123 * -__äom_Çme -; - -124 * -__to_Çme -; - -126 -__gcÚv_fù - -__fù -; - -127 -__gcÚv_btowc_fù - -__btowc_fù -; - -128 -__gcÚv_š™_fù - -__š™_fù -; - -129 -__gcÚv_’d_fù - -__’d_fù -; - -133  -__mš_Ãeded_äom -; - -134  -__max_Ãeded_äom -; - -135  -__mš_Ãeded_to -; - -136  -__max_Ãeded_to -; - -139  -__¡©eful -; - -141 * -__d©a -; - -146  - s__gcÚv_¡•_d©a - - -148 * -__outbuf -; - -149 * -__outbuãnd -; - -153  -__æags -; - -157  -__švoÿtiÚ_couÁ” -; - -161  -__š‹º®_u£ -; - -163 -__mb¡©e_t - * -__¡©• -; - -164 -__mb¡©e_t - -__¡©e -; - -168  -__gcÚv_Œªs_d©a - * -__Œªs -; - -173  - s__gcÚv_šfo - - -175 -size_t - -__n¡•s -; - -176  -__gcÚv_¡• - * -__¡•s -; - -177 -__ex‹nsiÚ__ -  -__gcÚv_¡•_d©a - -__d©a - -__æex¬r -; - -178 } * - t__gcÚv_t -; - - @/usr/include/gnu/stubs-32.h - -6 #ifdeà -_LIBC - - -7 #”rÜ -AµliÿtiÚs - -may - -nÙ - -defše - -the - -maüo - -_LIBC - - -10  - #__¡ub___k”Ãl_co¦ - - - ) - -11  - #__¡ub___k”Ãl_sšl - - - ) - -12  - #__¡ub___k”Ãl_Æ - - - ) - -13  - #__¡ub_chæags - - - ) - -14  - #__¡ub_ç‰ach - - - ) - -15  - #__¡ub_fchæags - - - ) - -16  - #__¡ub_fd‘ach - - - ) - -17  - #__¡ub_g‰y - - - ) - -18  - #__¡ub_lchmod - - - ) - -19  - #__¡ub_»voke - - - ) - -20  - #__¡ub_£Žogš - - - ) - -21  - #__¡ub_sig»tuº - - - ) - -22  - #__¡ub_s¡k - - - ) - -23  - #__¡ub_¡ty - - - ) - - @/usr/include/wchar.h - -24 #iâdeà -_WCHAR_H - - -26 #ià! -defšed - -__Ãed_mb¡©e_t - && !defšed -__Ãed_wšt_t - - -27  - #_WCHAR_H - 1 - - ) - -28  - ~<ã©u»s.h -> - -31 #ifdeà -_WCHAR_H - - -33  - #__Ãed___FILE - - - ) - -34 #ià -defšed - -__USE_UNIX98 - || defšed -__USE_XOPEN2K - - -35  - #__Ãed_FILE - - - ) - -37  - ~<¡dio.h -> - -39  - #__Ãed___va_li¡ - - - ) - -40  - ~<¡d¬g.h -> - -42  - ~ - -45  - #__Ãed_size_t - - - ) - -46  - #__Ãed_wch¬_t - - - ) - -47  - #__Ãed_NULL - - - ) - -49 #ià -defšed - -_WCHAR_H - || defšed -__Ãed_wšt_t - || !defšed -__WINT_TYPE__ - - -50 #undeà -__Ãed_wšt_t - - -51  - #__Ãed_wšt_t - - - ) - -52  - ~<¡ddef.h -> - -56 #iâdeà -_WINT_T - - -61  - #_WINT_T - - - ) - -62  - twšt_t -; - -66 #ià -defšed - -__ýlu¥lus - && defšed -_GLIBCPP_USE_NAMESPACES - \ - -67 && -defšed - -__WINT_TYPE__ - - -68 -__BEGIN_NAMESPACE_STD - - -69  -__WINT_TYPE__ - - twšt_t -; - -70 - g__END_NAMESPACE_STD - - -75 #ià -defšed - -__ýlu¥lus - && -__GNUC_PREREQ - (4, 4) - -76  - #__CORRECT_ISO_CPP_WCHAR_H_PROTO - - - ) - -80 #ià( -defšed - -_WCHAR_H - || defšed -__Ãed_mb¡©e_t -è&& !defšed -__mb¡©e_t_defšed - - -81  - #__mb¡©e_t_defšed - 1 - - ) - -85  - m__couÁ -; - -88 #ifdeà -__WINT_TYPE__ - - -89 -__WINT_TYPE__ - - m__wch -; - -91 -wšt_t - - m__wch -; - -93  - m__wchb -[4]; - -94 } - m__v®ue -; - -95 } - t__mb¡©e_t -; - -97 #undeà -__Ãed_mb¡©e_t - - -102 #ifdeà -_WCHAR_H - - -104 -__BEGIN_NAMESPACE_C99 - - -106  -__mb¡©e_t - - tmb¡©e_t -; - -107 - g__END_NAMESPACE_C99 - - -108 #ifdeà -__USE_GNU - - -109 - $__USING_NAMESPACE_C99 -( -mb¡©e_t -) - -112 #iâdeà -WCHAR_MIN - - -114  - #WCHAR_MIN - -__WCHAR_MIN - - - ) - -115  - #WCHAR_MAX - -__WCHAR_MAX - - - ) - -118 #iâdeà -WEOF - - -119  - #WEOF - (0xffffffffu) - - ) - -124 #ià -defšed - -__USE_XOPEN - && !defšed -__USE_UNIX98 - - -125  - ~ - -129 -__BEGIN_DECLS - - -131 -__BEGIN_NAMESPACE_STD - - -134  -tm -; - -135 -__END_NAMESPACE_STD - - -139 - $__USING_NAMESPACE_STD -( -tm -) - -142 -__BEGIN_NAMESPACE_STD - - -144 -wch¬_t - * - $wcsýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -145 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -è -__THROW -; - -147 -wch¬_t - * - $wc¢ýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -148 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, -size_t - -__n -) - -149 -__THROW -; - -152 -wch¬_t - * - $wcsÿt - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -153 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -è -__THROW -; - -155 -wch¬_t - * - $wc¢ÿt - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -156 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, -size_t - -__n -) - -157 -__THROW -; - -160  - $wcscmp - ( -__cÚ¡ - -wch¬_t - * -__s1 -, __cÚ¡ wch¬_ˆ* -__s2 -) - -161 -__THROW - -__©Œibu‹_pu»__ -; - -163  - $wc¢cmp - ( -__cÚ¡ - -wch¬_t - * -__s1 -, __cÚ¡ wch¬_ˆ* -__s2 -, -size_t - -__n -) - -164 -__THROW - -__©Œibu‹_pu»__ -; - -165 -__END_NAMESPACE_STD - - -167 #ifdeà -__USE_XOPEN2K8 - - -169  - $wcsÿ£cmp - ( -__cÚ¡ - -wch¬_t - * -__s1 -, __cÚ¡ wch¬_ˆ* -__s2 -è -__THROW -; - -172  - $wc¢ÿ£cmp - ( -__cÚ¡ - -wch¬_t - * -__s1 -, __cÚ¡ wch¬_ˆ* -__s2 -, - -173 -size_t - -__n -è -__THROW -; - -177  - ~ - -179  - $wcsÿ£cmp_l - ( -__cÚ¡ - -wch¬_t - * -__s1 -, __cÚ¡ wch¬_ˆ* -__s2 -, - -180 -__loÿË_t - -__loc -è -__THROW -; - -182  - $wc¢ÿ£cmp_l - ( -__cÚ¡ - -wch¬_t - * -__s1 -, __cÚ¡ wch¬_ˆ* -__s2 -, - -183 -size_t - -__n -, -__loÿË_t - -__loc -è -__THROW -; - -186 -__BEGIN_NAMESPACE_STD - - -189  - $wcscÞl - ( -__cÚ¡ - -wch¬_t - * -__s1 -, __cÚ¡ wch¬_ˆ* -__s2 -è -__THROW -; - -193 -size_t - - $wcsxäm - ( -wch¬_t - * -__»¡riù - -__s1 -, - -194 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -è -__THROW -; - -195 -__END_NAMESPACE_STD - - -197 #ifdeà -__USE_XOPEN2K8 - - -203  - $wcscÞl_l - ( -__cÚ¡ - -wch¬_t - * -__s1 -, __cÚ¡ wch¬_ˆ* -__s2 -, - -204 -__loÿË_t - -__loc -è -__THROW -; - -209 -size_t - - $wcsxäm_l - ( -wch¬_t - * -__s1 -, -__cÚ¡ - wch¬_ˆ* -__s2 -, - -210 -size_t - -__n -, -__loÿË_t - -__loc -è -__THROW -; - -213 -wch¬_t - * - $wcsdup - ( -__cÚ¡ - -wch¬_t - * -__s -è -__THROW - -__©Œibu‹_m®loc__ -; - -216 -__BEGIN_NAMESPACE_STD - - -218 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -219 "C++" -wch¬_t - * - $wcschr - ( -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -220 -__THROW - - `__asm - ("wcschr"è -__©Œibu‹_pu»__ -; - -221 "C++" -__cÚ¡ - -wch¬_t - * - $wcschr - ( -__cÚ¡ - -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -222 -__THROW - - `__asm - ("wcschr"è -__©Œibu‹_pu»__ -; - -224 -wch¬_t - * - $wcschr - ( -__cÚ¡ - -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -225 -__THROW - -__©Œibu‹_pu»__ -; - -228 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -229 "C++" -wch¬_t - * - $wc¤chr - ( -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -230 -__THROW - - `__asm - ("wc¤chr"è -__©Œibu‹_pu»__ -; - -231 "C++" -__cÚ¡ - -wch¬_t - * - $wc¤chr - ( -__cÚ¡ - -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -232 -__THROW - - `__asm - ("wc¤chr"è -__©Œibu‹_pu»__ -; - -234 -wch¬_t - * - $wc¤chr - ( -__cÚ¡ - -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -235 -__THROW - -__©Œibu‹_pu»__ -; - -237 -__END_NAMESPACE_STD - - -239 #ifdeà -__USE_GNU - - -242 -wch¬_t - * - $wcschºul - ( -__cÚ¡ - -wch¬_t - * -__s -, wch¬_ˆ -__wc -) - -243 -__THROW - -__©Œibu‹_pu»__ -; - -246 -__BEGIN_NAMESPACE_STD - - -249 -size_t - - $wcsc¥n - ( -__cÚ¡ - -wch¬_t - * -__wcs -, __cÚ¡ wch¬_ˆ* -__»jeù -) - -250 -__THROW - -__©Œibu‹_pu»__ -; - -253 -size_t - - $wcs¥n - ( -__cÚ¡ - -wch¬_t - * -__wcs -, __cÚ¡ wch¬_ˆ* -__acû± -) - -254 -__THROW - -__©Œibu‹_pu»__ -; - -256 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -257 "C++" -wch¬_t - * - $wc¥brk - ( -wch¬_t - * -__wcs -, -__cÚ¡ - wch¬_ˆ* -__acû± -) - -258 -__THROW - - `__asm - ("wc¥brk"è -__©Œibu‹_pu»__ -; - -259 "C++" -__cÚ¡ - -wch¬_t - * - $wc¥brk - ( -__cÚ¡ - -wch¬_t - * -__wcs -, - -260 -__cÚ¡ - -wch¬_t - * -__acû± -) - -261 -__THROW - - `__asm - ("wc¥brk"è -__©Œibu‹_pu»__ -; - -263 -wch¬_t - * - $wc¥brk - ( -__cÚ¡ - -wch¬_t - * -__wcs -, __cÚ¡ wch¬_ˆ* -__acû± -) - -264 -__THROW - -__©Œibu‹_pu»__ -; - -267 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -268 "C++" -wch¬_t - * - $wcs¡r - ( -wch¬_t - * -__hay¡ack -, -__cÚ¡ - wch¬_ˆ* -__ÃedË -) - -269 -__THROW - - `__asm - ("wcs¡r"è -__©Œibu‹_pu»__ -; - -270 "C++" -__cÚ¡ - -wch¬_t - * - $wcs¡r - ( -__cÚ¡ - -wch¬_t - * -__hay¡ack -, - -271 -__cÚ¡ - -wch¬_t - * -__ÃedË -) - -272 -__THROW - - `__asm - ("wcs¡r"è -__©Œibu‹_pu»__ -; - -274 -wch¬_t - * - $wcs¡r - ( -__cÚ¡ - -wch¬_t - * -__hay¡ack -, __cÚ¡ wch¬_ˆ* -__ÃedË -) - -275 -__THROW - -__©Œibu‹_pu»__ -; - -279 -wch¬_t - * - $wc¡ok - ( -wch¬_t - * -__»¡riù - -__s -, - -280 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__d–im -, - -281 -wch¬_t - ** -__»¡riù - -__±r -è -__THROW -; - -284 -size_t - - $wc¦’ - ( -__cÚ¡ - -wch¬_t - * -__s -è -__THROW - -__©Œibu‹_pu»__ -; - -285 -__END_NAMESPACE_STD - - -287 #ifdeà -__USE_XOPEN - - -289 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -290 "C++" -wch¬_t - * - $wcswcs - ( -wch¬_t - * -__hay¡ack -, -__cÚ¡ - wch¬_ˆ* -__ÃedË -) - -291 -__THROW - - `__asm - ("wcswcs"è -__©Œibu‹_pu»__ -; - -292 "C++" -__cÚ¡ - -wch¬_t - * - $wcswcs - ( -__cÚ¡ - -wch¬_t - * -__hay¡ack -, - -293 -__cÚ¡ - -wch¬_t - * -__ÃedË -) - -294 -__THROW - - `__asm - ("wcswcs"è -__©Œibu‹_pu»__ -; - -296 -wch¬_t - * - $wcswcs - ( -__cÚ¡ - -wch¬_t - * -__hay¡ack -, __cÚ¡ wch¬_ˆ* -__ÃedË -) - -297 -__THROW - -__©Œibu‹_pu»__ -; - -301 #ifdeà -__USE_XOPEN2K8 - - -303 -size_t - - $wc¢Ën - ( -__cÚ¡ - -wch¬_t - * -__s -, -size_t - -__maxËn -) - -304 -__THROW - -__©Œibu‹_pu»__ -; - -308 -__BEGIN_NAMESPACE_STD - - -310 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -311 "C++" -wch¬_t - * - $wmemchr - ( -wch¬_t - * -__s -, wch¬_ˆ -__c -, -size_t - -__n -) - -312 -__THROW - - `__asm - ("wmemchr"è -__©Œibu‹_pu»__ -; - -313 "C++" -__cÚ¡ - -wch¬_t - * - $wmemchr - ( -__cÚ¡ - -wch¬_t - * -__s -, wch¬_ˆ -__c -, - -314 -size_t - -__n -) - -315 -__THROW - - `__asm - ("wmemchr"è -__©Œibu‹_pu»__ -; - -317 -wch¬_t - * - $wmemchr - ( -__cÚ¡ - -wch¬_t - * -__s -, wch¬_ˆ -__c -, -size_t - -__n -) - -318 -__THROW - -__©Œibu‹_pu»__ -; - -322  - $wmemcmp - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s1 -, - -323 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -) - -324 -__THROW - -__©Œibu‹_pu»__ -; - -327 -wch¬_t - * - $wmemýy - ( -wch¬_t - * -__»¡riù - -__s1 -, - -328 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -è -__THROW -; - -332 -wch¬_t - * - $wmemmove - ( -wch¬_t - * -__s1 -, -__cÚ¡ - wch¬_ˆ* -__s2 -, -size_t - -__n -) - -333 -__THROW -; - -336 -wch¬_t - * - $wmem£t - ( -wch¬_t - * -__s -, wch¬_ˆ -__c -, -size_t - -__n -è -__THROW -; - -337 -__END_NAMESPACE_STD - - -339 #ifdeà -__USE_GNU - - -342 -wch¬_t - * - $wmempýy - ( -wch¬_t - * -__»¡riù - -__s1 -, - -343 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -) - -344 -__THROW -; - -348 -__BEGIN_NAMESPACE_STD - - -351 -wšt_t - - $btowc - ( -__c -è -__THROW -; - -355  - $wùob - ( -wšt_t - -__c -è -__THROW -; - -359  - $mbsš™ - ( -__cÚ¡ - -mb¡©e_t - * -__ps -è -__THROW - -__©Œibu‹_pu»__ -; - -363 -size_t - - $mb¹owc - ( -wch¬_t - * -__»¡riù - -__pwc -, - -364 -__cÚ¡ - * -__»¡riù - -__s -, -size_t - -__n -, - -365 -mb¡©e_t - * -__p -è -__THROW -; - -368 -size_t - - $wütomb - (* -__»¡riù - -__s -, -wch¬_t - -__wc -, - -369 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -372 -size_t - - $__mb¾’ - ( -__cÚ¡ - * -__»¡riù - -__s -, -size_t - -__n -, - -373 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -374 -size_t - - $mb¾’ - ( -__cÚ¡ - * -__»¡riù - -__s -, -size_t - -__n -, - -375 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -376 -__END_NAMESPACE_STD - - -378 #ifdeà -__USE_EXTERN_INLINES - - -384 -wšt_t - - $__btowc_®Ÿs - ( -__c -è - `__asm - ("btowc"); - -385 -__ex‹º_šlše - -wšt_t - - -386 - `__NTH - ( - $btowc - ( -__c -)) - -387 {  ( - `__bužtš_cÚ¡ªt_p - ( -__c -) && __c >= '\0' && __c <= '\x7f' - -388 ? ( -wšt_t -è -__c - : - `__btowc_®Ÿs - (__c)); - } -} - -390  - $__wùob_®Ÿs - ( -wšt_t - -__c -è - `__asm - ("wctob"); - -391 -__ex‹º_šlše -  - -392 - `__NTH - ( - $wùob - ( -wšt_t - -__wc -)) - -393 {  ( - `__bužtš_cÚ¡ªt_p - ( -__wc -è&& __wø>ð -L -'\0' && __wc <= L'\x7f' - -394 ? (è -__wc - : - `__wùob_®Ÿs - (__wc)); - } -} - -396 -__ex‹º_šlše - -size_t - - -397 -__NTH - ( - $mb¾’ - ( -__cÚ¡ - * -__»¡riù - -__s -, -size_t - -__n -, - -398 -mb¡©e_t - * -__»¡riù - -__ps -)) - -399 {  ( -__ps - !ð -NULL - - -400 ? - `mb¹owc - ( -NULL -, -__s -, -__n -, -__ps -è: - `__mb¾’ - (__s, __n, NULL)); - } -} - -403 -__BEGIN_NAMESPACE_STD - - -406 -size_t - - $mb¤towcs - ( -wch¬_t - * -__»¡riù - -__d¡ -, - -407 -__cÚ¡ - ** -__»¡riù - -__¤c -, -size_t - -__Ën -, - -408 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -412 -size_t - - $wc¤tombs - (* -__»¡riù - -__d¡ -, - -413 -__cÚ¡ - -wch¬_t - ** -__»¡riù - -__¤c -, -size_t - -__Ën -, - -414 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -415 -__END_NAMESPACE_STD - - -418 #ifdef -__USE_XOPEN2K8 - - -421 -size_t - - $mb¢¹owcs - ( -wch¬_t - * -__»¡riù - -__d¡ -, - -422 -__cÚ¡ - ** -__»¡riù - -__¤c -, -size_t - -__nmc -, - -423 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -427 -size_t - - $wc¢¹ombs - (* -__»¡riù - -__d¡ -, - -428 -__cÚ¡ - -wch¬_t - ** -__»¡riù - -__¤c -, - -429 -size_t - -__nwc -, size_ˆ -__Ën -, - -430 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -435 #ifdeà -__USE_XOPEN - - -437  - $wcwidth - ( -wch¬_t - -__c -è -__THROW -; - -441  - $wcswidth - ( -__cÚ¡ - -wch¬_t - * -__s -, -size_t - -__n -è -__THROW -; - -445 -__BEGIN_NAMESPACE_STD - - -448  - $wc¡od - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -449 -wch¬_t - ** -__»¡riù - -__’d±r -è -__THROW -; - -450 -__END_NAMESPACE_STD - - -452 #ifdeà -__USE_ISOC99 - - -453 -__BEGIN_NAMESPACE_C99 - - -455  - $wc¡of - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -456 -wch¬_t - ** -__»¡riù - -__’d±r -è -__THROW -; - -457  - $wc¡Þd - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -458 -wch¬_t - ** -__»¡riù - -__’d±r -è -__THROW -; - -459 -__END_NAMESPACE_C99 - - -463 -__BEGIN_NAMESPACE_STD - - -466  - $wc¡Þ - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -467 -wch¬_t - ** -__»¡riù - -__’d±r -,  -__ba£ -è -__THROW -; - -471  - $wc¡oul - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -472 -wch¬_t - ** -__»¡riù - -__’d±r -,  -__ba£ -) - -473 -__THROW -; - -474 -__END_NAMESPACE_STD - - -476 #ià -defšed - -__USE_ISOC99 - || (defšed -__GNUC__ - && defšed -__USE_GNU -) - -477 -__BEGIN_NAMESPACE_C99 - - -480 -__ex‹nsiÚ__ - - -481  - $wc¡Þl - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -482 -wch¬_t - ** -__»¡riù - -__’d±r -,  -__ba£ -) - -483 -__THROW -; - -487 -__ex‹nsiÚ__ - - -488  - $wc¡ouÎ - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -489 -wch¬_t - ** -__»¡riù - -__’d±r -, - -490  -__ba£ -è -__THROW -; - -491 -__END_NAMESPACE_C99 - - -494 #ià -defšed - -__GNUC__ - && defšed -__USE_GNU - - -497 -__ex‹nsiÚ__ - - -498  - $wc¡oq - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -499 -wch¬_t - ** -__»¡riù - -__’d±r -,  -__ba£ -) - -500 -__THROW -; - -504 -__ex‹nsiÚ__ - - -505  - $wc¡ouq - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -506 -wch¬_t - ** -__»¡riù - -__’d±r -, - -507  -__ba£ -è -__THROW -; - -510 #ifdeà -__USE_GNU - - -524  - ~ - -528  - $wc¡Þ_l - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -529 -wch¬_t - ** -__»¡riù - -__’d±r -,  -__ba£ -, - -530 -__loÿË_t - -__loc -è -__THROW -; - -532  - $wc¡oul_l - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -533 -wch¬_t - ** -__»¡riù - -__’d±r -, - -534  -__ba£ -, -__loÿË_t - -__loc -è -__THROW -; - -536 -__ex‹nsiÚ__ - - -537  - $wc¡Þl_l - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -538 -wch¬_t - ** -__»¡riù - -__’d±r -, - -539  -__ba£ -, -__loÿË_t - -__loc -è -__THROW -; - -541 -__ex‹nsiÚ__ - - -542  - $wc¡ouÎ_l - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -543 -wch¬_t - ** -__»¡riù - -__’d±r -, - -544  -__ba£ -, -__loÿË_t - -__loc -) - -545 -__THROW -; - -547  - $wc¡od_l - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -548 -wch¬_t - ** -__»¡riù - -__’d±r -, -__loÿË_t - -__loc -) - -549 -__THROW -; - -551  - $wc¡of_l - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -552 -wch¬_t - ** -__»¡riù - -__’d±r -, -__loÿË_t - -__loc -) - -553 -__THROW -; - -555  - $wc¡Þd_l - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__Ō -, - -556 -wch¬_t - ** -__»¡riù - -__’d±r -, - -557 -__loÿË_t - -__loc -è -__THROW -; - -562 -wch¬_t - * - $wýýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -563 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -è -__THROW -; - -567 -wch¬_t - * - $wýnýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -568 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, -size_t - -__n -) - -569 -__THROW -; - -575 #ifdef -__USE_XOPEN2K8 - - -578 -__FILE - * - $ݒ_wmem¡»am - ( -wch¬_t - ** -__buæoc -, -size_t - * -__siz–oc -è -__THROW -; - -581 #ià -defšed - -__USE_ISOC95 - || defšed -__USE_UNIX98 - - -582 -__BEGIN_NAMESPACE_STD - - -585  - $fwide - ( -__FILE - * -__å -,  -__mode -è -__THROW -; - -592  - `fw´štf - ( -__FILE - * -__»¡riù - -__¡»am -, - -593 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -599  - `w´štf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -602  - $sw´štf - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__n -, - -603 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -604 -__THROW - ; - -610  - `vfw´štf - ( -__FILE - * -__»¡riù - -__s -, - -611 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -612 -__gnuc_va_li¡ - -__¬g -) - -618  - `vw´štf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -619 -__gnuc_va_li¡ - -__¬g -) - -623  - $vsw´štf - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__n -, - -624 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -625 -__gnuc_va_li¡ - -__¬g -) - -626 -__THROW - ; - -633  - `fwsÿnf - ( -__FILE - * -__»¡riù - -__¡»am -, - -634 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -640  - `wsÿnf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -643  - $swsÿnf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s -, - -644 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -645 -__THROW - ; - -647 #ià -defšed - -__USE_ISOC99 - && !defšed -__USE_GNU - \ - -648 && (! -defšed - -__LDBL_COMPAT - || !defšed -__REDIRECT -) \ - -649 && ( -defšed - -__STRICT_ANSI__ - || defšed -__USE_XOPEN2K -) - -650 #ifdeà -__REDIRECT - - -654  - `__REDIRECT - ( -fwsÿnf -, ( -__FILE - * -__»¡riù - -__¡»am -, - -655 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...), - -656 -__isoc99_fwsÿnf -) - -658  - `__REDIRECT - ( -wsÿnf -, ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...), - -659 -__isoc99_wsÿnf -) - -661  - `__REDIRECT_NTH - ( -swsÿnf -, ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s -, - -662 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -663 ...), -__isoc99_swsÿnf -) - -666  - `__isoc99_fwsÿnf - ( -__FILE - * -__»¡riù - -__¡»am -, - -667 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...); - -668  - `__isoc99_wsÿnf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...); - -669  - $__isoc99_swsÿnf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s -, - -670 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -671 -__THROW -; - -672  - #fwsÿnf - -__isoc99_fwsÿnf - - - ) - -673  - #wsÿnf - -__isoc99_wsÿnf - - - ) - -674  - #swsÿnf - -__isoc99_swsÿnf - - - ) - -678 -__END_NAMESPACE_STD - - -681 #ifdeà -__USE_ISOC99 - - -682 -__BEGIN_NAMESPACE_C99 - - -687  - `vfwsÿnf - ( -__FILE - * -__»¡riù - -__s -, - -688 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -689 -__gnuc_va_li¡ - -__¬g -) - -695  - `vwsÿnf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -696 -__gnuc_va_li¡ - -__¬g -) - -699  - $vswsÿnf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s -, - -700 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -701 -__gnuc_va_li¡ - -__¬g -) - -702 -__THROW - ; - -704 #ià! -defšed - -__USE_GNU - \ - -705 && (! -defšed - -__LDBL_COMPAT - || !defšed -__REDIRECT -) \ - -706 && ( -defšed - -__STRICT_ANSI__ - || defšed -__USE_XOPEN2K -) - -707 #ifdeà -__REDIRECT - - -708  - `__REDIRECT - ( -vfwsÿnf -, ( -__FILE - * -__»¡riù - -__s -, - -709 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -710 -__gnuc_va_li¡ - -__¬g -), -__isoc99_vfwsÿnf -) - -712  - `__REDIRECT - ( -vwsÿnf -, ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -713 -__gnuc_va_li¡ - -__¬g -), -__isoc99_vwsÿnf -) - -715  - `__REDIRECT_NTH - ( -vswsÿnf -, ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s -, - -716 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -717 -__gnuc_va_li¡ - -__¬g -), -__isoc99_vswsÿnf -) - -720  - `__isoc99_vfwsÿnf - ( -__FILE - * -__»¡riù - -__s -, - -721 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -722 -__gnuc_va_li¡ - -__¬g -); - -723  - `__isoc99_vwsÿnf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -724 -__gnuc_va_li¡ - -__¬g -); - -725  - $__isoc99_vswsÿnf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s -, - -726 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -727 -__gnuc_va_li¡ - -__¬g -è -__THROW -; - -728  - #vfwsÿnf - -__isoc99_vfwsÿnf - - - ) - -729  - #vwsÿnf - -__isoc99_vwsÿnf - - - ) - -730  - #vswsÿnf - -__isoc99_vswsÿnf - - - ) - -734 -__END_NAMESPACE_C99 - - -738 -__BEGIN_NAMESPACE_STD - - -743 -wšt_t - - `fg‘wc - ( -__FILE - * -__¡»am -); - -744 -wšt_t - - `g‘wc - ( -__FILE - * -__¡»am -); - -750 -wšt_t - - `g‘wch¬ - (); - -757 -wšt_t - - `åutwc - ( -wch¬_t - -__wc -, -__FILE - * -__¡»am -); - -758 -wšt_t - - `putwc - ( -wch¬_t - -__wc -, -__FILE - * -__¡»am -); - -764 -wšt_t - - `putwch¬ - ( -wch¬_t - -__wc -); - -772 -wch¬_t - * - `fg‘ws - (wch¬_ˆ* -__»¡riù - -__ws -,  -__n -, - -773 -__FILE - * -__»¡riù - -__¡»am -); - -779  - `åutws - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__ws -, - -780 -__FILE - * -__»¡riù - -__¡»am -); - -787 -wšt_t - - `ung‘wc - (wšt_ˆ -__wc -, -__FILE - * -__¡»am -); - -788 -__END_NAMESPACE_STD - - -791 #ifdeà -__USE_GNU - - -799 -wšt_t - - `g‘wc_uÆocked - ( -__FILE - * -__¡»am -); - -800 -wšt_t - - `g‘wch¬_uÆocked - (); - -808 -wšt_t - - `fg‘wc_uÆocked - ( -__FILE - * -__¡»am -); - -816 -wšt_t - - `åutwc_uÆocked - ( -wch¬_t - -__wc -, -__FILE - * -__¡»am -); - -825 -wšt_t - - `putwc_uÆocked - ( -wch¬_t - -__wc -, -__FILE - * -__¡»am -); - -826 -wšt_t - - `putwch¬_uÆocked - ( -wch¬_t - -__wc -); - -835 -wch¬_t - * - `fg‘ws_uÆocked - (wch¬_ˆ* -__»¡riù - -__ws -,  -__n -, - -836 -__FILE - * -__»¡riù - -__¡»am -); - -844  - `åutws_uÆocked - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__ws -, - -845 -__FILE - * -__»¡riù - -__¡»am -); - -849 -__BEGIN_NAMESPACE_C99 - - -853 -size_t - - $wcsáime - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__maxsize -, - -854 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -855 -__cÚ¡ -  -tm - * -__»¡riù - -__ -è -__THROW -; - -856 -__END_NAMESPACE_C99 - - -858 #ifdeà -__USE_GNU - - -859  - ~ - -863 -size_t - - $wcsáime_l - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__maxsize -, - -864 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -865 -__cÚ¡ -  -tm - * -__»¡riù - -__ -, - -866 -__loÿË_t - -__loc -è -__THROW -; - -875 #ià -defšed - -__USE_UNIX98 - && !defšed -__USE_GNU - - -876  - #__Ãed_iswxxx - - - ) - -877  - ~ - -881 #ià -__USE_FORTIFY_LEVEL - > 0 && -defšed - -__ex‹º_®ways_šlše - - -882  - ~ - -885 #ifdeà -__LDBL_COMPAT - - -886  - ~ - -889 -__END_DECLS - - -897 #undeà -__Ãed_mb¡©e_t - - -898 #undeà -__Ãed_wšt_t - - - @/usr/include/bits/wchar-ldbl.h - -20 #iâdeà -_WCHAR_H - - -24 #ià -defšed - -__USE_ISOC95 - || defšed -__USE_UNIX98 - - -25 -__BEGIN_NAMESPACE_C99 - - -26 -__LDBL_REDIR_DECL - ( -fw´štf -); - -27 -__LDBL_REDIR_DECL - ( -w´štf -); - -28 -__LDBL_REDIR_DECL - ( -sw´štf -); - -29 -__LDBL_REDIR_DECL - ( -vfw´štf -); - -30 -__LDBL_REDIR_DECL - ( -vw´štf -); - -31 -__LDBL_REDIR_DECL - ( -vsw´štf -); - -32 #ià -defšed - -__USE_ISOC99 - && !defšed -__USE_GNU - \ - -33 && ! -defšed - - g__REDIRECT - \ - -34 && ( -defšed - - g__STRICT_ANSI__ - || defšed - g__USE_XOPEN2K -) - -35 - $__LDBL_REDIR1_DECL - ( -fwsÿnf -, -__Ædbl___isoc99_fwsÿnf -) - -36 - $__LDBL_REDIR1_DECL - ( -wsÿnf -, -__Ædbl___isoc99_wsÿnf -) - -37 - $__LDBL_REDIR1_DECL - ( -swsÿnf -, -__Ædbl___isoc99_swsÿnf -) - -39 - `__LDBL_REDIR_DECL - ( -fwsÿnf -); - -40 - `__LDBL_REDIR_DECL - ( -wsÿnf -); - -41 - `__LDBL_REDIR_DECL - ( -swsÿnf -); - -43 -__END_NAMESPACE_C99 - - -46 #ifdeà -__USE_ISOC99 - - -47 -__BEGIN_NAMESPACE_C99 - - -48 - `__LDBL_REDIR1_DECL - ( -wc¡Þd -, -wc¡od -); - -49 #ià! -defšed - -__USE_GNU - && !defšed -__REDIRECT - \ - -50 && ( -defšed - -__STRICT_ANSI__ - || defšed -__USE_XOPEN2K -) - -51 - $__LDBL_REDIR1_DECL - ( -vfwsÿnf -, -__Ædbl___isoc99_vfwsÿnf -) - -52 - $__LDBL_REDIR1_DECL - ( -vwsÿnf -, -__Ædbl___isoc99_vwsÿnf -) - -53 - $__LDBL_REDIR1_DECL - ( -vswsÿnf -, -__Ædbl___isoc99_vswsÿnf -) - -55 - `__LDBL_REDIR_DECL - ( -vfwsÿnf -); - -56 - `__LDBL_REDIR_DECL - ( -vwsÿnf -); - -57 - `__LDBL_REDIR_DECL - ( -vswsÿnf -); - -59 -__END_NAMESPACE_C99 - - -62 #ifdeà -__USE_GNU - - -63 - `__LDBL_REDIR1_DECL - ( -wc¡Þd_l -, -wc¡od_l -); - -66 #ià -__USE_FORTIFY_LEVEL - > 0 && -defšed - -__ex‹º_®ways_šlše - - -67 - $__LDBL_REDIR_DECL - ( -__sw´štf_chk -) - -68 - $__LDBL_REDIR_DECL - ( -__vsw´štf_chk -) - -69 #ià -__USE_FORTIFY_LEVEL - > 1 - -70 - $__LDBL_REDIR_DECL - ( -__fw´štf_chk -) - -71 - $__LDBL_REDIR_DECL - ( -__w´štf_chk -) - -72 - $__LDBL_REDIR_DECL - ( -__vfw´štf_chk -) - -73 - $__LDBL_REDIR_DECL - ( -__vw´štf_chk -) - - @/usr/include/bits/wchar2.h - -20 #iâdeà -_WCHAR_H - - -25 -wch¬_t - * - $__wmemýy_chk - ( -wch¬_t - * -__»¡riù - -__s1 -, - -26 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -, - -27 -size_t - -__ns1 -è -__THROW -; - -28 -wch¬_t - * - `__REDIRECT_NTH - ( -__wmemýy_®Ÿs -, - -29 ( -wch¬_t - * -__»¡riù - -__s1 -, - -30 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -), - -31 -wmemýy -); - -32 -wch¬_t - * - `__REDIRECT_NTH - ( -__wmemýy_chk_w¬n -, - -33 ( -wch¬_t - * -__»¡riù - -__s1 -, - -34 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -, - -35 -size_t - -__ns1 -), -__wmemýy_chk -) - -36 - `__w¬Ç‰r - ("wmemcpy called with†ength biggerhan size of destination " - -39 -__ex‹º_®ways_šlše - -wch¬_t - * - -40 - `__NTH - ( - $wmemýy - ( -wch¬_t - * -__»¡riù - -__s1 -, -__cÚ¡ - wch¬_ˆ*__»¡riù -__s2 -, - -41 -size_t - -__n -)) - -43 ià( - `__bos0 - ( -__s1 -è!ð( -size_t -) -1) - -45 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -)) - -46  - `__wmemýy_chk - ( -__s1 -, -__s2 -, -__n -, - -47 - `__bos0 - ( -__s1 -è/  ( -wch¬_t -)); - -49 ià( -__n - > - `__bos0 - ( -__s1 -è/  ( -wch¬_t -)) - -50  - `__wmemýy_chk_w¬n - ( -__s1 -, -__s2 -, -__n -, - -51 - `__bos0 - ( -__s1 -è/  ( -wch¬_t -)); - -53  - `__wmemýy_®Ÿs - ( -__s1 -, -__s2 -, -__n -); - -54 - } -} - -57 -wch¬_t - * - $__wmemmove_chk - ( -wch¬_t - * -__s1 -, -__cÚ¡ - wch¬_ˆ* -__s2 -, - -58 -size_t - -__n -, size_ˆ -__ns1 -è -__THROW -; - -59 -wch¬_t - * - `__REDIRECT_NTH - ( -__wmemmove_®Ÿs -, (wch¬_ˆ* -__s1 -, - -60 -__cÚ¡ - -wch¬_t - * -__s2 -, - -61 -size_t - -__n -), -wmemmove -); - -62 -wch¬_t - * - `__REDIRECT_NTH - ( -__wmemmove_chk_w¬n -, - -63 ( -wch¬_t - * -__s1 -, -__cÚ¡ - wch¬_ˆ* -__s2 -, - -64 -size_t - -__n -, size_ˆ -__ns1 -), -__wmemmove_chk -) - -65 - `__w¬Ç‰r - ("wmemmove called with†ength biggerhan size of destination " - -68 -__ex‹º_®ways_šlše - -wch¬_t - * - -69 - `__NTH - ( - $wmemmove - ( -wch¬_t - * -__s1 -, -__cÚ¡ - wch¬_ˆ* -__s2 -, -size_t - -__n -)) - -71 ià( - `__bos0 - ( -__s1 -è!ð( -size_t -) -1) - -73 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -)) - -74  - `__wmemmove_chk - ( -__s1 -, -__s2 -, -__n -, - -75 - `__bos0 - ( -__s1 -è/  ( -wch¬_t -)); - -77 ià( -__n - > - `__bos0 - ( -__s1 -è/  ( -wch¬_t -)) - -78  - `__wmemmove_chk_w¬n - ( -__s1 -, -__s2 -, -__n -, - -79 - `__bos0 - ( -__s1 -è/  ( -wch¬_t -)); - -81  - `__wmemmove_®Ÿs - ( -__s1 -, -__s2 -, -__n -); - -82 - } -} - -85 #ifdeà -__USE_GNU - - -86 -wch¬_t - * - $__wmempýy_chk - ( -wch¬_t - * -__»¡riù - -__s1 -, - -87 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -, - -88 -size_t - -__ns1 -è -__THROW -; - -89 -wch¬_t - * - `__REDIRECT_NTH - ( -__wmempýy_®Ÿs -, - -90 ( -wch¬_t - * -__»¡riù - -__s1 -, - -91 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s2 -, - -92 -size_t - -__n -), -wmempýy -); - -93 -wch¬_t - * - `__REDIRECT_NTH - ( -__wmempýy_chk_w¬n -, - -94 ( -wch¬_t - * -__»¡riù - -__s1 -, - -95 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -, - -96 -size_t - -__ns1 -), -__wmempýy_chk -) - -97 - `__w¬Ç‰r - ("wmempcpy called with†ength biggerhan size of destination " - -100 -__ex‹º_®ways_šlše - -wch¬_t - * - -101 - `__NTH - ( - $wmempýy - ( -wch¬_t - * -__»¡riù - -__s1 -, -__cÚ¡ - wch¬_ˆ*__»¡riù -__s2 -, - -102 -size_t - -__n -)) - -104 ià( - `__bos0 - ( -__s1 -è!ð( -size_t -) -1) - -106 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -)) - -107  - `__wmempýy_chk - ( -__s1 -, -__s2 -, -__n -, - -108 - `__bos0 - ( -__s1 -è/  ( -wch¬_t -)); - -110 ià( -__n - > - `__bos0 - ( -__s1 -è/  ( -wch¬_t -)) - -111  - `__wmempýy_chk_w¬n - ( -__s1 -, -__s2 -, -__n -, - -112 - `__bos0 - ( -__s1 -è/  ( -wch¬_t -)); - -114  - `__wmempýy_®Ÿs - ( -__s1 -, -__s2 -, -__n -); - -115 - } -} - -119 -wch¬_t - * - $__wmem£t_chk - ( -wch¬_t - * -__s -, wch¬_ˆ -__c -, -size_t - -__n -, - -120 -size_t - -__ns -è -__THROW -; - -121 -wch¬_t - * - `__REDIRECT_NTH - ( -__wmem£t_®Ÿs -, (wch¬_ˆ* -__s -, wch¬_ˆ -__c -, - -122 -size_t - -__n -), -wmem£t -); - -123 -wch¬_t - * - `__REDIRECT_NTH - ( -__wmem£t_chk_w¬n -, - -124 ( -wch¬_t - * -__s -, wch¬_ˆ -__c -, -size_t - -__n -, - -125 -size_t - -__ns -), -__wmem£t_chk -) - -126 - `__w¬Ç‰r - ("wmemset called with†ength biggerhan size of destination " - -129 -__ex‹º_®ways_šlše - -wch¬_t - * - -130 - `__NTH - ( - $wmem£t - ( -wch¬_t - * -__s -, wch¬_ˆ -__c -, -size_t - -__n -)) - -132 ià( - `__bos0 - ( -__s -è!ð( -size_t -) -1) - -134 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -)) - -135  - `__wmem£t_chk - ( -__s -, -__c -, -__n -, - `__bos0 - (__sè/  ( -wch¬_t -)); - -137 ià( -__n - > - `__bos0 - ( -__s -è/  ( -wch¬_t -)) - -138  - `__wmem£t_chk_w¬n - ( -__s -, -__c -, -__n -, - -139 - `__bos0 - ( -__s -è/  ( -wch¬_t -)); - -141  - `__wmem£t_®Ÿs - ( -__s -, -__c -, -__n -); - -142 - } -} - -145 -wch¬_t - * - $__wcsýy_chk - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -146 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -147 -size_t - -__n -è -__THROW -; - -148 -wch¬_t - * - `__REDIRECT_NTH - ( -__wcsýy_®Ÿs -, - -149 ( -wch¬_t - * -__»¡riù - -__de¡ -, - -150 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -), -wcsýy -); - -152 -__ex‹º_®ways_šlše - -wch¬_t - * - -153 - `__NTH - ( - $wcsýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, -__cÚ¡ - wch¬_ˆ*__»¡riù -__¤c -)) - -155 ià( - `__bos - ( -__de¡ -è!ð( -size_t -) -1) - -156  - `__wcsýy_chk - ( -__de¡ -, -__¤c -, - `__bos - (__de¡è/  ( -wch¬_t -)); - -157  - `__wcsýy_®Ÿs - ( -__de¡ -, -__¤c -); - -158 - } -} - -161 -wch¬_t - * - $__wýýy_chk - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -162 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -163 -size_t - -__de¡Ën -è -__THROW -; - -164 -wch¬_t - * - `__REDIRECT_NTH - ( -__wýýy_®Ÿs -, - -165 ( -wch¬_t - * -__»¡riù - -__de¡ -, - -166 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -), -wýýy -); - -168 -__ex‹º_®ways_šlše - -wch¬_t - * - -169 - `__NTH - ( - $wýýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, -__cÚ¡ - wch¬_ˆ*__»¡riù -__¤c -)) - -171 ià( - `__bos - ( -__de¡ -è!ð( -size_t -) -1) - -172  - `__wýýy_chk - ( -__de¡ -, -__¤c -, - `__bos - (__de¡è/  ( -wch¬_t -)); - -173  - `__wýýy_®Ÿs - ( -__de¡ -, -__¤c -); - -174 - } -} - -177 -wch¬_t - * - $__wc¢ýy_chk - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -178 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, -size_t - -__n -, - -179 -size_t - -__de¡Ën -è -__THROW -; - -180 -wch¬_t - * - `__REDIRECT_NTH - ( -__wc¢ýy_®Ÿs -, - -181 ( -wch¬_t - * -__»¡riù - -__de¡ -, - -182 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -183 -size_t - -__n -), -wc¢ýy -); - -184 -wch¬_t - * - `__REDIRECT_NTH - ( -__wc¢ýy_chk_w¬n -, - -185 ( -wch¬_t - * -__»¡riù - -__de¡ -, - -186 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -187 -size_t - -__n -, size_ˆ -__de¡Ën -), -__wc¢ýy_chk -) - -188 - `__w¬Ç‰r - ("wcsncpy called with†ength biggerhan size of destination " - -191 -__ex‹º_®ways_šlše - -wch¬_t - * - -192 - `__NTH - ( - $wc¢ýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, -__cÚ¡ - wch¬_ˆ*__»¡riù -__¤c -, - -193 -size_t - -__n -)) - -195 ià( - `__bos - ( -__de¡ -è!ð( -size_t -) -1) - -197 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -)) - -198  - `__wc¢ýy_chk - ( -__de¡ -, -__¤c -, -__n -, - -199 - `__bos - ( -__de¡ -è/  ( -wch¬_t -)); - -200 ià( -__n - > - `__bos - ( -__de¡ -è/  ( -wch¬_t -)) - -201  - `__wc¢ýy_chk_w¬n - ( -__de¡ -, -__¤c -, -__n -, - -202 - `__bos - ( -__de¡ -è/  ( -wch¬_t -)); - -204  - `__wc¢ýy_®Ÿs - ( -__de¡ -, -__¤c -, -__n -); - -205 - } -} - -208 -wch¬_t - * - $__wýnýy_chk - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -209 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, -size_t - -__n -, - -210 -size_t - -__de¡Ën -è -__THROW -; - -211 -wch¬_t - * - `__REDIRECT_NTH - ( -__wýnýy_®Ÿs -, - -212 ( -wch¬_t - * -__»¡riù - -__de¡ -, - -213 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -214 -size_t - -__n -), -wýnýy -); - -215 -wch¬_t - * - `__REDIRECT_NTH - ( -__wýnýy_chk_w¬n -, - -216 ( -wch¬_t - * -__»¡riù - -__de¡ -, - -217 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -218 -size_t - -__n -, size_ˆ -__de¡Ën -), -__wýnýy_chk -) - -219 - `__w¬Ç‰r - ("wcpncpy called with†ength biggerhan size of destination " - -222 -__ex‹º_®ways_šlše - -wch¬_t - * - -223 - `__NTH - ( - $wýnýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, -__cÚ¡ - wch¬_ˆ*__»¡riù -__¤c -, - -224 -size_t - -__n -)) - -226 ià( - `__bos - ( -__de¡ -è!ð( -size_t -) -1) - -228 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -)) - -229  - `__wýnýy_chk - ( -__de¡ -, -__¤c -, -__n -, - -230 - `__bos - ( -__de¡ -è/  ( -wch¬_t -)); - -231 ià( -__n - > - `__bos - ( -__de¡ -è/  ( -wch¬_t -)) - -232  - `__wýnýy_chk_w¬n - ( -__de¡ -, -__¤c -, -__n -, - -233 - `__bos - ( -__de¡ -è/  ( -wch¬_t -)); - -235  - `__wýnýy_®Ÿs - ( -__de¡ -, -__¤c -, -__n -); - -236 - } -} - -239 -wch¬_t - * - $__wcsÿt_chk - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -240 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -241 -size_t - -__de¡Ën -è -__THROW -; - -242 -wch¬_t - * - `__REDIRECT_NTH - ( -__wcsÿt_®Ÿs -, - -243 ( -wch¬_t - * -__»¡riù - -__de¡ -, - -244 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -), -wcsÿt -); - -246 -__ex‹º_®ways_šlše - -wch¬_t - * - -247 - `__NTH - ( - $wcsÿt - ( -wch¬_t - * -__»¡riù - -__de¡ -, -__cÚ¡ - wch¬_ˆ*__»¡riù -__¤c -)) - -249 ià( - `__bos - ( -__de¡ -è!ð( -size_t -) -1) - -250  - `__wcsÿt_chk - ( -__de¡ -, -__¤c -, - `__bos - (__de¡è/  ( -wch¬_t -)); - -251  - `__wcsÿt_®Ÿs - ( -__de¡ -, -__¤c -); - -252 - } -} - -255 -wch¬_t - * - $__wc¢ÿt_chk - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -256 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -257 -size_t - -__n -, size_ˆ -__de¡Ën -è -__THROW -; - -258 -wch¬_t - * - `__REDIRECT_NTH - ( -__wc¢ÿt_®Ÿs -, - -259 ( -wch¬_t - * -__»¡riù - -__de¡ -, - -260 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__¤c -, - -261 -size_t - -__n -), -wc¢ÿt -); - -263 -__ex‹º_®ways_šlše - -wch¬_t - * - -264 - `__NTH - ( - $wc¢ÿt - ( -wch¬_t - * -__»¡riù - -__de¡ -, -__cÚ¡ - wch¬_ˆ*__»¡riù -__¤c -, - -265 -size_t - -__n -)) - -267 ià( - `__bos - ( -__de¡ -è!ð( -size_t -) -1) - -268  - `__wc¢ÿt_chk - ( -__de¡ -, -__¤c -, -__n -, - -269 - `__bos - ( -__de¡ -è/  ( -wch¬_t -)); - -270  - `__wc¢ÿt_®Ÿs - ( -__de¡ -, -__¤c -, -__n -); - -271 - } -} - -274  - $__sw´štf_chk - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__n -, - -275  -__æag -, -size_t - -__s_Ën -, - -276 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -277 -__THROW - ; - -279  - `__REDIRECT_NTH_LDBL - ( -__sw´štf_®Ÿs -, - -280 ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__n -, - -281 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fmt -, ...), - -282 -sw´štf -); - -284 #ifdeà -__va_¬g_·ck - - -285 -__ex‹º_®ways_šlše -  - -286 - `__NTH - ( - $sw´štf - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__n -, - -287 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fmt -, ...)) - -289 ià( - `__bos - ( -__s -è!ð( -size_t -è-1 || -__USE_FORTIFY_LEVEL - > 1) - -290  - `__sw´štf_chk - ( -__s -, -__n -, -__USE_FORTIFY_LEVEL - - 1, - -291 - `__bos - ( -__s -è/  ( -wch¬_t -), - -292 -__fmt -, - `__va_¬g_·ck - ()); - -293  - `__sw´štf_®Ÿs - ( -__s -, -__n -, -__fmt -, - `__va_¬g_·ck - ()); - -294 - } -} - -295 #–ià! -defšed - -__ýlu¥lus - - -297  - #sw´štf -( -s -, -n -, ...) \ - -298 ( - `__bos - ( -s -è!ð( -size_t -è-1 || -__USE_FORTIFY_LEVEL - > 1 \ - -299 ? - `__sw´štf_chk - ( -s -, -n -, -__USE_FORTIFY_LEVEL - - 1, \ - -300 - `__bos - ( -s -è/  ( -wch¬_t -), -__VA_ARGS__ -) \ - -301 : - `sw´štf - ( -s -, -n -, -__VA_ARGS__ -)) - - ) - -304  - $__vsw´štf_chk - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__n -, - -305  -__æag -, -size_t - -__s_Ën -, - -306 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -307 -__gnuc_va_li¡ - -__¬g -) - -308 -__THROW - ; - -310  - `__REDIRECT_NTH_LDBL - ( -__vsw´štf_®Ÿs -, - -311 ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__n -, - -312 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fmt -, - -313 -__gnuc_va_li¡ - -__­ -), -vsw´štf -); - -315 -__ex‹º_®ways_šlše -  - -316 - `__NTH - ( - $vsw´štf - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__n -, - -317 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fmt -, -__gnuc_va_li¡ - -__­ -)) - -319 ià( - `__bos - ( -__s -è!ð( -size_t -è-1 || -__USE_FORTIFY_LEVEL - > 1) - -320  - `__vsw´štf_chk - ( -__s -, -__n -, -__USE_FORTIFY_LEVEL - - 1, - -321 - `__bos - ( -__s -è/  ( -wch¬_t -), -__fmt -, -__­ -); - -322  - `__vsw´štf_®Ÿs - ( -__s -, -__n -, -__fmt -, -__­ -); - -323 - } -} - -326 #ià -__USE_FORTIFY_LEVEL - > 1 - -328  -__fw´štf_chk - ( -__FILE - * -__»¡riù - -__¡»am -,  -__æag -, - -329 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, ...); - -330  -__w´štf_chk - ( -__æag -, -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -332  -__vfw´štf_chk - ( -__FILE - * -__»¡riù - -__¡»am -,  -__æag -, - -333 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -334 -__gnuc_va_li¡ - -__­ -); - -335  -__vw´štf_chk - ( -__æag -, -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fÜm© -, - -336 -__gnuc_va_li¡ - -__­ -); - -338 #ifdeà -__va_¬g_·ck - - -339 -__ex‹º_®ways_šlše -  - -340 - $w´štf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fmt -, ...) - -342  - `__w´štf_chk - ( -__USE_FORTIFY_LEVEL - - 1, -__fmt -, - `__va_¬g_·ck - ()); - -343 - } -} - -345 -__ex‹º_®ways_šlše -  - -346 - $fw´štf - ( -__FILE - * -__»¡riù - -__¡»am -, -__cÚ¡ - -wch¬_t - *__»¡riù -__fmt -, ...) - -348  - `__fw´štf_chk - ( -__¡»am -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, - -349 - `__va_¬g_·ck - ()); - -350 - } -} - -351 #–ià! -defšed - -__ýlu¥lus - - -352  - #w´štf -(...) \ - -353 - `__w´štf_chk - ( -__USE_FORTIFY_LEVEL - - 1, -__VA_ARGS__ -) - - ) - -354  - #fw´štf -( -¡»am -, ...) \ - -355 - `__fw´štf_chk - ( -¡»am -, -__USE_FORTIFY_LEVEL - - 1, -__VA_ARGS__ -) - - ) - -358 -__ex‹º_®ways_šlše -  - -359 - $vw´štf - ( -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fmt -, -__gnuc_va_li¡ - -__­ -) - -361  - `__vw´štf_chk - ( -__USE_FORTIFY_LEVEL - - 1, -__fmt -, -__­ -); - -362 - } -} - -364 -__ex‹º_®ways_šlše -  - -365 - $vfw´štf - ( -__FILE - * -__»¡riù - -__¡»am -, - -366 -__cÚ¡ - -wch¬_t - * -__»¡riù - -__fmt -, -__gnuc_va_li¡ - -__­ -) - -368  - `__vfw´štf_chk - ( -__¡»am -, -__USE_FORTIFY_LEVEL - - 1, -__fmt -, -__­ -); - -369 - } -} - -373 -wch¬_t - * - $__fg‘ws_chk - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__size -,  -__n -, - -374 -__FILE - * -__»¡riù - -__¡»am -è -__wur -; - -375 -wch¬_t - * - `__REDIRECT - ( -__fg‘ws_®Ÿs -, - -376 ( -wch¬_t - * -__»¡riù - -__s -,  -__n -, - -377 -__FILE - * -__»¡riù - -__¡»am -), -fg‘ws -è -__wur -; - -378 -wch¬_t - * - `__REDIRECT - ( -__fg‘ws_chk_w¬n -, - -379 ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__size -,  -__n -, - -380 -__FILE - * -__»¡riù - -__¡»am -), -__fg‘ws_chk -) - -381 -__wur - - `__w¬Ç‰r - ("fgetws called with bigger sizehan†ength " - -384 -__ex‹º_®ways_šlše - -__wur - -wch¬_t - * - -385 - $fg‘ws - ( -wch¬_t - * -__»¡riù - -__s -,  -__n -, -__FILE - *__»¡riù -__¡»am -) - -387 ià( - `__bos - ( -__s -è!ð( -size_t -) -1) - -389 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -) || __n <= 0) - -390  - `__fg‘ws_chk - ( -__s -, - `__bos - (__sè/  ( -wch¬_t -), - -391 -__n -, -__¡»am -); - -393 ià(( -size_t -è -__n - > - `__bos - ( -__s -è/  ( -wch¬_t -)) - -394  - `__fg‘ws_chk_w¬n - ( -__s -, - `__bos - (__sè/  ( -wch¬_t -), - -395 -__n -, -__¡»am -); - -397  - `__fg‘ws_®Ÿs - ( -__s -, -__n -, -__¡»am -); - -398 - } -} - -400 #ifdeà -__USE_GNU - - -401 -wch¬_t - * - $__fg‘ws_uÆocked_chk - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__size -, - -402  -__n -, -__FILE - * -__»¡riù - -__¡»am -) - -403 -__wur -; - -404 -wch¬_t - * - `__REDIRECT - ( -__fg‘ws_uÆocked_®Ÿs -, - -405 ( -wch¬_t - * -__»¡riù - -__s -,  -__n -, - -406 -__FILE - * -__»¡riù - -__¡»am -), -fg‘ws_uÆocked -) - -407 -__wur -; - -408 -wch¬_t - * - `__REDIRECT - ( -__fg‘ws_uÆocked_chk_w¬n -, - -409 ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__size -,  -__n -, - -410 -__FILE - * -__»¡riù - -__¡»am -), - -411 -__fg‘ws_uÆocked_chk -) - -412 -__wur - - `__w¬Ç‰r - ("fgetws_unlocked called with bigger sizehan†ength " - -415 -__ex‹º_®ways_šlše - -__wur - -wch¬_t - * - -416 - $fg‘ws_uÆocked - ( -wch¬_t - * -__»¡riù - -__s -,  -__n -, -__FILE - *__»¡riù -__¡»am -) - -418 ià( - `__bos - ( -__s -è!ð( -size_t -) -1) - -420 ià(! - `__bužtš_cÚ¡ªt_p - ( -__n -) || __n <= 0) - -421  - `__fg‘ws_uÆocked_chk - ( -__s -, - `__bos - (__sè/  ( -wch¬_t -), - -422 -__n -, -__¡»am -); - -424 ià(( -size_t -è -__n - > - `__bos - ( -__s -è/  ( -wch¬_t -)) - -425  - `__fg‘ws_uÆocked_chk_w¬n - ( -__s -, - `__bos - (__sè/  ( -wch¬_t -), - -426 -__n -, -__¡»am -); - -428  - `__fg‘ws_uÆocked_®Ÿs - ( -__s -, -__n -, -__¡»am -); - -429 - } -} - -433 -size_t - - $__wütomb_chk - (* -__»¡riù - -__s -, -wch¬_t - -__wch¬ -, - -434 -mb¡©e_t - * -__»¡riù - -__p -, - -435 -size_t - -__buæ’ -è -__THROW - -__wur -; - -436 -size_t - - `__REDIRECT_NTH - ( -__wütomb_®Ÿs -, - -437 (* -__»¡riù - -__s -, -wch¬_t - -__wch¬ -, - -438 -mb¡©e_t - * -__»¡riù - -__ps -), -wütomb -è -__wur -; - -440 -__ex‹º_®ways_šlše - -__wur - -size_t - - -441 - `__NTH - ( - $wütomb - (* -__»¡riù - -__s -, -wch¬_t - -__wch¬ -, - -442 -mb¡©e_t - * -__»¡riù - -__ps -)) - -447  - #__WCHAR_MB_LEN_MAX - 16 - - ) - -448 #ià -defšed - -MB_LEN_MAX - && MB_LEN_MAX !ð -__WCHAR_MB_LEN_MAX - - -451 ià( - `__bos - ( -__s -è!ð( -size_t -è-1 && -__WCHAR_MB_LEN_MAX - > __bos (__s)) - -452  - `__wütomb_chk - ( -__s -, -__wch¬ -, -__ps -, - `__bos - (__s)); - -453  - `__wütomb_®Ÿs - ( -__s -, -__wch¬ -, -__ps -); - -454 - } -} - -457 -size_t - - $__mb¤towcs_chk - ( -wch¬_t - * -__»¡riù - -__d¡ -, - -458 -__cÚ¡ - ** -__»¡riù - -__¤c -, - -459 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -, - -460 -size_t - -__d¡Ën -è -__THROW -; - -461 -size_t - - `__REDIRECT_NTH - ( -__mb¤towcs_®Ÿs -, - -462 ( -wch¬_t - * -__»¡riù - -__d¡ -, - -463 -__cÚ¡ - ** -__»¡riù - -__¤c -, - -464 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -), - -465 -mb¤towcs -); - -466 -size_t - - `__REDIRECT_NTH - ( -__mb¤towcs_chk_w¬n -, - -467 ( -wch¬_t - * -__»¡riù - -__d¡ -, - -468 -__cÚ¡ - ** -__»¡riù - -__¤c -, - -469 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -, - -470 -size_t - -__d¡Ën -), -__mb¤towcs_chk -) - -471 - `__w¬Ç‰r - ("mbsrtowcs called with dst buffer smallerhan†en " - -474 -__ex‹º_®ways_šlše - -size_t - - -475 - `__NTH - ( - $mb¤towcs - ( -wch¬_t - * -__»¡riù - -__d¡ -, -__cÚ¡ - **__»¡riù -__¤c -, - -476 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -)) - -478 ià( - `__bos - ( -__d¡ -è!ð( -size_t -) -1) - -480 ià(! - `__bužtš_cÚ¡ªt_p - ( -__Ën -)) - -481  - `__mb¤towcs_chk - ( -__d¡ -, -__¤c -, -__Ën -, -__ps -, - -482 - `__bos - ( -__d¡ -è/  ( -wch¬_t -)); - -484 ià( -__Ën - > - `__bos - ( -__d¡ -è/  ( -wch¬_t -)) - -485  - `__mb¤towcs_chk_w¬n - ( -__d¡ -, -__¤c -, -__Ën -, -__ps -, - -486 - `__bos - ( -__d¡ -è/  ( -wch¬_t -)); - -488  - `__mb¤towcs_®Ÿs - ( -__d¡ -, -__¤c -, -__Ën -, -__ps -); - -489 - } -} - -492 -size_t - - $__wc¤tombs_chk - (* -__»¡riù - -__d¡ -, - -493 -__cÚ¡ - -wch¬_t - ** -__»¡riù - -__¤c -, - -494 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -, - -495 -size_t - -__d¡Ën -è -__THROW -; - -496 -size_t - - `__REDIRECT_NTH - ( -__wc¤tombs_®Ÿs -, - -497 (* -__»¡riù - -__d¡ -, - -498 -__cÚ¡ - -wch¬_t - ** -__»¡riù - -__¤c -, - -499 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -), - -500 -wc¤tombs -); - -501 -size_t - - `__REDIRECT_NTH - ( -__wc¤tombs_chk_w¬n -, - -502 (* -__»¡riù - -__d¡ -, - -503 -__cÚ¡ - -wch¬_t - ** -__»¡riù - -__¤c -, - -504 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -, - -505 -size_t - -__d¡Ën -), -__wc¤tombs_chk -) - -506 - `__w¬Ç‰r - ("wcsrtombs called with dst buffer smallerhan†en"); - -508 -__ex‹º_®ways_šlše - -size_t - - -509 - `__NTH - ( - $wc¤tombs - (* -__»¡riù - -__d¡ -, -__cÚ¡ - -wch¬_t - **__»¡riù -__¤c -, - -510 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -)) - -512 ià( - `__bos - ( -__d¡ -è!ð( -size_t -) -1) - -514 ià(! - `__bužtš_cÚ¡ªt_p - ( -__Ën -)) - -515  - `__wc¤tombs_chk - ( -__d¡ -, -__¤c -, -__Ën -, -__ps -, - `__bos - (__dst)); - -517 ià( -__Ën - > - `__bos - ( -__d¡ -)) - -518  - `__wc¤tombs_chk_w¬n - ( -__d¡ -, -__¤c -, -__Ën -, -__ps -, - `__bos - (__dst)); - -520  - `__wc¤tombs_®Ÿs - ( -__d¡ -, -__¤c -, -__Ën -, -__ps -); - -521 - } -} - -524 #ifdeà -__USE_GNU - - -525 -size_t - - $__mb¢¹owcs_chk - ( -wch¬_t - * -__»¡riù - -__d¡ -, - -526 -__cÚ¡ - ** -__»¡riù - -__¤c -, -size_t - -__nmc -, - -527 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -, - -528 -size_t - -__d¡Ën -è -__THROW -; - -529 -size_t - - `__REDIRECT_NTH - ( -__mb¢¹owcs_®Ÿs -, - -530 ( -wch¬_t - * -__»¡riù - -__d¡ -, - -531 -__cÚ¡ - ** -__»¡riù - -__¤c -, -size_t - -__nmc -, - -532 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -), - -533 -mb¢¹owcs -); - -534 -size_t - - `__REDIRECT_NTH - ( -__mb¢¹owcs_chk_w¬n -, - -535 ( -wch¬_t - * -__»¡riù - -__d¡ -, - -536 -__cÚ¡ - ** -__»¡riù - -__¤c -, -size_t - -__nmc -, - -537 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -, - -538 -size_t - -__d¡Ën -), -__mb¢¹owcs_chk -) - -539 - `__w¬Ç‰r - ("mbsnrtowcs called with dst buffer smallerhan†en " - -542 -__ex‹º_®ways_šlše - -size_t - - -543 - `__NTH - ( - $mb¢¹owcs - ( -wch¬_t - * -__»¡riù - -__d¡ -, -__cÚ¡ - **__»¡riù -__¤c -, - -544 -size_t - -__nmc -, size_ˆ -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -)) - -546 ià( - `__bos - ( -__d¡ -è!ð( -size_t -) -1) - -548 ià(! - `__bužtš_cÚ¡ªt_p - ( -__Ën -)) - -549  - `__mb¢¹owcs_chk - ( -__d¡ -, -__¤c -, -__nmc -, -__Ën -, -__ps -, - -550 - `__bos - ( -__d¡ -è/  ( -wch¬_t -)); - -552 ià( -__Ën - > - `__bos - ( -__d¡ -è/  ( -wch¬_t -)) - -553  - `__mb¢¹owcs_chk_w¬n - ( -__d¡ -, -__¤c -, -__nmc -, -__Ën -, -__ps -, - -554 - `__bos - ( -__d¡ -è/  ( -wch¬_t -)); - -556  - `__mb¢¹owcs_®Ÿs - ( -__d¡ -, -__¤c -, -__nmc -, -__Ën -, -__ps -); - -557 - } -} - -560 -size_t - - $__wc¢¹ombs_chk - (* -__»¡riù - -__d¡ -, - -561 -__cÚ¡ - -wch¬_t - ** -__»¡riù - -__¤c -, - -562 -size_t - -__nwc -, size_ˆ -__Ën -, - -563 -mb¡©e_t - * -__»¡riù - -__ps -, -size_t - -__d¡Ën -) - -564 -__THROW -; - -565 -size_t - - `__REDIRECT_NTH - ( -__wc¢¹ombs_®Ÿs -, - -566 (* -__»¡riù - -__d¡ -, - -567 -__cÚ¡ - -wch¬_t - ** -__»¡riù - -__¤c -, - -568 -size_t - -__nwc -, size_ˆ -__Ën -, - -569 -mb¡©e_t - * -__»¡riù - -__ps -), -wc¢¹ombs -); - -570 -size_t - - `__REDIRECT_NTH - ( -__wc¢¹ombs_chk_w¬n -, - -571 (* -__»¡riù - -__d¡ -, - -572 -__cÚ¡ - -wch¬_t - ** -__»¡riù - -__¤c -, - -573 -size_t - -__nwc -, size_ˆ -__Ën -, - -574 -mb¡©e_t - * -__»¡riù - -__ps -, - -575 -size_t - -__d¡Ën -), -__wc¢¹ombs_chk -) - -576 - `__w¬Ç‰r - ("wcsnrtombs called with dst buffer smallerhan†en"); - -578 -__ex‹º_®ways_šlše - -size_t - - -579 - `__NTH - ( - $wc¢¹ombs - (* -__»¡riù - -__d¡ -, -__cÚ¡ - -wch¬_t - **__»¡riù -__¤c -, - -580 -size_t - -__nwc -, size_ˆ -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -)) - -582 ià( - `__bos - ( -__d¡ -è!ð( -size_t -) -1) - -584 ià(! - `__bužtš_cÚ¡ªt_p - ( -__Ën -)) - -585  - `__wc¢¹ombs_chk - ( -__d¡ -, -__¤c -, -__nwc -, -__Ën -, -__ps -, - -586 - `__bos - ( -__d¡ -)); - -588 ià( -__Ën - > - `__bos - ( -__d¡ -)) - -589  - `__wc¢¹ombs_chk_w¬n - ( -__d¡ -, -__¤c -, -__nwc -, -__Ën -, -__ps -, - -590 - `__bos - ( -__d¡ -)); - -592  - `__wc¢¹ombs_®Ÿs - ( -__d¡ -, -__¤c -, -__nwc -, -__Ën -, -__ps -); - -593 - } -} - - @/usr/include/gnu/option-groups.h - -10 #iâdeà -__GNU_OPTION_GROUPS_H - - -11  - #__GNU_OPTION_GROUPS_H - - - ) - -13  - #__OPTION_EGLIBC_ADVANCED_INET6 - 1 - - ) - -14  - #__OPTION_EGLIBC_BACKTRACE - 1 - - ) - -15  - #__OPTION_EGLIBC_BIG_MACROS - 1 - - ) - -16  - #__OPTION_EGLIBC_BSD - 1 - - ) - -17  - #__OPTION_EGLIBC_CATGETS - 1 - - ) - -18  - #__OPTION_EGLIBC_CHARSETS - 1 - - ) - -19  - #__OPTION_EGLIBC_CRYPT - 1 - - ) - -20  - #__OPTION_EGLIBC_CRYPT_UFC - 1 - - ) - -21  - #__OPTION_EGLIBC_CXX_TESTS - 1 - - ) - -22  - #__OPTION_EGLIBC_DB_ALIASES - 1 - - ) - -23  - #__OPTION_EGLIBC_ENVZ - 1 - - ) - -24  - #__OPTION_EGLIBC_FCVT - 1 - - ) - -25  - #__OPTION_EGLIBC_FMTMSG - 1 - - ) - -26  - #__OPTION_EGLIBC_FSTAB - 1 - - ) - -27  - #__OPTION_EGLIBC_FTRAVERSE - 1 - - ) - -28  - #__OPTION_EGLIBC_GETLOGIN - 1 - - ) - -29  - #__OPTION_EGLIBC_IDN - 1 - - ) - -30  - #__OPTION_EGLIBC_INET - 1 - - ) - -31  - #__OPTION_EGLIBC_INET_ANL - 1 - - ) - -32  - #__OPTION_EGLIBC_LIBM - 1 - - ) - -33  - #__OPTION_EGLIBC_LIBM_BIG - 1 - - ) - -34  - #__OPTION_EGLIBC_LOCALES - 1 - - ) - -35  - #__OPTION_EGLIBC_LOCALE_CODE - 1 - - ) - -36  - #__OPTION_EGLIBC_MEMUSAGE - 1 - - ) - -37  - #__OPTION_EGLIBC_NIS - 1 - - ) - -38  - #__OPTION_EGLIBC_NSSWITCH - 1 - - ) - -39  - #__OPTION_EGLIBC_RCMD - 1 - - ) - -40  - #__OPTION_EGLIBC_RTLD_DEBUG - 1 - - ) - -41  - #__OPTION_EGLIBC_SPAWN - 1 - - ) - -42  - #__OPTION_EGLIBC_STREAMS - 1 - - ) - -43  - #__OPTION_EGLIBC_SUNRPC - 1 - - ) - -44  - #__OPTION_EGLIBC_UTMP - 1 - - ) - -45  - #__OPTION_EGLIBC_UTMPX - 1 - - ) - -46  - #__OPTION_EGLIBC_WORDEXP - 1 - - ) - -47  - #__OPTION_POSIX_C_LANG_WIDE_CHAR - 1 - - ) - -48  - #__OPTION_POSIX_REGEXP - 1 - - ) - -49  - #__OPTION_POSIX_REGEXP_GLIBC - 1 - - ) - -50  - #__OPTION_POSIX_WIDE_CHAR_DEVICE_IO - 1 - - ) - - @/usr/include/wctype.h - -24 #iâdeà -_WCTYPE_H - - -26  - ~<ã©u»s.h -> - -27  - ~ - -29 #iâdeà -__Ãed_iswxxx - - -30  - #_WCTYPE_H - 1 - - ) - -33  - #__Ãed_wšt_t - - - ) - -34  - ~ - -38 #iâdeà -WEOF - - -39  - #WEOF - (0xffffffffu) - - ) - -42 #undeà -__Ãed_iswxxx - - -47 #iâdeà -__iswxxx_defšed - - -48  - #__iswxxx_defšed - 1 - - ) - -50 -__BEGIN_NAMESPACE_C99 - - -53  - twùy³_t -; - -54 - g__END_NAMESPACE_C99 - - -56 #iâdeà -_ISwb™ - - -61  - ~<’dŸn.h -> - -62 #ià -__BYTE_ORDER - =ð -__BIG_ENDIAN - - -63  - #_ISwb™ -( -b™ -è(1 << (b™)) - - ) - -65  - #_ISwb™ -( -b™ -) \ - -66 (( -b™ -) < 8 ? () ((1UL << (bit)) << 24) \ - -67 : (( -b™ -) < 16 ? () ((1UL << (bit)) << 8) \ - -68 : (( -b™ -) < 24 ? () ((1UL << (bit)) >> 8) \ - -69 : (è((1UL << ( -b™ -)è>> 24)))) - - ) - -74 - m__ISwuµ” - = 0, - -75 - m__ISwlow” - = 1, - -76 - m__ISw®pha - = 2, - -77 - m__ISwdig™ - = 3, - -78 - m__ISwxdig™ - = 4, - -79 - m__ISw¥aû - = 5, - -80 - m__ISw´št - = 6, - -81 - m__ISwg¿ph - = 7, - -82 - m__ISwbÏnk - = 8, - -83 - m__ISwúŒl - = 9, - -84 - m__ISwpunù - = 10, - -85 - m__ISw®num - = 11, - -87 - m_ISwuµ” - = -_ISwb™ - ( -__ISwuµ” -), - -88 - m_ISwlow” - = -_ISwb™ - ( -__ISwlow” -), - -89 - m_ISw®pha - = -_ISwb™ - ( -__ISw®pha -), - -90 - m_ISwdig™ - = -_ISwb™ - ( -__ISwdig™ -), - -91 - m_ISwxdig™ - = -_ISwb™ - ( -__ISwxdig™ -), - -92 - m_ISw¥aû - = -_ISwb™ - ( -__ISw¥aû -), - -93 - m_ISw´št - = -_ISwb™ - ( -__ISw´št -), - -94 - m_ISwg¿ph - = -_ISwb™ - ( -__ISwg¿ph -), - -95 - m_ISwbÏnk - = -_ISwb™ - ( -__ISwbÏnk -), - -96 - m_ISwúŒl - = -_ISwb™ - ( -__ISwúŒl -), - -97 - m_ISwpunù - = -_ISwb™ - ( -__ISwpunù -), - -98 - m_ISw®num - = -_ISwb™ - ( -__ISw®num -) - -103 -__BEGIN_DECLS - - -105 -__BEGIN_NAMESPACE_C99 - - -112  - $isw®num - ( -wšt_t - -__wc -è -__THROW -; - -118  - $isw®pha - ( -wšt_t - -__wc -è -__THROW -; - -121  - $iswúŒl - ( -wšt_t - -__wc -è -__THROW -; - -125  - $iswdig™ - ( -wšt_t - -__wc -è -__THROW -; - -129  - $iswg¿ph - ( -wšt_t - -__wc -è -__THROW -; - -134  - $iswlow” - ( -wšt_t - -__wc -è -__THROW -; - -137  - $isw´št - ( -wšt_t - -__wc -è -__THROW -; - -142  - $iswpunù - ( -wšt_t - -__wc -è -__THROW -; - -147  - $isw¥aû - ( -wšt_t - -__wc -è -__THROW -; - -152  - $iswuµ” - ( -wšt_t - -__wc -è -__THROW -; - -157  - $iswxdig™ - ( -wšt_t - -__wc -è -__THROW -; - -162 #ifdeà -__USE_ISOC99 - - -163  - $iswbÏnk - ( -wšt_t - -__wc -è -__THROW -; - -172 -wùy³_t - - $wùy³ - ( -__cÚ¡ - * -__´Ý”ty -è -__THROW -; - -176  - $iswùy³ - ( -wšt_t - -__wc -, -wùy³_t - -__desc -è -__THROW -; - -177 -__END_NAMESPACE_C99 - - -184 -__BEGIN_NAMESPACE_C99 - - -187  -__cÚ¡ - - t__št32_t - * - twù¿ns_t -; - -188 -__END_NAMESPACE_C99 - - -189 #ifdeà -__USE_GNU - - -190 - $__USING_NAMESPACE_C99 -( -wù¿ns_t -) - -193 -__BEGIN_NAMESPACE_C99 - - -195 -wšt_t - - $towlow” - ( -wšt_t - -__wc -è -__THROW -; - -198 -wšt_t - - $towuµ” - ( -wšt_t - -__wc -è -__THROW -; - -199 -__END_NAMESPACE_C99 - - -201 -__END_DECLS - - -208 #ifdeà -_WCTYPE_H - - -214 -__BEGIN_DECLS - - -216 -__BEGIN_NAMESPACE_C99 - - -219 -wù¿ns_t - - $wù¿ns - ( -__cÚ¡ - * -__´Ý”ty -è -__THROW -; - -222 -wšt_t - - $towù¿ns - ( -wšt_t - -__wc -, -wù¿ns_t - -__desc -è -__THROW -; - -223 -__END_NAMESPACE_C99 - - -225 #ifdeà -__USE_XOPEN2K8 - - -227  - ~ - -231  - $isw®num_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -237  - $isw®pha_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -240  - $iswúŒl_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -244  - $iswdig™_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -248  - $iswg¿ph_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -253  - $iswlow”_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -256  - $isw´št_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -261  - $iswpunù_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -266  - $isw¥aû_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -271  - $iswuµ”_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -276  - $iswxdig™_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -281  - $iswbÏnk_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -285 -wùy³_t - - $wùy³_l - ( -__cÚ¡ - * -__´Ý”ty -, -__loÿË_t - -__loÿË -) - -286 -__THROW -; - -290  - $iswùy³_l - ( -wšt_t - -__wc -, -wùy³_t - -__desc -, -__loÿË_t - -__loÿË -) - -291 -__THROW -; - -299 -wšt_t - - $towlow”_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -302 -wšt_t - - $towuµ”_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -306 -wù¿ns_t - - $wù¿ns_l - ( -__cÚ¡ - * -__´Ý”ty -, -__loÿË_t - -__loÿË -) - -307 -__THROW -; - -310 -wšt_t - - $towù¿ns_l - ( -wšt_t - -__wc -, -wù¿ns_t - -__desc -, - -311 -__loÿË_t - -__loÿË -è -__THROW -; - -315 -__END_DECLS - - - @ -1 -. -1 -/usr/include -119 -3418 -email-common/email-common-list.c -email-common/email-common-msg-queue.c -email-common/include/email-common-list.h -email-common/include/email-common-msg-queue.h -email-ipc-api.c -email-ipc-api/email-ipc-api-info.c -email-ipc-api/email-ipc-param-list.c -email-ipc-api/email-ipc-param.c -email-ipc-api/include/email-ipc-api-info.h -email-ipc-api/include/email-ipc-param-list.h -email-ipc-api/include/email-ipc-param.h -email-ipc-build.c -email-ipc-proxy.c -email-ipc-stub.c -email-proxy/email-proxy-callback-info.c -email-proxy/email-proxy-main.c -email-proxy/email-proxy-socket.c -email-proxy/include/email-proxy-callback-info.h -email-proxy/include/email-proxy-main.h -email-proxy/include/email-proxy-socket.h -email-socket/email-ipc-socket.c -email-socket/include/email-ipc-socket.h -email-stub/email-stub-main.c -email-stub/email-stub-queue.c -email-stub/email-stub-response-info.c -email-stub/email-stub-socket.c -email-stub/email-stub-task-manager.c -email-stub/email-stub-task.c -email-stub/include/email-stub-main.h -email-stub/include/email-stub-queue.h -email-stub/include/email-stub-response-info.h -email-stub/include/email-stub-socket.h -email-stub/include/email-stub-task-manager.h -email-stub/include/email-stub-task.h -include/email-ipc-build.h -include/email-ipc.h -/usr/include/errno.h -/usr/include/malloc.h -/usr/include/pthread.h -/usr/include/stdio.h -/usr/include/stdlib.h -/usr/include/string.h -/usr/include/sys/epoll.h -/usr/include/sys/ioctl.h -/usr/include/sys/ipc.h -/usr/include/sys/msg.h -/usr/include/sys/select.h -/usr/include/sys/socket.h -/usr/include/sys/stat.h -/usr/include/sys/types.h -/usr/include/sys/un.h -/usr/include/unistd.h -/usr/include/alloca.h -/usr/include/bits/confname.h -/usr/include/bits/environments.h -/usr/include/bits/errno.h -/usr/include/bits/ioctl-types.h -/usr/include/bits/ioctls.h -/usr/include/bits/ipc.h -/usr/include/bits/ipctypes.h -/usr/include/bits/msq.h -/usr/include/bits/posix_opt.h -/usr/include/bits/pthreadtypes.h -/usr/include/bits/select.h -/usr/include/bits/setjmp.h -/usr/include/bits/sigset.h -/usr/include/bits/sockaddr.h -/usr/include/bits/socket.h -/usr/include/bits/socket2.h -/usr/include/bits/stat.h -/usr/include/bits/stdio-ldbl.h -/usr/include/bits/stdio.h -/usr/include/bits/stdio2.h -/usr/include/bits/stdio_lim.h -/usr/include/bits/stdlib-ldbl.h -/usr/include/bits/stdlib.h -/usr/include/bits/string.h -/usr/include/bits/string2.h -/usr/include/bits/string3.h -/usr/include/bits/sys_errlist.h -/usr/include/bits/time.h -/usr/include/bits/types.h -/usr/include/bits/unistd.h -/usr/include/bits/waitflags.h -/usr/include/bits/waitstatus.h -/usr/include/bits/wordsize.h -/usr/include/endian.h -/usr/include/features.h -/usr/include/getopt.h -/usr/include/libio.h -/usr/include/sched.h -/usr/include/stdint.h -/usr/include/sys/cdefs.h -/usr/include/sys/sysmacros.h -/usr/include/sys/ttydefaults.h -/usr/include/sys/uio.h -/usr/include/time.h -/usr/include/xlocale.h -/usr/include/_G_config.h -/usr/include/bits/byteswap.h -/usr/include/bits/endian.h -/usr/include/bits/libio-ldbl.h -/usr/include/bits/predefs.h -/usr/include/bits/sched.h -/usr/include/bits/stdio-lock.h -/usr/include/bits/typesizes.h -/usr/include/bits/uio.h -/usr/include/bits/wchar.h -/usr/include/ctype.h -/usr/include/gnu/stubs.h -/usr/include/linux/errno.h -/usr/include/bits/libc-lock.h -/usr/include/gconv.h -/usr/include/gnu/stubs-32.h -/usr/include/wchar.h -/usr/include/bits/wchar-ldbl.h -/usr/include/bits/wchar2.h -/usr/include/gnu/option-groups.h -/usr/include/wctype.h diff --git a/email-ipc/email-ipc-api.c b/email-ipc/email-ipc-api.c index b2fd4f8..bdfe2dd 100755 --- a/email-ipc/email-ipc-api.c +++ b/email-ipc/email-ipc-api.c @@ -43,16 +43,13 @@ EXPORT_API HIPC_API emipc_create_email_api(long api_id) { EM_DEBUG_FUNC_BEGIN(); - emipc_email_api_info *api_info = NULL; - - api_info = (emipc_email_api_info *)malloc(sizeof(emipc_email_api_info)); + emipc_email_api_info *api_info = (emipc_email_api_info *)calloc(1, sizeof(emipc_email_api_info)); if(api_info == NULL) { EM_DEBUG_EXCEPTION("Malloc failed"); return NULL; } - memset(api_info, 0x00, sizeof(emipc_email_api_info)); - emipc_set_api_id_of_api_info(api_info, api_id); + api_info->api_id = api_id; return (HIPC_API)api_info; } @@ -61,6 +58,7 @@ EXPORT_API void emipc_destroy_email_api(HIPC_API api) { EM_DEBUG_FUNC_BEGIN("API = %p", api); emipc_email_api_info *api_info = (emipc_email_api_info *)api; + emipc_free_api_info(api_info); EM_SAFE_FREE(api_info); } @@ -68,75 +66,112 @@ 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; - return emipc_get_api_id_of_api_info(api_info); + return api_info->api_id; } 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; - return emipc_get_app_id_of_api_info(api_info); + return api_info->app_id; } +/* note: there incurs additional cost (malloc & memcpy). */ +/* if data is a dynamic variable, please use emipc_dynamic_parameter instead */ EXPORT_API bool emipc_add_parameter(HIPC_API api, EPARAMETER_DIRECTION direction, void *data, int data_length) { - EM_DEBUG_FUNC_BEGIN(); + EM_DEBUG_FUNC_BEGIN("data_length[%d]", data_length); emipc_param_list *parameters = emipc_get_api_parameters(api, direction); - if (parameters) - return emipc_add_param_of_param_list(parameters, data, data_length); - else + if (!parameters) { + EM_DEBUG_EXCEPTION("emipc_get_api_parameters failed"); return false; } -EXPORT_API int emipc_get_parameter_count(HIPC_API api, EPARAMETER_DIRECTION direction) + return emipc_add_param_to_param_list(parameters, data, data_length); +} + +/* caution : data should be a dynamic variable */ +/* please, do not use a static variable */ +EXPORT_API bool emipc_add_dynamic_parameter(HIPC_API api, EPARAMETER_DIRECTION direction, void *data, int data_length) { - EM_DEBUG_FUNC_BEGIN(); + EM_DEBUG_FUNC_BEGIN("data_length[%d]", data_length); emipc_param_list *parameters = emipc_get_api_parameters(api, direction); + if (!parameters) { + EM_DEBUG_EXCEPTION("emipc_get_api_parameters failed"); + return false; + } - if(parameters) - return emipc_get_param_count_of_param_list(parameters); - else - return -1; + emipc_add_dynamic_param_to_param_list(parameters, data, data_length); + return true; } -EXPORT_API int emipc_get_parameter(HIPC_API input_api_handle, EPARAMETER_DIRECTION input_parameter_direction, int input_parameter_index, int input_parameter_buffer_size, void *output_parameter_buffer) + + +EXPORT_API int emipc_get_parameter(HIPC_API input_api_handle, EPARAMETER_DIRECTION input_parameter_direction, + int input_parameter_index, int input_parameter_buffer_size, void *output_parameter_buffer) { - EM_DEBUG_FUNC_BEGIN("input_api_handle [%d], input_parameter_direction [%d], input_parameter_index [%d], input_parameter_buffer_size [%d], output_parameter_buffer [%p]", input_api_handle , input_parameter_direction , input_parameter_index, input_parameter_buffer_size, output_parameter_buffer); + EM_DEBUG_FUNC_BEGIN("parameter_index [%d], parameter_buffer_size [%d]", input_parameter_index, input_parameter_buffer_size); emipc_param_list *parameters = NULL; void *local_buffer = NULL; if (input_parameter_buffer_size == 0 || output_parameter_buffer == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; } parameters = emipc_get_api_parameters(input_api_handle, input_parameter_direction); if (parameters == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_IPC_PROTOCOL_FAILURE"); - return EMF_ERROR_IPC_PROTOCOL_FAILURE; + 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("EMF_ERROR_IPC_PROTOCOL_FAILURE"); - return EMF_ERROR_IPC_PROTOCOL_FAILURE; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE"); + return EMAIL_ERROR_IPC_PROTOCOL_FAILURE; } if (emipc_get_param_len_of_param_list(parameters, input_parameter_index) != input_parameter_buffer_size) { - EM_DEBUG_EXCEPTION("EMF_ERROR_IPC_PROTOCOL_FAILURE"); - return EMF_ERROR_IPC_PROTOCOL_FAILURE; + EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE"); + return EMAIL_ERROR_IPC_PROTOCOL_FAILURE; } memcpy(output_parameter_buffer, local_buffer, input_parameter_buffer_size); - EM_DEBUG_FUNC_END("Suceeded"); - return EMF_ERROR_NONE; + EM_DEBUG_FUNC_END(); + return EMAIL_ERROR_NONE; +} + + +EXPORT_API void* emipc_get_nth_parameter_data(HIPC_API api_handle, EPARAMETER_DIRECTION direction, int param_index) +{ + EM_DEBUG_FUNC_BEGIN("nth_parameter_index [%d]", param_index); + emipc_param_list *parameters = NULL; + 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; + } + + EM_DEBUG_FUNC_END(); + return buf; } + EXPORT_API int emipc_get_parameter_length(HIPC_API api, EPARAMETER_DIRECTION direction, int parameter_index) { EM_DEBUG_FUNC_BEGIN(); @@ -149,7 +184,17 @@ EXPORT_API int emipc_get_parameter_length(HIPC_API api, EPARAMETER_DIRECTION dir return -1; } - +EXPORT_API int emipc_get_nth_parameter_length(HIPC_API api, EPARAMETER_DIRECTION direction, int parameter_index) +{ + EM_DEBUG_FUNC_BEGIN(); + emipc_param_list *parameters = emipc_get_api_parameters(api, direction); + if (parameters) { + EM_DEBUG_FUNC_END("Suceeded"); + return emipc_get_param_len_of_param_list(parameters, parameter_index); + } + EM_DEBUG_FUNC_END("Failed"); + return -1; +} 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 c4e2cba..23dc135 100755 --- a/email-ipc/email-ipc-api/email-ipc-api-info.c +++ b/email-ipc/email-ipc-api/email-ipc-api-info.c @@ -30,126 +30,98 @@ #include "email-debug-log.h" -static long emipc_parse_api_id_of_api_info(emipc_email_api_info *api_info, void *stream); -static long emipc_parse_response_id_of_api_info(emipc_email_api_info *api_info, void* stream); -static long emipc_parse_app_id_of_api_info(emipc_email_api_info *api_info, void* stream); -EXPORT_API bool emipc_set_api_id_of_api_info(emipc_email_api_info *api_info, long api_id) +/* deserializing data from stream */ +EXPORT_API bool emipc_deserialize_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction, void *stream) { - api_info->api_id = api_id; - return true; -} - -EXPORT_API long emipc_get_api_id_of_api_info(emipc_email_api_info *api_info) -{ - return api_info->api_id; -} - -EXPORT_API bool emipc_set_app_id_of_api_info(emipc_email_api_info *api_info, long app_id) -{ - api_info->app_id = app_id; - return true; -} - -EXPORT_API long emipc_get_app_id_of_api_info(emipc_email_api_info *api_info) -{ - return api_info->app_id; -} - -EXPORT_API bool emipc_set_response_id_of_api_info(emipc_email_api_info *api_info, long response_id) -{ - api_info->response_id = response_id; - return true; -} - -EXPORT_API long emipc_get_response_id_of_api_info(emipc_email_api_info *api_info) -{ - return api_info->response_id; -} - -EXPORT_API bool emipc_parse_stream_of_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction, void *stream) -{ - emipc_param_list *new_param_list = NULL; + EM_DEBUG_FUNC_BEGIN("emipc_email_api_info : [%p], direction : [%d]", api_info, direction); + + if (!api_info || !stream) { + EM_DEBUG_EXCEPTION("Invalid parameter."); + return false; + } if (api_info->params[direction] == NULL) { - new_param_list = (emipc_param_list *)malloc(sizeof(emipc_param_list)); - if (new_param_list == NULL) { - EM_DEBUG_EXCEPTION("Memory allocation failed."); + api_info->params[direction] = emipc_create_param_list(); + if (api_info->params[direction] == NULL) { + EM_DEBUG_EXCEPTION("Malloc failed"); return false; } - memset(new_param_list, 0x00, sizeof(emipc_param_list)); - api_info->params[direction] = new_param_list; } - emipc_parse_api_id_of_api_info(api_info, stream); - emipc_parse_app_id_of_api_info(api_info, stream); - emipc_parse_response_id_of_api_info(api_info, stream); + api_info->api_id = *((long *)stream + eSTREAM_APIID); + 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); } -EXPORT_API unsigned char *emipc_get_stream_of_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction) +EXPORT_API unsigned char *emipc_serialize_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction, int *stream_len) { - emipc_param_list *new_param_list = NULL; + EM_DEBUG_FUNC_BEGIN(); unsigned char *stream = NULL; + + if (!api_info) { + EM_DEBUG_EXCEPTION("Invalid parameter."); + return stream; + } if (api_info->params[direction] == NULL) { - new_param_list = (emipc_param_list *)malloc(sizeof(emipc_param_list)); - if (new_param_list == NULL) { - EM_DEBUG_EXCEPTION("Memory allocation failed."); - return false; + api_info->params[direction] = emipc_create_param_list(); + if (api_info->params[direction] == NULL) { + EM_DEBUG_EXCEPTION("Malloc failed"); + return NULL; } - memset(new_param_list, 0x00, sizeof(emipc_param_list)); - api_info->params[direction] = new_param_list; } - stream = emipc_get_stream_of_param_list(api_info->params[direction]); + stream = emipc_serialize_param_list(api_info->params[direction], stream_len); if (stream != NULL) { memcpy(stream, &(api_info->api_id), sizeof(api_info->api_id)); memcpy(stream+(sizeof(long)*eSTREAM_RESID), &(api_info->response_id), sizeof(api_info->response_id)); memcpy(stream+(sizeof(long)*eSTREAM_APPID), &(api_info->app_id), sizeof(api_info->app_id)); } + EM_DEBUG_FUNC_END(); return stream; } -EXPORT_API int emipc_get_stream_length_of_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction) -{ - if (api_info->params[direction] == NULL) - return 0; - - return emipc_get_stream_length_of_param_list(api_info->params[direction]); -} - EXPORT_API void *emipc_get_parameters_of_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction) { - emipc_param_list *new_param_list = NULL; - + EM_DEBUG_FUNC_BEGIN("emipc_email_api_info : [%p], direction : [%d]", api_info, direction); + + if (!api_info) { + EM_DEBUG_EXCEPTION("INVALID_PARAM"); + return NULL; + } + if (api_info->params[direction] == NULL) { - new_param_list = (emipc_param_list *)malloc(sizeof(emipc_param_list)); - if (new_param_list == NULL) { - EM_DEBUG_EXCEPTION("Memory allocation failed."); - return false; + api_info->params[direction] = emipc_create_param_list(); + if (api_info->params[direction] == NULL) { + EM_DEBUG_EXCEPTION("emipc_create_param_list failed"); + return NULL; } - memset(new_param_list, 0x00, sizeof(emipc_param_list)); - api_info->params[direction] = new_param_list; } + return api_info->params[direction]; } -static long emipc_parse_api_id_of_api_info(emipc_email_api_info *api_info, void *stream) +EXPORT_API bool emipc_free_api_info(emipc_email_api_info *api_info) { - api_info->api_id = *((long *)stream + eSTREAM_APIID); - return api_info->api_id; -} + if (!api_info) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + return false; + } -static long emipc_parse_response_id_of_api_info(emipc_email_api_info *api_info, void* stream) -{ - api_info->response_id = *((long*)stream + eSTREAM_RESID); - return api_info->response_id; -} + if (!emipc_destroy_param_list(api_info->params[ePARAMETER_IN])) { + EM_DEBUG_EXCEPTION("emipc_destroy_param_list failed : ePARAMETER[%d]", ePARAMETER_IN); + return false; + } -static long emipc_parse_app_id_of_api_info(emipc_email_api_info *api_info, void* stream) -{ - api_info->app_id = *((long*)stream + eSTREAM_APPID); - return api_info->app_id; + if (!emipc_destroy_param_list(api_info->params[ePARAMETER_OUT])) { + EM_DEBUG_EXCEPTION("emipc_destroy_param_list failed : ePARAMETER[%d]", ePARAMETER_OUT); + return false; + } + return true; } + + 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 d899743..1a80bad 100755 --- a/email-ipc/email-ipc-api/email-ipc-param-list.c +++ b/email-ipc/email-ipc-api/email-ipc-param-list.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Kyuho Jo , Sunghyun Kwon -* +* * 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 @@ -27,100 +27,145 @@ #include "email-ipc-param-list.h" #include "email-debug-log.h" +#include "email-utilities.h" /* stream */ /* +----------------------------------------------------------------------------------------------------------+ */ /* | API ID(4B) | Resp. ID (4B) | Param Count(4B) | Param1 Len | Param1 Data | ... | ParamN Len | ParamN data | */ /* +----------------------------------------------------------------------------------------------------------+ */ -static long emipc_parse_parameter_count(void *stream); -EXPORT_API bool emipc_parse_stream_of_param_list(emipc_param_list *param_list, void *stream_data) +EXPORT_API emipc_param_list *emipc_create_param_list() +{ + emipc_param_list *new_param_list = NULL; + + new_param_list = (emipc_param_list *) em_malloc (sizeof(emipc_param_list)); + if (new_param_list == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed."); + return NULL; + } + memset(new_param_list, 0x00, sizeof(emipc_param_list)); + + return new_param_list; +} + +EXPORT_API bool emipc_destroy_param_list(emipc_param_list *param_list) +{ + int count = 10; + int index = 0; + + if (!param_list) { + EM_DEBUG_EXCEPTION("Invalid parameter."); + return false; + } + + for (index = 0; index < count; index++) { + emipc_free_param(param_list->params[index]); + } + EM_SAFE_FREE(param_list->byte_stream); + EM_SAFE_FREE(param_list); + return true; +} + +/* making stream into param length and param data */ +EXPORT_API bool emipc_parse_stream_of_param_list(emipc_param_list *param_list, void *stream) { EM_DEBUG_FUNC_BEGIN(); - long parameter_count = emipc_parse_parameter_count(stream_data); + long parameter_count = *((long *)stream + eSTREAM_COUNT); if(parameter_count <= 0) { - EM_DEBUG_EXCEPTION("There is no parameter. "); + EM_DEBUG_EXCEPTION("INVALID_PARAM : count %d", parameter_count); return false; } - unsigned char* stream = (unsigned char*)stream_data; - long index, param_len, pos = sizeof(long)*eSTREAM_DATA; + unsigned char* cur = ((unsigned char*)stream) + sizeof(int)*eSTREAM_DATA; - for(index = 0; index < parameter_count; index++) { - long len =0; - memcpy(&len, stream+pos, sizeof(long)); - param_len = len; - EM_DEBUG_LOG("Parameter Length [%d] : %d ", index, param_len); - pos += sizeof(long); /* Move from length position to data position */ + 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++) { + /* reading length */ + memcpy(&len, cur, sizeof(int)); - emipc_add_param_of_param_list(param_list, (void*)(stream+pos), param_len); - pos += param_len; /* move to next parameter */ + /* moving from length field to data field */ + cur += sizeof(int); + emipc_add_param_to_param_list(param_list, (void*)cur, len); + + EM_DEBUG_LOG("Parsing stream : element %d is %dbyte long ", i, len); + + /* move to next parameter */ + cur += len; } - + + EM_DEBUG_FUNC_END(); return true; } -EXPORT_API unsigned char *emipc_get_stream_of_param_list(emipc_param_list *param_list) +EXPORT_API unsigned char *emipc_serialize_param_list(emipc_param_list *param_list, int *stream_length) { EM_DEBUG_FUNC_BEGIN(); if(param_list->byte_stream) return param_list->byte_stream; - - int stream_len = emipc_get_stream_length_of_param_list(param_list); - - if (stream_len > 0) { + + int stream_len = emipc_sum_param_list_length (param_list); + + if (stream_len <= 0) { + EM_DEBUG_EXCEPTION("stream_len error %d", stream_len); + EM_SAFE_FREE(param_list->byte_stream); + return NULL; + } + param_list->byte_stream = (unsigned char*)calloc(1, stream_len); int pos = sizeof(long)*eSTREAM_COUNT; if (pos + (int)sizeof(param_list->param_count) > stream_len ) { - EM_DEBUG_EXCEPTION("%d > stream_len", pos + sizeof(param_list->param_count)); + EM_DEBUG_EXCEPTION("%d > stream_len", pos + sizeof(param_list->param_count)); EM_SAFE_FREE(param_list->byte_stream); return NULL; } - + memcpy((param_list->byte_stream + pos), ¶m_list->param_count, sizeof(param_list->param_count)); - + pos += sizeof(long); int index = 0, length = 0; - /* check memory overflow */ - for(index=0; indexparam_count; index++) { - length = emipc_get_length(param_list->params[index]); - if (length <= 0) { - EM_DEBUG_EXCEPTION("index = %d, length = %d", index, length); - EM_SAFE_FREE(param_list->byte_stream); - return NULL; - } - - if (pos + (int)sizeof(long) > stream_len) { - EM_DEBUG_EXCEPTION("%d > stream_len", pos + sizeof(long)); - EM_SAFE_FREE(param_list->byte_stream); - return NULL; - } - memcpy((param_list->byte_stream+pos), &length, sizeof(long)); - pos += sizeof(long); - - if (pos + length > stream_len) { - EM_DEBUG_EXCEPTION("%d > stream_len", pos + length); - EM_SAFE_FREE(param_list->byte_stream); - return NULL; - } - + /* stream format */ + /* | param1 length | (param1 data) | param2 length | (param2 data) | ... |*/ + /* if param is 0 long, the param data is omitted */ + for(index=0; indexparam_count; index++) { + length = emipc_get_length(param_list->params[index]); + if (length < 0) { + EM_DEBUG_EXCEPTION("index = %d, length = %d", index, length); + EM_SAFE_FREE(param_list->byte_stream); + return NULL; + } + + if (pos + (int)sizeof(long) > stream_len) { + EM_DEBUG_EXCEPTION("%d > stream_len", pos + sizeof(long)); + EM_SAFE_FREE(param_list->byte_stream); + return NULL; + } + /* write param i length */ + memcpy((param_list->byte_stream+pos), &length, sizeof(long)); + pos += sizeof(long); + + if (pos + length > stream_len) { + EM_DEBUG_EXCEPTION("%d > stream_len", pos + length); + EM_SAFE_FREE(param_list->byte_stream); + return NULL; + } + /* write param i data if length is greater than 0 */ + if( length > 0 ) { memcpy((param_list->byte_stream+pos), emipc_get_data(param_list->params[index]), length); pos += length; } - return param_list->byte_stream; } - - EM_DEBUG_EXCEPTION("failed."); - EM_SAFE_FREE(param_list->byte_stream); + *stream_length = stream_len; EM_DEBUG_FUNC_END(); - return NULL; + return param_list->byte_stream; } -EXPORT_API int emipc_get_stream_length_of_param_list(emipc_param_list *param_list) +EXPORT_API int emipc_sum_param_list_length(emipc_param_list *param_list) { int length = sizeof(long) * eSTREAM_DATA; int index; @@ -131,7 +176,7 @@ EXPORT_API int emipc_get_stream_length_of_param_list(emipc_param_list *param_lis return length; } -EXPORT_API bool emipc_add_param_of_param_list(emipc_param_list *param_list, void *data, int len) +EXPORT_API bool emipc_add_param_to_param_list(emipc_param_list *param_list, void *data, int len) { EM_DEBUG_FUNC_BEGIN(); if (emipc_set_param(&(param_list->params[param_list->param_count]), data, len)) { @@ -142,6 +187,14 @@ EXPORT_API bool emipc_add_param_of_param_list(emipc_param_list *param_list, void return false; } +EXPORT_API void emipc_add_dynamic_param_to_param_list(emipc_param_list *param_list, void *data, int len) +{ + EM_DEBUG_FUNC_BEGIN(); + emipc_set_dynamic_param(&(param_list->params[param_list->param_count]), data, len); + param_list->param_count++; + EM_SAFE_FREE(param_list->byte_stream); +} + EXPORT_API void *emipc_get_param_of_param_list(emipc_param_list *param_list, int index) { EM_DEBUG_FUNC_BEGIN("index [%d]", index); @@ -162,16 +215,4 @@ EXPORT_API int emipc_get_param_len_of_param_list(emipc_param_list *param_list, i return emipc_get_length(param_list->params[index]); } -EXPORT_API int emipc_get_param_count_of_param_list(emipc_param_list *param_list) -{ - EM_DEBUG_FUNC_BEGIN("Parameter count [%d]", param_list->param_count); - return param_list->param_count; -} -static long emipc_parse_parameter_count(void *stream) -{ - EM_DEBUG_FUNC_BEGIN(); - long *parameter_count_position = (long *)stream + eSTREAM_COUNT; - - return *parameter_count_position; -} diff --git a/email-ipc/email-ipc-api/email-ipc-param.c b/email-ipc/email-ipc-api/email-ipc-param.c index 57db8c3..b66d32a 100755 --- a/email-ipc/email-ipc-api/email-ipc-param.c +++ b/email-ipc/email-ipc-api/email-ipc-param.c @@ -48,6 +48,25 @@ EXPORT_API bool emipc_set_param(emipc_param *param, void *data, int len) return true; } +EXPORT_API void emipc_set_dynamic_param(emipc_param *param, void *data, int len) +{ + EM_DEBUG_FUNC_BEGIN(); + + if (!param) { + EM_DEBUG_EXCEPTION("Invalid paramter"); + return; + } + + /* even take care of null data */ + param->data = data; + param->length = len; +} + +EXPORT_API void emipc_free_param(emipc_param param) +{ + EM_SAFE_FREE(param.data); +} + EXPORT_API int emipc_get_length(emipc_param param) { return param.length; 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 705b97d..a860b5e 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 @@ -36,27 +36,17 @@ typedef struct { emipc_param_list *params[2]; } emipc_email_api_info; -EXPORT_API bool emipc_set_api_id_of_api_info(emipc_email_api_info *api_info, long api_id); +/*EXPORT_API bool emipc_set_app_id_of_api_info(emipc_email_api_info *api_info, long app_id); */ -EXPORT_API long emipc_get_api_id_of_api_info(emipc_email_api_info *api_info); +EXPORT_API bool emipc_deserialize_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction, void *stream); -EXPORT_API bool emipc_set_app_id_of_api_info(emipc_email_api_info *api_info, long app_id); +EXPORT_API unsigned char *emipc_serialize_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction, int *stream_len); -EXPORT_API long emipc_get_app_id_of_api_info(emipc_email_api_info *api_info); - -EXPORT_API bool emipc_set_response_id_of_api_info(emipc_email_api_info *api_info, long response_id); - -EXPORT_API long emipc_get_response_id_of_api_info(emipc_email_api_info *api_info); - -EXPORT_API bool emipc_parse_stream_of_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction, void *stream); - -EXPORT_API unsigned char *emipc_get_stream_of_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction); - -EXPORT_API int emipc_get_stream_length_of_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction); +/*EXPORT_API int emipc_get_stream_length_of_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction); */ EXPORT_API void *emipc_get_parameters_of_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction); - +EXPORT_API bool emipc_free_api_info(emipc_email_api_info *api_info); /* don't insert empty line */ #define EM_APIID_TO_STR(nAPIID) \ @@ -67,6 +57,12 @@ EXPORT_API void *emipc_get_parameters_of_api_info(emipc_email_api_info *api_info case _EMAIL_API_ADD_ACCOUNT:\ s = "_EMAIL_API_ADD_ACCOUNT";\ break;\ + case _EMAIL_API_DELETE_ACCOUNT:\ + s = "_EMAIL_API_DELETE_ACCOUNT";\ + break;\ + case _EMAIL_API_UPDATE_ACCOUNT:\ + s = "_EMAIL_API_UPDATE_ACCOUNT";\ + break;\ case _EMAIL_API_ADD_MAILBOX:\ s = "_EMAIL_API_ADD_MAILBOX";\ break;\ @@ -76,6 +72,12 @@ EXPORT_API void *emipc_get_parameters_of_api_info(emipc_email_api_info *api_info case _EMAIL_API_UPDATE_MAILBOX:\ s = "_EMAIL_API_UPDATE_MAILBOX";\ break;\ + case _EMAIL_API_RENAME_MAILBOX:\ + s = "_EMAIL_API_RENAME_MAILBOX";\ + break;\ + case _EMAIL_API_SET_MAILBOX_TYPE:\ + s = "_EMAIL_API_SET_MAILBOX_TYPE";\ + break;\ case _EMAIL_API_SET_MAIL_SLOT_SIZE:\ s = "_EMAIL_API_SET_MAIL_SLOT_SIZE";\ break;\ @@ -154,9 +156,6 @@ EXPORT_API void *emipc_get_parameters_of_api_info(emipc_email_api_info *api_info case _EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD:\ s = "_EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD";\ break;\ - case _EMAIL_API_UPDATE_ACCOUNT:\ - s = "_EMAIL_API_UPDATE_ACCOUNT";\ - break;\ case _EMAIL_API_ADD_ATTACHMENT:\ s = "_EMAIL_API_ADD_ATTACHMENT";\ break;\ @@ -220,6 +219,9 @@ EXPORT_API void *emipc_get_parameters_of_api_info(emipc_email_api_info *api_info case _EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT:\ s = "_EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT";\ break;\ + case _EMAIL_API_SHOW_USER_MESSAGE:\ + s = "_EMAIL_API_SHOW_USER_MESSAGE";\ + 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 c7d71ba..5e7be71 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 @@ -41,20 +41,24 @@ typedef struct { unsigned char *byte_stream; } emipc_param_list; +EXPORT_API emipc_param_list *emipc_create_param_list(); + +EXPORT_API bool emipc_destroy_param_list(emipc_param_list *param_list); + EXPORT_API bool emipc_parse_stream_of_param_list(emipc_param_list *param_list, void *stream_data); -EXPORT_API unsigned char *emipc_get_stream_of_param_list(emipc_param_list *param_list); +EXPORT_API unsigned char *emipc_serialize_param_list(emipc_param_list *param_list, int *stream_length); + +EXPORT_API int emipc_sum_param_list_length (emipc_param_list *param_list); -EXPORT_API int emipc_get_stream_length_of_param_list(emipc_param_list *param_list); +EXPORT_API bool emipc_add_param_to_param_list(emipc_param_list *param_list, void *data, int len); -EXPORT_API bool emipc_add_param_of_param_list(emipc_param_list *param_list, void *data, int len); +EXPORT_API void emipc_add_dynamic_param_to_param_list(emipc_param_list *param_list, void *data, int len); EXPORT_API void *emipc_get_param_of_param_list(emipc_param_list *param_list, int index); EXPORT_API int emipc_get_param_len_of_param_list(emipc_param_list *param_list, int index); -EXPORT_API int emipc_get_param_count_of_param_list(emipc_param_list *param_list); - #endif /* _IPC_PARAMLIST_H_ */ diff --git a/email-ipc/email-ipc-api/include/email-ipc-param.h b/email-ipc/email-ipc-api/include/email-ipc-param.h index 361927b..e80425a 100755 --- a/email-ipc/email-ipc-api/include/email-ipc-param.h +++ b/email-ipc/email-ipc-api/include/email-ipc-param.h @@ -32,6 +32,10 @@ typedef struct { EXPORT_API bool emipc_set_param(emipc_param *param, void *data, int len); +EXPORT_API void emipc_set_dynamic_param(emipc_param *param, void *data, int len); + +EXPORT_API void emipc_free_param(emipc_param param); + EXPORT_API int emipc_get_length(emipc_param param); EXPORT_API void *emipc_get_data(emipc_param param); diff --git a/email-ipc/email-ipc-proxy.c b/email-ipc/email-ipc-proxy.c index 2aa6833..2d61de1 100755 --- a/email-ipc/email-ipc-proxy.c +++ b/email-ipc/email-ipc-proxy.c @@ -1,81 +1,96 @@ -/* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * PROPRIETARY/CONFIDENTIAL - * - * This software is the confidential and proprietary information of SAMSUNG - * ELECTRONICS ("Confidential Information"). You agree and acknowledge that - * this software is owned by Samsung and 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. - * SAMSUNG make no representations or warranties about the suitability of the - * software, either express or implied, including but not limited to the - * implied warranties of merchantability, fitness for a particular purpose, - * or non-infringement. SAMSUNG shall not be liable for any damages suffered - * by licensee arising out of or releated to this software. - * - */ - -#include "email-ipc-build.h" -#include "email-ipc.h" -#include "email-ipc-api-info.h" -#include "email-ipc-param-list.h" -#include "email-ipc-socket.h" -#include "email-proxy-main.h" - -#include "email-debug-log.h" -#include "email-api.h" -#include "email-types.h" - -EXPORT_API int emipc_initialize_proxy() -{ - EM_DEBUG_FUNC_BEGIN(); - - int err = emipc_initialize_proxy_main(); - - EM_DEBUG_FUNC_END(); - return err; -} - -EXPORT_API int emipc_finalize_proxy() -{ - EM_DEBUG_FUNC_BEGIN(); - return emipc_finalize_proxy_main(); -} - -EXPORT_API bool emipc_execute_proxy_api(HIPC_API api) -{ - EM_DEBUG_FUNC_BEGIN(); - int ret; - int err = EMF_ERROR_NONE; - emipc_email_api_info *api_info = (emipc_email_api_info *)api; - - EM_DEBUG_LOG("API [%p]", api_info); - - if(api_info == NULL) { - EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM"); - return EMF_ERROR_INVALID_PARAM; - } - - EM_DEBUG_LOG("APIID [%s], ResponseID [%d], APPID[%d]", EM_APIID_TO_STR(emipc_get_api_id_of_api_info(api_info)), emipc_get_response_id_of_api_info(api_info), emipc_get_app_id_of_api_info(api_info)); - - ret = emipc_execute_api_of_proxy_main(api_info); - - /* connection retry */ - if (!ret) { - emipc_finalize_proxy(); - - err = emipc_initialize_proxy(); - if (err != EMF_ERROR_NONE) { - EM_DEBUG_EXCEPTION("Failed to open the socket : [%d]", err); - return EMF_ERROR_CONNECTION_FAILURE; - } - - ret = emipc_execute_api_of_proxy_main(api_info); - if (!ret) { - EM_DEBUG_EXCEPTION("emipc_proxy_main : emipc_execute_api failed [%d]", err); - return EMF_ERROR_CONNECTION_FAILURE; - } - } - EM_DEBUG_FUNC_END("err [%d]", err); - return err; -} +/* +* email-service +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: Kyuho Jo , Sunghyun Kwon +* +* 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. +* +*/ + +#include "email-ipc-build.h" +#include "email-ipc.h" +#include "email-ipc-api-info.h" +#include "email-ipc-param-list.h" +#include "email-ipc-socket.h" +#include "email-proxy-main.h" + +#include "email-debug-log.h" +#include "email-api.h" +#include "email-types.h" +#include "email-internal-types.h" + +pthread_mutex_t proxy_mutex = PTHREAD_MUTEX_INITIALIZER; + +EXPORT_API int emipc_initialize_proxy() +{ + EM_DEBUG_FUNC_BEGIN(); + + int err = emipc_initialize_proxy_main(); + + EM_DEBUG_FUNC_END(); + return err; +} + +EXPORT_API int emipc_finalize_proxy() +{ + EM_DEBUG_FUNC_BEGIN(); + return emipc_finalize_proxy_main(); +} + +EXPORT_API int emipc_execute_proxy_api(HIPC_API api) +{ + EM_DEBUG_FUNC_BEGIN(); + int ret; + int err = EMAIL_ERROR_NONE; + emipc_email_api_info *api_info = (emipc_email_api_info *)api; + + EM_DEBUG_LOG("API [%p]", api_info); + + if(api_info == NULL) { + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + return EMAIL_ERROR_INVALID_PARAM; + } + + EM_DEBUG_LOG("APIID [%s], ResponseID [%d], APPID[%d]", + EM_APIID_TO_STR(api_info->api_id), api_info->response_id, api_info->app_id); + + ENTER_CRITICAL_SECTION(proxy_mutex); + ret = emipc_execute_api_of_proxy_main(api_info); + + /* connection retry */ + if (!ret) { + EM_DEBUG_LOG("Connection retry"); + emipc_finalize_proxy(); + + err = emipc_initialize_proxy(); + if (err != EMAIL_ERROR_NONE) { + EM_DEBUG_EXCEPTION("Failed to open the socket : [%d]", err); + err = EMAIL_ERROR_CONNECTION_FAILURE; + goto FINISH_OFF; + } + + ret = emipc_execute_api_of_proxy_main(api_info); + if (!ret) { + EM_DEBUG_EXCEPTION("emipc_proxy_main : emipc_execute_api failed [%d]", err); + err = EMAIL_ERROR_CONNECTION_FAILURE; + goto FINISH_OFF; + } + } + +FINISH_OFF: + LEAVE_CRITICAL_SECTION(proxy_mutex); + EM_DEBUG_FUNC_END("err [%d]", err); + return err; +} diff --git a/email-ipc/email-ipc-stub.c b/email-ipc/email-ipc-stub.c index 94e04e7..f435d2a 100755 --- a/email-ipc/email-ipc-stub.c +++ b/email-ipc/email-ipc-stub.c @@ -31,20 +31,12 @@ EXPORT_API bool emipc_initialize_stub(PFN_EXECUTE_API api_mapper) EM_DEBUG_LOG("[IPCLib] ipcEmailStub_Initialize "); return emipc_initialize_stub_main(api_mapper); -/* - return ipcEmailStubMain::Instance()->Initialize(api_mapper); -*/ } EXPORT_API bool emipc_finalize_stub() { emipc_finalize_stub_main(); return true; -/* - ipcEmailStubMain::Instance()->Finalize(); - ipcEmailStubMain::Instance()->FreeInstance(); - return true; -*/ } EXPORT_API bool emipc_execute_stub_api(HIPC_API api) @@ -55,11 +47,5 @@ EXPORT_API bool emipc_execute_stub_api(HIPC_API api) return false; return emipc_execute_api_stub_to_proxy(api_info); -/* - ipcEmailAPIInfo *pApi = static_cast(a_hAPI); - if(pApi == NULL) - return false; - return ipcEmailStubMain::Instance()->ExecuteAPIStubToProxy(pApi); -*/ } diff --git a/email-ipc/email-proxy/email-proxy-main.c b/email-ipc/email-proxy/email-proxy-main.c index d95d4d0..b4f729c 100755 --- a/email-ipc/email-proxy/email-proxy-main.c +++ b/email-ipc/email-proxy/email-proxy-main.c @@ -30,47 +30,40 @@ #include "email-proxy-socket.h" #include "email-proxy-callback-info.h" -#include "email-internal-types.h" #include "email-debug-log.h" -static int reference = 0; - -pthread_mutex_t ipc_proxy_mutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t ipc_proxy_cond = PTHREAD_COND_INITIALIZER; - - EXPORT_API int emipc_initialize_proxy_main() { EM_DEBUG_FUNC_BEGIN(); + int sock_fd = 0; + + sock_fd = emipc_get_proxy_socket_id(); - if (reference > 0) { - EM_DEBUG_EXCEPTION("Already Intialized reference[%d]", reference); - return EMF_ERROR_NONE; + if (sock_fd) { + EM_DEBUG_LOG("Socket already initialized"); + return EMAIL_ERROR_IPC_ALREADY_INITIALIZED; } - - reference++; if (!emipc_start_proxy_socket()) { EM_DEBUG_EXCEPTION("Socket start failed"); - return EMF_ERROR_IPC_CONNECTION_FAILURE; + return EMAIL_ERROR_IPC_CONNECTION_FAILURE; } EM_DEBUG_LOG("Socket ID : %d", emipc_get_proxy_socket_id()); EM_DEBUG_FUNC_END(); - return EMF_ERROR_NONE; + return EMAIL_ERROR_NONE; } EXPORT_API int emipc_finalize_proxy_main() { EM_DEBUG_FUNC_BEGIN(); - - if (--reference > 0) { - EM_DEBUG_EXCEPTION("More than one reference[%d]", reference); - return EMF_ERROR_NONE; + if (!emipc_end_proxy_socket()) { + EM_DEBUG_EXCEPTION("emipc_finalize_proxy_main failed"); + return EMAIL_ERROR_IPC_SOCKET_FAILURE; } EM_DEBUG_FUNC_END(); - return EMF_ERROR_NONE; + return EMAIL_ERROR_NONE; } EXPORT_API bool emipc_execute_api_of_proxy_main(emipc_email_api_info *api_info) @@ -78,8 +71,8 @@ EXPORT_API bool emipc_execute_api_of_proxy_main(emipc_email_api_info *api_info) EM_DEBUG_FUNC_BEGIN(); int ret; - unsigned char *in_stream = emipc_get_stream_of_api_info(api_info, ePARAMETER_IN); - int length = emipc_get_stream_length_of_api_info(api_info, ePARAMETER_IN); + unsigned char *in_stream = NULL; + int length = 0; bool result = false; int sending_bytes; @@ -88,9 +81,13 @@ EXPORT_API bool emipc_execute_api_of_proxy_main(emipc_email_api_info *api_info) return false; } - ENTER_CRITICAL_SECTION(ipc_proxy_mutex); + in_stream = emipc_serialize_api_info(api_info, ePARAMETER_IN, &length); + if( !in_stream ) { + EM_DEBUG_EXCEPTION("NULL stream"); + return false; + } + sending_bytes = emipc_send_proxy_socket(in_stream, length); - LEAVE_CRITICAL_SECTION(ipc_proxy_mutex); EM_DEBUG_LOG("Proxy=>stub sending %d byte.", sending_bytes); @@ -101,15 +98,13 @@ EXPORT_API bool emipc_execute_api_of_proxy_main(emipc_email_api_info *api_info) EM_DEBUG_LOG("in_stream[index] : [%x]", in_stream[index]); #endif char *ipc_buf = NULL; - - ENTER_CRITICAL_SECTION(ipc_proxy_mutex); - ret = emipc_recv_proxy_socket(&ipc_buf); - LEAVE_CRITICAL_SECTION(ipc_proxy_mutex); + ret = emipc_recv_proxy_socket(&ipc_buf); + EM_DEBUG_LOG("Recv length : %d", ret); if (ret > 0) - result = emipc_parse_stream_of_api_info(api_info, ePARAMETER_OUT, ipc_buf); + result = emipc_deserialize_api_info(api_info, ePARAMETER_OUT, ipc_buf); else result = false; @@ -119,43 +114,3 @@ EXPORT_API bool emipc_execute_api_of_proxy_main(emipc_email_api_info *api_info) EM_DEBUG_FUNC_END(); return result; } -#if 0 -EXPORT_API bool emipc_dispatch_proxy_main() -{ - EM_DEBUG_FUNC_BEGIN(); - - unsigned char stream[IPC_MSGQ_SIZE]; - emipc_email_api_info *api_info = NULL; - int api_id = 0; - int stream_length = 0; - - while(!recv_stop_flag) { - memset(stream, 0x00, sizeof(stream)); - - if (emcm_recv_msg(stream, sizeof(stream)) > 0) { - api_info = (emipc_email_api_info *)malloc(sizeof(emipc_email_api_info)); - if (api_info == NULL) { - EM_DEBUG_EXCEPTION("Malloc failed."); - return false; - } - memset(api_info, 0x00, sizeof(emipc_email_api_info)); - - api_id = *((int *)stream); - - emipc_set_api_id_of_api_info(api_info, api_id); - emipc_parse_stream_of_api_info(api_info, ePARAMETER_OUT, stream); - stream_length = emipc_get_stream_length_of_api_info(api_info, ePARAMETER_OUT); - EM_DEBUG_LOG("Proxy Message Queue Recv [api_id=%x], [Recv_len=%d]", api_id, stream_length); - -#ifdef IPCLIB_STREAM_TRACE_ON - int index = 0; - for (index = 0; index, Sunghyun Kwon -* +* * 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 @@ -45,7 +45,7 @@ EXPORT_API bool emipc_start_proxy_socket() ret = emipc_connect_email_socket(proxy_socket_fd); - return ret; + return ret; } EXPORT_API bool emipc_end_proxy_socket() @@ -54,21 +54,27 @@ EXPORT_API bool emipc_end_proxy_socket() EM_DEBUG_LOG("[IPCLib] emipc_end_proxy_socket_fd"); if (proxy_socket_fd) { - emipc_close_email_socket(proxy_socket_fd); - proxy_socket_fd = 0; + emipc_close_email_socket(&proxy_socket_fd); } - + return true; } +/* return result of emipc_send_email_socket + * EMAIL_ERROR_IPC_SOCKET_FAILURE, when no IPC connection */ EXPORT_API int emipc_send_proxy_socket(unsigned char *data, int len) { EM_DEBUG_FUNC_BEGIN(); if (!proxy_socket_fd) { EM_DEBUG_EXCEPTION("[IPCLib] emipc_send_proxy_socket_fd not connect"); - return false; + return EMAIL_ERROR_IPC_SOCKET_FAILURE; } - return emipc_send_email_socket(proxy_socket_fd, data, len); + int send_len = emipc_send_email_socket(proxy_socket_fd, data, len); + if (send_len == 0) { + EM_DEBUG_EXCEPTION("[IPCLib] server closed connection %x", proxy_socket_fd); + emipc_close_email_socket(&proxy_socket_fd); + } + return send_len; } EXPORT_API int emipc_get_proxy_socket_id() @@ -77,10 +83,18 @@ EXPORT_API int emipc_get_proxy_socket_id() return proxy_socket_fd; } +/* return true, when event occurred + * false, when select error + */ static bool wait_for_reply (int fd) { fd_set fds; + if (fd == 0) { + EM_DEBUG_EXCEPTION("Invalid file description : [%d]", fd); + return false; + } + FD_ZERO(&fds); FD_SET(fd, &fds); @@ -90,33 +104,33 @@ static bool wait_for_reply (int fd) } if (FD_ISSET(fd, &fds)) return true; - else return false; + + return false; } +/* return result of emipc_recv_email_socket + * EMAIL_ERROR_IPC_SOCKET_FAILURE, when no IPC connection, or wrong fd */ EXPORT_API int emipc_recv_proxy_socket(char **data) { EM_DEBUG_FUNC_BEGIN(); - - int recv_len = 0; - + if (!proxy_socket_fd) { EM_DEBUG_EXCEPTION("[IPCLib] proxy_socket_fd[%p] is not available or disconnected", proxy_socket_fd); - return 0; + return EMAIL_ERROR_IPC_SOCKET_FAILURE; } - if( !wait_for_reply(proxy_socket_fd) ) return 0; + if( !wait_for_reply(proxy_socket_fd) ) { - recv_len = emipc_recv_email_socket(proxy_socket_fd, data); + return EMAIL_ERROR_IPC_SOCKET_FAILURE; + } + int recv_len = emipc_recv_email_socket(proxy_socket_fd, data); if (recv_len == 0) { - EM_DEBUG_EXCEPTION("[IPCLib] Proxy recv delete %x", proxy_socket_fd); - emipc_close_email_socket(proxy_socket_fd); - proxy_socket_fd = 0; - } else if (recv_len == -1) { - EM_DEBUG_EXCEPTION("[IPCLib] Proxy recv error"); + EM_DEBUG_EXCEPTION("[IPCLib] server closed connection %x", proxy_socket_fd); + emipc_close_email_socket(&proxy_socket_fd); } - + return recv_len; } diff --git a/email-ipc/email-socket/email-ipc-socket.c b/email-ipc/email-socket/email-ipc-socket.c index 1c9c5aa..d345d99 100755 --- a/email-ipc/email-socket/email-ipc-socket.c +++ b/email-ipc/email-socket/email-ipc-socket.c @@ -38,7 +38,6 @@ #include #include - EXPORT_API bool emipc_init_email_socket(int *fd) { bool ret = true; @@ -56,18 +55,16 @@ EXPORT_API bool emipc_init_email_socket(int *fd) } /* Close */ -EXPORT_API bool emipc_close_email_socket(int fd) +EXPORT_API void emipc_close_email_socket(int* fd) { - EM_DEBUG_FUNC_BEGIN("fd[%d] to be removed", fd); - int ret = true; - EM_DEBUG_LOG("fd %d removal done", fd); - close(fd); - - EM_DEBUG_FUNC_END(); - return ret; + close(*fd); + *fd = 0; } +/* returns positive write length, + * 0, when connection is closed + * -1, when send error */ static int emipc_writen(int fd, const char *buf, int len) { int length = len; @@ -78,7 +75,8 @@ static int emipc_writen(int fd, const char *buf, int len) if (passed_len == -1) { EM_DEBUG_LOG("write : %s", EM_STRERROR(errno)); if (errno == EINTR) continue; - return passed_len; + else if (errno == EPIPE) return 0; /* connection closed */ + else return passed_len; /* -1 */ } else if (passed_len == 0) break; length -= passed_len; @@ -87,21 +85,26 @@ static int emipc_writen(int fd, const char *buf, int len) return (len - length); } +/* returns positive value, when write success, + * 0, when socket connection is broken, + * EMAIL_ERROR_IPC_SOCKET_FAILURE, when write failure, + * EMAIL_ERROR_INVALID_PARAM, when wrong parameter */ EXPORT_API int emipc_send_email_socket(int fd, unsigned char *buf, int len) { EM_DEBUG_FUNC_BEGIN("fd [%d], buffer [%p], buf_len [%d]", fd, buf, len); - if (!buf) { - EM_DEBUG_EXCEPTION("No data to send"); - return 0; + if (!buf || len <= 0) { + EM_DEBUG_EXCEPTION("No data to send %p, %d", buf, len); + return EMAIL_ERROR_INVALID_PARAM; } EM_DEBUG_LOG("Sending %dB data to [fd = %d]", len, fd); int write_len = emipc_writen(fd, (char*) buf, len); if ( write_len != len) { + if ( write_len == 0 ) return 0; EM_DEBUG_LOG("WARNING: buf_size [%d] != write_len[%d]", len, write_len); - return EMF_ERROR_IPC_SOCKET_FAILURE; + return EMAIL_ERROR_IPC_SOCKET_FAILURE; } EM_DEBUG_FUNC_END(); return write_len; @@ -127,35 +130,44 @@ static int emipc_readn(int fd, char *buf, int len) return (len-length); } - +/* returns positive value when read success, + * 0, when socket is closed + * EMAIL_ERROR_IPC_SOCKET_FAILURE, when read failed + * EMAIL_ERROR_INVALID_PARAM when wrong parameter */ EXPORT_API int emipc_recv_email_socket(int fd, char **buf) { EM_DEBUG_FUNC_BEGIN(); if (!buf) { EM_DEBUG_LOG("Buffer must not null"); - return EMF_ERROR_INVALID_PARAM; + return EMAIL_ERROR_INVALID_PARAM; } int read_len = 0; + /* read the size of message. note that ioctl is non-blocking */ if (ioctl(fd, FIONREAD, &read_len)) { EM_DEBUG_EXCEPTION("ioctl: %s", strerror(errno)); - return EMF_ERROR_IPC_SOCKET_FAILURE; + return EMAIL_ERROR_IPC_SOCKET_FAILURE; + } + /* server closed socket or is downed*/ + if ( read_len == 0 ) { + EM_DEBUG_EXCEPTION("[IPC Socket] server closed connection"); + return 0; } *buf = (char *) malloc(read_len); if (*buf == NULL) { EM_DEBUG_EXCEPTION("Malloc failed"); - return EMF_ERROR_OUT_OF_MEMORY; + return EMAIL_ERROR_OUT_OF_MEMORY; } memset(*buf, 0x00, read_len); - EM_DEBUG_LOG("[IPC Socket] Receiving Body begins for [%d] bytes", read_len); + EM_DEBUG_LOG("[IPC Socket] Receiving [%d] bytes", read_len); int len = emipc_readn(fd, *buf, read_len); if (read_len != len) { EM_SAFE_FREE(*buf); EM_DEBUG_LOG("WARNING: buf_size [%d] != read_len[%d]", read_len, len); - return EMF_ERROR_IPC_SOCKET_FAILURE; + return EMAIL_ERROR_IPC_SOCKET_FAILURE; } EM_DEBUG_LOG("[IPC Socket] Receiving [%d] bytes Completed", len); @@ -169,7 +181,7 @@ EXPORT_API int emipc_accept_email_socket(int fd) if (fd == -1) { EM_DEBUG_LOG("Server_socket not init"); - return EMF_ERROR_INVALID_PARAM; + return EMAIL_ERROR_INVALID_PARAM; } struct sockaddr_un remote; @@ -177,7 +189,7 @@ EXPORT_API int emipc_accept_email_socket(int fd) int client_fd = accept(fd, (struct sockaddr *)&remote, (socklen_t*) &remote_len); if (client_fd == -1) { EM_DEBUG_LOG("accept: %s", EM_STRERROR(errno)); - return EMF_ERROR_IPC_SOCKET_FAILURE; + return EMAIL_ERROR_IPC_SOCKET_FAILURE; } EM_DEBUG_LOG("%d is added", client_fd); @@ -192,12 +204,12 @@ EXPORT_API int emipc_open_email_socket(int fd, const char *path) if (!path || strlen(path) > 108) { EM_DEBUG_LOG("Path is null"); - return EMF_ERROR_IPC_SOCKET_FAILURE; + return EMAIL_ERROR_IPC_SOCKET_FAILURE; } if (fd <= 0) { EM_DEBUG_LOG("Socket not created %d", fd); - return EMF_ERROR_IPC_SOCKET_FAILURE; + return EMAIL_ERROR_IPC_SOCKET_FAILURE; } struct sockaddr_un local; @@ -209,7 +221,7 @@ EXPORT_API int emipc_open_email_socket(int fd, const char *path) if (bind(fd, (struct sockaddr *)&local, len) == -1) { EM_DEBUG_LOG("bind: %s", EM_STRERROR(errno)); - return EMF_ERROR_IPC_SOCKET_FAILURE; + return EMAIL_ERROR_IPC_SOCKET_FAILURE; } /** @@ -227,12 +239,12 @@ EXPORT_API int emipc_open_email_socket(int fd, const char *path) if (chmod(path, sock_mode) == -1) { EM_DEBUG_LOG("chmod: %s", EM_STRERROR(errno)); - return EMF_ERROR_IPC_SOCKET_FAILURE; + return EMAIL_ERROR_IPC_SOCKET_FAILURE; } if (listen(fd, 10) == -1) { EM_DEBUG_LOG("listen: %s", EM_STRERROR(errno)); - return EMF_ERROR_IPC_SOCKET_FAILURE; + return EMAIL_ERROR_IPC_SOCKET_FAILURE; } EM_DEBUG_FUNC_END(); diff --git a/email-ipc/email-socket/include/email-ipc-socket.h b/email-ipc/email-socket/include/email-ipc-socket.h index 9534af7..f3aef31 100755 --- a/email-ipc/email-socket/include/email-ipc-socket.h +++ b/email-ipc/email-socket/include/email-ipc-socket.h @@ -36,7 +36,7 @@ EXPORT_API bool emipc_init_email_socket(int *fd); -EXPORT_API bool emipc_close_email_socket(int fd); +EXPORT_API void emipc_close_email_socket(int *fd); EXPORT_API int emipc_send_email_socket(int fd, unsigned char *buf, int len); diff --git a/email-ipc/email-stub/email-stub-main.c b/email-ipc/email-stub/email-stub-main.c index 703ce54..79e29e4 100755 --- a/email-ipc/email-stub/email-stub-main.c +++ b/email-ipc/email-stub/email-stub-main.c @@ -23,7 +23,6 @@ #include "email-stub-main.h" #include "email-ipc.h" -#include "email-stub-response-info.h" #include "email-ipc-param-list.h" #include "email-ipc-build.h" #include "email-stub-socket.h" @@ -32,7 +31,6 @@ #include "email-debug-log.h" static bool stub_socket = false; -static GList *response_list = NULL; static PFN_EXECUTE_API this_fn_api_mapper = NULL; EXPORT_API bool emipc_initialize_stub_main(PFN_EXECUTE_API fn_api_mapper) @@ -61,9 +59,6 @@ EXPORT_API bool emipc_finalize_stub_main() { EM_DEBUG_FUNC_BEGIN(); - if (response_list) - response_list = NULL; - if (stub_socket) { emipc_end_stub_socket(); stub_socket = false; @@ -96,14 +91,16 @@ EXPORT_API bool emipc_execute_api_stub_to_proxy(emipc_email_api_info *api_info) { EM_DEBUG_FUNC_BEGIN("api_info [%p]", api_info); EM_IF_NULL_RETURN_VALUE(api_info, false); - EM_DEBUG_LOG("APIID [%s], response Socket ID [%d], APPID [%d]", EM_APIID_TO_STR(emipc_get_api_id_of_api_info(api_info)), emipc_get_response_id_of_api_info(api_info), emipc_get_app_id_of_api_info(api_info)); + EM_DEBUG_LOG("APIID [%s], response Socket ID [%d], APPID [%d]", + EM_APIID_TO_STR(api_info->api_id), api_info->response_id, api_info->app_id); - unsigned char *stream = emipc_get_stream_of_api_info(api_info, ePARAMETER_OUT); - int stream_length = emipc_get_stream_length_of_api_info(api_info, ePARAMETER_OUT); + unsigned char *stream = NULL; + int stream_length = 0; - EM_DEBUG_LOG("Data : %p, Data length : %dB", stream, stream_length); + stream = emipc_serialize_api_info(api_info, ePARAMETER_OUT, &stream_length); EM_DEBUG_LOG("Stub => Proxy Sending %dB", stream_length); - emipc_send_stub_socket(emipc_get_response_id_of_api_info(api_info), stream, stream_length); + + emipc_send_stub_socket(api_info->response_id, stream, stream_length); #ifdef IPCLIB_STREAM_TRACE_ON int index = 0; @@ -114,27 +111,3 @@ EXPORT_API bool emipc_execute_api_stub_to_proxy(emipc_email_api_info *api_info) EM_DEBUG_FUNC_END(); return true; } - -EXPORT_API bool emipc_set_response_info(long app_id, long api_id) -{ - EM_DEBUG_FUNC_BEGIN("Response ID [%d]", app_id); - - if (app_id <= 0) - return true; - - emipc_email_response_info *response_info = NULL; - response_info = (emipc_email_response_info *)malloc(sizeof(response_info)); - if (response_info == NULL) { - EM_DEBUG_EXCEPTION("Malloc failed"); - return false; - } - memset(response_info, 0x00, sizeof(response_info)); - - if (response_info) { - emipc_set_value_in_response_info(response_info, app_id, api_id); - response_list = g_list_append(response_list, response_info); - return true; - } - EM_DEBUG_FUNC_END(); - return false; -} diff --git a/email-ipc/email-stub/email-stub-queue.c b/email-ipc/email-stub/email-stub-queue.c deleted file mode 100755 index ce6dcc9..0000000 --- a/email-ipc/email-stub/email-stub-queue.c +++ /dev/null @@ -1,89 +0,0 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - -#include -#include - -#include "email-stub-queue.h" -#include "email-ipc-build.h" - -#include "email-debug-log.h" - -static emipc_email_queue_item *head = NULL; -static emipc_email_queue_item *tail = NULL; -int count = 0; - -EXPORT_API void *emipc_pop_in_queue() -{ - void *data = NULL; - - if (head) { - emipc_email_queue_item *popped = head; - data = popped->data; - - if (popped->next) { - head = popped->next; - } else { - head = tail = NULL; - } - - EM_SAFE_FREE(popped); - count = (count <= 0) ? 0 : count-1; - - return data; - } - return NULL; -} - -EXPORT_API bool emipc_push_in_queue(void *data) -{ - emipc_email_queue_item *item = NULL; - if (!data) { - EM_DEBUG_EXCEPTION("[IPCLib] emipc_push_in_queue - invalid input\n"); - return false; - } - - item = (emipc_email_queue_item *)malloc(sizeof(emipc_email_queue_item)); - if (item == NULL) { - EM_DEBUG_EXCEPTION("Malloc failed."); - return false; - } - memset(item, 0x00, sizeof(emipc_email_queue_item)); - - item->data = data; - item->next = NULL; - if (tail) { - tail->next = item; - tail = item; - } else { - head = tail = item; - } - - count++; - - return true; -} - -EXPORT_API int emipc_get_count_of_item() -{ - return count; -} diff --git a/email-ipc/email-stub/email-stub-response-info.c b/email-ipc/email-stub/email-stub-response-info.c deleted file mode 100755 index 01d67e8..0000000 --- a/email-ipc/email-stub/email-stub-response-info.c +++ /dev/null @@ -1,39 +0,0 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - -#include "email-stub-response-info.h" - -EXPORT_API bool emipc_set_value_in_response_info(emipc_email_response_info *response_info, long response_id, long api_id) -{ - response_info->response_id = response_id; - response_info->api_id = api_id; - return true; -} - -EXPORT_API long emipc_get_response_id_in_response_info(emipc_email_response_info *response_info) -{ - return response_info->response_id; -} - -EXPORT_API long emipc_get_api_id_in_response_info(emipc_email_response_info *response_info) -{ - return response_info->api_id; -} diff --git a/email-ipc/email-stub/email-stub-socket.c b/email-ipc/email-stub/email-stub-socket.c index d018634..58f4b55 100755 --- a/email-ipc/email-stub/email-stub-socket.c +++ b/email-ipc/email-stub/email-stub-socket.c @@ -164,8 +164,8 @@ EXPORT_API void emipc_wait_for_ipc_request() EM_DEBUG_LOG("[IPCLib]Stub Socket Recv [Socket ID = %d], [recv_len = %d]", event_fd, recv_len); EM_DEBUG_LOG("===================================================================="); emipc_create_task((unsigned char *)sz_buf, event_fd); - } else { - EM_DEBUG_LOG("[IPCLib] Socket [%d] removed - [%d] ", event_fd, recv_len); + } else if( recv_len == 0 ) { + EM_DEBUG_LOG("[IPCLib] Client closed connection [%d]", event_fd); epoll_ctl(epfd, EPOLL_CTL_DEL, event_fd, events); close(event_fd); } @@ -181,7 +181,7 @@ EXPORT_API bool emipc_end_stub_socket() EM_DEBUG_FUNC_BEGIN(); if (stub_socket) { - emipc_close_email_socket(stub_socket); + emipc_close_email_socket(&stub_socket); } if (stub_socket_thread) { diff --git a/email-ipc/email-stub/email-stub-task-manager.c b/email-ipc/email-stub/email-stub-task-manager.c index 04a2f43..e1563e1 100755 --- a/email-ipc/email-stub/email-stub-task-manager.c +++ b/email-ipc/email-stub/email-stub-task-manager.c @@ -76,7 +76,6 @@ EXPORT_API bool emipc_stop_task_thread() return true; } - EXPORT_API void *emipc_do_task_thread() { EM_DEBUG_FUNC_BEGIN(); @@ -95,7 +94,7 @@ EXPORT_API void *emipc_do_task_thread() if (task) { emipc_run_task(task); - EM_SAFE_FREE(task); + emipc_free_email_task(task); } } @@ -117,9 +116,9 @@ EXPORT_API bool emipc_create_task(unsigned char *task_stream, int response_chann EM_DEBUG_LOG("[IPCLib] ======================================================"); EM_DEBUG_LOG("[IPCLib] Register new task : %p", task); - EM_DEBUG_LOG("[IPCLib] Task API ID : %s", EM_APIID_TO_STR(emipc_get_api_info(task)->api_id)); - EM_DEBUG_LOG("[IPCLib] Task Response ID : %d", EM_APIID_TO_STR(emipc_get_api_info(task)->response_id)); - EM_DEBUG_LOG("[IPCLib] Task APP ID : %d", emipc_get_api_info(task)->app_id); + EM_DEBUG_LOG("[IPCLib] Task API ID : %s (%d)", EM_APIID_TO_STR(task->api_info->api_id), task->api_info->api_id); + EM_DEBUG_LOG("[IPCLib] Task Response ID : %d", EM_APIID_TO_STR(task->api_info->response_id)); + EM_DEBUG_LOG("[IPCLib] Task APP ID : %d", task->api_info->app_id); EM_DEBUG_LOG("[IPCLib] ======================================================"); ENTER_CRITICAL_SECTION(ipc_task_mutex); @@ -130,4 +129,3 @@ EXPORT_API bool emipc_create_task(unsigned char *task_stream, int response_chann } return ret; } - diff --git a/email-ipc/email-stub/email-stub-task.c b/email-ipc/email-stub/email-stub-task.c index f7dbbd7..be90db5 100755 --- a/email-ipc/email-stub/email-stub-task.c +++ b/email-ipc/email-stub/email-stub-task.c @@ -33,6 +33,19 @@ #include "email-api.h" #include "email-debug-log.h" +EXPORT_API void emipc_free_email_task(emipc_email_task *task) +{ + EM_DEBUG_FUNC_BEGIN("task [%p]", task); + + if (!task) { + EM_DEBUG_EXCEPTION("Invalid parameter."); + return; + } + + emipc_free_api_info(task->api_info); + EM_SAFE_FREE(task); +} + EXPORT_API bool emipc_parse_stream_email_task(emipc_email_task *task, void *stream, int response_id) { EM_DEBUG_FUNC_BEGIN(); @@ -45,8 +58,8 @@ EXPORT_API bool emipc_parse_stream_email_task(emipc_email_task *task, void *stre memset(task->api_info, 0x00, sizeof(emipc_email_api_info)); if (task->api_info) { - emipc_parse_stream_of_api_info(task->api_info, ePARAMETER_IN, stream); - emipc_set_response_id_of_api_info(task->api_info, response_id); + emipc_deserialize_api_info(task->api_info, ePARAMETER_IN, stream); + task->api_info->response_id = response_id; return true; } return false; @@ -66,16 +79,16 @@ EXPORT_API bool emipc_run_task(emipc_email_task *task) { EM_DEBUG_LOG("[IPCLib] starting a new task..."); - int app_id = emipc_get_app_id_of_api_info(task->api_info); - int api_id = emipc_get_api_id_of_api_info(task->api_info); + int api_id = task->api_info->api_id; + int app_id = task->api_info->app_id; + + EM_DEBUG_LOG("[IPCLib] This task (%s) is for async. App id [%d], Response ID [%d]", EM_APIID_TO_STR(api_id), app_id, api_id); - if (app_id > 0) { - EM_DEBUG_LOG("[IPCLib] This task (%s) is for async. Response ID [%d]", EM_APIID_TO_STR(api_id), api_id); - if (!emipc_set_response_info(app_id, api_id)) { - EM_DEBUG_EXCEPTION("emipc_set_response_info failed"); - return false; - } + if (!emipc_execute_api_proxy_to_stub(task->api_info)) { + EM_DEBUG_EXCEPTION("emipc_execute_api_proxy_to_stub failed"); + return false; } - return emipc_execute_api_proxy_to_stub(task->api_info); + + return true; } diff --git a/email-ipc/email-stub/include/email-stub-queue.h b/email-ipc/email-stub/include/email-stub-queue.h deleted file mode 100755 index bda8777..0000000 --- a/email-ipc/email-stub/include/email-stub-queue.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - - -#ifndef _IPC_QUEUE_H_ -#define _IPC_QUEUE_H_ - -#include "email-types.h" - -typedef struct emipc_email_queue_item { - void *data; - struct emipc_email_queue_item *next; -} emipc_email_queue_item; - - -EXPORT_API void *emipc_pop_in_queue(); - -EXPORT_API bool emipc_push_in_queue(void *data); - -EXPORT_API int emipc_get_count_of_item(); -#endif /* _IPC_QUEUE_H_ */ diff --git a/email-ipc/email-stub/include/email-stub-response-info.h b/email-ipc/email-stub/include/email-stub-response-info.h deleted file mode 100755 index c3194b7..0000000 --- a/email-ipc/email-stub/include/email-stub-response-info.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* email-service -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Kyuho Jo , Sunghyun Kwon -* -* 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. -* -*/ - - - -#ifndef _IPC_RESPONSE_INFO_H_ -#define _IPC_RESPONSE_INFO_H_ - -#include "email-types.h" - -typedef struct { - long response_id; - long api_id; -} emipc_email_response_info; - -EXPORT_API bool emipc_set_value_in_response_info(emipc_email_response_info *response_info, long response_id, long api_id); - -EXPORT_API long emipc_get_response_id_in_response_info(emipc_email_response_info *response_info); - -EXPORT_API long emipc_get_api_id_in_response_info(emipc_email_response_info *response_info); - -#endif /* _IPC_RESPONSE_INFO_H_ */ - - diff --git a/email-ipc/email-stub/include/email-stub-task.h b/email-ipc/email-stub/include/email-stub-task.h index 54fc8f6..c87262b 100755 --- a/email-ipc/email-stub/include/email-stub-task.h +++ b/email-ipc/email-stub/include/email-stub-task.h @@ -31,6 +31,8 @@ typedef struct { emipc_email_api_info *api_info; } emipc_email_task; +EXPORT_API void emipc_free_email_task(emipc_email_task *task); + EXPORT_API bool emipc_parse_stream_email_task(emipc_email_task *task, void *stream, int response_id); EXPORT_API emipc_email_api_info *emipc_get_api_info(emipc_email_task *task); diff --git a/email-ipc/include/email-ipc.h b/email-ipc/include/email-ipc.h index ff7206c..99924cc 100755 --- a/email-ipc/include/email-ipc.h +++ b/email-ipc/include/email-ipc.h @@ -57,7 +57,7 @@ EXPORT_API int emipc_initialize_proxy(); EXPORT_API int emipc_finalize_proxy(); -EXPORT_API bool emipc_execute_proxy_api(HIPC_API input_api_handle); +EXPORT_API int emipc_execute_proxy_api(HIPC_API input_api_handle); /* ------------------------------------------------------------------------------------------------------------ */ /* Stub AP */ @@ -77,11 +77,12 @@ EXPORT_API void emipc_destroy_email_api(HIPC_API input_api_handle); EXPORT_API long emipc_get_api_id(HIPC_API input_api_handle); EXPORT_API long emipc_get_app_id(HIPC_API input_api_handle); -EXPORT_API bool emipc_add_parameter(HIPC_API input_api_handle, EPARAMETER_DIRECTION input_parameter_direction, void *input_parameter_data, int input_data_length); -EXPORT_API int emipc_get_parameter_count(HIPC_API input_api_handle, EPARAMETER_DIRECTION input_parameter_direction); +EXPORT_API bool emipc_add_parameter(HIPC_API api, EPARAMETER_DIRECTION direction, void *data, int data_length); +EXPORT_API bool emipc_add_dynamic_parameter(HIPC_API api, EPARAMETER_DIRECTION direction, void *data, int data_length); EXPORT_API int emipc_get_parameter(HIPC_API input_api_handle, EPARAMETER_DIRECTION input_parameter_direction, int input_parameter_index, int input_parameter_buffer_size, void *output_parameter); +EXPORT_API void* emipc_get_nth_parameter_data(HIPC_API api_handle, EPARAMETER_DIRECTION direction, int param_index); EXPORT_API int emipc_get_parameter_length(HIPC_API input_api_handle, EPARAMETER_DIRECTION input_parameter_direction, int input_parameter_index); - +EXPORT_API int emipc_get_nth_parameter_length(HIPC_API input_api_handle, EPARAMETER_DIRECTION input_parameter_direction, int input_parameter_index); #ifdef __cplusplus } diff --git a/email-service_PG.h b/email-service_PG.h index bce43f7..8b90f91 100755 --- a/email-service_PG.h +++ b/email-service_PG.h @@ -1,1185 +1,1181 @@ -/** - * - * @ingroup PG - * @defgroup EMAILSVC Email Service -@{ -

Introduction

-

Overview

-Electronic mail, most commonly abbreviated email or e-mail, is a method of exchanging digital messages. E-mail systems are based on a store-and-forward model in which e-mail server computer systems accept, forward, deliver and store messages on behalf of users, who only need to connect to the e-mail infrastructure, typically an e-mail server, with a network-enabled device for the duration of message submission or retrieval. - -

Purpose of Programming Guide

-This document is mainly aimed at the core functionality of the Email Service. The EMail Service component is implemented by Samsung to provide EMail service to applications that make use of EMail Engine. Email Engine provides functionality for the user like composing mail, saving mail, sending mail, and creating user mailbox according to the settings. Mobile subscribers can use the Email Engine to perform storage opearations such as save, update, get, delete and transport operations such as send, download and other email operations. - -This programming guide is prepared for application developers who will use the email-service. It contains: -- List of features offered by email-service -- Information on How to use APIs provided by the email-service -- Examples - -

Target Domain / Application

-The Email Service Layer can be utilized by any component in the application layer which allow the end user to perform the email related operations such as save, send, download email message and others. - -For Example, the Email Service APIs shall be invoked by -@li Multimedia application when user opts to send media file through email -@li Email application when user tries to send an email message - -

Terminology & Acronyms

- - - - - - - - -
TerminologyDescription
Email Electronic mail
IMAPInternet Message Access Protocol
SMTPSimple mail transfer protocol for sending mails
POP3Post office protocol for receiving mails
RFC822Describes mail header, to address, cc, bcc etc. formats and decoding and encoding standards.
OMA Open Moblie Alliance
- - -@} - -@defgroup Email_Architecture 1. Email Service Architecture -@ingroup EMAILSVC -@{ -

Email-service Architecture

-

System Architecture

-@image html email_image001.png - -

Process Architecture

-@image html email_image002.png email-service Process view - -@image html email_image003.png email-service Process architecture - -Whenever an application wants to use email-service, it will call APIs from Email MAPI layer. Email MAPI layer APIs will internally call APIs provided by email framework module. -@} - -@defgroup Email_Feature 2. Email Service Feature -@ingroup EMAILSVC -@{ -

Email-service Features

- - - - - - - - - - - - - - - - - - - -
Feature API Reference
Account Operation -@n email_add_account() -@n email_delete_account() -@n email_update_account() -@n email_get_account() -@n email_get_account_list() -@n email_free_account() -@n email_validate_account() -
mailbox Operation -@n email_add_mailbox() -@n email_delete_mailbox() -@n email_update_mailbox() -@n email_get_mailbox_list() -@n email_get_mailbox_by_name() -@n email_get_child_mailbox_list() -@n email_get_mailbox_by_mailbox_type() -
Message Operation -@n email_add_message() -@n email_update_message() -@n email_count_message() -@n email_delete_message() -@n email_delete_all_message_in_mailbox() -@n email_clear_mail_data() -@n email_add_attachment() -@n email_delete_attachment() -@n email_get_info() -@n email_free_mail_info() -@n email_get_header_info() -@n email_free_header_info() -@n email_get_body_info() -@n email_free_body_info() -@n email_get_attachment_info() -@n email_free_attachment_info() -@n email_get_mail() -@n email_modify_mail_flag() -@n email_modify_seen_flag() -@n email_modify_extra_mail_flag() -@n email_move_mail_to_mailbox() -@n email_move_all_mails_to_mailbox() -@n email_count_message_with_draft_flag() -@n email_count_message_on_sending() -@n email_get_mailbox_list() -@n email_free_mailbox() -@n email_free_mail() -@n email_get_mail_flag() -@n email_free_mail_list() -@n email_release_mail() -@n email_retry_send_mail() -@n email_create_db_full() -@n email_get_mailbox_name_by_mail_id() -@n email_cancel_send_mail() -@n email_count_message_all_mailboxes() -@n email_get_latest_unread_mail_id() -@n email_get_max_mail_count() -@n email_get_disk_space_usage() -
Network Operation -@n email_send_mail() -@n email_sync_header() -@n email_download_body() -@n email_download_attachment() -@n email_cancel_job() -@n email_get_pending_job() -@n email_get_network_status() -@n email_send_report() -@n email_send_saved() -@n email_get_imap_mailbox_list() -@n email_sync_local_activity() -
Rule Operation -@n email_get_rule() -@n email_get_rule_list() -@n email_add_rule() -@n email_update_rule() -@n email_delete_rule() -@n email_free_rule() -
Control Operation -@n email_init_storage() -@n email_open_db() -@n email_close_db() -@n email_service_begin() -@n email_service_end() -
-@} - - - -@defgroup Use_Case1_account Account Operation -@ingroup EMAIL_USECASES -@{ -

Account Operation

-Account Operations are a set of operations to manage email accounts like add, update, delete or get account related details. - -Structure: -emf_account_t - - - - - - - - - - - - - - - - - - - - - - - - -
APIReturn Value / Exceptions
int email_add_account(emf_account_t* account)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param emf_account_t* account should be allocated and deallocated by Application
int email_delete_account(int account_id) Returns EMF_ERROR_NONE on success or negative value on failure
int email_update_account(int account_id , emf_account_t* new_account) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param emf_account_t* new_account should be allocated and deallocated by Application
int email_get_account(int account_id, int pulloption, emf_account_t** account) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param account will happen in email_get_account (). To free this memory, application should call email_free_account ()
int email_get_account_list(emf_account_t** account_list, int* count) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: Memory allocation for param ccount_list will happen in email_get_account_list (). To free this memory, application should call email_free_account ()
int email_free_account(emf_account_t** account_list, int count) Returns EMF_ERROR_NONE on success or negative value on failure
int email_validate_account(int account_id, unsigned* handle)Returns EMF_ERROR_NONE on success or negative value on failure
- -Sample Code -@li Add account -@code -/* Add account */ - -/* Assign values for new account */ -emf_account_t *account = NULL; - -account = malloc(sizeof(emf_account_t)); -memset(account, 0x00, sizeof(emf_account_t)); - -account->account_bind_type = 1; -account->retrieval_mode = 1; -account->use_security = 1; -account->sending_server_type = EMF_SERVER_TYPE_SMTP; -account->sending_port_num = EMF_SMTP_PORT; -account->sending_auth = 1; -account->flag1 = 2; -account->account_bind_type = 1; -account->account_name = strdup("gmail"); -account->display_name = strdup("Tom"); -account->email_addr = strdup("tom@gmail.com"); -account->reply_to_addr = strdup("tom@gmail.com"); -account->return_addr = strdup("tom@gmail.com"); -account->receiving_server_type = EMF_SERVER_TYPE_POP3; -account->receiving_server_addr = strdup("pop3.gmail.com"); -account->port_num = 995; -account->use_security = 1; -account->retrieval_mode = EMF_IMAP4_RETRIEVAL_MODE_ALL; -account->user_name = strdup("tom"); -account->password = strdup("tioimi"); -account->sending_server_type = EMF_SERVER_TYPE_SMTP; -account->sending_server_addr = strdup("smtp.gmail.com"); -account->sending_port_num = 587; -account->sending_security = 0x02; -account->sending_auth = 1; -account->sending_user = strdup("tom@gmail.com"); -account->sending_password = strdup("tioimi"); -account->pop_before_smtp = 0; -account->apop = 0; -account->flag1 = 2; -account->flag2 = 1; -account->preset_account = 1; -account->logo_icon_path = strdup("Logo Icon Path"); -account->target_storage = 0; -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 = strdup("Display name from"); -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("Signature"); -account->check_interval = 0; - -if(EMF_ERROR_NONE != email_add_account(account)) - /* failure */ -else -{ - /* success */ - if(account_id) - *account_id = account->account_id; /* Use this returned account id when calling APIs which need it */ -} - -/* free account */ -email_free_account(&account, 1); - -@endcode - -@li Get account -@code -/* Get account */ - -emf_account_t *account = NULL; -int account_id = 1; /* account id to be gotten */ - -if(EMF_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&account)) - /* failure */ -else - /* success */ - -/* free account */ -email_free_account(&account, 1); - -@endcode - -@li Update account -@code -/* Update account */ - -emf_account_t *new_account = NULL; -int account_id = 1; /* account id to be updated */ - -/* Get account to be updated */ -if(EMF_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&new_account)) - /* failure */ -else - /* success */ - -/* Set the new values */ -new_account->flag1 = 1; -new_account->account_name = strdup("gmail"); -new_account->display_name = strdup("Tom001"); -new_account->options.keep_local_copy = 1; -new_account->check_interval = 55; - -if(EMF_ERROR_NONE != email_update_account(account_id,new_account)) - /* failure */ -else - /* success */ - -/* free account */ -email_free_account(&new_account, 1); - -@endcode - -@li Delete account -@code -/* Delete account */ - -int account_id = 1; /* account id to be deleted */ - -if(EMF_ERROR_NONE != email_delete_account(account_id)) - /* failure */ -else - /* success */ - -@endcode - - -@li Get list of accounts -@code -/* Get list of accounts */ - -emf_account_t *account_list = NULL; -int count = 0; -int i; - -if(EMF_ERROR_NONE != email_get_account_list(&account_list,&count)) - /* failure */ -else -{ - /* success */ - for ( i = 0; i < count; i++ ) - { - /* Do something with each account */ - printf("account id : %d\n", account_list[i].account_id); - } -} - -/* free account */ -email_free_account(&account_list,count); - -@endcode - -@li Validate account - try to connect to server -@code -/* Validate account - try to connect to server */ -unsigned account_handle = 0; -int account_id = 1; - -if(EMF_ERROR_NONE != email_validate_account(account_id,&account_handle)) - /* failure */ -else - /* success */ -@endcode - -Flow Diagram -@image html email_image004.png -@} - -@defgroup Use_Case2_folder mailbox Operation -@ingroup EMAIL_USECASES -@{ -

mailbox Operation

-mailbox Operations are a set of operations to manage email mailboxes like add, update, delete or get mailbox related details. - -Structure: -emf_mailbox_t - - - - - - - - - - - - - - - - - - - - - - - - -
APIReturn Value / Exceptions
int email_add_mailbox(emf_mailbox_t* new_mailbox, int on_server, unsigned* handle) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param emf_mailbox_t* new_mailbox should be allocated and deallocated by Application
int email_delete_mailbox(emf_mailbox_t* mailbox, int on_server, unsigned* handle) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param emf_mailbox_t* mailbox should be allocated and deallocated by Application
int email_update_mailbox(emf_mailbox_t*old_mailbox, emf_mailbox_t* new_mailbox)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params emf_mailbox_t* old_mailbox and emf_mailbox_t* new_mailbox should be allocated and deallocated by Application
int email_get_mailbox_list(int account_id, int local_yn, emf_mailbox_t** mailbox_list, int* count)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_mailbox_list (). To free this memory application should call email_free_mailbox
int email_get_mailbox_by_name(int account_id, const char *pMailboxName, emf_mailbox_t **pMailbox)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param pMailbox will happen in email_get_mailbox_by_name (). To free this memory application should call email_free_mailbox
int email_get_child_mailbox_list(int account_id, const char *parent_mailbox, emf_mailbox_t** mailbox_list, int* count)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_child_mailbox_list (). To free this memory application should call email_free_mailbox
int email_get_mailbox_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, emf_mailbox_t** mailbox)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_mailbox_by_mailbox_type (). To free this memory application should call email_free_mailbox
- -Sample Code - -@li Create new mailbox -@code -emf_mailbox_t *mailbox = NULL, *new_mailbox = NULL; -unsigned handle = 0; -int on_server = 0; - -mailbox = malloc(sizeof(emf_mailbox_t)); -memset(mailbox, 0x00, sizeof(emf_mailbox_t)); - -mailbox->name = strdup("Personal"); -mailbox->alias = strdup("selfuse"); -mailbox->account_id = 1; -mailbox->local = on_server; -mailbox->mailbox_type = 7; - -/* create new mailbox */ -if(EMF_ERROR_NONE != email_add_mailbox(mailbox,on_server,&handle)) - /* failure */ -else - /* success */ - -@endcode - - -@li Update and Delete mailbox -@code -emf_mailbox_t *mailbox = NULL, *new_mailbox = NULL; -int on_server = 0; -unsigned handle = 0; - -new_mailbox = malloc(sizeof(emf_mailbox_t)); -memset(new_mailbox, 0x00, sizeof(emf_mailbox_t)); - -new_mailbox->name = strdup("Personal001"); - -/* update mailbox */ -if(EMF_ERROR_NONE != email_update_mailbox(mailbox,new_mailbox)) - /* failure */ -else - /* success */ - -/* delete mailbox */ -if(EMF_ERROR_NONE != email_delete_mailbox(mailbox,on_server,&handle)) - /* failure */ -else - /* success */ - -email_free_mailbox(&mailbox, 1); -email_free_mailbox(&new_mailbox, 1); - -@endcode - -@li Get list of mailboxes -@code -int account_id = 1; -int local_yn = 0; -emf_mailbox_t* mailbox_list = NULL; -int count = 0; - -/*get list of mailboxes */ -if(EMF_ERROR_NONE != email_get_mailbox_list(account_id, local_yn, &mailbox_list, &count)) - /* failure */ -else -{ - /* success */ - email_free_mailbox(&mailbox_list,count); -} -@endcode - -Flow Diagram -@image html email_image005.png -@} - -@defgroup Use_Case3_message Message Operation -@ingroup EMAIL_USECASES -@{ -

Message Operation

-Message Operations are a set of operations to manage email messages like add, update, delete or get message related details. - -Structure: -emf_mail_t - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
APIReturn Value / Exceptions
int email_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params emf_mail_data_t* input_mail_data and emf_attachment_data_t *input_attachment_data_list and emf_meeting_request_t* input_meeting_request should be allocated and deallocated by Application
int email_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params emf_mail_data_t* input_mail_data and emf_attachment_data_t *input_attachment_data_list and emf_meeting_request_t* input_meeting_request should be allocated and deallocated by Application
int email_count_message(emf_mailbox_t* mailbox, int* total, int* unseen) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param emf_mailbox_t* mailbox should be allocated and deallocated by Application
int email_delete_message(emf_mailbox_t* mailbox, int *mail_ids, int num, int from_server) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params int *mail_ids and mf_mailbox_t* mailbox should be allocated and deallocated by Application
int email_delete_all_message_in_mailbox(emf_mailbox_t* mailbox, int from_server) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param mf_mailbox_t* mailbox should be allocated and deallocated by Application
int email_clear_mail_data() Returns EMF_ERROR_NONE on success or negative value on failure
int email_add_attachment(emf_mailbox_t* mailbox, int mail_id, emf_attachment_info_t* attachment)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param mf_mailbox_t* mailbox and mf_attachment_info_t* attachment hould be allocated and deallocated by Application
int email_delete_attachment(emf_mailbox_t * mailbox, int mail_id, const char * attachment_id)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param emf_mailbox_t* mailbox should be allocated and deallocated by Application
int email_get_attachment_info(emf_mailbox_t* mailbox, int mail_id, const char* attachment_id, emf_attachment_info_t** attachment)Returns EMF_ERROR_NONE on success or negative value on failure.@n Remarks: --# Memory for param emf_mailbox_t* mailbox should be allocated and deallocated by Application --# Memory allocation for param emf_attachment_info_t** attachment will happen in email_get_attachment_info (). To free this memory, application should call email_free_attachment_info ()
int email_free_attachment_info(emf_attachment_info_t** atch_info) Returns EMF_ERROR_NONE on success or negative value on failure.
int email_modify_mail_flag(int mail_id, emf_mail_flag_t new_flag, int onserver) Returns EMF_ERROR_NONE on success or negative value on failure.
int email_modify_seen_flag(int *mail_ids, int num, int seen_flag, int onserver) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param int *mail_ids should be allocated and deallocated by Application
int email_modify_extra_mail_flag(int mail_id, emf_extra_flag_t new_flag) Returns EMF_ERROR_NONE on success or negative value on failure
int email_move_mail_to_mailbox(int *mail_ids, int num, emf_mailbox_t* new_mailbox) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params int *mail_ids and emf_mailbox_t* new_mailbox should be allocated and deallocated by Application
int email_move_all_mails_to_mailbox(emf_mailbox_t* src_mailbox, emf_mailbox_t* new_mailbox) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params emf_mailbox_t* src_mailbox and emf_mailbox_t* new_mailbox should be allocated and deallocated by Application
int email_count_message_with_draft_flag(emf_mailbox_t* mailbox, int* total) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param emf_mailbox_t* mailbox should be allocated and deallocated by Application
int email_count_message_on_sending(emf_mailbox_t* mailbox, int* total) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param emf_mailbox_t* mailbox should be allocated and deallocated by Application
int email_get_mailbox_list(int account_id, emf_mailbox_t** mailbox_list, int* count ) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param emf_mailbox_t** mailbox_list will happen in email_get_mailbox_list (). To free this memory, application should call email_free_mailbox ()
int email_free_mailbox(emf_mailbox_t** mailbox_list, int count) Returns EMF_ERROR_NONE on success or negative value on failure
int email_get_mail_flag(int account_id, int mail_id, emf_mail_flag_t* mail_flag) Returns EMF_ERROR_NONE on success or negative value on failure
int email_retry_send_mail( int mail_id, int timeout_in_sec) Returns EMF_ERROR_NONE on success or negative value on failure
int email_create_db_full()Returns EMF_ERROR_NONE on success or negative value on failure
int email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name)Returns EMF_ERROR_NONE on success or negative value on failure
int email_cancel_send_mail( int mail_id) Returns EMF_ERROR_NONE on success or negative value on failure
int email_count_message_all_mailboxes(emf_mailbox_t* mailbox, int* total, int* unseen) Returns EMF_ERROR_NONE on success or negative value on failure
int email_get_latest_unread_mail_id(int account_id, int *pMailID) Returns EMF_ERROR_NONE on success or negative value on failure
int email_get_max_mail_count(int *Count) Returns EMF_ERROR_NONE on success or negative value on failure
int email_get_disk_space_usage(unsigned long *total_size)Returns EMF_ERROR_NONE on success or negative value on failure
- -Sample Code - -@li Add, Update, Count and Delete message -@code -emf_mailbox_t *mailbox = NULL; -int on_server = 0, account_id = 0, mail_id = 0; -char *pFilePath = "/tmp/mail.txt"; -int i = 0; -int account_id = 0; -int from_eas = 0; -int attachment_count = 0; -int err = EMF_ERROR_NONE; -char arg[50] = { 0 , }; -char *body_file_path = "/opt/data/email/.emfdata/tmp/mail.txt"; -emf_mailbox_t *mailbox_data = NULL; -emf_mail_data_t *test_mail_data = NULL; -emf_attachment_data_t *attachment_data = NULL; -emf_meeting_request_t *meeting_req = NULL; -FILE *body_file; - -printf("\n > Enter account id : "); -scanf("%d", &account_id); - -memset(arg, 0x00, 50); -printf("\n > Enter mailbox name : "); -scanf("%s", arg); - -email_get_mailbox_by_name(account_id, arg, &mailbox_data); - -test_mail_data = malloc(sizeof(emf_mail_data_t)); -memset(test_mail_data, 0x00, sizeof(emf_mail_data_t)); - -printf("\n From EAS? [0/1]> "); -scanf("%d", &from_eas); - -test_mail_data->account_id = account_id; -test_mail_data->save_status = 1; -test_mail_data->flags_seen_field = 1; -test_mail_data->file_path_plain = strdup(body_file_path); -test_mail_data->mailbox_name = strdup(mailbox_data->name); -test_mail_data->mailbox_type = mailbox_data->mailbox_type; -test_mail_data->full_address_from = strdup(""); -test_mail_data->full_address_to = strdup(""); -test_mail_data->full_address_cc = strdup(""); -test_mail_data->full_address_bcc = strdup(""); -test_mail_data->subject = strdup("Meeting request mail"); - -body_file = fopen(body_file_path, "w"); - -for(i = 0; i < 500; i++) - fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2"); -fflush(body_file); - fclose(body_file); - - -if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMF_ERROR_NONE) - printf("email_add_mail failed. [%d]\n", err); -else - printf("email_add_mail success.\n"); - -/* Update message */ -/* variable 'mail' should be filled with data on DB. */ -/* And change values you want to update. */ -mail->head->subject = strdup("save.mailbox again..."); - -if(EMF_ERROR_NONE != email_update_message(mail_id,mail)) - /* failure */ -else - /* success */ - -/* Count message */ -int total = 0, unseen = 0; - -/* Get the total number of mails and the number of unseen mails */ -if(EMF_ERROR_NONE != email_count_message(mailbox,&total,&unseen)) - /* failure */ -else - /* success */ - -/* Delete message */ -int *mail_ids, num = 0; - -if(EMF_ERROR_NONE != email_delete_message(mailbox,mail_ids,num,on_server)) - /* failure */ -else - /* success */ -@endcode - -@li Delete all message in a specific mailbox -@code -/* Delete all message in mailbox */ -emf_mailbox_t *mailbox = NULL; -int on_server = 0; - -mailbox = malloc(sizeof(emf_mailbox_t)); -memset(mailbox, 0x00, sizeof(emf_mailbox_t)); - -mailbox->account_id = 1; -mailbox->name = strdup("INBOX"); - -if( EMF_ERROR_NONE != email_delete_all_message_in_mailbox(mailbox, on_server)) - /* failure */ -else - - /* success */ -@endcode - - -@li Clear all messages -@code -/* clear mail data */ -if(EMF_ERROR_NONE != email_clear_mail_data()) - /* failure */ -else - /* success */ -@endcode - -@li Modify flag -@code -emf_mail_flag_t newflag = {0}; -int mail_id = 0; -int on_server = 0; - -/* Modify mail flag*/ -if(EMF_ERROR_NONE != email_modify_mail_flag(mail_id,newflag,on_server)) - /* failure */ -else - /* success */ - -int mail_ids[] = {1, 2}; -int num = 2; -int seen_flag = 0; -int on_server = 0; - -/* Modify seen flag*/ -if(EMF_ERROR_NONE != email_modify_seen_flag(mail_ids, num, seen_flag,on_server)) - /* failure */ -else - /* success */ - -/* Modify extra flag*/ -int mail_id = 1; -if(EMF_ERROR_NONE != email_modify_extra_mail_flag(mail_id, newflag)) - /* failure */ -else - /* success */ -@endcode - - -@li Move mail -@code -int mail_id[],account_id = 1; -emf_mailbox_t *mailbox = NULL; -char *mailbox_name = "INBOX"; - -mailbox = malloc(sizeof(emf_mailbox_t)); -memset(mailbox, 0x00, sizeof(emf_mailbox_t)); - -mailbox->account_id = account_id; -mailbox->name = mailbox_name; - -/* Move mail to given mailbox*/ -if(EMF_ERROR_NONE != email_move_mail_to_mailbox(/*mail_id*/,/*num*/,mailbox)) - /* failure */ -else - /* success */ - -/* free mailbox*/ -email_free_mailbox(&mailbox,1); - -emf_mailbox_t *src_mailbox = NULL,*dest_mailbox = NULL; -int src_account_id = 0, dest_account_id = 0; -char * src_mailbox_name = NULL, *dest_mailbox_name = NULL; - -src_mailbox = malloc(sizeof(emf_mailbox_t)); -memset(src_mailbox, 0x00, sizeof(emf_mailbox_t)); - -dest_mailbox = malloc(sizeof(emf_mailbox_t)); -memset(dest_mailbox, 0x00, sizeof(emf_mailbox_t)); - -src_mailbox->account_id = /*src_account_id*/; -src_mailbox->name = /*src_mailbox_name*/ - -dest_mailbox->account_id = /*dest_account_id*/; -dest_mailbox->name = /*dest_mailbox_name*/ - -/*move all mails to given mailbox*/ -if(EMF_ERROR_NONE != email_move_all_mails_to_mailbox(src_mailbox,dest_mailbox)) - /* failure */ -else - /* success */ - -/* free mailbox*/ -email_free_mailbox(&src_mailbox,1); -email_free_mailbox(&dest_mailbox,1); - -int account_id = 0, total = 0; -emf_mailbox_t *mailbox = NULL; -char *mailbox_name = NULL; - -mailbox = malloc(sizeof(emf_mailbox_t)); -memset(mailbox, 0x00, sizeof(emf_mailbox_t)); - -mailbox->account_id = /*account_id*/; -mailbox->name = /*mailbox_name*/ - -/*count of draft msgs*/ -if(EMF_ERROR_NONE != email_count_message_with_draft_flag(mailbox,&total)) - /* failure */ -else - /* success */ - -/* free mailbox*/ -email_free_mailbox(&mailbox,1); -@endcode - -@li Count of msgs sent from given folde -@code -int account_id = 0, total = 0; -emf_mailbox_t *mailbox = NULL; -char *mailbox_name = NULL; - -mailbox = malloc(sizeof(emf_mailbox_t)); -memset(mailbox, 0x00, sizeof(emf_mailbox_t)); - -mailbox->account_id = /*account_id*/; -mailbox->name = /*mailbox_name*/ - -/*count of msgs sent from given mailbox*/ -if(EMF_ERROR_NONE != email_count_message_on_sending(mailbox,&total)) - /* failure */ -else - /* success */ - -/* free mailbox*/ -email_free_mailbox(&mailbox,1); - -@endcode - - -@li Get mailbox list -@code - -emf_mailbox_t* mailbox_list = NULL; -int account_id = 1, count = 0; - -/* Get mailbox list*/ -if(EMF_ERROR_NONE != email_get_mailbox_list(account_id,&mailbox_list,&count)) - /* failure */ -else - /* success */ - -/* free mailbox list*/ -email_free_mailbox(&mailbox,count); -@endcode - - -@li Get mailBox name by mailID -@code -/* Get mailBox name by mailID*/ -int mail_id = 1; -char *pMailbox_name=strdup("INBOX"); -err = email_get_mailbox_name_by_mail_id(mail_id,&pMailbox_name); - -free(pMailbox_name); - -@endcode - - -@li Cancel sending mail -@code - -/* email_cancel_send_mail*/ -int mail_id = 1; /* mail id of a mail which is on sending */ -err = email_cancel_send_mail(mail_id); - -@endcode - - - -@li Get the Total count and Unread count of all mailboxes -@code -/* Get the Total count and Unread count of all mailboxes */ -emf_mailbox_t* mailbox = NULL; -int account_id = 1, total = 0, unseen = 0; -char *mailbox_name = NULL; - -mailbox = malloc(sizeof(emf_mailbox_t)); -memset(mailbox, 0x00, sizeof(emf_mailbox_t)); - -mailbox->account_id = /*account_id*/; -mailbox->name = /*mailbox_name*/ - -err = email_count_message_all_mailboxes(mailbox,&total,&unseen); - -@endcode - -Flow Diagrams -@image html email_image006.png - -@image html email_image007.png - -@image html email_image008.png -@} - -@defgroup Use_Case4_network Network Operation -@ingroup EMAIL_USECASES -@{ -

Network Operation

-Network Operations are a set of operations to manage email send, receive and cancel related details. - -Structure: -emf_option_t - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
APIReturn Value / Exceptions
int email_send_mail( emf_mailbox_t* mailbox, int mail_id, emf_option_t* sending_option, unsigned* handle)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: --# Memory allocation and de-allocation for input param is to be done by application.
int email_sync_header(emf_mailbox_t* mailbox, unsigned* handle)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: --# Memory allocation and de-allocation for input param is to be done by application.
int email_download_body(emf_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: --# Memory allocation and de-allocation for input param is to be done by application.
int email_download_attachment(emf_mailbox_t* mailbox, int mail_id, const char* nth, unsigned* handle)Returns EMF_ERROR_NONE on success or negative value on failure.
int email_cancel_job(int account_id, int handle)Returns EMF_ERROR_NONE on success or negative value on failure.
int email_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t * status)Returns EMF_ERROR_NONE on success or negative value on failure.
void email_get_network_status(int* on_sending, int* on_receiving) Returns EMF_ERROR_NONE on success or negative value on failure
int email_send_saved(int account_id, emf_option_t* sending_option, unsigned* handle)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: --# Memory allocation and de-allocation for input param is to be done by application.
int email_get_imap_mailbox_list(int account_id, const char* mailbox, unsigned* handle)Returns EMF_ERROR_NONE on success or negative value on failure.
int email_sync_local_activity(int account_id)Returns EMF_ERROR_NONE on success or negative value on failure.
- -Sample Code -@li Send a mail -@code -/* TODO : Write sample to send a mail. */ -@endcode - -@li Download header of new emails from mail server -@code -/* Download header of new emails from mail server*/ -emf_mailbox_t mbox; -int account_id = 1; -int err = EMF_ERROR_NONE; -unsigned handle = 0; - -memset(&mbox, 0x00, sizeof(emf_mailbox_t)); - -mbox.account_id = account_id; -mbox.name = strdup("INBOX"); -err = email_sync_header (&mbox,&handle); -@endcode - - -@li Download email body from server -@code - -/*Download email body from server*/ -emf_mailbox_t mbox; -int mail_id = 1; -int account_id = 1; -int handle = 0; -int err = EMF_ERROR_NONE; - -memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); -mbox.account_id = account_id; -mbox.name = strdup("INBOX"); -err= email_download_body (&mbox,mail_id,0,&handle); - -@li Download a email nth-attachment from server -@code -/*Download a email nth-attachment from server*/ -emf_mailbox_t mailbox; -int mail_id = 1; -int account_id = 1; -char arg[50]; /* Input attachment number need to be download */ -unsigned handle = 0; -int err = EMF_ERROR_NONE; - -memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); -mailbox.name = "INBOX"; -mailbox.account_id = account_id; -err=email_download_attachment(&mailbox,mail_id,arg,&handle); -@endcode - -Flow Diagram -@image html email_image009.png -@} - -@defgroup Use_Case5_rule Rule Operation -@ingroup EMAIL_USECASES -@{ -

Rule Operation

-Rule Operations are a set of operations to manage email rules like add, get, delete or update rule related details. - -Structure: -emf_rule_t - - - - - - - - - - - - - - - --# Use email_free_rule to free allocated memory. - - - - - - -
APIReturn Value / Exceptions
int email_get_rule(int filter_id, emf_rule_t** filtering_set)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: --# Memory allocation for the param emf_rule_t** filtering_set will be done in this api. --# De-allocation is to be done by application.
int email_get_rule_list(emf_rule_t** filtering_set, int* count)Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: --# Memory allocation for the param emf_rule_t** filtering_set will be done in this api. --# De-allocation is to be done by application.
int email_add_rule(emf_rule_t* filtering_set) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: --# Memory allocation and de-allocation is to be done by application. --# Use email_free_rule to free allocated memory.
int email_update_rule(int filter_id, emf_rule_t* new_set) Returns EMF_ERROR_NONE on success or negative value on failure@n Remarks: --# Memory allocation and de-allocation is to be done by application.
int email_delete_rule(int filter_id)Returns EMF_ERROR_NONE on success or negative value on failure.
int email_free_rule(emf_rule_t** filtering_set, int count)Returns EMF_ERROR_NONE on success or negative value on failure
- -Sample Code -@li Filter Operation -@code -int err = EMF_ERROR_NONE; -emf_rule_t* rule = NULL; -int filter_id = 1; - -/* Get a information of filtering*/ -err = email_get_rule (filter_id,&rule); -err = email_free_rule (&rule,1); - -/* Get all filterings */ -int count = 0; -err = email_get_rule_list(&rule,&count); - - -/* Add a filter information */ -err = email_add_rule (rule); -err = email_free_rule (&rule,1); - -/* Change a filter information */ -err = email_update_rule (filter_id,rule); -err = email_free_rule (&rule,1); - -/* Delete a filter information*/ -err = email_delete_rule (filter_id); - -/* Free allocated memory */ -err = email_free_rule (&rule,1); -@endcode - -Flow Diagram -@image html email_image010.png -@} - -@defgroup Use_Case6_control Control Operation -@ingroup EMAIL_USECASES -@{ -

Control Operation

-Control Operations are a set of operations to manage Email MAPI Layer initialization. -The Application which will use the MAPIs MUST initialize IPC proxy and conntect to Email FW database before calling other APIs. -And it MUST finalize IPC proxy and disconnect to the DB if the application doesn't use APIs. - - - - - - - - - - - - - - - - - - - -
APIReturn Value / Exceptions
int email_init_storage(void)Returns EMF_ERROR_NONE on success or negative value on failure
int email_open_db(void)Returns EMF_ERROR_NONE on success or negative value on failure -@n Remarks: -@n Application should call email_close_db once db operation is over
int email_close_db(void)Returns EMF_ERROR_NONE on success or negative value on failure -@n Remarks: - -@n This API should be called only if email_open_db () is called.
int email_service_begin(void)Returns EMF_ERROR_NONE on success or negative value on failure
int email_service_end(void)Returns EMF_ERROR_NONE on success or negative value on failure -@n Remarks: -@n This API should be called only if email_service_begin () is called.
- -Sample Code -@li Initialize and Finalize Email MAPI Layer -@code -int err = EMF_ERROR_NONE; - -/* Initialize Email MAPI Layer before calling other MAPIs */ -if(EMF_ERROR_NONE == email_service_begin()) -{ - if(EMF_ERROR_NONE != email_open_db()) - { - return false; - } - if(EMF_ERROR_NONE != email_init_storage()) - { - return false; - } -} - -/* Call other MAPIs */ - -...... - -/* Finalize Email MAPI Layer when finishing application */ -err = email_close_db(); -err = email_service_end(); -@endcode - -Flow Diagram -@image html email_image011.png -@} - -@addtogroup Email_Feature -@{ -

System Configuration

-

Files to be included

-email-api.h -@n Emf_Mapi_Types.h - -

System Initialization and De-Initialization

-email_service_begin is used to initialize email-service at boot time. -@n email_service_end is used to deinitialize email-service at shutdown. -@n These two are separate executables. - -

Variable Configuration

-NA - -

Build Environment

-If the Application wants to use email-service Module, make sure that the following package should be included in the Makefile. - -email-service-dev - -

Runtime Environment

-NA -@} - -@defgroup EMAL_Appendix 4. Reference -@ingroup EMAILSVC -@{ -

Appendix

-

Email

-@image html email_image012.png - -- Alice composed a message using MUA (Mail User Agent). Alice enters the e-mail address of her correspondent, and hits the "send" button. -- MUA format the message using MIME and uses Simple mail Transfer Protocol to send the message to local MTA (Mail Transfer Agent) i,e smtp.a.org run by Alices ISP (Internet Service provider). -- The MTA looks at the destination address provided in the SMTP protocol i,e bob@b.org. An Internet e-mail address is a string of the form localpart@exampledomain. The part before the @ sign is the local part of the address, often the username of the recipient, and the part after the @ sign is a domain name. The MTA resolves a domain name to determine the fully qualified domain name of the mail exchange server in the Domain Name System (DNS). -- The DNS Server for the b.org domain, ns.b.org, responds with an MX Records listing the mail exchange servers for that domain, in this case mx.b.org, a server run by Bob's ISP. -- smtp.a.org sends the message to mx.b.org using SMTP, which delivers it to the mailbox of the user bob. -- Bob presses the "get mail" button in his MUA, which picks up the message using the Post Office Protocol (POP3). - -

RFC

--# RFC 2821-SMTP(Simple Mail Transfer Protocol) --# RFC 1939-POP3(Post Office Protocol) --# RFC 3501-IMAP4(Internate message protocol) -@} - -*/ - -/** -* @defgroup EMAILSVC - @{ -* @defgroup EMAIL_USECASES 3. API Description -* -@{ -

API Description

-This section describes APIs and shows the example of using them. -@} - @} -*/ - +/** + * + * @ingroup SLP_PG + * @defgroup EMAILSVC Email Service +@{ +

Introduction

+

Overview

+Electronic mail, most commonly abbreviated email or e-mail, is a method of exchanging digital messages. E-mail systems are based on a store-and-forward model in which e-mail server computer systems accept, forward, deliver and store messages on behalf of users, who only need to connect to the e-mail infrastructure, typically an e-mail server, with a network-enabled device for the duration of message submission or retrieval. + +

Purpose of Programming Guide

+This document is mainly aimed at the core functionality of the Email Service. The EMail Service component is implemented by Samsung to provide EMail service to applications that make use of EMail Engine. Email Engine provides functionality for the user like composing mail, saving mail, sending mail, and creating user mailbox according to the settings. Mobile subscribers can use the Email Engine to perform storage opearations such as save, update, get, delete and transport operations such as send, download and other email operations. + +This programming guide is prepared for application developers who will use the email-service. It contains: +- List of features offered by email-service +- Information on How to use APIs provided by the email-service +- Examples + +

Target Domain / Application

+The Email Service Layer can be utilized by any component in the application layer which allow the end user to perform the email related operations such as save, send, download email message and others. + +For Example, the Email Service APIs shall be invoked by +@li Multimedia application when user opts to send media file through email +@li Email application when user tries to send an email message + +

Terminology & Acronyms

+ + + + + + + + +
TerminologyDescription
Email Electronic mail
IMAPInternet Message Access Protocol
SMTPSimple mail transfer protocol for sending mails
POP3Post office protocol for receiving mails
RFC822Describes mail header, to address, cc, bcc etc. formats and decoding and encoding standards.
OMA Open Moblie Alliance
+ + +@} + +@defgroup Email_Architecture 1. Email Service Architecture +@ingroup EMAILSVC +@{ +

Email-service Architecture

+

System Architecture

+@image html email_image001.png + +

Process Architecture

+@image html email_image002.png email-service Process view + +@image html email_image003.png email-service Process architecture + +Whenever an application wants to use email-service, it will call APIs from Email MAPI layer. Email MAPI layer APIs will internally call APIs provided by email framework module. +@} + +@defgroup Email_Feature 2. Email Service Feature +@ingroup EMAILSVC +@{ +

Email-service Features

+ + + + + + + + + + + + + + + + + + + +
Feature API Reference
Account Operation +@n email_add_account() +@n email_delete_account() +@n email_update_account() +@n email_get_account() +@n email_get_account_list() +@n email_free_account() +@n email_validate_account() +
mailbox Operation +@n email_add_mailbox() +@n email_delete_mailbox() +@n email_update_mailbox() +@n email_get_mailbox_list() +@n email_get_mailbox_by_name() +@n email_get_child_mailbox_list() +@n email_get_mailbox_by_mailbox_type() +
Message Operation +@n email_add_message() +@n email_update_message() +@n email_count_mail() +@n email_delete_mail() +@n email_delete_all_mails_in_mailbox() +@n email_clear_mail_data() +@n email_add_attachment() +@n email_delete_attachment() +@n email_get_info() +@n email_free_mail_info() +@n email_get_header_info() +@n email_free_header_info() +@n email_get_body_info() +@n email_free_body_info() +@n email_get_attachment_data() +@n email_free_attachment_info() +@n email_get_mail() +@n email_modify_mail_flag() +@n email_modify_seen_flag() +@n email_modify_extra_mail_flag() +@n email_move_mail_to_mailbox() +@n email_move_all_mails_to_mailbox() +@n email_count_message_with_draft_flag() +@n email_count_message_on_sending() +@n email_get_mailbox_list() +@n email_free_mailbox() +@n email_free_mail() +@n email_get_mail_flag() +@n email_free_mail_list() +@n email_release_mail() +@n email_retry_sending_mail() +@n email_make_db_full() +@n email_get_mailbox_name_by_mail_id() +@n email_cancel_sending_mail() +@n email_count_message_all_mailboxes() +@n email_get_latest_unread_mail_id() +@n email_get_max_mail_count() +@n email_get_disk_space_usage() +
Network Operation +@n email_send_mail() +@n email_sync_header() +@n email_download_body() +@n email_download_attachment() +@n email_cancel_job() +@n email_get_pending_job() +@n email_get_network_status() +@n email_send_report() +@n email_send_saved() +@n email_sync_imap_mailbox_list() +@n email_sync_local_activity() +
Rule Operation +@n email_get_rule() +@n email_get_rule_list() +@n email_add_rule() +@n email_update_rule() +@n email_delete_rule() +@n email_free_rule() +
Control Operation +@n email_init_storage() +@n email_open_db() +@n email_close_db() +@n email_service_begin() +@n email_service_end() +
+@} + + + +@defgroup Use_Case1_account Account Operation +@ingroup EMAIL_USECASES +@{ +

Account Operation

+Account Operations are a set of operations to manage email accounts like add, update, delete or get account related details. + +Structure: +email_account_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */ + + + + + + + + + + + + + + + + + + + + + + + + +
APIReturn Value / Exceptions
int email_add_account(email_account_t* account)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_account_t* account should be allocated and deallocated by Application
int email_delete_account(int account_id) Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_update_account(int account_id , email_account_t* new_account) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_account_t* new_account should be allocated and deallocated by Application
int email_get_account(int account_id, int pulloption, email_account_t** account) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param account will happen in email_get_account (). To free this memory, application should call email_free_account ()
int email_get_account_list(email_account_t** account_list, int* count) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: Memory allocation for param ccount_list will happen in email_get_account_list (). To free this memory, application should call email_free_account ()
int email_free_account(email_account_t** account_list, int count) Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_validate_account(int account_id, unsigned* handle)Returns EMAIL_ERROR_NONE on success or negative value on failure
+ +Sample Code +@li Add account +@code +/* Add account */ + +/* Assign values for new account */ +email_account_t *account = NULL; + +account = malloc(sizeof(email_account_t)); +memset(account, 0x00, sizeof(email_account_t)); + +account->retrieval_mode = 1; +account->incoming_server_secure_connection = 1; +account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; +account->outgoing_server_port_number = EMAIL_SMTP_PORT; +account->outgoing_server_need_authentication = 1; +account->account_name = strdup("gmail"); +account->display_name = strdup("Tom"); +account->user_email_address = strdup("tom@gmail.com"); +account->reply_to_addr = strdup("tom@gmail.com"); +account->return_addr = strdup("tom@gmail.com"); +account->incoming_server_type = EMAIL_SERVER_TYPE_POP3; +account->incoming_server_address = strdup("pop3.gmail.com"); +account->incoming_server_port_number = 995; +account->incoming_server_secure_connection = 1; +account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL; +account->incoming_server_user_name = strdup("tom"); +account->password = strdup("tioimi"); +account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; +account->outgoing_server_address = strdup("smtp.gmail.com"); +account->outgoing_server_port_number = 587; +account->outgoing_server_secure_connection = 0x02; +account->outgoing_server_need_authentication = 1; +account->outgoing_server_user_name = strdup("tom@gmail.com"); +account->sending_password = strdup("tioimi"); +account->pop_before_smtp = 0; +account->incoming_server_requires_apop = 0; +account->flag1 = 2; +account->flag2 = 1; +account->is_preset_account = 1; +account->logo_icon_path = strdup("Logo Icon Path"); +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 = strdup("Display name from"); +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("Signature"); +account->check_interval = 0; + +if(EMAIL_ERROR_NONE != email_add_account(account)) + /* failure */ +else +{ + /* success */ + if(account_id) + *account_id = account->account_id; /* Use this returned account id when calling APIs which need it */ +} + +/* free account */ +email_free_account(&account, 1); + +@endcode + +@li Get account +@code +/* Get account */ + +email_account_t *account = NULL; +int account_id = 1; /* account id to be gotten */ + +if(EMAIL_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&account)) + /* failure */ +else + /* success */ + +/* free account */ +email_free_account(&account, 1); + +@endcode + +@li Update account +@code +/* Update account */ + +email_account_t *new_account = NULL; +int account_id = 1; /* account id to be updated */ + +/* Get account to be updated */ +if(EMAIL_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&new_account)) + /* failure */ +else + /* success */ + +/* Set the new values */ +new_account->flag1 = 1; +new_account->account_name = strdup("gmail"); +new_account->display_name = strdup("Tom001"); +new_account->options.keep_local_copy = 1; +new_account->check_interval = 55; + +if(EMAIL_ERROR_NONE != email_update_account(account_id,new_account)) + /* failure */ +else + /* success */ + +/* free account */ +email_free_account(&new_account, 1); + +@endcode + +@li Delete account +@code +/* Delete account */ + +int account_id = 1; /* account id to be deleted */ + +if(EMAIL_ERROR_NONE != email_delete_account(account_id)) + /* failure */ +else + /* success */ + +@endcode + + +@li Get list of accounts +@code +/* Get list of accounts */ + +email_account_t *account_list = NULL; +int count = 0; +int i; + +if(EMAIL_ERROR_NONE != email_get_account_list(&account_list,&count)) + /* failure */ +else +{ + /* success */ + for ( i = 0; i < count; i++ ) + { + /* Do something with each account */ + printf("account id : %d\n", account_list[i].account_id); + } +} + +/* free account */ +email_free_account(&account_list,count); + +@endcode + +@li Validate account - try to connect to server +@code +/* Validate account - try to connect to server */ +unsigned account_handle = 0; +int account_id = 1; + +if(EMAIL_ERROR_NONE != email_validate_account(account_id,&account_handle)) + /* failure */ +else + /* success */ +@endcode + +Flow Diagram +@image html email_image004.png +@} + +@defgroup Use_Case2_folder mailbox Operation +@ingroup EMAIL_USECASES +@{ +

mailbox Operation

+mailbox Operations are a set of operations to manage email mailboxes like add, update, delete or get mailbox related details. + +Structure: +email_mailbox_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */ + + + + + + + + + + + + + + + + + + + + + + + + +
APIReturn Value / Exceptions
int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* new_mailbox should be allocated and deallocated by Application
int email_delete_mailbox(email_mailbox_t* mailbox, int on_server, unsigned* handle) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application
int email_update_mailbox(email_mailbox_t*old_mailbox, email_mailbox_t* new_mailbox)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mailbox_t* old_mailbox and email_mailbox_t* new_mailbox should be allocated and deallocated by Application
int email_get_mailbox_list(int account_id, int local_yn, email_mailbox_t** mailbox_list, int* count)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_mailbox_list (). To free this memory application should call email_free_mailbox
int email_get_mailbox_by_name(int account_id, const char *pMailboxName, email_mailbox_t **pMailbox)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param pMailbox will happen in email_get_mailbox_by_name (). To free this memory application should call email_free_mailbox
int email_get_child_mailbox_list(int account_id, const char *parent_mailbox, email_mailbox_t** mailbox_list, int* count)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_child_mailbox_list (). To free this memory application should call email_free_mailbox
int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t** mailbox)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_mailbox_by_mailbox_type (). To free this memory application should call email_free_mailbox
+ +Sample Code + +@li Create new mailbox +@code +email_mailbox_t *mailbox = NULL, *new_mailbox = NULL; +unsigned handle = 0; +int on_server = 0; + +mailbox = malloc(sizeof(email_mailbox_t)); +memset(mailbox, 0x00, sizeof(email_mailbox_t)); + +mailbox->mailbox_name = strdup("Personal"); +mailbox->alias = strdup("selfuse"); +mailbox->account_id = 1; +mailbox->local = on_server; +mailbox->mailbox_type = 7; + +/* create new mailbox */ +if(EMAIL_ERROR_NONE != email_add_mailbox(mailbox,on_server,&handle)) + /* failure */ +else + /* success */ + +@endcode + + +@li Update and Delete mailbox +@code +email_mailbox_t *mailbox = NULL, *new_mailbox = NULL; +int on_server = 0; +unsigned handle = 0; + +new_mailbox = malloc(sizeof(email_mailbox_t)); +memset(new_mailbox, 0x00, sizeof(email_mailbox_t)); + +new_mailbox->mailbox_name = strdup("Personal001"); + +/* update mailbox */ +if(EMAIL_ERROR_NONE != email_update_mailbox(mailbox,new_mailbox)) + /* failure */ +else + /* success */ + +/* delete mailbox */ +if(EMAIL_ERROR_NONE != email_delete_mailbox(mailbox,on_server,&handle)) + /* failure */ +else + /* success */ + +email_free_mailbox(&mailbox, 1); +email_free_mailbox(&new_mailbox, 1); + +@endcode + +@li Get list of mailboxes +@code +int account_id = 1; +int local_yn = 0; +email_mailbox_t* mailbox_list = NULL; +int count = 0; + +/*get list of mailboxes */ +if(EMAIL_ERROR_NONE != email_get_mailbox_list(account_id, local_yn, &mailbox_list, &count)) + /* failure */ +else +{ + /* success */ + email_free_mailbox(&mailbox_list,count); +} +@endcode + +Flow Diagram +@image html email_image005.png +@} + +@defgroup Use_Case3_message Message Operation +@ingroup EMAIL_USECASES +@{ +

Message Operation

+Message Operations are a set of operations to manage email messages like add, update, delete or get message related details. + +Structure: +email_mail_data_t + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
APIReturn Value / Exceptions
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) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mail_data_t* input_mail_data and email_attachment_data_t *input_attachment_data_list and email_meeting_request_t* input_meeting_request should be allocated and deallocated by Application
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) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mail_data_t* input_mail_data and email_attachment_data_t *input_attachment_data_list and email_meeting_request_t* input_meeting_request should be allocated and deallocated by Application
int email_count_mail(email_mailbox_t* mailbox, int* total, int* unseen) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application
int email_delete_mail(email_mailbox_t* mailbox, int *mail_ids, int num, int from_server) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params int *mail_ids and mf_mailbox_t* mailbox should be allocated and deallocated by Application
int email_delete_all_mails_in_mailbox(email_mailbox_t* mailbox, int from_server) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param mf_mailbox_t* mailbox should be allocated and deallocated by Application
int email_clear_mail_data() Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_add_attachment(email_mailbox_t* mailbox, int mail_id, email_attachment_data_t* attachment)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param mf_mailbox_t* mailbox and mf_attachment_info_t* attachment hould be allocated and deallocated by Application
int email_delete_attachment(email_mailbox_t * mailbox, int mail_id, const char * attachment_id)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application
int email_get_attachment_data(email_mailbox_t* mailbox, int mail_id, const char* attachment_id, email_attachment_data_t** attachment)Returns EMAIL_ERROR_NONE on success or negative value on failure.@n Remarks: +-# Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application +-# Memory allocation for param email_attachment_data_t** attachment will happen in email_get_attachment_data (). To free this memory, application should call email_free_attachment_info ()
int email_free_attachment_info(email_attachment_data_t** atch_info) Returns EMAIL_ERROR_NONE on success or negative value on failure.
int email_modify_mail_flag(int mail_id, email_mail_flag_t new_flag, int onserver) Returns EMAIL_ERROR_NONE on success or negative value on failure.
int email_modify_seen_flag(int *mail_ids, int num, int seen_flag, int onserver) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param int *mail_ids should be allocated and deallocated by Application
int email_modify_extra_mail_flag(int mail_id, email_extra_flag_t new_flag) Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_move_mail_to_mailbox(int *mail_ids, int num, email_mailbox_t* new_mailbox) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params int *mail_ids and email_mailbox_t* new_mailbox should be allocated and deallocated by Application
int email_move_all_mails_to_mailbox(email_mailbox_t* src_mailbox, email_mailbox_t* new_mailbox) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mailbox_t* src_mailbox and email_mailbox_t* new_mailbox should be allocated and deallocated by Application
int email_count_message_with_draft_flag(email_mailbox_t* mailbox, int* total) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application
int email_count_message_on_sending(email_mailbox_t* mailbox, int* total) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application
int email_get_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count ) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param email_mailbox_t** mailbox_list will happen in email_get_mailbox_list (). To free this memory, application should call email_free_mailbox ()
int email_free_mailbox(email_mailbox_t** mailbox_list, int count) Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_get_mail_flag(int account_id, int mail_id, email_mail_flag_t* mail_flag) Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_retry_sending_mail( int mail_id, int timeout_in_sec) Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_make_db_full()Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name)Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_cancel_sending_mail( int mail_id) Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_count_message_all_mailboxes(email_mailbox_t* mailbox, int* total, int* unseen) Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_get_latest_unread_mail_id(int account_id, int *pMailID) Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_get_max_mail_count(int *Count) Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_get_disk_space_usage(unsigned long *total_size)Returns EMAIL_ERROR_NONE on success or negative value on failure
+ +Sample Code + +@li Add, Update, Count and Delete message +@code +email_mailbox_t *mailbox = NULL; +int on_server = 0, account_id = 0, mail_id = 0; +char *pFilePath = "/tmp/mail.txt"; +int i = 0; +int account_id = 0; +int from_eas = 0; +int attachment_count = 0; +int err = EMAIL_ERROR_NONE; +char arg[50] = { 0 , }; +char *body_file_path = "/opt/data/email/.emfdata/tmp/mail.txt"; +email_mailbox_t *mailbox_data = NULL; +email_mail_data_t *test_mail_data = NULL; +email_attachment_data_t *attachment_data = NULL; +email_meeting_request_t *meeting_req = NULL; +FILE *body_file; + +printf("\n > Enter account id : "); +scanf("%d", &account_id); + +memset(arg, 0x00, 50); +printf("\n > Enter mailbox name : "); +scanf("%s", arg); + +email_get_mailbox_by_name(account_id, arg, &mailbox_data); + +test_mail_data = malloc(sizeof(email_mail_data_t)); +memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); + +printf("\n From EAS? [0/1]> "); +scanf("%d", &from_eas); + +test_mail_data->account_id = account_id; +test_mail_data->save_status = 1; +test_mail_data->flags_seen_field = 1; +test_mail_data->file_path_plain = strdup(body_file_path); +test_mail_data->mailbox_name = strdup(mailbox_data->mailbox_name); +test_mail_data->mailbox_type = mailbox_data->mailbox_type; +test_mail_data->full_address_from = strdup(""); +test_mail_data->full_address_to = strdup(""); +test_mail_data->full_address_cc = strdup(""); +test_mail_data->full_address_bcc = strdup(""); +test_mail_data->subject = strdup("Meeting request mail"); + +body_file = fopen(body_file_path, "w"); + +for(i = 0; i < 500; i++) + fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2"); +fflush(body_file); + fclose(body_file); + + +if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE) + printf("email_add_mail failed. [%d]\n", err); +else + printf("email_add_mail success.\n"); + +/* Update message */ +/* variable 'mail' should be filled with data on DB. */ +/* And change values you want to update. */ +mail->head->subject = strdup("save.mailbox again..."); + +if(EMAIL_ERROR_NONE != email_update_message(mail_id,mail)) + /* failure */ +else + /* success */ + +/* Count message */ +int total = 0, unseen = 0; + +/* Get the total number of mails and the number of unseen mails */ +if(EMAIL_ERROR_NONE != email_count_mail(mailbox,&total,&unseen)) + /* failure */ +else + /* success */ + +/* Delete message */ +int *mail_ids, num = 0; + +if(EMAIL_ERROR_NONE != email_delete_mail(mailbox,mail_ids,num,on_server)) + /* failure */ +else + /* success */ +@endcode + +@li Delete all message in a specific mailbox +@code +/* Delete all message in mailbox */ +email_mailbox_t *mailbox = NULL; +int on_server = 0; + +mailbox = malloc(sizeof(email_mailbox_t)); +memset(mailbox, 0x00, sizeof(email_mailbox_t)); + +mailbox->account_id = 1; +mailbox->mailbox_name = strdup("INBOX"); + +if( EMAIL_ERROR_NONE != email_delete_all_mails_in_mailbox(mailbox, on_server)) + /* failure */ +else + + /* success */ +@endcode + + +@li Clear all messages +@code +/* clear mail data */ +if(EMAIL_ERROR_NONE != email_clear_mail_data()) + /* failure */ +else + /* success */ +@endcode + +@li Modify flag +@code +email_mail_flag_t newflag = {0}; +int mail_id = 0; +int on_server = 0; + +/* Modify mail flag*/ +if(EMAIL_ERROR_NONE != email_modify_mail_flag(mail_id,newflag,on_server)) + /* failure */ +else + /* success */ + +int mail_ids[] = {1, 2}; +int num = 2; +int seen_flag = 0; +int on_server = 0; + +/* Modify seen flag*/ +if(EMAIL_ERROR_NONE != email_modify_seen_flag(mail_ids, num, seen_flag,on_server)) + /* failure */ +else + /* success */ + +/* Modify extra flag*/ +int mail_id = 1; +if(EMAIL_ERROR_NONE != email_modify_extra_mail_flag(mail_id, newflag)) + /* failure */ +else + /* success */ +@endcode + + +@li Move mail +@code +int mail_id[],account_id = 1; +email_mailbox_t *mailbox = NULL; +char *mailbox_name = "INBOX"; + +mailbox = malloc(sizeof(email_mailbox_t)); +memset(mailbox, 0x00, sizeof(email_mailbox_t)); + +mailbox->account_id = account_id; +mailbox->mailbox_name = mailbox_name; + +/* Move mail to given mailbox*/ +if(EMAIL_ERROR_NONE != email_move_mail_to_mailbox(/*mail_id*/,/*num*/,mailbox)) + /* failure */ +else + /* success */ + +/* free mailbox*/ +email_free_mailbox(&mailbox,1); + +email_mailbox_t *src_mailbox = NULL,*dest_mailbox = NULL; +int src_account_id = 0, dest_account_id = 0; +char * src_mailbox_name = NULL, *dest_mailbox_name = NULL; + +src_mailbox = malloc(sizeof(email_mailbox_t)); +memset(src_mailbox, 0x00, sizeof(email_mailbox_t)); + +dest_mailbox = malloc(sizeof(email_mailbox_t)); +memset(dest_mailbox, 0x00, sizeof(email_mailbox_t)); + +src_mailbox->account_id = /*src_account_id*/; +src_mailbox->mailbox_name = /*src_mailbox_name*/ + +dest_mailbox->account_id = /*dest_account_id*/; +dest_mailbox->mailbox_name = /*dest_mailbox_name*/ + +/*move all mails to given mailbox*/ +if(EMAIL_ERROR_NONE != email_move_all_mails_to_mailbox(src_mailbox,dest_mailbox)) + /* failure */ +else + /* success */ + +/* free mailbox*/ +email_free_mailbox(&src_mailbox,1); +email_free_mailbox(&dest_mailbox,1); + +int account_id = 0, total = 0; +email_mailbox_t *mailbox = NULL; +char *mailbox_name = NULL; + +mailbox = malloc(sizeof(email_mailbox_t)); +memset(mailbox, 0x00, sizeof(email_mailbox_t)); + +mailbox->account_id = /*account_id*/; +mailbox->mailbox_name = /*mailbox_name*/ + +/*count of draft msgs*/ +if(EMAIL_ERROR_NONE != email_count_message_with_draft_flag(mailbox,&total)) + /* failure */ +else + /* success */ + +/* free mailbox*/ +email_free_mailbox(&mailbox,1); +@endcode + +@li Count of msgs sent from given folde +@code +int account_id = 0, total = 0; +email_mailbox_t *mailbox = NULL; +char *mailbox_name = NULL; + +mailbox = malloc(sizeof(email_mailbox_t)); +memset(mailbox, 0x00, sizeof(email_mailbox_t)); + +mailbox->account_id = /*account_id*/; +mailbox->mailbox_name = /*mailbox_name*/ + +/*count of msgs sent from given mailbox*/ +if(EMAIL_ERROR_NONE != email_count_message_on_sending(mailbox,&total)) + /* failure */ +else + /* success */ + +/* free mailbox*/ +email_free_mailbox(&mailbox,1); + +@endcode + + +@li Get mailbox list +@code + +email_mailbox_t* mailbox_list = NULL; +int account_id = 1, count = 0; + +/* Get mailbox list*/ +if(EMAIL_ERROR_NONE != email_get_mailbox_list(account_id,&mailbox_list,&count)) + /* failure */ +else + /* success */ + +/* free mailbox list*/ +email_free_mailbox(&mailbox,count); +@endcode + + +@li Get mailBox name by mailID +@code +/* Get mailBox name by mailID*/ +int mail_id = 1; +char *pMailbox_name=strdup("INBOX"); +err = email_get_mailbox_name_by_mail_id(mail_id,&pMailbox_name); + +free(pMailbox_name); + +@endcode + + +@li Cancel sending mail +@code + +/* email_cancel_sending_mail*/ +int mail_id = 1; /* mail id of a mail which is on sending */ +err = email_cancel_sending_mail(mail_id); + +@endcode + + + +@li Get the Total count and Unread count of all mailboxes +@code +/* Get the Total count and Unread count of all mailboxes */ +email_mailbox_t* mailbox = NULL; +int account_id = 1, total = 0, unseen = 0; +char *mailbox_name = NULL; + +mailbox = malloc(sizeof(email_mailbox_t)); +memset(mailbox, 0x00, sizeof(email_mailbox_t)); + +mailbox->account_id = /*account_id*/; +mailbox->mailbox_name = /*mailbox_name*/ + +err = email_count_message_all_mailboxes(mailbox,&total,&unseen); + +@endcode + +Flow Diagrams +@image html email_image006.png + +@image html email_image007.png + +@image html email_image008.png +@} + +@defgroup Use_Case4_network Network Operation +@ingroup EMAIL_USECASES +@{ +

Network Operation

+Network Operations are a set of operations to manage email send, receive and cancel related details. + +Structure: +email_option_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
APIReturn Value / Exceptions
int email_send_mail( email_mailbox_t* mailbox, int mail_id, email_option_t* sending_option, unsigned* handle)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: +-# Memory allocation and de-allocation for input param is to be done by application.
int email_sync_header(email_mailbox_t* mailbox, unsigned* handle)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: +-# Memory allocation and de-allocation for input param is to be done by application.
int email_download_body(email_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: +-# Memory allocation and de-allocation for input param is to be done by application.
int email_download_attachment(email_mailbox_t* mailbox, int mail_id, const char* nth, unsigned* handle)Returns EMAIL_ERROR_NONE on success or negative value on failure.
int email_cancel_job(int account_id, int handle)Returns EMAIL_ERROR_NONE on success or negative value on failure.
int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t * status)Returns EMAIL_ERROR_NONE on success or negative value on failure.
void email_get_network_status(int* on_sending, int* on_receiving) Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_send_saved(int account_id, email_option_t* sending_option, unsigned* handle)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: +-# Memory allocation and de-allocation for input param is to be done by application.
int email_sync_imap_mailbox_list(int account_id, const char* mailbox, unsigned* handle)Returns EMAIL_ERROR_NONE on success or negative value on failure.
int email_sync_local_activity(int account_id)Returns EMAIL_ERROR_NONE on success or negative value on failure.
+ +Sample Code +@li Send a mail +@code +/* TODO : Write sample to send a mail. */ +@endcode + +@li Download header of new emails from mail server +@code +/* Download header of new emails from mail server*/ +email_mailbox_t mailbox; +int account_id = 1; +int err = EMAIL_ERROR_NONE; +unsigned handle = 0; + +memset(&mailbox, 0x00, sizeof(email_mailbox_t)); + +mailbox.account_id = account_id; +mailbox.mailbox_name = strdup("INBOX"); +err = email_sync_header (&mailbox,&handle); +@endcode + + +@li Download email body from server +@code + +/*Download email body from server*/ +email_mailbox_t mailbox; +int mail_id = 1; +int account_id = 1; +int handle = 0; +int err = EMAIL_ERROR_NONE; + +memset(&mailbox, 0x00, sizeof(email_mailbox_t)); +mailbox.account_id = account_id; +mailbox.mailbox_name = strdup("INBOX"); +err= email_download_body (&mailbox,mail_id,0,&handle); + +@li Download a email nth-attachment from server +@code +/*Download a email nth-attachment from server*/ +email_mailbox_t mailbox; +int mail_id = 1; +int account_id = 1; +char arg[50]; /* Input attachment number need to be download */ +unsigned handle = 0; +int err = EMAIL_ERROR_NONE; + +memset(&mailbox, 0x00, sizeof(email_mailbox_t)); +mailbox.mailbox_name = "INBOX"; +mailbox.account_id = account_id; +err=email_download_attachment(&mailbox,mail_id,arg,&handle); +@endcode + +Flow Diagram +@image html email_image009.png +@} + +@defgroup Use_Case5_rule Rule Operation +@ingroup EMAIL_USECASES +@{ +

Rule Operation

+Rule Operations are a set of operations to manage email rules like add, get, delete or update rule related details. + +Structure: +email_rule_t- refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */ + + + + + + + + + + + + + + + +-# Use email_free_rule to free allocated memory. + + + + + + +
APIReturn Value / Exceptions
int email_get_rule(int filter_id, email_rule_t** filtering_set)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: +-# Memory allocation for the param email_rule_t** filtering_set will be done in this api. +-# De-allocation is to be done by application.
int email_get_rule_list(email_rule_t** filtering_set, int* count)Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: +-# Memory allocation for the param email_rule_t** filtering_set will be done in this api. +-# De-allocation is to be done by application.
int email_add_rule(email_rule_t* filtering_set) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: +-# Memory allocation and de-allocation is to be done by application. +-# Use email_free_rule to free allocated memory.
int email_update_rule(int filter_id, email_rule_t* new_set) Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: +-# Memory allocation and de-allocation is to be done by application.
int email_delete_rule(int filter_id)Returns EMAIL_ERROR_NONE on success or negative value on failure.
int email_free_rule(email_rule_t** filtering_set, int count)Returns EMAIL_ERROR_NONE on success or negative value on failure
+ +Sample Code +@li Filter Operation +@code +int err = EMAIL_ERROR_NONE; +email_rule_t* rule = NULL; +int filter_id = 1; + +/* Get a information of filtering*/ +err = email_get_rule (filter_id,&rule); +err = email_free_rule (&rule,1); + +/* Get all filterings */ +int count = 0; +err = email_get_rule_list(&rule,&count); + + +/* Add a filter information */ +err = email_add_rule (rule); +err = email_free_rule (&rule,1); + +/* Change a filter information */ +err = email_update_rule (filter_id,rule); +err = email_free_rule (&rule,1); + +/* Delete a filter information*/ +err = email_delete_rule (filter_id); + +/* Free allocated memory */ +err = email_free_rule (&rule,1); +@endcode + +Flow Diagram +@image html email_image010.png +@} + +@defgroup Use_Case6_control Control Operation +@ingroup EMAIL_USECASES +@{ +

Control Operation

+Control Operations are a set of operations to manage Email MAPI Layer initialization. +The Application which will use the MAPIs MUST initialize IPC proxy and conntect to Email FW database before calling other APIs. +And it MUST finalize IPC proxy and disconnect to the DB if the application doesn't use APIs. + + + + + + + + + + + + + + + + + + + +
APIReturn Value / Exceptions
int email_init_storage(void)Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_open_db(void)Returns EMAIL_ERROR_NONE on success or negative value on failure +@n Remarks: +@n Application should call email_close_db once db operation is over
int email_close_db(void)Returns EMAIL_ERROR_NONE on success or negative value on failure +@n Remarks: - +@n This API should be called only if email_open_db () is called.
int email_service_begin(void)Returns EMAIL_ERROR_NONE on success or negative value on failure
int email_service_end(void)Returns EMAIL_ERROR_NONE on success or negative value on failure +@n Remarks: +@n This API should be called only if email_service_begin () is called.
+ +Sample Code +@li Initialize and Finalize Email MAPI Layer +@code +int err = EMAIL_ERROR_NONE; + +/* Initialize Email MAPI Layer before calling other MAPIs */ +if(EMAIL_ERROR_NONE == email_service_begin()) +{ + if(EMAIL_ERROR_NONE != email_open_db()) + { + return false; + } + if(EMAIL_ERROR_NONE != email_init_storage()) + { + return false; + } +} + +/* Call other MAPIs */ + +...... + +/* Finalize Email MAPI Layer when finishing application */ +err = email_close_db(); +err = email_service_end(); +@endcode + +Flow Diagram +@image html email_image011.png +@} + +@addtogroup Email_Feature +@{ +

System Configuration

+

Files to be included

+email-api.h +@n email-types.h + +

System Initialization and De-Initialization

+email_service_begin is used to initialize email-service at boot time. +@n email_service_end is used to deinitialize email-service at shutdown. +@n These two are separate executables. + +

Variable Configuration

+NA + +

Build Environment

+If the Application wants to use email-service Module, make sure that the following package should be included in the Makefile. + +email-service-dev + +

Runtime Environment

+NA +@} + +@defgroup EMAL_Appendix 4. Reference +@ingroup EMAILSVC +@{ +

Appendix

+

Email

+@image html email_image012.png + +- Alice composed a message using MUA (Mail User Agent). Alice enters the e-mail address of her correspondent, and hits the "send" button. +- MUA format the message using MIME and uses Simple mail Transfer Protocol to send the message to local MTA (Mail Transfer Agent) i,e smtp.a.org run by Alices ISP (Internet Service provider). +- The MTA looks at the destination address provided in the SMTP protocol i,e bob@b.org. An Internet e-mail address is a string of the form localpart@exampledomain. The part before the @ sign is the local part of the address, often the username of the recipient, and the part after the @ sign is a domain name. The MTA resolves a domain name to determine the fully qualified domain name of the mail exchange server in the Domain Name System (DNS). +- The DNS Server for the b.org domain, ns.b.org, responds with an MX Records listing the mail exchange servers for that domain, in this case mx.b.org, a server run by Bob's ISP. +- smtp.a.org sends the message to mx.b.org using SMTP, which delivers it to the mailbox of the user bob. +- Bob presses the "get mail" button in his MUA, which picks up the message using the Post Office Protocol (POP3). + +

RFC

+-# RFC 2821-SMTP(Simple Mail Transfer Protocol) +-# RFC 1939-POP3(Post Office Protocol) +-# RFC 3501-IMAP4(Internate message protocol) +@} + +*/ + +/** +* @defgroup EMAILSVC + @{ +* @defgroup EMAIL_USECASES 3. API Description +* +@{ +

API Description

+This section describes APIs and shows the example of using them. +@} + @} +*/ + diff --git a/packaging/email-service.changes b/packaging/email-service.changes deleted file mode 100644 index 869f5e1..0000000 --- a/packaging/email-service.changes +++ /dev/null @@ -1,4 +0,0 @@ -* Fri Jun 22 2012 Patrick McCarty 0a6646f -- Add a service file for systemd support -- Create the initscripts and db in %install section - diff --git a/packaging/email-service.manifest b/packaging/email-service.manifest deleted file mode 100644 index 017d22d..0000000 --- a/packaging/email-service.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/email-service.spec b/packaging/email-service.spec old mode 100644 new mode 100755 index 645c617..369ff10 --- a/packaging/email-service.spec +++ b/packaging/email-service.spec @@ -1,19 +1,14 @@ Name: email-service Summary: E-mail Framework Middleware package -Version: 0.4.2 +Version: 0.9.8 Release: 1 Group: System/Libraries License: TBD Source0: %{name}-%{version}.tar.gz -Source1: email.service -Source1001: packaging/email-service.manifest Requires(post): /sbin/ldconfig -Requires(post): systemd Requires(post): /usr/bin/sqlite3 Requires(post): /usr/bin/vconftool -Requires(preun): systemd Requires(postun): /sbin/ldconfig -Requires(postun): systemd BuildRequires: cmake BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gthread-2.0) @@ -26,7 +21,7 @@ BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(contacts-service) BuildRequires: pkgconfig(uw-imap-toolkit) -BuildRequires: pkgconfig(drm-service) +BuildRequires: pkgconfig(drm-client) BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(alarm-service) BuildRequires: pkgconfig(mm-player) @@ -39,8 +34,11 @@ BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(libcurl) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(gconf-2.0) +BuildRequires: pkgconfig(cert-svc) +BuildRoot: %{_tmppath}/%{name}-%{version}-build + %description E-mail Framework Middleware Library/Binary package @@ -58,7 +56,6 @@ E-mail Framework Middleware Development package %setup -q %build -cp %{SOURCE1001} . export CFLAGS="${CFLAGS} -fPIC -Wall -g -fvisibility=hidden" export CXXFLAGS="${CXXFLAGS} -fPIC -Wall -g -fvisibility=hidden" @@ -66,107 +63,132 @@ export LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--rpath=%{_prefix}/lib -Wl, cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -make %{?_smp_mflags} +# Call make instruction with smp support +#make %{?jobs:-j%jobs} +make %install %make_install -mkdir -p %{buildroot}%{_libdir}/systemd/user/tizen-middleware.target.wants -install -m 0644 %SOURCE1 %{buildroot}%{_libdir}/systemd/user/ -ln -sf ../email.service %{buildroot}%{_libdir}/systemd/user/tizen-middleware.target.wants/ +%clean +rm -rf %{buildroot} + +%post +/sbin/ldconfig + + +################################################################# +# Add preset account information +################################################################# +echo "[EMAIL-SERVICE] Start adding preset account information..." + +################################################################################################ -rm -f %{buildroot}%{_bindir}/email-test-app +# for default mail slot szie +vconftool set -t int db/private/email-service/slot_size "100" -g 6514 -# FIXME: remove initscripts after systemd is ready -mkdir -p %{buildroot}%{_sysconfdir}/rc.d/init.d -cat << EOF > %{buildroot}%{_sysconfdir}/rc.d/init.d/email-service -#!/bin/sh -/usr/bin/email-service & -EOF +# for latest mail id +vconftool set -t int db/private/email-service/latest_mail_id "0" -g 6514 -mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc3.d -mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc5.d -ln -sf ../init.d/email-service %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S70email-service -ln -sf ../init.d/email-service %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S70email-service +# for default account id +vconftool set -t int db/private/email-service/default_account_id "0" -g 6514 -# Remove installed DB files; these are not the ones we want -rm -f %{buildroot}/opt/dbspace/.email-service.db -rm -f %{buildroot}/opt/dbspace/.email-service.db-journal + +################################################################# +# Set executin script +################################################################# +echo "[EMAIL-SERVICE] Set executing script ..." +EMAIL_SERVICE_EXEC_SCRIPT=/etc/rc.d/init.d/email-service +EMAIL_SERVICE_BOOT_SCRIPT=/etc/rc.d/rc3.d/S70email-service +EMAIL_SERVICE_FASTBOOT_SCRIPT=/etc/rc.d/rc5.d/S70email-service +echo '#!/bin/sh' > ${EMAIL_SERVICE_EXEC_SCRIPT} +echo '/usr/bin/email-service &' >> ${EMAIL_SERVICE_EXEC_SCRIPT} +chmod 755 ${EMAIL_SERVICE_EXEC_SCRIPT} +rm -rf ${EMAIL_SERVICE_BOOT_SCRIPT} +rm -rf ${EMAIL_SERVICE_FASTBOOT_SCRIPT} +ln -s ${EMAIL_SERVICE_EXEC_SCRIPT} ${EMAIL_SERVICE_BOOT_SCRIPT} +ln -s ${EMAIL_SERVICE_EXEC_SCRIPT} ${EMAIL_SERVICE_FASTBOOT_SCRIPT} +echo "[EMAIL-SERVICE] Finish executing script ..." ################################################################# # Create DB file and tables. ################################################################# -sqlite3 %{buildroot}/opt/dbspace/.email-service.db 'PRAGMA journal_mode = PERSIST; +echo "[EMAIL-SERVICE] Creating Email Tables ..." +sqlite3 /opt/dbspace/.email-service.db 'PRAGMA journal_mode = PERSIST; CREATE TABLE mail_account_tbl ( - account_bind_type INTEGER, - account_name VARCHAR(51), - receiving_server_type INTEGER, - receiving_server_addr VARCHAR(51), - email_addr VARCHAR(129), - user_name VARCHAR(51), - password VARCHAR(51), - retrieval_mode INTEGER, - port_num INTEGER, - use_security INTEGER, - sending_server_type INTEGER, - sending_server_addr VARCHAR(51), - sending_port_num INTEGER, - sending_auth INTEGER, - sending_security INTEGER, - sending_user VARCHAR(51), - sending_password VARCHAR(51), - display_name VARCHAR(31), - reply_to_addr VARCHAR(129), - return_addr VARCHAR(129), - account_id INTEGER PRIMARY KEY, - keep_on_server INTEGER, - flag1 INTEGER, - flag2 INTEGER, - pop_before_smtp INTEGER, - apop INTEGER, - logo_icon_path VARCHAR(256), - preset_account INTEGER, - target_storage INTEGER, - check_interval INTEGER, - priority INTEGER, - keep_local_copy INTEGER, - req_delivery_receipt INTEGER, - req_read_receipt INTEGER, - download_limit INTEGER, - block_address INTEGER, - block_subject INTEGER, - display_name_from VARCHAR(256), - reply_with_body INTEGER, - forward_with_files INTEGER, - add_myname_card INTEGER, - add_signature INTEGER, - signature VARCHAR(256), - add_my_address_to_bcc INTEGER, - my_account_id INTEGER, - index_color INTEGER, - sync_status INTEGER + account_id INTEGER PRIMARY KEY, + account_name VARCHAR(51), + logo_icon_path VARCHAR(256), + user_data BLOB, + user_data_length INTEGER, + account_svc_id INTEGER, + sync_status INTEGER, + sync_disabled INTEGER, + default_mail_slot_size INTEGER, + user_display_name VARCHAR(31), + user_email_address VARCHAR(129), + reply_to_address VARCHAR(129), + return_address VARCHAR(129), + incoming_server_type INTEGER, + incoming_server_address VARCHAR(51), + incoming_server_port_number INTEGER, + incoming_server_user_name VARCHAR(51), + incoming_server_password VARCHAR(51), + incoming_server_secure_connection INTEGER, + retrieval_mode INTEGER, + keep_mails_on_pop_server_after_download INTEGER, + check_interval INTEGER, + auto_download_size INTEGER, + outgoing_server_type INTEGER, + outgoing_server_address VARCHAR(51), + outgoing_server_port_number INTEGER, + outgoing_server_user_name VARCHAR(51), + outgoing_server_password VARCHAR(51), + outgoing_server_secure_connection INTEGER, + outgoing_server_need_authentication INTEGER, + outgoing_server_use_same_authenticator INTEGER, + priority INTEGER, + keep_local_copy INTEGER, + req_delivery_receipt INTEGER, + req_read_receipt INTEGER, + download_limit INTEGER, + block_address INTEGER, + block_subject INTEGER, + display_name_from VARCHAR(256), + reply_with_body INTEGER, + forward_with_files INTEGER, + add_myname_card INTEGER, + add_signature INTEGER, + signature VARCHAR(256), + add_my_address_to_bcc INTEGER, + pop_before_smtp INTEGER, + incoming_server_requires_apop INTEGER, + smime_type INTEGER, + certificate_path VARCHAR(256), + cipher_type INTEGER, + digest_type INTEGER ); CREATE TABLE mail_attachment_tbl ( - attachment_id INTEGER PRIMARY KEY, - attachment_name VARCHAR(257), - attachment_path VARCHAR(257), - attachment_size INTEGER, - mail_id INTEGER, - account_id INTEGER, - mailbox_name VARCHAR(129), - attachment_save_status INTEGER, - attachment_drm_type INTEGER, - attachment_drm_method INTEGER, - attachment_inline_content_status INTEGER, - attachment_mime_type VARCHAR(257) + attachment_id INTEGER PRIMARY KEY, + attachment_name VARCHAR(257), + attachment_path VARCHAR(257), + attachment_size INTEGER, + mail_id INTEGER, + account_id INTEGER, + mailbox_id INTEGER, + attachment_save_status INTEGER, + attachment_drm_type INTEGER, + attachment_drm_method INTEGER, + attachment_inline_content_status INTEGER, + attachment_mime_type VARCHAR(257) ); CREATE TABLE mail_box_tbl ( - mailbox_id INTEGER, + mailbox_id INTEGER PRIMARY KEY, account_id INTEGER, local_yn INTEGER, mailbox_name VARCHAR(256), @@ -176,34 +198,38 @@ CREATE TABLE mail_box_tbl modifiable_yn INTEGER, total_mail_count_on_server INTEGER, has_archived_mails INTEGER, - mail_slot_size INTEGER + mail_slot_size INTEGER, + last_sync_time DATETIME ); + CREATE TABLE mail_read_mail_uid_tbl ( account_id INTEGER , - local_mbox VARCHAR(129) , + mailbox_id INTEGER , local_uid INTEGER , - mailbox_name VARCHAR(129) , - s_uid VARCHAR(129) , + mailbox_name VARCHAR(256) , + s_uid VARCHAR(129) , data1 INTEGER , - data2 VARCHAR(257) , + data2 VARCHAR(257) , flag INTEGER , - idx_num INTEGER PRIMARY KEY + idx_num INTEGER PRIMARY KEY ); + CREATE TABLE mail_rule_tbl ( account_id INTEGER , - rule_id INTEGER PRIMARY KEY, + rule_id INTEGER PRIMARY KEY, type INTEGER , value VARCHAR(257) , action_type INTEGER , - dest_mailbox VARCHAR(129), - flag1 INTEGER , + target_mailbox_id INTEGER , + flag1 INTEGER , flag2 INTEGER ); + CREATE TABLE mail_tbl ( - mail_id INTEGER PRIMARY_KEY, + mail_id INTEGER PRIMARY KEY, account_id INTEGER, mailbox_id INTEGER, mailbox_name VARCHAR(129), @@ -227,6 +253,7 @@ CREATE TABLE mail_tbl body_download_status INTEGER, file_path_plain VARCHAR(257), file_path_html VARCHAR(257), + file_path_mime_entity VARCHAR(257), mail_size INTEGER, flags_seen_field BOOLEAN, flags_deleted_field BOOLEAN, @@ -246,13 +273,17 @@ CREATE TABLE mail_tbl thread_item_count INTEGER, preview_text TEXT, meeting_request_status INTEGER, + message_class INTEGER, + digest_type INTEGER, + smime_type INTEGER, FOREIGN KEY(account_id) REFERENCES mail_account_tbl(account_id) ); + CREATE TABLE mail_meeting_tbl ( mail_id INTEGER PRIMARY KEY, account_id INTEGER, - mailbox_name TEXT , + mailbox_id INTEGER, meeting_response INTEGER, start_time INTEGER, end_time INTEGER, @@ -266,6 +297,7 @@ CREATE TABLE mail_meeting_tbl daylight_time_start_date INTEGER, daylight_bias INTEGER ); + CREATE TABLE mail_local_activity_tbl ( activity_id INTEGER, @@ -277,312 +309,60 @@ CREATE TABLE mail_local_activity_tbl dest_mbox VARCHAR(129) ); +CREATE TABLE mail_certificate_tbl +( + certificate_id INTEGER, + issue_year INTEGER, + issue_month INTEGER, + issue_day INTEGER, + expiration_year INTEGER, + expiration_month INTEGER, + expiration_day INTEGER, + issue_organization_name VARCHAR(256), + email_address VARCHAR(129), + subject_str VARCHAR(256), + filepath VARCHAR(256), + password VARCHAR(51) +); + -CREATE UNIQUE INDEX mail_account_idx1 ON mail_account_tbl (account_bind_type, account_id); +CREATE UNIQUE INDEX mail_account_idx1 ON mail_account_tbl (account_id); CREATE UNIQUE INDEX mail_attachment_idx1 ON mail_attachment_tbl (mail_id, attachment_id); -CREATE UNIQUE INDEX mail_box_idx1 ON mail_box_tbl (account_id, local_yn, mailbox_name); +CREATE UNIQUE INDEX mail_box_idx1 ON mail_box_tbl (mailbox_id); CREATE UNIQUE INDEX mail_idx1 ON mail_tbl (mail_id, account_id); -CREATE UNIQUE INDEX mail_read_mail_uid_idx1 ON mail_read_mail_uid_tbl (account_id, local_mbox, local_uid, mailbox_name, s_uid); +CREATE UNIQUE INDEX mail_read_mail_uid_idx1 ON mail_read_mail_uid_tbl (account_id, mailbox_id, local_uid, mailbox_name, s_uid); CREATE UNIQUE INDEX mail_meeting_idx1 ON mail_meeting_tbl (mail_id); CREATE INDEX mail_idx_date_time ON mail_tbl (date_time); CREATE INDEX mail_idx_thread_item_count ON mail_tbl (thread_item_count); ' -%preun -if [ $1 == 0]; then - systemctl stop email.service -fi +echo "[EMAIL-SERVICE] Finish Creating Email Tables." -%post -/sbin/ldconfig -systemctl daemon-reload -if [ $1 == 1 ]; then - systemctl restart email.service -fi ################################################################# -# Add preset account information +# Change file permission ################################################################# -echo "[EMAIL-SERVICE] Start adding preset account information..." - -################################################################# -# Email Settings -################################################################# - -#if [ ${USER} = "root" ] -#then - - ## Setting - # Sending - vconftool set -g 5000 -t bool db/Services/Email/Sending/KeepCopy "1" - vconftool set -g 5000 -t bool db/Services/Email/Sending/SendMeCopy "1" - vconftool set -g 5000 -t bool db/Services/Email/Sending/ReqDeliveryRep "0" - vconftool set -g 5000 -t bool db/Services/Email/Sending/ReqReadRep "0" - vconftool set -g 5000 -t int db/Services/Email/Sending/Priority "1" - vconftool set -g 5000 -t string db/Services/Email/Sending/ActiveAccount "" - vconftool set -g 5000 -t bool db/Services/Email/Sending/IncBodyReply "1" - vconftool set -g 5000 -t bool db/Services/Email/Sending/IncAttachFwd "1" - # Receiving - vconftool set -g 5000 -t int db/Services/Email/Receiving/AutoPoll "0" - vconftool set -g 5000 -t int db/Services/Email/Receiving/PollTime "0" - vconftool set -g 5000 -t int db/Services/Email/Receiving/SendReadRep "2" - vconftool set -g 5000 -t int db/Services/Email/Receiving/Reclimit "0" - vconftool set -g 5000 -t int db/Services/Email/Receiving/FetchOption "0" - vconftool set -g 5000 -t bool db/Services/Email/Receiving/KeepServer "1" - vconftool set -g 5000 -t int db/Services/Email/Receiving/ServDelOption "1" - - vconftool set -g 5000 -t int db/Services/Email/NbAccount "6" - - ## Accounts - - # Gmail - vconftool set -g 5000 -t string db/Services/Email/1/General/NetworkName "default" - vconftool set -g 5000 -t string db/Services/Email/1/General/AccountName "Gmail" - vconftool set -g 5000 -t string db/Services/Email/1/General/EmailAddr "" - vconftool set -g 5000 -t string db/Services/Email/1/General/UserId "" - vconftool set -g 5000 -t string db/Services/Email/1/General/Password "" - vconftool set -g 5000 -t string db/Services/Email/1/General/LoginType "username_type" - - # MailboxType : pop3(0), imap4(1) -> pop3(1), imap4(2) in email-service - vconftool set -g 5000 -t int db/Services/Email/1/Incoming/MailboxType "1" - vconftool set -g 5000 -t string db/Services/Email/1/Incoming/ServAddr "imap.gmail.com" - vconftool set -g 5000 -t int db/Services/Email/1/Incoming/Port "993" - vconftool set -g 5000 -t int db/Services/Email/1/Incoming/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/1/Incoming/Apop "0" - vconftool set -g 5000 -t bool db/Services/Email/1/Incoming/AutoEmailSync "0" - vconftool set -g 5000 -t bool db/Services/Email/1/Incoming/IncludeAttach "0" - vconftool set -g 5000 -t int db/Services/Email/1/Incoming/ImapFetchOpt "1" - - vconftool set -g 5000 -t string db/Services/Email/1/Outgoing/ServAddr "smtp.gmail.com" - vconftool set -g 5000 -t int db/Services/Email/1/Outgoing/Port "465" - vconftool set -g 5000 -t bool db/Services/Email/1/Outgoing/SmtpAuth "0" - vconftool set -g 5000 -t int db/Services/Email/1/Outgoing/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/1/Outgoing/SameIdPwd "1" - vconftool set -g 5000 -t bool db/Services/Email/1/Outgoing/PopBeforeSmtp "0" - - # Hotmail - vconftool set -g 5000 -t string db/Services/Email/2/General/NetworkName "default" - vconftool set -g 5000 -t string db/Services/Email/2/General/AccountName "Hotmail" - vconftool set -g 5000 -t string db/Services/Email/2/General/EmailAddr "" - vconftool set -g 5000 -t string db/Services/Email/2/General/UserId "" - vconftool set -g 5000 -t string db/Services/Email/2/General/Password "" - vconftool set -g 5000 -t string db/Services/Email/2/General/LoginType "username_type" - - # MailboxType : pop3(0), imap4(1) -> pop3(1), imap4(2) in email-service - vconftool set -g 5000 -t int db/Services/Email/2/Incoming/MailboxType "0" - vconftool set -g 5000 -t string db/Services/Email/2/Incoming/ServAddr "pop3.live.com" - vconftool set -g 5000 -t int db/Services/Email/2/Incoming/Port "995" - vconftool set -g 5000 -t int db/Services/Email/2/Incoming/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/2/Incoming/Apop "0" - vconftool set -g 5000 -t bool db/Services/Email/2/Incoming/AutoEmailSync "0" - vconftool set -g 5000 -t bool db/Services/Email/2/Incoming/IncludeAttach "0" - vconftool set -g 5000 -t int db/Services/Email/2/Incoming/ImapFetchOpt "1" - - vconftool set -g 5000 -t string db/Services/Email/2/Outgoing/ServAddr "smtp.live.com" - vconftool set -g 5000 -t int db/Services/Email/2/Outgoing/Port "587" - vconftool set -g 5000 -t bool db/Services/Email/2/Outgoing/SmtpAuth "0" - vconftool set -g 5000 -t int db/Services/Email/2/Outgoing/Secure "2" - vconftool set -g 5000 -t bool db/Services/Email/2/Outgoing/SameIdPwd "1" - vconftool set -g 5000 -t bool db/Services/Email/2/Outgoing/PopBeforeSmtp "0" - - # AOL - vconftool set -g 5000 -t string db/Services/Email/3/General/NetworkName "default" - vconftool set -g 5000 -t string db/Services/Email/3/General/AccountName "AOL" - vconftool set -g 5000 -t string db/Services/Email/3/General/EmailAddr "" - vconftool set -g 5000 -t string db/Services/Email/3/General/UserId "" - vconftool set -g 5000 -t string db/Services/Email/3/General/Password "" - vconftool set -g 5000 -t string db/Services/Email/3/General/LoginType "username_type" - - # MailboxType : pop3(0), imap4(1) -> pop3(1), imap4(2) in email-service - vconftool set -g 5000 -t int db/Services/Email/3/Incoming/MailboxType "1" - vconftool set -g 5000 -t string db/Services/Email/3/Incoming/ServAddr "imap.aol.com" - vconftool set -g 5000 -t int db/Services/Email/3/Incoming/Port "143" - vconftool set -g 5000 -t int db/Services/Email/3/Incoming/Secure "0" - vconftool set -g 5000 -t bool db/Services/Email/3/Incoming/Apop "0" - vconftool set -g 5000 -t bool db/Services/Email/3/Incoming/AutoEmailSync "0" - vconftool set -g 5000 -t bool db/Services/Email/3/Incoming/IncludeAttach "0" - vconftool set -g 5000 -t int db/Services/Email/3/Incoming/ImapFetchOpt "0" - - vconftool set -g 5000 -t string db/Services/Email/3/Outgoing/ServAddr "smtp.aol.com" - vconftool set -g 5000 -t int db/Services/Email/3/Outgoing/Port "587" - vconftool set -g 5000 -t bool db/Services/Email/3/Outgoing/SmtpAuth "0" - vconftool set -g 5000 -t int db/Services/Email/3/Outgoing/Secure "0" - vconftool set -g 5000 -t bool db/Services/Email/3/Outgoing/SameIdPwd "1" - vconftool set -g 5000 -t bool db/Services/Email/3/Outgoing/PopBeforeSmtp "0" - - # Samsung 3G for test - vconftool set -g 5000 -t string db/Services/Email/4/General/NetworkName "default" - vconftool set -g 5000 -t string db/Services/Email/4/General/AccountName "Samsung 3G" - vconftool set -g 5000 -t string db/Services/Email/4/General/EmailAddr "" - vconftool set -g 5000 -t string db/Services/Email/4/General/UserId "" - vconftool set -g 5000 -t string db/Services/Email/4/General/Password "" - vconftool set -g 5000 -t string db/Services/Email/4/General/LoginType "username_type" - - # MailboxType : pop3(0), imap4(1) -> pop3(1), imap4(2) in email-service - vconftool set -g 5000 -t int db/Services/Email/4/Incoming/MailboxType "0" - vconftool set -g 5000 -t string db/Services/Email/4/Incoming/ServAddr "165.213.73.235" - vconftool set -g 5000 -t int db/Services/Email/4/Incoming/Port "995" - vconftool set -g 5000 -t int db/Services/Email/4/Incoming/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/4/Incoming/Apop "0" - vconftool set -g 5000 -t bool db/Services/Email/4/Incoming/AutoEmailSync "0" - vconftool set -g 5000 -t bool db/Services/Email/4/Incoming/IncludeAttach "0" - vconftool set -g 5000 -t int db/Services/Email/4/Incoming/ImapFetchOpt "1" - - vconftool set -g 5000 -t string db/Services/Email/4/Outgoing/ServAddr "165.213.73.235" - vconftool set -g 5000 -t int db/Services/Email/4/Outgoing/Port "465" - vconftool set -g 5000 -t bool db/Services/Email/4/Outgoing/SmtpAuth "0" - vconftool set -g 5000 -t int db/Services/Email/4/Outgoing/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/4/Outgoing/SameIdPwd "1" - vconftool set -g 5000 -t bool db/Services/Email/4/Outgoing/PopBeforeSmtp "0" - - # Samsung Imap for test - vconftool set -g 5000 -t string db/Services/Email/5/General/NetworkName "default" - vconftool set -g 5000 -t string db/Services/Email/5/General/AccountName "Samsung Imap" - vconftool set -g 5000 -t string db/Services/Email/5/General/EmailAddr "" - vconftool set -g 5000 -t string db/Services/Email/5/General/UserId "" - vconftool set -g 5000 -t string db/Services/Email/5/General/Password "" - vconftool set -g 5000 -t string db/Services/Email/5/General/LoginType "username_type" - - # MailboxType : pop3(0), imap4(1) -> pop3(1), imap4(2) in email-service - vconftool set -g 5000 -t int db/Services/Email/5/Incoming/MailboxType "1" - vconftool set -g 5000 -t string db/Services/Email/5/Incoming/ServAddr "165.213.73.235" - vconftool set -g 5000 -t int db/Services/Email/5/Incoming/Port "993" - vconftool set -g 5000 -t int db/Services/Email/5/Incoming/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/5/Incoming/Apop "0" - vconftool set -g 5000 -t bool db/Services/Email/5/Incoming/AutoEmailSync "0" - vconftool set -g 5000 -t bool db/Services/Email/5/Incoming/IncludeAttach "0" - vconftool set -g 5000 -t int db/Services/Email/5/Incoming/ImapFetchOpt "1" - - vconftool set -g 5000 -t string db/Services/Email/5/Outgoing/ServAddr "165.213.73.235" - vconftool set -g 5000 -t int db/Services/Email/5/Outgoing/Port "465" - vconftool set -g 5000 -t bool db/Services/Email/5/Outgoing/SmtpAuth "0" - vconftool set -g 5000 -t int db/Services/Email/5/Outgoing/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/5/Outgoing/SameIdPwd "1" - vconftool set -g 5000 -t bool db/Services/Email/5/Outgoing/PopBeforeSmtp "0" - - - # Yahoo - vconftool set -g 5000 -t string db/Services/Email/6/General/NetworkName "default" - vconftool set -g 5000 -t string db/Services/Email/6/General/AccountName "Yahoomail" - vconftool set -g 5000 -t string db/Services/Email/6/General/EmailAddr "" - vconftool set -g 5000 -t string db/Services/Email/6/General/UserId "" - vconftool set -g 5000 -t string db/Services/Email/6/General/Password "" - vconftool set -g 5000 -t string db/Services/Email/6/General/LoginType "username_type" - - # MailboxType : pop3(0), imap4(1) -> pop3(1), imap4(2) in email-service - vconftool set -g 5000 -t int db/Services/Email/6/Incoming/MailboxType "0" - vconftool set -g 5000 -t string db/Services/Email/6/Incoming/ServAddr "pop.mail.yahoo.co.kr" - vconftool set -g 5000 -t int db/Services/Email/6/Incoming/Port "995" - vconftool set -g 5000 -t int db/Services/Email/6/Incoming/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/6/Incoming/Apop "0" - vconftool set -g 5000 -t bool db/Services/Email/6/Incoming/AutoEmailSync "0" - vconftool set -g 5000 -t bool db/Services/Email/6/Incoming/IncludeAttach "0" - vconftool set -g 5000 -t int db/Services/Email/6/Incoming/ImapFetchOpt "1" - - vconftool set -g 5000 -t string db/Services/Email/6/Outgoing/ServAddr "smtp.mail.yahoo.co.kr" - vconftool set -g 5000 -t int db/Services/Email/6/Outgoing/Port "465" - vconftool set -g 5000 -t bool db/Services/Email/6/Outgoing/SmtpAuth "0" - vconftool set -g 5000 -t int db/Services/Email/6/Outgoing/Secure "1" - vconftool set -g 5000 -t bool db/Services/Email/6/Outgoing/SameIdPwd "1" - vconftool set -g 5000 -t bool db/Services/Email/6/Outgoing/PopBeforeSmtp "0" - -#fi +#echo "[EMAIL-SERVICE] Start setting permission ..." +# 1. libraries +# 2. executables -################################################################################################ - -#if [ ${USER} = "root" ] -#then - -vconftool set -t string db/email/preset_account/aol/sending_address "smtp.aol.com" -vconftool set -t int db/email/preset_account/aol/sending_port "587" -vconftool set -t int db/email/preset_account/aol/sending_ssl "0" -vconftool set -t int db/email/preset_account/aol/receiving_type "2" -vconftool set -t string db/email/preset_account/aol/receiving_address "imap.aol.com" -vconftool set -t int db/email/preset_account/aol/receiving_port "143" -vconftool set -t int db/email/preset_account/aol/receiving_ssl "0" - -vconftool set -t string db/email/preset_account/gmail/sending_address "smtp.gmail.com" -vconftool set -t int db/email/preset_account/gmail/sending_port "465" -vconftool set -t int db/email/preset_account/gmail/sending_ssl "1" -vconftool set -t int db/email/preset_account/gmail/receiving_type "2" -# for POP3 server -#vconftool set -t string db/email/preset_account/gmail/receiving_address "pop.gmail.com" -#vconftool set -t int db/email/preset_account/gmail/receiving_port "995" -# for IMAP4 server -vconftool set -t string db/email/preset_account/gmail/receiving_address "imap.gmail.com" -vconftool set -t int db/email/preset_account/gmail/receiving_port "993" -vconftool set -t int db/email/preset_account/gmail/receiving_ssl "1" - -vconftool set -t string db/email/preset_account/yahoo/sending_address "smtp.mail.yahoo.co.kr" -vconftool set -t int db/email/preset_account/yahoo/sending_port "465" -vconftool set -t int db/email/preset_account/yahoo/sending_ssl "1" -vconftool set -t int db/email/preset_account/yahoo/receiving_type "1" -vconftool set -t string db/email/preset_account/yahoo/receiving_address "pop.mail.yahoo.co.kr" -vconftool set -t int db/email/preset_account/yahoo/receiving_port "995" -vconftool set -t int db/email/preset_account/yahoo/receiving_ssl "1" - -vconftool set -t string db/email/preset_account/hotmail/sending_address "smtp.live.com" -vconftool set -t int db/email/preset_account/hotmail/sending_port "587" -vconftool set -t int db/email/preset_account/hotmail/sending_ssl "2" -vconftool set -t int db/email/preset_account/hotmail/receiving_type "1" -vconftool set -t string db/email/preset_account/hotmail/receiving_address "pop3.live.com" -vconftool set -t int db/email/preset_account/hotmail/receiving_port "995" -vconftool set -t int db/email/preset_account/hotmail/receiving_ssl "1" - -vconftool set -t string db/email/preset_account/samsung_pop3/sending_address "165.213.73.235" -vconftool set -t int db/email/preset_account/samsung_pop3/sending_port "465" -vconftool set -t int db/email/preset_account/samsung_pop3/sending_ssl "1" -vconftool set -t int db/email/preset_account/samsung_pop3/receiving_type "1" -vconftool set -t string db/email/preset_account/samsung_pop3/receiving_address "165.213.73.235" -vconftool set -t int db/email/preset_account/samsung_pop3/receiving_port "995" -vconftool set -t int db/email/preset_account/samsung_pop3/receiving_ssl "1" - -vconftool set -t string db/email/preset_account/samsung_imap4/sending_address "165.213.73.235" -vconftool set -t int db/email/preset_account/samsung_imap4/sending_port "465" -vconftool set -t int db/email/preset_account/samsung_imap4/sending_ssl "1" -vconftool set -t int db/email/preset_account/samsung_imap4/receiving_type "2" -vconftool set -t string db/email/preset_account/samsung_imap4/receiving_address "165.213.73.235" -vconftool set -t int db/email/preset_account/samsung_imap4/receiving_port "993" -vconftool set -t int db/email/preset_account/samsung_imap4/receiving_ssl "1" - -# for Active Sync - Let email app create this key -#vconftool set -t int db/email_handle/active_sync_handle "0" - -# for contact sync - sync from the first contact change -vconftool set -t int db/email/last_sync_time "0" - -# for contact sync - sync from the first contact change -vconftool set -t int db/email/slot_size "100" - -# for badge -vconftool set -t int db/badge/com.samsung.email "0" - -#fi - -echo "[EMAIL-SERVICE] Finish adding preset account information" - - - -%postun -/sbin/ldconfig -systemctl daemon-reload +# 3. DB files +chmod 644 /opt/dbspace/.email-service.db +chmod 644 /opt/dbspace/.email-service.db-journal +%postun -p /sbin/ldconfig %files -%manifest email-service.manifest -%attr(0755,root,root) %{_sysconfdir}/rc.d/init.d/email-service -%{_sysconfdir}/rc.d/rc3.d/S70email-service -%{_sysconfdir}/rc.d/rc5.d/S70email-service -%config(noreplace) %attr(0644,root,root) /opt/dbspace/.email-service.db -%config(noreplace) %attr(0644,root,root) /opt/dbspace/.email-service.db-journal -%{_bindir}/email-service +%exclude /usr/bin/email-test-app %{_libdir}/lib*.so.* -%{_libdir}/systemd/user/email.service -%{_libdir}/systemd/user/tizen-middleware.target.wants/email.service +%{_bindir}/email-service +/opt/data/email/res/* + %files devel -%manifest email-service.manifest %{_includedir}/email-service/*.h %{_libdir}/lib*.so %{_libdir}/pkgconfig/*.pc + + diff --git a/packaging/email.service b/packaging/email.service deleted file mode 100644 index 8d0cf15..0000000 --- a/packaging/email.service +++ /dev/null @@ -1,12 +0,0 @@ - -[Unit] -Description=Start the Email service - -[Service] -ExecStart=/usr/bin/email-service -Nice=5 -OOMScoreAdjust=100 - -[Install] -WantedBy=tizen-middleware.target - diff --git a/res/Q02_Notification_email.png b/res/Q02_Notification_email.png new file mode 100755 index 0000000000000000000000000000000000000000..f2c4701cd123921eabe8a60eac7bcfb31ca882de GIT binary patch literal 5445 zcmZX0Wl+=))b($PrMr9S?vh@*8w3QDUb+!-V zC_*lOfE>Tog+1tw69imGDk=(cpzuBdpwL+&d;n!wgc4&;z>poN71)8`u^?1%#shtP zI5hwbOI51^pjse!Nj{G`fWQG9#+;qD0TW@sf%oP2SpZ&gT@VfeY_r*EK!^+gLgkvM z0k|sw4U-RFX#&<_0JWR`fE=(W42bDkx#<8+9RO;AoTvrBCkDh!6XW;+oN&Nlgp)HA zh%Er9wa%;*e+f2{?+N^4s-Q)&i%U*3$`)TZ0ME)wgq3eXmrjsc#u3Z05GsOxUcev` zB}Mk_{0jgeGHCv7dwv%>LE1PmA(Prp`b7BP6Bxtco& z%IePhPo(1Q)#bO3TU=2R_EFk6*Wb`zE(|J}Co>6RomRi6Y2S7bVQyJwIR(m<1^GAKMlxW?WY`?o$XxpgpV>k0tQ zy8ZgT^5J8{-D5T=?(tdvq#|g`PEsX* zvcHb_rG0!oQ3N=uBluK~?8}KDr&rdTsrYmSao6m9IyjWcT#(U3YEusV3~3#4vsV@n zOC6Ror9dpX1Usz{844qSMD%TZkG6PrREw$7SK>DHt{Pd!SgkiiQ!c^cg=w^iqN%|5 zj7ljo<$F{0?qthp%Id>ns2}urk^|miB18RZ%@2eKvYf}7IU0!ThZvh4Heh!rT{=%T zhu}~~X`%>Za6;4|j;yLW)&|x_i#jzBW-cj;Wdd0O>{wGYFGp65{(GJe6n_Tjog~B) ztaXGq=PA>uM9ISw)dys`D3jDBc)QZEbek(IW+-R0W_-;!_l0VUq;wcLvqqO)yjt+& zvV|amBXK(=JN-M7J4`$5XSReTPSAjgYx6BWv(KJ-47=pJQoCT+dkmc=W?@SYFsHC12%8kd+>grb_-{j0Py3@H|dA$1({DEREht()=%4%k8U;9Vi z5A2H&Vv=~8nBhbiA43s69zBd9g#KN=K^4PnGQ+Tin5_6={$2rDfuE(dK)b*TnvBnc zIeIxfIZOhg7PWO%b?bFRmgkmZ7HPGQ%_ADMEG5miYYD#Q)?3ziljnZs%oY7**T zHGUQ<6_GY~Nno3PgMMT63R6V$lkJ`%2$3^GYp4*r7fF5m(@vYIfV)M3Jfv>+#z0YQxeda7*^gm(16y39D%hmEb-n;jgIYRW#;?C!9^`$nkHMo_S3%o)+L9aL{9pI

$MhHipP-MHrKY#kk8Ot9xx9(kG|o7;Yp#H zVOJG@m4bnS!SMK(@i*i11=2-I;tLXcMSDdHMH?Lsk3t^_wb!(Fy6U#Iw)zEulZg5;j>Ms`scPLL|e4-LDc#*p=3bURhpInsO zZl@aKAMhwKFPhbc(ZRZcV$Ktjlk}sKN%5Gw$~*eG<2!{*n{pf(gS+1J!VD5DYsh zN;S$B>*hM_1^cH|75Np{-z`hWsws#rRT|Z_Xk_$mACldDirdhaJGayFD9g zaE)uZAM{P`5M|B58}({UZ@{$?CTv%$`eE^iZ$SXB1?Fny_Gvunvs`X{so?nWm)6fK z>9WPAWtd}1H05Sydu6=7l`xC-_ud9ixfaEM=PQKUG`NEC55WzJov+#jeCCYnkFD|= zBYSzm485Wr_kE7;YXf;55?K=N#zh>iE*#q%TZ`Ikv^oBbFJV%qNqW^ty+W5q^Ky}I zHFTFL!SC~@g4OKzweluu zdEt$%lkErNFUr&N2kT+C+AC~i#Zrnk&-KnNMm?7Iqi3^VXOk%SFwc#`>@ejpFtoYBN2?sOxT@u2A{R8>{3~ES{1&Nf8uixe4u!rHETTFUEE#R z*k$L{brROw7VdVn&r~Wqv3Ak>{1+`|ey&tbX|4A>%T-j2Ei#bzZepx^DTMa~ z*<;-Ef;gXE)xHA9#Z2C3T&9t!()<{Py8hJf;xG*uDKV6=8mY4O(=SAh+0qT(9-O3Pp zi1p)WsHFJgi-$MIeIctMET?Zb$c%ShKwk1;-2XIRnom{VWHDrAVQ{eX&u^V2g;)OR zO^CCOnIQm#aRUH61_1tG{`q|Xcq#?}2Mz!rpAP_Zewj}Owf@Oae_ah#i_qmSnPUWS zF>+j(QcswWs(uqT(mY2kT*et?pk6W$TZjAolv4zR7rkt#XitF6d$ zF-|={o|OAHDF);8#&&`pFr2b@$*S!enkJfK=iuOQ4Ilie_F_W+U$_Xb%Ak{8D|E-G|9TDvgK>Ab;)Fw-v9FrJIA&Obxn~UiZZypNr4+BI_RBc_ zwfL_GM+Ygwt5AJ;!BrV5=G=PjtR2X!i{@llNac%(%@sUWE zrbHGM)#F9)YfS6PD$lAai_4^=7j8@ERgMdkQakHKg{%bHZakj$6Gb@6gI&6yRwjm$ zNA116Rm`sG2X_Z4M7e}Guxg!}2(SusJeXx^&G{8*FUcJlPyYDftOU>rb2R`DN&YP2 zeruCrNfbYb{XmrXl;FF2U|AqjZ}E7;l*`OhF8^+AI^sPIZfvALNq>p}d2(pwYW|~Z zoNv(juBPVZ(J=mJv1BZ>8uM|#F*-j(RcPGLcI+K7L>IXK9p%Vo+6OI0-g~<$%Nj-U z1sojXJ0*t2lufWqg2rEidy{K9VE3qAck$XAlhP+5X_qoxM?u`DC$~pec3+D^b;)+P zbIfopRV__E9apJL-4z!cqn|@Yuqx=omD`eg?w1#2_?$n+h#({U z^^fdxfz&_#HY=1G)1Llk6qC`jXYaVTZSq`HZqBq(9%A*Te4ODa@%z^zL_E|0*J^_7rjZX)_gr8A){a&?n|mp3Nc|1ui`Xg74Li4qDOF!487Cmc&tiQXrs~ zJau-Prdeswbx<;qTJ(iQUh%&b>79L<&T52wn}*+;_LGV`v7Q4#d4$Sl&3`UuN-|a} zxFtX-SVLH6(EY#Paa6qKgN70hBb8T!79pG{up{;&z~f#3NT|*djDS6O;UpvACeZVb zbbsM#o%6V7n>Ye;W}3#Dx{hAgK<{e>YL zL-WhTeZSQ~(|PL>SAvQn@7Z5If!Z9snODyEMLhRxN`bsSVFGca(e>42n24`P{x?o2 z;cl1J^3%XZ>^WR_bVbDX3|(!Rn~NLU%$TYW9v_X0sV-5(BE7k`V!U_6lr%P9kR2&w zO!aS1Wbahr;aibW8EBWd+pIVRSR+yXDyWx8R};tJrz91wQ|nWA&~}mIGNjGvb6?UN zo6}PU2qR8I8IT~xsr;EFBeO=sXkmLq!0WTHUO7yHZPsIVDU(f%Tcy=ex&{Ne8Jhe+~ z>_m3koEbnGhtgOpo9d@tixOzeUH85ou*_2b`EDjK*8(}MZF)Q>#1+Y(j`e@`?Q(3L z!H%D_AFv4e#USq>4=1FRhp<5LOh5*>O*CS*eHGaGgb3^wn)FuD?gSksPHNuP*l#Ws zS1;gDr!yZ-%G}ja3A_(t)|!?vuhh(R1PFE6Yx%fn;wsWDs5Ae!f{dotX|dKhX5KP5 zXkHL^Np@LUYk%ExET=D6b1 zVSAAw_t4!_q2Z-JVPt=mVS0SJEB30;m@mJOD6`k`$;;2Ec&9Z(8yg#fdHe%pxoyW6 zCG3N8|3aBQm}V2?$u&39Nqtitx?l?$(BZRvOq{>yhGco*tLcjM}yMwBR+o9!s=~T*MkrlO(d)7;ZE{=XwFk$9(4ry zhun_+Nm%k^UH>|?Bhz@r&sBIZ3kJbJFb?idjsnpFwhR8@9Z|gM7x8@ zQQV%O6veq9$Rk)(GG_czl3j8(@N@lfjS21ALBld#2X>q3BzSu zTs@4Kc}z_F^?IFQ4yS^84*l9weeA~>1on$JeB94sz^@7cHjXais{N5o6JMi{$c+0378hIJZ5KOUdyy#$u57{e+>cyFAv#=`n zeSJa@A1$cB*J!8#9%pmg*9{EL3lxX)*WGd9>wH|+{Rn=tA=c=bjFTft0c8o0nF=vt zb#~b*#vr*eXNJQALqdOaBOR2eHSw6OIgR;#pqQN*-SuO&j%DRr+T7DmJHI>_WSSU1 zWZ$_NFhe{YXPy^l#HH@?w_N?~p#nJAR&o@o30zgKW(L(dlq0QclGLDrn{q|a-fS0;KTYHmzuUH~CNT=xQ2iG^#m7{|`T@^vwVO literal 0 HcmV?d00001 diff --git a/utilities/test-application/include/testapp-account.h b/utilities/test-application/include/testapp-account.h index 267e01e..2f22aa0 100755 --- a/utilities/test-application/include/testapp-account.h +++ b/utilities/test-application/include/testapp-account.h @@ -20,8 +20,8 @@ */ -#ifndef EMF_TEST_ACCOUNT_H -#define EMF_TEST_ACCOUNT_H +#ifndef EMAIL_TEST_ACCOUNT_H +#define EMAIL_TEST_ACCOUNT_H /* export API */ void testapp_account_main(); diff --git a/utilities/test-application/include/testapp-mail.h b/utilities/test-application/include/testapp-mail.h index 0c50437..e7f3b40 100755 --- a/utilities/test-application/include/testapp-mail.h +++ b/utilities/test-application/include/testapp-mail.h @@ -21,8 +21,8 @@ -#ifndef EMF_TEST_MESSAGE_H -#define EMF_TEST_MESSAGE_H +#ifndef EMAIL_TEST_MESSAGE_H +#define EMAIL_TEST_MESSAGE_H #include @@ -31,5 +31,5 @@ void testapp_mail_main (void); -#endif /* EMF_TEST_MESSAGE_H */ +#endif /* EMAIL_TEST_MESSAGE_H */ diff --git a/utilities/test-application/include/testapp-mailbox.h b/utilities/test-application/include/testapp-mailbox.h index 3f92a9a..836a299 100755 --- a/utilities/test-application/include/testapp-mailbox.h +++ b/utilities/test-application/include/testapp-mailbox.h @@ -20,9 +20,9 @@ */ -#ifndef EMF_TEST_MAILBOX_H -#define EMF_TEST_MAILBOX_H +#ifndef EMAIL_TEST_MAILBOX_H +#define EMAIL_TEST_MAILBOX_H /* export API */ -void emf_test_mailbox_main (void); +void email_test_mailbox_main (void); #endif diff --git a/utilities/test-application/include/testapp-others.h b/utilities/test-application/include/testapp-others.h index 6864300..8c10989 100755 --- a/utilities/test-application/include/testapp-others.h +++ b/utilities/test-application/include/testapp-others.h @@ -21,8 +21,8 @@ -#ifndef EMF_TEST_OTHERS_H -#define EMF_TEST_OTHERS_H +#ifndef EMAIL_TEST_OTHERS_H +#define EMAIL_TEST_OTHERS_H /* export API */ void testapp_others_main(void); diff --git a/utilities/test-application/include/testapp-rule.h b/utilities/test-application/include/testapp-rule.h index 1a59a28..61f6e4c 100755 --- a/utilities/test-application/include/testapp-rule.h +++ b/utilities/test-application/include/testapp-rule.h @@ -21,11 +21,11 @@ -#ifndef EMF_TEST_RULE_H -#define EMF_TEST_RULE_H +#ifndef EMAIL_TEST_RULE_H +#define EMAIL_TEST_RULE_H /* export API */ -void emf_test_rule_main (void); +void email_test_rule_main (void); #endif diff --git a/utilities/test-application/include/testapp-thread.h b/utilities/test-application/include/testapp-thread.h index e5e0e99..c3e81c5 100755 --- a/utilities/test-application/include/testapp-thread.h +++ b/utilities/test-application/include/testapp-thread.h @@ -21,8 +21,8 @@ -#ifndef EMF_TEST_THREAD_H -#define EMF_TEST_THREAD_H +#ifndef EMAIL_TEST_THREAD_H +#define EMAIL_TEST_THREAD_H #include @@ -31,4 +31,4 @@ void testapp_thread_main(); -#endif /* EMF_TEST_THREAD_H */ \ No newline at end of file +#endif /* EMAIL_TEST_THREAD_H */ \ No newline at end of file diff --git a/utilities/test-application/include/testapp-utility.h b/utilities/test-application/include/testapp-utility.h index b6e0fa3..b88d69a 100755 --- a/utilities/test-application/include/testapp-utility.h +++ b/utilities/test-application/include/testapp-utility.h @@ -21,26 +21,26 @@ -#ifndef EMF_TEST_UTILITY_H -#define EMF_TEST_UTILITY_H +#ifndef EMAIL_TEST_UTILITY_H +#define EMAIL_TEST_UTILITY_H #include typedef enum { - EMF_MAIN_MENU = 0x0, - EMF_ACCOUNT_MENU, - EMF_MAIL_MENU, - EMF_MAILBOX_MENU, - EMF_RULE_MENU, - EMF_THREAD_MENU, - EMF_OTHERS_MENU, -} eEMF_MENU; + EMAIL_MAIN_MENU = 0x0, + EMAIL_ACCOUNT_MENU, + EMAIL_MAIL_MENU, + EMAIL_MAILBOX_MENU, + EMAIL_RULE_MENU, + EMAIL_THREAD_MENU, + EMAIL_OTHERS_MENU, +} eEMAIL_MENU; void testapp_print(char *fmt, ...); -void testapp_show_menu(eEMF_MENU menu); -void testapp_show_prompt(eEMF_MENU menu); +void testapp_show_menu(eEMAIL_MENU menu); +void testapp_show_prompt(eEMAIL_MENU menu); #endif diff --git a/utilities/test-application/main.c b/utilities/test-application/main.c index 1d58f62..449d72c 100755 --- a/utilities/test-application/main.c +++ b/utilities/test-application/main.c @@ -78,7 +78,7 @@ static gboolean testapp_initialize_testing () gettimeofday(&tv_1, NULL); - if ( email_service_begin() != EMF_ERROR_NONE ) { + if ( email_service_begin() != EMAIL_ERROR_NONE ) { testapp_print ("unexpected error: opening email service fail\n"); return FALSE; } @@ -87,7 +87,7 @@ static gboolean testapp_initialize_testing () testapp_print("\t email_service_begin Proceed time %d us\n",interval); gettimeofday(&tv_1, NULL); - if ( (error = email_open_db()) != EMF_ERROR_NONE) { + if ( (error = email_open_db()) != EMAIL_ERROR_NONE) { testapp_print("email_open_db failed [%d]\n", error); } gettimeofday(&tv_2, NULL); @@ -101,11 +101,11 @@ static gboolean testapp_finalize_testing () { int error; - if ( (error = email_close_db()) != EMF_ERROR_NONE) { + if ( (error = email_close_db()) != EMAIL_ERROR_NONE) { testapp_print("email_close_db failed [%d]\n", error); } - if ( email_service_end() != EMF_ERROR_NONE) { + if ( email_service_end() != EMAIL_ERROR_NONE) { testapp_print ("unexpected error: closing email service fail \n"); } @@ -145,14 +145,14 @@ static gboolean testapp_interpret_command (int menu_number) break; case 3: - emf_test_mailbox_main(); + email_test_mailbox_main(); break; case 4: break; case 5: - emf_test_rule_main(); + email_test_rule_main(); break; case 6: @@ -176,6 +176,7 @@ int main (int argc, char *argv[]) { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; if ( testapp_initialize_testing() == FALSE ) { testapp_print ("email-serivce is not ready\n"); @@ -183,10 +184,10 @@ int main (int argc, char *argv[]) } while (go_to_loop) { - testapp_show_menu (EMF_MAIN_MENU); - testapp_show_prompt (EMF_MAIN_MENU); + testapp_show_menu (EMAIL_MAIN_MENU); + testapp_show_prompt (EMAIL_MAIN_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf ("%d", &menu_number); go_to_loop = testapp_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-account.c b/utilities/test-application/testapp-account.c index 9c38a1b..c3d99c1 100755 --- a/utilities/test-application/testapp-account.c +++ b/utilities/test-application/testapp-account.c @@ -27,6 +27,7 @@ /* open header */ #include +#include "email-api.h" #include "email-api-account.h" #include "email-api-network.h" @@ -46,7 +47,7 @@ /* SAMSUNG 3G TEST */ #define S3G_RECV_SERVER_ADDR "165.213.73.235" -#define S3G_RECV_SERVER_PORT EMF_POP3_PORT +#define S3G_RECV_SERVER_PORT EMAIL_POP3_PORT #define S3G_RECV_USE_SECURITY 0 #define S3G_RECV_IMAP_USE_SECURITY 1 #define S3G_SMTP_SERVER_ADDR "165.213.73.235" @@ -57,9 +58,10 @@ gboolean testapp_test_create_account_by_account_type(int account_type,int *account_id) { - emf_account_t *account = NULL; + email_account_t *account = NULL; char id_string[100] = { 0, }, password_string[100] = { 0, }, address_string[100] = { 0, }; - int err_code = EMF_ERROR_NONE, samsung3g_account_index; + int err_code = EMAIL_ERROR_NONE, samsung3g_account_index; + int result_from_scanf = 0; unsigned handle; switch(account_type) { @@ -67,7 +69,7 @@ gboolean testapp_test_create_account_by_account_type(int account_type,int *accou case 5 : do { testapp_print("Enter your account index [1~10] : "); - scanf("%d",&samsung3g_account_index); + result_from_scanf = scanf("%d",&samsung3g_account_index); }while( samsung3g_account_index > 10 || samsung3g_account_index < 1); sprintf(id_string, "test%02d", samsung3g_account_index); sprintf(address_string, "", samsung3g_account_index); @@ -75,178 +77,188 @@ gboolean testapp_test_create_account_by_account_type(int account_type,int *accou break; default: testapp_print("Enter email address : "); - scanf("%s", address_string); + result_from_scanf = scanf("%s", address_string); testapp_print("Enter id : "); - scanf("%s", id_string); + result_from_scanf = scanf("%s", id_string); testapp_print("Enter password_string : "); - scanf("%s", password_string); + result_from_scanf = scanf("%s", password_string); break; } - account = malloc(sizeof(emf_account_t)); - memset(account, 0x00, sizeof(emf_account_t)); + account = malloc(sizeof(email_account_t)); + memset(account, 0x00, sizeof(email_account_t)); + + typedef struct { + int is_preset_account; + int index_color; + } user_data_t; + user_data_t data = (user_data_t) {1, 0}; + /* if user_data_t has any pointer member, please don't use sizeof(). */ + /* You need to serialize user_data to buffer and then take its length */ + int data_length = sizeof(data); /* Common Options */ - account->account_bind_type = EMF_BIND_TYPE_EM_CORE; - account->retrieval_mode = EMF_IMAP4_RETRIEVAL_MODE_ALL; - account->use_security = 1; - account->sending_server_type = EMF_SERVER_TYPE_SMTP; - account->flag1 = 2; - account->flag2 = 1; + account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL; + account->incoming_server_secure_connection = 1; + account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; + account->auto_download_size = 2; + account->outgoing_server_use_same_authenticator = 1; account->pop_before_smtp = 0; - account->apop = 0; - account->logo_icon_path = NULL; - account->preset_account = 0; - 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->incoming_server_requires_apop = 0; + account->logo_icon_path = NULL; + account->user_data = malloc (data_length); + memcpy( account->user_data, (void*) &data, data_length ); + account->user_data_length = data_length; + 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 = NULL; - account->options.add_my_address_to_bcc = 0; - account->target_storage = 0; - account->check_interval = 0; - account->keep_on_server = 1; - - account->account_name = strdup(address_string); - account->display_name = strdup(id_string); - account->email_addr = strdup(address_string); - account->reply_to_addr = strdup(address_string); - account->return_addr = strdup(address_string); - - account->user_name = strdup(id_string); - account->password = strdup(password_string); - account->sending_user = strdup(id_string); - account->sending_password = strdup(password_string); + 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->account_name = strdup(address_string); + account->user_display_name = strdup(id_string); + account->user_email_address = strdup(address_string); + account->reply_to_address = strdup(address_string); + account->return_address = strdup(address_string); + + account->incoming_server_user_name = strdup(id_string); + account->incoming_server_password = strdup(password_string); + account->outgoing_server_user_name = strdup(id_string); + account->outgoing_server_password = strdup(password_string); switch (account_type) { case 1:/* gawab */ - account->receiving_server_type = EMF_SERVER_TYPE_POP3 ; - account->receiving_server_addr = strdup(GWB_RECV_SERVER_ADDR); - account->port_num = EMF_POP3S_PORT; - account->sending_server_addr = strdup(GWB_SMTP_SERVER_ADDR); - account->use_security = 1; - account->sending_auth = 1; - account->sending_port_num = EMF_SMTPS_PORT; - account->sending_security = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_POP3 ; + account->incoming_server_address = strdup(GWB_RECV_SERVER_ADDR); + account->incoming_server_port_number = EMAIL_POP3S_PORT; + account->outgoing_server_address = strdup(GWB_SMTP_SERVER_ADDR); + account->incoming_server_secure_connection = 1; + account->outgoing_server_need_authentication = 1; + account->outgoing_server_port_number = EMAIL_SMTPS_PORT; + account->outgoing_server_secure_connection = 1; break; case 2:/* vadofone */ - account->receiving_server_type = EMF_SERVER_TYPE_IMAP4; - account->receiving_server_addr = strdup(VDF_RECV_SERVER_ADDR); - account->port_num = EMF_IMAP_PORT; - account->sending_server_addr = strdup(VDF_SMTP_SERVER_ADDR); - account->use_security = 0; - account->sending_auth = 0; + account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4; + account->incoming_server_address= strdup(VDF_RECV_SERVER_ADDR); + account->incoming_server_port_number = EMAIL_IMAP_PORT; + account->outgoing_server_address = strdup(VDF_SMTP_SERVER_ADDR); + account->incoming_server_secure_connection = 0; + account->outgoing_server_need_authentication = 0; break; case 4:/* SAMSUNG 3G TEST */ - account->receiving_server_type = EMF_SERVER_TYPE_POP3; - account->receiving_server_addr = strdup(S3G_RECV_SERVER_ADDR); - account->port_num = S3G_RECV_SERVER_PORT; - account->sending_server_addr = strdup(S3G_SMTP_SERVER_ADDR); - account->sending_port_num = S3G_SMTP_SERVER_PORT; - account->use_security = S3G_RECV_USE_SECURITY; - account->sending_security = S3G_SMTP_USE_SECURITY; - account->sending_auth = S3G_SMTP_AUTH; + account->incoming_server_type = EMAIL_SERVER_TYPE_POP3; + account->incoming_server_address = strdup(S3G_RECV_SERVER_ADDR); + account->incoming_server_port_number = S3G_RECV_SERVER_PORT; + account->outgoing_server_address = strdup(S3G_SMTP_SERVER_ADDR); + account->outgoing_server_port_number = S3G_SMTP_SERVER_PORT; + account->incoming_server_secure_connection = S3G_RECV_USE_SECURITY; + account->outgoing_server_secure_connection = S3G_SMTP_USE_SECURITY; + account->outgoing_server_need_authentication = S3G_SMTP_AUTH; break; - + case 5:/* SAMSUNG 3G TEST */ - account->receiving_server_type = EMF_SERVER_TYPE_IMAP4; - account->receiving_server_addr = strdup(S3G_RECV_SERVER_ADDR); - account->port_num = EMF_IMAPS_PORT; - account->sending_server_addr = strdup(S3G_SMTP_SERVER_ADDR); - account->sending_port_num = S3G_SMTP_SERVER_PORT; - account->use_security = 1; - account->sending_security = S3G_SMTP_USE_SECURITY; - account->sending_auth = S3G_SMTP_AUTH; + account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4; + account->incoming_server_address= strdup(S3G_RECV_SERVER_ADDR); + account->incoming_server_port_number = EMAIL_IMAPS_PORT; + account->outgoing_server_address = strdup(S3G_SMTP_SERVER_ADDR); + account->outgoing_server_port_number = S3G_SMTP_SERVER_PORT; + account->incoming_server_secure_connection = 1; + account->outgoing_server_secure_connection = S3G_SMTP_USE_SECURITY; + account->outgoing_server_need_authentication = S3G_SMTP_AUTH; break; case 6:/* Gmail POP3 */ - account->receiving_server_type = EMF_SERVER_TYPE_POP3; - account->receiving_server_addr = strdup("pop.gmail.com"); - account->port_num = 995; - account->use_security = 1; - account->sending_server_addr = strdup("smtp.gmail.com"); - account->sending_port_num = 465; - account->sending_security = 1; - account->sending_auth = 1; + 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->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; break; case 7 : /* Gmail IMAP4 */ - account->receiving_server_type = EMF_SERVER_TYPE_IMAP4; - account->receiving_server_addr = strdup("imap.gmail.com"); - account->port_num = 993; - account->use_security = 1; - account->sending_server_addr = strdup("smtp.gmail.com"); - account->sending_port_num = 465; - account->sending_security = 1; - account->sending_auth = 1; + 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->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; break; case 8: /* Active Sync */ - account->receiving_server_type = EMF_SERVER_TYPE_ACTIVE_SYNC; - account->receiving_server_addr = strdup(""); - account->port_num = 0; - account->use_security = 1; - account->sending_server_addr = strdup(""); - account->sending_port_num = 0; - account->sending_security = 1; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_ACTIVE_SYNC; + account->incoming_server_address= strdup(""); + account->incoming_server_port_number = 0; + account->incoming_server_secure_connection = 1; + account->outgoing_server_address = strdup(""); + account->outgoing_server_port_number = 0; + account->outgoing_server_secure_connection = 1; + account->outgoing_server_need_authentication = 1; break; case 9: /* AOL */ - account->receiving_server_type = EMF_SERVER_TYPE_IMAP4; - account->receiving_server_addr = strdup("imap.aol.com"); - account->port_num = 143; - account->use_security = 0; - account->sending_server_addr = strdup("smtp.aol.com"); - account->sending_port_num = 587; - account->sending_security = 0; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4; + account->incoming_server_address= strdup("imap.aol.com"); + account->incoming_server_port_number = 143; + account->incoming_server_secure_connection = 0; + account->outgoing_server_address = strdup("smtp.aol.com"); + account->outgoing_server_port_number = 587; + account->outgoing_server_secure_connection = 0; + account->outgoing_server_need_authentication = 1; break; case 10: /* Hotmail */ - account->receiving_server_type = EMF_SERVER_TYPE_POP3; - account->receiving_server_addr = strdup("pop3.live.com"); - account->port_num = 995; - account->use_security = 1; - account->sending_server_addr = strdup("smtp.live.com"); - account->sending_port_num = 587; - account->sending_security = 0x02; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_POP3; + account->incoming_server_address= strdup("pop3.live.com"); + account->incoming_server_port_number = 995; + account->incoming_server_secure_connection = 1; + account->outgoing_server_address = strdup("smtp.live.com"); + account->outgoing_server_port_number = 587; + account->outgoing_server_secure_connection = 0x02; + account->outgoing_server_need_authentication = 1; break; case 11:/* Daum IMAP4*/ - account->receiving_server_type = EMF_SERVER_TYPE_IMAP4; - account->receiving_server_addr = strdup("imap.daum.net"); - account->port_num = 993; - account->use_security = 1; - account->sending_server_addr = strdup("smtp.daum.net"); - account->sending_port_num = 465; - account->sending_security = 1; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4; + account->incoming_server_address= strdup("imap.daum.net"); + account->incoming_server_port_number = 993; + account->incoming_server_secure_connection = 1; + account->outgoing_server_address = strdup("smtp.daum.net"); + account->outgoing_server_port_number = 465; + account->outgoing_server_secure_connection = 1; + account->outgoing_server_need_authentication = 1; break; case 12:/* Daum POP3*/ - account->receiving_server_type = EMF_SERVER_TYPE_POP3; - account->receiving_server_addr = strdup("pop.daum.net"); - account->port_num = 995; - account->use_security = 1; - account->sending_server_addr = strdup("smtp.daum.net"); - account->sending_port_num = 465; - account->sending_security = 1; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_POP3; + account->incoming_server_address= strdup("pop.daum.net"); + account->incoming_server_port_number = 995; + account->incoming_server_secure_connection = 1; + account->outgoing_server_address = strdup("smtp.daum.net"); + account->outgoing_server_port_number = 465; + account->outgoing_server_secure_connection = 1; + account->outgoing_server_need_authentication = 1; break; default: @@ -254,12 +266,12 @@ gboolean testapp_test_create_account_by_account_type(int account_type,int *accou return FALSE; break; } - account->my_account_id = 77; + account->account_svc_id = 77; err_code = email_add_account_with_validation(account, &handle); if( err_code < 0) { testapp_print (" email_add_account_with_validation error : %d\n",err_code); return FALSE; - } + } testapp_print (" email_add_account succeed\n"); @@ -274,7 +286,8 @@ gboolean testapp_test_create_account_by_account_type(int account_type,int *accou static gboolean testapp_test_create_account() { int account_type = 0 ; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; testapp_print("1. Gawab\n"); testapp_print("2. Vodafone\n"); @@ -289,7 +302,7 @@ static gboolean testapp_test_create_account() testapp_print("12. Daum (POP3)\n"); testapp_print("Choose server type: "); - scanf("%d",&account_type); + result_from_scanf = scanf("%d",&account_type); if(!testapp_test_create_account_by_account_type(account_type,&err)) { testapp_print (" testapp_test_create_account_by_account_type error\n"); @@ -300,25 +313,27 @@ static gboolean testapp_test_create_account() static gboolean testapp_test_update_account() { + int result_from_scanf = 0; int account_id; - emf_account_t *account = NULL; - char account_name[20]; - int err = EMF_ERROR_NONE; + email_account_t *account = NULL; + char account_name[256]; + int err = EMAIL_ERROR_NONE; char signature[100] = {0}; - char email_addr[50] = {0,}; + char user_email_address[256] = {0,}; int add_my_address_to_bcc = 0; - int my_account_id = 0, with_validation = 0; + int account_svc_id = 0, with_validation = 0; testapp_print("\n>> Enter Account No: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); -/* sowmya.kr, 281209 Adding signature to options in emf_account_t changes */ - if( (err = email_get_account(account_id, GET_FULL_DATA,&account)) < 0) { - testapp_print ("email_get_account failed \n"); +/* sowmya.kr, 281209 Adding signature to options in email_account_t changes */ + if( (err = email_get_account(account_id, GET_FULL_DATA,&account)) != EMAIL_ERROR_NONE) { + testapp_print ("email_get_account failed - %d\n", err); + return false; } - else - testapp_print ("email_get_account result account_name - %s \n", account->account_name); + + testapp_print ("email_get_account result account_name - %s \n", account->account_name); testapp_print ("email_get_account result signature - %s \n", account->options.signature); @@ -327,57 +342,65 @@ static gboolean testapp_test_update_account() #endif testapp_print("\n Enter new Account name:"); - scanf("%s",account_name); + result_from_scanf = scanf("%s",account_name); testapp_print("\n Enter new email addr:"); - scanf("%s",email_addr); + result_from_scanf = scanf("%s",user_email_address); #ifdef __FEATURE_AUTO_POLLING__ testapp_print("\n Enter new check interval (in mins):"); - scanf("%d",&(account->check_interval)); + result_from_scanf = scanf("%d",&(account->check_interval)); #endif testapp_print("\n Enter new signature:"); - scanf("%s",signature); + result_from_scanf = scanf("%s",signature); testapp_print("\n>> Enter add_my_address_to_bcc:(0:off, 1:on) "); - scanf("%d",&add_my_address_to_bcc); + result_from_scanf = scanf("%d",&add_my_address_to_bcc); - testapp_print("\n>> Enter my_account_id: "); - scanf("%d",&my_account_id); + testapp_print("\n>> Enter account_svc_id: "); + result_from_scanf = scanf("%d",&account_svc_id); testapp_print("\n>> With validation ? (0: No, 1:Yes) "); - scanf("%d",&with_validation); + result_from_scanf = scanf("%d",&with_validation); if( account ) { account->account_name = strdup(account_name); - testapp_print("\n Assigning New Account name: %p", account->account_name); - account->email_addr = strdup(email_addr); + testapp_print("\n Assigning New Account name: (%s)", account->account_name); + account->user_email_address = strdup(user_email_address); account->options.signature = strdup(signature); - testapp_print("\n Assigning New Account name: %p", account->options.signature); + testapp_print("\n Assigning New Signature: (%s)\n", account->options.signature); account->options.add_my_address_to_bcc = add_my_address_to_bcc; - account->my_account_id= my_account_id; + account->account_svc_id = account_svc_id; if(with_validation) { - if((err = email_update_account_with_validation(account_id, account)) < 0) + if((err = email_update_account_with_validation(account_id, account)) != EMAIL_ERROR_NONE){ + testapp_print ("email_update_account_with_validation failed - %d\n", err); + return false; + } testapp_print ("email_update_account_with_validation successful \n"); } else { - if((err = email_update_account(account_id, account)) < 0) - testapp_print ("email_update_account_with_validation successful \n"); + if((err = email_update_account(account_id, account)) != EMAIL_ERROR_NONE) { + testapp_print ("email_update_account failed - %d\n", err); + return false; + } + testapp_print ("email_update_account successful \n"); } } - return FALSE; + return true; } static gboolean testapp_test_delete_account () { int account_id; - emf_account_t *account=NULL; - int err = EMF_ERROR_NONE; + email_account_t *account=NULL; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; + testapp_print("\n>> Enter Account No: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); -/* sowmya.kr, 281209 Adding signature to options in emf_account_t changes */ +/* sowmya.kr, 281209 Adding signature to options in email_account_t changes */ if( (err = email_get_account(account_id, WITHOUT_OPTION,&account)) < 0) { testapp_print ("email_get_account failed \n"); testapp_print("testapp_test_delete_account failed\n"); @@ -397,15 +420,16 @@ static gboolean testapp_test_delete_account () static gboolean testapp_test_validate_account () { + int result_from_scanf = 0; int account_id; - emf_account_t *account=NULL; - int err_code = EMF_ERROR_NONE; + email_account_t *account=NULL; + int err_code = EMAIL_ERROR_NONE; unsigned account_handle = 0; testapp_print("\n>> Enter Account No: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); -/* sowmya.kr, 281209 Adding signature to options in emf_account_t changes */ +/* sowmya.kr, 281209 Adding signature to options in email_account_t changes */ if( (err_code = email_get_account(account_id, WITHOUT_OPTION,&account)) < 0 ) { testapp_print ("email_get_account failed \n"); return FALSE; @@ -413,7 +437,7 @@ static gboolean testapp_test_validate_account () else testapp_print ("email_get_account result account_name - %s \n", account->account_name); - if((err_code = email_validate_account(account_id, &account_handle)) == EMF_ERROR_NONE ) + if((err_code = email_validate_account(account_id, &account_handle)) == EMAIL_ERROR_NONE ) testapp_print ("email_validate_account successful account_handle : %u\n",account_handle); else testapp_print ("email_validate_account failed err_code: %d \n",err_code); @@ -425,17 +449,18 @@ static gboolean testapp_test_validate_account () static gboolean testapp_test_cancel_validate_account () { + int result_from_scanf = 0; int account_id = 0; - int err_code = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; unsigned account_handle = 0; testapp_print("\n > Enter account_id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter handle: "); - scanf("%d", &account_handle); + result_from_scanf = scanf("%d", &account_handle); - err_code = email_cancel_job(account_id, account_handle); + err_code = email_cancel_job(account_id, account_handle, EMAIL_CANCELED_BY_USER); if(err_code == 0) testapp_print("email_cancel_job Success..!handle:[%d]", account_handle); else @@ -446,63 +471,110 @@ static gboolean testapp_test_cancel_validate_account () static gboolean testapp_test_get_account() { + int result_from_scanf = 0; int account_id; - emf_account_t *account=NULL; - int err_code = EMF_ERROR_NONE; + email_account_t *account=NULL; + int err_code = EMAIL_ERROR_NONE; testapp_print("\n>> Enter Account No: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); -/* sowmya.kr, 281209 Adding signature to options in emf_account_t changes */ + typedef struct { + int is_preset_account; + int index_color; + } user_data_t; + + testapp_print ("\n----------------------------------------------------------\n"); testapp_print ("email_get_account GET_FULL_DATA \n"); if( (err_code = email_get_account(account_id,GET_FULL_DATA,&account)) < 0) { - testapp_print ("email_get_account failed \n"); + testapp_print ("email_get_account failed - %d\n", err_code); return FALSE; } - else - testapp_print ("email_get_account result account_name - %s \n email_addr - %s \n use_security %d \n add_sig : %d \n signature %s \n add_my_address_to_bcc %d \nmy_account_id %d\n", + + user_data_t* val = (user_data_t*) account->user_data; + int is_preset_account = val? val->is_preset_account : 0; + int index_color = val? val->index_color : 0; + + testapp_print ("email_get_account result\n" + "account_name - %s \n" + "user_email_address - %s \n" + "incoming_server_secure_connection %d \n" + "add_sig : %d \n" + "signature %s \n" + "add_my_address_to_bcc %d \n" + "account_svc_id %d\n" + "incoming_server_address %s\n" + "outgoing_server_address %s\n" + "default_mail_slot_size %d\n" + "sync_status %d\n" + "sync_disabled %d\n" + "is_preset %d\n" + "index_color %d\n" + "certificate_path %s\n" + "digest_type %d\n" + , account->account_name, - account->email_addr, - account->use_security, + account->user_email_address, + account->incoming_server_secure_connection, account->options.add_signature, account->options.signature, account->options.add_my_address_to_bcc, - account->my_account_id + account->account_svc_id, + account->incoming_server_address, + account->outgoing_server_address, + account->default_mail_slot_size, + account->sync_status, + account->sync_disabled, + is_preset_account, + index_color, + account->certificate_path, + account->digest_type ); err_code = email_free_account(&account, 1); + testapp_print ("\n----------------------------------------------------------\n"); testapp_print ("email_get_account WITHOUT_OPTION \n"); - if( (err_code = email_get_account(account_id,WITHOUT_OPTION,&account)) < 0) { + if( (err_code = email_get_account(account_id, WITHOUT_OPTION, &account)) < 0) { testapp_print ("email_get_account failed \n"); return FALSE; } - else - testapp_print ("email_get_account result account_name - %s \n email_addr - %s \n use_security %d \n add_sig : %d \n ", + + testapp_print ("email_get_account result\n" + "account_name - %s \n" + "user_email_address - %s \n" + "incoming_server_secure_connection %d \n" + "add_signature : %d \n", account->account_name, - account->email_addr, - account->use_security, - account->options.add_signature); + account->user_email_address, + account->incoming_server_secure_connection, + account->options.add_signature + ); if(account->options.signature) - testapp_print ("signature : %s \n", account->options.signature); + testapp_print ("signature : %s\n", account->options.signature); else testapp_print ("signature not retrieved \n"); err_code = email_free_account(&account, 1); + testapp_print ("\n----------------------------------------------------------\n"); testapp_print ("email_get_account ONLY_OPTION \n"); - if( (err_code = email_get_account(account_id,ONLY_OPTION,&account)) < 0) { + if( (err_code = email_get_account(account_id, ONLY_OPTION, &account)) < 0) { testapp_print ("email_get_account failed \n"); return FALSE; } - else - testapp_print ("email_get_account result add_sig : %d \n signature %s \n add_my_address_to_bcc %d\n my_account_id %d\n", + + testapp_print ("email_get_account result\n" + "add_sig : %d \n" + "signature %s \n" + "add_my_address_to_bcc %d\n" + "account_svc_id %d\n", account->options.add_signature, account->options.signature, account->options.add_my_address_to_bcc, - account->my_account_id + account->account_svc_id ); if(account->account_name) @@ -510,10 +582,10 @@ static gboolean testapp_test_get_account() else testapp_print ("account_name not retrieved \n"); - if(account->email_addr) - testapp_print ("email_addr : %s \n", account->email_addr); + if(account->user_email_address) + testapp_print ("user_email_address : %s \n", account->user_email_address); else - testapp_print ("email_addr not retrieved \n"); + testapp_print ("user_email_address not retrieved \n"); err_code = email_free_account(&account, 1); return FALSE; @@ -523,10 +595,10 @@ static gboolean testapp_test_get_account_list () { int count, i; - emf_account_t *account_list=NULL; + email_account_t *account_list=NULL; struct timeval tv_1, tv_2; int interval; - int err_code = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; gettimeofday(&tv_1, NULL); @@ -542,7 +614,7 @@ static gboolean testapp_test_get_account_list () for(i=0;iservice_name); return FALSE; } @@ -601,6 +675,113 @@ static gboolean testapp_test_clear_all_notification() testapp_print("email_clear_all_notification_bar returned [%d]\n",error_code); return FALSE; } + +static gboolean testapp_test_save_default_account_id() +{ + int result_from_scanf = 0; + int error_code; + int account_id = 0; + + testapp_print ("\nInput default account id : "); + + result_from_scanf = scanf("%d", &account_id); + + error_code = email_save_default_account_id(account_id); + + testapp_print("email_save_default_account_id returned [%d]\n",error_code); + return FALSE; +} + +static gboolean testapp_test_load_default_account_id() +{ + int error_code; + int account_id = 0; + + error_code = email_load_default_account_id(&account_id); + + testapp_print ("\ndefault account id : %d\n", account_id); + testapp_print("email_load_default_account_id returned [%d]\n",error_code); + return FALSE; +} + +static gboolean testapp_test_add_certificate() +{ + int result_from_scanf = 0; + int ret = 0; + char save_name[50] = {0, }; + char certificate_path[255] = {0, }; + + testapp_print("Input cert path : "); + result_from_scanf = scanf("%s", certificate_path); + + testapp_print("Input cert email-address : "); + result_from_scanf = scanf("%s", save_name); + + testapp_print("cert path : [%s]", certificate_path); + testapp_print("email-address : [%s]", save_name); + + ret = email_add_certificate(certificate_path, save_name); + if (ret != EMAIL_ERROR_NONE) { + testapp_print("Add certificate failed\n"); + return false; + } + + testapp_print("Add certificate success\n"); + return true; +} + +static gboolean testapp_test_get_certificate() +{ + int result_from_scanf = 0; + int ret = 0; + char save_name[20] = {0, }; + email_certificate_t *certificate = NULL; + + testapp_print("Input cert email-address : "); + result_from_scanf = scanf("%s", save_name); + + ret = email_get_certificate(save_name, &certificate); + if (ret != EMAIL_ERROR_NONE) { + testapp_print("Get certificate failed\n"); + return false; + } + + testapp_print("certificate_id : %d\n", certificate->certificate_id); + testapp_print("issue_year : %d\n", certificate->issue_year); + testapp_print("issue_month : %d\n", certificate->issue_month); + testapp_print("issue_day : %d\n", certificate->issue_day); + testapp_print("expiration_year : %d\n", certificate->expiration_year); + testapp_print("expiration_month : %d\n", certificate->expiration_month); + testapp_print("expiration_day : %d\n", certificate->expiration_day); + testapp_print("issue_organization_name : %s\n", certificate->issue_organization_name); + testapp_print("subject_string : %s\n", certificate->subject_str); + testapp_print("file path : %s\n", certificate->filepath); + + if (certificate) + email_free_certificate(&certificate, 1); + + testapp_print("Get certificate success\n"); + return true; +} + +static gboolean testapp_test_delete_certificate() +{ + int result_from_scanf = 0; + int ret = 0; + char save_name[20] = {0, }; + + testapp_print("Input cert email-address : "); + result_from_scanf = scanf("%s", save_name); + + ret = email_delete_certificate(save_name); + if (ret != EMAIL_ERROR_NONE) { + testapp_print("Delete certificate failed\n"); + return false; + } + + testapp_print("Delete certificate success\n"); + return true; +} static gboolean testapp_test_interpret_command (int selected_number) { gboolean go_to_loop = TRUE; @@ -609,12 +790,15 @@ static gboolean testapp_test_interpret_command (int selected_number) case 1: testapp_test_create_account(); break; + case 2: testapp_test_update_account(); break; + case 3: testapp_test_delete_account(); break; + case 4: testapp_test_get_account(); break; @@ -651,6 +835,26 @@ static gboolean testapp_test_interpret_command (int selected_number) testapp_test_clear_all_notification(); break; + case 14: + testapp_test_save_default_account_id(); + break; + + case 15: + testapp_test_load_default_account_id(); + break; + + case 16: + testapp_test_add_certificate(); + break; + + case 17: + testapp_test_get_certificate(); + break; + + case 18: + testapp_test_delete_certificate(); + break; + case 0: go_to_loop = FALSE; break; @@ -666,12 +870,13 @@ void testapp_account_main () { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_ACCOUNT_MENU); - testapp_show_prompt (EMF_ACCOUNT_MENU); + testapp_show_menu (EMAIL_ACCOUNT_MENU); + testapp_show_prompt (EMAIL_ACCOUNT_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf ("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-mail.c b/utilities/test-application/testapp-mail.c index 219480e..b7870af 100755 --- a/utilities/test-application/testapp-mail.c +++ b/utilities/test-application/testapp-mail.c @@ -35,34 +35,36 @@ #include "email-api-network.h" #include "email-api-mail.h" #include "email-api-mailbox.h" +#include "email-api-etc.h" /* internal header */ #include "testapp-utility.h" #include "testapp-mail.h" #include "email-core-utils.h" +#include "email-core-mime.h" #define MAIL_TEMP_BODY "/tmp/mail.txt" /* static void testapp_test_print_sorting_menu() { - testapp_print(" EMF_SORT_DATETIME_HIGH = 0\n"); - testapp_print(" EMF_SORT_DATETIME_LOW = 1\n"); - testapp_print(" EMF_SORT_SENDER_HIGH = 2\n"); - testapp_print(" EMF_SORT_SENDER_LOW = 3\n"); - testapp_print(" EMF_SORT_RCPT_HIGH = 4\n"); - testapp_print(" EMF_SORT_RCPT_LOW = 5\n"); - testapp_print(" EMF_SORT_SUBJECT_HIGH = 6\n"); - testapp_print(" EMF_SORT_SUBJECT_LOW = 7\n"); - testapp_print(" EMF_SORT_PRIORITY_HIGH = 8\n"); - testapp_print(" EMF_SORT_PRIORITY_LOW = 9\n"); - testapp_print(" EMF_SORT_ATTACHMENT_HIGH = 10\n"); - testapp_print(" EMF_SORT_ATTACHMENT_LOW = 11\n"); - testapp_print(" EMF_SORT_FAVORITE_HIGH = 12\n"); - testapp_print(" EMF_SORT_FAVORITE_LOW = 13\n"); + testapp_print(" EMAIL_SORT_DATETIME_HIGH = 0\n"); + testapp_print(" EMAIL_SORT_DATETIME_LOW = 1\n"); + testapp_print(" EMAIL_SORT_SENDER_HIGH = 2\n"); + testapp_print(" EMAIL_SORT_SENDER_LOW = 3\n"); + testapp_print(" EMAIL_SORT_RCPT_HIGH = 4\n"); + testapp_print(" EMAIL_SORT_RCPT_LOW = 5\n"); + testapp_print(" EMAIL_SORT_SUBJECT_HIGH = 6\n"); + testapp_print(" EMAIL_SORT_SUBJECT_LOW = 7\n"); + testapp_print(" EMAIL_SORT_PRIORITY_HIGH = 8\n"); + testapp_print(" EMAIL_SORT_PRIORITY_LOW = 9\n"); + testapp_print(" EMAIL_SORT_ATTACHMENT_HIGH = 10\n"); + testapp_print(" EMAIL_SORT_ATTACHMENT_LOW = 11\n"); + testapp_print(" EMAIL_SORT_FAVORITE_HIGH = 12\n"); + testapp_print(" EMAIL_SORT_FAVORITE_LOW = 13\n"); } -static void testapp_test_print_mail_list_item(emf_mail_list_item_t *mail_list_item, int count) +static void testapp_test_print_mail_list_item(email_mail_list_item_t *mail_list_item, int count) { int i; @@ -107,41 +109,44 @@ static void testapp_test_print_mail_list_item(emf_mail_list_item_t *mail_list_it static gboolean testapp_test_add_mail (int *result_mail_id) { + int result_from_scanf = 0; int i = 0; int account_id = 0; + int mailbox_id = 0; int from_eas = 0; int attachment_count = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + int smime_type = 0; char arg[50] = { 0 , }; const char *body_file_path = MAIL_TEMP_BODY; - emf_mailbox_t *mailbox_data = NULL; - emf_mail_data_t *test_mail_data = NULL; - emf_attachment_data_t *attachment_data = NULL; - emf_meeting_request_t *meeting_req = NULL; + email_mailbox_t *mailbox_data = NULL; + email_mail_data_t *test_mail_data = NULL; + email_attachment_data_t *attachment_data = NULL; + email_meeting_request_t *meeting_req = NULL; FILE *body_file; testapp_print("\n > Enter account id : "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); memset(arg, 0x00, 50); - testapp_print("\n > Enter mailbox name : "); - scanf("%s", arg); + testapp_print("\n > Enter mailbox id : "); + result_from_scanf = scanf("%d", &mailbox_id); - email_get_mailbox_by_name(account_id, arg, &mailbox_data); + email_get_mailbox_by_mailbox_id(mailbox_id, &mailbox_data); - test_mail_data = malloc(sizeof(emf_mail_data_t)); - memset(test_mail_data, 0x00, sizeof(emf_mail_data_t)); + test_mail_data = malloc(sizeof(email_mail_data_t)); + memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); testapp_print("\n Sync server? [0/1]> "); - scanf("%d", &from_eas); + result_from_scanf = scanf("%d", &from_eas); test_mail_data->account_id = account_id; test_mail_data->save_status = 1; test_mail_data->body_download_status = 1; test_mail_data->flags_seen_field = 1; test_mail_data->file_path_plain = strdup(body_file_path); - test_mail_data->mailbox_name = strdup(mailbox_data->name); + test_mail_data->mailbox_id = mailbox_id; test_mail_data->mailbox_type = mailbox_data->mailbox_type; test_mail_data->full_address_from = strdup(""); test_mail_data->full_address_to = strdup(""); @@ -157,51 +162,58 @@ static gboolean testapp_test_add_mail (int *result_mail_id) testapp_print("\n fopen [%s]failed\n", body_file_path); return FALSE; } - +/* for(i = 0; i < 500; i++) fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2"); +*/ + fprintf(body_file, "Hello world"); fflush(body_file); fclose(body_file); + + testapp_print(" > Select smime? [0: Normal, 1: sign, 2: Encrpyt, 3: sing + encrypt] : "); + result_from_scanf = scanf("%d", &smime_type); + test_mail_data->smime_type = smime_type; - testapp_print(" > Attach file? [0/1] : "); - scanf("%d",&attachment_count); + testapp_print(" > How many file attachment? [>=0] : "); + result_from_scanf = scanf("%d",&attachment_count); - if ( attachment_count ) { + test_mail_data->attachment_count = attachment_count; + if ( attachment_count > 0 ) + attachment_data = calloc(attachment_count, sizeof(email_attachment_data_t)); + + + for ( i = 0; i < attachment_count ; i++ ) { memset(arg, 0x00, 50); testapp_print("\n > Enter attachment name : "); - scanf("%s", arg); + result_from_scanf = scanf("%s", arg); - attachment_data = malloc(sizeof(emf_attachment_data_t)); - - attachment_data->attachment_name = strdup(arg); + attachment_data[i].attachment_name = strdup(arg); memset(arg, 0x00, 50); testapp_print("\n > Enter attachment absolute path : "); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); - attachment_data->attachment_path = strdup(arg); - attachment_data->save_status = 1; - test_mail_data->attachment_count = attachment_count; + attachment_data[i].attachment_path = strdup(arg); + attachment_data[i].save_status = 1; + attachment_data[i].mailbox_id = test_mail_data->mailbox_id; } testapp_print("\n > Meeting Request? [0: no, 1: yes (request from server), 2: yes (response from local)]"); - scanf("%d", &(test_mail_data->meeting_request_status)); + result_from_scanf = scanf("%d", &(test_mail_data->meeting_request_status)); if ( test_mail_data->meeting_request_status == 1 || test_mail_data->meeting_request_status == 2 ) { time_t current_time; /* dummy data for meeting request */ - meeting_req = malloc(sizeof(emf_meeting_request_t)); - memset(meeting_req, 0x00, sizeof(emf_meeting_request_t)); + meeting_req = malloc(sizeof(email_meeting_request_t)); + memset(meeting_req, 0x00, sizeof(email_meeting_request_t)); meeting_req->meeting_response = 1; current_time = time(NULL); gmtime_r(¤t_time, &(meeting_req->start_time)); gmtime_r(¤t_time, &(meeting_req->end_time)); - meeting_req->location = malloc(strlen("Seoul") + 1); - memset(meeting_req->location, 0x00, strlen("Seoul") + 1); - strcpy(meeting_req->location, "Seoul"); - strcpy(meeting_req->global_object_id, "abcdef12345"); + meeting_req->location = strdup("Seoul"); + meeting_req->global_object_id = strdup("abcdef12345"); meeting_req->time_zone.offset_from_GMT = 9; strcpy(meeting_req->time_zone.standard_name, "STANDARD_NAME"); @@ -214,7 +226,7 @@ static gboolean testapp_test_add_mail (int *result_mail_id) } - if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMF_ERROR_NONE) + if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE) testapp_print("email_add_mail failed. [%d]\n", err); else testapp_print("email_add_mail success.\n"); @@ -238,45 +250,46 @@ static gboolean testapp_test_add_mail (int *result_mail_id) static gboolean testapp_test_update_mail() { + int result_from_scanf = 0; int mail_id = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int test_attachment_data_count = 0; char arg[50]; - emf_mail_data_t *test_mail_data = NULL; - emf_attachment_data_t *test_attachment_data_list = NULL; - emf_meeting_request_t *meeting_req = NULL; + email_mail_data_t *test_mail_data = NULL; + email_attachment_data_t *test_attachment_data_list = NULL; + email_meeting_request_t *meeting_req = NULL; testapp_print("\n > Enter mail id : "); - scanf("%d", &mail_id); + result_from_scanf = scanf("%d", &mail_id); email_get_mail_data(mail_id, &test_mail_data); testapp_print("\n > Enter Subject: "); - scanf("%s", arg); + result_from_scanf = scanf("%s", arg); test_mail_data->subject= strdup(arg); if (test_mail_data->attachment_count > 0) { - if ( (err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMF_ERROR_NONE ) { + if ( (err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMAIL_ERROR_NONE ) { testapp_print("email_get_meeting_request() failed [%d]\n", err); return FALSE; } } - if ( test_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_REQUEST - || test_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_RESPONSE - || test_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { + if ( test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST + || test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE + || test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { - if ( (err = email_get_meeting_request(mail_id, &meeting_req)) != EMF_ERROR_NONE ) { + if ( (err = email_get_meeting_request(mail_id, &meeting_req)) != EMAIL_ERROR_NONE ) { testapp_print("email_get_meeting_request() failed [%d]\n", err); return FALSE; } testapp_print("\n > Enter meeting response: "); - scanf("%d", (int*)&(meeting_req->meeting_response)); + result_from_scanf = scanf("%d", (int*)&(meeting_req->meeting_response)); } - if ( (err = email_update_mail(test_mail_data, test_attachment_data_list, test_attachment_data_count, meeting_req, 0)) != EMF_ERROR_NONE) + if ( (err = email_update_mail(test_mail_data, test_attachment_data_list, test_attachment_data_count, meeting_req, 0)) != EMAIL_ERROR_NONE) testapp_print("email_update_mail failed.[%d]\n", err); else testapp_print("email_update_mail success\n"); @@ -296,39 +309,40 @@ static gboolean testapp_test_update_mail() static gboolean testapp_test_get_mails() { testapp_print("\n >>> testapp_test_get_mails : Entered \n"); - emf_mail_data_t *mails = NULL, **mails_pointer = NULL; - char mailbox_name[50] = { 0, }; + email_mail_data_t *mails = NULL, **mails_pointer = NULL; + int mailbox_id = 0; int count = 0, i = 0; int account_id = 0; int start_index =0; int limit_count = 0; int sorting = 0; - int err_code = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; int to_get_count = 0; int is_for_thread_view = 0; int list_type; + int result_from_scanf = 0; struct tm *temp_time_info; testapp_print("\n > Enter Account_id (0 = all accounts) : "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); - testapp_print("\n > Enter Mailbox name (0 = all mailboxes) :"); - scanf("%s", mailbox_name); + testapp_print("\n > Enter Mailbox id (0 = all mailboxes) :"); + result_from_scanf = scanf("%d", &mailbox_id); testapp_print("\n > Enter Sorting : "); - scanf("%d",&sorting); + result_from_scanf = scanf("%d",&sorting); - testapp_print("\n > Enter Start index : "); - scanf("%d",&start_index); + testapp_print("\n > Enter Start index (starting at 0): "); + result_from_scanf = scanf("%d",&start_index); testapp_print("\n > Enter max_count : "); - scanf("%d",&limit_count); + result_from_scanf = scanf("%d",&limit_count); testapp_print("\n > For thread view : "); - scanf("%d",&is_for_thread_view); + result_from_scanf = scanf("%d",&is_for_thread_view); - testapp_print("\n > To get count : "); - scanf("%d",&to_get_count); + testapp_print("\n > Mail count only (0:list 1:count): "); + result_from_scanf = scanf("%d",&to_get_count); if(to_get_count) mails_pointer = NULL; @@ -336,23 +350,23 @@ static gboolean testapp_test_get_mails() mails_pointer = &mails; if(is_for_thread_view == -2) { - list_type = EMF_LIST_TYPE_LOCAL; + list_type = EMAIL_LIST_TYPE_LOCAL; } else if(is_for_thread_view == -1) - list_type = EMF_LIST_TYPE_THREAD; + list_type = EMAIL_LIST_TYPE_THREAD; else - list_type = EMF_LIST_TYPE_NORMAL; + list_type = EMAIL_LIST_TYPE_NORMAL; /* Get mail list */ - if(strcmp(mailbox_name, "0") == 0) { - testapp_print("Calling email_get_mail_list_ex for all mailbox.\n"); - err_code = email_get_mails(account_id, NULL, list_type, start_index, limit_count, sorting, mails_pointer, &count); + if(mailbox_id == 0) { + testapp_print("Calling email_get_mail_list for all mailbox.\n"); + err_code = email_get_mails(account_id, 0, list_type, start_index, limit_count, sorting, mails_pointer, &count); if ( err_code < 0) testapp_print("email_get_mails failed - err[%d]\n", err_code); } else { - testapp_print("Calling email_get_mail_list_ex for %s mailbox.\n", mailbox_name); - err_code = email_get_mails(account_id, mailbox_name, list_type, start_index, limit_count, sorting, mails_pointer, &count); + testapp_print("Calling email_get_mail_list for %d mailbox_id.\n", mailbox_id); + err_code = email_get_mails(account_id, mailbox_id, list_type, start_index, limit_count, sorting, mails_pointer, &count); if ( err_code < 0) testapp_print("email_get_mails failed - err[%d]\n", err_code); } @@ -361,7 +375,7 @@ static gboolean testapp_test_get_mails() if (mails) { for (i=0; i< count; i++) { testapp_print("\n[%d]\n", i); - testapp_print(" >>> mailbox_name [ %s ] \n", mails[i].mailbox_name); + testapp_print(" >>> mailbox_id [ %d ] \n", mails[i].mailbox_id); testapp_print(" >>> mail_id [ %d ] \n", mails[i].mail_id); testapp_print(" >>> account_id [ %d ] \n", mails[i].account_id); if ( mails[i].full_address_from != NULL ) @@ -372,7 +386,13 @@ static gboolean testapp_test_get_mails() testapp_print(" >>> subject [ %s ] \n", mails[i].subject); testapp_print(" >>> body_download_status [ %d ] \n", mails[i].body_download_status); temp_time_info = localtime(&mails[i].date_time); - testapp_print(" >>> date_time [ %d/%d/%d %d:%d:%d] \n", temp_time_info->tm_year + 1970, temp_time_info->tm_mon, temp_time_info->tm_mday, temp_time_info->tm_hour, temp_time_info->tm_min, temp_time_info->tm_sec); + testapp_print(" >>> date_time [ %d/%d/%d %d:%d:%d] \n", + temp_time_info->tm_year + 1900, + temp_time_info->tm_mon+1, + temp_time_info->tm_mday, + temp_time_info->tm_hour, + temp_time_info->tm_min, + temp_time_info->tm_sec); testapp_print(" >>> flags_seen_field [ %d ] \n", mails[i].flags_seen_field); testapp_print(" >>> priority [ %d ] \n", mails[i].priority); testapp_print(" >>> save_status [ %d ] \n", mails[i].save_status); @@ -393,25 +413,25 @@ static gboolean testapp_test_get_mails() static gboolean testapp_test_mail_send (int *result_mail_id) { int added_mail_id = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; unsigned handle = 0; - emf_option_t option = { 0 }; - emf_mailbox_t mailbox_data = { 0 }; - emf_mail_data_t *result_mail_data = NULL; + email_option_t option = { 0 }; + email_mailbox_t mailbox_data = { 0 }; + email_mail_data_t *result_mail_data = NULL; testapp_test_add_mail(&added_mail_id); if(result_mail_id) { email_get_mail_data(added_mail_id, &result_mail_data); - memset(&mailbox_data, 0x00, sizeof(emf_mailbox_t)); - mailbox_data.account_id = result_mail_data->account_id; - mailbox_data.name = result_mail_data->mailbox_name; - option.keep_local_copy = 1; + memset(&mailbox_data, 0x00, sizeof(email_mailbox_t)); + mailbox_data.account_id = result_mail_data->account_id; + mailbox_data.mailbox_id = result_mail_data->mailbox_id; + option.keep_local_copy = 1; testapp_print("Calling email_send_mail...\n"); - if( email_send_mail(&mailbox_data, added_mail_id, &option, &handle) < 0) { + if( email_send_mail(added_mail_id, &option, &handle) < 0) { testapp_print("Sending failed[%d]\n", err); } else { @@ -427,6 +447,104 @@ static gboolean testapp_test_mail_send (int *result_mail_id) return FALSE; } +static gboolean testapp_test_get_mail_list() +{ + email_list_filter_t *filter_list = NULL; + email_list_sorting_rule_t *sorting_rule_list = NULL; + email_mail_list_item_t *result_mail_list = NULL; + int result_mail_count = 0; + int err = EMAIL_ERROR_NONE; + int i = 0; + + filter_list = malloc(sizeof(email_list_filter_t) * 9); + memset(filter_list, 0 , sizeof(email_list_filter_t) * 9); + + filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT; + filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[0].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[0].list_filter_item.rule.case_sensitivity = false; + + filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + + filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_TO; + filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[2].list_filter_item.rule.case_sensitivity = false; + + filter_list[3].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[3].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + + filter_list[4].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[4].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_CC; + filter_list[4].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[4].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[4].list_filter_item.rule.case_sensitivity = false; + + filter_list[5].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[5].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + + filter_list[6].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[6].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_BCC; + filter_list[6].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[6].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[6].list_filter_item.rule.case_sensitivity = false; + + filter_list[7].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[7].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + + filter_list[8].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[8].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_FROM; + filter_list[8].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[8].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[8].list_filter_item.rule.case_sensitivity = false; + + /* + filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID; + 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 = 1; + + filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_AND; + + filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME; + filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("INBOX"); + filter_list[2].list_filter_item.rule.case_sensitivity = true; + */ + + sorting_rule_list = malloc(sizeof(email_list_sorting_rule_t) * 2); + memset(sorting_rule_list, 0 , sizeof(email_list_sorting_rule_t) * 2); + + sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_ATTACHMENT_COUNT; + sorting_rule_list[0].sort_order = EMAIL_SORT_ORDER_ASCEND; + sorting_rule_list[0].force_boolean_check = true; + + sorting_rule_list[1].target_attribute = EMAIL_MAIL_ATTRIBUTE_DATE_TIME; + sorting_rule_list[1].sort_order = EMAIL_SORT_ORDER_ASCEND; + + err = email_get_mail_list_ex(filter_list, 9, sorting_rule_list, 2, -1, -1, &result_mail_list, &result_mail_count); + + if(err == EMAIL_ERROR_NONE) { + testapp_print("email_get_mail_list_ex succeed.\n"); + + for(i = 0; i < result_mail_count; i++) { + testapp_print("mail_id [%d], subject [%s], from [%s]\n", result_mail_list[i].mail_id, result_mail_list[i].subject, result_mail_list[i].from); + } + } + else { + testapp_print("email_get_mail_list_ex failed.\n"); + } + + email_free_list_filter(&filter_list, 9); + + return FALSE; +} + static gboolean testapp_test_send_cancel () { int num = 0; @@ -435,9 +553,10 @@ static gboolean testapp_test_send_cancel () int j = 0; int *mailIdList = NULL; int mail_id = 0; + int result_from_scanf = 0; testapp_print("\n > Enter total Number of mail want to send: "); - scanf("%d", &num); + result_from_scanf = scanf("%d", &num); mailIdList = (int *)malloc(sizeof(int)*num); if(!mailIdList) return false ; @@ -452,15 +571,15 @@ static gboolean testapp_test_send_cancel () mail_id = 0; testapp_print("\n > Do you want to cancel the send mail job '1' or '0': "); - scanf("%d", &Y); + result_from_scanf = scanf("%d", &Y); if(Y == 1) { testapp_print("\n >Enter mail-id[1-%d] ",i); - scanf("%d", &j); + result_from_scanf = scanf("%d", &j); testapp_print("\n mailIdList[%d] ",mailIdList[j]); - if(email_cancel_send_mail( mailIdList[j]) < 0) - testapp_print("EmfMailSendCancel failed..!"); + if(email_cancel_sending_mail( mailIdList[j]) < 0) + testapp_print("email_cancel_sending_mail failed..!"); else - testapp_print("EmfMailSendCancel success..!"); + testapp_print("email_cancel_sending_mail success..!"); } } return FALSE; @@ -469,36 +588,29 @@ static gboolean testapp_test_send_cancel () static gboolean testapp_test_delete() { int mail_id=0, account_id =0; - emf_mailbox_t mbox = {0}; - char arg[10]; - int err = EMF_ERROR_NONE; + int mailbox_id = 0; + int err = EMAIL_ERROR_NONE; int from_server = 0; + int result_from_scanf = 0; testapp_print("\n > Enter Account_id: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter Mail_id: "); - scanf("%d",&mail_id); + result_from_scanf = scanf("%d", &mail_id); - testapp_print("\n > Enter Mailbox name: "); - scanf("%s",arg); + testapp_print("\n > Enter Mailbox id: "); + result_from_scanf = scanf("%d", &mailbox_id); testapp_print("\n > Enter from_server: "); - scanf("%d",&from_server); - - mbox.account_id = account_id; - mbox.name = strdup(arg); - + result_from_scanf = scanf("%d", &from_server); /* delete message */ - if( (err = email_delete_message(&mbox, &mail_id, 1, from_server)) < 0) - testapp_print("\n email_delete_message failed[%d]\n", err); + if( (err = email_delete_mail(mailbox_id, &mail_id, 1, from_server)) < 0) + testapp_print("\n email_delete_mail failed[%d]\n", err); else - testapp_print("\n email_delete_message success\n"); + testapp_print("\n email_delete_mail success\n"); - if ( mbox.name ) - free(mbox.name); - return FALSE; } @@ -507,50 +619,37 @@ static gboolean testapp_test_delete() static gboolean testapp_test_move() { int mail_id[3]; - int account_id =0; - emf_mailbox_t mbox; - char arg[10]; int i = 0; - - testapp_print("\n > Enter Account_id: "); - scanf("%d",&account_id); + int mailbox_id = 0; + int result_from_scanf = 0; for(i = 0; i< 3; i++) { - testapp_print("\n > Enter Mail_id: "); - scanf("%d",&mail_id[i]); + testapp_print("\n > Enter mail_id: "); + result_from_scanf = scanf("%d",&mail_id[i]); } - memset(&mbox, 0x00, sizeof(emf_mailbox_t)); - - testapp_print("\n > Enter Mailbox name: "); - scanf("%s",arg); - mbox.account_id = account_id; - mbox.name = strdup(arg); - /* move message */ - email_move_mail_to_mailbox(mail_id, 3, &mbox); + testapp_print("\n > Enter mailbox_id: "); + result_from_scanf = scanf("%d", &mailbox_id); + + /* move mail */ + email_move_mail_to_mailbox(mail_id, 3, mailbox_id); return FALSE; } static gboolean testapp_test_delete_all() { - int account_id =0; - emf_mailbox_t mbox = {0}; - char arg[100] = {0}; - int err = EMF_ERROR_NONE; - testapp_print("\n > Enter Account_id: "); - scanf("%d",&account_id); - - testapp_print("\n > Enter Mailbox name: "); - scanf("%s",arg); - - mbox.account_id = account_id; - mbox.name = strdup(arg); + int mailbox_id =0; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; + testapp_print("\n > Enter mailbox_id: "); + result_from_scanf = scanf("%d",&mailbox_id); + /* delete all message */ - if ( (err = email_delete_all_message_in_mailbox(&mbox, 0)) < 0) - testapp_print("email_delete_all_message_in_mailbox failed[%d]\n", err); + if ( (err = email_delete_all_mails_in_mailbox(mailbox_id, 0)) < 0) + testapp_print("email_delete_all_mails_in_mailbox failed [%d]\n", err); else - testapp_print("email_delete_all_message_in_mailbox Success\n"); + testapp_print("email_delete_all_mails_in_mailbox Success\n"); return FALSE; } @@ -558,41 +657,28 @@ static gboolean testapp_test_delete_all() static gboolean testapp_test_add_attachment() { - int account_id = 0; int mail_id = 0; + int result_from_scanf = 0; char arg[100]; - emf_mailbox_t mbox; - emf_attachment_info_t attachment; + email_attachment_data_t attachment; testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); - - testapp_print("\n > Enter Account_id: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d", &mail_id); - memset(arg, 0x00, 100); - testapp_print("\n > Enter Mailbox name: "); - scanf("%s",arg); - - memset(&mbox, 0x00, sizeof(emf_attachment_info_t)); - mbox.account_id = account_id; - mbox.name = strdup(arg); - - memset(&attachment, 0x00, sizeof(emf_attachment_info_t)); + memset(&attachment, 0x00, sizeof(email_attachment_data_t)); memset(arg, 0x00, 100); testapp_print("\n > Enter attachment name: "); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); - attachment.name = strdup(arg); + attachment.attachment_name = strdup(arg); memset(arg, 0x00, 100); testapp_print("\n > Enter attachment absolute path: "); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); - attachment.downloaded = true; - attachment.savename = strdup(arg); - attachment.next = NULL; - if(email_add_attachment( &mbox, mail_id, &attachment) < 0) + attachment.save_status = true; + attachment.attachment_path = strdup(arg); + if(email_add_attachment(mail_id, &attachment) < 0) testapp_print("email_add_attachment failed\n"); else testapp_print("email_add_attachment success\n"); @@ -602,42 +688,88 @@ static gboolean testapp_test_add_attachment() } +static gboolean testapp_test_set_deleted_flag() +{ + int index = 0; + int account_id = 0; + int mail_ids[100] = { 0, }; + int temp_mail_id = 0; + int err_code = EMAIL_ERROR_NONE; + int result_from_scanf = 0; + + testapp_print("\n >>> Input target account id: "); + result_from_scanf = scanf("%d", &account_id); + + do { + testapp_print("\n >>> Input target mail id ( Input 0 to terminate ) [MAX = 100]: "); + result_from_scanf = scanf("%d", &temp_mail_id); + mail_ids[index++] = temp_mail_id; + } while (temp_mail_id != 0); + + err_code = email_set_flags_field(account_id, mail_ids, index, EMAIL_FLAGS_DELETED_FIELD, 1, true); + testapp_print("email_set_flags_field returns - err[%d]\n", err_code); + + return 0; +} + +static gboolean testapp_test_expunge_mails_deleted_flagged() +{ + int mailbox_id = 0; + int on_server = 0; + int err_code = EMAIL_ERROR_NONE; + unsigned handle = 0; + int result_from_scanf = 0; + + testapp_print("\n >>> Input target mailbox id: "); + result_from_scanf = scanf("%d", &mailbox_id); + + testapp_print("\n >>> Expunge on server?: "); + result_from_scanf = scanf("%d", &on_server); + + err_code = email_expunge_mails_deleted_flagged(mailbox_id, on_server, &handle); + + testapp_print("email_expunge_mails_deleted_flagged returns - err[%d]\n", err_code); + + return 0; +} + static gboolean testapp_test_get_mail_list_ex() { testapp_print("\n >>> testapp_test_get_mail_list_ex : Entered \n"); - emf_mail_list_item_t *mail_list = NULL, **mail_list_pointer = NULL; - char mailbox_name[50] = { 0, }; + email_mail_list_item_t *mail_list = NULL, **mail_list_pointer = NULL; + int mailbox_id = 0; int count = 0, i = 0; int account_id = 0; int start_index =0; int limit_count = 0; int sorting = 0; - int err_code = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; int to_get_count = 0; int is_for_thread_view = 0; int list_type; struct tm *temp_time_info; + int result_from_scanf = 0; testapp_print("\n > Enter Account_id (0 = all accounts) : "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); - testapp_print("\n > Enter Mailbox name (0 = all mailboxes) :"); - scanf("%s", mailbox_name); + testapp_print("\n > Enter Mailbox id (0 = all mailboxes) :"); + result_from_scanf = scanf("%d", &mailbox_id); testapp_print("\n > Enter Sorting : "); - scanf("%d",&sorting); + result_from_scanf = scanf("%d",&sorting); - testapp_print("\n > Enter Start index : "); - scanf("%d",&start_index); + testapp_print("\n > Enter Start index (starting at 0): "); + result_from_scanf = scanf("%d",&start_index); testapp_print("\n > Enter max_count : "); - scanf("%d",&limit_count); + result_from_scanf = scanf("%d",&limit_count); testapp_print("\n > For thread view : "); - scanf("%d",&is_for_thread_view); + result_from_scanf = scanf("%d",&is_for_thread_view); - testapp_print("\n > To get count : "); - scanf("%d",&to_get_count); + testapp_print("\n > Count mails?(1: YES):"); + result_from_scanf = scanf("%d",&to_get_count); if(to_get_count) mail_list_pointer = NULL; @@ -645,32 +777,32 @@ static gboolean testapp_test_get_mail_list_ex() mail_list_pointer = &mail_list; if(is_for_thread_view == -2) { - list_type = EMF_LIST_TYPE_LOCAL; + list_type = EMAIL_LIST_TYPE_LOCAL; } else if(is_for_thread_view == -1) - list_type = EMF_LIST_TYPE_THREAD; + list_type = EMAIL_LIST_TYPE_THREAD; else - list_type = EMF_LIST_TYPE_NORMAL; + list_type = EMAIL_LIST_TYPE_NORMAL; /* Get mail list */ - if(strcmp(mailbox_name, "0") == 0) { - testapp_print("Calling email_get_mail_list_ex for all mailbox.\n"); - err_code = email_get_mail_list_ex(account_id, NULL, list_type, start_index, limit_count, sorting, mail_list_pointer, &count); + if( mailbox_id == 0) { + testapp_print("Calling email_get_mail_list for all mailbox.\n"); + err_code = email_get_mail_list(account_id, 0, list_type, start_index, limit_count, sorting, mail_list_pointer, &count); if ( err_code < 0) - testapp_print("email_get_mail_list_ex failed - err[%d]\n", err_code); + testapp_print("email_get_mail_list failed - err[%d]\n", err_code); } else { - testapp_print("Calling email_get_mail_list_ex for %s mailbox.\n", mailbox_name); - err_code = email_get_mail_list_ex(account_id, mailbox_name, list_type, start_index, limit_count, sorting, mail_list_pointer, &count); + testapp_print("Calling email_get_mail_list for %d mailbox_id.\n", mailbox_id); + err_code = email_get_mail_list(account_id, mailbox_id, list_type, start_index, limit_count, sorting, mail_list_pointer, &count); if ( err_code < 0) - testapp_print("email_get_mail_list_ex failed - err[%d]\n", err_code); + testapp_print("email_get_mail_list failed - err[%d]\n", err_code); } - testapp_print("email_get_mail_list_ex >>>>>>count - %d\n",count); + testapp_print("email_get_mail_list >>>>>>count - %d\n",count); if (mail_list) { for (i=0; i< count; i++) { testapp_print("\n[%d]\n", i); - testapp_print(" >>> mailbox_name [ %s ] \n", mail_list[i].mailbox_name); + testapp_print(" >>> mailbox_id [ %d ] \n", mail_list[i].mailbox_id); testapp_print(" >>> mail_id [ %d ] \n", mail_list[i].mail_id); testapp_print(" >>> account_id [ %d ] \n", mail_list[i].account_id); if ( mail_list[i].from != NULL ) @@ -681,7 +813,13 @@ static gboolean testapp_test_get_mail_list_ex() testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject); testapp_print(" >>> is_text_downloaded [ %d ] \n", mail_list[i].is_text_downloaded); temp_time_info = localtime(&mail_list[i].date_time); - testapp_print(" >>> date_time [ %d/%d/%d %d:%d:%d] \n", temp_time_info->tm_year + 1970, temp_time_info->tm_mon, temp_time_info->tm_mday, temp_time_info->tm_hour, temp_time_info->tm_min, temp_time_info->tm_sec); + testapp_print(" >>> date_time [ %d/%d/%d %d:%d:%d] \n", + temp_time_info->tm_year + 1900, + temp_time_info->tm_mon+1, + temp_time_info->tm_mday, + temp_time_info->tm_hour, + temp_time_info->tm_min, + temp_time_info->tm_sec); testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list[i].flags_seen_field); testapp_print(" >>> priority [ %d ] \n", mail_list[i].priority); testapp_print(" >>> save_status [ %d ] \n", mail_list[i].save_status); @@ -693,7 +831,7 @@ static gboolean testapp_test_get_mail_list_ex() free(mail_list); } - testapp_print("\n >>> email_get_mail_list_ex : End \n"); + testapp_print("\n >>> email_get_mail_list : End \n"); return 0; } @@ -701,24 +839,24 @@ static gboolean testapp_test_get_mail_list_ex() static gboolean testapp_test_get_mail_list_for_thread_view() { testapp_print(" >>> testapp_test_get_mail_list_for_thread_view : Entered \n"); - emf_mail_list_item_t *mail_list = NULL; + email_mail_list_item_t *mail_list = NULL; int count = 0, i = 0; int account_id = 0; - int err_code = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; struct tm *time_info; /* Get mail list */ - if ( email_get_mail_list_ex(account_id, NULL , EMF_LIST_TYPE_THREAD, 0, 500, EMF_SORT_DATETIME_HIGH, &mail_list, &count) < 0) { - testapp_print("email_get_mail_list_ex failed : %d\n",err_code); + if ( email_get_mail_list(account_id, 0 , EMAIL_LIST_TYPE_THREAD, 0, 500, EMAIL_SORT_DATETIME_HIGH, &mail_list, &count) < 0) { + testapp_print("email_get_mail_list failed : %d\n",err_code); return FALSE; } - testapp_print("email_get_mail_list_ex >>>>>>count - %d\n",count); + testapp_print("email_get_mail_list >>>>>>count - %d\n",count); if (mail_list) { for (i=0; i< count; i++) { testapp_print(" i [%d]\n", i); testapp_print(" >>> Mail ID [ %d ] \n", mail_list[i].mail_id); testapp_print(" >>> Account ID [ %d ] \n", mail_list[i].account_id); - testapp_print(" >>> Mailbox Name [ %s ] \n", mail_list[i].mailbox_name); + testapp_print(" >>> Mailbox id [ %d ] \n", mail_list[i].mailbox_id); testapp_print(" >>> From [ %s ] \n", mail_list[i].from); testapp_print(" >>> recipients [ %s ] \n", mail_list[i].recipients); testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject); @@ -742,83 +880,46 @@ static gboolean testapp_test_get_mail_list_for_thread_view() static gboolean testapp_test_count () { - emf_mailbox_t mailbox; - int account_id = 0; int total = 0; int unseen = 0; - char arg[50]; - - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - - testapp_print("\n > Enter account_id (0 means all accounts) : "); - scanf("%d", &account_id); - - if(account_id == 0) { - mailbox.name = NULL; - } - else { - testapp_print("\n > Enter maibox name: "); - scanf("%s", arg); - mailbox.name = strdup(arg); - } - - mailbox.account_id = account_id; - if(email_count_message(&mailbox, &total, &unseen) >= 0) - testapp_print("\n Total: %d, Unseen: %d \n", total, unseen); - - return TRUE; -} - -static gboolean testapp_test_modify_flag() -{ - emf_mail_flag_t newflag; - int mail_id = 0; - - memset(&newflag, 0x00, sizeof(emf_mail_flag_t)); - newflag.seen = 1; - newflag.answered = 0; - newflag.sticky = 1; - - testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); + email_list_filter_t *filter_list = NULL; - if(email_modify_mail_flag(mail_id, newflag, 1) < 0) - testapp_print("email_modify_mail_flag failed"); - else - testapp_print("email_modify_mail_flag success"); - - return TRUE; -} + filter_list = malloc(sizeof(email_list_filter_t) * 3); + memset(filter_list, 0 , sizeof(email_list_filter_t) * 3); -static gboolean testapp_test_modify_extra_flag () -{ - emf_extra_flag_t newflag; - int mail_id = 0; + filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT; + filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[0].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[0].list_filter_item.rule.case_sensitivity = false; - memset(&newflag, 0x00, sizeof(emf_extra_flag_t)); + filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; - testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); + filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_TO; + filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[2].list_filter_item.rule.case_sensitivity = false; - if( email_modify_extra_mail_flag(mail_id, newflag) < 0) - testapp_print("email_modify_extra_mail_flag failed"); - else - testapp_print("email_modify_extra_mail_flag success"); - return TRUE; + if(EMAIL_ERROR_NONE == email_count_mail(filter_list, 3, &total, &unseen)) + printf("\n Total: %d, Unseen: %d \n", total, unseen); + return 0; } static gboolean testapp_test_set_flags_field () { int account_id = 0; int mail_id = 0; + int result_from_scanf = 0; testapp_print("\n > Enter Account ID: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter Mail ID: "); - scanf("%d", &mail_id); + result_from_scanf = scanf("%d", &mail_id); - if(email_set_flags_field(account_id, &mail_id, 1, EMF_FLAGS_FLAGGED_FIELD, 1, 1) < 0) + if(email_set_flags_field(account_id, &mail_id, 1, EMAIL_FLAGS_FLAGGED_FIELD, 1, 1) < 0) testapp_print("email_set_flags_field failed"); else testapp_print("email_set_flags_field success"); @@ -829,25 +930,12 @@ static gboolean testapp_test_set_flags_field () static gboolean testapp_test_download_body () { int mail_id = 0; - int account_id = 0; - char arg[50]; unsigned handle = 0, err; - - emf_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); + int result_from_scanf = 0; - testapp_print("\n > Enter account_id: "); - scanf("%d", &account_id); - - testapp_print("\n > Enter maibox name: "); - scanf("%s", arg); - - mailbox.name = strdup(arg); - mailbox.account_id = account_id; - testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); - err = email_download_body(&mailbox, mail_id, 0, &handle); + result_from_scanf = scanf("%d", &mail_id); + err = email_download_body(mail_id, 0, &handle); if(err < 0) testapp_print("email_download_body failed"); else { @@ -863,35 +951,29 @@ static gboolean testapp_test_cancel_download_body () int mail_id = 0; int account_id = 0; int yes = 0; - char arg[50]; unsigned handle = 0; + int result_from_scanf = 0; - emf_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); + email_mailbox_t mailbox; + memset(&mailbox, 0x00, sizeof(email_mailbox_t)); testapp_print("\n > Enter account_id: "); - scanf("%d", &account_id); - - testapp_print("\n > Enter maibox name: "); - scanf("%s", arg); - - mailbox.name = strdup(arg); - mailbox.account_id = account_id; + result_from_scanf = scanf("%d", &account_id); - testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); + testapp_print("\n > Enter mail id: "); + result_from_scanf = scanf("%d", &mail_id); - if( email_download_body(&mailbox, mail_id, 0, &handle) < 0) + if( email_download_body(mail_id, 0, &handle) < 0) testapp_print("email_download_body failed"); else { testapp_print("email_download_body success\n"); testapp_print("Do u want to cancel download job>>>>>1/0\n"); - scanf("%d",&yes); + result_from_scanf = scanf("%d",&yes); if(1 == yes) { - if(email_cancel_job(account_id, handle) < 0) - testapp_print("EmfCancelJob failed..!"); + if(email_cancel_job(account_id, handle , EMAIL_CANCELED_BY_USER) < 0) + testapp_print("email_cancel_job failed..!"); else { - testapp_print("EmfCancelJob success..!"); + testapp_print("email_cancel_job success..!"); testapp_print("handle[%d]\n", handle); } } @@ -902,271 +984,74 @@ static gboolean testapp_test_cancel_download_body () static gboolean testapp_test_download_attachment () { int mail_id = 0; - int account_id = 0; - char arg[50]; + int attachment_no = 0; unsigned handle = 0; - - emf_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - - testapp_print("\n > Enter account_id: "); - scanf("%d", &account_id); - - memset(arg, 0x00, 50); - testapp_print("\n > Enter maibox name: "); - scanf("%s", arg); - - mailbox.name = strdup(arg); - mailbox.account_id = account_id; + int result_from_scanf = 0; testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); - - memset(arg, 0x00, 50); + result_from_scanf = scanf("%d", &mail_id); + testapp_print("\n > Enter attachment number: "); - scanf("%s",arg); + result_from_scanf = scanf("%d", &attachment_no); - if( email_download_attachment(&mailbox, mail_id, arg ,&handle) < 0) + if( email_download_attachment(mail_id, attachment_no ,&handle) < 0) testapp_print("email_download_attachment failed"); else { testapp_print("email_download_attachment success"); testapp_print("handle[%d]\n", handle); } return TRUE; + } static gboolean testapp_test_retry_send() { int mail_id = 0; int timeout = 0; + int result_from_scanf = 0; - emf_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); + email_mailbox_t mailbox; + memset(&mailbox, 0x00, sizeof(email_mailbox_t)); testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); + result_from_scanf = scanf("%d", &mail_id); testapp_print("\n > Enter timeout in seconds: "); - scanf("%d", &timeout); + result_from_scanf = scanf("%d", &timeout); - if( email_retry_send_mail(mail_id, timeout) < 0) - testapp_print("email_retry_send_mail failed"); + if( email_retry_sending_mail(mail_id, timeout) < 0) + testapp_print("email_retry_sending_mail failed"); return TRUE; } -static gboolean testapp_test_find() -{ - int i, account_id = 0, result_count; - char mailbox_name[255] = { 0, }, *mailbox_name_pointer = NULL, search_keyword[255] = { 0, }; - emf_mail_list_item_t *mail_list = NULL; - - testapp_print("\n > Enter account_id : "); - scanf("%d", &account_id); - - testapp_print("\n > Enter maibox name [0 means all mailboxes] : "); - scanf("%s", mailbox_name); - - if(strcmp(mailbox_name, "0") == 0) - mailbox_name_pointer = NULL; - else - mailbox_name_pointer = mailbox_name; - - testapp_print("\n > Enter Keyword : "); - scanf("%s", search_keyword); - - if(email_find_mail(account_id, mailbox_name_pointer, EMF_LIST_TYPE_NORMAL, EMF_SEARCH_FILTER_ALL , search_keyword, -1, -1, EMF_SORT_DATETIME_HIGH, &mail_list, &result_count) == EMF_ERROR_NONE) { - testapp_print("\n Result count [%d]", result_count); - for(i = 0; i < result_count; i++) { - testapp_print("\nmail_id[%d], from[%s], subject[%s]", mail_list[i].mail_id, mail_list[i].from, mail_list[i].subject); - } - } - - if(mail_list) - free(mail_list); - - return TRUE; -} - -static gboolean testapp_test_count_message_on_sending() -{ - emf_mailbox_t mailbox; - int total_count; - int err = EMF_ERROR_NONE; - char temp[128]; - - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - /* input mailbox information : need account_id and name */ - testapp_print("mail account id(0: All account)> "); - scanf("%d", &mailbox.account_id); - - testapp_print("mailbox_name(0 : NULL)> "); - scanf("%s", temp ); - if ( strcmp(temp, "0") == 0 ) { - mailbox.name = NULL; - } - else { - mailbox.name = malloc(strlen(temp) + 1); - if ( mailbox.name == NULL ) { - testapp_print("fail malloc\n"); - return false; - } - strcpy(mailbox.name, temp); - } - - err = email_count_message_on_sending(&mailbox, &total_count); - if ( err < 0 ) { - testapp_print(" fail email_count_message_on_sending: err[%d]\n", err); - } - else { - testapp_print(" success email_count_message_on_sending: # of messages on senging status : %d\n", total_count); - } - - if ( mailbox.name ) { - free(mailbox.name); - mailbox.name = NULL; - } - return false; -} - - static gboolean testapp_test_move_all_mails_to_mailbox() { - emf_mailbox_t src_mailbox; - emf_mailbox_t dest_mailbox; - int err = EMF_ERROR_NONE; - char temp[128]; - - memset(&src_mailbox, 0x00, sizeof(emf_mailbox_t)); - memset(&dest_mailbox, 0x00, sizeof(emf_mailbox_t)); - - /* input mailbox information : need account_id and name (src & dest) */ - testapp_print("src mail account id(0: All account)> "); - scanf("%d", &src_mailbox.account_id); - - testapp_print("src mailbox_name(0 : NULL)> "); - scanf("%s", temp ); - if ( strcmp(temp, "0") == 0 ) { - src_mailbox.name = NULL; - } - else { - src_mailbox.name = malloc(strlen(temp) + 1); - if ( src_mailbox.name == NULL ) { - testapp_print("fail malloc\n"); - return false; - } - strcpy(src_mailbox.name, temp); - } + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; + int src_mailbox_id; + int dest_mailbox_id; - /* Destination mailbox */ - testapp_print("dest mail account id> "); - scanf("%d", &dest_mailbox.account_id); - if ( dest_mailbox.account_id <= 0 ) { - testapp_print("Invalid dest account_id[%d]\n", dest_mailbox.account_id); - goto FINISH_OFF; - } + testapp_print("src mailbox id> "); + result_from_scanf = scanf("%d", &src_mailbox_id); - testapp_print("dest mailbox_name> "); - scanf("%s", temp); - if ( strcmp(temp, "") == 0 ) { - testapp_print("Invalid dest mailbox_name[%s]\n", temp); - goto FINISH_OFF; - } - else { - dest_mailbox.name = malloc(strlen(temp) + 1); - if ( dest_mailbox.name == NULL ) { - testapp_print("fail malloc\n"); - goto FINISH_OFF; - } - strcpy(dest_mailbox.name, temp); - } + testapp_print("dest mailbox id> "); + result_from_scanf = scanf("%d", &dest_mailbox_id); - err = email_move_all_mails_to_mailbox(&src_mailbox, &dest_mailbox); + err = email_move_all_mails_to_mailbox(src_mailbox_id, dest_mailbox_id); if ( err < 0 ) { - testapp_print(" fail email_move_all_mails_to_mailbox: err[%d]\n", err); + testapp_print("email_move_all_mails_to_mailbox failed: err[%d]\n", err); } else { - testapp_print(" success email_move_all_mails_to_mailbox: from [%d:%s] to [%d:%s]\n", src_mailbox.account_id, src_mailbox.name, dest_mailbox.account_id, dest_mailbox.name); + testapp_print("email_move_all_mails_to_mailbox suceeded\n"); } -FINISH_OFF: - if ( src_mailbox.name ) { - free(src_mailbox.name); - src_mailbox.name = NULL; - } - if ( dest_mailbox.name ) { - free(dest_mailbox.name); - dest_mailbox.name = NULL; - } return false; } -static gboolean testapp_test_count_message_with_draft_flag() -{ - emf_mailbox_t mailbox; - int total_count; - int err = EMF_ERROR_NONE; - char temp[128]; - - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - /* input mailbox information : need account_id and name */ - testapp_print("mail account id(0: All account)> "); - scanf("%d", &mailbox.account_id); - - testapp_print("mailbox_name(0 : NULL)> "); - scanf("%s", temp ); - if ( strcmp(temp, "0") == 0 ) { - mailbox.name = NULL; - } - else { - mailbox.name = malloc(strlen(temp) + 1); - if ( mailbox.name == NULL ) { - testapp_print("fail malloc\n"); - return false; - } - strcpy(mailbox.name, temp); - } - - err = email_count_message_with_draft_flag(&mailbox, &total_count); - - if ( err < 0) { - testapp_print(" fail email_count_message_with_draft_flag: err[%d]\n", err); - } - else { - testapp_print(" success email_count_message_with_draft_flag: # of messages with draft flag : %d\n", total_count); - } - - if ( mailbox.name ) { - free(mailbox.name); - mailbox.name = NULL; - } - return false; -} - -/* sowmya.kr@samsung.com, 01282010 - Changes to get latest unread mail id for given account */ -static gboolean testapp_test_get_latest_unread_mail_id() -{ - - int mail_id = 0,account_id = 0; - int err = EMF_ERROR_NONE; - - - testapp_print("Enter account Id to get latest unread mail Id,<-1 to get latest irrespective of account id> "); - scanf("%d", &account_id); - - err = email_get_latest_unread_mail_id(account_id, &mail_id); - if ( err < 0) { - testapp_print(" fail email_get_latest_unread_mail_id: err[%d]\n", err); - } - else { - testapp_print(" success email_get_latest_unread_mail_id: Latest unread mail id : %d\n", mail_id); - } - return FALSE; -} - static gboolean testapp_test_get_totaldiskusage() { unsigned long total_size = 0; - int err_code = EMF_ERROR_NONE ; + int err_code = EMAIL_ERROR_NONE ; err_code = email_get_disk_space_usage(&total_size); if ( err_code < 0) @@ -1181,7 +1066,8 @@ static gboolean testapp_test_get_totaldiskusage() static gboolean testapp_test_db_test() { - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; int mail_id; int account_id; char *to = NULL; @@ -1197,15 +1083,15 @@ static gboolean testapp_test_db_test() memset(bcc, 0x00, sizeof(to)); testapp_print("Input Mail id:\n"); - scanf("%d", &mail_id); + result_from_scanf = scanf("%d", &mail_id); testapp_print("Input Account id:\n"); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("Input TO field:\n"); - scanf("%s", to); + result_from_scanf = scanf("%s", to); testapp_print("Input CC field:\n"); - scanf("%s", cc); + result_from_scanf = scanf("%s", cc); testapp_print("Input BCC field:\n"); - scanf("%s", bcc); + result_from_scanf = scanf("%s", bcc); if ( emstorage_test(mail_id, account_id, to, cc, bcc, &err) == true ) { testapp_print(">> Saving Succeeded\n"); @@ -1228,7 +1114,7 @@ static gboolean testapp_test_address_format_check_test() int type; int index; int check_yn; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char *pAddress = NULL; char input_address[8096]; char *address_list[] = { @@ -1281,7 +1167,7 @@ static gboolean testapp_test_address_format_check_test() testapp_print("Select input method:\n"); testapp_print("1. Test data\n"); testapp_print("2. Keyboard\n"); - scanf("%d", &type); + result_from_scanf = scanf("%d", &type); switch ( type ) { case 1: @@ -1291,12 +1177,12 @@ static gboolean testapp_test_address_format_check_test() address_count++; } testapp_print("Choose address to be tested:[99:quit]\n"); - scanf("%d", &index); + result_from_scanf = scanf("%d", &index); if ( index == 99 ) break; testapp_print(">> [%d] Checking? (1:Yes, Other:No) [%s]\n", index, address_list[index]); - scanf("%d", &check_yn); + result_from_scanf = scanf("%d", &check_yn); if ( check_yn == 1 ) { pAddress = strdup(address_list[index]); if ( em_verify_email_address(pAddress, false, &err ) == true ) { @@ -1318,7 +1204,7 @@ static gboolean testapp_test_address_format_check_test() break; case 2: testapp_print("Input address: \n"); - scanf("%s", input_address); + result_from_scanf = scanf("%s", input_address); if ( em_verify_email_address(input_address, false, &err ) == true ) { testapp_print(">> Saving Succeeded : addr[%s]\n", input_address); } @@ -1337,7 +1223,7 @@ static gboolean testapp_test_address_format_check_test() static gboolean testapp_test_get_max_mail_count() { int max_count = -1; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; err = email_get_max_mail_count(&max_count); testapp_print("\n\t>>>>> email_get_max_mail_count() return [%d]\n\n", max_count); @@ -1349,9 +1235,9 @@ static gboolean testapp_test_get_max_mail_count() static gboolean testapp_test_test_get_thread_information() { int error_code, thread_id= 38; - emf_mail_list_item_t *result_mail; + email_mail_list_item_t *result_mail; - if( (error_code = email_get_thread_information_ex(thread_id, &result_mail)) == EMF_ERROR_NONE) { + if( (error_code = email_get_thread_information_ex(thread_id, &result_mail)) == EMAIL_ERROR_NONE) { testapp_print("email_get_thread_information returns = %d\n", error_code); testapp_print("subject = %s\n", result_mail->subject); testapp_print("mail_id = %d\n", result_mail->mail_id); @@ -1363,51 +1249,6 @@ static gboolean testapp_test_test_get_thread_information() return TRUE; } - -static gboolean testapp_test_get_sender_list() -{ - testapp_print(" >>> testapp_test_get_sender_list : Entered \n"); - - char *mailbox_name = NULL; - int i = 0; - int account_id = 0; - int sorting = 0; - int err_code = EMF_ERROR_NONE; - emf_sender_list_t *sender_list = NULL; - int sender_count = 0; - - mailbox_name = NULL; - account_id = 0; - sorting = 0; - - if ( (err_code = email_get_sender_list(account_id, mailbox_name, EMF_SEARCH_FILTER_NONE, NULL, sorting, &sender_list, &sender_count)) != EMF_ERROR_NONE) { - testapp_print("email_get_sender_list failed : %d\n",err_code); - return FALSE; - } - - testapp_print("===================================================\n"); - testapp_print("\t\t\tSender list\n"); - testapp_print("===================================================\n"); - testapp_print("sender address \tdisplay_name\t [unread/total]\n"); - testapp_print("===================================================\n"); - for ( i =0; i < sender_count; i++ ) { - testapp_print("[%s]\t[%s]\t[%d/%d]\n", sender_list[i].address, sender_list[i].display_name, sender_list[i].unread_count, sender_list[i].total_count); - } - testapp_print("===================================================\n"); - - if ( sender_list ) { - email_free_sender_list(&sender_list, sender_count); - } - if ( mailbox_name ) { - free(mailbox_name); - mailbox_name = NULL; - } - - testapp_print(" >>> testapp_test_get_sender_list : END \n"); - return TRUE; -} - - static gboolean testapp_test_get_address_info_list() { testapp_print(" >>> testapp_test_get_address_info_list : Entered \n"); @@ -1415,22 +1256,17 @@ static gboolean testapp_test_get_address_info_list() char buf[1024]; int i = 0; int mail_id = 0; - int err_code = EMF_ERROR_NONE; - emf_address_info_list_t *address_info_list= NULL; - emf_address_info_t *p_address_info = NULL; + int result_from_scanf = 0; + email_address_info_list_t *address_info_list= NULL; + email_address_info_t *p_address_info = NULL; GList *list = NULL; GList *node = NULL; memset(buf, 0x00, sizeof(buf)); testapp_print("\n > Enter mail_id: "); - scanf("%d",&mail_id); - + result_from_scanf = scanf("%d",&mail_id); - if ((err_code = email_get_address_info_list(mail_id, &address_info_list)) != EMF_ERROR_NONE) { - testapp_print("email_get_address_info_list failed : %d\n",err_code); - email_free_address_info_list(&address_info_list); - return FALSE; - } + email_get_address_info_list(mail_id, &address_info_list); testapp_print("===================================================\n"); testapp_print("\t\t\t address info list\n"); @@ -1438,18 +1274,18 @@ static gboolean testapp_test_get_address_info_list() testapp_print("address_type\t address \t\tdisplay_name\t contact id\n"); testapp_print("===================================================\n"); - for ( i = EMF_ADDRESS_TYPE_FROM; i <= EMF_ADDRESS_TYPE_BCC; i++ ) { + for ( i = EMAIL_ADDRESS_TYPE_FROM; i <= EMAIL_ADDRESS_TYPE_BCC; i++ ) { switch ( i ) { - case EMF_ADDRESS_TYPE_FROM: + case EMAIL_ADDRESS_TYPE_FROM: list = address_info_list->from; break; - case EMF_ADDRESS_TYPE_TO: + case EMAIL_ADDRESS_TYPE_TO: list = address_info_list->to; break; - case EMF_ADDRESS_TYPE_CC: + case EMAIL_ADDRESS_TYPE_CC: list = address_info_list->cc; break; - case EMF_ADDRESS_TYPE_BCC: + case EMAIL_ADDRESS_TYPE_BCC: list = address_info_list->bcc; break; } @@ -1457,7 +1293,7 @@ static gboolean testapp_test_get_address_info_list() /* delete dynamic-allocated memory for each item */ node = g_list_first(list); while ( node != NULL ) { - p_address_info = (emf_address_info_t*)node->data; + p_address_info = (email_address_info_t*)node->data; testapp_print("%d\t\t%s\t%s\t%d\n", p_address_info->address_type, p_address_info->address, p_address_info->display_name, p_address_info->contact_id); node = g_list_next(node); @@ -1466,30 +1302,32 @@ static gboolean testapp_test_get_address_info_list() } testapp_print("===================================================\n"); - email_free_address_info_list(&address_info_list); + if(address_info_list) + email_free_address_info_list(&address_info_list); testapp_print(" >>> testapp_test_get_address_info_list : END \n"); return TRUE; } -static gboolean testapp_test_find_mail_on_server() +static gboolean testapp_test_search_mail_on_server() { - testapp_print(" >>> testapp_test_find_mail_on_server : Entered \n"); + testapp_print(" >>> testapp_test_search_mail_on_server : Entered \n"); - int err_code = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; int account_id = 0; + int mailbox_id = 0; int search_key_value_integer = 0; + int result_from_scanf = 0; email_search_filter_type search_filter_type = 0; email_search_filter_t search_filter; unsigned int handle = 0; - char mailbox_name[MAILBOX_NAME_LENGTH]; char search_key_value_string[MAX_EMAIL_ADDRESS_LENGTH]; testapp_print("input account id : "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); - testapp_print("input mailbox name : "); - scanf("%s", mailbox_name); + testapp_print("input mailbox id : "); + result_from_scanf = scanf("%d", &mailbox_id); testapp_print( " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO = 1, ( integet type ) \n" @@ -1513,7 +1351,7 @@ static gboolean testapp_test_find_mail_on_server() " EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN = 36, ( integet type ) \n" " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID = 43, ( string type ) \n"); testapp_print("input search filter type : "); - scanf("%d", (int*)&search_filter_type); + result_from_scanf = scanf("%d", (int*)&search_filter_type); search_filter.search_filter_type = search_filter_type; @@ -1529,7 +1367,7 @@ static gboolean testapp_test_find_mail_on_server() case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT : case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN : testapp_print("input search filter key value : "); - scanf("%d", &search_key_value_integer); + result_from_scanf = scanf("%d", &search_key_value_integer); search_filter.search_filter_key_value.integer_type_key_value = search_key_value_integer; break; @@ -1541,7 +1379,7 @@ static gboolean testapp_test_find_mail_on_server() case EMAIL_SEARCH_FILTER_TYPE_TO : case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID : testapp_print("input search filter key value : "); - scanf("%s", search_key_value_string); + result_from_scanf = scanf("%s", search_key_value_string); search_filter.search_filter_key_value.string_type_key_value = search_key_value_string; break; @@ -1549,7 +1387,7 @@ static gboolean testapp_test_find_mail_on_server() case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON : case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE : testapp_print("input search filter key value (format = YYYYMMDDHHMMSS) : "); - scanf("%s", search_key_value_string); + result_from_scanf = scanf("%s", search_key_value_string); /* TODO : write codes for converting string to time */ /* search_filter.search_filter_key_value.time_type_key_value = search_key_value_string; */ break; @@ -1558,11 +1396,11 @@ static gboolean testapp_test_find_mail_on_server() return FALSE; } - if( (err_code = email_search_mail_on_server(account_id, mailbox_name, &search_filter,1, &handle)) != EMF_ERROR_NONE) { + if( (err_code = email_search_mail_on_server(account_id, mailbox_id, &search_filter,1, &handle)) != EMAIL_ERROR_NONE) { testapp_print("email_search_mail_on_server failed [%d]", err_code); } - testapp_print(" >>> testapp_test_find_mail_on_server : END \n"); + testapp_print(" >>> testapp_test_search_mail_on_server : END \n"); return TRUE; } @@ -1572,32 +1410,33 @@ static gboolean testapp_test_add_mail_to_search_result_box() int account_id = 0; int from_eas = 0; int attachment_count = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; char arg[50] = { 0 , }; char *body_file_path = MAIL_TEMP_BODY; - emf_mailbox_t *mailbox_data = NULL; - emf_mail_data_t *test_mail_data = NULL; - emf_attachment_data_t *attachment_data = NULL; - emf_meeting_request_t *meeting_req = NULL; + email_mailbox_t *mailbox_data = NULL; + email_mail_data_t *test_mail_data = NULL; + email_attachment_data_t *attachment_data = NULL; + email_meeting_request_t *meeting_req = NULL; FILE *body_file = NULL; testapp_print("\n > Enter account id : "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); - email_get_mailbox_by_name(account_id, EMF_SEARCH_RESULT_MAILBOX_NAME, &mailbox_data); + email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_SEARCH_RESULT, &mailbox_data); - test_mail_data = malloc(sizeof(emf_mail_data_t)); - memset(test_mail_data, 0x00, sizeof(emf_mail_data_t)); + test_mail_data = malloc(sizeof(email_mail_data_t)); + memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); testapp_print("\n From EAS? [0/1]> "); - scanf("%d", &from_eas); + result_from_scanf = scanf("%d", &from_eas); test_mail_data->account_id = account_id; test_mail_data->save_status = 1; test_mail_data->body_download_status = 1; test_mail_data->flags_seen_field = 1; test_mail_data->file_path_plain = strdup(body_file_path); - test_mail_data->mailbox_name = strdup(mailbox_data->name); + test_mail_data->mailbox_id = mailbox_data->mailbox_id; test_mail_data->mailbox_type = mailbox_data->mailbox_type; test_mail_data->full_address_from = strdup(""); test_mail_data->full_address_to = strdup(""); @@ -1613,20 +1452,20 @@ static gboolean testapp_test_add_mail_to_search_result_box() fclose(body_file); testapp_print(" > Attach file? [0/1] : "); - scanf("%d",&attachment_count); + result_from_scanf = scanf("%d",&attachment_count); if ( attachment_count ) { memset(arg, 0x00, 50); testapp_print("\n > Enter attachment name : "); - scanf("%s", arg); + result_from_scanf = scanf("%s", arg); - attachment_data = malloc(sizeof(emf_attachment_data_t)); + attachment_data = malloc(sizeof(email_attachment_data_t)); attachment_data->attachment_name = strdup(arg); memset(arg, 0x00, 50); testapp_print("\n > Enter attachment absolute path : "); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); attachment_data->attachment_path = strdup(arg); attachment_data->save_status = 1; @@ -1634,14 +1473,14 @@ static gboolean testapp_test_add_mail_to_search_result_box() } testapp_print("\n > Meeting Request? [0: no, 1: yes (request from server), 2: yes (response from local)]"); - scanf("%d", &(test_mail_data->meeting_request_status)); + result_from_scanf = scanf("%d", &(test_mail_data->meeting_request_status)); if ( test_mail_data->meeting_request_status == 1 || test_mail_data->meeting_request_status == 2 ) { time_t current_time; /* dummy data for meeting request */ - meeting_req = malloc(sizeof(emf_meeting_request_t)); - memset(meeting_req, 0x00, sizeof(emf_meeting_request_t)); + meeting_req = malloc(sizeof(email_meeting_request_t)); + memset(meeting_req, 0x00, sizeof(email_meeting_request_t)); meeting_req->meeting_response = 1; current_time = time(NULL); @@ -1663,7 +1502,7 @@ static gboolean testapp_test_add_mail_to_search_result_box() } - if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMF_ERROR_NONE) + if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE) testapp_print("email_add_mail failed. [%d]\n", err); else testapp_print("email_add_mail success.\n"); @@ -1682,6 +1521,67 @@ static gboolean testapp_test_add_mail_to_search_result_box() return FALSE; } +static gboolean testapp_test_email_load_eml_file() +{ + email_mail_data_t *mail_data = NULL; + email_attachment_data_t *mail_attachment_data = NULL; + int i = 0; + int attachment_count = 0; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; + char eml_file_path[255] = {0, }; + + testapp_print("Input eml file path : "); + result_from_scanf = scanf("%s", eml_file_path); + + if ((err = email_open_eml_file(eml_file_path, &mail_data, &mail_attachment_data, &attachment_count)) != EMAIL_ERROR_NONE) + { + testapp_print("email_open_eml_file failed : [%d]\n", err); + return false; + } + + testapp_print("load success\n"); + testapp_print("Return-Path: %s\n", mail_data->full_address_return); + testapp_print("To: %s\n", mail_data->full_address_to); + testapp_print("Subject: %s\n", mail_data->subject); + testapp_print("From: %s\n", mail_data->full_address_from); + testapp_print("Reply-To: %s\n", mail_data->full_address_reply); + testapp_print("Sender: %s\n", mail_data->email_address_sender); + testapp_print("Message-ID: %s\n", mail_data->message_id); + testapp_print("attachment_count: %d\n", mail_data->attachment_count); + testapp_print("inline content count : %d\n", mail_data->inline_content_count); + + for (i = 0;i < mail_data->attachment_count ; i++) { + testapp_print("attachment_id: %d\n", mail_attachment_data[i].attachment_id); + testapp_print("inline_attachment_status: %d\n", mail_attachment_data[i].inline_content_status); + testapp_print("attachment_name: %s\n", mail_attachment_data[i].attachment_name); + testapp_print("attachment_path: %s\n", mail_attachment_data[i].attachment_path); + testapp_print("mailbox_id: %d\n", mail_attachment_data[i].mailbox_id); + } + + testapp_print("Success : Open eml file\n"); + + if ((err = email_delete_eml_data(mail_data)) != EMAIL_ERROR_NONE) { + testapp_print("email_delete_eml_data failed : [%d]\n", err); + return false; + } + + testapp_print("Success : email_delete_eml_data\n"); + + if (mail_data) + email_free_mail_data(&mail_data, 1); + + testapp_print("Success : email_free_mail_data\n"); + + if (mail_attachment_data) + email_free_attachment_data(&mail_attachment_data, attachment_count); + + testapp_print("Success : email_free_attachment_data\n"); + + return true; + +} + /* internal functions */ static gboolean testapp_test_interpret_command (int menu_number) { @@ -1692,25 +1592,28 @@ static gboolean testapp_test_interpret_command (int menu_number) testapp_test_get_mails(); break; case 2: - testapp_test_mail_send (NULL); + testapp_test_mail_send(NULL); + break; + case 3: + testapp_test_get_mail_list(); break; case 4: testapp_test_add_attachment(); break; - case 9: - testapp_test_count (); + case 5: + testapp_test_set_deleted_flag(); break; - case 10: - testapp_test_modify_flag(); + case 6: + testapp_test_expunge_mails_deleted_flagged(); + break; + case 9: + testapp_test_count(); break; - case 11: - testapp_test_modify_extra_flag (); - break; case 14: - testapp_test_delete (); + testapp_test_delete(); break; case 16: - testapp_test_download_body (); + testapp_test_download_body(); break; case 17: testapp_test_download_attachment(); @@ -1724,21 +1627,9 @@ static gboolean testapp_test_interpret_command (int menu_number) case 23: testapp_test_retry_send(); break; - case 24: - testapp_test_find(); - break; - case 26: - testapp_test_count_message_on_sending(); - break; case 27: testapp_test_move_all_mails_to_mailbox(); break; - case 28: - testapp_test_count_message_with_draft_flag(); - break; - case 29: - testapp_test_get_latest_unread_mail_id(); - break; case 38: testapp_test_get_totaldiskusage(); break; @@ -1763,18 +1654,12 @@ static gboolean testapp_test_interpret_command (int menu_number) case 48: testapp_test_test_get_thread_information(); break; - case 49: - testapp_test_get_sender_list(); - break; case 51: testapp_test_get_mail_list_ex(); break; case 52: testapp_test_get_address_info_list(); break; - case 54: - email_get_recipients_list(1, NULL, NULL); - break; case 55: testapp_test_set_flags_field(); break; @@ -1785,11 +1670,14 @@ static gboolean testapp_test_interpret_command (int menu_number) testapp_test_update_mail(); break; case 58: - testapp_test_find_mail_on_server(); + testapp_test_search_mail_on_server(); break; case 59: testapp_test_add_mail_to_search_result_box(); break; + case 60: + testapp_test_email_load_eml_file(); + break; case 0: go_to_loop = FALSE; break; @@ -1804,12 +1692,13 @@ void testapp_mail_main() { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_MAIL_MENU); - testapp_show_prompt (EMF_MAIL_MENU); + testapp_show_menu(EMAIL_MAIL_MENU); + testapp_show_prompt(EMAIL_MAIL_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-mailbox.c b/utilities/test-application/testapp-mailbox.c index c267f29..ad7b961 100755 --- a/utilities/test-application/testapp-mailbox.c +++ b/utilities/test-application/testapp-mailbox.c @@ -37,45 +37,79 @@ #include "testapp-utility.h" #include "testapp-mailbox.h" +static gboolean testapp_print_mailbox_list(email_mailbox_t *input_mailbox_list, int input_count) +{ + int i; + char time_string[40] = { 0, }; + + + + testapp_print("There are %d mailboxes\n", input_count); + + testapp_print("============================================================================\n"); + testapp_print("id a_id name\t\t\t alias\t\t unread\t total\t total_on_ server\tmailbox_type\t last_sync_time\n"); + testapp_print("============================================================================\n"); + if ( input_count == 0 ) { + testapp_print("No mailbox is matched\n"); + } + else { + for(i=0;i Enter mailbox name: "); - scanf("%s",arg); - mbox.name = strdup(arg); + result_from_scanf = scanf("%s",arg); + mailbox.mailbox_name = strdup(arg); memset(arg, 0x00, 500); testapp_print("> Enter mailbox alias name: "); - scanf("%s",arg); - mbox.alias = strdup(arg); + result_from_scanf = scanf("%s",arg); + mailbox.alias = strdup(arg); testapp_print("> Enter account id: "); - scanf("%d", &account_id); - mbox.account_id = account_id; + result_from_scanf = scanf("%d", &account_id); + mailbox.account_id = account_id; testapp_print("> Enter local_yn (1/0): "); - scanf("%d", &local_yn); - mbox.local= local_yn; + result_from_scanf = scanf("%d", &local_yn); + mailbox.local= local_yn; testapp_print("> Enter mailbox type: "); - scanf("%d", &mailbox_type); - mbox.mailbox_type= mailbox_type; + result_from_scanf = scanf("%d", &mailbox_type); + mailbox.mailbox_type= mailbox_type; - ret = email_add_mailbox(&mbox, local_yn?0:1, &handle); + ret = email_add_mailbox(&mailbox, local_yn?0:1, &handle); if (ret < 0) { testapp_print("\n email_add_mailbox failed"); } else { - testapp_print("\n email_add_mailbox succeed : handle[%d]\n", handle); + testapp_print("\n email_add_mailbox succeed : handle[%d], mailbox_id [%d]\n", handle, mailbox.mailbox_id); } return FALSE; @@ -83,27 +117,19 @@ static gboolean testapp_test_add_mailbox() static gboolean testapp_test_delete_mailbox() { - - emf_mailbox_t mbox; - int account_id; - int local_yn = 0; - char arg[500]; + int mailbox_id = 0; + int on_server = 0; int ret; unsigned handle; + int result_from_scanf = 0; - memset(arg, 0x00, 500); - testapp_print("\n> Enter mailbox name:"); - scanf("%s",arg); - mbox.name = strdup(arg); + testapp_print("\n> Enter mailbox id:"); + result_from_scanf = scanf("%d", &mailbox_id); - testapp_print("> Enter account id: "); - scanf("%d", &account_id); - mbox.account_id = account_id; - - testapp_print("> Enter local_yn (1/0): "); - scanf("%d", &local_yn); + testapp_print("> Enter on_server (1/0): "); + result_from_scanf = scanf("%d", &on_server); - ret = email_delete_mailbox(&mbox, local_yn?0:1, &handle); + ret = email_delete_mailbox(mailbox_id, on_server, &handle); if ( ret < 0) { testapp_print("\n email_delete_mailbox failed"); @@ -116,55 +142,33 @@ static gboolean testapp_test_delete_mailbox() } -static gboolean testapp_test_update_mailbox() +static gboolean testapp_test_rename_mailbox() { - testapp_print ("testapp_test_update_mailbox - support ONLY updating mailbox type\n"); - emf_mailbox_t *old_mailbox_name = NULL; - emf_mailbox_t *new_mbox = NULL; - int account_id,mailbox_type = 0; - char arg[500]; + testapp_print ("testapp_test_rename_mailbox\n"); + int mailbox_id; + char mailbox_name[500] = { 0, }; + char mailbox_alias[500] = { 0, }; int err; - - memset(arg, 0x00, 500); + int result_from_scanf = 0; + unsigned handle = 0; - testapp_print("> Enter account id: "); - scanf("%d", &account_id); + testapp_print("> Enter mailbox id: "); + result_from_scanf = scanf("%d", &mailbox_id); - testapp_print("\n> Enter mailbox name: "); - scanf("%s", arg); - - testapp_print("> Enter mailbox type: "); - scanf("%d", &mailbox_type); + testapp_print("> Enter new mailbox name: "); + result_from_scanf = scanf("%s", mailbox_name); + + testapp_print("> Enter new mailbox name: "); + result_from_scanf = scanf("%s", mailbox_alias); - /* Get old mailbox information from db */ - if ( (err = email_get_mailbox_by_name(account_id, arg, &old_mailbox_name)) < 0 ) { - testapp_print("\n email_get_mailbox_by_name failed[%d]\n", err); - } - else { - testapp_print("\n email_get_mailbox_by_name succeed\n"); - } - - /* copy old maibox to new mailbox */ - if ( (err = email_get_mailbox_by_name(account_id, arg, &new_mbox)) < 0 ) { - testapp_print("\n email_get_mailbox_by_name failed[%d]\n", err); - } - else { - testapp_print("\n email_get_mailbox_by_name succeed\n"); - } - - /* set new value of new mailbox */ - new_mbox->mailbox_type= mailbox_type; - if ( (err = email_update_mailbox(old_mailbox_name, new_mbox)) < 0) { - testapp_print("\n email_update_mailbox failed[%d]\n", err); + if ( (err = email_rename_mailbox(mailbox_id, mailbox_name, mailbox_alias, true, &handle)) < 0) { + testapp_print("\n email_rename_mailbox failed[%d]\n", err); } else { - testapp_print("\n email_update_mailbox succeed\n"); + testapp_print("\n email_rename_mailbox succeed\n"); } - email_free_mailbox(&old_mailbox_name, 1); - email_free_mailbox(&new_mbox, 1); - return FALSE; } @@ -172,124 +176,82 @@ static gboolean testapp_test_get_imap_mailbox_list() { int account_id = 0; unsigned handle = 0; + int result_from_scanf = 0; testapp_print("> Enter account id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); - if( email_get_imap_mailbox_list(account_id, "", &handle) < 0) - testapp_print("email_get_imap_mailbox_list failed"); + if( email_sync_imap_mailbox_list(account_id, &handle) < 0) + testapp_print("email_sync_imap_mailbox_list failed"); return FALSE; } -static gboolean testapp_test_get_child_mailbox_list () +static gboolean testapp_test_get_mailbox_by_type () { - int account_id =0; - int count = 0; - int i = 0, err_code = EMF_ERROR_NONE; - emf_mailbox_t *mailbox_list=NULL; - char parent_mailbox[100], *parent_mailbox_pointer = NULL; - - - memset(parent_mailbox,0x00,sizeof(parent_mailbox)); + int account_id =0; + int err_code = EMAIL_ERROR_NONE; + int result_from_scanf = 0; + email_mailbox_t *mailbox =NULL; + email_mailbox_type_e mailbox_type =0; testapp_print("\n > Enter account id: "); - scanf("%d", &account_id); - - testapp_print("\n > Enter parent mailbox name to fetch child list: "); - scanf("%s", parent_mailbox); - - + result_from_scanf = scanf("%d", &account_id); - if(strcmp(parent_mailbox, "0") != 0) { - testapp_print("\ninput : %s\n", parent_mailbox); - parent_mailbox_pointer = parent_mailbox; - } + testapp_print("\n > Enter mailbox_type: "); + result_from_scanf = scanf("%d", (int*)&mailbox_type); - if( (err_code = email_get_child_mailbox_list(account_id,parent_mailbox_pointer, &mailbox_list, &count)) < 0) { - testapp_print(" email_get_child_mailbox_list error : %d\n",err_code); + if( (err_code = email_get_mailbox_by_mailbox_type(account_id,mailbox_type,&mailbox)) < 0) { + testapp_print(" email_get_mailbox_by_mailbox_type error : %d\n",err_code); return false ; } - testapp_print("There are %d mailboxes\n", count); - - testapp_print("============================================================================\n"); - testapp_print("number\taccount_id\t name\t alias\t local_yn\t unread\t mailbox_type\thas_archived_mails\n"); - testapp_print("============================================================================\n"); - if(count == 0) { - testapp_print("No mailbox is matched\n"); - } - else { - for(i=0;i Enter account id: "); - scanf("%d", &account_id); + testapp_print("\n > Enter mailbox id : "); + result_from_scanf = scanf("%d", &mailbox_id); - testapp_print("\n > Enter mailbox_type: "); - scanf("%d", (int*)&mailbox_type); + testapp_print("\n > Enter mailbox type : "); + result_from_scanf = scanf("%d", &mailbox_type); - if( (err_code = email_get_mailbox_by_mailbox_type(account_id,mailbox_type,&mailbox)) < 0) { - testapp_print(" email_get_mailbox_by_mailbox_type error : %d\n",err_code); - return false ; + if( (err_code = email_set_mailbox_type(mailbox_id, mailbox_type) ) != EMAIL_ERROR_NONE) { + testapp_print("\nemail_set_mailbox_type error : %d\n", err_code); } - testapp_print("============================================================================\n"); - testapp_print("number\taccount_id\t name\t alias\t local_yn\t unread\t mailbox_type\thas_archived_mails\n"); - testapp_print("============================================================================\n"); - - testapp_print("[%d] - ", i); - testapp_print(" %2d\t [%-15s]\t[%-15s]\t", mailbox->account_id, mailbox->name, mailbox->alias); - testapp_print(" %d\t %d\t %d\n", mailbox->local, mailbox->unread_count,mailbox->mailbox_type, mailbox->has_archived_mails); - - testapp_print("============================================================================\n"); - - email_free_mailbox(&mailbox, 1); return FALSE; } static gboolean testapp_test_set_mail_slot_size () { - - int account_id = 0, mail_slot_size = 0; - int err_code = EMF_ERROR_NONE; - char arg[500]; - char *mailbox_name = NULL; + int account_id = 0; + int mailbox_id = 0; + int mail_slot_size = 0; + int err_code = EMAIL_ERROR_NONE; + int result_from_scanf = 0; testapp_print("\n > Enter account id (0: All account): "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); - memset(arg, 0x00, 500); - testapp_print("\n> Enter mailbox name (0 : All mailboxes):"); - scanf("%s",arg); - if (strcmp(arg, "0") != 0 ) { - mailbox_name = arg; - } + testapp_print("\n> Enter mailbox id (0 : All mailboxes):"); + result_from_scanf = scanf("%d", &mailbox_id); testapp_print("\n > Enter mailbox slot size: "); - scanf("%d", &mail_slot_size); + result_from_scanf = scanf("%d", &mail_slot_size); - if( (err_code = email_set_mail_slot_size(account_id, mailbox_name, mail_slot_size) ) < 0) { + if( (err_code = email_set_mail_slot_size(account_id, mailbox_id, mail_slot_size) ) < 0) { testapp_print(" testapp_test_set_mail_slot_size error : %d\n", err_code); return false ; } @@ -299,62 +261,32 @@ static gboolean testapp_test_set_mail_slot_size () static gboolean testapp_test_get_mailbox_list () { - + int result_from_scanf = 0; int account_id =0; int mailbox_sync_type; int count = 0; - int i = 0, error_code = EMF_ERROR_NONE; - emf_mailbox_t *mailbox_list=NULL; + int error_code = EMAIL_ERROR_NONE; + email_mailbox_t *mailbox_list=NULL; testapp_print("\n > Enter account id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter mailbox_sync_type\n[-1 :for all mailboxes, 0 : for mailboxes from server, 1 : local mailboxes\n : "); - scanf("%d", &mailbox_sync_type); + result_from_scanf = scanf("%d", &mailbox_sync_type); if((error_code = email_get_mailbox_list(account_id, mailbox_sync_type, &mailbox_list, &count)) < 0) { testapp_print(" email_get_mailbox_list error %d\n", error_code); return false ; } - testapp_print("There are %d mailboxes\n", count); + testapp_print_mailbox_list(mailbox_list, count); - testapp_print("============================================================================\n"); - testapp_print("number\taccount_id\t name\t\t alias\t local_yn\t unread\tmailbox_type\t has_archived_mails\n"); - testapp_print("============================================================================\n"); - if ( count == 0 ) { - testapp_print("No mailbox is matched\n"); - } - else { - for(i=0;i Enter Account id (0: for all account) : "); - scanf("%d",&account_id); - - memset(arg, 0x00, 50); - testapp_print("\n > Enter Mailbox name (ALL: for all mailboxes) : "); - scanf("%s",arg); - - memset(&mbox, 0x00, sizeof(emf_mailbox_t)); + int mailbox_id = 0; - mbox.account_id = account_id; + testapp_print("\n > Enter Account id (0: for all account) : "); + result_from_scanf = scanf("%d",&account_id); - if(strcmp("ALL", arg) == 0) - mbox.name = NULL; - else - mbox.name = strdup(arg); + testapp_print("\n > Enter Mailbox id (0: for all mailboxes) : "); + result_from_scanf = scanf("%d",&mailbox_id); if(account_id == ALL_ACCOUNT) { if(email_sync_header_for_all_account(&handle) < 0) @@ -389,7 +312,7 @@ static gboolean testapp_test_sync_mailbox() testapp_print("\n email_sync_header_for_all_account success. Handle[%d]\n", handle); } else { - if(email_sync_header(&mbox,&handle) < 0) + if(email_sync_header(account_id, mailbox_id, &handle) < 0) testapp_print("\n email_sync_header failed\n"); else testapp_print("\n email_sync_header success. Handle[%d]\n", handle); @@ -398,6 +321,19 @@ static gboolean testapp_test_sync_mailbox() return FALSE; } +static gboolean testapp_test_stamp_sync_time() +{ + int result_from_scanf; + int input_mailbox_id = 0; + + testapp_print("\n > Enter Mailbox id : "); + result_from_scanf = scanf("%d",&input_mailbox_id); + + email_stamp_sync_time_of_mailbox(input_mailbox_id); + + return FALSE; +} + static gboolean testapp_test_interpret_command (int menu_number) { gboolean go_to_loop = TRUE; @@ -408,37 +344,41 @@ static gboolean testapp_test_interpret_command (int menu_number) break; case 2: - testapp_test_delete_mailbox (); + testapp_test_delete_mailbox(); break; case 3: - testapp_test_update_mailbox (); + testapp_test_rename_mailbox(); break; case 4: testapp_test_get_imap_mailbox_list(); break; - case 6: - testapp_test_get_child_mailbox_list(); - break; - case 7: testapp_test_get_mailbox_by_type(); - break; + break; case 8: - testapp_test_set_mail_slot_size(); + testapp_test_set_mailbox_type(); break; case 9: + testapp_test_set_mail_slot_size(); + break; + + case 10: testapp_test_get_mailbox_list (); break; - case 10: + case 11: testapp_test_sync_mailbox(); break; + case 12: + testapp_test_stamp_sync_time(); + break; + case 0: go_to_loop = FALSE; break; @@ -449,16 +389,17 @@ static gboolean testapp_test_interpret_command (int menu_number) return go_to_loop; } -void emf_test_mailbox_main() +void email_test_mailbox_main() { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_MAILBOX_MENU); - testapp_show_prompt (EMF_MAILBOX_MENU); + testapp_show_menu (EMAIL_MAILBOX_MENU); + testapp_show_prompt (EMAIL_MAILBOX_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-others.c b/utilities/test-application/testapp-others.c index 6aee94e..1181d90 100755 --- a/utilities/test-application/testapp-others.c +++ b/utilities/test-application/testapp-others.c @@ -55,18 +55,19 @@ static gboolean testapp_test_get_pending_job() int action = -1; int account_id = 0; int mail_id = 0; - emf_event_status_type_t status = -1; + int result_from_scanf = 0; + email_event_status_type_t status = -1; testapp_print( " Enter Action \n SEND_MAIL = 0 \n SYNC_HEADER = 1 \n" \ " DOWNLOAD_BODY,= 2 \n DOWNLOAD_ATTACHMENT = 3 \n" \ " DELETE_MAIL = 4 \n SEARCH_MAIL = 5 \n SAVE_MAIL = 6 \n" \ " NUM = 7 \n"); - scanf("%d",&action); + result_from_scanf = scanf("%d",&action); testapp_print("\n > Enter account_id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); + result_from_scanf = scanf("%d", &mail_id); if( email_get_pending_job( action, account_id, mail_id, &status) >= 0) testapp_print("\t status - %d \n",status); @@ -78,14 +79,15 @@ static gboolean testapp_test_cancel_job () { int account_id = 0; int handle = 0; + int result_from_scanf = 0; testapp_print("\n > Enter account_id (0: all account): "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter handle: "); - scanf("%d", &handle); + result_from_scanf = scanf("%d", &handle); - if(email_cancel_job(account_id, handle) < 0) + if(email_cancel_job(account_id, handle, EMAIL_CANCELED_BY_USER) < 0) testapp_print("email_cancel_job failed..!"); return FALSE; } @@ -110,12 +112,12 @@ static gboolean testapp_test_print_receving_queue_via_debug_msg() void* hAPI = (void*)emipc_create_email_api(_EMAIL_API_PRINT_RECEIVING_EVENT_QUEUE); if(hAPI == NULL) - return EMF_ERROR_NULL_VALUE; + return EMAIL_ERROR_NULL_VALUE; - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { testapp_print("testapp_test_print_receving_queue_via_debug_msg - emipc_execute_proxy_api failed \n "); if(hAPI == NULL) - return EMF_ERROR_NULL_VALUE; + return EMAIL_ERROR_NULL_VALUE; } emipc_get_parameter(hAPI, 1, 0, sizeof(int), &err); @@ -144,10 +146,10 @@ static int encode_base64(char *src, unsigned long src_len, char **enc, unsigned { unsigned char *content = NULL; int ret = true; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (err_code != NULL) { - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; } content = rfc822_binary(src, src_len, enc_len); @@ -155,7 +157,7 @@ static int encode_base64(char *src, unsigned long src_len, char **enc, unsigned if (content) *enc = (char *)content; else { - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; ret = false; } @@ -168,7 +170,7 @@ static int encode_base64(char *src, unsigned long src_len, char **enc, unsigned static gboolean testapp_test_encoding_test() { - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int has_special_character = 0, base64_file_name_length = 0, i; gsize bytes_read, bytes_written; char *encoded_file_name = NULL, *base64_file_name = NULL; @@ -364,6 +366,33 @@ static gboolean email_test_dtt_Datastore_C() return true; } +static gboolean testapp_test_show_user_message() +{ + int mail_id; + int result_from_scanf = 0; + + testapp_print("\n > Enter mail id : "); + result_from_scanf = scanf("%d", &mail_id); + + email_show_user_message(mail_id, EMAIL_ACTION_SEND_MAIL, EMAIL_ERROR_NETWORK_NOT_AVAILABLE); + return FALSE; +} + +static gboolean testapp_test_get_mime_entity() +{ + char mime_path[512] = {0, }; + int result_from_scanf = 0; + char *mime_entity = NULL; + + testapp_print("\n > Enter mime path for parsing : "); + result_from_scanf = scanf("%s", mime_path); + + email_get_mime_entity(mime_path, &mime_entity); + + testapp_print("\nmime_entity = %s\n", mime_entity); + return true; +} + static gboolean testapp_test_interpret_command (int menu_number) { gboolean go_to_loop = TRUE; @@ -398,6 +427,12 @@ static gboolean testapp_test_interpret_command (int menu_number) email_test_dtt_Datastore_C(); email_test_dtt_Datastore_R(); break; + case 15: + testapp_test_show_user_message(); + break; + case 16: + testapp_test_get_mime_entity(); + break; case 0: go_to_loop = FALSE; break; @@ -412,12 +447,13 @@ void testapp_others_main() { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_OTHERS_MENU); - testapp_show_prompt (EMF_OTHERS_MENU); + testapp_show_menu (EMAIL_OTHERS_MENU); + testapp_show_prompt (EMAIL_OTHERS_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf ("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-rule.c b/utilities/test-application/testapp-rule.c index 3d8c104..45a4ea9 100755 --- a/utilities/test-application/testapp-rule.c +++ b/utilities/test-application/testapp-rule.c @@ -38,46 +38,49 @@ static gboolean testapp_test_add_rule() { - emf_rule_t* rule = NULL; + email_rule_t* rule = NULL; int account_id = 0; + int target_mailbox_id = 0; int action = 0; int type = 0; int flag = 0; char arg[500]; + int result_from_scanf = 0; - rule = malloc(sizeof(emf_rule_t)); + rule = malloc(sizeof(email_rule_t)); testapp_print("> Enter account id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); rule->account_id = account_id; testapp_print("> Enter Type(FROM - 1 / SUBJECT - 2): "); - scanf("%d", &type); + result_from_scanf = scanf("%d", &type); rule->type= type; memset(arg, 0x00, 500); testapp_print("\n> Enter Filtering Value:"); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); rule->value= strdup(arg); testapp_print("> Enter Action(MOVE - 1, BLOCK - 2, DELETE - 3): "); - scanf("%d", &action); + result_from_scanf = scanf("%d", &action); rule->faction= action; - memset(arg, 0x00, 500); - testapp_print("\n> Enter mailbox name:"); - scanf("%s",arg); - rule->mailbox= strdup(arg); + if (action == 1) { + testapp_print("\n> Enter target mailbox id:"); + result_from_scanf = scanf("%d", &target_mailbox_id); + rule->target_mailbox_id = target_mailbox_id; + } testapp_print("> Enter Flag1 value: "); - scanf("%d", &flag); + result_from_scanf = scanf("%d", &flag); rule->flag1= flag; testapp_print("> Enter Flag2 value: "); - scanf("%d", &flag); + result_from_scanf = scanf("%d", &flag); rule->flag2= flag; if ( email_add_rule(rule) < 0) - testapp_print("\n EmfRuleAdd failed"); + testapp_print("\n email_add_rule failed"); email_free_rule(&rule, 1); @@ -87,11 +90,11 @@ static gboolean testapp_test_add_rule() static gboolean testapp_test_delete_rule() { - + int result_from_scanf = 0; int filter_id = 0; testapp_print("> Enter filter id: "); - scanf("%d", &filter_id); + result_from_scanf = scanf("%d", &filter_id); if(email_delete_rule(filter_id) < 0) testapp_print("email_delete_rule failed..! "); @@ -102,48 +105,50 @@ static gboolean testapp_test_delete_rule() static gboolean testapp_test_update_rule() { - - emf_rule_t* rule = NULL; + int result_from_scanf = 0; + email_rule_t* rule = NULL; int account_id = 0; + int target_mailbox_id = 0; int action = 0; int type = 0; int flag = 0; char arg[500]; int filter_id = 0; - rule = malloc(sizeof(emf_rule_t)); - memset(rule,0X00,sizeof(emf_rule_t)); + rule = malloc(sizeof(email_rule_t)); + memset(rule,0X00,sizeof(email_rule_t)); testapp_print("> Enter filter id: "); - scanf("%d", &filter_id); + result_from_scanf = scanf("%d", &filter_id); testapp_print("> Enter account id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); rule->account_id = account_id; testapp_print("> Enter Type(FROM - 1 / SUBJECT - 2): "); - scanf("%d", &type); + result_from_scanf = scanf("%d", &type); rule->type= type; memset(arg, 0x00, 500); testapp_print("\n> Enter Filtering Value:"); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); rule->value= strdup(arg); testapp_print("> Enter Action(MOVE - 1, BLOCK - 2, DELETE - 3): "); - scanf("%d", &action); + result_from_scanf = scanf("%d", &action); rule->faction= action; - memset(arg, 0x00, 500); - testapp_print("\n> Enter mailbox name:"); - scanf("%s",arg); - rule->mailbox= strdup(arg); + if (action == 1) { + testapp_print("\n> Enter target mailbox id:"); + result_from_scanf = scanf("%d", &target_mailbox_id); + rule->target_mailbox_id = target_mailbox_id; + } testapp_print("> Enter Flag1 value: "); - scanf("%d", &flag); + result_from_scanf = scanf("%d", &flag); rule->flag1= flag; testapp_print("> Enter Flag2 value: "); - scanf("%d", &flag); + result_from_scanf = scanf("%d", &flag); rule->flag2= flag; if( !email_update_rule(filter_id, rule) < 0) @@ -157,11 +162,12 @@ static gboolean testapp_test_update_rule() static gboolean testapp_test_get_rule(void) { - emf_rule_t* rule = NULL; + email_rule_t* rule = NULL; int filter_id = 0; + int result_from_scanf = 0; testapp_print("> Enter filter id: "); - scanf("%d", &filter_id); + result_from_scanf = scanf("%d", &filter_id); if(email_get_rule(filter_id, &rule) >= 0) testapp_print("\n Got rule of account_id = %d and type = %d\n", rule->account_id, rule->type); @@ -175,7 +181,7 @@ static gboolean testapp_test_get_rule(void) static gboolean testapp_test_get_rule_list (void) { int count, i; - emf_rule_t* rule_list=NULL; + email_rule_t* rule_list=NULL; if(email_get_rule_list(&rule_list, &count) < 0) { testapp_print(" email_get_rule_list error\n"); @@ -228,16 +234,17 @@ static gboolean testapp_test_interpret_command (int menu_number) return go_to_loop; } -void emf_test_rule_main() +void email_test_rule_main() { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_RULE_MENU); - testapp_show_prompt (EMF_RULE_MENU); + testapp_show_menu (EMAIL_RULE_MENU); + testapp_show_prompt (EMAIL_RULE_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-thread.c b/utilities/test-application/testapp-thread.c index e146506..c035fce 100755 --- a/utilities/test-application/testapp-thread.c +++ b/utilities/test-application/testapp-thread.c @@ -40,19 +40,20 @@ static gboolean testapp_test_move_thread() { int thread_id, move_always_flag; - char target_mailbox_name[512]; + int target_mailbox_id; int result; + int result_from_scanf = 0; testapp_print("\n > Enter thread_id: "); - scanf("%d", &thread_id); + result_from_scanf = scanf("%d", &thread_id); - testapp_print("\n > Enter target_mailbox_name: "); - scanf("%s", target_mailbox_name); + testapp_print("\n > Enter target_mailbox_id: "); + result_from_scanf = scanf("%d", &target_mailbox_id); testapp_print("\n > Enter move_always_flag: "); - scanf("%d", &move_always_flag); + result_from_scanf = scanf("%d", &move_always_flag); - result = email_move_thread_to_mailbox(thread_id, target_mailbox_name, move_always_flag); + result = email_move_thread_to_mailbox(thread_id, target_mailbox_id, move_always_flag); return FALSE; } @@ -61,12 +62,13 @@ static gboolean testapp_test_delete_thread() { int thread_id, delete_always_flag; int result; + int result_from_scanf = 0; testapp_print("\n > Enter thread_id: "); - scanf("%d", &thread_id); + result_from_scanf = scanf("%d", &thread_id); testapp_print("\n > Enter delete_always_flag: "); - scanf("%d", &delete_always_flag); + result_from_scanf = scanf("%d", &delete_always_flag); result = email_delete_thread(thread_id, delete_always_flag); @@ -77,15 +79,16 @@ static gboolean testapp_test_set_seen_flag_of_thread() { int thread_id, seen_flag, on_server; int result; + int result_from_scanf = 0; testapp_print("\n > Enter thread_id: "); - scanf("%d", &thread_id); + result_from_scanf = scanf("%d", &thread_id); testapp_print("\n > Enter seen_flag: "); - scanf("%d", &seen_flag); + result_from_scanf = scanf("%d", &seen_flag); testapp_print("\n > Enter on_server: "); - scanf("%d", &on_server); + result_from_scanf = scanf("%d", &on_server); result = email_modify_seen_flag_of_thread(thread_id, seen_flag, on_server); @@ -123,12 +126,13 @@ void testapp_thread_main() { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_THREAD_MENU); - testapp_show_prompt (EMF_THREAD_MENU); + testapp_show_menu (EMAIL_THREAD_MENU); + testapp_show_prompt (EMAIL_THREAD_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-utility.c b/utilities/test-application/testapp-utility.c index 527df2c..5ee0dfd 100755 --- a/utilities/test-application/testapp-utility.c +++ b/utilities/test-application/testapp-utility.c @@ -43,10 +43,10 @@ void testapp_print (char *fmt, ...) fflush (stdout); } -void testapp_show_menu (eEMF_MENU menu) +void testapp_show_menu (eEMAIL_MENU menu) { switch (menu) { - case EMF_MAIN_MENU: + case EMAIL_MAIN_MENU: testapp_print ("==========================================\n"); testapp_print (" Email test application \n"); testapp_print ("==========================================\n"); @@ -60,47 +60,49 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("------------------------------------------\n"); break; - case EMF_ACCOUNT_MENU: + case EMAIL_ACCOUNT_MENU: testapp_print ("==========================================\n"); testapp_print (" ACCOUNT MENU \n"); testapp_print ("==========================================\n"); - testapp_print (" 1. Create Account\n"); - testapp_print (" 2. Update Account\n"); - testapp_print (" 3. Delete Account\n"); - testapp_print (" 4. Get Account\n"); - testapp_print (" 5. Get Account List\n"); - testapp_print (" 7. Validate Account\n"); + testapp_print (" 1. Create account\n"); + testapp_print (" 2. Update account\n"); + testapp_print (" 3. Delete account\n"); + testapp_print (" 4. Get account\n"); + testapp_print (" 5. Get account list\n"); + testapp_print (" 7. Validate account\n"); testapp_print (" 8. Cancel validate Account\n"); - testapp_print (" 9. Backup All Accounts\n"); + testapp_print (" 9. Backup All accounts\n"); testapp_print (" 10. Restore accounts\n"); testapp_print (" 11. Get password length of account\n"); testapp_print (" 12. Query server info\n"); testapp_print (" 13. Clear all notifications\n"); + testapp_print (" 14. Save default account ID\n"); + testapp_print (" 15. Load default account ID\n"); + testapp_print (" 16. Add certificate\n"); + testapp_print (" 17. Get certificate\n"); + testapp_print (" 18. Delete certificate\n"); testapp_print (" 0. Go to Main Menu\n"); testapp_print ("------------------------------------------\n"); break; - case EMF_MAIL_MENU: + case EMAIL_MAIL_MENU: testapp_print ("==========================================\n"); testapp_print (" MAIL MENU\n"); testapp_print ("==========================================\n"); testapp_print ("1. Get mails\n"); testapp_print ("2. Send a mail \n"); + testapp_print ("3. Get mail list\n"); testapp_print ("4. Add Attachment\n"); + testapp_print ("5. Set deleted flag\n"); + testapp_print ("6. Expunge deleted flagged mails\n"); testapp_print ("9. Mail Count \n"); - testapp_print ("10. Modify mail flag \n"); - testapp_print ("11. Modify mail extra flag modify\n"); testapp_print ("14. Delete a mail \n"); testapp_print ("16. Download mail body\n"); testapp_print ("17. Download an attachment\n"); testapp_print ("20. Delete all mail\n"); testapp_print ("21. Move Mail \n"); testapp_print ("23. Resend Mail \n"); - testapp_print ("24. Find mails\n"); - testapp_print ("26. Count mails On Sending\n"); testapp_print ("27. Move all mails to mailbox\n"); - testapp_print ("28. Count mails with Draft Flag\n"); - testapp_print ("29. Get latest unread mail Id\n"); testapp_print ("38. Get total email disk usage \n"); testapp_print ("40. Verify Email Address Format\n"); testapp_print ("41. Get Max Mail Count\n"); @@ -108,7 +110,6 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("43. Send mail Cancel\n"); testapp_print ("44. Cancel Download Body\n"); testapp_print ("48. Get thread information\n"); - testapp_print ("49. Get sender list\n"); testapp_print ("51. Get mail list ex\n"); testapp_print ("52. Get address info list\n"); testapp_print ("55. Set a field of flags\n"); @@ -116,28 +117,30 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("57. Update mail\n"); testapp_print ("58. Search on server\n"); testapp_print ("59. Add mail to search result table\n"); + testapp_print ("60. Open eml file\n"); testapp_print ("0. Go to Main Menu\n"); testapp_print ("------------------------------------------\n"); break; - case EMF_MAILBOX_MENU: + case EMAIL_MAILBOX_MENU: testapp_print ("==========================================\n"); testapp_print (" MAILBOX MENU\n"); testapp_print ("==========================================\n"); testapp_print (" 1. Add mailbox\n"); testapp_print (" 2. Delete mailbox\n"); - testapp_print (" 3. Update mailbox\n"); + testapp_print (" 3. Raname mailbox\n"); testapp_print (" 4. Get IMAP mailbox List\n"); - testapp_print (" 6. Get Child List for given mailbox \n"); testapp_print (" 7. Get mailbox by mailbox type\n"); - testapp_print (" 8. Set mail slot size\n"); - testapp_print (" 9. Get mailbox list\n"); - testapp_print ("10. Sync mailbox\n"); + testapp_print (" 8. Set mailbox type\n"); + testapp_print (" 9. Set mail slot size\n"); + testapp_print ("10. Get mailbox list\n"); + testapp_print ("11. Sync mailbox\n"); + testapp_print ("12. Stamp sync time\n"); testapp_print ("0. Go to Main Menu\n"); testapp_print ("------------------------------------------\n"); break; - case EMF_RULE_MENU: + case EMAIL_RULE_MENU: testapp_print ("==========================================\n"); testapp_print (" RULE MENU\n"); testapp_print ("==========================================\n"); @@ -150,7 +153,7 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("------------------------------------------\n"); break; - case EMF_THREAD_MENU: + case EMAIL_THREAD_MENU: testapp_print ("==========================================\n"); testapp_print (" TRHEAD MENU\n"); testapp_print ("==========================================\n"); @@ -161,7 +164,7 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("------------------------------------------\n"); break; - case EMF_OTHERS_MENU: + case EMAIL_OTHERS_MENU: testapp_print ("==========================================\n"); testapp_print (" OTHERS\n"); testapp_print ("==========================================\n"); @@ -175,6 +178,8 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("12. Create DB full\n"); testapp_print ("13. Encoding Test\n"); testapp_print ("14. DTT Test\n"); + testapp_print ("15. Show User Message\n"); + testapp_print ("16. Get mime entity in signed file\n"); testapp_print ("0. Go to Main Menu\n"); testapp_print ("------------------------------------------\n"); break; @@ -183,34 +188,34 @@ void testapp_show_menu (eEMF_MENU menu) break; } } -void testapp_show_prompt (eEMF_MENU menu) +void testapp_show_prompt (eEMAIL_MENU menu) { switch (menu) { - case EMF_MAIN_MENU: + case EMAIL_MAIN_MENU: testapp_print ("[MAIN]# "); break; - case EMF_ACCOUNT_MENU: + case EMAIL_ACCOUNT_MENU: testapp_print ("[ACCOUNT]# "); break; - case EMF_MAIL_MENU: + case EMAIL_MAIL_MENU: testapp_print ("[MAIL]# "); break; - case EMF_MAILBOX_MENU: + case EMAIL_MAILBOX_MENU: testapp_print ("[MAILBOX]# "); break; - case EMF_RULE_MENU: + case EMAIL_RULE_MENU: testapp_print ("[RULE]# "); break; - case EMF_THREAD_MENU: + case EMAIL_THREAD_MENU: testapp_print ("[THREAD]# "); break; - case EMF_OTHERS_MENU: + case EMAIL_OTHERS_MENU: testapp_print ("[OTHERS]# "); break; -- 2.7.4