From: Jimmy Huang Date: Wed, 29 Jan 2014 21:51:35 +0000 (-0800) Subject: Use FindObject instead of deprecated findProperty to pull from AMB X-Git-Tag: submit/accepted/tizen/ivi/20140131.204941^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F14%2F15914%2F1;p=profile%2Fivi%2Flemolo.git Use FindObject instead of deprecated findProperty to pull from AMB - Use the FindObject method to get night mode property instead of findProperty since it's being deprecated. This will also fix TIVI-2631, since it wasn't getting the right values when dialer starts Change-Id: Ia3151dc26c10ff9b6ce74d6ac9f8f87c275eb613 Signed-off-by: Jimmy Huang --- diff --git a/dialer/gui.c b/dialer/gui.c index c23b369..30500c0 100644 --- a/dialer/gui.c +++ b/dialer/gui.c @@ -31,7 +31,7 @@ static Evas_Object *current_view = NULL; static OFono_Callback_List_Modem_Node *callback_node_modem_changed = NULL; static OFono_Callback_List_USSD_Notify_Node *callback_node_ussd_notify = NULL; -static AMB_Callback_List_Node *callback_node_night_mode_changed = NULL; +static AMB_Callback_List_Node *callback_node_amb_properties_changed = NULL; /* XXX elm_flip should just do the right thing, but it does not */ static Eina_Bool in_call = EINA_FALSE; @@ -250,14 +250,12 @@ static void _ofono_changed(void *data __UNUSED__) elm_object_part_text_set(main_layout, "elm.text.voicemail", buf); } -static void _night_mode_changed(void *data __UNUSED__) +static void _amb_properties_changed(void *data __UNUSED__) { - DBG("Night mode changed"); - Eina_Bool changed = amb_night_mode_get(); - if (night_mode != changed) - { - DBG("Nightmode changed to %d", changed); - night_mode = changed; + Eina_Bool night_mode_changed = amb_night_mode_get(); + if (night_mode != night_mode_changed) { + DBG("Night mode changed to %d", night_mode_changed); + night_mode = night_mode_changed; util_set_night_mode(night_mode); if (current_view) @@ -378,8 +376,8 @@ Eina_Bool gui_init(void) ofono_modem_changed_cb_add(_ofono_changed, NULL); callback_node_ussd_notify = ofono_ussd_notify_cb_add(_ofono_ussd_notify, NULL); - callback_node_night_mode_changed = - amb_properties_changed_cb_add(_night_mode_changed, NULL); + callback_node_amb_properties_changed = + amb_properties_changed_cb_add(_amb_properties_changed, NULL); /* TODO: make it match better with Tizen: icon and other properties */ obj = elm_layout_edje_get(lay); diff --git a/packaging/lemolo.changes b/packaging/lemolo.changes index 81c7acf..d141abb 100644 --- a/packaging/lemolo.changes +++ b/packaging/lemolo.changes @@ -1,3 +1,7 @@ +* Wed Jan 29 2014 Jimmy Huang accepted/tizen/20131115.212927@9ce884c +- Use FindObject instead of deprecated findProperty to pull from AMB +- Fixes TIVI-2631 + * Wed Nov 13 2013 Jimmy Huang accepted/tizen/20130920.213555@96e7dfe - Implement last user mode diff --git a/utils/amb.c b/utils/amb.c index 82df582..1059cc7 100644 --- a/utils/amb.c +++ b/utils/amb.c @@ -16,7 +16,6 @@ static E_DBus_Connection *bus_conn = NULL; static char *bus_id = NULL; static AMB_Manager *amb_manager = NULL; static E_DBus_Signal_Handler *sig_amb_properties_changed = NULL; -static DBusPendingCall *amb_get_night_mode_path = NULL; struct _AMB_Callback_List_Node { @@ -62,15 +61,13 @@ struct _AMB_Manager AMB_Bus_Object base; const char *name; unsigned int interfaces; - unsigned char vehiclespeed; - Eina_Bool nightmode : 1; + Eina_Bool night_mode; }; static void _amb_property_update(AMB_Manager *m, const char *interface, DBusMessageIter *property) { if (strcmp(interface, AMB_NIGHT_MODE_IFACE) == 0) { - /* TODO: change later to use night mode */ DBusMessageIter entry, variant; const char *key; @@ -81,8 +78,8 @@ static void _amb_property_update(AMB_Manager *m, const char *interface, dbus_message_iter_next(&entry); dbus_message_iter_recurse(&entry, &variant); - m->nightmode = _dbus_bool_get(&variant); - DBG("NightMode updated: %d", m->nightmode); + m->night_mode = _dbus_bool_get(&variant); + DBG("NightMode updated: %d", m->night_mode); } else { DBG("invalid key: %s", key); } @@ -104,7 +101,7 @@ static void _notify_amb_callbacks_list(Eina_Inlist *list) node->cb((void *) node->cb_data); } -static void _amb_get_night_mode_reply(void *data __UNUSED__, DBusMessage *msg, +static void _amb_get_property_reply(void *data __UNUSED__, DBusMessage *msg, DBusError *err) { if (!msg) { @@ -115,47 +112,70 @@ static void _amb_get_night_mode_reply(void *data __UNUSED__, DBusMessage *msg, return; } + EINA_SAFETY_ON_NULL_RETURN(data); + DBusError e; dbus_error_init(&e); - dbus_bool_t value; + DBusMessageIter iter; + DBusMessageIter variant; + + if (dbus_message_iter_init(msg, &iter) == FALSE) { + ERR("Invalid dbus response"); + return; + } + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) { + ERR("Unexpected dbus response type"); + return; + } + char *property_name = (char*) data; AMB_Manager *m = _amb_get(); + dbus_message_iter_recurse(&iter, &variant); - dbus_message_get_args(msg, &e, DBUS_TYPE_BOOLEAN, &value, DBUS_TYPE_INVALID); + if (strcmp(property_name, PROP_NIGHT_MODE_STRING) == 0) { + m->night_mode = _dbus_bool_get(&variant); + DBG("NightMode is set to: %d", m->night_mode); + } else { + return; + } - m->nightmode = value; - DBG("NightMode is set to: %d", m->nightmode); _notify_amb_callbacks_list(cbs_amb_properties_changed); } static void _amb_manager_property_get(char *property, char *path, E_DBus_Method_Return_Cb cb, void *data) { DBusMessage *msg; + char *interface_name; EINA_SAFETY_ON_NULL_RETURN(property); EINA_SAFETY_ON_NULL_RETURN(path); if (strcmp(property, PROP_NIGHT_MODE_STRING) == 0) { - char* interface_name = AMB_NIGHT_MODE_IFACE; + interface_name = AMB_NIGHT_MODE_IFACE; + } else { + return; + } - msg = dbus_message_new_method_call( - bus_id, path, AMB_PROPERTIES_IFACE, "Get"); + msg = dbus_message_new_method_call( + bus_id, path, AMB_PROPERTIES_IFACE, "Get"); - dbus_message_append_args(msg, - DBUS_TYPE_STRING, &interface_name, - DBUS_TYPE_STRING, &property, - DBUS_TYPE_INVALID); + dbus_message_append_args(msg, + DBUS_TYPE_STRING, &interface_name, + DBUS_TYPE_STRING, &property, + DBUS_TYPE_INVALID); - e_dbus_message_send(bus_conn, msg, cb, -1, data); - } + e_dbus_message_send(bus_conn, msg, cb, -1, data); dbus_message_unref(msg); } -static void _amb_get_night_mode_path_reply(void *data __UNUSED__, DBusMessage *msg, +static void _amb_get_property_path_reply(void *data, DBusMessage *msg, DBusError *err) { - amb_get_night_mode_path = NULL; + DBusError e; + DBusMessageIter iter, array; + char *path; if (!msg) { if (err) @@ -165,17 +185,52 @@ static void _amb_get_night_mode_path_reply(void *data __UNUSED__, DBusMessage *m return; } - DBusError e; - char *path; + EINA_SAFETY_ON_NULL_RETURN(data); + dbus_error_init(&e); dbus_message_get_args(msg, &e, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); + if (!dbus_message_iter_init(msg, &iter)) { + ERR("Could not handle message %p", msg); + return; + } + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) { + ERR("Could not handle message %p", msg); + return; + } + + dbus_message_iter_recurse(&iter, &array); + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_OBJECT_PATH) { + ERR("Message does not contain object path"); + return; + } + dbus_message_iter_get_basic(&array, &path); if(!path) { - ERR("Could not get NightMode object path"); + ERR("Could not get object path"); return; } - _amb_manager_property_get(PROP_NIGHT_MODE_STRING, path, _amb_get_night_mode_reply, NULL); + _amb_manager_property_get((char*) data, path, _amb_get_property_reply, data); +} + +static void _amb_get_property_path(const char *property, E_DBus_Method_Return_Cb cb) +{ + DBusMessage *msg = dbus_message_new_method_call( + bus_id, "/", AMB_MANAGER_IFACE, "FindObject"); + + dbus_message_append_args(msg, + DBUS_TYPE_STRING, &property, + DBUS_TYPE_INVALID); + + e_dbus_message_send(bus_conn, msg, cb, -1, (void*) property); + + dbus_message_unref(msg); +} + +static void _amb_get_property(const char *property) +{ + _amb_get_property_path(property, _amb_get_property_path_reply); } static AMB_Manager *_amb_new(const char *path) @@ -216,6 +271,7 @@ static void _amb_properties_changed(void *data __UNUSED__, DBusMessage *msg) dbus_message_iter_next(&iter); dbus_message_iter_recurse(&iter, &value); + DBG("AMB property changed at %s", interface); if (strcmp(interface, AMB_NIGHT_MODE_IFACE) == 0) { _amb_property_update(m, interface, &value); _notify_amb_callbacks_list(cbs_amb_properties_changed); @@ -227,19 +283,7 @@ static void _amb_load(void) amb_manager = _amb_new("/"); EINA_SAFETY_ON_NULL_RETURN(amb_manager); - char *property_name = PROP_NIGHT_MODE_STRING; - - DBusMessage *msg = dbus_message_new_method_call( - bus_id, "/", AMB_MANAGER_IFACE, "findProperty"); - - dbus_message_append_args(msg, - DBUS_TYPE_STRING, &property_name, - DBUS_TYPE_INVALID); - - amb_get_night_mode_path = e_dbus_message_send( - bus_conn, msg, _amb_get_night_mode_path_reply, -1, NULL); - - dbus_message_unref(msg); + _amb_get_property(PROP_NIGHT_MODE_STRING); } static void _amb_connected(const char *id) @@ -327,11 +371,11 @@ static void _amb_get_name_owner(void *data __UNUSED__, DBusMessage *msg, DBusErr _amb_connected(id); } -Eina_Bool amb_nightmode_get(void) +Eina_Bool amb_night_mode_get(void) { AMB_Manager *m = _amb_get(); EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE); - return m->nightmode; + return m->night_mode; } Eina_Bool amb_init(void) @@ -366,13 +410,6 @@ void amb_shutdown(void) _amb_disconnected(); } -Eina_Bool amb_night_mode_get(void) -{ - AMB_Manager *m = _amb_get(); - EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE); - return m->nightmode; -} - static AMB_Callback_List_Node * _amb_callback_list_node_create( void (*cb)(void *data),const void *data) {