Commit graph

187 commits

Author SHA1 Message Date
Thomas Haller 6fa069fad1 example: add example configuration snippet '30-anon.conf' 2017-01-09 14:50:33 +01:00
Beniamino Galvani 8af465d579 examples: add DNS example with python and GObject introspection 2016-12-12 22:06:24 +01:00
Thomas Haller 2837da9b30 examples/python: fix "import gi" in example
Otherwise there is a warning:

  from gi.repository import GLib, NM
  __main__:1: PyGIWarning: NM was imported without specifying a version first. Use gi.require_version(NM, 1.0) before import to ensure that the right version gets loaded.
2016-11-16 11:50:30 +01:00
Thomas Haller 351851cf27 build: merge "examples/Makefile.am" into toplevel Makefile 2016-10-21 17:37:57 +02:00
Thomas Haller b648772fc4 build: merge "examples/C/qt/Makefile.am" into toplevel Makefile 2016-10-21 17:37:57 +02:00
Thomas Haller 742d36c476 build: merge "examples/C/glib/Makefile.am" into toplevel Makefile 2016-10-21 17:37:57 +02:00
Beniamino Galvani 1ab616b59c checkpoint: make python example accept multiple devices and timeout
Add a timeout parameter and allow passing multiple interfaces to make
the script more useful for testing purposes.
2016-09-26 15:10:39 +02:00
Beniamino Galvani 048801add3 checkpoint: add python D-Bus example 2016-08-17 14:55:34 +02:00
Beniamino Galvani 76348adb8e examples: fix crash in add-connection-libnm
Reported-by: Ali Nematollahi <alirezan1@gmail.com>
2016-04-20 07:48:17 +02:00
Thomas Haller 05f17ace71 man: fix typo in NetworkManager.conf manual and 10-ifcfg-rh-routes.sh comment 2016-03-31 20:46:52 +02:00
Lubomir Rintel 3a2803b42c docs: replace spec.html with docbook D-Bus API reference
May use a lot of improvement (actually documenting the names and
objects that use the interfaces in question), but at least this looks a
lot better on developer.gnome.org.
2016-03-26 11:28:19 +01:00
Adrian Likins 6c59443ad5 Fix missing commas in list-devices devtypes dict. 2016-03-02 18:43:28 +01:00
Thomas Haller 1b00009169 device: add new NMDeviceType NM_DEVICE_TYPE_VETH
Based-on-patch-by: Jiří Klimeš <jklimes@redhat.com>
2016-02-23 23:15:37 +01:00
Thomas Haller 71962881a8 examples: add missing device-types to examples
Based-on-patch-by: Jiří Klimeš <jklimes@redhat.com>
2016-02-23 15:24:39 +01:00
Thomas Haller 8bace23beb all: cleanup includes and let "nm-default.h" include "config.h"
- All internal source files (except "examples", which are not internal)
  should include "config.h" first. As also all internal source
  files should include "nm-default.h", let "config.h" be included
  by "nm-default.h" and include "nm-default.h" as first in every
  source file.
  We already wanted to include "nm-default.h" before other headers
  because it might contains some fixes (like "nm-glib.h" compatibility)
  that is required first.

- After including "nm-default.h", we optinally allow for including the
  corresponding header file for the source file at hand. The idea
  is to ensure that each header file is self contained.

- Don't include "config.h" or "nm-default.h" in any header file
  (except "nm-sd-adapt.h"). Public headers anyway must not include
  these headers, and internal headers are never included after
  "nm-default.h", as of the first previous point.

- Include all internal headers with quotes instead of angle brackets.
  In practice it doesn't matter, because in our public headers we must
  include other headers with angle brackets. As we use our public
  headers also to compile our interal source files, effectively the
  result must be the same. Still do it for consistency.

- Except for <config.h> itself. Include it with angle brackets as suggested by
  https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
2016-02-19 17:53:25 +01:00
Dan Williams 91f06323c7 examples: avoid compile errors around NM versioning 2016-01-28 12:27:14 -06:00
Thomas Haller bc7ad75d99 contrib/rpm: install pre-up dispatcher script "10-ifcfg-rh-routes.sh" as no-wait
The main reason to introduce the "no-wait.d" dispatcher directory was
"10-ifcfg-rh-routes.sh", which (as a pre-up script) delays activation.
We even extracted the script to a separate package on RHEL to avoid
delays by default.

Invoke the script via no-wait.d.
2016-01-08 14:27:18 +01:00
Thomas Haller db80ec05ab build: rename directory "include" to "shared"
Up to now, the "include" directory contained (only) header files that were
used project-wide by libs, core, clients, et al.

Since the directory now also contains a non-header file, the "include"
name is misleading. Instead of adding yet another directory that is
project-wide, with non-header-only content, rename the "include"
directory to "shared".
2015-12-24 11:42:37 +01:00
Thomas Haller 14bb9419a0 examples: add README for python-networkmanager NetworkManager library 2015-12-07 16:06:46 +01:00
Thomas Haller 5b732c3b9f examples: add README for examples/python/gi 2015-12-07 15:59:20 +01:00
Dan Williams 4db851f852 libnm/libnm-glib: add NMClient.get_all_devices() method and AllDevices property
Mirror new NetworkManager API to return both real devices and
device placeholders.
2015-12-04 12:16:41 +01:00
Thomas Haller 8d1233e67e python: use gi.require_version() in generate-setting-docs.py and examples
gi now emits a warning when not loading a specific library
version [1]:

  ./generate-setting-docs.py:21: PyGIWarning: NM was imported without specifying a version first. Use gi.require_version(NM, 1.0) before import to ensure that the right version gets loaded.
    from gi.repository import NM, GObject

Seems require_version() is reasonably old to just always use it without
breaking on older versions [2].

[1] Related: https://bugzilla.gnome.org/show_bug.cgi?id=727379
[2] https://git.gnome.org/browse/pygobject/commit/?id=76758efb6579752237a0dc4d56cf9518de6c6e55
2015-11-11 10:56:05 +01:00
Beniamino Galvani bd4df767c6 examples: add python GI example for retrieving LLDP neighbors 2015-10-12 14:44:31 +02:00
Thomas Haller 7bf10a75db build: extract version macros from "nm-version.h" to new header file "nm-version-macros.h"
For libnm library, "nm-dbus-interface.h" contains defines like the D-Bus
paths of NetworkManager. It is desirable to have this header usable without
having a dependency on "glib.h", for example for a QT application. For that,
commit c0852964a8 removed that dependancy.

For libnm-glib library, the analog to "nm-dbus-interface.h" is
"NetworkManager.h", and the same applies there. Commit
159e827a72 removed that include.
However, that broke build on PackageKit [1] which expected to get the
version macros by including "NetworkManager.h". So at least for libnm-glib,
we need to preserve old behavior so that a user including
"NetworkManager.h" gets the version macros, but not "glib.h".

Extract the version macros to a new header file "nm-version-macros.h".
This header doesn't include "glib.h" and can be included from
"NetworkManager.h". This gives as previous behavior and a glib-free
include.

For libnm we still don't include "nm-version-macros.h" to "nm-dbus-interface.h".
Very few users will actually need the version macros, but not using
libnm.
Users that use libnm, should just include (libnm's) "NetworkManager.h" to
get all headers.
As a special case, a user who doesn't want to use glib/libnm, but still
needs both "nm-dbus-interface.h" and "nm-version-macros.h", can include
them both separately.

[1] https://github.com/hughsie/PackageKit/issues/85

Fixes: 4545a7fe96
2015-09-30 23:10:29 +02:00
Jiří Klimeš 8e3ae81566 examples: generate UUID in add-wifi-eap-connection.py
so that it can be run multiple times.
2015-09-17 14:49:04 +02:00
Jiří Klimeš a25bbde641 examples: add a python example for adding WPA PSK Wi-Fi connection
and rename add-system-wifi-connection.py to add-wifi-eap-connection.py
2015-09-17 14:46:19 +02:00
Jiří Klimeš cb64067b7a examples: add flags and mode parsing to show-wifi-networks.[lua|py] 2015-08-24 12:33:04 +02:00
Dan Williams d1d048c93d examples: add python+dbus example to print active access point 2015-07-08 09:31:22 -05:00
Jiří Klimeš eebfe56a90 examples: python: add an D-Bus example creating and activating a bond 2015-06-23 15:06:31 +02:00
Jiří Klimeš 1e923cb923 examples: add wifi-hotspot.py script to Makefile.am
Fixes: 1af8e2f132
2015-06-23 15:04:43 +02:00
Dan Williams 1af8e2f132 examples: add DBus + Python example for starting/stopping a WiFi hotspot 2015-05-18 15:11:12 -05:00
Petr Vorel 1e646f30f2 examples: bash: print errors int stderr
+ whitespace

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
2015-03-18 15:07:59 -05:00
Srdjan Grubor 0e1fe1fe4e examples: update Python NM example to print detailed connection state
Current Python NM example has a very crude connection state output
and the global NM connectivity is not used in them either.

https://bugzilla.gnome.org/show_bug.cgi?id=746045
2015-03-12 10:39:00 +01:00
Petr Vorel 4213c17b44 examples: python: print into stderr
https://mail.gnome.org/archives/networkmanager-list/2015-March/msg00024.html

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
2015-03-10 12:17:59 +01:00
Thomas Haller 2171084378 examples/trvial: replace tabs by whitespace in python example 2015-03-10 12:17:23 +01:00
Jiří Klimeš 6b5de0ab5f examples: add a Python example deactivating connections by type (bgo #732826)
https://bugzilla.gnome.org/show_bug.cgi?id=732826
2015-03-05 15:59:52 +01:00
Jiří Klimeš 489f80e3c0 examples: add a Lua example deactivating connections by type (bgo #732826)
https://bugzilla.gnome.org/show_bug.cgi?id=732826
2015-03-05 15:59:32 +01:00
Jiří Klimeš 37becd2ee6 examples: add a Lua example setting user name for a VPN connection 2015-02-11 13:34:38 +01:00
Jiří Klimeš 21c9c7e21c examples: add a Lua example getting IP configuration of a device
Unfortunately, there is a bug in lgi library causing the incorrect values
being returned and the example crashes. I am going to send a patch to lgi
to fix the issues.
2015-02-10 10:35:41 +01:00
Jiří Klimeš f124848b60 examples: add a Lua example showing basic NetworkManager information 2015-02-09 10:11:18 +01:00
Jiří Klimeš 3d991b8e32 examples: add a Lua example for getting Wi-Fi access points 2015-02-09 10:11:12 +01:00
Jiří Klimeš 6be3d7cbad examples: add some examples in Lua using lgi library
[libnm]     https://developer.gnome.org/libnm/1.0/
[lgi]       https://github.com/pavouk/lgi
[lgi-guide] https://github.com/pavouk/lgi/blob/master/docs/guide.md

On most distribution just install lua-lgi.

Note:
There is a bug in lgi. It doesn't handle GPtrArray corectly. It results in
crashing on list-devices.lua and list-connections.lua.
I will send a patch to lgi to fix the issue.
2015-01-30 14:41:13 +01:00
Dan Winship 8de1bec803 dispatcher: fix ifcfg-rh example dispatcher script (rh #1160013)
Routing table entries for a device get flushed when the device is
deactivated, but rules table entries don't, so we have to flush them
by hand.
2015-01-27 13:51:45 -05:00
Dan Winship f79d62692e ifcfg-rh: allow handling complex routing rules via dispatcher (rh #1160013)
If a connection has an associated "rule-NAME" or "rule6-NAME" file,
don't try to read in the routes, since NetworkManager won't be able to
parse them correctly. Instead, log a warning that they will need to be
applied via a dispatcher script, and provide a script that would do
that in examples/dispatcher/.
2015-01-12 09:53:24 -05:00
Dan Winship 66936decfa examples: update python examples
Update the raw D-Bus python examples to use newer APIs where
appropriate (and split the add-connection example into 1.0-only and
0.9-compatible versions). Update the gi-based python examples for the
various API changes since they were last updated.

Also add a comment to the ruby add-connection example pointing out
that it's still using the old settings APIs.
2014-11-15 09:31:49 -05:00
Dan Winship 3bfb163a74 all: consistently include config.h
config.h should be included from every .c file, and it should be
included before any other include. Fix that.

(As a side effect of how I did this, this also changes us to
consistently use "config.h" rather than <config.h>. To the extent that
it matters [which is not much], quotes are more correct anyway, since
we're talking about a file in our own build tree, not a system
include.)
2014-11-13 17:18:42 -05:00
Dan Winship 3f30c6f1c2 libnm-core: extract NMSettingIPConfig superclass out of IP4, IP6 classes
Split a base NMSettingIPConfig class out of NMSettingIP4Config and
NMSettingIP6Config, and update things accordingly.

Further simplifications of now-redundant IPv4-vs-IPv6 code are
possible, and should happen in the future.
2014-11-07 07:49:40 -05:00
Thomas Haller 0923769285 test,examples: fix scripts to avoid 'has_key' for Python 3
'has_key' on Dictionaries is removed from Python3 in favor of 'in'.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-31 16:39:00 +01:00
Dan Winship 6ae4224850 libnm: change GSList to GPtrArray in libnm methods
libnm mostly used GPtrArrays in its APIs, except that arrays of
connections were usually GSLists. Fix this and make them GPtrArrays
too (and rename nm_client_list_connections() to
nm_client_get_connections() to match everything else).
2014-10-28 17:17:17 -04:00
Dan Winship 6f3d1f9526 libnm: merge NMRemoteSettings into NMClient
Make NMRemoteSettings internal and have NMClient wrap all of its APIs,
just like it does with NMManager.
2014-10-10 12:40:19 -04:00