net_nfc_error_e result,
void *user_data);
+typedef void (*net_nfc_se_get_se_cb)(
+ net_nfc_error_e result,
+ net_nfc_se_type_e se_type,
+ void *user_data);
+
typedef void (*net_nfc_se_set_card_emulation_cb)(net_nfc_error_e result,
void *user_data);
net_nfc_se_type_e se_type);
-net_nfc_error_e net_nfc_client_se_get_secure_element_type(void *user_data);
-
+net_nfc_error_e net_nfc_client_se_get_secure_element_type(
+ net_nfc_se_get_se_cb callback, void *user_data);
net_nfc_error_e net_nfc_client_se_get_secure_element_type_sync(
net_nfc_se_type_e *se_type);
net_nfc_card_emulation_mode_t mode);
net_nfc_error_e net_nfc_client_se_open_internal_secure_element(
- net_nfc_se_type_e se_type, net_nfc_se_open_se_cb callback, void *user_data);
-
+ net_nfc_se_type_e se_type,
+ net_nfc_se_open_se_cb callback,
+ void *user_data);
net_nfc_error_e net_nfc_client_se_open_internal_secure_element_sync(
net_nfc_se_type_e se_type, net_nfc_target_handle_h *handle);
-
net_nfc_error_e net_nfc_client_se_close_internal_secure_element(
- net_nfc_target_handle_h handle, net_nfc_se_close_se_cb callback, void *user_data);
-
+ net_nfc_target_handle_h handle,
+ net_nfc_se_close_se_cb callback,
+ void *user_data);
net_nfc_error_e net_nfc_client_se_close_internal_secure_element_sync(
net_nfc_target_handle_h handle);
-
net_nfc_error_e net_nfc_client_se_get_atr(net_nfc_target_handle_h handle,
net_nfc_se_get_atr_cb callback, void *user_data);
-
net_nfc_error_e net_nfc_client_se_get_atr_sync(net_nfc_target_handle_h handle,
data_h *atr);
-
net_nfc_error_e net_nfc_client_se_send_apdu(net_nfc_target_handle_h handle,
data_h apdu_data, net_nfc_se_send_apdu_cb callback, void *user_data);
-
net_nfc_error_e net_nfc_client_se_send_apdu_sync(
net_nfc_target_handle_h handle, data_h apdu_data, data_h *response);
-
/************* Secure Element CallBack Register/Deregister functions*************/
void net_nfc_client_se_set_ese_detection_cb(
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <vconf.h>
#include "net_nfc_typedef_internal.h"
#include "net_nfc_debug_internal.h"
gpointer user_data)
{
SeFuncData *func_data = (SeFuncData *)user_data;
- net_nfc_error_e result;
+ net_nfc_error_e result = NET_NFC_OK;
GError *error = NULL;
g_assert(user_data != NULL);
g_free(func_data);
}
+static void get_secure_element(GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ NetNfcCallback *func_data = (NetNfcCallback *)user_data;
+ net_nfc_error_e result = NET_NFC_OK;
+ gint type = 0;
+ GError *error = NULL;
+
+ g_assert(user_data != NULL);
+
+ if (net_nfc_gdbus_secure_element_call_get_finish(se_proxy,
+ &result,
+ &type,
+ res,
+ &error) == FALSE)
+ {
+ DEBUG_ERR_MSG("Could not set secure element: %s",
+ error->message);
+
+ g_error_free(error);
+
+ result = NET_NFC_IPC_FAIL;
+ }
+
+ if (func_data->callback != NULL)
+ {
+ net_nfc_se_get_se_cb se_callback =
+ (net_nfc_se_get_se_cb)func_data->callback;
+
+ se_callback(result, type, func_data->user_data);
+ }
+
+ g_free(func_data);
+}
static void _set_card_emulation_cb(GObject *source_object,
GAsyncResult *res,
return result;
}
+API net_nfc_error_e net_nfc_client_se_get_secure_element_type(
+ net_nfc_se_get_se_cb callback,
+ void *user_data)
+{
+ NetNfcCallback *func_data;
+
+ if (se_proxy == NULL)
+ {
+ DEBUG_ERR_MSG("Can not get se_proxy");
+
+ return NET_NFC_NOT_INITIALIZED;
+ }
+
+ /* prevent executing daemon when nfc is off */
+ if (net_nfc_client_manager_is_activated() == false) {
+ return NET_NFC_INVALID_STATE;
+ }
+
+ func_data = g_try_new0(NetNfcCallback, 1);
+ if (func_data == NULL)
+ return NET_NFC_ALLOC_FAIL;
+
+ func_data->callback = (gpointer)callback;
+ func_data->user_data = user_data;
+
+ net_nfc_gdbus_secure_element_call_get(
+ se_proxy,
+ net_nfc_client_gdbus_get_privilege(),
+ NULL,
+ get_secure_element,
+ func_data);
+
+ return NET_NFC_OK;
+}
+
+API net_nfc_error_e net_nfc_client_se_get_secure_element_type_sync(
+ net_nfc_se_type_e *se_type)
+{
+ net_nfc_error_e result = NET_NFC_OK;
+ gint type;
+#if 0
+ GError *error = NULL;
+#endif
+ if (se_proxy == NULL)
+ {
+ DEBUG_ERR_MSG("Can not get se_proxy");
+
+ return NET_NFC_NOT_INITIALIZED;
+ }
+
+ /* prevent executing daemon when nfc is off */
+ if (net_nfc_client_manager_is_activated() == false) {
+ return NET_NFC_INVALID_STATE;
+ }
+#if 1
+ if (vconf_get_int(VCONFKEY_NFC_SE_TYPE, &type) == 0) {
+ *se_type = type;
+ } else {
+ result = NET_NFC_OPERATION_FAIL;
+ }
+#else
+ if (net_nfc_gdbus_secure_element_call_get_sync(
+ se_proxy,
+ net_nfc_client_gdbus_get_privilege(),
+ &result,
+ (gint)&type,
+ NULL,
+ &error) == true) {
+ *se_type = type;
+ } else {
+ DEBUG_ERR_MSG("Set secure element failed: %s", error->message);
+
+ g_error_free(error);
+
+ result = NET_NFC_IPC_FAIL;
+ }
+#endif
+ return result;
+}
+
API net_nfc_error_e net_nfc_set_card_emulation_mode(
net_nfc_card_emulation_mode_t mode,
net_nfc_se_set_card_emulation_cb callback,
<arg type="i" name="result" direction="out" />
</method>
+ <!--
+ Get
+ -->
+ <method name="Get">
+ <arg type="a(y)" name="privilege" direction="in" />
+ <arg type="i" name="result" direction="out" />
+ <arg type="i" name="type" direction="out" />
+ </method>
+
<!--
SetCardEmulation
-->
static net_nfc_target_handle_s *gdbus_ese_handle;
static int gdbus_uicc_ready;
+
/* server_side */
typedef struct _ServerSeData ServerSeData;
return result;
}
+static void se_get_data_thread_func(gpointer user_data)
+{
+ SeDataSeType *data = (SeDataSeType *)user_data;
+ net_nfc_error_e result = NET_NFC_OK;
+
+ g_assert(data != NULL);
+ g_assert(data->object != NULL);
+ g_assert(data->invocation != NULL);
+
+ net_nfc_gdbus_secure_element_complete_get(data->object,
+ data->invocation,
+ net_nfc_server_se_get_se_type(),
+ result);
+
+ g_object_unref(data->invocation);
+ g_object_unref(data->object);
+
+ g_free(data);
+}
+
+static gboolean se_handle_get(
+ NetNfcGDbusSecureElement *object,
+ GDBusMethodInvocation *invocation,
+ GVariant *smack_privilege)
+{
+ SeDataSeType *data;
+ gboolean result;
+
+ 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,
+ smack_privilege,
+ "nfc-manager",
+ "r") == false) {
+ DEBUG_ERR_MSG("permission denied, and finished request");
+
+ return FALSE;
+ }
+
+ data = g_try_new0(SeDataSeType, 1);
+ if (data == NULL)
+ {
+ DEBUG_ERR_MSG("Memory allocation failed");
+ g_dbus_method_invocation_return_dbus_error(invocation,
+ "org.tizen.NetNfcService.AllocationError",
+ "Can not allocate memory");
+
+ return FALSE;
+ }
+
+ data->object = g_object_ref(object);
+ data->invocation = g_object_ref(invocation);
+
+ result = net_nfc_server_controller_async_queue_push(
+ se_get_data_thread_func, data);
+ if (result == FALSE)
+ {
+ g_dbus_method_invocation_return_dbus_error(invocation,
+ "org.tizen.NetNfcService.Se.ThreadError",
+ "can not push to controller thread");
+
+ g_object_unref(data->object);
+ g_object_unref(data->invocation);
+
+ g_free(data);
+ }
+
+ return result;
+}
+
gboolean net_nfc_server_se_init(GDBusConnection *connection)
{
GError *error = NULL;
"handle-set",
G_CALLBACK(se_handle_set),
NULL);
+
+ g_signal_connect(se_skeleton,
+ "handle-get",
+ G_CALLBACK(se_handle_get),
+ NULL);
+
g_signal_connect(se_skeleton,
"handle-set-card-emulation",
G_CALLBACK(_se_handle_set_card_emulation),