summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhyunho kang <hhstark.kang@samsung.com>2015-12-09 16:17:40 +0900
committerhyunho kang <hhstark.kang@samsung.com>2015-12-09 20:32:49 +0900
commit2a83ff9352e78b00cd00d480ea05747eea65c72e (patch)
treed33a873615e22faa9e0d8e348cd2539e8c00fcac
parentb644eca19b66275da048e5368b26c4ecd40c3901 (diff)
downloadmessage-port-2a83ff9352e78b00cd00d480ea05747eea65c72e.tar.gz
message-port-2a83ff9352e78b00cd00d480ea05747eea65c72e.tar.bz2
message-port-2a83ff9352e78b00cd00d480ea05747eea65c72e.zip
Apply tizen coding rules.
Change-Id: I57b7eeb4b0152c2c2ccf176974a7a8e39edc83b3 Signed-off-by: hyunho kang <hhstark.kang@samsung.com>
-rwxr-xr-xsrc/message-port.c139
-rw-r--r--src/message_port.c104
-rw-r--r--src/message_port_internal.c36
3 files changed, 116 insertions, 163 deletions
diff --git a/src/message-port.c b/src/message-port.c
index 3135714..a5a55c7 100755
--- a/src/message-port.c
+++ b/src/message-port.c
@@ -1,19 +1,20 @@
-// Message Port
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// 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.
-//
+/*
+ Message Port
+ Copyright (c) 2015 Samsung Electronics Co., Ltd.
+
+ 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 message-port.cpp
@@ -170,9 +171,8 @@ static char *__get_encoded_name(const char *remote_app_id, const char *port_name
temp += 2;
}
- if (postfix && postfix_len > 0) {
+ if (postfix && postfix_len > 0)
snprintf(temp, encoded_bus_name_len - (temp - md5_interface), "%s", postfix);
- }
if (bus_name)
free(bus_name);
@@ -186,9 +186,8 @@ static int __remote_port_compare_cb(gconstpointer a, gconstpointer b)
port_list_info_s *key1 = (port_list_info_s *)a;
port_list_info_s *key2 = (port_list_info_s *)b;
- if (key1->is_trusted == key2->is_trusted) {
+ if (key1->is_trusted == key2->is_trusted)
return strcmp(key1->port_name, key2->port_name);
- }
return 1;
}
@@ -253,7 +252,7 @@ static int __check_certificate(const char *local_appid, const char *remote_appid
return MESSAGEPORT_ERROR_NONE;
}
-static void on_name_appeared (GDBusConnection *connection,
+static void on_name_appeared(GDBusConnection *connection,
const gchar *name,
const gchar *name_owner,
gpointer user_data)
@@ -261,7 +260,7 @@ static void on_name_appeared (GDBusConnection *connection,
_LOGI("name appeared : %s %s", __app_id, name);
}
-static void on_name_vanished (GDBusConnection *connection,
+static void on_name_vanished(GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
@@ -275,9 +274,8 @@ static int __get_local_port_info(int id, message_port_local_port_info_s **info)
{
message_port_local_port_info_s *mi = (message_port_local_port_info_s *)g_hash_table_lookup(__local_port_info, GINT_TO_POINTER(id));
- if (mi == NULL) {
+ if (mi == NULL)
return MESSAGEPORT_ERROR_INVALID_PARAMETER;
- }
*info = mi;
return MESSAGEPORT_ERROR_NONE;
@@ -308,7 +306,7 @@ static port_list_info_s *__set_remote_port_info(const char *remote_app_id, const
port_info->sock_pair[0] = 0;
port_info->sock_pair[1] = 0;
- out:
+out:
if (ret_val != MESSAGEPORT_ERROR_NONE) {
if (port_info) {
FREE_AND_NULL(port_info->port_name);
@@ -346,7 +344,7 @@ static message_port_remote_app_info_s *__set_remote_app_info(const char *remote_
remote_app_info->port_list = g_list_append(remote_app_info->port_list, port_info);
- out:
+out:
if (ret_val != MESSAGEPORT_ERROR_NONE) {
if (remote_app_info) {
FREE_AND_NULL(remote_app_info->remote_app_id);
@@ -416,9 +414,8 @@ static bool __is_local_port_registed(const char *local_port, bool trusted, int *
if ((mi->is_trusted == trusted) && strcmp(mi->port_name, local_port) == 0) {
*local_id = mi->local_id;
- if (lpi != NULL) {
+ if (lpi != NULL)
*lpi = mi;
- }
return true;
}
}
@@ -440,7 +437,7 @@ static int __get_sender_pid(GDBusConnection *conn, const char *sender_name)
goto out;
}
- g_dbus_message_set_body (msg, g_variant_new ("(s)", sender_name));
+ g_dbus_message_set_body(msg, g_variant_new("(s)", sender_name));
reply = g_dbus_connection_send_message_with_reply_sync(conn, msg,
G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &err);
@@ -470,8 +467,8 @@ message_port_pkt_s *__message_port_recv_raw(int fd)
int ret;
message_port_pkt_s *pkt = NULL;
- pkt = (message_port_pkt_s *) calloc(sizeof(char) * MAX_MESSAGE_SIZE, 1);
- if(pkt == NULL) {
+ pkt = (message_port_pkt_s *)calloc(sizeof(char) * MAX_MESSAGE_SIZE, 1);
+ if (pkt == NULL) {
close(fd);
return NULL;
}
@@ -491,7 +488,7 @@ retry_recv:
close(fd);
return NULL;
}
- while( len < (pkt->len + HEADER_LEN) ) {
+ while (len < (pkt->len + HEADER_LEN)) {
retry_recv1:
ret = recv(fd, &pkt->data[len - 8], MAX_MESSAGE_SIZE, 0);
if (ret < 0) {
@@ -536,8 +533,6 @@ static gboolean __socket_request_handler(GIOChannel *gio,
return TRUE;
}
- //_LOGI("__socket_request_handler fd : %d", fd);
-
mi = (message_port_callback_info_s *)data;
if ((pkt = __message_port_recv_raw(fd)) == NULL) {
@@ -548,11 +543,10 @@ static gboolean __socket_request_handler(GIOChannel *gio,
kb = bundle_decode(pkt->data, pkt->len);
is_bidirection = pkt->is_bidirection;
- if (is_bidirection) {
+ if (is_bidirection)
mi->callback(mi->local_id, mi->remote_app_id, mi->remote_port, mi->is_trusted, kb, NULL);
- } else {
+ else
mi->callback(mi->local_id, mi->remote_app_id, NULL, mi->is_trusted, kb, NULL);
- }
if (pkt)
free(pkt);
@@ -616,11 +610,11 @@ static bool send_message(GVariant *parameters, GDBusMethodInvocation *invocation
if (remote_trusted) {
if (g_hash_table_lookup(__trusted_app_list_hash, (gpointer)local_appid) == NULL) {
if (!__is_preloaded(local_appid, remote_appid)) {
- // Check the certificate
+ /* Check the certificate */
int ret = __check_certificate(local_appid, remote_appid);
- if (ret == MESSAGEPORT_ERROR_NONE) {
+ if (ret == MESSAGEPORT_ERROR_NONE)
g_hash_table_insert(__trusted_app_list_hash, local_appid, "TRUE");
- } else {
+ else {
_LOGE("The application (%s) is not signed with the same certificate",
local_appid);
goto out;
@@ -630,9 +624,9 @@ static bool send_message(GVariant *parameters, GDBusMethodInvocation *invocation
}
callback_info = (message_port_callback_info_s *)calloc(1, sizeof(message_port_callback_info_s));
- if (callback_info == NULL) {
+ if (callback_info == NULL)
goto out;
- }
+
callback_info->local_id = mi->local_id;
callback_info->remote_app_id = strdup(local_appid);
callback_info->remote_port = strdup(local_port);
@@ -679,11 +673,11 @@ static bool send_message(GVariant *parameters, GDBusMethodInvocation *invocation
}
LOGI("call calback %s", local_appid);
- if (bi_dir) {
+ if (bi_dir)
mi->callback(mi->local_id, local_appid, local_port, local_trusted, data, NULL);
- } else {
+ else
mi->callback(mi->local_id, local_appid, NULL, false, data, NULL);
- }
+
out:
@@ -707,19 +701,19 @@ static int __check_remote_port(const char *remote_app_id, const char *remote_por
_LOGI("remote_app_id, app_id :[%s : %s] ", remote_app_id, __app_id);
ret_val = __get_remote_port_info(remote_app_id, remote_port, is_trusted, &remote_app_info, &port_info);
- if (ret_val != MESSAGEPORT_ERROR_NONE) {
+ if (ret_val != MESSAGEPORT_ERROR_NONE)
return ret_val;
- }
- // self check
+
+ /* self check */
if (strcmp(remote_app_id, __app_id) == 0) {
_LOGI("__is_local_port_registed ");
- if (!__is_local_port_registed(remote_port, is_trusted, &local_reg_id, &mi)) {
+ if (!__is_local_port_registed(remote_port, is_trusted, &local_reg_id, &mi))
*exist = false;
- } else {
+ else
*exist = true;
- }
+
_LOGI("__is_local_port_registed : %d ", *exist);
return MESSAGEPORT_ERROR_NONE;
}
@@ -753,8 +747,7 @@ static int __check_remote_port(const char *remote_app_id, const char *remote_por
LOGE("Name not exist %s", bus_name);
*exist = false;
ret_val = MESSAGEPORT_ERROR_NONE;
- }
- else {
+ } else {
if (is_trusted) {
if (remote_app_info->certificate_info != CERTIFICATE_MATCH) {
@@ -827,9 +820,8 @@ static void __dbus_method_call_handler(GDBusConnection *conn,
return;
}
- if (g_strcmp0(method_name, "send_message") == 0) {
+ if (g_strcmp0(method_name, "send_message") == 0)
send_message(parameters, invocation);
- }
}
@@ -864,7 +856,8 @@ out:
}
-int __register_dbus_interface(const char *port_name, bool is_trusted) {
+int __register_dbus_interface(const char *port_name, bool is_trusted)
+{
GDBusNodeInfo *introspection_data = NULL;
int registration_id = 0;
@@ -1000,9 +993,8 @@ static void __hash_destory_remote_value(gpointer data)
if (mri) {
FREE_AND_NULL(mri->sender_id);
FREE_AND_NULL(mri->remote_app_id);
- if (mri->port_list) {
+ if (mri->port_list)
g_list_free_full(mri->port_list, __list_free_port_list);
- }
}
}
@@ -1045,10 +1037,8 @@ static bool __initialize(void)
retvm_if(!__trusted_app_list_hash, false, "fail to create __trusted_app_list_hash");
}
-
- if (!__dbus_init()) {
+ if (!__dbus_init())
return false;
- }
_initialized = true;
return true;
@@ -1080,10 +1070,9 @@ static int __register_message_port(const char *local_port, bool is_trusted, mess
int local_id = 0;
- // Check the message port is already registed
- if (__is_local_port_registed(local_port, is_trusted, &local_id, NULL)) {
+ /* Check the message port is already registed */
+ if (__is_local_port_registed(local_port, is_trusted, &local_id, NULL))
return local_id;
- }
local_id = __register_dbus_interface(local_port, is_trusted);
if (local_id < 1) {
@@ -1091,9 +1080,8 @@ static int __register_message_port(const char *local_port, bool is_trusted, mess
return MESSAGEPORT_ERROR_OUT_OF_MEMORY;
}
- if (!__message_port_register_port(local_id, local_port, is_trusted, callback)) {
+ if (!__message_port_register_port(local_id, local_port, is_trusted, callback))
return MESSAGEPORT_ERROR_OUT_OF_MEMORY;
- }
return local_id;
}
@@ -1144,9 +1132,9 @@ retry_send:
if ((len = send(sockfd, pkt, pkt_size, 0)) != pkt_size) {
SECURE_LOGE("send() failed - len[%d] pkt_size[%d] (errno %d[%s])", len, pkt_size,
errno, strerror(errno));
- if (errno == EPIPE) {
+ if (errno == EPIPE)
_LOGE("fd:%d\n", sockfd);
- }
+
if (errno == EINTR) {
if (retry_ctr > 0) {
_LOGI("Retrying send on fd[%d]", sockfd);
@@ -1188,9 +1176,8 @@ static int __message_port_send_message(const char *remote_appid, const char *rem
GVariant *body = NULL;
ret = __get_remote_port_info(remote_appid, remote_port, trusted_message, &remote_app_info, &port_info);
- if (ret != MESSAGEPORT_ERROR_NONE) {
+ if (ret != MESSAGEPORT_ERROR_NONE)
return ret;
- }
if (port_info->exist == false) {
bool exist = false;
@@ -1226,7 +1213,7 @@ static int __message_port_send_message(const char *remote_appid, const char *rem
remote_appid, remote_port, trusted_message, len, raw);
- if (strcmp(remote_appid, __app_id) != 0) { // self send
+ if (strcmp(remote_appid, __app_id) != 0) { /* self send */
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, port_info->sock_pair) != 0) {
_LOGE("error create socket pair");
@@ -1286,9 +1273,8 @@ int __message_send_bidirectional_message(int id, const char *remote_app_id, cons
{
message_port_local_port_info_s *local_info;
int ret = __get_local_port_info(id, &local_info);
- if (ret != MESSAGEPORT_ERROR_NONE) {
+ if (ret != MESSAGEPORT_ERROR_NONE)
return ret;
- }
_LOGI("bidirectional_message %s", local_info->port_name);
return __message_port_send_message(remote_app_id, remote_port,
@@ -1462,15 +1448,13 @@ int messageport_get_local_port_name(int id, char **name)
message_port_local_port_info_s *local_info;
int ret = __get_local_port_info(id, &local_info);
- if (ret != MESSAGEPORT_ERROR_NONE) {
+ if (ret != MESSAGEPORT_ERROR_NONE)
return ret;
- }
*name = strdup(local_info->port_name);
- if (*name == NULL) {
+ if (*name == NULL)
return MESSAGEPORT_ERROR_OUT_OF_MEMORY;
- }
return MESSAGEPORT_ERROR_NONE;
}
@@ -1480,9 +1464,8 @@ int messageport_check_trusted_local_port(int id, bool *trusted)
message_port_local_port_info_s *local_info;
int ret = __get_local_port_info(id, &local_info);
- if (ret != MESSAGEPORT_ERROR_NONE) {
+ if (ret != MESSAGEPORT_ERROR_NONE)
return ret;
- }
*trusted = local_info->is_trusted;
diff --git a/src/message_port.c b/src/message_port.c
index 827c446..3107b09 100644
--- a/src/message_port.c
+++ b/src/message_port.c
@@ -34,13 +34,10 @@ static pthread_mutex_t __mutex = PTHREAD_MUTEX_INITIALIZER;
static void do_callback(message_port_message_cb callback, int local_port_id, const char *remote_app_id, const char *remote_port, bool trusted_remote_port, bundle *message, void *user_data)
{
- if (callback)
- {
+ if (callback) {
callback(local_port_id, remote_app_id, remote_port, trusted_remote_port, message, user_data);
bundle_free(message);
- }
- else
- {
+ } else {
_LOGI("Ignored");
}
}
@@ -61,67 +58,62 @@ static void trusted_message_dispatcher(int trusted_local_port_id, const char *re
int message_port_register_local_port(const char *local_port, message_port_message_cb callback, void *user_data)
{
- if (local_port == NULL || callback == NULL)
- {
+ if (local_port == NULL || callback == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
}
int local_port_id = messageport_register_local_port(local_port, message_dispatcher);
- if (local_port_id > 0)
- {
+ if (local_port_id > 0) {
_SECURE_LOGI("Register local port ID (%d).", local_port_id);
- if (__listeners == NULL) {
+ if (__listeners == NULL)
__listeners = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
- }
+
pthread_mutex_lock(&__mutex);
message_port_callback_item *item =
(message_port_callback_item *)g_hash_table_lookup(__listeners, GINT_TO_POINTER(local_port_id));
if (item == NULL) {
item = (message_port_callback_item *)calloc(1, sizeof(message_port_callback_item));
- if (item == NULL) {
+ if (item == NULL)
return MESSAGE_PORT_ERROR_OUT_OF_MEMORY;
- }
+
g_hash_table_insert(__listeners, GINT_TO_POINTER(local_port_id), item);
}
-
item->callback = callback;
item->user_data = user_data;
pthread_mutex_unlock(&__mutex);
} else {
_SECURE_LOGI("Register local port fail (%d).", local_port_id);
-
}
+
return convert_to_tizen_error((messageport_error_e)local_port_id);
}
int message_port_register_trusted_local_port(const char *local_port, message_port_trusted_message_cb callback, void *user_data)
{
- if (local_port == NULL || callback == NULL)
- {
+ if (local_port == NULL || callback == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
}
int trusted_local_port_id = messageport_register_trusted_local_port(local_port, trusted_message_dispatcher);
- if (trusted_local_port_id > 0)
- {
+ if (trusted_local_port_id > 0) {
_SECURE_LOGI("Register trusted local port ID (%d).", trusted_local_port_id);
- if (__trusted_listeners == NULL) {
+ if (__trusted_listeners == NULL)
__trusted_listeners = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
- }
+
pthread_mutex_lock(&__mutex);
message_port_callback_item *item =
(message_port_callback_item *)g_hash_table_lookup(__trusted_listeners, GINT_TO_POINTER(trusted_local_port_id));
if (item == NULL) {
item = (message_port_callback_item *)calloc(1, sizeof(message_port_callback_item));
- if (item == NULL) {
+ if (item == NULL)
return MESSAGE_PORT_ERROR_OUT_OF_MEMORY;
- }
+
g_hash_table_insert(__trusted_listeners, GINT_TO_POINTER(trusted_local_port_id), item);
}
@@ -130,7 +122,6 @@ int message_port_register_trusted_local_port(const char *local_port, message_por
pthread_mutex_unlock(&__mutex);
} else {
_SECURE_LOGI("Register trusted local port fail (%d).", trusted_local_port_id);
-
}
return convert_to_tizen_error((messageport_error_e)trusted_local_port_id);
@@ -139,12 +130,10 @@ int message_port_register_trusted_local_port(const char *local_port, message_por
int message_port_unregister_local_port(int local_port_id)
{
int res = MESSAGE_PORT_ERROR_NONE;
- if (local_port_id <= 0)
- {
+ if (local_port_id <= 0) {
_LOGE("[MESSAGEPORT_ERROR_INVALID_PARAMETER] Neither 0 nor negative value is allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
- }
- else {
+ } else {
res = messageport_unregister_local_port(local_port_id, false);
g_hash_table_remove(__listeners, GINT_TO_POINTER(local_port_id));
}
@@ -155,12 +144,10 @@ int message_port_unregister_trusted_local_port(int trusted_local_port_id)
{
int res = MESSAGE_PORT_ERROR_NONE;
- if (trusted_local_port_id <= 0)
- {
+ if (trusted_local_port_id <= 0) {
_LOGE("[MESSAGEPORT_ERROR_INVALID_PARAMETER] Neither 0 nor negative value is allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
- }
- else {
+ } else {
res = messageport_unregister_local_port(trusted_local_port_id, true);
g_hash_table_remove(__trusted_listeners, GINT_TO_POINTER(trusted_local_port_id));
}
@@ -170,8 +157,7 @@ int message_port_unregister_trusted_local_port(int trusted_local_port_id)
int message_port_check_remote_port(const char* remote_app_id, const char *remote_port, bool* exist)
{
- if (remote_app_id == NULL || remote_port == NULL)
- {
+ if (remote_app_id == NULL || remote_port == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
}
@@ -181,8 +167,7 @@ int message_port_check_remote_port(const char* remote_app_id, const char *remote
int message_port_check_trusted_remote_port(const char* remote_app_id, const char *remote_port, bool *exist)
{
- if (remote_app_id == NULL || remote_port == NULL)
- {
+ if (remote_app_id == NULL || remote_port == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
}
@@ -192,8 +177,7 @@ int message_port_check_trusted_remote_port(const char* remote_app_id, const char
int message_port_send_message(const char *remote_app_id, const char *remote_port, bundle *message)
{
- if (remote_app_id == NULL || remote_port == NULL || message == NULL)
- {
+ if (remote_app_id == NULL || remote_port == NULL || message == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
}
@@ -202,8 +186,7 @@ int message_port_send_message(const char *remote_app_id, const char *remote_port
int message_port_send_trusted_message(const char *remote_app_id, const char *remote_port, bundle *message)
{
- if (remote_app_id == NULL || remote_port == NULL || message == NULL)
- {
+ if (remote_app_id == NULL || remote_port == NULL || message == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
}
@@ -212,31 +195,25 @@ int message_port_send_trusted_message(const char *remote_app_id, const char *rem
int message_port_send_message_with_local_port(const char *remote_app_id, const char *remote_port, bundle *message, int local_port_id)
{
- if (remote_app_id == NULL || remote_port == NULL || message == NULL)
- {
+ if (remote_app_id == NULL || remote_port == NULL || message == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
- }
- else if (local_port_id <= 0)
- {
+ } else if (local_port_id <= 0) {
_LOGE("[MESSAGEPORT_ERROR_INVALID_PARAMETER] Neither 0 nor negative value is allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
- }
- else {
+ } else {
message_port_callback_item *item = NULL;
message_port_callback_item *trusted_item = NULL;
- if (__listeners != NULL) {
+ if (__listeners != NULL)
item = (message_port_callback_item *)g_hash_table_lookup(__listeners, GINT_TO_POINTER(local_port_id));
- }
- if (item == NULL && __trusted_listeners != NULL) {
+
+ if (item == NULL && __trusted_listeners != NULL)
trusted_item = (message_port_callback_item *)g_hash_table_lookup(__trusted_listeners, GINT_TO_POINTER(local_port_id));
- }
- if (item == NULL && trusted_item == NULL)
- {
+ if (item == NULL && trusted_item == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_PORT_NOT_FOUND] The local port ID (%d) is not registered.", local_port_id);
return MESSAGE_PORT_ERROR_PORT_NOT_FOUND;
}
@@ -248,30 +225,23 @@ int message_port_send_message_with_local_port(const char *remote_app_id, const c
int message_port_send_trusted_message_with_local_port(const char* remote_app_id, const char *remote_port, bundle* message, int local_port_id)
{
- if (remote_app_id == NULL || remote_port == NULL || message == NULL)
- {
+ if (remote_app_id == NULL || remote_port == NULL || message == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_INVALID_PARAMETER] NULL value is not allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
- }
- else if (local_port_id <= 0)
- {
+ } else if (local_port_id <= 0) {
_LOGE("[MESSAGEPORT_ERROR_INVALID_PARAMETER] Neither 0 nor negative value is allowed.");
return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
- }
- else {
+ } else {
message_port_callback_item *item = NULL;
message_port_callback_item *trusted_item = NULL;
- if (__listeners != NULL) {
+ if (__listeners != NULL)
item = (message_port_callback_item *)g_hash_table_lookup(__listeners, GINT_TO_POINTER(local_port_id));
- }
- if (item == NULL && __trusted_listeners != NULL) {
- trusted_item = (message_port_callback_item *)g_hash_table_lookup(__trusted_listeners, GINT_TO_POINTER(local_port_id));
- }
+ if (item == NULL && __trusted_listeners != NULL)
+ trusted_item = (message_port_callback_item *)g_hash_table_lookup(__trusted_listeners, GINT_TO_POINTER(local_port_id));
- if (item == NULL && trusted_item == NULL)
- {
+ if (item == NULL && trusted_item == NULL) {
_LOGE("[MESSAGE_PORT_ERROR_PORT_NOT_FOUND] The local port ID (%d) is not registered.", local_port_id);
return MESSAGE_PORT_ERROR_PORT_NOT_FOUND;
}
diff --git a/src/message_port_internal.c b/src/message_port_internal.c
index 1373005..258b41a 100644
--- a/src/message_port_internal.c
+++ b/src/message_port_internal.c
@@ -19,23 +19,23 @@
int convert_to_tizen_error(messageport_error_e error)
{
switch (error) {
- case MESSAGEPORT_ERROR_NONE:
- return MESSAGE_PORT_ERROR_NONE;
- case MESSAGEPORT_ERROR_IO_ERROR:
- return MESSAGE_PORT_ERROR_IO_ERROR;
- case MESSAGEPORT_ERROR_OUT_OF_MEMORY:
- return MESSAGE_PORT_ERROR_OUT_OF_MEMORY;
- case MESSAGEPORT_ERROR_INVALID_PARAMETER:
- return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
- case MESSAGEPORT_ERROR_MESSAGEPORT_NOT_FOUND:
- return MESSAGE_PORT_ERROR_PORT_NOT_FOUND;
- case MESSAGEPORT_ERROR_CERTIFICATE_NOT_MATCH:
- return MESSAGE_PORT_ERROR_CERTIFICATE_NOT_MATCH;
- case MESSAGEPORT_ERROR_MAX_EXCEEDED:
- return MESSAGE_PORT_ERROR_MAX_EXCEEDED;
- case MESSAGEPORT_ERROR_RESOURCE_UNAVAILABLE:
- return MESSAGE_PORT_ERROR_RESOURCE_UNAVAILABLE;
- default:
- return error;
+ case MESSAGEPORT_ERROR_NONE:
+ return MESSAGE_PORT_ERROR_NONE;
+ case MESSAGEPORT_ERROR_IO_ERROR:
+ return MESSAGE_PORT_ERROR_IO_ERROR;
+ case MESSAGEPORT_ERROR_OUT_OF_MEMORY:
+ return MESSAGE_PORT_ERROR_OUT_OF_MEMORY;
+ case MESSAGEPORT_ERROR_INVALID_PARAMETER:
+ return MESSAGE_PORT_ERROR_INVALID_PARAMETER;
+ case MESSAGEPORT_ERROR_MESSAGEPORT_NOT_FOUND:
+ return MESSAGE_PORT_ERROR_PORT_NOT_FOUND;
+ case MESSAGEPORT_ERROR_CERTIFICATE_NOT_MATCH:
+ return MESSAGE_PORT_ERROR_CERTIFICATE_NOT_MATCH;
+ case MESSAGEPORT_ERROR_MAX_EXCEEDED:
+ return MESSAGE_PORT_ERROR_MAX_EXCEEDED;
+ case MESSAGEPORT_ERROR_RESOURCE_UNAVAILABLE:
+ return MESSAGE_PORT_ERROR_RESOURCE_UNAVAILABLE;
+ default:
+ return error;
}
}