- return 1;
-}
-
-/* Device Commands */
-static int
-_on_cmd_device_propose_scan(char *cmd, char *args)
-{
- char *path;
- E_Connman_Element *e;
-
- if (!args)
- {
- fputs("ERROR: missing the device path\n", stderr);
- return 1;
- }
- _tok(args);
- path = args;
-
- e = e_connman_device_get(path);
- if (e_connman_device_propose_scan
- (e, _method_success_check, "device_propose_scan"))
- printf(":::Proposing scan %s...\n", path);
- else
- fputs("ERROR: can't propose scan\n", stderr);
- return 1;
-}
-
-static int
-_on_cmd_device_get_address(char *cmd, char *args)
-{
- const char *address, *path;
- E_Connman_Element *e;
-
- if (!args)
- {
- fputs("ERROR: missing the device path\n", stderr);
- return 1;
- }
- _tok(args);
- path = args;
-
- e = e_connman_device_get(path);
- if (e_connman_device_address_get(e, &address))
- printf(":::Device %s Address = \"%s\"\n", path, address);
- else
- fputs("ERROR: can't get device address\n", stderr);
- return 1;
-}
-
-static int
-_on_cmd_device_get_name(char *cmd, char *args)
-{
- const char *name, *path;
- E_Connman_Element *e;
-
- if (!args)
- {
- fputs("ERROR: missing the device path\n", stderr);
- return 1;
- }
- _tok(args);
- path = args;
-
- e = e_connman_device_get(path);
- if (e_connman_device_name_get(e, &name))
- printf(":::Device %s Name = \"%s\"\n", path, name);
- else
- fputs("ERROR: can't get device name\n", stderr);
- return 1;
-}
-
-static int
-_on_cmd_device_get_type(char *cmd, char *args)
-{
- const char *type, *path;
- E_Connman_Element *e;
-
- if (!args)
- {
- fputs("ERROR: missing the device path\n", stderr);
- return 1;
- }
- _tok(args);
- path = args;
-
- e = e_connman_device_get(path);
- if (e_connman_device_type_get(e, &type))
- printf(":::Device %s Type = \"%s\"\n", path, type);
- else
- fputs("ERROR: can't get device type\n", stderr);
- return 1;
-}
-
-static int
-_on_cmd_device_get_interface(char *cmd, char *args)
-{
- const char *interface, *path;
- E_Connman_Element *e;
-
- if (!args)
- {
- fputs("ERROR: missing the device path\n", stderr);
- return 1;
- }
- _tok(args);
- path = args;
-
- e = e_connman_device_get(path);
- if (e_connman_device_interface_get(e, &interface))
- printf(":::Device %s Interface = \"%s\"\n", path, interface);
- else
- fputs("ERROR: can't get device interface\n", stderr);
- return 1;
-}
-
-static int
-_on_cmd_device_get_powered(char *cmd, char *args)
-{
- char *path;
- bool powered;
- E_Connman_Element *e;
-
- if (!args)
- {
- fputs("ERROR: missing the device path\n", stderr);
- return 1;
- }
- _tok(args);
- path = args;
-
- e = e_connman_device_get(path);
- if (e_connman_device_powered_get(e, &powered))
- printf(":::Device %s Powered = %hhu\n", path, powered);
- else
- fputs("ERROR: can't get device powered\n", stderr);
- return 1;
-}
-
-static int
-_on_cmd_device_set_powered(char *cmd, char *args)
-{
- char *device_path, *next_args;
- bool powered;
- E_Connman_Element *e;
-
- if (!args)
- {
- fputs("ERROR: missing the device path\n", stderr);
- return 1;
- }
- device_path = args;
- next_args = _tok(args);
- if (!next_args)
- {
- fputs("ERROR: missing the powered value\n", stderr);
- return 1;
- }
- powered = !!atol(next_args);
-
- e = e_connman_device_get(device_path);
- if (e_connman_device_powered_set
- (e, powered, _method_success_check, "device_set_powered"))
- printf(":::Device %s powered set to %hhu\n", device_path, powered);
- else
- fputs("ERROR: can't set device powered\n", stderr);
- return 1;
-}
-
-static int
-_on_cmd_device_get_scan_interval(char *cmd, char *args)
-{
- char *path;
- unsigned short scan_interval;
- E_Connman_Element *e;
-
- if (!args)
- {
- fputs("ERROR: missing the device path\n", stderr);
- return 1;
- }
- _tok(args);
- path = args;
-
- e = e_connman_device_get(path);
- if (e_connman_device_scan_interval_get(e, &scan_interval))
- printf(":::Device %s ScanInterval = %hu\n", path, scan_interval);
- else
- fputs("ERROR: can't get device scan interval\n", stderr);
- return 1;
-}
-
-static int
-_on_cmd_device_set_scan_interval(char *cmd, char *args)
-{
- char *device_path, *next_args, *p;
- unsigned short scan_interval;
- E_Connman_Element *e;
-
- if (!args)
- {
- fputs("ERROR: missing the device path\n", stderr);
- return 1;
- }
- device_path = args;
- next_args = _tok(args);
- if (!next_args)
- {
- fputs("ERROR: missing the scan interval value\n", stderr);
- return 1;
- }
- scan_interval = strtol(next_args, &p, 0);
- if (p == next_args)
- {
- fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
- return 1;
- }
-
- e = e_connman_device_get(device_path);
- if (e_connman_device_scan_interval_set
- (e, scan_interval, _method_success_check, "device_set_scan_interval"))
- printf(":::Device %s scan interval set to %hu\n", device_path, scan_interval);
- else
- fputs("ERROR: can't set device scan interval\n", stderr);
- return 1;
-}
-
-static int
-_on_cmd_device_get_scanning(char *cmd, char *args)
-{
- char *path;
- bool scanning;
- E_Connman_Element *e;
-
- if (!args)
- {
- fputs("ERROR: missing the device path\n", stderr);
- return 1;
- }
- _tok(args);
- path = args;
-
- e = e_connman_device_get(path);
- if (e_connman_device_scanning_get(e, &scanning))
- printf(":::Device %s Scanning = %hhu\n", path, scanning);
- else
- fputs("ERROR: can't get device scanning\n", stderr);
- return 1;
-}
-
-static int
-_on_cmd_device_get_networks(char *cmd, char *args)
-{
- E_Connman_Element **networks;
- unsigned int count;
- char *path;
- E_Connman_Element *e;
-
- if (!args)
- {
- fputs("ERROR: missing the device path\n", stderr);
- return 1;
- }
- _tok(args);
- path = args;
-
- e = e_connman_device_get(path);
- if (!e_connman_device_networks_get(e, &count, &networks))
- {
- fputs("ERROR: can't get networks\n", stderr);
- return 1;
- }
-
- printf("BEG: all device network elements count = %d\n", count);
- _elements_print(networks, count);
- return 1;