X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=client%2Fdbus_helpers.c;h=1c68a28a4355438579f2bdb1fe748473c4cd85d4;hb=c647a4b6f1132684c9d8b8ad71ec38d81147b278;hp=8c6bdbb387ea1a6fd0e4a02e3c76bccdbb77c40a;hpb=04d1dbacf6aabbb44f16f6776496192964d460d8;p=platform%2Fupstream%2Fconnman.git diff --git a/client/dbus_helpers.c b/client/dbus_helpers.c index 8c6bdbb..1c68a28 100644 --- a/client/dbus_helpers.c +++ b/client/dbus_helpers.c @@ -30,6 +30,34 @@ #define TIMEOUT 120000 +#ifndef DBUS_ERROR_UNKNOWN_METHOD +#define DBUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod" +#endif + +#ifndef DBUS_ERROR_UNKNOWN_PROPERTY +#define DBUS_ERROR_UNKNOWN_PROPERTY "org.freedesktop.DBus.Error.UnknownProperty" +#endif + +#ifndef DBUS_ERROR_UNKNOWN_OBJECT +#define DBUS_ERROR_UNKNOWN_OBJECT "org.freedesktop.DBus.Error.UnknownObject" +#endif + +static int string2errno(const char *error) +{ + if (!g_strcmp0(error, DBUS_ERROR_UNKNOWN_METHOD)) + return -ENOTSUP; + if (!g_strcmp0(error, DBUS_ERROR_UNKNOWN_PROPERTY)) + return -ENOENT; + if (!g_strcmp0(error, DBUS_ERROR_UNKNOWN_OBJECT)) + return -ENODEV; + if (!g_strcmp0(error, "net.connman.Error.AlreadyEnabled")) + return -EALREADY; + if (!g_strcmp0(error, "net.connman.Error.AlreadyDisabled")) + return -EALREADY; + + return -EINVAL; +} + void __connmanctl_dbus_print(DBusMessageIter *iter, const char *pre, const char *dict, const char *sep) { @@ -159,14 +187,15 @@ static void dbus_method_reply(DBusPendingCall *call, void *user_data) dbus_error_init(&err); dbus_set_error_from_message(&err, reply); - callback->cb(NULL, err.message, callback->user_data); + callback->cb(NULL, string2errno(err.name), err.message, + callback->user_data); dbus_error_free(&err); goto end; } dbus_message_iter_init(reply, &iter); - res = callback->cb(&iter, NULL, callback->user_data); + res = callback->cb(&iter, 0, NULL, callback->user_data); end: __connmanctl_redraw_rl();