4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
\r
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
\r
8 * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * you may not use this file except in compliance with the License.
\r
10 * You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing, software
\r
15 * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * See the License for the specific language governing permissions and
\r
18 * limitations under the License.
\r
23 * email-core-signal.c
\r
25 * Created on: 2012. 11. 22.
\r
26 * Author: kyuho.jo@samsung.com
\r
28 #include <dbus/dbus.h>
\r
30 #include "email-core-signal.h"
\r
31 #include "email-core-utils.h"
\r
32 #include "email-internal-types.h"
\r
33 #include "email-debug-log.h"
\r
35 #define EMAIL_STORAGE_CHANGE_NOTI "User.Email.StorageChange"
\r
36 #define EMAIL_NETOWRK_CHANGE_NOTI "User.Email.NetworkStatus"
\r
37 #define EMAIL_RESPONSE_TO_API_NOTI "User.Email.ResponseToAPI"
\r
39 #define DBUS_SIGNAL_PATH_FOR_TASK_STATUS "/User/Email/TaskStatus"
\r
40 #define DBUS_SIGNAL_INTERFACE_FOR_TASK_STATUS "User.Email.TaskStatus"
\r
41 #define DBUS_SIGNAL_NAME_FOR_TASK_STATUS "email"
\r
43 static pthread_mutex_t _dbus_noti_lock = PTHREAD_MUTEX_INITIALIZER;
\r
46 _NOTI_TYPE_STORAGE = 0,
\r
47 _NOTI_TYPE_NETWORK = 1,
\r
48 _NOTI_TYPE_RESPONSE_TO_API = 2,
\r
51 INTERNAL_FUNC int emcore_initialize_signal()
\r
53 return EMAIL_ERROR_NONE;
\r
56 INTERNAL_FUNC int emcore_finalize_signal()
\r
58 DELETE_CRITICAL_SECTION(_dbus_noti_lock);
\r
59 return EMAIL_ERROR_NONE;
\r
62 static int emcore_send_signal(enotitype_t notiType, int subType, int data1, int data2, char *data3, int data4)
\r
64 EM_DEBUG_FUNC_BEGIN();
\r
65 EM_PROFILE_BEGIN(profile_emcore_send_signal);
\r
68 DBusConnection *connection;
\r
69 DBusMessage *signal = NULL;
\r
70 DBusError dbus_error;
\r
71 dbus_uint32_t error = 0;
\r
72 const char *nullString = "";
\r
74 ENTER_CRITICAL_SECTION(_dbus_noti_lock);
\r
76 dbus_error_init(&dbus_error);
\r
77 connection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
\r
79 if (dbus_error_is_set(&dbus_error)) {
\r
80 EM_DEBUG_EXCEPTION("dbus_bus_get failed: [%s]", dbus_error.message);
\r
81 dbus_error_free(&dbus_error);
\r
85 if (notiType == _NOTI_TYPE_STORAGE) {
\r
86 signal = dbus_message_new_signal("/User/Email/StorageChange", EMAIL_STORAGE_CHANGE_NOTI, "email");
\r
88 if (signal == NULL) {
\r
89 EM_DEBUG_EXCEPTION("dbus_message_new_signal is failed");
\r
92 EM_DEBUG_LOG("/User/Email/StorageChange Signal is created by dbus_message_new_signal");
\r
94 dbus_message_append_args(signal, DBUS_TYPE_INT32, &subType, DBUS_TYPE_INVALID);
\r
95 dbus_message_append_args(signal, DBUS_TYPE_INT32, &data1, DBUS_TYPE_INVALID);
\r
96 dbus_message_append_args(signal, DBUS_TYPE_INT32, &data2, DBUS_TYPE_INVALID);
\r
98 dbus_message_append_args(signal, DBUS_TYPE_STRING, &nullString, DBUS_TYPE_INVALID);
\r
100 dbus_message_append_args(signal, DBUS_TYPE_STRING, &data3, DBUS_TYPE_INVALID);
\r
101 dbus_message_append_args(signal, DBUS_TYPE_INT32, &data4, DBUS_TYPE_INVALID);
\r
102 } else if (notiType == _NOTI_TYPE_NETWORK) {
\r
103 signal = dbus_message_new_signal("/User/Email/NetworkStatus", EMAIL_NETOWRK_CHANGE_NOTI, "email");
\r
105 if (signal == NULL) {
\r
106 EM_DEBUG_EXCEPTION("dbus_message_new_signal is failed");
\r
110 EM_DEBUG_LOG("/User/Email/NetworkStatus Signal is created by dbus_message_new_signal");
\r
112 dbus_message_append_args(signal, DBUS_TYPE_INT32, &subType, DBUS_TYPE_INVALID);
\r
113 dbus_message_append_args(signal, DBUS_TYPE_INT32, &data1, DBUS_TYPE_INVALID);
\r
115 dbus_message_append_args(signal, DBUS_TYPE_STRING, &nullString, DBUS_TYPE_INVALID);
\r
117 dbus_message_append_args(signal, DBUS_TYPE_STRING, &data3, DBUS_TYPE_INVALID);
\r
118 dbus_message_append_args(signal, DBUS_TYPE_INT32, &data2, DBUS_TYPE_INVALID);
\r
119 dbus_message_append_args(signal, DBUS_TYPE_INT32, &data4, DBUS_TYPE_INVALID);
\r
120 } else if (notiType == _NOTI_TYPE_RESPONSE_TO_API) {
\r
121 signal = dbus_message_new_signal("/User/Email/ResponseToAPI", EMAIL_RESPONSE_TO_API_NOTI, "email");
\r
123 if (signal == NULL) {
\r
124 EM_DEBUG_EXCEPTION("dbus_message_new_signal is failed");
\r
128 EM_DEBUG_LOG("/User/Email/ResponseToAPI Signal is created by dbus_message_new_signal");
\r
130 dbus_message_append_args(signal, DBUS_TYPE_INT32, &subType, DBUS_TYPE_INVALID);
\r
131 dbus_message_append_args(signal, DBUS_TYPE_INT32, &data1, DBUS_TYPE_INVALID);
\r
132 dbus_message_append_args(signal, DBUS_TYPE_INT32, &data2, DBUS_TYPE_INVALID);
\r
134 EM_DEBUG_EXCEPTION("Wrong notification type [%d]", notiType);
\r
135 error = EMAIL_ERROR_IPC_CRASH;
\r
139 if (!dbus_connection_send(connection, signal, &error)) {
\r
140 EM_DEBUG_EXCEPTION("dbus_connection_send failed [%d]", error);
\r
142 EM_DEBUG_LOG_DEV("dbus_connection_send done");
\r
146 /* EM_DEBUG_LOG("Before dbus_connection_flush"); */
\r
147 /* dbus_connection_flush(connection); */
\r
148 /* EM_DEBUG_LOG("After dbus_connection_flush"); */
\r
153 dbus_message_unref(signal);
\r
155 LEAVE_CRITICAL_SECTION(_dbus_noti_lock);
\r
156 EM_PROFILE_END(profile_emcore_send_signal);
\r
157 EM_DEBUG_FUNC_END("ret [%d]", ret);
\r
161 INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNotiData *data)
\r
163 EM_DEBUG_FUNC_BEGIN("subType [%d], data [%p]", subType, data);
\r
165 DBusConnection *connection;
\r
166 DBusMessage *signal = NULL;
\r
167 DBusError dbus_error;
\r
169 dbus_uint32_t error = 0;
\r
171 const char *null_string = "";
\r
173 ENTER_CRITICAL_SECTION(_dbus_noti_lock);
\r
175 dbus_error_init(&dbus_error);
\r
176 connection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
\r
177 if (dbus_error_is_set(&dbus_error)) {
\r
178 EM_DEBUG_EXCEPTION("dbus_bus_get failed: [%s]", dbus_error.message);
\r
179 dbus_error_free(&dbus_error);
\r
184 signal = dbus_message_new_signal("/User/Email/ActiveSync", EMAIL_ACTIVE_SYNC_NOTI, "email");
\r
186 dbus_message_append_args(signal, DBUS_TYPE_INT32, &subType, DBUS_TYPE_INVALID);
\r
188 case ACTIVE_SYNC_NOTI_SEND_MAIL:
\r
189 EM_DEBUG_LOG("handle:[%d]", data->send_mail.handle);
\r
190 EM_DEBUG_LOG("account_id:[%d]", data->send_mail.account_id);
\r
191 EM_DEBUG_LOG("mail_id:[%d]", data->send_mail.mail_id);
\r
193 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.handle), DBUS_TYPE_INVALID);
\r
194 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.account_id), DBUS_TYPE_INVALID);
\r
195 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.mail_id), DBUS_TYPE_INVALID);
\r
196 if (data->send_mail.multi_user_name)
\r
197 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.multi_user_name), DBUS_TYPE_INVALID);
\r
199 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
202 case ACTIVE_SYNC_NOTI_SEND_SAVED: /* publish a send notification to ASE (active sync engine) */
\r
203 EM_DEBUG_EXCEPTION("Not support yet : subType[ACTIVE_SYNC_NOTI_SEND_SAVED] %d", subType);
\r
205 case ACTIVE_SYNC_NOTI_SEND_REPORT:
\r
206 EM_DEBUG_EXCEPTION("Not support yet : subType[ACTIVE_SYNC_NOTI_SEND_REPORT] %d", subType);
\r
208 case ACTIVE_SYNC_NOTI_SYNC_HEADER:
\r
209 EM_DEBUG_LOG("handle:[%d]", data->sync_header.handle);
\r
210 EM_DEBUG_LOG("account_id:[%d]", data->sync_header.account_id);
\r
211 EM_DEBUG_LOG("mailbox_id:[%d]", data->sync_header.mailbox_id);
\r
213 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.handle), DBUS_TYPE_INVALID);
\r
214 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.account_id), DBUS_TYPE_INVALID);
\r
215 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.mailbox_id), DBUS_TYPE_INVALID);
\r
216 if (data->sync_header.multi_user_name)
\r
217 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->sync_header.multi_user_name), DBUS_TYPE_INVALID);
\r
219 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
222 case ACTIVE_SYNC_NOTI_DOWNLOAD_BODY: /* publish a download body notification to ASE */
\r
223 EM_DEBUG_LOG("handle:[%d]", data->download_body.handle);
\r
224 EM_DEBUG_LOG("account_id:[%d]", data->download_body.account_id);
\r
225 EM_DEBUG_LOG("mail_id:[%d]", data->download_body.mail_id);
\r
226 EM_DEBUG_LOG("with_attachment:[%d]", data->download_body.with_attachment);
\r
228 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.handle), DBUS_TYPE_INVALID);
\r
229 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.account_id), DBUS_TYPE_INVALID);
\r
230 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.mail_id), DBUS_TYPE_INVALID);
\r
231 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.with_attachment), DBUS_TYPE_INVALID);
\r
232 if (data->download_body.multi_user_name)
\r
233 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->download_body.multi_user_name), DBUS_TYPE_INVALID);
\r
235 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
240 case ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT:
\r
241 EM_DEBUG_LOG("handle:[%d]", data->download_attachment.handle);
\r
242 EM_DEBUG_LOG("account_id:[%d]", data->download_attachment.account_id);
\r
243 EM_DEBUG_LOG("mail_id:[%d]", data->download_attachment.mail_id);
\r
244 EM_DEBUG_LOG("with_attachment:[%d]", data->download_attachment.attachment_order);
\r
246 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.handle), DBUS_TYPE_INVALID);
\r
247 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.account_id), DBUS_TYPE_INVALID);
\r
248 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.mail_id), DBUS_TYPE_INVALID);
\r
249 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.attachment_order), DBUS_TYPE_INVALID);
\r
250 if (data->download_attachment.multi_user_name)
\r
251 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->download_attachment.multi_user_name), DBUS_TYPE_INVALID);
\r
253 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
257 case ACTIVE_SYNC_NOTI_VALIDATE_ACCOUNT:
\r
258 EM_DEBUG_EXCEPTION("Not support yet : subType[ACTIVE_SYNC_NOTI_VALIDATE_ACCOUNT] %d", subType);
\r
261 case ACTIVE_SYNC_NOTI_CANCEL_JOB:
\r
262 EM_DEBUG_LOG("account_id:[%d]", data->cancel_job.account_id);
\r
263 EM_DEBUG_LOG("handle to cancel:[%d]", data->cancel_job.handle);
\r
264 EM_DEBUG_LOG("cancel_type:[%d]", data->cancel_job.cancel_type);
\r
266 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.account_id), DBUS_TYPE_INVALID);
\r
267 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.handle), DBUS_TYPE_INVALID);
\r
268 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.cancel_type), DBUS_TYPE_INVALID);
\r
269 if (data->cancel_job.multi_user_name)
\r
270 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->cancel_job.multi_user_name), DBUS_TYPE_INVALID);
\r
272 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
276 case ACTIVE_SYNC_NOTI_SEARCH_ON_SERVER:
\r
277 EM_DEBUG_LOG("account_id:[%d]", data->search_mail_on_server.account_id);
\r
278 EM_DEBUG_LOG("mailbox_id:[%d]", data->search_mail_on_server.mailbox_id);
\r
279 EM_DEBUG_LOG("search_filter_count:[%d]", data->search_mail_on_server.search_filter_count);
\r
280 EM_DEBUG_LOG("handle to cancel:[%d]", data->search_mail_on_server.handle);
\r
282 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.account_id), DBUS_TYPE_INVALID);
\r
283 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.mailbox_id), DBUS_TYPE_INVALID);
\r
284 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_count), DBUS_TYPE_INVALID);
\r
285 for (i = 0; i < data->search_mail_on_server.search_filter_count; i++) {
\r
286 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_list[i].search_filter_type), DBUS_TYPE_INVALID);
\r
287 switch (data->search_mail_on_server.search_filter_list[i].search_filter_type) {
\r
288 case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO:
\r
289 case EMAIL_SEARCH_FILTER_TYPE_UID:
\r
290 case EMAIL_SEARCH_FILTER_TYPE_ALL:
\r
291 case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER:
\r
292 case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER:
\r
293 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED:
\r
294 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW:
\r
295 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED:
\r
296 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD:
\r
297 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT:
\r
298 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED:
\r
299 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT:
\r
300 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN:
\r
301 case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY:
\r
302 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);
\r
305 case EMAIL_SEARCH_FILTER_TYPE_BCC:
\r
306 case EMAIL_SEARCH_FILTER_TYPE_BODY:
\r
307 case EMAIL_SEARCH_FILTER_TYPE_CC:
\r
308 case EMAIL_SEARCH_FILTER_TYPE_FROM:
\r
309 case EMAIL_SEARCH_FILTER_TYPE_KEYWORD:
\r
310 case EMAIL_SEARCH_FILTER_TYPE_TEXT:
\r
311 case EMAIL_SEARCH_FILTER_TYPE_SUBJECT:
\r
312 case EMAIL_SEARCH_FILTER_TYPE_TO:
\r
313 case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID:
\r
314 case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME:
\r
315 case EMAIL_SEARCH_FILTER_TYPE_CHARSET:
\r
316 case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED:
\r
317 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);
\r
320 case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE:
\r
321 case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON:
\r
322 case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE:
\r
323 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);
\r
326 EM_DEBUG_EXCEPTION("Invalid filter type [%d]", data->search_mail_on_server.search_filter_list[i].search_filter_type);
\r
330 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.handle), DBUS_TYPE_INVALID);
\r
331 if (data->search_mail_on_server.multi_user_name)
\r
332 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->search_mail_on_server.multi_user_name), DBUS_TYPE_INVALID);
\r
334 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
338 case ACTIVE_SYNC_NOTI_CLEAR_RESULT_OF_SEARCH_ON_SERVER:
\r
339 EM_DEBUG_LOG("account_id:[%d]", data->clear_result_of_search_mail_on_server.account_id);
\r
340 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.account_id), DBUS_TYPE_INVALID);
\r
341 if (data->search_mail_on_server.multi_user_name)
\r
342 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->search_mail_on_server.multi_user_name), DBUS_TYPE_INVALID);
\r
344 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
348 case ACTIVE_SYNC_NOTI_EXPUNGE_MAILS_DELETED_FLAGGED:
\r
349 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->expunge_mails_deleted_flagged.account_id), DBUS_TYPE_INVALID);
\r
350 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->expunge_mails_deleted_flagged.mailbox_id), DBUS_TYPE_INVALID);
\r
351 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->expunge_mails_deleted_flagged.on_server), DBUS_TYPE_INVALID);
\r
352 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->expunge_mails_deleted_flagged.handle), DBUS_TYPE_INVALID);
\r
353 if (data->expunge_mails_deleted_flagged.multi_user_name)
\r
354 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->expunge_mails_deleted_flagged.multi_user_name), DBUS_TYPE_INVALID);
\r
356 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
360 case ACTIVE_SYNC_NOTI_RESOLVE_RECIPIENT:
\r
361 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->get_resolve_recipients.account_id), DBUS_TYPE_INVALID);
\r
362 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->get_resolve_recipients.email_address), DBUS_TYPE_INVALID);
\r
363 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->get_resolve_recipients.handle), DBUS_TYPE_INVALID);
\r
364 if (data->get_resolve_recipients.multi_user_name)
\r
365 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->get_resolve_recipients.multi_user_name), DBUS_TYPE_INVALID);
\r
367 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
371 case ACTIVE_SYNC_NOTI_VALIDATE_CERTIFICATE:
\r
372 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->validate_certificate.account_id), DBUS_TYPE_INVALID);
\r
373 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->validate_certificate.email_address), DBUS_TYPE_INVALID);
\r
374 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->validate_certificate.handle), DBUS_TYPE_INVALID);
\r
375 if (data->validate_certificate.multi_user_name)
\r
376 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->validate_certificate.multi_user_name), DBUS_TYPE_INVALID);
\r
378 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
382 case ACTIVE_SYNC_NOTI_ADD_MAILBOX:
\r
383 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->add_mailbox.account_id), DBUS_TYPE_INVALID);
\r
384 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->add_mailbox.mailbox_path), DBUS_TYPE_INVALID);
\r
385 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->add_mailbox.mailbox_alias), DBUS_TYPE_INVALID);
\r
386 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->add_mailbox.handle), DBUS_TYPE_INVALID);
\r
387 /* eas is not ready to use void array and length */
\r
388 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->add_mailbox.eas_data), DBUS_TYPE_INVALID);
\r
389 /* dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->add_mailbox.eas_data_length), DBUS_TYPE_INVALID);
\r
390 if (data->add_mailbox.eas_data_length > 0) {
\r
391 dbus_message_append_args (signal, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &(data->add_mailbox.eas_data),\
\r
392 data->add_mailbox.eas_data_length,DBUS_TYPE_INVALID);
\r
394 if (data->add_mailbox.multi_user_name)
\r
395 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->add_mailbox.multi_user_name), DBUS_TYPE_INVALID);
\r
397 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
401 case ACTIVE_SYNC_NOTI_RENAME_MAILBOX:
\r
402 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->rename_mailbox.account_id), DBUS_TYPE_INVALID);
\r
403 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->rename_mailbox.mailbox_id), DBUS_TYPE_INVALID);
\r
404 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->rename_mailbox.mailbox_name), DBUS_TYPE_INVALID);
\r
405 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->rename_mailbox.mailbox_alias), DBUS_TYPE_INVALID);
\r
406 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->rename_mailbox.handle), DBUS_TYPE_INVALID);
\r
407 /* eas is not ready to use void array and length */
\r
408 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->rename_mailbox.eas_data), DBUS_TYPE_INVALID);
\r
409 /* dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->rename_mailbox.eas_data_length), DBUS_TYPE_INVALID);
\r
410 if (data->rename_mailbox.eas_data_length > 0) {
\r
411 dbus_message_append_args (signal, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &(data->rename_mailbox.eas_data),\
\r
412 data->rename_mailbox.eas_data_length, DBUS_TYPE_INVALID);
\r
414 if (data->rename_mailbox.multi_user_name)
\r
415 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->rename_mailbox.multi_user_name), DBUS_TYPE_INVALID);
\r
417 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
421 case ACTIVE_SYNC_NOTI_DELETE_MAILBOX:
\r
422 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox.account_id), DBUS_TYPE_INVALID);
\r
423 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox.mailbox_id), DBUS_TYPE_INVALID);
\r
424 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox.handle), DBUS_TYPE_INVALID);
\r
425 if (data->delete_mailbox.multi_user_name)
\r
426 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->delete_mailbox.multi_user_name), DBUS_TYPE_INVALID);
\r
428 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
432 case ACTIVE_SYNC_NOTI_DELETE_MAILBOX_EX:
\r
433 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox_ex.account_id), DBUS_TYPE_INVALID);
\r
434 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox_ex.mailbox_id_count), DBUS_TYPE_INVALID);
\r
435 for (i = 0; i < data->delete_mailbox_ex.mailbox_id_count; i++)
\r
436 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox_ex.mailbox_id_array[i]), DBUS_TYPE_INVALID);
\r
437 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox_ex.handle), DBUS_TYPE_INVALID);
\r
438 if (data->delete_mailbox_ex.multi_user_name)
\r
439 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->delete_mailbox_ex.multi_user_name), DBUS_TYPE_INVALID);
\r
441 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
445 case ACTIVE_SYNC_NOTI_SEND_MAIL_WITH_DOWNLOADING_OF_ORIGINAL_MAIL:
\r
446 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail_with_downloading_attachment_of_original_mail.handle), DBUS_TYPE_INVALID);
\r
447 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail_with_downloading_attachment_of_original_mail.mail_id), DBUS_TYPE_INVALID);
\r
448 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail_with_downloading_attachment_of_original_mail.account_id), DBUS_TYPE_INVALID);
\r
449 if (data->send_mail_with_downloading_attachment_of_original_mail.multi_user_name)
\r
450 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail_with_downloading_attachment_of_original_mail.multi_user_name), DBUS_TYPE_INVALID);
\r
452 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
456 case ACTIVE_SYNC_NOTI_SCHEDULE_SENDING_MAIL:
\r
457 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->schedule_sending_mail.handle), DBUS_TYPE_INVALID);
\r
458 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->schedule_sending_mail.account_id), DBUS_TYPE_INVALID);
\r
459 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->schedule_sending_mail.mail_id), DBUS_TYPE_INVALID);
\r
460 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->schedule_sending_mail.scheduled_time), DBUS_TYPE_INVALID);
\r
461 if (data->schedule_sending_mail.multi_user_name)
\r
462 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->schedule_sending_mail.multi_user_name), DBUS_TYPE_INVALID);
\r
464 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
468 case ACTIVE_SYNC_NOTI_CANCEL_SENDING_MAIL:
\r
469 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_sending_mail.handle), DBUS_TYPE_INVALID);
\r
470 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_sending_mail.account_id), DBUS_TYPE_INVALID);
\r
471 dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_sending_mail.mail_id), DBUS_TYPE_INVALID);
\r
472 if (data->cancel_sending_mail.multi_user_name)
\r
473 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->cancel_sending_mail.multi_user_name), DBUS_TYPE_INVALID);
\r
475 dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
\r
480 EM_DEBUG_EXCEPTION("Invalid Notification type of Active Sync : subType[%d]", subType);
\r
485 if (!dbus_connection_send(connection, signal, &error)) {
\r
486 EM_DEBUG_EXCEPTION("dbus_connection_send failed [%d]", error);
\r
490 /*dbus_connection_flush(connection);*/
\r
495 dbus_message_unref(signal);
\r
497 LEAVE_CRITICAL_SECTION(_dbus_noti_lock);
\r
498 EM_DEBUG_FUNC_END();
\r
502 INTERNAL_FUNC int emcore_notify_storage_event(email_noti_on_storage_event transaction_type, int data1, int data2 , char *data3, int data4)
\r
504 EM_DEBUG_FUNC_BEGIN("transaction_type[%d], data1[%d], data2[%d], data3[%p], data4[%d]", transaction_type, data1, data2, data3, data4);
\r
505 return emcore_send_signal(_NOTI_TYPE_STORAGE, (int)transaction_type, data1, data2, data3, data4);
\r
508 INTERNAL_FUNC int emcore_notify_network_event(email_noti_on_network_event status_type, int data1, char *data2, int data3, int data4)
\r
510 EM_DEBUG_FUNC_BEGIN("status_type[%d], data1[%d], data2[%p], data3[%d], data4[%d]", status_type, data1, data2, data3, data4);
\r
511 return emcore_send_signal(_NOTI_TYPE_NETWORK, (int)status_type, data1, data3, data2, data4);
\r
514 INTERNAL_FUNC int emcore_notify_response_to_api(email_event_type_t event_type, int data1, int data2)
\r
516 EM_DEBUG_FUNC_BEGIN("event_type[%d], data1[%d], data2[%p], data3[%d], data4[%d]", event_type, data1, data2);
\r
517 return emcore_send_signal(_NOTI_TYPE_RESPONSE_TO_API, (int)event_type, data1, data2, NULL, 0);
\r
520 INTERNAL_FUNC int emcore_send_task_status_signal(email_task_type_t input_task_type, int input_task_id, email_task_status_type_t input_task_status, int input_param_1, int input_param_2)
\r
522 EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_task_id [%d] input_task_status [%d] input_param_1 [%d] input_param_2 [%d]", input_task_type, input_task_id, input_task_status, input_param_1, input_param_2);
\r
524 int err = EMAIL_ERROR_NONE;
\r
525 DBusConnection *connection;
\r
526 DBusMessage *signal = NULL;
\r
527 DBusError dbus_error;
\r
528 dbus_uint32_t error = 0;
\r
530 ENTER_CRITICAL_SECTION(_dbus_noti_lock);
\r
532 dbus_error_init(&dbus_error);
\r
533 connection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
\r
534 if (dbus_error_is_set(&dbus_error)) {
\r
535 EM_DEBUG_EXCEPTION("dbus_bus_get failed: [%s]", dbus_error.message);
\r
536 dbus_error_free(&dbus_error);
\r
537 err = EMAIL_ERROR_IPC_CONNECTION_FAILURE;
\r
541 signal = dbus_message_new_signal(DBUS_SIGNAL_PATH_FOR_TASK_STATUS, DBUS_SIGNAL_INTERFACE_FOR_TASK_STATUS, DBUS_SIGNAL_NAME_FOR_TASK_STATUS);
\r
543 if (signal == NULL) {
\r
544 EM_DEBUG_EXCEPTION("dbus_message_new_signal is failed");
\r
545 err = EMAIL_ERROR_IPC_CONNECTION_FAILURE;
\r
548 EM_DEBUG_LOG("Signal for task status has been created by dbus_message_new_signal");
\r
550 dbus_message_append_args(signal, DBUS_TYPE_INT32, &input_task_type, DBUS_TYPE_INVALID);
\r
551 dbus_message_append_args(signal, DBUS_TYPE_INT32, &input_task_id, DBUS_TYPE_INVALID);
\r
552 dbus_message_append_args(signal, DBUS_TYPE_INT32, &input_task_status, DBUS_TYPE_INVALID);
\r
553 dbus_message_append_args(signal, DBUS_TYPE_INT32, &input_param_1, DBUS_TYPE_INVALID);
\r
554 dbus_message_append_args(signal, DBUS_TYPE_INT32, &input_param_2, DBUS_TYPE_INVALID);
\r
556 if (!dbus_connection_send(connection, signal, &error)) {
\r
557 EM_DEBUG_EXCEPTION("dbus_connection_send failed: [%d]", error);
\r
558 err = EMAIL_ERROR_IPC_CONNECTION_FAILURE;
\r
560 EM_DEBUG_LOG("dbus_connection_send done");
\r
563 /* EM_DEBUG_LOG("Before dbus_connection_flush"); */
\r
564 /* dbus_connection_flush(connection); */
\r
565 /* EM_DEBUG_LOG("After dbus_connection_flush"); */
\r
569 dbus_message_unref(signal);
\r
571 LEAVE_CRITICAL_SECTION(_dbus_noti_lock);
\r
572 EM_DEBUG_FUNC_END("err [%d]", err);
\r