summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangSoo Lee <constant.lee@samsung.com>2013-04-05 19:20:21 +0900
committerJaekyun Lee <jkyun.lee@samsung.com>2013-04-18 17:08:47 +0900
commit92f838819323aa0cc4fc61228514c5013105990e (patch)
tree14b1349e92ee29b61c68fc15474f665a26310946
parent5cbe77dcb8aa610e16f2480ce19008d515f10990 (diff)
downloadnfc-manager-neard-92f838819323aa0cc4fc61228514c5013105990e.tar.gz
nfc-manager-neard-92f838819323aa0cc4fc61228514c5013105990e.tar.bz2
nfc-manager-neard-92f838819323aa0cc4fc61228514c5013105990e.zip
API modify about foreground app control
Change-Id: Ibbffe5301d6094d3c827063a4e63a17c9307b7a0
-rw-r--r--packaging/nfc-manager.spec7
-rwxr-xr-xsrc/clientlib/net_nfc_client_nfc.c19
-rwxr-xr-xsrc/commonlib/include/net_nfc_typedef_private.h9
-rw-r--r--src/manager/CMakeLists.txt2
-rw-r--r--src/manager/include/net_nfc_app_util_private.h1
-rw-r--r--src/manager/include/net_nfc_server_context_private.h6
-rw-r--r--src/manager/net_nfc_app_util.c55
-rw-r--r--src/manager/net_nfc_server_context.c91
8 files changed, 119 insertions, 71 deletions
diff --git a/packaging/nfc-manager.spec b/packaging/nfc-manager.spec
index e9f18d6..cc5ce67 100644
--- a/packaging/nfc-manager.spec
+++ b/packaging/nfc-manager.spec
@@ -1,7 +1,7 @@
Name: nfc-manager
Summary: NFC framework manager
-Version: 0.0.38
-Release: 1
+Version: 0.0.42
+Release: 0
Group: libs
License: Flora Software License
Source0: %{name}-%{version}.tar.gz
@@ -29,6 +29,8 @@ BuildRequires: pkgconfig(libssl)
BuildRequires: pkgconfig(pmapi)
BuildRequires: pkgconfig(pkgmgr)
BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(ecore-x)
+BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: cmake
BuildRequires: gettext-tools
Requires(post): /sbin/ldconfig
@@ -106,7 +108,6 @@ vconftool set -t bool db/nfc/sbeam 0 -u 5000 -f
vconftool set -t int db/nfc/se_type 0 -u 5000 -f
vconftool set -t bool db/nfc/predefined_item_state 0 -u 5000 -f
vconftool set -t string db/nfc/predefined_item "None" -u 5000 -f
-vconftool set -t bool memory/private/nfc-manager/popup_disabled 0 -u 5000 -f
ln -s /etc/init.d/libnfc-manager-0 /etc/rc.d/rc3.d/S81libnfc-manager-0 -f
ln -s /etc/init.d/libnfc-manager-0 /etc/rc.d/rc5.d/S81libnfc-manager-0 -f
diff --git a/src/clientlib/net_nfc_client_nfc.c b/src/clientlib/net_nfc_client_nfc.c
index 8ead1e6..fbf6126 100755
--- a/src/clientlib/net_nfc_client_nfc.c
+++ b/src/clientlib/net_nfc_client_nfc.c
@@ -307,7 +307,16 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_launch_popup_state(int enable)
request.length = sizeof(net_nfc_request_set_launch_state_t);
request.request_type = NET_NFC_MESSAGE_SERVICE_SET_LAUNCH_STATE;
- request.set_launch_popup = enable;
+
+ pthread_mutex_lock(&g_client_context.g_client_lock);
+ g_client_context.set_launch_popup = enable;
+
+ if(enable)
+ request.set_launch_popup = NET_NFC_LAUNCH_APP_SELECT;
+ else
+ request.set_launch_popup = NET_NFC_NO_LAUNCH_APP_SELECT;
+
+ pthread_mutex_unlock(&g_client_context.g_client_lock);
ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
@@ -321,11 +330,9 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_launch_popup_state(int *state)
if (state == NULL)
return NET_NFC_NULL_PARAMETER;
- /* check state of launch popup */
- if (vconf_get_bool(NET_NFC_DISABLE_LAUNCH_POPUP_KEY, state) != 0)
- {
- result = NET_NFC_OPERATION_FAIL;
- }
+ pthread_mutex_lock(&g_client_context.g_client_lock);
+ *state = g_client_context.set_launch_popup;
+ pthread_mutex_unlock(&g_client_context.g_client_lock);
return result;
}
diff --git a/src/commonlib/include/net_nfc_typedef_private.h b/src/commonlib/include/net_nfc_typedef_private.h
index a23a41c..07a39de 100755
--- a/src/commonlib/include/net_nfc_typedef_private.h
+++ b/src/commonlib/include/net_nfc_typedef_private.h
@@ -375,6 +375,12 @@ typedef enum _client_state_e
NET_NFC_CLIENT_ACTIVE_STATE,
} client_state_e;
+typedef enum _net_nfc_launch_popup_state_e
+{
+ NET_NFC_LAUNCH_APP_SELECT = 0x00,
+ NET_NFC_NO_LAUNCH_APP_SELECT,
+} net_nfc_launch_popup_state_e;
+
/* server state */
#define NET_NFC_SERVER_IDLE 0
#define NET_NFC_SERVER_DISCOVERY (1 << 1)
@@ -410,7 +416,7 @@ typedef struct _net_nfc_request_change_client_state_t
typedef struct _net_nfc_request_set_launch_state_t
{
NET_NFC_REQUEST_MSG_HEADER
- bool set_launch_popup;
+ net_nfc_launch_popup_state_e set_launch_popup;
}net_nfc_request_set_launch_state_t;
typedef struct _net_nfc_request_transceive_t
@@ -1150,6 +1156,7 @@ typedef struct _client_context
net_nfc_target_info_s *target_info;
#endif
bool initialized;
+ int set_launch_popup;
} client_context_t;
// data exchanger
diff --git a/src/manager/CMakeLists.txt b/src/manager/CMakeLists.txt
index afd8db5..cda3e65 100644
--- a/src/manager/CMakeLists.txt
+++ b/src/manager/CMakeLists.txt
@@ -14,7 +14,7 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
INCLUDE(FindPkgConfig)
-pkg_check_modules(manager_pkges REQUIRED aul glib-2.0 gobject-2.0 security-server dbus-glib-1 vconf dlog tapi appsvc libcurl bluetooth-api heynoti smartcard-service smartcard-service-common libssl pmapi svi capi-media-wav-player pkgmgr pkgmgr-info)
+pkg_check_modules(manager_pkges REQUIRED aul glib-2.0 gobject-2.0 security-server dbus-glib-1 vconf dlog tapi appsvc libcurl bluetooth-api heynoti smartcard-service smartcard-service-common libssl pmapi svi capi-media-wav-player pkgmgr pkgmgr-info ecore-x capi-appfw-app-manager)
FOREACH(flag ${manager_pkges_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
diff --git a/src/manager/include/net_nfc_app_util_private.h b/src/manager/include/net_nfc_app_util_private.h
index cd7f3b9..ad93c8d 100644
--- a/src/manager/include/net_nfc_app_util_private.h
+++ b/src/manager/include/net_nfc_app_util_private.h
@@ -35,5 +35,6 @@ int net_nfc_app_util_appsvc_launch(const char *operation, const char *uri, const
int net_nfc_app_util_launch_se_transaction_app(uint8_t *aid, uint32_t aid_len, uint8_t *param, uint32_t param_len);
int net_nfc_app_util_encode_base64(uint8_t *buffer, uint32_t buf_len, char *result, uint32_t max_result);
int net_nfc_app_util_decode_base64(const char *buffer, uint32_t buf_len, uint8_t *result, uint32_t *res_len);
+bool net_nfc_app_util_check_launch_state();
#endif
diff --git a/src/manager/include/net_nfc_server_context_private.h b/src/manager/include/net_nfc_server_context_private.h
index 10e2ff3..2cfe156 100644
--- a/src/manager/include/net_nfc_server_context_private.h
+++ b/src/manager/include/net_nfc_server_context_private.h
@@ -30,7 +30,7 @@ typedef struct _net_nfc_client_info_t
uint32_t src_id;
client_state_e state;
//client_type_e client_type;
- bool is_set_launch_popup;
+ net_nfc_launch_popup_state_e launch_popup_state;
net_nfc_target_handle_s *target_handle;
} net_nfc_client_info_t;
@@ -46,7 +46,7 @@ void net_nfc_server_for_each_client_context(net_nfc_server_for_each_client_cb cb
bool net_nfc_server_check_client_is_running(int socket);
client_state_e net_nfc_server_get_client_state(int socket);
void net_nfc_server_set_client_state(int socket, client_state_e state);
-bool net_nfc_server_is_set_launch_state();
-void net_nfc_server_set_launch_state(int socket, bool enable);
+void net_nfc_server_set_launch_state(int socket, net_nfc_launch_popup_state_e popup_state);
+net_nfc_launch_popup_state_e net_nfc_server_get_client_popup_state(pid_t pid);
#endif /* NET_NFC_SERVER_CONTEXT_H */
diff --git a/src/manager/net_nfc_app_util.c b/src/manager/net_nfc_app_util.c
index f7630ce..ec6530e 100644
--- a/src/manager/net_nfc_app_util.c
+++ b/src/manager/net_nfc_app_util.c
@@ -33,6 +33,8 @@
#include "appsvc.h"
#include "aul.h"
#include "vconf.h"
+#include "Ecore_X.h"
+#include "app_manager.h"
#include "net_nfc_typedef.h"
#include "net_nfc_typedef_private.h"
@@ -43,6 +45,7 @@
#include "net_nfc_util_ndef_record.h"
#include "net_nfc_manager_util_private.h"
#include "net_nfc_app_util_private.h"
+#include "net_nfc_server_context_private.h"
//#include "syspopup_caller.h"
#define OSP_K_COND "__OSP_COND_NAME__"
@@ -98,7 +101,7 @@ net_nfc_error_e net_nfc_app_util_process_ndef(data_s *data)
}
/* check state of launch popup */
- if (vconf_get_bool(NET_NFC_DISABLE_LAUNCH_POPUP_KEY, &disable) == 0 && disable == FALSE)
+ if(net_nfc_app_util_check_launch_state() == TRUE)
{
DEBUG_SERVER_MSG("skip launch popup!!!");
result = NET_NFC_OK;
@@ -906,3 +909,53 @@ int net_nfc_app_util_decode_base64(const char *buffer, uint32_t buf_len, uint8_t
return ret;
}
+
+static pid_t _net_nfc_app_util_get_current_app_pid()
+{
+ char *app_id = NULL;
+ app_context_h context = NULL;
+ pid_t pid, pgid;
+
+ pid = getpid();
+ app_manager_get_app_id(pid, &app_id);
+ app_manager_get_app_context(app_id, &context);
+
+ app_context_get_pid(context, &pgid);
+
+ free(app_id);
+ app_context_destroy(context);
+
+ return pgid;
+}
+
+static pid_t _net_nfc_app_util_get_focus_app_pid()
+{
+ Ecore_X_Window focus;
+ pid_t pid;
+
+ ecore_x_init(NULL);
+
+ focus = ecore_x_window_focus_get();
+ if (ecore_x_netwm_pid_get(focus, &pid))
+ return pid;
+
+ return -1;
+}
+
+bool net_nfc_app_util_check_launch_state()
+{
+ pid_t focus_app_pid, current_app_pid;
+ net_nfc_launch_popup_state_e popup_state;
+ bool result = false;
+
+ current_app_pid = _net_nfc_app_util_get_current_app_pid();
+ focus_app_pid = _net_nfc_app_util_get_focus_app_pid();
+
+ popup_state = net_nfc_server_get_client_popup_state(current_app_pid);
+
+ if(popup_state == NET_NFC_NO_LAUNCH_APP_SELECT && current_app_pid == focus_app_pid)
+ result = true;
+
+ return result;
+}
+
diff --git a/src/manager/net_nfc_server_context.c b/src/manager/net_nfc_server_context.c
index bba8c4e..6ad5908 100644
--- a/src/manager/net_nfc_server_context.c
+++ b/src/manager/net_nfc_server_context.c
@@ -27,14 +27,27 @@
static GList *g_client_contexts = NULL;
static pthread_mutex_t g_client_context_lock = PTHREAD_MUTEX_INITIALIZER;
-static gint _client_context_compare_func(gconstpointer a, gconstpointer b)
+static gint _client_context_compare_by_socket(gconstpointer a, gconstpointer b)
{
gint result = -1;
net_nfc_client_info_t *info = (net_nfc_client_info_t *)a;
if (info->socket == (int)b)
result = 0;
- else if (info->socket > (int)b)
+ else
+ result = 1;
+
+ return result;
+}
+
+static gint _client_context_compare_by_pid(gconstpointer a, gconstpointer b)
+{
+ gint result = -1;
+ net_nfc_client_info_t *info = (net_nfc_client_info_t *)a;
+
+ if (info->pid == (int)b)
+ result = 0;
+ else
result = 1;
return result;
@@ -63,9 +76,6 @@ static void _cleanup_client_context(gpointer data)
close(info->socket);
}
- if (vconf_set_bool(NET_NFC_DISABLE_LAUNCH_POPUP_KEY, net_nfc_server_is_set_launch_state()) != 0)
- DEBUG_ERR_MSG("SERVER :set launch vconf fail");
-
DEBUG_SERVER_MSG("cleanup success : client [%d]", info->socket);
_net_nfc_util_free_mem(info);
@@ -101,7 +111,7 @@ net_nfc_client_info_t *net_nfc_server_get_client_context(int socket)
pthread_mutex_lock(&g_client_context_lock);
- item = g_list_find_custom(g_client_contexts, (gconstpointer)socket, _client_context_compare_func);
+ item = g_list_find_custom(g_client_contexts, (gconstpointer)socket, _client_context_compare_by_socket);
if (item != NULL)
{
result = item->data;
@@ -130,7 +140,7 @@ void net_nfc_server_add_client_context(pid_t pid, int socket, GIOChannel *channe
info->channel = channel;
info->src_id = src_id;
info->state = state;
- info->is_set_launch_popup = TRUE;
+ info->launch_popup_state = NET_NFC_LAUNCH_APP_SELECT;
g_client_contexts = g_list_append(g_client_contexts, info);
}
@@ -157,7 +167,7 @@ void net_nfc_server_cleanup_client_context(int socket)
pthread_mutex_lock(&g_client_context_lock);
- item = g_list_find_custom(g_client_contexts, (gconstpointer)socket, _client_context_compare_func);
+ item = g_list_find_custom(g_client_contexts, (gconstpointer)socket, _client_context_compare_by_socket);
if (item != NULL)
{
_cleanup_client_context(item->data);
@@ -252,7 +262,7 @@ client_state_e net_nfc_server_get_client_state(int socket)
pthread_mutex_lock(&g_client_context_lock);
- item = g_list_find_custom(g_client_contexts, (gconstpointer)socket, _client_context_compare_func);
+ item = g_list_find_custom(g_client_contexts, (gconstpointer)socket, _client_context_compare_by_socket);
if (item != NULL)
{
state = ((net_nfc_client_info_t *)item->data)->state;
@@ -269,7 +279,7 @@ void net_nfc_server_set_client_state(int socket, client_state_e state)
pthread_mutex_lock(&g_client_context_lock);
- item = g_list_find_custom(g_client_contexts, (gconstpointer)socket, _client_context_compare_func);
+ item = g_list_find_custom(g_client_contexts, (gconstpointer)socket, _client_context_compare_by_socket);
if (item != NULL)
{
((net_nfc_client_info_t *)item->data)->state = state;
@@ -278,62 +288,31 @@ void net_nfc_server_set_client_state(int socket, client_state_e state)
pthread_mutex_unlock(&g_client_context_lock);
}
-static void _enable_launch_state(gpointer data, gpointer user_data)
-{
- net_nfc_client_info_t *info = (net_nfc_client_info_t *)data;
-
- if (info != NULL)
- {
- info->state = (bool)user_data;
- }
-}
-
-static gint _check_launch_state(gconstpointer a, gconstpointer b)
-{
- gint result = 1;
- net_nfc_client_info_t *info = (net_nfc_client_info_t *)a;
-
- if (info->is_set_launch_popup == false)
- result = 0;
-
- return result;
-}
-
-void net_nfc_server_set_launch_state(int socket, bool enable)
+void net_nfc_server_set_launch_state(int socket, net_nfc_launch_popup_state_e popup_state)
{
- if (vconf_set_bool(NET_NFC_DISABLE_LAUNCH_POPUP_KEY, enable) != 0)
- {
- DEBUG_ERR_MSG("SERVER : launch state set vconf fail");
- }
-
- if (enable == true)
- {
- pthread_mutex_lock(&g_client_context_lock);
- g_list_foreach(g_client_contexts, _enable_launch_state, (gpointer)true);
- pthread_mutex_unlock(&g_client_context_lock);
- }
- else
+ net_nfc_client_info_t *context = net_nfc_server_get_client_context(socket);
+ pthread_mutex_lock(&g_client_context_lock);
+ if (context != NULL)
{
- net_nfc_client_info_t *context = net_nfc_server_get_client_context(socket);
- pthread_mutex_lock(&g_client_context_lock);
- if (context != NULL)
- {
- context->state = enable;
- }
- pthread_mutex_unlock(&g_client_context_lock);
+ context->launch_popup_state = popup_state;
}
+ pthread_mutex_unlock(&g_client_context_lock);
}
-bool net_nfc_server_is_set_launch_state()
+net_nfc_launch_popup_state_e net_nfc_server_get_client_popup_state(pid_t pid)
{
- bool result = true;
GList *item = NULL;
+ net_nfc_launch_popup_state_e state;
- item = g_list_find_custom(g_client_contexts, NULL, _check_launch_state);
+ pthread_mutex_lock(&g_client_context_lock);
+
+ item = g_list_find_custom(g_client_contexts, (gconstpointer)pid, _client_context_compare_by_pid);
if (item != NULL)
{
- result = false;
+ state = ((net_nfc_client_info_t *)item->data)->launch_popup_state;
}
- return result;
+ pthread_mutex_unlock(&g_client_context_lock);
+
+ return state;
}