aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
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/mozilla
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/mozilla')
-rw-r--r--embed/mozilla/EphySingle.cpp35
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp41
2 files changed, 62 insertions, 14 deletions
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;