aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-01-11 20:56:54 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-01-11 20:56:54 +0800
commit476dd3a483d5002b07859036b1b7dbb6f883e4f9 (patch)
tree1d25606e82e82faf3a06b85635b0b3502d6416c2 /embed/mozilla
parentaa24bfd629dfa18c35b98eedcbb06f6d1e64cec2 (diff)
downloadgsoc2013-epiphany-476dd3a483d5002b07859036b1b7dbb6f883e4f9.tar
gsoc2013-epiphany-476dd3a483d5002b07859036b1b7dbb6f883e4f9.tar.gz
gsoc2013-epiphany-476dd3a483d5002b07859036b1b7dbb6f883e4f9.tar.bz2
gsoc2013-epiphany-476dd3a483d5002b07859036b1b7dbb6f883e4f9.tar.lz
gsoc2013-epiphany-476dd3a483d5002b07859036b1b7dbb6f883e4f9.tar.xz
gsoc2013-epiphany-476dd3a483d5002b07859036b1b7dbb6f883e4f9.tar.zst
gsoc2013-epiphany-476dd3a483d5002b07859036b1b7dbb6f883e4f9.zip
Implement a cancel api. Fix refcount to really destroy the WebPersist
2003-01-11 Marco Pesenti Gritti <marco@it.gnome.org> * embed/ephy-embed-persist.c: (ephy_embed_persist_cancel): * embed/ephy-embed-persist.h: * embed/mozilla/ProgressListener.cpp: * embed/mozilla/mozilla-embed-persist.cpp: * embed/mozilla/mozilla-embed-persist.h: Implement a cancel api. Fix refcount to really destroy the WebPersist object when done.
Diffstat (limited to 'embed/mozilla')
-rw-r--r--embed/mozilla/mozilla-embed-persist.cpp37
-rw-r--r--embed/mozilla/mozilla-embed-persist.h4
2 files changed, 35 insertions, 6 deletions
diff --git a/embed/mozilla/mozilla-embed-persist.cpp b/embed/mozilla/mozilla-embed-persist.cpp
index 3453f18cd..a2db4ac4a 100644
--- a/embed/mozilla/mozilla-embed-persist.cpp
+++ b/embed/mozilla/mozilla-embed-persist.cpp
@@ -36,10 +36,13 @@ mozilla_embed_persist_finalize (GObject *object);
static gresult
impl_save (EphyEmbedPersist *persist);
+static gresult
+impl_cancel (EphyEmbedPersist *persist);
struct MozillaEmbedPersistPrivate
{
- gpointer dummy;
+ nsCOMPtr<nsIWebBrowserPersist> mPersist;
+ GProgressListener *mProgress;
};
static GObjectClass *parent_class = NULL;
@@ -85,12 +88,14 @@ mozilla_embed_persist_class_init (MozillaEmbedPersistClass *klass)
object_class->finalize = mozilla_embed_persist_finalize;
persist_class->save = impl_save;
+ persist_class->cancel = impl_cancel;
}
static void
mozilla_embed_persist_init (MozillaEmbedPersist *persist)
{
persist->priv = g_new0 (MozillaEmbedPersistPrivate, 1);
+ persist->priv->mPersist = do_CreateInstance (NS_WEBBROWSERPERSIST_CONTRACTID);
}
static void
@@ -103,6 +108,9 @@ mozilla_embed_persist_finalize (GObject *object)
persist = MOZILLA_EMBED_PERSIST (object);
+ persist->priv->mPersist->SetProgressListener (nsnull);
+ persist->priv->mPersist = nsnull;
+
g_return_if_fail (persist->priv != NULL);
g_free (persist->priv);
@@ -110,6 +118,24 @@ mozilla_embed_persist_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+void
+mozilla_embed_persist_completed (MozillaEmbedPersist *persist)
+{
+ g_signal_emit_by_name (persist, "completed");
+}
+
+static gresult
+impl_cancel (EphyEmbedPersist *persist)
+{
+ nsCOMPtr<nsIWebBrowserPersist> bpersist =
+ MOZILLA_EMBED_PERSIST (persist)->priv->mPersist;
+ if (!bpersist) return G_FAILED;
+
+ bpersist->CancelSave ();
+
+ return G_OK;
+}
+
static gresult
impl_save (EphyEmbedPersist *persist)
{
@@ -132,6 +158,10 @@ impl_save (EphyEmbedPersist *persist)
g_return_val_if_fail (filename != NULL, G_FAILED);
+ nsCOMPtr<nsIWebBrowserPersist> bpersist =
+ MOZILLA_EMBED_PERSIST (persist)->priv->mPersist;
+ if (!bpersist) return G_FAILED;
+
nsCOMPtr<nsIURI> linkURI;
linkURI = nsnull;
if (uri)
@@ -141,10 +171,6 @@ impl_save (EphyEmbedPersist *persist)
if (NS_FAILED(rv) || !linkURI) return G_FAILED;
}
- nsCOMPtr<nsIWebBrowserPersist> bpersist =
- do_CreateInstance(NS_WEBBROWSERPERSIST_CONTRACTID, &rv);
- if (NS_FAILED(rv) || !persist) return G_FAILED;
-
nsCOMPtr<nsILocalFile> file;
NS_NewLocalFile(NS_ConvertUTF8toUCS2(filename), PR_TRUE, getter_AddRefs(file));
if (NS_FAILED(rv) || !file) return G_FAILED;
@@ -194,6 +220,7 @@ impl_save (EphyEmbedPersist *persist)
}
GProgressListener *aProgress = new GProgressListener ();
+ MOZILLA_EMBED_PERSIST (persist)->priv->mProgress = aProgress;
if (uri == NULL)
{
diff --git a/embed/mozilla/mozilla-embed-persist.h b/embed/mozilla/mozilla-embed-persist.h
index bcd073ca3..d65170eda 100644
--- a/embed/mozilla/mozilla-embed-persist.h
+++ b/embed/mozilla/mozilla-embed-persist.h
@@ -38,7 +38,7 @@ typedef struct MozillaEmbedPersistClass MozillaEmbedPersistClass;
typedef struct MozillaEmbedPersist MozillaEmbedPersist;
typedef struct MozillaEmbedPersistPrivate MozillaEmbedPersistPrivate;
-struct MozillaEmbedPersist
+struct MozillaEmbedPersist
{
EphyEmbedPersist parent;
MozillaEmbedPersistPrivate *priv;
@@ -51,6 +51,8 @@ struct MozillaEmbedPersistClass
GType mozilla_embed_persist_get_type (void);
+void mozilla_embed_persist_completed (MozillaEmbedPersist *persist);
+
G_END_DECLS
#endif