From: Patrik Flykt Date: Tue, 19 Feb 2013 19:57:24 +0000 (+0200) Subject: client: Factor out connect command X-Git-Tag: 1.12~42 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e9d752f92e7320f5e36536efe367d26dc00cbdb;p=platform%2Fupstream%2Fconnman.git client: Factor out connect command --- diff --git a/client/commands.c b/client/commands.c index dd24d10..20a0507 100644 --- a/client/commands.c +++ b/client/commands.c @@ -207,7 +207,19 @@ static int cmd_scan(char *args[], int num, struct option *options) static int cmd_connect(char *args[], int num, struct option *options) { - return -1; + int err; + + if (num > 2) + return -E2BIG; + + if (num < 2) + return -EINVAL; + + err = connect_service(connection, args[1]); + if (err == 0) + printf("Connected\n"); + + return 0; } static int cmd_disconnect(char *args[], int num, struct option *options) @@ -504,17 +516,6 @@ int commands_no_options(DBusConnection *connection, char *argv[], int argc) cmd_help(NULL, 0, NULL); printf("\nNote: arguments and output are considered " "EXPERIMENTAL for now.\n\n"); - } else if (strcmp(argv[0], "connect") == 0) { - if (argc != 2) { - fprintf(stderr, "Connect requires a service name or " - "path, see help\n"); - error = -EINVAL; - } else - error = connect_service(connection, - strip_service_path(argv[1])); - if (error == 0) - printf("Connected to: %s\n", - strip_service_path(argv[1])); } else if (strcmp(argv[0], "disconnect") == 0) { if (argc != 2) { fprintf(stderr, "Disconnect requires a service name or "