aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2004-02-25 07:44:58 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2004-02-25 07:44:58 +0800
commit9fb6164dd427630f8e72d69113c48a78dd449bc8 (patch)
treebb8614a2c6a04bbcb05be59c1ed525abc77d9f83
parentd055989e9fc45f0849de45ec00e02802e6769dc0 (diff)
downloadgsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar.gz
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar.bz2
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar.lz
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar.xz
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar.zst
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.zip
Make max size property use long / bytes.
2004-02-25 Marco Pesenti Gritti <marco@gnome.org> * embed/ephy-embed-persist.c: (ephy_embed_persist_set_max_size), (ephy_embed_persist_set_property), (ephy_embed_persist_get_property), (ephy_embed_persist_init), (ephy_embed_persist_class_init): * embed/ephy-embed-persist.h: Make max size property use long / bytes. * embed/ephy-favicon-cache.c: (ephy_favicon_cache_download): Correct to use bytes. * embed/mozilla/EphyHeaderSniffer.cpp: * embed/mozilla/MozDownload.cpp: * embed/mozilla/MozDownload.h: * embed/mozilla/mozilla-embed-persist.cpp: Actually respect the max_size property.
-rw-r--r--ChangeLog21
-rw-r--r--embed/ephy-embed-persist.c14
-rw-r--r--embed/ephy-embed-persist.h2
-rw-r--r--embed/ephy-favicon-cache.c2
-rw-r--r--embed/mozilla/EphyHeaderSniffer.cpp2
-rw-r--r--embed/mozilla/MozDownload.cpp19
-rw-r--r--embed/mozilla/MozDownload.h6
-rw-r--r--embed/mozilla/mozilla-embed-persist.cpp4
8 files changed, 52 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index fb3c873d7..09899a626 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2004-02-25 Marco Pesenti Gritti <marco@gnome.org>
+
+ * embed/ephy-embed-persist.c: (ephy_embed_persist_set_max_size),
+ (ephy_embed_persist_set_property),
+ (ephy_embed_persist_get_property), (ephy_embed_persist_init),
+ (ephy_embed_persist_class_init):
+ * embed/ephy-embed-persist.h:
+
+ Make max size property use long / bytes.
+
+ * embed/ephy-favicon-cache.c: (ephy_favicon_cache_download):
+
+ Correct to use bytes.
+
+ * embed/mozilla/EphyHeaderSniffer.cpp:
+ * embed/mozilla/MozDownload.cpp:
+ * embed/mozilla/MozDownload.h:
+ * embed/mozilla/mozilla-embed-persist.cpp:
+
+ Actually respect the max_size property.
+
2004-02-24 Christian Persch <chpe@cvs.gnome.org>
* src/ephy-tab.c: (let_me_resize_hack), (ephy_tab_size_to_cb):
diff --git a/embed/ephy-embed-persist.c b/embed/ephy-embed-persist.c
index 7197fa6be..4fed96cbb 100644
--- a/embed/ephy-embed-persist.c
+++ b/embed/ephy-embed-persist.c
@@ -50,7 +50,7 @@ struct EphyEmbedPersistPrivate
char *fc_title;
char *persist_key;
EphyEmbed *embed;
- int max_size;
+ long max_size;
EmbedPersistFlags flags;
GtkWindow *fc_parent;
};
@@ -135,7 +135,7 @@ ephy_embed_persist_set_flags (EphyEmbedPersist *persist,
void
ephy_embed_persist_set_max_size (EphyEmbedPersist *persist,
- int value)
+ long value)
{
g_return_if_fail (EPHY_IS_EMBED_PERSIST (persist));
@@ -250,7 +250,7 @@ ephy_embed_persist_set_property (GObject *object,
ephy_embed_persist_set_flags (persist, g_value_get_int (value));
break;
case PROP_MAX_SIZE:
- ephy_embed_persist_set_max_size (persist, g_value_get_int (value));
+ ephy_embed_persist_set_max_size (persist, g_value_get_long (value));
break;
case PROP_PERSISTKEY:
ephy_embed_persist_set_persist_key (persist, g_value_get_string (value));
@@ -287,7 +287,7 @@ ephy_embed_persist_get_property (GObject *object,
g_value_set_int (value, ephy_embed_persist_get_flags (persist));
break;
case PROP_MAX_SIZE:
- g_value_set_int (value, ephy_embed_persist_get_max_size (persist));
+ g_value_set_long (value, ephy_embed_persist_get_max_size (persist));
break;
case PROP_PERSISTKEY:
g_value_set_string (value, ephy_embed_persist_get_persist_key (persist));
@@ -310,7 +310,7 @@ ephy_embed_persist_init (EphyEmbedPersist *persist)
persist->priv->fc_title = NULL;
persist->priv->fc_parent = NULL;
persist->priv->flags = 0;
- persist->priv->max_size = 0;
+ persist->priv->max_size = -1;
persist->priv->persist_key = NULL;
}
@@ -395,11 +395,11 @@ ephy_embed_persist_class_init (EphyEmbedPersistClass *klass)
g_object_class_install_property (object_class,
PROP_MAX_SIZE,
- g_param_spec_int ("max_size",
+ g_param_spec_long ("max_size",
"Maxsize",
"Maximum size of the file",
0,
- G_MAXINT,
+ G_MAXLONG,
0,
G_PARAM_READWRITE));
diff --git a/embed/ephy-embed-persist.h b/embed/ephy-embed-persist.h
index 1591e4d60..7e3b0180b 100644
--- a/embed/ephy-embed-persist.h
+++ b/embed/ephy-embed-persist.h
@@ -94,7 +94,7 @@ void ephy_embed_persist_set_flags (EphyEmbedPersist *persist,
EmbedPersistFlags value);
void ephy_embed_persist_set_max_size (EphyEmbedPersist *persist,
- int value);
+ long value);
void ephy_embed_persist_set_persist_key (EphyEmbedPersist *persist,
const char *value);
diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c
index c83471dee..4aae929a6 100644
--- a/embed/ephy-favicon-cache.c
+++ b/embed/ephy-favicon-cache.c
@@ -356,7 +356,7 @@ ephy_favicon_cache_download (EphyFaviconCache *cache,
ephy_embed_persist_set_dest (persist, dest);
ephy_embed_persist_set_flags (persist, EMBED_PERSIST_NO_VIEW);
- ephy_embed_persist_set_max_size (persist, 100);
+ ephy_embed_persist_set_max_size (persist, 100 * 1024);
ephy_embed_persist_set_source (persist, favicon_url);
g_free (dest);
diff --git a/embed/mozilla/EphyHeaderSniffer.cpp b/embed/mozilla/EphyHeaderSniffer.cpp
index 136a40325..c9240c1b3 100644
--- a/embed/mozilla/EphyHeaderSniffer.cpp
+++ b/embed/mozilla/EphyHeaderSniffer.cpp
@@ -353,7 +353,7 @@ nsresult EphyHeaderSniffer::InitiateDownload (nsILocalFile *aDestFile)
LOG ("Initiating download")
return InitiateMozillaDownload (mDocument, mURL, aDestFile,
mContentType.get(), mOriginalURI, mEmbedPersist,
- mPostData, nsnull);
+ mPostData, nsnull, -1);
}
NS_IMETHODIMP EphyHeaderSniffer::Prompt (const PRUnichar *dialogTitle, const PRUnichar *text,
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp
index 6261b40af..f6a592d6d 100644
--- a/embed/mozilla/MozDownload.cpp
+++ b/embed/mozilla/MozDownload.cpp
@@ -63,7 +63,9 @@
const char* const persistContractID = "@mozilla.org/embedding/browser/nsWebBrowserPersist;1";
MozDownload::MozDownload() :
- mGotFirstStateChange(false), mIsNetworkTransfer(false),
+ mMaxSize(-1),
+ mGotFirstStateChange(false),
+ mIsNetworkTransfer(false),
mStatus(NS_OK),
mEmbedPersist(nsnull),
mDownloadState(EPHY_DOWNLOAD_DOWNLOADING)
@@ -79,9 +81,10 @@ NS_IMPL_ISUPPORTS2(MozDownload, nsIDownload, nsIWebProgressListener)
NS_IMETHODIMP
MozDownload::InitForEmbed (nsIURI *aSource, nsILocalFile *aTarget, const PRUnichar *aDisplayName,
nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsIWebBrowserPersist *aPersist,
- MozillaEmbedPersist *aEmbedPersist)
+ MozillaEmbedPersist *aEmbedPersist, PRInt32 aMaxSize)
{
mEmbedPersist = aEmbedPersist;
+ mMaxSize = aMaxSize;
return Init (aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aPersist);
}
@@ -355,6 +358,13 @@ MozDownload::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest
PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
{
+ if (mMaxSize >= 0 &&
+ ((aMaxTotalProgress > 0 && mMaxSize > aMaxTotalProgress) ||
+ mMaxSize > aCurTotalProgress))
+ {
+ Cancel ();
+ }
+
if (!mRequest)
mRequest = aRequest;
@@ -449,7 +459,8 @@ MozDownload::Resume()
nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI,
nsILocalFile* inDestFile, const char *contentType,
nsIURI* inOriginalURI, MozillaEmbedPersist *embedPersist,
- nsIInputStream *postData, nsISupports *aCacheKey)
+ nsIInputStream *postData, nsISupports *aCacheKey,
+ PRInt32 aMaxSize)
{
nsresult rv = NS_OK;
@@ -472,7 +483,7 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI
MozDownload *downloader = new MozDownload ();
/* dlListener attaches to its progress dialog here, which gains ownership */
rv = downloader->InitForEmbed (inOriginalURI, inDestFile, fileDisplayName.get(),
- nsnull, timeNow, webPersist, embedPersist);
+ nsnull, timeNow, webPersist, embedPersist, aMaxSize);
NS_ENSURE_SUCCESS (rv, rv);
PRInt32 flags = nsIWebBrowserPersist::PERSIST_FLAGS_REPLACE_EXISTING_FILES;
diff --git a/embed/mozilla/MozDownload.h b/embed/mozilla/MozDownload.h
index f6c82705e..e7f51b2e0 100644
--- a/embed/mozilla/MozDownload.h
+++ b/embed/mozilla/MozDownload.h
@@ -83,7 +83,8 @@
nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceUri,
nsILocalFile* inDestFile, const char *contentType,
nsIURI* inOriginalURI, MozillaEmbedPersist *embedPersist,
- nsIInputStream *postData, nsISupports *aCacheKey);
+ nsIInputStream *postData, nsISupports *aCacheKey,
+ PRInt32 aMaxSize);
nsresult BuildDownloadPath (const char *defaultFileName, nsILocalFile **_retval);
class MozDownload : public nsIDownload,
@@ -108,7 +109,7 @@ public:
nsresult InitForEmbed (nsIURI *aSource, nsILocalFile *aTarget,
const PRUnichar *aDisplayName, nsIMIMEInfo *aMIMEInfo,
PRInt64 startTime, nsIWebBrowserPersist *aPersist,
- MozillaEmbedPersist *aEmbedPersist);
+ MozillaEmbedPersist *aEmbedPersist, PRInt32 aMaxSize);
protected:
nsCOMPtr<nsIURI> mSource;
@@ -121,6 +122,7 @@ protected:
PRInt32 mPercentComplete;
PRInt32 mTotalProgress;
PRInt32 mCurrentProgress;
+ PRInt32 mMaxSize;
bool mGotFirstStateChange, mIsNetworkTransfer;
nsresult mStatus;
diff --git a/embed/mozilla/mozilla-embed-persist.cpp b/embed/mozilla/mozilla-embed-persist.cpp
index 7de40e6d3..5828a92ae 100644
--- a/embed/mozilla/mozilla-embed-persist.cpp
+++ b/embed/mozilla/mozilla-embed-persist.cpp
@@ -133,7 +133,7 @@ impl_save (EphyEmbedPersist *persist)
nsresult rv;
char *filename;
char *uri;
- int max_size;
+ long max_size;
EphyEmbed *embed;
EmbedPersistFlags flags;
PRUint32 persistFlags = 0;
@@ -257,7 +257,7 @@ impl_save (EphyEmbedPersist *persist)
rv = InitiateMozillaDownload (DOMDocument, inURI, destFile,
nsnull, inURI, MOZILLA_EMBED_PERSIST (persist),
- postData, pageDescriptor);
+ postData, pageDescriptor, max_size);
if (NS_FAILED (rv)) return FALSE;
}