mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-17 17:24:32 +08:00
serial: moving error functions to error.c
This commit is contained in:
parent
e5d465b5ad
commit
ceeb274a3b
@ -26,3 +26,82 @@
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
|
||||
#define SERIAL_ERROR_INTERFACE "org.bluez.serial.Error"
|
||||
|
||||
DBusHandlerResult err_connection_canceled(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionCanceled",
|
||||
"Connection creation canceled"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_connection_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionAttemptFailed", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_connection_in_progress(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionInProgress",
|
||||
"Connection creation in progress"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_connection_not_in_progress(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionNotInProgress",
|
||||
"Connection creation not in progress"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_does_not_exist(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".DoesNotExist", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".Failed", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_invalid_args(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".InvalidArguments", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_not_authorized(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".NotAuthorized",
|
||||
"Owner not allowed"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_not_supported(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".NotSupported",
|
||||
"The service is not supported by the remote device"));
|
||||
}
|
||||
|
@ -20,3 +20,24 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <dbus.h>
|
||||
|
||||
DBusHandlerResult err_connection_canceled(DBusConnection *conn,
|
||||
DBusMessage *msg);
|
||||
DBusHandlerResult err_connection_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult err_connection_in_progress(DBusConnection *conn,
|
||||
DBusMessage *msg);
|
||||
DBusHandlerResult err_connection_not_in_progress(DBusConnection *conn,
|
||||
DBusMessage *msg);
|
||||
DBusHandlerResult err_does_not_exist(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult err_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult err_invalid_args(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult err_not_authorized(DBusConnection *conn,
|
||||
DBusMessage *msg);
|
||||
DBusHandlerResult err_not_supported(DBusConnection *conn,
|
||||
DBusMessage *msg);
|
||||
|
@ -47,11 +47,11 @@
|
||||
#include "dbus-helper.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "manager.h"
|
||||
|
||||
#define SERIAL_MANAGER_PATH "/org/bluez/serial"
|
||||
#define SERIAL_MANAGER_INTERFACE "org.bluez.serial.Manager"
|
||||
#define SERIAL_ERROR_INTERFACE "org.bluez.serial.Error"
|
||||
|
||||
#define BASE_UUID "00000000-0000-1000-8000-00805F9B34FB"
|
||||
|
||||
@ -176,83 +176,6 @@ static uint16_t str2class(const char *pattern)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DBusHandlerResult err_connection_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionAttemptFailed", str));
|
||||
}
|
||||
|
||||
static DBusHandlerResult err_connection_canceled(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionCanceled",
|
||||
"Connection creation canceled"));
|
||||
}
|
||||
|
||||
static DBusHandlerResult err_connection_in_progress(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionInProgress",
|
||||
"Connection creation in progress"));
|
||||
}
|
||||
|
||||
static DBusHandlerResult err_connection_not_in_progress(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionNotInProgress",
|
||||
"Connection creation not in progress"));
|
||||
}
|
||||
|
||||
static DBusHandlerResult err_does_not_exist(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".DoesNotExist", str));
|
||||
}
|
||||
|
||||
static DBusHandlerResult err_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".Failed", str));
|
||||
}
|
||||
|
||||
static DBusHandlerResult err_invalid_args(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".InvalidArguments", str));
|
||||
}
|
||||
|
||||
static DBusHandlerResult err_not_authorized(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".NotAuthorized",
|
||||
"Owner not allowed"));
|
||||
}
|
||||
|
||||
static DBusHandlerResult err_not_supported(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".NotSupported",
|
||||
"The service is not supported by the remote device"));
|
||||
}
|
||||
|
||||
static int rfcomm_release(int16_t id)
|
||||
{
|
||||
struct rfcomm_dev_req req;
|
||||
|
Loading…
Reference in New Issue
Block a user