diff --git a/agent.c b/agent.c index d22588a..b9d813a 100644 --- a/agent.c +++ b/agent.c @@ -263,7 +263,7 @@ static DBusMessage *agent_request_browser(DBusConnection *connection, dbus_message_iter_next(&iter); dbus_message_iter_get_basic(&iter, &url); - tmp = format_agent_msg("Agent RequestBrowser", service, + tmp = format_agent_msg(key_agent_request_browser, service, json_object_new_string(url)); format_agent_with_callback(tmp, "Connected ?", "request_browser_return"); @@ -337,7 +337,7 @@ static DBusMessage *agent_request_input(DBusConnection *connection, dbus_message_iter_next(&iter); - res = format_agent_msg("Input Requested", service, + res = format_agent_msg(key_agent_request_input, service, dbus_to_json(&iter)); free(service); @@ -348,8 +348,7 @@ static DBusMessage *agent_request_input(DBusConnection *connection, } static void agent_unregister_return(DBusMessageIter *iter, - const char *error, - void *user_data) + const char *error, void *user_data) { if (error) agent_error_callback(format_agent_error(error, "Got error while" diff --git a/commands.c b/commands.c index 1771f97..8354f04 100644 --- a/commands.c +++ b/commands.c @@ -576,33 +576,33 @@ static DBusHandlerResult monitor_changed(DBusConnection *connection, path++; if (dbus_message_is_signal(message, key_manager_interface, - "ServicesChanged")) { - sig_name = json_object_new_string("ServicesChanged"); + key_sig_serv_changed)) { + sig_name = json_object_new_string(key_sig_serv_changed); } else if (dbus_message_is_signal(message, key_manager_interface, - "PropertyChanged")) { - sig_name = json_object_new_string("PropertyChanged"); + key_sig_prop_changed)) { + sig_name = json_object_new_string(key_sig_prop_changed); } else if (dbus_message_is_signal(message, key_manager_interface, - "TechnologyAdded")) { + key_sig_tech_added)) { path = dbus_message_get_member(message); - sig_name = json_object_new_string("TechnologyAdded"); + sig_name = json_object_new_string(key_sig_tech_added); } else if (dbus_message_is_signal(message, key_manager_interface, - "TechnologyRemoved")) { + key_sig_tech_removed)) { path = dbus_message_get_member(message); - sig_name = json_object_new_string("TechnologyRemoved"); + sig_name = json_object_new_string(key_sig_tech_removed); } else if (dbus_message_is_signal(message, key_service_interface, - "PropertyChanged")) { - sig_name = json_object_new_string("PropertyChanged"); + key_sig_prop_changed)) { + sig_name = json_object_new_string(key_sig_prop_changed); } else if (dbus_message_is_signal(message, key_technology_interface, - "PropertyChanged")) { - sig_name = json_object_new_string("PropertyChanged"); + key_sig_prop_changed)) { + sig_name = json_object_new_string(key_sig_prop_changed); } else { - sig_name = json_object_new_string("Signal unsupported"); + sig_name = json_object_new_string(key_sig_unsupported); } dbus_message_iter_init(message, &iter); diff --git a/engine.c b/engine.c index 1ba7344..62cf28b 100644 --- a/engine.c +++ b/engine.c @@ -848,7 +848,7 @@ static void react_to_sig_manager(struct json_object *interface, *tmp, *tmp_array; int i, len; - if (strcmp(sig_name, "ServicesChanged") == 0) { + if (strcmp(sig_name, key_sig_serv_changed) == 0) { // remove services (they disappeared) serv_to_del = json_object_array_get_idx(data, 1); len = json_object_array_length(serv_to_del); @@ -877,7 +877,7 @@ static void react_to_sig_manager(struct json_object *interface, } } - } else if (strcmp(sig_name, "PropertyChanged") == 0) { + } else if (strcmp(sig_name, key_sig_prop_changed) == 0) { /* state: * { * "State": "online", @@ -891,10 +891,10 @@ static void react_to_sig_manager(struct json_object *interface, json_object_object_add(state, tmp_str, json_object_array_get_idx(data, 1)); - } else if (strcmp(sig_name, "TechnologyAdded") == 0) { + } else if (strcmp(sig_name, key_sig_tech_added) == 0) { json_object_array_add(technologies, json_object_get(data)); - } else if (strcmp(sig_name, "TechnologyRemoved") == 0) { + } else if (strcmp(sig_name, key_sig_tech_removed) == 0) { tmp_str = json_object_get_string(data); tmp_array = json_object_new_array(); len = json_object_array_length(technologies); diff --git a/keys.c b/keys.c index 0a61167..ce1131c 100644 --- a/keys.c +++ b/keys.c @@ -59,6 +59,8 @@ char key_agent_interface[] = "net.connman.Agent"; const char key_agent_error_message[] = "agent_error_message"; const char key_agent_error_callback[] = "agent_error_callback"; const char key_agent_msg_data[] = "agent_msg_data"; +const char key_agent_request_browser[] = "Agent RequestBrowser"; +const char key_agent_request_input[] = "Input Requested"; const char key_scan_return[] = "scan_return"; const char key_connect_return[] = "connect_return"; @@ -105,3 +107,9 @@ const char key_serv_prov_host[] = "Host"; const char key_serv_prov_domain[] = "Domain"; const char key_serv_prov_name[] = "Name"; const char key_serv_prov_type[] = "Type"; + +const char key_sig_serv_changed[]= "ServicesChanged"; +const char key_sig_prop_changed[] = "PropertyChanged"; +const char key_sig_tech_added[] = "TechnologyAdded"; +const char key_sig_tech_removed[] = "TechnologyRemoved"; +const char key_sig_unsupported[] = "Signal unsupported"; diff --git a/keys.h b/keys.h index 018680f..f531229 100644 --- a/keys.h +++ b/keys.h @@ -63,6 +63,8 @@ extern char key_agent_interface[]; extern const char key_agent_error_message[]; extern const char key_agent_error_callback[]; extern const char key_agent_msg_data[]; +extern const char key_agent_request_browser[]; +extern const char key_agent_request_input[]; extern const char key_scan_return[]; extern const char key_connect_return[]; @@ -116,4 +118,10 @@ extern const char key_serv_prov_domain[]; extern const char key_serv_prov_name[]; extern const char key_serv_prov_type[]; +extern const char key_sig_serv_changed[]; +extern const char key_sig_prop_changed[]; +extern const char key_sig_tech_added[]; +extern const char key_sig_tech_removed[]; +extern const char key_sig_unsupported[]; + #endif diff --git a/main.c b/main.c index 3848ac8..b2e1602 100644 --- a/main.c +++ b/main.c @@ -492,7 +492,7 @@ static void action_on_signal(struct json_object *jobj) json_object_object_get_ex(jobj, key_command_data, &sig_data); json_object_object_get_ex(jobj, key_signal, &sig_name); - is_tech_removed = strncmp("TechnologyRemoved", json_object_get_string(sig_name), 50) == 0; + is_tech_removed = strncmp(key_sig_tech_removed, json_object_get_string(sig_name), 50) == 0; if (context.tech->dbus_name == NULL) is_current_tech = false; @@ -702,10 +702,10 @@ static void action_on_agent_msg(struct json_object *jobj) request_str = json_object_get_string(request); service_str = json_object_get_string(service); - if (strncmp("Input Requested", request_str, 15) == 0) + if (strncmp(key_agent_request_input, request_str, 15) == 0) agent_input_popup(service_str, data); - else if (strncmp("Agent RequestBrowser", request_str, 21) == 0) + else if (strncmp(key_agent_request_browser, request_str, 21) == 0) print_info_in_footer(false, "The agent request you to" " open the web page: %s", json_object_get_string(jobj));