File: ProgressListener.h

package info (click to toggle)
galeon 2.0.2-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 19,212 kB
  • ctags: 9,891
  • sloc: ansic: 77,793; cpp: 15,301; sh: 8,961; xml: 5,761; makefile: 888
file content (153 lines) | stat: -rw-r--r-- 4,157 bytes parent folder | download
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 *  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>

#ifdef HAVE_NSITRANSFER_H
#include <nsITransfer.h>
#else
#include <nsIDownload.h>
#endif
#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 : 
#ifdef HAVE_NSITRANSFER_H
			  public nsITransfer,
#else
			  public nsIDownload,
			  public nsIWebProgressListener,
#endif
 			  public nsSupportsWeakReference
{
 public:
 	NS_DECL_ISUPPORTS
	NS_DECL_NSIWEBPROGRESSLISTENER
#ifdef HAVE_NSIWEBPROGRESSLISTENER2_H
	NS_DECL_NSIWEBPROGRESSLISTENER2
#else
	NS_METHOD OnProgressChange64 (nsIWebProgress *aWebProgress,
				      nsIRequest *aRequest,
				      PRInt64 aCurSelfProgress,
				      PRInt64 aMaxSelfProgress,
				      PRInt64 aCurTotalProgress,
				      PRInt64 aMaxTotalProgress);
#endif
#ifndef HAVE_NSITRANSFER_H
	NS_DECL_NSIDOWNLOAD
#endif
	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);

#ifdef HAVE_NSITRANSFER_NSICANCELABLE
	nsCOMPtr<nsICancelable> mCancelable;
#else
	nsCOMPtr<nsIWebBrowserPersist> mPersist;
	nsCOMPtr<nsIObserver> mObserver;
#endif
	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__