diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-10-27 20:18:49 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-10-27 20:18:49 (GMT) |
commit | 45287c880c4a62b6a5b9da4d8fe34bbee801ff1e (patch) | |
tree | 5b40901b14d3a6b9aecff4574a5cf21e651a7c8c /lib/src/SugarDownload.cpp | |
parent | a95355c860a8cd28029a8f50b30b5a88f83744e1 (diff) | |
parent | f1949d4672091daad1492f5c7a4d72b03db8142b (diff) |
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
Diffstat (limited to 'lib/src/SugarDownload.cpp')
-rw-r--r-- | lib/src/SugarDownload.cpp | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/lib/src/SugarDownload.cpp b/lib/src/SugarDownload.cpp index b288dfe..9c68b8f 100644 --- a/lib/src/SugarDownload.cpp +++ b/lib/src/SugarDownload.cpp @@ -1,7 +1,3 @@ -#include <stdio.h> -#include <stdlib.h> -#include <nsStringAPI.h> - #include "sugar-browser-chandler.h" #include "SugarDownload.h" @@ -28,15 +24,11 @@ GSugarDownload::Init (nsIURI *aSource, nsILocalFile *aTempFile, nsICancelable *aCancelable) { - FILE *file = fopen("/home/tomeu/file.txt","a+"); - fprintf(file,"%s\n","GSugarDownload::Init"); - fclose(file); - mSource = aSource; - mTarget = aTarget; + aTarget->GetPath(mTargetFileName); mMIMEInfo = aMIMEInfo; mTempFile = aTempFile; - + return NS_OK; } @@ -46,7 +38,7 @@ GSugarDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aReques { nsCString url; nsCString mimeType; - nsCString tmpFileName; + nsCString targetURI; if ((((aStateFlags & STATE_IS_REQUEST) && (aStateFlags & STATE_IS_NETWORK) && @@ -56,18 +48,12 @@ GSugarDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aReques mMIMEInfo->GetMIMEType(mimeType); mSource->GetSpec(url); - mTempFile->GetNativeLeafName(tmpFileName); - - // FIXME: Hack. Mozilla adds a .part to the file name. Must exist a better/simpler way. - // FIXME: Also creates a nice memory leak. - char *tmpFileName_striped = (char*)malloc(strlen(tmpFileName.get())); - strncpy(tmpFileName_striped, tmpFileName.get(), strlen(tmpFileName.get()) - 5); - + SugarBrowserChandler *browser_chandler = sugar_get_browser_chandler(); sugar_browser_chandler_handle_content(browser_chandler, url.get(), mimeType.get(), - tmpFileName_striped); + mTargetFileName.get()); } return NS_OK; |