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[@]}"
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
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>
- Remove list of authors from files that had them; these serve no
purpose except to quickly get out of date (and were only used in
libnm-util and not libnm-glib anyway).
- Just say "Copyright", not "(C) Copyright" or "Copyright (C)"
- Put copyright statement after the license, not before
- Remove "NetworkManager - Network link manager" from the few files
that contained it, and "libnm_glib -- Access network status &
information from glib applications" from the many files that
contained it.
- Remove vim modeline from nm-device-olpc-mesh.[ch], add emacs modeline
to files that were missing it.
This function behaves like verify(), but it also performs some
normalization/fixing of inconsistent connections.
Contrary to verify(), this function might modify the settings.
This will be mainly used, to repair connections from older versions
and to fix deprecated options.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Add versioned NM_DEPRECATED_IN_* and NM_AVAILABLE_IN_* macros, and tag
new/deprecated functions accordingly. (All currently-deprecated
functions are assumed to have been deprecated in 0.9.10.)
Add NM_VERSION_MIN_REQUIRED and NM_VERSION_MAX_ALLOWED macros which
can be set to determine which versions will cause warnings.
With the current settings, external consumers of the
libnm-util/libnm-glib APIs will have MIN_REQUIRED and MAX_ALLOWED both
set to NM_VERSION_0_9_8 by default, meaning they will get warnings
about functions added in 0.9.10. NM internally sets
NM_VERSION_MAX_ALLOWED to NM_VERSION_NEXT_STABLE to ensure that it is
always allowed to use all APIs.
This changes behaviour of nm_connection_update_secrets() in that it will
now return %TRUE, if there are no secrets to be cleared. Seems more
correct, to return success if there is nothing to do.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Often, nm_connection_clear_secrets does have no consequences, because
there is nothing to be cleared. Only raise a signal, if something
actually changed.
Signed-off-by: Thomas Haller <thaller@redhat.com>
INFERRABLE means the opposite of CANDIDATE; a property which NetworkManager
can read ("infer") from the system or the kernel when generating
connections. CANDIDATE isn't a great name and thus dies.
When NM was registering all of its enum types by hand, it was using
NamesLikeThis rather than the default names-like-this for the "nick"
values. When we switched to using glib-mkenums, this resulted in
dbus-glib using different strings for the D-Bus error names, causing
compatibility problems.
Fix this by using glib-mkenums annotations to manually fix all the
enum values back to what they were before. (This can't be done in a
more automated way, because the old names aren't 100% consistent. Eg,
"UNKNOWN" frequently becomes "UnknownError" rather than just
"Unknown".)
Rather than generating enum classes by hand (and complaining in each
file that "this should really be standard"), use glib-mkenums.
Unfortunately, we need a very new version of glib-mkenums in order to
deal with NM's naming conventions and to fix a few other bugs, so just
import that into the source tree temporarily.
Also, to simplify the use of glib-mkenums, import Makefile.glib from
https://bugzilla.gnome.org/654395.
To avoid having to run glib-mkenums for every subdirectory of src/,
add a new "generated" directory, and put the generated enums files
there.
Finally, use Makefile.glib for marshallers too, and generate separate
ones for libnm-glib and NetworkManager.
Some connection types such as bonding, bridging and VLAN require
specific virtual kernel interfaces identified by name to be auto
connected to the connection.
The function nm_connection_get_virtual_iface_name() returns the name
of the kernel interface if the connection type requires this
functionatlity.
Each connection base type settings class can implement the function
get_virtual_iface_name() if the connection needs to be auto connected
to a specific kernel interface.
Signed-off-by: Thomas Graf <tgraf@redhat.com>
What we want to do here is keep separate caches of system and
agent secrets. For system secrets, we cache them because NM
periodically clears secrets using nm_connection_clear_secrets() to
ensure they don't stay around in memory, and that transient secrets
get requested again when they are needed. For agent secrets, we
only want them during activation, but a connection read from disk
will not include agent secrets becuase by definition they aren't
stored in system settings along with the connection. Thus we need
to keep the agent/transient secrets somewhere for the duration of
the activation to ensure they don't get deleted.
This removes the copy-back hack in update_auth_cb() which copied
agent/transient secrets back into the connection over top of the
transient secrets that had been copied back in
nm_settings_connection_replace_settings(). No reason to copy
them twice if we keep an agent/transient secrets hash and do
the right thing with it.
It turns out we need a way to ignore transient (agent-owned or unsaved)
secrets during connection comparison. For example, if the user is
connecting to a network where the password is not saved, other
changes could trigger a writeout of that connection to disk when
connecting, which would the connection back in due to inotify, and the
re-read connection would then no longer be recognized as the same as
the in-memory connection due to the transient secret which obviously
wasn't read in from disk.
Adding these compare flags allows the code to not bother writing the
connection out to disk when the only difference between the on-disk
and in-memory connections are secrets that shouldn't get written to
disk anyway.
Not all connections will require every secret, and sometimes we
can't automatically figure out whether we need the secret. For
vpnc sometimes the group password isn't used, and sometimes PPP
providers require a username but don't want a password, etc.
Becuase there's only one 'flags' property for WEP keys (because it's pretty
dumb to have different flags for all 4 WEP keys) we need to do some tap dancing
with the secret name, so that requests for "wep-keyX" look up the "wep-key-flags"
property.
This allows the necessary flexibility when handling secrets; otherwise
it wouldn't be known when NM should save secrets returned from agents
to backing storage, or when the agents should store the secrets. We
can't simply use lack of a secret in persistent storage as the indicator
of this, as (for example) when creating a new connection without
secrets the storage method would be abmiguous.
At the same time, fold in "always ask" functionality for OTP tokens
so user agents don't have to store that attribute themselves out-of-band.
Simplifies code internally, and makes it easier for clients as well in
some cases where they want to control what ends up in the resulting
hash and what does not.
Patch from Tambet Ingo <tambet@gmail.com>
* libnm-util/nm-setting.c
libnm-util/nm-setting.h
- (NMSettingValueIterFn): instead of just a gboolean for secrets, take
all the GParamSpec flags of the property
* system-settings/plugins/keyfile/nm-keyfile-connection.c
system-settings/plugins/keyfile/reader.c
system-settings/plugins/keyfile/writer.c
- Update for NMSettingValueIterFn change
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4322 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Add a GError argument to nm_connection_verify() and nm_setting_verify(),
and add error enums to each NMSetting subclass. Each NMSetting subclass now
returns a descriptive GError when verification fails.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3751 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
* libnm-util/nm-connection.c
libnm-util/nm-connection.h
- (nm_connection_compare): accept compare flags and pass them to the
setting compare function
* libnm-util/nm-setting.c
libnm-util/nm-setting.h
- (nm_setting_compare): accept compare flags; ignore properties that are
marked fuzzy
* libnm-util/nm-setting-connection.c
libnm-util/nm-setting-wireless.c
libnm-util/nm-setting-ppp.c
libnm-util/nm-setting-wired.c
- Mark some setting properties as ignorable when doing a fuzzy compare
* src/nm-device.c
- (device_activation_precheck): use exact compare
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3336 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Fix vpn-properties setting update_secrets call for new NMSetting stuff.
Since the vpn-properties are managed and known by the VPN daemons themselves,
libnm-util doesn't know what's secret and what's in the setting's 'data'
member.
* libnm-util/nm-setting.h
libnm-util/nm-setting.c
- Add the ability for subclasses to override update_one_secret
* libnm-util/nm-setting-vpn-properties.c
- Override update_one_secret and just copy the values into the
internal table
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3078 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Rework NMSetting structures: Move each setting to it's own file.
Convert to GObject. Remove home grown setting types and use
GTypes.
Use GObject property introspection for hash conversion,
enumerating
properties, etc.
* libnm-util/nm-setting-connection.[ch]
* libnm-util/nm-setting-ip4-config.[ch]
* libnm-util/nm-setting-ppp.[ch]
* libnm-util/nm-setting-vpn.[ch]
* libnm-util/nm-setting-vpn-properties.[ch]
* libnm-util/nm-setting-wired.[ch]
* libnm-util/nm-setting-wireless.[ch]
* libnm-util/nm-setting-wireless-security.[ch]
New files, each containing a setting.
* libnm-util/nm-setting-template.[ch]: A template for creating
* new
settings. To use it, just replace 'template' with the new
setting
name, and you're half-way done.
* libnm-util/nm-setting.c: Convert to GObject and use GObject
introspection instead of internal types and tables.
* libnm-util/nm-connection.c: Adapt the new NMSetting work.
* libnm-util/nm-param-spec-specialized.[ch]: Implement. Handles
GValue types defined by dbus-glib for composed types like
collections,
structures and maps.
* src/*: The API of NMSetting and NMConnection changed a bit:
* Getting
a setting from connection takes the setting type now. Also,
since
the settings are in multiple files, include relevant settings.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3068 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Implement support for static IP addresses, additional/overridden
DNS and
DNS domain search lists.
* libnm-util/nm-setting.c (uint_array_to_gvalue): Implement.
(ip4_addresses_to_gvalue): Implement.
(convert_array_to_byte_array): Implement.
(nm_setting_populate_from_hash_default): Handle
NM_S_TYPE_UINT_ARRAY and
NM_S_TYPE_IP4_ADDRESSES.
(nm_setting_hash): Ditto.
(default_setting_clear_secrets): Add a default case for the
switch: IP address
shouldn't be secret, ever.
(setting_ip4_config_verify): Update, requires addresses in case
of manual
configurations.
(setting_ip4_config_destroy): Free stuff.
* src/nm-device.c (merge_ip4_config): Implement.
(real_act_stage4_get_ip4_config): Merge IP4 configuration from
NMConnection.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2996 4912f4e0-d625-0410-9fb7-b9a5a253dbdc