Commit graph

44 commits

Author SHA1 Message Date
Jiří Klimeš a751398785 libnm-glib: do not use deprecated Gtk-Doc Type: and Virtual: tags
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=744250
2018-03-26 12:46:22 +02:00
Lubomir Rintel 55ad538cfb libnm-glib/secret-agent: don't error out on missing out_connection
It's perfectly valid to call the function with out_connection == NULL
when connection_hash == NULL too, as cancel_get_secrets() does.

Fixes: fbb1662269
(cherry picked from commit c4a0002f05)
2017-04-13 14:45:58 +02:00
Thomas Haller a83eb773ce all: modify line separator comments to be 80 chars wide
sed 's#^/\*\{5\}\*\+/$#/*****************************************************************************/#' $(git grep -l '\*\{5\}' | grep '\.[hc]$') -i
2016-10-03 12:01:15 +02:00
Thomas Haller fbb1662269 libnm-glib: don't fail creating connection in NMSecretAgent
The connection should be created best-effort. If the connection doesn't
validate, the connection request still can be answered by the agent.
2016-03-29 11:56:27 +02:00
Thomas Haller cd4f84b738 all: don't include error->code in log messages
GError codes are only unique per domain, so logging the code without
also indicating the domain is not helpful. And anyway, if the error
messages are not distinctive enough to tell the whole story then we
should fix the error messages.

Based-on-patch-by: Dan Winship <danw@gnome.org>
2016-03-03 18:54:20 +01:00
Thomas Haller 01b9b4104c all: clean-up usage of GError
Functions that take a GError** MUST fill it in on error. There is no
need to check whether error is NULL if the function it was passed to
had a failing return value.

Likewise, a proper GError must have a non-NULL message, so there's no
need to double-check that either.

Based-on-patch-by: Dan Winship <danw@gnome.org>
2016-03-03 18:54:20 +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
Thomas Haller 19c3ea948a all: make use of new header file "nm-default.h" 2015-08-05 15:32:40 +02:00
Dan Winship ee707ba95a libnm-glib: drop private bus support
Anything that actually *needs* private bus support will be built
against libnm these days anyway.
2015-07-24 13:25:47 -04:00
Dan Winship 3452ee2a0e all: rename nm-glib-compat.h to nm-glib.h, use everywhere
Rather than randomly including one or more of <glib.h>,
<glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include
"nm-glib-compat.h" most of the time), rename nm-glib-compat.h to
nm-glib.h, include <gio/gio.h> from there, and then change all .c
files in NM to include "nm-glib.h" rather than including the glib
headers directly.

(Public headers files still have to include the real glib headers,
since nm-glib.h isn't installed...)

Also, remove glib includes from header files that are already
including a base object header file (which must itself already include
the glib headers).
2015-07-24 13:25:47 -04: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
Thomas Haller 86ffea8004 libnm: ensure auto-registration only when not yet registered
Calling nm_secret_agent_register() on an already registered
instance leads to a warning. Ensure to call register during
auto-registration only when needed.

https://bugzilla.gnome.org/show_bug.cgi?id=727923

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-27 08:52:25 +02:00
Dan Winship 2570c5a17c libnm-util, libnm-glib: whitespace fixes
Fix indentation, kill trailing whitespace, split some long lines.
2014-07-15 09:44:55 -04:00
Dan Winship cb7e1893e7 libnm-util, libnm-glib: standardize copyright/license headers
- 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.
2014-07-15 09:44:54 -04:00
Dan Winship aa1dce6da2 all: remove remaining GParamSpec name/blurb strings
Remove all remaining GParamSpec name and blurb strings (and fix
indentation while we're there), and add G_PARAM_STATIC_STRINGS to all
paramspecs that were lacking it.
2014-06-19 17:45:03 -04:00
Dan Williams e7dbe20526 libnm-glib: add support for agent capabilities during registration
Tries the new RegisterWithCapabilities method first, and falls back
to the old Register method for compatibility with older NetworkManager.
2013-07-31 08:16:40 -05:00
Dan Winship d529580cbb libnm-glib, core: use g_cclosure_marshal_generic
Since we depend on new glib now, we can just use the generic
marshaller rather than generating our own.
2013-05-08 14:59:29 -04:00
Martin Pitt d5fb24b5b5 libnm-glib: Make SecretAgent introspectable
Use the correct annotation for vfuncs, so that NMClient.SecretAgent becomes
introspectable.

Use "self" as the first argument of the vfuncs in their declarations, to match
the actual name in nm-secret-agent.c. This avoids warnings from g-ir-scanner.

https://bugzilla.gnome.org/show_bug.cgi?id=698184
2013-04-19 09:40:32 -04:00
Dan Williams 110a40358d libnm-glib: never call NM D-Bus methods if NM isn't running
Though the client shouldn't be calling anything when NM isn't running
(because clients have nm_client_get_manager_running()), make sure
that NMClient never calls a NetworkManager method when NM isn't
on the bus.

Next, ensure NMObject doesn't try to refresh properties when NM isn't
running.  Creating an NMClient may trigger a property refresh request,
but if NM isn't running, defer that until NM starts, to ensure that
we don't D-Bus autostart NM.

Third, ensure NMRemoteSettings doesn't attempt to list connections
unless NM is running.

This prevents service activation of NetworkManager in lieu of dbus-glib
learning about DBUS_HEADER_FLAG_NO_AUTO_START.
2013-04-08 11:30:32 -05:00
Dan Williams a87b5a15df libnm-glib: use private connection before trying the system bus
Use the D-Bus connection helper whenever we need a connection to
NM, which by default tries to use a private connection instead of
the shared bus connection whenever the user is root.  Doing this
by default will not change the behavior of libnm-glib, and allows
tools like nmcli and libnm-glib-using clients to work in minimal
environments (those without a bus daemon) by default.
2013-04-08 11:30:32 -05:00
Dan Williams 661d09852d libnm-glib: use helpers to create dbus proxies
When using a private connection, we need to use dbus_g_proxy_new_for_peer()
because the bus isn't involved.  Since many parts of libnm-glib create a
proxy for their corresponding remote object, consolidate the proxy creation
logic.

A later patch will add logic to use a private connection versus a bus-based
one.
2013-04-08 11:30:32 -05:00
Dan Winship 6f44b7f3c6 all: remove redundant return-if-fail checks
NM_IS_FOO(x) returns FALSE if x is NULL, so we don't need a separate
(x != NULL) check before it.
2013-03-07 07:32:27 -05:00
Dan Williams 8b7287ab66 core: fix agent secret cancelation
Two issues here: first, the daemon code was using the wrong D-Bus type
(strings instead of object-path) to send the connection path to the
secret agent, which resulted in a method-not-found error and nothing
happening in the agent.

Second, the agent-side method call verification code would fail the
request anyway, becuase verify_request() determined success based
on the reconstructed connection, which isn't given when canceling
secrets requests.
2012-12-04 11:31:12 -06:00
Dan Winship 6878d20ac4 all: Don't use ctype.h macros
The ctype macros (eg, isalnum(), tolower()) are locale-dependent. Use
glib's ASCII-only versions instead.

Also, replace isascii() with g_ascii_isprint(), since isascii()
accepts control characters, which isn't what the code wanted in any of
the places where it was using it.
2012-09-26 12:14:37 -04:00
Dan Williams 9c2c4e0591 libnm-glib: fix build on older glib without g_clear_object() 2012-04-27 15:04:29 -05:00
Dan Winship be18dd06cd libnm-glib: NULL out priv fields on dispose()
In some situations, objects might get used after being disposed, so
clear out their various priv fields so we don't try to access unreffed
objects, freed strings, etc.

https://bugzilla.gnome.org/show_bug.cgi?id=674473
2012-04-23 16:09:58 -04:00
Dan Williams 1da9738f1b libnm-glib: add 'registered' property for NMSecretAgent
So clients can track when the agent is actually registered and when
it's registration state changes.
2012-03-19 13:24:28 -05:00
Dan Winship 839eab5564 Use glib-mkenums to generate enum types
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.
2012-02-15 11:42:15 -05:00
Dan Williams 724df841a2 docs: update docs for NMSecretAgent callbacks 2012-01-26 12:21:27 -06:00
Dan Williams a7f7e80839 libnm-glib: fix introspection annotations for callbacks and user_data (rh #747302)
user_data arguments should be annotated with (closure) and callbacks
should be marked (allow none) where it's safe to pass NULL.
2011-10-26 10:33:38 -05:00
Dan Williams 4fca276e9a libnm-glib: automatically cancel secrets requests if NM goes away 2011-03-17 13:42:21 -05:00
Dan Williams 09b46bb269 libnm-glib: update some documentation 2011-03-10 11:55:09 -06:00
Dan Williams 02f676c001 libnm-glib: document secret agent request flags 2011-03-02 02:03:12 -06:00
Giovanni Campagna e77acd43b6 libnm-glib: more GObject introspection fixes (bgo #181415)
Fix some annotations and add the necessary ones for new functions.
2011-02-21 18:11:21 -06:00
Dan Williams 7ddf9c5e72 libnm-glib: implement NMSecretAgent autoregistration
Handles registering with NM and re-registering if NM restarts.
2011-01-19 16:59:01 -06:00
Dan Williams 9cf13cc3e1 agent: request_new -> flags
Use some flags to modify GetSecrets behavior instead of just the
request_new boolean.
2011-01-18 14:17:18 -06:00
Dan Williams cc88e4e51c trivial: fix a few small issues in the NMSecretAgent class 2011-01-18 13:21:02 -06:00
Dan Williams 30c7308e9d libnm-glib: implement agent secrets request cancelation 2011-01-18 13:20:34 -06:00
Dan Williams 61cc2494ad libnm-glib: add helper functions and callbacks to Secret Agent API
First, remove anything dbus-glib related from the public API and use
callbacks to handle returning secrets requested by D-Bus.  Second,
add helper functions so local code can use the same API to request
secrets.
2011-01-13 14:18:29 -06:00
Dan Williams 7779a3f151 libnm-glib: add NM_SECRET_AGENT_ERROR_NO_SECRETS 2011-01-13 13:43:26 -06:00
Dan Williams a3d4688431 libnm-glib: add NM_SECRET_AGENT_ERROR_INTERNAL_ERROR 2011-01-13 13:42:01 -06:00
Dan Williams 81bc9c8572 libnm-glib: allow the '.' character in agent identifiers 2010-12-14 11:19:19 -06:00
Dan Williams 84abb13554 libnm-glib: fix infinite loop checking agent identifier 2010-12-14 11:12:24 -06:00
Dan Williams 1496f8056f libnm-glib: add secret agent base class 2010-12-14 00:03:22 -06:00