diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2012-06-11 13:30:39 +0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2012-06-11 13:38:03 +0300 |
commit | 9e14f0458deca53ef1e98221f1cc2d34a81e98a5 (patch) | |
tree | f3af1a5c13404165d19a08966406843d00c3a1ab | |
parent | 7b0aa717c531cb359e71b253b5dec62cd7d79035 (diff) | |
download | obexd-9e14f0458deca53ef1e98221f1cc2d34a81e98a5.tar.gz |
client: Fix using org.openobex.Error
In addition use define so it is easier to change this in future
-rw-r--r-- | client/ftp.c | 42 | ||||
-rw-r--r-- | client/manager.c | 19 | ||||
-rw-r--r-- | client/map.c | 17 | ||||
-rw-r--r-- | client/opp.c | 12 | ||||
-rw-r--r-- | client/pbap.c | 70 | ||||
-rw-r--r-- | client/session.c | 10 | ||||
-rw-r--r-- | client/transfer.c | 7 |
7 files changed, 92 insertions, 85 deletions
diff --git a/client/ftp.c b/client/ftp.c index 0b12d12..45c1057 100644 --- a/client/ftp.c +++ b/client/ftp.c @@ -43,6 +43,7 @@ #define OBEX_FTP_UUID_LEN 16 #define FTP_INTERFACE "org.bluez.obex.FileTransfer" +#define ERROR_INTERFACE "org.bluez.obex.Error" #define FTP_UUID "00001106-0000-1000-8000-00805f9b34fb" #define PCSUITE_UUID "00005005-0000-1000-8000-0002ee000001" @@ -58,7 +59,7 @@ static void async_cb(struct obc_session *session, struct obc_transfer *transfer, DBusMessage *reply, *msg = user_data; if (err != NULL) - reply = g_dbus_create_error(msg, "org.openobex.Error.Failed", + reply = g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", "%s", err->message); else reply = dbus_message_new_method_return(msg); @@ -79,13 +80,13 @@ static DBusMessage *change_folder(DBusConnection *connection, DBUS_TYPE_STRING, &folder, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); obc_session_setpath(session, folder, async_cb, message, &err); if (err != NULL) { DBusMessage *reply; reply = g_dbus_create_error(message, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; @@ -188,13 +189,13 @@ static DBusMessage *create_folder(DBusConnection *connection, DBUS_TYPE_STRING, &folder, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); obc_session_mkdir(session, folder, async_cb, message, &err); if (err != NULL) { DBusMessage *reply; reply = g_dbus_create_error(message, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; @@ -225,7 +226,7 @@ static DBusMessage *list_folder(DBusConnection *connection, } fail: - reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; @@ -246,7 +247,7 @@ static DBusMessage *get_file(DBusConnection *connection, DBUS_TYPE_STRING, &source_file, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); transfer = obc_transfer_get(NULL, source_file, target_file, &err); if (transfer == NULL) @@ -258,7 +259,7 @@ static DBusMessage *get_file(DBusConnection *connection, return obc_transfer_create_dbus_reply(transfer, message); fail: - reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; @@ -279,7 +280,7 @@ static DBusMessage *put_file(DBusConnection *connection, DBUS_TYPE_STRING, &targetfile, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", + ERROR_INTERFACE ".InvalidArguments", "Invalid arguments in method call"); transfer = obc_transfer_put(NULL, targetfile, sourcefile, NULL, 0, @@ -293,7 +294,7 @@ static DBusMessage *put_file(DBusConnection *connection, return obc_transfer_create_dbus_reply(transfer, message); fail: - reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; @@ -312,14 +313,13 @@ static DBusMessage *copy_file(DBusConnection *connection, DBUS_TYPE_STRING, &destname, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); obc_session_copy(session, filename, destname, async_cb, message, &err); if (err != NULL) { DBusMessage *reply; - reply = g_dbus_create_error(message, - "org.openobex.Error.Failed", - "%s", err->message); + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", + "%s", err->message); g_error_free(err); return reply; } @@ -342,14 +342,13 @@ static DBusMessage *move_file(DBusConnection *connection, DBUS_TYPE_STRING, &destname, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); obc_session_move(session, filename, destname, async_cb, message, &err); if (err != NULL) { DBusMessage *reply; - reply = g_dbus_create_error(message, - "org.openobex.Error.Failed", - "%s", err->message); + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", + "%s", err->message); g_error_free(err); return reply; } @@ -371,14 +370,13 @@ static DBusMessage *delete(DBusConnection *connection, DBUS_TYPE_STRING, &file, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); obc_session_delete(session, file, async_cb, message, &err); if (err != NULL) { DBusMessage *reply; - reply = g_dbus_create_error(message, - "org.openobex.Error.Failed", - "%s", err->message); + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", + "%s", err->message); g_error_free(err); return reply; } diff --git a/client/manager.c b/client/manager.c index 1ae95f5..7f2fede9 100644 --- a/client/manager.c +++ b/client/manager.c @@ -48,6 +48,7 @@ #define CLIENT_SERVICE "org.bluez.obex.client" #define CLIENT_INTERFACE "org.bluez.obex.Client" +#define ERROR_INTERFACE "org.bluez.obex.Error" #define CLIENT_PATH "/" struct send_data { @@ -84,7 +85,7 @@ static void create_callback(struct obc_session *session, if (err != NULL) { DBusMessage *error = g_dbus_create_error(data->message, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "%s", err->message); g_dbus_send_message(data->connection, error); shutdown_session(session); @@ -162,26 +163,26 @@ static DBusMessage *create_session(DBusConnection *connection, dbus_message_iter_init(message, &iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); dbus_message_iter_get_basic(&iter, &dest); dbus_message_iter_next(&iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); dbus_message_iter_recurse(&iter, &dict); parse_device_dict(&dict, &source, &target, &channel); if (dest == NULL || target == NULL) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); data = g_try_malloc0(sizeof(*data)); if (data == NULL) return g_dbus_create_error(message, - "org.openobex.Error.NoMemory", NULL); + ERROR_INTERFACE ".Error.NoMemory", NULL); data->connection = dbus_connection_ref(connection); data->message = dbus_message_ref(message); @@ -198,7 +199,7 @@ static DBusMessage *create_session(DBusConnection *connection, dbus_connection_unref(data->connection); g_free(data); - return g_dbus_create_error(message, "org.openobex.Error.Failed", NULL); + return g_dbus_create_error(message, ERROR_INTERFACE ".Failed", NULL); } static DBusMessage *remove_session(DBusConnection *connection, @@ -211,17 +212,17 @@ static DBusMessage *remove_session(DBusConnection *connection, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); session = find_session(path); if (session == NULL) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); sender = dbus_message_get_sender(message); if (g_str_equal(sender, obc_session_get_owner(session)) == FALSE) return g_dbus_create_error(message, - "org.openobex.Error.NotAuthorized", + ERROR_INTERFACE ".NotAuthorized", "Not Authorized"); shutdown_session(session); diff --git a/client/map.c b/client/map.c index 1bf1f4f..18c4af1 100644 --- a/client/map.c +++ b/client/map.c @@ -41,6 +41,7 @@ #define OBEX_MAS_UUID_LEN 16 #define MAP_INTERFACE "org.bluez.obex.MessageAccess" +#define ERROR_INTERFACE "org.bluez.obex.Error" #define MAS_UUID "00001132-0000-1000-8000-00805f9b34fb" struct map_data { @@ -59,7 +60,7 @@ static void simple_cb(struct obc_session *session, if (err != NULL) reply = g_dbus_create_error(map->msg, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "%s", err->message); else reply = dbus_message_new_method_return(map->msg); @@ -78,14 +79,14 @@ static DBusMessage *map_setpath(DBusConnection *connection, if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &folder, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", + ERROR_INTERFACE ".InvalidArguments", NULL); obc_session_setpath(map->session, folder, simple_cb, map, &err); if (err != NULL) { DBusMessage *reply; reply = g_dbus_create_error(message, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; @@ -108,7 +109,7 @@ static void buffer_cb(struct obc_session *session, if (err != NULL) { reply = g_dbus_create_error(map->msg, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "%s", err->message); goto done; } @@ -116,7 +117,7 @@ static void buffer_cb(struct obc_session *session, perr = obc_transfer_get_contents(transfer, &contents, &size); if (perr < 0) { reply = g_dbus_create_error(map->msg, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "Error reading contents: %s", strerror(-perr)); goto done; @@ -149,7 +150,7 @@ static DBusMessage *map_get_folder_listing(DBusConnection *connection, } fail: - reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; @@ -169,7 +170,7 @@ static DBusMessage *map_get_message_listing(DBusConnection *connection, if (dbus_message_iter_get_arg_type(&msg_iter) != DBUS_TYPE_STRING) return g_dbus_create_error(message, - "org.openobex.Error.InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); dbus_message_iter_get_basic(&msg_iter, &folder); @@ -183,7 +184,7 @@ static DBusMessage *map_get_message_listing(DBusConnection *connection, } fail: - reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; diff --git a/client/opp.c b/client/opp.c index 5e84f41..5137de8 100644 --- a/client/opp.c +++ b/client/opp.c @@ -37,7 +37,7 @@ #define OPP_UUID "00001105-0000-1000-8000-00805f9b34fb" #define OPP_INTERFACE "org.bluez.obex.ObjectPush" -#define ERROR_INF OPP_INTERFACE ".Error" +#define ERROR_INTERFACE "org.bluez.obex.Error" struct opp_data { struct obc_session *session; @@ -59,7 +59,7 @@ static DBusMessage *opp_send_file(DBusConnection *connection, DBUS_TYPE_STRING, &filename, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); basename = g_path_get_basename(filename); @@ -77,7 +77,7 @@ static DBusMessage *opp_send_file(DBusConnection *connection, fail: reply = g_dbus_create_error(message, - ERROR_INF ".Failed", "%s", err->message); + ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; } @@ -95,7 +95,7 @@ static DBusMessage *opp_pull_business_card(DBusConnection *connection, DBUS_TYPE_STRING, &filename, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); pull = obc_transfer_get("text/x-vcard", NULL, filename, &err); if (pull == NULL) @@ -108,7 +108,7 @@ static DBusMessage *opp_pull_business_card(DBusConnection *connection, fail: reply = g_dbus_create_error(message, - ERROR_INF ".Failed", "%s", err->message); + ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; } @@ -116,7 +116,7 @@ fail: static DBusMessage *opp_exchange_business_cards(DBusConnection *connection, DBusMessage *message, void *user_data) { - return g_dbus_create_error(message, "org.openobex.Error.Failed", NULL); + return g_dbus_create_error(message, ERROR_INTERFACE ".Failed", NULL); } static const GDBusMethodTable opp_methods[] = { diff --git a/client/pbap.c b/client/pbap.c index 9bd93b8..5ec7634 100644 --- a/client/pbap.c +++ b/client/pbap.c @@ -45,8 +45,6 @@ "\x79\x61\x35\xF0\xF0\xC5\x11\xD8\x09\x66\x08\x00\x20\x0C\x9A\x66" #define OBEX_PBAP_UUID_LEN 16 -#define ERROR_INF PBAP_INTERFACE ".Error" - #define FORMAT_VCARD21 0x0 #define FORMAT_VCARD30 0x1 @@ -123,6 +121,7 @@ static const char *filter_list[] = { #define FILTER_ALL 0xFFFFFFFFFFFFFFFFULL #define PBAP_INTERFACE "org.bluez.obex.PhonebookAccess" +#define ERROR_INTERFACE "org.bluez.obex.Error" #define PBAP_UUID "0000112f-0000-1000-8000-00805f9b34fb" struct pbap_data { @@ -284,8 +283,8 @@ static void pbap_setpath_cb(struct obc_session *session, if (err) { DBusMessage *reply = g_dbus_create_error(request->msg, - ERROR_INF ".Failed", - "%s", err->message); + ERROR_INTERFACE ".Failed", + "%s", err->message); g_dbus_send_message(conn, reply); } else g_dbus_send_reply(conn, request->msg, DBUS_TYPE_INVALID); @@ -351,7 +350,7 @@ static void phonebook_size_callback(struct obc_session *session, if (err) { reply = g_dbus_create_error(request->msg, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "%s", err->message); goto send; } @@ -383,7 +382,7 @@ static void pull_vcard_listing_callback(struct obc_session *session, if (err) { reply = g_dbus_create_error(request->msg, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "%s", err->message); goto send; } @@ -391,7 +390,7 @@ static void pull_vcard_listing_callback(struct obc_session *session, perr = obc_transfer_get_contents(transfer, &contents, &size); if (perr < 0) { reply = g_dbus_create_error(request->msg, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "Error reading contents: %s", strerror(-perr)); goto send; @@ -534,7 +533,7 @@ static DBusMessage *pull_vcard_listing(struct pbap_data *pbap, pending_request_free(request); fail: - reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; @@ -667,12 +666,13 @@ static DBusMessage *pbap_select(DBusConnection *connection, DBUS_TYPE_STRING, &item, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); path = build_phonebook_path(location, item); if (path == NULL) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", "Invalid path"); + ERROR_INTERFACE ".InvalidArguments", + "Invalid path"); if (pbap->path != NULL && g_str_equal(pbap->path, path)) { g_free(path); @@ -685,7 +685,7 @@ static DBusMessage *pbap_select(DBusConnection *connection, &err); if (err != NULL) { DBusMessage *reply; - reply = g_dbus_create_error(message, ERROR_INF ".Failed", + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); g_free(path); @@ -710,13 +710,14 @@ static DBusMessage *pbap_pull_all(DBusConnection *connection, if (!pbap->path) return g_dbus_create_error(message, - ERROR_INF ".Forbidden", "Call Select first of all"); + ERROR_INTERFACE ".Forbidden", + "Call Select first of all"); if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &targetfile, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); name = g_strconcat(pbap->path, ".vcf", NULL); @@ -727,8 +728,8 @@ static DBusMessage *pbap_pull_all(DBusConnection *connection, if (transfer == NULL) { DBusMessage *reply = g_dbus_create_error(message, - "org.openobex.Error.Failed", "%s", - err->message); + ERROR_INTERFACE ".Failed", "%s", + err->message); g_error_free(err); return reply; } @@ -748,7 +749,7 @@ static DBusMessage *pbap_pull_vcard(DBusConnection *connection, if (!pbap->path) return g_dbus_create_error(message, - ERROR_INF ".Forbidden", + ERROR_INTERFACE ".Forbidden", "Call Select first of all"); if (dbus_message_get_args(message, NULL, @@ -756,7 +757,7 @@ static DBusMessage *pbap_pull_vcard(DBusConnection *connection, DBUS_TYPE_STRING, &targetfile, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); transfer = obc_transfer_get("x-bt/vcard", name, targetfile, &err); if (transfer == NULL) @@ -777,7 +778,7 @@ static DBusMessage *pbap_pull_vcard(DBusConnection *connection, return obc_transfer_create_dbus_reply(transfer, message); fail: - reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", err->message); g_error_free(err); return reply; @@ -790,7 +791,8 @@ static DBusMessage *pbap_list(DBusConnection *connection, if (!pbap->path) return g_dbus_create_error(message, - ERROR_INF ".Forbidden", "Call Select first of all"); + ERROR_INTERFACE ".Forbidden", + "Call Select first of all"); return pull_vcard_listing(pbap, message, "", pbap->order, "", ATTRIB_NAME, DEFAULT_COUNT, DEFAULT_OFFSET); @@ -808,11 +810,12 @@ static DBusMessage *pbap_search(DBusConnection *connection, DBUS_TYPE_STRING, &value, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); if (!pbap->path) return g_dbus_create_error(message, - ERROR_INF ".Forbidden", "Call Select first of all"); + ERROR_INTERFACE ".Forbidden", + "Call Select first of all"); if (!field || g_str_equal(field, "")) attrib = ATTRIB_NAME; @@ -824,7 +827,7 @@ static DBusMessage *pbap_search(DBusConnection *connection, attrib = ATTRIB_SOUND; else return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); return pull_vcard_listing(pbap, message, "", pbap->order, value, attrib, DEFAULT_COUNT, DEFAULT_OFFSET); @@ -841,7 +844,8 @@ static DBusMessage *pbap_get_size(DBusConnection *connection, if (!pbap->path) return g_dbus_create_error(message, - ERROR_INF ".Forbidden", "Call Select first of all"); + ERROR_INTERFACE ".Forbidden", + "Call Select first of all"); name = g_strconcat(pbap->path, ".vcf", NULL); @@ -854,9 +858,8 @@ static DBusMessage *pbap_get_size(DBusConnection *connection, if (transfer != NULL) return NULL; - reply = g_dbus_create_error(message, - "org.openobex.Error.Failed", "%s", - err->message); + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", + err->message); g_error_free(err); return reply; } @@ -871,11 +874,12 @@ static DBusMessage *pbap_set_format(DBusConnection *connection, DBUS_TYPE_STRING, &format, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); if (set_format(pbap, format) < 0) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", "InvalidFormat"); + ERROR_INTERFACE ".InvalidArguments", + "InvalidFormat"); return dbus_message_new_method_return(message); } @@ -890,11 +894,12 @@ static DBusMessage *pbap_set_order(DBusConnection *connection, DBUS_TYPE_STRING, &order, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); if (set_order(pbap, order) < 0) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", "InvalidFilter"); + ERROR_INTERFACE ".InvalidArguments", + "InvalidFilter"); return dbus_message_new_method_return(message); } @@ -911,7 +916,7 @@ static DBusMessage *pbap_set_filter(DBusConnection *connection, DBUS_TYPE_STRING, &filters, &size, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", NULL); + ERROR_INTERFACE ".InvalidArguments", NULL); remove_filter(pbap, "ALL"); if (size == 0) @@ -922,7 +927,8 @@ static DBusMessage *pbap_set_filter(DBusConnection *connection, pbap->filter = oldfilter; g_strfreev(filters); return g_dbus_create_error(message, - ERROR_INF ".InvalidArguments", "InvalidFilters"); + ERROR_INTERFACE ".InvalidArguments", + "InvalidFilters"); } } diff --git a/client/session.c b/client/session.c index 7f88a6a..1b6b927 100644 --- a/client/session.c +++ b/client/session.c @@ -46,6 +46,7 @@ #include "transport.h" #define SESSION_INTERFACE "org.bluez.obex.Session" +#define ERROR_INTERFACE "org.bluez.obex.Error" #define SESSION_BASEPATH "/org/bluez/obex" #define OBEX_IO_ERROR obex_io_error_quark() @@ -567,7 +568,7 @@ static void capabilities_complete_callback(struct obc_session *session, if (err != NULL) { DBusMessage *error = g_dbus_create_error(message, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "%s", err->message); g_dbus_send_message(session->conn, error); goto done; @@ -576,7 +577,7 @@ static void capabilities_complete_callback(struct obc_session *session, perr = obc_transfer_get_contents(transfer, &contents, &size); if (perr < 0) { DBusMessage *error = g_dbus_create_error(message, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "Error reading contents: %s", strerror(-perr)); g_dbus_send_message(session->conn, error); @@ -613,9 +614,8 @@ static DBusMessage *get_capabilities(DBusConnection *connection, return NULL; fail: - reply = g_dbus_create_error(message, - "org.openobex.Error.Failed", - "%s", gerr->message); + reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", + gerr->message); g_error_free(gerr); return reply; diff --git a/client/transfer.c b/client/transfer.c index 1e7cb46..242d989 100644 --- a/client/transfer.c +++ b/client/transfer.c @@ -44,6 +44,7 @@ #include "transfer.h" #define TRANSFER_INTERFACE "org.bluez.obex.Transfer" +#define ERROR_INTERFACE "org.bluez.obex.Error" #define OBC_TRANSFER_ERROR obc_transfer_error_quark() @@ -209,12 +210,12 @@ static DBusMessage *obc_transfer_cancel(DBusConnection *connection, sender = dbus_message_get_sender(message); if (g_strcmp0(transfer->owner, sender) != 0) return g_dbus_create_error(message, - "org.openobex.Error.NotAuthorized", + ERROR_INTERFACE ".NotAuthorized", "Not Authorized"); if (!obc_transfer_abort(transfer)) return g_dbus_create_error(message, - "org.openobex.Error.Failed", + ERROR_INTERFACE ".Failed", "Failed"); transfer->msg = dbus_message_ref(message); @@ -487,7 +488,7 @@ static void xfer_complete(GObex *obex, GError *err, gpointer user_data) TRANSFER_INTERFACE, "Complete", DBUS_TYPE_INVALID); } else { - const char *code = "org.openobex.Error.Failed"; + const char *code = ERROR_INTERFACE ".Failed"; if (transfer->op == G_OBEX_OP_GET && transfer->filename != NULL) remove(transfer->filename); |