summaryrefslogtreecommitdiff
path: root/examples/C
Commit message (Collapse)AuthorAgeFilesLines
* all: use the elvis operator wherever possibleLubomir Rintel2018-05-101-1/+1
| | | | | | | | | | | | | | | | | | | | | Coccinelle: @@ expression a, b; @@ -a ? a : b +a ?: b Applied with: spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir . With some manual adjustments on spots that Cocci didn't catch for reasons unknown. Thanks to the marvelous effort of the GNU compiler developer we can now spare a couple of bits that could be used for more important things, like this commit message. Standards commitees yet have to catch up.
* all: remove consecutive empty linesBeniamino Galvani2018-04-304-4/+0
| | | | | | | Normalize coding style by removing consecutive empty lines from C sources and headers. https://github.com/NetworkManager/NetworkManager/pull/108
* all: drop trailing spacesThomas Haller2018-02-071-2/+2
|
* version: drop NM_VERSION_MAX_ALLOWED defines for internal buildThomas Haller2018-01-231-1/+0
| | | | | | It already defaults to the right value. We only need to define NM_VERSION_MIN_REQUIRED, so that parts of our internal build can make use of deprecated API.
* version: combine NM_VERSION_CUR_STABLE and NM_VERSION_NEXT_STABLEThomas Haller2018-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need to have two version defines "CUR" and "NEXT". The main purpose of these macros (if not their only), is to make NM_AVAILABLE_IN_* and NM_DEPRECATED_IN_* macros work. 1) At the precise commit of a release, "CUR" and "NEXT" must be identical, because whenever the user configures NM_VERSION_MIN_REQUIRED and NM_VERSION_MAX_ALLOWED, then they both compare against the current version, at which point "CUR" == "NEXT". 2) Every other commit aside the release, is a development version that leads up the the next coming release. But as far as versioning is concerned, such a development version should be treated like that future release. It's unstable API and it may or may not be close to later API of the release. But we shall treat it as that version. Hence, also in this case, we want to set both "NM_VERSION_CUR_STABLE" and again NEXT to the future version. This makes NM_VERSION_NEXT_STABLE redundant. Previously, the separation between current and next version would for example allow that NM_VERSION_CUR_STABLE is the previously release stable API, and NM_VERSION_NEXT_STABLE is the version of the next upcoming stable API. So, we could allow "examples" to make use of development API, but other(?) internal code still restrict to unstable API. But it's unclear which other code would want to avoid current development. Also, the points 1) and 2) were badly understood. Note that for our previousy releases, we usually didn't bump the macros at the stable release (and if we did, we didn't set them to be the same). While using two macros might be more powerful, it is hard to grok and easy to forget to bump the macros a the right time. One macro shall suffice. All this also means, that *immediately* after making a new release, we shall bump the version number in `configure.ac` and "NM_VERSION_CUR_STABLE".
* all: require glib 2.40lr/glib-2-40Lubomir Rintel2018-01-188-40/+0
| | | | | | RHEL 7.1 and Ubuntu 14.04 LTS both have this. https://bugzilla.gnome.org/show_bug.cgi?id=792323
* meson: Improve dependency systemIñigo Martínez2018-01-101-18/+11
| | | | | | | | | | | | | | | | | | | | Some targets are missing dependencies on some generated sources in the meson port. These makes the build to fail due to missing source files on a highly parallelized build. These dependencies have been resolved by taking advantage of meson's internal dependencies which can be used to pass source files, include directories, libraries and compiler flags. One of such internal dependencies called `core_dep` was already in use. However, in order to avoid any confusion with another new internal dependency called `nm_core_dep`, which is used to include directories and source files from the `libnm-core` directory, the `core_dep` dependency has been renamed to `nm_dep`. These changes have allowed minimizing the build details which are inherited by using those dependencies. The parallelized build has also been improved.
* build: use template files for enum types' sources generationIñigo Martínez2017-12-181-2/+2
| | | | | | | | | | Source files for enum types are generated by passing segments of the source code of the files to the `glib-mkenums` command. This patch removes those parameters where source code is used from meson build files by moving those segmeents to template files. https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00057.html
* build: add initial support for meson build systemIñigo Martínez2017-12-132-0/+74
| | | | | | | | | | meson is a build system focused on speed an ease of use, which helps speeding up the software development. This patch adds meson support along autotools. [thaller@redhat.com: rebased patch and adjusted for iwd support] https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00022.html
* examples: linker requires that library dependencies follow useLucas Rangit Magasweran2017-09-218-8/+8
| | | | | | | | | | | | | | | | | | | | On modern distributions, ld runs with the '--as-needed' option enabled by default, meaning library dependencies must come after files that require them. Also, this allows indirect linking so the build commands can be simplified. The alternative is to add the '-Wl,--no-as-needed' gcc option or use the top-level Makefile. Tested on: * Ubuntu 16.04.3 with gcc Ubuntu 5.4.1-8ubuntu1 * Fedora 24 with gcc Red Hat 6.1.1-3 Signed-off-by: Lucas Magasweran <lucas.magasweran@ieee.org> https://mail.gnome.org/archives/networkmanager-list/2017-September/msg00022.html https://mail.gnome.org/archives/networkmanager-list/2017-September/msg00023.html https://mail.gnome.org/archives/networkmanager-list/2017-September/msg00025.html
* build: declare build dependencies requiring "nm-core-enum-types.h"Thomas Haller2017-03-293-1/+12
| | | | | | | | | | | | | | | | cat <<-EOF > /tmp/glib-mkenums #!/bin/bash sleep 15 && /usr/bin/glib-mkenums "\$@" EOF chmod +x /tmp/glib-mkenums (export PATH="/tmp:$PATH" && git clean -fdx && ./autogen.sh && make -j20 all-am) (cherry picked from commit 68ab166f3894834af9473d42f5dab72e0ed15394)
* include: use double-quotes to include our own headersThomas Haller2017-03-093-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In practice, this should only matter when there are multiple header files with the same name. That is something we try to avoid already, by giving headers a distinct name. When building NetworkManager itself, we clearly want to use double-quotes for including our own headers. But we also want to do that in our public headers. For example: ./a.c #include <stdio.h> #include <nm-1.h> void main() { printf ("INCLUDED %s/nm-2.h\n", SYMB); } ./1/nm-1.h #include <nm-2.h> ./1/nm-2.h #define SYMB "1" ./2/nm-2.h #define SYMB "2" $ cc -I./2 -I./1 ./a.c $ ./a.out INCLUDED 2/nm-2.h Exceptions to this are - headers in "shared/nm-utils" that include <NetworkManager.h>. These headers are copied into projects and hence used like headers owned by those projects. - examples/C
* build: merge "examples/C/qt/Makefile.am" into toplevel MakefileThomas Haller2016-10-212-51/+0
|
* build: merge "examples/C/glib/Makefile.am" into toplevel MakefileThomas Haller2016-10-212-56/+1
|
* examples: fix crash in add-connection-libnmBeniamino Galvani2016-04-201-1/+1
| | | | Reported-by: Ali Nematollahi <alirezan1@gmail.com>
* all: cleanup includes and let "nm-default.h" include "config.h"Thomas Haller2016-02-198-16/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* examples: avoid compile errors around NM versioningDan Williams2016-01-281-1/+2
|
* build: rename directory "include" to "shared"Thomas Haller2015-12-241-2/+2
| | | | | | | | | | 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".
* build: extract version macros from "nm-version.h" to new header file ↵Thomas Haller2015-09-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "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 c0852964a890cf43cc2dcaeff41ac6edc5028f24 removed that dependancy. For libnm-glib library, the analog to "nm-dbus-interface.h" is "NetworkManager.h", and the same applies there. Commit 159e827a72f420048e12d318f8ba1edd3f641fc8 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: 4545a7fe9670ce4d7c259c11c2cc853bfae6729b
* all: consistently include config.hDan Winship2014-11-138-0/+16
| | | | | | | | | | | 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.)
* libnm-core: extract NMSettingIPConfig superclass out of IP4, IP6 classesDan Winship2014-11-072-2/+2
| | | | | | | | 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.
* libnm: change GSList to GPtrArray in libnm methodsDan Winship2014-10-281-6/+6
| | | | | | | 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).
* libnm: merge NMRemoteSettings into NMClientDan Winship2014-10-102-28/+22
| | | | | Make NMRemoteSettings internal and have NMClient wrap all of its APIs, just like it does with NMManager.
* libnm: make sync/async APIs more GLib-likeDan Winship2014-09-251-17/+16
| | | | | | | | | | | | Make synchronous APIs take GCancellables, and make asynchronous APIs use GAsyncReadyCallbacks and have names ending in "_async", with "_finish" functions to retrieve the results. Also, make nm_client_activate_connection_finish(), nm_client_add_and_activate_finish(), and nm_remote_settings_add_connection_finish() be (transfer full) rather than (transfer none), because the refcounting semantics become slightly confusing in some edge cases otherwise.
* libnm: merge saved and unsaved connection methodsDan Winship2014-09-251-1/+1
| | | | | | | | Merge nm_remote_settings_add_connection() and nm_remote_settings_add_connection_unsaved(), and likewise nm_remote_connection_commit_changes() and nm_remote_connection_commit_changes_unsaved(), by adding a boolean flag to each saying whether to save to disk.
* tui,examples: accept null SSID gracefullyJiří Klimeš2014-09-191-3/+9
| | | | | | Signed-off-by: Jiří Klimeš <jklimes@redhat.com> https://bugzilla.gnome.org/show_bug.cgi?id=736802
* libnm: port to GDBusDan Winship2014-09-181-4/+0
| | | | | | | | | Port libnm-core/libnm to GDBus. The NetworkManager daemon continues to use dbus-glib; the previously-added connection hash/variant conversion methods are now moved to NetworkManagerUtils (along with a few other utilities that are now only needed by the daemon code).
* examples: port dbus-glib-based examples to gdbusDan Winship2014-09-0413-622/+554
| | | | | | | | | | | | | | | | | Port the dbus-glib-based examples to GDBus. Also, don't use libnm in them at all; there's not much point in examples that use the D-Bus API directly if they're just going to fall back to libnm for the hard stuff... (And also, this avoids the problem that GDBus uses GVariant, while the libnm-core APIs currently still use GHashTables.) Also fix up some comment grammar and copyright style, and add emacs modelines where missing. Also rename the existing GDBus-based examples to have names ending in "-gdbus", not "-GDBus", since there's no reason to gratuitously capitalize here.
* libnm: change empty-GPtrArray-return semanticsDan Winship2014-09-041-2/+2
| | | | | | | | | | libnm functions that return GPtrArrays of objects had a rule that if the array was empty, they would return NULL rather than a 0-length array. As it turns out, this is just a nuisance to clients, since in most places the code for the non-empty case would end up doing the right thing for the empty case as well (and where it doesn't, we can check "array->len == 0" just as easily as "array == NULL"). So just return the 0-length array instead.
* libnm: drop NM_TYPE_SSID, use G_TYPE_BYTESDan Winship2014-09-041-4/+5
| | | | | Make NMAccessPoint:ssid be G_TYPE_BYTES and update the corresponding APIs accordingly.
* libnm-core: replace GByteArray with pointer + length in some APIsDan Winship2014-09-041-2/+2
| | | | | | | APIs that take arbitrary data should take it in the form of a pointer and length, not a GByteArray, so that you can use them regardless of what format you have the data in (GByteArray, GBytes, plain array, etc).
* libnm-core: rename NMConnection to/from_hash methodsDan Winship2014-09-042-2/+2
| | | | | | | | | | | | Rename nm_connection_to_hash() to nm_connection_to_dbus(), and nm_connection_new_from_hash() to nm_connection_new_from_dbus(). In addition to clarifying that this is specifically the D-Bus serialization format, these names will also work better in the GDBus-based future where the serialization format is GVariant, not GHashTable. Also, move NMSettingHashFlags to nm-connection.h, and rename it NMConnectionSerializationFlags.
* libnm-core, libnm, core: make NMConnection an interfaceDan Winship2014-08-163-3/+3
| | | | | | | | | | | | | | | | | | | | | | The fact that NMRemoteConnection has to be an NMConnection and therefore can't be an NMObject means that it needs to reimplement bits of NMObject functionality (and likewise NMObject needs some special magic to deal with it). Likewise, we will need a daemon-side equivalent of NMObject as part of the gdbus port, and we would want NMSettingsConnection to be able to inherit from this as well. Solve this problem by making NMConnection into an interface, and having NMRemoteConnection and NMSettingsConnection implement it. (We use some hacks to keep the GHashTable of NMSettings objects inside nm-connection.c rather than having to be implemented by the implementations.) Since NMConnection is no longer an instantiable type, this adds NMSimpleConnection to replace the various non-D-Bus-based uses of NMConnection throughout the code. nm_connection_new() becomes nm_simple_connection_new(), nm_connection_new_from_hash() becomes nm_simple_connection_new_from_hash(), and nm_connection_duplicate() becomes nm_simple_connection_new_clone().
* libnm: port NMRemoteSettings to NMObjectDan Winship2014-08-071-88/+17
| | | | | | | | | | | | | | | | | | | NMRemoteSettings duplicates a bunch of NMObject's functionality that it doesn't need to. In libnm-glib, it wouldn't have been possible to port NMRemoteSettings to NMObject without breaking ABI, but now in libnm we can do that. As a side effect of this, NMRemoteSettings gains a "connections" property, and "connection-added" and "connection-removed" signals (with the former replacing the old "new-connection" signal). This also removes the "connections-loaded" signal, since the connections will now always be loaded (via the initialization of the "connections" property) during init()/init_async(). Also, this removes NMRemoteConnection's "removed" signal, since it's redundant with the new NMRemoteSettings::connection-removed (and having the signal on NMRemoteSettings instead is more consistent with other objects).
* libnm: synchronize NMClient and NMRemoteSettings "is NM running" propertiesDan Winship2014-08-071-1/+1
| | | | | Rename NMClient:manager-running and NMRemoteSettings:service-running to both be :nm-running.
* libnm: add NetworkManager.h, disallow including individual headersDan Winship2014-08-016-31/+6
| | | | | | | | | | Add NetworkManager.h, which includes all of the other NM header, and require all external users of libnm to use that rather than the individual headers. (An exception is made for nm-dbus-interface.h, nm-vpn-dbus-interface.h, and nm-version.h, which can be included separately.)
* libnm: rename NetworkManager.h and NetworkManagerVPN.hDan Winship2014-08-019-14/+14
| | | | | | | "NetworkManager.h"'s name (and non-standard capitalization) suggest that it's some sort of high-level super-important header, but it's really just low-level D-Bus stuff. Rename it to "nm-dbus-interface.h" and likewise "NetworkManagerVPN.h" to "nm-vpn-dbus-interface.h"
* libnm: make the the use of GInitable mandatoryDan Winship2014-08-013-14/+17
| | | | | | | | | | | Remove _nm_object_ensure_inited(), etc; objects that implement GInitable are now mandatory-to-init(). Remove constructor() implementations that sometimes return NULL; do all the relevant checking in init() instead. Make nm_client_new() and nm_remote_settings_new() take a GCancellable and a GError**.
* libnm: consistently use "INTERFACE" rather than "IFACE" in macrosDan Winship2014-08-016-8/+8
| | | | | | Most D-Bus interface name macros used "INTERFACE" in their name (eg, NM_DBUS_INTERFACE), but a few used "IFACE" instead (eg, NM_DBUS_IFACE_SETTINGS). Make them consistent.
* all: port everything to libnmDan Winship2014-08-0110-51/+40
| | | | | | | | | | | Since the API has not changed at this point, this is mostly just a matter of updating Makefiles, and changing references to the library name in comments. NetworkManager cannot link to libnm due to the duplicated type/symbol names. So it links to libnm-core.la directly, which means that NetworkManager gets a separate copy of that code from libnm.so. Everything else links to libnm.
* build: more srcdir!=builddir fixesDan Winship2014-07-151-1/+0
| | | | | | | | nm-version.h was getting disted, making srcdir!=builddir work for tarball builds, but not for git builds. Also, remove "-I${top_builddir}/include" from all Makefile.ams, since there's nothing generated in include/ any more.
* libnm-util: move NetworkManager.h, etc, from include/ to hereDan Winship2014-07-151-2/+2
| | | | | | | | NetworkManager.h, NetworkManagerVPN.h, and nm-version.h are part of the libnm-util API, so move them to libnm-util. include/ still contains headers that are strictly NM-internal (eg, nm-glib-compat.h).
* examples: fix get-active-connections-dbus-glib.c exampleJiří Klimeš2014-06-091-45/+18
|
* libnm-glib: don't use deprecated nm_access_point_get_hw_address()Thomas Haller2014-06-071-1/+1
| | | | | | | | | nm_access_point_get_hw_address() is already deprecated since pre-0.9.0-beta3 (f30e15a04d56a922f50e20c3c155a452d635a187). However, it also is defined as NM_DEPRECATED_IN_0_9_10, because there are no deprecated macros for previous version. Signed-off-by: Thomas Haller <thaller@redhat.com>
* all: g_type_init() has been deprecated in GLib 2.35.0Jiří Klimeš2014-05-279-0/+18
| | | | | g_type_init() deprecation: https://bugzilla.gnome.org/show_bug.cgi?id=686161
* examples: fix qt demo to work without STL supportThomas Haller2014-04-041-2/+2
| | | | | | | | | | | | | | | | The function toStdString() is only available when QT was compiled with STL support. The configure script does not check STL support and might build the QT examples even if toStdString() is not available. Fix this, by not using the function. This fixes the previous commit f73e3669b3bb9b3547173896dcea8e2eb17d30ec that I pushed accidentally. https://bugzilla.gnome.org/show_bug.cgi?id=727608 Signed-off-by: Thomas Haller <thaller@redhat.com>
* examples: fix qt demo to work without STL supportThomas Haller2014-04-041-2/+2
| | | | | | | | | | | | | The function toStdString() is only available when QT was compiled with STL support. The configure script does not check STL support and might build the QT examples even if toStdString() is not available. Fix this, by not using the function. https://bugzilla.gnome.org/show_bug.cgi?id=727608 Signed-off-by: Thomas Haller <thaller@redhat.com>
* examples: use correct Mbit/s for bitratesJiří Klimeš2014-04-011-2/+2
|
* coverity: fix various warnings detected with CoverityThomas Haller2013-11-131-5/+11
| | | | | | | | | | | | | These are (most likely) only warnings and not severe bugs. Some of these changes are mostly made to get a clean run of Coverity without any warnings. Error found by running Coverity scan https://bugzilla.redhat.com/show_bug.cgi?id=1025894 Co-Authored-By: Jiří Klimeš <jklimes@redhat.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* core: cleanup freeing of glib collections of pointersThomas Haller2013-10-221-2/+2
| | | | | | | | | | | | | | | | When freeing one of the collections such as GArray, GPtrArray, GSList, etc. it is common that the items inside the connections must be freed/unrefed too. The previous code often iterated over the collection first with e.g. g_ptr_array_foreach and passing e.g. g_free as GFunc argument. For one, this has the problem, that g_free has a different signature GDestroyNotify then the expected GFunc. Moreover, this can be simplified either by setting a clear function (g_ptr_array_set_clear_func) or by passing the destroy function to the free function (g_slist_free_full). Signed-off-by: Thomas Haller <thaller@redhat.com>