Re: NetworkManager - console

2013-07-30 Thread Vanessa Županović
No problem, but at the moment it is done on very retarded way (personal
use). I added the command "add" to main menu, code is also little nasty, I
was planning to fix it (make it more modular) because I put all my code in
nmcli.c and nmcli.h what is bad, I know :)

Usage example:

nmcli add id myid apn data.vip.hr (simple stuff)

or just hit nmcli add to see help

Two files mentioned above are in the attachment, I am completely aware that
this needs remodeling...


2013/7/30 Dan Williams 

> On Tue, 2013-07-30 at 18:16 +, Vanessa Županović wrote:
> > Hello everyone,
> >
> >
> > First of all I'm 20 years old student who is pretty much new at this :)
> so I might sound really nooby, but I noticed that network manager (all
> versions) doesn't support setting up a new connection from console which is
> necessary in some cases (it can be done only from applet), so I have
> implemented mentioned feature for my personal use and added it to nmcli
> source (i'm talking about connecting to mobile Internet) ...
>
> Sounds neat!  Jirka Klimes has been working on support for this for a
> while in his 'cli-enhance' branch which was merged to git master
> recently, which has some simple support for mobile broadband.  Could you
> mail your patches to this list so everyone can take a look at them and
> see how they could fit into current git master's nmcli?
>
> Thanks!
> Dan
>
>
/* nmcli - command-line tool to control NetworkManager
 *
 * Jiri Klimes 
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * (C) Copyright 2010 - 2012 Red Hat, Inc.
 */

/* Generated configuration file */
#include "config.h"

#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include "nmcli.h"
#include "utils.h"
#include "connections.h"
#include "devices.h"
#include "network-manager.h"

#define DBUS_TYPE_G_MAP_OF_VARIANT  (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT   (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))

#define NOT_SET "not_set"

#if defined(NM_DIST_VERSION)
# define NMCLI_VERSION NM_DIST_VERSION
#else
# define NMCLI_VERSION VERSION
#endif


typedef struct {
	NmCli *nmc;
	int argc;
	char **argv;
} ArgsInfo;

/* --- Global variables --- */
GMainLoop *loop = NULL;


/* Get an error quark for use with GError */
GQuark
nmcli_error_quark (void)
{
	static GQuark error_quark = 0;

	if (G_UNLIKELY (error_quark == 0))
		error_quark = g_quark_from_static_string ("nmcli-error-quark");

	return error_quark;
}

static void
usage (const char *prog_name)
{
	fprintf (stderr,
	 _("Usage: %s [OPTIONS] OBJECT { COMMAND | help }\n"
	 "\n"
	 "OPTIONS\n"
	 "  -t[erse]   terse output\n"
	 "  -p[retty]  pretty output\n"
	 "  -m[ode] tabular|multiline  output mode\n"
	 "  -f[ields] |all|common   specify fields to output\n"
	 "  -e[scape] yes|no   escape columns separators in values\n"
	 "  -n[ocheck] don't check nmcli and NetworkManager versions\n"
	 "  -v[ersion] show program version\n"
	 "  -h[elp]print this help\n"
	 "\n"
	 "OBJECT\n"
	 "  nm  NetworkManager's status\n"
	 "  c[onnection]NetworkManager's connections\n"
	 "  d[evice]devices managed by NetworkManager\n"
	 "  addadd new connection via NetworkManager\n"
	 "\n"),
	  prog_name);
}

static NMCResultCode 
do_help (NmCli *nmc, int argc, char **argv)
{
	usage ("nmcli");
	return NMC_RESULT_SUCCESS;
}

static void
usage_add (void)
{
	fprintf (stderr,
	 _("Usage: nmcli add { help | COMMAND }\n"
	 "  COMMAND := id  param1  param2  ... param_n \n"
	 "  Available parameters: \n"
	 " \t [has to be specified]\n"
	 " \t   [autoconnect] default: true (t/f)\n"
	 " \t\n"
	 " \t\n"
	 " \t\n"
	 " \t\n"
	 " \t  [network id]\n"
	

Re: NetworkManager - console

2013-07-30 Thread Dan Williams
On Tue, 2013-07-30 at 18:16 +, Vanessa Županović wrote:
> Hello everyone,
> 
> 
> First of all I'm 20 years old student who is pretty much new at this :) so I 
> might sound really nooby, but I noticed that network manager (all versions) 
> doesn't support setting up a new connection from console which is necessary 
> in some cases (it can be done only from applet), so I have implemented 
> mentioned feature for my personal use and added it to nmcli source (i'm 
> talking about connecting to mobile Internet) ...

Sounds neat!  Jirka Klimes has been working on support for this for a
while in his 'cli-enhance' branch which was merged to git master
recently, which has some simple support for mobile broadband.  Could you
mail your patches to this list so everyone can take a look at them and
see how they could fit into current git master's nmcli?

Thanks!
Dan

___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list