Commit graph

44 commits

Author SHA1 Message Date
Thomas Haller 3b69f02164 all: unify format of our Copyright source code comments
```bash

readarray -d '' FILES < <(
  git ls-files -z \
    ':(exclude)po' \
    ':(exclude)shared/c-rbtree' \
    ':(exclude)shared/c-list' \
    ':(exclude)shared/c-siphash' \
    ':(exclude)shared/c-stdaux' \
    ':(exclude)shared/n-acd' \
    ':(exclude)shared/n-dhcp4' \
    ':(exclude)src/systemd/src' \
    ':(exclude)shared/systemd/src' \
    ':(exclude)m4' \
    ':(exclude)COPYING*'
  )

sed \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[-–] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C1pyright#\5 - \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[,] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C2pyright#\5, \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C3pyright#\5#\7/' \
  -e 's/^Copyright \(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/C4pyright#\1#\3/' \
  -i \
  "${FILES[@]}"

echo ">>> untouched Copyright lines"
git grep Copyright "${FILES[@]}"

echo ">>> Copyright lines with unusual extra"
git grep '\<C[0-9]pyright#' "${FILES[@]}" | grep -i reserved

sed \
  -e 's/\<C[0-9]pyright#\([^#]*\)#\(.*\)$/Copyright (C) \1 \2/' \
  -i \
  "${FILES[@]}"

```

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/298
2019-10-02 17:03:52 +02:00
Lubomir Rintel 24028a2246 all: SPDX header conversion
$ find * -type f |xargs perl contrib/scripts/spdx.pl
  $ git rm contrib/scripts/spdx.pl
2019-09-10 11:19:56 +02:00
Thomas Haller 87a73df959 all: drop empty first line from sources
git ls-files -z -- ':(exclude)src/settings/plugins/keyfile/tests/keyfiles' | xargs -0 -n1 sed -i '1 { /^$/d }'
2019-06-11 10:15:06 +02:00
Thomas Haller c0e075c902 all: drop emacs file variables from source files
We no longer add these. If you use Emacs, configure it yourself.

Also, due to our "smart-tab" usage the editor anyway does a subpar
job handling our tabs. However, on the upside every user can choose
whatever tab-width he/she prefers. If "smart-tabs" are used properly
(like we do), every tab-width will work.

No manual changes, just ran commands:

    F=($(git grep -l -e '-\*-'))
    sed '1 { /\/\* *-\*-  *[mM]ode.*\*\/$/d }'     -i "${F[@]}"
    sed '1,4 { /^\(#\|--\|dnl\) *-\*- [mM]ode/d }' -i "${F[@]}"

Check remaining lines with:

    git grep -e '-\*-'

The ultimate purpose of this is to cleanup our files and eventually use
SPDX license identifiers. For that, first get rid of the boilerplate lines.
2019-06-11 10:04:00 +02:00
Thomas Haller 0cc68e1c4f libnm: add init_from_dbus() virtual function to NMSetting 2019-05-23 18:09:49 +02:00
Thomas Haller b1344b6b94 libnm: pass connection to compare_property() function
We have certain artificial properties that not only depend on one
property alone or that depend on a property in another(!) setting.

For that, we have synth_func.

Other than that, synth_func and get_func are really fundamentally
similar and should be merged. That is because the distinction whether a
property value is "synthetized" or just based on a plain property is
minor. It's better to have the general concept of "convert property to
GVariant" in one form only.

Note that compare_property() is by default implemented based
on get_func. Hence, if get_func and synth_func get merged,
compare_property() will also require access to the NMConnection.

Also it makes some sense: some properties are artificial and actually
stored in "another" setting of the connection. But still, the property
descriptor for the property is in this setting. The example is the
"bond.interface-name" which only exists on D-Bus. It's stored as
"connection.interface-name".
I don't really like to say "exists on D-Bus only". It's still a valid
property, despite in NMSetting it's stored somehow differently (or not
at all). So, this is also just a regular property for which we have a
property-info vtable.
Does it make sense to compare such properties? Maybe. But the point is that
compare_property() function needs sometimes access to the entire
connection. So add the argument.
2019-05-01 13:46:32 +02:00
Thomas Haller 353e619c9f libnm,core: make for-each-secret implementation virtual functions of NMSetting
We already need to special handle regular settings (with secrets as
GObject properties) and VPN secrets.

Next, we will also need to special handle WireGuard peers, which can
have secrets too.

Move the code to a virtual function, so that "nm-connection.c" and
"nm-setting.c" does not have explicit per-setting knowledge.
2019-02-04 20:15:20 +01:00
Thomas Haller b64e24dcd7 libnm: rework _nm_setting_aggregate() to delegate to setting class
Instead of special-casing the aggregate implementation for NMSettingVpn,
delegate to a virtual function.

This will also work with other settings, that have properties/secrets
that are not GObject based properties.
2019-02-04 20:15:20 +01:00
Thomas Haller 52368678d6 libnm: extend nm_setting_enumerate_values() to support non-GObject base properties
While nm_setting_enumerate_values() should not be used anymore, still
extend it to make it workable also for properties that are not based on
GObject properties.
2019-02-04 20:15:20 +01:00
Thomas Haller 08a0f682e1 libnm: always call clear_secrets() function for all properties
And merge it with the version that uses no flags.

Previously, clear_secrets(_with_flags()) was only implemented
by NMSettingVpn. All other settings would only consider GObject-based
properties.

As we will add secrets that have no GObject property, call the virtual
function always, so that the setting can hook into this (for WireGuard
peers).
2019-01-22 16:30:23 +01:00
Thomas Haller 3a915a0205 libnm: support nm_setting_duplicate() for non-GObject base properties
Add a hook so that we can overwrite the property info.

Yes, this is an API/ABI change for NMSettingClass, which is in a
header file. But this is not API that we want to support. Users must
not use this. Alternatively, I could hook the callback into
NMSettInfoSetting, but either works.
2019-01-22 16:30:23 +01:00
Thomas Haller 885c872d5a libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().

compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().

Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.

If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().

This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-11 11:48:47 +01:00
Thomas Haller 20a738c92f libnm: fix NM_SETTING_DIFF_RESULT_IN_B_DEFAULT flag for nm_setting_diff()
This is public API, but if it was used, it was very wrong.
Cannot help but fix it.

Fixes: 68bc95c12f
2019-01-10 13:43:51 +01:00
Thomas Haller 4a5514dc0f libnm: cleanup secret-flags setter and getter
There are 3 kinds of secret flag implementations:

1) regular properties have a GObject property and a corresponding
  "-flags" property.

2) NMSettingVpn handles this entirely differently

3) NMSettingWirelessSecurity's WEP keys, where the secret keys
   share a flags property that does not follow the same naming
   scheme as 1).

The getter and setter had a boolean "verifiy_secret", only to
handle 3). Drop that parameter. Don't let NMSettingWirelessSecurity
call the parent's implementation for WEP keys. Just let it handle
it directly.
2019-01-07 10:42:33 +01:00
luz.paz 58510ed566 docs: misc. typos pt2
Remainder of typos found using `codespell -q 3 --skip="./shared,./src/systemd,*.po" -I ../NetworkManager-word-whitelist.txt` whereby whitelist consists of:
 ```
ans
busses
cace
cna
conexant
crasher
iff
liftime
creat
nd
sav
technik
uint
```

https://github.com/NetworkManager/NetworkManager/pull/205
2018-09-17 11:26:13 +02:00
Thomas Haller 4e0f1b16b9 libnm: add generic-data for implementing NMSetting
Add a new way how NMSetting subclasses can be implemented.

Currently, most NMSetting implementations realize all their properties
via GObject properties. That has some downsides:

 - the biggest one, is the large effort to add new properties.
   Most of them are implemented on a one-by-one basis and they come
   with additional API (like native getter functions).
   It makes it cumbersome to add more properties.

 - for certain properties, it's hard to encode them entirely in
   a GObject property. That results in unusable API like
   NM_SETTING_IP_CONFIG_ADDRESSES, NM_SETTING_BOND_OPTIONS,
   NM_SETTING_USER_DATA. These complex valued properties only
   exist, because we currently always need GObject properties
   to even implement simple functionality. For example,
   nm_setting_duplicate() is entirely implemented via
   nm_setting_enumerate_values(), which can only iterate
   GObject properies. There is no reason why this is necessary.
   Note also how nmcli badly handles bond options and VPN
   data. That is only a shortcoming of nmcli and wouldn't
   need to be that way. But it happend, because we didn't
   keep an open mind that settings might be more than just
   accessing GObject properties.

 - a major point of NMSetting is to convert to/from a GVariant
   from the D-Bus API. As NMSetting needs to squeeze all values
   into the static GObject structure, there is no place to
   encode invalid or unknown properties. Optimally,
   _nm_setting_new_from_dbus() does not loose any information
   and a subsequent _nm_setting_to_dbus() can restore the original
   variant. That is interesting, because we want that an older
   libnm client can talk to a newer NetworkManager version. The
   client needs to handle unknown properties gracefully to stay
   forward compatible. However, it also should not just drop the
   properties on the floor.
   Note however, optimally we want that nm_setting_verify() still
   can reject settings that have such unknown/invalid values. So,
   it should be possible to create an NMSetting instance without
   error or loosing information. But verify() should be usable to
   identify such settings as invalid.

They also have a few upsides.

 - libnm is heavily oriented around GObject. So, we generate
   our nm-settings manual based on the gtk-doc. Note however,
   how we fail to generate a useful manual for bond.options.
   Also note, that there is no reason we couldn't generate
   great documentation, even if the properties are not GObject
   properties.

 - GObject properties do give some functionality like meta-data,
   data binding and notification. However, the meta-data is not
   sufficient on its own. Note how keyfile and nmcli need extensive
   descriptor tables on top of GObject properties, to make this
   useful. Note how GObject notifications for NMSetting instances
   are usually not useful, aside for data binding like nmtui does.

Also note how NMSettingBond already follows a different paradigm
than using GObject properties. Nowdays, NMSettingBond is considered
a mistake (related bug rh#1032808). Many ideas of NMSettingBond
are flawed, like exposing an inferiour API that reduces everything
to a string hash. Also, it only implemented the options hash inside
NMSettingBond. That means, if we would consider this a good style,
we would have to duplicate this approach in each new setting
implementation.

Add a new style to track data for NMSetting subclasses. It keeps
an internal hash table with all GVariant properies. Also, the
functionality is hooked into NMSetting base class, so all future
subclasses that follow this way, can benefit from this. This approach
has a few similiarties with NMSettingBond, but avoids its flaws.

With this, we also no longer need GObject properties (if we would
also implement generating useful documentation based on non-gkt-doc).
They may be added as accessors if they are useful, but there is no
need for them.

Also, handling the properties as a hash of variants invites for a
more generic approach when handling them. While we still could add
accessors that operate on a one-by-one bases, this leads to a more
generic usage where we apply common functionality to a set of properties.

Also, this is for the moment entirely internal and an implementation
detail. It's entirely up to the NMSetting subclass to make use of this
new style. Also, there are little hooks for the subclass available.
If they turn out to be necessary, they might be added. However, for
the moment, the functionality is restricted to what is useful and
necessary.
2018-08-10 10:38:19 +02:00
Thomas Haller 9c47e2ce30 libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().

Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.

Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.

The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).

Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.

Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.

While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-08-10 10:38:19 +02:00
Thomas Haller e1c7a2b5d0 all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.

    $ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
    587
    $ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
    21114

One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during

  g_object_set (obj, PROPERTY, (gint) value, NULL);

However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.

Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).

A simple style guide is instead: don't use these typedefs.

No manual actions, I only ran the bash script:

  FILES=($(git ls-files '*.[hc]'))
  sed -i \
      -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
      -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>  /\1   /g' \
      -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
      "${FILES[@]}"
2018-07-11 12:02:06 +02:00
Beniamino Galvani 1b5925ce88 all: remove consecutive empty lines
Normalize coding style by removing consecutive empty lines from C
sources and headers.

https://github.com/NetworkManager/NetworkManager/pull/108
2018-04-30 16:24:52 +02:00
Thomas Haller 831286df30 include: use double-quotes to include our own headers
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
2017-03-09 14:12:35 +01:00
Jiří Klimeš b41b32cb7b libnm: add nm_setting_verify_secrets() and nm_connection_verify_secrets()
for verifying the secrets, because it is not done in plain nm_setting_verify().

For simple verification of free-form string secrets,
_nm_setting_verify_secret_string() helper is used.
2015-11-20 10:35:10 +01:00
Dan Williams 0222822134 libnm: add Wi-Fi MAC address randomization property 2015-11-18 15:37:42 +01:00
Thomas Haller c9b3617c35 libnm: mark properties that take effect immediately on active connection (REAPPLY_IMMEDIATELY)
The flag is still unused.
2015-09-18 17:31:51 +02:00
Dan Winship 780d8bf2fe libnm: fix nm-setting-docs.xml property types
Add nm_setting_get_dbus_property_type(), and use this to get the
correct type for properties in nm-seting-docs.xml, in situations where
the D-Bus and GObject property types don't match.

In the case of enum/flags-valued properties, give both the enum name
and the underlying D-Bus type.
2014-11-19 09:24:10 -05:00
Jiří Klimeš 093a3c88d0 libnm-core: add NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP flag
for ignoring timestamp when comparing settings or connections.
2014-11-19 10:58:58 +01:00
Jiří Klimeš 20814094eb libnm-core: (trivial) indent NMSettingCompareFlags description for readibility 2014-11-19 10:58:58 +01:00
Dan Winship 9e5c7d915b libnm-core: make nm_setting_verify() take an NMConnection
nm_setting_verify() took a GSList of other NMSettings, but really it
would just be simpler all around to pass the NMConnection instead...

This means that several formerly NMSetting-branded functions that
operated on lists-of-settings now get replaced with
NMConnection-branded functions instead.
2014-10-28 17:17:17 -04:00
Dan Winship b108790833 libnm-core: add nm-core-types.h, remove cross-includes
Add nm-core-types.h, typedefing all of the GObject types in
libnm-core; this is needed so that nm-setting.h can reference
NMConnection in addition to nm-connection.h referencing NMSetting.

Removing the cross-includes from the various headers causes lots of
fallout elsewhere. (In particular, nm-utils.h used to include
nm-connection.h, which included every setting header, so any file that
included nm-utils.h automatically got most of the rest of libnm-core
without needing to pay attention to specifics.) Fix this up by
including nm-core-internal.h from those files that are now missing
includes.
2014-10-28 17:17:17 -04:00
Dan Winship 2d8e7bd247 libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.

So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)

Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.

Renamed error codes:

NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET

Remapped error codes:

NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY

Dropped error codes (were previously defined but unused):

NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-22 08:29:07 -04:00
Dan Winship a7b1ee77db libnm-core: drop nm_setting_lookup_type_by_quark()
nm_setting_lookup_type_by_quark() was only ever used in places that
were still mistakenly assuming the old style of nm_connection_verify()
errors, where the error message would contain only a property name and
no further explanation. Fix those places to assume that the error will
contain a real error message, and include both the setting name and
the property name.

Given that, there's no longer any need for
nm_setting_lookup_type_by_quark(), so drop it.
2014-10-22 08:29:07 -04:00
Thomas Haller 68bc95c12f libnm-util: let nm_setting_diff() be symetric not to return properties that are set to default
Previously, nm_setting_diff() (and thus nm_connection_diff()), returned
only properties that are different AND not set to the default value.
However, if the opposite setting 'B' was missing, it would always
include all properties from 'A', even the default ones.

This behaviour was asymetric. Add two new compare flags
@NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT and
@NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT to control the
behaviour of whether to include default properties.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller e5194fd346 libnm: hide API for generic handling of secrets
The functions nm_setting_clear_secrets(),
nm_setting_clear_secrets_with_flags(), and nm_setting_need_secrets()
are not used outside of libnm-core. Remove them from public API.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Dan Winship fcfb4b40ba libnm: make use of GParamSpecFlags and GParamSpecEnum
Make enum- and flags-valued properties use GParamSpecEnum and
GParamSpecFlags, for better introspectability/bindability.

This requires no changes outside libnm-core/libnm since the expected
data size is still the same with g_object_get()/g_object_set(), and
GLib will internally convert between int/uint and enum/flags GValues
when using g_object_get_property()/g_object_set_property().
2014-10-03 09:36:28 -04:00
Dan Winship acf86f68b3 libnm-core: change connection hash tables to variants in API
In preparation for porting to GDBus, make nm_connection_to_dbus(),
etc, represent connections as GVariants of type 'a{sa{sv}}' rather
than as GHashTables-of-GHashTables-of-GValues.

This means we're constantly converting back and forth internally, but
this is just a stepping stone on the way to the full GDBus port, and
all of that code will go away again later.
2014-09-18 11:51:09 -04:00
Dan Winship 7314256b77 libnm-core: drop nm_{setting,connection}_get_virtual_iface_name()
Since we enforce the fact that bond, bridge, team, and vlan
interface-name properties match NMSettingConnection:interface-name,
nm_connection_get_virtual_iface_name() can be replaced with
nm_connection_get_interface_name() basically everywhere.

The one place this doesn't work is with InfiniBand partitions (where
get_virtual_iface_name() was actually computing the name), but for the
most part we only need to care about the interface names of InfiniBand
partitions in places where we also already need to do some other
InfiniBand-specific handling as well, so we can use an
InfiniBand-specific method
(nm_setting_infiniband_get_virtual_interface_name()) to get it.

(Also, while updating nm_device_get_virtual_device_description(), fix
it to handle InfiniBand partitions too.)
2014-09-04 09:18:43 -04:00
Dan Winship 773d3f0ab6 libnm-core: rename NMConnection to/from_hash methods
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.
2014-09-04 09:17:36 -04:00
Dan Winship c9653a9e67 libnm-core: make the NMSetting hash methods private
Make nm_setting_to_hash() and nm_setting_new_from_hash() private, and
remove the public nm_setting_update_secrets() wrapper around the
existing private _nm_setting_update_secrets().

These functions should really only be called from the corresponding
NMConnection-level methods, and in particular, with certain
compatibility properties in the future, we will need to consider the
entire connection all at once when setting properties, so it won't
make sense to serialize/deserialize a single setting in isolation.
2014-09-04 09:17:36 -04:00
Thomas Haller d299c425d4 libnm: move declaration of NM_SETTING_SECRET_FLAGS_ALL to nm-core-internal.h
As NM_SETTING_SECRET_FLAGS_ALL is used in libnm/nm-vpn-plugin-utils.c,
it is exposed as internal API and should be declared in
nm-core-internal.h.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-22 15:22:16 +02:00
Dan Winship 32c26a859b libnm-core: move some fake NMConnection methods over to NMSetting
nm_connection_lookup_setting_type() and
nm_connection_lookup_setting_type_by_quark() have nothing to do with
NMConnection. So move them to NMSetting (and rename them to
nm_setting_lookup_type() and nm_setting_lookup_type_by_quark()).
2014-08-16 10:17:53 -04:00
Dan Winship c81fb49aa5 all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).

Fix this by changing the include guards in the non-API-stable parts of
the tree:

  - libnm-glib/nm-ip4-config.h remains   NM_IP4_CONFIG_H
  - libnm/nm-ip4-config.h now uses     __NM_IP4_CONFIG_H__
  - src/nm-ip4-config.h now uses       __NETWORKMANAGER_IP4_CONFIG_H__

And likewise for all other headers.

The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-16 10:17:14 -04:00
Dan Winship d0b05b34d5 libnm: add NetworkManager.h, disallow including individual headers
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.)
2014-08-01 14:34:40 -04:00
Dan Winship 2fc55941a3 libnm: fix up class struct reserved slots
Add reserved slots to those classes that were missing them (or had run
out), and sync up the number of slots across classes:

  - 8 slots for "important" classes, abstract base classes, and
    classes we expect we might need to add new virtual methods or
    signals to later.

  - 4 for everything else

Also, rearrange the class elements in a few places into standard order
(signals first, then methods).
2014-08-01 14:34:40 -04:00
Dan Winship 054c12ea30 libnm: remove all deprecated functions and types
Remove deprecated functions and enum types.

For now, deprecated properties are still around, because removing them
would cause warnings when talking to older implementations.
2014-08-01 14:34:05 -04:00
Dan Winship d595f7843e libnm: add libnm/libnm-core (part 1)
This commit begins creating the new "libnm", which will replace
libnm-util and libnm-glib.

The main reason for the libnm-util/libnm-glib split is that the daemon
needs to link to libnm-util (to get NMSettings, NMConnection, etc),
but can't link to libnm-glib (because it uses many of the same type
names as the NetworkManager daemon. eg, NMDevice). So the daemon links
to only libnm-util, but basically all clients link to both.

With libnm, there will be only a single client-visible library, and
NetworkManager will internally link against a private "libnm-core"
containing the parts that used to be in libnm-util.

(The "libnm-core" parts still need to be in their own directory so
that the daemon can see those header files without also seeing the
ones in libnm/ that conflict with its own headers.)

[This commit just copies the source code from libnm-util/ to
libnm-core/, and libnm-glib/ to libnm/:

  mkdir -p libnm-core/tests/
  mkdir -p libnm/tests/
  cp libnm-util/*.[ch] libnm-util/nm-version.h.in libnm-core/
  rm -f libnm-core/nm-version.h libnm-core/nm-setting-template.[ch] libnm-core/nm-utils-enum-types.[ch]
  cp libnm-util/tests/*.[ch] libnm-core/tests/
  cp libnm-glib/*.[ch] libnm/
  rm -f libnm/libnm_glib.[ch] libnm/libnm-glib-test.c libnm/nm-glib-enum-types.[ch]
  cp libnm-glib/tests/*.[ch] libnm/tests/

]
2014-08-01 14:34:04 -04:00