+++ /dev/null
-\r
- Apache License\r
- Version 2.0, January 2004\r
- http://www.apache.org/licenses/\r
-\r
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
-\r
- 1. Definitions.\r
-\r
- "License" shall mean the terms and conditions for use, reproduction,\r
- and distribution as defined by Sections 1 through 9 of this document.\r
-\r
- "Licensor" shall mean the copyright owner or entity authorized by\r
- the copyright owner that is granting the License.\r
-\r
- "Legal Entity" shall mean the union of the acting entity and all\r
- other entities that control, are controlled by, or are under common\r
- control with that entity. For the purposes of this definition,\r
- "control" means (i) the power, direct or indirect, to cause the\r
- direction or management of such entity, whether by contract or\r
- otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
- outstanding shares, or (iii) beneficial ownership of such entity.\r
-\r
- "You" (or "Your") shall mean an individual or Legal Entity\r
- exercising permissions granted by this License.\r
-\r
- "Source" form shall mean the preferred form for making modifications,\r
- including but not limited to software source code, documentation\r
- source, and configuration files.\r
-\r
- "Object" form shall mean any form resulting from mechanical\r
- transformation or translation of a Source form, including but\r
- not limited to compiled object code, generated documentation,\r
- and conversions to other media types.\r
-\r
- "Work" shall mean the work of authorship, whether in Source or\r
- Object form, made available under the License, as indicated by a\r
- copyright notice that is included in or attached to the work\r
- (an example is provided in the Appendix below).\r
-\r
- "Derivative Works" shall mean any work, whether in Source or Object\r
- form, that is based on (or derived from) the Work and for which the\r
- editorial revisions, annotations, elaborations, or other modifications\r
- represent, as a whole, an original work of authorship. For the purposes\r
- of this License, Derivative Works shall not include works that remain\r
- separable from, or merely link (or bind by name) to the interfaces of,\r
- the Work and Derivative Works thereof.\r
-\r
- "Contribution" shall mean any work of authorship, including\r
- the original version of the Work and any modifications or additions\r
- to that Work or Derivative Works thereof, that is intentionally\r
- submitted to Licensor for inclusion in the Work by the copyright owner\r
- or by an individual or Legal Entity authorized to submit on behalf of\r
- the copyright owner. For the purposes of this definition, "submitted"\r
- means any form of electronic, verbal, or written communication sent\r
- to the Licensor or its representatives, including but not limited to\r
- communication on electronic mailing lists, source code control systems,\r
- and issue tracking systems that are managed by, or on behalf of, the\r
- Licensor for the purpose of discussing and improving the Work, but\r
- excluding communication that is conspicuously marked or otherwise\r
- designated in writing by the copyright owner as "Not a Contribution."\r
-\r
- "Contributor" shall mean Licensor and any individual or Legal Entity\r
- on behalf of whom a Contribution has been received by Licensor and\r
- subsequently incorporated within the Work.\r
-\r
- 2. Grant of Copyright License. Subject to the terms and conditions of\r
- this License, each Contributor hereby grants to You a perpetual,\r
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
- copyright license to reproduce, prepare Derivative Works of,\r
- publicly display, publicly perform, sublicense, and distribute the\r
- Work and such Derivative Works in Source or Object form.\r
-\r
- 3. Grant of Patent License. Subject to the terms and conditions of\r
- this License, each Contributor hereby grants to You a perpetual,\r
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
- (except as stated in this section) patent license to make, have made,\r
- use, offer to sell, sell, import, and otherwise transfer the Work,\r
- where such license applies only to those patent claims licensable\r
- by such Contributor that are necessarily infringed by their\r
- Contribution(s) alone or by combination of their Contribution(s)\r
- with the Work to which such Contribution(s) was submitted. If You\r
- institute patent litigation against any entity (including a\r
- cross-claim or counterclaim in a lawsuit) alleging that the Work\r
- or a Contribution incorporated within the Work constitutes direct\r
- or contributory patent infringement, then any patent licenses\r
- granted to You under this License for that Work shall terminate\r
- as of the date such litigation is filed.\r
-\r
- 4. Redistribution. You may reproduce and distribute copies of the\r
- Work or Derivative Works thereof in any medium, with or without\r
- modifications, and in Source or Object form, provided that You\r
- meet the following conditions:\r
-\r
- (a) You must give any other recipients of the Work or\r
- Derivative Works a copy of this License; and\r
-\r
- (b) You must cause any modified files to carry prominent notices\r
- stating that You changed the files; and\r
-\r
- (c) You must retain, in the Source form of any Derivative Works\r
- that You distribute, all copyright, patent, trademark, and\r
- attribution notices from the Source form of the Work,\r
- excluding those notices that do not pertain to any part of\r
- the Derivative Works; and\r
-\r
- (d) If the Work includes a "NOTICE" text file as part of its\r
- distribution, then any Derivative Works that You distribute must\r
- include a readable copy of the attribution notices contained\r
- within such NOTICE file, excluding those notices that do not\r
- pertain to any part of the Derivative Works, in at least one\r
- of the following places: within a NOTICE text file distributed\r
- as part of the Derivative Works; within the Source form or\r
- documentation, if provided along with the Derivative Works; or,\r
- within a display generated by the Derivative Works, if and\r
- wherever such third-party notices normally appear. The contents\r
- of the NOTICE file are for informational purposes only and\r
- do not modify the License. You may add Your own attribution\r
- notices within Derivative Works that You distribute, alongside\r
- or as an addendum to the NOTICE text from the Work, provided\r
- that such additional attribution notices cannot be construed\r
- as modifying the License.\r
-\r
- You may add Your own copyright statement to Your modifications and\r
- may provide additional or different license terms and conditions\r
- for use, reproduction, or distribution of Your modifications, or\r
- for any such Derivative Works as a whole, provided Your use,\r
- reproduction, and distribution of the Work otherwise complies with\r
- the conditions stated in this License.\r
-\r
- 5. Submission of Contributions. Unless You explicitly state otherwise,\r
- any Contribution intentionally submitted for inclusion in the Work\r
- by You to the Licensor shall be under the terms and conditions of\r
- this License, without any additional terms or conditions.\r
- Notwithstanding the above, nothing herein shall supersede or modify\r
- the terms of any separate license agreement you may have executed\r
- with Licensor regarding such Contributions.\r
-\r
- 6. Trademarks. This License does not grant permission to use the trade\r
- names, trademarks, service marks, or product names of the Licensor,\r
- except as required for reasonable and customary use in describing the\r
- origin of the Work and reproducing the content of the NOTICE file.\r
-\r
- 7. Disclaimer of Warranty. Unless required by applicable law or\r
- agreed to in writing, Licensor provides the Work (and each\r
- Contributor provides its Contributions) on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
- implied, including, without limitation, any warranties or conditions\r
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
- PARTICULAR PURPOSE. You are solely responsible for determining the\r
- appropriateness of using or redistributing the Work and assume any\r
- risks associated with Your exercise of permissions under this License.\r
-\r
- 8. Limitation of Liability. In no event and under no legal theory,\r
- whether in tort (including negligence), contract, or otherwise,\r
- unless required by applicable law (such as deliberate and grossly\r
- negligent acts) or agreed to in writing, shall any Contributor be\r
- liable to You for damages, including any direct, indirect, special,\r
- incidental, or consequential damages of any character arising as a\r
- result of this License or out of the use or inability to use the\r
- Work (including but not limited to damages for loss of goodwill,\r
- work stoppage, computer failure or malfunction, or any and all\r
- other commercial damages or losses), even if such Contributor\r
- has been advised of the possibility of such damages.\r
-\r
- 9. Accepting Warranty or Additional Liability. While redistributing\r
- the Work or Derivative Works thereof, You may choose to offer,\r
- and charge a fee for, acceptance of support, warranty, indemnity,\r
- or other liability obligations and/or rights consistent with this\r
- License. However, in accepting such obligations, You may act only\r
- on Your own behalf and on Your sole responsibility, not on behalf\r
- of any other Contributor, and only if You agree to indemnify,\r
- defend, and hold each Contributor harmless for any liability\r
- incurred by, or claims asserted against, such Contributor by reason\r
- of your accepting any such warranty or additional liability.\r
-\r
- END OF TERMS AND CONDITIONS\r
-\r
- APPENDIX: How to apply the Apache License to your work.\r
-\r
- To apply the Apache License to your work, attach the following\r
- boilerplate notice, with the fields enclosed by brackets "[]"\r
- replaced with your own identifying information. (Don't include\r
- the brackets!) The text should be enclosed in the appropriate\r
- comment syntax for the file format. We also recommend that a\r
- file or class name and description of purpose be included on the\r
- same "printed page" as the copyright notice for easier\r
- identification within third-party archives.\r
-\r
- Copyright [yyyy] [name of copyright owner]\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
#include "msg_transport_types.h"
#include "msg_types.h"
-#include <TelSms.h>
-#include <TapiUtility.h>
-#include <ITapiNetText.h>
+#ifdef SUPPORT_EMAIL
+/*Email Header Files*/
+#include "email-types.h"
+#include "email-api-init.h"
+#include "email-api-account.h"
+#include "email-api-mailbox.h"
+#include "email-api-mail.h"
+#include "email-api-network.h"
+#endif
#include <bluetooth_map_agent.h>
G_TYPE_INVALID))
static msg_handle_t g_msg_handle = NULL;
-static TapiHandle *g_tapi_handle = NULL;
-static TelSmsAddressInfo_t *g_sca_info = NULL;
#define BT_MAP_NEW_MESSAGE "NewMessage"
#define BT_MAP_STATUS_CB "sent status callback"
#define LANGUAGE "LANGUAGE:%s\r\n"
#define LENGTH "LENGTH:%d\r\n"
#define MSG_BODY "BEGIN:MSG\r\n%s\r\nEND:MSG\r\n"
-#define MSG_BODY_BEGIN "BEGIN:MSG\r\n"
-#define MSG_BODY_END "\r\nEND:MSG\r\n"
-GSList *id_list = NULL;
+/* This has been added for testing purpose, will be removed when SMS APIs
+ are available. */
+#define TEST_PDU "06810000000000040681567777000021017101750261A05"\
+ "376BA0D8297E5F3B73BCC4ED3F3A030FB1ECECF41613A"\
+ "5D1E1ED3E7A0B2BD2CCF8362AEA4195407C941ECF77C9"\
+ "E769F41753968FC769BD3E4B27B5C0691EB6510FD0D7AD"\
+ "BCBF27B397D46D343A163990E42BFDB6590BCDC4E93D3"\
+ "E539889E86CF41F437485E26D7C765D0DB5E96DFCBE933"\
+ "9A1E9A36A72063900AA2BF41B5DBED760385E920E9DC357B35A9"
+
+GSList* id_list = NULL;
guint64 current_push_map_id;
-typedef enum {
- SMS_TON_UNKNOWN = 0, /* unknown */
- SMS_TON_INTERNATIONAL = 1, /* international number */
- SMS_TON_NATIONAL = 2, /* national number */
- SMS_TON_NETWORK_SPECIFIC = 3, /* network specific number */
- SMS_TON_DEDICATED_ACCESS = 4, /* subscriber number */
- SMS_TON_ALPHA_NUMERIC = 5, /* alphanumeric, GSM 7-bit default */
- SMS_TON_ABBREVIATED_NUMBER = 6, /* abbreviated number */
- SMS_TON_RESERVED_FOR_EXT = 7 /* reserved for extension */
-} bt_sim_type_of_num_t;
-
struct id_info {
guint64 map_id;
int uid;
gchar *remote_addr,
gboolean status,
DBusGMethodInvocation *context);
-static gboolean bluetooth_map_destroy_agent(BluetoothMapAgent *agent,
- DBusGMethodInvocation *context);
+
#include "bluetooth_map_agent_glue.h"
static guint64 _bt_validate_uid(int uid)
{
- DBG("Validate uid");
- struct id_info *info;
- int count;
- int i;
-
- count = g_slist_length(id_list);
- for (i = 0; i < count; i++) {
- info = (struct id_info *)g_slist_nth_data(id_list, i);
+ DBG("Validate uid");
+ struct id_info *info;
+ int count;
+ int i;
+
+ count = g_slist_length(id_list);
+ for (i = 0; i < count; i++) {
+ info = (struct id_info *)g_slist_nth_data(id_list, i);
if (!info)
break;
- if (info->uid == uid) {
- printf("uid = %d\n", uid);
- return info->map_id;
- }
- }
+ if (info->uid == uid) {
+ printf("uid = %d\n", uid);
+ return info->map_id;
+ }
+ }
- return 0;
+ return 0;
}
static guint64 __bt_add_id(int uid)
{
- DBG("Add id: %d\n", uid);
- static guint64 map_id;
- struct id_info *info;
- guint64 test;
+ DBG("Add id: %d\n", uid);
+ static guint64 map_id;
+ struct id_info *info;
+ guint64 test;
- test = _bt_validate_uid(uid);
- DBG("test: %llx\n", test);
- if (test)
- return test;
+ test = _bt_validate_uid(uid);
+ DBG("test: %llx\n", test);
+ if (test)
+ return test;
- info = g_new0(struct id_info, 1);
+ info = g_new0(struct id_info, 1);
- map_id++;
+ map_id++;
- info->map_id = map_id;
- info->uid = uid;
- DBG("map_id = %llx, uid = %d \n", info->map_id, info->uid);
+ info->map_id = map_id;
+ info->uid = uid;
+ DBG("map_id = %llx, uid = %d \n", info->map_id, info->uid);
- id_list = g_slist_append(id_list, info);
+ id_list = g_slist_append(id_list, info);
- return map_id;
+ return map_id;
}
static int __bt_get_id(guint64 map_id)
{
- DBG("get id\n");
- struct id_info *info;
- int count;
+ DBG("get id\n");
+ struct id_info *info;
+ int count;
int i;
- count = g_slist_length(id_list);
+ count = g_slist_length(id_list);
- for (i = 0; i < count; i++) {
- info = (struct id_info *)g_slist_nth_data(id_list, i);
+ for (i = 0; i < count; i++) {
+ info = (struct id_info *)g_slist_nth_data(id_list, i);
- if (info->map_id == map_id)
- return info->uid;
- }
+ if (info->map_id == map_id)
+ return info->uid;
+ }
- return -1;
+ return -1;
}
static int __bt_get_uid(gchar *handle)
}
}
- return -1;
+ return -1;
}
static void __bt_remove_list(GSList *id_list)
if (!id_list)
return;
- DBG("Removing id list\n");
- g_slist_free_full(id_list, g_free);
+ DBG("Removing id list\n");
+ g_slist_free_full(id_list, g_free);
}
int ret;
char folder_name[BT_MAP_MSG_INFO_MAX] = {0,};
- msg_struct_list_s folder_list = {0,};
+ msg_struct_list_s g_folderList;
msg_struct_t p_folder;
- ret = msg_get_folder_list(g_msg_handle, &folder_list);
+ ret = msg_get_folder_list(g_msg_handle, &g_folderList);
if (ret != MSG_SUCCESS)
- return g_strdup("TELECOM/MSG");
-
- if (folder_list.msg_struct_info == NULL)
- return g_strdup("TELECOM/MSG");
+ goto done;
- p_folder = folder_list.msg_struct_info[id];
+ p_folder = g_folderList.msg_struct_info[id];
ret = msg_get_str_value(p_folder, MSG_FOLDER_INFO_NAME_STR,
folder_name, BT_MAP_MSG_INFO_MAX);
+ if (ret != MSG_SUCCESS)
+ goto done;
- if (folder_list.msg_struct_info) {
- ret = msg_release_list_struct(&folder_list);
- DBG("Err %d", ret);
- }
+ return g_strdup_printf("TELECOM/MSG/%s", folder_name);
- if (ret != MSG_SUCCESS)
- return g_strdup("TELECOM/MSG");
- else
- return g_strdup_printf("TELECOM/MSG/%s", folder_name);
+done:
+ return g_strdup("TELECOM/MSG");
}
static void __get_msg_timestamp(time_t *ltime, char *timestamp)
return;
}
-#define SET_TON_NPI(dest, ton, npi) { \
- dest = 0x80; \
- dest |= (ton & 0x07) << 4; \
- dest |= npi & 0x0F; \
-}
-
-static int __bt_ascii_to_upper(int ch)
-{
- return (('a' <= (ch) && (ch) <= 'z') ? ((ch) - ('a'-'A')) : (ch));
-}
-
-static int __bt_sms_pack_gsm_code(gchar *p_out, const char *data, int in_len)
-{
- DBG("+");
- int i;
- int pos;
- int shift = 0;
-
- for (pos = 0, i = 0; i < in_len; pos++, i++) {
- /* pack the low bits */
- p_out[pos] = data[i] >> shift;
-
- if (i + 1 < in_len) {
- /* pack the high bits using the low bits
- of the next character */
- p_out[pos] |= data[i+1] << (7 - shift);
-
- shift++;
-
- if (shift == 7) {
- shift = 0;
- i++;
- }
- }
- }
- DBG("-");
- return pos;
-}
-
-static void __bt_sms_conv_digit_to_bcd(gchar *p_bcd, char *p_digits, int digit_len)
-{
- int i;
- int j;
- int digit;
- unsigned char higher;
- unsigned char lower;
-
- if (p_bcd == NULL || p_digits == NULL)
- return;
-
- /* 0123456789 -> 1032547698 */
- for (i = 0, j = 0; i < digit_len; i = i + 2, j++) {
- if (p_digits[i] == '*')
- digit = 0x0A;
- else if (p_digits[i] == '#')
- digit = 0x0B;
- else if (__bt_ascii_to_upper(p_digits[i]) == 'P')
- digit = 0x0C;
- else
- digit = (int) (p_digits[i] - '0');
-
- lower = digit & 0x0F;
-
- if (digit_len != i + 1) {
- if (p_digits[i+1] == '*')
- digit = 0x0A;
- else if (p_digits[i+1] == '#')
- digit = 0x0B;
- else if (__bt_ascii_to_upper(p_digits[i+1]) == 'P')
- digit = 0x0C;
- else
- digit = (int) (p_digits[i+1] - '0');
-
- higher = digit & 0x0F;
- } else {
- higher = 0xFF;
- }
-
- p_bcd[j] = (higher << 4) | lower;
- }
-}
-
-static int __bt_sms_encode_addr(gchar *addr_field, char *dial_num,
- int dial_num_len, int ton, int npi)
-{
- DBG("+");
- int index = 0;
-
- if (dial_num == NULL || addr_field == NULL)
- return -1;
-
- if (dial_num[0] == '+') {
- dial_num++;
- dial_num_len--;
- ton = SMS_TON_INTERNATIONAL;
- }
-
- if (ton != SMS_TON_ALPHA_NUMERIC) {
- /* Origination address length address length */
- addr_field[index++] = (unsigned char)dial_num_len;
- } else {
- addr_field[index] = (unsigned char)
- (((dial_num_len * 7 + 7) / 8) * 2);
-
- if (((dial_num_len * 7) % 8) <= 4)
- addr_field[index]--;
-
- index++;
- }
-
- SET_TON_NPI(addr_field[index], ton, npi);
- index++; /* SET_TON_NPI */
-
- if (ton != SMS_TON_ALPHA_NUMERIC) {
- __bt_sms_conv_digit_to_bcd(&addr_field[index],
- (char *)dial_num, dial_num_len);
-
- if (dial_num_len % 2)
- index += (dial_num_len / 2) + 1;
- else
- index += dial_num_len / 2;
- } else {
- index += __bt_sms_pack_gsm_code(&addr_field[index],
- dial_num, (int)dial_num_len);
- }
-
- return index;
-}
-
-static int __bt_sms_encode_time(gchar *addr_field, time_t *tm)
-{
- int index = 0;
- struct tm ltime;
- int year;
- int month;
-
- if (!localtime_r(tm, <ime))
- return index;
-
- year = ltime.tm_year + 1900; /* years since 1900 */
- year = year % 100;
- month = ltime.tm_mon + 1; /* months since January */
-
- addr_field[index++] = ((year % 10) << 4) + (year / 10);
- addr_field[index++] = ((month % 10) << 4) + (month / 10);
- addr_field[index++] = ((ltime.tm_mday % 10) << 4) +
- (ltime.tm_mday / 10);
- addr_field[index++] = ((ltime.tm_hour % 10) << 4) +
- (ltime.tm_hour / 10);
- addr_field[index++] = ((ltime.tm_min % 10) << 4) + (ltime.tm_min / 10);
- addr_field[index++] = ((ltime.tm_sec % 10) << 4) + (ltime.tm_sec / 10);
- addr_field[index] = 0x00;
-
- return index;
-}
-
-static gchar *__bt_get_sms_pdu_from_msg_data(gchar *number,
- char *msg, time_t tm,
- int *msg_pdu_len)
-{
- DBG("+");
- gchar packet[TAPI_NETTEXT_MSG_SIZE_MAX] = {0,};
- int index = 0;
-
- packet[index] = 0x00; /* Since SCA is unknown for stored messages */
- index++;
-
- /* TP-MTI : Type of message */
- packet[index] = 0x00; /* SMS-DELIVER PDU */
-
- /* TP-MMS bit is set to 1 as we support only SMS */
- packet[index] |= 0x04;
- index++;
-
- /* TP-OA : Mobile originating address */
- index += __bt_sms_encode_addr(packet+index,
- number, strlen(number),
- g_sca_info->Ton, g_sca_info->Npi);
-
- /* TP-PID : Since we use only SMS so set to 0 */
- packet[index++] = 0x00;
-
- /* TP-DCS : Data Coding Scheme, default value set */
- packet[index++] = 0x00;
-
- /* TP-SCTS : Message timestamp */
- index += __bt_sms_encode_time(packet+index, &tm);
- index++;
- /* TP-UDL : Message body length */
- packet[index++] = strlen(msg);
-
- /* TP-UD : Message body */
- index += __bt_sms_pack_gsm_code(packet + index, msg, strlen(msg));
-
- *msg_pdu_len = index;
- DBG("-");
-
- return g_memdup(packet, index);
-}
-
-static void __bt_get_sms_sca(TapiHandle *handle, int result, void *data,
- void *user_data)
-{
- TelSmsAddressInfo_t *scaInfo = data;
- unsigned int i = 0;
-
- DBG("__bt_get_sms_sca 0x%x", result);
-
- if (data == NULL)
- return;
-
- g_sca_info = g_malloc0(sizeof(TelSmsAddressInfo_t));
- g_sca_info->Ton = scaInfo->Ton;
- g_sca_info->Npi = scaInfo->Npi;
- g_sca_info->DialNumLen = scaInfo->DialNumLen;
-
- DBG(" - TON = %d", scaInfo->Ton);
- DBG(" - NPI = %d", scaInfo->Npi);
- DBG(" - DialNumLen = %d", scaInfo->DialNumLen);
- DBG(" - SCA Num");
-
- for (i = 0; i < scaInfo->DialNumLen; i++) {
- g_sca_info->szDiallingNum[i] = scaInfo->szDiallingNum[i];
- DBG("[%02x]", g_sca_info->szDiallingNum[i]);
- }
-}
-
static char *__bt_prepare_msg_bmseg(msg_struct_t msg_info, gboolean attach,
gboolean transcode)
{
int m_type = MSG_TYPE_SMS;
int folder_id;
int count;
- int dptime = 0;
- int j;
bool read_status = false;
char msg_body[BT_MAP_MSG_BODY_MAX] = {0,};
char addr_value[MAX_ADDRESS_VAL_LEN] = {0,};
- char name_value[MAX_DISPLAY_NAME_LEN] = {0,};
-
- msg_list_handle_t addr_list = NULL;
- msg_struct_t addr_info = NULL;
+ char name_value[MAX_ADDRESS_VAL_LEN] = {0,};
+ gchar *folder_path;
+ msg_struct_list_s *addr_list = NULL;
GString *msg;
- gchar *folder_path;
- gchar *msg_pdu;
msg = g_string_new(BEGIN_BMSEG);
g_string_append(msg, BMSEG_VERSION);
ret = msg_get_int_value(msg_info, MSG_MESSAGE_TYPE_INT, &m_type);
if (ret == MSG_SUCCESS) {
DBG("m_type %d\n", m_type);
+ }
+
+ switch (m_type) {
+ case MSG_TYPE_MMS:
+ case MSG_TYPE_MMS_JAVA:
+ case MSG_TYPE_MMS_NOTI:
+ g_string_append_printf(msg, MSEG_TYPE, "MMS");
+ break;
+
+ default:
g_string_append_printf(msg, MSEG_TYPE, "SMS_GSM");
+ break;
}
ret = msg_get_int_value(msg_info, MSG_MESSAGE_FOLDER_ID_INT,
&folder_id);
if (ret == MSG_SUCCESS) {
DBG("folder_id %d\n", folder_id);
-
- folder_path = __bt_get_folder_name(folder_id);
- g_string_append_printf(msg, FOLDER_PATH, folder_path);
}
- ret = msg_get_list_handle(msg_info, MSG_MESSAGE_ADDR_LIST_HND,
- (void **)&addr_list);
+ folder_path = __bt_get_folder_name(folder_id);
+ g_string_append_printf(msg, FOLDER_PATH, folder_path);
+
+
+ ret = msg_get_list_handle(msg_info, MSG_MESSAGE_ADDR_LIST_STRUCT,
+ (void **)&addr_list);
if (ret == MSG_SUCCESS) {
- count = msg_list_length(addr_list);
+ count = addr_list->nCount;
DBG("count %d \n", count);
-
- if (count > 0) {
- addr_info = (msg_struct_t)msg_list_nth_data(addr_list,
- 0);
+ while (count > 0) {
+ msg_struct_t addr_info = NULL;
+ addr_info = addr_list->msg_struct_info[count - 1];
msg_get_str_value(addr_info,
MSG_ADDRESS_INFO_ADDRESS_VALUE_STR,
DBG("addr_value %s\n", addr_value);
msg_get_str_value(addr_info,
MSG_ADDRESS_INFO_DISPLAYNAME_STR,
- name_value, MAX_DISPLAY_NAME_LEN);
+ name_value, MAX_ADDRESS_VAL_LEN);
if (!strlen(name_value))
g_stpcpy(name_value, addr_value);
g_string_append_printf(msg, VCARD, name_value,
addr_value);
+ count--;
}
}
if (transcode) {
g_string_append_printf(msg, CHARSET, "UTF-8");
+ if (m_type == MSG_TYPE_MMS)
+ ret = msg_get_str_value(msg_info,
+ MSG_MESSAGE_MMS_TEXT_STR,
+ msg_body, BT_MAP_SUBJECT_MAX_LEN);
+ else
+ ret = msg_get_str_value(msg_info,
+ MSG_MESSAGE_SMS_DATA_STR,
+ msg_body, BT_MAP_MSG_BODY_MAX);
- ret = msg_get_str_value(msg_info,
- MSG_MESSAGE_SMS_DATA_STR,
- msg_body, BT_MAP_MSG_BODY_MAX);
if (ret == MSG_SUCCESS) {
g_string_append_printf(msg, LENGTH, strlen(msg_body));
g_string_append_printf(msg, MSG_BODY, msg_body);
}
} else {
+ gchar *msg_pdu;
g_string_append_printf(msg, ENCODING, "G-7BIT");
g_string_append_printf(msg, CHARSET, "native");
-
- msg_get_int_value(msg_info,
- MSG_MESSAGE_DISPLAY_TIME_INT, &dptime);
-
- ret = msg_get_str_value(msg_info, MSG_MESSAGE_SMS_DATA_STR,
- msg_body, BT_MAP_MSG_BODY_MAX);
- if (ret == MSG_SUCCESS) {
- int msg_pdu_len = 0;
- msg_pdu = __bt_get_sms_pdu_from_msg_data(addr_value,
- msg_body, dptime,
- &msg_pdu_len);
- DBG("msg_pdu_len = %d", msg_pdu_len);
-
- g_string_append_printf(msg, LENGTH, msg_pdu_len);
- g_string_append(msg, MSG_BODY_BEGIN);
- for (j = 0; j < msg_pdu_len; j++)
- g_string_append_printf(msg, "%02x",
- msg_pdu[j]);
-
- g_string_append(msg, MSG_BODY_END);
- g_free(msg_pdu);
- }
+ /* The below line has been added for testing purpose,
+ will be removed when SMS APIs are available. */
+ msg_pdu = g_strdup(TEST_PDU);
+ g_string_append_printf(msg, LENGTH, strlen(msg_pdu));
+ g_string_append_printf(msg, MSG_BODY, msg_pdu);
+ g_free(msg_pdu);
}
g_string_append(msg, END_BBODY);
int data_size;
int priority;
int direction_type;
- int count;
bool protect_status = 0;
bool read_status = 0;
char msg_size[5] = {0,};
char msg_body[BT_MAP_MSG_BODY_MAX] = {0,};
char addr_value[MAX_ADDRESS_VAL_LEN] = {0,};
- char name_value[MAX_DISPLAY_NAME_LEN] = {0,};
+ char name_value[MAX_ADDRESS_VAL_LEN] = {0,};
msg_info.text = FALSE;
msg_info.protect = FALSE;
msg_struct_t msg = NULL;
msg_struct_t send_opt = NULL;
- msg_list_handle_t addr_list = NULL;
+ msg_struct_list_s *addr_list = NULL;
msg_struct_t addr_info = NULL;
ret = msg_get_int_value(msg_struct_handle, MSG_MESSAGE_ID_INT, &msg_id);
goto next;
}
- ret = msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND,
+ ret = msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_STRUCT,
(void **)&addr_list);
if (ret != MSG_SUCCESS) {
DBG("ret = %d\n", ret);
goto next;
}
- count = msg_list_length(addr_list);
-
- if (count != 0) {
- addr_info = (msg_struct_t)msg_list_nth_data(addr_list, 0);
+ addr_info = addr_list->msg_struct_info[0];
- ret = msg_get_str_value(addr_info,
- MSG_ADDRESS_INFO_ADDRESS_VALUE_STR,
- addr_value, MAX_ADDRESS_VAL_LEN);
- if (ret == MSG_SUCCESS)
- DBG("addr_value %s\n", addr_value);
-
- ret = msg_get_str_value(addr_info,
- MSG_ADDRESS_INFO_DISPLAYNAME_STR,
- name_value, MAX_DISPLAY_NAME_LEN);
+ ret = msg_get_str_value(addr_info, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR,
+ addr_value, MAX_ADDRESS_VAL_LEN);
+ if (ret == MSG_SUCCESS)
+ DBG("addr_value %s\n", addr_value);
- if (ret == MSG_SUCCESS)
- DBG("name_value %s\n", name_value);
+ ret = msg_get_str_value(addr_info, MSG_ADDRESS_INFO_DISPLAYNAME_STR,
+ name_value, MAX_ADDRESS_VAL_LEN);
+ if (ret == MSG_SUCCESS)
+ DBG("name_value %s\n", name_value);
- if (!strlen(name_value))
- g_stpcpy(name_value, addr_value);
+ if (!strlen(name_value))
+ g_stpcpy(name_value, addr_value);
- DBG("name_value %s\n", name_value);
- }
+ DBG("name_value %s\n", name_value);
- ret = msg_get_int_value(msg, MSG_MESSAGE_DIRECTION_INT,
- &direction_type);
+ ret = msg_get_int_value(msg, MSG_MESSAGE_DIRECTION_INT, &direction_type);
if (ret != MSG_SUCCESS)
goto next;
msg_release_struct(&msg);
msg_release_struct(&send_opt);
- ret = msg_get_int_value(msg_struct_handle,
- MSG_MESSAGE_DISPLAY_TIME_INT, &dptime);
+ ret = msg_get_int_value(msg_struct_handle, MSG_MESSAGE_DISPLAY_TIME_INT, &dptime);
if (ret == MSG_SUCCESS) {
__get_msg_timestamp((time_t *)&dptime, msg_datetime);
}
{
msg_error_t err = MSG_SUCCESS;
gboolean msg_ret = TRUE;
+#ifdef SUPPORT_EMAIL
+ int email_err = EMAIL_ERROR_NONE;
+ gboolean email_ret = TRUE;
+#endif
err = msg_open_msg_handle(&g_msg_handle);
if (err != MSG_SUCCESS) {
}
done:
+
+#ifdef SUPPORT_EMAIL
+
+ email_err = email_service_begin();
+ if (email_err != EMAIL_ERROR_NONE) {
+ ERR("email_service_begin fail error = %d\n", email_err);
+ email_ret = FALSE;
+ }
+
+ if (msg_ret || email_ret)
+ return TRUE;
+ else
+ return FALSE;
+
+#else
+
return msg_ret;
+
+#endif
}
static void __bluetooth_map_stop_service()
g_msg_handle = NULL;
+#ifdef SUPPORT_EMAIL
+ if (EMAIL_ERROR_NONE != email_service_end())
+ ERR("email_service_end fail \n");
+#endif
return;
}
-static gboolean __bt_convert_to_utf8(char **text)
+#ifdef SUPPORT_EMAIL
+static int __bt_store_mail(email_mailbox_type_e type, char *subject,
+ char *body, char *recepients)
{
- char *utf8;
- gsize len;
+ int account_id;
+ int mail_id;
+ int err;
+ char from_address[BT_MAIL_ID_MAX_LENGTH] = { 0, };
+ FILE *body_file;
+ struct stat st_buf;
+
+ email_account_t *account_data = NULL;
+ email_mailbox_t *mailbox_data = NULL;
+ email_mail_data_t *mail_data = NULL;
+
+ err = email_load_default_account_id(&account_id);
+ if (EMAIL_ERROR_NONE != err)
+ goto fail;
- if (g_utf8_validate(*text, -1, NULL))
- return TRUE;
+ err = email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD,
+ &account_data);
+ if (EMAIL_ERROR_NONE != err)
+ goto fail;
- utf8 = g_convert(*text, -1, "UTF-8", "ISO-8859-1", 0, &len, NULL);
- if (!utf8)
- return FALSE;
+ err = email_get_mailbox_by_mailbox_type(account_id, type,
+ &mailbox_data);
+ if (EMAIL_ERROR_NONE != err)
+ goto fail;
- DBG("conversion done %d\n", len);
- g_free(*text);
- *text = utf8;
+ snprintf(from_address, BT_MAIL_ID_MAX_LENGTH, "<%s>",
+ account_data->user_email_address);
+ email_free_account(&account_data, 1);
- return TRUE;
-}
+ mail_data = calloc(1, sizeof(email_mail_data_t));
+ if (NULL == mail_data) {
+ email_free_mailbox(&mailbox_data, 1);
+ goto fail;
+ }
-static gboolean __bt_convert_msg_data(struct message_info *msg_info)
-{
- if (msg_info == NULL)
- return FALSE;
+ DBG("\n account_id %d\n", account_id);
+ mail_data->account_id = account_id;
+ mail_data->save_status = 1;
+ mail_data->body_download_status = 1;
+ /* mail_data->flags_draft_field = 1; */
+ mail_data->flags_seen_field = 1;
+ mail_data->file_path_plain = g_strdup(BT_MAIL_TEMP_BODY);
+
+ mail_data->mailbox_id = mailbox_data->mailbox_id;
+ mail_data->mailbox_type = mailbox_data->mailbox_type;
+ email_free_mailbox(&mailbox_data, 1);
+
+ mail_data->full_address_from = g_strdup(from_address);
+ mail_data->full_address_to = g_strdup(recepients);
+ mail_data->subject = g_strdup(subject);
+ mail_data->report_status = EMAIL_MAIL_REQUEST_DSN |
+ EMAIL_MAIL_REQUEST_MDN;
+
+ body_file = fopen(BT_MAIL_TEMP_BODY, "w");
+ if (body_file == NULL) {
+ DBG("\n fopen [%s]failed\n", BT_MAIL_TEMP_BODY);
+ email_free_mail_data(&mail_data, 1);
+ goto fail;
+ }
+
+ fprintf(body_file, body);
+ fflush(body_file);
+ fclose(body_file);
- if (msg_info->subject)
- if (!__bt_convert_to_utf8(&msg_info->subject))
- return FALSE;
+ err = email_add_mail(mail_data, NULL, 0, NULL, 0);
+ if (err != EMAIL_ERROR_NONE) {
+ DBG("email_add_mail failed. [%d]\n", err);
+ if (!stat(mail_data->file_path_plain, &st_buf))
+ remove(mail_data->file_path_plain);
- if (msg_info->sender_name)
- if (!__bt_convert_to_utf8(&msg_info->sender_name))
- return FALSE;
+ email_free_mail_data(&mail_data, 1);
+ goto fail;
+ }
- if (msg_info->sender_addressing)
- if (!__bt_convert_to_utf8(&msg_info->sender_addressing))
- return FALSE;
+ DBG("saved mail id = [%d]\n", mail_data->mail_id);
- if (msg_info->replyto_addressing)
- if (!__bt_convert_to_utf8(&msg_info->replyto_addressing))
- return FALSE;
+ mail_id = mail_data->mail_id;
- if (msg_info->recipient_name)
- if (!__bt_convert_to_utf8(&msg_info->recipient_name))
- return FALSE;
+ email_free_mail_data(&mail_data, 1);
- if (msg_info->recipient_addressing)
- if (!__bt_convert_to_utf8(&msg_info->recipient_addressing))
- return FALSE;
+ return mail_id;
- return TRUE;
+fail:
+ return 0;
}
+static int __bt_email_send(char *subject, char *body, char* recepients)
+{
+ int err;
+ int mail_id;
+ int handle;
+
+ mail_id = __bt_store_mail(EMAIL_MAILBOX_TYPE_OUTBOX, subject,
+ body, recepients);
+ if (mail_id) {
+ DBG("mail_id = %d\n", mail_id);
+ err = email_send_mail(mail_id, &handle);
+ if (err != EMAIL_ERROR_NONE)
+ DBG("Sending failed[%d]\n", err);
+ }
+
+ return mail_id;
+}
+#endif
+
static int __bt_get_folder_id(char *folder_path)
{
int folder_id = -1;
int i;
char *folder;
- msg_struct_list_s folder_list = {0,};
+ msg_struct_list_s folder_list;
msg_error_t err;
msg_struct_t p_folder;
- DBG("folder_path %s\n", folder_path);
+ DBG("__bt_get_folder_id\n");
folder = strrchr(folder_path, '/');
if (NULL == folder)
err = msg_get_folder_list(g_msg_handle, &folder_list);
if (err != MSG_SUCCESS)
- goto done;
+ return -1;
for (i = 0; i < folder_list.nCount; i++) {
p_folder = folder_list.msg_struct_info[i];
if (err != MSG_SUCCESS)
continue;
- DBG("folder_name %s\n", folder_name);
+ DBG("folderName %s\n", folder_name);
if (!g_ascii_strncasecmp(folder_name, folder, strlen(folder))) {
- err = msg_get_int_value(p_folder,
- MSG_FOLDER_INFO_ID_INT,
- &folder_id);
+ err = msg_get_int_value(p_folder, MSG_FOLDER_INFO_ID_INT,
+ &folder_id);
if (err != MSG_SUCCESS)
- goto done;
+ return -1;
- DBG("folder_id %d", folder_id);
break;
}
}
-done:
- if (folder_list.msg_struct_info) {
- err = msg_release_list_struct(&folder_list);
- DBG("Err%d", err);
- }
-
return folder_id;
}
DBG("+ \n");
msg_struct_t msg_info = NULL;
msg_struct_t send_opt = NULL;
+ msg_struct_list_s *addr_list;
msg_error_t err;
int count = 0;
goto fail;
if (body) {
- err = msg_set_str_value(msg_info,
- MSG_MESSAGE_SMS_DATA_STR,
- body, strlen(body));
+ err = msg_set_str_value(msg_info, MSG_MESSAGE_SMS_DATA_STR, body,
+ strlen(body));
if (err != MSG_SUCCESS)
goto fail;
} else {
if (recepients) {
count = g_slist_length(recepients);
DBG("Count = %d\n", count);
+ msg_get_list_handle(msg_info, MSG_MESSAGE_ADDR_LIST_STRUCT,
+ (void**)&addr_list);
+ addr_list->nCount = count;
for (i = 0; i < count; i++) {
- msg_struct_t tmp_addr;
char *address = (char *)g_slist_nth_data(recepients, i);
if (address == NULL) {
DBG("[ERROR] address is value NULL, skip");
continue;
}
- msg_list_add_item(msg_info,
- MSG_MESSAGE_ADDR_LIST_HND, &tmp_addr);
+ msg_set_int_value(addr_list->msg_struct_info[i],
+ MSG_ADDRESS_INFO_ADDRESS_TYPE_INT,
+ MSG_ADDRESS_TYPE_PLMN);
- msg_set_int_value(tmp_addr,
- MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT,
- MSG_RECIPIENTS_TYPE_TO);
+ msg_set_int_value(addr_list->msg_struct_info[i],
+ MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT,
+ MSG_RECIPIENTS_TYPE_TO);
- msg_set_str_value(tmp_addr,
- MSG_ADDRESS_INFO_ADDRESS_VALUE_STR,
- address, strlen(address));
+ msg_set_str_value(addr_list->msg_struct_info[i],
+ MSG_ADDRESS_INFO_ADDRESS_VALUE_STR,
+ address, strlen(address));
}
}
int ret;
gboolean msg_ret = TRUE;
- msg_struct_list_s folder_list = {0,};
+ msg_struct_list_s g_folderList;
msg_struct_t p_folder;
+#ifdef SUPPORT_EMAIL
+ int j;
+ int account_id = 0;
+ int mailbox_count = 0;
+ gboolean flag = FALSE;
+ email_mailbox_t *mailbox_list = NULL;
+#endif
+
if (g_msg_handle == NULL) {
msg_ret = FALSE;
goto done;
}
- if (msg_get_folder_list(g_msg_handle, &folder_list) != MSG_SUCCESS) {
+ if (msg_get_folder_list(g_msg_handle, &g_folderList) != MSG_SUCCESS) {
msg_ret = FALSE;
goto done;
}
- for (i = 0; i < folder_list.nCount; i++) {
- p_folder = folder_list.msg_struct_info[i];
+ for (i = 0; i < g_folderList.nCount; i++) {
+ p_folder = g_folderList.msg_struct_info[i];
memset(folder_name, 0x00, BT_MAP_MSG_INFO_MAX);
ret = msg_get_str_value(p_folder, MSG_FOLDER_INFO_NAME_STR,
g_ptr_array_add(array, g_value_get_boxed(&value));
}
-done:
+#ifdef SUPPORT_EMAIL
+email:
+ if (EMAIL_ERROR_NONE != email_load_default_account_id(&account_id))
+ goto done;
- if (folder_list.msg_struct_info) {
- ret = msg_release_list_struct(&folder_list);
- DBG("Err %d", ret);
+ if (EMAIL_ERROR_NONE != email_get_mailbox_list(account_id,
+ EMAIL_MAILBOX_ALL,
+ &mailbox_list,
+ &mailbox_count)) {
+ goto done;
}
+ msg_ret = TRUE;
+
+ for (i = 0; i < mailbox_count; i++) {
+ flag = FALSE;
+ for (j = 0; j < g_folderList.nCount; j++) {
+
+ p_folder = g_folderList.msg_struct_info[j];
+ memset(folder_name, 0x00, BT_MAP_MSG_INFO_MAX);
+
+ ret = msg_get_str_value(p_folder,
+ MSG_FOLDER_INFO_NAME_STR,
+ folder_name,
+ BT_MAP_MSG_INFO_MAX);
+ if (ret != MSG_SUCCESS)
+ continue;
+
+ if (!g_ascii_strncasecmp(mailbox_list[i].alias,
+ folder_name, strlen(mailbox_list[i].alias))) {
+ flag = TRUE;
+ break;
+ }
+ }
+
+ if (!flag) {
+ g_strlcpy(name, mailbox_list[i].alias, sizeof(name));
+
+ if (!g_ascii_strncasecmp(name, BT_MAP_SENT_FOLDER_NAME,
+ strlen(BT_MAP_SENT_FOLDER_NAME)))
+ continue;
+
+ memset(&value, 0, sizeof(GValue));
+ g_value_init(&value, DBUS_STRUCT_STRING_STRING_UINT);
+ g_value_take_boxed(&value,
+ dbus_g_type_specialized_construct(
+ DBUS_STRUCT_STRING_STRING_UINT));
+ dbus_g_type_struct_set(&value, 0, name, G_MAXUINT);
+ g_ptr_array_add(array, g_value_get_boxed(&value));
+ }
+ }
+
+ if (mailbox_list != NULL)
+ email_free_mailbox(&mailbox_list, mailbox_count);
+#endif
+
+done:
+
if (msg_ret == FALSE) {
g_ptr_array_free(array, TRUE);
char *folder = NULL;
int i = 0;
int ret = 0;
- int folder_id = -1;
+ int folder_id = 0;
int unread_cnt;
- guint64 count = 0;
- gboolean newmsg = FALSE;
+ guint64 count;
+ gboolean newmsg;
- msg_struct_list_s folder_list = {0,};
- msg_struct_list_s msg_list = {0,};
+ msg_struct_list_s g_folderList;
+ msg_struct_list_s msg_list;
msg_struct_t count_info;
- msg_struct_t list_cond;
+
+#ifdef SUPPORT_EMAIL
+ int total = 0;
+ int account_id = 0;
+ int mailbox_count = 0;
+ int mail_count = 0;
+ char *type = NULL;
+ char msg_datetime[BT_MAP_TIMESTAMP_MAX_LEN] = {0,};
+ email_mailbox_t *mailbox_list = NULL;
+ email_mail_list_item_t *mail_list = NULL;
+ email_list_filter_t *filter_list = NULL;
+ email_list_sorting_rule_t *sorting_rule_list = NULL;
+#endif
if (g_msg_handle == NULL)
goto fail;
else
folder++;
- if (!strlen(folder))
- goto done;
-
- ret = msg_get_folder_list(g_msg_handle, &folder_list);
+ ret = msg_get_folder_list(g_msg_handle, &g_folderList);
if (ret != MSG_SUCCESS)
goto fail;
- for (i = 0; i < folder_list.nCount; i++) {
- msg_struct_t pFolder = folder_list.msg_struct_info[i];
+ for (i = 0; i < g_folderList.nCount; i++) {
+ msg_struct_t pFolder = g_folderList.msg_struct_info[i];
char folderName[BT_MAP_MSG_INFO_MAX] = {0, };
ret = msg_get_str_value(pFolder, MSG_FOLDER_INFO_NAME_STR,
}
}
- if (folder_id == -1)
- goto done;
-
- list_cond = msg_create_struct(MSG_STRUCT_MSG_LIST_CONDITION);
- ret = msg_set_int_value(list_cond,
- MSG_LIST_CONDITION_FOLDER_ID_INT,
- folder_id);
- if (ret != MSG_SUCCESS)
- goto fail;
-
- ret = msg_get_message_list2(g_msg_handle, list_cond, &msg_list);
-
- msg_release_struct(&list_cond);
-
- if (ret != MSG_SUCCESS)
+ ret = msg_get_folder_view_list(g_msg_handle, folder_id,
+ NULL, &msg_list);
+ if (ret != MSG_SUCCESS)
goto fail;
count = msg_list.nCount;
if (unread_cnt != 0)
newmsg = TRUE;
+ else
+ newmsg = FALSE;
msg_release_struct(&count_info);
msg_info = __bt_message_info_get(msg_list.msg_struct_info[i]);
- if (!__bt_convert_msg_data(&msg_info)) {
- __bt_message_info_free(msg_info);
- continue;
- }
+/* Keeping the bleow debug till stabilization is done. */
+
+/*
+ DBG("msg_info.handle = %s\n", msg_info.handle);
+ DBG("msg_info.subject = %s\n", msg_info.subject);
+ DBG("msg_info.datetime = %s\n", msg_info.datetime);
+ DBG("msg_info.sender_name = %s\n", msg_info.sender_name);
+ DBG("msg_info.sender_addressing = %s\n", msg_info.sender_addressing);
+ DBG("msg_info.replyto_addressing = %s\n", msg_info.replyto_addressing);
+ DBG("msg_info.recipient_name = %s\n", msg_info.recipient_name);
+ DBG("msg_info.recipient_addressing = %s\n",
+ msg_info.recipient_addressing);
+ DBG("msg_info.type = %s\n", msg_info.type);
+ DBG("msg_info.reception_status = %s\n", msg_info.reception_status);
+ DBG("msg_info.size = %s\n", msg_info.size);
+ DBG("msg_info.attachment_size = %s\n", msg_info.attachment_size);
+ DBG("msg_info.text = %d\n", msg_info.text);
+ DBG("msg_info.read = %d\n", msg_info.read);
+ DBG("msg_info.sent = %d\n", msg_info.sent);
+ DBG("msg_info.protect = %d\n", msg_info.protect);
+ DBG("msg_info.priority = %d\n", msg_info.priority);
+*/
dbus_g_type_struct_set(&value, 0, msg_info.handle,
1, msg_info.subject,
13, msg_info.read,
14, msg_info.sent,
15, msg_info.protect,
- 16, msg_info.replyto_addressing,
- G_MAXUINT);
+ 16, msg_info.replyto_addressing, G_MAXUINT);
g_ptr_array_add(array, g_value_get_boxed(&value));
__bt_message_info_free(msg_info);
}
-done:
- DBG("Request completed \n");
+#ifdef SUPPORT_EMAIL
+email:
+ if (EMAIL_ERROR_NONE != email_load_default_account_id(&account_id)) {
+ if (!msg_ret)
+ goto fail;
+ }
- if (folder_list.msg_struct_info) {
- ret = msg_release_list_struct(&folder_list);
- DBG("Err %d", ret);
+ if (EMAIL_ERROR_NONE != email_get_mailbox_list(account_id,
+ EMAIL_MAILBOX_ALL,
+ &mailbox_list,
+ &mailbox_count)) {
+ if (!msg_ret)
+ goto fail;
}
- if (msg_list.msg_struct_info) {
- ret = msg_release_list_struct(&msg_list);
- DBG("Err%d", ret);
+ if (mailbox_list == NULL)
+ goto fail;
+
+ for (i = 0; i < mailbox_count; i++) {
+ DBG("mailbox alias = %s \n", mailbox_list[i].alias);
+ if (!g_ascii_strncasecmp(mailbox_list[i].alias, folder,
+ strlen(folder))) {
+ total = mailbox_list[i].total_mail_count_on_server;
+ DBG("Total mail on sever:%d\n", total);
+ DBG("mailbox name:%s\n", mailbox_list[i].mailbox_name);
+
+ break;
+ }
+
+ if (!msg_ret)
+ goto fail;
+ else
+ goto done;
+ }
+
+ /* Need to modify the filter code, have to make it dynamic
+ based on remote device request Also to check whether it needs
+ to be done in agent or in obexd */
+
+ filter_list = g_new0(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_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 =
+ account_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.target_attribute =
+ EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME;
+ filter_list[2].list_filter_item.rule.rule_type =
+ EMAIL_LIST_FILTER_RULE_EQUAL;
+ type = g_strdup(mailbox_list[i].mailbox_name);
+ filter_list[2].list_filter_item.rule.key_value.string_type_value = type;
+ filter_list[2].list_filter_item.rule.case_sensitivity = true;
+
+ sorting_rule_list = g_new0(email_list_sorting_rule_t, 1);
+ sorting_rule_list->target_attribute = EMAIL_MAIL_ATTRIBUTE_DATE_TIME;
+ sorting_rule_list->sort_order = EMAIL_SORT_ORDER_ASCEND;
+
+ ret = email_get_mail_list_ex(filter_list, 3,
+ sorting_rule_list, 1, 0, total - 1,
+ &mail_list, &mail_count);
+
+ DBG("email API ret %d \n", ret);
+ if (ret != EMAIL_ERROR_NONE) {
+ if (!msg_ret) {
+ g_free(type);
+ g_free(filter_list);
+ g_free(sorting_rule_list);
+ goto fail;
+ } else
+ goto done;
}
+ for (i = 0; i < mail_count; ++i) {
+ time_t time = {0,};
+ memset(&value, 0, sizeof(GValue));
+ g_value_init(&value, DBUS_STRUCT_MESSAGE_LIST);
+ g_value_take_boxed(&value, dbus_g_type_specialized_construct(
+ DBUS_STRUCT_MESSAGE_LIST));
+
+ uid = __bt_add_id(mail_list[i].mail_id);
+ snprintf(msg_handle, sizeof(msg_handle), "%llx", uid);
+
+ g_strlcpy(msg_type, "EMAIL", sizeof(msg_type));
+
+ time = mail_list[i].date_time;
+ __get_msg_timestamp(&time, msg_datetime);
+
+ dbus_g_type_struct_set(&value, 0, msg_handle, 1, msg_type,
+ 2, msg_datetime, G_MAXUINT);
+ g_ptr_array_add(array, g_value_get_boxed(&value));
+ }
+
+ if (mailbox_list != NULL)
+ email_free_mailbox(&mailbox_list, mailbox_count);
+ if (mail_list != NULL)
+ g_free(mail_list);
+
+ g_free(filter_list);
+ g_free(sorting_rule_list);
+ g_free(type);
+#endif
+
+done:
+ DBG("Request completed \n");
dbus_g_method_return(context, newmsg, count, array);
g_ptr_array_free(array, TRUE);
DBG("Request completed successfully \n");
return TRUE;
fail:
- if (folder_list.msg_struct_info) {
- ret = msg_release_list_struct(&folder_list);
- DBG("Err %d", ret);
- }
-
- if (msg_list.msg_struct_info) {
- ret = msg_release_list_struct(&msg_list);
- DBG("Err%d", ret);
- }
g_ptr_array_free(array, TRUE);
error = __bt_map_agent_error(BT_MAP_AGENT_ERROR_INTERNAL,
"InternalError");
msg_struct_t msg = NULL;
msg_struct_t send_opt = NULL;
-
+#ifdef SUPPORT_EMAIL
+ email_mail_data_t *mail_data = NULL;
+#endif
message_id = __bt_get_uid(message_name);
if (message_id == -1)
goto fail;
msg_release_struct(&msg);
msg_release_struct(&send_opt);
+#ifdef SUPPORT_EMAIL
+ } else if (msg_type == BT_EMAIL) {
+
+ FILE *body_file;
+ int account_id;
+ long read_size;
+ long email_size;
+
+ if (EMAIL_ERROR_NONE !=
+ email_load_default_account_id(&account_id))
+ goto fail;
+
+ if (EMAIL_ERROR_NONE !=
+ email_get_mail_data(message_id, &mail_data))
+ goto fail;
+
+ body_file = fopen(mail_data->file_path_plain, "r");
+ if (body_file == NULL)
+ body_file = fopen(mail_data->file_path_html, "rb");
+
+ if (body_file != NULL) {
+ fseek(body_file , 0, SEEK_END);
+ email_size = ftell(body_file);
+ rewind(body_file);
+
+ buf = (char *)g_malloc0(sizeof(char) * email_size);
+
+ read_size = fread(buf, 1, email_size, body_file);
+
+ fclose(body_file);
+
+ if (read_size != email_size)
+ goto fail;
+ } else
+ buf = (char *)g_strdup("");
+
+ email_free_mail_data(&mail_data, 1);
+#endif
} else {
DBG("msg_type not supported %d \n", msg_type);
goto fail;
if (send_opt)
msg_release_struct(&send_opt);
+#ifdef SUPPORT_EMAIL
+ if (mail_data)
+ email_free_mail_data(&mail_data, 1);
+#endif
+
error = __bt_map_agent_error(BT_MAP_AGENT_ERROR_INTERNAL,
"InternalError");
dbus_g_method_return_error(context, error);
if (MSG_OUTBOX_ID == folder_id)
send = TRUE;
- body = bmsg_get_msg_body(bmsg_info, opt.native);
+ body = bmsg_get_msg_body(bmsg_info);
if (body == NULL)
goto done;
DBusGMethodInvocation *context)
{
int err = TRUE;
+#ifdef SUPPORT_EMAIL
+ int handle;
+ err = email_sync_header_for_all_account(&handle);
+
+ if (err == EMAIL_ERROR_NONE) {
+ DBG("Handle to stop download = %d \n", handle);
+ } else {
+ ERR("Message Update failed \n");
+ }
dbus_g_method_return(context, err);
+ return (err == EMAIL_ERROR_NONE) ? TRUE : FALSE;
+#else
+ dbus_g_method_return(context, err);
return TRUE;
+#endif
}
static gboolean bluetooth_map_set_read_status(BluetoothMapAgent *agent,
{
int message_id = 0;
int msg_type = BT_SMS;
-
+#ifdef SUPPORT_EMAIL
+ email_mail_data_t *mail_data = NULL;
+#endif
GError *error = NULL;
DBG("+\n");
if (msg_err != MSG_SUCCESS)
goto fail;
- } else {
+#ifdef SUPPORT_EMAIL
+ } else if (msg_type == BT_EMAIL) {
+
+ if (email_get_mail_data(message_id, &mail_data) !=
+ EMAIL_ERROR_NONE) {
+ ERR("email_get_mail_data failed\n");
+ goto fail;
+ }
+
+ if (email_set_flags_field(mail_data->account_id, &message_id, 1,
+ EMAIL_FLAGS_SEEN_FIELD, read_status, 0) !=
+ EMAIL_ERROR_NONE) {
+ email_free_mail_data(&mail_data, 1);
+ goto fail;
+ }
+
+ email_free_mail_data(&mail_data, 1);
+#endif
+ } else
goto fail;
- }
dbus_g_method_return(context);
DBG("-\n");
{
int message_id = 0;
int msg_type = BT_SMS;
-
+#ifdef SUPPORT_EMAIL
+ email_mail_data_t *mail_data = NULL;
+#endif
GError *error = NULL;
DBG("+\n");
MSG_SUCCESS) {
goto fail;
}
+#ifdef SUPPORT_EMAIL
+ } else if (msg_type == BT_EMAIL) {
+
+ if (email_get_mail_data(message_id, &mail_data) !=
+ EMAIL_ERROR_NONE)
+ goto fail;
+
+ if (email_delete_mail(mail_data->mailbox_id, &message_id,
+ 1, 1) != EMAIL_ERROR_NONE) {
+ email_free_mail_data(&mail_data, 1);
+ goto fail;
+ }
+
+ email_free_mail_data(&mail_data, 1);
+#endif
} else
goto fail;
return TRUE;
}
-static gboolean bluetooth_map_destroy_agent(BluetoothMapAgent *agent,
- DBusGMethodInvocation *context)
-{
- DBG("+");
- g_main_loop_quit(g_mainloop);
- DBG("-");
-}
-
-int main(void)
+int main(int argc, char **argv)
{
BluetoothMapAgent *bluetooth_map_obj = NULL;
DBusGProxy *bus_proxy = NULL;
guint result = 0;
- int ret;
GError *error = NULL;
- DBG("Starting Bluetooth MAP agent");
g_type_init();
if (__bluetooth_map_start_service() == FALSE)
goto failure;
- g_tapi_handle = tel_init(NULL);
- if (!g_tapi_handle)
- goto failure;
-
- ret = tel_get_sms_sca(g_tapi_handle, 0, __bt_get_sms_sca, NULL);
- if (ret != TAPI_API_SUCCESS)
- goto failure;
-
g_main_loop_run(g_mainloop);
failure:
+ DBG("Terminate the bluetooth-map-agent\n");
__bt_remove_list(id_list);
- tel_deinit(g_tapi_handle);
- g_free(g_sca_info);
-
if (g_mns_path)
__bt_mns_client_disconnect();
if (bus_proxy)
__bluetooth_map_stop_service();
- DBG("Terminate Bluetooth MAP agent\n");
return EXIT_FAILURE;
}