  #define HAVE_STRCASESTR
  #else
  #undef HAVE_STRCASESTR
+-- 
+1.7.10.2
+

+};
+
+
 struct gui_download_window {
 	download_context* ctx;
-	BWindow* window;
-	BStatusBar* bar;
-	unsigned long progress;
+	NSDownloadWindow* window;
+
+	BLocker* storageLock;
+	BDataIO* storage;
 };
 
 
+NSDownloadWindow::NSDownloadWindow(download_context* ctx)
+	: BWindow(BRect(30, 30, 400, 200), "Downloads", B_TITLED_WINDOW,
+		B_NOT_RESIZABLE)

+}
+
+
+struct gui_download_window *gui_download_window_create(download_context *ctx,
+		struct gui_window *parent)
+{
+	struct gui_download_window *download = (struct gui_download_window*)malloc(sizeof *download);
+	if (download == NULL)
+		return NULL;
+
+	download->storageLock = new BLocker("storage_lock");
+	download->storage = new BMallocIO();
+	download->ctx = ctx;
+
+	download->window = new NSDownloadWindow(ctx);
+
+	// Also ask the user where to save the file
+	// TODO inject the suggested name somehow
+	BMessage* msg = new BMessage(B_SAVE_REQUESTED);
+
+	BFilePanel* panel = new BFilePanel(B_SAVE_PANEL,
+		new BMessenger(download->window), NULL, 0, false);
+
+	msg->AddPointer("source", panel);
+	msg->AddPointer("dw", download);
+	panel->SetMessage(msg);
+	
+	panel->Show();
+
+	return download;
+}
+
+
+nserror gui_download_window_data(struct gui_download_window *dw, 
+		const char *data, unsigned int size)
+{
+	dw->window->Progress(size);
+
+	dw->storageLock->Lock();
+	dw->storage->Write(data, size);
+	dw->storageLock->Unlock();
+
+	return NSERROR_OK;
+}
+
+
+void gui_download_window_error(struct gui_download_window *dw,
+		const char *error_msg)
+{
+	dw->window->Failure(error_msg);
+
+	delete dw->storageLock;
+	delete dw->storage;
+}
+
+
+void gui_download_window_done(struct gui_download_window *dw)
+{
+	dw->window->Success();
+
+	dw->storageLock->Lock();
