Skip to content

Commit

Permalink
💄 Add some more keys
Browse files Browse the repository at this point in the history
Change-Id: I66681339b27ef4781a4264e0a984d2023b2edc79
  • Loading branch information
Guittet Thibault committed Aug 22, 2014
1 parent 08a3767 commit b0c7b58
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 24 deletions.
7 changes: 3 additions & 4 deletions agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);

Expand All @@ -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"
Expand Down
26 changes: 13 additions & 13 deletions commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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",
Expand All @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
8 changes: 8 additions & 0 deletions keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit b0c7b58

Please sign in to comment.