Navigation Menu

Skip to content

Commit

Permalink
Various clean-up
Browse files Browse the repository at this point in the history
Change-Id: If6255c0a4df1ab461aa428feb2f747539ccb7559
  • Loading branch information
Guittet Thibault committed Aug 22, 2014
1 parent b0c7b58 commit 93b6ad0
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 44 deletions.
6 changes: 3 additions & 3 deletions commands.c
Expand Up @@ -183,7 +183,7 @@ int __cmd_scan(const char *tech_dbus_name)
}

/*
* Toogle the Powered state of the technology.
* Toggle the Powered state of the technology.
* @param tech_dbus_name the dbus name of the technology
* @param set_power_to the new power state to set
*/
Expand All @@ -200,7 +200,7 @@ int __cmd_toggle_tech_power(const char *tech_dbus_name, bool set_power_to)
}

/*
* Toogle the OfflineMode attribute of Manager.
* Toggle the OfflineMode attribute of Manager.
* @param set_offline_to the new offline mode to set
*/
int __cmd_toggle_offline_mode(bool set_offline_to)
Expand Down Expand Up @@ -400,7 +400,7 @@ static void user_proof_manual_method(struct json_object *service,
/*
* Note that option names are the same as the ones in connman/doc/services-api.txt
*
"options": {
{
"IPv4.Configuration": {
"Method": "dhcp"|"manual"|"off",
"Address": "xxxx",
Expand Down
16 changes: 8 additions & 8 deletions engine.c
Expand Up @@ -348,7 +348,7 @@ static int get_home_page(struct json_object *jobj)
json_object_object_add(res, key_state, json_object_get(state));
json_object_object_add(res, key_technologies, json_object_get(technologies));

engine_callback(0, coating("get_home_page", res));
engine_callback(0, coating(key_engine_get_home_page, res));

// coating increment ref count of res, but creating a new object already
// increment the ref count of res
Expand Down Expand Up @@ -431,7 +431,7 @@ static int get_services_from_tech(struct json_object *jobj)
res = json_object_new_object();
json_object_object_add(res, key_services, res_serv);
json_object_object_add(res, key_technology, res_tech);
engine_callback(0, coating("get_services_from_tech", res));
engine_callback(0, coating(key_engine_get_services_from_tech, res));
json_object_put(res);

return -EINPROGRESS;
Expand Down Expand Up @@ -621,21 +621,21 @@ static struct {
{ key_engine_get_technologies, get_technologies, true, { "" } },
{ key_engine_get_home_page, get_home_page, true, { "" } },
{ key_engine_get_services_from_tech, get_services_from_tech, true, {
"{ \"technology\": \"(%5C%5C|/|([a-zA-Z]))+\" }" } },
key_engine_tech_regex } },
{ key_engine_connect, connect_to_service, true, {
"{ \"service\": \"(%5C%5C|/|([a-zA-Z]))+\" }" } },
key_engine_serv_regex } },
{ key_engine_disconnect, disconnect_technology, true, {
"{ \"technology\": \"(%5C%5C|/|([a-zA-Z]))+\" }" } },
key_engine_tech_regex } },
{ key_engine_agent_response, agent_response, false, { "" } },
{ key_engine_agent_retry, agent_error_response, false, { "" } },
{ key_engine_scan_tech, scan_technology, true, {
"{ \"technology\": \"(%5C%5C|/|([a-zA-Z]))+\" }" } },
key_engine_tech_regex } },
{ key_engine_config_service, config_service, false, { "" } },
{ key_engine_toggle_tech_power, toggle_power_technology, true, {
"{ \"technology\": \"(%5C%5C|/|([a-zA-Z]))+\" }" } },
key_engine_tech_regex } },
{ key_engine_toggle_offline_mode, toggle_offline_mode, true, { "" } },
{ key_engine_remove_service, remove_service, true, {
"{ \"service\": \"(%5C%5C|/|([a-zA-Z]))+\" }" } },
key_engine_serv_regex } },
{ NULL, }, // this is a sentinel
};

Expand Down
42 changes: 21 additions & 21 deletions json_regex.c
Expand Up @@ -68,41 +68,41 @@ void generate_trusted_json(void)
jregex_config_service = json_object_new_object();
opt = json_object_new_object();
tmp = json_object_new_object();
json_object_object_add(tmp, "Method", json_object_new_string("^(dhcp|manual|off)$"));
json_object_object_add(tmp, "Address", json_object_new_string(IPV4_REGEX));
json_object_object_add(tmp, "Netmask", json_object_new_string(IPV4_REGEX));
json_object_object_add(tmp, "Gateway", json_object_new_string(IPV4_REGEX));
json_object_object_add(opt, "IPv4.Configuration", tmp);
json_object_object_add(tmp, key_serv_ipv4_method, json_object_new_string("^(dhcp|manual|off)$"));
json_object_object_add(tmp, key_serv_ipv4_address, json_object_new_string(IPV4_REGEX));
json_object_object_add(tmp, key_serv_ipv4_netmask, json_object_new_string(IPV4_REGEX));
json_object_object_add(tmp, key_serv_ipv4_gateway, json_object_new_string(IPV4_REGEX));
json_object_object_add(opt, key_serv_ipv4_config, tmp);
tmp = json_object_new_object();
json_object_object_add(tmp, "Method", json_object_new_string("^(auto|manual|6to4|off)$"));
json_object_object_add(tmp, "Address", json_object_new_string(IPV6_REGEX));
json_object_object_add(tmp, "PrefixLength", json_object_new_int(12));
json_object_object_add(tmp, "Gateway", json_object_new_string(IPV6_REGEX));
json_object_object_add(tmp, "Privacy", json_object_new_string("^(auto|disabled|enabled|prefered)$"));
json_object_object_add(opt, "IPv6.Configuration", tmp);
json_object_object_add(tmp, key_serv_ipv6_method, json_object_new_string("^(auto|manual|6to4|off)$"));
json_object_object_add(tmp, key_serv_ipv6_address, json_object_new_string(IPV6_REGEX));
json_object_object_add(tmp, key_serv_ipv6_prefixlength, json_object_new_int(12));
json_object_object_add(tmp, key_serv_ipv6_gateway, json_object_new_string(IPV6_REGEX));
json_object_object_add(tmp, key_serv_ipv6_privacy, json_object_new_string("^(auto|disabled|enabled|prefered)$"));
json_object_object_add(opt, key_serv_ipv6_config, tmp);
tmp = json_object_new_object();
json_object_object_add(tmp, "Method", json_object_new_string("^(direct|auto|manual)$"));
json_object_object_add(tmp, key_serv_proxy_method, json_object_new_string("^(direct|auto|manual)$"));
arr = json_object_new_array();
json_object_array_add(arr, json_object_new_string("^([[:print:]]*)$"));
json_object_object_add(tmp, "URL", arr);
json_object_object_add(tmp, key_serv_proxy_url, arr);
arr = json_object_new_array();
json_object_array_add(arr, json_object_new_string("^([[:print:]]*)$"));
json_object_object_add(tmp, "Servers", arr);
json_object_object_add(tmp, key_serv_proxy_servers, arr);
arr = json_object_new_array();
json_object_array_add(arr, json_object_new_string("^([[:print:]]*)$"));
json_object_object_add(tmp, "Excludes", arr);
json_object_object_add(opt, "Proxy.Configuration", tmp);
json_object_object_add(opt, "AutoConnect", json_object_new_boolean(TRUE));
json_object_object_add(tmp, key_serv_proxy_excludes, arr);
json_object_object_add(opt, key_serv_proxy_config, tmp);
json_object_object_add(opt, key_serv_autoconnect, json_object_new_boolean(TRUE));
arr = json_object_new_array();
json_object_array_add(arr, json_object_new_string("^([[:print:]]*)$"));
json_object_object_add(opt, "Domains.Configuration", arr);
json_object_object_add(opt, key_serv_domains_config, arr);
arr = json_object_new_array();
json_object_array_add(arr, json_object_new_string("^([[:print:]]*)$"));
json_object_object_add(opt, "Nameservers.Configuration", arr);
json_object_object_add(opt, key_serv_nameservers_config, arr);
arr = json_object_new_array();
json_object_array_add(arr, json_object_new_string("^([[:print:]]*)$"));
json_object_object_add(opt, "Timeservers.Configuration", arr);
json_object_object_add(jregex_config_service, "options", opt);
json_object_object_add(opt, key_serv_timeservers_config, arr);
json_object_object_add(jregex_config_service, key_options, opt);
json_object_object_add(jregex_config_service, key_service, json_object_new_string("(%5C%5C|/|([a-zA-Z]))+"));

}
Expand Down
2 changes: 2 additions & 0 deletions keys.c
Expand Up @@ -43,6 +43,8 @@ const char key_engine_config_service[] = "config_service";
const char key_engine_toggle_tech_power[] = "toggle_tech_power";
const char key_engine_toggle_offline_mode[] = "toggle_offline_mode";
const char key_engine_remove_service[] = "remove_service";
const char key_engine_tech_regex[] = "{ \"technology\": \"(%5C%5C|/|([a-zA-Z]))+\" }";
const char key_engine_serv_regex[] = "{ \"service\": \"(%5C%5C|/|([a-zA-Z]))+\" }";

const char key_success[] = "OK";
const char key_error[] = "ERROR";
Expand Down
2 changes: 2 additions & 0 deletions keys.h
Expand Up @@ -47,6 +47,8 @@ extern const char key_engine_config_service[];
extern const char key_engine_toggle_tech_power[];
extern const char key_engine_toggle_offline_mode[];
extern const char key_engine_remove_service[];
extern const char key_engine_tech_regex[];
extern const char key_engine_serv_regex[];

extern const char key_success[];
extern const char key_error[];
Expand Down
6 changes: 3 additions & 3 deletions main.c
Expand Up @@ -1153,7 +1153,7 @@ static void modify_service_config(void)

json_object_object_add(cmd_data, key_service,
json_object_new_string(context.serv->dbus_name));
json_object_object_add(cmd_data, "options", options);
json_object_object_add(cmd_data, key_options, options);
json_object_object_add(cmd, key_command_data, cmd_data);
json_object_object_add(cmd, key_command,
json_object_new_string(key_engine_config_service));
Expand Down Expand Up @@ -1187,12 +1187,12 @@ static void exec_action_context_home(int ch)
case 'p':
item = current_item(main_menu);
toggle_power_tech(item_userptr(item));
print_info_in_footer(false, "Toogling power...");
print_info_in_footer(false, "Toggling power...");
break;

case 'o':
toggle_offline_mode();
print_info_in_footer(false, "Toogling OfflineMode...");
print_info_in_footer(false, "Toggling OfflineMode...");
break;

case KEY_ENTER:
Expand Down
2 changes: 1 addition & 1 deletion ncurses_utils.c
Expand Up @@ -31,7 +31,7 @@
#include "ncurses_utils.h"

/*
* This file aim to provide simple functions to print informations in win_footer
* This file provide simple functions to print informations in win_footer
* and keep footer messages.
*/

Expand Down
6 changes: 3 additions & 3 deletions renderers.c
Expand Up @@ -577,7 +577,7 @@ static void renderers_services_ethernet(struct json_object *jobj)
struct json_object *sub_array, *serv_name, *serv_dict, *tmp;
struct userptr_data *data;

mvwprintw(win_body, 3, 2, " %-33s%-17s", "Name", "State");
mvwprintw(win_body, 3, 2, " %-33s%-17s", key_serv_name, key_serv_state);

for (i = 0; i < nb_items; i++) {
sub_array = json_object_array_get_idx(jobj, i);
Expand Down Expand Up @@ -630,8 +630,8 @@ static void renderers_services_wifi(struct json_object *jobj)
struct json_object *sub_array, *serv_name, *serv_dict, *tmp;
struct userptr_data *data;

mvwprintw(win_body, 3, 2, " %-33s%-17s%-10s%15s", "eSSID", "State",
"Security", "Signal" " Strength");
mvwprintw(win_body, 3, 2, " %-33s%-17s%-10s%15s", "eSSID",
key_serv_state, key_serv_security, "Signal Strength");

for (i = 0; i < nb_items; i++) {
sub_array = json_object_array_get_idx(jobj, i);
Expand Down
6 changes: 3 additions & 3 deletions string_utils.c
Expand Up @@ -34,16 +34,16 @@ char* trim_whitespaces(char *str)
char *end;

// trim leading space
while(isspace(*str))
while (isspace(*str))
str++;

if(*str == 0) // all spaces?
if (*str == 0) // all spaces?
return str;

// trim trailing space
end = str + strnlen(str, 128) - 1;

while(end > str && isspace(*end))
while (end > str && isspace(*end))
end--;

// write new null terminator
Expand Down
2 changes: 1 addition & 1 deletion test_json_utils.c
Expand Up @@ -62,7 +62,7 @@ int main()
json_object_object_add(jsubtrusted, "IPv4", jsubtrusted2);
json_object_object_add(jsubtrusted3, "Address", json_object_new_string(IPV6_REGEX));
json_object_object_add(jsubtrusted, "IPv6", jsubtrusted3);
json_object_object_add(jtrusted, "options", jsubtrusted);
json_object_object_add(jtrusted, key_options, jsubtrusted);

for (i = 0; to_test[i]; i++) {

Expand Down
2 changes: 1 addition & 1 deletion test_regexp.c
Expand Up @@ -89,7 +89,7 @@ int main()
json_object_object_add(jsubtrusted, "IPv4", jsubtrusted2);
json_object_object_add(jsubtrusted3, "Address", json_object_new_string(IPV6_REGEX));
json_object_object_add(jsubtrusted, "IPv6", jsubtrusted3);
json_object_object_add(jtrusted, "options", jsubtrusted);
json_object_object_add(jtrusted, key_options, jsubtrusted);
*/

/*
Expand Down

0 comments on commit 93b6ad0

Please sign in to comment.