diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2006-01-16 06:42:46 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2006-01-16 06:42:46 +0800 |
commit | 73e8920c461a5403f8f0ad1e9754910c3089ef2f (patch) | |
tree | 2f50b0c5f734542062889d54a53e5cbe9070fa6b | |
parent | 2097f11220e25f83dda2026d07cc66e7a0a31544 (diff) | |
download | gsoc2013-epiphany-73e8920c461a5403f8f0ad1e9754910c3089ef2f.tar gsoc2013-epiphany-73e8920c461a5403f8f0ad1e9754910c3089ef2f.tar.gz gsoc2013-epiphany-73e8920c461a5403f8f0ad1e9754910c3089ef2f.tar.bz2 gsoc2013-epiphany-73e8920c461a5403f8f0ad1e9754910c3089ef2f.tar.lz gsoc2013-epiphany-73e8920c461a5403f8f0ad1e9754910c3089ef2f.tar.xz gsoc2013-epiphany-73e8920c461a5403f8f0ad1e9754910c3089ef2f.tar.zst gsoc2013-epiphany-73e8920c461a5403f8f0ad1e9754910c3089ef2f.zip |
Add NetworkManager magic for connection status autodetection. Defaults to
2006-01-15 Christian Persch <chpe@cvs.gnome.org>
* configure.ac:
* embed/mozilla/Makefile.am:
* embed/mozilla/mozilla-embed-single.cpp:
* src/Makefile.am:
Add NetworkManager magic for connection status autodetection.
Defaults to disabled because I'm not very happy with the libnm-glib
implementation. Oh, and it may crash on startup, too.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | configure.ac | 23 | ||||
-rw-r--r-- | embed/mozilla/Makefile.am | 5 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 104 | ||||
-rw-r--r-- | src/Makefile.am | 7 |
5 files changed, 141 insertions, 9 deletions
@@ -1,3 +1,14 @@ +2006-01-15 Christian Persch <chpe@cvs.gnome.org> + + * configure.ac: + * embed/mozilla/Makefile.am: + * embed/mozilla/mozilla-embed-single.cpp: + * src/Makefile.am: + + Add NetworkManager magic for connection status autodetection. + Defaults to disabled because I'm not very happy with the libnm-glib + implementation. Oh, and it may crash on startup, too. + 2006-01-15 Jean-François Rameau <jframeau@cvs.gnome.org> * lib/ephy-adblock.h: diff --git a/configure.ac b/configure.ac index 074089a5e..a1bb14fbe 100644 --- a/configure.ac +++ b/configure.ac @@ -557,6 +557,29 @@ fi AM_CONDITIONAL([ENABLE_CERTIFICATE_MANAGER],[test "$enable_certificate_manager" = "yes"]) +# NetworkManager + +AC_MSG_CHECKING([whether to enable NetworkManager support]) +AC_ARG_ENABLE([network-manager], + AS_HELP_STRING([--enable-network-manager],[Whether to enable automatic network status with NetworkManager (default: disabled]), + [],[enable_network_manager=no]) +AC_MSG_RESULT([$enable_network_manager]) + +if test "x$enable_network_manager" != "xno"; then + NETWORKMANAGER_REQUIRED=0.5.0 + + PKG_CHECK_MODULES([NETWORK_MANAGER],[libnm_glib >= $NETWORKMANAGER_REQUIRED], + [enable_network_manager=yes],[enable_network_manager=no]) + AC_SUBST([NETWORK_MANAGER_CFLAGS]) + AC_SUBST([NETWORK_MANAGER_LIBS]) +fi + +if test "x$enable_network_manager" = "xyes"; then + AC_DEFINE([ENABLE_NETWORK_MANAGER],[1],[Define for NetworkManager support]) +fi + +AM_CONDITIONAL([ENABLE_NETWORK_MANAGER],[test "x$enable_network_manager" = "xyes"]) + # ******************************* # Add warning flags # ******************************* diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am index f5504128b..291cbd069 100644 --- a/embed/mozilla/Makefile.am +++ b/embed/mozilla/Makefile.am @@ -148,3 +148,8 @@ libephymozillaembed_la_CXXFLAGS = \ $(GECKO_CFLAGS) \ $(DEPENDENCIES_CFLAGS) \ $(AM_CXXFLAGS) + +if ENABLE_NETWORK_MANAGER +libephymozillaembed_la_CXXFLAGS += \ + $(NETWORK_MANAGER_CFLAGS) +endif diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index 05cdfbf18..d542dc20c 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -1,7 +1,7 @@ /* vim:set ts=8 noet sw=8: * Copyright (C) 2000-2004 Marco Pesenti Gritti * Copyright (C) 2003 Robert Marcano - * Copyright (C) 2003, 2004 Christian Persch + * Copyright (C) 2003, 2004, 2005, 2006 Christian Persch * Copyright (C) 2005 Crispin Flowerday * * This program is free software; you can redistribute it and/or modify @@ -102,8 +102,17 @@ #include <nsIIDNService.h> #endif /* ALLOW_PRIVATE_API */ +#ifdef HAVE_GECKO_1_8 +#include <nsIStyleSheetService.h> +#include "EphyUtils.h" +#endif + #include <stdlib.h> +#ifdef ENABLE_NETWORK_MANAGER +#include <libnm_glib.h> +#endif + #define MOZILLA_PROFILE_DIR "/mozilla" #define MOZILLA_PROFILE_NAME "epiphany" #define MOZILLA_PROFILE_FILE "prefs.js" @@ -120,6 +129,11 @@ struct MozillaEmbedSinglePrivate EphySingle *mSingleObserver; +#ifdef ENABLE_NETWORK_MANAGER + libnm_glib_ctx *nm_context; + guint nm_callback_id; +#endif + guint online : 1; }; @@ -522,6 +536,62 @@ mozilla_init_observer (MozillaEmbedSingle *single) } } +#ifdef ENABLE_NETWORK_MANAGER + +static void +network_state_cb (libnm_glib_ctx *context, + gpointer data) +{ + EphyEmbedSingle *single = EPHY_EMBED_SINGLE (data); + libnm_glib_state state; + + state = libnm_glib_get_network_state (context); + + LOG ("Network state: %d\n", state); + + switch (state) + { + case LIBNM_NO_DBUS: + case LIBNM_NO_NETWORKMANAGER: + case LIBNM_INVALID_CONTEXT: + /* do nothing */ + break; + case LIBNM_NO_NETWORK_CONNECTION: + ephy_embed_single_set_network_status (single, FALSE); + break; + case LIBNM_ACTIVE_NETWORK_CONNECTION: + ephy_embed_single_set_network_status (single, TRUE); + break; + } +} + +static void +mozilla_init_network_manager (MozillaEmbedSingle *single) +{ + MozillaEmbedSinglePrivate *priv = single->priv; + + priv->nm_context = libnm_glib_init (); + if (priv->nm_context == NULL) + { + g_warning ("Could not initialise NetworkManager, connection status will not be managed!\n"); + return; + } + + priv->nm_callback_id = libnm_glib_register_callback (priv->nm_context, + network_state_cb, + single, NULL); + if (priv->nm_callback_id == 0) + { + libnm_glib_shutdown (priv->nm_context); + priv->nm_context = NULL; + + g_warning ("Could not connect to NetworkManager, connection status will not be managed!\n"); + return; + } +} + +#endif /* ENABLE_NETWORK_MANAGER */ + static gboolean init_services (MozillaEmbedSingle *single) { @@ -544,6 +614,8 @@ init_services (MozillaEmbedSingle *single) /* Fire up the beast */ gtk_moz_embed_push_startup (); + mozilla_register_components (); + /* Until gtkmozembed does this itself */ mozilla_init_chrome (); @@ -563,10 +635,12 @@ init_services (MozillaEmbedSingle *single) mozilla_notifiers_init (); STOP_PROFILER ("Mozilla prefs notifiers") - mozilla_register_components (); - mozilla_init_observer (single); +#ifdef ENABLE_NETWORK_MANAGER + mozilla_init_network_manager (single); +#endif + return TRUE; } @@ -621,13 +695,29 @@ static void mozilla_embed_single_dispose (GObject *object) { MozillaEmbedSingle *single = MOZILLA_EMBED_SINGLE (object); + MozillaEmbedSinglePrivate *priv = single->priv; + + if (priv->mSingleObserver) + { + priv->mSingleObserver->Detach (); + NS_RELEASE (priv->mSingleObserver); + priv->mSingleObserver = nsnull; + } - if (single->priv->mSingleObserver) +#ifdef ENABLE_NETWORK_MANAGER + if (priv->nm_context != NULL) { - single->priv->mSingleObserver->Detach (); - NS_RELEASE (single->priv->mSingleObserver); - single->priv->mSingleObserver = nsnull; + if (priv->nm_callback_id != 0) + { + libnm_glib_unregister_callback (priv->nm_context, + priv->nm_callback_id); + priv->nm_callback_id = 0; + } + + libnm_glib_shutdown (priv->nm_context); + priv->nm_context = NULL; } +#endif parent_class->dispose (object); } diff --git a/src/Makefile.am b/src/Makefile.am index 4d76bd68b..fcf98c2ff 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -216,9 +216,7 @@ epiphany_LDADD += \ $(PYTHON_LIB_LOC) $(PYTHON_LIBS) \ $(PYTHON_EXTRA_LIBS) \ $(PYGTK_LIBS) -endif -if ENABLE_PYTHON pydefsdir = $(datadir)/pygtk/2.0/defs pydefs_DATA = epiphany.defs @@ -227,6 +225,11 @@ EXTRA_DIST += \ $(pydefs_DATA) endif +if ENABLE_NETWORK_MANAGER +epiphany_LDADD += \ + $(NETWORK_MANAGER_LIBS) +endif + BUILT_SOURCES = \ $(TYPES_SOURCE) \ ephy-dbus-client-bindings.h \ |