예제 #1
0
int __near_agent_init(void)
{
	DBG("");

	connection = near_dbus_get_connection();
	if (!connection)
		return -1;

	g_dbus_register_interface(connection, NFC_PATH,
						NFC_AGENT_MANAGER_INTERFACE,
						manager_methods,
						NULL, NULL, NULL, NULL);

	/*
	 * Legacy interface, for backward compatibility only.
	 * To be removed after 0.16.
	 */
	g_dbus_register_interface(connection, "/", "org.neard.Manager",
						manager_methods,
						NULL, NULL, NULL, NULL);


	ndef_app_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
						g_free, ndef_agent_free);

	ho_agent_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal,
						NULL, handover_agent_free);

	return 0;
}
예제 #2
0
파일: se.c 프로젝트: aklein53/neard
static void close_channel_cb(void *context, uint8_t *apdu, size_t apdu_length,
									int err)
{
	struct close_channel_context *ctx = context;
	char *channel_path;
	DBusConnection *conn;

	conn = near_dbus_get_connection();

	if (err)
		return close_channel_error(ctx, err);

	/* Check response status */
	err = __seel_apdu_resp_status(apdu, apdu_length);
	if (err)
		return close_channel_error(ctx, err);

	channel_path = __seel_channel_get_path(ctx->channel);
	if (!g_hash_table_remove(ctx->se->channel_hash, channel_path))
		return close_channel_error(ctx, -ENODEV);

	g_dbus_send_reply(conn, ctx->msg, DBUS_TYPE_INVALID);

	dbus_message_unref(ctx->msg);
	ctx->msg = NULL;
	g_free(ctx);

	return;
}
예제 #3
0
파일: adapter.c 프로젝트: aklein53/neard
int __near_adapter_init(void)
{
	DBG("");

	connection = near_dbus_get_connection();

	adapter_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal,
							NULL, free_adapter);

	return 0;
}
예제 #4
0
파일: se.c 프로젝트: aklein53/neard
static void select_aid_cb(void *context,
			uint8_t *apdu, size_t apdu_length,
			int err)
{
	struct open_channel_context *ctx = context;
	struct seel_apdu *close_channel;
	struct seel_channel *channel;
	char *path;
	DBusConnection *conn;
	int ret;

	conn = near_dbus_get_connection();

	if (err != 0) {
		/*
		 * err != 0 means SW != 9000.
		 * In this case, we need to clean the previously
		 * allocated logical channel.
		 */
		close_channel = __seel_apdu_close_logical_channel(ctx->channel);
		if (!close_channel)
			goto err;

		ret = __seel_se_queue_io(ctx->se, close_channel, NULL, ctx);
		if (ret < 0) {
			near_error("close channel error %d", ret);
			err = ret;
		}

		goto err;
	}

	channel = __seel_channel_add(ctx->se, ctx->channel,
					ctx->aid, ctx->aid_len, false);
	if (!channel) {
		err = -ENOMEM;
		goto err;
	}

	path = __seel_channel_get_path(channel);
	g_hash_table_replace(ctx->se->channel_hash, path, channel);

	g_dbus_send_reply(conn, ctx->msg,
				DBUS_TYPE_OBJECT_PATH, &path,
				DBUS_TYPE_INVALID);

	dbus_message_unref(ctx->msg);
	ctx->msg = NULL;
	g_free(ctx);
	return;

err:
	return open_channel_error(ctx, err);
}
예제 #5
0
파일: se.c 프로젝트: aklein53/neard
static void close_channel_error(struct close_channel_context *ctx, int err)
{
	DBusMessage *reply;
	DBusConnection *conn;

	near_error("error %d", err);

	conn = near_dbus_get_connection();

	reply = __near_error_failed(ctx->msg, -err);
	if (reply != NULL)
		g_dbus_send_message(conn, reply);

	dbus_message_unref(ctx->msg);
	ctx->msg = NULL;
	g_free(ctx);
}
예제 #6
0
파일: tizen.c 프로젝트: aklein53/neard
static int tapi_init(void)
{
	int err;

	DBG("");

	connection = near_dbus_get_connection();
	if (connection == NULL)
		return -EIO;

	watch = g_dbus_add_service_watch(connection, TELEPHONY_SERVICE,
					tapi_connect, tapi_disconnect,
					NULL, NULL);

	sim_watch = g_dbus_add_signal_watch(connection, TELEPHONY_SERVICE,
					NULL, SIM_INTERFACE, SIM_STATUS,
					sim_changed, NULL, NULL);

	if (watch == 0 || sim_watch == 0) {
		err = -EIO;
		goto remove;
	}

	err = seel_io_driver_register(&tizen_io_driver);
	if (err < 0)
		goto remove;

	err = seel_cert_driver_register(&tizen_cert_driver);
	if (err < 0) {
		seel_io_driver_unregister(&tizen_io_driver);
		goto remove;
	}

	return 0;

remove:
	g_dbus_remove_watch(connection, watch);
	g_dbus_remove_watch(connection, sim_watch);

	dbus_connection_unref(connection);

	return err;
}
예제 #7
0
/* Initialize the PHDC plugin - Expose our dbus entry points */
int phdc_init(void)
{
	gboolean err;

	DBG("");

	/* save the dbus connection */
	phdc_conn = near_dbus_get_connection();

	mgr_list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
								free_mgr_data);

	/* register dbus interface */
	err = g_dbus_register_interface(phdc_conn, "/org/neard",
							NFC_NEARD_PHDC_IFACE,
							phdc_methods,
							NULL, NULL, NULL, NULL);

	return err;
}