File: ProgressListener.h

package info (click to toggle)
galeon 2.0.6-2.1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 19,156 kB
  • ctags: 9,680
  • sloc: ansic: 77,798; cpp: 13,928; sh: 9,000; xml: 5,761; makefile: 901
file content (127 lines) | stat: -rw-r--r-- 3,520 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 *  Copyright (C) 2001 Philip Langdale, Matthew Aubury
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 *  As of 5th Jan 2005: The progress listener can optionally implement
 *  nsIObserver which allows it to be informed of the temporary file being
 *  used for a download before the final location is specified. We currently
 *  don't do this but if we need that information we can get it.
 *  nsITransfer.h for details.
 */

#ifndef PROGRESSLISTENER2_H__
#define PROGRESSLISTENER2_H__

#include "galeon-embed-persist.h"
#include "galeon-embed-shell.h"
#include "downloader-view.h"

#include <gtk/gtkwidget.h>

#include <nsITransfer.h>
#include <nsIWebProgressListener.h>
#include <nsCOMPtr.h>
#include <nsWeakReference.h>

#include "GulString.h"

class nsIHelperAppLauncherDialog;
class nsIExternalHelperAppService;
class nsIWebBrowserPersist;
class nsIURI;
class nsILocalFile;
class nsIFile;
class nsIRequest;
class nsIDOMDocument;
class nsIObserver;
class nsIInputStream;

#define G_PROGRESSDIALOG_CID                \
{ /* d2a2f743-f126-4f1f-1234-d4e50490f112 */         \
    0xd2a2f743,                                      \
    0xf126,                                          \
    0x4f1f,                                          \
    {0x12, 0x34, 0xd4, 0xe5, 0x04, 0x90, 0xf1, 0x12} \
}

#define G_PROGRESSDIALOG_CLASSNAME "Galeon's Download Progress Dialog"
#define G_PROGRESSDIALOG_CONTRACTID "@mozilla.org/progressdialog;1"

class GProgressListener : 
			  public nsITransfer,
 			  public nsSupportsWeakReference
{
 public:
 	NS_DECL_ISUPPORTS
	NS_DECL_NSIWEBPROGRESSLISTENER
	NS_DECL_NSIWEBPROGRESSLISTENER2
	NS_DECL_NSITRANSFER

	GProgressListener ();
	virtual ~GProgressListener ();

	NS_METHOD InitForPersist (nsIWebBrowserPersist *aPersist,
				  nsIURI *aURI,
				  nsIFile *aFile,
				  GaleonEmbedPersist *galeonPersist);

	nsresult Pause (void);
	nsresult Resume (void);
	nsresult Abort (void);

 private:
	NS_METHOD PrivateInit (void);
	NS_METHOD LaunchHelperApp (void);
	NS_METHOD SetRequest (nsIRequest *aRequest);

	nsCOMPtr<nsICancelable> mCancelable;
	nsCOMPtr<nsIRequest> mRequest;
	
	GaleonEmbedPersist *mGaleonPersist;
	
	nsCOMPtr<nsIURI> mUri;
	nsCOMPtr<nsIFile> mFile;
	nsCOMPtr<nsIURI> mTarget;
	
	PRInt64 mStartTime;
	PRInt64 mLastUpdate;

	PRBool mCanPause;
	PRBool mIsPaused;
	PRBool mAddToRecent;
	
	Download *mDownload;
	PRInt64   mContentLength;
	GulCString mContentType;

	nsCOMPtr<nsIMIMEInfo> mMIMEInfo;
};

nsresult 
InitiateMozillaDownload (nsIURI *sourceURI, nsILocalFile* inDestFile,
			 GaleonEmbedPersist *embedPersist,
			 nsIDOMDocument *domDocument, 
			 nsISupports *cacheKey,
			 nsIInputStream *postData,
			 PRBool decode,
			 nsIURI *displayURI);

nsresult
BuildDownloadPath (const char *defaultFileName, GtkWidget *parent,
		   nsILocalFile **_retval);

#endif // PROGRESSLISTENER2_H__