diff options
Diffstat (limited to 'libnm-glib')
69 files changed, 7949 insertions, 4289 deletions
diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am index 165977cfa..08a61cc29 100644 --- a/libnm-glib/Makefile.am +++ b/libnm-glib/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS=. tests + INCLUDES = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/libnm-util \ @@ -10,25 +12,28 @@ BUILT_SOURCES = \ nm-device-ethernet-bindings.h \ nm-device-wifi-bindings.h \ nm-device-bt-bindings.h \ - nm-exported-connection-glue.h \ - nm-exported-connection-bindings.h \ - nm-settings-glue.h \ + nm-settings-connection-bindings.h \ + nm-device-wimax-bindings.h \ + nm-device-modem-bindings.h \ nm-settings-bindings.h \ - nm-settings-system-bindings.h \ nm-vpn-connection-bindings.h \ nm-vpn-plugin-glue.h \ nm-active-connection-bindings.h \ nm-ip4-config-bindings.h \ nm-dhcp4-config-bindings.h \ nm-ip6-config-bindings.h \ - nm-dhcp6-config-bindings.h + nm-dhcp6-config-bindings.h \ + nm-secret-agent-glue.h + + +noinst_LTLIBRARIES = \ + libdeprecated-nm-glib.la \ + libnm-glib-test.la ##################################################### # Deprecated original libnm_glib bits ##################################################### -noinst_LTLIBRARIES = libdeprecated-nm-glib.la - libdeprecated_nm_glib_la_SOURCES = \ libnm_glib.h \ libnm_glib.c @@ -43,6 +48,9 @@ libdeprecated_nm_glib_la_LIBADD = \ $(DBUS_LIBS) \ $(GLIB_LIBS) +libdeprecateddir = $(includedir)/libnm-glib +libdeprecated_HEADERS = libnm_glib.h + ##################################################### # Real libnm-glib stuff ##################################################### @@ -55,9 +63,9 @@ libnm_glib_la_CFLAGS = \ $(GUDEV_CFLAGS) libnmincludedir = $(includedir)/libnm-glib +libnmvpndir = $(includedir)/libnm-glib libnminclude_HEADERS = \ - libnm_glib.h \ nm-object.h \ nm-client.h \ nm-device.h \ @@ -66,60 +74,59 @@ libnminclude_HEADERS = \ nm-device-bt.h \ nm-access-point.h \ nm-ip4-config.h \ - nm-gsm-device.h \ - nm-cdma-device.h \ - nm-serial-device.h \ + nm-device-modem.h \ nm-vpn-connection.h \ - nm-vpn-plugin.h \ - nm-vpn-plugin-ui-interface.h \ nm-types.h \ nm-active-connection.h \ nm-dhcp4-config.h \ nm-ip6-config.h \ nm-dhcp6-config.h \ nm-remote-connection.h \ - nm-settings-interface.h \ - nm-settings-system-interface.h \ nm-remote-settings.h \ - nm-remote-settings-system.h \ - nm-settings-connection-interface.h \ - nm-exported-connection.h \ - nm-settings-service.h + nm-secret-agent.h \ + nm-device-wimax.h \ + nm-wimax-nsp.h -libnm_glib_la_SOURCES = \ +libnmvpn_HEADERS = \ + nm-vpn-plugin.h \ + nm-vpn-plugin-ui-interface.h \ + nm-vpn-plugin-utils.h + +libnm_glib_la_csources = \ nm-object.c \ - nm-object-private.h \ nm-client.c \ nm-dbus-utils.c \ - nm-dbus-utils.h \ nm-device.c \ - nm-device-private.h \ nm-device-ethernet.c \ nm-device-wifi.c \ nm-device-bt.c \ nm-access-point.c \ nm-ip4-config.c \ - nm-gsm-device.c \ - nm-cdma-device.c \ - nm-serial-device.c \ + nm-device-modem.c \ nm-vpn-connection.c \ nm-types.c \ - nm-types-private.h \ nm-object-cache.c \ - nm-object-cache.h \ nm-active-connection.c \ nm-dhcp4-config.c \ nm-ip6-config.c \ nm-dhcp6-config.c \ nm-remote-connection.c \ - nm-remote-connection-private.h \ - nm-settings-interface.c \ - nm-settings-system-interface.c \ nm-remote-settings.c \ - nm-remote-settings-system.c \ - nm-settings-connection-interface.c \ - nm-exported-connection.c \ - nm-settings-service.c + nm-secret-agent.c \ + nm-device-wimax.c \ + nm-wimax-nsp.c + +libnm_glib_la_private_headers = \ + nm-object-private.h \ + nm-dbus-utils.h \ + nm-device-private.h \ + nm-types-private.h \ + nm-object-cache.h \ + nm-remote-connection-private.h + +libnm_glib_la_SOURCES = \ + $(libnm_glib_la_csources) \ + $(libnm_glib_la_private_headers) libnm_glib_la_LIBADD = \ $(top_builddir)/libnm-util/libnm-util.la \ @@ -132,7 +139,7 @@ libnm_glib_la_LIBADD = \ SYMBOL_VIS_FILE=$(srcdir)/libnm-glib.ver libnm_glib_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \ - -version-info "6:3:4" + -version-info "5:0:1" noinst_PROGRAMS = libnm-glib-test @@ -141,14 +148,39 @@ libnm_glib_test_CFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS) libnm_glib_test_LDADD = libnm-glib.la $(top_builddir)/libnm-util/libnm-util.la $(GLIB_LIBS) $(DBUS_LIBS) -libnm_glib_vpn_la_SOURCES = nm-vpn-plugin.c nm-vpn-plugin-ui-interface.c +libnm_glib_vpn_la_SOURCES = \ + nm-vpn-plugin.c \ + nm-vpn-plugin-ui-interface.c \ + nm-vpn-plugin-utils.c libnm_glib_vpn_la_CFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS) libnm_glib_vpn_la_LIBADD = $(top_builddir)/libnm-util/libnm-util.la $(GLIB_LIBS) $(DBUS_LIBS) libnm_glib_vpn_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnm-glib-vpn.ver \ - -version-info "1:0:0" + -version-info "2:0:1" + +##################################################### +# Test libnm-glib stuff +##################################################### +libnm_glib_test_la_CFLAGS = \ + $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) \ + $(GUDEV_CFLAGS) \ + -DLIBNM_GLIB_TEST + +libnm_glib_test_la_SOURCES = \ + $(libnminclude_HEADERS) \ + $(libnm_glib_la_SOURCES) + +libnm_glib_test_la_LIBADD = \ + $(top_builddir)/libnm-util/libnm-util.la \ + $(top_builddir)/marshallers/libmarshallers.la \ + $(GLIB_LIBS) \ + $(DBUS_LIBS) \ + $(GUDEV_LIBS) + +##################################################### -nm-client-bindings.h: $(top_srcdir)/introspection/nm-manager-client.xml +nm-client-bindings.h: $(top_srcdir)/introspection/nm-manager.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_client --mode=glib-client --output=$@ $< nm-device-bindings.h: $(top_srcdir)/introspection/nm-device.xml @@ -166,20 +198,11 @@ nm-device-bt-bindings.h: $(top_srcdir)/introspection/nm-device-bt.xml nm-access-point-bindings.h: $(top_srcdir)/introspection/nm-access-point.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_access_point --mode=glib-client --output=$@ $< -nm-settings-glue.h: $(top_srcdir)/introspection/nm-settings.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-server --output=$@ $< - nm-settings-bindings.h: $(top_srcdir)/introspection/nm-settings.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-client --output=$@ $< -nm-settings-system-bindings.h: $(top_srcdir)/introspection/nm-settings-system.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings_system --mode=glib-client --output=$@ $< - -nm-exported-connection-glue.h: $(top_srcdir)/introspection/nm-exported-connection.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_exported_connection --mode=glib-server --output=$@ $< - -nm-exported-connection-bindings.h: $(top_srcdir)/introspection/nm-exported-connection.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_exported_connection --mode=glib-client --output=$@ $< +nm-settings-connection-bindings.h: $(top_srcdir)/introspection/nm-settings-connection.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings_connection --mode=glib-client --output=$@ $< nm-vpn-connection-bindings.h: $(top_srcdir)/introspection/nm-vpn-connection.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection --mode=glib-client --output=$@ $< @@ -202,6 +225,15 @@ nm-ip6-config-bindings.h: $(top_srcdir)/introspection/nm-ip6-config.xml nm-dhcp6-config-bindings.h: $(top_srcdir)/introspection/nm-dhcp6-config.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_dhcp6_config --mode=glib-client --output=$@ $< +nm-secret-agent-glue.h: $(top_srcdir)/introspection/nm-secret-agent.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_secret_agent --mode=glib-server --output=$@ $< + +nm-device-wimax-bindings.h: $(top_srcdir)/introspection/nm-device-wimax.xml + dbus-binding-tool --prefix=nm_device_wimax --mode=glib-client --output=$@ $< + +nm-device-modem-bindings.h: $(top_srcdir)/introspection/nm-device-modem.xml + dbus-binding-tool --prefix=nm_device_modem --mode=glib-client --output=$@ $< + pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libnm-glib.pc libnm-glib-vpn.pc @@ -209,7 +241,32 @@ DISTCLEANFILES = libnm-glib.pc libnm-glib.pc EXTRA_DIST = libnm-glib.pc.in libnm-glib-vpn.pc.in libnm-glib.ver libnm-glib-vpn.ver -CLEANFILES = $(BUILT_SOURCES) +CLEANFILES = $(BUILT_SOURCES) *-bindings.h *-glue.h + +-include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_COMPILER_ARGS = --includedir=$(top_builddir)/libnm-util + +if HAVE_INTROSPECTION +introspection_sources = $(libnminclude_HEADERS) $(libnm_glib_la_csources) + +NMClient-1.0.gir: libnm-glib.la +NMClient_1_0_gir_INCLUDES = GObject-2.0 DBusGLib-1.0 +NMClient_1_0_gir_PACKAGES = gobject-2.0 dbus-glib-1 gudev-1.0 +NMClient_1_0_gir_CFLAGS = $(INCLUDES) -I$(top_srcdir)/libnm-glib -I$(top_srcdir)/libnm-util +NMClient_1_0_gir_LIBS = libnm-glib.la +NMClient_1_0_gir_FILES = $(introspection_sources) +NMClient_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=NM --symbol-prefix=nm_ --include-uninstalled=$(top_builddir)/libnm-util/NetworkManager-1.0.gir +INTROSPECTION_GIRS += NMClient-1.0.gir + +girdir = $(datadir)/gir-1.0 +gir_DATA = $(INTROSPECTION_GIRS) + +typelibdir = $(libdir)/girepository-1.0 +typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) + +CLEANFILES += $(gir_DATA) $(typelib_DATA) +endif if WITH_TESTS diff --git a/libnm-glib/Makefile.in b/libnm-glib/Makefile.in index be259d7e7..01bbaf36b 100644 --- a/libnm-glib/Makefile.in +++ b/libnm-glib/Makefile.in @@ -38,17 +38,25 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ noinst_PROGRAMS = libnm-glib-test$(EXEEXT) +@HAVE_INTROSPECTION_TRUE@am__append_1 = NMClient-1.0.gir +@HAVE_INTROSPECTION_TRUE@am__append_2 = $(gir_DATA) $(typelib_DATA) subdir = libnm-glib -DIST_COMMON = $(libnminclude_HEADERS) $(srcdir)/Makefile.am \ +DIST_COMMON = $(libdeprecated_HEADERS) $(libnminclude_HEADERS) \ + $(libnmvpn_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/libnm-glib-vpn.pc.in \ $(srcdir)/libnm-glib.pc.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/libnl-check.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/introspection.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnl-check.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -76,8 +84,10 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" \ - "$(DESTDIR)$(libnmincludedir)" +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(girdir)" \ + "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(typelibdir)" \ + "$(DESTDIR)$(libdeprecateddir)" "$(DESTDIR)$(libnmincludedir)" \ + "$(DESTDIR)$(libnmvpndir)" LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = libdeprecated_nm_glib_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ @@ -89,11 +99,47 @@ libdeprecated_nm_glib_la_OBJECTS = \ AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent +libnm_glib_test_la_DEPENDENCIES = \ + $(top_builddir)/libnm-util/libnm-util.la \ + $(top_builddir)/marshallers/libmarshallers.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am__objects_1 = +am__objects_2 = libnm_glib_test_la-nm-object.lo \ + libnm_glib_test_la-nm-client.lo \ + libnm_glib_test_la-nm-dbus-utils.lo \ + libnm_glib_test_la-nm-device.lo \ + libnm_glib_test_la-nm-device-ethernet.lo \ + libnm_glib_test_la-nm-device-wifi.lo \ + libnm_glib_test_la-nm-device-bt.lo \ + libnm_glib_test_la-nm-access-point.lo \ + libnm_glib_test_la-nm-ip4-config.lo \ + libnm_glib_test_la-nm-device-modem.lo \ + libnm_glib_test_la-nm-vpn-connection.lo \ + libnm_glib_test_la-nm-types.lo \ + libnm_glib_test_la-nm-object-cache.lo \ + libnm_glib_test_la-nm-active-connection.lo \ + libnm_glib_test_la-nm-dhcp4-config.lo \ + libnm_glib_test_la-nm-ip6-config.lo \ + libnm_glib_test_la-nm-dhcp6-config.lo \ + libnm_glib_test_la-nm-remote-connection.lo \ + libnm_glib_test_la-nm-remote-settings.lo \ + libnm_glib_test_la-nm-secret-agent.lo \ + libnm_glib_test_la-nm-device-wimax.lo \ + libnm_glib_test_la-nm-wimax-nsp.lo +am__objects_3 = $(am__objects_2) $(am__objects_1) +am_libnm_glib_test_la_OBJECTS = $(am__objects_1) $(am__objects_3) +libnm_glib_test_la_OBJECTS = $(am_libnm_glib_test_la_OBJECTS) +libnm_glib_test_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(libnm_glib_test_la_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ libnm_glib_vpn_la_DEPENDENCIES = \ $(top_builddir)/libnm-util/libnm-util.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am_libnm_glib_vpn_la_OBJECTS = libnm_glib_vpn_la-nm-vpn-plugin.lo \ - libnm_glib_vpn_la-nm-vpn-plugin-ui-interface.lo + libnm_glib_vpn_la-nm-vpn-plugin-ui-interface.lo \ + libnm_glib_vpn_la-nm-vpn-plugin-utils.lo libnm_glib_vpn_la_OBJECTS = $(am_libnm_glib_vpn_la_OBJECTS) libnm_glib_vpn_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ @@ -103,14 +149,13 @@ libnm_glib_la_DEPENDENCIES = $(top_builddir)/libnm-util/libnm-util.la \ $(top_builddir)/marshallers/libmarshallers.la \ $(builddir)/libdeprecated-nm-glib.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -am_libnm_glib_la_OBJECTS = libnm_glib_la-nm-object.lo \ - libnm_glib_la-nm-client.lo libnm_glib_la-nm-dbus-utils.lo \ - libnm_glib_la-nm-device.lo libnm_glib_la-nm-device-ethernet.lo \ +am__objects_4 = libnm_glib_la-nm-object.lo libnm_glib_la-nm-client.lo \ + libnm_glib_la-nm-dbus-utils.lo libnm_glib_la-nm-device.lo \ + libnm_glib_la-nm-device-ethernet.lo \ libnm_glib_la-nm-device-wifi.lo libnm_glib_la-nm-device-bt.lo \ libnm_glib_la-nm-access-point.lo \ - libnm_glib_la-nm-ip4-config.lo libnm_glib_la-nm-gsm-device.lo \ - libnm_glib_la-nm-cdma-device.lo \ - libnm_glib_la-nm-serial-device.lo \ + libnm_glib_la-nm-ip4-config.lo \ + libnm_glib_la-nm-device-modem.lo \ libnm_glib_la-nm-vpn-connection.lo libnm_glib_la-nm-types.lo \ libnm_glib_la-nm-object-cache.lo \ libnm_glib_la-nm-active-connection.lo \ @@ -118,13 +163,10 @@ am_libnm_glib_la_OBJECTS = libnm_glib_la-nm-object.lo \ libnm_glib_la-nm-ip6-config.lo \ libnm_glib_la-nm-dhcp6-config.lo \ libnm_glib_la-nm-remote-connection.lo \ - libnm_glib_la-nm-settings-interface.lo \ - libnm_glib_la-nm-settings-system-interface.lo \ libnm_glib_la-nm-remote-settings.lo \ - libnm_glib_la-nm-remote-settings-system.lo \ - libnm_glib_la-nm-settings-connection-interface.lo \ - libnm_glib_la-nm-exported-connection.lo \ - libnm_glib_la-nm-settings-service.lo + libnm_glib_la-nm-secret-agent.lo \ + libnm_glib_la-nm-device-wimax.lo libnm_glib_la-nm-wimax-nsp.lo +am_libnm_glib_la_OBJECTS = $(am__objects_4) $(am__objects_1) libnm_glib_la_OBJECTS = $(am_libnm_glib_la_OBJECTS) libnm_glib_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libnm_glib_la_CFLAGS) \ @@ -141,7 +183,7 @@ libnm_glib_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(libnm_glib_test_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/depcomp +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ @@ -167,18 +209,56 @@ AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libdeprecated_nm_glib_la_SOURCES) \ - $(libnm_glib_vpn_la_SOURCES) $(libnm_glib_la_SOURCES) \ - $(libnm_glib_test_SOURCES) + $(libnm_glib_test_la_SOURCES) $(libnm_glib_vpn_la_SOURCES) \ + $(libnm_glib_la_SOURCES) $(libnm_glib_test_SOURCES) DIST_SOURCES = $(libdeprecated_nm_glib_la_SOURCES) \ - $(libnm_glib_vpn_la_SOURCES) $(libnm_glib_la_SOURCES) \ - $(libnm_glib_test_SOURCES) -DATA = $(pkgconfig_DATA) -HEADERS = $(libnminclude_HEADERS) + $(libnm_glib_test_la_SOURCES) $(libnm_glib_vpn_la_SOURCES) \ + $(libnm_glib_la_SOURCES) $(libnm_glib_test_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +DATA = $(gir_DATA) $(pkgconfig_DATA) $(typelib_DATA) +HEADERS = $(libdeprecated_HEADERS) $(libnminclude_HEADERS) \ + $(libnmvpn_HEADERS) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir ETAGS = etags CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" ACLOCAL = @ACLOCAL@ -ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ ALL_LINGUAS = @ALL_LINGUAS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ @@ -187,8 +267,6 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ -CATALOGS = @CATALOGS@ -CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -205,6 +283,7 @@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCLIENT_VERSION = @DHCLIENT_VERSION@ DHCPCD_PATH = @DHCPCD_PATH@ DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ +DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -213,6 +292,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ @@ -221,8 +301,8 @@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ GLIB_LIBS = @GLIB_LIBS@ GMODULE_CFLAGS = @GMODULE_CFLAGS@ GMODULE_LIBS = @GMODULE_LIBS@ -GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ @@ -237,13 +317,23 @@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INSTOBJEXT = @INSTOBJEXT@ INTLLIBS = @INTLLIBS@ INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ INTLTOOL_MERGE = @INTLTOOL_MERGE@ INTLTOOL_PERL = @INTLTOOL_PERL@ INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ +INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ +INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ +INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ +INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ +INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ +INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ +INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ +IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ +IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LD = @LD@ LDFLAGS = @LDFLAGS@ @@ -251,6 +341,8 @@ LIBDL = @LIBDL@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ LIBM = @LIBM@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ @@ -259,13 +351,15 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ -MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ -MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ @@ -291,12 +385,9 @@ PKGCONFIG_PATH = @PKGCONFIG_PATH@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POFILES = @POFILES@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ -PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ -PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ @@ -311,10 +402,13 @@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ VERSION = @VERSION@ XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -363,6 +457,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +SUBDIRS = . tests INCLUDES = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/libnm-util \ @@ -375,24 +470,27 @@ BUILT_SOURCES = \ nm-device-ethernet-bindings.h \ nm-device-wifi-bindings.h \ nm-device-bt-bindings.h \ - nm-exported-connection-glue.h \ - nm-exported-connection-bindings.h \ - nm-settings-glue.h \ + nm-settings-connection-bindings.h \ + nm-device-wimax-bindings.h \ + nm-device-modem-bindings.h \ nm-settings-bindings.h \ - nm-settings-system-bindings.h \ nm-vpn-connection-bindings.h \ nm-vpn-plugin-glue.h \ nm-active-connection-bindings.h \ nm-ip4-config-bindings.h \ nm-dhcp4-config-bindings.h \ nm-ip6-config-bindings.h \ - nm-dhcp6-config-bindings.h + nm-dhcp6-config-bindings.h \ + nm-secret-agent-glue.h + +noinst_LTLIBRARIES = \ + libdeprecated-nm-glib.la \ + libnm-glib-test.la ##################################################### # Deprecated original libnm_glib bits ##################################################### -noinst_LTLIBRARIES = libdeprecated-nm-glib.la libdeprecated_nm_glib_la_SOURCES = \ libnm_glib.h \ libnm_glib.c @@ -407,6 +505,8 @@ libdeprecated_nm_glib_la_LIBADD = \ $(DBUS_LIBS) \ $(GLIB_LIBS) +libdeprecateddir = $(includedir)/libnm-glib +libdeprecated_HEADERS = libnm_glib.h ##################################################### # Real libnm-glib stuff @@ -418,8 +518,8 @@ libnm_glib_la_CFLAGS = \ $(GUDEV_CFLAGS) libnmincludedir = $(includedir)/libnm-glib +libnmvpndir = $(includedir)/libnm-glib libnminclude_HEADERS = \ - libnm_glib.h \ nm-object.h \ nm-client.h \ nm-device.h \ @@ -428,60 +528,59 @@ libnminclude_HEADERS = \ nm-device-bt.h \ nm-access-point.h \ nm-ip4-config.h \ - nm-gsm-device.h \ - nm-cdma-device.h \ - nm-serial-device.h \ + nm-device-modem.h \ nm-vpn-connection.h \ - nm-vpn-plugin.h \ - nm-vpn-plugin-ui-interface.h \ nm-types.h \ nm-active-connection.h \ nm-dhcp4-config.h \ nm-ip6-config.h \ nm-dhcp6-config.h \ nm-remote-connection.h \ - nm-settings-interface.h \ - nm-settings-system-interface.h \ nm-remote-settings.h \ - nm-remote-settings-system.h \ - nm-settings-connection-interface.h \ - nm-exported-connection.h \ - nm-settings-service.h + nm-secret-agent.h \ + nm-device-wimax.h \ + nm-wimax-nsp.h -libnm_glib_la_SOURCES = \ +libnmvpn_HEADERS = \ + nm-vpn-plugin.h \ + nm-vpn-plugin-ui-interface.h \ + nm-vpn-plugin-utils.h + +libnm_glib_la_csources = \ nm-object.c \ - nm-object-private.h \ nm-client.c \ nm-dbus-utils.c \ - nm-dbus-utils.h \ nm-device.c \ - nm-device-private.h \ nm-device-ethernet.c \ nm-device-wifi.c \ nm-device-bt.c \ nm-access-point.c \ nm-ip4-config.c \ - nm-gsm-device.c \ - nm-cdma-device.c \ - nm-serial-device.c \ + nm-device-modem.c \ nm-vpn-connection.c \ nm-types.c \ - nm-types-private.h \ nm-object-cache.c \ - nm-object-cache.h \ nm-active-connection.c \ nm-dhcp4-config.c \ nm-ip6-config.c \ nm-dhcp6-config.c \ nm-remote-connection.c \ - nm-remote-connection-private.h \ - nm-settings-interface.c \ - nm-settings-system-interface.c \ nm-remote-settings.c \ - nm-remote-settings-system.c \ - nm-settings-connection-interface.c \ - nm-exported-connection.c \ - nm-settings-service.c + nm-secret-agent.c \ + nm-device-wimax.c \ + nm-wimax-nsp.c + +libnm_glib_la_private_headers = \ + nm-object-private.h \ + nm-dbus-utils.h \ + nm-device-private.h \ + nm-types-private.h \ + nm-object-cache.h \ + nm-remote-connection-private.h + +libnm_glib_la_SOURCES = \ + $(libnm_glib_la_csources) \ + $(libnm_glib_la_private_headers) libnm_glib_la_LIBADD = \ $(top_builddir)/libnm-util/libnm-util.la \ @@ -493,24 +592,62 @@ libnm_glib_la_LIBADD = \ SYMBOL_VIS_FILE = $(srcdir)/libnm-glib.ver libnm_glib_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \ - -version-info "6:3:4" + -version-info "5:0:1" libnm_glib_test_SOURCES = libnm-glib-test.c libnm_glib_test_CFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS) libnm_glib_test_LDADD = libnm-glib.la $(top_builddir)/libnm-util/libnm-util.la $(GLIB_LIBS) $(DBUS_LIBS) -libnm_glib_vpn_la_SOURCES = nm-vpn-plugin.c nm-vpn-plugin-ui-interface.c +libnm_glib_vpn_la_SOURCES = \ + nm-vpn-plugin.c \ + nm-vpn-plugin-ui-interface.c \ + nm-vpn-plugin-utils.c + libnm_glib_vpn_la_CFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS) libnm_glib_vpn_la_LIBADD = $(top_builddir)/libnm-util/libnm-util.la $(GLIB_LIBS) $(DBUS_LIBS) libnm_glib_vpn_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnm-glib-vpn.ver \ - -version-info "1:0:0" + -version-info "2:0:1" + + +##################################################### +# Test libnm-glib stuff +##################################################### +libnm_glib_test_la_CFLAGS = \ + $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) \ + $(GUDEV_CFLAGS) \ + -DLIBNM_GLIB_TEST + +libnm_glib_test_la_SOURCES = \ + $(libnminclude_HEADERS) \ + $(libnm_glib_la_SOURCES) + +libnm_glib_test_la_LIBADD = \ + $(top_builddir)/libnm-util/libnm-util.la \ + $(top_builddir)/marshallers/libmarshallers.la \ + $(GLIB_LIBS) \ + $(DBUS_LIBS) \ + $(GUDEV_LIBS) pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libnm-glib.pc libnm-glib-vpn.pc DISTCLEANFILES = libnm-glib.pc libnm-glib.pc EXTRA_DIST = libnm-glib.pc.in libnm-glib-vpn.pc.in libnm-glib.ver libnm-glib-vpn.ver -CLEANFILES = $(BUILT_SOURCES) +CLEANFILES = $(BUILT_SOURCES) *-bindings.h *-glue.h $(am__append_2) +INTROSPECTION_GIRS = $(am__append_1) +INTROSPECTION_COMPILER_ARGS = --includedir=$(top_builddir)/libnm-util +@HAVE_INTROSPECTION_TRUE@introspection_sources = $(libnminclude_HEADERS) $(libnm_glib_la_csources) +@HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_INCLUDES = GObject-2.0 DBusGLib-1.0 +@HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_PACKAGES = gobject-2.0 dbus-glib-1 gudev-1.0 +@HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_CFLAGS = $(INCLUDES) -I$(top_srcdir)/libnm-glib -I$(top_srcdir)/libnm-util +@HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_LIBS = libnm-glib.la +@HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_FILES = $(introspection_sources) +@HAVE_INTROSPECTION_TRUE@NMClient_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=NM --symbol-prefix=nm_ --include-uninstalled=$(top_builddir)/libnm-util/NetworkManager-1.0.gir +@HAVE_INTROSPECTION_TRUE@girdir = $(datadir)/gir-1.0 +@HAVE_INTROSPECTION_TRUE@gir_DATA = $(INTROSPECTION_GIRS) +@HAVE_INTROSPECTION_TRUE@typelibdir = $(libdir)/girepository-1.0 +@HAVE_INTROSPECTION_TRUE@typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-am + $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj @@ -590,6 +727,8 @@ clean-noinstLTLIBRARIES: done libdeprecated-nm-glib.la: $(libdeprecated_nm_glib_la_OBJECTS) $(libdeprecated_nm_glib_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libdeprecated_nm_glib_la_OBJECTS) $(libdeprecated_nm_glib_la_LIBADD) $(LIBS) +libnm-glib-test.la: $(libnm_glib_test_la_OBJECTS) $(libnm_glib_test_la_DEPENDENCIES) + $(AM_V_CCLD)$(libnm_glib_test_la_LINK) $(libnm_glib_test_la_OBJECTS) $(libnm_glib_test_la_LIBADD) $(LIBS) libnm-glib-vpn.la: $(libnm_glib_vpn_la_OBJECTS) $(libnm_glib_vpn_la_DEPENDENCIES) $(AM_V_CCLD)$(libnm_glib_vpn_la_LINK) -rpath $(libdir) $(libnm_glib_vpn_la_OBJECTS) $(libnm_glib_vpn_la_LIBADD) $(LIBS) libnm-glib.la: $(libnm_glib_la_OBJECTS) $(libnm_glib_la_DEPENDENCIES) @@ -616,33 +755,51 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdeprecated_nm_glib_la-libnm_glib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-access-point.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-active-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-cdma-device.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-client.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-dbus-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-device-bt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-device-ethernet.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-device-modem.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-device-wifi.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-device-wimax.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-device.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-dhcp4-config.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-dhcp6-config.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-exported-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-gsm-device.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-ip4-config.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-ip6-config.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-object-cache.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-object.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-remote-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-remote-settings-system.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-remote-settings.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-serial-device.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-settings-connection-interface.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-settings-interface.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-settings-service.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-settings-system-interface.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-secret-agent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-types.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-vpn-connection.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_la-nm-wimax-nsp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test-libnm-glib-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-access-point.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-active-connection.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-client.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-dbus-utils.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-device-bt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-device-ethernet.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-device-modem.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-device-wifi.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-device-wimax.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-device.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-dhcp4-config.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-dhcp6-config.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-ip4-config.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-ip6-config.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-object-cache.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-object.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-remote-connection.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-remote-settings.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-secret-agent.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-types.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-vpn-connection.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_test_la-nm-wimax-nsp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_vpn_la-nm-vpn-plugin-ui-interface.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_vpn_la-nm-vpn-plugin-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_glib_vpn_la-nm-vpn-plugin.Plo@am__quote@ .c.o: @@ -680,6 +837,182 @@ libdeprecated_nm_glib_la-libnm_glib.lo: libnm_glib.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdeprecated_nm_glib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdeprecated_nm_glib_la-libnm_glib.lo `test -f 'libnm_glib.c' || echo '$(srcdir)/'`libnm_glib.c +libnm_glib_test_la-nm-object.lo: nm-object.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-object.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-object.Tpo -c -o libnm_glib_test_la-nm-object.lo `test -f 'nm-object.c' || echo '$(srcdir)/'`nm-object.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-object.Tpo $(DEPDIR)/libnm_glib_test_la-nm-object.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-object.c' object='libnm_glib_test_la-nm-object.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-object.lo `test -f 'nm-object.c' || echo '$(srcdir)/'`nm-object.c + +libnm_glib_test_la-nm-client.lo: nm-client.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-client.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-client.Tpo -c -o libnm_glib_test_la-nm-client.lo `test -f 'nm-client.c' || echo '$(srcdir)/'`nm-client.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-client.Tpo $(DEPDIR)/libnm_glib_test_la-nm-client.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-client.c' object='libnm_glib_test_la-nm-client.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-client.lo `test -f 'nm-client.c' || echo '$(srcdir)/'`nm-client.c + +libnm_glib_test_la-nm-dbus-utils.lo: nm-dbus-utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-dbus-utils.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-dbus-utils.Tpo -c -o libnm_glib_test_la-nm-dbus-utils.lo `test -f 'nm-dbus-utils.c' || echo '$(srcdir)/'`nm-dbus-utils.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-dbus-utils.Tpo $(DEPDIR)/libnm_glib_test_la-nm-dbus-utils.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-dbus-utils.c' object='libnm_glib_test_la-nm-dbus-utils.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-dbus-utils.lo `test -f 'nm-dbus-utils.c' || echo '$(srcdir)/'`nm-dbus-utils.c + +libnm_glib_test_la-nm-device.lo: nm-device.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-device.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-device.Tpo -c -o libnm_glib_test_la-nm-device.lo `test -f 'nm-device.c' || echo '$(srcdir)/'`nm-device.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-device.Tpo $(DEPDIR)/libnm_glib_test_la-nm-device.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-device.c' object='libnm_glib_test_la-nm-device.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-device.lo `test -f 'nm-device.c' || echo '$(srcdir)/'`nm-device.c + +libnm_glib_test_la-nm-device-ethernet.lo: nm-device-ethernet.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-device-ethernet.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-device-ethernet.Tpo -c -o libnm_glib_test_la-nm-device-ethernet.lo `test -f 'nm-device-ethernet.c' || echo '$(srcdir)/'`nm-device-ethernet.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-device-ethernet.Tpo $(DEPDIR)/libnm_glib_test_la-nm-device-ethernet.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-device-ethernet.c' object='libnm_glib_test_la-nm-device-ethernet.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-device-ethernet.lo `test -f 'nm-device-ethernet.c' || echo '$(srcdir)/'`nm-device-ethernet.c + +libnm_glib_test_la-nm-device-wifi.lo: nm-device-wifi.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-device-wifi.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-device-wifi.Tpo -c -o libnm_glib_test_la-nm-device-wifi.lo `test -f 'nm-device-wifi.c' || echo '$(srcdir)/'`nm-device-wifi.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-device-wifi.Tpo $(DEPDIR)/libnm_glib_test_la-nm-device-wifi.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-device-wifi.c' object='libnm_glib_test_la-nm-device-wifi.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-device-wifi.lo `test -f 'nm-device-wifi.c' || echo '$(srcdir)/'`nm-device-wifi.c + +libnm_glib_test_la-nm-device-bt.lo: nm-device-bt.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-device-bt.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-device-bt.Tpo -c -o libnm_glib_test_la-nm-device-bt.lo `test -f 'nm-device-bt.c' || echo '$(srcdir)/'`nm-device-bt.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-device-bt.Tpo $(DEPDIR)/libnm_glib_test_la-nm-device-bt.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-device-bt.c' object='libnm_glib_test_la-nm-device-bt.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-device-bt.lo `test -f 'nm-device-bt.c' || echo '$(srcdir)/'`nm-device-bt.c + +libnm_glib_test_la-nm-access-point.lo: nm-access-point.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-access-point.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-access-point.Tpo -c -o libnm_glib_test_la-nm-access-point.lo `test -f 'nm-access-point.c' || echo '$(srcdir)/'`nm-access-point.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-access-point.Tpo $(DEPDIR)/libnm_glib_test_la-nm-access-point.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-access-point.c' object='libnm_glib_test_la-nm-access-point.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-access-point.lo `test -f 'nm-access-point.c' || echo '$(srcdir)/'`nm-access-point.c + +libnm_glib_test_la-nm-ip4-config.lo: nm-ip4-config.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-ip4-config.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-ip4-config.Tpo -c -o libnm_glib_test_la-nm-ip4-config.lo `test -f 'nm-ip4-config.c' || echo '$(srcdir)/'`nm-ip4-config.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-ip4-config.Tpo $(DEPDIR)/libnm_glib_test_la-nm-ip4-config.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-ip4-config.c' object='libnm_glib_test_la-nm-ip4-config.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-ip4-config.lo `test -f 'nm-ip4-config.c' || echo '$(srcdir)/'`nm-ip4-config.c + +libnm_glib_test_la-nm-device-modem.lo: nm-device-modem.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-device-modem.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-device-modem.Tpo -c -o libnm_glib_test_la-nm-device-modem.lo `test -f 'nm-device-modem.c' || echo '$(srcdir)/'`nm-device-modem.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-device-modem.Tpo $(DEPDIR)/libnm_glib_test_la-nm-device-modem.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-device-modem.c' object='libnm_glib_test_la-nm-device-modem.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-device-modem.lo `test -f 'nm-device-modem.c' || echo '$(srcdir)/'`nm-device-modem.c + +libnm_glib_test_la-nm-vpn-connection.lo: nm-vpn-connection.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-vpn-connection.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-vpn-connection.Tpo -c -o libnm_glib_test_la-nm-vpn-connection.lo `test -f 'nm-vpn-connection.c' || echo '$(srcdir)/'`nm-vpn-connection.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-vpn-connection.Tpo $(DEPDIR)/libnm_glib_test_la-nm-vpn-connection.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-vpn-connection.c' object='libnm_glib_test_la-nm-vpn-connection.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-vpn-connection.lo `test -f 'nm-vpn-connection.c' || echo '$(srcdir)/'`nm-vpn-connection.c + +libnm_glib_test_la-nm-types.lo: nm-types.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-types.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-types.Tpo -c -o libnm_glib_test_la-nm-types.lo `test -f 'nm-types.c' || echo '$(srcdir)/'`nm-types.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-types.Tpo $(DEPDIR)/libnm_glib_test_la-nm-types.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-types.c' object='libnm_glib_test_la-nm-types.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-types.lo `test -f 'nm-types.c' || echo '$(srcdir)/'`nm-types.c + +libnm_glib_test_la-nm-object-cache.lo: nm-object-cache.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-object-cache.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-object-cache.Tpo -c -o libnm_glib_test_la-nm-object-cache.lo `test -f 'nm-object-cache.c' || echo '$(srcdir)/'`nm-object-cache.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-object-cache.Tpo $(DEPDIR)/libnm_glib_test_la-nm-object-cache.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-object-cache.c' object='libnm_glib_test_la-nm-object-cache.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-object-cache.lo `test -f 'nm-object-cache.c' || echo '$(srcdir)/'`nm-object-cache.c + +libnm_glib_test_la-nm-active-connection.lo: nm-active-connection.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-active-connection.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-active-connection.Tpo -c -o libnm_glib_test_la-nm-active-connection.lo `test -f 'nm-active-connection.c' || echo '$(srcdir)/'`nm-active-connection.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-active-connection.Tpo $(DEPDIR)/libnm_glib_test_la-nm-active-connection.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-active-connection.c' object='libnm_glib_test_la-nm-active-connection.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-active-connection.lo `test -f 'nm-active-connection.c' || echo '$(srcdir)/'`nm-active-connection.c + +libnm_glib_test_la-nm-dhcp4-config.lo: nm-dhcp4-config.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-dhcp4-config.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-dhcp4-config.Tpo -c -o libnm_glib_test_la-nm-dhcp4-config.lo `test -f 'nm-dhcp4-config.c' || echo '$(srcdir)/'`nm-dhcp4-config.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-dhcp4-config.Tpo $(DEPDIR)/libnm_glib_test_la-nm-dhcp4-config.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-dhcp4-config.c' object='libnm_glib_test_la-nm-dhcp4-config.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-dhcp4-config.lo `test -f 'nm-dhcp4-config.c' || echo '$(srcdir)/'`nm-dhcp4-config.c + +libnm_glib_test_la-nm-ip6-config.lo: nm-ip6-config.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-ip6-config.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-ip6-config.Tpo -c -o libnm_glib_test_la-nm-ip6-config.lo `test -f 'nm-ip6-config.c' || echo '$(srcdir)/'`nm-ip6-config.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-ip6-config.Tpo $(DEPDIR)/libnm_glib_test_la-nm-ip6-config.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-ip6-config.c' object='libnm_glib_test_la-nm-ip6-config.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-ip6-config.lo `test -f 'nm-ip6-config.c' || echo '$(srcdir)/'`nm-ip6-config.c + +libnm_glib_test_la-nm-dhcp6-config.lo: nm-dhcp6-config.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-dhcp6-config.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-dhcp6-config.Tpo -c -o libnm_glib_test_la-nm-dhcp6-config.lo `test -f 'nm-dhcp6-config.c' || echo '$(srcdir)/'`nm-dhcp6-config.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-dhcp6-config.Tpo $(DEPDIR)/libnm_glib_test_la-nm-dhcp6-config.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-dhcp6-config.c' object='libnm_glib_test_la-nm-dhcp6-config.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-dhcp6-config.lo `test -f 'nm-dhcp6-config.c' || echo '$(srcdir)/'`nm-dhcp6-config.c + +libnm_glib_test_la-nm-remote-connection.lo: nm-remote-connection.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-remote-connection.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-remote-connection.Tpo -c -o libnm_glib_test_la-nm-remote-connection.lo `test -f 'nm-remote-connection.c' || echo '$(srcdir)/'`nm-remote-connection.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-remote-connection.Tpo $(DEPDIR)/libnm_glib_test_la-nm-remote-connection.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-remote-connection.c' object='libnm_glib_test_la-nm-remote-connection.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-remote-connection.lo `test -f 'nm-remote-connection.c' || echo '$(srcdir)/'`nm-remote-connection.c + +libnm_glib_test_la-nm-remote-settings.lo: nm-remote-settings.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-remote-settings.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-remote-settings.Tpo -c -o libnm_glib_test_la-nm-remote-settings.lo `test -f 'nm-remote-settings.c' || echo '$(srcdir)/'`nm-remote-settings.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-remote-settings.Tpo $(DEPDIR)/libnm_glib_test_la-nm-remote-settings.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-remote-settings.c' object='libnm_glib_test_la-nm-remote-settings.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-remote-settings.lo `test -f 'nm-remote-settings.c' || echo '$(srcdir)/'`nm-remote-settings.c + +libnm_glib_test_la-nm-secret-agent.lo: nm-secret-agent.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-secret-agent.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-secret-agent.Tpo -c -o libnm_glib_test_la-nm-secret-agent.lo `test -f 'nm-secret-agent.c' || echo '$(srcdir)/'`nm-secret-agent.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-secret-agent.Tpo $(DEPDIR)/libnm_glib_test_la-nm-secret-agent.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-secret-agent.c' object='libnm_glib_test_la-nm-secret-agent.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-secret-agent.lo `test -f 'nm-secret-agent.c' || echo '$(srcdir)/'`nm-secret-agent.c + +libnm_glib_test_la-nm-device-wimax.lo: nm-device-wimax.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-device-wimax.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-device-wimax.Tpo -c -o libnm_glib_test_la-nm-device-wimax.lo `test -f 'nm-device-wimax.c' || echo '$(srcdir)/'`nm-device-wimax.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-device-wimax.Tpo $(DEPDIR)/libnm_glib_test_la-nm-device-wimax.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-device-wimax.c' object='libnm_glib_test_la-nm-device-wimax.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-device-wimax.lo `test -f 'nm-device-wimax.c' || echo '$(srcdir)/'`nm-device-wimax.c + +libnm_glib_test_la-nm-wimax-nsp.lo: nm-wimax-nsp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -MT libnm_glib_test_la-nm-wimax-nsp.lo -MD -MP -MF $(DEPDIR)/libnm_glib_test_la-nm-wimax-nsp.Tpo -c -o libnm_glib_test_la-nm-wimax-nsp.lo `test -f 'nm-wimax-nsp.c' || echo '$(srcdir)/'`nm-wimax-nsp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_test_la-nm-wimax-nsp.Tpo $(DEPDIR)/libnm_glib_test_la-nm-wimax-nsp.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-wimax-nsp.c' object='libnm_glib_test_la-nm-wimax-nsp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_test_la-nm-wimax-nsp.lo `test -f 'nm-wimax-nsp.c' || echo '$(srcdir)/'`nm-wimax-nsp.c + libnm_glib_vpn_la-nm-vpn-plugin.lo: nm-vpn-plugin.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_vpn_la_CFLAGS) $(CFLAGS) -MT libnm_glib_vpn_la-nm-vpn-plugin.lo -MD -MP -MF $(DEPDIR)/libnm_glib_vpn_la-nm-vpn-plugin.Tpo -c -o libnm_glib_vpn_la-nm-vpn-plugin.lo `test -f 'nm-vpn-plugin.c' || echo '$(srcdir)/'`nm-vpn-plugin.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_vpn_la-nm-vpn-plugin.Tpo $(DEPDIR)/libnm_glib_vpn_la-nm-vpn-plugin.Plo @@ -696,6 +1029,14 @@ libnm_glib_vpn_la-nm-vpn-plugin-ui-interface.lo: nm-vpn-plugin-ui-interface.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_vpn_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_vpn_la-nm-vpn-plugin-ui-interface.lo `test -f 'nm-vpn-plugin-ui-interface.c' || echo '$(srcdir)/'`nm-vpn-plugin-ui-interface.c +libnm_glib_vpn_la-nm-vpn-plugin-utils.lo: nm-vpn-plugin-utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_vpn_la_CFLAGS) $(CFLAGS) -MT libnm_glib_vpn_la-nm-vpn-plugin-utils.lo -MD -MP -MF $(DEPDIR)/libnm_glib_vpn_la-nm-vpn-plugin-utils.Tpo -c -o libnm_glib_vpn_la-nm-vpn-plugin-utils.lo `test -f 'nm-vpn-plugin-utils.c' || echo '$(srcdir)/'`nm-vpn-plugin-utils.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_vpn_la-nm-vpn-plugin-utils.Tpo $(DEPDIR)/libnm_glib_vpn_la-nm-vpn-plugin-utils.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-vpn-plugin-utils.c' object='libnm_glib_vpn_la-nm-vpn-plugin-utils.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_vpn_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_vpn_la-nm-vpn-plugin-utils.lo `test -f 'nm-vpn-plugin-utils.c' || echo '$(srcdir)/'`nm-vpn-plugin-utils.c + libnm_glib_la-nm-object.lo: nm-object.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-object.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-object.Tpo -c -o libnm_glib_la-nm-object.lo `test -f 'nm-object.c' || echo '$(srcdir)/'`nm-object.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-object.Tpo $(DEPDIR)/libnm_glib_la-nm-object.Plo @@ -768,29 +1109,13 @@ libnm_glib_la-nm-ip4-config.lo: nm-ip4-config.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-ip4-config.lo `test -f 'nm-ip4-config.c' || echo '$(srcdir)/'`nm-ip4-config.c -libnm_glib_la-nm-gsm-device.lo: nm-gsm-device.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-gsm-device.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-gsm-device.Tpo -c -o libnm_glib_la-nm-gsm-device.lo `test -f 'nm-gsm-device.c' || echo '$(srcdir)/'`nm-gsm-device.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-gsm-device.Tpo $(DEPDIR)/libnm_glib_la-nm-gsm-device.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-gsm-device.c' object='libnm_glib_la-nm-gsm-device.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-gsm-device.lo `test -f 'nm-gsm-device.c' || echo '$(srcdir)/'`nm-gsm-device.c - -libnm_glib_la-nm-cdma-device.lo: nm-cdma-device.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-cdma-device.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-cdma-device.Tpo -c -o libnm_glib_la-nm-cdma-device.lo `test -f 'nm-cdma-device.c' || echo '$(srcdir)/'`nm-cdma-device.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-cdma-device.Tpo $(DEPDIR)/libnm_glib_la-nm-cdma-device.Plo +libnm_glib_la-nm-device-modem.lo: nm-device-modem.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-device-modem.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-device-modem.Tpo -c -o libnm_glib_la-nm-device-modem.lo `test -f 'nm-device-modem.c' || echo '$(srcdir)/'`nm-device-modem.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-device-modem.Tpo $(DEPDIR)/libnm_glib_la-nm-device-modem.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-cdma-device.c' object='libnm_glib_la-nm-cdma-device.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-device-modem.c' object='libnm_glib_la-nm-device-modem.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-cdma-device.lo `test -f 'nm-cdma-device.c' || echo '$(srcdir)/'`nm-cdma-device.c - -libnm_glib_la-nm-serial-device.lo: nm-serial-device.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-serial-device.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-serial-device.Tpo -c -o libnm_glib_la-nm-serial-device.lo `test -f 'nm-serial-device.c' || echo '$(srcdir)/'`nm-serial-device.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-serial-device.Tpo $(DEPDIR)/libnm_glib_la-nm-serial-device.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-serial-device.c' object='libnm_glib_la-nm-serial-device.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-serial-device.lo `test -f 'nm-serial-device.c' || echo '$(srcdir)/'`nm-serial-device.c +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-device-modem.lo `test -f 'nm-device-modem.c' || echo '$(srcdir)/'`nm-device-modem.c libnm_glib_la-nm-vpn-connection.lo: nm-vpn-connection.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-vpn-connection.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-vpn-connection.Tpo -c -o libnm_glib_la-nm-vpn-connection.lo `test -f 'nm-vpn-connection.c' || echo '$(srcdir)/'`nm-vpn-connection.c @@ -856,22 +1181,6 @@ libnm_glib_la-nm-remote-connection.lo: nm-remote-connection.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-remote-connection.lo `test -f 'nm-remote-connection.c' || echo '$(srcdir)/'`nm-remote-connection.c -libnm_glib_la-nm-settings-interface.lo: nm-settings-interface.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-settings-interface.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-settings-interface.Tpo -c -o libnm_glib_la-nm-settings-interface.lo `test -f 'nm-settings-interface.c' || echo '$(srcdir)/'`nm-settings-interface.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-settings-interface.Tpo $(DEPDIR)/libnm_glib_la-nm-settings-interface.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-settings-interface.c' object='libnm_glib_la-nm-settings-interface.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-settings-interface.lo `test -f 'nm-settings-interface.c' || echo '$(srcdir)/'`nm-settings-interface.c - -libnm_glib_la-nm-settings-system-interface.lo: nm-settings-system-interface.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-settings-system-interface.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-settings-system-interface.Tpo -c -o libnm_glib_la-nm-settings-system-interface.lo `test -f 'nm-settings-system-interface.c' || echo '$(srcdir)/'`nm-settings-system-interface.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-settings-system-interface.Tpo $(DEPDIR)/libnm_glib_la-nm-settings-system-interface.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-settings-system-interface.c' object='libnm_glib_la-nm-settings-system-interface.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-settings-system-interface.lo `test -f 'nm-settings-system-interface.c' || echo '$(srcdir)/'`nm-settings-system-interface.c - libnm_glib_la-nm-remote-settings.lo: nm-remote-settings.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-remote-settings.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-remote-settings.Tpo -c -o libnm_glib_la-nm-remote-settings.lo `test -f 'nm-remote-settings.c' || echo '$(srcdir)/'`nm-remote-settings.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-remote-settings.Tpo $(DEPDIR)/libnm_glib_la-nm-remote-settings.Plo @@ -880,37 +1189,29 @@ libnm_glib_la-nm-remote-settings.lo: nm-remote-settings.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-remote-settings.lo `test -f 'nm-remote-settings.c' || echo '$(srcdir)/'`nm-remote-settings.c -libnm_glib_la-nm-remote-settings-system.lo: nm-remote-settings-system.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-remote-settings-system.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-remote-settings-system.Tpo -c -o libnm_glib_la-nm-remote-settings-system.lo `test -f 'nm-remote-settings-system.c' || echo '$(srcdir)/'`nm-remote-settings-system.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-remote-settings-system.Tpo $(DEPDIR)/libnm_glib_la-nm-remote-settings-system.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-remote-settings-system.c' object='libnm_glib_la-nm-remote-settings-system.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-remote-settings-system.lo `test -f 'nm-remote-settings-system.c' || echo '$(srcdir)/'`nm-remote-settings-system.c - -libnm_glib_la-nm-settings-connection-interface.lo: nm-settings-connection-interface.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-settings-connection-interface.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-settings-connection-interface.Tpo -c -o libnm_glib_la-nm-settings-connection-interface.lo `test -f 'nm-settings-connection-interface.c' || echo '$(srcdir)/'`nm-settings-connection-interface.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-settings-connection-interface.Tpo $(DEPDIR)/libnm_glib_la-nm-settings-connection-interface.Plo +libnm_glib_la-nm-secret-agent.lo: nm-secret-agent.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-secret-agent.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-secret-agent.Tpo -c -o libnm_glib_la-nm-secret-agent.lo `test -f 'nm-secret-agent.c' || echo '$(srcdir)/'`nm-secret-agent.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-secret-agent.Tpo $(DEPDIR)/libnm_glib_la-nm-secret-agent.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-settings-connection-interface.c' object='libnm_glib_la-nm-settings-connection-interface.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-secret-agent.c' object='libnm_glib_la-nm-secret-agent.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-settings-connection-interface.lo `test -f 'nm-settings-connection-interface.c' || echo '$(srcdir)/'`nm-settings-connection-interface.c +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-secret-agent.lo `test -f 'nm-secret-agent.c' || echo '$(srcdir)/'`nm-secret-agent.c -libnm_glib_la-nm-exported-connection.lo: nm-exported-connection.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-exported-connection.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-exported-connection.Tpo -c -o libnm_glib_la-nm-exported-connection.lo `test -f 'nm-exported-connection.c' || echo '$(srcdir)/'`nm-exported-connection.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-exported-connection.Tpo $(DEPDIR)/libnm_glib_la-nm-exported-connection.Plo +libnm_glib_la-nm-device-wimax.lo: nm-device-wimax.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-device-wimax.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-device-wimax.Tpo -c -o libnm_glib_la-nm-device-wimax.lo `test -f 'nm-device-wimax.c' || echo '$(srcdir)/'`nm-device-wimax.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-device-wimax.Tpo $(DEPDIR)/libnm_glib_la-nm-device-wimax.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-exported-connection.c' object='libnm_glib_la-nm-exported-connection.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-device-wimax.c' object='libnm_glib_la-nm-device-wimax.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-exported-connection.lo `test -f 'nm-exported-connection.c' || echo '$(srcdir)/'`nm-exported-connection.c +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-device-wimax.lo `test -f 'nm-device-wimax.c' || echo '$(srcdir)/'`nm-device-wimax.c -libnm_glib_la-nm-settings-service.lo: nm-settings-service.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-settings-service.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-settings-service.Tpo -c -o libnm_glib_la-nm-settings-service.lo `test -f 'nm-settings-service.c' || echo '$(srcdir)/'`nm-settings-service.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-settings-service.Tpo $(DEPDIR)/libnm_glib_la-nm-settings-service.Plo +libnm_glib_la-nm-wimax-nsp.lo: nm-wimax-nsp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -MT libnm_glib_la-nm-wimax-nsp.lo -MD -MP -MF $(DEPDIR)/libnm_glib_la-nm-wimax-nsp.Tpo -c -o libnm_glib_la-nm-wimax-nsp.lo `test -f 'nm-wimax-nsp.c' || echo '$(srcdir)/'`nm-wimax-nsp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_glib_la-nm-wimax-nsp.Tpo $(DEPDIR)/libnm_glib_la-nm-wimax-nsp.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-settings-service.c' object='libnm_glib_la-nm-settings-service.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-wimax-nsp.c' object='libnm_glib_la-nm-wimax-nsp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-settings-service.lo `test -f 'nm-settings-service.c' || echo '$(srcdir)/'`nm-settings-service.c +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_la_CFLAGS) $(CFLAGS) -c -o libnm_glib_la-nm-wimax-nsp.lo `test -f 'nm-wimax-nsp.c' || echo '$(srcdir)/'`nm-wimax-nsp.c libnm_glib_test-libnm-glib-test.o: libnm-glib-test.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnm_glib_test_CFLAGS) $(CFLAGS) -MT libnm_glib_test-libnm-glib-test.o -MD -MP -MF $(DEPDIR)/libnm_glib_test-libnm-glib-test.Tpo -c -o libnm_glib_test-libnm-glib-test.o `test -f 'libnm-glib-test.c' || echo '$(srcdir)/'`libnm-glib-test.c @@ -933,6 +1234,26 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs +install-girDATA: $(gir_DATA) + @$(NORMAL_INSTALL) + test -z "$(girdir)" || $(MKDIR_P) "$(DESTDIR)$(girdir)" + @list='$(gir_DATA)'; test -n "$(girdir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(girdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(girdir)" || exit $$?; \ + done + +uninstall-girDATA: + @$(NORMAL_UNINSTALL) + @list='$(gir_DATA)'; test -n "$(girdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(girdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(girdir)" && rm -f $$files install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" @@ -953,6 +1274,46 @@ uninstall-pkgconfigDATA: test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files +install-typelibDATA: $(typelib_DATA) + @$(NORMAL_INSTALL) + test -z "$(typelibdir)" || $(MKDIR_P) "$(DESTDIR)$(typelibdir)" + @list='$(typelib_DATA)'; test -n "$(typelibdir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(typelibdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(typelibdir)" || exit $$?; \ + done + +uninstall-typelibDATA: + @$(NORMAL_UNINSTALL) + @list='$(typelib_DATA)'; test -n "$(typelibdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(typelibdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(typelibdir)" && rm -f $$files +install-libdeprecatedHEADERS: $(libdeprecated_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(libdeprecateddir)" || $(MKDIR_P) "$(DESTDIR)$(libdeprecateddir)" + @list='$(libdeprecated_HEADERS)'; test -n "$(libdeprecateddir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libdeprecateddir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(libdeprecateddir)" || exit $$?; \ + done + +uninstall-libdeprecatedHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(libdeprecated_HEADERS)'; test -n "$(libdeprecateddir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(libdeprecateddir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(libdeprecateddir)" && rm -f $$files install-libnmincludeHEADERS: $(libnminclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(libnmincludedir)" || $(MKDIR_P) "$(DESTDIR)$(libnmincludedir)" @@ -973,6 +1334,96 @@ uninstall-libnmincludeHEADERS: test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(libnmincludedir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(libnmincludedir)" && rm -f $$files +install-libnmvpnHEADERS: $(libnmvpn_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(libnmvpndir)" || $(MKDIR_P) "$(DESTDIR)$(libnmvpndir)" + @list='$(libnmvpn_HEADERS)'; test -n "$(libnmvpndir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libnmvpndir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(libnmvpndir)" || exit $$?; \ + done + +uninstall-libnmvpnHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(libnmvpn_HEADERS)'; test -n "$(libnmvpndir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(libnmvpndir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(libnmvpndir)" && rm -f $$files + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -984,10 +1435,23 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) mkid -fID $$unique tags: TAGS -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ @@ -1006,7 +1470,7 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ fi; \ fi ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -1056,26 +1520,55 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done @WITH_TESTS_FALSE@check-local: check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-local check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-am + $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(libnmincludedir)"; do \ +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(girdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(typelibdir)" "$(DESTDIR)$(libdeprecateddir)" "$(DESTDIR)$(libnmincludedir)" "$(DESTDIR)$(libnmvpndir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am + $(MAKE) $(AM_MAKEFLAGS) install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -installcheck: installcheck-am +installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ @@ -1095,99 +1588,112 @@ maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -clean: clean-am +clean: clean-recursive clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ clean-noinstLTLIBRARIES clean-noinstPROGRAMS mostlyclean-am -distclean: distclean-am +distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags -dvi: dvi-am +dvi: dvi-recursive dvi-am: -html: html-am +html: html-recursive html-am: -info: info-am +info: info-recursive info-am: -install-data-am: install-libnmincludeHEADERS install-pkgconfigDATA +install-data-am: install-girDATA install-libdeprecatedHEADERS \ + install-libnmincludeHEADERS install-libnmvpnHEADERS \ + install-pkgconfigDATA install-typelibDATA -install-dvi: install-dvi-am +install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-libLTLIBRARIES -install-html: install-html-am +install-html: install-html-recursive install-html-am: -install-info: install-info-am +install-info: install-info-recursive install-info-am: install-man: -install-pdf: install-pdf-am +install-pdf: install-pdf-recursive install-pdf-am: -install-ps: install-ps-am +install-ps: install-ps-recursive install-ps-am: installcheck-am: -maintainer-clean: maintainer-clean-am +maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic -mostlyclean: mostlyclean-am +mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool -pdf: pdf-am +pdf: pdf-recursive pdf-am: -ps: ps-am +ps: ps-recursive ps-am: -uninstall-am: uninstall-libLTLIBRARIES uninstall-libnmincludeHEADERS \ - uninstall-pkgconfigDATA +uninstall-am: uninstall-girDATA uninstall-libLTLIBRARIES \ + uninstall-libdeprecatedHEADERS uninstall-libnmincludeHEADERS \ + uninstall-libnmvpnHEADERS uninstall-pkgconfigDATA \ + uninstall-typelibDATA -.MAKE: all check check-am install install-am install-strip +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ + check-am ctags-recursive install install-am install-strip \ + tags-recursive -.PHONY: CTAGS GTAGS all all-am check check-am check-local clean \ - clean-generic clean-libLTLIBRARIES clean-libtool \ - clean-noinstLTLIBRARIES clean-noinstPROGRAMS ctags distclean \ +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am check-local clean clean-generic \ + clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \ + clean-noinstPROGRAMS ctags ctags-recursive distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am \ - install-libLTLIBRARIES install-libnmincludeHEADERS install-man \ - install-pdf install-pdf-am install-pkgconfigDATA install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-libLTLIBRARIES \ - uninstall-libnmincludeHEADERS uninstall-pkgconfigDATA - - -nm-client-bindings.h: $(top_srcdir)/introspection/nm-manager-client.xml + install-dvi-am install-exec install-exec-am install-girDATA \ + install-html install-html-am install-info install-info-am \ + install-libLTLIBRARIES install-libdeprecatedHEADERS \ + install-libnmincludeHEADERS install-libnmvpnHEADERS \ + install-man install-pdf install-pdf-am install-pkgconfigDATA \ + install-ps install-ps-am install-strip install-typelibDATA \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-girDATA uninstall-libLTLIBRARIES \ + uninstall-libdeprecatedHEADERS uninstall-libnmincludeHEADERS \ + uninstall-libnmvpnHEADERS uninstall-pkgconfigDATA \ + uninstall-typelibDATA + + +##################################################### + +nm-client-bindings.h: $(top_srcdir)/introspection/nm-manager.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_client --mode=glib-client --output=$@ $< nm-device-bindings.h: $(top_srcdir)/introspection/nm-device.xml @@ -1205,20 +1711,11 @@ nm-device-bt-bindings.h: $(top_srcdir)/introspection/nm-device-bt.xml nm-access-point-bindings.h: $(top_srcdir)/introspection/nm-access-point.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_access_point --mode=glib-client --output=$@ $< -nm-settings-glue.h: $(top_srcdir)/introspection/nm-settings.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-server --output=$@ $< - nm-settings-bindings.h: $(top_srcdir)/introspection/nm-settings.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-client --output=$@ $< -nm-settings-system-bindings.h: $(top_srcdir)/introspection/nm-settings-system.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings_system --mode=glib-client --output=$@ $< - -nm-exported-connection-glue.h: $(top_srcdir)/introspection/nm-exported-connection.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_exported_connection --mode=glib-server --output=$@ $< - -nm-exported-connection-bindings.h: $(top_srcdir)/introspection/nm-exported-connection.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_exported_connection --mode=glib-client --output=$@ $< +nm-settings-connection-bindings.h: $(top_srcdir)/introspection/nm-settings-connection.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings_connection --mode=glib-client --output=$@ $< nm-vpn-connection-bindings.h: $(top_srcdir)/introspection/nm-vpn-connection.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection --mode=glib-client --output=$@ $< @@ -1241,6 +1738,19 @@ nm-ip6-config-bindings.h: $(top_srcdir)/introspection/nm-ip6-config.xml nm-dhcp6-config-bindings.h: $(top_srcdir)/introspection/nm-dhcp6-config.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_dhcp6_config --mode=glib-client --output=$@ $< +nm-secret-agent-glue.h: $(top_srcdir)/introspection/nm-secret-agent.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_secret_agent --mode=glib-server --output=$@ $< + +nm-device-wimax-bindings.h: $(top_srcdir)/introspection/nm-device-wimax.xml + dbus-binding-tool --prefix=nm_device_wimax --mode=glib-client --output=$@ $< + +nm-device-modem-bindings.h: $(top_srcdir)/introspection/nm-device-modem.xml + dbus-binding-tool --prefix=nm_device_modem --mode=glib-client --output=$@ $< + +-include $(INTROSPECTION_MAKEFILE) + +@HAVE_INTROSPECTION_TRUE@NMClient-1.0.gir: libnm-glib.la + @WITH_TESTS_TRUE@check-local: @WITH_TESTS_TRUE@ $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-glib.so $(SYMBOL_VIS_FILE) diff --git a/libnm-glib/libnm-glib-test.c b/libnm-glib/libnm-glib-test.c index 6284fecab..16e6fad64 100644 --- a/libnm-glib/libnm-glib-test.c +++ b/libnm-glib/libnm-glib-test.c @@ -80,8 +80,8 @@ ip4_address_as_string (guint32 ip) if (inet_ntop (AF_INET, &tmp_addr, buf, INET_ADDRSTRLEN)) { return g_strdup (buf); } else { - nm_warning ("%s: error converting IP4 address 0x%X", - __func__, ntohl (tmp_addr.s_addr)); + g_warning ("%s: error converting IP4 address 0x%X", + __func__, ntohl (tmp_addr.s_addr)); return NULL; } } diff --git a/libnm-glib/libnm-glib-vpn.pc.in b/libnm-glib/libnm-glib-vpn.pc.in index 73b7a9c71..5f341594f 100644 --- a/libnm-glib/libnm-glib-vpn.pc.in +++ b/libnm-glib/libnm-glib-vpn.pc.in @@ -6,7 +6,7 @@ includedir=@includedir@ Name: libnm-glib-vpn Description: Convenience library for NetworkManager VPN plugins Version: @VERSION@ -Requires: NetworkManager >= 0.7.999 glib-2.0 dbus-glib-1 +Requires: NetworkManager >= 0.8.995 glib-2.0 dbus-glib-1 Cflags: -I${includedir}/libnm-glib Libs: -L${libdir} -lnm-glib-vpn diff --git a/libnm-glib/libnm-glib-vpn.ver b/libnm-glib/libnm-glib-vpn.ver index 16643d2ea..9d2bad5e2 100644 --- a/libnm-glib/libnm-glib-vpn.ver +++ b/libnm-glib/libnm-glib-vpn.ver @@ -21,6 +21,8 @@ global: nm_vpn_plugin_ui_widget_interface_get_widget; nm_vpn_plugin_ui_widget_interface_save_secrets; nm_vpn_plugin_ui_widget_interface_update_connection; + nm_vpn_plugin_utils_get_secret_flags; + nm_vpn_plugin_utils_read_vpn_details; local: *; }; diff --git a/libnm-glib/libnm-glib.pc.in b/libnm-glib/libnm-glib.pc.in index 5c3471b16..2668b4e56 100644 --- a/libnm-glib/libnm-glib.pc.in +++ b/libnm-glib/libnm-glib.pc.in @@ -6,7 +6,7 @@ includedir=@includedir@ Name: libnm-glib Description: Convenience library for clients of NetworkManager Version: @VERSION@ -Requires: NetworkManager >= 0.7.999 glib-2.0 dbus-glib-1 +Requires: NetworkManager >= 0.8.995 gobject-2.0 dbus-glib-1 Cflags: -I${includedir}/libnm-glib Libs: -L${libdir} -lnm-glib diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver index 69c07a647..96e6704cf 100644 --- a/libnm-glib/libnm-glib.ver +++ b/libnm-glib/libnm-glib.ver @@ -5,6 +5,8 @@ global: libnm_glib_register_callback; libnm_glib_shutdown; libnm_glib_unregister_callback; + nm_access_point_filter_connections; + nm_access_point_get_bssid; nm_access_point_get_flags; nm_access_point_get_frequency; nm_access_point_get_hw_address; @@ -20,15 +22,12 @@ global: nm_active_connection_get_default6; nm_active_connection_get_default; nm_active_connection_get_devices; - nm_active_connection_get_scope; - nm_active_connection_get_service_name; nm_active_connection_get_specific_object; nm_active_connection_get_state; nm_active_connection_get_type; nm_active_connection_new; - nm_cdma_device_get_type; - nm_cdma_device_new; nm_client_activate_connection; + nm_client_add_and_activate_connection; nm_client_deactivate_connection; nm_client_get_active_connections; nm_client_get_device_by_path; @@ -37,10 +36,14 @@ global: nm_client_get_permission_result; nm_client_get_state; nm_client_get_type; + nm_client_get_version; nm_client_networking_get_enabled; nm_client_networking_set_enabled; nm_client_new; nm_client_sleep; + nm_client_wimax_get_enabled; + nm_client_wimax_hardware_get_enabled; + nm_client_wimax_set_enabled; nm_client_wireless_get_enabled; nm_client_wireless_hardware_get_enabled; nm_client_wireless_set_enabled; @@ -59,7 +62,9 @@ global: nm_device_ethernet_get_speed; nm_device_ethernet_get_type; nm_device_ethernet_new; + nm_device_filter_connections; nm_device_get_capabilities; + nm_device_get_device_type; nm_device_get_dhcp4_config; nm_device_get_dhcp6_config; nm_device_get_driver; @@ -73,6 +78,9 @@ global: nm_device_get_type; nm_device_get_udi; nm_device_get_vendor; + nm_device_modem_get_current_capabilities; + nm_device_modem_get_modem_capabilities; + nm_device_modem_get_type; nm_device_new; nm_device_wifi_get_access_point_by_path; nm_device_wifi_get_access_points; @@ -84,6 +92,17 @@ global: nm_device_wifi_get_permanent_hw_address; nm_device_wifi_get_type; nm_device_wifi_new; + nm_device_wimax_get_active_nsp; + nm_device_wimax_get_bsid; + nm_device_wimax_get_center_frequency; + nm_device_wimax_get_cinr; + nm_device_wimax_get_hw_address; + nm_device_wimax_get_nsp_by_path; + nm_device_wimax_get_nsps; + nm_device_wimax_get_rssi; + nm_device_wimax_get_tx_power; + nm_device_wimax_get_type; + nm_device_wimax_new; nm_dhcp4_config_get_one_option; nm_dhcp4_config_get_options; nm_dhcp4_config_get_type; @@ -92,13 +111,8 @@ global: nm_dhcp6_config_get_options; nm_dhcp6_config_get_type; nm_dhcp6_config_new; - nm_exported_connection_get_type; - nm_exported_connection_new; - nm_gsm_device_get_type; - nm_gsm_device_new; nm_ip4_config_get_addresses; nm_ip4_config_get_domains; - nm_ip4_config_get_hostname; nm_ip4_config_get_nameservers; nm_ip4_config_get_routes; nm_ip4_config_get_type; @@ -117,33 +131,27 @@ global: nm_object_get_connection; nm_object_get_path; nm_object_get_type; + nm_remote_connection_commit_changes; + nm_remote_connection_delete; + nm_remote_connection_get_secrets; nm_remote_connection_get_type; nm_remote_connection_new; + nm_remote_settings_add_connection; + nm_remote_settings_error_get_type; + nm_remote_settings_error_quark; + nm_remote_settings_get_connection_by_path; nm_remote_settings_get_type; + nm_remote_settings_list_connections; nm_remote_settings_new; - nm_remote_settings_system_get_type; - nm_remote_settings_system_new; - nm_serial_device_get_bytes_received; - nm_serial_device_get_bytes_sent; - nm_serial_device_get_type; - nm_settings_connection_interface_delete; - nm_settings_connection_interface_emit_updated; - nm_settings_connection_interface_get_secrets; - nm_settings_connection_interface_get_type; - nm_settings_connection_interface_update; - nm_settings_interface_add_connection; - nm_settings_interface_error_get_type; - nm_settings_interface_error_quark; - nm_settings_interface_get_connection_by_path; - nm_settings_interface_get_type; - nm_settings_interface_list_connections; - nm_settings_service_export; - nm_settings_service_export_connection; - nm_settings_service_get_connection_by_path; - nm_settings_service_get_type; - nm_settings_system_interface_get_permissions; - nm_settings_system_interface_get_type; - nm_settings_system_interface_save_hostname; + nm_remote_settings_save_hostname; + nm_secret_agent_delete_secrets; + nm_secret_agent_error_get_type; + nm_secret_agent_error_quark; + nm_secret_agent_get_secrets; + nm_secret_agent_get_type; + nm_secret_agent_register; + nm_secret_agent_save_secrets; + nm_secret_agent_unregister; nm_ssid_get_type; nm_string_array_get_type; nm_uint_array_get_type; @@ -151,6 +159,12 @@ global: nm_vpn_connection_get_type; nm_vpn_connection_get_vpn_state; nm_vpn_connection_new; + nm_wimax_nsp_filter_connections; + nm_wimax_nsp_get_name; + nm_wimax_nsp_get_network_type; + nm_wimax_nsp_get_signal_quality; + nm_wimax_nsp_get_type; + nm_wimax_nsp_new; local: *; }; diff --git a/libnm-glib/libnm_glib.c b/libnm-glib/libnm_glib.c index 5e0e5cf57..911d0cec4 100644 --- a/libnm-glib/libnm_glib.c +++ b/libnm-glib/libnm_glib.c @@ -31,7 +31,6 @@ #include "libnm_glib.h" #define DBUS_NO_SERVICE_ERROR "org.freedesktop.DBus.Error.ServiceDoesNotExist" -#define NM_DBUS_SIGNAL_STATE_CHANGE "StateChange" struct libnm_glib_ctx @@ -194,18 +193,18 @@ libnm_glib_update_state (libnm_glib_ctx *ctx, g_return_if_fail (ctx != NULL); old_state = ctx->nm_state; - switch (state) - { - case NM_STATE_CONNECTED: + switch (state) { + case NM_STATE_CONNECTED_LOCAL: + case NM_STATE_CONNECTED_SITE: + case NM_STATE_CONNECTED_GLOBAL: ctx->nm_state = LIBNM_ACTIVE_NETWORK_CONNECTION; break; - case NM_STATE_ASLEEP: case NM_STATE_CONNECTING: case NM_STATE_DISCONNECTED: + case NM_STATE_DISCONNECTING: ctx->nm_state = LIBNM_NO_NETWORK_CONNECTION; break; - case NM_STATE_UNKNOWN: default: ctx->nm_state = LIBNM_NO_NETWORKMANAGER; @@ -272,7 +271,7 @@ libnm_glib_dbus_filter (DBusConnection *connection, { libnm_glib_get_nm_state (ctx); } - else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, NM_DBUS_SIGNAL_STATE_CHANGE)) + else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "StateChanged")) { NMState state = NM_STATE_UNKNOWN; diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c index 777e41de6..2712f36ce 100644 --- a/libnm-glib/nm-access-point.c +++ b/libnm-glib/nm-access-point.c @@ -18,10 +18,18 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2008 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ +#include <config.h> #include <string.h> +#include <netinet/ether.h> + +#include <nm-connection.h> +#include <nm-setting-connection.h> +#include <nm-setting-wireless.h> +#include <nm-setting-wireless-security.h> +#include <nm-utils.h> #include "nm-access-point.h" #include "NetworkManager.h" @@ -38,12 +46,12 @@ typedef struct { gboolean disposed; DBusGProxy *proxy; - guint32 flags; - guint32 wpa_flags; - guint32 rsn_flags; + NM80211ApFlags flags; + NM80211ApSecurityFlags wpa_flags; + NM80211ApSecurityFlags rsn_flags; GByteArray *ssid; guint32 frequency; - char *hw_address; + char *bssid; NM80211Mode mode; guint32 max_bitrate; guint8 strength; @@ -60,6 +68,7 @@ enum { PROP_MODE, PROP_MAX_BITRATE, PROP_STRENGTH, + PROP_BSSID, LAST_PROP }; @@ -81,7 +90,7 @@ enum { * * Creates a new #NMAccessPoint. * - * Returns: a new access point + * Returns: (transfer full): a new access point **/ GObject * nm_access_point_new (DBusGConnection *connection, const char *path) @@ -99,11 +108,11 @@ nm_access_point_new (DBusGConnection *connection, const char *path) * nm_access_point_get_flags: * @ap: a #NMAccessPoint * - * Gets the flags of the access point + * Gets the flags of the access point. * * Returns: the flags **/ -guint32 +NM80211ApFlags nm_access_point_get_flags (NMAccessPoint *ap) { NMAccessPointPrivate *priv; @@ -114,7 +123,8 @@ nm_access_point_get_flags (NMAccessPoint *ap) if (!priv->flags) { priv->flags = _nm_object_get_uint_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, - DBUS_PROP_FLAGS); + DBUS_PROP_FLAGS, + NULL); } return priv->flags; @@ -124,11 +134,11 @@ nm_access_point_get_flags (NMAccessPoint *ap) * nm_access_point_get_wpa_flags: * @ap: a #NMAccessPoint * - * Gets the WPA flags of the access point. + * Gets the WPA (version 1) flags of the access point. * * Returns: the WPA flags **/ -guint32 +NM80211ApSecurityFlags nm_access_point_get_wpa_flags (NMAccessPoint *ap) { NMAccessPointPrivate *priv; @@ -139,7 +149,8 @@ nm_access_point_get_wpa_flags (NMAccessPoint *ap) if (!priv->wpa_flags) { priv->wpa_flags = _nm_object_get_uint_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, - DBUS_PROP_WPA_FLAGS); + DBUS_PROP_WPA_FLAGS, + NULL); } return priv->wpa_flags; @@ -149,11 +160,12 @@ nm_access_point_get_wpa_flags (NMAccessPoint *ap) * nm_access_point_get_rsn_flags: * @ap: a #NMAccessPoint * - * Gets the RSN flags of the access point. + * Gets the RSN (Robust Secure Network, ie WPA version 2) flags of the access + * point. * * Returns: the RSN flags **/ -guint32 +NM80211ApSecurityFlags nm_access_point_get_rsn_flags (NMAccessPoint *ap) { NMAccessPointPrivate *priv; @@ -164,7 +176,8 @@ nm_access_point_get_rsn_flags (NMAccessPoint *ap) if (!priv->rsn_flags) { priv->rsn_flags = _nm_object_get_uint_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, - DBUS_PROP_RSN_FLAGS); + DBUS_PROP_RSN_FLAGS, + NULL); } return priv->rsn_flags; @@ -190,7 +203,8 @@ nm_access_point_get_ssid (NMAccessPoint *ap) if (!priv->ssid) { priv->ssid = _nm_object_get_byte_array_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, - DBUS_PROP_SSID); + DBUS_PROP_SSID, + NULL); } return priv->ssid; @@ -215,36 +229,55 @@ nm_access_point_get_frequency (NMAccessPoint *ap) if (!priv->frequency) { priv->frequency = _nm_object_get_uint_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, - DBUS_PROP_FREQUENCY); + DBUS_PROP_FREQUENCY, + NULL); } return priv->frequency; } /** - * nm_access_point_get_hw_address: + * nm_access_point_get_bssid: * @ap: a #NMAccessPoint * - * Gets the hardware (MAC) address of the access point. + * Gets the Basic Service Set ID (BSSID) of the WiFi access point. * - * Returns: the hardware address of the access point. This is the internal string used by the - * access point and must not be modified. + * Returns: the BSSID of the access point. This is an internal string and must + * not be modified or freed. **/ const char * -nm_access_point_get_hw_address (NMAccessPoint *ap) +nm_access_point_get_bssid (NMAccessPoint *ap) { NMAccessPointPrivate *priv; g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL); priv = NM_ACCESS_POINT_GET_PRIVATE (ap); - if (!priv->hw_address) { - priv->hw_address = _nm_object_get_string_property (NM_OBJECT (ap), - NM_DBUS_INTERFACE_ACCESS_POINT, - DBUS_PROP_HW_ADDRESS); + if (!priv->bssid) { + priv->bssid = _nm_object_get_string_property (NM_OBJECT (ap), + NM_DBUS_INTERFACE_ACCESS_POINT, + DBUS_PROP_HW_ADDRESS, + NULL); } - return priv->hw_address; + return priv->bssid; +} + +/** + * nm_access_point_get_hw_address: + * @ap: a #NMAccessPoint + * + * Gets the hardware (MAC) address of the access point. + * + * Returns: the hardware address of the access point. This is the internal string used by the + * access point and must not be modified. + * + * Deprecated: 0.9: Use nm_access_point_get_bssid() instead. + **/ +const char * +nm_access_point_get_hw_address (NMAccessPoint *ap) +{ + return nm_access_point_get_bssid (ap); } /** @@ -266,7 +299,8 @@ nm_access_point_get_mode (NMAccessPoint *ap) if (!priv->mode) { priv->mode = _nm_object_get_uint_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, - DBUS_PROP_MODE); + DBUS_PROP_MODE, + NULL); } return priv->mode; @@ -291,7 +325,8 @@ nm_access_point_get_max_bitrate (NMAccessPoint *ap) if (!priv->max_bitrate) { priv->max_bitrate = _nm_object_get_uint_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, - DBUS_PROP_MAX_BITRATE); + DBUS_PROP_MAX_BITRATE, + NULL); } return priv->max_bitrate; @@ -316,12 +351,131 @@ nm_access_point_get_strength (NMAccessPoint *ap) if (!priv->strength) { priv->strength = _nm_object_get_byte_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, - DBUS_PROP_STRENGTH); + DBUS_PROP_STRENGTH, + NULL); } return priv->strength; } +/** + * nm_access_point_filter_connections: + * @ap: an #NMAccessPoint to filter connections for + * @connections: a list of #NMConnection objects to filter + * + * Filters a given list of connections for a given #NMAccessPoint object and + * return connections which may be activated with the access point. Any + * returned connections will match the @ap's SSID and (if given) BSSID and + * other attributes like security settings, channel, etc. + * + * Returns: (transfer container) (element-type NetworkManager.Connection): a + * list of #NMConnection objects that could be activated with the given @ap. + * The elements of the list are owned by their creator and should not be freed + * by the caller, but the returned list itself is owned by the caller and should + * be freed with g_slist_free() when it is no longer required. + **/ +GSList * +nm_access_point_filter_connections (NMAccessPoint *ap, const GSList *connections) +{ + GSList *filtered = NULL; + const GSList *iter; + + for (iter = connections; iter; iter = g_slist_next (iter)) { + NMConnection *candidate = NM_CONNECTION (iter->data); + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + const char *ctype, *ap_bssid_str; + const GByteArray *setting_ssid; + const GByteArray *ap_ssid; + const GByteArray *setting_bssid; + struct ether_addr *ap_bssid; + const char *setting_mode; + NM80211Mode ap_mode; + const char *setting_band; + guint32 ap_freq, setting_chan, ap_chan; + + s_con = (NMSettingConnection *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION); + g_assert (s_con); + ctype = nm_setting_connection_get_connection_type (s_con); + if (strcmp (ctype, NM_SETTING_WIRELESS_SETTING_NAME) != 0) + continue; + + s_wifi = (NMSettingWireless *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIRELESS); + if (!s_wifi) + continue; + + /* SSID checks */ + ap_ssid = nm_access_point_get_ssid (ap); + g_warn_if_fail (ap_ssid != NULL); + setting_ssid = nm_setting_wireless_get_ssid (s_wifi); + if (!setting_ssid || !ap_ssid || (setting_ssid->len != ap_ssid->len)) + continue; + if (memcmp (setting_ssid->data, ap_ssid->data, ap_ssid->len) != 0) + continue; + + /* BSSID checks */ + ap_bssid_str = nm_access_point_get_bssid (ap); + g_warn_if_fail (ap_bssid_str); + setting_bssid = nm_setting_wireless_get_bssid (s_wifi); + if (setting_bssid && ap_bssid_str) { + g_assert (setting_bssid->len == ETH_ALEN); + ap_bssid = ether_aton (ap_bssid_str); + g_warn_if_fail (ap_bssid); + if (ap_bssid) { + if (memcmp (ap_bssid->ether_addr_octet, setting_bssid->data, ETH_ALEN) != 0) + continue; + } + } + + /* Mode */ + ap_mode = nm_access_point_get_mode (ap); + g_warn_if_fail (ap_mode != NM_802_11_MODE_UNKNOWN); + setting_mode = nm_setting_wireless_get_mode (s_wifi); + if (setting_mode && ap_mode) { + if (!strcmp (setting_mode, "infrastructure") && (ap_mode != NM_802_11_MODE_INFRA)) + return NULL; + if (!strcmp (setting_mode, "adhoc") && (ap_mode != NM_802_11_MODE_ADHOC)) + return NULL; + } + + /* Band and Channel/Frequency */ + ap_freq = nm_access_point_get_frequency (ap); + g_warn_if_fail (ap_freq > 0); + if (ap_freq) { + setting_band = nm_setting_wireless_get_band (s_wifi); + if (g_strcmp0 (setting_band, "a") == 0) { + if (ap_freq < 4915 || ap_freq > 5825) + continue; + } else if (g_strcmp0 (setting_band, "bg") == 0) { + if (ap_freq < 2412 || ap_freq > 2484) + continue; + } + + setting_chan = nm_setting_wireless_get_channel (s_wifi); + if (setting_chan) { + ap_chan = nm_utils_wifi_freq_to_channel (ap_freq); + if (setting_chan != ap_chan) + continue; + } + } + + s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIRELESS_SECURITY); + if (!nm_setting_wireless_ap_security_compatible (s_wifi, + s_wsec, + nm_access_point_get_flags (ap), + nm_access_point_get_wpa_flags (ap), + nm_access_point_get_rsn_flags (ap), + ap_mode)) + continue; + + /* Connection applies to this device */ + filtered = g_slist_prepend (filtered, candidate); + } + + return g_slist_reverse (filtered); +} + /************************************************************/ static void @@ -354,8 +508,7 @@ finalize (GObject *object) if (priv->ssid) g_byte_array_free (priv->ssid, TRUE); - if (priv->hw_address) - g_free (priv->hw_address); + g_free (priv->bssid); G_OBJECT_CLASS (nm_access_point_parent_class)->finalize (object); } @@ -385,7 +538,10 @@ get_property (GObject *object, g_value_set_uint (value, nm_access_point_get_frequency (ap)); break; case PROP_HW_ADDRESS: - g_value_set_string (value, nm_access_point_get_hw_address (ap)); + g_value_set_string (value, nm_access_point_get_bssid (ap)); + break; + case PROP_BSSID: + g_value_set_string (value, nm_access_point_get_bssid (ap)); break; case PROP_MODE: g_value_set_uint (value, nm_access_point_get_mode (ap)); @@ -420,9 +576,9 @@ register_for_property_changed (NMAccessPoint *ap) { NM_ACCESS_POINT_FLAGS, _nm_object_demarshal_generic, &priv->flags }, { NM_ACCESS_POINT_WPA_FLAGS, _nm_object_demarshal_generic, &priv->wpa_flags }, { NM_ACCESS_POINT_RSN_FLAGS, _nm_object_demarshal_generic, &priv->rsn_flags }, - { NM_ACCESS_POINT_SSID, demarshal_ssid, &priv->ssid }, + { NM_ACCESS_POINT_SSID, demarshal_ssid, &priv->ssid }, { NM_ACCESS_POINT_FREQUENCY, _nm_object_demarshal_generic, &priv->frequency }, - { NM_ACCESS_POINT_HW_ADDRESS, _nm_object_demarshal_generic, &priv->hw_address }, + { NM_ACCESS_POINT_HW_ADDRESS, _nm_object_demarshal_generic, &priv->bssid }, { NM_ACCESS_POINT_MODE, _nm_object_demarshal_generic, &priv->mode }, { NM_ACCESS_POINT_MAX_BITRATE, _nm_object_demarshal_generic, &priv->max_bitrate }, { NM_ACCESS_POINT_STRENGTH, _nm_object_demarshal_generic, &priv->strength }, @@ -544,6 +700,19 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) G_PARAM_READABLE)); /** + * NMAccessPoint:bssid: + * + * The BSSID of the access point. + **/ + g_object_class_install_property + (object_class, PROP_BSSID, + g_param_spec_string (NM_ACCESS_POINT_BSSID, + "BSSID", + "BSSID", + NULL, + G_PARAM_READABLE)); + + /** * NMAccessPoint:hw-address: * * The hardware address of the access point. diff --git a/libnm-glib/nm-access-point.h b/libnm-glib/nm-access-point.h index 770248152..24b69d5e6 100644 --- a/libnm-glib/nm-access-point.h +++ b/libnm-glib/nm-access-point.h @@ -18,7 +18,7 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2008 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ #ifndef NM_ACCESS_POINT_H @@ -42,12 +42,16 @@ G_BEGIN_DECLS #define NM_ACCESS_POINT_WPA_FLAGS "wpa-flags" #define NM_ACCESS_POINT_RSN_FLAGS "rsn-flags" #define NM_ACCESS_POINT_SSID "ssid" +#define NM_ACCESS_POINT_BSSID "bssid" #define NM_ACCESS_POINT_FREQUENCY "frequency" -#define NM_ACCESS_POINT_HW_ADDRESS "hw-address" #define NM_ACCESS_POINT_MODE "mode" #define NM_ACCESS_POINT_MAX_BITRATE "max-bitrate" #define NM_ACCESS_POINT_STRENGTH "strength" +/* DEPRECATED */ +#define NM_ACCESS_POINT_HW_ADDRESS "hw-address" + + typedef struct { NMObject parent; } NMAccessPoint; @@ -68,15 +72,21 @@ GType nm_access_point_get_type (void); GObject *nm_access_point_new (DBusGConnection *connection, const char *path); -guint32 nm_access_point_get_flags (NMAccessPoint *ap); -guint32 nm_access_point_get_wpa_flags (NMAccessPoint *ap); -guint32 nm_access_point_get_rsn_flags (NMAccessPoint *ap); -const GByteArray * nm_access_point_get_ssid (NMAccessPoint *ap); -guint32 nm_access_point_get_frequency (NMAccessPoint *ap); -const char * nm_access_point_get_hw_address (NMAccessPoint *ap); -NM80211Mode nm_access_point_get_mode (NMAccessPoint *ap); -guint32 nm_access_point_get_max_bitrate (NMAccessPoint *ap); -guint8 nm_access_point_get_strength (NMAccessPoint *ap); +NM80211ApFlags nm_access_point_get_flags (NMAccessPoint *ap); +NM80211ApSecurityFlags nm_access_point_get_wpa_flags (NMAccessPoint *ap); +NM80211ApSecurityFlags nm_access_point_get_rsn_flags (NMAccessPoint *ap); +const GByteArray * nm_access_point_get_ssid (NMAccessPoint *ap); +const char * nm_access_point_get_bssid (NMAccessPoint *ap); +guint32 nm_access_point_get_frequency (NMAccessPoint *ap); +NM80211Mode nm_access_point_get_mode (NMAccessPoint *ap); +guint32 nm_access_point_get_max_bitrate (NMAccessPoint *ap); +guint8 nm_access_point_get_strength (NMAccessPoint *ap); + +GSList * nm_access_point_filter_connections (NMAccessPoint *ap, + const GSList *connections); + +/* DEPRECATED */ +const char * nm_access_point_get_hw_address (NMAccessPoint *ap); G_END_DECLS diff --git a/libnm-glib/nm-active-connection.c b/libnm-glib/nm-active-connection.c index 2468da099..64d265ae1 100644 --- a/libnm-glib/nm-active-connection.c +++ b/libnm-glib/nm-active-connection.c @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * Copyright (C) 2007 - 2010 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. * Copyright (C) 2008 Novell, Inc. */ @@ -43,8 +43,6 @@ typedef struct { gboolean disposed; DBusGProxy *proxy; - char *service_name; - NMConnectionScope scope; char *connection; char *specific_object; GPtrArray *devices; @@ -55,7 +53,6 @@ typedef struct { enum { PROP_0, - PROP_SERVICE_NAME, PROP_CONNECTION, PROP_SPECIFIC_OBJECT, PROP_DEVICES, @@ -66,7 +63,6 @@ enum { LAST_PROP }; -#define DBUS_PROP_SERVICE_NAME "ServiceName" #define DBUS_PROP_CONNECTION "Connection" #define DBUS_PROP_SPECIFIC_OBJECT "SpecificObject" #define DBUS_PROP_DEVICES "Devices" @@ -81,7 +77,7 @@ enum { * * Creates a new #NMActiveConnection. * - * Returns: a new active connection + * Returns: (transfer full): a new active connection **/ GObject * nm_active_connection_new (DBusGConnection *connection, const char *path) @@ -95,62 +91,6 @@ nm_active_connection_new (DBusGConnection *connection, const char *path) NULL); } -static NMConnectionScope -get_scope_for_service_name (const char *service_name) -{ - if (service_name && !strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS)) - return NM_CONNECTION_SCOPE_USER; - else if (service_name && !strcmp (service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS)) - return NM_CONNECTION_SCOPE_SYSTEM; - - return NM_CONNECTION_SCOPE_UNKNOWN; -} - -/** - * nm_active_connection_get_service_name: - * @connection: a #NMActiveConnection - * - * Gets the service name of the active connection. - * - * Returns: the service name. This is the internal string used by the - * connection, and must not be modified. - **/ -const char * -nm_active_connection_get_service_name (NMActiveConnection *connection) -{ - NMActiveConnectionPrivate *priv; - - g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); - - priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection); - if (!priv->service_name) { - priv->service_name = _nm_object_get_string_property (NM_OBJECT (connection), - NM_DBUS_INTERFACE_ACTIVE_CONNECTION, - DBUS_PROP_SERVICE_NAME); - priv->scope = get_scope_for_service_name (priv->service_name); - } - - return priv->service_name; -} - -/** - * nm_active_connection_get_scope: - * @connection: a #NMActiveConnection - * - * Gets the scope of the active connection. - * - * Returns: the connection's scope - **/ -NMConnectionScope -nm_active_connection_get_scope (NMActiveConnection *connection) -{ - g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NM_CONNECTION_SCOPE_UNKNOWN); - - /* Make sure service_name and scope are up-to-date */ - nm_active_connection_get_service_name (connection); - return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->scope; -} - /** * nm_active_connection_get_connection: * @connection: a #NMActiveConnection @@ -171,7 +111,8 @@ nm_active_connection_get_connection (NMActiveConnection *connection) if (!priv->connection) { priv->connection = _nm_object_get_string_property (NM_OBJECT (connection), NM_DBUS_INTERFACE_ACTIVE_CONNECTION, - DBUS_PROP_CONNECTION); + DBUS_PROP_CONNECTION, + NULL); } return priv->connection; @@ -197,7 +138,8 @@ nm_active_connection_get_specific_object (NMActiveConnection *connection) if (!priv->specific_object) { priv->specific_object = _nm_object_get_string_property (NM_OBJECT (connection), NM_DBUS_INTERFACE_ACTIVE_CONNECTION, - DBUS_PROP_SPECIFIC_OBJECT); + DBUS_PROP_SPECIFIC_OBJECT, + NULL); } return priv->specific_object; @@ -209,7 +151,7 @@ nm_active_connection_get_specific_object (NMActiveConnection *connection) * * Gets the #NMDevice<!-- -->s used for the active connections. * - * Returns: the #GPtrArray containing #NMDevice<!-- -->s. + * Returns: (element-type NMClient.Device): the #GPtrArray containing #NMDevice<!-- -->s. * This is the internal copy used by the connection, and must not be modified. **/ const GPtrArray * @@ -227,7 +169,8 @@ nm_active_connection_get_devices (NMActiveConnection *connection) if (!_nm_object_get_property (NM_OBJECT (connection), NM_DBUS_INTERFACE_ACTIVE_CONNECTION, DBUS_PROP_DEVICES, - &value)) { + &value, + NULL)) { return NULL; } @@ -256,7 +199,8 @@ nm_active_connection_get_state (NMActiveConnection *connection) if (!priv->state) { priv->state = _nm_object_get_uint_property (NM_OBJECT (connection), NM_DBUS_INTERFACE_ACTIVE_CONNECTION, - DBUS_PROP_STATE); + DBUS_PROP_STATE, + NULL); } return priv->state; @@ -282,7 +226,8 @@ nm_active_connection_get_default (NMActiveConnection *connection) if (!priv->is_default) { priv->is_default = _nm_object_get_boolean_property (NM_OBJECT (connection), NM_DBUS_INTERFACE_ACTIVE_CONNECTION, - DBUS_PROP_DEFAULT); + DBUS_PROP_DEFAULT, + NULL); } return priv->is_default; @@ -308,7 +253,8 @@ nm_active_connection_get_default6 (NMActiveConnection *connection) if (!priv->is_default6) { priv->is_default6 = _nm_object_get_boolean_property (NM_OBJECT (connection), NM_DBUS_INTERFACE_ACTIVE_CONNECTION, - DBUS_PROP_DEFAULT6); + DBUS_PROP_DEFAULT6, + NULL); } return priv->is_default6; @@ -345,7 +291,6 @@ finalize (GObject *object) { NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); - g_free (priv->service_name); g_free (priv->connection); g_free (priv->specific_object); @@ -361,11 +306,8 @@ get_property (GObject *object, NMActiveConnection *self = NM_ACTIVE_CONNECTION (object); switch (prop_id) { - case PROP_SERVICE_NAME: - g_value_set_string (value, nm_active_connection_get_service_name (self)); - break; case PROP_CONNECTION: - g_value_set_boxed (value, nm_active_connection_get_connection (self)); + g_value_set_string (value, nm_active_connection_get_connection (self)); break; case PROP_SPECIFIC_OBJECT: g_value_set_boxed (value, nm_active_connection_get_specific_object (self)); @@ -401,24 +343,11 @@ demarshal_devices (NMObject *object, GParamSpec *pspec, GValue *value, gpointer return TRUE; } -static gboolean -demarshal_service (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) -{ - NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); - - if (_nm_object_demarshal_generic (object, pspec, value, field)) { - priv->scope = get_scope_for_service_name (priv->service_name); - return TRUE; - } - return FALSE; -} - static void register_for_property_changed (NMActiveConnection *connection) { NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection); const NMPropertiesChangedInfo property_changed_info[] = { - { NM_ACTIVE_CONNECTION_SERVICE_NAME, demarshal_service, &priv->service_name }, { NM_ACTIVE_CONNECTION_CONNECTION, _nm_object_demarshal_generic, &priv->connection }, { NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, _nm_object_demarshal_generic, &priv->specific_object }, { NM_ACTIVE_CONNECTION_DEVICES, demarshal_devices, &priv->devices }, @@ -476,19 +405,6 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) /* properties */ /** - * NMActiveConnection:service-name: - * - * The service name of the active connection. - **/ - g_object_class_install_property - (object_class, PROP_SERVICE_NAME, - g_param_spec_string (NM_ACTIVE_CONNECTION_SERVICE_NAME, - "Service Name", - "Service Name", - NULL, - G_PARAM_READABLE)); - - /** * NMActiveConnection:connection: * * The connection's path of the active connection. @@ -538,7 +454,7 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) "State", "State", NM_ACTIVE_CONNECTION_STATE_UNKNOWN, - NM_ACTIVE_CONNECTION_STATE_ACTIVATED, + NM_ACTIVE_CONNECTION_STATE_DEACTIVATING, NM_ACTIVE_CONNECTION_STATE_UNKNOWN, G_PARAM_READABLE)); diff --git a/libnm-glib/nm-active-connection.h b/libnm-glib/nm-active-connection.h index 30edf047a..a641e7c1a 100644 --- a/libnm-glib/nm-active-connection.h +++ b/libnm-glib/nm-active-connection.h @@ -39,7 +39,6 @@ G_BEGIN_DECLS #define NM_IS_ACTIVE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_ACTIVE_CONNECTION)) #define NM_ACTIVE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionClass)) -#define NM_ACTIVE_CONNECTION_SERVICE_NAME "service-name" #define NM_ACTIVE_CONNECTION_CONNECTION "connection" #define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object" #define NM_ACTIVE_CONNECTION_DEVICES "devices" @@ -67,8 +66,6 @@ GType nm_active_connection_get_type (void); GObject *nm_active_connection_new (DBusGConnection *connection, const char *path); -const char * nm_active_connection_get_service_name (NMActiveConnection *connection); -NMConnectionScope nm_active_connection_get_scope (NMActiveConnection *connection); const char * nm_active_connection_get_connection (NMActiveConnection *connection); const char * nm_active_connection_get_specific_object (NMActiveConnection *connection); const GPtrArray *nm_active_connection_get_devices (NMActiveConnection *connection); diff --git a/libnm-glib/nm-cdma-device.c b/libnm-glib/nm-cdma-device.c deleted file mode 100644 index 31b2e99c3..000000000 --- a/libnm-glib/nm-cdma-device.c +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Red Hat, Inc. - * Copyright (C) 2008 Novell, Inc. - */ - -#include "nm-cdma-device.h" -#include "nm-device-private.h" -#include "nm-object-private.h" - -G_DEFINE_TYPE (NMCdmaDevice, nm_cdma_device, NM_TYPE_SERIAL_DEVICE) - -#define NM_CDMA_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CDMA_DEVICE, NMCdmaDevicePrivate)) - -typedef struct { - DBusGProxy *proxy; - - gboolean disposed; -} NMCdmaDevicePrivate; - -static void -nm_cdma_device_init (NMCdmaDevice *device) -{ -} - -static void -register_for_property_changed (NMCdmaDevice *device) -{ - NMCdmaDevicePrivate *priv = NM_CDMA_DEVICE_GET_PRIVATE (device); - const NMPropertiesChangedInfo property_changed_info[] = { - { NULL }, - }; - - _nm_object_handle_properties_changed (NM_OBJECT (device), - priv->proxy, - property_changed_info); -} - -static GObject* -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - GObject *object; - NMCdmaDevicePrivate *priv; - - object = G_OBJECT_CLASS (nm_cdma_device_parent_class)->constructor (type, - n_construct_params, - construct_params); - if (!object) - return NULL; - - priv = NM_CDMA_DEVICE_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_CDMA_DEVICE); - - register_for_property_changed (NM_CDMA_DEVICE (object)); - - return object; -} - -static void -dispose (GObject *object) -{ - NMCdmaDevicePrivate *priv = NM_CDMA_DEVICE_GET_PRIVATE (object); - - if (priv->disposed) { - G_OBJECT_CLASS (nm_cdma_device_parent_class)->dispose (object); - return; - } - - priv->disposed = TRUE; - - g_object_unref (priv->proxy); - - G_OBJECT_CLASS (nm_cdma_device_parent_class)->dispose (object); -} - -static void -nm_cdma_device_class_init (NMCdmaDeviceClass *device_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (device_class); - - g_type_class_add_private (device_class, sizeof (NMCdmaDevicePrivate)); - - /* virtual methods */ - object_class->constructor = constructor; - object_class->dispose = dispose; -} - -/** - * nm_cdma_device_new: - * @connection: the #DBusGConnection - * @path: the DBus object path of the device - * - * Creates a new #NMCdmaDevice. - * - * Returns: a new device - **/ -GObject * -nm_cdma_device_new (DBusGConnection *connection, const char *path) -{ - g_return_val_if_fail (connection != NULL, NULL); - g_return_val_if_fail (path != NULL, NULL); - - return g_object_new (NM_TYPE_CDMA_DEVICE, - NM_OBJECT_DBUS_CONNECTION, connection, - NM_OBJECT_DBUS_PATH, path, - NULL); -} diff --git a/libnm-glib/nm-cdma-device.h b/libnm-glib/nm-cdma-device.h deleted file mode 100644 index f40124ace..000000000 --- a/libnm-glib/nm-cdma-device.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Red Hat, Inc. - * Copyright (C) 2008 Novell, Inc. - */ - -#ifndef NM_CDMA_DEVICE_H -#define NM_CDMA_DEVICE_H - -#include "nm-serial-device.h" - -G_BEGIN_DECLS - -#define NM_TYPE_CDMA_DEVICE (nm_cdma_device_get_type ()) -#define NM_CDMA_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CDMA_DEVICE, NMCdmaDevice)) -#define NM_CDMA_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CDMA_DEVICE, NMCdmaDeviceClass)) -#define NM_IS_CDMA_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CDMA_DEVICE)) -#define NM_IS_CDMA_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_CDMA_DEVICE)) -#define NM_CDMA_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CDMA_DEVICE, NMCdmaDeviceClass)) - -typedef struct { - NMSerialDevice parent; -} NMCdmaDevice; - -typedef struct { - NMSerialDeviceClass parent; - - /* Padding for future expansion */ - void (*_reserved1) (void); - void (*_reserved2) (void); - void (*_reserved3) (void); - void (*_reserved4) (void); - void (*_reserved5) (void); - void (*_reserved6) (void); -} NMCdmaDeviceClass; - -GType nm_cdma_device_get_type (void); - -GObject *nm_cdma_device_new (DBusGConnection *connection, const char *path); - -G_END_DECLS - -#endif /* NM_CDMA_DEVICE_H */ diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index 1de7b863c..fa60f21ea 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -28,8 +28,6 @@ #include "nm-client.h" #include "nm-device-ethernet.h" #include "nm-device-wifi.h" -#include "nm-gsm-device.h" -#include "nm-cdma-device.h" #include "nm-device-private.h" #include "nm-marshal.h" #include "nm-types-private.h" @@ -43,7 +41,6 @@ void _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, gboolean enabled); - G_DEFINE_TYPE (NMClient, nm_client, NM_TYPE_OBJECT) #define NM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CLIENT, NMClientPrivate)) @@ -54,6 +51,7 @@ typedef struct { DBusGProxy *client_proxy; DBusGProxy *bus_proxy; gboolean manager_running; + char *version; NMState state; GPtrArray *devices; GPtrArray *active_connections; @@ -61,6 +59,11 @@ typedef struct { DBusGProxyCall *perm_call; GHashTable *permissions; + /* Activations waiting for their NMActiveConnection + * to appear and then their callback to be called. + */ + GSList *pending_activations; + gboolean have_networking_enabled; gboolean networking_enabled; gboolean wireless_enabled; @@ -68,10 +71,14 @@ typedef struct { gboolean wwan_enabled; gboolean wwan_hw_enabled; + + gboolean wimax_enabled; + gboolean wimax_hw_enabled; } NMClientPrivate; enum { PROP_0, + PROP_VERSION, PROP_STATE, PROP_MANAGER_RUNNING, PROP_NETWORKING_ENABLED, @@ -79,6 +86,8 @@ enum { PROP_WIRELESS_HARDWARE_ENABLED, PROP_WWAN_ENABLED, PROP_WWAN_HARDWARE_ENABLED, + PROP_WIMAX_ENABLED, + PROP_WIMAX_HARDWARE_ENABLED, PROP_ACTIVE_CONNECTIONS, LAST_PROP @@ -152,8 +161,9 @@ update_wireless_status (NMClient *client, gboolean notify) gboolean poke = FALSE; val = _nm_object_get_boolean_property (NM_OBJECT (client), - NM_DBUS_INTERFACE, - "WirelessHardwareEnabled"); + NM_DBUS_INTERFACE, + "WirelessHardwareEnabled", + NULL); if (val != priv->wireless_hw_enabled) { priv->wireless_hw_enabled = val; poke = TRUE; @@ -165,8 +175,9 @@ update_wireless_status (NMClient *client, gboolean notify) val = FALSE; else val = _nm_object_get_boolean_property (NM_OBJECT (client), - NM_DBUS_INTERFACE, - "WirelessEnabled"); + NM_DBUS_INTERFACE, + "WirelessEnabled", + NULL); if (val != priv->wireless_enabled) { priv->wireless_enabled = val; poke = TRUE; @@ -192,7 +203,8 @@ update_wwan_status (NMClient *client, gboolean notify) val = _nm_object_get_boolean_property (NM_OBJECT (client), NM_DBUS_INTERFACE, - "WwanHardwareEnabled"); + "WwanHardwareEnabled", + NULL); if (val != priv->wwan_hw_enabled) { priv->wwan_hw_enabled = val; if (notify) @@ -204,7 +216,8 @@ update_wwan_status (NMClient *client, gboolean notify) else { val = _nm_object_get_boolean_property (NM_OBJECT (client), NM_DBUS_INTERFACE, - "WwanEnabled"); + "WwanEnabled", + NULL); } if (val != priv->wwan_enabled) { @@ -214,6 +227,40 @@ update_wwan_status (NMClient *client, gboolean notify) } } +#if WITH_WIMAX +static void +update_wimax_status (NMClient *client, gboolean notify) +{ + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); + gboolean val; + + val = _nm_object_get_boolean_property (NM_OBJECT (client), + NM_DBUS_INTERFACE, + "WimaxHardwareEnabled", + NULL); + if (val != priv->wimax_hw_enabled) { + priv->wimax_hw_enabled = val; + if (notify) + _nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_WIMAX_HARDWARE_ENABLED); + } + + if (priv->wimax_hw_enabled == FALSE) + val = FALSE; + else { + val = _nm_object_get_boolean_property (NM_OBJECT (client), + NM_DBUS_INTERFACE, + "WimaxEnabled", + NULL); + } + + if (val != priv->wimax_enabled) { + priv->wimax_enabled = val; + if (notify) + _nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_WIMAX_ENABLED); + } +} +#endif + static GObject * new_active_connection (DBusGConnection *connection, const char *path) { @@ -275,12 +322,15 @@ register_for_property_changed (NMClient *client) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); const NMPropertiesChangedInfo property_changed_info[] = { + { NM_CLIENT_VERSION, _nm_object_demarshal_generic, &priv->version }, { NM_CLIENT_STATE, _nm_object_demarshal_generic, &priv->state }, { NM_CLIENT_NETWORKING_ENABLED, _nm_object_demarshal_generic, &priv->networking_enabled }, { NM_CLIENT_WIRELESS_ENABLED, _nm_object_demarshal_generic, &priv->wireless_enabled }, { NM_CLIENT_WIRELESS_HARDWARE_ENABLED, _nm_object_demarshal_generic, &priv->wireless_hw_enabled }, { NM_CLIENT_WWAN_ENABLED, _nm_object_demarshal_generic, &priv->wwan_enabled }, { NM_CLIENT_WWAN_HARDWARE_ENABLED, _nm_object_demarshal_generic, &priv->wwan_hw_enabled }, + { NM_CLIENT_WIMAX_ENABLED, _nm_object_demarshal_generic, &priv->wimax_enabled }, + { NM_CLIENT_WIMAX_HARDWARE_ENABLED, _nm_object_demarshal_generic, &priv->wimax_hw_enabled }, { NM_CLIENT_ACTIVE_CONNECTIONS, demarshal_active_connections, &priv->active_connections }, { NULL }, }; @@ -290,10 +340,17 @@ register_for_property_changed (NMClient *client) property_changed_info); } -#define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network" -#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI "org.freedesktop.NetworkManager.enable-disable-wifi" -#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN "org.freedesktop.NetworkManager.enable-disable-wwan" -#define NM_AUTH_PERMISSION_USE_USER_CONNECTIONS "org.freedesktop.NetworkManager.use-user-connections" +#define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network" +#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI "org.freedesktop.NetworkManager.enable-disable-wifi" +#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN "org.freedesktop.NetworkManager.enable-disable-wwan" +#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX "org.freedesktop.NetworkManager.enable-disable-wimax" +#define NM_AUTH_PERMISSION_SLEEP_WAKE "org.freedesktop.NetworkManager.sleep-wake" +#define NM_AUTH_PERMISSION_NETWORK_CONTROL "org.freedesktop.NetworkManager.network-control" +#define NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED "org.freedesktop.NetworkManager.wifi.share.protected" +#define NM_AUTH_PERMISSION_WIFI_SHARE_OPEN "org.freedesktop.NetworkManager.wifi.share.open" +#define NM_AUTH_PERMISSION_SETTINGS_MODIFY_SYSTEM "org.freedesktop.NetworkManager.settings.modify.system" +#define NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN "org.freedesktop.NetworkManager.settings.modify.own" +#define NM_AUTH_PERMISSION_SETTINGS_MODIFY_HOSTNAME "org.freedesktop.NetworkManager.settings.modify.hostname" static NMClientPermission nm_permission_to_client (const char *nm) @@ -304,8 +361,23 @@ nm_permission_to_client (const char *nm) return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI; else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN)) return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN; - else if (!strcmp (nm, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS)) - return NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS; + else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX)) + return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX; + else if (!strcmp (nm, NM_AUTH_PERMISSION_SLEEP_WAKE)) + return NM_CLIENT_PERMISSION_SLEEP_WAKE; + else if (!strcmp (nm, NM_AUTH_PERMISSION_NETWORK_CONTROL)) + return NM_CLIENT_PERMISSION_NETWORK_CONTROL; + else if (!strcmp (nm, NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED)) + return NM_CLIENT_PERMISSION_WIFI_SHARE_PROTECTED; + else if (!strcmp (nm, NM_AUTH_PERMISSION_WIFI_SHARE_OPEN)) + return NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN; + else if (!strcmp (nm, NM_AUTH_PERMISSION_SETTINGS_MODIFY_SYSTEM)) + return NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM; + else if (!strcmp (nm, NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN)) + return NM_CLIENT_PERMISSION_SETTINGS_MODIFY_OWN; + else if (!strcmp (nm, NM_AUTH_PERMISSION_SETTINGS_MODIFY_HOSTNAME)) + return NM_CLIENT_PERMISSION_SETTINGS_MODIFY_HOSTNAME; + return NM_CLIENT_PERMISSION_NONE; } @@ -414,495 +486,13 @@ client_recheck_permissions (DBusGProxy *proxy, gpointer user_data) } } -static GObject* -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - NMObject *object; - DBusGConnection *connection; - NMClientPrivate *priv; - GError *err = NULL; - - object = (NMObject *) G_OBJECT_CLASS (nm_client_parent_class)->constructor (type, - n_construct_params, - construct_params); - if (!object) - return NULL; - - priv = NM_CLIENT_GET_PRIVATE (object); - connection = nm_object_get_connection (object); - - priv->client_proxy = dbus_g_proxy_new_for_name (connection, - NM_DBUS_SERVICE, - nm_object_get_path (object), - NM_DBUS_INTERFACE); - - register_for_property_changed (NM_CLIENT (object)); - - dbus_g_proxy_add_signal (priv->client_proxy, "DeviceAdded", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->client_proxy, - "DeviceAdded", - G_CALLBACK (client_device_added_proxy), - object, - NULL); - - dbus_g_proxy_add_signal (priv->client_proxy, "DeviceRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->client_proxy, - "DeviceRemoved", - G_CALLBACK (client_device_removed_proxy), - object, - NULL); - - /* Permissions */ - dbus_g_proxy_add_signal (priv->client_proxy, "CheckPermissions", G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->client_proxy, - "CheckPermissions", - G_CALLBACK (client_recheck_permissions), - object, - NULL); - get_permissions_sync (NM_CLIENT (object)); - - priv->bus_proxy = dbus_g_proxy_new_for_name (connection, - "org.freedesktop.DBus", - "/org/freedesktop/DBus", - "org.freedesktop.DBus"); - - dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->bus_proxy, - "NameOwnerChanged", - G_CALLBACK (proxy_name_owner_changed), - object, NULL); - - if (!dbus_g_proxy_call (priv->bus_proxy, - "NameHasOwner", &err, - G_TYPE_STRING, NM_DBUS_SERVICE, - G_TYPE_INVALID, - G_TYPE_BOOLEAN, &priv->manager_running, - G_TYPE_INVALID)) { - g_warning ("Error on NameHasOwner DBUS call: %s", err->message); - g_error_free (err); - } - - if (priv->manager_running) { - update_wireless_status (NM_CLIENT (object), FALSE); - update_wwan_status (NM_CLIENT (object), FALSE); - nm_client_get_state (NM_CLIENT (object)); - } - - g_signal_connect (G_OBJECT (object), "notify::" NM_CLIENT_WIRELESS_ENABLED, - G_CALLBACK (wireless_enabled_cb), NULL); - - return G_OBJECT (object); -} - -static void -free_object_array (GPtrArray **array) -{ - g_return_if_fail (array != NULL); - - if (*array) { - g_ptr_array_foreach (*array, (GFunc) g_object_unref, NULL); - g_ptr_array_free (*array, TRUE); - *array = NULL; - } -} - -static void -dispose (GObject *object) -{ - NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object); - - if (priv->disposed) { - G_OBJECT_CLASS (nm_client_parent_class)->dispose (object); - return; - } - - if (priv->perm_call) - dbus_g_proxy_cancel_call (priv->client_proxy, priv->perm_call); - - g_object_unref (priv->client_proxy); - g_object_unref (priv->bus_proxy); - - free_object_array (&priv->devices); - free_object_array (&priv->active_connections); - - g_hash_table_destroy (priv->permissions); - - G_OBJECT_CLASS (nm_client_parent_class)->dispose (object); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object); - gboolean b; - - switch (prop_id) { - case PROP_WIRELESS_ENABLED: - b = g_value_get_boolean (value); - if (priv->wireless_enabled != b) { - priv->wireless_enabled = b; - _nm_object_queue_notify (NM_OBJECT (object), NM_CLIENT_WIRELESS_ENABLED); - } - break; - case PROP_WIRELESS_HARDWARE_ENABLED: - b = g_value_get_boolean (value); - if (priv->wireless_hw_enabled != b) { - priv->wireless_hw_enabled = b; - _nm_object_queue_notify (NM_OBJECT (object), NM_CLIENT_WIRELESS_HARDWARE_ENABLED); - } - break; - case PROP_WWAN_ENABLED: - b = g_value_get_boolean (value); - if (priv->wwan_enabled != b) { - priv->wwan_enabled = b; - _nm_object_queue_notify (NM_OBJECT (object), NM_CLIENT_WWAN_ENABLED); - } - break; - case PROP_WWAN_HARDWARE_ENABLED: - b = g_value_get_boolean (value); - if (priv->wwan_hw_enabled != b) { - priv->wwan_hw_enabled = b; - _nm_object_queue_notify (NM_OBJECT (object), NM_CLIENT_WWAN_HARDWARE_ENABLED); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - NMClient *self = NM_CLIENT (object); - NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self); - - switch (prop_id) { - case PROP_STATE: - g_value_set_uint (value, nm_client_get_state (self)); - break; - case PROP_MANAGER_RUNNING: - g_value_set_boolean (value, priv->manager_running); - break; - case PROP_NETWORKING_ENABLED: - g_value_set_boolean (value, priv->networking_enabled); - break; - case PROP_WIRELESS_ENABLED: - g_value_set_boolean (value, priv->wireless_enabled); - break; - case PROP_WIRELESS_HARDWARE_ENABLED: - g_value_set_boolean (value, priv->wireless_hw_enabled); - break; - case PROP_WWAN_ENABLED: - g_value_set_boolean (value, priv->wwan_enabled); - break; - case PROP_WWAN_HARDWARE_ENABLED: - g_value_set_boolean (value, priv->wwan_hw_enabled); - break; - case PROP_ACTIVE_CONNECTIONS: - g_value_set_boxed (value, nm_client_get_active_connections (self)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -nm_client_class_init (NMClientClass *client_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (client_class); - - g_type_class_add_private (client_class, sizeof (NMClientPrivate)); - - /* virtual methods */ - object_class->constructor = constructor; - object_class->set_property = set_property; - object_class->get_property = get_property; - object_class->dispose = dispose; - - /* properties */ - - /** - * NMClient:state: - * - * The current daemon state. - **/ - g_object_class_install_property - (object_class, PROP_STATE, - g_param_spec_uint (NM_CLIENT_STATE, - "State", - "NetworkManager state", - NM_STATE_UNKNOWN, NM_STATE_DISCONNECTED, NM_STATE_UNKNOWN, - G_PARAM_READABLE)); - - /** - * NMClient::manager-running: - * - * Whether the daemon is running. - **/ - g_object_class_install_property - (object_class, PROP_MANAGER_RUNNING, - g_param_spec_boolean (NM_CLIENT_MANAGER_RUNNING, - "ManagerRunning", - "Whether NetworkManager is running", - FALSE, - G_PARAM_READABLE)); - - /** - * NMClient::networking-enabled: - * - * Whether networking is enabled. - **/ - g_object_class_install_property - (object_class, PROP_NETWORKING_ENABLED, - g_param_spec_boolean (NM_CLIENT_NETWORKING_ENABLED, - "NetworkingEnabled", - "Is networking enabled", - TRUE, - G_PARAM_READABLE)); - - /** - * NMClient::wireless-enabled: - * - * Whether wireless is enabled. - **/ - g_object_class_install_property - (object_class, PROP_WIRELESS_ENABLED, - g_param_spec_boolean (NM_CLIENT_WIRELESS_ENABLED, - "WirelessEnabled", - "Is wireless enabled", - TRUE, - G_PARAM_READWRITE)); - - /** - * NMClient::wireless-hardware-enabled: - * - * Whether the wireless hardware is enabled. - **/ - g_object_class_install_property - (object_class, PROP_WIRELESS_HARDWARE_ENABLED, - g_param_spec_boolean (NM_CLIENT_WIRELESS_HARDWARE_ENABLED, - "WirelessHardwareEnabled", - "Is wireless hardware enabled", - TRUE, - G_PARAM_READABLE)); - - /** - * NMClient::wwan-enabled: - * - * Whether WWAN functionality is enabled. - **/ - g_object_class_install_property - (object_class, PROP_WWAN_ENABLED, - g_param_spec_boolean (NM_CLIENT_WWAN_ENABLED, - "WwanEnabled", - "Is WWAN enabled", - TRUE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - /** - * NMClient::wwan-hardware-enabled: - * - * Whether the WWAN hardware is enabled. - **/ - g_object_class_install_property - (object_class, PROP_WWAN_HARDWARE_ENABLED, - g_param_spec_boolean (NM_CLIENT_WWAN_HARDWARE_ENABLED, - "WwanHardwareEnabled", - "Is WWAN hardware enabled", - TRUE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - /** - * NMClient::active-connections: - * - * The active connections. - **/ - g_object_class_install_property - (object_class, PROP_ACTIVE_CONNECTIONS, - g_param_spec_boxed (NM_CLIENT_ACTIVE_CONNECTIONS, - "Active connections", - "Active connections", - NM_TYPE_OBJECT_ARRAY, - G_PARAM_READABLE)); - - /* signals */ - - /** - * NMClient::device-added: - * @client: the client that received the signal - * @device: the new device - * - * Notifies that a #NMDevice is added. - **/ - signals[DEVICE_ADDED] = - g_signal_new ("device-added", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMClientClass, device_added), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - G_TYPE_OBJECT); - - /** - * NMClient::device-removed: - * @widget: the client that received the signal - * @device: the removed device - * - * Notifies that a #NMDevice is removed. - **/ - signals[DEVICE_REMOVED] = - g_signal_new ("device-removed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMClientClass, device_removed), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - G_TYPE_OBJECT); - - /** - * NMClient::permission-changed: - * @widget: the client that received the signal - * @permission: a permission from #NMClientPermission - * @result: the permission's result, one of #NMClientPermissionResult - * - * Notifies that a permission has changed - **/ - signals[PERMISSION_CHANGED] = - g_signal_new ("permission-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, - _nm_marshal_VOID__UINT_UINT, - G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); -} - -/** - * nm_client_new: - * - * Creates a new #NMClient. - * - * Returns: a new #NMClient - **/ -NMClient * -nm_client_new (void) -{ - DBusGConnection *connection; - GError *err = NULL; - - connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err); - if (!connection) { - g_warning ("Couldn't connect to system bus: %s", err->message); - g_error_free (err); - return NULL; - } - - return (NMClient *) g_object_new (NM_TYPE_CLIENT, - NM_OBJECT_DBUS_CONNECTION, connection, - NM_OBJECT_DBUS_PATH, NM_DBUS_PATH, - NULL); -} - -static void -proxy_name_owner_changed (DBusGProxy *proxy, - const char *name, - const char *old_owner, - const char *new_owner, - gpointer user_data) -{ - NMClient *client = NM_CLIENT (user_data); - NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); - gboolean old_good = (old_owner && strlen (old_owner)); - gboolean new_good = (new_owner && strlen (new_owner)); - gboolean new_running = FALSE; - - if (!name || strcmp (name, NM_DBUS_SERVICE)) - return; - - if (!old_good && new_good) - new_running = TRUE; - else if (old_good && !new_good) - new_running = FALSE; - - if (new_running == priv->manager_running) - return; - - priv->manager_running = new_running; - if (!priv->manager_running) { - priv->state = NM_STATE_UNKNOWN; - _nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_MANAGER_RUNNING); - poke_wireless_devices_with_rf_status (client); - free_object_array (&priv->devices); - free_object_array (&priv->active_connections); - priv->wireless_enabled = FALSE; - priv->wireless_hw_enabled = FALSE; - priv->wwan_enabled = FALSE; - priv->wwan_hw_enabled = FALSE; - } else { - _nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_MANAGER_RUNNING); - update_wireless_status (client, TRUE); - update_wwan_status (client, TRUE); - } -} - -static void -client_device_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data) -{ - NMClient *client = NM_CLIENT (user_data); - NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); - GObject *device; - - device = G_OBJECT (nm_client_get_device_by_path (client, path)); - if (!device) { - DBusGConnection *connection = nm_object_get_connection (NM_OBJECT (client)); - - device = G_OBJECT (_nm_object_cache_get (path)); - if (device) { - g_ptr_array_add (priv->devices, g_object_ref (device)); - } else { - device = G_OBJECT (nm_device_new (connection, path)); - if (device) - g_ptr_array_add (priv->devices, device); - } - } - - if (device) - g_signal_emit (client, signals[DEVICE_ADDED], 0, device); -} - -static void -client_device_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data) -{ - NMClient *client = NM_CLIENT (user_data); - NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); - NMDevice *device; - - device = nm_client_get_device_by_path (client, path); - if (device) { - g_signal_emit (client, signals[DEVICE_REMOVED], 0, device); - g_ptr_array_remove (priv->devices, device); - g_object_unref (device); - } -} - /** * nm_client_get_devices: * @client: a #NMClient * * Gets all the detected devices. * - * Returns: a #GPtrArray containing all the #NMDevice<!-- -->s. + * Returns: (transfer none) (element-type NMClient.Device): a #GPtrArray containing all the #NMDevice<!-- -->s. * The returned array is owned by the client and should not be modified. **/ const GPtrArray * @@ -942,7 +532,7 @@ nm_client_get_devices (NMClient *client) * * Gets a #NMDevice from a #NMClient. * - * Returns: the #NMDevice for the given @object_path or %NULL if none is found. + * Returns: (transfer none): the #NMDevice for the given @object_path or %NULL if none is found. **/ NMDevice * nm_client_get_device_by_path (NMClient *client, const char *object_path) @@ -970,9 +560,75 @@ nm_client_get_device_by_path (NMClient *client, const char *object_path) } typedef struct { - NMClientActivateDeviceFn fn; + NMClient *client; + NMClientActivateFn act_fn; + NMClientAddActivateFn add_act_fn; + char *active_path; + char *new_connection_path; gpointer user_data; -} ActivateDeviceInfo; +} ActivateInfo; + +static void +activate_info_free (ActivateInfo *info) +{ + g_free (info->active_path); + g_free (info->new_connection_path); + memset (info, 0, sizeof (*info)); + g_slice_free (ActivateInfo, info); +} + +static void +activate_info_complete (ActivateInfo *info, + NMActiveConnection *active, + GError *error) +{ + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (info->client); + + if (info->act_fn) + info->act_fn (info->client, error ? NULL : active, error, info->user_data); + else if (info->add_act_fn) { + info->add_act_fn (info->client, + error ? NULL : active, + error ? NULL : info->new_connection_path, + error, + info->user_data); + } else if (error) + g_warning ("Device activation failed: (%d) %s", error->code, error->message); + + priv->pending_activations = g_slist_remove (priv->pending_activations, info); +} + +static void +recheck_pending_activations (NMClient *self) +{ + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self); + GSList *iter; + const GPtrArray *active_connections; + int i; + + active_connections = nm_client_get_active_connections (self); + if (!active_connections) + return; + + /* For each active connection, look for a pending activation that has + * the active connection's object path, and call its callback. + */ + for (i = 0; i < active_connections->len; i++) { + NMActiveConnection *active = g_ptr_array_index (active_connections, i); + const char *active_path = nm_object_get_path (NM_OBJECT (active)); + + for (iter = priv->pending_activations; iter; iter = g_slist_next (iter)) { + ActivateInfo *info = iter->data; + + if (g_strcmp0 (info->active_path, active_path) == 0) { + /* Call the pending activation's callback and it all up*/ + activate_info_complete (info, active, NULL); + activate_info_free (info); + break; + } + } + } +} static void activate_cb (DBusGProxy *proxy, @@ -980,63 +636,154 @@ activate_cb (DBusGProxy *proxy, GError *error, gpointer user_data) { - ActivateDeviceInfo *info = (ActivateDeviceInfo *) user_data; - - if (info->fn) - info->fn (info->user_data, path, error); - else if (error) - nm_warning ("Device activation failed: (%d) %s", error->code, error->message); + ActivateInfo *info = user_data; - g_slice_free (ActivateDeviceInfo, info); + if (error) { + activate_info_complete (info, NULL, error); + activate_info_free (info); + } else { + info->active_path = g_strdup (path); + recheck_pending_activations (info->client); + } } /** * nm_client_activate_connection: * @client: a #NMClient - * @service_name: the connection's service name - * @connection_path: the connection's DBus path - * @device: the #NMDevice - * @specific_object: the device specific object (currently used only for - * activating wireless devices and should be the #NMAccessPoint<!-- -->'s path. - * @callback: the function to call when the call is done - * @user_data: user data to pass to the callback function + * @connection: an #NMConnection + * @device: (allow-none): the #NMDevice + * @specific_object: (allow-none): the object path of a connection-type-specific + * object this activation should use. This parameter is currently ignored for + * wired and mobile broadband connections, and the value of NULL should be used + * (ie, no specific object). For WiFi or WiMAX connections, pass the object + * path of a #NMAccessPoint or #NMWimaxNsp owned by @device, which you can + * get using nm_object_get_path(), and which will be used to complete the + * details of the newly added connection. + * @callback: (scope async) (allow-none): the function to call when the call is done + * @user_data: (closure): user data to pass to the callback function * - * Activates a connection with the given #NMDevice. + * Starts a connection to a particular network using the configuration settings + * from @connection and the network device @device. Certain connection types + * also take a "specific object" which is the object path of a connection- + * specific object, like an #NMAccessPoint for WiFi connections, or an + * #NMWimaxNsp for WiMAX connections, to which you wish to connect. If the + * specific object is not given, NetworkManager can, in some cases, automatically + * determine which network to connect to given the settings in @connection. **/ void nm_client_activate_connection (NMClient *client, - const char *service_name, - const char *connection_path, - NMDevice *device, - const char *specific_object, - NMClientActivateDeviceFn callback, - gpointer user_data) + NMConnection *connection, + NMDevice *device, + const char *specific_object, + NMClientActivateFn callback, + gpointer user_data) +{ + NMClientPrivate *priv; + ActivateInfo *info; + + g_return_if_fail (NM_IS_CLIENT (client)); + if (device) + g_return_if_fail (NM_IS_DEVICE (device)); + g_return_if_fail (NM_IS_CONNECTION (connection)); + + info = g_slice_new0 (ActivateInfo); + info->act_fn = callback; + info->user_data = user_data; + info->client = client; + + priv = NM_CLIENT_GET_PRIVATE (client); + priv->pending_activations = g_slist_prepend (priv->pending_activations, info); + + org_freedesktop_NetworkManager_activate_connection_async (priv->client_proxy, + nm_connection_get_path (connection), + device ? nm_object_get_path (NM_OBJECT (device)) : "/", + specific_object ? specific_object : "/", + activate_cb, + info); +} + +static void +add_activate_cb (DBusGProxy *proxy, + char *connection_path, + char *active_path, + GError *error, + gpointer user_data) +{ + ActivateInfo *info = user_data; + + if (error) { + activate_info_complete (info, NULL, error); + activate_info_free (info); + } else { + info->new_connection_path = g_strdup (connection_path); + info->active_path = g_strdup (active_path); + recheck_pending_activations (info->client); + } +} + +/** + * nm_client_add_and_activate_connection: + * @client: a #NMClient + * @partial: (allow-none): an #NMConnection to add; the connection may be + * partially filled (or even NULL) and will be completed by NetworkManager + * using the given @device and @specific_object before being added + * @device: the #NMDevice + * @specific_object: (allow-none): the object path of a connection-type-specific + * object this activation should use. This parameter is currently ignored for + * wired and mobile broadband connections, and the value of NULL should be used + * (ie, no specific object). For WiFi or WiMAX connections, pass the object + * path of a #NMAccessPoint or #NMWimaxNsp owned by @device, which you can + * get using nm_object_get_path(), and which will be used to complete the + * details of the newly added connection. + * @callback: (scope async) (allow-none): the function to call when the call is done + * @user_data: (closure): user data to pass to the callback function + * + * Adds a new connection using the given details (if any) as a template, + * automatically filling in missing settings with the capabilities of the + * given device and specific object. The new connection is then activated. + * Cannot be used for VPN connections at this time. + **/ +void +nm_client_add_and_activate_connection (NMClient *client, + NMConnection *partial, + NMDevice *device, + const char *specific_object, + NMClientAddActivateFn callback, + gpointer user_data) { - ActivateDeviceInfo *info; - char *internal_so = (char *) specific_object; + NMClientPrivate *priv; + ActivateInfo *info; + GHashTable *hash = NULL; g_return_if_fail (NM_IS_CLIENT (client)); g_return_if_fail (NM_IS_DEVICE (device)); - g_return_if_fail (service_name != NULL); - g_return_if_fail (connection_path != NULL); - - /* NULL specific object must be translated into "/" because D-Bus does - * not have any idea of NULL object paths. - */ - if (internal_so == NULL) - internal_so = "/"; - info = g_slice_new (ActivateDeviceInfo); - info->fn = callback; + info = g_slice_new0 (ActivateInfo); + info->add_act_fn = callback; info->user_data = user_data; + info->client = client; - org_freedesktop_NetworkManager_activate_connection_async (NM_CLIENT_GET_PRIVATE (client)->client_proxy, - service_name, - connection_path, - nm_object_get_path (NM_OBJECT (device)), - internal_so, - activate_cb, - info); + if (partial) + hash = nm_connection_to_hash (partial, NM_SETTING_HASH_FLAG_ALL); + else + hash = g_hash_table_new (g_str_hash, g_str_equal); + + priv = NM_CLIENT_GET_PRIVATE (client); + priv->pending_activations = g_slist_prepend (priv->pending_activations, info); + + org_freedesktop_NetworkManager_add_and_activate_connection_async (priv->client_proxy, + hash, + nm_object_get_path (NM_OBJECT (device)), + specific_object ? specific_object : "/", + add_activate_cb, + info); + g_hash_table_unref (hash); +} + +static void +active_connections_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data) +{ + recheck_pending_activations (NM_CLIENT (object)); } /** @@ -1071,7 +818,8 @@ nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active) * * Gets the active connections. * - * Returns: a #GPtrArray containing all the active #NMActiveConnection<!-- -->s. + * Returns: (transfer none) (element-type NMClient.ActiveConnection): a #GPtrArray +* containing all the active #NMActiveConnection<!-- -->s. * The returned array is owned by the client and should not be modified. **/ const GPtrArray * @@ -1092,11 +840,12 @@ nm_client_get_active_connections (NMClient *client) if (!_nm_object_get_property (NM_OBJECT (client), "org.freedesktop.NetworkManager", "ActiveConnections", - &value)) { + &value, + NULL)) { return NULL; } - demarshal_active_connections (NM_OBJECT (client), NULL, &value, &priv->active_connections); + demarshal_active_connections (NM_OBJECT (client), NULL, &value, &priv->active_connections); g_value_unset (&value); return handle_ptr_array_return (priv->active_connections); @@ -1213,6 +962,92 @@ nm_client_wwan_hardware_get_enabled (NMClient *client) } /** + * nm_client_wimax_get_enabled: + * @client: a #NMClient + * + * Determines whether WiMAX is enabled. + * + * Returns: %TRUE if WiMAX is enabled + **/ +gboolean +nm_client_wimax_get_enabled (NMClient *client) +{ + g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); + + return NM_CLIENT_GET_PRIVATE (client)->wimax_enabled; +} + +/** + * nm_client_wimax_set_enabled: + * @client: a #NMClient + * @enabled: %TRUE to enable WiMAX + * + * Enables or disables WiMAX devices. + **/ +void +nm_client_wimax_set_enabled (NMClient *client, gboolean enabled) +{ + GValue value = {0,}; + + g_return_if_fail (NM_IS_CLIENT (client)); + + g_value_init (&value, G_TYPE_BOOLEAN); + g_value_set_boolean (&value, enabled); + + _nm_object_set_property (NM_OBJECT (client), + NM_DBUS_INTERFACE, + "WimaxEnabled", + &value); +} + +/** + * nm_client_wimax_hardware_get_enabled: + * @client: a #NMClient + * + * Determines whether the WiMAX hardware is enabled. + * + * Returns: %TRUE if the WiMAX hardware is enabled + **/ +gboolean +nm_client_wimax_hardware_get_enabled (NMClient *client) +{ + g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); + + return NM_CLIENT_GET_PRIVATE (client)->wimax_hw_enabled; +} + +/** + * nm_client_get_version: + * @client: a #NMClient + * + * Gets NetworkManager version. + * + * Returns: string with the version + **/ +const char * +nm_client_get_version (NMClient *client) +{ + NMClientPrivate *priv; + GError *err = NULL; + + g_return_val_if_fail (NM_IS_CLIENT (client), NULL); + + priv = NM_CLIENT_GET_PRIVATE (client); + + if (!priv->manager_running) + return NULL; + + if (!priv->version) + priv->version = _nm_object_get_string_property (NM_OBJECT (client), NM_DBUS_INTERFACE, "Version", &err); + + /* TODO: we don't pass the error to the caller yet, maybe later */ + if (err) + g_error_free (err); + + return priv->version; +} + +/** * nm_client_get_state: * @client: a #NMClient * @@ -1233,7 +1068,7 @@ nm_client_get_state (NMClient *client) return NM_STATE_UNKNOWN; if (priv->state == NM_STATE_UNKNOWN) - priv->state = _nm_object_get_uint_property (NM_OBJECT (client), NM_DBUS_INTERFACE, "State"); + priv->state = _nm_object_get_uint_property (NM_OBJECT (client), NM_DBUS_INTERFACE, "State", NULL); return priv->state; } @@ -1259,7 +1094,8 @@ nm_client_networking_get_enabled (NMClient *client) if (!priv->networking_enabled) { priv->networking_enabled = _nm_object_get_boolean_property (NM_OBJECT (client), NM_DBUS_INTERFACE, - "NetworkingEnabled"); + "NetworkingEnabled", + NULL); priv->have_networking_enabled = TRUE; } } @@ -1340,3 +1176,566 @@ nm_client_get_permission_result (NMClient *client, NMClientPermission permission return GPOINTER_TO_UINT (result); } +/****************************************************************/ + +static void +free_object_array (GPtrArray **array) +{ + g_return_if_fail (array != NULL); + + if (*array) { + g_ptr_array_foreach (*array, (GFunc) g_object_unref, NULL); + g_ptr_array_free (*array, TRUE); + *array = NULL; + } +} + +static void +proxy_name_owner_changed (DBusGProxy *proxy, + const char *name, + const char *old_owner, + const char *new_owner, + gpointer user_data) +{ + NMClient *client = NM_CLIENT (user_data); + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); + gboolean old_good = (old_owner && strlen (old_owner)); + gboolean new_good = (new_owner && strlen (new_owner)); + gboolean new_running = FALSE; + + if (!name || strcmp (name, NM_DBUS_SERVICE)) + return; + + if (!old_good && new_good) + new_running = TRUE; + else if (old_good && !new_good) + new_running = FALSE; + + if (new_running == priv->manager_running) + return; + + priv->manager_running = new_running; + if (!priv->manager_running) { + priv->state = NM_STATE_UNKNOWN; + _nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_MANAGER_RUNNING); + poke_wireless_devices_with_rf_status (client); + free_object_array (&priv->devices); + free_object_array (&priv->active_connections); + priv->wireless_enabled = FALSE; + priv->wireless_hw_enabled = FALSE; + priv->wwan_enabled = FALSE; + priv->wwan_hw_enabled = FALSE; + priv->wimax_enabled = FALSE; + priv->wimax_hw_enabled = FALSE; + } else { + _nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_MANAGER_RUNNING); + update_wireless_status (client, TRUE); + update_wwan_status (client, TRUE); +#if WITH_WIMAX + update_wimax_status (client, TRUE); +#endif + } +} + +static void +client_device_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data) +{ + NMClient *client = NM_CLIENT (user_data); + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); + GObject *device; + + device = G_OBJECT (nm_client_get_device_by_path (client, path)); + if (!device) { + DBusGConnection *connection = nm_object_get_connection (NM_OBJECT (client)); + + device = G_OBJECT (_nm_object_cache_get (path)); + if (device) { + g_ptr_array_add (priv->devices, device); + } else { + device = G_OBJECT (nm_device_new (connection, path)); + if (device) + g_ptr_array_add (priv->devices, device); + } + } + + if (device) + g_signal_emit (client, signals[DEVICE_ADDED], 0, device); +} + +static void +client_device_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data) +{ + NMClient *client = NM_CLIENT (user_data); + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); + NMDevice *device; + + device = nm_client_get_device_by_path (client, path); + if (device) { + g_signal_emit (client, signals[DEVICE_REMOVED], 0, device); + g_ptr_array_remove (priv->devices, device); + g_object_unref (device); + } +} + +/****************************************************************/ + +/** + * nm_client_new: + * + * Creates a new #NMClient. + * + * Returns: a new #NMClient + **/ +NMClient * +nm_client_new (void) +{ + DBusGConnection *connection; + GError *err = NULL; + +#ifdef LIBNM_GLIB_TEST + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &err); +#else + connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err); +#endif + if (!connection) { + g_warning ("Couldn't connect to system bus: %s", err->message); + g_error_free (err); + return NULL; + } + + return (NMClient *) g_object_new (NM_TYPE_CLIENT, + NM_OBJECT_DBUS_CONNECTION, connection, + NM_OBJECT_DBUS_PATH, NM_DBUS_PATH, + NULL); +} + +static GObject* +constructor (GType type, + guint n_construct_params, + GObjectConstructParam *construct_params) +{ + NMObject *object; + DBusGConnection *connection; + NMClientPrivate *priv; + GError *err = NULL; + + object = (NMObject *) G_OBJECT_CLASS (nm_client_parent_class)->constructor (type, + n_construct_params, + construct_params); + if (!object) + return NULL; + + priv = NM_CLIENT_GET_PRIVATE (object); + connection = nm_object_get_connection (object); + + priv->client_proxy = dbus_g_proxy_new_for_name (connection, + NM_DBUS_SERVICE, + nm_object_get_path (object), + NM_DBUS_INTERFACE); + + register_for_property_changed (NM_CLIENT (object)); + + dbus_g_proxy_add_signal (priv->client_proxy, "DeviceAdded", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->client_proxy, + "DeviceAdded", + G_CALLBACK (client_device_added_proxy), + object, + NULL); + + dbus_g_proxy_add_signal (priv->client_proxy, "DeviceRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->client_proxy, + "DeviceRemoved", + G_CALLBACK (client_device_removed_proxy), + object, + NULL); + + /* Permissions */ + dbus_g_proxy_add_signal (priv->client_proxy, "CheckPermissions", G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->client_proxy, + "CheckPermissions", + G_CALLBACK (client_recheck_permissions), + object, + NULL); + get_permissions_sync (NM_CLIENT (object)); + + priv->bus_proxy = dbus_g_proxy_new_for_name (connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + + dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->bus_proxy, + "NameOwnerChanged", + G_CALLBACK (proxy_name_owner_changed), + object, NULL); + + if (!dbus_g_proxy_call (priv->bus_proxy, + "NameHasOwner", &err, + G_TYPE_STRING, NM_DBUS_SERVICE, + G_TYPE_INVALID, + G_TYPE_BOOLEAN, &priv->manager_running, + G_TYPE_INVALID)) { + g_warning ("Error on NameHasOwner DBUS call: %s", err->message); + g_error_free (err); + } + + if (priv->manager_running) { + update_wireless_status (NM_CLIENT (object), FALSE); + update_wwan_status (NM_CLIENT (object), FALSE); +#if WITH_WIMAX + update_wimax_status (NM_CLIENT (object), FALSE); +#endif + nm_client_get_state (NM_CLIENT (object)); + } + + g_signal_connect (G_OBJECT (object), "notify::" NM_CLIENT_WIRELESS_ENABLED, + G_CALLBACK (wireless_enabled_cb), NULL); + + g_signal_connect (object, "notify::" NM_CLIENT_ACTIVE_CONNECTIONS, + G_CALLBACK (active_connections_changed_cb), NULL); + + return G_OBJECT (object); +} + +static void +dispose (GObject *object) +{ + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object); + + if (priv->disposed) { + G_OBJECT_CLASS (nm_client_parent_class)->dispose (object); + return; + } + + if (priv->perm_call) + dbus_g_proxy_cancel_call (priv->client_proxy, priv->perm_call); + + g_object_unref (priv->client_proxy); + g_object_unref (priv->bus_proxy); + + free_object_array (&priv->devices); + free_object_array (&priv->active_connections); + + g_slist_foreach (priv->pending_activations, (GFunc) activate_info_free, NULL); + g_slist_free (priv->pending_activations); + + g_hash_table_destroy (priv->permissions); + + G_OBJECT_CLASS (nm_client_parent_class)->dispose (object); +} + +static void +finalize (GObject *object) +{ + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object); + + g_free (priv->version); + + G_OBJECT_CLASS (nm_client_parent_class)->finalize (object); +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object); + gboolean b; + + switch (prop_id) { + case PROP_NETWORKING_ENABLED: + b = g_value_get_boolean (value); + if (priv->networking_enabled != b) { + nm_client_networking_set_enabled (NM_CLIENT (object), b); + /* Let the property value flip when we get the change signal from NM */ + } + break; + case PROP_WIRELESS_ENABLED: + b = g_value_get_boolean (value); + if (priv->wireless_enabled != b) { + nm_client_wireless_set_enabled (NM_CLIENT (object), b); + /* Let the property value flip when we get the change signal from NM */ + } + break; + case PROP_WWAN_ENABLED: + b = g_value_get_boolean (value); + if (priv->wwan_enabled != b) { + nm_client_wwan_set_enabled (NM_CLIENT (object), b); + /* Let the property value flip when we get the change signal from NM */ + } + break; + case PROP_WIMAX_ENABLED: + b = g_value_get_boolean (value); + if (priv->wimax_enabled != b) { + nm_client_wimax_set_enabled (NM_CLIENT (object), b); + /* Let the property value flip when we get the change signal from NM */ + } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NMClient *self = NM_CLIENT (object); + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self); + + switch (prop_id) { + case PROP_VERSION: + g_value_set_string (value, nm_client_get_version (self)); + break; + case PROP_STATE: + g_value_set_uint (value, nm_client_get_state (self)); + break; + case PROP_MANAGER_RUNNING: + g_value_set_boolean (value, priv->manager_running); + break; + case PROP_NETWORKING_ENABLED: + g_value_set_boolean (value, nm_client_networking_get_enabled (self)); + break; + case PROP_WIRELESS_ENABLED: + g_value_set_boolean (value, priv->wireless_enabled); + break; + case PROP_WIRELESS_HARDWARE_ENABLED: + g_value_set_boolean (value, priv->wireless_hw_enabled); + break; + case PROP_WWAN_ENABLED: + g_value_set_boolean (value, priv->wwan_enabled); + break; + case PROP_WWAN_HARDWARE_ENABLED: + g_value_set_boolean (value, priv->wwan_hw_enabled); + break; + case PROP_WIMAX_ENABLED: + g_value_set_boolean (value, priv->wimax_enabled); + break; + case PROP_WIMAX_HARDWARE_ENABLED: + g_value_set_boolean (value, priv->wimax_hw_enabled); + break; + case PROP_ACTIVE_CONNECTIONS: + g_value_set_boxed (value, nm_client_get_active_connections (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_client_class_init (NMClientClass *client_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (client_class); + + g_type_class_add_private (client_class, sizeof (NMClientPrivate)); + + /* virtual methods */ + object_class->constructor = constructor; + object_class->set_property = set_property; + object_class->get_property = get_property; + object_class->dispose = dispose; + object_class->finalize = finalize; + + /* properties */ + + /** + * NMClient:version: + * + * The NetworkManager version. + **/ + g_object_class_install_property (object_class, PROP_VERSION, + g_param_spec_string (NM_CLIENT_VERSION, + "Version", + "NetworkManager version", + NULL, + G_PARAM_READABLE)); + + /** + * NMClient:state: + * + * The current daemon state. + **/ + g_object_class_install_property + (object_class, PROP_STATE, + g_param_spec_uint (NM_CLIENT_STATE, + "State", + "NetworkManager state", + NM_STATE_UNKNOWN, NM_STATE_CONNECTED_GLOBAL, NM_STATE_UNKNOWN, + G_PARAM_READABLE)); + + /** + * NMClient::manager-running: + * + * Whether the daemon is running. + **/ + g_object_class_install_property + (object_class, PROP_MANAGER_RUNNING, + g_param_spec_boolean (NM_CLIENT_MANAGER_RUNNING, + "ManagerRunning", + "Whether NetworkManager is running", + FALSE, + G_PARAM_READABLE)); + + /** + * NMClient::networking-enabled: + * + * Whether networking is enabled. + **/ + g_object_class_install_property + (object_class, PROP_NETWORKING_ENABLED, + g_param_spec_boolean (NM_CLIENT_NETWORKING_ENABLED, + "NetworkingEnabled", + "Is networking enabled", + TRUE, + G_PARAM_READWRITE)); + + /** + * NMClient::wireless-enabled: + * + * Whether wireless is enabled. + **/ + g_object_class_install_property + (object_class, PROP_WIRELESS_ENABLED, + g_param_spec_boolean (NM_CLIENT_WIRELESS_ENABLED, + "WirelessEnabled", + "Is wireless enabled", + FALSE, + G_PARAM_READWRITE)); + + /** + * NMClient::wireless-hardware-enabled: + * + * Whether the wireless hardware is enabled. + **/ + g_object_class_install_property + (object_class, PROP_WIRELESS_HARDWARE_ENABLED, + g_param_spec_boolean (NM_CLIENT_WIRELESS_HARDWARE_ENABLED, + "WirelessHardwareEnabled", + "Is wireless hardware enabled", + TRUE, + G_PARAM_READABLE)); + + /** + * NMClient::wwan-enabled: + * + * Whether WWAN functionality is enabled. + **/ + g_object_class_install_property + (object_class, PROP_WWAN_ENABLED, + g_param_spec_boolean (NM_CLIENT_WWAN_ENABLED, + "WwanEnabled", + "Is WWAN enabled", + FALSE, + G_PARAM_READWRITE)); + + /** + * NMClient::wwan-hardware-enabled: + * + * Whether the WWAN hardware is enabled. + **/ + g_object_class_install_property + (object_class, PROP_WWAN_HARDWARE_ENABLED, + g_param_spec_boolean (NM_CLIENT_WWAN_HARDWARE_ENABLED, + "WwanHardwareEnabled", + "Is WWAN hardware enabled", + FALSE, + G_PARAM_READABLE)); + + /** + * NMClient::wimax-enabled: + * + * Whether WiMAX functionality is enabled. + **/ + g_object_class_install_property + (object_class, PROP_WIMAX_ENABLED, + g_param_spec_boolean (NM_CLIENT_WIMAX_ENABLED, + "WimaxEnabled", + "Is WiMAX enabled", + FALSE, + G_PARAM_READWRITE)); + + /** + * NMClient::wimax-hardware-enabled: + * + * Whether the WiMAX hardware is enabled. + **/ + g_object_class_install_property + (object_class, PROP_WIMAX_HARDWARE_ENABLED, + g_param_spec_boolean (NM_CLIENT_WIMAX_HARDWARE_ENABLED, + "WimaxHardwareEnabled", + "Is WiMAX hardware enabled", + FALSE, + G_PARAM_READABLE)); + + /** + * NMClient::active-connections: + * + * The active connections. + * Type: GPtrArray<NMClient.ActiveConnection> + **/ + g_object_class_install_property + (object_class, PROP_ACTIVE_CONNECTIONS, + g_param_spec_boxed (NM_CLIENT_ACTIVE_CONNECTIONS, + "Active connections", + "Active connections", + NM_TYPE_OBJECT_ARRAY, + G_PARAM_READABLE)); + + /* signals */ + + /** + * NMClient::device-added: + * @client: the client that received the signal + * @device: (type NMClient.Device): the new device + * + * Notifies that a #NMDevice is added. + **/ + signals[DEVICE_ADDED] = + g_signal_new ("device-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMClientClass, device_added), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + G_TYPE_OBJECT); + + /** + * NMClient::device-removed: + * @widget: the client that received the signal + * @device: (type NMClient.Device): the removed device + * + * Notifies that a #NMDevice is removed. + **/ + signals[DEVICE_REMOVED] = + g_signal_new ("device-removed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMClientClass, device_removed), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + G_TYPE_OBJECT); + + /** + * NMClient::permission-changed: + * @widget: the client that received the signal + * @permission: a permission from #NMClientPermission + * @result: the permission's result, one of #NMClientPermissionResult + * + * Notifies that a permission has changed + **/ + signals[PERMISSION_CHANGED] = + g_signal_new ("permission-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + _nm_marshal_VOID__UINT_UINT, + G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); +} + diff --git a/libnm-glib/nm-client.h b/libnm-glib/nm-client.h index c67e0d8f8..450c09471 100644 --- a/libnm-glib/nm-client.h +++ b/libnm-glib/nm-client.h @@ -18,7 +18,7 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2010 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ #ifndef NM_CLIENT_H @@ -41,6 +41,7 @@ G_BEGIN_DECLS #define NM_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_CLIENT)) #define NM_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CLIENT, NMClientClass)) +#define NM_CLIENT_VERSION "version" #define NM_CLIENT_STATE "state" #define NM_CLIENT_MANAGER_RUNNING "manager-running" #define NM_CLIENT_NETWORKING_ENABLED "networking-enabled" @@ -48,6 +49,8 @@ G_BEGIN_DECLS #define NM_CLIENT_WIRELESS_HARDWARE_ENABLED "wireless-hardware-enabled" #define NM_CLIENT_WWAN_ENABLED "wwan-enabled" #define NM_CLIENT_WWAN_HARDWARE_ENABLED "wwan-hardware-enabled" +#define NM_CLIENT_WIMAX_ENABLED "wimax-enabled" +#define NM_CLIENT_WIMAX_HARDWARE_ENABLED "wimax-hardware-enabled" #define NM_CLIENT_ACTIVE_CONNECTIONS "active-connections" /* Permissions */ @@ -56,9 +59,16 @@ typedef enum { NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK = 1, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI = 2, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN = 3, - NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS = 4, - - NM_CLIENT_PERMISSION_LAST = NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS + NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX = 4, + NM_CLIENT_PERMISSION_SLEEP_WAKE = 5, + NM_CLIENT_PERMISSION_NETWORK_CONTROL = 6, + NM_CLIENT_PERMISSION_WIFI_SHARE_PROTECTED = 7, + NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN = 8, + NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM = 9, + NM_CLIENT_PERMISSION_SETTINGS_MODIFY_OWN = 10, + NM_CLIENT_PERMISSION_SETTINGS_MODIFY_HOSTNAME = 11, + + NM_CLIENT_PERMISSION_LAST = NM_CLIENT_PERMISSION_SETTINGS_MODIFY_HOSTNAME } NMClientPermission; typedef enum { @@ -79,6 +89,9 @@ typedef struct { /* Signals */ void (*device_added) (NMClient *client, NMDevice *device); void (*device_removed) (NMClient *client, NMDevice *device); + void (*permission_changed) (NMClient *client, + NMClientPermission permission, + NMClientPermissionResult result); /* Padding for future expansion */ void (*_reserved1) (void); @@ -96,15 +109,30 @@ NMClient *nm_client_new (void); const GPtrArray *nm_client_get_devices (NMClient *client); NMDevice *nm_client_get_device_by_path (NMClient *client, const char *object_path); -typedef void (*NMClientActivateDeviceFn) (gpointer user_data, const char *object_path, GError *error); +typedef void (*NMClientActivateFn) (NMClient *client, + NMActiveConnection *active_connection, + GError *error, + gpointer user_data); void nm_client_activate_connection (NMClient *client, - const char *service_name, - const char *connection_path, - NMDevice *device, - const char *specific_object, - NMClientActivateDeviceFn callback, - gpointer user_data); + NMConnection *connection, + NMDevice *device, + const char *specific_object, + NMClientActivateFn callback, + gpointer user_data); + +typedef void (*NMClientAddActivateFn) (NMClient *client, + NMActiveConnection *connection, + const char *new_connection_path, + GError *error, + gpointer user_data); + +void nm_client_add_and_activate_connection (NMClient *client, + NMConnection *partial, + NMDevice *device, + const char *specific_object, + NMClientAddActivateFn callback, + gpointer user_data); void nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active); @@ -119,6 +147,11 @@ gboolean nm_client_wwan_get_enabled (NMClient *client); void nm_client_wwan_set_enabled (NMClient *client, gboolean enabled); gboolean nm_client_wwan_hardware_get_enabled (NMClient *client); +gboolean nm_client_wimax_get_enabled (NMClient *client); +void nm_client_wimax_set_enabled (NMClient *client, gboolean enabled); +gboolean nm_client_wimax_hardware_get_enabled (NMClient *client); + +const char *nm_client_get_version (NMClient *client); NMState nm_client_get_state (NMClient *client); gboolean nm_client_get_manager_running (NMClient *client); const GPtrArray *nm_client_get_active_connections (NMClient *client); diff --git a/libnm-glib/nm-device-bt.c b/libnm-glib/nm-device-bt.c index 0451f2b0f..1209f61aa 100644 --- a/libnm-glib/nm-device-bt.c +++ b/libnm-glib/nm-device-bt.c @@ -18,9 +18,16 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2009 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ +#include <config.h> +#include <string.h> +#include <netinet/ether.h> + +#include <nm-setting-connection.h> +#include <nm-setting-bluetooth.h> + #include "nm-device-bt.h" #include "nm-device-private.h" #include "nm-object-private.h" @@ -62,7 +69,7 @@ enum { * * Creates a new #NMDeviceBt. * - * Returns: a new device + * Returns: (transfer full): a new device **/ GObject * nm_device_bt_new (DBusGConnection *connection, const char *path) @@ -96,7 +103,8 @@ nm_device_bt_get_hw_address (NMDeviceBt *device) if (!priv->hw_address) { priv->hw_address = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_BLUETOOTH, - DBUS_PROP_HW_ADDRESS); + DBUS_PROP_HW_ADDRESS, + NULL); } return priv->hw_address; @@ -121,7 +129,8 @@ nm_device_bt_get_name (NMDeviceBt *device) if (!priv->name) { priv->name = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_BLUETOOTH, - DBUS_PROP_NAME); + DBUS_PROP_NAME, + NULL); } return priv->name; @@ -146,13 +155,86 @@ nm_device_bt_get_capabilities (NMDeviceBt *device) if (!priv->bt_capabilities_valid) { priv->bt_capabilities = _nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_BLUETOOTH, - DBUS_PROP_BT_CAPABILITIES); + DBUS_PROP_BT_CAPABILITIES, + NULL); priv->bt_capabilities_valid = TRUE; } return priv->bt_capabilities; } +static NMBluetoothCapabilities +get_connection_bt_type (NMConnection *connection) +{ + NMSettingBluetooth *s_bt; + const char *bt_type; + + s_bt = (NMSettingBluetooth *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BLUETOOTH); + if (!s_bt) + return NM_BT_CAPABILITY_NONE; + + bt_type = nm_setting_bluetooth_get_connection_type (s_bt); + g_assert (bt_type); + + if (!strcmp (bt_type, NM_SETTING_BLUETOOTH_TYPE_DUN)) + return NM_BT_CAPABILITY_DUN; + else if (!strcmp (bt_type, NM_SETTING_BLUETOOTH_TYPE_PANU)) + return NM_BT_CAPABILITY_NAP; + + return NM_BT_CAPABILITY_NONE; +} + +static GSList * +filter_connections (NMDevice *device, const GSList *connections) +{ + GSList *filtered = NULL; + const GSList *iter; + + for (iter = connections; iter; iter = g_slist_next (iter)) { + NMConnection *candidate = NM_CONNECTION (iter->data); + NMSettingConnection *s_con; + NMSettingBluetooth *s_bt; + const char *ctype; + const GByteArray *mac; + const char *hw_str; + struct ether_addr *hw_mac; + NMBluetoothCapabilities dev_caps; + NMBluetoothCapabilities bt_type; + + s_con = (NMSettingConnection *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION); + g_assert (s_con); + + ctype = nm_setting_connection_get_connection_type (s_con); + if (strcmp (ctype, NM_SETTING_BLUETOOTH_SETTING_NAME) != 0) + continue; + + s_bt = (NMSettingBluetooth *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_BLUETOOTH); + if (!s_bt) + continue; + + /* Check BT address */ + hw_str = nm_device_bt_get_hw_address (NM_DEVICE_BT (device)); + if (hw_str) { + hw_mac = ether_aton (hw_str); + mac = nm_setting_bluetooth_get_bdaddr (s_bt); + if (mac && hw_mac && memcmp (mac->data, hw_mac->ether_addr_octet, ETH_ALEN)) + continue; + } + + dev_caps = nm_device_bt_get_capabilities (NM_DEVICE_BT (device)); + bt_type = get_connection_bt_type (candidate); + if (!(bt_type & dev_caps)) + continue; + + /* Connection applies to this device */ + filtered = g_slist_prepend (filtered, candidate); + } + + return g_slist_reverse (filtered); +} + +/************************************************************/ + static void nm_device_bt_init (NMDeviceBt *device) { @@ -250,17 +332,19 @@ get_property (GObject *object, } static void -nm_device_bt_class_init (NMDeviceBtClass *device_class) +nm_device_bt_class_init (NMDeviceBtClass *bt_class) { - GObjectClass *object_class = G_OBJECT_CLASS (device_class); + GObjectClass *object_class = G_OBJECT_CLASS (bt_class); + NMDeviceClass *device_class = NM_DEVICE_CLASS (bt_class); - g_type_class_add_private (device_class, sizeof (NMDeviceBtPrivate)); + g_type_class_add_private (bt_class, sizeof (NMDeviceBtPrivate)); /* virtual methods */ object_class->constructor = constructor; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + device_class->filter_connections = filter_connections; /* properties */ diff --git a/libnm-glib/nm-device-ethernet.c b/libnm-glib/nm-device-ethernet.c index 44b274276..932c6bda3 100644 --- a/libnm-glib/nm-device-ethernet.c +++ b/libnm-glib/nm-device-ethernet.c @@ -18,9 +18,17 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2010 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ +#include <config.h> +#include <string.h> +#include <netinet/ether.h> + +#include <nm-setting-connection.h> +#include <nm-setting-wired.h> +#include <nm-setting-pppoe.h> + #include "nm-device-ethernet.h" #include "nm-device-private.h" #include "nm-object-private.h" @@ -65,7 +73,7 @@ enum { * * Creates a new #NMDeviceEthernet. * - * Returns: a new device + * Returns: (transfer full): a new device **/ GObject * nm_device_ethernet_new (DBusGConnection *connection, const char *path) @@ -99,7 +107,8 @@ nm_device_ethernet_get_hw_address (NMDeviceEthernet *device) if (!priv->hw_address) { priv->hw_address = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, - DBUS_PROP_HW_ADDRESS); + DBUS_PROP_HW_ADDRESS, + NULL); } return priv->hw_address; @@ -125,7 +134,8 @@ nm_device_ethernet_get_permanent_hw_address (NMDeviceEthernet *device) if (!priv->perm_hw_address) { priv->perm_hw_address = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, - DBUS_PROP_PERM_HW_ADDRESS); + DBUS_PROP_PERM_HW_ADDRESS, + NULL); } return priv->perm_hw_address; @@ -150,7 +160,8 @@ nm_device_ethernet_get_speed (NMDeviceEthernet *device) if (!priv->speed) { priv->speed = _nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, - DBUS_PROP_SPEED); + DBUS_PROP_SPEED, + NULL); } return priv->speed; @@ -175,13 +186,67 @@ nm_device_ethernet_get_carrier (NMDeviceEthernet *device) if (!priv->carrier_valid) { priv->carrier = _nm_object_get_boolean_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, - DBUS_PROP_CARRIER); + DBUS_PROP_CARRIER, + NULL); priv->carrier_valid = TRUE; } return priv->carrier; } +static GSList * +filter_connections (NMDevice *device, const GSList *connections) +{ + GSList *filtered = NULL; + const GSList *iter; + + for (iter = connections; iter; iter = g_slist_next (iter)) { + NMConnection *candidate = NM_CONNECTION (iter->data); + NMSettingConnection *s_con; + NMSettingWired *s_wired; + const char *ctype; + gboolean is_pppoe = FALSE; + + s_con = (NMSettingConnection *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION); + g_assert (s_con); + + ctype = nm_setting_connection_get_connection_type (s_con); + if (!strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME)) + is_pppoe = TRUE; + else if (strcmp (ctype, NM_SETTING_WIRED_SETTING_NAME) != 0) + continue; + + s_wired = (NMSettingWired *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIRED); + /* Wired setting optional for PPPoE */ + if (!is_pppoe && !s_wired) + continue; + + if (s_wired) { + const GByteArray *mac; + const char *perm_str; + struct ether_addr *perm_mac; + + /* FIXME: filter using s390 subchannels when they are exported over the bus */ + + /* Check MAC address */ + perm_str = nm_device_ethernet_get_permanent_hw_address (NM_DEVICE_ETHERNET (device)); + if (perm_str) { + perm_mac = ether_aton (perm_str); + mac = nm_setting_wired_get_mac_address (s_wired); + if (mac && perm_mac && memcmp (mac->data, perm_mac->ether_addr_octet, ETH_ALEN)) + continue; + } + } + + /* Connection applies to this device */ + filtered = g_slist_prepend (filtered, candidate); + } + + return g_slist_reverse (filtered); +} + +/***********************************************************/ + static void nm_device_ethernet_init (NMDeviceEthernet *device) { @@ -257,11 +322,8 @@ finalize (GObject *object) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object); - if (priv->hw_address) - g_free (priv->hw_address); - - if (priv->perm_hw_address) - g_free (priv->perm_hw_address); + g_free (priv->hw_address); + g_free (priv->perm_hw_address); G_OBJECT_CLASS (nm_device_ethernet_parent_class)->finalize (object); } @@ -294,17 +356,19 @@ get_property (GObject *object, } static void -nm_device_ethernet_class_init (NMDeviceEthernetClass *device_class) +nm_device_ethernet_class_init (NMDeviceEthernetClass *eth_class) { - GObjectClass *object_class = G_OBJECT_CLASS (device_class); + GObjectClass *object_class = G_OBJECT_CLASS (eth_class); + NMDeviceClass *device_class = NM_DEVICE_CLASS (eth_class); - g_type_class_add_private (device_class, sizeof (NMDeviceEthernetPrivate)); + g_type_class_add_private (eth_class, sizeof (NMDeviceEthernetPrivate)); /* virtual methods */ object_class->constructor = constructor; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + device_class->filter_connections = filter_connections; /* properties */ diff --git a/libnm-glib/nm-device-modem.c b/libnm-glib/nm-device-modem.c new file mode 100644 index 000000000..fba0b003a --- /dev/null +++ b/libnm-glib/nm-device-modem.c @@ -0,0 +1,285 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * libnm_glib -- Access network status & information from glib applications + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2008 Novell, Inc. + */ + +#include <config.h> +#include <string.h> + +#include <nm-setting-connection.h> +#include <nm-setting-gsm.h> +#include <nm-setting-cdma.h> + +#include "nm-device-modem.h" +#include "nm-device-private.h" +#include "nm-object-private.h" +#include "nm-marshal.h" + +G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE) + +#define NM_DEVICE_MODEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ + NM_TYPE_DEVICE_MODEM, \ + NMDeviceModemPrivate)) + +typedef struct { + DBusGProxy *proxy; + + NMDeviceModemCapabilities caps; + NMDeviceModemCapabilities current_caps; + + gboolean disposed; +} NMDeviceModemPrivate; + +enum { + PROP_0, + PROP_MODEM_CAPS, + PROP_CURRENT_CAPS, + LAST_PROP +}; + +#define DBUS_PROP_MODEM_CAPS "ModemCapabilities" +#define DBUS_PROP_CURRENT_CAPS "CurrentCapabilities" + +/** + * nm_device_modem_get_modem_capabilities: + * @self: a #NMDeviceModem + * + * Returns a bitfield of the generic access technology families the modem + * supports. Not all capabilities are available concurrently however; some + * may require a firmware reload or reinitialization. + * + * Returns: the generic access technology families the modem supports + **/ +NMDeviceModemCapabilities +nm_device_modem_get_modem_capabilities (NMDeviceModem *self) +{ + NMDeviceModemPrivate *priv; + + g_return_val_if_fail (self != NULL, NM_DEVICE_MODEM_CAPABILITY_NONE); + g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE); + + priv = NM_DEVICE_MODEM_GET_PRIVATE (self); + if (!priv->caps) { + priv->caps = _nm_object_get_uint_property (NM_OBJECT (self), + NM_DBUS_INTERFACE_DEVICE_MODEM, + DBUS_PROP_MODEM_CAPS, + NULL); + } + + return priv->caps; +} + +/** + * nm_device_modem_get_current_capabilities: + * @self: a #NMDeviceModem + * + * Returns a bitfield of the generic access technology families the modem + * supports without a firmware reload or reinitialization. This value + * represents the network types the modem can immediately connect to. + * + * Returns: the generic access technology families the modem supports without + * a firmware reload or other reinitialization + **/ +NMDeviceModemCapabilities +nm_device_modem_get_current_capabilities (NMDeviceModem *self) +{ + NMDeviceModemPrivate *priv; + + g_return_val_if_fail (self != NULL, NM_DEVICE_MODEM_CAPABILITY_NONE); + g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE); + + priv = NM_DEVICE_MODEM_GET_PRIVATE (self); + if (!priv->current_caps) { + priv->current_caps = _nm_object_get_uint_property (NM_OBJECT (self), + NM_DBUS_INTERFACE_DEVICE_MODEM, + DBUS_PROP_CURRENT_CAPS, + NULL); + } + + return priv->current_caps; +} + +static GSList * +filter_connections (NMDevice *device, const GSList *connections) +{ + GSList *filtered = NULL; + const GSList *iter; + + for (iter = connections; iter; iter = g_slist_next (iter)) { + NMConnection *candidate = NM_CONNECTION (iter->data); + NMSettingConnection *s_con; + NMSettingGsm *s_gsm; + NMSettingCdma *s_cdma; + const char *ctype; + NMDeviceModemCapabilities current_caps; + + s_con = (NMSettingConnection *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION); + g_assert (s_con); + + ctype = nm_setting_connection_get_connection_type (s_con); + if ( strcmp (ctype, NM_SETTING_GSM_SETTING_NAME) != 0 + && strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME) != 0) + continue; + + s_gsm = (NMSettingGsm *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_GSM); + s_cdma = (NMSettingCdma *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_CDMA); + if (!s_cdma && !s_gsm) + continue; + + current_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); + if ( (s_gsm && (current_caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)) + || (s_cdma && (current_caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO))) { + /* Connection applies to this device */ + filtered = g_slist_prepend (filtered, candidate); + } + } + + return g_slist_reverse (filtered); +} + +/*******************************************************************/ + +static void +register_for_property_changed (NMDeviceModem *device) +{ + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); + const NMPropertiesChangedInfo property_changed_info[] = { + { NM_DEVICE_MODEM_MODEM_CAPABILITIES, _nm_object_demarshal_generic, &priv->caps }, + { NM_DEVICE_MODEM_CURRENT_CAPABILITIES, _nm_object_demarshal_generic, &priv->current_caps }, + { NULL }, + }; + + _nm_object_handle_properties_changed (NM_OBJECT (device), + priv->proxy, + property_changed_info); +} + +static GObject* +constructor (GType type, + guint n_construct_params, + GObjectConstructParam *construct_params) +{ + GObject *object; + NMDeviceModemPrivate *priv; + + object = G_OBJECT_CLASS (nm_device_modem_parent_class)->constructor (type, + n_construct_params, + construct_params); + if (object) { + priv = NM_DEVICE_MODEM_GET_PRIVATE (object); + + priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), + NM_DBUS_SERVICE, + nm_object_get_path (NM_OBJECT (object)), + NM_DBUS_INTERFACE_DEVICE_MODEM); + + register_for_property_changed (NM_DEVICE_MODEM (object)); + } + + return object; +} + +static void +nm_device_modem_init (NMDeviceModem *device) +{ +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NMDeviceModem *self = NM_DEVICE_MODEM (object); + + switch (prop_id) { + case PROP_MODEM_CAPS: + g_value_set_uint (value, nm_device_modem_get_modem_capabilities (self)); + break; + case PROP_CURRENT_CAPS: + g_value_set_uint (value, nm_device_modem_get_current_capabilities (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +dispose (GObject *object) +{ + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); + + if (priv->disposed) { + G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object); + return; + } + + priv->disposed = TRUE; + + g_object_unref (priv->proxy); + + G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object); +} + +static void +nm_device_modem_class_init (NMDeviceModemClass *modem_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (modem_class); + NMDeviceClass *device_class = NM_DEVICE_CLASS (modem_class); + + g_type_class_add_private (modem_class, sizeof (NMDeviceModemPrivate)); + + /* virtual methods */ + object_class->constructor = constructor; + object_class->get_property = get_property; + object_class->dispose = dispose; + device_class->filter_connections = filter_connections; + + /** + * NMDeviceModem:modem-capabilities: + * + * The generic family of access technologies the modem supports. Not all + * capabilities are available at the same time however; some modems require + * a firmware reload or other reinitialization to switch between eg + * CDMA/EVDO and GSM/UMTS. + **/ + g_object_class_install_property (object_class, PROP_MODEM_CAPS, + g_param_spec_uint (NM_DEVICE_MODEM_MODEM_CAPABILITIES, + "Modem capabilities", + "Modem capabilities", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE)); + + /** + * NMDeviceModem:current-capabilities: + * + * The generic family of access technologies the modem currently supports + * without a firmware reload or reinitialization. + **/ + g_object_class_install_property (object_class, PROP_CURRENT_CAPS, + g_param_spec_uint (NM_DEVICE_MODEM_CURRENT_CAPABILITIES, + "Current capabilities", + "Current capabilities", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE)); +} + diff --git a/libnm-glib/nm-serial-device.h b/libnm-glib/nm-device-modem.h index 51f08df33..bf84b90d8 100644 --- a/libnm-glib/nm-serial-device.h +++ b/libnm-glib/nm-device-modem.h @@ -17,33 +17,34 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * + * Copyright (C) 2011 Red Hat, Inc. * Copyright (C) 2008 Novell, Inc. */ -#ifndef NM_SERIAL_DEVICE_H -#define NM_SERIAL_DEVICE_H +#ifndef NM_DEVICE_MODEM_H +#define NM_DEVICE_MODEM_H #include "nm-device.h" G_BEGIN_DECLS -#define NM_TYPE_SERIAL_DEVICE (nm_serial_device_get_type ()) -#define NM_SERIAL_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SERIAL_DEVICE, NMSerialDevice)) -#define NM_SERIAL_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SERIAL_DEVICE, NMSerialDeviceClass)) -#define NM_IS_SERIAL_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SERIAL_DEVICE)) -#define NM_IS_SERIAL_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SERIAL_DEVICE)) -#define NM_SERIAL_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SERIAL_DEVICE, NMSerialDeviceClass)) +#define NM_TYPE_DEVICE_MODEM (nm_device_modem_get_type ()) +#define NM_DEVICE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_MODEM, NMDeviceModem)) +#define NM_DEVICE_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_MODEM, NMDeviceModemClass)) +#define NM_IS_DEVICE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_MODEM)) +#define NM_IS_DEVICE_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_DEVICE_MODEM)) +#define NM_DEVICE_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_MODEM, NMDeviceModemClass)) + +#define NM_DEVICE_MODEM_MODEM_CAPABILITIES "modem-capabilities" +#define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities" typedef struct { NMDevice parent; -} NMSerialDevice; +} NMDeviceModem; typedef struct { NMDeviceClass parent; - /* Signals */ - void (*ppp_stats) (NMSerialDevice *self, guint32 in_bytes, guint32 out_bytes); - /* Padding for future expansion */ void (*_reserved1) (void); void (*_reserved2) (void); @@ -51,13 +52,13 @@ typedef struct { void (*_reserved4) (void); void (*_reserved5) (void); void (*_reserved6) (void); -} NMSerialDeviceClass; +} NMDeviceModemClass; -GType nm_serial_device_get_type (void); +GType nm_device_modem_get_type (void); -guint32 nm_serial_device_get_bytes_received (NMSerialDevice *self); -guint32 nm_serial_device_get_bytes_sent (NMSerialDevice *self); +NMDeviceModemCapabilities nm_device_modem_get_modem_capabilities (NMDeviceModem *self); +NMDeviceModemCapabilities nm_device_modem_get_current_capabilities (NMDeviceModem *self); G_END_DECLS -#endif /* NM_SERIAL_DEVICE_H */ +#endif /* NM_DEVICE_MODEM_H */ diff --git a/libnm-glib/nm-device-wifi.c b/libnm-glib/nm-device-wifi.c index 3d1702395..c58e70d3b 100644 --- a/libnm-glib/nm-device-wifi.c +++ b/libnm-glib/nm-device-wifi.c @@ -18,10 +18,16 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2010 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ +#include <config.h> #include <string.h> +#include <netinet/ether.h> + +#include <nm-setting-connection.h> +#include <nm-setting-wireless.h> +#include <nm-setting-wireless-security.h> #include "nm-device-wifi.h" #include "nm-device-private.h" @@ -50,7 +56,7 @@ typedef struct { guint32 rate; NMAccessPoint *active_ap; gboolean null_active_ap; - guint32 wireless_caps; + NMDeviceWifiCapabilities wireless_caps; GPtrArray *aps; gboolean wireless_enabled; @@ -91,7 +97,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; * * Creates a new #NMDeviceWifi. * - * Returns: a new device + * Returns: (transfer full): a new WiFi device **/ GObject * nm_device_wifi_new (DBusGConnection *connection, const char *path) @@ -125,7 +131,8 @@ nm_device_wifi_get_hw_address (NMDeviceWifi *device) if (!priv->hw_address) { priv->hw_address = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, - DBUS_PROP_HW_ADDRESS); + DBUS_PROP_HW_ADDRESS, + NULL); } return priv->hw_address; @@ -151,7 +158,8 @@ nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device) if (!priv->perm_hw_address) { priv->perm_hw_address = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, - DBUS_PROP_PERM_HW_ADDRESS); + DBUS_PROP_PERM_HW_ADDRESS, + NULL); } return priv->perm_hw_address; @@ -176,7 +184,8 @@ nm_device_wifi_get_mode (NMDeviceWifi *device) if (!priv->mode) { priv->mode = _nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, - DBUS_PROP_MODE); + DBUS_PROP_MODE, + NULL); } return priv->mode; @@ -200,22 +209,22 @@ nm_device_wifi_get_bitrate (NMDeviceWifi *device) state = nm_device_get_state (NM_DEVICE (device)); switch (state) { - case NM_DEVICE_STATE_PREPARE: - case NM_DEVICE_STATE_CONFIG: - case NM_DEVICE_STATE_NEED_AUTH: case NM_DEVICE_STATE_IP_CONFIG: + case NM_DEVICE_STATE_IP_CHECK: + case NM_DEVICE_STATE_SECONDARIES: case NM_DEVICE_STATE_ACTIVATED: + case NM_DEVICE_STATE_DEACTIVATING: break; default: return 0; - break; } priv = NM_DEVICE_WIFI_GET_PRIVATE (device); if (!priv->rate) { priv->rate = _nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, - DBUS_PROP_BITRATE); + DBUS_PROP_BITRATE, + NULL); } return priv->rate; @@ -229,7 +238,7 @@ nm_device_wifi_get_bitrate (NMDeviceWifi *device) * * Returns: the capabilities **/ -guint32 +NMDeviceWifiCapabilities nm_device_wifi_get_capabilities (NMDeviceWifi *device) { NMDeviceWifiPrivate *priv; @@ -240,7 +249,8 @@ nm_device_wifi_get_capabilities (NMDeviceWifi *device) if (!priv->wireless_caps) { priv->wireless_caps = _nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, - DBUS_PROP_WIRELESS_CAPABILITIES); + DBUS_PROP_WIRELESS_CAPABILITIES, + NULL); } return priv->wireless_caps; @@ -252,7 +262,7 @@ nm_device_wifi_get_capabilities (NMDeviceWifi *device) * * Gets the active #NMAccessPoint. * - * Returns: the access point or %NULL if none is active + * Returns: (transfer none): the access point or %NULL if none is active **/ NMAccessPoint * nm_device_wifi_get_active_access_point (NMDeviceWifi *device) @@ -270,7 +280,10 @@ nm_device_wifi_get_active_access_point (NMDeviceWifi *device) case NM_DEVICE_STATE_CONFIG: case NM_DEVICE_STATE_NEED_AUTH: case NM_DEVICE_STATE_IP_CONFIG: + case NM_DEVICE_STATE_IP_CHECK: + case NM_DEVICE_STATE_SECONDARIES: case NM_DEVICE_STATE_ACTIVATED: + case NM_DEVICE_STATE_DEACTIVATING: break; default: return NULL; @@ -285,7 +298,8 @@ nm_device_wifi_get_active_access_point (NMDeviceWifi *device) path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, - DBUS_PROP_ACTIVE_ACCESS_POINT); + DBUS_PROP_ACTIVE_ACCESS_POINT, + NULL); if (path) { g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH); g_value_take_boxed (&value, path); @@ -302,7 +316,8 @@ nm_device_wifi_get_active_access_point (NMDeviceWifi *device) * * Gets all the scanned access points of the #NMDeviceWifi. * - * Returns: a #GPtrArray containing all the scanned #NMAccessPoint<!-- -->s. + * Returns: (element-type NMClient.AccessPoint): a #GPtrArray containing all the + * scanned #NMAccessPoint<!-- -->s. * The returned array is owned by the client and should not be modified. **/ const GPtrArray * @@ -342,7 +357,7 @@ nm_device_wifi_get_access_points (NMDeviceWifi *device) * * Gets a #NMAccessPoint by path. * - * Returns: the access point or %NULL if none is found. + * Returns: (transfer none): the access point or %NULL if none is found. **/ NMAccessPoint * nm_device_wifi_get_access_point_by_path (NMDeviceWifi *device, @@ -386,7 +401,7 @@ access_point_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data) priv = NM_DEVICE_WIFI_GET_PRIVATE (self); ap = G_OBJECT (_nm_object_cache_get (path)); if (ap) { - g_ptr_array_add (priv->aps, g_object_ref (ap)); + g_ptr_array_add (priv->aps, ap); } else { ap = G_OBJECT (nm_access_point_new (connection, path)); if (ap) @@ -470,6 +485,90 @@ _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, clean_up_aps (device, TRUE); } +#define WPA_CAPS (NM_WIFI_DEVICE_CAP_CIPHER_TKIP | \ + NM_WIFI_DEVICE_CAP_CIPHER_CCMP | \ + NM_WIFI_DEVICE_CAP_WPA | \ + NM_WIFI_DEVICE_CAP_RSN) + +#define RSN_CAPS (NM_WIFI_DEVICE_CAP_CIPHER_CCMP | NM_WIFI_DEVICE_CAP_RSN) + +static gboolean +has_proto (NMSettingWirelessSecurity *s_wsec, const char *proto) +{ + int i; + + for (i = 0; i < nm_setting_wireless_security_get_num_protos (s_wsec); i++) { + if (g_strcmp0 (proto, nm_setting_wireless_security_get_proto (s_wsec, i)) == 0) + return TRUE; + } + return FALSE; +} + +static GSList * +filter_connections (NMDevice *device, const GSList *connections) +{ + GSList *filtered = NULL; + const GSList *iter; + + for (iter = connections; iter; iter = g_slist_next (iter)) { + NMConnection *candidate = NM_CONNECTION (iter->data); + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + const char *ctype; + const GByteArray *mac; + const char *hw_str; + struct ether_addr *hw_mac; + NMDeviceWifiCapabilities wifi_caps; + const char *key_mgmt; + + s_con = (NMSettingConnection *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION); + g_assert (s_con); + + ctype = nm_setting_connection_get_connection_type (s_con); + if (strcmp (ctype, NM_SETTING_WIRELESS_SETTING_NAME) != 0) + continue; + + s_wifi = (NMSettingWireless *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIRELESS); + if (!s_wifi) + continue; + + /* Check MAC address */ + hw_str = nm_device_wifi_get_permanent_hw_address (NM_DEVICE_WIFI (device)); + if (hw_str) { + hw_mac = ether_aton (hw_str); + mac = nm_setting_wireless_get_mac_address (s_wifi); + if (mac && hw_mac && memcmp (mac->data, hw_mac->ether_addr_octet, ETH_ALEN)) + continue; + } + + /* Check device capabilities; we assume all devices can do WEP at least */ + wifi_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (device)); + + s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIRELESS_SECURITY); + if (s_wsec) { + /* Connection has security, verify it against the device's capabilities */ + key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); + if ( !g_strcmp0 (key_mgmt, "wpa-none") + || !g_strcmp0 (key_mgmt, "wpa-psk") + || !g_strcmp0 (key_mgmt, "wpa-eap")) { + + /* Is device only WEP capable? */ + if (!(wifi_caps & WPA_CAPS)) + continue; + + /* Make sure WPA2/RSN-only connections don't get chosen for WPA-only cards */ + if (has_proto (s_wsec, "rsn") && !has_proto (s_wsec, "wpa") && !(wifi_caps & RSN_CAPS)) + continue; + } + } + + /* Connection applies to this device */ + filtered = g_slist_prepend (filtered, candidate); + } + + return g_slist_reverse (filtered); +} /**************************************************************/ @@ -560,9 +659,7 @@ demarshal_active_ap (NMObject *object, GParamSpec *pspec, GValue *value, gpointe priv->null_active_ap = TRUE; else { ap = NM_ACCESS_POINT (_nm_object_cache_get (path)); - if (ap) - ap = g_object_ref (ap); - else { + if (!ap) { connection = nm_object_get_connection (object); ap = NM_ACCESS_POINT (nm_access_point_new (connection, path)); } @@ -668,27 +765,26 @@ finalize (GObject *object) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object); - if (priv->hw_address) - g_free (priv->hw_address); - - if (priv->perm_hw_address) - g_free (priv->perm_hw_address); + g_free (priv->hw_address); + g_free (priv->perm_hw_address); G_OBJECT_CLASS (nm_device_wifi_parent_class)->finalize (object); } static void -nm_device_wifi_class_init (NMDeviceWifiClass *device_class) +nm_device_wifi_class_init (NMDeviceWifiClass *wifi_class) { - GObjectClass *object_class = G_OBJECT_CLASS (device_class); + GObjectClass *object_class = G_OBJECT_CLASS (wifi_class); + NMDeviceClass *device_class = NM_DEVICE_CLASS (wifi_class); - g_type_class_add_private (device_class, sizeof (NMDeviceWifiPrivate)); + g_type_class_add_private (wifi_class, sizeof (NMDeviceWifiPrivate)); /* virtual methods */ object_class->constructor = constructor; object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; + device_class->filter_connections = filter_connections; /* properties */ diff --git a/libnm-glib/nm-device-wifi.h b/libnm-glib/nm-device-wifi.h index 21f3558af..fb2ab27da 100644 --- a/libnm-glib/nm-device-wifi.h +++ b/libnm-glib/nm-device-wifi.h @@ -67,17 +67,17 @@ GType nm_device_wifi_get_type (void); GObject *nm_device_wifi_new (DBusGConnection *connection, const char *path); -const char * nm_device_wifi_get_hw_address (NMDeviceWifi *device); -const char * nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device); -NM80211Mode nm_device_wifi_get_mode (NMDeviceWifi *device); -guint32 nm_device_wifi_get_bitrate (NMDeviceWifi *device); -guint32 nm_device_wifi_get_capabilities (NMDeviceWifi *device); -NMAccessPoint * nm_device_wifi_get_active_access_point (NMDeviceWifi *device); +const char * nm_device_wifi_get_hw_address (NMDeviceWifi *device); +const char * nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device); +NM80211Mode nm_device_wifi_get_mode (NMDeviceWifi *device); +guint32 nm_device_wifi_get_bitrate (NMDeviceWifi *device); +NMDeviceWifiCapabilities nm_device_wifi_get_capabilities (NMDeviceWifi *device); +NMAccessPoint * nm_device_wifi_get_active_access_point (NMDeviceWifi *device); -NMAccessPoint * nm_device_wifi_get_access_point_by_path (NMDeviceWifi *device, - const char *path); +NMAccessPoint * nm_device_wifi_get_access_point_by_path (NMDeviceWifi *device, + const char *path); -const GPtrArray *nm_device_wifi_get_access_points (NMDeviceWifi *device); +const GPtrArray * nm_device_wifi_get_access_points (NMDeviceWifi *device); G_END_DECLS diff --git a/libnm-glib/nm-device-wimax.c b/libnm-glib/nm-device-wimax.c new file mode 100644 index 000000000..7278a471b --- /dev/null +++ b/libnm-glib/nm-device-wimax.c @@ -0,0 +1,911 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * libnm_glib -- Access network status & information from glib applications + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2009 Novell, Inc. + */ + +#include <config.h> +#include <string.h> +#include <netinet/ether.h> + +#include <nm-setting-connection.h> +#include <nm-setting-wimax.h> + +#include "nm-device-wimax.h" +#include "nm-object-private.h" +#include "nm-object-cache.h" +#include "nm-dbus-glib-types.h" +#include "nm-types-private.h" + +#include "nm-device-wimax-bindings.h" + +G_DEFINE_TYPE (NMDeviceWimax, nm_device_wimax, NM_TYPE_DEVICE) + +#define NM_DEVICE_WIMAX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxPrivate)) + +static gboolean demarshal_active_nsp (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field); + +void _nm_device_wimax_set_wireless_enabled (NMDeviceWimax *wimax, gboolean enabled); + +typedef struct { + gboolean disposed; + DBusGProxy *proxy; + + char *hw_address; + NMWimaxNsp *active_nsp; + gboolean null_active_nsp; + GPtrArray *nsps; + + guint center_freq; + gint rssi; + gint cinr; + gint tx_power; + char *bsid; +} NMDeviceWimaxPrivate; + +enum { + PROP_0, + PROP_HW_ADDRESS, + PROP_ACTIVE_NSP, + PROP_CENTER_FREQ, + PROP_RSSI, + PROP_CINR, + PROP_TX_POWER, + PROP_BSID, + + LAST_PROP +}; + +#define DBUS_PROP_HW_ADDRESS "HwAddress" +#define DBUS_PROP_ACTIVE_NSP "ActiveNsp" +#define DBUS_PROP_CENTER_FREQUENCY "CenterFrequency" +#define DBUS_PROP_RSSI "Rssi" +#define DBUS_PROP_CINR "Cinr" +#define DBUS_PROP_TX_POWER "TxPower" +#define DBUS_PROP_BSID "Bsid" + +enum { + NSP_ADDED, + NSP_REMOVED, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +/** + * nm_device_wimax_new: + * @connection: the #DBusGConnection + * @path: the D-Bus object path of the WiMAX device + * + * Creates a new #NMDeviceWimax. + * + * Returns: (transfer full): a new WiMAX device + **/ +GObject * +nm_device_wimax_new (DBusGConnection *connection, const char *path) +{ + g_return_val_if_fail (connection != NULL, NULL); + g_return_val_if_fail (path != NULL, NULL); + + return g_object_new (NM_TYPE_DEVICE_WIMAX, + NM_OBJECT_DBUS_CONNECTION, connection, + NM_OBJECT_DBUS_PATH, path, + NULL); +} + +/** + * nm_device_wimax_get_hw_address: + * @wimax: a #NMDeviceWimax + * + * Gets the hardware (MAC) address of the #NMDeviceWimax + * + * Returns: the hardware address. This is the internal string used by the + * device, and must not be modified. + **/ +const char * +nm_device_wimax_get_hw_address (NMDeviceWimax *wimax) +{ + NMDeviceWimaxPrivate *priv; + + g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL); + + priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax); + if (!priv->hw_address) { + priv->hw_address = _nm_object_get_string_property (NM_OBJECT (wimax), + NM_DBUS_INTERFACE_DEVICE_WIMAX, + DBUS_PROP_HW_ADDRESS, + NULL); + } + + return priv->hw_address; +} + +/** + * nm_device_wimax_get_active_nsp: + * @wimax: a #NMDeviceWimax + * + * Gets the active #NMWimaxNsp. + * + * Returns: (transfer full): the access point or %NULL if none is active + **/ +NMWimaxNsp * +nm_device_wimax_get_active_nsp (NMDeviceWimax *wimax) +{ + NMDeviceWimaxPrivate *priv; + NMDeviceState state; + char *path; + GValue value = { 0, }; + + g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL); + + state = nm_device_get_state (NM_DEVICE (wimax)); + switch (state) { + case NM_DEVICE_STATE_PREPARE: + case NM_DEVICE_STATE_CONFIG: + case NM_DEVICE_STATE_NEED_AUTH: + case NM_DEVICE_STATE_IP_CONFIG: + case NM_DEVICE_STATE_IP_CHECK: + case NM_DEVICE_STATE_SECONDARIES: + case NM_DEVICE_STATE_ACTIVATED: + case NM_DEVICE_STATE_DEACTIVATING: + break; + default: + return NULL; + break; + } + + priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax); + if (priv->active_nsp) + return priv->active_nsp; + if (priv->null_active_nsp) + return NULL; + + path = _nm_object_get_object_path_property (NM_OBJECT (wimax), + NM_DBUS_INTERFACE_DEVICE_WIMAX, + DBUS_PROP_ACTIVE_NSP, + NULL); + if (path) { + g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH); + g_value_take_boxed (&value, path); + demarshal_active_nsp (NM_OBJECT (wimax), NULL, &value, &priv->active_nsp); + g_value_unset (&value); + } + + return priv->active_nsp; +} + +/** + * nm_device_wimax_get_nsps: + * @wimax: a #NMDeviceWimax + * + * Gets all the scanned NSPs of the #NMDeviceWimax. + * + * Returns: (element-type NMClient.WimaxNsp): a #GPtrArray containing + * all the scanned #NMWimaxNsp<!-- -->s. + * The returned array is owned by the client and should not be modified. + **/ +const GPtrArray * +nm_device_wimax_get_nsps (NMDeviceWimax *wimax) +{ + NMDeviceWimaxPrivate *priv; + DBusGConnection *connection; + GValue value = { 0, }; + GError *error = NULL; + GPtrArray *temp; + + g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL); + + priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax); + if (priv->nsps) + return handle_ptr_array_return (priv->nsps); + + if (!org_freedesktop_NetworkManager_Device_WiMax_get_nsp_list (priv->proxy, &temp, &error)) { + g_warning ("%s: error getting NSPs: %s", __func__, error->message); + g_error_free (error); + return NULL; + } + + g_value_init (&value, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH); + g_value_take_boxed (&value, temp); + connection = nm_object_get_connection (NM_OBJECT (wimax)); + _nm_object_array_demarshal (&value, &priv->nsps, connection, nm_wimax_nsp_new); + g_value_unset (&value); + + return handle_ptr_array_return (priv->nsps); +} + +/** + * nm_device_wimax_get_nsp_by_path: + * @wimax: a #NMDeviceWimax + * @path: the object path of the NSP + * + * Gets a #NMWimaxNsp by path. + * + * Returns: (transfer none): the access point or %NULL if none is found. + **/ +NMWimaxNsp * +nm_device_wimax_get_nsp_by_path (NMDeviceWimax *wimax, + const char *path) +{ + const GPtrArray *nsps; + int i; + NMWimaxNsp *nsp = NULL; + + g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL); + g_return_val_if_fail (path != NULL, NULL); + + nsps = nm_device_wimax_get_nsps (wimax); + if (!nsps) + return NULL; + + for (i = 0; i < nsps->len; i++) { + NMWimaxNsp *candidate = g_ptr_array_index (nsps, i); + if (!strcmp (nm_object_get_path (NM_OBJECT (candidate)), path)) { + nsp = candidate; + break; + } + } + + return nsp; +} + +static void +nsp_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data) +{ + NMDeviceWimax *self = NM_DEVICE_WIMAX (user_data); + NMDeviceWimaxPrivate *priv; + GObject *nsp; + + g_return_if_fail (self != NULL); + + nsp = G_OBJECT (nm_device_wimax_get_nsp_by_path (self, path)); + if (!nsp) { + DBusGConnection *connection = nm_object_get_connection (NM_OBJECT (self)); + + priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); + nsp = G_OBJECT (_nm_object_cache_get (path)); + if (nsp) { + g_ptr_array_add (priv->nsps, nsp); + } else { + nsp = G_OBJECT (nm_wimax_nsp_new (connection, path)); + if (nsp) + g_ptr_array_add (priv->nsps, nsp); + } + } + + if (nsp) + g_signal_emit (self, signals[NSP_ADDED], 0, nsp); +} + +static void +nsp_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data) +{ + NMDeviceWimax *self = NM_DEVICE_WIMAX (user_data); + NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); + NMWimaxNsp *nsp; + + g_return_if_fail (self != NULL); + + nsp = nm_device_wimax_get_nsp_by_path (self, path); + if (nsp) { + if (nsp == priv->active_nsp) { + g_object_unref (priv->active_nsp); + priv->active_nsp = NULL; + priv->null_active_nsp = FALSE; + + _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_ACTIVE_NSP); + } + + g_signal_emit (self, signals[NSP_REMOVED], 0, nsp); + g_ptr_array_remove (priv->nsps, nsp); + g_object_unref (G_OBJECT (nsp)); + } +} + +static void +clean_up_nsps (NMDeviceWimax *self, gboolean notify) +{ + NMDeviceWimaxPrivate *priv; + + g_return_if_fail (NM_IS_DEVICE_WIMAX (self)); + + priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); + + if (priv->active_nsp) { + g_object_unref (priv->active_nsp); + priv->active_nsp = NULL; + } + + if (priv->nsps) { + while (priv->nsps->len) { + NMWimaxNsp *nsp = NM_WIMAX_NSP (g_ptr_array_index (priv->nsps, 0)); + + if (notify) + g_signal_emit (self, signals[NSP_REMOVED], 0, nsp); + g_ptr_array_remove (priv->nsps, nsp); + g_object_unref (nsp); + } + g_ptr_array_free (priv->nsps, TRUE); + priv->nsps = NULL; + } +} + +/** + * nm_device_wimax_get_center_frequency: + * @self: a #NMDeviceWimax + * + * Gets the center frequency (in KHz) of the radio channel the device is using + * to communicate with the network when connected. Has no meaning when the + * device is not connected. + * + * Returns: the center frequency in KHz, or 0 + **/ +guint +nm_device_wimax_get_center_frequency (NMDeviceWimax *self) +{ + NMDeviceWimaxPrivate *priv; + + g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); + + priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); + if (!priv->center_freq) { + priv->center_freq = _nm_object_get_uint_property (NM_OBJECT (self), + NM_DBUS_INTERFACE_DEVICE_WIMAX, + DBUS_PROP_CENTER_FREQUENCY, + NULL); + } + return priv->center_freq; +} + +/** + * nm_device_wimax_get_rssi: + * @self: a #NMDeviceWimax + * + * Gets the RSSI of the current radio link in dBm. This value indicates how + * strong the raw received RF signal from the base station is, but does not + * indicate the overall quality of the radio link. Has no meaning when the + * device is not connected. + * + * Returns: the RSSI in dBm, or 0 + **/ +gint +nm_device_wimax_get_rssi (NMDeviceWimax *self) +{ + NMDeviceWimaxPrivate *priv; + + g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); + + priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); + if (!priv->rssi) { + priv->rssi = _nm_object_get_int_property (NM_OBJECT (self), + NM_DBUS_INTERFACE_DEVICE_WIMAX, + DBUS_PROP_RSSI, + NULL); + } + return priv->rssi; +} + +/** + * nm_device_wimax_get_cinr: + * @self: a #NMDeviceWimax + * + * Gets the CINR (Carrier to Interference + Noise Ratio) of the current radio + * link in dB. CINR is a more accurate measure of radio link quality. Has no + * meaning when the device is not connected. + * + * Returns: the CINR in dB, or 0 + **/ +gint +nm_device_wimax_get_cinr (NMDeviceWimax *self) +{ + NMDeviceWimaxPrivate *priv; + + g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); + + priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); + if (!priv->cinr) { + priv->cinr = _nm_object_get_int_property (NM_OBJECT (self), + NM_DBUS_INTERFACE_DEVICE_WIMAX, + DBUS_PROP_CINR, + NULL); + } + return priv->cinr; +} + +/** + * nm_device_wimax_get_tx_power: + * @self: a #NMDeviceWimax + * + * Average power of the last burst transmitted by the device, in units of + * 0.5 dBm. i.e. a TxPower of -11 represents an actual device TX power of + * -5.5 dBm. Has no meaning when the device is not connected. + * + * Returns: the TX power in dBm, or 0 + **/ +gint +nm_device_wimax_get_tx_power (NMDeviceWimax *self) +{ + NMDeviceWimaxPrivate *priv; + + g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); + + priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); + if (!priv->tx_power) { + priv->tx_power = _nm_object_get_int_property (NM_OBJECT (self), + NM_DBUS_INTERFACE_DEVICE_WIMAX, + DBUS_PROP_TX_POWER, + NULL); + } + return priv->tx_power; +} + +/** + * nm_device_wimax_get_bsid: + * @self: a #NMDeviceWimax + * + * Gets the ID of the serving Base Station when the device is connected. + * + * Returns: the ID of the serving Base Station, or NULL + **/ +const char * +nm_device_wimax_get_bsid (NMDeviceWimax *self) +{ + NMDeviceWimaxPrivate *priv; + + g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), NULL); + + priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); + if (!priv->bsid) { + priv->bsid = _nm_object_get_string_property (NM_OBJECT (self), + NM_DBUS_INTERFACE_DEVICE_WIMAX, + DBUS_PROP_BSID, + NULL); + } + return priv->bsid; +} + +static GSList * +filter_connections (NMDevice *device, const GSList *connections) +{ + GSList *filtered = NULL; + const GSList *iter; + + for (iter = connections; iter; iter = g_slist_next (iter)) { + NMConnection *candidate = NM_CONNECTION (iter->data); + NMSettingConnection *s_con; + NMSettingWimax *s_wimax; + const char *ctype; + const GByteArray *mac; + const char *hw_str; + struct ether_addr *hw_mac; + + s_con = (NMSettingConnection *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION); + g_assert (s_con); + + ctype = nm_setting_connection_get_connection_type (s_con); + if (strcmp (ctype, NM_SETTING_WIMAX_SETTING_NAME) != 0) + continue; + + s_wimax = (NMSettingWimax *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIMAX); + if (!s_wimax) + continue; + + /* Check MAC address */ + hw_str = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device)); + if (hw_str) { + hw_mac = ether_aton (hw_str); + mac = nm_setting_wimax_get_mac_address (s_wimax); + if (mac && hw_mac && memcmp (mac->data, hw_mac->ether_addr_octet, ETH_ALEN)) + continue; + } + + /* Connection applies to this device */ + filtered = g_slist_prepend (filtered, candidate); + } + + return g_slist_reverse (filtered); +} + +/**************************************************************/ + +static void +nm_device_wimax_init (NMDeviceWimax *wimax) +{ +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NMDeviceWimax *self = NM_DEVICE_WIMAX (object); + + switch (prop_id) { + case PROP_HW_ADDRESS: + g_value_set_string (value, nm_device_wimax_get_hw_address (self)); + break; + case PROP_ACTIVE_NSP: + g_value_set_object (value, nm_device_wimax_get_active_nsp (self)); + break; + case PROP_CENTER_FREQ: + g_value_set_uint (value, nm_device_wimax_get_center_frequency (self)); + break; + case PROP_RSSI: + g_value_set_int (value, nm_device_wimax_get_rssi (self)); + break; + case PROP_CINR: + g_value_set_int (value, nm_device_wimax_get_cinr (self)); + break; + case PROP_TX_POWER: + g_value_set_int (value, nm_device_wimax_get_tx_power (self)); + break; + case PROP_BSID: + g_value_set_string (value, nm_device_wimax_get_bsid (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +clear_link_status (NMDeviceWimax *self) +{ + NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); + + if (priv->center_freq) { + priv->center_freq = 0; + _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_CENTER_FREQUENCY); + } + + if (priv->rssi) { + priv->rssi = 0; + _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_RSSI); + } + + if (priv->cinr) { + priv->cinr = 0; + _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_CINR); + } + + if (priv->tx_power) { + priv->tx_power = 0; + _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_TX_POWER); + } + + if (priv->bsid) { + g_free (priv->bsid); + priv->bsid = NULL; + _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_BSID); + } +} + +static void +state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data) +{ + NMDeviceWimax *self = NM_DEVICE_WIMAX (device); + NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); + NMDeviceState state; + + state = nm_device_get_state (device); + switch (state) { + case NM_DEVICE_STATE_UNKNOWN: + case NM_DEVICE_STATE_UNMANAGED: + case NM_DEVICE_STATE_UNAVAILABLE: + case NM_DEVICE_STATE_DISCONNECTED: + case NM_DEVICE_STATE_FAILED: + if (priv->active_nsp) { + g_object_unref (priv->active_nsp); + priv->active_nsp = NULL; + priv->null_active_nsp = FALSE; + } + _nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIMAX_ACTIVE_NSP); + clear_link_status (self); + break; + case NM_DEVICE_STATE_PREPARE: + case NM_DEVICE_STATE_CONFIG: + case NM_DEVICE_STATE_NEED_AUTH: + case NM_DEVICE_STATE_IP_CONFIG: + clear_link_status (self); + break; + default: + break; + } +} + +static gboolean +demarshal_active_nsp (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) +{ + NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object); + const char *path; + NMWimaxNsp *nsp = NULL; + DBusGConnection *connection; + + if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) + return FALSE; + + priv->null_active_nsp = FALSE; + + path = g_value_get_boxed (value); + if (path) { + if (!strcmp (path, "/")) + priv->null_active_nsp = TRUE; + else { + nsp = NM_WIMAX_NSP (_nm_object_cache_get (path)); + if (!nsp) { + connection = nm_object_get_connection (object); + nsp = NM_WIMAX_NSP (nm_wimax_nsp_new (connection, path)); + } + } + } + + if (priv->active_nsp) { + g_object_unref (priv->active_nsp); + priv->active_nsp = NULL; + } + + if (nsp) + priv->active_nsp = nsp; + + _nm_object_queue_notify (object, NM_DEVICE_WIMAX_ACTIVE_NSP); + return TRUE; +} + +static void +register_for_property_changed (NMDeviceWimax *wimax) +{ + NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax); + const NMPropertiesChangedInfo property_changed_info[] = { + { NM_DEVICE_WIMAX_HW_ADDRESS, _nm_object_demarshal_generic, &priv->hw_address }, + { NM_DEVICE_WIMAX_ACTIVE_NSP, demarshal_active_nsp, &priv->active_nsp }, + { NM_DEVICE_WIMAX_CENTER_FREQUENCY, _nm_object_demarshal_generic, &priv->center_freq }, + { NM_DEVICE_WIMAX_RSSI, _nm_object_demarshal_generic, &priv->rssi }, + { NM_DEVICE_WIMAX_CINR, _nm_object_demarshal_generic, &priv->cinr }, + { NM_DEVICE_WIMAX_TX_POWER, _nm_object_demarshal_generic, &priv->tx_power }, + { NM_DEVICE_WIMAX_BSID, _nm_object_demarshal_generic, &priv->bsid }, + { NULL }, + }; + + _nm_object_handle_properties_changed (NM_OBJECT (wimax), + priv->proxy, + property_changed_info); +} + +static GObject* +constructor (GType type, + guint n_construct_params, + GObjectConstructParam *construct_params) +{ + GObject *object; + NMDeviceWimaxPrivate *priv; + + object = G_OBJECT_CLASS (nm_device_wimax_parent_class)->constructor (type, + n_construct_params, + construct_params); + if (!object) + return NULL; + + priv = NM_DEVICE_WIMAX_GET_PRIVATE (object); + + priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), + NM_DBUS_SERVICE, + nm_object_get_path (NM_OBJECT (object)), + NM_DBUS_INTERFACE_DEVICE_WIMAX); + + dbus_g_proxy_add_signal (priv->proxy, "NspAdded", + DBUS_TYPE_G_OBJECT_PATH, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->proxy, "NspAdded", + G_CALLBACK (nsp_added_proxy), + object, NULL); + + dbus_g_proxy_add_signal (priv->proxy, "NspRemoved", + DBUS_TYPE_G_OBJECT_PATH, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->proxy, "NspRemoved", + G_CALLBACK (nsp_removed_proxy), + object, NULL); + + register_for_property_changed (NM_DEVICE_WIMAX (object)); + + g_signal_connect (object, + "notify::" NM_DEVICE_STATE, + G_CALLBACK (state_changed_cb), + NULL); + + return object; +} + +static void +dispose (GObject *object) +{ + NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object); + + if (priv->disposed) { + G_OBJECT_CLASS (nm_device_wimax_parent_class)->dispose (object); + return; + } + + priv->disposed = TRUE; + + g_free (priv->hw_address); + g_free (priv->bsid); + + clean_up_nsps (NM_DEVICE_WIMAX (object), FALSE); + g_object_unref (priv->proxy); + + G_OBJECT_CLASS (nm_device_wimax_parent_class)->dispose (object); +} + +static void +nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (wimax_class); + NMDeviceClass *device_class = NM_DEVICE_CLASS (wimax_class); + + g_type_class_add_private (wimax_class, sizeof (NMDeviceWimaxPrivate)); + + /* virtual methods */ + object_class->constructor = constructor; + object_class->get_property = get_property; + object_class->dispose = dispose; + device_class->filter_connections = filter_connections; + + /* properties */ + + /** + * NMDeviceWimax:hw-address: + * + * The hardware (MAC) address of the device. + **/ + g_object_class_install_property + (object_class, PROP_HW_ADDRESS, + g_param_spec_string (NM_DEVICE_WIMAX_HW_ADDRESS, + "MAC Address", + "Hardware MAC address", + NULL, + G_PARAM_READABLE)); + + /** + * NMDeviceWimax:active-nsp: + * + * The active #NMWimaxNsp of the device. + **/ + g_object_class_install_property + (object_class, PROP_ACTIVE_NSP, + g_param_spec_object (NM_DEVICE_WIMAX_ACTIVE_NSP, + "Active NSP", + "Active NSP", + NM_TYPE_WIMAX_NSP, + G_PARAM_READABLE)); + + /** + * NMDeviceWimax:center-frequency: + * + * The center frequency (in KHz) of the radio channel the device is using to + * communicate with the network when connected. Has no meaning when the + * device is not connected. + **/ + g_object_class_install_property + (object_class, PROP_CENTER_FREQ, + g_param_spec_uint (NM_DEVICE_WIMAX_CENTER_FREQUENCY, + "Center frequency", + "Center frequency", + 0, G_MAXUINT, 0, + G_PARAM_READABLE)); + + /** + * NMDeviceWimax:rssi: + * + * RSSI of the current radio link in dBm. This value indicates how strong + * the raw received RF signal from the base station is, but does not + * indicate the overall quality of the radio link. Has no meaning when the + * device is not connected. + **/ + g_object_class_install_property + (object_class, PROP_RSSI, + g_param_spec_int (NM_DEVICE_WIMAX_RSSI, + "RSSI", + "RSSI", + G_MININT, G_MAXINT, 0, + G_PARAM_READABLE)); + + /** + * NMDeviceWimax:cinr: + * + * CINR (Carrier to Interference + Noise Ratio) of the current radio link + * in dB. CINR is a more accurate measure of radio link quality. Has no + * meaning when the device is not connected. + **/ + g_object_class_install_property + (object_class, PROP_CINR, + g_param_spec_int (NM_DEVICE_WIMAX_CINR, + "CINR", + "CINR", + G_MININT, G_MAXINT, 0, + G_PARAM_READABLE)); + + /** + * NMDeviceWimax:tx-power: + * + * Average power of the last burst transmitted by the device, in units of + * 0.5 dBm. i.e. a TxPower of -11 represents an actual device TX power of + * -5.5 dBm. Has no meaning when the device is not connected. + **/ + g_object_class_install_property + (object_class, PROP_TX_POWER, + g_param_spec_int (NM_DEVICE_WIMAX_TX_POWER, + "TX Power", + "TX Power", + G_MININT, G_MAXINT, 0, + G_PARAM_READABLE)); + + /** + * NMDeviceWimax:bsid: + * + * The ID of the serving base station as received from the network. Has + * no meaning when the device is not connected. + **/ + g_object_class_install_property + (object_class, PROP_BSID, + g_param_spec_string (NM_DEVICE_WIMAX_BSID, + "BSID", + "BSID", + NULL, + G_PARAM_READABLE)); + + /* signals */ + + /** + * NMDeviceWimax::nsp-added: + * @self: the wimax device that received the signal + * @nsp: the new NSP + * + * Notifies that a #NMWimaxNsp is added to the wimax device. + **/ + signals[NSP_ADDED] = + g_signal_new ("nsp-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMDeviceWimaxClass, nsp_added), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + G_TYPE_OBJECT); + + /** + * NMDeviceWimax::nsp-removed: + * @self: the wimax device that received the signal + * @nsp: the removed NSP + * + * Notifies that a #NMWimaxNsp is removed from the wimax device. + **/ + signals[NSP_REMOVED] = + g_signal_new ("nsp-removed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMDeviceWimaxClass, nsp_removed), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + G_TYPE_OBJECT); +} diff --git a/libnm-glib/nm-device-wimax.h b/libnm-glib/nm-device-wimax.h new file mode 100644 index 000000000..5e19bbaf9 --- /dev/null +++ b/libnm-glib/nm-device-wimax.h @@ -0,0 +1,79 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * libnm_glib -- Access network status & information from glib applications + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2009 Novell, Inc. + */ + +#ifndef NM_DEVICE_WIMAX_H +#define NM_DEVICE_WIMAX_H + +#include "nm-device.h" +#include "nm-wimax-nsp.h" + +G_BEGIN_DECLS + +#define NM_TYPE_DEVICE_WIMAX (nm_device_wimax_get_type ()) +#define NM_DEVICE_WIMAX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimax)) +#define NM_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass)) +#define NM_IS_DEVICE_WIMAX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_WIMAX)) +#define NM_IS_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_DEVICE_WIMAX)) +#define NM_DEVICE_WIMAX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass)) + +#define NM_DEVICE_WIMAX_HW_ADDRESS "hw-address" +#define NM_DEVICE_WIMAX_ACTIVE_NSP "active-nsp" +#define NM_DEVICE_WIMAX_CENTER_FREQUENCY "center-frequency" +#define NM_DEVICE_WIMAX_RSSI "rssi" +#define NM_DEVICE_WIMAX_CINR "cinr" +#define NM_DEVICE_WIMAX_TX_POWER "tx-power" +#define NM_DEVICE_WIMAX_BSID "bsid" + +typedef struct { + NMDevice parent; +} NMDeviceWimax; + +typedef struct { + NMDeviceClass parent; + + /* Signals */ + void (*nsp_added) (NMDeviceWimax *self, NMWimaxNsp *nsp); + void (*nsp_removed) (NMDeviceWimax *self, NMWimaxNsp *nsp); +} NMDeviceWimaxClass; + +GType nm_device_wimax_get_type (void); + +GObject *nm_device_wimax_new (DBusGConnection *connection, + const char *path); + +const char *nm_device_wimax_get_hw_address (NMDeviceWimax *wimax); +NMWimaxNsp *nm_device_wimax_get_active_nsp (NMDeviceWimax *wimax); +NMWimaxNsp *nm_device_wimax_get_nsp_by_path (NMDeviceWimax *wimax, + const char *path); + +const GPtrArray *nm_device_wimax_get_nsps (NMDeviceWimax *wimax); + +guint nm_device_wimax_get_center_frequency (NMDeviceWimax *self); +gint nm_device_wimax_get_rssi (NMDeviceWimax *self); +gint nm_device_wimax_get_cinr (NMDeviceWimax *self); +gint nm_device_wimax_get_tx_power (NMDeviceWimax *self); +const char * nm_device_wimax_get_bsid (NMDeviceWimax *self); + +G_END_DECLS + +#endif /* NM_DEVICE_WIMAX_H */ diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index b8998f70b..b198f526c 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -18,20 +18,19 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2010 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ #include <string.h> -#define G_UDEV_API_IS_SUBJECT_TO_CHANGE #include <gudev/gudev.h> #include "NetworkManager.h" #include "nm-device-ethernet.h" #include "nm-device-wifi.h" -#include "nm-gsm-device.h" -#include "nm-cdma-device.h" +#include "nm-device-modem.h" #include "nm-device-bt.h" +#include "nm-device-wimax.h" #include "nm-device.h" #include "nm-device-private.h" #include "nm-object-private.h" @@ -50,9 +49,10 @@ typedef struct { char *iface; char *ip_iface; + NMDeviceType device_type; char *udi; char *driver; - guint32 capabilities; + NMDeviceCapabilities capabilities; gboolean managed; gboolean firmware_missing; NMIP4Config *ip4_config; @@ -86,6 +86,7 @@ enum { PROP_VENDOR, PROP_DHCP6_CONFIG, PROP_IP_INTERFACE, + PROP_DEVICE_TYPE, LAST_PROP }; @@ -126,9 +127,7 @@ demarshal_ip4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint priv->null_ip4_config = TRUE; else { config = NM_IP4_CONFIG (_nm_object_cache_get (path)); - if (config) - config = g_object_ref (config); - else { + if (!config) { connection = nm_object_get_connection (object); config = NM_IP4_CONFIG (nm_ip4_config_new (connection, path)); } @@ -166,9 +165,7 @@ demarshal_dhcp4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi priv->null_dhcp4_config = TRUE; else { config = NM_DHCP4_CONFIG (_nm_object_cache_get (path)); - if (config) - config = g_object_ref (config); - else { + if (!config) { connection = nm_object_get_connection (object); config = NM_DHCP4_CONFIG (nm_dhcp4_config_new (connection, path)); } @@ -206,9 +203,7 @@ demarshal_ip6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint priv->null_ip6_config = TRUE; else { config = NM_IP6_CONFIG (_nm_object_cache_get (path)); - if (config) - config = g_object_ref (config); - else { + if (!config) { connection = nm_object_get_connection (object); config = NM_IP6_CONFIG (nm_ip6_config_new (connection, path)); } @@ -246,9 +241,7 @@ demarshal_dhcp6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi priv->null_dhcp6_config = TRUE; else { config = NM_DHCP6_CONFIG (_nm_object_cache_get (path)); - if (config) - config = g_object_ref (config); - else { + if (!config) { connection = nm_object_get_connection (object); config = NM_DHCP6_CONFIG (nm_dhcp6_config_new (connection, path)); } @@ -400,6 +393,9 @@ get_property (GObject *object, NMDevice *device = NM_DEVICE (object); switch (prop_id) { + case PROP_DEVICE_TYPE: + g_value_set_uint (value, nm_device_get_device_type (device)); + break; case PROP_UDI: g_value_set_string (value, nm_device_get_udi (device)); break; @@ -449,6 +445,26 @@ get_property (GObject *object, } static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + NMDevice *self = NM_DEVICE (object); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + + switch (prop_id) { + case PROP_DEVICE_TYPE: + /* Construct only */ + priv->device_type = g_value_get_uint (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void nm_device_class_init (NMDeviceClass *device_class) { GObjectClass *object_class = G_OBJECT_CLASS (device_class); @@ -458,6 +474,7 @@ nm_device_class_init (NMDeviceClass *device_class) /* virtual methods */ object_class->constructor = constructor; object_class->get_property = get_property; + object_class->set_property = set_property; object_class->dispose = dispose; object_class->finalize = finalize; @@ -491,9 +508,26 @@ nm_device_class_init (NMDeviceClass *device_class) G_PARAM_READABLE)); /** + * NMDevice:device-type: + * + * The numeric type of the device. + **/ + g_object_class_install_property + (object_class, PROP_DEVICE_TYPE, + g_param_spec_uint (NM_DEVICE_DEVICE_TYPE, + "Device Type", + "Numeric device type (ie ethernet, wifi, etc)", + NM_DEVICE_TYPE_UNKNOWN, G_MAXUINT32, NM_DEVICE_TYPE_UNKNOWN, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + /** * NMDevice:udi: * - * The Unique Device Identifier of the device. + * An operating-system specific device hardware identifier; this is not + * unique to a specific hardware device across reboots or hotplugs. It + * is an opaque string which for some device types (Bluetooth, Modem) + * contains an identifier provided by the underlying hardware service daemon + * such as Bluez or ModemManager, and clients can use this property to + * request more information about the device from those services. **/ g_object_class_install_property (object_class, PROP_UDI, @@ -674,7 +708,7 @@ nm_device_class_init (NMDeviceClass *device_class) * * Creates a new #NMDevice. * - * Returns: a new device + * Returns: (transfer full): a new device **/ GObject * nm_device_new (DBusGConnection *connection, const char *path) @@ -684,6 +718,7 @@ nm_device_new (DBusGConnection *connection, const char *path) GValue value = {0,}; GType dtype = 0; NMDevice *device = NULL; + NMDeviceType nm_dtype; g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (path != NULL, NULL); @@ -708,22 +743,23 @@ nm_device_new (DBusGConnection *connection, const char *path) goto out; } - switch (g_value_get_uint (&value)) { + nm_dtype = g_value_get_uint (&value); + switch (nm_dtype) { case NM_DEVICE_TYPE_ETHERNET: dtype = NM_TYPE_DEVICE_ETHERNET; break; case NM_DEVICE_TYPE_WIFI: dtype = NM_TYPE_DEVICE_WIFI; break; - case NM_DEVICE_TYPE_GSM: - dtype = NM_TYPE_GSM_DEVICE; - break; - case NM_DEVICE_TYPE_CDMA: - dtype = NM_TYPE_CDMA_DEVICE; + case NM_DEVICE_TYPE_MODEM: + dtype = NM_TYPE_DEVICE_MODEM; break; case NM_DEVICE_TYPE_BT: dtype = NM_TYPE_DEVICE_BT; break; + case NM_DEVICE_TYPE_WIMAX: + dtype = NM_TYPE_DEVICE_WIMAX; + break; default: g_warning ("Unknown device type %d", g_value_get_uint (&value)); break; @@ -733,6 +769,7 @@ nm_device_new (DBusGConnection *connection, const char *path) device = (NMDevice *) g_object_new (dtype, NM_OBJECT_DBUS_CONNECTION, connection, NM_OBJECT_DBUS_PATH, path, + NM_DEVICE_DEVICE_TYPE, nm_dtype, NULL); } @@ -761,7 +798,8 @@ nm_device_get_iface (NMDevice *device) if (!priv->iface) { priv->iface = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, - "Interface"); + "Interface", + NULL); } return priv->iface; @@ -788,13 +826,30 @@ nm_device_get_ip_iface (NMDevice *device) if (!priv->ip_iface) { priv->ip_iface = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, - "IpInterface"); + "IpInterface", + NULL); } return priv->ip_iface; } /** + * nm_device_get_device_type: + * @device: a #NMDevice + * + * Returns the numeric type of the #NMDevice, ie ethernet, wifi, etc. + * + * Returns: the device type + **/ +NMDeviceType +nm_device_get_device_type (NMDevice *self) +{ + g_return_val_if_fail (NM_IS_DEVICE (self), NM_DEVICE_TYPE_UNKNOWN); + + return NM_DEVICE_GET_PRIVATE (self)->device_type; +} + +/** * nm_device_get_udi: * @device: a #NMDevice * @@ -815,7 +870,8 @@ nm_device_get_udi (NMDevice *device) if (!priv->udi) { priv->udi = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, - "Udi"); + "Udi", + NULL); } return priv->udi; @@ -841,7 +897,8 @@ nm_device_get_driver (NMDevice *device) if (!priv->driver) { priv->driver = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, - "Driver"); + "Driver", + NULL); } return priv->driver; @@ -855,7 +912,7 @@ nm_device_get_driver (NMDevice *device) * * Returns: the capabilities **/ -guint32 +NMDeviceCapabilities nm_device_get_capabilities (NMDevice *device) { NMDevicePrivate *priv; @@ -866,7 +923,8 @@ nm_device_get_capabilities (NMDevice *device) if (!priv->capabilities) { priv->capabilities = _nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, - "Capabilities"); + "Capabilities", + NULL); } return priv->capabilities; @@ -891,7 +949,8 @@ nm_device_get_managed (NMDevice *device) if (!priv->managed) { priv->managed = _nm_object_get_boolean_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, - "Managed"); + "Managed", + NULL); } return priv->managed; @@ -918,7 +977,8 @@ nm_device_get_firmware_missing (NMDevice *device) if (!priv->firmware_missing) { priv->firmware_missing = _nm_object_get_boolean_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, - "FirmwareMissing"); + "FirmwareMissing", + NULL); } return priv->firmware_missing; @@ -930,7 +990,7 @@ nm_device_get_firmware_missing (NMDevice *device) * * Gets the current #NMIP4Config associated with the #NMDevice. * - * Returns: the #NMIP4Config or %NULL if the device is not activated. + * Returns: (transfer none): the #NMIP4Config or %NULL if the device is not activated. **/ NMIP4Config * nm_device_get_ip4_config (NMDevice *device) @@ -947,7 +1007,7 @@ nm_device_get_ip4_config (NMDevice *device) if (priv->null_ip4_config) return NULL; - path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip4Config"); + path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip4Config", NULL); if (path) { g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH); g_value_take_boxed (&value, path); @@ -964,7 +1024,7 @@ nm_device_get_ip4_config (NMDevice *device) * * Gets the current #NMDHCP4Config associated with the #NMDevice. * - * Returns: the #NMDHCPConfig or %NULL if the device is not activated or not + * Returns: (transfer none): the #NMDHCPConfig or %NULL if the device is not activated or not * using DHCP. **/ NMDHCP4Config * @@ -982,7 +1042,7 @@ nm_device_get_dhcp4_config (NMDevice *device) if (priv->null_dhcp4_config) return NULL; - path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Dhcp4Config"); + path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Dhcp4Config", NULL); if (path) { g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH); g_value_take_boxed (&value, path); @@ -999,7 +1059,7 @@ nm_device_get_dhcp4_config (NMDevice *device) * * Gets the current #NMIP6Config associated with the #NMDevice. * - * Returns: the #NMIP6Config or %NULL if the device is not activated. + * Returns: (transfer none): the #NMIP6Config or %NULL if the device is not activated. **/ NMIP6Config * nm_device_get_ip6_config (NMDevice *device) @@ -1016,7 +1076,7 @@ nm_device_get_ip6_config (NMDevice *device) if (priv->null_ip6_config) return NULL; - path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip6Config"); + path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip6Config", NULL); if (path) { g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH); g_value_take_boxed (&value, path); @@ -1033,7 +1093,7 @@ nm_device_get_ip6_config (NMDevice *device) * * Gets the current #NMDHCP6Config associated with the #NMDevice. * - * Returns: the #NMDHCPConfig or %NULL if the device is not activated or not + * Returns: (transfer none): the #NMDHCPConfig or %NULL if the device is not activated or not * using DHCP. **/ NMDHCP6Config * @@ -1051,7 +1111,7 @@ nm_device_get_dhcp6_config (NMDevice *device) if (priv->null_dhcp6_config) return NULL; - path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Dhcp6Config"); + path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Dhcp6Config", NULL); if (path) { g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH); g_value_take_boxed (&value, path); @@ -1081,7 +1141,8 @@ nm_device_get_state (NMDevice *device) if (priv->state == NM_DEVICE_STATE_UNKNOWN) { priv->state = _nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, - "State"); + "State", + NULL); } return priv->state; @@ -1313,7 +1374,7 @@ deactivate_cb (DBusGProxy *proxy, /** * nm_device_disconnect: * @device: a #NMDevice - * @callback: callback to be called when disconnect operation completes + * @callback: (scope async): callback to be called when disconnect operation completes * @user_data: caller-specific data passed to @callback * * Disconnects the device if currently connected, and prevents the device from @@ -1339,3 +1400,30 @@ nm_device_disconnect (NMDevice *device, info); } +/** + * nm_device_filter_connections: + * @device: an #NMDevice to filter connections for + * @connections: a list of #NMConnection objects to filter + * + * Filters a given list of connections for a given #NMDevice object and return + * connections which may be activated with the device. For example if @device + * is a WiFi device that supports only WEP encryption, the returned list will + * contain any WiFi connections in @connections that allow connection to + * unencrypted or WEP-enabled SSIDs. The returned list will not contain + * Ethernet, Bluetooth, WiFi WPA connections, or any other connection that is + * incompatible with the device. + * + * Returns: (transfer container) (element-type NetworkManager.Connection): a + * list of #NMConnection objects that could be activated with the given @device. + * The elements of the list are owned by their creator and should not be freed + * by the caller, but the returned list itself is owned by the caller and should + * be freed with g_slist_free() when it is no longer required. + **/ +GSList * +nm_device_filter_connections (NMDevice *device, const GSList *connections) +{ + if (NM_DEVICE_GET_CLASS (device)->filter_connections) + return NM_DEVICE_GET_CLASS (device)->filter_connections (device, connections); + return NULL; +} + diff --git a/libnm-glib/nm-device.h b/libnm-glib/nm-device.h index 59bf4de6b..0b641587a 100644 --- a/libnm-glib/nm-device.h +++ b/libnm-glib/nm-device.h @@ -18,7 +18,7 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2010 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ #ifndef NM_DEVICE_H @@ -44,6 +44,7 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_DEVICE)) #define NM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE, NMDeviceClass)) +#define NM_DEVICE_DEVICE_TYPE "device-type" #define NM_DEVICE_UDI "udi" #define NM_DEVICE_INTERFACE "interface" #define NM_DEVICE_IP_INTERFACE "ip-interface" @@ -72,6 +73,9 @@ typedef struct { NMDeviceState old_state, NMDeviceStateReason reason); + GSList * (*filter_connections) (NMDevice *device, + const GSList *connections); + /* Padding for future expansion */ void (*_reserved1) (void); void (*_reserved2) (void); @@ -85,26 +89,30 @@ GType nm_device_get_type (void); GObject * nm_device_new (DBusGConnection *connection, const char *path); -const char * nm_device_get_iface (NMDevice *device); -const char * nm_device_get_ip_iface (NMDevice *device); -const char * nm_device_get_udi (NMDevice *device); -const char * nm_device_get_driver (NMDevice *device); -guint32 nm_device_get_capabilities (NMDevice *device); -gboolean nm_device_get_managed (NMDevice *device); -gboolean nm_device_get_firmware_missing (NMDevice *device); -NMIP4Config * nm_device_get_ip4_config (NMDevice *device); -NMDHCP4Config * nm_device_get_dhcp4_config (NMDevice *device); -NMIP6Config * nm_device_get_ip6_config (NMDevice *device); -NMDHCP6Config * nm_device_get_dhcp6_config (NMDevice *device); -NMDeviceState nm_device_get_state (NMDevice *device); -const char * nm_device_get_product (NMDevice *device); -const char * nm_device_get_vendor (NMDevice *device); +const char * nm_device_get_iface (NMDevice *device); +const char * nm_device_get_ip_iface (NMDevice *device); +NMDeviceType nm_device_get_device_type (NMDevice *device); +const char * nm_device_get_udi (NMDevice *device); +const char * nm_device_get_driver (NMDevice *device); +NMDeviceCapabilities nm_device_get_capabilities (NMDevice *device); +gboolean nm_device_get_managed (NMDevice *device); +gboolean nm_device_get_firmware_missing (NMDevice *device); +NMIP4Config * nm_device_get_ip4_config (NMDevice *device); +NMDHCP4Config * nm_device_get_dhcp4_config (NMDevice *device); +NMIP6Config * nm_device_get_ip6_config (NMDevice *device); +NMDHCP6Config * nm_device_get_dhcp6_config (NMDevice *device); +NMDeviceState nm_device_get_state (NMDevice *device); +const char * nm_device_get_product (NMDevice *device); +const char * nm_device_get_vendor (NMDevice *device); typedef void (*NMDeviceDeactivateFn) (NMDevice *device, GError *error, gpointer user_data); -void nm_device_disconnect (NMDevice *device, - NMDeviceDeactivateFn callback, - gpointer user_data); +void nm_device_disconnect (NMDevice *device, + NMDeviceDeactivateFn callback, + gpointer user_data); + +GSList * nm_device_filter_connections (NMDevice *device, + const GSList *connections); G_END_DECLS diff --git a/libnm-glib/nm-dhcp4-config.c b/libnm-glib/nm-dhcp4-config.c index 442d19d19..8299de029 100644 --- a/libnm-glib/nm-dhcp4-config.c +++ b/libnm-glib/nm-dhcp4-config.c @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * Copyright (C) 2008 - 2010 Red Hat, Inc. + * Copyright (C) 2008 - 2011 Red Hat, Inc. * Copyright (C) 2008 Novell, Inc. */ @@ -169,6 +169,9 @@ nm_dhcp4_config_class_init (NMDHCP4ConfigClass *config_class) * NMDHCP4Config:options: * * The #GHashTable containing options of the configuration. + * + * Type: GLib.HashTable + * Element-Type: utf8,GObject.Value **/ g_object_class_install_property (object_class, PROP_OPTIONS, @@ -186,7 +189,7 @@ nm_dhcp4_config_class_init (NMDHCP4ConfigClass *config_class) * * Creates a new #NMDHCP4Config. * - * Returns: a new configuration + * Returns: (transfer full): a new configuration **/ GObject * nm_dhcp4_config_new (DBusGConnection *connection, const char *object_path) @@ -203,7 +206,7 @@ nm_dhcp4_config_new (DBusGConnection *connection, const char *object_path) * * Gets all the options contained in the configuration. * - * Returns: the #GHashTable containing strings for keys and values. + * Returns: (transfer none) (element-type utf8 GObject.Value): the #GHashTable containing strings for keys and values. * This is the internal copy used by the configuration, and must not be modified. **/ GHashTable * @@ -218,7 +221,8 @@ nm_dhcp4_config_get_options (NMDHCP4Config *config) if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_DHCP4_CONFIG, "Options", - &value)) + &value, + NULL)) goto out; demarshal_dhcp4_options (NM_OBJECT (config), NULL, &value, &priv->options); diff --git a/libnm-glib/nm-dhcp6-config.c b/libnm-glib/nm-dhcp6-config.c index 379286720..00698ed54 100644 --- a/libnm-glib/nm-dhcp6-config.c +++ b/libnm-glib/nm-dhcp6-config.c @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * Copyright (C) 2008 - 2010 Red Hat, Inc. + * Copyright (C) 2008 - 2011 Red Hat, Inc. * Copyright (C) 2008 Novell, Inc. */ @@ -169,6 +169,9 @@ nm_dhcp6_config_class_init (NMDHCP6ConfigClass *config_class) * NMDHCP6Config:options: * * The #GHashTable containing options of the configuration. + * + * Type: GLib.HashTable + * Element-Type: utf8,GObject.Value **/ g_object_class_install_property (object_class, PROP_OPTIONS, @@ -186,7 +189,7 @@ nm_dhcp6_config_class_init (NMDHCP6ConfigClass *config_class) * * Creates a new #NMDHCP6Config. * - * Returns: a new configuration + * Returns: (transfer full): a new configuration **/ GObject * nm_dhcp6_config_new (DBusGConnection *connection, const char *object_path) @@ -203,7 +206,7 @@ nm_dhcp6_config_new (DBusGConnection *connection, const char *object_path) * * Gets all the options contained in the configuration. * - * Returns: the #GHashTable containing strings for keys and values. + * Returns: (transfer none) (element-type utf8 GObject.Value): the #GHashTable containing strings for keys and values. * This is the internal copy used by the configuration, and must not be modified. **/ GHashTable * @@ -218,7 +221,8 @@ nm_dhcp6_config_get_options (NMDHCP6Config *config) if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_DHCP6_CONFIG, "Options", - &value)) + &value, + NULL)) goto out; demarshal_dhcp6_options (NM_OBJECT (config), NULL, &value, &priv->options); diff --git a/libnm-glib/nm-exported-connection.c b/libnm-glib/nm-exported-connection.c deleted file mode 100644 index b0e974cdc..000000000 --- a/libnm-glib/nm-exported-connection.c +++ /dev/null @@ -1,300 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 Novell, Inc. - * (C) Copyright 2008 - 2011 Red Hat, Inc. - */ - -#include <NetworkManager.h> -#include <dbus/dbus-glib-lowlevel.h> -#include <nm-setting-connection.h> - -#include "nm-exported-connection.h" -#include "nm-settings-interface.h" -#include "nm-settings-connection-interface.h" - -static gboolean impl_exported_connection_get_settings (NMExportedConnection *connection, - GHashTable **settings, - GError **error); - -static void impl_exported_connection_update (NMExportedConnection *connection, - GHashTable *new_settings, - DBusGMethodInvocation *context); - -static void impl_exported_connection_delete (NMExportedConnection *connection, - DBusGMethodInvocation *context); - -static void impl_exported_connection_get_secrets (NMExportedConnection *connection, - const gchar *setting_name, - const gchar **hints, - gboolean request_new, - DBusGMethodInvocation *context); - -#include "nm-exported-connection-glue.h" - -static void settings_connection_interface_init (NMSettingsConnectionInterface *class); - -G_DEFINE_TYPE_EXTENDED (NMExportedConnection, nm_exported_connection, NM_TYPE_CONNECTION, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE, - settings_connection_interface_init)) - -#define NM_EXPORTED_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_EXPORTED_CONNECTION, \ - NMExportedConnectionPrivate)) - -typedef struct { - gboolean foo; -} NMExportedConnectionPrivate; - - -/**************************************************************/ - -/* Has to be the same as NM_SYSCONFIG_SETTINGS_TIMESTAMP_TAG in nm-sysconfig-settings.h */ -#define CONNECTION_TIMESTAMP_TAG "timestamp-tag" - -static GHashTable * -real_get_settings (NMExportedConnection *self, GError **error) -{ - NMConnection *no_secrets; - GHashTable *settings; - NMSettingConnection *s_con; - guint64 *timestamp; - - /* Secrets should *never* be returned by the GetSettings method, they - * get returned by the GetSecrets method which can be better - * protected against leakage of secrets to unprivileged callers. - */ - no_secrets = nm_connection_duplicate (NM_CONNECTION (self)); - g_assert (no_secrets); - nm_connection_clear_secrets (no_secrets); - - /* Timestamp is not updated internally in connection's 'timestamp' - * property, because it would force updating the connection and in turn - * writing to /etc periodically, which we want to avoid. Rather real - * timestamps are kept track of in data associated with GObject. - * Here we substitute connection's timestamp with the real one. - */ - timestamp = (guint64 *) g_object_get_data (G_OBJECT (self), CONNECTION_TIMESTAMP_TAG); - if (timestamp) { - s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (NM_CONNECTION (no_secrets), NM_TYPE_SETTING_CONNECTION)); - g_assert (s_con); - g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, *timestamp, NULL); - } - - settings = nm_connection_to_hash (no_secrets); - g_assert (settings); - g_object_unref (no_secrets); - - return settings; -} - -/**************************************************************/ - -static gboolean -check_writable (NMConnection *connection, GError **error) -{ - NMSettingConnection *s_con; - - g_return_val_if_fail (connection != NULL, FALSE); - g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); - - s_con = (NMSettingConnection *) nm_connection_get_setting (connection, - NM_TYPE_SETTING_CONNECTION); - if (!s_con) { - g_set_error_literal (error, - NM_SETTINGS_INTERFACE_ERROR, - NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION, - "Connection did not have required 'connection' setting"); - return FALSE; - } - - /* If the connection is read-only, that has to be changed at the source of - * the problem (ex a system settings plugin that can't write connections out) - * instead of over D-Bus. - */ - if (nm_setting_connection_get_read_only (s_con)) { - g_set_error_literal (error, - NM_SETTINGS_INTERFACE_ERROR, - NM_SETTINGS_INTERFACE_ERROR_READ_ONLY_CONNECTION, - "Connection is read-only"); - return FALSE; - } - - return TRUE; -} - -static gboolean -impl_exported_connection_get_settings (NMExportedConnection *self, - GHashTable **settings, - GError **error) -{ - /* Must always be implemented */ - g_assert (NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_settings); - *settings = NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_settings (self, error); - return *settings ? TRUE : FALSE; -} - -static gboolean -update (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data) -{ - g_object_ref (connection); - nm_settings_connection_interface_emit_updated (connection); - callback (connection, NULL, user_data); - g_object_unref (connection); - return TRUE; -} - -static void -impl_exported_connection_update (NMExportedConnection *self, - GHashTable *new_settings, - DBusGMethodInvocation *context) -{ - NMConnection *tmp; - GError *error = NULL; - - /* If the connection is read-only, that has to be changed at the source of - * the problem (ex a system settings plugin that can't write connections out) - * instead of over D-Bus. - */ - if (!check_writable (NM_CONNECTION (self), &error)) { - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } - - /* Check if the settings are valid first */ - tmp = nm_connection_new_from_hash (new_settings, &error); - if (!tmp) { - g_assert (error); - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } - g_object_unref (tmp); - - if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->update) - NM_EXPORTED_CONNECTION_GET_CLASS (self)->update (self, new_settings, context); - else { - error = g_error_new (NM_SETTINGS_INTERFACE_ERROR, - NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, - "%s: %s:%d update() unimplemented", __func__, __FILE__, __LINE__); - dbus_g_method_return_error (context, error); - g_error_free (error); - } -} - -static gboolean -do_delete (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, - gpointer user_data) -{ - g_object_ref (connection); - g_signal_emit_by_name (connection, "removed"); - callback (connection, NULL, user_data); - g_object_unref (connection); - return TRUE; -} - -static void -impl_exported_connection_delete (NMExportedConnection *self, - DBusGMethodInvocation *context) -{ - GError *error = NULL; - - if (!check_writable (NM_CONNECTION (self), &error)) { - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } - - if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->delete) - NM_EXPORTED_CONNECTION_GET_CLASS (self)->delete (self, context); - else { - error = g_error_new (NM_SETTINGS_INTERFACE_ERROR, - NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, - "%s: %s:%d delete() unimplemented", __func__, __FILE__, __LINE__); - dbus_g_method_return_error (context, error); - g_error_free (error); - } -} - -static void -impl_exported_connection_get_secrets (NMExportedConnection *self, - const gchar *setting_name, - const gchar **hints, - gboolean request_new, - DBusGMethodInvocation *context) -{ - GError *error = NULL; - - if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets) - NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets (self, setting_name, hints, request_new, context); - else { - error = g_error_new (NM_SETTINGS_INTERFACE_ERROR, - NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, - "%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__); - dbus_g_method_return_error (context, error); - g_error_free (error); - } -} - -/**************************************************************/ - -static void -settings_connection_interface_init (NMSettingsConnectionInterface *iface) -{ - iface->update = update; - iface->delete = do_delete; -} - -/** - * nm_exported_connection_new: - * @scope: the Connection scope (either user or system) - * - * Creates a new object representing the remote connection. - * - * Returns: the new exported connection object on success, or %NULL on failure - **/ -NMExportedConnection * -nm_exported_connection_new (NMConnectionScope scope) -{ - g_return_val_if_fail (scope != NM_CONNECTION_SCOPE_UNKNOWN, NULL); - - return (NMExportedConnection *) g_object_new (NM_TYPE_EXPORTED_CONNECTION, - NM_CONNECTION_SCOPE, scope, - NULL); -} - -static void -nm_exported_connection_init (NMExportedConnection *self) -{ -} - -static void -nm_exported_connection_class_init (NMExportedConnectionClass *class) -{ - g_type_class_add_private (class, sizeof (NMExportedConnectionPrivate)); - - /* Virtual methods */ - class->get_settings = real_get_settings; - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (class), - &dbus_glib_nm_exported_connection_object_info); -} diff --git a/libnm-glib/nm-exported-connection.h b/libnm-glib/nm-exported-connection.h deleted file mode 100644 index 53dc3b024..000000000 --- a/libnm-glib/nm-exported-connection.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * (C) Copyright 2009 Red Hat, Inc. - */ - -#ifndef NM_EXPORTED_CONNECTION_H -#define NM_EXPORTED_CONNECTION_H - -#include <nm-connection.h> -#include <dbus/dbus-glib.h> - -G_BEGIN_DECLS - -#define NM_TYPE_EXPORTED_CONNECTION (nm_exported_connection_get_type ()) -#define NM_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnection)) -#define NM_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnectionClass)) -#define NM_IS_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION)) -#define NM_IS_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION)) -#define NM_EXPORTED_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnectionClass)) - -typedef struct { - NMConnection parent; -} NMExportedConnection; - -typedef struct { - NMConnectionClass parent; - - GHashTable * (*get_settings) (NMExportedConnection *self, - GError **error); - - void (*update) (NMExportedConnection *self, - GHashTable *new_settings, - DBusGMethodInvocation *context); - - void (*delete) (NMExportedConnection *self, - DBusGMethodInvocation *context); - - void (*get_secrets) (NMExportedConnection *self, - const gchar *setting_name, - const gchar **hints, - gboolean request_new, - DBusGMethodInvocation *context); - - /* Padding for future expansion */ - void (*_reserved1) (void); - void (*_reserved2) (void); - void (*_reserved3) (void); - void (*_reserved4) (void); - void (*_reserved5) (void); - void (*_reserved6) (void); -} NMExportedConnectionClass; - -GType nm_exported_connection_get_type (void); - -NMExportedConnection *nm_exported_connection_new (NMConnectionScope scope); - -G_END_DECLS - -#endif /* NM_EXPORTED_CONNECTION_H */ diff --git a/libnm-glib/nm-gsm-device.c b/libnm-glib/nm-gsm-device.c deleted file mode 100644 index aacbbb826..000000000 --- a/libnm-glib/nm-gsm-device.c +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2008 Red Hat, Inc. - */ - -#include "nm-gsm-device.h" -#include "nm-device-private.h" -#include "nm-object-private.h" - -G_DEFINE_TYPE (NMGsmDevice, nm_gsm_device, NM_TYPE_SERIAL_DEVICE) - -#define NM_GSM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_GSM_DEVICE, NMGsmDevicePrivate)) - -typedef struct { - DBusGProxy *proxy; - - gboolean disposed; -} NMGsmDevicePrivate; - -static void -nm_gsm_device_init (NMGsmDevice *device) -{ -} - -static void -register_for_property_changed (NMGsmDevice *device) -{ - NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (device); - const NMPropertiesChangedInfo property_changed_info[] = { - { NULL }, - }; - - _nm_object_handle_properties_changed (NM_OBJECT (device), - priv->proxy, - property_changed_info); -} - -static GObject* -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - GObject *object; - NMGsmDevicePrivate *priv; - - object = G_OBJECT_CLASS (nm_gsm_device_parent_class)->constructor (type, - n_construct_params, - construct_params); - if (!object) - return NULL; - - priv = NM_GSM_DEVICE_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_GSM_DEVICE); - - register_for_property_changed (NM_GSM_DEVICE (object)); - - return object; -} - -static void -dispose (GObject *object) -{ - NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (object); - - if (priv->disposed) { - G_OBJECT_CLASS (nm_gsm_device_parent_class)->dispose (object); - return; - } - - priv->disposed = TRUE; - - g_object_unref (priv->proxy); - - G_OBJECT_CLASS (nm_gsm_device_parent_class)->dispose (object); -} - -static void -nm_gsm_device_class_init (NMGsmDeviceClass *device_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (device_class); - - g_type_class_add_private (device_class, sizeof (NMGsmDevicePrivate)); - - /* virtual methods */ - object_class->constructor = constructor; - object_class->dispose = dispose; -} - -/** - * nm_gsm_device_new: - * @connection: the #DBusGConnection - * @path: the DBus object path of the device - * - * Creates a new #NMGsmDevice. - * - * Returns: a new device - **/ -NMGsmDevice * -nm_gsm_device_new (DBusGConnection *connection, const char *path) -{ - g_return_val_if_fail (connection != NULL, NULL); - g_return_val_if_fail (path != NULL, NULL); - - return (NMGsmDevice *) g_object_new (NM_TYPE_GSM_DEVICE, - NM_OBJECT_DBUS_CONNECTION, connection, - NM_OBJECT_DBUS_PATH, path, - NULL); -} diff --git a/libnm-glib/nm-gsm-device.h b/libnm-glib/nm-gsm-device.h deleted file mode 100644 index d8440973f..000000000 --- a/libnm-glib/nm-gsm-device.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2008 Red Hat, Inc. - */ - -#ifndef NM_GSM_DEVICE_H -#define NM_GSM_DEVICE_H - -#include "nm-serial-device.h" - -G_BEGIN_DECLS - -#define NM_TYPE_GSM_DEVICE (nm_gsm_device_get_type ()) -#define NM_GSM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_GSM_DEVICE, NMGsmDevice)) -#define NM_GSM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_GSM_DEVICE, NMGsmDeviceClass)) -#define NM_IS_GSM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_GSM_DEVICE)) -#define NM_IS_GSM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_GSM_DEVICE)) -#define NM_GSM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_GSM_DEVICE, NMGsmDeviceClass)) - -typedef struct { - NMSerialDevice parent; -} NMGsmDevice; - -typedef struct { - NMSerialDeviceClass parent; - - /* Padding for future expansion */ - void (*_reserved1) (void); - void (*_reserved2) (void); - void (*_reserved3) (void); - void (*_reserved4) (void); - void (*_reserved5) (void); - void (*_reserved6) (void); -} NMGsmDeviceClass; - -GType nm_gsm_device_get_type (void); - -NMGsmDevice *nm_gsm_device_new (DBusGConnection *connection, - const char *path); - -G_END_DECLS - -#endif /* NM_GSM_DEVICE_H */ diff --git a/libnm-glib/nm-ip4-config.c b/libnm-glib/nm-ip4-config.c index 4bedc7a1a..9f6096a40 100644 --- a/libnm-glib/nm-ip4-config.c +++ b/libnm-glib/nm-ip4-config.c @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * Copyright (C) 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2011 Novell, Inc. * Copyright (C) 2008 Red Hat, Inc. */ @@ -47,7 +47,6 @@ typedef struct { enum { PROP_0, PROP_ADDRESSES, - PROP_HOSTNAME, PROP_NAMESERVERS, PROP_DOMAINS, PROP_ROUTES, @@ -201,9 +200,6 @@ get_property (GObject *object, case PROP_ADDRESSES: nm_utils_ip4_addresses_to_gvalue (priv->addresses, value); break; - case PROP_HOSTNAME: - g_value_set_string (value, NULL); - break; case PROP_NAMESERVERS: g_value_set_boxed (value, nm_ip4_config_get_nameservers (self)); break; @@ -249,19 +245,6 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) G_PARAM_READABLE)); /** - * NMIP4Config:hostname: - * - * DEPRECATED. Don't use. - **/ - g_object_class_install_property - (object_class, PROP_HOSTNAME, - g_param_spec_string (NM_IP4_CONFIG_HOSTNAME, - "Hostname", - "Hostname", - NULL, - G_PARAM_READABLE)); - - /** * NMIP4Config:nameservers: * * The #GArray containing name servers (%guint32<!-- -->es) of the configuration. @@ -320,7 +303,7 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) * * Creates a new #NMIP4Config. * - * Returns: a new IP4 configuration + * Returns: (transfer full): a new IP4 configuration **/ GObject * nm_ip4_config_new (DBusGConnection *connection, const char *object_path) @@ -337,8 +320,8 @@ nm_ip4_config_new (DBusGConnection *connection, const char *object_path) * * Gets the IP4 addresses (containing the address, prefix, and gateway). * - * Returns: the #GSList containing #NMSettingIP4Address<!-- -->es. This is the internal copy - * used by the configuration and must not be modified. + * Returns: (element-type NetworkManager.IP4Address): the #GSList containing #NMIP4Address<!-- -->es. + * This is the internal copy used by the configuration and must not be modified. **/ const GSList * nm_ip4_config_get_addresses (NMIP4Config *config) @@ -346,7 +329,7 @@ nm_ip4_config_get_addresses (NMIP4Config *config) NMIP4ConfigPrivate *priv; GValue value = { 0, }; - g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0); + g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); priv = NM_IP4_CONFIG_GET_PRIVATE (config); if (priv->addresses) @@ -355,7 +338,8 @@ nm_ip4_config_get_addresses (NMIP4Config *config) if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP4_CONFIG, "Addresses", - &value)) { + &value, + NULL)) { return NULL; } @@ -366,26 +350,12 @@ nm_ip4_config_get_addresses (NMIP4Config *config) } /** - * nm_ip4_config_get_hostname: - * @config: a #NMIP4Config - * - * DEPRECATED. Don't use. - * - * Returns: NULL - **/ -const char * -nm_ip4_config_get_hostname (NMIP4Config *config) -{ - return NULL; -} - -/** * nm_ip4_config_get_nameservers: * @config: a #NMIP4Config * * Gets the domain name servers (DNS). * - * Returns: the #GArray containing %guint32<!-- -->s. This is the internal copy used by the + * Returns: (element-type guint32): the #GArray containing %guint32<!-- -->s. This is the internal copy used by the * configuration and must not be modified. **/ const GArray * @@ -402,7 +372,8 @@ nm_ip4_config_get_nameservers (NMIP4Config *config) if (_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP4_CONFIG, "Nameservers", - &value)) { + &value, + NULL)) { array = (GArray *) g_value_get_boxed (&value); if (array && array->len) { priv->nameservers = g_array_sized_new (FALSE, TRUE, sizeof (guint32), array->len); @@ -421,7 +392,7 @@ nm_ip4_config_get_nameservers (NMIP4Config *config) * * Gets the domain names. * - * Returns: the #GPtrArray containing domains as strings. This is the + * Returns: (element-type utf8): the #GPtrArray containing domains as strings. This is the * internal copy used by the configuration, and must not be modified. **/ const GPtrArray * @@ -439,7 +410,8 @@ nm_ip4_config_get_domains (NMIP4Config *config) if (_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP4_CONFIG, "Domains", - &value)) { + &value, + NULL)) { char **array = NULL, **p; array = (char **) g_value_get_boxed (&value); @@ -460,8 +432,8 @@ nm_ip4_config_get_domains (NMIP4Config *config) * * Gets the Windows Internet Name Service servers (WINS). * - * Returns: the #GArray containing %guint32<!-- -->s. This is the internal copy used by the - * configuration and must not be modified. + * Returns: (element-type guint32): the #GArray containing %guint32<!-- -->s. + * This is the internal copy used by the configuration and must not be modified. **/ const GArray * nm_ip4_config_get_wins_servers (NMIP4Config *config) @@ -477,7 +449,8 @@ nm_ip4_config_get_wins_servers (NMIP4Config *config) if (_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP4_CONFIG, "Nameservers", - &value)) { + &value, + NULL)) { array = (GArray *) g_value_get_boxed (&value); if (array && array->len) { priv->nameservers = g_array_sized_new (FALSE, TRUE, sizeof (guint32), array->len); @@ -496,8 +469,9 @@ nm_ip4_config_get_wins_servers (NMIP4Config *config) * * Gets the routes. * - * Returns: the #GSList containing #NMSettingIP4Route<!-- -->s. This is the - * internal copy used by the configuration, and must not be modified. + * Returns: (element-type NetworkManager.IP4Route): the #GSList containing + * #NMIP4Route<!-- -->s. This is the internal copy used by the configuration, + * and must not be modified. **/ const GSList * nm_ip4_config_get_routes (NMIP4Config *config) @@ -505,7 +479,7 @@ nm_ip4_config_get_routes (NMIP4Config *config) NMIP4ConfigPrivate *priv; GValue value = { 0, }; - g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0); + g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); priv = NM_IP4_CONFIG_GET_PRIVATE (config); if (priv->routes) @@ -514,7 +488,8 @@ nm_ip4_config_get_routes (NMIP4Config *config) if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP4_CONFIG, "Routes", - &value)) { + &value, + NULL)) { return NULL; } diff --git a/libnm-glib/nm-ip4-config.h b/libnm-glib/nm-ip4-config.h index 373d12e1e..ddff7e0ec 100644 --- a/libnm-glib/nm-ip4-config.h +++ b/libnm-glib/nm-ip4-config.h @@ -55,7 +55,6 @@ typedef struct { } NMIP4ConfigClass; #define NM_IP4_CONFIG_ADDRESSES "addresses" -#define NM_IP4_CONFIG_HOSTNAME "hostname" /* DEPRECATED */ #define NM_IP4_CONFIG_NAMESERVERS "nameservers" #define NM_IP4_CONFIG_DOMAINS "domains" #define NM_IP4_CONFIG_ROUTES "routes" @@ -66,7 +65,6 @@ GType nm_ip4_config_get_type (void); GObject *nm_ip4_config_new (DBusGConnection *connection, const char *object_path); const GSList * nm_ip4_config_get_addresses (NMIP4Config *config); -const char * nm_ip4_config_get_hostname (NMIP4Config *config); /* DEPRECATED */ const GArray * nm_ip4_config_get_nameservers (NMIP4Config *config); const GPtrArray *nm_ip4_config_get_domains (NMIP4Config *config); const GSList * nm_ip4_config_get_routes (NMIP4Config *config); diff --git a/libnm-glib/nm-ip6-config.c b/libnm-glib/nm-ip6-config.c index fe71c1b8d..7e9bf3cd8 100644 --- a/libnm-glib/nm-ip6-config.c +++ b/libnm-glib/nm-ip6-config.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2008 Red Hat, Inc. + * Copyright (C) 2008 - 2011 Red Hat, Inc. */ #include <string.h> @@ -60,7 +60,7 @@ enum { * * Creates a new #NMIP6Config. * - * Returns: a new IP6 configuration + * Returns: (transfer full): a new IP6 configuration **/ GObject * nm_ip6_config_new (DBusGConnection *connection, const char *object_path) @@ -146,8 +146,9 @@ register_for_property_changed (NMIP6Config *config) * * Gets the IP6 addresses (containing the address, prefix, and gateway). * - * Returns: the #GSList containing #NMSettingIP6Address<!-- -->es. This is the internal copy - * used by the configuration and must not be modified. + * Returns: (element-type NetworkManager.IP6Address): the #GSList containing + * #NMIP6Address<!-- -->es. This is the internal copy used by the configuration + * and must not be modified. **/ const GSList * nm_ip6_config_get_addresses (NMIP6Config *config) @@ -155,7 +156,7 @@ nm_ip6_config_get_addresses (NMIP6Config *config) NMIP6ConfigPrivate *priv; GValue value = { 0, }; - g_return_val_if_fail (NM_IS_IP6_CONFIG (config), 0); + g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); priv = NM_IP6_CONFIG_GET_PRIVATE (config); if (priv->addresses) @@ -164,7 +165,8 @@ nm_ip6_config_get_addresses (NMIP6Config *config) if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP6_CONFIG, "Addresses", - &value)) { + &value, + NULL)) { return NULL; } @@ -174,15 +176,16 @@ nm_ip6_config_get_addresses (NMIP6Config *config) return priv->addresses; } +/* FIXME: like in libnm_util, in6_addr is not introspectable, so skipping here */ /** - * nm_ip6_config_get_nameservers: + * nm_ip6_config_get_nameservers: (skip) * @config: a #NMIP6Config * * Gets the domain name servers (DNS). * - * Returns: a #GSList containing elements of type 'struct in6_addr' which contain - * the addresses of nameservers of the configuration. This is the internal copy - * used by the configuration and must not be modified. + * Returns: (element-type Posix.in6_addr): a #GSList containing elements of type + * 'struct in6_addr' which contain the addresses of nameservers of the configuration. + * This is the internal copy used by the configuration and must not be modified. **/ const GSList * nm_ip6_config_get_nameservers (NMIP6Config *config) @@ -200,7 +203,8 @@ nm_ip6_config_get_nameservers (NMIP6Config *config) if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP6_CONFIG, "Nameservers", - &value)) { + &value, + NULL)) { return NULL; } @@ -217,8 +221,8 @@ nm_ip6_config_get_nameservers (NMIP6Config *config) * * Gets the domain names. * - * Returns: the #GPtrArray containing domains as strings. This is the - * internal copy used by the configuration, and must not be modified. + * Returns: (element-type utf8): the #GPtrArray containing domains as strings. + * This is the internal copy used by the configuration, and must not be modified. **/ const GPtrArray * nm_ip6_config_get_domains (NMIP6Config *config) @@ -235,7 +239,8 @@ nm_ip6_config_get_domains (NMIP6Config *config) if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP6_CONFIG, "Domains", - &value)) { + &value, + NULL)) { return NULL; } @@ -251,8 +256,9 @@ nm_ip6_config_get_domains (NMIP6Config *config) * * Gets the routes. * - * Returns: the #GSList containing #NMSettingIP6Route<!-- -->s. This is the - * internal copy used by the configuration, and must not be modified. + * Returns: (element-type NetworkManager.IP6Route): the #GSList containing + * #NMIP6Route<!-- -->s. This is the internal copy used by the configuration, + * and must not be modified. **/ const GSList * nm_ip6_config_get_routes (NMIP6Config *config) @@ -260,7 +266,7 @@ nm_ip6_config_get_routes (NMIP6Config *config) NMIP6ConfigPrivate *priv; GValue value = { 0, }; - g_return_val_if_fail (NM_IS_IP6_CONFIG (config), 0); + g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); priv = NM_IP6_CONFIG_GET_PRIVATE (config); if (priv->routes) @@ -269,7 +275,8 @@ nm_ip6_config_get_routes (NMIP6Config *config) if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP6_CONFIG, "Routes", - &value)) { + &value, + NULL)) { return NULL; } diff --git a/libnm-glib/nm-object-cache.c b/libnm-glib/nm-object-cache.c index fdbca00f5..c43b42733 100644 --- a/libnm-glib/nm-object-cache.c +++ b/libnm-glib/nm-object-cache.c @@ -67,6 +67,6 @@ _nm_object_cache_get (const char *path) _init_cache (); object = g_hash_table_lookup (cache, path); - return object; + return object ? g_object_ref (object) : NULL; } diff --git a/libnm-glib/nm-object-cache.h b/libnm-glib/nm-object-cache.h index b8cf2121b..2348dcfa0 100644 --- a/libnm-glib/nm-object-cache.h +++ b/libnm-glib/nm-object-cache.h @@ -29,6 +29,7 @@ G_BEGIN_DECLS +/* Returns referenced object from the cache */ NMObject *_nm_object_cache_get (const char *path); void _nm_object_cache_add (NMObject *object); void _nm_object_cache_remove_by_object (NMObject *object); diff --git a/libnm-glib/nm-object-private.h b/libnm-glib/nm-object-private.h index 93514cbe4..4410df22d 100644 --- a/libnm-glib/nm-object-private.h +++ b/libnm-glib/nm-object-private.h @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * Copyright (C) 2008 Red Hat, Inc. + * Copyright (C) 2008 - 2011 Red Hat, Inc. */ #ifndef NM_OBJECT_PRIVATE_H @@ -37,9 +37,11 @@ typedef struct { } NMPropertiesChangedInfo; -void _nm_object_handle_properties_changed (NMObject *object, - DBusGProxy *proxy, - const NMPropertiesChangedInfo *info); +void _nm_object_handle_properties_changed (NMObject *object, + DBusGProxy *proxy, + const NMPropertiesChangedInfo *info); + +void _nm_object_process_properties_changed (NMObject *self, GHashTable *properties); gboolean _nm_object_demarshal_generic (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field); @@ -48,46 +50,55 @@ void _nm_object_queue_notify (NMObject *object, const char *property); /* DBus property accessors */ gboolean _nm_object_get_property (NMObject *object, - const char *interface, - const char *prop_name, - GValue *value); + const char *interface, + const char *prop_name, + GValue *value, + GError **error); void _nm_object_set_property (NMObject *object, - const char *interface, - const char *prop_name, - GValue *value); + const char *interface, + const char *prop_name, + GValue *value); char *_nm_object_get_string_property (NMObject *object, - const char *interface, - const char *prop_name); + const char *interface, + const char *prop_name, + GError **error); char *_nm_object_get_object_path_property (NMObject *object, - const char *interface, - const char *prop_name); + const char *interface, + const char *prop_name, + GError **error); gint32 _nm_object_get_int_property (NMObject *object, - const char *interface, - const char *prop_name); + const char *interface, + const char *prop_name, + GError **error); guint32 _nm_object_get_uint_property (NMObject *object, - const char *interface, - const char *prop_name); + const char *interface, + const char *prop_name, + GError **error); gboolean _nm_object_get_boolean_property (NMObject *object, - const char *interface, - const char *prop_name); + const char *interface, + const char *prop_name, + GError **error); gint8 _nm_object_get_byte_property (NMObject *object, - const char *interface, - const char *prop_name); + const char *interface, + const char *prop_name, + GError **error); gdouble _nm_object_get_double_property (NMObject *object, - const char *interface, - const char *prop_name); + const char *interface, + const char *prop_name, + GError **error); GByteArray *_nm_object_get_byte_array_property (NMObject *object, - const char *interface, - const char *prop_name); + const char *interface, + const char *prop_name, + GError **error); static inline const GPtrArray * handle_ptr_array_return (GPtrArray *array) diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index 85cb6b78a..8540ccca3 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2008 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ #include <string.h> @@ -223,7 +223,7 @@ nm_object_class_init (NMObjectClass *nm_object_class) * * Gets the #NMObject's DBusGConnection. * - * Returns: the connection + * Returns: (transfer none): the connection **/ DBusGConnection * nm_object_get_connection (NMObject *object) @@ -369,12 +369,18 @@ out: g_free (prop_name); } +void +_nm_object_process_properties_changed (NMObject *self, GHashTable *properties) +{ + g_hash_table_foreach (properties, handle_property_changed, self); +} + static void properties_changed_proxy (DBusGProxy *proxy, GHashTable *properties, gpointer user_data) { - g_hash_table_foreach (properties, handle_property_changed, user_data); + _nm_object_process_properties_changed (NM_OBJECT (user_data), properties); } void @@ -480,9 +486,10 @@ done: gboolean _nm_object_get_property (NMObject *object, - const char *interface, - const char *prop_name, - GValue *value) + const char *interface, + const char *prop_name, + GValue *value, + GError **error) { GError *err = NULL; @@ -490,6 +497,7 @@ _nm_object_get_property (NMObject *object, g_return_val_if_fail (interface != NULL, FALSE); g_return_val_if_fail (prop_name != NULL, FALSE); g_return_val_if_fail (value != NULL, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); if (!dbus_g_proxy_call_with_timeout (NM_OBJECT_GET_PRIVATE (object)->properties_proxy, "Get", 15000, &err, @@ -500,8 +508,10 @@ _nm_object_get_property (NMObject *object, G_TYPE_INVALID)) { /* Don't warn about D-Bus no reply/timeout errors; it's mostly noise and * happens for example when NM quits and the applet is still running. - */ - if (!(err->domain == DBUS_GERROR && err->code == DBUS_GERROR_NO_REPLY)) { + * And don't warn when 'error' is not NULL, rather propagate 'err' so the caller + * can do something with it. */ + if ( !error + && !(err->domain == DBUS_GERROR && err->code == DBUS_GERROR_NO_REPLY)) { g_warning ("%s: Error getting '%s' for %s: (%d) %s\n", __func__, prop_name, @@ -509,7 +519,7 @@ _nm_object_get_property (NMObject *object, err->code, err->message); } - g_error_free (err); + g_propagate_error (error, err); return FALSE; } @@ -542,13 +552,14 @@ _nm_object_set_property (NMObject *object, char * _nm_object_get_string_property (NMObject *object, - const char *interface, - const char *prop_name) + const char *interface, + const char *prop_name, + GError **error) { char *str = NULL; GValue value = {0,}; - if (_nm_object_get_property (object, interface, prop_name, &value)) { + if (_nm_object_get_property (object, interface, prop_name, &value, error)) { if (G_VALUE_HOLDS_STRING (&value)) str = g_strdup (g_value_get_string (&value)); else if (G_VALUE_HOLDS (&value, DBUS_TYPE_G_OBJECT_PATH)) @@ -561,13 +572,14 @@ _nm_object_get_string_property (NMObject *object, char * _nm_object_get_object_path_property (NMObject *object, - const char *interface, - const char *prop_name) + const char *interface, + const char *prop_name, + GError **error) { char *path = NULL; GValue value = {0,}; - if (_nm_object_get_property (object, interface, prop_name, &value)) { + if (_nm_object_get_property (object, interface, prop_name, &value, error)) { path = g_strdup (g_value_get_boxed (&value)); g_value_unset (&value); } @@ -577,13 +589,14 @@ _nm_object_get_object_path_property (NMObject *object, gint32 _nm_object_get_int_property (NMObject *object, - const char *interface, - const char *prop_name) + const char *interface, + const char *prop_name, + GError **error) { gint32 i = 0; GValue value = {0,}; - if (_nm_object_get_property (object, interface, prop_name, &value)) { + if (_nm_object_get_property (object, interface, prop_name, &value, error)) { i = g_value_get_int (&value); g_value_unset (&value); } @@ -593,13 +606,14 @@ _nm_object_get_int_property (NMObject *object, guint32 _nm_object_get_uint_property (NMObject *object, - const char *interface, - const char *prop_name) + const char *interface, + const char *prop_name, + GError **error) { guint32 i = 0; GValue value = {0,}; - if (_nm_object_get_property (object, interface, prop_name, &value)) { + if (_nm_object_get_property (object, interface, prop_name, &value, error)) { i = g_value_get_uint (&value); g_value_unset (&value); } @@ -609,13 +623,14 @@ _nm_object_get_uint_property (NMObject *object, gboolean _nm_object_get_boolean_property (NMObject *object, - const char *interface, - const char *prop_name) + const char *interface, + const char *prop_name, + GError **error) { - gboolean b = FALSE; // FIXME: somehow convey failure if needed + gboolean b = FALSE; GValue value = {0,}; - if (_nm_object_get_property (object, interface, prop_name, &value)) { + if (_nm_object_get_property (object, interface, prop_name, &value, error)) { b = g_value_get_boolean (&value); g_value_unset (&value); } @@ -625,13 +640,14 @@ _nm_object_get_boolean_property (NMObject *object, gint8 _nm_object_get_byte_property (NMObject *object, - const char *interface, - const char *prop_name) + const char *interface, + const char *prop_name, + GError **error) { gint8 b = G_MAXINT8; GValue value = {0,}; - if (_nm_object_get_property (object, interface, prop_name, &value)) { + if (_nm_object_get_property (object, interface, prop_name, &value, error)) { b = g_value_get_uchar (&value); g_value_unset (&value); } @@ -641,13 +657,14 @@ _nm_object_get_byte_property (NMObject *object, gdouble _nm_object_get_double_property (NMObject *object, - const char *interface, - const char *prop_name) + const char *interface, + const char *prop_name, + GError **error) { gdouble d = G_MAXDOUBLE; GValue value = {0,}; - if (_nm_object_get_property (object, interface, prop_name, &value)) { + if (_nm_object_get_property (object, interface, prop_name, &value, error)) { d = g_value_get_double (&value); g_value_unset (&value); } @@ -657,13 +674,14 @@ _nm_object_get_double_property (NMObject *object, GByteArray * _nm_object_get_byte_array_property (NMObject *object, - const char *interface, - const char *prop_name) + const char *interface, + const char *prop_name, + GError **error) { - GByteArray * array = NULL; + GByteArray *array = NULL; GValue value = {0,}; - if (_nm_object_get_property (object, interface, prop_name, &value)) { + if (_nm_object_get_property (object, interface, prop_name, &value, error)) { GArray * tmp = g_value_get_boxed (&value); int i; unsigned char byte; diff --git a/libnm-glib/nm-remote-connection-private.h b/libnm-glib/nm-remote-connection-private.h index 22d84ae74..3df576062 100644 --- a/libnm-glib/nm-remote-connection-private.h +++ b/libnm-glib/nm-remote-connection-private.h @@ -28,7 +28,8 @@ typedef enum { NM_REMOTE_CONNECTION_INIT_RESULT_UNKNOWN = 0, NM_REMOTE_CONNECTION_INIT_RESULT_SUCCESS, - NM_REMOTE_CONNECTION_INIT_RESULT_ERROR + NM_REMOTE_CONNECTION_INIT_RESULT_ERROR, + NM_REMOTE_CONNECTION_INIT_RESULT_INVISIBLE, } NMRemoteConnectionInitResult; #endif /* __NM_REMOTE_CONNECTION_PRIVATE__ */ diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c index 1039a7d18..57870c624 100644 --- a/libnm-glib/nm-remote-connection.c +++ b/libnm-glib/nm-remote-connection.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2010 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ #include <string.h> @@ -29,15 +29,11 @@ #include "nm-remote-connection.h" #include "nm-remote-connection-private.h" #include "nm-dbus-glib-types.h" -#include "nm-exported-connection-bindings.h" -#include "nm-settings-connection-interface.h" +#include "nm-settings-connection-bindings.h" #define NM_REMOTE_CONNECTION_BUS "bus" -static void settings_connection_interface_init (NMSettingsConnectionInterface *klass); - -G_DEFINE_TYPE_EXTENDED (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNECTION, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE, settings_connection_interface_init)) +G_DEFINE_TYPE (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNECTION) enum { PROP_0, @@ -47,10 +43,18 @@ enum { LAST_PROP }; +enum { + UPDATED, + REMOVED, + VISIBLE, + + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + typedef struct { NMRemoteConnection *self; - DBusGProxy *proxy; DBusGProxyCall *call; GFunc callback; gpointer user_data; @@ -59,10 +63,10 @@ typedef struct { typedef struct { DBusGConnection *bus; DBusGProxy *proxy; - DBusGProxy *secrets_proxy; GSList *calls; NMRemoteConnectionInitResult init_result; + gboolean visible; gboolean disposed; } NMRemoteConnectionPrivate; @@ -88,161 +92,184 @@ static void update_cb (DBusGProxy *proxy, GError *error, gpointer user_data) { RemoteCall *call = user_data; - NMSettingsConnectionInterfaceUpdateFunc func = (NMSettingsConnectionInterfaceUpdateFunc) call->callback; + NMRemoteConnectionCommitFunc func = (NMRemoteConnectionCommitFunc) call->callback; - (*func)(NM_SETTINGS_CONNECTION_INTERFACE (call->self), error, call->user_data); + (*func)(call->self, error, call->user_data); remote_call_complete (call->self, call); } -static gboolean -update (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data) +/** + * nm_remote_connection_commit_changes: + * @connection: the #NMRemoteConnection + * @callback: (scope async): a function to be called when the commit completes + * @user_data: caller-specific data to be passed to @callback + * + * Save any local changes to the settings and properties of this connection and + * save them in the settings service. + **/ +void +nm_remote_connection_commit_changes (NMRemoteConnection *self, + NMRemoteConnectionCommitFunc callback, + gpointer user_data) { - NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection); - NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + NMRemoteConnectionPrivate *priv; GHashTable *settings = NULL; RemoteCall *call; + g_return_if_fail (self != NULL); + g_return_if_fail (NM_IS_REMOTE_CONNECTION (self)); + g_return_if_fail (callback != NULL); + + priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + call = g_malloc0 (sizeof (RemoteCall)); call->self = self; call->callback = (GFunc) callback; call->user_data = user_data; - call->proxy = priv->proxy; - settings = nm_connection_to_hash (NM_CONNECTION (self)); + settings = nm_connection_to_hash (NM_CONNECTION (self), NM_SETTING_HASH_FLAG_ALL); - call->call = org_freedesktop_NetworkManagerSettings_Connection_update_async (priv->proxy, - settings, - update_cb, - call); + call->call = org_freedesktop_NetworkManager_Settings_Connection_update_async (priv->proxy, + settings, + update_cb, + call); g_assert (call->call); priv->calls = g_slist_append (priv->calls, call); g_hash_table_destroy (settings); - - return TRUE; } static void delete_cb (DBusGProxy *proxy, GError *error, gpointer user_data) { RemoteCall *call = user_data; - NMSettingsConnectionInterfaceDeleteFunc func = (NMSettingsConnectionInterfaceDeleteFunc) call->callback; + NMRemoteConnectionDeleteFunc func = (NMRemoteConnectionDeleteFunc) call->callback; - (*func)(NM_SETTINGS_CONNECTION_INTERFACE (call->self), error, call->user_data); + if (func != NULL) + (*func)(call->self, error, call->user_data); remote_call_complete (call->self, call); } -static gboolean -do_delete (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, - gpointer user_data) +/** + * nm_remote_connection_delete: + * @connection: the #NMRemoteConnection + * @callback: (scope async) (allow-none): a function to be called when the delete completes + * @user_data: caller-specific data to be passed to @callback + * + * Delete the connection. + **/ +void +nm_remote_connection_delete (NMRemoteConnection *self, + NMRemoteConnectionDeleteFunc callback, + gpointer user_data) { - NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection); - NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + NMRemoteConnectionPrivate *priv; RemoteCall *call; + g_return_if_fail (self != NULL); + g_return_if_fail (NM_IS_REMOTE_CONNECTION (self)); + + priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + call = g_malloc0 (sizeof (RemoteCall)); call->self = self; call->callback = (GFunc) callback; call->user_data = user_data; - call->proxy = priv->proxy; - call->call = org_freedesktop_NetworkManagerSettings_Connection_delete_async (priv->proxy, - delete_cb, - call); + call->call = org_freedesktop_NetworkManager_Settings_Connection_delete_async (priv->proxy, + delete_cb, + call); g_assert (call->call); priv->calls = g_slist_append (priv->calls, call); - - return TRUE; } static void get_secrets_cb (DBusGProxy *proxy, GHashTable *secrets, GError *error, gpointer user_data) { RemoteCall *call = user_data; - NMSettingsConnectionInterfaceGetSecretsFunc func = (NMSettingsConnectionInterfaceGetSecretsFunc) call->callback; + NMRemoteConnectionGetSecretsFunc func = (NMRemoteConnectionGetSecretsFunc) call->callback; - (*func)(NM_SETTINGS_CONNECTION_INTERFACE (call->self), error ? NULL : secrets, error, call->user_data); + (*func)(call->self, error ? NULL : secrets, error, call->user_data); remote_call_complete (call->self, call); } -static gboolean -get_secrets (NMSettingsConnectionInterface *connection, - const char *setting_name, - const char **hints, - gboolean request_new, - NMSettingsConnectionInterfaceGetSecretsFunc callback, - gpointer user_data) +/** + * nm_remote_connection_get_secrets: + * @connection: the #NMRemoteConnection + * @setting_name: the #NMSetting object name to get secrets for + * @callback: (scope async): a function to be called when the update completes + * @user_data: caller-specific data to be passed to @callback + * + * Request the connection's secrets. + **/ +void +nm_remote_connection_get_secrets (NMRemoteConnection *self, + const char *setting_name, + NMRemoteConnectionGetSecretsFunc callback, + gpointer user_data) { - NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection); - NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + NMRemoteConnectionPrivate *priv; RemoteCall *call; + g_return_if_fail (self != NULL); + g_return_if_fail (NM_IS_REMOTE_CONNECTION (self)); + g_return_if_fail (callback != NULL); + + priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + call = g_malloc0 (sizeof (RemoteCall)); call->self = self; call->callback = (GFunc) callback; call->user_data = user_data; - call->proxy = priv->secrets_proxy; - - call->call = org_freedesktop_NetworkManagerSettings_Connection_Secrets_get_secrets_async (priv->secrets_proxy, - setting_name, - hints, - request_new, - get_secrets_cb, - call); + + call->call = org_freedesktop_NetworkManager_Settings_Connection_get_secrets_async (priv->proxy, + setting_name, + get_secrets_cb, + call); g_assert (call->call); priv->calls = g_slist_append (priv->calls, call); - - return TRUE; } /****************************************************************/ -static gboolean +static void replace_settings (NMRemoteConnection *self, GHashTable *new_settings) { GError *error = NULL; - if (!nm_connection_replace_settings (NM_CONNECTION (self), new_settings, &error)) { - g_warning ("%s: error updating %s connection %s settings: (%d) %s", + if (nm_connection_replace_settings (NM_CONNECTION (self), new_settings, &error)) + g_signal_emit (self, signals[UPDATED], 0, new_settings); + else { + g_warning ("%s: error updating connection %s settings: (%d) %s", __func__, - (nm_connection_get_scope (NM_CONNECTION (self)) == NM_CONNECTION_SCOPE_USER) ? "user" : "system", nm_connection_get_path (NM_CONNECTION (self)), error ? error->code : -1, (error && error->message) ? error->message : "(unknown)"); g_clear_error (&error); - return FALSE; - } - /* Emit update irregardless to let listeners figure out what to do with - * the connection; whether to delete / ignore it or not. - */ - nm_settings_connection_interface_emit_updated (NM_SETTINGS_CONNECTION_INTERFACE (self)); - return TRUE; + g_signal_emit (self, signals[REMOVED], 0); + } } static void -get_settings_cb (DBusGProxy *proxy, - GHashTable *new_settings, - GError *error, - gpointer user_data) +init_get_settings_cb (DBusGProxy *proxy, + GHashTable *new_settings, + GError *error, + gpointer user_data) { NMRemoteConnection *self = user_data; NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); if (error) { - g_warning ("%s: error getting %s connection %s settings: (%d) %s", - __func__, - (nm_connection_get_scope (NM_CONNECTION (self)) == NM_CONNECTION_SCOPE_USER) ? "user" : "system", - nm_connection_get_path (NM_CONNECTION (self)), - error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); - g_error_free (error); - priv->init_result = NM_REMOTE_CONNECTION_INIT_RESULT_ERROR; + /* Connection doesn't exist, or isn't visible to this user */ + if (dbus_g_error_has_name (error, "org.freedesktop.NetworkManager.Settings.PermissionDenied")) + priv->init_result = NM_REMOTE_CONNECTION_INIT_RESULT_INVISIBLE; + else + priv->init_result = NM_REMOTE_CONNECTION_INIT_RESULT_ERROR; + g_object_notify (G_OBJECT (self), NM_REMOTE_CONNECTION_INIT_RESULT); } else { + priv->visible = TRUE; replace_settings (self, new_settings); g_hash_table_destroy (new_settings); priv->init_result = NM_REMOTE_CONNECTION_INIT_RESULT_SUCCESS; @@ -251,34 +278,64 @@ get_settings_cb (DBusGProxy *proxy, } static void -updated_cb (DBusGProxy *proxy, GHashTable *settings, gpointer user_data) +updated_get_settings_cb (DBusGProxy *proxy, + GHashTable *new_settings, + GError *error, + gpointer user_data) { - replace_settings (NM_REMOTE_CONNECTION (user_data), settings); + NMRemoteConnection *self = user_data; + NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + + if (error) { + GHashTable *hash; + + /* Connection is no longer visible to this user. Let the settings + * service handle this via 'visible'. The settings service will emit + * the "removed" signal for us since it handles the lifetime of this + * object. + */ + hash = g_hash_table_new (g_str_hash, g_str_equal); + nm_connection_replace_settings (NM_CONNECTION (self), hash, NULL); + g_hash_table_destroy (hash); + + priv->visible = FALSE; + g_signal_emit (self, signals[VISIBLE], 0, FALSE); + } else { + replace_settings (self, new_settings); + g_hash_table_destroy (new_settings); + + /* Settings service will handle announcing the connection to clients */ + if (priv->visible == FALSE) { + priv->visible = TRUE; + g_signal_emit (self, signals[VISIBLE], 0, TRUE); + } + } } static void -removed_cb (DBusGProxy *proxy, gpointer user_data) +updated_cb (DBusGProxy *proxy, gpointer user_data) { - g_signal_emit_by_name (G_OBJECT (user_data), "removed"); -} + NMRemoteConnection *self = NM_REMOTE_CONNECTION (user_data); + NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); -/****************************************************************/ + /* The connection got updated; request the replacement settings */ + org_freedesktop_NetworkManager_Settings_Connection_get_settings_async (priv->proxy, + updated_get_settings_cb, + self); +} static void -settings_connection_interface_init (NMSettingsConnectionInterface *klass) +removed_cb (DBusGProxy *proxy, gpointer user_data) { - /* interface implementation */ - klass->update = update; - klass->delete = do_delete; - klass->get_secrets = get_secrets; + g_signal_emit (G_OBJECT (user_data), signals[REMOVED], 0); } +/****************************************************************/ + /** * nm_remote_connection_new: * @bus: a valid and connected D-Bus connection - * @scope: the Connection scope (either user or system) * @path: the D-Bus path of the connection as exported by the settings service - * indicated by @scope * * Creates a new object representing the remote connection. * @@ -286,7 +343,6 @@ settings_connection_interface_init (NMSettingsConnectionInterface *klass) **/ NMRemoteConnection * nm_remote_connection_new (DBusGConnection *bus, - NMConnectionScope scope, const char *path) { g_return_val_if_fail (bus != NULL, NULL); @@ -294,7 +350,6 @@ nm_remote_connection_new (DBusGConnection *bus, return (NMRemoteConnection *) g_object_new (NM_TYPE_REMOTE_CONNECTION, NM_REMOTE_CONNECTION_BUS, bus, - NM_CONNECTION_SCOPE, scope, NM_CONNECTION_PATH, path, NULL); } @@ -306,7 +361,6 @@ constructor (GType type, { GObject *object; NMRemoteConnectionPrivate *priv; - const char *service = NM_DBUS_SERVICE_USER_SETTINGS; object = G_OBJECT_CLASS (nm_remote_connection_parent_class)->constructor (type, n_construct_params, construct_params); if (!object) @@ -316,32 +370,22 @@ constructor (GType type, g_assert (priv->bus); g_assert (nm_connection_get_path (NM_CONNECTION (object))); - if (nm_connection_get_scope (NM_CONNECTION (object)) == NM_CONNECTION_SCOPE_SYSTEM) - service = NM_DBUS_SERVICE_SYSTEM_SETTINGS; - priv->proxy = dbus_g_proxy_new_for_name (priv->bus, - service, + NM_DBUS_SERVICE, nm_connection_get_path (NM_CONNECTION (object)), NM_DBUS_IFACE_SETTINGS_CONNECTION); g_assert (priv->proxy); dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT); - priv->secrets_proxy = dbus_g_proxy_new_for_name (priv->bus, - service, - nm_connection_get_path (NM_CONNECTION (object)), - NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS); - g_assert (priv->secrets_proxy); - dbus_g_proxy_set_default_timeout (priv->secrets_proxy, G_MAXINT); - - dbus_g_proxy_add_signal (priv->proxy, "Updated", DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, G_TYPE_INVALID); + dbus_g_proxy_add_signal (priv->proxy, "Updated", G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->proxy, "Updated", G_CALLBACK (updated_cb), object, NULL); dbus_g_proxy_add_signal (priv->proxy, "Removed", G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->proxy, "Removed", G_CALLBACK (removed_cb), object, NULL); - org_freedesktop_NetworkManagerSettings_Connection_get_settings_async (priv->proxy, - get_settings_cb, - object); + org_freedesktop_NetworkManager_Settings_Connection_get_settings_async (priv->proxy, + init_get_settings_cb, + object); return object; } @@ -397,7 +441,6 @@ dispose (GObject *object) remote_call_complete (self, priv->calls->data); g_object_unref (priv->proxy); - g_object_unref (priv->secrets_proxy); dbus_g_connection_unref (priv->bus); } @@ -435,5 +478,46 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class) NM_REMOTE_CONNECTION_INIT_RESULT_ERROR, NM_REMOTE_CONNECTION_INIT_RESULT_UNKNOWN, G_PARAM_READABLE)); -} + /* Signals */ + /** + * NMRemoteConnection::updated: + * @connection: a #NMConnection + * + * This signal is emitted when a connection changes, and it is + * still visible to the user. + */ + signals[UPDATED] = + g_signal_new (NM_REMOTE_CONNECTION_UPDATED, + G_TYPE_FROM_CLASS (remote_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMRemoteConnectionClass, updated), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + /** + * NMRemoteConnection::removed: + * @connection: a #NMConnection + * + * This signal is emitted when a connection is either deleted or becomes + * invisible to the current user. + */ + signals[REMOVED] = + g_signal_new (NM_REMOTE_CONNECTION_REMOVED, + G_TYPE_FROM_CLASS (remote_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMRemoteConnectionClass, removed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + /* Private signal */ + signals[VISIBLE] = + g_signal_new ("visible", + G_TYPE_FROM_CLASS (remote_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); +} diff --git a/libnm-glib/nm-remote-connection.h b/libnm-glib/nm-remote-connection.h index ef5452f99..809927ea4 100644 --- a/libnm-glib/nm-remote-connection.h +++ b/libnm-glib/nm-remote-connection.h @@ -18,7 +18,7 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2009 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ #ifndef __NM_REMOTE_CONNECTION_H__ @@ -38,6 +38,9 @@ G_BEGIN_DECLS #define NM_IS_REMOTE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_REMOTE_CONNECTION)) #define NM_REMOTE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionClass)) +#define NM_REMOTE_CONNECTION_UPDATED "updated" +#define NM_REMOTE_CONNECTION_REMOVED "removed" + typedef struct { NMConnection parent; } NMRemoteConnection; @@ -45,6 +48,12 @@ typedef struct { typedef struct { NMConnectionClass parent_class; + /* Signals */ + void (*updated) (NMRemoteConnection *connection, + GHashTable *new_settings); + + void (*removed) (NMRemoteConnection *connection); + /* Padding for future expansion */ void (*_reserved1) (void); void (*_reserved2) (void); @@ -54,11 +63,36 @@ typedef struct { void (*_reserved6) (void); } NMRemoteConnectionClass; +typedef void (*NMRemoteConnectionCommitFunc) (NMRemoteConnection *connection, + GError *error, + gpointer user_data); + +typedef void (*NMRemoteConnectionDeleteFunc) (NMRemoteConnection *connection, + GError *error, + gpointer user_data); + +typedef void (*NMRemoteConnectionGetSecretsFunc) (NMRemoteConnection *connection, + GHashTable *secrets, + GError *error, + gpointer user_data); + GType nm_remote_connection_get_type (void); NMRemoteConnection *nm_remote_connection_new (DBusGConnection *bus, - NMConnectionScope scope, const char *path); + +void nm_remote_connection_commit_changes (NMRemoteConnection *connection, + NMRemoteConnectionCommitFunc callback, + gpointer user_data); + +void nm_remote_connection_delete (NMRemoteConnection *connection, + NMRemoteConnectionDeleteFunc callback, + gpointer user_data); + +void nm_remote_connection_get_secrets (NMRemoteConnection *connection, + const char *setting_name, + NMRemoteConnectionGetSecretsFunc callback, + gpointer user_data); G_END_DECLS #endif /* __NM_REMOTE_CONNECTION__ */ diff --git a/libnm-glib/nm-remote-settings-system.c b/libnm-glib/nm-remote-settings-system.c deleted file mode 100644 index 95098c7e6..000000000 --- a/libnm-glib/nm-remote-settings-system.c +++ /dev/null @@ -1,375 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2009 - 2010 Red Hat, Inc. - */ - -#include <string.h> -#include <NetworkManager.h> -#include <nm-connection.h> - -#include "nm-marshal.h" -#include "nm-dbus-glib-types.h" -#include "nm-remote-settings-system.h" -#include "nm-settings-system-bindings.h" -#include "nm-settings-system-interface.h" - -static void settings_system_interface_init (NMSettingsSystemInterface *klass); - -G_DEFINE_TYPE_EXTENDED (NMRemoteSettingsSystem, nm_remote_settings_system, NM_TYPE_REMOTE_SETTINGS, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_SYSTEM_INTERFACE, settings_system_interface_init)) - -#define NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_SETTINGS_SYSTEM, NMRemoteSettingsSystemPrivate)) - -typedef struct { - DBusGProxy *proxy; - DBusGProxy *props_proxy; - - char *hostname; - gboolean can_modify; - - NMSettingsSystemPermissions permissions; - gboolean have_permissions; - - gboolean disposed; -} NMRemoteSettingsSystemPrivate; - -static void -properties_changed_cb (DBusGProxy *proxy, - GHashTable *properties, - gpointer user_data) -{ - NMRemoteSettingsSystem *self = NM_REMOTE_SETTINGS_SYSTEM (user_data); - NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (self); - GHashTableIter iter; - gpointer key, tmp; - - g_hash_table_iter_init (&iter, properties); - while (g_hash_table_iter_next (&iter, &key, &tmp)) { - GValue *value = tmp; - - if (!strcmp ((const char *) key, "Hostname")) { - g_free (priv->hostname); - priv->hostname = g_value_dup_string (value); - g_object_notify (G_OBJECT (self), NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME); - } - - if (!strcmp ((const char *) key, "CanModify")) { - priv->can_modify = g_value_get_boolean (value); - g_object_notify (G_OBJECT (self), NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY); - } - } -} - -static void -get_all_cb (DBusGProxy *proxy, - DBusGProxyCall *call, - gpointer user_data) -{ - NMRemoteSettingsSystem *self = NM_REMOTE_SETTINGS_SYSTEM (user_data); - GHashTable *props = NULL; - GError *error = NULL; - - if (!dbus_g_proxy_end_call (proxy, call, &error, - DBUS_TYPE_G_MAP_OF_VARIANT, &props, - G_TYPE_INVALID)) { - /* Don't warn when the call times out because the settings service can't - * be activated or whatever. - */ - if (!(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_NO_REPLY)) { - g_warning ("%s: couldn't retrieve system settings properties: (%d) %s.", - __func__, - error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); - } - g_clear_error (&error); - return; - } - - properties_changed_cb (NULL, props, self); - g_hash_table_destroy (props); -} - -typedef struct { - NMSettingsSystemInterface *settings; - NMSettingsSystemSaveHostnameFunc callback; - gpointer callback_data; -} SaveHostnameInfo; - -static void -save_hostname_cb (DBusGProxy *proxy, - DBusGProxyCall *call, - gpointer user_data) -{ - SaveHostnameInfo *info = user_data; - GError *error = NULL; - - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); - info->callback (info->settings, error, info->callback_data); - g_clear_error (&error); -} - -static gboolean -save_hostname (NMSettingsSystemInterface *settings, - const char *hostname, - NMSettingsSystemSaveHostnameFunc callback, - gpointer user_data) -{ - NMRemoteSettingsSystem *self = NM_REMOTE_SETTINGS_SYSTEM (settings); - NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (self); - SaveHostnameInfo *info; - - info = g_malloc0 (sizeof (SaveHostnameInfo)); - info->settings = settings; - info->callback = callback; - info->callback_data = user_data; - - dbus_g_proxy_begin_call (priv->proxy, "SaveHostname", - save_hostname_cb, - info, - g_free, - G_TYPE_STRING, hostname ? hostname : "", - G_TYPE_INVALID); - return TRUE; -} - -typedef struct { - NMSettingsSystemInterface *settings; - NMSettingsSystemGetPermissionsFunc callback; - gpointer callback_data; -} GetPermissionsInfo; - -static void -get_permissions_cb (DBusGProxy *proxy, - DBusGProxyCall *call, - gpointer user_data) -{ - GetPermissionsInfo *info = user_data; - NMRemoteSettingsSystem *self = NM_REMOTE_SETTINGS_SYSTEM (info->settings); - NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (self); - NMSettingsSystemPermissions permissions = NM_SETTINGS_SYSTEM_PERMISSION_NONE; - GError *error = NULL; - - dbus_g_proxy_end_call (proxy, call, &error, - G_TYPE_UINT, &permissions, - G_TYPE_INVALID); - priv->permissions = permissions; - priv->have_permissions = !error; - info->callback (info->settings, permissions, error, info->callback_data); - g_clear_error (&error); -} - -static gboolean -get_permissions (NMSettingsSystemInterface *settings, - NMSettingsSystemGetPermissionsFunc callback, - gpointer user_data) -{ - NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (settings); - GetPermissionsInfo *info; - - /* Skip D-Bus if we already have permissions */ - if (priv->have_permissions) { - callback (settings, priv->permissions, NULL, user_data); - return TRUE; - } - - /* Otherwise fetch them from NM */ - info = g_malloc0 (sizeof (GetPermissionsInfo)); - info->settings = settings; - info->callback = callback; - info->callback_data = user_data; - - dbus_g_proxy_begin_call (priv->proxy, "GetPermissions", - get_permissions_cb, - info, - g_free, - G_TYPE_INVALID); - return TRUE; -} - -static void -check_permissions_cb (DBusGProxy *proxy, gpointer user_data) -{ - NMRemoteSettingsSystem *self = NM_REMOTE_SETTINGS_SYSTEM (user_data); - NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (self); - - /* Permissions need to be re-fetched */ - priv->have_permissions = FALSE; - g_signal_emit_by_name (self, NM_SETTINGS_SYSTEM_INTERFACE_CHECK_PERMISSIONS); -} - -/****************************************************************/ - -static void -settings_system_interface_init (NMSettingsSystemInterface *klass) -{ - /* interface implementation */ - klass->save_hostname = save_hostname; - klass->get_permissions = get_permissions; -} - -/** - * nm_remote_settings_system_new: - * @bus: a valid and connected D-Bus connection - * - * Creates a new object representing the remote system settings service. - * - * Returns: the new remote system settings object on success, or %NULL on failure - **/ -NMRemoteSettingsSystem * -nm_remote_settings_system_new (DBusGConnection *bus) -{ - g_return_val_if_fail (bus != NULL, NULL); - - return (NMRemoteSettingsSystem *) g_object_new (NM_TYPE_REMOTE_SETTINGS_SYSTEM, - NM_REMOTE_SETTINGS_BUS, bus, - NM_REMOTE_SETTINGS_SCOPE, NM_CONNECTION_SCOPE_SYSTEM, - NULL); -} - -static void -nm_remote_settings_system_init (NMRemoteSettingsSystem *self) -{ -} - -static GObject * -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - GObject *object; - NMRemoteSettingsSystemPrivate *priv; - DBusGConnection *bus = NULL; - - object = G_OBJECT_CLASS (nm_remote_settings_system_parent_class)->constructor (type, n_construct_params, construct_params); - if (!object) - return NULL; - - priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (object); - - g_object_get (G_OBJECT (object), NM_REMOTE_SETTINGS_BUS, &bus, NULL); - g_assert (bus); - - /* D-Bus properties proxy */ - priv->props_proxy = dbus_g_proxy_new_for_name (bus, - NM_DBUS_SERVICE_SYSTEM_SETTINGS, - NM_DBUS_PATH_SETTINGS, - "org.freedesktop.DBus.Properties"); - g_assert (priv->props_proxy); - - /* System settings proxy */ - priv->proxy = dbus_g_proxy_new_for_name (bus, - NM_DBUS_SERVICE_SYSTEM_SETTINGS, - NM_DBUS_PATH_SETTINGS, - NM_DBUS_IFACE_SETTINGS_SYSTEM); - g_assert (priv->proxy); - dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT); - - dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, - DBUS_TYPE_G_MAP_OF_VARIANT, - G_TYPE_INVALID); - dbus_g_proxy_add_signal (priv->proxy, "PropertiesChanged", - DBUS_TYPE_G_MAP_OF_VARIANT, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged", - G_CALLBACK (properties_changed_cb), - object, - NULL); - - /* Monitor for permissions changes */ - dbus_g_proxy_add_signal (priv->proxy, "CheckPermissions", G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->proxy, "CheckPermissions", - G_CALLBACK (check_permissions_cb), - object, - NULL); - - /* Get properties */ - dbus_g_proxy_begin_call (priv->props_proxy, "GetAll", - get_all_cb, - object, - NULL, - G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS_SYSTEM, - G_TYPE_INVALID); - - dbus_g_connection_unref (bus); - - return object; -} - -static void -dispose (GObject *object) -{ - NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (object); - - if (priv->disposed) - return; - - priv->disposed = TRUE; - - g_free (priv->hostname); - - g_object_unref (priv->props_proxy); - g_object_unref (priv->proxy); - - G_OBJECT_CLASS (nm_remote_settings_system_parent_class)->dispose (object); -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (object); - - switch (prop_id) { - case NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME: - g_value_set_string (value, priv->hostname); - break; - case NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY: - g_value_set_boolean (value, priv->can_modify); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -nm_remote_settings_system_class_init (NMRemoteSettingsSystemClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (NMRemoteSettingsSystemPrivate)); - - /* Virtual methods */ - object_class->constructor = constructor; - object_class->get_property = get_property; - object_class->dispose = dispose; - - /* Properties */ - g_object_class_override_property (object_class, - NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME, - NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME); - - g_object_class_override_property (object_class, - NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY, - NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY); -} - diff --git a/libnm-glib/nm-remote-settings-system.h b/libnm-glib/nm-remote-settings-system.h deleted file mode 100644 index b51822733..000000000 --- a/libnm-glib/nm-remote-settings-system.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2009 Red Hat, Inc. - */ - -#ifndef NM_REMOTE_SETTINGS_SYSTEM_H -#define NM_REMOTE_SETTINGS_SYSTEM_H - -#include <glib.h> -#include <dbus/dbus-glib.h> - -#include "nm-remote-settings.h" -#include "nm-settings-system-interface.h" - -G_BEGIN_DECLS - -#define NM_TYPE_REMOTE_SETTINGS_SYSTEM (nm_remote_settings_system_get_type ()) -#define NM_REMOTE_SETTINGS_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_REMOTE_SETTINGS_SYSTEM, NMRemoteSettingsSystem)) -#define NM_REMOTE_SETTINGS_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_REMOTE_SETTINGS_SYSTEM, NMRemoteSettingsSystemClass)) -#define NM_IS_REMOTE_SETTINGS_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_REMOTE_SETTINGS_SYSTEM)) -#define NM_IS_REMOTE_SETTINGS_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_REMOTE_SETTINGS_SYSTEM)) -#define NM_REMOTE_SETTINGS_SYSTEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_SETTINGS_SYSTEM, NMRemoteSettingsSystemClass)) - -typedef struct { - NMRemoteSettings parent; -} NMRemoteSettingsSystem; - -typedef struct { - NMRemoteSettingsClass parent; - - /* Padding for future expansion */ - void (*_reserved1) (void); - void (*_reserved2) (void); - void (*_reserved3) (void); - void (*_reserved4) (void); - void (*_reserved5) (void); - void (*_reserved6) (void); -} NMRemoteSettingsSystemClass; - -GType nm_remote_settings_system_get_type (void); - -NMRemoteSettingsSystem *nm_remote_settings_system_new (DBusGConnection *bus); - -G_END_DECLS - -#endif /* NM_REMOTE_SETTINGS_SYSTEM_H */ diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c index 6a9a1d71e..e8239d787 100644 --- a/libnm-glib/nm-remote-settings.c +++ b/libnm-glib/nm-remote-settings.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2009 - 2010 Red Hat, Inc. + * Copyright (C) 2009 - 2011 Red Hat, Inc. */ #include <string.h> @@ -26,26 +26,30 @@ #include <nm-connection.h> #include "nm-marshal.h" +#include "nm-dbus-glib-types.h" #include "nm-remote-settings.h" #include "nm-settings-bindings.h" -#include "nm-settings-interface.h" #include "nm-remote-connection-private.h" -static void settings_interface_init (NMSettingsInterface *class); - -G_DEFINE_TYPE_EXTENDED (NMRemoteSettings, nm_remote_settings, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_INTERFACE, settings_interface_init)) +G_DEFINE_TYPE (NMRemoteSettings, nm_remote_settings, G_TYPE_OBJECT) #define NM_REMOTE_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsPrivate)) typedef struct { DBusGConnection *bus; - NMConnectionScope scope; DBusGProxy *proxy; GHashTable *connections; GHashTable *pending; /* Connections we don't have settings for yet */ gboolean service_running; + guint32 init_left; + + /* AddConnectionInfo objects that are waiting for the connection to become initialized */ + GSList *add_list; + + DBusGProxy *props_proxy; + char *hostname; + gboolean can_modify; DBusGProxy *dbus_proxy; @@ -57,15 +61,124 @@ typedef struct { enum { PROP_0, PROP_BUS, - PROP_SCOPE, PROP_SERVICE_RUNNING, + PROP_HOSTNAME, + PROP_CAN_MODIFY, LAST_PROP }; -static NMSettingsConnectionInterface * -get_connection_by_path (NMSettingsInterface *settings, const char *path) +/* Signals */ +enum { + NEW_CONNECTION, + CONNECTIONS_READ, + + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +/**********************************************************************/ + +/** + * nm_remote_settings_error_quark: + * + * Registers an error quark for #NMRemoteSettings if necessary. + * + * Returns: the error quark used for #NMRemoteSettings errors. + **/ +GQuark +nm_remote_settings_error_quark (void) +{ + static GQuark quark; + + if (G_UNLIKELY (!quark)) + quark = g_quark_from_static_string ("nm-remote-settings-error-quark"); + return quark; +} + +/* This should really be standard. */ +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } + +GType +nm_remote_settings_error_get_type (void) +{ + static GType etype = 0; + + if (etype == 0) { + static const GEnumValue values[] = { + ENUM_ENTRY (NM_REMOTE_SETTINGS_ERROR_UNKNOWN, "UnknownError"), + ENUM_ENTRY (NM_REMOTE_SETTINGS_ERROR_CONNECTION_REMOVED, "ConnectionRemoved"), + ENUM_ENTRY (NM_REMOTE_SETTINGS_ERROR_CONNECTION_UNAVAILABLE, "ConnectionUnavailable"), + { 0, 0, 0 } + }; + etype = g_enum_register_static ("NMRemoteSettingsError", values); + } + return etype; +} + +/**********************************************************************/ + +typedef struct { + NMRemoteSettings *self; + NMRemoteSettingsAddConnectionFunc callback; + gpointer callback_data; + NMRemoteConnection *connection; +} AddConnectionInfo; + +static AddConnectionInfo * +add_connection_info_find (NMRemoteSettings *self, NMRemoteConnection *connection) +{ + NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); + GSList *iter; + + for (iter = priv->add_list; iter; iter = g_slist_next (iter)) { + AddConnectionInfo *info = iter->data; + + if (info->connection == connection) + return info; + } + + return NULL; +} + +static void +add_connection_info_dispose (NMRemoteSettings *self, AddConnectionInfo *info) +{ + NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); + + priv->add_list = g_slist_remove (priv->add_list, info); + + g_free (info); +} + +static void +add_connection_info_complete (NMRemoteSettings *self, + AddConnectionInfo *info, + GError *error) +{ + g_return_if_fail (info != NULL); + + info->callback (info->self, error ? NULL : info->connection, error, info->callback_data); + add_connection_info_dispose (self, info); +} + +/** + * nm_remote_settings_get_connection_by_path: + * @settings: the %NMRemoteSettings + * @path: the D-Bus object path of the remote connection + * + * Returns the %NMRemoteConnection representing the connection at @path. + * + * Returns: (transfer none): the remote connection object on success, or NULL if the object was + * not known + **/ +NMRemoteConnection * +nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings, const char *path) { + g_return_val_if_fail (settings != NULL, NULL); + g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL); + g_return_val_if_fail (path != NULL, NULL); + return g_hash_table_lookup (NM_REMOTE_SETTINGS_GET_PRIVATE (settings)->connections, path); } @@ -74,14 +187,68 @@ connection_removed_cb (NMRemoteConnection *remote, gpointer user_data) { NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data); NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); + AddConnectionInfo *addinfo; + GError *add_error; const char *path; + /* Might have been removed while it was waiting to be initialized */ + addinfo = add_connection_info_find (self, remote); + if (addinfo) { + add_error = g_error_new_literal (NM_REMOTE_SETTINGS_ERROR, + NM_REMOTE_SETTINGS_ERROR_CONNECTION_REMOVED, + "Connection removed before it was initialized"); + add_connection_info_complete (self, addinfo, add_error); + g_error_free (add_error); + } + path = nm_connection_get_path (NM_CONNECTION (remote)); g_hash_table_remove (priv->connections, path); g_hash_table_remove (priv->pending, path); } static void +connection_visible_cb (NMRemoteConnection *remote, + gboolean visible, + gpointer user_data) +{ + NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data); + NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); + const char *path; + + path = nm_connection_get_path (NM_CONNECTION (remote)); + g_assert (path); + + /* When a connection becomes invisible, we put it back in the pending + * hash until it becomes visible again. When it does, we move it back to + * the normal connections hash. + */ + if (visible) { + /* Connection visible to this user again */ + if (g_hash_table_lookup (priv->pending, path)) { + /* Move connection from pending to visible hash; emit for clients */ + g_hash_table_insert (priv->connections, g_strdup (path), g_object_ref (remote)); + g_hash_table_remove (priv->pending, path); + g_signal_emit (self, signals[NEW_CONNECTION], 0, remote); + } + } else { + /* Connection now invisible to this user */ + if (g_hash_table_lookup (priv->connections, path)) { + /* Move connection to pending hash and wait for it to become visible again */ + g_hash_table_insert (priv->pending, g_strdup (path), g_object_ref (remote)); + g_hash_table_remove (priv->connections, path); + + /* Signal to clients that the connection is gone; but we have to + * block our connection removed handler so we don't destroy + * the connection when the signal is emitted. + */ + g_signal_handlers_block_by_func (remote, connection_removed_cb, self); + g_signal_emit_by_name (remote, NM_REMOTE_CONNECTION_REMOVED); + g_signal_handlers_unblock_by_func (remote, connection_removed_cb, self); + } + } +} + +static void connection_init_result_cb (NMRemoteConnection *remote, GParamSpec *pspec, gpointer user_data) @@ -89,7 +256,10 @@ connection_init_result_cb (NMRemoteConnection *remote, NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data); NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); guint32 init_result = NM_REMOTE_CONNECTION_INIT_RESULT_UNKNOWN; + AddConnectionInfo *addinfo; const char *path; + GError *add_error = NULL; + gboolean remove_from_pending = TRUE; /* Disconnect from the init-result signal just to be safe */ g_signal_handlers_disconnect_matched (remote, @@ -106,6 +276,8 @@ connection_init_result_cb (NMRemoteConnection *remote, NM_REMOTE_CONNECTION_INIT_RESULT, &init_result, NULL); + addinfo = add_connection_info_find (self, remote); + switch (init_result) { case NM_REMOTE_CONNECTION_INIT_RESULT_SUCCESS: /* ref it when adding to ->connections, since removing it from ->pending @@ -113,36 +285,69 @@ connection_init_result_cb (NMRemoteConnection *remote, */ g_hash_table_insert (priv->connections, g_strdup (path), g_object_ref (remote)); + /* If there's a pending AddConnection request, complete that here before + * signaling new-connection. + */ + if (addinfo) + add_connection_info_complete (self, addinfo, NULL); + /* Finally, let users know of the new connection now that it has all * its settings and is valid. */ - g_signal_emit_by_name (self, "new-connection", remote); + g_signal_emit (self, signals[NEW_CONNECTION], 0, remote); break; + case NM_REMOTE_CONNECTION_INIT_RESULT_INVISIBLE: + remove_from_pending = FALSE; + /* fall through */ case NM_REMOTE_CONNECTION_INIT_RESULT_ERROR: + /* Complete pending AddConnection callbacks */ + if (addinfo) { + add_error = g_error_new_literal (NM_REMOTE_SETTINGS_ERROR, + NM_REMOTE_SETTINGS_ERROR_CONNECTION_UNAVAILABLE, + "Connection not visible or not available"); + add_connection_info_complete (self, addinfo, add_error); + g_error_free (add_error); + } + break; default: break; } - g_hash_table_remove (priv->pending, path); + if (remove_from_pending) + g_hash_table_remove (priv->pending, path); /* Let listeners know that all connections have been found */ - if (!g_hash_table_size (priv->pending)) - g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CONNECTIONS_READ); + priv->init_left--; + if (priv->init_left == 0) + g_signal_emit (self, signals[CONNECTIONS_READ], 0); } -static void +static NMRemoteConnection * new_connection_cb (DBusGProxy *proxy, const char *path, gpointer user_data) { NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data); NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); - NMRemoteConnection *connection; - - connection = nm_remote_connection_new (priv->bus, priv->scope, path); + NMRemoteConnection *connection = NULL; + + /* Make double-sure we don't already have it */ + connection = g_hash_table_lookup (priv->pending, path); + if (connection) + return connection; + connection = g_hash_table_lookup (priv->connections, path); + if (connection) + return connection; + + /* Create a new connection object for it */ + connection = nm_remote_connection_new (priv->bus, path); if (connection) { - g_signal_connect (connection, "removed", + g_signal_connect (connection, NM_REMOTE_CONNECTION_REMOVED, G_CALLBACK (connection_removed_cb), self); + g_signal_connect (connection, "visible", + G_CALLBACK (connection_visible_cb), + self); + g_signal_connect (connection, "notify::" NM_REMOTE_CONNECTION_INIT_RESULT, G_CALLBACK (connection_init_result_cb), self); @@ -153,6 +358,7 @@ new_connection_cb (DBusGProxy *proxy, const char *path, gpointer user_data) */ g_hash_table_insert (priv->pending, g_strdup (path), connection); } + return connection; } static void @@ -162,45 +368,38 @@ fetch_connections_done (DBusGProxy *proxy, gpointer user_data) { NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data); - NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); + NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); int i; if (error) { - gboolean is_spawn_error = FALSE; - - /* Don't warn if the user settings service wasn't running since that's - * just annoying when running headless. - */ - if ( g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN) - || g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NAME_HAS_NO_OWNER)) - is_spawn_error = TRUE; - - if (!is_spawn_error || priv->scope == NM_CONNECTION_SCOPE_SYSTEM) { - g_warning ("%s: error fetching %s connections: (%d) %s.", - __func__, - priv->scope == NM_CONNECTION_SCOPE_USER ? "user" : "system", + /* Ignore settings service spawn errors */ + if ( !g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN) + && !g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NAME_HAS_NO_OWNER)) { + g_warning ("%s: error fetching connections: (%d) %s.", + __func__, error->code, error->message ? error->message : "(unknown)"); } g_clear_error (&error); /* We tried to read connections and failed */ - g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CONNECTIONS_READ); + g_signal_emit (self, signals[CONNECTIONS_READ], 0); return; } /* Let listeners know we are done getting connections */ - if (connections->len == 0) { - g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CONNECTIONS_READ); - return; + if (connections->len == 0) + g_signal_emit (self, signals[CONNECTIONS_READ], 0); + else { + priv->init_left = connections->len; + for (i = 0; i < connections->len; i++) { + char *path = g_ptr_array_index (connections, i); + + new_connection_cb (proxy, path, user_data); + g_free (path); + } } - for (i = 0; connections && (i < connections->len); i++) { - char *path = g_ptr_array_index (connections, i); - - new_connection_cb (proxy, path, user_data); - g_free (path); - } g_ptr_array_free (connections, TRUE); } @@ -212,20 +411,36 @@ fetch_connections (gpointer user_data) priv->fetch_id = 0; - org_freedesktop_NetworkManagerSettings_list_connections_async (priv->proxy, - fetch_connections_done, - self); + org_freedesktop_NetworkManager_Settings_list_connections_async (priv->proxy, + fetch_connections_done, + self); return FALSE; } -static GSList * -list_connections (NMSettingsInterface *settings) +/** + * nm_remote_settings_list_connections: + * @settings: the %NMRemoteSettings + * + * Returns: (transfer container) (element-type NMClient.RemoteConnection): a + * list containing all connections provided by the remote settings service. + * Each element of the returned list is a %NMRemoteConnection instance, which is + * owned by the %NMRemoteSettings object and should not be freed by the caller. + * The returned list is, however, owned by the caller and should be freed + * using g_slist_free() when no longer required. + **/ +GSList * +nm_remote_settings_list_connections (NMRemoteSettings *settings) { - NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); + NMRemoteSettingsPrivate *priv; GSList *list = NULL; GHashTableIter iter; gpointer value; + g_return_val_if_fail (settings != NULL, NULL); + g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL); + + priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); + g_hash_table_iter_init (&iter, priv->connections); while (g_hash_table_iter_next (&iter, NULL, &value)) list = g_slist_prepend (list, NM_REMOTE_CONNECTION (value)); @@ -233,53 +448,77 @@ list_connections (NMSettingsInterface *settings) return list; } -typedef struct { - NMSettingsInterface *self; - NMSettingsAddConnectionFunc callback; - gpointer callback_data; -} AddConnectionInfo; - static void -add_connection_done (DBusGProxy *proxy, - GError *error, - gpointer user_data) +add_connection_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) { AddConnectionInfo *info = user_data; + GError *error = NULL; + char *path = NULL; - info->callback (info->self, error, info->callback_data); - g_free (info); + if (dbus_g_proxy_end_call (proxy, call, &error, DBUS_TYPE_G_OBJECT_PATH, &path, G_TYPE_INVALID)) { + info->connection = new_connection_cb (proxy, path, info->self); + g_assert (info->connection); + /* Wait until this connection is fully initialized before calling the callback */ + g_free (path); + } else + add_connection_info_complete (info->self, info, error); + + g_clear_error (&error); } -static gboolean -add_connection (NMSettingsInterface *settings, - NMConnection *connection, - NMSettingsAddConnectionFunc callback, - gpointer user_data) +/** + * nm_remote_settings_add_connection: + * @settings: the %NMRemoteSettings + * @connection: the connection to add. Note that this object's settings will be + * added, not the object itself + * @callback: (scope async): callback to be called when the add operation completes + * @user_data: caller-specific data passed to @callback + * + * Requests that the remote settings service add the given settings to a new + * connection. + * + * Returns: TRUE if the request was successful, FALSE if it failed + **/ +gboolean +nm_remote_settings_add_connection (NMRemoteSettings *settings, + NMConnection *connection, + NMRemoteSettingsAddConnectionFunc callback, + gpointer user_data) { - NMRemoteSettings *self = NM_REMOTE_SETTINGS (settings); - NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); + NMRemoteSettingsPrivate *priv; AddConnectionInfo *info; GHashTable *new_settings; + g_return_val_if_fail (settings != NULL, FALSE); + g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE); + g_return_val_if_fail (connection != NULL, FALSE); + g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); + g_return_val_if_fail (callback != NULL, FALSE); + + priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); + info = g_malloc0 (sizeof (AddConnectionInfo)); info->self = settings; info->callback = callback; info->callback_data = user_data; - new_settings = nm_connection_to_hash (connection); - org_freedesktop_NetworkManagerSettings_add_connection_async (priv->proxy, - new_settings, - add_connection_done, - info); + new_settings = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL); + dbus_g_proxy_begin_call (priv->proxy, "AddConnection", + add_connection_done, + info, + NULL, + DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, new_settings, + G_TYPE_INVALID); g_hash_table_destroy (new_settings); + + priv->add_list = g_slist_append (priv->add_list, info); + return TRUE; } -static gboolean -remove_connections (gpointer user_data) +static void +clear_one_hash (GHashTable *table) { - NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data); - NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); GHashTableIter iter; gpointer value; GSList *list = NULL, *list_iter; @@ -289,18 +528,90 @@ remove_connections (gpointer user_data) * that explicitly removes the the connection from the hash table somewhere * else. */ - g_hash_table_iter_init (&iter, priv->connections); + g_hash_table_iter_init (&iter, table); while (g_hash_table_iter_next (&iter, NULL, &value)) list = g_slist_prepend (list, NM_REMOTE_CONNECTION (value)); for (list_iter = list; list_iter; list_iter = g_slist_next (list_iter)) - g_signal_emit_by_name (NM_REMOTE_CONNECTION (list_iter->data), "removed"); + g_signal_emit_by_name (NM_REMOTE_CONNECTION (list_iter->data), NM_REMOTE_CONNECTION_REMOVED); g_slist_free (list); - g_hash_table_remove_all (priv->connections); + g_hash_table_remove_all (table); +} + +static gboolean +remove_connections (gpointer user_data) +{ + NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data); + NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); + + clear_one_hash (priv->pending); + clear_one_hash (priv->connections); return FALSE; } +typedef struct { + NMRemoteSettings *settings; + NMRemoteSettingsSaveHostnameFunc callback; + gpointer callback_data; +} SaveHostnameInfo; + +static void +save_hostname_cb (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer user_data) +{ + SaveHostnameInfo *info = user_data; + GError *error = NULL; + + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + info->callback (info->settings, error, info->callback_data); + g_clear_error (&error); +} + +/** + * nm_remote_settings_save_hostname: + * @settings: the %NMRemoteSettings + * @hostname: the new persistent hostname to set, or NULL to clear any existing + * persistent hostname + * @callback: (scope async): callback to be called when the hostname operation completes + * @user_data: caller-specific data passed to @callback + * + * Requests that the machine's persistent hostname be set to the specified value + * or cleared. + * + * Returns: TRUE if the request was successful, FALSE if it failed + **/ +gboolean +nm_remote_settings_save_hostname (NMRemoteSettings *settings, + const char *hostname, + NMRemoteSettingsSaveHostnameFunc callback, + gpointer user_data) +{ + NMRemoteSettingsPrivate *priv; + SaveHostnameInfo *info; + + g_return_val_if_fail (settings != NULL, FALSE); + g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE); + g_return_val_if_fail (hostname != NULL, FALSE); + g_return_val_if_fail (callback != NULL, FALSE); + + priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); + + info = g_malloc0 (sizeof (SaveHostnameInfo)); + info->settings = settings; + info->callback = callback; + info->callback_data = user_data; + + dbus_g_proxy_begin_call (priv->proxy, "SaveHostname", + save_hostname_cb, + info, + g_free, + G_TYPE_STRING, hostname ? hostname : "", + G_TYPE_INVALID); + return TRUE; +} + static void name_owner_changed (DBusGProxy *proxy, const char *name, @@ -310,10 +621,7 @@ name_owner_changed (DBusGProxy *proxy, { NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data); NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); - const char *sname = NM_DBUS_SERVICE_USER_SETTINGS; - - if (priv->scope == NM_CONNECTION_SCOPE_SYSTEM) - sname = NM_DBUS_SERVICE_SYSTEM_SETTINGS; + const char *sname = NM_DBUS_SERVICE; if (!strcmp (name, sname)) { if (priv->fetch_id) @@ -330,35 +638,80 @@ name_owner_changed (DBusGProxy *proxy, } } -/****************************************************************/ +static void +properties_changed_cb (DBusGProxy *proxy, + GHashTable *properties, + gpointer user_data) +{ + NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data); + NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); + GHashTableIter iter; + gpointer key, tmp; + + g_hash_table_iter_init (&iter, properties); + while (g_hash_table_iter_next (&iter, &key, &tmp)) { + GValue *value = tmp; + + if (!strcmp ((const char *) key, "Hostname")) { + g_free (priv->hostname); + priv->hostname = g_value_dup_string (value); + g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_HOSTNAME); + } + + if (!strcmp ((const char *) key, "CanModify")) { + priv->can_modify = g_value_get_boolean (value); + g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_CAN_MODIFY); + } + } +} static void -settings_interface_init (NMSettingsInterface *iface) +get_all_cb (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer user_data) { - /* interface implementation */ - iface->list_connections = list_connections; - iface->get_connection_by_path = get_connection_by_path; - iface->add_connection = add_connection; + NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data); + GHashTable *props = NULL; + GError *error = NULL; + + if (!dbus_g_proxy_end_call (proxy, call, &error, + DBUS_TYPE_G_MAP_OF_VARIANT, &props, + G_TYPE_INVALID)) { + /* Don't warn when the call times out because the settings service can't + * be activated or whatever. + */ + if (!(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_NO_REPLY)) { + g_warning ("%s: couldn't retrieve system settings properties: (%d) %s.", + __func__, + error ? error->code : -1, + (error && error->message) ? error->message : "(unknown)"); + } + g_clear_error (&error); + return; + } + + properties_changed_cb (NULL, props, self); + g_hash_table_destroy (props); } +/****************************************************************/ + /** * nm_remote_settings_new: - * @bus: a valid and connected D-Bus connection - * @scope: the settings service scope (either user or system) + * @bus: (allow-none): a valid and connected D-Bus connection * * Creates a new object representing the remote settings service. * * Returns: the new remote settings object on success, or %NULL on failure **/ NMRemoteSettings * -nm_remote_settings_new (DBusGConnection *bus, NMConnectionScope scope) +nm_remote_settings_new (DBusGConnection *bus) { - g_return_val_if_fail (bus != NULL, NULL); - g_return_val_if_fail (scope != NM_CONNECTION_SCOPE_UNKNOWN, NULL); + if (bus == NULL) + bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); return (NMRemoteSettings *) g_object_new (NM_TYPE_REMOTE_SETTINGS, NM_REMOTE_SETTINGS_BUS, bus, - NM_REMOTE_SETTINGS_SCOPE, scope, NULL); } @@ -378,7 +731,6 @@ constructor (GType type, { GObject *object; NMRemoteSettingsPrivate *priv; - const char *service = NM_DBUS_SERVICE_USER_SETTINGS; GError *error = NULL; object = G_OBJECT_CLASS (nm_remote_settings_parent_class)->constructor (type, n_construct_params, construct_params); @@ -406,12 +758,8 @@ constructor (GType type, G_CALLBACK (name_owner_changed), object, NULL); - /* Settings service proxy */ - if (priv->scope == NM_CONNECTION_SCOPE_SYSTEM) - service = NM_DBUS_SERVICE_SYSTEM_SETTINGS; - if (!dbus_g_proxy_call (priv->dbus_proxy, "NameHasOwner", &error, - G_TYPE_STRING, service, + G_TYPE_STRING, NM_DBUS_SERVICE, G_TYPE_INVALID, G_TYPE_BOOLEAN, &priv->service_running, G_TYPE_INVALID)) { @@ -424,7 +772,7 @@ constructor (GType type, } priv->proxy = dbus_g_proxy_new_for_name (priv->bus, - service, + NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_IFACE_SETTINGS); g_assert (priv->proxy); @@ -440,13 +788,43 @@ constructor (GType type, priv->fetch_id = g_idle_add (fetch_connections, object); + + /* D-Bus properties proxy */ + priv->props_proxy = dbus_g_proxy_new_for_name (priv->bus, + NM_DBUS_SERVICE, + NM_DBUS_PATH_SETTINGS, + "org.freedesktop.DBus.Properties"); + g_assert (priv->props_proxy); + + /* Monitor properties */ + dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, + DBUS_TYPE_G_MAP_OF_VARIANT, + G_TYPE_INVALID); + dbus_g_proxy_add_signal (priv->proxy, "PropertiesChanged", + DBUS_TYPE_G_MAP_OF_VARIANT, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged", + G_CALLBACK (properties_changed_cb), + object, + NULL); + + /* Get properties */ + dbus_g_proxy_begin_call (priv->props_proxy, "GetAll", + get_all_cb, + object, + NULL, + G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS, + G_TYPE_INVALID); + return object; } static void dispose (GObject *object) { - NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object); + NMRemoteSettings *self = NM_REMOTE_SETTINGS (object); + NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); if (priv->disposed) return; @@ -456,14 +834,20 @@ dispose (GObject *object) if (priv->fetch_id) g_source_remove (priv->fetch_id); + while (g_slist_length (priv->add_list)) + add_connection_info_dispose (self, (AddConnectionInfo *) priv->add_list->data); + if (priv->connections) g_hash_table_destroy (priv->connections); if (priv->pending) g_hash_table_destroy (priv->pending); + g_free (priv->hostname); + g_object_unref (priv->dbus_proxy); g_object_unref (priv->proxy); + g_object_unref (priv->props_proxy); dbus_g_connection_unref (priv->bus); G_OBJECT_CLASS (nm_remote_settings_parent_class)->dispose (object); @@ -480,9 +864,6 @@ set_property (GObject *object, guint prop_id, /* Construct only */ priv->bus = dbus_g_connection_ref ((DBusGConnection *) g_value_get_boxed (value)); break; - case PROP_SCOPE: - priv->scope = (NMConnectionScope) g_value_get_uint (value); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -499,12 +880,15 @@ get_property (GObject *object, guint prop_id, case PROP_BUS: g_value_set_boxed (value, priv->bus); break; - case PROP_SCOPE: - g_value_set_uint (value, priv->scope); - break; case PROP_SERVICE_RUNNING: g_value_set_boolean (value, priv->service_running); break; + case PROP_HOSTNAME: + g_value_set_string (value, priv->hostname); + break; + case PROP_CAN_MODIFY: + g_value_set_boolean (value, priv->can_modify); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -534,21 +918,46 @@ nm_remote_settings_class_init (NMRemoteSettingsClass *class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property - (object_class, PROP_SCOPE, - g_param_spec_uint (NM_REMOTE_SETTINGS_SCOPE, - "Scope", - "NMConnection scope", - NM_CONNECTION_SCOPE_UNKNOWN, - NM_CONNECTION_SCOPE_USER, - NM_CONNECTION_SCOPE_USER, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, PROP_SERVICE_RUNNING, g_param_spec_boolean (NM_REMOTE_SETTINGS_SERVICE_RUNNING, "Service running", "Is service running", FALSE, G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_HOSTNAME, + g_param_spec_string (NM_REMOTE_SETTINGS_HOSTNAME, + "Hostname", + "Persistent hostname", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_CAN_MODIFY, + g_param_spec_boolean (NM_REMOTE_SETTINGS_CAN_MODIFY, + "CanModify", + "Can modify anything (hostname, connections, etc)", + FALSE, + G_PARAM_READABLE)); + + /* Signals */ + signals[NEW_CONNECTION] = + g_signal_new (NM_REMOTE_SETTINGS_NEW_CONNECTION, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMRemoteSettingsClass, new_connection), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + + signals[CONNECTIONS_READ] = + g_signal_new (NM_REMOTE_SETTINGS_CONNECTIONS_READ, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMRemoteSettingsClass, connections_read), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } diff --git a/libnm-glib/nm-remote-settings.h b/libnm-glib/nm-remote-settings.h index d3085566e..f6ea5fbe7 100644 --- a/libnm-glib/nm-remote-settings.h +++ b/libnm-glib/nm-remote-settings.h @@ -38,17 +38,65 @@ G_BEGIN_DECLS #define NM_IS_REMOTE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_REMOTE_SETTINGS)) #define NM_REMOTE_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsClass)) -#define NM_REMOTE_SETTINGS_BUS "bus" -#define NM_REMOTE_SETTINGS_SCOPE "scope" +/** + * NMRemoteSettingsError: + * @NM_REMOTE_SETTINGS_ERROR_UNKNOWN: unknown or unclassified error + * @NM_REMOTE_SETTINGS_ERROR_CONNECTION_REMOVED: the #NMRemoteConnection object + * was removed before it was completely initialized + * @NM_REMOTE_SETTINGS_ERROR_CONNECTION_UNAVAILABLE: the #NMRemoteConnection object + * is not visible or otherwise unreadable + * + * Describes errors that may result from operations involving a #NMRemoteSettings. + * + **/ +typedef enum { + NM_REMOTE_SETTINGS_ERROR_UNKNOWN = 0, + NM_REMOTE_SETTINGS_ERROR_CONNECTION_REMOVED, + NM_REMOTE_SETTINGS_ERROR_CONNECTION_UNAVAILABLE, +} NMRemoteSettingsError; + +#define NM_TYPE_REMOTE_SETTINGS_ERROR (nm_remote_settings_error_get_type ()) +GType nm_remote_settings_error_get_type (void); + +#define NM_REMOTE_SETTINGS_ERROR nm_remote_settings_error_quark () +GQuark nm_remote_settings_error_quark (void); + + +#define NM_REMOTE_SETTINGS_BUS "bus" #define NM_REMOTE_SETTINGS_SERVICE_RUNNING "service-running" +#define NM_REMOTE_SETTINGS_HOSTNAME "hostname" +#define NM_REMOTE_SETTINGS_CAN_MODIFY "can-modify" + +#define NM_REMOTE_SETTINGS_NEW_CONNECTION "new-connection" +#define NM_REMOTE_SETTINGS_CONNECTIONS_READ "connections-read" + +typedef struct _NMRemoteSettings NMRemoteSettings; +typedef struct _NMRemoteSettingsClass NMRemoteSettingsClass; + -typedef struct { +typedef void (*NMRemoteSettingsAddConnectionFunc) (NMRemoteSettings *settings, + NMRemoteConnection *connection, + GError *error, + gpointer user_data); + +typedef void (*NMRemoteSettingsSaveHostnameFunc) (NMRemoteSettings *settings, + GError *error, + gpointer user_data); + + +struct _NMRemoteSettings { GObject parent; -} NMRemoteSettings; +}; -typedef struct { +struct _NMRemoteSettingsClass { GObjectClass parent; + /* Signals */ + void (*new_connection) (NMRemoteSettings *settings, + NMRemoteConnection *connection); + + void (*connections_read) (NMRemoteSettings *settings); + /* Padding for future expansion */ void (*_reserved1) (void); void (*_reserved2) (void); @@ -56,11 +104,26 @@ typedef struct { void (*_reserved4) (void); void (*_reserved5) (void); void (*_reserved6) (void); -} NMRemoteSettingsClass; +}; GType nm_remote_settings_get_type (void); -NMRemoteSettings *nm_remote_settings_new (DBusGConnection *bus, NMConnectionScope scope); +NMRemoteSettings *nm_remote_settings_new (DBusGConnection *bus); + +GSList *nm_remote_settings_list_connections (NMRemoteSettings *settings); + +NMRemoteConnection * nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings, + const char *path); + +gboolean nm_remote_settings_add_connection (NMRemoteSettings *settings, + NMConnection *connection, + NMRemoteSettingsAddConnectionFunc callback, + gpointer user_data); + +gboolean nm_remote_settings_save_hostname (NMRemoteSettings *settings, + const char *hostname, + NMRemoteSettingsSaveHostnameFunc callback, + gpointer user_data); G_END_DECLS diff --git a/libnm-glib/nm-secret-agent.c b/libnm-glib/nm-secret-agent.c new file mode 100644 index 000000000..90bdfbe76 --- /dev/null +++ b/libnm-glib/nm-secret-agent.c @@ -0,0 +1,988 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2010 - 2011 Red Hat, Inc. + */ + +#include <config.h> +#include <ctype.h> +#include <string.h> +#include <NetworkManager.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include "nm-secret-agent.h" +#include "nm-marshal.h" +#include "NetworkManager.h" + +static void impl_secret_agent_get_secrets (NMSecretAgent *self, + GHashTable *connection_hash, + const char *connection_path, + const char *setting_name, + const char **hints, + guint32 flags, + DBusGMethodInvocation *context); + +static void impl_secret_agent_cancel_get_secrets (NMSecretAgent *self, + const char *connection_path, + const char *setting_name, + DBusGMethodInvocation *context); + +static void impl_secret_agent_save_secrets (NMSecretAgent *self, + GHashTable *connection_hash, + const char *connection_path, + DBusGMethodInvocation *context); + +static void impl_secret_agent_delete_secrets (NMSecretAgent *self, + GHashTable *connection_hash, + const char *connection_path, + DBusGMethodInvocation *context); + +#include "nm-secret-agent-glue.h" + +G_DEFINE_ABSTRACT_TYPE (NMSecretAgent, nm_secret_agent, G_TYPE_OBJECT) + +#define NM_SECRET_AGENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ + NM_TYPE_SECRET_AGENT, \ + NMSecretAgentPrivate)) + +static gboolean auto_register_cb (gpointer user_data); + +typedef struct { + gboolean registered; + + DBusGConnection *bus; + DBusGProxy *dbus_proxy; + DBusGProxy *manager_proxy; + DBusGProxyCall *reg_call; + + /* GetSecretsInfo structs of in-flight GetSecrets requests */ + GSList *pending_gets; + + char *nm_owner; + + char *identifier; + gboolean auto_register; + gboolean suppress_auto; + gboolean auto_register_id; + + gboolean disposed; +} NMSecretAgentPrivate; + +enum { + PROP_0, + PROP_IDENTIFIER, + PROP_AUTO_REGISTER, + + LAST_PROP +}; + +enum { + REGISTRATION_RESULT, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + + +/********************************************************************/ + +GQuark +nm_secret_agent_error_quark (void) +{ + static GQuark ret = 0; + + if (G_UNLIKELY (ret == 0)) + ret = g_quark_from_static_string ("nm-secret-agent-error"); + return ret; +} + +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } + +GType +nm_secret_agent_error_get_type (void) +{ + static GType etype = 0; + + if (etype == 0) { + static const GEnumValue values[] = { + /* Sender is not authorized to make this request */ + ENUM_ENTRY (NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, "NotAuthorized"), + /* Given connection details do not make a valid connection */ + ENUM_ENTRY (NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, "InvalidConnection"), + /* The request was canceled explicitly by the user */ + ENUM_ENTRY (NM_SECRET_AGENT_ERROR_USER_CANCELED, "UserCanceled"), + /* The request was canceled, but not by the user */ + ENUM_ENTRY (NM_SECRET_AGENT_ERROR_AGENT_CANCELED, "AgentCanceled"), + /* Some internal error prevented returning secrets */ + ENUM_ENTRY (NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, "InternalError"), + /* No secrets could be found to fulfill the request */ + ENUM_ENTRY (NM_SECRET_AGENT_ERROR_NO_SECRETS, "NoSecrets"), + { 0, 0, 0 } + }; + etype = g_enum_register_static ("NMSecretAgentError", values); + } + return etype; +} + +/*************************************************************/ + +static const char * +get_nm_owner (NMSecretAgent *self) +{ + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + GError *error = NULL; + char *owner; + + if (!priv->nm_owner) { + if (!dbus_g_proxy_call_with_timeout (priv->dbus_proxy, + "GetNameOwner", 2000, &error, + G_TYPE_STRING, NM_DBUS_SERVICE, + G_TYPE_INVALID, + G_TYPE_STRING, &owner, + G_TYPE_INVALID)) + return NULL; + + priv->nm_owner = g_strdup (owner); + g_free (owner); + } + + return priv->nm_owner; +} + +static void +_internal_unregister (NMSecretAgent *self) +{ + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + + if (priv->registered) { + dbus_g_connection_unregister_g_object (priv->bus, G_OBJECT (self)); + priv->registered = FALSE; + } +} + +typedef struct { + char *path; + char *setting_name; + DBusGMethodInvocation *context; +} GetSecretsInfo; + +static void +get_secrets_info_finalize (NMSecretAgent *self, GetSecretsInfo *info) +{ + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + + g_return_if_fail (info != NULL); + + priv->pending_gets = g_slist_remove (priv->pending_gets, info); + + g_free (info->path); + g_free (info->setting_name); + memset (info, 0, sizeof (*info)); + g_free (info); +} + +static void +name_owner_changed (DBusGProxy *proxy, + const char *name, + const char *old_owner, + const char *new_owner, + gpointer user_data) +{ + NMSecretAgent *self = NM_SECRET_AGENT (user_data); + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + gboolean old_owner_good = (old_owner && strlen (old_owner)); + gboolean new_owner_good = (new_owner && strlen (new_owner)); + GSList *iter; + + if (strcmp (name, NM_DBUS_SERVICE) == 0) { + g_free (priv->nm_owner); + priv->nm_owner = g_strdup (new_owner); + + if (!old_owner_good && new_owner_good) { + /* NM appeared */ + auto_register_cb (self); + } else if (old_owner_good && !new_owner_good) { + /* Cancel any pending secrets requests */ + for (iter = priv->pending_gets; iter; iter = g_slist_next (iter)) { + GetSecretsInfo *info = iter->data; + + NM_SECRET_AGENT_GET_CLASS (self)->cancel_get_secrets (self, + info->path, + info->setting_name); + } + g_slist_free (priv->pending_gets); + priv->pending_gets = NULL; + + /* NM disappeared */ + _internal_unregister (self); + } else if (old_owner_good && new_owner_good && strcmp (old_owner, new_owner)) { + /* Hmm, NM magically restarted */ + _internal_unregister (self); + auto_register_cb (self); + } + } +} + +static gboolean +verify_request (NMSecretAgent *self, + DBusGMethodInvocation *context, + GHashTable *connection_hash, + const char *connection_path, + NMConnection **out_connection, + GError **error) +{ + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + NMConnection *connection = NULL; + DBusConnection *bus; + char *sender; + const char *nm_owner; + DBusError dbus_error; + uid_t sender_uid = G_MAXUINT; + GError *local = NULL; + + g_return_val_if_fail (context != NULL, FALSE); + + /* Verify the sender's UID is 0, and that the sender is the same as + * NetworkManager's bus name owner. + */ + + nm_owner = get_nm_owner (self); + if (!nm_owner) { + g_set_error_literal (error, + NM_SECRET_AGENT_ERROR, + NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, + "NetworkManager bus name owner unknown."); + return FALSE; + } + + bus = dbus_g_connection_get_connection (priv->bus); + if (!bus) { + g_set_error_literal (error, + NM_SECRET_AGENT_ERROR, + NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, + "Failed to get DBus connection."); + return FALSE; + } + + sender = dbus_g_method_get_sender (context); + if (!sender) { + g_set_error_literal (error, + NM_SECRET_AGENT_ERROR, + NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, + "Failed to get request sender."); + return FALSE; + } + + /* Check that the sender matches the current NM bus name owner */ + if (strcmp (sender, nm_owner) != 0) { + g_set_error_literal (error, + NM_SECRET_AGENT_ERROR, + NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, + "Request sender does not match NetworkManager bus name owner."); + goto out; + } + + dbus_error_init (&dbus_error); + sender_uid = dbus_bus_get_unix_user (bus, sender, &dbus_error); + if (dbus_error_is_set (&dbus_error)) { + g_set_error (error, + NM_SECRET_AGENT_ERROR, + NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, + "Failed to get request unix user: (%s) %s.", + dbus_error.name, dbus_error.message); + dbus_error_free (&dbus_error); + goto out; + } + + if (0 != sender_uid) { + g_set_error_literal (error, + NM_SECRET_AGENT_ERROR, + NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, + "Request sender is not root."); + goto out; + } + + /* And make sure the connection is actually valid */ + if (connection_hash) { + connection = nm_connection_new_from_hash (connection_hash, &local); + if (connection && connection_path) { + nm_connection_set_path (connection, connection_path); + } else { + g_set_error (error, + NM_SECRET_AGENT_ERROR, + NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, + "Invalid connection: (%d) %s", + local ? local->code : -1, + (local && local->message) ? local->message : "(unknown)"); + g_clear_error (&local); + } + } + +out: + if (out_connection) + *out_connection = connection; + g_free (sender); + + return !!connection; +} + +static void +get_secrets_cb (NMSecretAgent *self, + NMConnection *connection, + GHashTable *secrets, + GError *error, + gpointer user_data) +{ + GetSecretsInfo *info = user_data; + + if (error) + dbus_g_method_return_error (info->context, error); + else + dbus_g_method_return (info->context, secrets); + + /* Remove the request from internal tracking */ + get_secrets_info_finalize (self, info); +} + +static void +impl_secret_agent_get_secrets (NMSecretAgent *self, + GHashTable *connection_hash, + const char *connection_path, + const char *setting_name, + const char **hints, + guint32 flags, + DBusGMethodInvocation *context) +{ + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + GError *error = NULL; + NMConnection *connection = NULL; + GetSecretsInfo *info; + + /* Make sure the request comes from NetworkManager and is valid */ + if (!verify_request (self, context, connection_hash, connection_path, &connection, &error)) { + dbus_g_method_return_error (context, error); + g_clear_error (&error); + return; + } + + info = g_malloc0 (sizeof (GetSecretsInfo)); + info->path = g_strdup (connection_path); + info->setting_name = g_strdup (setting_name); + info->context = context; + priv->pending_gets = g_slist_append (priv->pending_gets, info); + + NM_SECRET_AGENT_GET_CLASS (self)->get_secrets (self, + connection, + connection_path, + setting_name, + hints, + flags, + get_secrets_cb, + info); + g_object_unref (connection); +} + +static GetSecretsInfo * +find_get_secrets_info (GSList *list, const char *path, const char *setting_name) +{ + GSList *iter; + + for (iter = list; iter; iter = g_slist_next (iter)) { + GetSecretsInfo *candidate = iter->data; + + if ( g_strcmp0 (path, candidate->path) == 0 + && g_strcmp0 (setting_name, candidate->setting_name) == 0) + return candidate; + } + return NULL; +} + +static void +impl_secret_agent_cancel_get_secrets (NMSecretAgent *self, + const char *connection_path, + const char *setting_name, + DBusGMethodInvocation *context) +{ + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + GError *error = NULL; + GetSecretsInfo *info; + + /* Make sure the request comes from NetworkManager and is valid */ + if (!verify_request (self, context, NULL, NULL, NULL, &error)) { + dbus_g_method_return_error (context, error); + g_clear_error (&error); + return; + } + + info = find_get_secrets_info (priv->pending_gets, connection_path, setting_name); + if (!info) { + g_set_error_literal (&error, + NM_SECRET_AGENT_ERROR, + NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, + "No secrets request in progress for this connection."); + dbus_g_method_return_error (context, error); + g_clear_error (&error); + return; + } + + /* Send the cancel request up to the subclass and finalize it */ + NM_SECRET_AGENT_GET_CLASS (self)->cancel_get_secrets (self, + info->path, + info->setting_name); + dbus_g_method_return (context); +} + +static void +save_secrets_cb (NMSecretAgent *self, + NMConnection *connection, + GError *error, + gpointer user_data) +{ + DBusGMethodInvocation *context = user_data; + + if (error) + dbus_g_method_return_error (context, error); + else + dbus_g_method_return (context); +} + +static void +impl_secret_agent_save_secrets (NMSecretAgent *self, + GHashTable *connection_hash, + const char *connection_path, + DBusGMethodInvocation *context) +{ + GError *error = NULL; + NMConnection *connection = NULL; + + /* Make sure the request comes from NetworkManager and is valid */ + if (!verify_request (self, context, connection_hash, connection_path, &connection, &error)) { + dbus_g_method_return_error (context, error); + g_clear_error (&error); + return; + } + + NM_SECRET_AGENT_GET_CLASS (self)->save_secrets (self, + connection, + connection_path, + save_secrets_cb, + context); + g_object_unref (connection); +} + +static void +delete_secrets_cb (NMSecretAgent *self, + NMConnection *connection, + GError *error, + gpointer user_data) +{ + DBusGMethodInvocation *context = user_data; + + if (error) + dbus_g_method_return_error (context, error); + else + dbus_g_method_return (context); +} + +static void +impl_secret_agent_delete_secrets (NMSecretAgent *self, + GHashTable *connection_hash, + const char *connection_path, + DBusGMethodInvocation *context) +{ + GError *error = NULL; + NMConnection *connection = NULL; + + /* Make sure the request comes from NetworkManager and is valid */ + if (!verify_request (self, context, connection_hash, connection_path, &connection, &error)) { + dbus_g_method_return_error (context, error); + g_clear_error (&error); + return; + } + + NM_SECRET_AGENT_GET_CLASS (self)->delete_secrets (self, + connection, + connection_path, + delete_secrets_cb, + context); + g_object_unref (connection); +} + +/**************************************************************/ + +static void +reg_request_cb (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer user_data) +{ + NMSecretAgent *self = NM_SECRET_AGENT (user_data); + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + GError *error = NULL; + + priv->reg_call = NULL; + + if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID)) + priv->registered = TRUE; + else { + /* If registration failed we shouldn't expose ourselves on the bus */ + _internal_unregister (self); + } + + g_signal_emit (self, signals[REGISTRATION_RESULT], 0, error); + g_clear_error (&error); +} + +/** + * nm_secret_agent_register: + * @self: a #NMSecretAgent + * + * Registers the #NMSecretAgent with the NetworkManager secret manager, + * indicating to NetworkManager that the agent is able to provide and save + * secrets for connections on behalf of its user. Registration is an + * asynchronous operation and its success or failure is indicated via the + * 'registration-result' signal. + * + * Returns: a new %TRUE if registration was successfully requested (this does + * not mean registration itself was successful), %FALSE if registration was not + * successfully requested. + **/ +gboolean +nm_secret_agent_register (NMSecretAgent *self) +{ + NMSecretAgentPrivate *priv; + NMSecretAgentClass *class; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (NM_IS_SECRET_AGENT (self), FALSE); + + priv = NM_SECRET_AGENT_GET_PRIVATE (self); + + g_return_val_if_fail (priv->registered == FALSE, FALSE); + g_return_val_if_fail (priv->reg_call == NULL, FALSE); + g_return_val_if_fail (priv->bus != NULL, FALSE); + g_return_val_if_fail (priv->manager_proxy != NULL, FALSE); + + /* Also make sure the subclass can actually respond to secrets requests */ + class = NM_SECRET_AGENT_GET_CLASS (self); + g_return_val_if_fail (class->get_secrets != NULL, FALSE); + g_return_val_if_fail (class->save_secrets != NULL, FALSE); + g_return_val_if_fail (class->delete_secrets != NULL, FALSE); + + priv->suppress_auto = FALSE; + + /* Export our secret agent interface before registering with the manager */ + dbus_g_connection_register_g_object (priv->bus, + NM_DBUS_PATH_SECRET_AGENT, + G_OBJECT (self)); + + priv->reg_call = dbus_g_proxy_begin_call_with_timeout (priv->manager_proxy, + "Register", + reg_request_cb, + self, + NULL, + 5000, + G_TYPE_STRING, priv->identifier, + G_TYPE_INVALID); + + return TRUE; +} + +/** + * nm_secret_agent_unregister: + * @self: a #NMSecretAgent + * + * Unregisters the #NMSecretAgent with the NetworkManager secret manager, + * indicating to NetworkManager that the agent is will no longer provide or + * store secrets on behalf of this user. + * + * Returns: a new %TRUE if unregistration was successful, %FALSE if it was not. + **/ +gboolean +nm_secret_agent_unregister (NMSecretAgent *self) +{ + NMSecretAgentPrivate *priv; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (NM_IS_SECRET_AGENT (self), FALSE); + + priv = NM_SECRET_AGENT_GET_PRIVATE (self); + + g_return_val_if_fail (priv->registered == TRUE, FALSE); + g_return_val_if_fail (priv->bus != NULL, FALSE); + g_return_val_if_fail (priv->manager_proxy != NULL, FALSE); + + dbus_g_proxy_call_no_reply (priv->manager_proxy, "Unregister", G_TYPE_INVALID); + + _internal_unregister (self); + priv->suppress_auto = TRUE; + + return TRUE; +} + +static gboolean +auto_register_cb (gpointer user_data) +{ + NMSecretAgent *self = NM_SECRET_AGENT (user_data); + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + + priv->auto_register_id = 0; + if (priv->auto_register && !priv->suppress_auto && (priv->reg_call == NULL)) + nm_secret_agent_register (self); + return FALSE; +} + +/**************************************************************/ + +/** + * nm_secret_agent_get_secrets: + * @self: a #NMSecretAgent + * @connection: the #NMConnection for which we're asked secrets + * @setting_name: the name of the secret setting + * @hints: (array zero-terminated=1): hints to the agent + * @flags: flags that modify the behavior of the request + * @callback: (scope async): a callback, invoked when the operation is done + * @callback_data: (closure): + * + * Asyncronously retrieve secrets belonging to @connection for the + * setting @setting_name. @flags indicate specific behavior that the secret + * agent should use when performing the request, for example returning only + * existing secrets without user interaction, or requesting entirely new + * secrets from the user. + * + * VFunc: get_secrets + */ +void +nm_secret_agent_get_secrets (NMSecretAgent *self, + NMConnection *connection, + const char *setting_name, + const char **hints, + NMSecretAgentGetSecretsFlags flags, + NMSecretAgentGetSecretsFunc callback, + gpointer callback_data) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (NM_IS_SECRET_AGENT (self)); + g_return_if_fail (connection != NULL); + g_return_if_fail (NM_IS_CONNECTION (connection)); + g_return_if_fail (nm_connection_get_path (connection)); + g_return_if_fail (setting_name != NULL); + g_return_if_fail (strlen (setting_name) > 0); + g_return_if_fail (callback != NULL); + + NM_SECRET_AGENT_GET_CLASS (self)->get_secrets (self, + connection, + nm_connection_get_path (connection), + setting_name, + hints, + flags, + callback, + callback_data); +} + +/** + * nm_secret_agent_save_secrets: + * @self: a #NMSecretAgent + * @connection: a #NMConnection + * @callback: (scope async): a callback, invoked when the operation is done + * @callback_data: (closure): + * + * Asyncronously ensure that all secrets inside @connection + * are stored to disk. + * + * VFunc: save_secrets + */ +void +nm_secret_agent_save_secrets (NMSecretAgent *self, + NMConnection *connection, + NMSecretAgentSaveSecretsFunc callback, + gpointer callback_data) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (NM_IS_SECRET_AGENT (self)); + g_return_if_fail (connection != NULL); + g_return_if_fail (NM_IS_CONNECTION (connection)); + g_return_if_fail (nm_connection_get_path (connection)); + + NM_SECRET_AGENT_GET_CLASS (self)->save_secrets (self, + connection, + nm_connection_get_path (connection), + callback, + callback_data); +} + +/** + * nm_secret_agent_delete_secrets: + * @self: a #NMSecretAgent + * @connection: a #NMConnection + * @callback: (scope async): a callback, invoked when the operation is done + * @callback_data: (closure): + * + * Asynchronously ask the agent to delete all saved secrets belonging to + * @connection. + * + * VFunc: delete_secrets + */ +void +nm_secret_agent_delete_secrets (NMSecretAgent *self, + NMConnection *connection, + NMSecretAgentDeleteSecretsFunc callback, + gpointer callback_data) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (NM_IS_SECRET_AGENT (self)); + g_return_if_fail (connection != NULL); + g_return_if_fail (NM_IS_CONNECTION (connection)); + g_return_if_fail (nm_connection_get_path (connection)); + + NM_SECRET_AGENT_GET_CLASS (self)->delete_secrets (self, + connection, + nm_connection_get_path (connection), + callback, + callback_data); +} + +/**************************************************************/ + +static gboolean +validate_identifier (const char *identifier) +{ + const char *p = identifier; + size_t id_len; + + /* Length between 3 and 255 characters inclusive */ + id_len = strlen (identifier); + if (id_len < 3 || id_len > 255) + return FALSE; + + if ((identifier[0] == '.') || (identifier[id_len - 1] == '.')) + return FALSE; + + /* FIXME: do complete validation here */ + while (p && *p) { + if (!isalnum (*p) && (*p != '_') && (*p != '-') && (*p != '.')) + return FALSE; + if ((*p == '.') && (*(p + 1) == '.')) + return FALSE; + p++; + } + + return TRUE; +} + +static void +nm_secret_agent_init (NMSecretAgent *self) +{ + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + GError *error = NULL; + + priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); + if (!priv->bus) { + g_warning ("Couldn't connect to system bus: %s", error->message); + g_error_free (error); + return; + } + + priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->bus, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + if (!priv->dbus_proxy) { + g_warning ("Couldn't create messagebus proxy."); + return; + } + + dbus_g_object_register_marshaller (_nm_marshal_VOID__STRING_STRING_STRING, + G_TYPE_NONE, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_add_signal (priv->dbus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->dbus_proxy, + "NameOwnerChanged", + G_CALLBACK (name_owner_changed), + self, NULL); + + priv->manager_proxy = dbus_g_proxy_new_for_name (priv->bus, + NM_DBUS_SERVICE, + NM_DBUS_PATH_AGENT_MANAGER, + NM_DBUS_INTERFACE_AGENT_MANAGER); + if (!priv->manager_proxy) { + g_warning ("Couldn't create NM agent manager proxy."); + return; + } + + priv->auto_register_id = g_idle_add (auto_register_cb, self); +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_IDENTIFIER: + g_value_set_string (value, priv->identifier); + break; + case PROP_AUTO_REGISTER: + g_value_set_boolean (value, priv->auto_register); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (object); + const char *identifier; + + switch (prop_id) { + case PROP_IDENTIFIER: + identifier = g_value_get_string (value); + + g_return_if_fail (validate_identifier (identifier)); + + g_free (priv->identifier); + priv->identifier = g_strdup (identifier); + break; + case PROP_AUTO_REGISTER: + priv->auto_register = g_value_get_boolean (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +dispose (GObject *object) +{ + NMSecretAgent *self = NM_SECRET_AGENT (object); + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + + if (!priv->disposed) { + priv->disposed = TRUE; + + if (priv->registered) + nm_secret_agent_unregister (self); + + if (priv->auto_register_id) + g_source_remove (priv->auto_register_id); + + g_free (priv->identifier); + g_free (priv->nm_owner); + + while (priv->pending_gets) + get_secrets_info_finalize (self, priv->pending_gets->data); + + if (priv->dbus_proxy) + g_object_unref (priv->dbus_proxy); + + if (priv->manager_proxy) + g_object_unref (priv->manager_proxy); + + if (priv->bus) + dbus_g_connection_unref (priv->bus); + } + + G_OBJECT_CLASS (nm_secret_agent_parent_class)->dispose (object); +} + +static void +nm_secret_agent_class_init (NMSecretAgentClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + g_type_class_add_private (class, sizeof (NMSecretAgentPrivate)); + + /* Virtual methods */ + object_class->dispose = dispose; + object_class->get_property = get_property; + object_class->set_property = set_property; + + /** + * NMSecretAgent:identifier: + * + * Identifies this agent; only one agent in each user session may use the + * same identifier. Identifier formatting follows the same rules as + * D-Bus bus names with the exception that the ':' character is not + * allowed. The valid set of characters is "[A-Z][a-z][0-9]_-." and the + * identifier is limited in length to 255 characters with a minimum + * of 3 characters. An example valid identifier is 'org.gnome.nm-applet' + * (without quotes). + **/ + g_object_class_install_property + (object_class, PROP_IDENTIFIER, + g_param_spec_string (NM_SECRET_AGENT_IDENTIFIER, + "Identifier", + "Identifier", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + /** + * NMSecretAgent:auto-register: + * + * If TRUE, the agent will attempt to automatically register itself after + * it is created (via an idle handler) and to re-register itself if + * NetworkManager restarts. If FALSE, the agent does not automatically + * register with NetworkManager, and nm_secret_agent_register() must be + * called. If 'auto-register' is TRUE, calling nm_secret_agent_unregister() + * will suppress auto-registration until nm_secret_agent_register() is + * called, which re-enables auto-registration. + **/ + g_object_class_install_property + (object_class, PROP_AUTO_REGISTER, + g_param_spec_boolean (NM_SECRET_AGENT_AUTO_REGISTER, + "Auto Register", + "Auto Register", + TRUE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + /** + * NMSecretAgent::registration-result: + * @agent: the agent that received the signal + * @error: the error, if any, that occured while registering + * + * Indicates the result of a registration request; if @error is NULL the + * request was successful. + **/ + signals[REGISTRATION_RESULT] = + g_signal_new (NM_SECRET_AGENT_REGISTRATION_RESULT, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (class), + &dbus_glib_nm_secret_agent_object_info); + + dbus_g_error_domain_register (NM_SECRET_AGENT_ERROR, + NM_DBUS_INTERFACE_SECRET_AGENT, + NM_TYPE_SECRET_AGENT_ERROR); +} + diff --git a/libnm-glib/nm-secret-agent.h b/libnm-glib/nm-secret-agent.h new file mode 100644 index 000000000..6b209c440 --- /dev/null +++ b/libnm-glib/nm-secret-agent.h @@ -0,0 +1,189 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2010 - 2011 Red Hat, Inc. + */ + +#ifndef NM_SECRET_AGENT_H +#define NM_SECRET_AGENT_H + +#include <nm-connection.h> + +G_BEGIN_DECLS + +#define NM_SECRET_AGENT_ERROR (nm_secret_agent_error_quark ()) +#define NM_TYPE_SECRET_AGENT_ERROR (nm_secret_agent_error_get_type ()) + +GQuark nm_secret_agent_error_quark (void); +GType nm_secret_agent_error_get_type (void); + +typedef enum { + NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED = 0, + NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, + NM_SECRET_AGENT_ERROR_USER_CANCELED, + NM_SECRET_AGENT_ERROR_AGENT_CANCELED, + NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, + NM_SECRET_AGENT_ERROR_NO_SECRETS, +} NMSecretAgentError; + +/** + * NMSecretAgentGetSecretsFlags: + * @NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE: no special behavior; by default no + * user interaction is allowed and requests for secrets are fulfilled from + * persistent storage, or if no secrets are available an error is returned. + * @NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION: allows the request to + * interact with the user, possibly prompting via UI for secrets if any are + * required, or if none are found in persistent storage. + * @NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW: explicitly prompt for new + * secrets from the user. This flag signals that NetworkManager thinks any + * existing secrets are invalid or wrong. This flag implies that interaction + * is allowed. + * + * #NMSecretAgentGetSecretsFlags values modify the behavior of a GetSecrets request. + */ +typedef enum { + NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0, + NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1, + NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW = 0x2 +} NMSecretAgentGetSecretsFlags; + +#define NM_TYPE_SECRET_AGENT (nm_secret_agent_get_type ()) +#define NM_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgent)) +#define NM_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SECRET_AGENT, NMSecretAgentClass)) +#define NM_IS_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SECRET_AGENT)) +#define NM_IS_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SECRET_AGENT)) +#define NM_SECRET_AGENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgentClass)) + +#define NM_SECRET_AGENT_IDENTIFIER "identifier" +#define NM_SECRET_AGENT_AUTO_REGISTER "auto-register" + +#define NM_SECRET_AGENT_REGISTRATION_RESULT "registration-result" + +typedef struct { + GObject parent; +} NMSecretAgent; + +typedef void (*NMSecretAgentGetSecretsFunc) (NMSecretAgent *agent, + NMConnection *connection, + GHashTable *secrets, + GError *error, + gpointer user_data); + +typedef void (*NMSecretAgentSaveSecretsFunc) (NMSecretAgent *agent, + NMConnection *connection, + GError *error, + gpointer user_data); + +typedef void (*NMSecretAgentDeleteSecretsFunc) (NMSecretAgent *agent, + NMConnection *connection, + GError *error, + gpointer user_data); + +typedef struct { + GObjectClass parent; + + /* Virtual methods for subclasses */ + + /* Called when the subclass should retrieve and return secrets. Subclass + * must copy or reference any arguments it may require after returning from + * this method, as the arguments will freed (except for 'agent', 'callback', + * and 'callback_data' of course). If the request is canceled, the callback + * should still be called, but with the NM_SECRET_AGENT_ERROR_AGENT_CANCELED + * error. + */ + void (*get_secrets) (NMSecretAgent *agent, + NMConnection *connection, + const char *connection_path, + const char *setting_name, + const char **hints, + NMSecretAgentGetSecretsFlags flags, + NMSecretAgentGetSecretsFunc callback, + gpointer callback_data); + + /* Called when the subclass should cancel an outstanding request to + * get secrets for a given connection. Canceling the request MUST + * call the callback that was passed along with the initial get_secrets + * call, sending the NM_SECRET_AGENT_ERROR/NM_SECRET_AGENT_ERROR_AGENT_CANCELED + * error to that callback. + */ + void (*cancel_get_secrets) (NMSecretAgent *agent, + const char *connection_path, + const char *setting_name); + + /* Called when the subclass should save the secrets contained in the + * connection to backing storage. Subclass must copy or reference any + * arguments it may require after returning from this method, as the + * arguments will freed (except for 'agent', 'callback', and 'callback_data' + * of course). + */ + void (*save_secrets) (NMSecretAgent *agent, + NMConnection *connection, + const char *connection_path, + NMSecretAgentSaveSecretsFunc callback, + gpointer callback_data); + + /* Called when the subclass should delete the secrets contained in the + * connection from backing storage. Subclass must copy or reference any + * arguments it may require after returning from this method, as the + * arguments will freed (except for 'agent', 'callback', and 'callback_data' + * of course). + */ + void (*delete_secrets) (NMSecretAgent *agent, + NMConnection *connection, + const char *connection_path, + NMSecretAgentDeleteSecretsFunc callback, + gpointer callback_data); + + /* Signals */ + void (*registration_result) (NMSecretAgent *agent, GError *error); + + /* Padding for future expansion */ + void (*_reserved1) (void); + void (*_reserved2) (void); + void (*_reserved3) (void); + void (*_reserved4) (void); + void (*_reserved5) (void); + void (*_reserved6) (void); +} NMSecretAgentClass; + +GType nm_secret_agent_get_type (void); + +gboolean nm_secret_agent_register (NMSecretAgent *self); + +gboolean nm_secret_agent_unregister (NMSecretAgent *self); + +void nm_secret_agent_get_secrets (NMSecretAgent *self, + NMConnection *connection, + const char *setting_name, + const char **hints, + NMSecretAgentGetSecretsFlags flags, + NMSecretAgentGetSecretsFunc callback, + gpointer callback_data); + +void nm_secret_agent_save_secrets (NMSecretAgent *self, + NMConnection *connection, + NMSecretAgentSaveSecretsFunc callback, + gpointer callback_data); + +void nm_secret_agent_delete_secrets (NMSecretAgent *self, + NMConnection *connection, + NMSecretAgentDeleteSecretsFunc callback, + gpointer callback_data); + +G_END_DECLS + +#endif /* NM_SECRET_AGENT_H */ diff --git a/libnm-glib/nm-serial-device.c b/libnm-glib/nm-serial-device.c deleted file mode 100644 index bb45d7c43..000000000 --- a/libnm-glib/nm-serial-device.c +++ /dev/null @@ -1,207 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - */ - -#include "nm-serial-device.h" -#include "nm-device-private.h" -#include "nm-object-private.h" -#include "nm-marshal.h" - -G_DEFINE_ABSTRACT_TYPE (NMSerialDevice, nm_serial_device, NM_TYPE_DEVICE) - -#define NM_SERIAL_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SERIAL_DEVICE, NMSerialDevicePrivate)) - -typedef struct { - DBusGProxy *proxy; - - guint32 in_bytes; - guint32 out_bytes; - - gboolean disposed; -} NMSerialDevicePrivate; - -enum { - PPP_STATS, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -/** - * nm_serial_device_get_bytes_received: - * @self: a #NMSerialDevice - * - * Gets the amount of bytes received by the serial device. - * This counter is reset when the device is activated. - * - * Returns: bytes received - **/ -guint32 -nm_serial_device_get_bytes_received (NMSerialDevice *self) -{ - g_return_val_if_fail (NM_IS_SERIAL_DEVICE (self), 0); - - return NM_SERIAL_DEVICE_GET_PRIVATE (self)->in_bytes; -} - -/** - * nm_serial_device_get_bytes_sent: - * @self: a #NMSerialDevice - * - * Gets the amount of bytes sent by the serial device. - * This counter is reset when the device is activated. - * - * Returns: bytes sent - **/ -guint32 -nm_serial_device_get_bytes_sent (NMSerialDevice *self) -{ - g_return_val_if_fail (NM_IS_SERIAL_DEVICE (self), 0); - - return NM_SERIAL_DEVICE_GET_PRIVATE (self)->out_bytes; -} - -static void -ppp_stats (DBusGProxy *proxy, - guint32 in_bytes, - guint32 out_bytes, - gpointer user_data) -{ - NMSerialDevice *self = NM_SERIAL_DEVICE (user_data); - NMSerialDevicePrivate *priv = NM_SERIAL_DEVICE_GET_PRIVATE (self); - - priv->in_bytes = in_bytes; - priv->out_bytes = out_bytes; - - g_signal_emit (self, signals[PPP_STATS], 0, in_bytes, out_bytes); -} - -static void -device_state_changed (NMDevice *device, GParamSpec *pspec, gpointer user_data) -{ - NMSerialDevicePrivate *priv; - - switch (nm_device_get_state (device)) { - case NM_DEVICE_STATE_UNMANAGED: - case NM_DEVICE_STATE_UNAVAILABLE: - case NM_DEVICE_STATE_DISCONNECTED: - priv = NM_SERIAL_DEVICE_GET_PRIVATE (device); - priv->in_bytes = priv->out_bytes = 0; - break; - default: - break; - } -} - -static void -nm_serial_device_init (NMSerialDevice *device) -{ -} - -static GObject* -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - GObject *object; - NMSerialDevicePrivate *priv; - - object = G_OBJECT_CLASS (nm_serial_device_parent_class)->constructor (type, - n_construct_params, - construct_params); - if (!object) - return NULL; - - priv = NM_SERIAL_DEVICE_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_SERIAL_DEVICE); - - dbus_g_object_register_marshaller (_nm_marshal_VOID__UINT_UINT, - G_TYPE_NONE, - G_TYPE_UINT, G_TYPE_UINT, - G_TYPE_INVALID); - - dbus_g_proxy_add_signal (priv->proxy, "PppStats", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->proxy, "PppStats", - G_CALLBACK (ppp_stats), - object, - NULL); - - /* Catch NMDevice::state changes to reset the counters */ - g_signal_connect (object, "notify::state", - G_CALLBACK (device_state_changed), - object); - - return object; -} - -static void -dispose (GObject *object) -{ - NMSerialDevicePrivate *priv = NM_SERIAL_DEVICE_GET_PRIVATE (object); - - if (priv->disposed) { - G_OBJECT_CLASS (nm_serial_device_parent_class)->dispose (object); - return; - } - - priv->disposed = TRUE; - - g_object_unref (priv->proxy); - - G_OBJECT_CLASS (nm_serial_device_parent_class)->dispose (object); -} - -static void -nm_serial_device_class_init (NMSerialDeviceClass *device_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (device_class); - - g_type_class_add_private (device_class, sizeof (NMSerialDevicePrivate)); - - /* virtual methods */ - object_class->constructor = constructor; - object_class->dispose = dispose; - - /* Signals */ - - /** - * NMSerialDevice::ppp-stats: - * @device: the serial device that received the signal - * @in_bytes: the amount of bytes received - * @out_bytes: the amount of bytes sent - * - * Notifies that a #NMAccessPoint is added to the wifi device. - **/ - signals[PPP_STATS] = - g_signal_new ("ppp-stats", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSerialDeviceClass, ppp_stats), - NULL, NULL, - _nm_marshal_VOID__UINT_UINT, - G_TYPE_NONE, 2, - G_TYPE_UINT, G_TYPE_UINT); -} diff --git a/libnm-glib/nm-settings-connection-interface.c b/libnm-glib/nm-settings-connection-interface.c deleted file mode 100644 index 868ad047a..000000000 --- a/libnm-glib/nm-settings-connection-interface.c +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2009 Red Hat, Inc. - */ - -#include "nm-settings-connection-interface.h" -#include "nm-dbus-glib-types.h" - -/** - * nm_settings_connection_interface_update: - * @connection: an object implementing #NMSettingsConnectionInterface - * @callback: a function to be called when the update completes - * @user_data: caller-specific data to be passed to @callback - * - * Update the connection with current settings and properties. - * - * Returns: TRUE on success, FALSE on failure - **/ -gboolean -nm_settings_connection_interface_update (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data) -{ - g_return_val_if_fail (connection != NULL, FALSE); - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection), FALSE); - g_return_val_if_fail (callback != NULL, FALSE); - - if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->update) { - return NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->update (connection, - callback, - user_data); - } - return FALSE; -} - -/** - * nm_settings_connection_interface_delete: - * @connection: a objecting implementing #NMSettingsConnectionInterface - * @callback: a function to be called when the delete completes - * @user_data: caller-specific data to be passed to @callback - * - * Delete the connection. - * - * Returns: TRUE on success, FALSE on failure - **/ -gboolean -nm_settings_connection_interface_delete (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, - gpointer user_data) -{ - g_return_val_if_fail (connection != NULL, FALSE); - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection), FALSE); - g_return_val_if_fail (callback != NULL, FALSE); - - if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->delete) { - return NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->delete (connection, - callback, - user_data); - } - return FALSE; -} - -/** - * nm_settings_connection_interface_get_secrets: - * @connection: a object implementing #NMSettingsConnectionInterface - * @setting_name: the #NMSetting object name to get secrets for - * @hints: #NMSetting key names to get secrets for (optional) - * @request_new: hint that new secrets (instead of cached or stored secrets) - * should be returned - * @callback: a function to be called when the update completes - * @user_data: caller-specific data to be passed to @callback - * - * Request the connection's secrets. - * - * Returns: TRUE on success, FALSE on failure - **/ -gboolean -nm_settings_connection_interface_get_secrets (NMSettingsConnectionInterface *connection, - const char *setting_name, - const char **hints, - gboolean request_new, - NMSettingsConnectionInterfaceGetSecretsFunc callback, - gpointer user_data) -{ - g_return_val_if_fail (connection != NULL, FALSE); - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection), FALSE); - g_return_val_if_fail (callback != NULL, FALSE); - - if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->get_secrets) { - return NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->get_secrets (connection, - setting_name, - hints, - request_new, - callback, - user_data); - } - return FALSE; -} - -void -nm_settings_connection_interface_emit_updated (NMSettingsConnectionInterface *connection) -{ - if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->emit_updated) - NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->emit_updated (connection); - else { - NMConnection *tmp; - GHashTable *settings; - - tmp = nm_connection_duplicate (NM_CONNECTION (connection)); - nm_connection_clear_secrets (tmp); - settings = nm_connection_to_hash (tmp); - g_object_unref (tmp); - - g_signal_emit_by_name (connection, NM_SETTINGS_CONNECTION_INTERFACE_UPDATED, settings); - g_hash_table_destroy (settings); - } -} - -static void -nm_settings_connection_interface_init (gpointer g_iface) -{ - GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); - static gboolean initialized = FALSE; - - if (initialized) - return; - - /* Signals */ - g_signal_new (NM_SETTINGS_CONNECTION_INTERFACE_UPDATED, - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsConnectionInterface, updated), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT); - - g_signal_new (NM_SETTINGS_CONNECTION_INTERFACE_REMOVED, - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsConnectionInterface, removed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - initialized = TRUE; -} - -GType -nm_settings_connection_interface_get_type (void) -{ - static GType itype = 0; - - if (!itype) { - const GTypeInfo iinfo = { - sizeof (NMSettingsConnectionInterface), /* class_size */ - nm_settings_connection_interface_init, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - - itype = g_type_register_static (G_TYPE_INTERFACE, - "NMSettingsConnectionInterface", - &iinfo, 0); - - g_type_interface_add_prerequisite (itype, NM_TYPE_CONNECTION); - } - - return itype; -} - diff --git a/libnm-glib/nm-settings-connection-interface.h b/libnm-glib/nm-settings-connection-interface.h deleted file mode 100644 index 7c7a198c7..000000000 --- a/libnm-glib/nm-settings-connection-interface.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2009 Red Hat, Inc. - */ - -#ifndef __NM_SETTINGS_CONNECTION_INTERFACE_H__ -#define __NM_SETTINGS_CONNECTION_INTERFACE_H__ - -#include <glib-object.h> -#include <dbus/dbus-glib.h> - -#include <nm-connection.h> - -G_BEGIN_DECLS - -#define NM_TYPE_SETTINGS_CONNECTION_INTERFACE (nm_settings_connection_interface_get_type ()) -#define NM_SETTINGS_CONNECTION_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_CONNECTION_INTERFACE, NMSettingsConnectionInterface)) -#define NM_IS_SETTINGS_CONNECTION_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_CONNECTION_INTERFACE)) -#define NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_CONNECTION_INTERFACE, NMSettingsConnectionInterface)) - -#define NM_SETTINGS_CONNECTION_INTERFACE_UPDATED "updated" -#define NM_SETTINGS_CONNECTION_INTERFACE_REMOVED "removed" - -typedef struct _NMSettingsConnectionInterface NMSettingsConnectionInterface; - -typedef void (*NMSettingsConnectionInterfaceUpdateFunc) (NMSettingsConnectionInterface *connection, - GError *error, - gpointer user_data); - -typedef void (*NMSettingsConnectionInterfaceDeleteFunc) (NMSettingsConnectionInterface *connection, - GError *error, - gpointer user_data); - -typedef void (*NMSettingsConnectionInterfaceGetSecretsFunc) (NMSettingsConnectionInterface *connection, - GHashTable *secrets, - GError *error, - gpointer user_data); - -struct _NMSettingsConnectionInterface { - GTypeInterface g_iface; - - /* Methods */ - gboolean (*update) (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data); - - gboolean (*delete) (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, - gpointer user_data); - - gboolean (*get_secrets) (NMSettingsConnectionInterface *connection, - const char *setting_name, - const char **hints, - gboolean request_new, - NMSettingsConnectionInterfaceGetSecretsFunc callback, - gpointer user_data); - - void (*emit_updated) (NMSettingsConnectionInterface *connection); - - /* Signals */ - /* 'new_settings' hash should *not* contain secrets */ - void (*updated) (NMSettingsConnectionInterface *connection, - GHashTable *new_settings); - - void (*removed) (NMSettingsConnectionInterface *connection); - - /* Padding for future expansion */ - void (*_reserved1) (void); - void (*_reserved2) (void); - void (*_reserved3) (void); - void (*_reserved4) (void); - void (*_reserved5) (void); - void (*_reserved6) (void); -}; - -GType nm_settings_connection_interface_get_type (void); - -gboolean nm_settings_connection_interface_update (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data); - -gboolean nm_settings_connection_interface_delete (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, - gpointer user_data); - -gboolean nm_settings_connection_interface_get_secrets (NMSettingsConnectionInterface *connection, - const char *setting_name, - const char **hints, - gboolean request_new, - NMSettingsConnectionInterfaceGetSecretsFunc callback, - gpointer user_data); - -void nm_settings_connection_interface_emit_updated (NMSettingsConnectionInterface *connection); - -G_END_DECLS - -#endif /* __NM_SETTINGS_CONNECTION_INTERFACE_H__ */ - diff --git a/libnm-glib/nm-settings-interface.c b/libnm-glib/nm-settings-interface.c deleted file mode 100644 index 3bd4037a1..000000000 --- a/libnm-glib/nm-settings-interface.c +++ /dev/null @@ -1,206 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2010 Red Hat, Inc. - */ - -#include "nm-settings-interface.h" - - -/** - * nm_settings_interface_error_quark: - * - * Setting error quark. - * - * Returns: the setting error quark - **/ -GQuark -nm_settings_interface_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-settings-interface-error-quark"); - return quark; -} - -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_settings_interface_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* The connection was invalid. */ - ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION, "InvalidConnection"), - /* The connection is read-only; modifications are not allowed. */ - ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_READ_ONLY_CONNECTION, "ReadOnlyConnection"), - /* A bug in the settings service caused the error. */ - ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, "InternalError"), - /* Retrieval or request of secrets failed. */ - ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE, "SecretsUnavailable"), - /* The request for secrets was canceled. */ - ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED, "SecretsRequestCanceled"), - /* The request could not be completed because permission was denied. */ - ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED, "PermissionDenied"), - /* The requested setting does not existing in this connection. */ - ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_INVALID_SETTING, "InvalidSetting"), - { 0, 0, 0 }, - }; - etype = g_enum_register_static ("NMSettingsInterfaceError", values); - } - return etype; -} - - -/** - * nm_settings_list_connections: - * @settings: a object implementing %NMSettingsInterface - * - * Returns: all connections known to the object. - **/ -GSList * -nm_settings_interface_list_connections (NMSettingsInterface *settings) -{ - g_return_val_if_fail (settings != NULL, NULL); - g_return_val_if_fail (NM_IS_SETTINGS_INTERFACE (settings), NULL); - - if (NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->list_connections) - return NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->list_connections (settings); - return NULL; -} - -/** - * nm_settings_get_connection_by_path: - * @settings: a object implementing %NMSettingsInterface - * @path: the D-Bus object path of the remote connection - * - * Returns the object implementing %NMSettingsConnectionInterface at @path. - * - * Returns: the remote connection object on success, or NULL if the object was - * not known - **/ -NMSettingsConnectionInterface * -nm_settings_interface_get_connection_by_path (NMSettingsInterface *settings, - const char *path) -{ - g_return_val_if_fail (settings != NULL, NULL); - g_return_val_if_fail (NM_IS_SETTINGS_INTERFACE (settings), NULL); - g_return_val_if_fail (path != NULL, NULL); - - if (NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->get_connection_by_path) - return NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->get_connection_by_path (settings, path); - return NULL; -} - -/** - * nm_settings_interface_add_connection: - * @settings: a object implementing %NMSettingsInterface - * @connection: the settings to add; note that this object's settings will be - * added, not the object itself - * @callback: callback to be called when the add operation completes - * @user_data: caller-specific data passed to @callback - * - * Requests that the settings service add the given settings to a new connection. - * - * Returns: TRUE if the request was successful, FALSE if it failed - **/ -gboolean -nm_settings_interface_add_connection (NMSettingsInterface *settings, - NMConnection *connection, - NMSettingsAddConnectionFunc callback, - gpointer user_data) -{ - g_return_val_if_fail (settings != NULL, FALSE); - g_return_val_if_fail (NM_IS_SETTINGS_INTERFACE (settings), FALSE); - g_return_val_if_fail (connection != NULL, FALSE); - g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); - g_return_val_if_fail (callback != NULL, FALSE); - - if (NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->add_connection) { - return NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->add_connection (settings, - connection, - callback, - user_data); - } - return FALSE; -} - -/*****************************************************************/ - -static void -nm_settings_interface_init (gpointer g_iface) -{ - GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); - static gboolean initialized = FALSE; - - if (initialized) - return; - - /* Signals */ - g_signal_new (NM_SETTINGS_INTERFACE_NEW_CONNECTION, - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsInterface, new_connection), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, G_TYPE_OBJECT); - - g_signal_new (NM_SETTINGS_INTERFACE_CONNECTIONS_READ, - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsInterface, connections_read), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - initialized = TRUE; -} - -GType -nm_settings_interface_get_type (void) -{ - static GType settings_interface_type = 0; - - if (!settings_interface_type) { - const GTypeInfo settings_interface_info = { - sizeof (NMSettingsInterface), /* class_size */ - nm_settings_interface_init, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - - settings_interface_type = g_type_register_static (G_TYPE_INTERFACE, - "NMSettingsInterface", - &settings_interface_info, 0); - - g_type_interface_add_prerequisite (settings_interface_type, G_TYPE_OBJECT); - } - - return settings_interface_type; -} - diff --git a/libnm-glib/nm-settings-interface.h b/libnm-glib/nm-settings-interface.h deleted file mode 100644 index 5920bd825..000000000 --- a/libnm-glib/nm-settings-interface.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2010 Red Hat, Inc. - */ - -#ifndef NM_SETTINGS_INTERFACE_H -#define NM_SETTINGS_INTERFACE_H - -#include <glib-object.h> - -#include "NetworkManager.h" -#include "nm-settings-connection-interface.h" - -G_BEGIN_DECLS - -typedef enum { - NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION = 0, - NM_SETTINGS_INTERFACE_ERROR_READ_ONLY_CONNECTION, - NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, - NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE, - NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED, - NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED, - NM_SETTINGS_INTERFACE_ERROR_INVALID_SETTING, -} NMSettingsInterfaceError; - -#define NM_SETTINGS_INTERFACE_ERROR (nm_settings_interface_error_quark ()) -GQuark nm_settings_interface_error_quark (void); - -#define NM_TYPE_SETTINGS_INTERFACE_ERROR (nm_settings_interface_error_get_type ()) -GType nm_settings_interface_error_get_type (void); - - -#define NM_TYPE_SETTINGS_INTERFACE (nm_settings_interface_get_type ()) -#define NM_SETTINGS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_INTERFACE, NMSettingsInterface)) -#define NM_IS_SETTINGS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_INTERFACE)) -#define NM_SETTINGS_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_INTERFACE, NMSettingsInterface)) - -#define NM_SETTINGS_INTERFACE_NEW_CONNECTION "new-connection" -#define NM_SETTINGS_INTERFACE_CONNECTIONS_READ "connections-read" - -typedef struct _NMSettingsInterface NMSettingsInterface; - -typedef void (*NMSettingsAddConnectionFunc) (NMSettingsInterface *settings, - GError *error, - gpointer user_data); - -struct _NMSettingsInterface { - GTypeInterface g_iface; - - /* Methods */ - /* Returns a list of objects implementing NMSettingsConnectionInterface */ - GSList * (*list_connections) (NMSettingsInterface *settings); - - NMSettingsConnectionInterface * (*get_connection_by_path) (NMSettingsInterface *settings, - const char *path); - - gboolean (*add_connection) (NMSettingsInterface *settings, - NMConnection *connection, - NMSettingsAddConnectionFunc callback, - gpointer user_data); - - /* Signals */ - void (*new_connection) (NMSettingsInterface *settings, - NMSettingsConnectionInterface *connection); - - void (*connections_read) (NMSettingsInterface *settings); - - /* Padding for future expansion */ - void (*_reserved1) (void); - void (*_reserved2) (void); - void (*_reserved3) (void); - void (*_reserved4) (void); - void (*_reserved5) (void); - void (*_reserved6) (void); -}; - -GType nm_settings_interface_get_type (void); - -/* Returns a list of objects implementing NMSettingsConnectionInterface */ -GSList *nm_settings_interface_list_connections (NMSettingsInterface *settings); - -NMSettingsConnectionInterface *nm_settings_interface_get_connection_by_path (NMSettingsInterface *settings, - const char *path); - -gboolean nm_settings_interface_add_connection (NMSettingsInterface *settings, - NMConnection *connection, - NMSettingsAddConnectionFunc callback, - gpointer user_data); - -G_END_DECLS - -#endif /* NM_SETTINGS_INTERFACE_H */ diff --git a/libnm-glib/nm-settings-service.c b/libnm-glib/nm-settings-service.c deleted file mode 100644 index 6266d10da..000000000 --- a/libnm-glib/nm-settings-service.c +++ /dev/null @@ -1,372 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 Novell, Inc. - * (C) Copyright 2008 - 2009 Red Hat, Inc. - */ - -#include <string.h> -#include <NetworkManager.h> -#include <dbus/dbus-glib-lowlevel.h> - -#include "nm-settings-service.h" -#include "nm-settings-interface.h" -#include "nm-exported-connection.h" - -static gboolean impl_settings_list_connections (NMSettingsService *self, - GPtrArray **connections, - GError **error); - -static void impl_settings_add_connection (NMSettingsService *self, - GHashTable *settings, - DBusGMethodInvocation *context); - -#include "nm-settings-glue.h" - -static void settings_interface_init (NMSettingsInterface *class); - -G_DEFINE_TYPE_EXTENDED (NMSettingsService, nm_settings_service, G_TYPE_OBJECT, G_TYPE_FLAG_ABSTRACT, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_INTERFACE, settings_interface_init)) - -#define NM_SETTINGS_SERVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_SETTINGS_SERVICE, \ - NMSettingsServicePrivate)) - -typedef struct { - DBusGConnection *bus; - NMConnectionScope scope; - gboolean exported; - - gboolean disposed; -} NMSettingsServicePrivate; - -enum { - PROP_0, - PROP_BUS, - PROP_SCOPE, - - LAST_PROP -}; - - -/**************************************************************/ - -void -nm_settings_service_export (NMSettingsService *self) -{ - NMSettingsServicePrivate *priv; - - g_return_if_fail (self != NULL); - g_return_if_fail (NM_IS_SETTINGS_SERVICE (self)); - - priv = NM_SETTINGS_SERVICE_GET_PRIVATE (self); - - g_return_if_fail (priv->bus != NULL); - - /* Don't allow exporting twice */ - g_return_if_fail (priv->exported == FALSE); - - dbus_g_connection_register_g_object (priv->bus, - NM_DBUS_PATH_SETTINGS, - G_OBJECT (self)); - priv->exported = TRUE; -} - -/**************************************************************/ - -static GSList * -list_connections (NMSettingsInterface *settings) -{ - /* Must always be implemented */ - g_assert (NM_SETTINGS_SERVICE_GET_CLASS (settings)->list_connections); - return NM_SETTINGS_SERVICE_GET_CLASS (settings)->list_connections (NM_SETTINGS_SERVICE (settings)); -} - -static gboolean -impl_settings_list_connections (NMSettingsService *self, - GPtrArray **connections, - GError **error) -{ - GSList *list = NULL, *iter; - - list = list_connections (NM_SETTINGS_INTERFACE (self)); - *connections = g_ptr_array_sized_new (g_slist_length (list) + 1); - for (iter = list; iter; iter = g_slist_next (iter)) { - g_ptr_array_add (*connections, - g_strdup (nm_connection_get_path (NM_CONNECTION (iter->data)))); - } - g_slist_free (list); - return TRUE; -} - -static NMSettingsConnectionInterface * -get_connection_by_path (NMSettingsInterface *settings, const char *path) -{ - NMExportedConnection *connection = NULL; - GSList *list = NULL, *iter; - - list = list_connections (settings); - for (iter = list; iter; iter = g_slist_next (iter)) { - if (!strcmp (nm_connection_get_path (NM_CONNECTION (iter->data)), path)) { - connection = NM_EXPORTED_CONNECTION (iter->data); - break; - } - } - g_slist_free (list); - - return (NMSettingsConnectionInterface *) connection; -} - -NMExportedConnection * -nm_settings_service_get_connection_by_path (NMSettingsService *self, - const char *path) -{ - g_return_val_if_fail (self != NULL, NULL); - g_return_val_if_fail (NM_IS_SETTINGS_SERVICE (self), NULL); - - return (NMExportedConnection *) get_connection_by_path (NM_SETTINGS_INTERFACE (self), path); -} - -static gboolean -add_connection (NMSettingsInterface *settings, - NMConnection *connection, - NMSettingsAddConnectionFunc callback, - gpointer user_data) -{ - NMSettingsService *self = NM_SETTINGS_SERVICE (settings); - GError *error = NULL; - gboolean success = FALSE; - - if (NM_SETTINGS_SERVICE_GET_CLASS (self)->add_connection) { - NM_SETTINGS_SERVICE_GET_CLASS (self)->add_connection (NM_SETTINGS_SERVICE (self), - connection, - NULL, - callback, - user_data); - success = TRUE; - } else { - error = g_error_new (NM_SETTINGS_INTERFACE_ERROR, - NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, - "%s: %s:%d add_connection() not implemented", - __func__, __FILE__, __LINE__); - callback (settings, error, user_data); - g_error_free (error); - } - - return success; -} - -static void -dbus_add_connection_cb (NMSettingsInterface *settings, - GError *error, - gpointer user_data) -{ - DBusGMethodInvocation *context = user_data; - - if (error) - dbus_g_method_return_error (context, error); - else - dbus_g_method_return (context); -} - -static void -impl_settings_add_connection (NMSettingsService *self, - GHashTable *settings, - DBusGMethodInvocation *context) -{ - NMConnection *tmp; - GError *error = NULL; - - /* Check if the settings are valid first */ - tmp = nm_connection_new_from_hash (settings, &error); - if (!tmp) { - g_assert (error); - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } - - if (NM_SETTINGS_SERVICE_GET_CLASS (self)->add_connection) { - NM_SETTINGS_SERVICE_GET_CLASS (self)->add_connection (NM_SETTINGS_SERVICE (self), - tmp, - context, - dbus_add_connection_cb, - context); - } else { - error = g_error_new (NM_SETTINGS_INTERFACE_ERROR, - NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, - "%s: %s:%d add_connection() not implemented", - __func__, __FILE__, __LINE__); - dbus_g_method_return_error (context, error); - g_error_free (error); - } - - g_object_unref (tmp); -} - -void -nm_settings_service_export_connection (NMSettingsService *self, - NMSettingsConnectionInterface *connection) -{ - NMSettingsServicePrivate *priv = NM_SETTINGS_SERVICE_GET_PRIVATE (self); - static guint32 ec_counter = 0; - char *path; - - g_return_if_fail (connection != NULL); - g_return_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection)); - g_return_if_fail (priv->bus != NULL); - - /* Don't allow exporting twice */ - g_return_if_fail (nm_connection_get_path (NM_CONNECTION (connection)) == NULL); - - path = g_strdup_printf ("%s/%u", NM_DBUS_PATH_SETTINGS, ec_counter++); - nm_connection_set_path (NM_CONNECTION (connection), path); - nm_connection_set_scope (NM_CONNECTION (connection), priv->scope); - - dbus_g_connection_register_g_object (priv->bus, path, G_OBJECT (connection)); - g_free (path); -} - -/**************************************************************/ - -static void -settings_interface_init (NMSettingsInterface *iface) -{ - /* interface implementation */ - iface->list_connections = list_connections; - iface->get_connection_by_path = get_connection_by_path; - iface->add_connection = add_connection; - - dbus_g_object_type_install_info (G_TYPE_FROM_INTERFACE (iface), - &dbus_glib_nm_settings_object_info); -} - -static GObject * -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - GObject *object; - - object = G_OBJECT_CLASS (nm_settings_service_parent_class)->constructor (type, n_construct_params, construct_params); - if (object) { - g_assert (NM_SETTINGS_SERVICE_GET_PRIVATE (object)->scope != NM_CONNECTION_SCOPE_UNKNOWN); - } - return object; -} - -static void -nm_settings_service_init (NMSettingsService *self) -{ -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMSettingsServicePrivate *priv = NM_SETTINGS_SERVICE_GET_PRIVATE (object); - DBusGConnection *bus; - - switch (prop_id) { - case PROP_BUS: - /* Construct only */ - bus = g_value_get_boxed (value); - if (bus) - priv->bus = dbus_g_connection_ref (bus); - break; - case PROP_SCOPE: - /* Construct only */ - priv->scope = g_value_get_uint (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMSettingsServicePrivate *priv = NM_SETTINGS_SERVICE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_BUS: - g_value_set_boxed (value, priv->bus); - break; - case PROP_SCOPE: - g_value_set_uint (value, priv->scope); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -dispose (GObject *object) -{ - NMSettingsServicePrivate *priv = NM_SETTINGS_SERVICE_GET_PRIVATE (object); - - if (!priv->disposed) { - priv->disposed = TRUE; - if (priv->bus) - dbus_g_connection_unref (priv->bus); - } - - G_OBJECT_CLASS (nm_settings_service_parent_class)->dispose (object); -} - -static void -nm_settings_service_class_init (NMSettingsServiceClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - g_type_class_add_private (class, sizeof (NMSettingsServicePrivate)); - - /* Virtual methods */ - object_class->dispose = dispose; - object_class->constructor = constructor; - object_class->get_property = get_property; - object_class->set_property = set_property; - - /** - * NMSettingsService:bus: - * - * The %DBusGConnection which this object is exported on - **/ - g_object_class_install_property (object_class, PROP_BUS, - g_param_spec_boxed (NM_SETTINGS_SERVICE_BUS, - "Bus", - "Bus", - DBUS_TYPE_G_CONNECTION, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - /** - * NMSettingsService:scope: - * - * The capabilities of the device. - **/ - g_object_class_install_property (object_class, PROP_SCOPE, - g_param_spec_uint (NM_SETTINGS_SERVICE_SCOPE, - "Scope", - "Scope", - NM_CONNECTION_SCOPE_SYSTEM, - NM_CONNECTION_SCOPE_USER, - NM_CONNECTION_SCOPE_USER, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); -} diff --git a/libnm-glib/nm-settings-service.h b/libnm-glib/nm-settings-service.h deleted file mode 100644 index 9f4b95fcc..000000000 --- a/libnm-glib/nm-settings-service.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * (C) Copyright 2009 Red Hat, Inc. - */ - -#ifndef NM_SETTINGS_SERVICE_H -#define NM_SETTINGS_SERVICE_H - -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> -#include <nm-exported-connection.h> -#include <nm-settings-interface.h> - -G_BEGIN_DECLS - -#define NM_TYPE_SETTINGS_SERVICE (nm_settings_service_get_type ()) -#define NM_SETTINGS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_SERVICE, NMSettingsService)) -#define NM_SETTINGS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTINGS_SERVICE, NMSettingsServiceClass)) -#define NM_IS_SETTINGS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_SERVICE)) -#define NM_IS_SETTINGS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SETTINGS_SERVICE)) -#define NM_SETTINGS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTINGS_SERVICE, NMSettingsServiceClass)) - -#define NM_SETTINGS_SERVICE_BUS "bus" -#define NM_SETTINGS_SERVICE_SCOPE "scope" - -typedef struct { - GObject parent; -} NMSettingsService; - -typedef struct { - GObjectClass parent; - - /* Returned list must contain all NMExportedConnection objects exported - * by the settings service. The list (but not the NMExportedConnection - * objects) will be freed by caller. - */ - GSList * (*list_connections) (NMSettingsService *self); - - void (*add_connection) (NMSettingsService *self, - NMConnection *connection, - DBusGMethodInvocation *context, /* Only present for D-Bus calls */ - NMSettingsAddConnectionFunc callback, - gpointer user_data); - - /* Padding for future expansion */ - void (*_reserved1) (void); - void (*_reserved2) (void); - void (*_reserved3) (void); - void (*_reserved4) (void); - void (*_reserved5) (void); - void (*_reserved6) (void); -} NMSettingsServiceClass; - -GType nm_settings_service_get_type (void); - -NMExportedConnection *nm_settings_service_get_connection_by_path (NMSettingsService *self, - const char *path); - -void nm_settings_service_export (NMSettingsService *self); - -void nm_settings_service_export_connection (NMSettingsService *self, - NMSettingsConnectionInterface *exported); - -G_END_DECLS - -#endif /* NM_SETTINGS_SERVICE_H */ diff --git a/libnm-glib/nm-settings-system-interface.c b/libnm-glib/nm-settings-system-interface.c deleted file mode 100644 index 0f59377a5..000000000 --- a/libnm-glib/nm-settings-system-interface.c +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2008 Red Hat, Inc. - */ - -#include "nm-settings-interface.h" -#include "nm-settings-system-interface.h" - - -/** - * nm_settings_system_interface_save_hostname: - * @settings: a object implementing %NMSettingsSystemInterface - * @hostname: the new persistent hostname to set, or NULL to clear any existing - * persistent hostname - * @callback: callback to be called when the hostname operation completes - * @user_data: caller-specific data passed to @callback - * - * Requests that the machine's persistent hostname be set to the specified value - * or cleared. - * - * Returns: TRUE if the request was successful, FALSE if it failed - **/ -gboolean -nm_settings_system_interface_save_hostname (NMSettingsSystemInterface *settings, - const char *hostname, - NMSettingsSystemSaveHostnameFunc callback, - gpointer user_data) -{ - g_return_val_if_fail (settings != NULL, FALSE); - g_return_val_if_fail (NM_IS_SETTINGS_SYSTEM_INTERFACE (settings), FALSE); - g_return_val_if_fail (hostname != NULL, FALSE); - g_return_val_if_fail (callback != NULL, FALSE); - - if (NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->save_hostname) { - return NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->save_hostname (settings, - hostname, - callback, - user_data); - } - return FALSE; -} - -/** - * nm_settings_system_interface_get_permissions: - * @settings: a object implementing %NMSettingsSystemInterface - * @callback: callback to be called when the permissions operation completes - * @user_data: caller-specific data passed to @callback - * - * Requests an indication of the operations the caller is permitted to perform - * including those that may require authorization. - * - * Returns: TRUE if the request was successful, FALSE if it failed - **/ -gboolean -nm_settings_system_interface_get_permissions (NMSettingsSystemInterface *settings, - NMSettingsSystemGetPermissionsFunc callback, - gpointer user_data) -{ - g_return_val_if_fail (settings != NULL, FALSE); - g_return_val_if_fail (NM_IS_SETTINGS_SYSTEM_INTERFACE (settings), FALSE); - g_return_val_if_fail (callback != NULL, FALSE); - - if (NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->get_permissions) - return NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->get_permissions (settings, callback, user_data); - return FALSE; -} - -static void -nm_settings_system_interface_init (gpointer g_iface) -{ - GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); - static gboolean initialized = FALSE; - - if (initialized) - return; - - /* Properties */ - g_object_interface_install_property - (g_iface, - g_param_spec_string (NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME, - "Hostname", - "Persistent hostname", - NULL, - G_PARAM_READABLE)); - - g_object_interface_install_property - (g_iface, - g_param_spec_boolean (NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY, - "CanModify", - "Can modify anything (hostname, connections, etc)", - FALSE, - G_PARAM_READABLE)); - - /* Signals */ - g_signal_new (NM_SETTINGS_SYSTEM_INTERFACE_CHECK_PERMISSIONS, - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsSystemInterface, check_permissions), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - initialized = TRUE; -} - -GType -nm_settings_system_interface_get_type (void) -{ - static GType itype = 0; - - if (!itype) { - const GTypeInfo iinfo = { - sizeof (NMSettingsSystemInterface), /* class_size */ - nm_settings_system_interface_init, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - - itype = g_type_register_static (G_TYPE_INTERFACE, - "NMSettingsSystemInterface", - &iinfo, 0); - - g_type_interface_add_prerequisite (itype, NM_TYPE_SETTINGS_INTERFACE); - } - - return itype; -} - diff --git a/libnm-glib/nm-settings-system-interface.h b/libnm-glib/nm-settings-system-interface.h deleted file mode 100644 index d01655612..000000000 --- a/libnm-glib/nm-settings-system-interface.h +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2009 Red Hat, Inc. - */ - -#ifndef NM_SETTINGS_SYSTEM_INTERFACE_H -#define NM_SETTINGS_SYSTEM_INTERFACE_H - -#include <glib-object.h> - -#include "NetworkManager.h" - -G_BEGIN_DECLS - -typedef enum { - NM_SETTINGS_SYSTEM_PERMISSION_NONE = 0x0, - NM_SETTINGS_SYSTEM_PERMISSION_CONNECTION_MODIFY = 0x1, - NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_PROTECTED = 0x2, - NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_OPEN = 0x4, - NM_SETTINGS_SYSTEM_PERMISSION_HOSTNAME_MODIFY = 0x8 -} NMSettingsSystemPermissions; - -#define NM_TYPE_SETTINGS_SYSTEM_INTERFACE (nm_settings_system_interface_get_type ()) -#define NM_SETTINGS_SYSTEM_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_SYSTEM_INTERFACE, NMSettingsSystemInterface)) -#define NM_IS_SETTINGS_SYSTEM_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_SYSTEM_INTERFACE)) -#define NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_SYSTEM_INTERFACE, NMSettingsSystemInterface)) - -#define NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME "hostname" -#define NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY "can-modify" - -#define NM_SETTINGS_SYSTEM_INTERFACE_CHECK_PERMISSIONS "check-permissions" - -typedef enum { - NM_SETTINGS_SYSTEM_INTERFACE_PROP_FIRST = 0x1000, - - NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME = NM_SETTINGS_SYSTEM_INTERFACE_PROP_FIRST, - NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY -} NMSettingsSystemInterfaceProp; - - -typedef struct _NMSettingsSystemInterface NMSettingsSystemInterface; - - -typedef void (*NMSettingsSystemSaveHostnameFunc) (NMSettingsSystemInterface *settings, - GError *error, - gpointer user_data); - -typedef void (*NMSettingsSystemGetPermissionsFunc) (NMSettingsSystemInterface *settings, - NMSettingsSystemPermissions permissions, - GError *error, - gpointer user_data); - -struct _NMSettingsSystemInterface { - GTypeInterface g_iface; - - /* Methods */ - gboolean (*save_hostname) (NMSettingsSystemInterface *settings, - const char *hostname, - NMSettingsSystemSaveHostnameFunc callback, - gpointer user_data); - - gboolean (*get_permissions) (NMSettingsSystemInterface *settings, - NMSettingsSystemGetPermissionsFunc callback, - gpointer user_data); - - /* Signals */ - void (*check_permissions) (NMSettingsSystemInterface *settings); - - /* Padding for future expansion */ - void (*_reserved1) (void); - void (*_reserved2) (void); - void (*_reserved3) (void); - void (*_reserved4) (void); - void (*_reserved5) (void); - void (*_reserved6) (void); -}; - -GType nm_settings_system_interface_get_type (void); - -gboolean nm_settings_system_interface_save_hostname (NMSettingsSystemInterface *settings, - const char *hostname, - NMSettingsSystemSaveHostnameFunc callback, - gpointer user_data); - -gboolean nm_settings_system_interface_get_permissions (NMSettingsSystemInterface *settings, - NMSettingsSystemGetPermissionsFunc callback, - gpointer user_data); - -G_END_DECLS - -#endif /* NM_SETTINGS_SYSTEM_INTERFACE_H */ diff --git a/libnm-glib/nm-types.c b/libnm-glib/nm-types.c index cf9e084c7..a2d6d2b4f 100644 --- a/libnm-glib/nm-types.c +++ b/libnm-glib/nm-types.c @@ -52,7 +52,7 @@ nm_ssid_get_type (void) static GType our_type = 0; if (our_type == 0) - our_type = g_boxed_type_register_static (g_intern_static_string ("nm-ssid"), + our_type = g_boxed_type_register_static (g_intern_static_string ("NMSsid"), (GBoxedCopyFunc) nm_ssid_copy, (GBoxedFreeFunc) nm_ssid_free); return our_type; @@ -105,7 +105,7 @@ nm_uint_array_get_type (void) static GType our_type = 0; if (our_type == 0) - our_type = g_boxed_type_register_static (g_intern_static_string ("nm-uint-array"), + our_type = g_boxed_type_register_static (g_intern_static_string ("NMUintArray"), (GBoxedCopyFunc) nm_uint_array_copy, (GBoxedFreeFunc) nm_uint_array_free); return our_type; @@ -163,7 +163,7 @@ nm_string_array_get_type (void) static GType our_type = 0; if (our_type == 0) - our_type = g_boxed_type_register_static (g_intern_static_string ("nm-string-array"), + our_type = g_boxed_type_register_static (g_intern_static_string ("NMStringArray"), (GBoxedCopyFunc) nm_string_array_copy, (GBoxedFreeFunc) nm_string_array_free); return our_type; @@ -224,7 +224,7 @@ nm_object_array_get_type (void) static GType our_type = 0; if (our_type == 0) - our_type = g_boxed_type_register_static (g_intern_static_string ("nm-object-array"), + our_type = g_boxed_type_register_static (g_intern_static_string ("NMObjectArray"), (GBoxedCopyFunc) nm_object_array_copy, (GBoxedFreeFunc) nm_object_array_free); return our_type; @@ -253,9 +253,9 @@ _nm_object_array_demarshal (GValue *value, path = g_ptr_array_index (array, i); object = G_OBJECT (_nm_object_cache_get (path)); - if (object) { - g_ptr_array_add (temp, g_object_ref (object)); - } else { + if (object) + g_ptr_array_add (temp, object); + else { object = (*func) (connection, path); if (object) g_ptr_array_add (temp, object); @@ -306,7 +306,7 @@ nm_ip6_address_object_array_get_type (void) static GType our_type = 0; if (our_type == 0) - our_type = g_boxed_type_register_static (g_intern_static_string ("nm-ip6-address-object-array"), + our_type = g_boxed_type_register_static (g_intern_static_string ("NMIP6AddressObjectArray"), (GBoxedCopyFunc) nm_ip6_address_object_array_copy, (GBoxedFreeFunc) nm_ip6_address_object_array_free); return our_type; @@ -348,7 +348,7 @@ nm_ip6_address_array_get_type (void) static GType our_type = 0; if (our_type == 0) - our_type = g_boxed_type_register_static (g_intern_static_string ("nm-ip6-address-array"), + our_type = g_boxed_type_register_static (g_intern_static_string ("NMIP6AddressArray"), (GBoxedCopyFunc) nm_ip6_address_array_copy, (GBoxedFreeFunc) nm_ip6_address_array_free); return our_type; @@ -415,7 +415,7 @@ nm_ip6_route_object_array_get_type (void) static GType our_type = 0; if (our_type == 0) - our_type = g_boxed_type_register_static (g_intern_static_string ("nm-ip6-route-object-array"), + our_type = g_boxed_type_register_static (g_intern_static_string ("NMIP6RouteObjectArray"), (GBoxedCopyFunc) nm_ip6_route_object_array_copy, (GBoxedFreeFunc) nm_ip6_route_object_array_free); return our_type; diff --git a/libnm-glib/nm-vpn-connection.c b/libnm-glib/nm-vpn-connection.c index 6910b6f63..dd219b2a1 100644 --- a/libnm-glib/nm-vpn-connection.c +++ b/libnm-glib/nm-vpn-connection.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2010 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ #include <string.h> @@ -60,14 +60,23 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +/** + * nm_vpn_connection_new: + * @connection: the #DBusGConnection + * @path: the DBus object path of the new connection + * + * Creates a new #NMVPNConnection. + * + * Returns: (transfer full): a new connection object + **/ GObject * -nm_vpn_connection_new (DBusGConnection *dbus_connection, const char *path) +nm_vpn_connection_new (DBusGConnection *connection, const char *path) { - g_return_val_if_fail (dbus_connection != NULL, NULL); + g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (path != NULL, NULL); return g_object_new (NM_TYPE_VPN_CONNECTION, - NM_OBJECT_DBUS_CONNECTION, dbus_connection, + NM_OBJECT_DBUS_CONNECTION, connection, NM_OBJECT_DBUS_PATH, path, NULL); } @@ -86,7 +95,8 @@ nm_vpn_connection_get_banner (NMVPNConnection *vpn) if (!priv->banner) { priv->banner = _nm_object_get_string_property (NM_OBJECT (vpn), NM_DBUS_INTERFACE_VPN_CONNECTION, - DBUS_PROP_BANNER); + DBUS_PROP_BANNER, + NULL); if (priv->banner && !strlen (priv->banner)) { g_free (priv->banner); priv->banner = NULL; @@ -106,7 +116,8 @@ nm_vpn_connection_get_vpn_state (NMVPNConnection *vpn) if (priv->vpn_state == NM_VPN_CONNECTION_STATE_UNKNOWN) { priv->vpn_state = _nm_object_get_uint_property (NM_OBJECT (vpn), NM_DBUS_INTERFACE_VPN_CONNECTION, - DBUS_PROP_VPN_STATE); + DBUS_PROP_VPN_STATE, + NULL); } return priv->vpn_state; } @@ -175,9 +186,7 @@ finalize (GObject *object) { NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object); - if (priv->banner) - g_free (priv->banner); - + g_free (priv->banner); g_object_unref (priv->proxy); G_OBJECT_CLASS (nm_vpn_connection_parent_class)->finalize (object); diff --git a/libnm-glib/nm-vpn-connection.h b/libnm-glib/nm-vpn-connection.h index e03a80c77..8541e704a 100644 --- a/libnm-glib/nm-vpn-connection.h +++ b/libnm-glib/nm-vpn-connection.h @@ -65,7 +65,7 @@ typedef struct { GType nm_vpn_connection_get_type (void); -GObject * nm_vpn_connection_new (DBusGConnection *dbus_connection, const char *path); +GObject * nm_vpn_connection_new (DBusGConnection *connection, const char *path); NMVPNConnectionState nm_vpn_connection_get_vpn_state (NMVPNConnection *vpn); const char * nm_vpn_connection_get_banner (NMVPNConnection *vpn); diff --git a/libnm-glib/nm-vpn-plugin-utils.c b/libnm-glib/nm-vpn-plugin-utils.c new file mode 100644 index 000000000..8234a9197 --- /dev/null +++ b/libnm-glib/nm-vpn-plugin-utils.c @@ -0,0 +1,188 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright (C) 2011 Red Hat, Inc. + */ + +#include <errno.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +#include "nm-vpn-plugin-utils.h" +#include "nm-setting-private.h" + +#define DATA_KEY_TAG "DATA_KEY=" +#define DATA_VAL_TAG "DATA_VAL=" +#define SECRET_KEY_TAG "SECRET_KEY=" +#define SECRET_VAL_TAG "SECRET_VAL=" + +static void +free_secret (gpointer data) +{ + char *secret = data; + + memset (secret, 0, strlen (secret)); + g_free (secret); +} + +/** + * nm_vpn_plugin_utils_read_vpn_details: + * @fd: file descriptor to read from, usually stdin (0) + * @out_data: (out) (transfer full): on successful return, a hash table + * (mapping char*:char*) containing the key/value pairs of VPN data items + * @out_secrets: (out) (transfer full): on successful return, a hash table + * (mapping char*:char*) containing the key/value pairsof VPN secrets + * + * Parses key/value pairs from a file descriptor (normally stdin) passed by + * an applet when the applet calls the authentication dialog of the VPN plugin. + * + * Returns: %TRUE if reading values was successful, %FALSE if not + **/ +gboolean +nm_vpn_plugin_utils_read_vpn_details (int fd, + GHashTable **out_data, + GHashTable **out_secrets) +{ + GHashTable *data, *secrets; + gboolean success = FALSE; + char *key = NULL, *val = NULL; + GString *line; + gchar c; + + if (out_data) + g_return_val_if_fail (*out_data == NULL, FALSE); + if (out_secrets) + g_return_val_if_fail (*out_secrets == NULL, FALSE); + + data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_secret); + + line = g_string_new (NULL); + + /* Read stdin for data and secret items until we get a DONE */ + while (1) { + ssize_t nr; + GHashTable *hash = NULL; + + errno = 0; + nr = read (fd, &c, 1); + if (nr == -1) { + if (errno == EAGAIN) { + g_usleep (100); + continue; + } + break; + } + + if (c != '\n') { + g_string_append_c (line, c); + continue; + } + + /* Check for the finish marker */ + if (strcmp (line->str, "DONE") == 0) + break; + + /* Otherwise it's a data/secret item */ + if (strncmp (line->str, DATA_KEY_TAG, strlen (DATA_KEY_TAG)) == 0) { + hash = data; + key = g_strdup (line->str + strlen (DATA_KEY_TAG)); + } else if (strncmp (line->str, DATA_VAL_TAG, strlen (DATA_VAL_TAG)) == 0) { + hash = data; + val = g_strdup (line->str + strlen (DATA_VAL_TAG)); + } else if (strncmp (line->str, SECRET_KEY_TAG, strlen (SECRET_KEY_TAG)) == 0) { + hash = secrets; + key = g_strdup (line->str + strlen (SECRET_KEY_TAG)); + } else if (strncmp (line->str, SECRET_VAL_TAG, strlen (SECRET_VAL_TAG)) == 0) { + hash = secrets; + val = g_strdup (line->str + strlen (SECRET_VAL_TAG)); + } + g_string_truncate (line, 0); + + if (key && val && hash) { + g_hash_table_insert (hash, key, val); + key = NULL; + val = NULL; + success = TRUE; /* Got at least one value */ + } + } + + if (success) { + if (out_data) + *out_data = data; + else + g_hash_table_destroy (data); + + if (out_secrets) + *out_secrets = secrets; + else + g_hash_table_destroy (secrets); + } else { + g_hash_table_destroy (data); + g_hash_table_destroy (secrets); + } + + g_string_free (line, TRUE); + return success; +} + +/** + * nm_vpn_plugin_utils_get_secret_flags: + * @data: hash table containing VPN key/value pair data items + * @secret_name: VPN secret key name for which to retrieve flags for + * @out_flags: (out): on success, the flags associated with @secret_name + * + * Given a VPN secret key name, attempts to find the corresponding flags data + * item in @data. If found, converts the flags data item to + * #NMSettingSecretFlags and returns it. + * + * Returns: %TRUE if the flag data item was found and successfully converted + * to flags, %FALSE if not + **/ +gboolean +nm_vpn_plugin_utils_get_secret_flags (GHashTable *data, + const char *secret_name, + NMSettingSecretFlags *out_flags) +{ + char *flag_name; + const char *val; + unsigned long tmp; + gboolean success = FALSE; + + g_return_val_if_fail (data != NULL, FALSE); + g_return_val_if_fail (secret_name != NULL, FALSE); + g_return_val_if_fail (out_flags != NULL, FALSE); + g_return_val_if_fail (*out_flags == NM_SETTING_SECRET_FLAG_NONE, FALSE); + + flag_name = g_strdup_printf ("%s-flags", secret_name); + + /* Try new flags value first */ + val = g_hash_table_lookup (data, flag_name); + if (val) { + errno = 0; + tmp = strtoul (val, NULL, 10); + if (errno == 0 && tmp <= NM_SETTING_SECRET_FLAGS_ALL) { + *out_flags = (NMSettingSecretFlags) tmp; + success = TRUE; + } + } + + g_free (flag_name); + return success; +} + diff --git a/libnm-glib/nm-vpn-plugin-utils.h b/libnm-glib/nm-vpn-plugin-utils.h new file mode 100644 index 000000000..aab73c4e6 --- /dev/null +++ b/libnm-glib/nm-vpn-plugin-utils.h @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright (C) 2011 Red Hat, Inc. + */ + +#ifndef NM_VPN_PLUGIN_UTILS_H +#define NM_VPN_PLUGIN_UTILS_H + +#include <glib.h> +#include <nm-setting.h> + +G_BEGIN_DECLS + +gboolean nm_vpn_plugin_utils_read_vpn_details (int fd, + GHashTable **out_data, + GHashTable **out_secrets); + +gboolean nm_vpn_plugin_utils_get_secret_flags (GHashTable *data, + const char *secret_name, + NMSettingSecretFlags *out_flags); + +G_END_DECLS + +#endif /* NM_VPN_PLUGIN_UTILS_H */ diff --git a/libnm-glib/nm-vpn-plugin.c b/libnm-glib/nm-vpn-plugin.c index fe7a2b635..4c3813e34 100644 --- a/libnm-glib/nm-vpn-plugin.c +++ b/libnm-glib/nm-vpn-plugin.c @@ -259,10 +259,10 @@ connect_timer_expired (gpointer data) NMVPNPlugin *plugin = NM_VPN_PLUGIN (data); GError *err = NULL; - nm_info ("Connect timer expired, disconnecting."); + g_message ("Connect timer expired, disconnecting."); nm_vpn_plugin_disconnect (plugin, &err); if (err) { - nm_warning ("Disconnect failed: %s", err->message); + g_warning ("Disconnect failed: %s", err->message); g_error_free (err); } @@ -367,11 +367,11 @@ impl_vpn_plugin_connect (NMVPNPlugin *plugin, connection = nm_connection_new_from_hash (properties, error); if (!connection) { - nm_warning ("%s: Invalid connection: '%s' / '%s' invalid: %d", - __func__, - g_type_name (nm_connection_lookup_setting_type_by_quark ((*error)->domain)), - (*error)->message, - (*error)->code); + g_warning ("%s: Invalid connection: '%s' / '%s' invalid: %d", + __func__, + g_type_name (nm_connection_lookup_setting_type_by_quark ((*error)->domain)), + (*error)->message, + (*error)->code); } else { success = nm_vpn_plugin_connect (plugin, connection, error); g_object_unref (connection); @@ -558,7 +558,7 @@ constructor (GType type, err: if (err) { - nm_warning ("%s", err->message); + g_warning ("Failed to initialize VPN plugin: %s", err->message); g_error_free (err); } @@ -633,7 +633,7 @@ dispose (GObject *object) nm_vpn_plugin_disconnect (plugin, &err); if (err) { - nm_warning ("%s", err->message); + g_warning ("Error disconnecting VPN connection: %s", err->message); g_error_free (err); } diff --git a/libnm-glib/nm-wimax-nsp.c b/libnm-glib/nm-wimax-nsp.c new file mode 100644 index 000000000..c33633e97 --- /dev/null +++ b/libnm-glib/nm-wimax-nsp.c @@ -0,0 +1,366 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * libnm_glib -- Access network status & information from glib applications + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright (C) 2011 Red Hat, Inc. + */ + +#include <config.h> +#include <string.h> + +#include <nm-connection.h> +#include <nm-setting-connection.h> +#include <nm-setting-wimax.h> + +#include "nm-wimax-nsp.h" +#include "NetworkManager.h" +#include "nm-types-private.h" +#include "nm-object-private.h" + +G_DEFINE_TYPE (NMWimaxNsp, nm_wimax_nsp, NM_TYPE_OBJECT) + +#define NM_WIMAX_NSP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_WIMAX_NSP, NMWimaxNspPrivate)) + +typedef struct { + gboolean disposed; + DBusGProxy *proxy; + + char *name; + guint32 signal_quality; + NMWimaxNspNetworkType network_type; +} NMWimaxNspPrivate; + +enum { + PROP_0, + PROP_NAME, + PROP_SIGNAL_QUALITY, + PROP_NETWORK_TYPE, + + LAST_PROP +}; + +#define DBUS_PROP_NAME "Name" +#define DBUS_PROP_SIGNAL_QUALITY "SignalQuality" +#define DBUS_PROP_NETWORK_TYPE "NetworkType" + +/** + * nm_wimax_nsp_new: + * @connection: the #DBusGConnection + * @path: the D-Bus object path of the WiMAX NSP + * + * Creates a new #NMWimaxNsp. + * + * Returns: (transfer full): a new WiMAX NSP + **/ +GObject * +nm_wimax_nsp_new (DBusGConnection *connection, const char *path) +{ + g_return_val_if_fail (connection != NULL, NULL); + g_return_val_if_fail (path != NULL, NULL); + + return (GObject *) g_object_new (NM_TYPE_WIMAX_NSP, + NM_OBJECT_DBUS_CONNECTION, connection, + NM_OBJECT_DBUS_PATH, path, + NULL); +} + +/** + * nm_wimax_nsp_get_name: + * @nsp: a #NMWimaxNsp + * + * Gets the name of the wimax NSP + * + * Returns: the name + **/ +const char * +nm_wimax_nsp_get_name (NMWimaxNsp *nsp) +{ + NMWimaxNspPrivate *priv; + + g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), NULL); + + priv = NM_WIMAX_NSP_GET_PRIVATE (nsp); + if (!priv->name) + priv->name = _nm_object_get_string_property (NM_OBJECT (nsp), + NM_DBUS_INTERFACE_WIMAX_NSP, + DBUS_PROP_NAME, + NULL); + + return priv->name; +} + +/** + * nm_wimax_nsp_get_signal_quality: + * @nsp: a #NMWimaxNsp + * + * Gets the WPA signal quality of the wimax NSP. + * + * Returns: the signal quality + **/ +guint32 +nm_wimax_nsp_get_signal_quality (NMWimaxNsp *nsp) +{ + NMWimaxNspPrivate *priv; + + g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), 0); + + priv = NM_WIMAX_NSP_GET_PRIVATE (nsp); + if (!priv->signal_quality) { + priv->signal_quality = _nm_object_get_uint_property (NM_OBJECT (nsp), + NM_DBUS_INTERFACE_WIMAX_NSP, + DBUS_PROP_SIGNAL_QUALITY, + NULL); + } + + return priv->signal_quality; +} + +/** + * nm_wimax_nsp_get_network_type: + * @nsp: a #NMWimaxNsp + * + * Gets the network type of the wimax NSP. + * + * Returns: the network type + **/ +NMWimaxNspNetworkType +nm_wimax_nsp_get_network_type (NMWimaxNsp *nsp) +{ + NMWimaxNspPrivate *priv; + + g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN); + + priv = NM_WIMAX_NSP_GET_PRIVATE (nsp); + if (!priv->network_type) { + priv->network_type = _nm_object_get_uint_property (NM_OBJECT (nsp), + NM_DBUS_INTERFACE_WIMAX_NSP, + DBUS_PROP_NETWORK_TYPE, + NULL); + } + + return priv->network_type; +} + +/** + * nm_wimax_nsp_filter_connections: + * @nsp: an #NMWimaxNsp to filter connections for + * @connections: a list of #NMConnection objects to filter + * + * Filters a given list of connections for a given #NMWimaxNsp object and + * return connections which may be activated with the access point. Any + * returned connections will match the @nsp's network name and other attributes. + * + * Returns: (transfer container) (element-type NetworkManager.Connection): a + * list of #NMConnection objects that could be activated with the given @nsp. + * The elements of the list are owned by their creator and should not be freed + * by the caller, but the returned list itself is owned by the caller and should + * be freed with g_slist_free() when it is no longer required. + **/ +GSList * +nm_wimax_nsp_filter_connections (NMWimaxNsp *nsp, const GSList *connections) +{ + GSList *filtered = NULL; + const GSList *iter; + + for (iter = connections; iter; iter = g_slist_next (iter)) { + NMConnection *candidate = NM_CONNECTION (iter->data); + NMSettingConnection *s_con; + NMSettingWimax *s_wimax; + const char *ctype; + const char *nsp_name; + const char *setting_name; + + s_con = (NMSettingConnection *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION); + g_assert (s_con); + ctype = nm_setting_connection_get_connection_type (s_con); + if (strcmp (ctype, NM_SETTING_WIMAX_SETTING_NAME) != 0) + continue; + + s_wimax = (NMSettingWimax *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIMAX); + if (!s_wimax) + continue; + + setting_name = nm_setting_wimax_get_network_name (s_wimax); + if (!setting_name) + continue; + + nsp_name = nm_wimax_nsp_get_name (nsp); + g_warn_if_fail (nsp_name != NULL); + if (g_strcmp0 (nsp_name, setting_name) != 0) + continue; + + /* Connection applies to this device */ + filtered = g_slist_prepend (filtered, candidate); + } + + return g_slist_reverse (filtered); +} + +/************************************************************/ + +static void +nm_wimax_nsp_init (NMWimaxNsp *nsp) +{ +} + +static void +dispose (GObject *object) +{ + NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (object); + + if (priv->disposed) { + G_OBJECT_CLASS (nm_wimax_nsp_parent_class)->dispose (object); + return; + } + + priv->disposed = TRUE; + + g_object_unref (priv->proxy); + + G_OBJECT_CLASS (nm_wimax_nsp_parent_class)->dispose (object); +} + +static void +finalize (GObject *object) +{ + NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (object); + + g_free (priv->name); + + G_OBJECT_CLASS (nm_wimax_nsp_parent_class)->finalize (object); +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NMWimaxNsp *nsp = NM_WIMAX_NSP (object); + + switch (prop_id) { + case PROP_NAME: + g_value_set_string (value, nm_wimax_nsp_get_name (nsp)); + break; + case PROP_SIGNAL_QUALITY: + g_value_set_uint (value, nm_wimax_nsp_get_signal_quality (nsp)); + break; + case PROP_NETWORK_TYPE: + g_value_set_uint (value, nm_wimax_nsp_get_network_type (nsp)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +register_for_property_changed (NMWimaxNsp *nsp) +{ + NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (nsp); + const NMPropertiesChangedInfo property_changed_info[] = { + { NM_WIMAX_NSP_SIGNAL_QUALITY, _nm_object_demarshal_generic, &priv->signal_quality }, + { NULL }, + }; + + _nm_object_handle_properties_changed (NM_OBJECT (nsp), + priv->proxy, + property_changed_info); +} + +static GObject* +constructor (GType type, + guint n_construct_params, + GObjectConstructParam *construct_params) +{ + NMObject *object; + NMWimaxNspPrivate *priv; + + object = (NMObject *) G_OBJECT_CLASS (nm_wimax_nsp_parent_class)->constructor (type, + n_construct_params, + construct_params); + if (!object) + return NULL; + + priv = NM_WIMAX_NSP_GET_PRIVATE (object); + + priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (object), + NM_DBUS_SERVICE, + nm_object_get_path (object), + NM_DBUS_INTERFACE_WIMAX_NSP); + + register_for_property_changed (NM_WIMAX_NSP (object)); + + return G_OBJECT (object); +} + + +static void +nm_wimax_nsp_class_init (NMWimaxNspClass *nsp_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (nsp_class); + + g_type_class_add_private (nsp_class, sizeof (NMWimaxNspPrivate)); + + /* virtual methods */ + object_class->constructor = constructor; + object_class->get_property = get_property; + object_class->dispose = dispose; + object_class->finalize = finalize; + + /* properties */ + + /** + * NMWimaxNsp:name: + * + * The name of the WiMAX NSP. + **/ + g_object_class_install_property + (object_class, PROP_NAME, + g_param_spec_string (NM_WIMAX_NSP_NAME, + "Name", + "Name", + NULL, + G_PARAM_READABLE)); + + /** + * NMWimaxNsp:signal-quality: + * + * The signal quality of the WiMAX NSP. + **/ + g_object_class_install_property + (object_class, PROP_SIGNAL_QUALITY, + g_param_spec_uint (NM_WIMAX_NSP_SIGNAL_QUALITY, + "Signal Quality", + "Signal Quality", + 0, 100, 0, + G_PARAM_READABLE)); + + /** + * NMWimaxNsp:network-type: + * + * The network type of the WiMAX NSP. + **/ + g_object_class_install_property + (object_class, PROP_NETWORK_TYPE, + g_param_spec_uint (NM_WIMAX_NSP_NETWORK_TYPE, + "Network Type", + "Network Type", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE)); +} diff --git a/libnm-glib/nm-wimax-nsp.h b/libnm-glib/nm-wimax-nsp.h new file mode 100644 index 000000000..07736ae4e --- /dev/null +++ b/libnm-glib/nm-wimax-nsp.h @@ -0,0 +1,81 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * libnm_glib -- Access network status & information from glib applications + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2009 Novell, Inc. + */ + +#ifndef NM_WIMAX_NSP_H +#define NM_WIMAX_NSP_H + +#include <glib.h> +#include <glib-object.h> +#include <NetworkManager.h> +#include "nm-object.h" + +G_BEGIN_DECLS + +#define NM_TYPE_WIMAX_NSP (nm_wimax_nsp_get_type ()) +#define NM_WIMAX_NSP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIMAX_NSP, NMWimaxNsp)) +#define NM_WIMAX_NSP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIMAX_NSP, NMWimaxNspClass)) +#define NM_IS_WIMAX_NSP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIMAX_NSP)) +#define NM_IS_WIMAX_NSP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_WIMAX_NSP)) +#define NM_WIMAX_NSP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIMAX_NSP, NMWimaxNspClass)) + +#define NM_WIMAX_NSP_NAME "name" +#define NM_WIMAX_NSP_SIGNAL_QUALITY "signal-quality" +#define NM_WIMAX_NSP_NETWORK_TYPE "network-type" + +typedef enum { + NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN = 0, + NM_WIMAX_NSP_NETWORK_TYPE_HOME = 1, + NM_WIMAX_NSP_NETWORK_TYPE_PARTNER = 2, + NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER = 3 +} NMWimaxNspNetworkType; + +typedef struct { + NMObject parent; +} NMWimaxNsp; + +typedef struct { + NMObjectClass parent; + + /* Padding for future expansion */ + void (*_reserved1) (void); + void (*_reserved2) (void); + void (*_reserved3) (void); + void (*_reserved4) (void); + void (*_reserved5) (void); + void (*_reserved6) (void); +} NMWimaxNspClass; + +GType nm_wimax_nsp_get_type (void); + +GObject *nm_wimax_nsp_new (DBusGConnection *connection, const char *path); + +const char * nm_wimax_nsp_get_name (NMWimaxNsp *nsp); +guint32 nm_wimax_nsp_get_signal_quality (NMWimaxNsp *nsp); +NMWimaxNspNetworkType nm_wimax_nsp_get_network_type (NMWimaxNsp *nsp); + +GSList * nm_wimax_nsp_filter_connections (NMWimaxNsp *nsp, + const GSList *connections); + +G_END_DECLS + +#endif /* NM_WIMAX_NSP_H */ diff --git a/libnm-glib/tests/Makefile.am b/libnm-glib/tests/Makefile.am new file mode 100644 index 000000000..06aee7125 --- /dev/null +++ b/libnm-glib/tests/Makefile.am @@ -0,0 +1,35 @@ +INCLUDES = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/libnm-util \ + -I$(top_srcdir)/libnm-glib + +noinst_PROGRAMS = test-remote-settings-client + +####### remote settings client test ####### + +test_remote_settings_client_SOURCES = \ + test-remote-settings-client.c + +test_remote_settings_client_CPPFLAGS = \ + $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) + +test_remote_settings_client_LDADD = \ + $(top_builddir)/libnm-util/libnm-util.la \ + $(top_builddir)/libnm-glib/libnm-glib-test.la \ + $(GLIB_LIBS) \ + $(DBUS_LIBS) + +########################################### + +TEST_RSS_BIN = test-remote-settings-service.py + +EXTRA_DIST = $(TEST_RSS_BIN) + +if WITH_TESTS + +check-local: test-remote-settings-client + $(abs_builddir)/test-remote-settings-client $(abs_srcdir) $(TEST_RSS_BIN) + +endif + diff --git a/libnm-glib/tests/Makefile.in b/libnm-glib/tests/Makefile.in new file mode 100644 index 000000000..96c0a3cde --- /dev/null +++ b/libnm-glib/tests/Makefile.in @@ -0,0 +1,634 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = test-remote-settings-client$(EXEEXT) +subdir = libnm-glib/tests +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ + $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/introspection.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnl-check.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) +am_test_remote_settings_client_OBJECTS = test_remote_settings_client-test-remote-settings-client.$(OBJEXT) +test_remote_settings_client_OBJECTS = \ + $(am_test_remote_settings_client_OBJECTS) +am__DEPENDENCIES_1 = +test_remote_settings_client_DEPENDENCIES = \ + $(top_builddir)/libnm-util/libnm-util.la \ + $(top_builddir)/libnm-glib/libnm-glib-test.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(test_remote_settings_client_SOURCES) +DIST_SOURCES = $(test_remote_settings_client_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DHCLIENT_PATH = @DHCLIENT_PATH@ +DHCLIENT_VERSION = @DHCLIENT_VERSION@ +DHCPCD_PATH = @DHCPCD_PATH@ +DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GIO_CFLAGS = @GIO_CFLAGS@ +GIO_LIBS = @GIO_LIBS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GMODULE_CFLAGS = @GMODULE_CFLAGS@ +GMODULE_LIBS = @GMODULE_LIBS@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ +GNUTLS_LIBS = @GNUTLS_LIBS@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ +INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ +INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ +INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ +INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ +INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ +INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ +INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ +IPTABLES_PATH = @IPTABLES_PATH@ +IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ +IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ +KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDL = @LIBDL@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBM = @LIBM@ +LIBNL_CFLAGS = @LIBNL_CFLAGS@ +LIBNL_LIBS = @LIBNL_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ +NM_MICRO_VERSION = @NM_MICRO_VERSION@ +NM_MINOR_VERSION = @NM_MINOR_VERSION@ +NM_VERSION = @NM_VERSION@ +NSS_CFLAGS = @NSS_CFLAGS@ +NSS_LIBS = @NSS_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_PATH = @PKGCONFIG_PATH@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POLKIT_CFLAGS = @POLKIT_CFLAGS@ +POLKIT_LIBS = @POLKIT_LIBS@ +POSUB = @POSUB@ +PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +RANLIB = @RANLIB@ +RESOLVCONF_PATH = @RESOLVCONF_PATH@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ +UDEV_BASE_DIR = @UDEV_BASE_DIR@ +USE_NLS = @USE_NLS@ +UUID_CFLAGS = @UUID_CFLAGS@ +UUID_LIBS = @UUID_LIBS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +systemdsystemunitdir = @systemdsystemunitdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +INCLUDES = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/libnm-util \ + -I$(top_srcdir)/libnm-glib + + +####### remote settings client test ####### +test_remote_settings_client_SOURCES = \ + test-remote-settings-client.c + +test_remote_settings_client_CPPFLAGS = \ + $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) + +test_remote_settings_client_LDADD = \ + $(top_builddir)/libnm-util/libnm-util.la \ + $(top_builddir)/libnm-glib/libnm-glib-test.la \ + $(GLIB_LIBS) \ + $(DBUS_LIBS) + + +########################################### +TEST_RSS_BIN = test-remote-settings-service.py +EXTRA_DIST = $(TEST_RSS_BIN) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libnm-glib/tests/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu libnm-glib/tests/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +test-remote-settings-client$(EXEEXT): $(test_remote_settings_client_OBJECTS) $(test_remote_settings_client_DEPENDENCIES) + @rm -f test-remote-settings-client$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_remote_settings_client_OBJECTS) $(test_remote_settings_client_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_remote_settings_client-test-remote-settings-client.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +test_remote_settings_client-test-remote-settings-client.o: test-remote-settings-client.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_remote_settings_client_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_remote_settings_client-test-remote-settings-client.o -MD -MP -MF $(DEPDIR)/test_remote_settings_client-test-remote-settings-client.Tpo -c -o test_remote_settings_client-test-remote-settings-client.o `test -f 'test-remote-settings-client.c' || echo '$(srcdir)/'`test-remote-settings-client.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remote_settings_client-test-remote-settings-client.Tpo $(DEPDIR)/test_remote_settings_client-test-remote-settings-client.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-remote-settings-client.c' object='test_remote_settings_client-test-remote-settings-client.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_remote_settings_client_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_remote_settings_client-test-remote-settings-client.o `test -f 'test-remote-settings-client.c' || echo '$(srcdir)/'`test-remote-settings-client.c + +test_remote_settings_client-test-remote-settings-client.obj: test-remote-settings-client.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_remote_settings_client_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_remote_settings_client-test-remote-settings-client.obj -MD -MP -MF $(DEPDIR)/test_remote_settings_client-test-remote-settings-client.Tpo -c -o test_remote_settings_client-test-remote-settings-client.obj `if test -f 'test-remote-settings-client.c'; then $(CYGPATH_W) 'test-remote-settings-client.c'; else $(CYGPATH_W) '$(srcdir)/test-remote-settings-client.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remote_settings_client-test-remote-settings-client.Tpo $(DEPDIR)/test_remote_settings_client-test-remote-settings-client.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-remote-settings-client.c' object='test_remote_settings_client-test-remote-settings-client.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_remote_settings_client_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_remote_settings_client-test-remote-settings-client.obj `if test -f 'test-remote-settings-client.c'; then $(CYGPATH_W) 'test-remote-settings-client.c'; else $(CYGPATH_W) '$(srcdir)/test-remote-settings-client.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +@WITH_TESTS_FALSE@check-local: +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am check-local clean \ + clean-generic clean-libtool clean-noinstPROGRAMS ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am + + +@WITH_TESTS_TRUE@check-local: test-remote-settings-client +@WITH_TESTS_TRUE@ $(abs_builddir)/test-remote-settings-client $(abs_srcdir) $(TEST_RSS_BIN) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libnm-glib/tests/test-remote-settings-client.c b/libnm-glib/tests/test-remote-settings-client.c new file mode 100644 index 000000000..ad62075d4 --- /dev/null +++ b/libnm-glib/tests/test-remote-settings-client.c @@ -0,0 +1,406 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2010 - 2011 Red Hat, Inc. + * + */ + +#include <dbus/dbus.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> +#include <glib.h> +#include <string.h> +#include <sys/types.h> +#include <signal.h> + +#include <NetworkManager.h> + +#include <nm-setting-connection.h> +#include <nm-setting-wired.h> +#include <nm-utils.h> + +#include "nm-remote-settings.h" + +static GPid spid = 0; +static NMRemoteSettings *settings = NULL; +DBusGConnection *bus = NULL; +NMRemoteConnection *remote = NULL; + +/*******************************************************************/ + +static void +cleanup (void) +{ + if (settings) + g_object_unref (settings); + kill (spid, SIGTERM); +} + +#define test_assert(condition) \ +do { \ + if (!G_LIKELY (condition)) \ + cleanup (); \ + g_assert (condition); \ +} while (0) + +/*******************************************************************/ + +static void +add_cb (NMRemoteSettings *s, + NMRemoteConnection *connection, + GError *error, + gpointer user_data) +{ + if (error) + g_warning ("Add error: %s", error->message); + + *((gboolean *) user_data) = TRUE; + remote = connection; +} + +#define TEST_CON_ID "blahblahblah" + +static void +test_add_connection (void) +{ + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + char *uuid; + gboolean success; + time_t start, now; + gboolean done = FALSE; + + connection = nm_connection_new (); + + s_con = (NMSettingConnection *) nm_setting_connection_new (); + uuid = nm_utils_uuid_generate (); + g_object_set (G_OBJECT (s_con), + NM_SETTING_CONNECTION_ID, TEST_CON_ID, + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, + NULL); + g_free (uuid); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + s_wired = (NMSettingWired *) nm_setting_wired_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wired)); + + success = nm_remote_settings_add_connection (settings, + connection, + add_cb, + &done); + test_assert (success == TRUE); + + start = time (NULL); + do { + now = time (NULL); + g_main_context_iteration (NULL, FALSE); + } while ((done == FALSE) && (now - start < 5)); + test_assert (done == TRUE); + test_assert (remote != NULL); + + /* Make sure the connection is the same as what we added */ + test_assert (nm_connection_compare (connection, + NM_CONNECTION (remote), + NM_SETTING_COMPARE_FLAG_EXACT) == TRUE); +} + +/*******************************************************************/ + +static void +set_visible_cb (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer user_data) +{ + GError *error = NULL; + gboolean success; + + success = dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + if (!success) + g_warning ("Failed to change connection visibility: %s", error->message); + test_assert (success == TRUE); + test_assert (error == NULL); +} + +static void +invis_removed_cb (NMRemoteConnection *connection, gboolean *done) +{ + *done = TRUE; +} + +static void +invis_has_settings_cb (NMSetting *setting, + const char *key, + const GValue *value, + GParamFlags flags, + gpointer user_data) +{ + *((gboolean *) user_data) = TRUE; +} + +static void +test_make_invisible (void) +{ + time_t start, now; + GSList *list, *iter; + DBusGProxy *proxy; + gboolean done = FALSE, has_settings = FALSE; + char *path; + + test_assert (remote != NULL); + + /* Listen for the remove event when the connection becomes invisible */ + g_signal_connect (remote, "removed", G_CALLBACK (invis_removed_cb), &done); + + path = g_strdup (nm_connection_get_path (NM_CONNECTION (remote))); + proxy = dbus_g_proxy_new_for_name (bus, + NM_DBUS_SERVICE, + path, + NM_DBUS_IFACE_SETTINGS_CONNECTION); + test_assert (proxy != NULL); + + /* Bypass the NMRemoteSettings object so we can test it independently */ + dbus_g_proxy_begin_call (proxy, "SetVisible", set_visible_cb, NULL, NULL, + G_TYPE_BOOLEAN, FALSE, G_TYPE_INVALID); + + /* Wait for the connection to be removed */ + start = time (NULL); + do { + now = time (NULL); + g_main_context_iteration (NULL, FALSE); + } while ((done == FALSE) && (now - start < 5)); + test_assert (done == TRUE); + + /* Ensure NMRemoteSettings no longer has the connection */ + list = nm_remote_settings_list_connections (settings); + for (iter = list; iter; iter = g_slist_next (iter)) { + NMConnection *candidate = NM_CONNECTION (iter->data); + + test_assert ((gpointer) remote != (gpointer) candidate); + test_assert (strcmp (path, nm_connection_get_path (candidate)) != 0); + } + + /* And ensure the invisible connection no longer has any settings */ + nm_connection_for_each_setting_value (NM_CONNECTION (remote), + invis_has_settings_cb, + &has_settings); + test_assert (has_settings == FALSE); + + g_free (path); + g_object_unref (proxy); +} + +/*******************************************************************/ + +static void +vis_new_connection_cb (NMRemoteSettings *foo, + NMRemoteConnection *connection, + NMRemoteConnection **new) +{ + *new = connection; +} + +static void +test_make_visible (void) +{ + time_t start, now; + GSList *list, *iter; + DBusGProxy *proxy; + gboolean found = FALSE; + char *path; + NMRemoteConnection *new = NULL; + + test_assert (remote != NULL); + + /* Wait for the new-connection signal when the connection is visible again */ + g_signal_connect (settings, NM_REMOTE_SETTINGS_NEW_CONNECTION, + G_CALLBACK (vis_new_connection_cb), &new); + + path = g_strdup (nm_connection_get_path (NM_CONNECTION (remote))); + proxy = dbus_g_proxy_new_for_name (bus, + NM_DBUS_SERVICE, + path, + NM_DBUS_IFACE_SETTINGS_CONNECTION); + test_assert (proxy != NULL); + + /* Bypass the NMRemoteSettings object so we can test it independently */ + dbus_g_proxy_begin_call (proxy, "SetVisible", set_visible_cb, NULL, NULL, + G_TYPE_BOOLEAN, TRUE, G_TYPE_INVALID); + + + /* Wait for the settings service to announce the connection again */ + start = time (NULL); + do { + now = time (NULL); + g_main_context_iteration (NULL, FALSE); + } while ((new == NULL) && (now - start < 5)); + + /* Ensure the new connection is the same as the one we made visible again */ + test_assert (new == remote); + + /* Ensure NMRemoteSettings has the connection */ + list = nm_remote_settings_list_connections (settings); + for (iter = list; iter; iter = g_slist_next (iter)) { + NMConnection *candidate = NM_CONNECTION (iter->data); + + if ((gpointer) remote == (gpointer) candidate) { + test_assert (strcmp (path, nm_connection_get_path (candidate)) == 0); + test_assert (strcmp (TEST_CON_ID, nm_connection_get_id (candidate)) == 0); + found = TRUE; + break; + } + } + test_assert (found == TRUE); + + g_free (path); + g_object_unref (proxy); +} + +/*******************************************************************/ + +static void +deleted_cb (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer user_data) +{ + GError *error = NULL; + gboolean success; + + success = dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + if (!success) + g_warning ("Failed to delete connection: %s", error->message); + test_assert (success == TRUE); + test_assert (error == NULL); +} + +static void +removed_cb (NMRemoteConnection *connection, gboolean *done) +{ + *done = TRUE; +} + +static void +test_remove_connection (void) +{ + NMRemoteConnection *connection; + time_t start, now; + GSList *list, *iter; + DBusGProxy *proxy; + gboolean done = FALSE; + char *path; + + /* Find a connection to delete */ + list = nm_remote_settings_list_connections (settings); + test_assert (g_slist_length (list) > 0); + + connection = NM_REMOTE_CONNECTION (list->data); + path = g_strdup (nm_connection_get_path (NM_CONNECTION (connection))); + g_signal_connect (connection, "removed", G_CALLBACK (removed_cb), &done); + + proxy = dbus_g_proxy_new_for_name (bus, + NM_DBUS_SERVICE, + path, + NM_DBUS_IFACE_SETTINGS_CONNECTION); + test_assert (proxy != NULL); + + /* Bypass the NMRemoteSettings object so we can test it independently */ + dbus_g_proxy_begin_call (proxy, "Delete", deleted_cb, NULL, NULL, G_TYPE_INVALID); + + start = time (NULL); + do { + now = time (NULL); + g_main_context_iteration (NULL, FALSE); + } while ((done == FALSE) && (now - start < 5)); + test_assert (done == TRUE); + + /* Ensure NMRemoteSettings no longer has the connection */ + list = nm_remote_settings_list_connections (settings); + for (iter = list; iter; iter = g_slist_next (iter)) { + NMConnection *candidate = NM_CONNECTION (iter->data); + + test_assert ((gpointer) connection != (gpointer) candidate); + test_assert (strcmp (path, nm_connection_get_path (candidate)) != 0); + } + + g_free (path); + g_object_unref (proxy); +} + +/*******************************************************************/ + +#if GLIB_CHECK_VERSION(2,25,12) +typedef GTestFixtureFunc TCFunc; +#else +typedef void (*TCFunc)(void); +#endif + +#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL) + +int main (int argc, char **argv) +{ + GTestSuite *suite; + char *service_argv[3] = { NULL, NULL, NULL }; + int ret; + GError *error = NULL; + int i = 100; + + g_assert (argc == 3); + + g_type_init (); + + g_test_init (&argc, &argv, NULL); + + bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (!bus) { + g_warning ("Error connecting to D-Bus: %s", error->message); + g_assert (error == NULL); + } + + service_argv[0] = g_strdup_printf ("%s/%s", argv[1], argv[2]); + if (!g_spawn_async (argv[1], service_argv, NULL, 0, NULL, NULL, &spid, &error)) { + g_warning ("Error spawning %s: %s", argv[2], error->message); + g_assert (error == NULL); + } + + /* Wait until the service is registered on the bus */ + while (i > 0) { + g_usleep (G_USEC_PER_SEC / 50); + if (dbus_bus_name_has_owner (dbus_g_connection_get_connection (bus), + "org.freedesktop.NetworkManager", + NULL)) + break; + i--; + } + test_assert (i > 0); + + settings = nm_remote_settings_new (bus); + test_assert (settings != NULL); + + suite = g_test_get_root (); + + g_test_suite_add (suite, TESTCASE (test_add_connection, NULL)); + g_test_suite_add (suite, TESTCASE (test_make_invisible, NULL)); + g_test_suite_add (suite, TESTCASE (test_make_visible, NULL)); + g_test_suite_add (suite, TESTCASE (test_remove_connection, NULL)); + + ret = g_test_run (); + + cleanup (); + + return ret; +} + diff --git a/libnm-glib/tests/test-remote-settings-service.py b/libnm-glib/tests/test-remote-settings-service.py new file mode 100755 index 000000000..865420055 --- /dev/null +++ b/libnm-glib/tests/test-remote-settings-service.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python +# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + +import glib +import gobject +import sys +import dbus +import dbus.service +import dbus.mainloop.glib + +IFACE_SETTINGS = 'org.freedesktop.NetworkManager.Settings' +IFACE_CONNECTION = 'org.freedesktop.NetworkManager.Settings.Connection' +IFACE_DBUS = 'org.freedesktop.DBus' + +class UnknownInterfaceException(dbus.DBusException): + _dbus_error_name = IFACE_DBUS + '.UnknownInterface' + +class UnknownPropertyException(dbus.DBusException): + _dbus_error_name = IFACE_DBUS + '.UnknownProperty' + +class PermissionDeniedException(dbus.DBusException): + _dbus_error_name = IFACE_SETTINGS + '.PermissionDenied' + +mainloop = gobject.MainLoop() + +class Connection(dbus.service.Object): + def __init__(self, bus, object_path, settings, remove_func): + dbus.service.Object.__init__(self, bus, object_path) + self.path = object_path + self.settings = settings + self.remove_func = remove_func + self.visible = True + + @dbus.service.method(dbus_interface=IFACE_CONNECTION, in_signature='', out_signature='a{sa{sv}}') + def GetSettings(self): + if not self.visible: + raise PermissionDeniedException() + return self.settings + + @dbus.service.method(dbus_interface=IFACE_CONNECTION, in_signature='b', out_signature='') + def SetVisible(self, vis): + self.visible = vis + self.Updated() + + @dbus.service.method(dbus_interface=IFACE_CONNECTION, in_signature='', out_signature='') + def Delete(self): + self.remove_func(self) + self.Removed() + + @dbus.service.signal(IFACE_CONNECTION, signature='') + def Removed(self): + pass + + @dbus.service.signal(IFACE_CONNECTION, signature='') + def Updated(self): + pass + +class Settings(dbus.service.Object): + def __init__(self, bus, object_path): + dbus.service.Object.__init__(self, bus, object_path) + self.connections = {} + self.bus = bus + self.counter = 1 + self.props = {} + self.props['Hostname'] = "foobar.baz" + self.props['CanModify'] = True + + @dbus.service.method(dbus_interface=IFACE_SETTINGS, in_signature='', out_signature='ao') + def ListConnections(self): + connections = [] + return self.connections.keys() + + @dbus.service.method(dbus_interface=IFACE_SETTINGS, in_signature='a{sa{sv}}', out_signature='o') + def AddConnection(self, settings): + path = "/org/freedesktop/NetworkManager/Settings/Connection/%d" % self.counter + self.counter = self.counter + 1 + self.connections[path] = Connection(self.bus, path, settings, self.delete_connection) + print "Added connection %s" % path + return path + + def delete_connection(self, connection): + del self.connections[connection.path] + + @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}') + def GetAll(self, iface): + if iface != IFACE_SETTINGS: + raise UnknownInterfaceException() + return self.props + + @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='ss', out_signature='v') + def Get(self, iface, name): + if iface != IFACE_SETTINGS: + raise UnknownInterfaceException() + if not name in self.props.keys(): + raise UnknownPropertyException() + return self.props[name] + + @dbus.service.signal(IFACE_SETTINGS, signature='o') + def NewConnection(self, path): + pass + + @dbus.service.method(IFACE_SETTINGS, in_signature='', out_signature='') + def Quit(self): + mainloop.quit() + +def quit_cb(user_data): + mainloop.quit() + +def main(): + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + bus = dbus.SessionBus() + obj = Settings(bus, "/org/freedesktop/NetworkManager/Settings") + if not bus.request_name("org.freedesktop.NetworkManager"): + sys.exit(1) + + print "Service started" + + gobject.timeout_add_seconds(20, quit_cb, None) + + try: + mainloop.run() + except Exception, e: + pass + + print "Service stopped" + sys.exit(0) + +if __name__ == '__main__': + main() + |