diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-01-11 20:56:54 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-01-11 20:56:54 +0800 |
commit | 476dd3a483d5002b07859036b1b7dbb6f883e4f9 (patch) | |
tree | 1d25606e82e82faf3a06b85635b0b3502d6416c2 /embed | |
parent | aa24bfd629dfa18c35b98eedcbb06f6d1e64cec2 (diff) | |
download | gsoc2013-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')
-rw-r--r-- | embed/ephy-embed-persist.c | 7 | ||||
-rw-r--r-- | embed/ephy-embed-persist.h | 6 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-persist.cpp | 37 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-persist.h | 4 |
4 files changed, 48 insertions, 6 deletions
diff --git a/embed/ephy-embed-persist.c b/embed/ephy-embed-persist.c index a1d742587..33b5b7eb7 100644 --- a/embed/ephy-embed-persist.c +++ b/embed/ephy-embed-persist.c @@ -364,6 +364,13 @@ ephy_embed_persist_set_dest (EphyEmbedPersist *persist, } gresult +ephy_embed_persist_cancel (EphyEmbedPersist *persist) +{ + EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist); + return klass->cancel (persist); +} + +gresult ephy_embed_persist_save (EphyEmbedPersist *persist) { EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist); diff --git a/embed/ephy-embed-persist.h b/embed/ephy-embed-persist.h index 2ad883647..144927003 100644 --- a/embed/ephy-embed-persist.h +++ b/embed/ephy-embed-persist.h @@ -69,10 +69,14 @@ struct EphyEmbedPersistClass gresult (* set_source) (EphyEmbedPersist *persist, const char *url); + gresult (* set_dest) (EphyEmbedPersist *persist, const char *dir); + gresult (* save) (EphyEmbedPersist *persist); + gresult (* cancel) (EphyEmbedPersist *persist); + gresult (* set_max_size) (EphyEmbedPersist *persist, int max_size); @@ -124,6 +128,8 @@ gresult ephy_embed_persist_get_flags (EphyEmbedPersist *persist, gresult ephy_embed_persist_save (EphyEmbedPersist *persist); +gresult ephy_embed_persist_cancel (EphyEmbedPersist *persist); + G_END_DECLS #endif 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 |