bool net_nfc_util_aid_is_prefix(const char *aid);
bool net_nfc_util_aid_is_matched(const char *aid_criteria, const char *aid_target);
-bool net_nfc_util_get_login_user(uid_t * uid);
+void net_nfc_util_get_login_user(uid_t * uid);
bool net_nfc_util_get_pkgid_by_pid(pid_t pid, char *pkgid, size_t len);
bool net_nfc_util_hex_string_to_binary(const char *str, data_s * result);
<arg type="u" name="state" direction="out" />
</method>
+ <!--
+ ConfigureDiscovery
+ -->
+ <method name="ConfigureDiscovery">
+ <arg type="i" name="mode" direction="in" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
<!--
Activated
-->
return result;
}
-bool net_nfc_util_get_login_user(uid_t * uid)
+void net_nfc_util_get_login_user(uid_t * uid)
{
int i, ret;
uid_t *uids;
int uid_count;
+ *uid = 5001;
+
uid_count = sd_get_uids(&uids);
if (uid_count <= 0) {
- DEBUG_ERR_MSG("sd_get_uids failed [%d]", uid_count);
- return false;
+ return;
}
for (i = 0; i < uid_count; i++) {
ret = sd_uid_get_state(uids[i], &state);
- if (ret < 0) {
- DEBUG_ERR_MSG("sd_uid_get_state failed [%d]", ret);
- } else {
+ if (ret >= 0) {
if (!strncmp(state, "online", 6)) {
*uid = uids[i];
free(state);
free(uids);
- return true;
+ return;
}
}
free(state);
}
- DEBUG_ERR_MSG("not exist login user");
-
free(uids);
- return false;
+ return;
}
bool net_nfc_util_get_pkgid_by_pid(pid_t pid, char *pkgid, size_t len)
bool result = false;
uid_t uid = 0;
- if (net_nfc_util_get_login_user(&uid) == false) {
- DEBUG_ERR_MSG("net_nfc_util_get_login_user is failed");
-
- goto END;
- }
+ net_nfc_util_get_login_user(&uid);
/* get pkgid id from pid */
ret = aul_app_get_appid_bypid_for_uid(pid, package, sizeof(package), uid);
int result = 0;
uid_t uid = 0;
- if (net_nfc_util_get_login_user(&uid) == false) {
- DEBUG_ERR_MSG("net_nfc_util_get_login_user is failed");
- return;
- }
+ net_nfc_util_get_login_user(&uid);
if ((result = aul_launch_app_for_uid(package_name, kb, uid)) < 0) {
switch (result) {
appsvc_add_data(bd, "data", param_string);
}
- if (net_nfc_util_get_login_user(&uid) == true) {
- SECURE_MSG("launch app uid : %d", uid);
- appsvc_usr_run_service(bd, 0, NULL, NULL, uid);
- }
+ net_nfc_util_get_login_user(&uid);
+
+ SECURE_MSG("launch app uid : %d", uid);
+ appsvc_usr_run_service(bd, 0, NULL, NULL, uid);
bundle_free(bd);
appsvc_add_data(bd, "data", param_string);
}
- if (net_nfc_util_get_login_user(&uid) == true) {
- SECURE_MSG("launch app uid : %d", uid);
- appsvc_usr_run_service(bd, 0, NULL, NULL, uid);
- }
+ net_nfc_util_get_login_user(&uid);
+
+ SECURE_MSG("launch app uid : %d", uid);
+ appsvc_usr_run_service(bd, 0, NULL, NULL, uid);
bundle_free(bd);
}
if (handler != NULL) {
- if (net_nfc_util_get_login_user(&uid) == true) {
- SECURE_MSG("package name : %s, launch app uid : %d", handler->package, uid);
- aul_launch_app_for_uid(handler->package, bd, uid);
- }
+ net_nfc_util_get_login_user(&uid);
+
+ SECURE_MSG("package name : %s, launch app uid : %d", handler->package, uid);
+ aul_launch_app_for_uid(handler->package, bd, uid);
}
bundle_free(bd);
int *pid = (int *)data;
int status;
- if (net_nfc_util_get_login_user(&uid) == false) {
- DEBUG_ERR_MSG("net_nfc_util_get_login_user is failed");
- return 0;
- }
+ net_nfc_util_get_login_user(&uid);
status = aul_app_get_status_bypid_for_uid(info->pid, uid);
uid_t uid = 0;
int pid = 0;
- if (net_nfc_util_get_login_user(&uid) == false) {
- DEBUG_ERR_MSG("net_nfc_util_get_login_user is failed");
- return -1;
- }
+ net_nfc_util_get_login_user(&uid);
ret = aul_app_get_all_running_app_info_for_uid(_iter_func, &pid, uid);
appsvc_set_operation(bd, "http://tizen.org/appcontrol/operation/nfc/card_emulation/host_apdu_service");
appsvc_add_data(bd, "data", aid);
- if (net_nfc_util_get_login_user(&uid) == true) {
- char *app_id;
- pkgmgrinfo_pkginfo_h pkgmgr_handle;
+ char *app_id;
+ pkgmgrinfo_pkginfo_h pkgmgr_handle;
- ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(handler->package, uid, &pkgmgr_handle);
+ net_nfc_util_get_login_user(&uid);
+
+ ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(handler->package, uid, &pkgmgr_handle);
+ if (ret == PMINFO_R_OK) {
+ ret = pkgmgrinfo_pkginfo_get_mainappid(pkgmgr_handle, &app_id);
if (ret == PMINFO_R_OK) {
- ret = pkgmgrinfo_pkginfo_get_mainappid(pkgmgr_handle, &app_id);
- if (ret == PMINFO_R_OK) {
- DEBUG_SERVER_MSG("appid is %s", app_id);
- ret = aul_launch_app_for_uid(app_id, bd, uid);
- if (ret < 0)
- DEBUG_ERR_MSG("aul_launch_app_for_uid failed, uid [%d] ret [%d]", uid, ret);
- }
+ DEBUG_SERVER_MSG("appid is %s", app_id);
+ ret = aul_launch_app_for_uid(app_id, bd, uid);
+ if (ret < 0)
+ DEBUG_ERR_MSG("aul_launch_app_for_uid failed, uid [%d] ret [%d]", uid, ret);
}
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgr_handle);
- } else {
- DEBUG_ERR_MSG("net_nfc_util_get_login_user is failed");
}
+ pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgr_handle);
bundle_free(bd);
}
gboolean is_active;
};
+typedef struct _ManagerConfigureDiscoveryData ManagerConfigureDiscoveryData;
+
+struct _ManagerConfigureDiscoveryData {
+ NetNfcGDbusManager *manager;
+ GDBusMethodInvocation *invocation;
+ gint mode;
+};
+
static NetNfcGDbusManager *manager_skeleton = NULL;
static net_nfc_error_e manager_active(void);
return TRUE;
}
-/* LCOV_EXCL_STOP */
+
+static void manager_handle_configure_discovery_thread_func(gpointer user_data)
+{
+ ManagerConfigureDiscoveryData *data = (ManagerConfigureDiscoveryData *)user_data;
+ net_nfc_error_e result;
+
+ g_assert(data != NULL);
+ g_assert(data->manager != NULL);
+ g_assert(data->invocation != NULL);
+
+ net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_STOP, NET_NFC_ALL_DISABLE, &result);
+ DEBUG_ERR_MSG("configure discovery disable result : %d", result);
+
+ net_nfc_controller_configure_discovery(data->mode, NET_NFC_ALL_ENABLE, &result);
+ DEBUG_ERR_MSG("configure discovery enable result : %d", result);
+
+ net_nfc_gdbus_manager_complete_configure_discovery(data->manager,
+ data->invocation,
+ result);
+
+ g_object_unref(data->invocation);
+ g_object_unref(data->manager);
+
+ g_free(data);
+}
+
+static gboolean manager_handle_configure_discovery(NetNfcGDbusManager *manager,
+ GDBusMethodInvocation *invocation,
+ gint mode,
+ GVariant *smack_privilege,
+ gpointer user_data)
+{
+ ManagerConfigureDiscoveryData *data = NULL;
+ gint result = NET_NFC_OK;
+
+ INFO_MSG(">>> REQUEST from [%s]",
+ g_dbus_method_invocation_get_sender(invocation));
+
+ /* check privilege and update client context */
+ if (net_nfc_server_gdbus_check_privilege(invocation, NET_NFC_PRIVILEGE_NFC) == false) {
+ DEBUG_ERR_MSG("permission denied, and finished request");
+ result = NET_NFC_PERMISSION_DENIED;
+
+ goto END;
+ }
+
+ DEBUG_SERVER_MSG("mode : %d", mode);
+
+ data = g_try_new0(ManagerConfigureDiscoveryData, 1);
+ if (data == NULL)
+ {
+ DEBUG_ERR_MSG("Memory allocation failed");
+ result = NET_NFC_ALLOC_FAIL;
+
+ goto END;
+ }
+
+ data->manager = g_object_ref(manager);
+ data->invocation = g_object_ref(invocation);
+ data->mode = mode;
+
+ if (net_nfc_server_controller_async_queue_push(
+ manager_handle_configure_discovery_thread_func, data) == FALSE)
+ {
+ /* return error if queue was blocked */
+ DEBUG_SERVER_MSG("controller is processing important message..");
+ result = NET_NFC_BUSY;
+
+ goto END;
+ }
+
+ return TRUE;
+
+END :
+ if (data != NULL) {
+ g_object_unref(data->invocation);
+ g_object_unref(data->manager);
+
+ g_free(data);
+ }
+
+ net_nfc_gdbus_manager_complete_configure_discovery(manager,
+ invocation,
+ result);
+
+ return TRUE;
+}
/* server side */
static void manager_active_thread_func(gpointer user_data)
g_signal_connect(manager_skeleton, "handle-get-server-state", G_CALLBACK(manager_handle_get_server_state), NULL);
+ g_signal_connect(manager_skeleton, "handle-configure-discovery", G_CALLBACK(manager_handle_configure_discovery), NULL);
+
+
if (g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(manager_skeleton), connection, "/org/tizen/NetNfcService/Manager", &error) == FALSE) {
DEBUG_ERR_MSG("Can not skeleton_export %s", error->message);