X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fdbus.c;h=daa2239c536926cb79809f45c2b35693bda091f5;hb=fc2cca4fa403a4a22caa0f6111c43be40e6094e3;hp=333b4cf8ba206a1a7788d132831248b99b44bdf7;hpb=0548e30af62395997767f51ac5c0804f8d7545cc;p=connman diff --git a/src/dbus.c b/src/dbus.c index 333b4cf..daa2239 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -2,7 +2,7 @@ * * Connection Manager * - * Copyright (C) 2007-2008 Intel Corporation. All rights reserved. + * Copyright (C) 2007-2009 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -23,7 +23,35 @@ #include #endif -#include +#include + +#include "connman.h" + +char *connman_dbus_encode_string(const char *value) +{ + GString *str; + unsigned int i, size; + + if (value == NULL) + return NULL; + + size = strlen(value); + + str = g_string_new(NULL); + if (str == NULL) + return NULL; + + for (i = 0; i < size; i++) { + const char tmp = value[i]; + if ((tmp < '0' || tmp > '9') && (tmp < 'A' || tmp > 'Z') && + (tmp < 'a' || tmp > 'z')) + g_string_append_printf(str, "_%02x", tmp); + else + str = g_string_append_c(str, tmp); + } + + return g_string_free(str, FALSE); +} void connman_dbus_property_append_variant(DBusMessageIter *iter, const char *key, int type, void *val) @@ -114,3 +142,25 @@ void connman_dbus_dict_append_variant(DBusMessageIter *dict, dbus_message_iter_close_container(dict, &entry); } + +static DBusConnection *connection = NULL; + +DBusConnection *connman_dbus_get_connection(void) +{ + if (connection == NULL) + return NULL; + + return dbus_connection_ref(connection); +} + +int __connman_dbus_init(DBusConnection *conn) +{ + connection = conn; + + return 0; +} + +void __connman_dbus_cleanup(void) +{ + connection = NULL; +}