Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco 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)
commit45287c880c4a62b6a5b9da4d8fe34bbee801ff1e (patch)
tree5b40901b14d3a6b9aecff4574a5cf21e651a7c8c
parenta95355c860a8cd28029a8f50b30b5a88f83744e1 (diff)
parentf1949d4672091daad1492f5c7a4d72b03db8142b (diff)
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
-rw-r--r--lib/src/Makefile.am4
-rw-r--r--lib/src/SugarContentHandler.cpp (renamed from lib/src/sugar-content-handler.cpp)13
-rw-r--r--lib/src/SugarContentHandler.h (renamed from lib/src/sugar-content-handler.h)0
-rw-r--r--lib/src/SugarDownload.cpp24
-rw-r--r--lib/src/SugarDownload.h9
-rw-r--r--lib/src/sugar-browser-chandler.c3
-rw-r--r--lib/src/sugar-browser.cpp2
7 files changed, 17 insertions, 38 deletions
diff --git a/lib/src/Makefile.am b/lib/src/Makefile.am
index 078c927..0224885 100644
--- a/lib/src/Makefile.am
+++ b/lib/src/Makefile.am
@@ -21,8 +21,8 @@ libsugarprivate_la_SOURCES = \
sugar-browser.cpp \
sugar-browser-chandler.h \
sugar-browser-chandler.c \
- sugar-content-handler.h \
- sugar-content-handler.cpp \
+ SugarContentHandler.h \
+ SugarContentHandler.cpp \
SugarDownload.h \
SugarDownload.cpp \
sugar-key-grabber.h \
diff --git a/lib/src/sugar-content-handler.cpp b/lib/src/SugarContentHandler.cpp
index 44aae59..b39b20b 100644
--- a/lib/src/sugar-content-handler.cpp
+++ b/lib/src/SugarContentHandler.cpp
@@ -1,15 +1,10 @@
-#include <stdio.h>
-
-#include <nsStringAPI.h>
#include <nsCExternalHandlerService.h>
-#include <nsIMIMEInfo.h>
-#include <nsIURL.h>
#include <nsIFile.h>
#include "sugar-browser-chandler.h"
#include "SugarDownload.h"
-#include "sugar-content-handler.h"
+#include "SugarContentHandler.h"
GSugarContentHandler::GSugarContentHandler()
{
@@ -28,10 +23,10 @@ GSugarContentHandler::Show (nsIHelperAppLauncher *aLauncher,
nsISupports *aContext,
PRUint32 aReason)
{
- nsCOMPtr<nsIFile> tmp_file;
- aLauncher->GetTargetFile(getter_AddRefs(tmp_file));
+ nsCOMPtr<nsIFile> tmpFile;
+ aLauncher->GetTargetFile(getter_AddRefs(tmpFile));
- aLauncher->SaveToDisk (tmp_file, PR_FALSE);
+ aLauncher->SaveToDisk (tmpFile, PR_FALSE);
return NS_OK;
}
diff --git a/lib/src/sugar-content-handler.h b/lib/src/SugarContentHandler.h
index da5ae40..da5ae40 100644
--- a/lib/src/sugar-content-handler.h
+++ b/lib/src/SugarContentHandler.h
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;
diff --git a/lib/src/SugarDownload.h b/lib/src/SugarDownload.h
index 468428c..b858f53 100644
--- a/lib/src/SugarDownload.h
+++ b/lib/src/SugarDownload.h
@@ -8,6 +8,7 @@
#include <nsIMIMEInfo.h>
#include <nsIURL.h>
#include <nsILocalFile.h>
+#include <nsStringAPI.h>
#define G_SUGARDOWNLOAD_CID \
{ /* b1813bbe-6518-11db-967e-00e08161165f */ \
@@ -29,10 +30,10 @@ public:
NS_DECL_NSITRANSFER
protected:
- nsIURI *mSource;
- nsIURI *mTarget;
- nsIMIMEInfo *mMIMEInfo;
- nsILocalFile *mTempFile;
+ nsIURI *mSource;
+ nsCString mTargetFileName;
+ nsIMIMEInfo *mMIMEInfo;
+ nsILocalFile *mTempFile;
};
#endif // SugarDownload_h__
diff --git a/lib/src/sugar-browser-chandler.c b/lib/src/sugar-browser-chandler.c
index 930b19f..a65519a 100644
--- a/lib/src/sugar-browser-chandler.c
+++ b/lib/src/sugar-browser-chandler.c
@@ -1,6 +1,3 @@
-#include <stdio.h>
-#include <string.h>
-
#include "sugar-marshal.h"
#include "sugar-browser-chandler.h"
diff --git a/lib/src/sugar-browser.cpp b/lib/src/sugar-browser.cpp
index 0cbfd29..d2ffb8a 100644
--- a/lib/src/sugar-browser.cpp
+++ b/lib/src/sugar-browser.cpp
@@ -18,7 +18,7 @@
*/
#include "sugar-browser.h"
-#include "sugar-content-handler.h"
+#include "SugarContentHandler.h"
#include "SugarDownload.h"
#include <gtkmozembed_internal.h>