aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-01-16 06:42:46 +0800
committerChristian Persch <chpe@src.gnome.org>2006-01-16 06:42:46 +0800
commit73e8920c461a5403f8f0ad1e9754910c3089ef2f (patch)
tree2f50b0c5f734542062889d54a53e5cbe9070fa6b /embed
parent2097f11220e25f83dda2026d07cc66e7a0a31544 (diff)
downloadgsoc2013-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.
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/Makefile.am5
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp104
2 files changed, 102 insertions, 7 deletions
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);
}