aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-06-27 02:28:44 +0800
committerChristian Persch <chpe@src.gnome.org>2004-06-27 02:28:44 +0800
commite497b299846293f001ad98f2b7dca3e68db2bf26 (patch)
tree967f73acbdd043c9f935d8e86093d7c35718b2bf /embed
parent4119e2dbc0194ff0bc2d7c903b10cd35180b32b0 (diff)
downloadgsoc2013-epiphany-e497b299846293f001ad98f2b7dca3e68db2bf26.tar
gsoc2013-epiphany-e497b299846293f001ad98f2b7dca3e68db2bf26.tar.gz
gsoc2013-epiphany-e497b299846293f001ad98f2b7dca3e68db2bf26.tar.bz2
gsoc2013-epiphany-e497b299846293f001ad98f2b7dca3e68db2bf26.tar.lz
gsoc2013-epiphany-e497b299846293f001ad98f2b7dca3e68db2bf26.tar.xz
gsoc2013-epiphany-e497b299846293f001ad98f2b7dca3e68db2bf26.tar.zst
gsoc2013-epiphany-e497b299846293f001ad98f2b7dca3e68db2bf26.zip
Implement File->Work Off-Line command and backend. No DBUS/HAL/whatever
2004-06-26 Christian Persch <chpe@cvs.gnome.org> * data/ui/epiphany-ui.xml: * embed/ephy-embed-single.c: (ephy_embed_single_iface_init), (ephy_embed_single_set_offline_mode), (ephy_embed_single_get_offline_mode): * embed/ephy-embed-single.h: * embed/mozilla/EphySingle.cpp: * embed/mozilla/mozilla-embed-single.cpp: * src/ephy-window.c: (network_status_changed), (ephy_window_init), (ephy_window_finalize): * src/window-commands.c: (window_cmd_file_save_as), (window_cmd_file_work_offline): * src/window-commands.h: Implement File->Work Off-Line command and backend. No DBUS/HAL/whatever integration yet.
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed-single.c30
-rw-r--r--embed/ephy-embed-single.h44
-rw-r--r--embed/mozilla/EphySingle.cpp35
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp41
4 files changed, 117 insertions, 33 deletions
diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c
index 9581883e4..c609d3efc 100644
--- a/embed/ephy-embed-single.c
+++ b/embed/ephy-embed-single.c
@@ -81,6 +81,23 @@ ephy_embed_single_iface_init (gpointer g_class)
G_TYPE_STRING,
G_TYPE_STRING);
+/**
+ * EphyEmbedSingle::network-status:
+ * @single:
+ * @offline: the network status
+ *
+ * The ::network-status signal is emitted when the network status changes.
+ **/
+ g_signal_new ("network-status",
+ EPHY_TYPE_EMBED_SINGLE,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EphyEmbedSingleIface, network_status),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_BOOLEAN);
+
initialised = TRUE;
}
}
@@ -135,6 +152,19 @@ ephy_embed_single_set_offline_mode (EphyEmbedSingle *single,
}
/**
+ * ephy_embed_single_get_offline_mode:
+ * @single: the #EphyEmbedSingle
+ *
+ * Gets the state of the network connection.
+ **/
+gboolean
+ephy_embed_single_get_offline_mode (EphyEmbedSingle *single)
+{
+ EphyEmbedSingleIface *iface = EPHY_EMBED_SINGLE_GET_IFACE (single);
+ return iface->get_offline_mode (single);
+}
+
+/**
* ephy_embed_single_load_proxy_autoconf:
* @single: the #EphyEmbedSingle
* @url: a URL to a PAC file
diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h
index 3893a4aa8..b7b66d13b 100644
--- a/embed/ephy-embed-single.h
+++ b/embed/ephy-embed-single.h
@@ -45,40 +45,46 @@ struct _EphyEmbedSingleIface
char *mime_type,
char *uri);
+ void (* network_status) (EphyEmbedSingle *single,
+ gboolean offline);
+
/* Methods */
- void (* open_window) (EphyEmbedSingle *single,
- EphyEmbed *parent,
- const char *address,
- const char *features);
- void (* clear_cache) (EphyEmbedSingle *shell);
- void (* clear_auth_cache) (EphyEmbedSingle *shell);
- void (* set_offline_mode) (EphyEmbedSingle *shell,
- gboolean offline);
- void (* load_proxy_autoconf) (EphyEmbedSingle *shell,
- const char* url);
- GList * (* get_font_list) (EphyEmbedSingle *shell,
- const char *langGroup);
+ void (* open_window) (EphyEmbedSingle *single,
+ EphyEmbed *parent,
+ const char *address,
+ const char *features);
+ void (* clear_cache) (EphyEmbedSingle *shell);
+ void (* clear_auth_cache) (EphyEmbedSingle *shell);
+ void (* set_offline_mode) (EphyEmbedSingle *shell,
+ gboolean offline);
+ gboolean (* get_offline_mode) (EphyEmbedSingle *single);
+ void (* load_proxy_autoconf) (EphyEmbedSingle *shell,
+ const char* url);
+ GList * (* get_font_list) (EphyEmbedSingle *shell,
+ const char *langGroup);
};
-GType ephy_embed_single_get_type (void);
+GType ephy_embed_single_get_type (void);
-void ephy_embed_single_open_window (EphyEmbedSingle *single,
+void ephy_embed_single_open_window (EphyEmbedSingle *single,
EphyEmbed *parent,
const char *address,
const char *features);
-void ephy_embed_single_clear_cache (EphyEmbedSingle *single);
+void ephy_embed_single_clear_cache (EphyEmbedSingle *single);
-void ephy_embed_single_clear_auth_cache (EphyEmbedSingle *single);
+void ephy_embed_single_clear_auth_cache (EphyEmbedSingle *single);
-void ephy_embed_single_set_offline_mode (EphyEmbedSingle *single,
+void ephy_embed_single_set_offline_mode (EphyEmbedSingle *single,
gboolean offline);
-void ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *single,
+gboolean ephy_embed_single_get_offline_mode (EphyEmbedSingle *single);
+
+void ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *single,
const char* url);
-GList *ephy_embed_single_get_font_list (EphyEmbedSingle *single,
+GList *ephy_embed_single_get_font_list (EphyEmbedSingle *single,
const char *lang_group);
G_END_DECLS
diff --git a/embed/mozilla/EphySingle.cpp b/embed/mozilla/EphySingle.cpp
index b667c16d1..e059b5344 100644
--- a/embed/mozilla/EphySingle.cpp
+++ b/embed/mozilla/EphySingle.cpp
@@ -37,10 +37,9 @@
NS_IMPL_ISUPPORTS1(EphySingle, nsIObserver)
EphySingle::EphySingle()
+: mOwner(nsnull)
{
- LOG ("EphySingle constructor")
-
- mOwner = nsnull;
+ LOG ("EphySingle ctor")
}
nsresult
@@ -48,14 +47,17 @@ EphySingle::Init (EphyEmbedSingle *aOwner)
{
LOG ("EphySingle::Init")
- mOwner = aOwner;
-
mObserverService = do_GetService ("@mozilla.org/observer-service;1");
NS_ENSURE_TRUE (mObserverService, NS_ERROR_FAILURE);
- mObserverService->AddObserver (this, "cookie-changed", PR_FALSE);
- mObserverService->AddObserver (this, "cookie-rejected", PR_FALSE);
- mObserverService->AddObserver (this, "perm-changed", PR_FALSE);
+ nsresult rv;
+ rv = mObserverService->AddObserver (this, "cookie-changed", PR_TRUE);
+ rv |= mObserverService->AddObserver (this, "cookie-rejected", PR_TRUE);
+ rv |= mObserverService->AddObserver (this, "perm-changed", PR_TRUE);
+ rv |= mObserverService->AddObserver (this, "network:offline-status-changed", PR_TRUE);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
+ mOwner = aOwner;
return NS_OK;
}
@@ -63,11 +65,14 @@ EphySingle::Init (EphyEmbedSingle *aOwner)
nsresult
EphySingle::Detach ()
{
+ LOG ("EphySingle::Detach")
+
if (mObserverService)
{
mObserverService->RemoveObserver (this, "cookie-changed");
mObserverService->RemoveObserver (this, "cookie-rejected");
mObserverService->RemoveObserver (this, "perm-changed");
+ mObserverService->RemoveObserver (this, "network:offline-status-changed");
}
return NS_OK;
@@ -75,9 +80,8 @@ EphySingle::Detach ()
EphySingle::~EphySingle()
{
- LOG ("EphySingle destructor")
+ LOG ("EphySingle dtor")
- Detach();
mOwner = nsnull;
}
@@ -202,9 +206,18 @@ NS_IMETHODIMP EphySingle::Observe(nsISupports *aSubject,
rv = NS_ERROR_FAILURE;
}
}
+ else if (strcmp (aTopic, "network:offline-status-changed") == 0)
+ {
+ /* aData is either (PRUnichar[]) "offline" or "online" */
+ gboolean offline;
+
+ offline = (aData[1] == 'f');
+
+ g_signal_emit_by_name (mOwner, "network-status", offline);
+ }
else
{
- g_warning ("EphySingle observed unknown topic!\n");
+ g_warning ("EphySingle observed unknown topic '%s'!\n", aTopic);
rv = NS_ERROR_FAILURE;
}
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 62efe62de..33f14737e 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -414,11 +414,17 @@ mozilla_init_chrome (void)
static void
mozilla_init_observer (MozillaEmbedSingle *single)
{
- single->priv->mSingleObserver = new EphySingle ();
+ EphySingle *observer;
- if (single->priv->mSingleObserver)
+ observer = new EphySingle ();
+
+ if (observer)
{
- single->priv->mSingleObserver->Init (EPHY_EMBED_SINGLE (single));
+ nsresult rv;
+ rv = observer->Init (EPHY_EMBED_SINGLE (single));
+ if (NS_FAILED (rv)) return;
+
+ NS_ADDREF (single->priv->mSingleObserver = observer);
}
}
@@ -492,6 +498,19 @@ mozilla_embed_single_init (MozillaEmbedSingle *mes)
}
static void
+mozilla_embed_single_dispose (GObject *object)
+{
+ MozillaEmbedSingle *single = MOZILLA_EMBED_SINGLE (object);
+
+ if (single->priv->mSingleObserver)
+ {
+ single->priv->mSingleObserver->Detach ();
+ NS_RELEASE (single->priv->mSingleObserver);
+ single->priv->mSingleObserver = nsnull;
+ }
+}
+
+static void
mozilla_embed_single_finalize (GObject *object)
{
MozillaEmbedSingle *mes = MOZILLA_EMBED_SINGLE (object);
@@ -542,6 +561,20 @@ impl_set_offline_mode (EphyEmbedSingle *shell,
io->SetOffline(offline);
}
+static gboolean
+impl_get_offline_mode (EphyEmbedSingle *shell)
+{
+ nsCOMPtr<nsIIOService> io = do_GetService(NS_IOSERVICE_CONTRACTID);
+ if (!io) return FALSE; /* no way to check the state, assume offline */
+
+ PRBool isOffline;
+ nsresult rv;
+ rv = io->GetOffline(&isOffline);
+ NS_ENSURE_SUCCESS (rv, FALSE);
+
+ return isOffline;
+}
+
static void
impl_load_proxy_autoconf (EphyEmbedSingle *shell,
const char* url)
@@ -868,6 +901,7 @@ mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass)
parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
+ object_class->dispose = mozilla_embed_single_dispose;
object_class->finalize = mozilla_embed_single_finalize;
g_type_class_add_private (object_class, sizeof (MozillaEmbedSinglePrivate));
@@ -879,6 +913,7 @@ ephy_embed_single_iface_init (EphyEmbedSingleIface *iface)
iface->clear_cache = impl_clear_cache;
iface->clear_auth_cache = impl_clear_auth_cache;
iface->set_offline_mode = impl_set_offline_mode;
+ iface->get_offline_mode = impl_get_offline_mode;
iface->load_proxy_autoconf = impl_load_proxy_autoconf;
iface->get_font_list = impl_get_font_list;
iface->open_window = impl_open_window;