From: Marcel Holtmann Date: Sat, 4 Apr 2009 02:58:20 +0000 (+0200) Subject: Add skeleton for service state property X-Git-Tag: accepted/2.0alpha-wayland/20121110.002834~3908 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=44412dd26ca12bbea6e6907546ce166cf8d281ec;p=profile%2Fivi%2Fconnman.git Add skeleton for service state property --- diff --git a/src/profile.c b/src/profile.c index b2d9bed..3cf1e1e 100644 --- a/src/profile.c +++ b/src/profile.c @@ -30,6 +30,11 @@ #define PROFILE_DEFAULT "/profile/default" +enum connman_service_state { + CONNMAN_SERVICE_STATE_UNKNOWN = 0, + CONNMAN_SERVICE_STATE_IDLE = 1, +}; + struct connman_group { char *path; char *type; @@ -38,6 +43,7 @@ struct connman_group { char *security; connman_uint8_t strength; connman_bool_t favorite; + enum connman_service_state state; struct connman_network *network; }; @@ -45,12 +51,25 @@ static GHashTable *groups = NULL; static DBusConnection *connection = NULL; +static const char *state2string(enum connman_service_state state) +{ + switch (state) { + case CONNMAN_SERVICE_STATE_UNKNOWN: + break; + case CONNMAN_SERVICE_STATE_IDLE: + return "idle"; + } + + return NULL; +} + static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { struct connman_group *group = data; DBusMessage *reply; DBusMessageIter array, dict; + const char *str; DBG("conn %p", conn); @@ -65,6 +84,11 @@ static DBusMessage *get_properties(DBusConnection *conn, DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); + str = state2string(group->state); + if (str != NULL) + connman_dbus_dict_append_variant(&dict, "State", + DBUS_TYPE_STRING, &str); + if (group->type != NULL) connman_dbus_dict_append_variant(&dict, "Type", DBUS_TYPE_STRING, &group->type); @@ -177,6 +201,8 @@ static struct connman_group *lookup_group(const char *name) group->favorite = FALSE; + group->state = CONNMAN_SERVICE_STATE_IDLE; + g_hash_table_insert(groups, g_strdup(name), group); g_dbus_register_interface(connection, group->path,