Compare commits
188 Commits
test
...
HttpConnec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62260249d7 | ||
|
|
ef04ff435d | ||
|
|
3ee96f57b8 | ||
|
|
f26f30b4c5 | ||
|
|
ce3e6ddbf9 | ||
|
|
54d006d031 | ||
|
|
6d979a3f4b | ||
|
|
6795a88baf | ||
|
|
8be0416d54 | ||
|
|
93d7718522 | ||
|
|
e7457f6c5e | ||
|
|
3355b20538 | ||
|
|
e38c0729b3 | ||
|
|
54e8ca8f3b | ||
|
|
bf655521c6 | ||
|
|
4db19a052e | ||
|
|
80364fb1a4 | ||
|
|
8f7941b6f1 | ||
|
|
55e1ff9673 | ||
|
|
ab3135f787 | ||
|
|
52c9c730d8 | ||
|
|
b3956fe708 | ||
|
|
63d68c34fd | ||
|
|
96a41c2c14 | ||
|
|
08fd9995e0 | ||
|
|
2ca3743459 | ||
|
|
8a48845120 | ||
|
|
bc09fdf610 | ||
|
|
802b66d97d | ||
|
|
96083a1e49 | ||
|
|
31989208be | ||
|
|
29d9b38fe8 | ||
|
|
a8f751a9d9 | ||
|
|
81066b3e6e | ||
|
|
e462d551cb | ||
|
|
09b30c7d5a | ||
|
|
96b0c82bcf | ||
|
|
15ffdf8caa | ||
|
|
0262c5af7e | ||
|
|
01ca73096c | ||
|
|
dadf65501b | ||
|
|
348ee07541 | ||
|
|
dbe972baa8 | ||
|
|
f5d02b707a | ||
|
|
258f97e0cd | ||
|
|
95cdab9527 | ||
|
|
7a5dbad111 | ||
|
|
3e08b330b5 | ||
|
|
f058c57c79 | ||
|
|
b8032d0c21 | ||
|
|
4a6fc79ce2 | ||
|
|
0b5526cd2c | ||
|
|
03d7306f8b | ||
|
|
7ff9289c01 | ||
|
|
7fe1a07870 | ||
|
|
010c993ecc | ||
|
|
17fbfd000c | ||
|
|
cca34ca60b | ||
|
|
45374a5c34 | ||
|
|
17778cbb4a | ||
|
|
b757903490 | ||
|
|
341c5930e6 | ||
|
|
c8b278e410 | ||
|
|
e3e7aaa151 | ||
|
|
d1e31737be | ||
|
|
24ba71145e | ||
|
|
b3d65cb774 | ||
|
|
129ffc6314 | ||
|
|
b52ef0d361 | ||
|
|
a409e246b6 | ||
|
|
343e849a97 | ||
|
|
76e256eaa3 | ||
|
|
a7fdcf52fa | ||
|
|
cd099d2cbc | ||
|
|
f7deb0fa0b | ||
|
|
cd47bfdae2 | ||
|
|
f91fdf403e | ||
|
|
09f6fd004d | ||
|
|
ea9dbc1fa2 | ||
|
|
cde877f50f | ||
|
|
13aefaef6b | ||
|
|
498945875e | ||
|
|
2e0e94ae65 | ||
|
|
7b7422e29a | ||
|
|
d84a726e54 | ||
|
|
73880344b4 | ||
|
|
1b45fe664e | ||
|
|
2f6c90b945 | ||
|
|
644337e67b | ||
|
|
22654d4d46 | ||
|
|
34fba3d4c0 | ||
|
|
e693567a2e | ||
|
|
1c256a65b9 | ||
|
|
bfd50df9de | ||
|
|
edd4b252cd | ||
|
|
73ee7fdc9a | ||
|
|
96eeeb78af | ||
|
|
ea54c51a9d | ||
|
|
7dcb9cc71e | ||
|
|
aa97b1196f | ||
|
|
c85775f835 | ||
|
|
0c98acd0ca | ||
|
|
e928f09133 | ||
|
|
a392db3c90 | ||
|
|
4bae98b66c | ||
|
|
785b49036d | ||
|
|
2596789db7 | ||
|
|
407bbe2241 | ||
|
|
f35727b8ea | ||
|
|
dccd3fea0e | ||
|
|
75ece73a17 | ||
|
|
2ca018925a | ||
|
|
c913fbc495 | ||
|
|
f3fef266f1 | ||
|
|
22764d875c | ||
|
|
774f30876b | ||
|
|
700f64697f | ||
|
|
48e663acf8 | ||
|
|
52efc959be | ||
|
|
5920a24815 | ||
|
|
f67fb40d23 | ||
|
|
bd8bea34a9 | ||
|
|
d3a97bdb9e | ||
|
|
7b767f7ab5 | ||
|
|
59a0933f9d | ||
|
|
8e96dfd851 | ||
|
|
3d39ad60e2 | ||
|
|
7381c52b0f | ||
|
|
0cd86a0e53 | ||
|
|
66cd209313 | ||
|
|
9e5e3dc4f8 | ||
|
|
05af1518f0 | ||
|
|
faaeef8dd0 | ||
|
|
91a290a394 | ||
|
|
6c53a6fa81 | ||
|
|
c30d3dc75c | ||
|
|
0f93d336e4 | ||
|
|
e3451cffcc | ||
|
|
c0a2d2872c | ||
|
|
188591212e | ||
|
|
12228ebdea | ||
|
|
5cccdcfb92 | ||
|
|
1e12ea24d8 | ||
|
|
86bc259321 | ||
|
|
5f592da9ec | ||
|
|
88e1476dcc | ||
|
|
7401de36e0 | ||
|
|
fd3d77122b | ||
|
|
b5e422c515 | ||
|
|
f8b07e1d79 | ||
|
|
25b34db661 | ||
|
|
4ef5a05f6e | ||
|
|
72467e9543 | ||
|
|
5ad305a325 | ||
|
|
4ad5e810d4 | ||
|
|
e9295b308b | ||
|
|
e561e68462 | ||
|
|
ec68a17487 | ||
|
|
87d17ebb9b | ||
|
|
c871441282 | ||
|
|
8e676fcec9 | ||
|
|
01902287ba | ||
|
|
284de57c74 | ||
|
|
7defd5c982 | ||
|
|
196d5f01e3 | ||
|
|
e20d8aa5c0 | ||
|
|
50504e342c | ||
|
|
b841b1c329 | ||
|
|
3c3b40c6a4 | ||
|
|
420c4bdd1e | ||
|
|
32278d385e | ||
|
|
c3af281416 | ||
|
|
aeff9e633b | ||
|
|
29112c02e3 | ||
|
|
a80623ea05 | ||
|
|
252b1505d4 | ||
|
|
9604b2c9e7 | ||
|
|
dee90d33b6 | ||
|
|
e45e176315 | ||
|
|
8c6b501871 | ||
|
|
6ce46da402 | ||
|
|
6a81aac1ee | ||
|
|
efc73f0976 | ||
|
|
5438ed3f24 | ||
|
|
bc635e6b90 | ||
|
|
5b0ac3f43e | ||
|
|
48541d57ac | ||
|
|
a7d10a1cd7 |
27
mozilla/content/build/gbdate.pl
Executable file
27
mozilla/content/build/gbdate.pl
Executable file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
# XP way of doing the build date.
|
||||
# 1998091509 = 1998, September, 15th, 9am local time zone
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
|
||||
# localtime returns year minus 1900
|
||||
$year = $year + 1900;
|
||||
printf("#define PRODUCT_VERSION \"%04d%02d%02d\"\n", $year, 1+$mon, $mday);
|
||||
90
mozilla/content/build/nsContentHTTPStartup.cpp
Normal file
90
mozilla/content/build/nsContentHTTPStartup.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsContentHTTPStartup.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "gbdate.h"
|
||||
|
||||
#define PRODUCT_NAME "Gecko"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentHTTPStartup,nsIObserver)
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::Observe( nsISupports *aSubject,
|
||||
const PRUnichar *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (nsCRT::strcmp(aTopic, NS_HTTP_STARTUP_TOPIC) != 0)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = nsnull;
|
||||
|
||||
nsCOMPtr<nsIHttpProtocolHandler> http(do_QueryInterface(aSubject));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProduct(PRODUCT_NAME);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProductSub((char*) PRODUCT_VERSION);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::RegisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString previousEntry;
|
||||
rv = catMan->AddCategoryEntry(NS_HTTP_STARTUP_CATEGORY,
|
||||
"Content UserAgent Setter",
|
||||
NS_CONTENTHTTPSTARTUP_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE,
|
||||
getter_Copies(previousEntry));
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::UnregisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
5215
mozilla/content/html/document/src/nsHTMLContentSink.cpp
Normal file
5215
mozilla/content/html/document/src/nsHTMLContentSink.cpp
Normal file
File diff suppressed because it is too large
Load Diff
3513
mozilla/content/html/document/src/nsHTMLDocument.cpp
Normal file
3513
mozilla/content/html/document/src/nsHTMLDocument.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1424
mozilla/content/xbl/src/nsXBLService.cpp
Normal file
1424
mozilla/content/xbl/src/nsXBLService.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1126
mozilla/content/xml/document/src/nsXMLDocument.cpp
Normal file
1126
mozilla/content/xml/document/src/nsXMLDocument.cpp
Normal file
File diff suppressed because it is too large
Load Diff
121
mozilla/content/xml/document/src/nsXMLDocument.h
Normal file
121
mozilla/content/xml/document/src/nsXMLDocument.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsXMLDocument_h___
|
||||
#define nsXMLDocument_h___
|
||||
|
||||
#include "nsMarkupDocument.h"
|
||||
#include "nsIXMLDocument.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
|
||||
class nsIParser;
|
||||
class nsIDOMNode;
|
||||
class nsICSSLoader;
|
||||
class nsIURI;
|
||||
|
||||
class nsXMLDocument : public nsMarkupDocument,
|
||||
public nsIXMLDocument,
|
||||
public nsIHTMLContentContainer,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIHttpEventSink
|
||||
{
|
||||
public:
|
||||
nsXMLDocument();
|
||||
virtual ~nsXMLDocument();
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
NS_IMETHOD Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup);
|
||||
|
||||
NS_IMETHOD GetContentType(nsAWritableString& aContentType) const;
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* channel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE);
|
||||
|
||||
NS_IMETHOD EndLoad();
|
||||
|
||||
NS_IMETHOD GetBaseTarget(nsAWritableString &aBaseTarget);
|
||||
NS_IMETHOD SetBaseTarget(const nsAReadableString &aBaseTarget);
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDocumentType);
|
||||
NS_IMETHOD CreateCDATASection(const nsAReadableString& aData, nsIDOMCDATASection** aReturn);
|
||||
NS_IMETHOD CreateEntityReference(const nsAReadableString& aName, nsIDOMEntityReference** aReturn);
|
||||
NS_IMETHOD CreateProcessingInstruction(const nsAReadableString& aTarget, const nsAReadableString& aData, nsIDOMProcessingInstruction** aReturn);
|
||||
NS_IMETHOD CreateElement(const nsAReadableString& aTagName,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD ImportNode(nsIDOMNode* aImportedNode,
|
||||
PRBool aDeep,
|
||||
nsIDOMNode** aReturn);
|
||||
NS_IMETHOD CreateElementNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aQualifiedName,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateAttributeNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aQualifiedName,
|
||||
nsIDOMAttr** aReturn);
|
||||
NS_IMETHOD GetElementById(const nsAReadableString& aElementId,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD Load(const nsAReadableString& aUrl);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
NS_IMETHOD SetDefaultStylesheets(nsIURI* aUrl);
|
||||
NS_IMETHOD SetTitle(const PRUnichar *aTitle);
|
||||
|
||||
// nsIHTMLContentContainer
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
|
||||
NS_IMETHOD GetCSSLoader(nsICSSLoader*& aLoader);
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
NS_IMETHOD GetInterface(const nsIID& aIID, void** aSink);
|
||||
|
||||
// nsIHTTPEventSink
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
|
||||
protected:
|
||||
virtual void InternalAddStyleSheet(nsIStyleSheet* aSheet); // subclass hook for sheet ordering
|
||||
virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
|
||||
|
||||
// For HTML elements in our content model
|
||||
// XXX This is not clean, but is there a better way?
|
||||
nsIHTMLStyleSheet* mAttrStyleSheet;
|
||||
nsIHTMLCSSStyleSheet* mInlineStyleSheet;
|
||||
nsString mBaseTarget;
|
||||
|
||||
nsIParser *mParser;
|
||||
nsICSSLoader* mCSSLoader;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsXMLDocument_h___
|
||||
4989
mozilla/docshell/base/nsDocShell.cpp
Normal file
4989
mozilla/docshell/base/nsDocShell.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1438
mozilla/docshell/base/nsWebShell.cpp
Normal file
1438
mozilla/docshell/base/nsWebShell.cpp
Normal file
File diff suppressed because it is too large
Load Diff
4555
mozilla/dom/src/base/nsGlobalWindow.cpp
Normal file
4555
mozilla/dom/src/base/nsGlobalWindow.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1210
mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp
Normal file
1210
mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp
Normal file
File diff suppressed because it is too large
Load Diff
250
mozilla/extensions/cookie/nsCookieHTTPNotify.cpp
Normal file
250
mozilla/extensions/cookie/nsCookieHTTPNotify.cpp
Normal file
@@ -0,0 +1,250 @@
|
||||
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifdef DEBUG_dp
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "nsCookieService.h" /* don't remove -- needed for mac build */
|
||||
#include "nsCookieHTTPNotify.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsCookie.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsINetModuleMgr.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIHttpProtocolHandler.h" // for NS_HTTP_STARTUP_CATEGORY
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIPrompt.h"
|
||||
|
||||
static NS_DEFINE_CID(kINetModuleMgrCID, NS_NETMODULEMGR_CID);
|
||||
|
||||
///////////////////////////////////
|
||||
// nsISupports
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsCookieHTTPNotify, nsIHttpNotify, nsINetNotify);
|
||||
|
||||
///////////////////////////////////
|
||||
// nsCookieHTTPNotify Implementation
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCookieHTTPNotify, Init)
|
||||
|
||||
nsresult nsCookieHTTPNotify::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
return nsCookieHTTPNotifyConstructor(aOuter, aIID, aResult);
|
||||
}
|
||||
|
||||
NS_METHOD nsCookieHTTPNotify::RegisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
// Register ourselves into the NS_CATEGORY_HTTP_STARTUP
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString prevEntry;
|
||||
rv = catman->AddCategoryEntry(NS_HTTP_STARTUP_CATEGORY, "Http Cookie Notify", NS_COOKIEHTTPNOTIFY_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(prevEntry));
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_METHOD nsCookieHTTPNotify::UnregisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString prevEntry;
|
||||
rv = catman->DeleteCategoryEntry(NS_HTTP_STARTUP_CATEGORY, NS_COOKIEHTTPNOTIFY_CONTRACTID, PR_TRUE,
|
||||
getter_Copies(prevEntry));
|
||||
|
||||
// Return value is not used from this function.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::Init()
|
||||
{
|
||||
// Register to handing http requests and responses
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsINetModuleMgr> pNetModuleMgr = do_GetService(kINetModuleMgrCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = pNetModuleMgr->RegisterModule(NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_CONTRACTID,
|
||||
(nsIHttpNotify *)this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = pNetModuleMgr->RegisterModule(NS_NETWORK_MODULE_MANAGER_HTTP_RESPONSE_CONTRACTID,
|
||||
(nsIHttpNotify *)this);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCookieHTTPNotify::nsCookieHTTPNotify()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mCookieService = nsnull;
|
||||
#ifdef DEBUG_dp
|
||||
printf("CookieHTTPNotify Created.\n");
|
||||
#endif /* DEBUG_dp */
|
||||
}
|
||||
|
||||
nsCookieHTTPNotify::~nsCookieHTTPNotify()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::SetupCookieService()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!mCookieService)
|
||||
{
|
||||
mCookieService = do_GetService(NS_COOKIESERVICE_CONTRACTID, &rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// nsIHttpNotify
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::OnModifyRequest(nsIHttpChannel *aHttpChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
// Preconditions
|
||||
NS_ENSURE_ARG_POINTER(aHttpChannel);
|
||||
|
||||
// Get the url
|
||||
nsCOMPtr<nsIURI> pURL;
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the original url that the user either typed in or clicked on
|
||||
nsCOMPtr<nsILoadGroup> pLoadGroup;
|
||||
rv = aHttpChannel->GetLoadGroup(getter_AddRefs(pLoadGroup));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> pChannel;
|
||||
if (pLoadGroup) {
|
||||
nsCOMPtr<nsIRequest> pRequest;
|
||||
rv = pLoadGroup->GetDefaultLoadRequest(getter_AddRefs(pRequest));
|
||||
if (pRequest)
|
||||
pChannel = do_QueryInterface(pRequest);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> pFirstURL;
|
||||
if (pChannel) {
|
||||
rv = pChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
} else {
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Ensure that the cookie service exists
|
||||
rv = SetupCookieService();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char * cookie;
|
||||
rv = mCookieService->GetCookieStringFromHttp(pURL, pFirstURL, &cookie);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Set the cookie into the request headers
|
||||
if (cookie && *cookie)
|
||||
rv = aHttpChannel->SetRequestHeader("Cookie", cookie);
|
||||
nsMemory::Free((void *)cookie);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::OnExamineResponse(nsIHttpChannel *aHttpChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
// Preconditions
|
||||
NS_ENSURE_ARG_POINTER(aHttpChannel);
|
||||
|
||||
// Get the Cookie header
|
||||
nsXPIDLCString cookieHeader;
|
||||
rv = aHttpChannel->GetResponseHeader("Set-Cookie", getter_Copies(cookieHeader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!cookieHeader) return NS_OK; // not an error, there's just no header.
|
||||
|
||||
// Get the url
|
||||
nsCOMPtr<nsIURI> pURL;
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the original url that the user either typed in or clicked on
|
||||
nsCOMPtr<nsILoadGroup> pLoadGroup;
|
||||
rv = aHttpChannel->GetLoadGroup(getter_AddRefs(pLoadGroup));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIChannel> pChannel;
|
||||
if (pLoadGroup) {
|
||||
nsCOMPtr<nsIRequest> pRequest;
|
||||
rv = pLoadGroup->GetDefaultLoadRequest(getter_AddRefs(pRequest));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
pChannel = do_QueryInterface(pRequest);
|
||||
}
|
||||
nsCOMPtr<nsIURI> pFirstURL;
|
||||
if (pChannel) {
|
||||
rv = pChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
} else {
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the prompter
|
||||
nsCOMPtr<nsIInterfaceRequestor> pInterfaces;
|
||||
nsCOMPtr<nsIPrompt> pPrompter;
|
||||
if (pChannel) {
|
||||
pChannel->GetNotificationCallbacks(getter_AddRefs(pInterfaces));
|
||||
} else {
|
||||
aHttpChannel->GetNotificationCallbacks(getter_AddRefs(pInterfaces));
|
||||
}
|
||||
if (pInterfaces)
|
||||
pInterfaces->GetInterface(NS_GET_IID(nsIPrompt), getter_AddRefs(pPrompter));
|
||||
|
||||
// Get the expires
|
||||
nsXPIDLCString dateHeader;
|
||||
rv = aHttpChannel->GetResponseHeader("Date", getter_Copies(dateHeader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Ensure that we have the cookie service
|
||||
rv = SetupCookieService();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Save the cookie
|
||||
rv = mCookieService->SetCookieStringFromHttp(pURL, pFirstURL, pPrompter, cookieHeader, dateHeader);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
71
mozilla/extensions/cookie/nsCookieHTTPNotify.h
Normal file
71
mozilla/extensions/cookie/nsCookieHTTPNotify.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsCookieHTTPNotify_h___
|
||||
#define nsCookieHTTPNotify_h___
|
||||
|
||||
#include "nsIHttpNotify.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
// {6BC1F522-1F45-11d3-8AD4-00105A1B8860}
|
||||
#define NS_COOKIEHTTPNOTIFY_CID \
|
||||
{ 0x6bc1f522, 0x1f45, 0x11d3, { 0x8a, 0xd4, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } }
|
||||
|
||||
#define NS_COOKIEHTTPNOTIFY_CONTRACTID "@mozilla.org/cookie-notifier;1"
|
||||
#define NS_COOKIEHTTPNOTIFY_CLASSNAME "Cookie Notifier"
|
||||
|
||||
struct nsModuleComponentInfo; // forward declaration
|
||||
|
||||
class nsCookieHTTPNotify : public nsIHttpNotify {
|
||||
public:
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// Init method
|
||||
NS_IMETHOD Init();
|
||||
|
||||
// nsIHttpNotify methods:
|
||||
NS_DECL_NSIHTTPNOTIFY
|
||||
|
||||
// nsCookieHTTPNotify methods:
|
||||
nsCookieHTTPNotify();
|
||||
virtual ~nsCookieHTTPNotify();
|
||||
|
||||
static nsresult Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType,
|
||||
const nsModuleComponentInfo *info);
|
||||
static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const nsModuleComponentInfo *info);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsICookieService> mCookieService;
|
||||
|
||||
NS_IMETHOD SetupCookieService();
|
||||
};
|
||||
#endif /* nsCookieHTTPNotify_h___ */
|
||||
43
mozilla/extensions/datetime/Makefile.in
Normal file
43
mozilla/extensions/datetime/Makefile.in
Normal file
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = necko
|
||||
LIBRARY_NAME = nkdatetm_s
|
||||
REQUIRES = xpcom string
|
||||
|
||||
CPPSRCS = \
|
||||
nsDateTimeHandler.cpp \
|
||||
nsDateTimeChannel.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
327
mozilla/extensions/datetime/nsDateTimeChannel.cpp
Normal file
327
mozilla/extensions/datetime/nsDateTimeChannel.cpp
Normal file
@@ -0,0 +1,327 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// datetime implementation
|
||||
|
||||
#include "nsDateTimeChannel.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
#include "nsITransport.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
|
||||
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
|
||||
|
||||
// nsDateTimeChannel methods
|
||||
nsDateTimeChannel::nsDateTimeChannel() {
|
||||
NS_INIT_REFCNT();
|
||||
mContentLength = -1;
|
||||
mPort = -1;
|
||||
}
|
||||
|
||||
nsDateTimeChannel::~nsDateTimeChannel() {
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS4(nsDateTimeChannel,
|
||||
nsIChannel,
|
||||
nsIRequest,
|
||||
nsIStreamListener,
|
||||
nsIRequestObserver)
|
||||
|
||||
nsresult
|
||||
nsDateTimeChannel::Init(nsIURI* uri)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_ASSERTION(uri, "no uri");
|
||||
|
||||
mUrl = uri;
|
||||
|
||||
rv = mUrl->GetPort(&mPort);
|
||||
if (NS_FAILED(rv) || mPort < 1)
|
||||
mPort = DATETIME_PORT;
|
||||
|
||||
rv = mUrl->GetPath(getter_Copies(mHost));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!*(const char *)mHost) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsDateTimeChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
|
||||
{
|
||||
nsDateTimeChannel* dc = new nsDateTimeChannel();
|
||||
if (dc == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(dc);
|
||||
nsresult rv = dc->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(dc);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRequest methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetName(PRUnichar* *result)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::IsPending(PRBool *result)
|
||||
{
|
||||
NS_NOTREACHED("nsDateTimeChannel::IsPending");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetStatus(nsresult *status)
|
||||
{
|
||||
*status = NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::Cancel(nsresult status)
|
||||
{
|
||||
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
|
||||
NS_NOTREACHED("nsDateTimeChannel::Cancel");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::Suspend(void)
|
||||
{
|
||||
NS_NOTREACHED("nsDateTimeChannel::Suspend");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::Resume(void)
|
||||
{
|
||||
NS_NOTREACHED("nsDateTimeChannel::Resume");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIChannel methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetOriginalURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mOriginalURI ? mOriginalURI : mUrl;
|
||||
NS_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetOriginalURI(nsIURI* aURI)
|
||||
{
|
||||
mOriginalURI = aURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mUrl;
|
||||
NS_IF_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::Open(nsIInputStream **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsITransport> transport;
|
||||
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
transport->SetNotificationCallbacks(mCallbacks,
|
||||
(mLoadFlags & LOAD_BACKGROUND));
|
||||
|
||||
return transport->OpenInputStream(0, -1, 0, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsITransport> transport;
|
||||
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
transport->SetNotificationCallbacks(mCallbacks,
|
||||
(mLoadFlags & LOAD_BACKGROUND));
|
||||
|
||||
mListener = aListener;
|
||||
|
||||
nsCOMPtr<nsIRequest> request;
|
||||
return transport->AsyncRead(this, ctxt, 0, -1, 0, getter_AddRefs(request));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetLoadFlags(PRUint32 *aLoadFlags)
|
||||
{
|
||||
*aLoadFlags = mLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetLoadFlags(PRUint32 aLoadFlags)
|
||||
{
|
||||
mLoadFlags = aLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define DATETIME_TYPE "text/plain"
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetContentType(char* *aContentType) {
|
||||
if (!aContentType) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aContentType = nsCRT::strdup(DATETIME_TYPE);
|
||||
if (!*aContentType) return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetContentType(const char *aContentType)
|
||||
{
|
||||
//It doesn't make sense to set the content-type on this type
|
||||
// of channel...
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetContentLength(PRInt32 *aContentLength)
|
||||
{
|
||||
*aContentLength = mContentLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetContentLength(PRInt32 aContentLength)
|
||||
{
|
||||
NS_NOTREACHED("nsDateTimeChannel::SetContentLength");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
if (mLoadGroup) // if we already had a load group remove ourselves...
|
||||
(void)mLoadGroup->RemoveRequest(this, nsnull, NS_OK);
|
||||
|
||||
mLoadGroup = aLoadGroup;
|
||||
if (mLoadGroup) {
|
||||
return mLoadGroup->AddRequest(this, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
*aOwner = mOwner.get();
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::GetSecurityInfo(nsISupports **sec)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(sec);
|
||||
*sec = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIRequestObserver methods
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::OnStartRequest(nsIRequest *request, nsISupports *aContext) {
|
||||
return mListener->OnStartRequest(this, aContext);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext,
|
||||
nsresult aStatus) {
|
||||
if (mLoadGroup) {
|
||||
nsresult rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return mListener->OnStopRequest(this, aContext, aStatus);
|
||||
}
|
||||
|
||||
|
||||
// nsIStreamListener method
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeChannel::OnDataAvailable(nsIRequest *request, nsISupports* aContext,
|
||||
nsIInputStream *aInputStream, PRUint32 aSourceOffset,
|
||||
PRUint32 aLength) {
|
||||
mContentLength = aLength;
|
||||
return mListener->OnDataAvailable(this, aContext, aInputStream, aSourceOffset, aLength);
|
||||
}
|
||||
|
||||
78
mozilla/extensions/datetime/nsDateTimeChannel.h
Normal file
78
mozilla/extensions/datetime/nsDateTimeChannel.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// A datetime channel retrieves date time information from
|
||||
// RFC 867 compliant datetime servers. The date/time returned
|
||||
// to the caller is of MIME type "text/plain".
|
||||
|
||||
#ifndef nsDateTimeChannel_h___
|
||||
#define nsDateTimeChannel_h___
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsDateTimeHandler.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
|
||||
class nsDateTimeChannel
|
||||
: public nsIChannel,
|
||||
public nsIStreamListener {
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSICHANNEL
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
// nsDateTimeChannel methods:
|
||||
nsDateTimeChannel();
|
||||
virtual ~nsDateTimeChannel();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
|
||||
nsresult Init(nsIURI* uri);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mUrl;
|
||||
nsCOMPtr<nsIStreamListener> mListener;
|
||||
PRUint32 mLoadFlags;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCString mContentType;
|
||||
PRInt32 mContentLength;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
||||
PRInt32 mPort;
|
||||
nsXPIDLCString mHost;
|
||||
};
|
||||
|
||||
#endif /* nsDateTimeChannel_h___ */
|
||||
117
mozilla/extensions/datetime/nsDateTimeHandler.cpp
Normal file
117
mozilla/extensions/datetime/nsDateTimeHandler.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsDateTimeChannel.h"
|
||||
#include "nsDateTimeHandler.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsDateTimeHandler::nsDateTimeHandler() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsDateTimeHandler::~nsDateTimeHandler() {
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDateTimeHandler, nsIProtocolHandler)
|
||||
|
||||
NS_METHOD
|
||||
nsDateTimeHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) {
|
||||
|
||||
nsDateTimeHandler* ph = new nsDateTimeHandler();
|
||||
if (ph == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(ph);
|
||||
nsresult rv = ph->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(ph);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProtocolHandler methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeHandler::GetScheme(char* *result) {
|
||||
*result = nsCRT::strdup("datetime");
|
||||
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeHandler::GetDefaultPort(PRInt32 *result) {
|
||||
*result = DATETIME_PORT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
nsIURI **result) {
|
||||
nsresult rv;
|
||||
|
||||
// no concept of a relative datetime url
|
||||
NS_ASSERTION(!aBaseURI, "base url passed into datetime protocol handler");
|
||||
|
||||
nsIURI* url;
|
||||
rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
|
||||
NS_GET_IID(nsIURI),
|
||||
(void**)&url);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = url->SetSpec((char*)aSpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(url);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = url;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDateTimeHandler::NewChannel(nsIURI* url, nsIChannel* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsDateTimeChannel* channel;
|
||||
rv = nsDateTimeChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->Init(url);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = channel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
51
mozilla/extensions/datetime/nsDateTimeHandler.h
Normal file
51
mozilla/extensions/datetime/nsDateTimeHandler.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// The datetime protocol handler creates "datetime" URIs of the form
|
||||
// "datetime:RFC867Server".
|
||||
|
||||
#ifndef nsDateTimeHandler_h___
|
||||
#define nsDateTimeHandler_h___
|
||||
|
||||
#include "nsIProtocolHandler.h"
|
||||
|
||||
#define DATETIME_PORT 13
|
||||
|
||||
// {AA27D2A0-B71B-11d3-A1A0-0050041CAF44}
|
||||
#define NS_DATETIMEHANDLER_CID \
|
||||
{ 0xaa27d2a0, 0xb71b, 0x11d3, { 0xa1, 0xa0, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } }
|
||||
|
||||
class nsDateTimeHandler : public nsIProtocolHandler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
|
||||
// nsDateTimeHandler methods:
|
||||
nsDateTimeHandler();
|
||||
virtual ~nsDateTimeHandler();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
};
|
||||
|
||||
#endif /* nsDateTimeHandler_h___ */
|
||||
34
mozilla/extensions/datetime/nsDateTimeModule.cpp
Normal file
34
mozilla/extensions/datetime/nsDateTimeModule.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsDateTimeHandler.h"
|
||||
|
||||
static nsModuleComponentInfo gResComponents[] = {
|
||||
{ "The DateTime Protocol Handler",
|
||||
NS_DATETIMEHANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "datetime",
|
||||
nsDateTimeHandler::Create
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(datetime, gResComponents)
|
||||
42
mozilla/extensions/finger/Makefile.in
Normal file
42
mozilla/extensions/finger/Makefile.in
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Brian Ryner.
|
||||
# Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Brian Ryner <bryner@uiuc.edu>
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = necko
|
||||
LIBRARY_NAME = nkfinger_s
|
||||
REQUIRES = xpcom string mimetype
|
||||
|
||||
CPPSRCS = \
|
||||
nsFingerHandler.cpp \
|
||||
nsFingerChannel.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
427
mozilla/extensions/finger/nsFingerChannel.cpp
Normal file
427
mozilla/extensions/finger/nsFingerChannel.cpp
Normal file
@@ -0,0 +1,427 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@uiuc.edu>
|
||||
*/
|
||||
|
||||
// finger implementation
|
||||
|
||||
#include "nsFingerChannel.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsITXTToHTMLConv.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
|
||||
#define BUFFER_SEG_SIZE (4*1024)
|
||||
#define BUFFER_MAX_SIZE (64*1024)
|
||||
|
||||
// nsFingerChannel methods
|
||||
nsFingerChannel::nsFingerChannel()
|
||||
: mContentLength(-1),
|
||||
mActAsObserver(PR_TRUE),
|
||||
mPort(-1),
|
||||
mStatus(NS_OK)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsFingerChannel::~nsFingerChannel() {
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel,
|
||||
nsIChannel,
|
||||
nsIRequest,
|
||||
nsIStreamListener,
|
||||
nsIRequestObserver)
|
||||
|
||||
nsresult
|
||||
nsFingerChannel::Init(nsIURI* uri)
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPIDLCString autoBuffer;
|
||||
|
||||
NS_ASSERTION(uri, "no uri");
|
||||
|
||||
mUrl = uri;
|
||||
|
||||
// For security reasons, we do not allow the user to specify a
|
||||
// non-default port for finger: URL's.
|
||||
|
||||
mPort = FINGER_PORT;
|
||||
|
||||
rv = mUrl->GetPath(getter_Copies(autoBuffer)); // autoBuffer = user@host
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Now parse out the user and host
|
||||
const char* buf = autoBuffer.get();
|
||||
const char* pos = PL_strchr(buf, '@');
|
||||
|
||||
// Catch the case of just the host being given
|
||||
if (!pos) {
|
||||
mHost.Assign(buf);
|
||||
} else {
|
||||
mUser.Assign(buf,pos-buf);
|
||||
mHost.Assign(pos+1); // ignore '@'
|
||||
}
|
||||
|
||||
if (mHost.IsEmpty()) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsFingerChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
|
||||
{
|
||||
nsFingerChannel* fc = new nsFingerChannel();
|
||||
if (fc == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(fc);
|
||||
nsresult rv = fc->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(fc);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRequest methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetName(PRUnichar* *result)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::IsPending(PRBool *result)
|
||||
{
|
||||
NS_NOTREACHED("nsFingerChannel::IsPending");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetStatus(nsresult *status)
|
||||
{
|
||||
*status = mStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::Cancel(nsresult status)
|
||||
{
|
||||
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
mStatus = status;
|
||||
if (mTransportRequest) {
|
||||
rv = mTransportRequest->Cancel(status);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::Suspend(void)
|
||||
{
|
||||
NS_NOTREACHED("nsFingerChannel::Suspend");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::Resume(void)
|
||||
{
|
||||
NS_NOTREACHED("nsFingerChannel::Resume");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIChannel methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetOriginalURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mOriginalURI ? mOriginalURI : mUrl;
|
||||
NS_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetOriginalURI(nsIURI* aURI)
|
||||
{
|
||||
mOriginalURI = aURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mUrl;
|
||||
NS_IF_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::Open(nsIInputStream **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE,
|
||||
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mTransport->SetNotificationCallbacks(mCallbacks,
|
||||
(mLoadFlags & LOAD_BACKGROUND));
|
||||
|
||||
return mTransport->OpenInputStream(0, PRUint32(-1), 0, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE,
|
||||
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mTransport->SetNotificationCallbacks(mCallbacks,
|
||||
(mLoadFlags & LOAD_BACKGROUND));
|
||||
|
||||
mListener = aListener;
|
||||
mResponseContext = ctxt;
|
||||
|
||||
return SendRequest(mTransport);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetLoadFlags(PRUint32 *aLoadFlags)
|
||||
{
|
||||
*aLoadFlags = mLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetLoadFlags(PRUint32 aLoadFlags)
|
||||
{
|
||||
mLoadFlags = aLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define FINGER_TYPE TEXT_HTML
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetContentType(char* *aContentType) {
|
||||
if (!aContentType) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aContentType = nsCRT::strdup(FINGER_TYPE);
|
||||
if (!*aContentType) return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetContentType(const char *aContentType)
|
||||
{
|
||||
//It doesn't make sense to set the content-type on this type
|
||||
// of channel...
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetContentLength(PRInt32 *aContentLength)
|
||||
{
|
||||
*aContentLength = mContentLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetContentLength(PRInt32 aContentLength)
|
||||
{
|
||||
NS_NOTREACHED("nsFingerChannel::SetContentLength");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
*aOwner = mOwner.get();
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
|
||||
{
|
||||
*aSecurityInfo = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIRequestObserver methods
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) {
|
||||
if (!mActAsObserver) {
|
||||
// acting as a listener
|
||||
return mListener->OnStartRequest(this, mResponseContext);
|
||||
} else {
|
||||
// we don't want to pass our AsyncWrite's OnStart through
|
||||
// we just ignore this
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext,
|
||||
nsresult aStatus)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (NS_FAILED(aStatus) || !mActAsObserver) {
|
||||
if (mLoadGroup) {
|
||||
rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
rv = mListener->OnStopRequest(this, mResponseContext, aStatus);
|
||||
mTransport = 0;
|
||||
return rv;
|
||||
} else {
|
||||
// at this point we know the request has been sent.
|
||||
// we're no longer acting as an observer.
|
||||
|
||||
mActAsObserver = PR_FALSE;
|
||||
nsCOMPtr<nsIStreamListener> converterListener;
|
||||
|
||||
NS_WITH_SERVICE(nsIStreamConverterService, StreamConvService,
|
||||
kStreamConverterServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString fromStr; fromStr.AssignWithConversion("text/plain");
|
||||
nsAutoString toStr; toStr.AssignWithConversion("text/html");
|
||||
|
||||
rv = StreamConvService->AsyncConvertData(fromStr.GetUnicode(),
|
||||
toStr.GetUnicode(), this, mResponseContext,
|
||||
getter_AddRefs(converterListener));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsITXTToHTMLConv> converter(do_QueryInterface(converterListener));
|
||||
if (converter) {
|
||||
nsAutoString title; title.AssignWithConversion("Finger information for ");
|
||||
nsXPIDLCString userHost;
|
||||
rv = mUrl->GetPath(getter_Copies(userHost));
|
||||
title.AppendWithConversion(userHost);
|
||||
converter->SetTitle(title.GetUnicode());
|
||||
converter->PreFormatHTML(PR_TRUE);
|
||||
}
|
||||
|
||||
return mTransport->AsyncRead(converterListener, mResponseContext, 0, PRUint32(-1), 0,
|
||||
getter_AddRefs(mTransportRequest));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// nsIStreamListener method
|
||||
NS_IMETHODIMP
|
||||
nsFingerChannel::OnDataAvailable(nsIRequest *aRequest, nsISupports* aContext,
|
||||
nsIInputStream *aInputStream, PRUint32 aSourceOffset,
|
||||
PRUint32 aLength) {
|
||||
mContentLength = aLength;
|
||||
return mListener->OnDataAvailable(this, mResponseContext, aInputStream, aSourceOffset, aLength);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFingerChannel::SendRequest(nsITransport* aTransport) {
|
||||
// The text to send should already be in mUser
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsISupports> result;
|
||||
nsCOMPtr<nsIInputStream> charstream;
|
||||
nsCString requestBuffer(mUser);
|
||||
|
||||
if (mLoadGroup) {
|
||||
mLoadGroup->AddRequest(this, nsnull);
|
||||
}
|
||||
|
||||
requestBuffer.Append(CRLF);
|
||||
|
||||
mRequest = requestBuffer.ToNewCString();
|
||||
|
||||
rv = NS_NewCharInputStream(getter_AddRefs(result), mRequest);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
charstream = do_QueryInterface(result, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = NS_AsyncWriteFromStream(getter_AddRefs(mTransportRequest),
|
||||
aTransport, charstream,
|
||||
0, requestBuffer.Length(), 0,
|
||||
this, nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
88
mozilla/extensions/finger/nsFingerChannel.h
Normal file
88
mozilla/extensions/finger/nsFingerChannel.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@uiuc.edu>
|
||||
*/
|
||||
|
||||
#ifndef nsFingerChannel_h___
|
||||
#define nsFingerChannel_h___
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsFingerHandler.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsITransport.h"
|
||||
|
||||
class nsFingerChannel
|
||||
: public nsIChannel,
|
||||
public nsIStreamListener {
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSICHANNEL
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
// nsFingerChannel methods:
|
||||
nsFingerChannel();
|
||||
virtual ~nsFingerChannel();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
|
||||
nsresult Init(nsIURI* uri);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mUrl;
|
||||
nsCOMPtr<nsIStreamListener> mListener;
|
||||
PRUint32 mLoadFlags;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCString mContentType;
|
||||
PRInt32 mContentLength;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
PRUint32 mBufferSegmentSize;
|
||||
PRUint32 mBufferMaxSize;
|
||||
PRBool mActAsObserver;
|
||||
|
||||
PRInt32 mPort;
|
||||
nsCString mHost;
|
||||
nsCString mUser;
|
||||
|
||||
nsXPIDLCString mRequest;
|
||||
|
||||
nsCOMPtr<nsISupports> mResponseContext;
|
||||
nsCOMPtr<nsITransport> mTransport;
|
||||
nsCOMPtr<nsIRequest> mTransportRequest;
|
||||
nsresult mStatus;
|
||||
|
||||
protected:
|
||||
nsresult SendRequest(nsITransport* aTransport);
|
||||
};
|
||||
|
||||
#endif /* nsFingerChannel_h___ */
|
||||
117
mozilla/extensions/finger/nsFingerHandler.cpp
Normal file
117
mozilla/extensions/finger/nsFingerHandler.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@uiuc.edu>
|
||||
*/
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsFingerChannel.h"
|
||||
#include "nsFingerHandler.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsFingerHandler::nsFingerHandler() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsFingerHandler::~nsFingerHandler() {
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsFingerHandler, nsIProtocolHandler)
|
||||
|
||||
NS_METHOD
|
||||
nsFingerHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) {
|
||||
|
||||
nsFingerHandler* ph = new nsFingerHandler();
|
||||
if (ph == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(ph);
|
||||
nsresult rv = ph->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(ph);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProtocolHandler methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerHandler::GetScheme(char* *result) {
|
||||
*result = nsCRT::strdup("finger");
|
||||
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerHandler::GetDefaultPort(PRInt32 *result) {
|
||||
*result = FINGER_PORT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
nsIURI **result) {
|
||||
nsresult rv;
|
||||
|
||||
// no concept of a relative finger url
|
||||
NS_ASSERTION(!aBaseURI, "base url passed into finger protocol handler");
|
||||
|
||||
nsIURI* url;
|
||||
rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
|
||||
NS_GET_IID(nsIURI),
|
||||
(void**)&url);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = url->SetSpec((char*)aSpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(url);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = url;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFingerHandler::NewChannel(nsIURI* url, nsIChannel* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsFingerChannel* channel;
|
||||
rv = nsFingerChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->Init(url);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = channel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
52
mozilla/extensions/finger/nsFingerHandler.h
Normal file
52
mozilla/extensions/finger/nsFingerHandler.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@uiuc.edu>
|
||||
*/
|
||||
|
||||
// The finger protocol handler creates "finger" URIs of the form
|
||||
// "finger:user@host" or "finger:host".
|
||||
|
||||
#ifndef nsFingerHandler_h___
|
||||
#define nsFingerHandler_h___
|
||||
|
||||
#include "nsIProtocolHandler.h"
|
||||
|
||||
#define FINGER_PORT 79
|
||||
|
||||
// {0x76d6d5d8-1dd2-11b2-b361-850ddf15ef07}
|
||||
#define NS_FINGERHANDLER_CID \
|
||||
{ 0x76d6d5d8, 0x1dd2, 0x11b2, \
|
||||
{0xb3, 0x61, 0x85, 0x0d, 0xdf, 0x15, 0xef, 0x07} }
|
||||
|
||||
class nsFingerHandler : public nsIProtocolHandler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
|
||||
// nsFingerHandler methods:
|
||||
nsFingerHandler();
|
||||
virtual ~nsFingerHandler();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
};
|
||||
|
||||
#endif /* nsFingerHandler_h___ */
|
||||
34
mozilla/extensions/finger/nsFingerModule.cpp
Normal file
34
mozilla/extensions/finger/nsFingerModule.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Brian Ryner.
|
||||
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@uiuc.edu>
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsFingerHandler.h"
|
||||
|
||||
static nsModuleComponentInfo gResComponents[] = {
|
||||
{ "The Finger Protocol Handler",
|
||||
NS_FINGERHANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "finger",
|
||||
nsFingerHandler::Create
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(finger, gResComponents)
|
||||
180
mozilla/extensions/xmlextras/base/public/nsIXMLHttpRequest.idl
Normal file
180
mozilla/extensions/xmlextras/base/public/nsIXMLHttpRequest.idl
Normal file
@@ -0,0 +1,180 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMDocument;
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIHttpChannel;
|
||||
|
||||
[scriptable, uuid(b7215e70-4157-11d4-9a42-000064657374)]
|
||||
interface nsIXMLHttpRequest : nsISupports {
|
||||
/**
|
||||
* Meant to be a script-only mechanism for setting a load event listener.
|
||||
* The attribute is expected to be JavaScript function object. When
|
||||
* the load event occurs, the function is invoked.
|
||||
* This attribute should not be used from native code!!
|
||||
*/
|
||||
attribute nsISupports onload;
|
||||
|
||||
/**
|
||||
* Meant to be a script-only mechanism for setting an error event listener.
|
||||
* The attribute is expected to be JavaScript function object. When
|
||||
* the error event occurs, the function is invoked.
|
||||
* This attribute should not be used from native code!!
|
||||
*/
|
||||
attribute nsISupports onerror;
|
||||
|
||||
/**
|
||||
* The HTTP request uses an HTTP channel in order to perform the
|
||||
* request. This attribute represents the HTTP channel used
|
||||
* for the request. NULL if the HTTP channel has not yet been
|
||||
* created.
|
||||
*/
|
||||
readonly attribute nsIHttpChannel channel;
|
||||
|
||||
/**
|
||||
* The response to the HTTP request is parsed as if it were a
|
||||
* text/xml stream. This attributes represents the response as
|
||||
* a DOM Document object. NULL if the request is unsuccessful or
|
||||
* has not yet been sent.
|
||||
*/
|
||||
readonly attribute nsIDOMDocument responseXML;
|
||||
|
||||
/**
|
||||
* The response to the HTTP request as text.
|
||||
* NULL if the request is unsuccessful or
|
||||
* has not yet been sent.
|
||||
*/
|
||||
readonly attribute wstring responseText;
|
||||
|
||||
|
||||
/**
|
||||
* The status of the response to the HTTP request.
|
||||
*/
|
||||
readonly attribute unsigned long status;
|
||||
|
||||
/**
|
||||
* The string representing the status of the response to the
|
||||
* HTTP request.
|
||||
*/
|
||||
readonly attribute string statusText;
|
||||
|
||||
/**
|
||||
* If the HTTP request has been sent already, this method will
|
||||
* abort the request.
|
||||
*/
|
||||
void abort();
|
||||
|
||||
/**
|
||||
* Returns all of the HTTP response headers as a string string.
|
||||
*
|
||||
* @returns A string containing all of the response headers.
|
||||
* NULL if the response has not yet been received.
|
||||
*/
|
||||
string getAllResponseHeaders();
|
||||
|
||||
/**
|
||||
* Returns the text of the header with the specified name.
|
||||
*
|
||||
* @param header The name of the header to retrieve
|
||||
* @returns A string containing the text of the header specified.
|
||||
* NULL if the response has not yet been received or the
|
||||
* header does not exist in the response.
|
||||
*/
|
||||
string getResponseHeader(in string header);
|
||||
|
||||
/**
|
||||
* Native (non-script) method to initialize a request. Note that
|
||||
* the HTTP request is not sent until the <code>send</code> method
|
||||
* is invoked.
|
||||
*
|
||||
* @param method The HTTP method - either "POST" or "GET".
|
||||
* @param url The URL to which to send the request.
|
||||
* @param async Whether the request is synchronous or asynchronous
|
||||
* i.e. whether send returns only after the response
|
||||
* is received or if it returns immediately after
|
||||
* sending the request. In the latter case, notification
|
||||
* of completion is sent through the event listeners.
|
||||
* @param user A username for authentication if necessary.
|
||||
* @param password A password for authentication if necessary.
|
||||
*/
|
||||
[noscript] void openRequest(in string method,
|
||||
in string url,
|
||||
in boolean async,
|
||||
in string user,
|
||||
in string password);
|
||||
|
||||
/**
|
||||
* Meant to be a script-only method for initializing a request.
|
||||
* The parameters are similar to the ones detailed in the
|
||||
* description of <code>openRequest</code>, but the last
|
||||
* 3 are optional.
|
||||
*
|
||||
* @param method The HTTP method - either "POST" or "GET".
|
||||
* @param url The URL to which to send the request.
|
||||
* @param async (optional) Whether the request is synchronous or
|
||||
* asynchronous i.e. whether send returns only after
|
||||
* the response is received or if it returns immediately after
|
||||
* sending the request. In the latter case, notification
|
||||
* of completion is sent through the event listeners.
|
||||
* The default value is true.
|
||||
* @param user (optional) A username for authentication if necessary.
|
||||
* The default value is the empty string
|
||||
* @param password (optional) A password for authentication if necessary.
|
||||
* The default value is the empty string
|
||||
*/
|
||||
void open(in string method, in string url);
|
||||
|
||||
/**
|
||||
* Sends the HTTP request. If the request is asynchronous, returns
|
||||
* immediately after sending the request. If it is synchronous
|
||||
* returns only after the response has been received.
|
||||
*
|
||||
* @param body Either an instance of nsIDOMDocument, nsIInputStream
|
||||
* or a string (nsISupportsWString in the native calling
|
||||
* case). This is used to populate the body of the
|
||||
* HTTP request if the HTTP request method is "POST".
|
||||
* If the parameter is a nsIDOMDocument, it is serialized.
|
||||
* If the parameter is a nsIInputStream, it is expected
|
||||
* to contain the ContentType: and ContentLength: headers
|
||||
* and trailing carriage-return/line-feed pairs.
|
||||
*/
|
||||
void send(in nsISupports body);
|
||||
|
||||
/**
|
||||
* Sets a HTTP request header.
|
||||
*
|
||||
* @param header The name of the header to set in the request.
|
||||
* @param value The body of the header.
|
||||
*/
|
||||
void setRequestHeader(in string header, in string value);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_XMLHTTPREQUEST_CID \
|
||||
{ /* d164e770-4157-11d4-9a42-000064657374 */ \
|
||||
0xd164e770, 0x4157, 0x11d4, \
|
||||
{0x9a, 0x42, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
|
||||
#define NS_XMLHTTPREQUEST_CONTRACTID \
|
||||
"@mozilla.org/xmlextras/xmlhttprequest;1"
|
||||
%}
|
||||
1459
mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp
Normal file
1459
mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
244
mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.h
Normal file
244
mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.h
Normal file
@@ -0,0 +1,244 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsXMLHttpRequest_h__
|
||||
#define nsXMLHttpRequest_h__
|
||||
|
||||
#define IMPLEMENT_SYNC_LOAD
|
||||
|
||||
#include "nsIXMLHttpRequest.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMLoadListener.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsISecurityCheckedComponent.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#ifdef IMPLEMENT_SYNC_LOAD
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#endif
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
enum {
|
||||
XML_HTTP_REQUEST_INITIALIZED,
|
||||
XML_HTTP_REQUEST_OPENED,
|
||||
XML_HTTP_REQUEST_SENT,
|
||||
XML_HTTP_REQUEST_COMPLETED,
|
||||
XML_HTTP_REQUEST_ABORTED
|
||||
};
|
||||
|
||||
class nsXMLHttpRequest : public nsIXMLHttpRequest,
|
||||
public nsIDOMLoadListener,
|
||||
public nsIDOMEventTarget,
|
||||
public nsISecurityCheckedComponent,
|
||||
public nsIStreamListener,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
nsXMLHttpRequest();
|
||||
virtual ~nsXMLHttpRequest();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIXMLHttpRequest
|
||||
NS_DECL_NSIXMLHTTPREQUEST
|
||||
|
||||
// nsIDOMEventTarget
|
||||
NS_DECL_NSIDOMEVENTTARGET
|
||||
|
||||
// nsIDOMEventListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
// nsIDOMLoadListener
|
||||
NS_IMETHOD Load(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
|
||||
// nsISecurityCheckedComponent
|
||||
NS_DECL_NSISECURITYCHECKEDCOMPONENT
|
||||
|
||||
// nsIStreamListener
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
||||
// nsIRequestObserver
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
protected:
|
||||
nsresult MakeScriptEventListener(nsISupports* aObject,
|
||||
nsIDOMEventListener** aListener);
|
||||
void GetScriptEventListener(nsISupportsArray* aList,
|
||||
nsIDOMEventListener** aListener);
|
||||
PRBool StuffReturnValue(nsIDOMEventListener* aListener);
|
||||
|
||||
|
||||
nsresult GetStreamForWString(const PRUnichar* aStr,
|
||||
PRInt32 aLength,
|
||||
nsIInputStream** aStream);
|
||||
|
||||
nsCOMPtr<nsISupports> mContext;
|
||||
nsCOMPtr<nsIHttpChannel> mChannel;
|
||||
nsCOMPtr<nsIRequest> mReadRequest;
|
||||
nsCOMPtr<nsIDOMDocument> mDocument;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
nsCOMPtr<nsIDocument> mBaseDocument;
|
||||
#ifdef IMPLEMENT_SYNC_LOAD
|
||||
nsCOMPtr<nsIWebBrowserChrome> mChromeWindow;
|
||||
#endif
|
||||
nsCOMPtr<nsISupportsArray> mLoadEventListeners;
|
||||
nsCOMPtr<nsISupportsArray> mErrorEventListeners;
|
||||
|
||||
nsresult DetectCharset(nsAWritableString& aCharset);
|
||||
nsresult ConvertBodyToText(PRUnichar **aOutBuffer);
|
||||
static NS_METHOD StreamReaderFunc(nsIInputStream* in,
|
||||
void* closure,
|
||||
const char* fromRawSegment,
|
||||
PRUint32 toOffset,
|
||||
PRUint32 count,
|
||||
PRUint32 *writeCount);
|
||||
|
||||
// used to implement getAllResponseHeaders()
|
||||
class nsHeaderVisitor : public nsIHttpHeaderVisitor {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIHTTPHEADERVISITOR
|
||||
nsHeaderVisitor() { NS_INIT_ISUPPORTS(); }
|
||||
virtual ~nsHeaderVisitor() {}
|
||||
const nsACString &Headers() { return mHeaders; }
|
||||
private:
|
||||
nsCString mHeaders;
|
||||
};
|
||||
|
||||
#if 1 // When nsCString::Append()/Length() works for strings that contain nulls, remove this buffer impl
|
||||
class ResponseBodyBuffer {
|
||||
public:
|
||||
ResponseBodyBuffer()
|
||||
: mBuffer(0),
|
||||
mBufferSize(0),
|
||||
mBufferFreeIndex(0),
|
||||
mCanBeString(PR_FALSE),
|
||||
mBufferChecked(PR_FALSE) {}
|
||||
~ResponseBodyBuffer() { nsMemory::Free(mBuffer); }
|
||||
void Truncate(void) {
|
||||
nsMemory::Free(mBuffer);
|
||||
mBuffer=nsnull;
|
||||
mBufferSize=mBufferFreeIndex=0;
|
||||
mCanBeString = PR_FALSE;
|
||||
mBufferChecked = PR_FALSE;
|
||||
}
|
||||
nsresult Append(const char* aBuffer, PRUint32 aBufferLen) {
|
||||
if (aBufferLen > (mBufferSize-mBufferFreeIndex)) {
|
||||
PRUint32 newBufferSize = (mBufferSize > aBufferLen ? mBufferSize : aBufferLen)<<1;
|
||||
char * newBuffer = NS_STATIC_CAST(char*,nsMemory::Realloc(mBuffer,newBufferSize));
|
||||
if (!newBuffer) {
|
||||
nsMemory::Free(mBuffer);
|
||||
mBuffer = nsnull;
|
||||
mBufferChecked = PR_FALSE;
|
||||
mCanBeString = PR_FALSE;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mBuffer = newBuffer;
|
||||
mBufferSize = newBufferSize;
|
||||
}
|
||||
memcpy(&mBuffer[mBufferFreeIndex],aBuffer,aBufferLen);
|
||||
mBufferFreeIndex += aBufferLen;
|
||||
mBufferChecked = PR_FALSE;
|
||||
mCanBeString = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
const char * GetBuffer(void) { return mBuffer; }
|
||||
PRUint32 GetBufferLength(void) { return mBufferFreeIndex; }
|
||||
PRBool CanBeString(void) {
|
||||
if (!mBufferFreeIndex)
|
||||
return PR_TRUE; // Perhaps this is a bit questionable...
|
||||
if (!mBufferChecked) {
|
||||
mBufferChecked = PR_TRUE;
|
||||
|
||||
mCanBeString = PR_TRUE;
|
||||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < mBufferFreeIndex; i++) {
|
||||
if (!mBuffer[i]) {
|
||||
mCanBeString = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mCanBeString;
|
||||
}
|
||||
private:
|
||||
char *mBuffer;
|
||||
PRUint32 mBufferSize;
|
||||
PRUint32 mBufferFreeIndex;
|
||||
PRPackedBool mCanBeString;
|
||||
PRPackedBool mBufferChecked;
|
||||
};
|
||||
ResponseBodyBuffer mResponseBody;
|
||||
#else
|
||||
nsCString mResponseBody;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIStreamListener> mXMLParserStreamListener;
|
||||
|
||||
PRInt32 mStatus;
|
||||
PRBool mAsync;
|
||||
};
|
||||
|
||||
#define NS_IPRIVATEJSEVENTLISTENER_IID \
|
||||
{ /* d47a6550-4327-11d4-9a45-000064657374 */ \
|
||||
0xd47a6550, 0x4327, 0x11d4, \
|
||||
{0x9a, 0x45, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
|
||||
|
||||
class nsIPrivateJSEventListener : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRIVATEJSEVENTLISTENER_IID)
|
||||
|
||||
NS_IMETHOD GetFunctionObj(JSObject** aObj) = 0;
|
||||
};
|
||||
|
||||
class nsXMLHttpRequestScriptListener : public nsIDOMEventListener,
|
||||
public nsIPrivateJSEventListener
|
||||
{
|
||||
public:
|
||||
nsXMLHttpRequestScriptListener(JSObject* aScopeObj, JSObject* aFunctionObj);
|
||||
virtual ~nsXMLHttpRequestScriptListener();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMEventListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
// nsIPrivateJSEventListener
|
||||
NS_IMETHOD GetFunctionObj(JSObject** aObj);
|
||||
|
||||
protected:
|
||||
JSObject* mScopeObj;
|
||||
JSObject* mFunctionObj;
|
||||
};
|
||||
|
||||
#endif
|
||||
907
mozilla/gfx/src/nsImageNetContextAsync.cpp
Normal file
907
mozilla/gfx/src/nsImageNetContextAsync.cpp
Normal file
@@ -0,0 +1,907 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "libimg.h"
|
||||
#include "nsImageNet.h"
|
||||
#include "ilINetContext.h"
|
||||
#include "ilIURL.h"
|
||||
#include "ilINetReader.h"
|
||||
#include "ilErrors.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "prprf.h"
|
||||
|
||||
|
||||
#include "nsITimer.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsIURIContentListener.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
static NS_DEFINE_CID(kStreamConvServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
static NS_DEFINE_IID(kIURLIID, NS_IURL_IID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
PRLogModuleInfo *image_net_context_async_log_module = NULL;
|
||||
|
||||
#define IMAGE_BUF_SIZE 4096
|
||||
|
||||
class ImageConsumer;
|
||||
|
||||
class ImageNetContextImpl : public ilINetContext {
|
||||
public:
|
||||
ImageNetContextImpl(ImgCachePolicy aReloadPolicy,
|
||||
nsISupports * aLoadContext,
|
||||
nsReconnectCB aReconnectCallback,
|
||||
void* aReconnectArg);
|
||||
virtual ~ImageNetContextImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual ilINetContext* Clone();
|
||||
|
||||
virtual ImgCachePolicy GetReloadPolicy();
|
||||
virtual ImgCachePolicy SetReloadPolicy(ImgCachePolicy ReloadPolicy);
|
||||
|
||||
|
||||
virtual void AddReferer(ilIURL *aUrl);
|
||||
|
||||
virtual void Interrupt();
|
||||
|
||||
virtual ilIURL* CreateURL(const char *aUrl,
|
||||
ImgCachePolicy aReloadMethod);
|
||||
|
||||
virtual PRBool IsLocalFileURL(char *aAddress);
|
||||
#ifdef NU_CACHE
|
||||
virtual PRBool IsURLInCache(ilIURL *aUrl);
|
||||
#else /* NU_CACHE */
|
||||
virtual PRBool IsURLInMemCache(ilIURL *aUrl);
|
||||
|
||||
virtual PRBool IsURLInDiskCache(ilIURL *aUrl);
|
||||
#endif
|
||||
|
||||
virtual int GetURL (ilIURL * aUrl, ImgCachePolicy aLoadMethod,
|
||||
ilINetReader *aReader, PRBool IsAnimationLoop);
|
||||
|
||||
virtual int GetContentLength(ilIURL * aURL);
|
||||
|
||||
nsresult RemoveRequest(ImageConsumer *aConsumer);
|
||||
nsresult RequestDone(ImageConsumer *aConsumer, nsIRequest* request,
|
||||
nsISupports* ctxt, nsresult status, const PRUnichar* aMsg);
|
||||
|
||||
nsVoidArray *mRequests; // WEAK references to |ImageConsumer|s
|
||||
ImgCachePolicy mReloadPolicy;
|
||||
nsWeakPtr mLoadContext;
|
||||
nsReconnectCB mReconnectCallback;
|
||||
void* mReconnectArg;
|
||||
};
|
||||
|
||||
class ImageConsumer : public nsIStreamListener, public nsIURIContentListener, public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
ImageConsumer(ilIURL *aURL, ImageNetContextImpl *aContext);
|
||||
|
||||
// nsIRequestObserver methods:
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
void SetKeepPumpingData(nsIRequest* request, nsISupports* context) {
|
||||
NS_ADDREF(request);
|
||||
NS_IF_RELEASE(mRequest);
|
||||
mRequest = request;
|
||||
|
||||
NS_IF_ADDREF(context);
|
||||
NS_IF_RELEASE(mUserContext);
|
||||
mUserContext = context;
|
||||
}
|
||||
|
||||
void Interrupt();
|
||||
|
||||
static void KeepPumpingStream(nsITimer *aTimer, void *aClosure);
|
||||
|
||||
protected:
|
||||
virtual ~ImageConsumer();
|
||||
ilIURL *mURL;
|
||||
PRBool mInterrupted;
|
||||
ImageNetContextImpl *mContext;
|
||||
nsIInputStream *mStream;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
PRBool mFirstRead;
|
||||
char *mBuffer;
|
||||
PRInt32 mStatus;
|
||||
nsIRequest* mRequest;
|
||||
nsISupports* mUserContext;
|
||||
PRBool mIsMulti;
|
||||
};
|
||||
|
||||
ImageConsumer::ImageConsumer(ilIURL *aURL, ImageNetContextImpl *aContext)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mURL = aURL;
|
||||
NS_ADDREF(mURL);
|
||||
mContext = aContext;
|
||||
NS_ADDREF(mContext);
|
||||
mInterrupted = PR_FALSE;
|
||||
mFirstRead = PR_TRUE;
|
||||
mStream = nsnull;
|
||||
mBuffer = nsnull;
|
||||
mStatus = 0;
|
||||
mRequest = nsnull;
|
||||
mUserContext = nsnull;
|
||||
mIsMulti = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(ImageConsumer)
|
||||
NS_IMPL_THREADSAFE_RELEASE(ImageConsumer)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(ImageConsumer)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP ImageConsumer::GetInterface(const nsIID & aIID, void * *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
// nsIURIContentListener support
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::OnStartURIOpen(nsIURI* aURI,
|
||||
const char* aWindowTarget, PRBool* aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandler)
|
||||
{
|
||||
*aProtocolHandler = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::GetParentContentListener(nsIURIContentListener** aParent)
|
||||
{
|
||||
*aParent = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::SetParentContentListener(nsIURIContentListener* aParent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::GetLoadCookie(nsISupports ** aLoadCookie)
|
||||
{
|
||||
nsCOMPtr<nsISupports> loadContext = do_QueryReferent(mContext->mLoadContext);
|
||||
*aLoadCookie = loadContext;
|
||||
NS_IF_ADDREF(*aLoadCookie);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::IsPreferred(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
return CanHandleContent(aContentType, aCommand, aWindowTarget,
|
||||
aDesiredContentType, aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::CanHandleContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
// if we had a webshell or doc shell around, we'd pass this call
|
||||
// through to it...but we don't =(
|
||||
if (!nsCRT::strcasecmp(aContentType, "message/rfc822"))
|
||||
*aDesiredContentType = nsCRT::strdup("application/vnd.mozilla.xul+xml");
|
||||
// since we explicilty loaded the url, we always want to handle it!
|
||||
*aCanHandleContent = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::DoContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsIRequest * aOpenedChannel,
|
||||
nsIStreamListener ** aContentHandler,
|
||||
PRBool * aAbortProcess)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aAbortProcess)
|
||||
*aAbortProcess = PR_FALSE;
|
||||
|
||||
nsAutoString contentType; contentType.AssignWithConversion(aContentType);
|
||||
|
||||
if (contentType.EqualsWithConversion("multipart/x-mixed-replace")
|
||||
|| contentType.EqualsWithConversion("multipart/mixed")) {
|
||||
// if we're getting multipart data, we have to convert it.
|
||||
// so wedge the converter inbetween us and the consumer.
|
||||
mIsMulti= PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIStreamConverterService> convServ = do_GetService(kStreamConvServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString astrix; astrix.AssignWithConversion("*/*");
|
||||
return convServ->AsyncConvertData(contentType.GetUnicode(),
|
||||
astrix.GetUnicode(),
|
||||
NS_STATIC_CAST(nsIStreamListener*, this),
|
||||
nsnull /*a context?*/, aContentHandler);
|
||||
}
|
||||
|
||||
QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
|
||||
{
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
|
||||
|
||||
PRUint32 httpStatus;
|
||||
if (mInterrupted) {
|
||||
mStatus = MK_INTERRUPTED;
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
mBuffer = (char *)PR_MALLOC(IMAGE_BUF_SIZE);
|
||||
if (mBuffer == nsnull) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> pHTTPCon(do_QueryInterface(channel));
|
||||
if (pHTTPCon) {
|
||||
pHTTPCon->GetResponseStatus(&httpStatus);
|
||||
if (httpStatus == 404) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
ilINetReader *reader = mURL->GetReader(); //ptn test: nsCOMPtr??
|
||||
/*nsresult err=*/ reader->FlushImgBuffer(); //flush current data in buffer before starting
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
char* aContentType = NULL;
|
||||
rv = channel->GetContentType(&aContentType); //nsCRT alloc's str
|
||||
if (NS_FAILED(rv)) {
|
||||
if(aContentType){
|
||||
nsCRT::free(aContentType);
|
||||
}
|
||||
aContentType = nsCRT::strdup("unknown");
|
||||
}
|
||||
if(nsCRT::strlen(aContentType) > 50){
|
||||
//somethings wrong. mimetype string shouldn't be this big.
|
||||
//protect us from the user.
|
||||
nsCRT::free(aContentType);
|
||||
aContentType = nsCRT::strdup("unknown");
|
||||
}
|
||||
|
||||
if (reader->StreamCreated(mURL, aContentType) != PR_TRUE) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
reader->StreamAbort(mStatus);
|
||||
NS_RELEASE(reader);
|
||||
nsCRT::free(aContentType);
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
nsCRT::free(aContentType);
|
||||
NS_RELEASE(reader);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define IMAGE_BUF_SIZE 4096
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::OnDataAvailable(nsIRequest* request, nsISupports* aContext,
|
||||
nsIInputStream *pIStream, PRUint32 offset, PRUint32 length)
|
||||
{
|
||||
PRUint32 max_read=0;
|
||||
PRUint32 bytes_read = 0;
|
||||
ilINetReader *reader = mURL->GetReader();
|
||||
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
||||
|
||||
if (mInterrupted || mStatus != 0) {
|
||||
mStatus = MK_INTERRUPTED;
|
||||
reader->StreamAbort(mStatus);
|
||||
NS_RELEASE(reader);
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
nsresult err = 0;
|
||||
PRUint32 nb = 0;
|
||||
char* uriStr = NULL;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
||||
err = channel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(err) && uri) {
|
||||
err = uri->GetSpec(&uriStr);
|
||||
if (NS_FAILED(err)){
|
||||
/* if we can't get a file spec, it is bad, very bad.*/
|
||||
mStatus = MK_INTERRUPTED;
|
||||
reader->StreamAbort(mStatus);
|
||||
NS_RELEASE(reader);
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
err = reader->WriteReady(&max_read); //max read is most decoder can handle
|
||||
if(NS_FAILED(err)) //note length tells how much we already have.
|
||||
break;
|
||||
|
||||
if(max_read < 0){
|
||||
max_read = 128;
|
||||
}
|
||||
|
||||
if (max_read > (length - bytes_read)) {
|
||||
max_read = length - bytes_read;
|
||||
}
|
||||
|
||||
if (max_read > IMAGE_BUF_SIZE) {
|
||||
max_read = IMAGE_BUF_SIZE;
|
||||
}
|
||||
|
||||
// make sure there's enough data available to decode the image.
|
||||
// put test into WriteReady
|
||||
if (mFirstRead && length < 4)
|
||||
break;
|
||||
|
||||
err = pIStream->Read(mBuffer,
|
||||
max_read, &nb);
|
||||
|
||||
if (err == NS_BASE_STREAM_WOULD_BLOCK) {
|
||||
NS_ASSERTION(nb == 0, "Data will be lost.");
|
||||
err = NS_OK;
|
||||
break;
|
||||
}
|
||||
if (NS_FAILED(err) || nb == 0) {
|
||||
NS_ASSERTION(nb == 0, "Data will be lost.");
|
||||
break;
|
||||
}
|
||||
|
||||
bytes_read += nb;
|
||||
if (mFirstRead == PR_TRUE) {
|
||||
|
||||
err = reader->FirstWrite((const unsigned char *)mBuffer, nb, uriStr);
|
||||
mFirstRead = PR_FALSE; //? move after err chk?
|
||||
/*
|
||||
* If FirstWrite(...) fails then the image type
|
||||
* cannot be determined and the il_container
|
||||
* stream functions have not been initialized!
|
||||
*/
|
||||
if (NS_FAILED(err)) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
mInterrupted = PR_TRUE;
|
||||
if(uriStr)
|
||||
nsCRT::free(uriStr);
|
||||
NS_RELEASE(reader);
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
err = reader->Write((const unsigned char *)mBuffer, (int32)nb);
|
||||
if(NS_FAILED(err)){
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
mInterrupted = PR_TRUE;
|
||||
if(uriStr)
|
||||
nsCRT::free(uriStr);
|
||||
NS_RELEASE(reader);
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
} while(bytes_read < length);
|
||||
|
||||
if (uriStr) {
|
||||
nsCRT::free(uriStr);
|
||||
}
|
||||
|
||||
if (NS_FAILED(err)) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
mInterrupted = PR_TRUE;
|
||||
}
|
||||
|
||||
if (bytes_read < length) {
|
||||
// If we haven't emptied the stream, hold onto it, because
|
||||
// we will need to read from it subsequently and we don't
|
||||
// know if we'll get a OnDataAvailable call again.
|
||||
//
|
||||
// Addref the new stream before releasing the old one,
|
||||
// in case it is the same stream!
|
||||
NS_ADDREF(pIStream);
|
||||
NS_IF_RELEASE(mStream);
|
||||
mStream = pIStream;
|
||||
} else {
|
||||
NS_IF_RELEASE(mStream);
|
||||
}
|
||||
NS_RELEASE(reader);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
ImageConsumer::KeepPumpingStream(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
ImageConsumer *consumer = (ImageConsumer *)aClosure;
|
||||
|
||||
consumer->OnStopRequest(consumer->mRequest, consumer->mUserContext,
|
||||
NS_BINDING_SUCCEEDED);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::OnStopRequest(nsIRequest* request, nsISupports* aContext, nsresult status)
|
||||
{
|
||||
if (mTimer) {
|
||||
mTimer->Cancel();
|
||||
mTimer = nsnull;
|
||||
}
|
||||
|
||||
if (NS_BINDING_SUCCEEDED != status) {
|
||||
mStatus = MK_INTERRUPTED;
|
||||
}
|
||||
|
||||
|
||||
// Since we're still holding on to the stream, there's still data
|
||||
// that needs to be read. So, pump the stream ourselves.
|
||||
if((mStream != nsnull) && (status == NS_BINDING_SUCCEEDED)) {
|
||||
PRUint32 str_length;
|
||||
nsresult err = mStream->Available(&str_length);
|
||||
if (NS_SUCCEEDED(err)) {
|
||||
NS_ASSERTION((str_length > 0), "No data left in the stream!");
|
||||
err = OnDataAvailable(request, aContext, mStream, 0, str_length); // XXX fix offset
|
||||
if (NS_SUCCEEDED(err)) {
|
||||
// If we still have the stream, there's still data to be
|
||||
// pumped, so we set a timer to call us back again.
|
||||
if (mStream) {
|
||||
SetKeepPumpingData(request, aContext);
|
||||
|
||||
nsresult rv;
|
||||
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||
if (NS_FAILED(rv) ||
|
||||
(NS_OK != mTimer->Init(ImageConsumer::KeepPumpingStream, this, 0))) {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
NS_RELEASE(mStream);
|
||||
}
|
||||
else {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
NS_IF_RELEASE(mStream);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mStatus = MK_IMAGE_LOSSAGE;
|
||||
NS_IF_RELEASE(mStream);
|
||||
}
|
||||
}
|
||||
|
||||
ilINetReader *reader = mURL->GetReader();
|
||||
if (0 != mStatus) {
|
||||
reader->StreamAbort(mStatus);
|
||||
}
|
||||
else {
|
||||
reader->StreamComplete(mIsMulti);
|
||||
}
|
||||
|
||||
if(mIsMulti)
|
||||
mFirstRead = PR_TRUE; //reset to read new frame
|
||||
|
||||
reader->NetRequestDone(mURL, mStatus);
|
||||
NS_RELEASE(reader);
|
||||
|
||||
return mContext->RequestDone(this, request, aContext, status, nsnull);
|
||||
}
|
||||
|
||||
void
|
||||
ImageConsumer::Interrupt()
|
||||
{
|
||||
mInterrupted = PR_TRUE;
|
||||
}
|
||||
|
||||
ImageConsumer::~ImageConsumer()
|
||||
{
|
||||
if (mTimer) {
|
||||
mTimer->Cancel();
|
||||
mTimer = nsnull;
|
||||
}
|
||||
if (mContext) {
|
||||
nsresult res = mContext->RemoveRequest(this);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
// The load was canceled.
|
||||
mStatus = MK_INTERRUPTED;
|
||||
if (mURL) {
|
||||
nsCOMPtr<ilINetReader> reader( dont_AddRef( mURL->GetReader() ) );
|
||||
reader->StreamAbort(mStatus);
|
||||
reader->NetRequestDone(mURL, mStatus);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(mContext);
|
||||
}
|
||||
NS_IF_RELEASE(mURL);
|
||||
NS_IF_RELEASE(mStream);
|
||||
if (mBuffer != nsnull) {
|
||||
PR_DELETE(mBuffer);
|
||||
}
|
||||
NS_IF_RELEASE(mRequest);
|
||||
NS_IF_RELEASE(mUserContext);
|
||||
}
|
||||
|
||||
ImageNetContextImpl::ImageNetContextImpl(ImgCachePolicy aReloadPolicy,
|
||||
nsISupports * aLoadContext,
|
||||
nsReconnectCB aReconnectCallback,
|
||||
void* aReconnectArg)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mRequests = nsnull;
|
||||
mLoadContext = getter_AddRefs(NS_GetWeakReference(aLoadContext));
|
||||
mReloadPolicy = aReloadPolicy;
|
||||
mReconnectCallback = aReconnectCallback;
|
||||
mReconnectArg = aReconnectArg;
|
||||
}
|
||||
|
||||
ImageNetContextImpl::~ImageNetContextImpl()
|
||||
{
|
||||
delete mRequests;
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(ImageNetContextImpl, ilINetContext)
|
||||
|
||||
ilINetContext*
|
||||
ImageNetContextImpl::Clone()
|
||||
{
|
||||
ilINetContext *cx;
|
||||
nsCOMPtr<nsISupports> loadContext = do_QueryReferent(mLoadContext);
|
||||
|
||||
//mReconnectArg is ImageGroup. If GetURL is triggered
|
||||
//by timer for animation, ImageGroup may have been unloaded
|
||||
//before timer kicks off.
|
||||
//mReconnectCallback=nsnull; mReconnectArg=nsnull;
|
||||
|
||||
if (NS_NewImageNetContext(&cx, loadContext, mReconnectCallback, mReconnectArg) == NS_OK)
|
||||
{
|
||||
return cx;
|
||||
}
|
||||
else {
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
ImgCachePolicy
|
||||
ImageNetContextImpl::GetReloadPolicy()
|
||||
{
|
||||
return mReloadPolicy;
|
||||
}
|
||||
|
||||
ImgCachePolicy
|
||||
ImageNetContextImpl::SetReloadPolicy(ImgCachePolicy reloadpolicy)
|
||||
{
|
||||
mReloadPolicy=reloadpolicy;
|
||||
return mReloadPolicy;
|
||||
}
|
||||
|
||||
void
|
||||
ImageNetContextImpl::AddReferer(ilIURL *aUrl)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ImageNetContextImpl::Interrupt()
|
||||
{
|
||||
if (mRequests != nsnull) {
|
||||
int i, count = mRequests->Count();
|
||||
for (i=0; i < count; i++) {
|
||||
ImageConsumer *ic = (ImageConsumer *)mRequests->ElementAt(i);
|
||||
ic->Interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ilIURL*
|
||||
ImageNetContextImpl::CreateURL(const char *aURL,
|
||||
ImgCachePolicy aReloadMethod)
|
||||
{
|
||||
ilIURL *url;
|
||||
|
||||
nsCOMPtr<nsISupports> loadContext (do_QueryReferent(mLoadContext));
|
||||
nsCOMPtr<nsILoadGroup> group (do_GetInterface(loadContext));
|
||||
if (NS_NewImageURL(&url, aURL, group) == NS_OK)
|
||||
{
|
||||
return url;
|
||||
}
|
||||
else {
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
ImageNetContextImpl::IsLocalFileURL(char *aAddress)
|
||||
{
|
||||
if (PL_strncasecmp(aAddress, "file:", 5) == 0) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NU_CACHE
|
||||
PRBool
|
||||
ImageNetContextImpl::IsURLInCache(ilIURL *aUrl)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
#else /* NU_CACHE */
|
||||
PRBool
|
||||
ImageNetContextImpl::IsURLInMemCache(ilIURL *aUrl)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
ImageNetContextImpl::IsURLInDiskCache(ilIURL *aUrl)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif /* NU_CACHE */
|
||||
|
||||
int
|
||||
ImageNetContextImpl::GetContentLength (ilIURL * aURL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ImageNetContextImpl::GetURL (ilIURL * aURL,
|
||||
ImgCachePolicy aLoadMethod,
|
||||
ilINetReader *aReader,
|
||||
PRBool IsAnimationLoop)
|
||||
{
|
||||
|
||||
|
||||
NS_PRECONDITION(nsnull != aURL, "null URL");
|
||||
NS_PRECONDITION(nsnull != aReader, "null reader");
|
||||
if (aURL == nsnull || aReader == nsnull) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mRequests == nsnull) {
|
||||
mRequests = new nsVoidArray();
|
||||
if (mRequests == nsnull) {
|
||||
// XXX Should still call exit function
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int ret;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> nsurl = do_QueryInterface(aURL, &rv);
|
||||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
aURL->SetReader(aReader);
|
||||
SetReloadPolicy(aLoadMethod);
|
||||
|
||||
|
||||
// Find previously created ImageConsumer if possible
|
||||
ImageConsumer *ic = new ImageConsumer(aURL, this);
|
||||
if (ic == nsnull)
|
||||
return -1;
|
||||
NS_ADDREF(ic);
|
||||
|
||||
// See if a reconnect is being done...(XXX: hack!)
|
||||
if (mReconnectCallback == nsnull
|
||||
|| !(*mReconnectCallback)(mReconnectArg, ic)) {
|
||||
// first, create a channel for the protocol....
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsCOMPtr<nsISupports> loadContext (do_QueryReferent(mLoadContext));
|
||||
nsCOMPtr<nsILoadGroup> group (do_GetInterface(loadContext));
|
||||
nsCOMPtr<nsIInterfaceRequestor> sink(do_QueryInterface(loadContext));
|
||||
|
||||
nsLoadFlags flags=0;
|
||||
if(IsAnimationLoop)
|
||||
flags |= nsIRequest::LOAD_FROM_CACHE;
|
||||
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), nsurl, nsnull, group, sink, flags);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
if (httpChannel)
|
||||
{
|
||||
// Get the defloadRequest from the loadgroup-
|
||||
nsCOMPtr<nsIRequest> defLoadRequest;
|
||||
if (NS_SUCCEEDED(group->GetDefaultLoadRequest(
|
||||
getter_AddRefs(defLoadRequest))) && defLoadRequest)
|
||||
{
|
||||
nsCOMPtr<nsIChannel> reqchannel = do_QueryInterface(defLoadRequest);
|
||||
|
||||
// Get the referrer from the loadchannel-
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
if (NS_SUCCEEDED(reqchannel->GetURI(getter_AddRefs(referrer))))
|
||||
{
|
||||
// Set the referrer-
|
||||
httpChannel->SetReferrer(referrer, nsIHttpChannel::REFERRER_INLINES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rv = channel->GetLoadFlags(&flags);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
if (aURL->GetBackgroundLoad())
|
||||
flags |= nsIRequest::LOAD_BACKGROUND;
|
||||
|
||||
(void)channel->SetLoadFlags(flags);
|
||||
|
||||
nsCOMPtr<nsISupports> window (do_QueryInterface(NS_STATIC_CAST(nsIStreamListener *, ic)));
|
||||
|
||||
// let's try uri dispatching...
|
||||
nsCOMPtr<nsIURILoader> pURILoader (do_GetService(NS_URI_LOADER_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsURILoadCommand loadCmd = nsIURILoader::viewNormal;
|
||||
PRBool bIsBackground = aURL->GetBackgroundLoad();
|
||||
if (bIsBackground) {
|
||||
loadCmd = nsIURILoader::viewNormalBackground;
|
||||
}
|
||||
|
||||
|
||||
rv = pURILoader->OpenURI(channel, loadCmd, nsnull /* window target */,
|
||||
window);
|
||||
}
|
||||
// rv = channel->AsyncOpen(ic, nsnull);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
}
|
||||
|
||||
ret = mRequests->AppendElement((void *)ic) ? 0 : -1;
|
||||
NS_RELEASE(ic); // if nothing else is holding onto it, it will remove
|
||||
// itself from mRequests
|
||||
return ret;
|
||||
|
||||
error:
|
||||
NS_RELEASE(ic);
|
||||
return -1;
|
||||
}
|
||||
|
||||
nsresult
|
||||
ImageNetContextImpl::RemoveRequest(ImageConsumer *aConsumer)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mRequests) {
|
||||
rv = mRequests->RemoveElement((void *)aConsumer)?NS_OK:NS_ERROR_FAILURE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
ImageNetContextImpl::RequestDone(ImageConsumer *aConsumer, nsIRequest* request,
|
||||
nsISupports* ctxt, nsresult status, const PRUnichar* aMsg)
|
||||
{
|
||||
RemoveRequest(aConsumer);
|
||||
/// if (mLoadGroup)
|
||||
/// return mLoadGroup->RemoveChannel(channel, ctxt, status, aMsg);
|
||||
/// else
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" NS_GFX_(nsresult)
|
||||
NS_NewImageNetContext(ilINetContext **aInstancePtrResult,
|
||||
nsISupports * aLoadContext,
|
||||
nsReconnectCB aReconnectCallback,
|
||||
void* aReconnectArg)
|
||||
{
|
||||
|
||||
PRUint32 necko_attribs;
|
||||
ImgCachePolicy imglib_attribs = USE_IMG_CACHE;
|
||||
nsLoadFlags defchan_attribs = nsIRequest::LOAD_NORMAL;
|
||||
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if(aLoadContext){
|
||||
nsCOMPtr<nsILoadGroup> group (do_GetInterface(aLoadContext));
|
||||
/*nsresult rv = */group->GetLoadFlags(&necko_attribs);
|
||||
/*
|
||||
Need code to check freshness of necko cache.
|
||||
*/
|
||||
nsCOMPtr<nsIRequest> defLoadRequest;
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
if (NS_SUCCEEDED(group->GetDefaultLoadRequest(
|
||||
getter_AddRefs(defLoadRequest))) && defLoadRequest)
|
||||
{
|
||||
channel = do_QueryInterface(defLoadRequest);
|
||||
if (channel) channel->GetLoadFlags(&defchan_attribs);
|
||||
}
|
||||
|
||||
#if defined( DEBUG )
|
||||
if (image_net_context_async_log_module == NULL) {
|
||||
image_net_context_async_log_module = PR_NewLogModule("IMAGENETCTXASYNC");
|
||||
}
|
||||
#endif
|
||||
if((nsIRequest::VALIDATE_ALWAYS & defchan_attribs)||
|
||||
(nsIRequest::INHIBIT_PERSISTENT_CACHING & defchan_attribs)||
|
||||
(nsIRequest::LOAD_BYPASS_CACHE & defchan_attribs)) {
|
||||
imglib_attribs = DONT_USE_IMG_CACHE;
|
||||
#if defined( DEBUG )
|
||||
PR_LOG(image_net_context_async_log_module, 1, ("ImageNetContextAsync: NS_NewImageNetContext: DONT_USE_IMAGE_CACHE\n"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
ilINetContext *cx = new ImageNetContextImpl( imglib_attribs,
|
||||
aLoadContext,
|
||||
aReconnectCallback,
|
||||
aReconnectArg);
|
||||
if (cx == nsnull) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return cx->QueryInterface(NS_GET_IID(ilINetContext), (void **) aInstancePtrResult);
|
||||
|
||||
}
|
||||
106
mozilla/intl/chardet/src/nsObserverBase.cpp
Normal file
106
mozilla/intl/chardet/src/nsObserverBase.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
//#define DONT_INFORM_WEBSHELL
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsIWebShellServices.h"
|
||||
#include "nsIContentViewerContainer.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsObserverBase.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID);
|
||||
static NS_DEFINE_IID(kIWebShellServicesIID, NS_IWEB_SHELL_SERVICES_IID);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsObserverBase::NotifyWebShell(
|
||||
nsISupports* aParserBundle, const char* charset, nsCharsetSource source)
|
||||
{
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsISupportsParserBundle> bundle=do_QueryInterface(aParserBundle);
|
||||
|
||||
if (bundle) {
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// XXX - Make sure not to reload POST data to prevent bugs such as 27006
|
||||
nsAutoString theChannelKey;
|
||||
theChannelKey.AssignWithConversion("channel");
|
||||
|
||||
nsCOMPtr<nsIChannel> channel=nsnull;
|
||||
res=bundle->GetDataFromBundle(theChannelKey,getter_AddRefs(channel));
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel,&res));
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
nsXPIDLCString method;
|
||||
httpChannel->GetRequestMethod(getter_Copies(method));
|
||||
if(method) {
|
||||
if(!PL_strcasecmp(method, "POST"))
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString theDocShellKey;
|
||||
theDocShellKey.AssignWithConversion("docshell"); // Key to find docshell from the bundle.
|
||||
|
||||
nsCOMPtr<nsIDocShell> docshell=nsnull;
|
||||
|
||||
res=bundle->GetDataFromBundle(theDocShellKey,getter_AddRefs(docshell));
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
nsCOMPtr<nsIWebShellServices> wss=nsnull;
|
||||
wss=do_QueryInterface(docshell,&res); // Query webshell service through docshell.
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
|
||||
#ifndef DONT_INFORM_WEBSHELL
|
||||
// ask the webshellservice to load the URL
|
||||
if(NS_FAILED( res = wss->SetRendering(PR_FALSE) ))
|
||||
rv=res;
|
||||
|
||||
// XXX nisheeth, uncomment the following two line to see the reent problem
|
||||
|
||||
else if(NS_FAILED(res = wss->StopDocumentLoad())){
|
||||
rv = wss->SetRendering(PR_TRUE); // turn on the rendering so at least we will see something.
|
||||
}
|
||||
|
||||
else if(NS_FAILED(res = wss->ReloadDocument(charset, source))) {
|
||||
rv = wss->SetRendering(PR_TRUE); // turn on the rendering so at least we will see something.
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_HTMLPARSER_STOPPARSING; // We're reloading a new document...stop loading the current.
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
27
mozilla/layout/build/gbdate.pl
Executable file
27
mozilla/layout/build/gbdate.pl
Executable file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
# XP way of doing the build date.
|
||||
# 1998091509 = 1998, September, 15th, 9am local time zone
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
|
||||
# localtime returns year minus 1900
|
||||
$year = $year + 1900;
|
||||
printf("#define PRODUCT_VERSION \"%04d%02d%02d\"\n", $year, 1+$mon, $mday);
|
||||
90
mozilla/layout/build/nsContentHTTPStartup.cpp
Normal file
90
mozilla/layout/build/nsContentHTTPStartup.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsContentHTTPStartup.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "gbdate.h"
|
||||
|
||||
#define PRODUCT_NAME "Gecko"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentHTTPStartup,nsIObserver)
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::Observe( nsISupports *aSubject,
|
||||
const PRUnichar *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (nsCRT::strcmp(aTopic, NS_HTTP_STARTUP_TOPIC) != 0)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = nsnull;
|
||||
|
||||
nsCOMPtr<nsIHttpProtocolHandler> http(do_QueryInterface(aSubject));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProduct(PRODUCT_NAME);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProductSub((char*) PRODUCT_VERSION);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::RegisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString previousEntry;
|
||||
rv = catMan->AddCategoryEntry(NS_HTTP_STARTUP_CATEGORY,
|
||||
"Content UserAgent Setter",
|
||||
NS_CONTENTHTTPSTARTUP_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE,
|
||||
getter_Copies(previousEntry));
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::UnregisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
1813
mozilla/layout/html/forms/src/nsFormFrame.cpp
Normal file
1813
mozilla/layout/html/forms/src/nsFormFrame.cpp
Normal file
File diff suppressed because it is too large
Load Diff
864
mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp
Normal file
864
mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp
Normal file
@@ -0,0 +1,864 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "msgCore.h" // for pre-compiled headers
|
||||
#include "nsCOMPtr.h"
|
||||
#include <stdio.h>
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "comi18n.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAbSyncPostEngine.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsIAbSync.h"
|
||||
#include "nsAbSyncCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kCookieServiceCID, NS_COOKIESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCAbSyncMojoCID, NS_AB_SYNC_MOJO_CID);
|
||||
static NS_DEFINE_CID(kAbSync, NS_ABSYNC_SERVICE_CID);
|
||||
|
||||
/*
|
||||
* This function will be used by the factory to generate an
|
||||
* object class object....
|
||||
*/
|
||||
NS_METHOD
|
||||
nsAbSyncPostEngine::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsAbSyncPostEngine *ph = new nsAbSyncPostEngine();
|
||||
if (ph == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return ph->QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsAbSyncPostEngine)
|
||||
NS_IMPL_RELEASE(nsAbSyncPostEngine)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsAbSyncPostEngine)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAbSyncPostEngine)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
/*
|
||||
* Inherited methods for nsMimeConverter
|
||||
*/
|
||||
nsAbSyncPostEngine::nsAbSyncPostEngine()
|
||||
{
|
||||
/* the following macro is used to initialize the ref counting data */
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// Init member variables...
|
||||
mTotalWritten = 0;
|
||||
mStillRunning = PR_TRUE;
|
||||
mContentType = nsnull;
|
||||
mCharset = nsnull;
|
||||
|
||||
mListenerArray = nsnull;
|
||||
mListenerArrayCount = 0;
|
||||
|
||||
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostIdle;
|
||||
mTransactionID = 0;
|
||||
mMessageSize = 0;
|
||||
mAuthenticationRunning = PR_TRUE;
|
||||
mCookie = nsnull;
|
||||
mUser = nsnull;
|
||||
mSyncProtocolRequest = nsnull;
|
||||
mSyncProtocolRequestPrefix = nsnull;
|
||||
mChannel = nsnull;
|
||||
mMojoSyncSpec = nsnull;
|
||||
}
|
||||
|
||||
nsAbSyncPostEngine::~nsAbSyncPostEngine()
|
||||
{
|
||||
mStillRunning = PR_FALSE;
|
||||
PR_FREEIF(mContentType);
|
||||
PR_FREEIF(mCharset);
|
||||
|
||||
PR_FREEIF(mSyncProtocolRequest);
|
||||
PR_FREEIF(mSyncProtocolRequestPrefix);
|
||||
PR_FREEIF(mCookie);
|
||||
PR_FREEIF(mUser);
|
||||
PR_FREEIF(mMojoSyncSpec);
|
||||
DeleteListeners();
|
||||
}
|
||||
|
||||
PRInt32 Base64Decode_int(const char *in_str, unsigned char *out_str,
|
||||
PRUint32& decoded_len);
|
||||
/* ==================================================================
|
||||
* Base64Encode
|
||||
*
|
||||
* Returns number of bytes that were encoded.
|
||||
*
|
||||
* >0 -> OK
|
||||
* -1 -> BAD (output buffer not big enough).
|
||||
*
|
||||
* ==================================================================
|
||||
*/
|
||||
PRInt32 Base64Encode(const unsigned char *in_str, PRInt32 in_len, char *out_str,
|
||||
PRInt32 out_len)
|
||||
{
|
||||
static unsigned char base64[] =
|
||||
{
|
||||
/* 0 1 2 3 4 5 6 7 */
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', /* 0 */
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', /* 1 */
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', /* 2 */
|
||||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', /* 3 */
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', /* 4 */
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', /* 5 */
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3', /* 6 */
|
||||
'4', '5', '6', '7', '8', '9', '+', '/' /* 7 */
|
||||
};
|
||||
PRInt32 curr_out_len = 0;
|
||||
|
||||
PRInt32 i = 0;
|
||||
unsigned char a, b, c;
|
||||
|
||||
out_str[0] = '\0';
|
||||
|
||||
if (in_len > 0)
|
||||
{
|
||||
|
||||
while (i < in_len)
|
||||
{
|
||||
a = in_str[i];
|
||||
b = (i + 1 >= in_len) ? 0 : in_str[i + 1];
|
||||
c = (i + 2 >= in_len) ? 0 : in_str[i + 2];
|
||||
|
||||
if (i + 2 < in_len)
|
||||
{
|
||||
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
|
||||
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
|
||||
+ ((b >> 4) & 0xf)]);
|
||||
out_str[curr_out_len++] = (base64[((b << 2) & 0x3c)
|
||||
+ ((c >> 6) & 0x3)]);
|
||||
out_str[curr_out_len++] = (base64[c & 0x3F]);
|
||||
}
|
||||
else if (i + 1 < in_len)
|
||||
{
|
||||
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
|
||||
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
|
||||
+ ((b >> 4) & 0xf)]);
|
||||
out_str[curr_out_len++] = (base64[((b << 2) & 0x3c)
|
||||
+ ((c >> 6) & 0x3)]);
|
||||
out_str[curr_out_len++] = '=';
|
||||
}
|
||||
else
|
||||
{
|
||||
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
|
||||
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
|
||||
+ ((b >> 4) & 0xf)]);
|
||||
out_str[curr_out_len++] = '=';
|
||||
out_str[curr_out_len++] = '=';
|
||||
}
|
||||
|
||||
i += 3;
|
||||
|
||||
if((curr_out_len + 4) > out_len)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
}
|
||||
out_str[curr_out_len] = '\0';
|
||||
}
|
||||
|
||||
return curr_out_len;
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine decodes base64 string to a buffer.
|
||||
* Populates 'out_str' with b64 decoded data.
|
||||
*
|
||||
* Returns number of bytes that were decoded.
|
||||
* >0 -> OK
|
||||
* -1 -> BAD (output buffer not big enough).
|
||||
*/
|
||||
PRInt32 Base64Decode(const char *in_str, unsigned char *out_str,
|
||||
PRUint32* decoded_len)
|
||||
{
|
||||
return Base64Decode_int(in_str, out_str, *decoded_len);
|
||||
}
|
||||
|
||||
PRInt32 Base64Decode_int(const char *in_str, unsigned char *out_str,
|
||||
PRUint32& decoded_len)
|
||||
{
|
||||
PRInt32 in_len = strlen (/*(char *)*/ in_str);
|
||||
PRInt32 ii = 0;
|
||||
PRInt32 a = 0;
|
||||
char ch;
|
||||
PRInt32 b1 = 0;
|
||||
long b4 = 0;
|
||||
PRInt32 nn = 0;
|
||||
|
||||
/* Decode remainder of base 64 string */
|
||||
|
||||
while (ii < in_len)
|
||||
{
|
||||
ch = in_str[ii++];
|
||||
if (ch >= 'A' && ch <= 'Z') b1 = (ch - 'A');
|
||||
else if (ch >= 'a' && ch <= 'z') b1 = 26 + (ch - 'a');
|
||||
else if (ch >= '0' && ch <= '9') b1 = 52 + (ch - '0');
|
||||
else if (ch == '+') b1 = 62;
|
||||
else if (ch == '/') b1 = 63;
|
||||
else if (ch == '\r' || ch == '\n') continue;
|
||||
else
|
||||
{
|
||||
if (ch == '=')
|
||||
{
|
||||
if (nn == 3)
|
||||
{
|
||||
if ((a + 2) > (PRInt32) decoded_len)
|
||||
return (-1); /* Bail. Buffer overflow */
|
||||
b4 = (b4 << 6);
|
||||
out_str[a++] = (char) (0xff & (b4 >> 16));
|
||||
out_str[a++] = (char) (0xff & (b4 >> 8));
|
||||
}
|
||||
else if (nn == 2)
|
||||
{
|
||||
if ((a + 1) > (PRInt32) decoded_len)
|
||||
{
|
||||
return (-1); /* Bail. Buffer overflow */
|
||||
}
|
||||
b4 = (b4 << 12);
|
||||
out_str[a++] = (char) (0xff & (b4 >> 16));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
b4 = (b4 << 6) | (long) b1;
|
||||
nn++;
|
||||
if (nn == 4)
|
||||
{
|
||||
if ((a + 3) > (PRInt32) decoded_len)
|
||||
{
|
||||
return (-1); /* Bail. Buffer overflow */
|
||||
}
|
||||
out_str[a++] = (char) (0xff & (b4 >> 16));
|
||||
out_str[a++] = (char) (0xff & (b4 >> 8));
|
||||
out_str[a++] = (char) (0xff & (b4));
|
||||
nn = 0;
|
||||
}
|
||||
}
|
||||
|
||||
out_str[a] = '\0';
|
||||
decoded_len = a;
|
||||
|
||||
return (a);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::GetInterface(const nsIID & aIID, void * *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
// nsIURIContentListener support
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::OnStartURIOpen(nsIURI* aURI,
|
||||
const char* aWindowTarget, PRBool* aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandler)
|
||||
{
|
||||
*aProtocolHandler = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::IsPreferred(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
return CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
|
||||
aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::CanHandleContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
if (nsCRT::strcasecmp(aContentType, MESSAGE_RFC822) == 0)
|
||||
*aDesiredContentType = nsCRT::strdup("text/html");
|
||||
|
||||
// since we explicilty loaded the url, we always want to handle it!
|
||||
*aCanHandleContent = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::DoContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsIRequest *request,
|
||||
nsIStreamListener ** aContentHandler,
|
||||
PRBool * aAbortProcess)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aAbortProcess)
|
||||
*aAbortProcess = PR_FALSE;
|
||||
QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::GetParentContentListener(nsIURIContentListener** aParent)
|
||||
{
|
||||
*aParent = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::SetParentContentListener(nsIURIContentListener* aParent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::GetLoadCookie(nsISupports ** aLoadCookie)
|
||||
{
|
||||
*aLoadCookie = mLoadCookie;
|
||||
NS_IF_ADDREF(*aLoadCookie);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
{
|
||||
mLoadCookie = aLoadCookie;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::StillRunning(PRBool *running)
|
||||
{
|
||||
*running = mStillRunning;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Methods for nsIStreamListener...
|
||||
nsresult
|
||||
nsAbSyncPostEngine::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream,
|
||||
PRUint32 sourceOffset, PRUint32 aLength)
|
||||
{
|
||||
PRUint32 readLen = aLength;
|
||||
|
||||
char *buf = (char *)PR_Malloc(aLength);
|
||||
if (!buf)
|
||||
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
|
||||
// read the data from the input stram...
|
||||
nsresult rv = aIStream->Read(buf, aLength, &readLen);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// write to the protocol response buffer...
|
||||
mProtocolResponse.Append(NS_ConvertASCIItoUCS2(buf, readLen));
|
||||
PR_FREEIF(buf);
|
||||
mTotalWritten += readLen;
|
||||
|
||||
if (!mAuthenticationRunning)
|
||||
NotifyListenersOnProgress(mTransactionID, mTotalWritten, 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Methods for nsIRequestObserver
|
||||
nsresult
|
||||
nsAbSyncPostEngine::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||
{
|
||||
if (mAuthenticationRunning)
|
||||
NotifyListenersOnStartAuthOperation();
|
||||
else
|
||||
NotifyListenersOnStartSending(mTransactionID, mMessageSize);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus)
|
||||
{
|
||||
#ifdef NS_DEBUG_rhp
|
||||
printf("nsAbSyncPostEngine::OnStopRequest()\n");
|
||||
#endif
|
||||
|
||||
char *tProtResponse = nsnull;
|
||||
|
||||
//
|
||||
// Now complete the stream!
|
||||
//
|
||||
mStillRunning = PR_FALSE;
|
||||
|
||||
// Check the content type!
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
||||
if (channel)
|
||||
{
|
||||
char *contentType = nsnull;
|
||||
char *charset = nsnull;
|
||||
|
||||
if (NS_SUCCEEDED(channel->GetContentType(&contentType)) && contentType)
|
||||
{
|
||||
if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE))
|
||||
{
|
||||
mContentType = contentType;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
if (httpChannel)
|
||||
{
|
||||
if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset)
|
||||
{
|
||||
mCharset = charset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set the state...
|
||||
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostIdle;
|
||||
|
||||
if (mAuthenticationRunning)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mSyncMojo)
|
||||
rv = mSyncMojo->GetAbSyncMojoResults(&mUser, &mCookie, &mMojoSyncSpec, &mMojoSyncPort);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// Before we really get started...lets let sync know who is doing this...
|
||||
NS_WITH_SERVICE(nsIAbSync, sync, kAbSync, &rv);
|
||||
if (NS_SUCCEEDED(rv) || sync)
|
||||
sync->SetAbSyncUser(mUser);
|
||||
|
||||
// Base64 encode then url encode it...
|
||||
//
|
||||
char tUser[256] = "";
|
||||
|
||||
if (Base64Encode((unsigned char *)mUser, nsCRT::strlen(mUser), tUser, sizeof(tUser)) < 0)
|
||||
{
|
||||
rv = NS_ERROR_FAILURE;
|
||||
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
|
||||
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *tUser2 = nsEscape(tUser, url_Path);
|
||||
if (!tUser2)
|
||||
{
|
||||
rv = NS_ERROR_FAILURE;
|
||||
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
|
||||
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSyncProtocolRequestPrefix = PR_smprintf("cn=%s&cc=%s&", tUser2, mCookie);
|
||||
PR_FREEIF(tUser2);
|
||||
NotifyListenersOnStopAuthOperation(aStatus, tProtResponse);
|
||||
KickTheSyncOperation();
|
||||
}
|
||||
}
|
||||
|
||||
// RICHIE - Special here to show the server we are hitting!
|
||||
// RICHIE - REMOVE THIS BEFORE SHIPPING!!!!
|
||||
#ifdef DEBUG
|
||||
PRUnichar *msgValue = nsnull;
|
||||
msgValue = nsTextFormatter::smprintf(nsString(NS_ConvertASCIItoUCS2("Server: %s - port %d")).GetUnicode(),
|
||||
mMojoSyncSpec, mMojoSyncPort);
|
||||
NotifyListenersOnStatus(mTransactionID, msgValue);
|
||||
PR_FREEIF(msgValue);
|
||||
// RICHIE
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
|
||||
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
|
||||
}
|
||||
|
||||
mSyncMojo = nsnull;
|
||||
}
|
||||
else
|
||||
{
|
||||
tProtResponse = mProtocolResponse.ToNewCString();
|
||||
NotifyListenersOnStopSending(mTransactionID, aStatus, tProtResponse);
|
||||
}
|
||||
|
||||
PR_FREEIF(tProtResponse);
|
||||
|
||||
// Time to return...
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void AddSyncListener (in nsIAbSyncPostListener aListener); */
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::AddPostListener(nsIAbSyncPostListener *aListener)
|
||||
{
|
||||
if ( (mListenerArrayCount > 0) || mListenerArray )
|
||||
{
|
||||
++mListenerArrayCount;
|
||||
mListenerArray = (nsIAbSyncPostListener **)
|
||||
PR_Realloc(*mListenerArray, sizeof(nsIAbSyncPostListener *) * mListenerArrayCount);
|
||||
if (!mListenerArray)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
{
|
||||
mListenerArray[mListenerArrayCount - 1] = aListener;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mListenerArrayCount = 1;
|
||||
mListenerArray = (nsIAbSyncPostListener **) PR_Malloc(sizeof(nsIAbSyncPostListener *) * mListenerArrayCount);
|
||||
if (!mListenerArray)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCRT::memset(mListenerArray, 0, (sizeof(nsIAbSyncPostListener *) * mListenerArrayCount));
|
||||
|
||||
mListenerArray[0] = aListener;
|
||||
NS_ADDREF(mListenerArray[0]);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* void RemoveSyncListener (in nsIAbSyncPostListener aListener); */
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::RemovePostListener(nsIAbSyncPostListener *aListener)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] == aListener)
|
||||
{
|
||||
NS_RELEASE(mListenerArray[i]);
|
||||
mListenerArray[i] = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::DeleteListeners()
|
||||
{
|
||||
if ( (mListenerArray) && (*mListenerArray) )
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
{
|
||||
NS_RELEASE(mListenerArray[i]);
|
||||
}
|
||||
|
||||
PR_FREEIF(mListenerArray);
|
||||
}
|
||||
|
||||
mListenerArrayCount = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnStartAuthOperation(void)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnStartAuthOperation();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnStopAuthOperation(nsresult aStatus, const char *aCookie)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnStopAuthOperation(aStatus, nsnull, aCookie);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnStartSending(PRInt32 aTransactionID, PRUint32 aMsgSize)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnStartOperation(aTransactionID, aMsgSize);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnProgress(PRInt32 aTransactionID, PRUint32 aProgress, PRUint32 aProgressMax)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnProgress(aTransactionID, aProgress, aProgressMax);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnStatus(PRInt32 aTransactionID, PRUnichar *aMsg)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnStatus(aTransactionID, aMsg);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::NotifyListenersOnStopSending(PRInt32 aTransactionID, nsresult aStatus,
|
||||
char *aProtocolResponse)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListenerArrayCount; i++)
|
||||
if (mListenerArray[i] != nsnull)
|
||||
mListenerArray[i]->OnStopOperation(aTransactionID, aStatus, nsnull, aProtocolResponse);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Utility to create a nsIURI object...
|
||||
extern "C" nsresult
|
||||
nsEngineNewURI(nsIURI** aInstancePtrResult, const char *aSpec, nsIURI *aBase)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (nsnull == aInstancePtrResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_WITH_SERVICE(nsIIOService, pService, kIOServiceCID, &res);
|
||||
if (NS_FAILED(res))
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
|
||||
return pService->NewURI(aSpec, aBase, aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbSyncPostEngine::FireURLRequest(nsIURI *aURL, const char *postData)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIInputStream> postStream;
|
||||
|
||||
if (!postData)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(mChannel), aURL, nsnull), NS_ERROR_FAILURE);
|
||||
|
||||
// Tag the post stream onto the channel...but never seemed to work...so putting it
|
||||
// directly on the URL spec
|
||||
//
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
|
||||
if (!httpChannel)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postStream), PR_FALSE, postData, 0)))
|
||||
httpChannel->SetUploadStream(postStream);
|
||||
|
||||
httpChannel->AsyncOpen(this, nsnull);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRInt32 GetCurrentState (); */
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::GetCurrentState(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = mPostEngineState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is the implementation of the actual post driver.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::BuildMojoString(nsIDocShell *aRootDocShell, char **aID)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!aID)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Now, get the COMPtr to the Mojo!
|
||||
if (!mSyncMojo)
|
||||
{
|
||||
rv = nsComponentManager::CreateInstance(kCAbSyncMojoCID, NULL, NS_GET_IID(nsIAbSyncMojo), getter_AddRefs(mSyncMojo));
|
||||
if ( NS_FAILED(rv) || (!mSyncMojo) )
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = mSyncMojo->BuildMojoString(aRootDocShell, aID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbSyncPostEngine::SendAbRequest(const char *aSpec, PRInt32 aPort, const char *aProtocolRequest, PRInt32 aTransactionID,
|
||||
nsIDocShell *aDocShell, const char *aUser)
|
||||
{
|
||||
nsresult rv;
|
||||
char *mojoUser = nsnull;
|
||||
char *mojoSnack = nsnull;
|
||||
|
||||
// Only try if we are not currently busy!
|
||||
if (mPostEngineState != nsIAbSyncPostEngineState::nsIAbSyncPostIdle)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Now, get the COMPtr to the Mojo!
|
||||
if (!mSyncMojo)
|
||||
{
|
||||
rv = nsComponentManager::CreateInstance(kCAbSyncMojoCID, NULL, NS_GET_IID(nsIAbSyncMojo), getter_AddRefs(mSyncMojo));
|
||||
if ( NS_FAILED(rv) || (!mSyncMojo) )
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aUser)
|
||||
mUser = nsCRT::strdup(aUser);
|
||||
if (NS_FAILED(mSyncMojo->StartAbSyncMojo(this, aDocShell, mUser)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Set transaction ID and save/init Sync info...
|
||||
mTransactionID = aTransactionID;
|
||||
|
||||
// Init stuff we need....
|
||||
mSyncProtocolRequest = nsCRT::strdup(aProtocolRequest);
|
||||
mProtocolResponse = NS_ConvertASCIItoUCS2("");
|
||||
mTotalWritten = 0;
|
||||
|
||||
// The first thing we need to do is authentication so do it!
|
||||
mAuthenticationRunning = PR_TRUE;
|
||||
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncAuthenticationRunning;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::KickTheSyncOperation(void)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIURI *workURI = nsnull;
|
||||
char *protString = nsnull;
|
||||
|
||||
// The first thing we need to do is authentication so do it!
|
||||
mAuthenticationRunning = PR_FALSE;
|
||||
mProtocolResponse = NS_ConvertASCIItoUCS2("");
|
||||
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostRunning;
|
||||
|
||||
char *postHeader = "Content-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\nCookie: %s\r\n\r\n%s";
|
||||
protString = PR_smprintf("%s%s", mSyncProtocolRequestPrefix, mSyncProtocolRequest);
|
||||
if (protString)
|
||||
mMessageSize = nsCRT::strlen(protString);
|
||||
else
|
||||
mMessageSize = 0;
|
||||
|
||||
char *tCommand = PR_smprintf(postHeader, mMessageSize, mCookie, protString);
|
||||
PR_FREEIF(protString);
|
||||
|
||||
#ifdef DEBUG_rhp
|
||||
printf("COMMAND = %s\n", tCommand);
|
||||
#endif
|
||||
|
||||
if (!tCommand)
|
||||
{
|
||||
rv = NS_ERROR_OUT_OF_MEMORY; // we couldn't allocate the string
|
||||
goto GetOuttaHere;
|
||||
}
|
||||
|
||||
rv = nsEngineNewURI(&workURI, mMojoSyncSpec, nsnull);
|
||||
if (NS_FAILED(rv) || (!workURI))
|
||||
{
|
||||
rv = NS_ERROR_FAILURE; // we couldn't allocate the string
|
||||
goto GetOuttaHere;
|
||||
}
|
||||
|
||||
if (mMojoSyncPort > 0)
|
||||
workURI->SetPort(mMojoSyncPort);
|
||||
|
||||
rv = FireURLRequest(workURI, tCommand);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
NotifyListenersOnStartSending(mTransactionID, mMessageSize);
|
||||
|
||||
GetOuttaHere:
|
||||
NS_IF_RELEASE(workURI);
|
||||
PR_FREEIF(tCommand);
|
||||
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostRunning;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::CancelAbSync()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (mSyncMojo)
|
||||
{
|
||||
rv = mSyncMojo->CancelTheMojo();
|
||||
}
|
||||
else if (mChannel)
|
||||
{
|
||||
rv = mChannel->Cancel(NS_BINDING_ABORTED);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::GetMojoUserAndSnack(char **aMojoUser, char **aMojoSnack)
|
||||
{
|
||||
if ( (!mUser) || (!mCookie) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aMojoUser = nsCRT::strdup(mUser);
|
||||
*aMojoSnack = nsCRT::strdup(mCookie);
|
||||
|
||||
if ( (!*aMojoUser) || (!*aMojoSnack) )
|
||||
return NS_ERROR_FAILURE;
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
2107
mozilla/mailnews/compose/src/nsMsgCompUtils.cpp
Normal file
2107
mozilla/mailnews/compose/src/nsMsgCompUtils.cpp
Normal file
File diff suppressed because it is too large
Load Diff
453
mozilla/mailnews/compose/src/nsURLFetcher.cpp
Normal file
453
mozilla/mailnews/compose/src/nsURLFetcher.cpp
Normal file
@@ -0,0 +1,453 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "nsURLFetcher.h"
|
||||
|
||||
#include "msgCore.h" // for pre-compiled headers
|
||||
#include "nsCOMPtr.h"
|
||||
#include <stdio.h>
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "comi18n.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsMsgAttachmentHandler.h"
|
||||
#include "nsMsgSend.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS7(nsURLFetcher, nsIURLFetcher, nsIStreamListener, nsIURIContentListener, nsIInterfaceRequestor, nsIWebProgressListener, nsIHttpEventSink, nsISupportsWeakReference)
|
||||
|
||||
|
||||
/*
|
||||
* Inherited methods for nsMimeConverter
|
||||
*/
|
||||
nsURLFetcher::nsURLFetcher()
|
||||
{
|
||||
#if defined(DEBUG_ducarroz)
|
||||
printf("CREATE nsURLFetcher: %x\n", this);
|
||||
#endif
|
||||
/* the following macro is used to initialize the ref counting data */
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// Init member variables...
|
||||
mOutStream = nsnull;
|
||||
mTotalWritten = 0;
|
||||
mStillRunning = PR_TRUE;
|
||||
mCallback = nsnull;
|
||||
mContentType = nsnull;
|
||||
mCharset = nsnull;
|
||||
mOnStopRequestProcessed = PR_FALSE;
|
||||
mRedirection = PR_FALSE;
|
||||
}
|
||||
|
||||
nsURLFetcher::~nsURLFetcher()
|
||||
{
|
||||
#if defined(DEBUG_ducarroz)
|
||||
printf("DISPOSE nsURLFetcher: %x\n", this);
|
||||
#endif
|
||||
mStillRunning = PR_FALSE;
|
||||
|
||||
PR_FREEIF(mContentType);
|
||||
PR_FREEIF(mCharset);
|
||||
// Remove the DocShell as a listener of the old WebProgress...
|
||||
if (mLoadCookie)
|
||||
{
|
||||
nsCOMPtr<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));
|
||||
|
||||
if (webProgress)
|
||||
webProgress->RemoveProgressListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsURLFetcher::GetInterface(const nsIID & aIID, void * *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
// nsIURIContentListener support
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnStartURIOpen(nsIURI* aURI,
|
||||
const char* aWindowTarget, PRBool* aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandler)
|
||||
{
|
||||
*aProtocolHandler = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::IsPreferred(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
return CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
|
||||
aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::CanHandleContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
if (nsCRT::strcasecmp(aContentType, MESSAGE_RFC822) == 0)
|
||||
*aDesiredContentType = nsCRT::strdup("text/html");
|
||||
|
||||
// since we explicilty loaded the url, we always want to handle it!
|
||||
*aCanHandleContent = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::DoContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsIRequest *request,
|
||||
nsIStreamListener ** aContentHandler,
|
||||
PRBool * aAbortProcess)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aAbortProcess)
|
||||
*aAbortProcess = PR_FALSE;
|
||||
QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::GetParentContentListener(nsIURIContentListener** aParent)
|
||||
{
|
||||
*aParent = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::SetParentContentListener(nsIURIContentListener* aParent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::GetLoadCookie(nsISupports ** aLoadCookie)
|
||||
{
|
||||
*aLoadCookie = mLoadCookie;
|
||||
NS_IF_ADDREF(*aLoadCookie);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
{
|
||||
// Remove the DocShell as a listener of the old WebProgress...
|
||||
if (mLoadCookie)
|
||||
{
|
||||
nsCOMPtr<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));
|
||||
|
||||
if (webProgress)
|
||||
webProgress->RemoveProgressListener(this);
|
||||
}
|
||||
|
||||
mLoadCookie = aLoadCookie;
|
||||
|
||||
// Add the DocShell as a listener to the new WebProgress...
|
||||
if (mLoadCookie)
|
||||
{
|
||||
nsCOMPtr<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));
|
||||
|
||||
if (webProgress)
|
||||
webProgress->AddProgressListener(this);
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURLFetcher::StillRunning(PRBool *running)
|
||||
{
|
||||
*running = mStillRunning;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Methods for nsIStreamListener...
|
||||
nsresult
|
||||
nsURLFetcher::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream,
|
||||
PRUint32 sourceOffset, PRUint32 aLength)
|
||||
{
|
||||
PRUint32 readLen = aLength;
|
||||
PRUint32 wroteIt;
|
||||
|
||||
if (!mOutStream)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
char *buf = (char *)PR_Malloc(aLength);
|
||||
if (!buf)
|
||||
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
|
||||
// read the data from the input stram...
|
||||
nsresult rv = aIStream->Read(buf, aLength, &readLen);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// write to the output file...
|
||||
wroteIt = mOutStream->write(buf, readLen);
|
||||
PR_FREEIF(buf);
|
||||
|
||||
if (wroteIt != readLen)
|
||||
return NS_ERROR_FAILURE;
|
||||
else
|
||||
{
|
||||
mTotalWritten += wroteIt;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Methods for nsIStreamObserver
|
||||
nsresult
|
||||
nsURLFetcher::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||
{
|
||||
mRedirection = PR_FALSE; // start a new request, reset mRedirection
|
||||
|
||||
nsMsgAttachmentHandler *attachmentHdl = (nsMsgAttachmentHandler *)mTagData;
|
||||
if (attachmentHdl)
|
||||
{
|
||||
nsCOMPtr<nsIMsgSend> sendPtr;
|
||||
attachmentHdl->GetMimeDeliveryState(getter_AddRefs(sendPtr));
|
||||
if (sendPtr)
|
||||
{
|
||||
nsCOMPtr<nsIMsgProgress> progress;
|
||||
sendPtr->GetProgress(getter_AddRefs(progress));
|
||||
if (progress)
|
||||
{
|
||||
PRBool cancel = PR_FALSE;
|
||||
progress->GetProcessCanceledByUser(&cancel);
|
||||
if (cancel)
|
||||
return request->Cancel(NS_ERROR_ABORT);
|
||||
}
|
||||
}
|
||||
attachmentHdl->mRequest = request;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURLFetcher::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus)
|
||||
{
|
||||
#if defined(DEBUG_ducarroz)
|
||||
printf("nsURLFetcher::OnStopRequest()\n");
|
||||
#endif
|
||||
|
||||
// it's possible we could get in here from the channel calling us with an OnStopRequest and from our
|
||||
// onStatusChange method (in the case of an error). So we should protect against this to make sure we
|
||||
// don't process the on stop request twice...
|
||||
|
||||
if (mOnStopRequestProcessed) return NS_OK;
|
||||
mOnStopRequestProcessed = PR_TRUE;
|
||||
|
||||
nsMsgAttachmentHandler *attachmentHdl = (nsMsgAttachmentHandler *)mTagData;
|
||||
if (attachmentHdl)
|
||||
attachmentHdl->mRequest = nsnull;
|
||||
|
||||
//
|
||||
// Now complete the stream!
|
||||
//
|
||||
mStillRunning = PR_FALSE;
|
||||
|
||||
// First close the output stream...
|
||||
if (mOutStream)
|
||||
{
|
||||
mOutStream->close();
|
||||
mOutStream = nsnull;
|
||||
}
|
||||
|
||||
|
||||
// Check the content type!
|
||||
char *contentType = nsnull;
|
||||
char *charset = nsnull;
|
||||
|
||||
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
|
||||
if(!aChannel) return NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_SUCCEEDED(aChannel->GetContentType(&contentType)) && contentType)
|
||||
{
|
||||
if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE))
|
||||
{
|
||||
mContentType = contentType;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel)
|
||||
{
|
||||
if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset)
|
||||
{
|
||||
mCharset = charset;
|
||||
}
|
||||
}
|
||||
|
||||
// Now if there is a callback, we need to call it...
|
||||
if (mCallback)
|
||||
mCallback (aStatus, mContentType, mCharset, mTotalWritten, nsnull, mTagData);
|
||||
|
||||
// Time to return...
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURLFetcher::Initialize(nsOutputFileStream *fOut,
|
||||
nsAttachSaveCompletionCallback cb,
|
||||
void *tagData)
|
||||
{
|
||||
if (!fOut)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (!fOut->is_open())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mOutStream = fOut;
|
||||
mCallback = cb; //JFD: Please, no more callback, use a listener...
|
||||
mTagData = tagData; //JFD: TODO, WE SHOULD USE A NSCOMPTR to hold this stuff!!!
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
|
||||
nsAttachSaveCompletionCallback cb, void *tagData)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if ( (!aURL) || (!fOut) )
|
||||
{
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!fOut->is_open())
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// we're about to fire a new url request so make sure the on stop request flag is cleared...
|
||||
mOnStopRequestProcessed = PR_FALSE;
|
||||
|
||||
// let's try uri dispatching...
|
||||
nsCOMPtr<nsIURILoader> pURILoader (do_GetService(NS_URI_LOADER_CONTRACTID));
|
||||
NS_ENSURE_TRUE(pURILoader, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsISupports> cntListener (do_QueryInterface(NS_STATIC_CAST(nsIStreamListener *, this)));
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
pURILoader->GetLoadGroupForContext(cntListener, getter_AddRefs(loadGroup));
|
||||
NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(channel), aURL, nsnull, loadGroup, this), NS_ERROR_FAILURE);
|
||||
|
||||
rv = pURILoader->OpenURI(channel, nsIURILoader::viewNormal, nsnull /* window target */,
|
||||
cntListener);
|
||||
|
||||
mOutStream = fOut;
|
||||
mCallback = cb;
|
||||
mTagData = tagData;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// web progress listener implementation
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnProgressChange(nsIWebProgress *aProgress, nsIRequest *aRequest,
|
||||
PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress,
|
||||
PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest,
|
||||
PRInt32 aStateFlags, nsresult aStatus)
|
||||
{
|
||||
// all we care about is the case where an error occurred (as in we were unable to locate the
|
||||
// the url....
|
||||
|
||||
if (NS_FAILED(aStatus))
|
||||
{
|
||||
//... but we must ignore abort message caused by a redirection!
|
||||
if (aStatus == NS_BINDING_ABORTED && mRedirection)
|
||||
return NS_OK;
|
||||
|
||||
OnStopRequest(aRequest, nsnull, aStatus);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnLocationChange(nsIWebProgress* aWebProgress,
|
||||
nsIRequest* aRequest,
|
||||
nsIURI *aURI)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnStatusChange(nsIWebProgress* aWebProgress,
|
||||
nsIRequest* aRequest,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* aMessage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnSecurityChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 state)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnRedirect(nsIHttpChannel *aOldChannel, nsIChannel *aNewChannel)
|
||||
{
|
||||
mRedirection = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
88
mozilla/mailnews/compose/src/nsURLFetcher.h
Normal file
88
mozilla/mailnews/compose/src/nsURLFetcher.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsURLFetcher_h_
|
||||
#define nsURLFetcher_h_
|
||||
|
||||
#include "nsIURLFetcher.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsIURIContentListener.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
|
||||
class nsURLFetcher : public nsIURLFetcher,
|
||||
public nsIStreamListener,
|
||||
public nsIURIContentListener,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIWebProgressListener,
|
||||
public nsIHttpEventSink,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
nsURLFetcher();
|
||||
virtual ~nsURLFetcher();
|
||||
|
||||
/* this macro defines QueryInterface, AddRef and Release for this class */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// Methods for nsIURLFetcher
|
||||
NS_DECL_NSIURLFETCHER
|
||||
|
||||
// Methods for nsIStreamListener
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
||||
// Methods for nsIRequestObserver
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
// Methods for nsIURICOntentListener
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
|
||||
// Methods for nsIInterfaceRequestor
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
// Methods for nsIWebProgressListener
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
// Methods for nsIHttpEventSink
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
|
||||
private:
|
||||
nsOutputFileStream *mOutStream; // the output file stream
|
||||
PRBool mStillRunning; // Are we still running?
|
||||
PRInt32 mTotalWritten; // Size counter variable
|
||||
char *mContentType; // The content type retrieved from the server
|
||||
char *mCharset; // The charset retrieved from the server
|
||||
void *mTagData; // Tag data for callback...
|
||||
nsAttachSaveCompletionCallback mCallback; // Callback to call once the file is saved...
|
||||
nsCOMPtr<nsISupports> mLoadCookie; // load cookie used by the uri loader when we fetch the url
|
||||
PRBool mOnStopRequestProcessed; // used to prevent calling OnStopRequest multiple times
|
||||
PRBool mRedirection; // Set when we get a redirection, should ignore stop message.
|
||||
};
|
||||
|
||||
#endif /* nsURLFetcher_h_ */
|
||||
39
mozilla/modules/libjar/nsIJARChannel.idl
Normal file
39
mozilla/modules/libjar/nsIJARChannel.idl
Normal file
@@ -0,0 +1,39 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIChannel.idl"
|
||||
|
||||
interface nsISimpleEnumerator;
|
||||
|
||||
[scriptable, uuid(c7e410d1-85f2-11d3-9f63-006008a6efe9)]
|
||||
interface nsIJARChannel : nsIChannel
|
||||
{
|
||||
|
||||
/**
|
||||
* Enumerates all the entries in the JAR (the root URI).
|
||||
* ARGUMENTS:
|
||||
* aRoot - a string representing the root dir to enumerate from
|
||||
* or null to enumerate the whole thing.
|
||||
*/
|
||||
nsISimpleEnumerator EnumerateEntries(in string aRoot);
|
||||
|
||||
};
|
||||
34
mozilla/modules/libjar/nsIJARProtocolHandler.idl
Normal file
34
mozilla/modules/libjar/nsIJARProtocolHandler.idl
Normal file
@@ -0,0 +1,34 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIProtocolHandler.idl"
|
||||
|
||||
interface nsIZipReaderCache;
|
||||
|
||||
[scriptable, uuid(92c3b42c-98c4-11d3-8cd9-0060b0fc14a3)]
|
||||
interface nsIJARProtocolHandler : nsIProtocolHandler {
|
||||
|
||||
/**
|
||||
* JARCache contains the collection of open jar files.
|
||||
*/
|
||||
readonly attribute nsIZipReaderCache JARCache;
|
||||
};
|
||||
42
mozilla/modules/libjar/nsIJARURI.idl
Normal file
42
mozilla/modules/libjar/nsIJARURI.idl
Normal file
@@ -0,0 +1,42 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsIURI.idl"
|
||||
|
||||
/**
|
||||
* JAR URLs have the following syntax
|
||||
*
|
||||
* jar:<jar-file-uri>!/<jar-entry>
|
||||
*
|
||||
* EXAMPLE: jar:http://www.big.com/blue.jar!/ocean.html
|
||||
*/
|
||||
[scriptable, uuid(c7e410d3-85f2-11d3-9f63-006008a6efe9)]
|
||||
interface nsIJARURI : nsIURI {
|
||||
|
||||
/**
|
||||
* Returns the root URI (the one for the actual JAR file) for this JAR.
|
||||
* eg http://www.big.com/blue.jar
|
||||
*/
|
||||
attribute nsIURI JARFile;
|
||||
|
||||
/**
|
||||
* Returns the entry specified for this JAR URI.
|
||||
* eg ocean.html
|
||||
*/
|
||||
attribute string JAREntry;
|
||||
};
|
||||
696
mozilla/modules/libjar/nsJARChannel.cpp
Normal file
696
mozilla/modules/libjar/nsJARChannel.cpp
Normal file
@@ -0,0 +1,696 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998,2000 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsJARChannel.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIFileTransportService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsIAggregatePrincipal.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIJAR.h"
|
||||
|
||||
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
|
||||
static NS_DEFINE_CID(kScriptSecurityManagerCID, NS_SCRIPTSECURITYMANAGER_CID);
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
//
|
||||
// Log module for SocketTransport logging...
|
||||
//
|
||||
// To enable logging (see prlog.h for full details):
|
||||
//
|
||||
// set NSPR_LOG_MODULES=nsJarProtocol:5
|
||||
// set NSPR_LOG_FILE=nspr.log
|
||||
//
|
||||
// this enables PR_LOG_DEBUG level information and places all output in
|
||||
// the file nspr.log
|
||||
//
|
||||
PRLogModuleInfo* gJarProtocolLog = nsnull;
|
||||
|
||||
#endif /* PR_LOGGING */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NS_DEFAULT_JAR_BUFFER_SEGMENT_SIZE (16*1024)
|
||||
#define NS_DEFAULT_JAR_BUFFER_MAX_SIZE (256*1024)
|
||||
|
||||
nsJARChannel::nsJARChannel()
|
||||
: mLoadFlags(LOAD_NORMAL),
|
||||
mContentType(nsnull),
|
||||
mContentLength(-1),
|
||||
mJAREntry(nsnull),
|
||||
mStatus(NS_OK),
|
||||
mMonitor(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
//
|
||||
// Initialize the global PRLogModule for socket transport logging
|
||||
// if necessary...
|
||||
//
|
||||
if (nsnull == gJarProtocolLog) {
|
||||
gJarProtocolLog = PR_NewLogModule("nsJarProtocol");
|
||||
}
|
||||
#endif /* PR_LOGGING */
|
||||
}
|
||||
|
||||
nsJARChannel::~nsJARChannel()
|
||||
{
|
||||
if (mContentType)
|
||||
nsCRT::free(mContentType);
|
||||
if (mJAREntry)
|
||||
nsCRT::free(mJAREntry);
|
||||
if (mMonitor)
|
||||
PR_DestroyMonitor(mMonitor);
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS7(nsJARChannel,
|
||||
nsIJARChannel,
|
||||
nsIChannel,
|
||||
nsIRequest,
|
||||
nsIRequestObserver,
|
||||
nsIStreamListener,
|
||||
nsIStreamIO,
|
||||
nsIDownloadObserver)
|
||||
|
||||
NS_METHOD
|
||||
nsJARChannel::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsJARChannel* jarChannel = new nsJARChannel();
|
||||
if (jarChannel == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(jarChannel);
|
||||
rv = jarChannel->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(jarChannel);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARChannel::Init(nsIJARProtocolHandler* aHandler, nsIURI* uri)
|
||||
{
|
||||
nsresult rv;
|
||||
mURI = do_QueryInterface(uri, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mMonitor = PR_NewMonitor();
|
||||
if (mMonitor == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
mJARProtocolHandler = aHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRequest methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetName(PRUnichar* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPIDLCString urlStr;
|
||||
rv = mURI->GetSpec(getter_Copies(urlStr));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsString name;
|
||||
name.AppendWithConversion(urlStr);
|
||||
*result = name.ToNewUnicode();
|
||||
return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::IsPending(PRBool* result)
|
||||
{
|
||||
NS_NOTREACHED("nsJARChannel::IsPending");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetStatus(nsresult *status)
|
||||
{
|
||||
*status = mStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Cancel(nsresult status)
|
||||
{
|
||||
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoMonitor monitor(mMonitor);
|
||||
|
||||
if (mJarExtractionTransport) {
|
||||
rv = mJarExtractionTransport->Cancel(status);
|
||||
mJarExtractionTransport = nsnull;
|
||||
}
|
||||
|
||||
mStatus = status;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Suspend()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoMonitor monitor(mMonitor);
|
||||
|
||||
if (mJarExtractionTransport) {
|
||||
rv = mJarExtractionTransport->Suspend();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Resume()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoMonitor monitor(mMonitor);
|
||||
|
||||
if (mJarExtractionTransport) {
|
||||
rv = mJarExtractionTransport->Resume();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIChannel methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetOriginalURI(nsIURI* *aOriginalURI)
|
||||
{
|
||||
if (mOriginalURI)
|
||||
*aOriginalURI = mOriginalURI;
|
||||
else
|
||||
*aOriginalURI = NS_STATIC_CAST(nsIURI*, mURI);
|
||||
|
||||
NS_IF_ADDREF(*aOriginalURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetOriginalURI(nsIURI* aOriginalURI)
|
||||
{
|
||||
mOriginalURI = aOriginalURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetURI(nsIURI* *aURI)
|
||||
{
|
||||
*aURI = mURI;
|
||||
NS_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARChannel::OpenJARElement()
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoCMonitor mon(this);
|
||||
rv = Open(nsnull, nsnull);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = GetInputStream(getter_AddRefs(mSynchronousInputStream));
|
||||
mon.Notify(); // wake up nsIChannel::Open
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Open(nsIInputStream* *result)
|
||||
{
|
||||
nsAutoCMonitor mon(this);
|
||||
nsresult rv;
|
||||
mSynchronousRead = PR_TRUE;
|
||||
rv = EnsureJARFileAvailable();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (mSynchronousInputStream == nsnull)
|
||||
mon.Wait();
|
||||
if (mSynchronousInputStream)
|
||||
{
|
||||
*result = mSynchronousInputStream; // Result of GetInputStream called on transport thread
|
||||
NS_ADDREF(*result);
|
||||
mSynchronousInputStream = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::AsyncOpen(nsIStreamListener* listener, nsISupports* ctxt)
|
||||
{
|
||||
nsresult rv;
|
||||
mUserContext = ctxt;
|
||||
mUserListener = listener;
|
||||
|
||||
if (mLoadGroup) {
|
||||
rv = mLoadGroup->AddRequest(this, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
mSynchronousRead = PR_FALSE;
|
||||
return EnsureJARFileAvailable();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARChannel::EnsureJARFileAvailable()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIChannel> jarBaseChannel;
|
||||
nsCOMPtr<nsIFile> jarCacheFile;
|
||||
nsCOMPtr<nsIChannel> jarCacheTransport;
|
||||
nsCOMPtr<nsIInputStream> jarBaseIn;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
nsXPIDLCString jarURLStr;
|
||||
mURI->GetSpec(getter_Copies(jarURLStr));
|
||||
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
||||
("nsJarProtocol: EnsureJARFileAvailable %s", (const char*)jarURLStr));
|
||||
#endif
|
||||
|
||||
rv = mURI->GetJARFile(getter_AddRefs(mJARBaseURI));
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
rv = mURI->GetJAREntry(&mJAREntry);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
rv = NS_NewDownloader(getter_AddRefs(mDownloader),
|
||||
mJARBaseURI, this, nsnull, mSynchronousRead, mLoadGroup, mCallbacks,
|
||||
mLoadFlags);
|
||||
|
||||
// if DownloadComplete() was called early, need to release the reference.
|
||||
if (mSynchronousRead && mSynchronousInputStream)
|
||||
mDownloader = null_nsCOMPtr();
|
||||
|
||||
error:
|
||||
if (NS_FAILED(rv) && mLoadGroup) {
|
||||
nsresult rv2 = mLoadGroup->RemoveRequest(this, nsnull, NS_OK);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed");
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARChannel::AsyncReadJARElement()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsAutoMonitor monitor(mMonitor);
|
||||
|
||||
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsITransport> jarTransport;
|
||||
rv = fts->CreateTransportFromStreamIO(this, getter_AddRefs(jarTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (mCallbacks) {
|
||||
nsCOMPtr<nsIProgressEventSink> sink = do_GetInterface(mCallbacks);
|
||||
if (sink) {
|
||||
// don't think that this is not needed anymore
|
||||
// jarTransport->SetProgressEventSink(sink);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
nsXPIDLCString jarURLStr;
|
||||
mURI->GetSpec(getter_Copies(jarURLStr));
|
||||
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
||||
("nsJarProtocol: AsyncRead jar entry %s", (const char*)jarURLStr));
|
||||
#endif
|
||||
|
||||
rv = jarTransport->AsyncRead(this, nsnull, 0, PRUint32(-1), 0,
|
||||
getter_AddRefs(mJarExtractionTransport));
|
||||
mJarExtractionTransport = 0;
|
||||
jarTransport = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetLoadFlags(PRUint32* aLoadFlags)
|
||||
{
|
||||
*aLoadFlags = mLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetLoadFlags(PRUint32 aLoadFlags)
|
||||
{
|
||||
mLoadFlags = aLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetContentType(char* *aContentType)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mContentType == nsnull) {
|
||||
if (!mJAREntry)
|
||||
return NS_ERROR_FAILURE;
|
||||
char* fileName = nsCRT::strdup(mJAREntry);
|
||||
if (fileName != nsnull) {
|
||||
PRInt32 len = nsCRT::strlen(fileName);
|
||||
const char* ext = nsnull;
|
||||
for (PRInt32 i = len-1; i >= 0; i--) {
|
||||
if (fileName[i] == '.') {
|
||||
ext = &fileName[i + 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ext) {
|
||||
nsCOMPtr<nsIMIMEService> mimeServ (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mimeServ->GetTypeFromExtension(ext, &mContentType);
|
||||
}
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCRT::free(fileName);
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
mContentType = nsCRT::strdup(UNKNOWN_CONTENT_TYPE);
|
||||
if (mContentType == nsnull)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*aContentType = nsCRT::strdup(mContentType);
|
||||
if (*aContentType == nsnull)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetContentType(const char *aContentType)
|
||||
{
|
||||
if (mContentType) {
|
||||
nsCRT::free(mContentType);
|
||||
}
|
||||
|
||||
mContentType = nsCRT::strdup(aContentType);
|
||||
if (!mContentType) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetContentLength(PRInt32* aContentLength)
|
||||
{
|
||||
if (mContentLength == -1)
|
||||
return NS_ERROR_FAILURE;
|
||||
*aContentLength = mContentLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetContentLength(PRInt32 aContentLength)
|
||||
{
|
||||
NS_NOTREACHED("nsJARChannel::SetContentLength");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mOwner == nsnull) {
|
||||
//-- Verify signature, if one is present, and set owner accordingly
|
||||
rv = EnsureZipReader();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIJAR> jar = do_QueryInterface(mJAR, &rv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Zip reader is not an nsIJAR");
|
||||
nsCOMPtr<nsIPrincipal> certificate;
|
||||
rv = jar->GetCertificatePrincipal(mJAREntry,
|
||||
getter_AddRefs(certificate));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (certificate)
|
||||
{ // Get the codebase principal
|
||||
NS_WITH_SERVICE(nsIScriptSecurityManager, secMan,
|
||||
kScriptSecurityManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIPrincipal> codebase;
|
||||
rv = secMan->GetCodebasePrincipal(mJARBaseURI,
|
||||
getter_AddRefs(codebase));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Join the certificate and the codebase
|
||||
nsCOMPtr<nsIAggregatePrincipal> agg;
|
||||
agg = do_QueryInterface(certificate, &rv);
|
||||
rv = agg->SetCodebase(codebase);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mOwner = do_QueryInterface(agg, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
*aOwner = mOwner;
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
|
||||
{
|
||||
*aSecurityInfo = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIDownloadObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::OnDownloadComplete(nsIDownloader* aDownloader, nsISupports* aClosure,
|
||||
nsresult aStatus, nsIFile* aFile)
|
||||
{
|
||||
nsresult rv=aStatus;
|
||||
if(NS_SUCCEEDED(aStatus)) {
|
||||
NS_ASSERTION(!mDownloader ||(aDownloader == mDownloader.get()), "wrong downloader");
|
||||
mDownloadedJARFile = aFile;
|
||||
// after successfully downloading the jar file to the cache,
|
||||
// start the extraction process:
|
||||
if (mSynchronousRead)
|
||||
rv = OpenJARElement();
|
||||
else
|
||||
rv = AsyncReadJARElement();
|
||||
}
|
||||
mDownloader = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRequestObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::OnStartRequest(nsIRequest* jarExtractionTransport,
|
||||
nsISupports* context)
|
||||
{
|
||||
return mUserListener->OnStartRequest(this, mUserContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::OnStopRequest(nsIRequest* jarExtractionTransport, nsISupports* context,
|
||||
nsresult aStatus)
|
||||
{
|
||||
nsresult rv;
|
||||
#ifdef PR_LOGGING
|
||||
nsCOMPtr<nsIURI> jarURI;
|
||||
nsXPIDLCString jarURLStr;
|
||||
rv = mURI->GetSpec(getter_Copies(jarURLStr));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
||||
("nsJarProtocol: jar extraction complete %s status=%x",
|
||||
(const char*)jarURLStr, aStatus));
|
||||
}
|
||||
#endif
|
||||
|
||||
rv = mUserListener->OnStopRequest(this, mUserContext, aStatus);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "OnStopRequest failed");
|
||||
|
||||
if (mLoadGroup)
|
||||
mLoadGroup->RemoveRequest(this, context, aStatus);
|
||||
|
||||
mUserListener = nsnull;
|
||||
mUserContext = nsnull;
|
||||
mJarExtractionTransport = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamListener methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::OnDataAvailable(nsIRequest* jarCacheTransport,
|
||||
nsISupports* context,
|
||||
nsIInputStream *inStr,
|
||||
PRUint32 sourceOffset,
|
||||
PRUint32 count)
|
||||
{
|
||||
return mUserListener->OnDataAvailable(this, mUserContext,
|
||||
inStr, sourceOffset, count);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamIO methods:
|
||||
|
||||
nsresult
|
||||
nsJARChannel::EnsureZipReader()
|
||||
{
|
||||
if (mJAR == nsnull) {
|
||||
nsresult rv;
|
||||
if (mDownloadedJARFile == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIZipReaderCache> jarCache;
|
||||
rv = mJARProtocolHandler->GetJARCache(getter_AddRefs(jarCache));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = jarCache->GetZip(mDownloadedJARFile, getter_AddRefs(mJAR));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Open(char* *contentType, PRInt32 *contentLength)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = EnsureZipReader();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIZipEntry> entry;
|
||||
rv = mJAR->GetEntry(mJAREntry, getter_AddRefs(entry));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (contentLength) {
|
||||
rv = entry->GetRealSize((PRUint32*)contentLength);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
if (contentType) {
|
||||
rv = GetContentType(contentType);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::Close(nsresult status)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetInputStream(nsIInputStream* *aInputStream)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
nsXPIDLCString jarURLStr;
|
||||
mURI->GetSpec(getter_Copies(jarURLStr));
|
||||
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
||||
("nsJarProtocol: GetInputStream jar entry %s", (const char*)jarURLStr));
|
||||
#endif
|
||||
NS_ENSURE_TRUE(mJAR, NS_ERROR_NULL_POINTER);
|
||||
return mJAR->GetInputStream(mJAREntry, aInputStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetOutputStream(nsIOutputStream* *aOutputStream)
|
||||
{
|
||||
NS_NOTREACHED("nsJARChannel::GetOutputStream");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetName(char* *aName)
|
||||
{
|
||||
return mURI->GetSpec(aName);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIJARChannel methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::EnumerateEntries(const char *aRoot, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
NS_NOTREACHED("nsJARChannel::EnumerateEntries");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
111
mozilla/modules/libjar/nsJARChannel.h
Normal file
111
mozilla/modules/libjar/nsJARChannel.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998,2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsJARChannel_h__
|
||||
#define nsJARChannel_h__
|
||||
|
||||
#include "nsIJARChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIJARProtocolHandler.h"
|
||||
#include "nsIJARURI.h"
|
||||
#include "nsIStreamIO.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFile.h"
|
||||
#include "prmon.h"
|
||||
#include "nsIDownloader.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
||||
class nsIFileChannel;
|
||||
class nsJARChannel;
|
||||
|
||||
#define NS_JARCHANNEL_CID \
|
||||
{ /* 0xc7e410d5-0x85f2-11d3-9f63-006008a6efe9 */ \
|
||||
0xc7e410d5, \
|
||||
0x85f2, \
|
||||
0x11d3, \
|
||||
{0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \
|
||||
}
|
||||
|
||||
class nsJARChannel : public nsIJARChannel,
|
||||
public nsIStreamListener,
|
||||
public nsIStreamIO,
|
||||
public nsIDownloadObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSICHANNEL
|
||||
NS_DECL_NSIJARCHANNEL
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSISTREAMIO
|
||||
NS_DECL_NSIDOWNLOADOBSERVER
|
||||
|
||||
nsJARChannel();
|
||||
virtual ~nsJARChannel();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
nsresult Init(nsIJARProtocolHandler* aHandler, nsIURI* uri);
|
||||
nsresult EnsureJARFileAvailable();
|
||||
nsresult OpenJARElement();
|
||||
nsresult AsyncReadJARElement();
|
||||
nsresult EnsureZipReader();
|
||||
|
||||
friend class nsJARDownloadObserver;
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIJARProtocolHandler> mJARProtocolHandler;
|
||||
nsCOMPtr<nsIJARURI> mURI;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsLoadFlags mLoadFlags;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
||||
nsCOMPtr<nsISupports> mUserContext;
|
||||
nsCOMPtr<nsIStreamListener> mUserListener;
|
||||
|
||||
char* mContentType;
|
||||
PRInt32 mContentLength;
|
||||
nsCOMPtr<nsIURI> mJARBaseURI;
|
||||
char* mJAREntry;
|
||||
nsCOMPtr<nsIZipReader> mJAR;
|
||||
nsCOMPtr<nsIFile> mDownloadedJARFile;
|
||||
nsresult mStatus;
|
||||
PRBool mSynchronousRead;
|
||||
nsCOMPtr<nsIInputStream> mSynchronousInputStream;
|
||||
|
||||
PRMonitor* mMonitor;
|
||||
nsCOMPtr<nsIDownloader> mDownloader;
|
||||
nsCOMPtr<nsIRequest> mJarExtractionTransport;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsJARChannel_h__
|
||||
162
mozilla/modules/libjar/nsJARProtocolHandler.cpp
Normal file
162
mozilla/modules/libjar/nsJARProtocolHandler.cpp
Normal file
@@ -0,0 +1,162 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsJARProtocolHandler.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsJARURI.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsJARChannel.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kJARUriCID, NS_JARURI_CID);
|
||||
static NS_DEFINE_CID(kZipReaderCacheCID, NS_ZIPREADERCACHE_CID);
|
||||
|
||||
#define NS_JAR_CACHE_SIZE 32
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsJARProtocolHandler::nsJARProtocolHandler()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARProtocolHandler::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsComponentManager::CreateInstance(kZipReaderCacheCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIZipReaderCache),
|
||||
getter_AddRefs(mJARCache));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mJARCache->Init(NS_JAR_CACHE_SIZE);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsJARProtocolHandler::~nsJARProtocolHandler()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsJARProtocolHandler,
|
||||
nsIJARProtocolHandler,
|
||||
nsIProtocolHandler)
|
||||
|
||||
NS_METHOD
|
||||
nsJARProtocolHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsJARProtocolHandler* ph = new nsJARProtocolHandler();
|
||||
if (ph == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(ph);
|
||||
nsresult rv = ph->Init();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = ph->QueryInterface(aIID, aResult);
|
||||
}
|
||||
NS_RELEASE(ph);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::GetJARCache(nsIZipReaderCache* *result)
|
||||
{
|
||||
*result = mJARCache;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProtocolHandler methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::GetScheme(char* *result)
|
||||
{
|
||||
*result = nsCRT::strdup("jar");
|
||||
if (*result == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::GetDefaultPort(PRInt32 *result)
|
||||
{
|
||||
*result = -1; // no port for JAR: URLs
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
nsIURI **result)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsIURI* url;
|
||||
|
||||
rv = nsJARURI::Create(nsnull, NS_GET_IID(nsIJARURI), (void**)&url);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (aBaseURI)
|
||||
{
|
||||
nsXPIDLCString aResolvedURI;
|
||||
rv = aBaseURI->Resolve(aSpec, getter_Copies(aResolvedURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = url->SetSpec(aResolvedURI);
|
||||
} else {
|
||||
rv = url->SetSpec((char*)aSpec);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(url);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = url;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsJARChannel* channel;
|
||||
rv = nsJARChannel::Create(nsnull, NS_GET_IID(nsIJARChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->Init(this, uri);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = channel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
61
mozilla/modules/libjar/nsJARProtocolHandler.h
Normal file
61
mozilla/modules/libjar/nsJARProtocolHandler.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsJARProtocolHandler_h___
|
||||
#define nsJARProtocolHandler_h___
|
||||
|
||||
#include "nsIJARProtocolHandler.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsIJARURI.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_JARPROTOCOLHANDLER_CID \
|
||||
{ /* 0xc7e410d4-0x85f2-11d3-9f63-006008a6efe9 */ \
|
||||
0xc7e410d4, \
|
||||
0x85f2, \
|
||||
0x11d3, \
|
||||
{0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \
|
||||
}
|
||||
|
||||
|
||||
class nsJARProtocolHandler : public nsIJARProtocolHandler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
NS_DECL_NSIJARPROTOCOLHANDLER
|
||||
|
||||
// nsJARProtocolHandler methods:
|
||||
nsJARProtocolHandler();
|
||||
virtual ~nsJARProtocolHandler();
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
nsresult Init();
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIZipReaderCache> mJARCache;
|
||||
};
|
||||
|
||||
#endif /* nsJARProtocolHandler_h___ */
|
||||
38
mozilla/modules/libjar/nsJARProtocolModule.cpp
Normal file
38
mozilla/modules/libjar/nsJARProtocolModule.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIModule.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsJARProtocolHandler.h"
|
||||
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "JAR Protocol Handler",
|
||||
NS_JARPROTOCOLHANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "jar",
|
||||
nsJARProtocolHandler::Create
|
||||
},
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(nsJarProtocolModule, components);
|
||||
|
||||
|
||||
396
mozilla/modules/libjar/nsJARURI.cpp
Normal file
396
mozilla/modules/libjar/nsJARURI.cpp
Normal file
@@ -0,0 +1,396 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsJARURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIZipReader.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsJARURI::nsJARURI()
|
||||
: mJAREntry(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsJARURI::~nsJARURI()
|
||||
{
|
||||
if (mJAREntry)
|
||||
nsMemory::Free(mJAREntry);
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsJARURI, nsIJARURI, nsIURI)
|
||||
|
||||
NS_METHOD
|
||||
nsJARURI::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsJARURI* uri = new nsJARURI();
|
||||
|
||||
if (uri == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(uri);
|
||||
nsresult rv = uri->Init();
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = uri->QueryInterface(aIID, aResult);
|
||||
}
|
||||
NS_RELEASE(uri);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARURI::Init()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define NS_JAR_SCHEME "jar:"
|
||||
#define NS_JAR_DELIMITER "!/"
|
||||
|
||||
nsresult
|
||||
nsJARURI::FormatSpec(const char* entryPath, char* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
char* jarFileSpec;
|
||||
rv = mJARFile->GetSpec(&jarFileSpec);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCString spec(NS_JAR_SCHEME);
|
||||
spec += jarFileSpec;
|
||||
nsCRT::free(jarFileSpec);
|
||||
spec += NS_JAR_DELIMITER;
|
||||
spec += entryPath;
|
||||
|
||||
*result = nsCRT::strdup(spec);
|
||||
return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsURI methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetSpec(char* *aSpec)
|
||||
{
|
||||
return FormatSpec(mJAREntry, aSpec);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetSpec(const char * aSpec)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRUint32 startPos, endPos;
|
||||
rv = serv->ExtractScheme(aSpec, &startPos, &endPos, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (nsCRT::strncmp("jar", &aSpec[startPos], endPos - startPos - 1) != 0)
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
|
||||
// Search backward from the end for the "!/" delimiter. Remember, jar URLs
|
||||
// can nest, e.g.:
|
||||
// jar:jar:http://www.foo.com/bar.jar!/a.jar!/b.html
|
||||
// This gets the b.html document from out of the a.jar file, that's
|
||||
// contained within the bar.jar file.
|
||||
|
||||
nsCAutoString jarPath(aSpec);
|
||||
PRInt32 pos = jarPath.RFind(NS_JAR_DELIMITER);
|
||||
if (pos == -1 || endPos + 1 > (PRUint32)pos)
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
|
||||
jarPath.Cut(pos, jarPath.Length());
|
||||
jarPath.Cut(0, endPos);
|
||||
|
||||
rv = serv->NewURI(jarPath, nsnull, getter_AddRefs(mJARFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCAutoString entry(aSpec);
|
||||
entry.Cut(0, pos + 2); // 2 == strlen(NS_JAR_DELIMITER)
|
||||
while (entry.CharAt(0) == '/')
|
||||
entry.Cut(0,1); // Strip any additional leading slashes from entry path
|
||||
|
||||
rv = serv->ResolveRelativePath(entry, nsnull, &mJAREntry);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetPrePath(char* *prePath)
|
||||
{
|
||||
*prePath = nsCRT::strdup("jar:");
|
||||
return *prePath ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetPrePath(const char* prePath)
|
||||
{
|
||||
NS_NOTREACHED("nsJARURI::SetPrePath");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetScheme(char * *aScheme)
|
||||
{
|
||||
*aScheme = nsCRT::strdup("jar");
|
||||
return *aScheme ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetScheme(const char * aScheme)
|
||||
{
|
||||
// doesn't make sense to set the scheme of a jar: URL
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetUsername(char * *aUsername)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetUsername(const char * aUsername)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetPassword(char * *aPassword)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetPassword(const char * aPassword)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetPreHost(char * *aPreHost)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetPreHost(const char * aPreHost)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetHost(char * *aHost)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetHost(const char * aHost)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetPort(PRInt32 *aPort)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetPort(PRInt32 aPort)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetPath(char * *aPath)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetPath(const char * aPath)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::Equals(nsIURI *other, PRBool *result)
|
||||
{
|
||||
nsresult rv;
|
||||
*result = PR_FALSE;
|
||||
|
||||
if (other == nsnull)
|
||||
return NS_OK; // not equal
|
||||
|
||||
nsJARURI* otherJAR;
|
||||
rv = other->QueryInterface(NS_GET_IID(nsIJARURI), (void**)&otherJAR);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK; // not equal
|
||||
|
||||
nsCOMPtr<nsIURI> otherJARFile;
|
||||
rv = otherJAR->GetJARFile(getter_AddRefs(otherJARFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRBool equal;
|
||||
rv = mJARFile->Equals(otherJARFile, &equal);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!equal)
|
||||
return NS_OK; // not equal
|
||||
|
||||
char* otherJAREntry;
|
||||
rv = otherJAR->GetJAREntry(&otherJAREntry);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = nsCRT::strcmp(mJAREntry, otherJAREntry) == 0;
|
||||
nsCRT::free(otherJAREntry);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SchemeIs(const char *i_Scheme, PRBool *o_Equals)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(o_Equals);
|
||||
if (!i_Scheme) return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (*i_Scheme == 'j' || *i_Scheme == 'J') {
|
||||
*o_Equals = PL_strcasecmp("jar", i_Scheme) ? PR_FALSE : PR_TRUE;
|
||||
} else {
|
||||
*o_Equals = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::Clone(nsIURI **result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIURI> newJARFile;
|
||||
rv = mJARFile->Clone(getter_AddRefs(newJARFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char* newJAREntry = nsCRT::strdup(mJAREntry);
|
||||
if (newJAREntry == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsJARURI* uri = new nsJARURI();
|
||||
if (uri == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(uri);
|
||||
uri->mJARFile = newJARFile;
|
||||
uri->mJAREntry = newJAREntry;
|
||||
*result = uri;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::Resolve(const char *relativePath, char **result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!relativePath) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString scheme;
|
||||
rv = serv->ExtractScheme(relativePath, nsnull, nsnull, getter_Copies(scheme));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// then aSpec is absolute
|
||||
*result = nsCRT::strdup(relativePath);
|
||||
if (*result == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCAutoString path(mJAREntry);
|
||||
PRInt32 pos = path.RFind("/");
|
||||
if (pos >= 0)
|
||||
path.Truncate(pos + 1);
|
||||
else
|
||||
path = "";
|
||||
|
||||
char* resolvedEntry;
|
||||
rv = serv->ResolveRelativePath(relativePath, path.get(),
|
||||
&resolvedEntry);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = FormatSpec(resolvedEntry, result);
|
||||
nsCRT::free(resolvedEntry);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIJARUri methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetJARFile(nsIURI* *jarFile)
|
||||
{
|
||||
*jarFile = mJARFile;
|
||||
NS_ADDREF(*jarFile);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetJARFile(nsIURI* jarFile)
|
||||
{
|
||||
mJARFile = jarFile;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::GetJAREntry(char* *entryPath)
|
||||
{
|
||||
nsCAutoString entry(mJAREntry);
|
||||
PRInt32 pos = entry.RFindCharInSet("#?;");
|
||||
if (pos >= 0)
|
||||
entry.Truncate(pos);
|
||||
*entryPath = entry.ToNewCString();
|
||||
return *entryPath ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetJAREntry(const char* entryPath)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (mJAREntry)
|
||||
nsCRT::free(mJAREntry);
|
||||
|
||||
rv = serv->ResolveRelativePath(entryPath, nsnull, &mJAREntry);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
55
mozilla/modules/libjar/nsJARURI.h
Normal file
55
mozilla/modules/libjar/nsJARURI.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsJARURI_h__
|
||||
#define nsJARURI_h__
|
||||
|
||||
#include "nsIJARURI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_JARURI_CID \
|
||||
{ /* 0xc7e410d7-0x85f2-11d3-9f63-006008a6efe9 */ \
|
||||
0xc7e410d7, \
|
||||
0x85f2, \
|
||||
0x11d3, \
|
||||
{0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \
|
||||
}
|
||||
|
||||
class nsJARURI : public nsIJARURI
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIURI
|
||||
NS_DECL_NSIJARURI
|
||||
|
||||
// nsJARURI
|
||||
nsJARURI();
|
||||
virtual ~nsJARURI();
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
nsresult Init();
|
||||
nsresult FormatSpec(const char* entryPath, char* *result);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIURI> mJARFile;
|
||||
char *mJAREntry;
|
||||
};
|
||||
|
||||
#endif // nsJARURI_h__
|
||||
221
mozilla/modules/libpr0n/src/imgCache.cpp
Normal file
221
mozilla/modules/libpr0n/src/imgCache.cpp
Normal file
@@ -0,0 +1,221 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "imgCache.h"
|
||||
|
||||
#include "ImageLogging.h"
|
||||
|
||||
#include "imgRequest.h"
|
||||
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsICache.h"
|
||||
#include "nsICacheService.h"
|
||||
#include "nsICacheSession.h"
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(imgCache, imgICache)
|
||||
|
||||
imgCache::imgCache()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
imgCache::~imgCache()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* void clearCache (in boolean chrome); */
|
||||
NS_IMETHODIMP imgCache::ClearCache(PRBool chrome)
|
||||
{
|
||||
if (chrome)
|
||||
return imgCache::ClearChromeImageCache();
|
||||
else
|
||||
return imgCache::ClearImageCache();
|
||||
}
|
||||
|
||||
static nsCOMPtr<nsICacheSession> gSession = nsnull;
|
||||
static nsCOMPtr<nsICacheSession> gChromeSession = nsnull;
|
||||
|
||||
void GetCacheSession(nsIURI *aURI, nsICacheSession **_retval)
|
||||
{
|
||||
NS_ASSERTION(aURI, "Null URI!");
|
||||
|
||||
PRBool isChrome = PR_FALSE;
|
||||
aURI->SchemeIs("chrome", &isChrome);
|
||||
|
||||
if (gSession && !isChrome) {
|
||||
*_retval = gSession;
|
||||
NS_ADDREF(*_retval);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gChromeSession && isChrome) {
|
||||
*_retval = gChromeSession;
|
||||
NS_ADDREF(*_retval);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICacheService> cacheService(do_GetService("@mozilla.org/network/cache-service;1"));
|
||||
if (!cacheService) {
|
||||
NS_WARNING("Unable to get the cache service");
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICacheSession> newSession;
|
||||
cacheService->CreateSession(isChrome ? "image-chrome" : "image",
|
||||
nsICache::NOT_STREAM_BASED,
|
||||
PR_FALSE, getter_AddRefs(newSession));
|
||||
|
||||
if (!newSession) {
|
||||
NS_WARNING("Unable to create a cache session");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isChrome)
|
||||
gChromeSession = newSession;
|
||||
else
|
||||
gSession = newSession;
|
||||
|
||||
*_retval = newSession;
|
||||
NS_ADDREF(*_retval);
|
||||
}
|
||||
|
||||
|
||||
void imgCache::Shutdown()
|
||||
{
|
||||
gSession = nsnull;
|
||||
gChromeSession = nsnull;
|
||||
}
|
||||
|
||||
|
||||
nsresult imgCache::ClearChromeImageCache()
|
||||
{
|
||||
if (!gChromeSession)
|
||||
return NS_OK;
|
||||
|
||||
return gChromeSession->EvictEntries();
|
||||
}
|
||||
|
||||
nsresult imgCache::ClearImageCache()
|
||||
{
|
||||
if (!gSession)
|
||||
return NS_OK;
|
||||
|
||||
return gSession->EvictEntries();
|
||||
}
|
||||
|
||||
PRBool imgCache::Put(nsIURI *aKey, imgRequest *request, nsICacheEntryDescriptor **aEntry)
|
||||
{
|
||||
LOG_STATIC_FUNC(gImgLog, "imgCache::Put");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICacheSession> ses;
|
||||
GetCacheSession(aKey, getter_AddRefs(ses));
|
||||
if (!ses) return PR_FALSE;
|
||||
|
||||
nsXPIDLCString spec;
|
||||
aKey->GetSpec(getter_Copies(spec));
|
||||
|
||||
nsCOMPtr<nsICacheEntryDescriptor> entry;
|
||||
|
||||
rv = ses->OpenCacheEntry(spec, nsICache::ACCESS_WRITE, nsICache::BLOCKING, getter_AddRefs(entry));
|
||||
|
||||
if (NS_FAILED(rv) || !entry)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsISupports> sup(do_QueryInterface(NS_STATIC_CAST(imgIRequest*, request)));
|
||||
entry->SetCacheElement(sup);
|
||||
|
||||
entry->MarkValid();
|
||||
|
||||
*aEntry = entry;
|
||||
NS_ADDREF(*aEntry);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool imgCache::Get(nsIURI *aKey, imgRequest **aRequest, nsICacheEntryDescriptor **aEntry)
|
||||
{
|
||||
LOG_STATIC_FUNC(gImgLog, "imgCache::Get");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICacheSession> ses;
|
||||
GetCacheSession(aKey, getter_AddRefs(ses));
|
||||
if (!ses) return PR_FALSE;
|
||||
|
||||
nsXPIDLCString spec;
|
||||
aKey->GetSpec(getter_Copies(spec));
|
||||
|
||||
nsCOMPtr<nsICacheEntryDescriptor> entry;
|
||||
|
||||
rv = ses->OpenCacheEntry(spec, nsICache::ACCESS_READ, nsICache::BLOCKING, getter_AddRefs(entry));
|
||||
|
||||
if (NS_FAILED(rv) || !entry)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
entry->GetCacheElement(getter_AddRefs(sup));
|
||||
|
||||
nsCOMPtr<imgIRequest> req(do_QueryInterface(sup));
|
||||
*aRequest = NS_REINTERPRET_CAST(imgRequest*, req.get());
|
||||
NS_IF_ADDREF(*aRequest);
|
||||
|
||||
*aEntry = entry;
|
||||
NS_ADDREF(*aEntry);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
PRBool imgCache::Remove(nsIURI *aKey)
|
||||
{
|
||||
LOG_STATIC_FUNC(gImgLog, "imgCache::Remove");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICacheSession> ses;
|
||||
GetCacheSession(aKey, getter_AddRefs(ses));
|
||||
if (!ses) return PR_FALSE;
|
||||
|
||||
nsXPIDLCString spec;
|
||||
aKey->GetSpec(getter_Copies(spec));
|
||||
|
||||
nsCOMPtr<nsICacheEntryDescriptor> entry;
|
||||
|
||||
rv = ses->OpenCacheEntry(spec, nsICache::ACCESS_READ, nsICache::BLOCKING, getter_AddRefs(entry));
|
||||
|
||||
if (NS_FAILED(rv) || !entry)
|
||||
return PR_FALSE;
|
||||
|
||||
entry->Doom();
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
388
mozilla/modules/libpr0n/src/imgLoader.cpp
Normal file
388
mozilla/modules/libpr0n/src/imgLoader.cpp
Normal file
@@ -0,0 +1,388 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "imgLoader.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "imgCache.h"
|
||||
#include "imgRequest.h"
|
||||
#include "imgRequestProxy.h"
|
||||
|
||||
#include "ImageLogging.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(imgLoader, imgILoader)
|
||||
|
||||
imgLoader::imgLoader()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
imgLoader::~imgLoader()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* imgIRequest loadImage (in nsIURI uri, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports cx); */
|
||||
NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgIDecoderObserver *aObserver, nsISupports *cx, imgIRequest **_retval)
|
||||
{
|
||||
NS_ASSERTION(aURI, "imgLoader::LoadImage -- NULL URI pointer");
|
||||
|
||||
if (!aURI)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
nsXPIDLCString spec;
|
||||
aURI->GetSpec(getter_Copies(spec));
|
||||
LOG_SCOPE_WITH_PARAM(gImgLog, "imgLoader::LoadImage", "aURI", spec.get());
|
||||
#endif
|
||||
|
||||
imgRequest *request = nsnull;
|
||||
|
||||
nsCOMPtr<nsICacheEntryDescriptor> entry;
|
||||
imgCache::Get(aURI, &request, getter_AddRefs(entry)); // addrefs request
|
||||
|
||||
if (request && entry && aLoadGroup) {
|
||||
/* this isn't exactly what I want here. This code will re-doom every
|
||||
cache hit in a document while it is force reloading. So for multiple
|
||||
copies of an image on a page, when you force reload, this will cause
|
||||
you to get seperate loads for each copy of the image... this sucks.
|
||||
*/
|
||||
PRUint32 flags = 0;
|
||||
PRBool doomRequest = PR_FALSE;
|
||||
aLoadGroup->GetLoadFlags(&flags);
|
||||
if (flags & nsIRequest::LOAD_BYPASS_CACHE)
|
||||
doomRequest = PR_TRUE;
|
||||
else {
|
||||
nsCOMPtr<nsIRequest> r;
|
||||
aLoadGroup->GetDefaultLoadRequest(getter_AddRefs(r));
|
||||
if (r) {
|
||||
r->GetLoadFlags(&flags);
|
||||
if (flags & nsIRequest::LOAD_BYPASS_CACHE)
|
||||
doomRequest = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (doomRequest) {
|
||||
entry->Doom(); // doom this thing.
|
||||
entry = nsnull;
|
||||
NS_RELEASE(request);
|
||||
request = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
if (!request) {
|
||||
/* no request from the cache. do a new load */
|
||||
LOG_SCOPE(gImgLog, "imgLoader::LoadImage |cache miss|");
|
||||
|
||||
nsCOMPtr<nsIIOService> ioserv(do_GetService("@mozilla.org/network/io-service;1"));
|
||||
if (!ioserv) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIChannel> newChannel;
|
||||
ioserv->NewChannelFromURI(aURI, getter_AddRefs(newChannel));
|
||||
if (!newChannel) return NS_ERROR_FAILURE;
|
||||
|
||||
if (aLoadGroup) {
|
||||
PRUint32 flags;
|
||||
aLoadGroup->GetLoadFlags(&flags);
|
||||
newChannel->SetLoadFlags(flags);
|
||||
}
|
||||
|
||||
NS_NEWXPCOM(request, imgRequest);
|
||||
if (!request) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(request);
|
||||
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG,
|
||||
("[this=%p] imgLoader::LoadImage -- Created new imgRequest [request=%p]\n", this, request));
|
||||
|
||||
#ifdef MOZ_NEW_CACHE
|
||||
imgCache::Put(aURI, request, getter_AddRefs(entry));
|
||||
|
||||
request->Init(newChannel, entry);
|
||||
#else
|
||||
request->Init(newChannel, nsnull);
|
||||
#endif
|
||||
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG,
|
||||
("[this=%p] imgLoader::LoadImage -- Calling channel->AsyncOpen()\n", this));
|
||||
|
||||
// create the proxy listener
|
||||
ProxyListener *pl = new ProxyListener(NS_STATIC_CAST(nsIStreamListener *, request));
|
||||
if (!pl) {
|
||||
NS_RELEASE(request);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(pl);
|
||||
|
||||
// set the referrer if this is an HTTP request
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(newChannel));
|
||||
if (aLoadGroup && httpChannel) {
|
||||
nsresult rv;
|
||||
// Get the defloadRequest from the loadgroup
|
||||
nsCOMPtr<nsIRequest> defLoadRequest;
|
||||
rv = aLoadGroup->GetDefaultLoadRequest(getter_AddRefs(defLoadRequest));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && defLoadRequest) {
|
||||
nsCOMPtr<nsIChannel> reqChannel(do_QueryInterface(defLoadRequest));
|
||||
|
||||
if (reqChannel) {
|
||||
// Get the referrer from the loadchannel
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
rv = reqChannel->GetURI(getter_AddRefs(referrer));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Set the referrer
|
||||
httpChannel->SetReferrer(referrer, nsIHttpChannel::REFERRER_INLINES);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX Are we calling AsyncOpen() too early? Is it possible for
|
||||
AsyncOpen to result in an OnStartRequest to the channel before
|
||||
we call CreateNewProxyForRequest() ?
|
||||
*/
|
||||
nsresult asyncOpenResult = newChannel->AsyncOpen(NS_STATIC_CAST(nsIStreamListener *, pl), nsnull);
|
||||
|
||||
NS_RELEASE(pl);
|
||||
|
||||
if (NS_FAILED(asyncOpenResult)) {
|
||||
/* If AsyncOpen fails, then we want to hand back a request proxy
|
||||
object that has a canceled load.
|
||||
*/
|
||||
LOG_MSG(gImgLog, "imgLoader::LoadImage", "async open failed.");
|
||||
|
||||
nsresult rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver,
|
||||
cx, _retval);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
request->OnStartRequest(newChannel, nsnull);
|
||||
request->OnStopRequest(newChannel, nsnull, NS_BINDING_ABORTED);
|
||||
}
|
||||
|
||||
NS_RELEASE(request);
|
||||
|
||||
return asyncOpenResult;
|
||||
}
|
||||
|
||||
} else {
|
||||
/* request found in cache. use it */
|
||||
LOG_MSG_WITH_PARAM(gImgLog, "imgLoader::LoadImage |cache hit|", "request", request);
|
||||
}
|
||||
|
||||
LOG_MSG(gImgLog, "imgLoader::LoadImage", "creating proxy request.");
|
||||
|
||||
nsresult rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver, cx, _retval);
|
||||
|
||||
NS_RELEASE(request);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* imgIRequest loadImageWithChannel(in nsIChannel, in imgIDecoderObserver aObserver, in nsISupports cx, out nsIStreamListener); */
|
||||
NS_IMETHODIMP imgLoader::LoadImageWithChannel(nsIChannel *channel, imgIDecoderObserver *aObserver, nsISupports *cx, nsIStreamListener **listener, imgIRequest **_retval)
|
||||
{
|
||||
NS_ASSERTION(channel, "imgLoader::LoadImageWithChannel -- NULL channel pointer");
|
||||
|
||||
imgRequest *request = nsnull;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetOriginalURI(getter_AddRefs(uri));
|
||||
|
||||
nsCOMPtr<nsICacheEntryDescriptor> entry;
|
||||
imgCache::Get(uri, &request, getter_AddRefs(entry)); // addrefs request
|
||||
|
||||
if (request) {
|
||||
// we have this in our cache already.. cancel the current (document) load
|
||||
|
||||
/* XXX If |*listener| is null when we return here, the caller should
|
||||
probably cancel the channel instead of us doing it here.
|
||||
*/
|
||||
channel->Cancel(NS_BINDING_ABORTED); // this should fire an OnStopRequest
|
||||
|
||||
*listener = nsnull; // give them back a null nsIStreamListener
|
||||
} else {
|
||||
NS_NEWXPCOM(request, imgRequest);
|
||||
if (!request) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(request);
|
||||
|
||||
imgCache::Put(uri, request, getter_AddRefs(entry));
|
||||
|
||||
request->Init(channel, entry);
|
||||
|
||||
ProxyListener *pl = new ProxyListener(NS_STATIC_CAST(nsIStreamListener *, request));
|
||||
if (!pl) {
|
||||
NS_RELEASE(request);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(pl);
|
||||
|
||||
*listener = NS_STATIC_CAST(nsIStreamListener*, pl);
|
||||
NS_ADDREF(*listener);
|
||||
|
||||
NS_RELEASE(pl);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
channel->GetLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
nsresult rv = CreateNewProxyForRequest(request, loadGroup, aObserver, cx, _retval);
|
||||
|
||||
NS_RELEASE(request);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
imgLoader::CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup *aLoadGroup,
|
||||
imgIDecoderObserver *aObserver, nsISupports *cx,
|
||||
imgIRequest **_retval)
|
||||
{
|
||||
LOG_SCOPE_WITH_PARAM(gImgLog, "imgLoader::CreateNewProxyForRequest", "imgRequest", aRequest);
|
||||
|
||||
/* XXX If we move decoding onto seperate threads, we should save off the
|
||||
calling thread here and pass it off to |proxyRequest| so that it call
|
||||
proxy calls to |aObserver|.
|
||||
*/
|
||||
|
||||
imgRequestProxy *proxyRequest;
|
||||
NS_NEWXPCOM(proxyRequest, imgRequestProxy);
|
||||
if (!proxyRequest) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(proxyRequest);
|
||||
|
||||
// init adds itself to imgRequest's list of observers
|
||||
nsresult rv = proxyRequest->Init(aRequest, aLoadGroup, aObserver, cx);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(proxyRequest);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*_retval = NS_STATIC_CAST(imgIRequest*, proxyRequest);
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
NS_RELEASE(proxyRequest);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* proxy stream listener class used to handle multipart/x-mixed-replace
|
||||
*/
|
||||
|
||||
#include "nsIRequest.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(ProxyListener, nsIStreamListener, nsIRequestObserver)
|
||||
|
||||
ProxyListener::ProxyListener(nsIStreamListener *dest) :
|
||||
mDestListener(dest)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
ProxyListener::~ProxyListener()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
|
||||
/** nsIRequestObserver methods **/
|
||||
|
||||
/* void onStartRequest (in nsIRequest request, in nsISupports ctxt); */
|
||||
NS_IMETHODIMP ProxyListener::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt)
|
||||
{
|
||||
if (!mDestListener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
|
||||
if (channel) {
|
||||
nsXPIDLCString contentType;
|
||||
nsresult rv = channel->GetContentType(getter_Copies(contentType));
|
||||
|
||||
if (contentType.get()) {
|
||||
/* If multipart/x-mixed-replace content, we'll insert a MIME decoder
|
||||
in the pipeline to handle the content and pass it along to our
|
||||
original listener.
|
||||
*/
|
||||
if (NS_LITERAL_CSTRING("multipart/x-mixed-replace").Equals(contentType)) {
|
||||
|
||||
nsCOMPtr<nsIStreamConverterService> convServ(do_GetService("@mozilla.org/streamConverters;1", &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIStreamListener> toListener(mDestListener);
|
||||
nsCOMPtr<nsIStreamListener> fromListener;
|
||||
|
||||
rv = convServ->AsyncConvertData(NS_LITERAL_STRING("multipart/x-mixed-replace").get(),
|
||||
NS_LITERAL_STRING("*/*").get(),
|
||||
toListener,
|
||||
nsnull,
|
||||
getter_AddRefs(fromListener));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mDestListener = fromListener;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mDestListener->OnStartRequest(aRequest, ctxt);
|
||||
}
|
||||
|
||||
/* void onStopRequest (in nsIRequest request, in nsISupports ctxt, in nsresult status); */
|
||||
NS_IMETHODIMP ProxyListener::OnStopRequest(nsIRequest *aRequest, nsISupports *ctxt, nsresult status)
|
||||
{
|
||||
if (!mDestListener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return mDestListener->OnStopRequest(aRequest, ctxt, status);
|
||||
}
|
||||
|
||||
/** nsIStreamListener methods **/
|
||||
|
||||
/* void onDataAvailable (in nsIRequest request, in nsISupports ctxt, in nsIInputStream inStr, in unsigned long sourceOffset, in unsigned long count); */
|
||||
NS_IMETHODIMP ProxyListener::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
|
||||
{
|
||||
if (!mDestListener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return mDestListener->OnDataAvailable(aRequest, ctxt, inStr, sourceOffset, count);
|
||||
}
|
||||
491
mozilla/modules/libpref/src/init/all.js
Normal file
491
mozilla/modules/libpref/src/init/all.js
Normal file
@@ -0,0 +1,491 @@
|
||||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// SYNTAX HINTS: dashes are delimiters. Use underscores instead.
|
||||
// The first character after a period must be alphabetic.
|
||||
|
||||
pref("network.search.url","http://cgi.netscape.com/cgi-bin/url_search.cgi?search=");
|
||||
|
||||
pref("keyword.URL", "http://keyword.netscape.com/keyword/");
|
||||
pref("keyword.enabled", true);
|
||||
pref("general.useragent.locale", "chrome://navigator/locale/navigator.properties");
|
||||
pref("general.useragent.misc", "rv:0.9+");
|
||||
|
||||
pref("general.startup.browser", true);
|
||||
pref("general.startup.mail", false);
|
||||
pref("general.startup.news", false);
|
||||
pref("general.startup.editor", false);
|
||||
pref("general.startup.compose", false);
|
||||
pref("general.startup.addressbook", false);
|
||||
|
||||
pref("general.open_location.last_url", "");
|
||||
pref("general.open_location.last_window_choice", 0);
|
||||
|
||||
// 0 = blank, 1 = home (browser.startup.homepage), 2 = last
|
||||
pref("browser.startup.page", 1);
|
||||
pref("browser.startup.homepage", "chrome://navigator-region/locale/region.properties");
|
||||
// "browser.startup.homepage_override" was for 4.x
|
||||
pref("browser.startup.homepage_override.1", true);
|
||||
pref("browser.startup.autoload_homepage", true);
|
||||
|
||||
pref("browser.cache.disk_cache_size", 50000);
|
||||
pref("browser.cache.enable", true);
|
||||
pref("browser.cache.disk.enable", true);
|
||||
pref("browser.cache.memory_cache_size", 4096);
|
||||
pref("browser.cache.disk_cache_ssl", false);
|
||||
pref("browser.cache.check_doc_frequency", 0);
|
||||
|
||||
pref("browser.display.use_document_fonts", 1); // 0 = never, 1 = quick, 2 = always
|
||||
pref("browser.display.use_document_colors", true);
|
||||
pref("browser.display.use_system_colors",true);
|
||||
pref("browser.display.foreground_color", "#000000");
|
||||
pref("browser.display.background_color", "#C0C0C0");
|
||||
pref("browser.anchor_color", "#0000EE");
|
||||
pref("browser.visited_color", "#551A8B");
|
||||
pref("browser.underline_anchors", true);
|
||||
|
||||
pref("browser.display.use_focus_colors", false);
|
||||
pref("browser.display.focus_background_color", "#117722");
|
||||
pref("browser.display.focus_text_color", "#ffffff");
|
||||
pref("browser.display.focus_ring_width", 1);
|
||||
pref("browser.display.focus_ring_on_anything", false);
|
||||
|
||||
pref("browser.chrome.toolbar_tips", true);
|
||||
pref("browser.chrome.toolbar_style", 2);
|
||||
|
||||
pref("browser.toolbars.showbutton.bookmarks", true);
|
||||
pref("browser.toolbars.showbutton.go", false);
|
||||
pref("browser.toolbars.showbutton.home", true);
|
||||
pref("browser.toolbars.showbutton.mynetscape", true);
|
||||
pref("browser.toolbars.showbutton.net2phone", true);
|
||||
pref("browser.toolbars.showbutton.print", true);
|
||||
pref("browser.toolbars.showbutton.search", true);
|
||||
|
||||
pref("accessibility.browsewithcaret", false);
|
||||
pref("accessibility.usetexttospeech", "");
|
||||
pref("accessibility.usebrailledisplay", "");
|
||||
|
||||
// Dialog modality issues
|
||||
pref("browser.prefWindowModal", true);
|
||||
pref("browser.show_about_as_stupid_modal_window", false);
|
||||
|
||||
pref("browser.download.progressDnldDialog.keepAlive", false); // keep the dnload progress dialog up after dnload is complete
|
||||
|
||||
// various default search settings
|
||||
pref("browser.search.defaulturl", "chrome://navigator-region/locale/region.properties");
|
||||
pref("browser.search.opensidebarsearchpanel", true);
|
||||
pref("browser.search.last_search_category", "NC:SearchCategory?category=urn:search:category:1");
|
||||
pref("browser.search.mode", 0);
|
||||
pref("browser.search.powermode", 0);
|
||||
pref("browser.urlbar.autocomplete.enabled", true);
|
||||
pref("browser.urlbar.clickSelectsAll",false);
|
||||
|
||||
pref("browser.history.last_page_visited", "");
|
||||
pref("browser.history_expire_days", 9);
|
||||
pref("browser.sessionhistory.max_entries", 50);
|
||||
|
||||
pref("browser.PICS.ratings_enabled", false);
|
||||
pref("browser.PICS.pages_must_be_rated", false);
|
||||
pref("browser.PICS.disable_for_this_session", false);
|
||||
pref("browser.PICS.reenable_for_this_session", false);
|
||||
pref("browser.PICS.service.http___home_netscape_com_default_rating.service_enabled", true);
|
||||
pref("browser.PICS.service.http___home_netscape_com_default_rating.s", 0);
|
||||
|
||||
pref("browser.target_new_blocked", false);
|
||||
|
||||
// loading and rendering of framesets and iframes
|
||||
pref("browser.frames.enabled", true);
|
||||
|
||||
// view source
|
||||
pref("view_source.syntax_highlight", true);
|
||||
|
||||
// gfx widgets
|
||||
pref("nglayout.widget.mode", 2);
|
||||
pref("nglayout.widget.gfxscrollbars", true);
|
||||
|
||||
// use nsViewManager2
|
||||
pref("nglayout.view.useViewManager2", true);
|
||||
|
||||
// css2 hover pref
|
||||
pref("nglayout.events.showHierarchicalHover", false);
|
||||
|
||||
// whether or not to use xbl form controls
|
||||
pref("nglayout.debug.enable_xbl_forms", false);
|
||||
|
||||
// Smart Browsing prefs
|
||||
pref("browser.related.enabled", true);
|
||||
pref("browser.related.autoload", 1); // 0 = Always, 1 = After first use, 2 = Never
|
||||
pref("browser.related.provider", "http://www-rl.netscape.com/wtgn?");
|
||||
pref("browser.related.disabledForDomains", "");
|
||||
pref("browser.goBrowsing.enabled", true);
|
||||
|
||||
//Internet Search
|
||||
pref("browser.search.defaultenginename", "chrome://navigator/locale/navigator.properties");
|
||||
|
||||
// Default Capability Preferences: Security-Critical!
|
||||
// Editing these may create a security risk - be sure you know what you're doing
|
||||
//pref("capability.policy.default.barprop.visible.set", "UniversalBrowserWrite");
|
||||
|
||||
pref("capability.policy.default.Domexception.code", "allAccess");
|
||||
pref("capability.policy.default.Domexception.message", "allAccess");
|
||||
pref("capability.policy.default.Domexception.name", "allAccess");
|
||||
pref("capability.policy.default.Domexception.result", "allAccess");
|
||||
pref("capability.policy.default.Domexception.tostring", "allAccess");
|
||||
|
||||
pref("capability.policy.default.History.back", "allAccess");
|
||||
pref("capability.policy.default.History.current", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.forward", "allAccess");
|
||||
pref("capability.policy.default.History.go", "allAccess");
|
||||
//pref("capability.policy.default.History.item", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.length", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.next", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.previous", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.toString", "UniversalBrowserRead");
|
||||
|
||||
pref("capability.policy.default.HTMLDocument.close", "allAccess");
|
||||
pref("capability.policy.default.HTMLDocument.open", "allAccess");
|
||||
pref("capability.policy.default.HTMLDocument.write", "allAccess");
|
||||
pref("capability.policy.default.HTMLDocument.writeln", "allAccess");
|
||||
|
||||
pref("capability.policy.default.Location.hash.set", "allAccess");
|
||||
pref("capability.policy.default.Location.host.set", "allAccess");
|
||||
pref("capability.policy.default.Location.hostname.set", "allAccess");
|
||||
pref("capability.policy.default.Location.href.set", "allAccess");
|
||||
pref("capability.policy.default.Location.pathname.set", "allAccess");
|
||||
pref("capability.policy.default.Location.port.set", "allAccess");
|
||||
pref("capability.policy.default.Location.protocol.set", "allAccess");
|
||||
pref("capability.policy.default.Location.reload", "allAccess");
|
||||
pref("capability.policy.default.Location.replace", "allAccess");
|
||||
pref("capability.policy.default.Location.search.set", "allAccess");
|
||||
|
||||
pref("capability.policy.default.Navigator.preference", "allAccess");
|
||||
pref("capability.policy.default.Navigator.preferenceinternal.get", "UniversalPreferencesRead");
|
||||
pref("capability.policy.default.Navigator.preferenceinternal.set", "UniversalPreferencesWrite");
|
||||
|
||||
pref("capability.policy.default.Window.blur", "allAccess");
|
||||
pref("capability.policy.default.Window.close", "allAccess");
|
||||
pref("capability.policy.default.Window.closed", "allAccess");
|
||||
pref("capability.policy.default.Window.Components", "allAccess");
|
||||
pref("capability.policy.default.Window.document", "allAccess");
|
||||
pref("capability.policy.default.Window.focus", "allAccess");
|
||||
pref("capability.policy.default.Window.history", "allAccess");
|
||||
pref("capability.policy.default.Window.location", "allAccess");
|
||||
// window.openDialog is insecure and must be made inaccessible from web scripts - see bug 56009
|
||||
pref("capability.policy.default.Window.opendialog", "noAccess");
|
||||
pref("capability.policy.default.Window.self", "allAccess");
|
||||
pref("capability.policy.default.Window.window", "allAccess");
|
||||
|
||||
pref("capability.policy.mailnews.Domexception.tostring", "noAccess");
|
||||
pref("capability.policy.mailnews.HTMLDocument.domain", "noAccess");
|
||||
pref("capability.policy.mailnews.HTMLDocument.URL", "noAccess");
|
||||
//pref("capability.policy.mailnews.nsdocument.location", "noAccess");
|
||||
pref("capability.policy.mailnews.sites", "mailbox: imap: news:");
|
||||
pref("capability.policy.mailnews.Window.name.set", "noAccess");
|
||||
pref("capability.policy.mailnews.Window.location", "noAccess");
|
||||
|
||||
pref("javascript.enabled", true);
|
||||
pref("javascript.allow.mailnews", false);
|
||||
pref("javascript.options.strict", false);
|
||||
|
||||
// advanced prefs
|
||||
pref("advanced.always_load_images", true);
|
||||
pref("security.enable_java", true);
|
||||
pref("css.allow", true);
|
||||
pref("advanced.mailftp", false);
|
||||
pref("image.animation_mode", "normal");
|
||||
|
||||
pref("offline.startup_state", 0);
|
||||
pref("offline.send.unsent_messages", 0);
|
||||
pref("offline.download.download_messages", 0);
|
||||
pref("offline.prompt_synch_on_exit", true);
|
||||
pref("offline.news.download.use_days", 0);
|
||||
|
||||
pref("network.hosts.smtp_server", "mail");
|
||||
pref("network.hosts.pop_server", "mail");
|
||||
pref("network.protocols.useSystemDefaults", false); // set to true if user links should use system default handlers
|
||||
|
||||
// <ruslan>
|
||||
pref("network.http.version", "1.1"); // default
|
||||
// pref("network.http.version", "1.0"); // uncomment this out in case of problems
|
||||
// pref("network.http.version", "0.9"); // it'll work too if you're crazy
|
||||
// keep-alive option is effectively obsolete. Nevertheless it'll work with
|
||||
// some older 1.0 servers:
|
||||
|
||||
pref("network.http.keep-alive", true); // set it to false in case of problems
|
||||
pref("network.http.proxy.keep-alive", true );
|
||||
pref("network.http.keep-alive.timeout", 300);
|
||||
|
||||
pref("network.http.max-connections", 16);
|
||||
pref("network.http.max-connections-per-server", 8);
|
||||
pref("network.http.keep-alive.max-connections", 20); // max connections to be kept alive
|
||||
pref("network.http.keep-alive.max-connections-per-server", 8);
|
||||
|
||||
pref("network.http.connect.timeout", 30); // in seconds
|
||||
pref("network.http.request.timeout", 120); // in seconds
|
||||
|
||||
// Enable http compression: comment this out in case of problems with 1.1
|
||||
pref("network.http.accept-encoding" ,"gzip,deflate,compress,identity");
|
||||
|
||||
pref("network.http.pipelining" , false);
|
||||
pref("network.http.proxy.pipelining", false);
|
||||
|
||||
// Always pipeling the very first request: this will only work when you are
|
||||
// absolutely sure the the site or proxy you are browsing to/through support
|
||||
// pipelining; the default behavior will be that the browser will first make
|
||||
// a normal, non-pipelined request, then examine and remember the responce
|
||||
// and only the subsequent requests to that site will be pipeline
|
||||
pref("network.http.pipelining.firstrequest", false);
|
||||
|
||||
// Max number of requests in the pipeline
|
||||
pref("network.http.pipelining.maxrequests" , 4);
|
||||
|
||||
pref("network.http.proxy.ssl.connect",true);
|
||||
// </ruslan>
|
||||
|
||||
// until the directory view has an owner
|
||||
// necko will produce html -- dougt
|
||||
pref("network.dir.generate_html", true);
|
||||
|
||||
// sspitzer: change this back to "news" when we get to beta.
|
||||
// for now, set this to news.mozilla.org because you can only
|
||||
// post to the server specified by this pref.
|
||||
pref("network.hosts.nntp_server", "news.mozilla.org");
|
||||
|
||||
pref("network.hosts.socks_server", "");
|
||||
pref("network.hosts.socks_serverport", 1080);
|
||||
pref("network.hosts.socks_conf", "");
|
||||
pref("network.image.imageBehavior", 0); // 0-Accept, 1-dontAcceptForeign, 2-dontUse
|
||||
pref("network.image.warnAboutImages", false);
|
||||
pref("network.proxy.autoconfig_url", "");
|
||||
pref("network.proxy.type", 0);
|
||||
pref("network.proxy.ftp", "");
|
||||
pref("network.proxy.ftp_port", 0);
|
||||
pref("network.proxy.gopher", "");
|
||||
pref("network.proxy.gopher_port", 0);
|
||||
pref("network.proxy.news", "");
|
||||
pref("network.proxy.news_port", 0);
|
||||
pref("network.proxy.http", "");
|
||||
pref("network.proxy.http_port", 0);
|
||||
pref("network.proxy.wais", "");
|
||||
pref("network.proxy.wais_port", 0);
|
||||
pref("network.proxy.ssl", "");
|
||||
pref("network.proxy.ssl_port", 0);
|
||||
pref("network.proxy.socks", "");
|
||||
pref("network.proxy.socks_port", 0);
|
||||
pref("network.proxy.no_proxies_on", "");
|
||||
pref("network.online", true); //online/offline
|
||||
pref("network.accept_cookies", 0); // 0 = Always, 1 = warn, 2 = never
|
||||
pref("network.foreign_cookies", 0); // 0 = Accept, 1 = Don't accept
|
||||
pref("network.cookie.cookieBehavior", 0); // 0-Accept, 1-dontAcceptForeign, 2-dontUse
|
||||
pref("network.cookie.warnAboutCookies", false);
|
||||
pref("signon.rememberSignons", true);
|
||||
pref("network.sendRefererHeader", 2); // 0=don't send any, 1=send only on clicks, 2=send on image requests as well
|
||||
pref("network.enablePad", false); // Allow client to do proxy autodiscovery
|
||||
pref("converter.html2txt.structs", true); // Output structured phrases (strong, em, code, sub, sup, b, i, u)
|
||||
pref("converter.html2txt.header_strategy", 1); // 0 = no indention; 1 = indention, increased with header level; 2 = numbering and slight indention
|
||||
pref("wallet.captureForms", true);
|
||||
pref("wallet.notified", false);
|
||||
pref("wallet.TutorialFromMenu", "chrome://navigator/locale/navigator.properties");
|
||||
pref("wallet.Server", "chrome://navigator/locale/navigator.properties");
|
||||
pref("wallet.Samples", "chrome://navigator/locale/navigator.properties");
|
||||
pref("wallet.version", "1");
|
||||
pref("wallet.enabled", true);
|
||||
pref("wallet.crypto", false);
|
||||
pref("imageblocker.enabled", true);
|
||||
pref("intl.accept_languages", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.accept_charsets", "iso-8859-1,*,utf-8");
|
||||
pref("intl.collationOption", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.menuitems.alwaysappendacceskeys","chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.static", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.more1", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.more2", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.more3", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.more4", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.more5", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.mailedit", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charsetmenu.browser.cache", "");
|
||||
pref("intl.charsetmenu.mailview.cache", "");
|
||||
pref("intl.charsetmenu.composer.cache", "");
|
||||
pref("intl.charsetmenu.browser.cache.size", 5);
|
||||
pref("intl.charset.detector", "chrome://navigator/locale/navigator.properties");
|
||||
pref("intl.charset.default", "chrome://navigator/locale/navigator.properties");
|
||||
|
||||
pref("font.default", "serif");
|
||||
pref("font.size.variable.ar", 16);
|
||||
pref("font.size.fixed.ar", 13);
|
||||
|
||||
pref("font.size.variable.el", 16);
|
||||
pref("font.size.fixed.el", 13);
|
||||
|
||||
pref("font.size.variable.he", 16);
|
||||
pref("font.size.fixed.he", 13);
|
||||
|
||||
pref("font.size.variable.ja", 16);
|
||||
pref("font.size.fixed.ja", 16);
|
||||
|
||||
pref("font.size.variable.ko", 16);
|
||||
pref("font.size.fixed.ko", 16);
|
||||
|
||||
pref("font.size.variable.th", 16);
|
||||
pref("font.size.fixed.th", 13);
|
||||
|
||||
pref("font.size.variable.tr", 16);
|
||||
pref("font.size.fixed.tr", 13);
|
||||
|
||||
pref("font.size.variable.x-baltic", 16);
|
||||
pref("font.size.fixed.x-baltic", 13);
|
||||
|
||||
pref("font.size.variable.x-central-euro", 16);
|
||||
pref("font.size.fixed.x-central-euro", 13);
|
||||
|
||||
pref("font.size.variable.x-cyrillic", 16);
|
||||
pref("font.size.fixed.x-cyrillic", 13);
|
||||
|
||||
pref("font.size.variable.x-unicode", 16);
|
||||
pref("font.size.fixed.x-unicode", 13);
|
||||
|
||||
pref("font.size.variable.x-western", 16);
|
||||
pref("font.size.fixed.x-western", 13);
|
||||
|
||||
pref("font.size.variable.zh-CN", 16);
|
||||
pref("font.size.fixed.zh-CN", 16);
|
||||
|
||||
pref("font.size.variable.zh-TW", 16);
|
||||
pref("font.size.fixed.zh-TW", 16);
|
||||
|
||||
// -- folders (Mac: these are binary aliases.)
|
||||
localDefPref("mail.signature_file", "");
|
||||
localDefPref("mail.directory", "");
|
||||
|
||||
pref("images.dither", "auto");
|
||||
localDefPref("news.directory", "");
|
||||
localDefPref("security.directory", "");
|
||||
|
||||
pref("autoupdate.enabled", true);
|
||||
|
||||
pref("silentdownload.enabled", true);
|
||||
pref("silentdownload.directory", "");
|
||||
pref("silentdownload.range", 3000);
|
||||
pref("silentdownload.interval", 10000);
|
||||
|
||||
pref("browser.editor.disabled", false);
|
||||
|
||||
pref("spellchecker.dictionary", "");
|
||||
|
||||
pref("signed.applets.codebase_principal_support", false);
|
||||
pref("security.checkloaduri", true);
|
||||
pref("security.xpconnect.plugin.unrestricted", true);
|
||||
|
||||
// Modifier key prefs: default to Windows settings,
|
||||
// menu access key = alt, accelerator key = control.
|
||||
pref("ui.key.accelKey", 17);
|
||||
pref("ui.key.menuAccessKey", 18);
|
||||
pref("ui.key.menuAccessKeyFocuses", false);
|
||||
pref("ui.key.saveLink.shift", true); // true = shift, false = meta
|
||||
|
||||
// Middle-mouse handling
|
||||
pref("middlemouse.paste", false);
|
||||
pref("middlemouse.openNewWindow", true);
|
||||
pref("middlemouse.contentLoadURL", false);
|
||||
pref("middlemouse.scrollbarPosition", false);
|
||||
|
||||
// Clipboard behavior
|
||||
pref("clipboard.autocopy", false);
|
||||
|
||||
// 0=lines, 1=pages, 2=history , 3=text size
|
||||
pref("mousewheel.withnokey.action",0);
|
||||
pref("mousewheel.withnokey.numlines",1);
|
||||
pref("mousewheel.withnokey.sysnumlines",true);
|
||||
pref("mousewheel.withcontrolkey.action",0);
|
||||
pref("mousewheel.withcontrolkey.numlines",1);
|
||||
pref("mousewheel.withcontrolkey.sysnumlines",true);
|
||||
pref("mousewheel.withshiftkey.action",0);
|
||||
pref("mousewheel.withshiftkey.numlines",1);
|
||||
pref("mousewheel.withshiftkey.sysnumlines",false);
|
||||
pref("mousewheel.withaltkey.action",2);
|
||||
pref("mousewheel.withaltkey.numlines",1);
|
||||
pref("mousewheel.withaltkey.sysnumlines",false);
|
||||
|
||||
pref("profile.confirm_automigration",true);
|
||||
|
||||
// Customizable toolbar stuff
|
||||
pref("custtoolbar.personal_toolbar_folder", "");
|
||||
|
||||
pref("sidebar.customize.all_panels.url", "http://sidebar-rdf.netscape.com/%LOCALE%/sidebar-rdf/%SIDEBAR_VERSION%/all-panels.rdf");
|
||||
pref("sidebar.customize.more_panels.url", "http://dmoz.org/Netscape/Sidebar/");
|
||||
|
||||
pref("prefs.converted-to-utf8",false);
|
||||
// --------------------------------------------------
|
||||
// IBMBIDI
|
||||
// --------------------------------------------------
|
||||
//
|
||||
// ------------------
|
||||
// Text Direction
|
||||
// ------------------
|
||||
// 1 = directionLTRBidi *
|
||||
// 2 = directionRTLBidi
|
||||
pref("bidi.direction", 1);
|
||||
// ------------------
|
||||
// Text Type
|
||||
// ------------------
|
||||
// 1 = charsettexttypeBidi *
|
||||
// 2 = logicaltexttypeBidi
|
||||
// 3 = visualtexttypeBidi
|
||||
pref("bidi.texttype", 1);
|
||||
// ------------------
|
||||
// Controls Text Mode
|
||||
// ------------------
|
||||
// 1 = logicalcontrolstextmodeBidiCmd
|
||||
// 2 = visiualcontrolstextmodeBidi
|
||||
// 3 = containercontrolstextmodeBidi *
|
||||
pref("bidi.controlstextmode", 1);
|
||||
// ------------------
|
||||
// Clipboard Text Mode
|
||||
// ------------------
|
||||
// 1 = logicalclipboardtextmodeBidi
|
||||
// 2 = visiualclipboardtextmodeBidi
|
||||
// 3 = sourceclipboardtextmodeBidi *
|
||||
pref("bidi.clipboardtextmode", 3);
|
||||
// ------------------
|
||||
// Numeral Style
|
||||
// ------------------
|
||||
// 1 = regularcontextnumeralBidi *
|
||||
// 2 = hindicontextnumeralBidi
|
||||
// 3 = arabicnumeralBidi
|
||||
// 4 = hindinumeralBidi
|
||||
pref("bidi.numeral", 1);
|
||||
// ------------------
|
||||
// Support Mode
|
||||
// ------------------
|
||||
// 1 = mozillaBidisupport *
|
||||
// 2 = OsBidisupport
|
||||
// 3 = disableBidisupport
|
||||
pref("bidi.support", 1);
|
||||
// ------------------
|
||||
// Charset Mode
|
||||
// ------------------
|
||||
// 1 = doccharactersetBidi *
|
||||
// 2 = defaultcharactersetBidi
|
||||
pref("bidi.characterset", 1);
|
||||
|
||||
|
||||
pref("browser.throbber.url","chrome://navigator-region/locale/region.properties");
|
||||
493
mozilla/modules/libpref/src/nsAutoConfig.cpp
Normal file
493
mozilla/modules/libpref/src/nsAutoConfig.cpp
Normal file
@@ -0,0 +1,493 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mitesh Shah <mitesh@netscape.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsAutoConfig.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "prmem.h"
|
||||
#include "jsapi.h"
|
||||
#include "prefapi.h"
|
||||
#include "nsIProfile.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsLiteralString.h"
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsAutoConfig, nsIAutoConfig, nsITimerCallback, nsIStreamListener,nsIObserver)
|
||||
|
||||
nsAutoConfig::nsAutoConfig()
|
||||
{
|
||||
/* member initializers and constructor code */
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsresult nsAutoConfig::Init()
|
||||
{
|
||||
/* member initializers and constructor code */
|
||||
|
||||
nsresult rv=NS_OK;
|
||||
|
||||
mLoaded = PR_FALSE;
|
||||
|
||||
// Registering the object as an observer to the profile-after-change topic
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (observerService) {
|
||||
rv = observerService->AddObserver(this,
|
||||
NS_LITERAL_STRING("profile-after-change").get());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
nsCOMPtr<nsIPrefService> prefs =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = prefs->GetBranch(nsnull,getter_AddRefs(mPrefBranch));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoConfig::~nsAutoConfig()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
||||
if (observerService)
|
||||
rv = observerService->RemoveObserver(this,
|
||||
NS_LITERAL_STRING("profile-after-change").get());
|
||||
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoConfig::OnStartRequest(nsIRequest* request, nsISupports* context)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoConfig::OnDataAvailable(nsIRequest* request,
|
||||
nsISupports* context,
|
||||
nsIInputStream *aIStream,
|
||||
PRUint32 aSourceOffset,
|
||||
PRUint32 aLength)
|
||||
{
|
||||
PRUint32 amt, size;
|
||||
nsresult rv;
|
||||
char buf[1025];
|
||||
|
||||
while (aLength) {
|
||||
size = PR_MIN(aLength, sizeof(buf));
|
||||
rv = aIStream->Read(buf, size, &amt);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION((NS_BASE_STREAM_WOULD_BLOCK != rv),
|
||||
"The stream should never block.");
|
||||
return rv;
|
||||
}
|
||||
mBuf.Append(buf,amt);
|
||||
aLength -= amt;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoConfig::OnStopRequest(nsIRequest* request, nsISupports* context,
|
||||
nsresult aStatus)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// If the request is failed, go read the failover.jsc file
|
||||
if (NS_FAILED(aStatus)) {
|
||||
return readOfflineFile();
|
||||
}
|
||||
|
||||
//Checking for the http response, if failure go read the failover file.
|
||||
nsCOMPtr<nsIHttpChannel> pHTTPCon(do_QueryInterface(request));
|
||||
if (pHTTPCon) {
|
||||
PRUint32 httpStatus;
|
||||
pHTTPCon->GetResponseStatus(&httpStatus);
|
||||
if (httpStatus != 200)
|
||||
return readOfflineFile();
|
||||
}
|
||||
|
||||
// Send the autoconfig.jsc to javascript engine.
|
||||
PRBool success = PREF_EvaluateConfigScript(mBuf.get(), mBuf.Length(),nsnull,
|
||||
PR_FALSE,PR_TRUE,PR_FALSE);
|
||||
if (success) {
|
||||
rv = writeFailoverFile(); /* Write the autoconfig.jsc to
|
||||
failover.jsc (cached copy) */
|
||||
if(NS_FAILED(rv))
|
||||
NS_WARNING("Error writing failover.jsc file");
|
||||
// Clean up the previous read.
|
||||
// If there is a timer, these methods will be called again.
|
||||
mBuf.Truncate(0);
|
||||
mLoaded = PR_TRUE; //Releasing the deadlock
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
NS_WARNING("Error reading autoconfig.jsc from the network, reading the offline version");
|
||||
// Clean up the previous read so it will be ready for
|
||||
// the next updated read.
|
||||
mBuf.Truncate(0);
|
||||
return readOfflineFile();
|
||||
}
|
||||
}
|
||||
|
||||
// Notify method as a TimerCallBack function
|
||||
NS_IMETHODIMP_(void) nsAutoConfig::Notify(nsITimer *timer)
|
||||
{
|
||||
DownloadAutoCfg();
|
||||
}
|
||||
|
||||
/* Observe() is called twice: once at the instantiation time and other
|
||||
after the profile is set. It doesn't do anything but return NS_OK during the
|
||||
creation time. Second time it calls DownloadAutoCfg().
|
||||
*/
|
||||
NS_IMETHODIMP nsAutoConfig::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-after-change").get()))
|
||||
{
|
||||
// Getting the current profile name since we already have the
|
||||
// pointer to the object.
|
||||
nsCOMPtr<nsIProfile> profile = do_QueryInterface(aSubject);
|
||||
if (profile) {
|
||||
nsXPIDLString profileName;
|
||||
rv = profile->GetCurrentProfile(getter_Copies(profileName));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
// setting the member variable to the current profile name
|
||||
mCurrProfile.AssignWithConversion(profileName);
|
||||
else
|
||||
return rv;
|
||||
}
|
||||
return DownloadAutoCfg();
|
||||
}
|
||||
else if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("app-startup").get()))
|
||||
{
|
||||
// This is the object instantiation, do nothing and return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAutoConfig::DownloadAutoCfg()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCAutoString emailAddr;
|
||||
nsXPIDLCString urlName;
|
||||
PRBool appendMail=PR_FALSE, offline=PR_FALSE;
|
||||
static PRBool firstTime = PR_TRUE;
|
||||
|
||||
|
||||
// get the value of the autoconfig url
|
||||
rv = mPrefBranch->GetCharPref("autoadmin.global_config_url",
|
||||
getter_Copies(urlName));
|
||||
if(NS_FAILED(rv) || (nsCRT::strlen(urlName) == 0))
|
||||
return NS_OK; /* Return ok if there is no config url set. */
|
||||
|
||||
// Check to see if the network is online/offline
|
||||
|
||||
nsCOMPtr<nsIIOService> ios =
|
||||
do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = ios->GetOffline(&offline);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (offline) {
|
||||
|
||||
PRBool offlineFailover = PR_FALSE;
|
||||
rv = mPrefBranch->GetBoolPref("autoadmin.offline_failover",
|
||||
&offlineFailover);
|
||||
|
||||
// Read the failover.jsc if the network is offline and the pref says so
|
||||
if ( offlineFailover ) {
|
||||
return readOfflineFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsCAutoString cfgUrl(urlName);
|
||||
|
||||
/* Append user's identity at the end of the URL if the pref says so.
|
||||
First we are checking for the user's email address but if it is not
|
||||
available in the case where the client is used without messenger, user's
|
||||
profile name will be used as an unique identifier
|
||||
*/
|
||||
|
||||
rv = mPrefBranch->GetBoolPref("autoadmin.append_emailaddr", &appendMail);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && appendMail) {
|
||||
rv = getEmailAddr(emailAddr);
|
||||
if (NS_SUCCEEDED(rv) && emailAddr) {
|
||||
/* Adding the unique identifier at the end of autoconfig URL.
|
||||
In this case the autoconfig URL is a script and
|
||||
emailAddr as passed as an argument */
|
||||
cfgUrl.Append("?");
|
||||
cfgUrl.Append(emailAddr);
|
||||
}
|
||||
}
|
||||
|
||||
// Getting an event queue. If we start an AsyncOpen, the thread
|
||||
// needs to wait before the reading of autoconfig is done
|
||||
|
||||
nsCOMPtr<nsIEventQueue> currentThreadQ;
|
||||
|
||||
if (firstTime) {
|
||||
nsCOMPtr<nsIEventQueueService> service =
|
||||
do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = service->GetThreadEventQueue(NS_CURRENT_THREAD,getter_AddRefs(currentThreadQ));
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||
}
|
||||
mLoaded = PR_FALSE;
|
||||
|
||||
// create a new url
|
||||
|
||||
nsCOMPtr<nsIURI> url;
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
|
||||
rv = NS_NewURI(getter_AddRefs(url), cfgUrl, nsnull, nsnull);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
||||
// open a channel for the url
|
||||
|
||||
rv = NS_OpenURI(getter_AddRefs(channel),url, nsnull, nsnull);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->AsyncOpen(this, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
readOfflineFile();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// Set a repeating timer if the pref is set.
|
||||
// This is to be done only once.
|
||||
|
||||
if (firstTime) {
|
||||
firstTime = PR_FALSE;
|
||||
PRInt32 minutes = 0;
|
||||
rv = mPrefBranch->GetIntPref("autoadmin.refresh_interval",
|
||||
&minutes);
|
||||
if(NS_SUCCEEDED(rv) && minutes > 0) {
|
||||
// Create a new timer and pass this nsAutoConfig
|
||||
// object as a timer callback.
|
||||
nsCOMPtr<nsITimer> timer;
|
||||
timer = do_CreateInstance("@mozilla.org/timer;1",&rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = timer->Init(this, minutes*60*1000, NS_PRIORITY_NORMAL,
|
||||
NS_TYPE_REPEATING_SLACK);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// process events until we're finished. AutoConfig.jsc reading needs
|
||||
// to be finished before the browser starts loading up
|
||||
// We are waiting for the mLoaded which will be set through
|
||||
// onStopRequest or readOfflineFile methods
|
||||
// There is a possibility of deadlock so we need to make sure
|
||||
// that mLoaded will be set to true in any case (success/failure)
|
||||
|
||||
PLEvent *event;
|
||||
while (!mLoaded) {
|
||||
rv = currentThreadQ->WaitForEvent(&event);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"-->nsAutoConfig::DownloadAutoCfg: currentThreadQ->WaitForEvent failed...");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = currentThreadQ->HandleEvent(event);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "-->nsAutoConfig::DownloadAutoCfg: currentThreadQ->HandleEvent failed...");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
}
|
||||
|
||||
} //first_time
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // nsPref::DownloadAutoCfg()
|
||||
|
||||
|
||||
|
||||
nsresult nsAutoConfig::readOfflineFile()
|
||||
{
|
||||
PRBool failCache = PR_TRUE;
|
||||
nsresult rv;
|
||||
PRBool offline;
|
||||
|
||||
rv = mPrefBranch->GetBoolPref("autoadmin.failover_to_cached", &failCache);
|
||||
|
||||
if (failCache == PR_FALSE) {
|
||||
|
||||
// disable network connections and return.
|
||||
|
||||
nsCOMPtr<nsIIOService> ios =
|
||||
do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return reportError();
|
||||
|
||||
rv = ios->GetOffline(&offline);
|
||||
if (NS_FAILED(rv)) return reportError();
|
||||
if (!offline) {
|
||||
rv = ios->SetOffline(PR_TRUE);
|
||||
if (NS_FAILED(rv)) return reportError();
|
||||
}
|
||||
|
||||
// lock the "network.online" prference so user cannot toggle back to
|
||||
// online mode.
|
||||
rv = mPrefBranch->SetBoolPref("network.online", PR_FALSE);
|
||||
if (NS_FAILED(rv)) return reportError();
|
||||
mPrefBranch->LockPref("network.online");
|
||||
|
||||
mLoaded = PR_TRUE;
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
// failCache = true
|
||||
|
||||
// Open the file and read the content.
|
||||
// execute the javascript file
|
||||
|
||||
nsCOMPtr<nsIFile> failoverFile;
|
||||
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
getter_AddRefs(failoverFile));
|
||||
if (NS_FAILED(rv)) return reportError();
|
||||
#ifdef XP_MAC
|
||||
failoverFile->Append("Essential Files");
|
||||
#endif
|
||||
|
||||
failoverFile->Append("failover.jsc");
|
||||
rv = evaluateLocalFile(failoverFile);
|
||||
if (NS_FAILED(rv))
|
||||
NS_WARNING("Couldn't open failover.jsc, going back to default prefs");
|
||||
mLoaded = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAutoConfig::evaluateLocalFile(nsIFile* file)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIInputStream> inStr;
|
||||
|
||||
rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), file);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt64 fileSize;
|
||||
PRUint32 fs, amt=0;
|
||||
file->GetFileSize(&fileSize);
|
||||
LL_L2UI(fs, fileSize); // Converting 64 bit structure to unsigned int
|
||||
char* buf = (char *) PR_Malloc(fs*sizeof(char)) ;
|
||||
if(!buf)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = inStr->Read(buf, fs, &amt);
|
||||
if (NS_FAILED(rv))
|
||||
NS_ASSERTION((NS_BASE_STREAM_WOULD_BLOCK != rv),
|
||||
"The stream should never block.");
|
||||
|
||||
if (!PREF_EvaluateConfigScript(buf,fs,nsnull, PR_FALSE, PR_TRUE, PR_FALSE)){
|
||||
PR_FREEIF(buf);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
inStr->Close();
|
||||
PR_FREEIF(buf);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAutoConfig::writeFailoverFile()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFile> failoverFile;
|
||||
nsCOMPtr<nsIOutputStream> outStr;
|
||||
PRUint32 amt;
|
||||
|
||||
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
getter_AddRefs(failoverFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#ifdef XP_MAC
|
||||
failoverFile->Append("Essential Files");
|
||||
#endif
|
||||
|
||||
failoverFile->Append("failover.jsc");
|
||||
|
||||
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outStr), failoverFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = outStr->Write(mBuf.get(),mBuf.Length(),&amt);
|
||||
outStr->Close();
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAutoConfig::getEmailAddr(nsAWritableCString & emailAddr)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
nsXPIDLCString prefValue;
|
||||
|
||||
/* Getting an email address through set of three preferences:
|
||||
First getting a default account with
|
||||
"mail.accountmanager.defaultaccount"
|
||||
second getting an associated id with the default account
|
||||
Third getting an email address with id
|
||||
*/
|
||||
|
||||
rv = mPrefBranch->GetCharPref("mail.accountmanager.defaultaccount",
|
||||
getter_Copies(prefValue));
|
||||
// Checking prefValue and its length. Since by default the preference
|
||||
// is set to nothing
|
||||
if (NS_SUCCEEDED(rv) && nsCRT::strlen(prefValue) > 0) {
|
||||
emailAddr = NS_LITERAL_CSTRING("mail.account.") +
|
||||
nsLocalCString(prefValue) + NS_LITERAL_CSTRING(".identities");
|
||||
rv = mPrefBranch->GetCharPref(PromiseFlatCString(emailAddr).get(),
|
||||
getter_Copies(prefValue));
|
||||
if (NS_FAILED(rv) || nsCRT::strlen(prefValue) < 0) return rv;
|
||||
emailAddr = NS_LITERAL_CSTRING("mail.identity.") +
|
||||
nsLocalCString(prefValue) + NS_LITERAL_CSTRING(".useremail");
|
||||
rv = mPrefBranch->GetCharPref(PromiseFlatCString(emailAddr).get(),
|
||||
getter_Copies(prefValue));
|
||||
if (NS_FAILED(rv) || nsCRT::strlen(prefValue) < 0) return rv;
|
||||
emailAddr = nsLocalCString(prefValue);
|
||||
}
|
||||
else {
|
||||
if (mCurrProfile) {
|
||||
emailAddr = mCurrProfile;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsAutoConfig::reportError()
|
||||
{
|
||||
NS_ERROR("AutoConfig::readOfflineFile() failed");
|
||||
mLoaded = PR_TRUE; //Releasing lock to avoid deadlock in DownloadAutoCfg()
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
BIN
mozilla/modules/plugin/base/macbuild/plugin.mcp
Normal file
BIN
mozilla/modules/plugin/base/macbuild/plugin.mcp
Normal file
Binary file not shown.
105
mozilla/modules/plugin/base/src/Makefile.in
Normal file
105
mozilla/modules/plugin/base/src/Makefile.in
Normal file
@@ -0,0 +1,105 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = plugin
|
||||
XPIDL_MODULE = layout
|
||||
LIBRARY_NAME = gkplugin
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
REQUIRES = xpcom string java pref necko gtkxtbin webshell caps intl dom locale layout widget cookie mimetype oji exthandler docshell webbrwsr nkcache gfx2 timer windowwatcher js
|
||||
# for xlib port
|
||||
REQUIRES += xlibrgb
|
||||
|
||||
CPPSRCS = \
|
||||
ns4xPlugin.cpp \
|
||||
ns4xPluginInstance.cpp \
|
||||
nsPluginDocLoaderFactory.cpp \
|
||||
nsPluginHostImpl.cpp \
|
||||
nsPluginModule.cpp \
|
||||
nsPluginInstancePeer.cpp \
|
||||
nsPluginViewer.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH), BeOS)
|
||||
CPPSRCS += nsPluginsDirBeOS.cpp
|
||||
else
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
CPPSRCS += nsPluginsDirOS2.cpp
|
||||
else
|
||||
CPPSRCS += nsPluginsDirUnix.cpp
|
||||
endif
|
||||
endif
|
||||
|
||||
EXPORTS = \
|
||||
nsPluginsCID.h \
|
||||
nsIPluginHost.h \
|
||||
nsIPluginInstanceOwner.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
EXTRA_DSO_LIBS += gkgfx
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MOZ_NECKO_UTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_GTK_LDFLAGS)
|
||||
else
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_PLUGIN
|
||||
|
||||
ifdef MOZ_ENABLE_GTK
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -L/usr/X11R6/lib -lXt
|
||||
else
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -L/usr/X11R6/lib -lXt
|
||||
endif #MOZ_MONOLITHIC_TOOLKIT
|
||||
endif #MOZ_ENABLE_GTK
|
||||
|
||||
ifdef MOZ_ENABLE_QT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_QT_LDFLAGS)
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
CXXFLAGS += $(MOZ_QT_CFLAGS)
|
||||
CFLAGS += $(MOZ_QT_CFLAGS)
|
||||
else
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
endif #MOZ_MONOLITHIC_TOOLKIT
|
||||
endif #MOZ_ENABLE_QT
|
||||
99
mozilla/modules/plugin/base/src/makefile.win
Normal file
99
mozilla/modules/plugin/base/src/makefile.win
Normal file
@@ -0,0 +1,99 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
|
||||
EXPORTS = \
|
||||
nsPluginsCID.h \
|
||||
nsIPluginHost.h \
|
||||
nsIPluginInstanceOwner.h
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = gkplugin
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
MODULE=raptor
|
||||
IS_COMPONENT=1
|
||||
|
||||
DEFINES =-D_IMPL_NS_PLUGIN -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\ns4xPlugin.obj \
|
||||
.\$(OBJDIR)\ns4xPluginInstance.obj \
|
||||
.\$(OBJDIR)\nsPluginDocLoaderFactory.obj \
|
||||
.\$(OBJDIR)\nsPluginHostImpl.obj \
|
||||
.\$(OBJDIR)\nsPluginModule.obj \
|
||||
.\$(OBJDIR)\nsPluginInstancePeer.obj \
|
||||
.\$(OBJDIR)\nsPluginViewer.obj \
|
||||
.\$(OBJDIR)\nsPluginsDirWin.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS = \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\plugin \
|
||||
-I$(PUBLIC)\java \
|
||||
!ifdef NECKO
|
||||
-I$(PUBLIC)\necko \
|
||||
!else
|
||||
-I$(PUBLIC)\netlib \
|
||||
!endif
|
||||
-I$(PUBLIC)\oji \
|
||||
-I$(PUBLIC)\cache \
|
||||
-I$(PUBLIC)\pref \
|
||||
-I$(PUBLIC)\js \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
-D_IMPL_NS_PLUGIN \
|
||||
-GX \
|
||||
$(NULL)
|
||||
|
||||
!ifdef NU_CACHE
|
||||
CACHELIBNAME=cache.lib
|
||||
!else
|
||||
CACHELIBNAME=netcache.lib
|
||||
!endif
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)\lib\gkgfxwin.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\xppref32.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
WIN_LIBS = \
|
||||
version.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
it:
|
||||
echo $(LLIBS)
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(DLLNAME).dll
|
||||
4437
mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp
Normal file
4437
mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
BIN
mozilla/modules/plugin/macbuild/plugin.mcp
Normal file
BIN
mozilla/modules/plugin/macbuild/plugin.mcp
Normal file
Binary file not shown.
105
mozilla/modules/plugin/nglsrc/Makefile.in
Normal file
105
mozilla/modules/plugin/nglsrc/Makefile.in
Normal file
@@ -0,0 +1,105 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = plugin
|
||||
XPIDL_MODULE = layout
|
||||
LIBRARY_NAME = gkplugin
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
REQUIRES = xpcom string java pref necko gtkxtbin webshell caps intl dom locale layout widget cookie mimetype oji exthandler docshell webbrwsr nkcache gfx2 timer windowwatcher js
|
||||
# for xlib port
|
||||
REQUIRES += xlibrgb
|
||||
|
||||
CPPSRCS = \
|
||||
ns4xPlugin.cpp \
|
||||
ns4xPluginInstance.cpp \
|
||||
nsPluginDocLoaderFactory.cpp \
|
||||
nsPluginHostImpl.cpp \
|
||||
nsPluginModule.cpp \
|
||||
nsPluginInstancePeer.cpp \
|
||||
nsPluginViewer.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH), BeOS)
|
||||
CPPSRCS += nsPluginsDirBeOS.cpp
|
||||
else
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
CPPSRCS += nsPluginsDirOS2.cpp
|
||||
else
|
||||
CPPSRCS += nsPluginsDirUnix.cpp
|
||||
endif
|
||||
endif
|
||||
|
||||
EXPORTS = \
|
||||
nsPluginsCID.h \
|
||||
nsIPluginHost.h \
|
||||
nsIPluginInstanceOwner.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
EXTRA_DSO_LIBS += gkgfx
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MOZ_NECKO_UTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_GTK_LDFLAGS)
|
||||
else
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_PLUGIN
|
||||
|
||||
ifdef MOZ_ENABLE_GTK
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -L/usr/X11R6/lib -lXt
|
||||
else
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -L/usr/X11R6/lib -lXt
|
||||
endif #MOZ_MONOLITHIC_TOOLKIT
|
||||
endif #MOZ_ENABLE_GTK
|
||||
|
||||
ifdef MOZ_ENABLE_QT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_QT_LDFLAGS)
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
CXXFLAGS += $(MOZ_QT_CFLAGS)
|
||||
CFLAGS += $(MOZ_QT_CFLAGS)
|
||||
else
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
endif #MOZ_MONOLITHIC_TOOLKIT
|
||||
endif #MOZ_ENABLE_QT
|
||||
99
mozilla/modules/plugin/nglsrc/makefile.win
Normal file
99
mozilla/modules/plugin/nglsrc/makefile.win
Normal file
@@ -0,0 +1,99 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
|
||||
EXPORTS = \
|
||||
nsPluginsCID.h \
|
||||
nsIPluginHost.h \
|
||||
nsIPluginInstanceOwner.h
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = gkplugin
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
MODULE=raptor
|
||||
IS_COMPONENT=1
|
||||
|
||||
DEFINES =-D_IMPL_NS_PLUGIN -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\ns4xPlugin.obj \
|
||||
.\$(OBJDIR)\ns4xPluginInstance.obj \
|
||||
.\$(OBJDIR)\nsPluginDocLoaderFactory.obj \
|
||||
.\$(OBJDIR)\nsPluginHostImpl.obj \
|
||||
.\$(OBJDIR)\nsPluginModule.obj \
|
||||
.\$(OBJDIR)\nsPluginInstancePeer.obj \
|
||||
.\$(OBJDIR)\nsPluginViewer.obj \
|
||||
.\$(OBJDIR)\nsPluginsDirWin.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS = \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\plugin \
|
||||
-I$(PUBLIC)\java \
|
||||
!ifdef NECKO
|
||||
-I$(PUBLIC)\necko \
|
||||
!else
|
||||
-I$(PUBLIC)\netlib \
|
||||
!endif
|
||||
-I$(PUBLIC)\oji \
|
||||
-I$(PUBLIC)\cache \
|
||||
-I$(PUBLIC)\pref \
|
||||
-I$(PUBLIC)\js \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
-D_IMPL_NS_PLUGIN \
|
||||
-GX \
|
||||
$(NULL)
|
||||
|
||||
!ifdef NU_CACHE
|
||||
CACHELIBNAME=cache.lib
|
||||
!else
|
||||
CACHELIBNAME=netcache.lib
|
||||
!endif
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)\lib\gkgfxwin.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\xppref32.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
WIN_LIBS = \
|
||||
version.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
it:
|
||||
echo $(LLIBS)
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(DLLNAME).dll
|
||||
4437
mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp
Normal file
4437
mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
47
mozilla/netwerk/Makefile.in
Normal file
47
mozilla/netwerk/Makefile.in
Normal file
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = \
|
||||
base \
|
||||
cache \
|
||||
dns \
|
||||
socket \
|
||||
mime \
|
||||
streamconv \
|
||||
protocol \
|
||||
build \
|
||||
build2 \
|
||||
resources \
|
||||
$(NULL)
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += test
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
32
mozilla/netwerk/base/Makefile.in
Normal file
32
mozilla/netwerk/base/Makefile.in
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
31
mozilla/netwerk/base/makefile.win
Normal file
31
mozilla/netwerk/base/makefile.win
Normal file
@@ -0,0 +1,31 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH = ..\..
|
||||
|
||||
MODULE = necko
|
||||
|
||||
DIRS= \
|
||||
public \
|
||||
src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
8
mozilla/netwerk/base/public/MANIFEST
Normal file
8
mozilla/netwerk/base/public/MANIFEST
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
netCore.h
|
||||
nsNetUtil.h
|
||||
nsUnixColorPrintf.h
|
||||
nsIPasswordManagerUtils.h
|
||||
34
mozilla/netwerk/base/public/MANIFEST_IDL
Normal file
34
mozilla/netwerk/base/public/MANIFEST_IDL
Normal file
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
nsIAuthenticator.idl
|
||||
nsIAuthPrompt.idl
|
||||
nsIChannel.idl
|
||||
nsIFileChannel.idl
|
||||
nsIDownloader.idl
|
||||
nsIFileTransportService.idl
|
||||
nsIPrompt.idl
|
||||
nsIProtocolProxyService.idl
|
||||
nsIProxyAutoConfig.idl
|
||||
nsIProxyAutoConfigUtils.idl
|
||||
nsIProxy.idl
|
||||
nsIRequest.idl
|
||||
nsISocketTransportService.idl
|
||||
nsIStreamIO.idl
|
||||
nsIStreamIOChannel.idl
|
||||
nsIStreamListener.idl
|
||||
nsITransport.idl
|
||||
nsIStreamLoader.idl
|
||||
nsIDownloader.idl
|
||||
nsIRequestObserver.idl
|
||||
nsIRequestObserverProxy.idl
|
||||
nsIStreamProvider.idl
|
||||
nsIURI.idl
|
||||
nsIURL.idl
|
||||
nsIURLParser.idl
|
||||
nsIWebFilters.idl
|
||||
nsISecurityEventSink.idl
|
||||
nsISecretDecoderRing.idl
|
||||
nsISecureBrowserUI.idl
|
||||
nsISecurityManagerComponent.idl
|
||||
1
mozilla/netwerk/base/public/MANIFEST_PREFS
Normal file
1
mozilla/netwerk/base/public/MANIFEST_PREFS
Normal file
@@ -0,0 +1 @@
|
||||
security-prefs.js
|
||||
82
mozilla/netwerk/base/public/Makefile.in
Normal file
82
mozilla/netwerk/base/public/Makefile.in
Normal file
@@ -0,0 +1,82 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = necko
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIAuthenticator.idl \
|
||||
nsIAuthPrompt.idl \
|
||||
nsIChannel.idl \
|
||||
nsIFileChannel.idl \
|
||||
nsIDownloader.idl \
|
||||
nsIFileStreams.idl \
|
||||
nsIFileTransportService.idl \
|
||||
nsIIOService.idl \
|
||||
nsILoadGroup.idl \
|
||||
nsINetModRegEntry.idl \
|
||||
nsINetModuleMgr.idl \
|
||||
nsINetNotify.idl \
|
||||
nsIProgressEventSink.idl \
|
||||
nsIPrompt.idl \
|
||||
nsIProtocolHandler.idl \
|
||||
nsIProtocolProxyService.idl \
|
||||
nsIProxy.idl \
|
||||
nsIProxyAutoConfig.idl \
|
||||
nsIProxyAutoConfigUtils.idl \
|
||||
nsIRequest.idl \
|
||||
nsITransport.idl \
|
||||
nsISocketTransport.idl \
|
||||
nsISocketTransportService.idl \
|
||||
nsIStreamIO.idl \
|
||||
nsIStreamIOChannel.idl \
|
||||
nsIRequestObserver.idl \
|
||||
nsIRequestObserverProxy.idl \
|
||||
nsIStreamListener.idl \
|
||||
nsIStreamProvider.idl \
|
||||
nsIStreamLoader.idl \
|
||||
nsIURI.idl \
|
||||
nsIURL.idl \
|
||||
nsIURLParser.idl \
|
||||
nsIWebFilters.idl \
|
||||
nsISecurityEventSink.idl \
|
||||
nsISecretDecoderRing.idl \
|
||||
nsISecureBrowserUI.idl \
|
||||
nsISecurityManagerComponent.idl \
|
||||
nsICachingChannel.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
netCore.h \
|
||||
nsNetUtil.h \
|
||||
nsUnixColorPrintf.h \
|
||||
$(NULL)
|
||||
|
||||
PREF_JS_EXPORTS = $(srcdir)/security-prefs.js
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
84
mozilla/netwerk/base/public/makefile.win
Normal file
84
mozilla/netwerk/base/public/makefile.win
Normal file
@@ -0,0 +1,84 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
MODULE = necko
|
||||
|
||||
DEPTH = ..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
EXPORTS = \
|
||||
netCore.h \
|
||||
nsNetUtil.h \
|
||||
nsUnixColorPrintf.h \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsIAuthenticator.idl \
|
||||
.\nsIAuthPrompt.idl \
|
||||
.\nsIChannel.idl \
|
||||
.\nsIFileChannel.idl \
|
||||
.\nsIFileStreams.idl \
|
||||
.\nsIFileTransportService.idl \
|
||||
.\nsIIOService.idl \
|
||||
.\nsILoadGroup.idl \
|
||||
.\nsINetModRegEntry.idl \
|
||||
.\nsINetModuleMgr.idl \
|
||||
.\nsINetNotify.idl \
|
||||
.\nsIProgressEventSink.idl \
|
||||
.\nsIPrompt.idl \
|
||||
.\nsIProtocolHandler.idl \
|
||||
.\nsIProtocolProxyService.idl \
|
||||
.\nsIProxyAutoConfig.idl \
|
||||
.\nsIProxyAutoConfigUtils.idl \
|
||||
.\nsIProxy.idl \
|
||||
.\nsIRequest.idl \
|
||||
.\nsITransport.idl \
|
||||
.\nsISocketTransport.idl \
|
||||
.\nsISocketTransportService.idl \
|
||||
.\nsIStreamIO.idl \
|
||||
.\nsIStreamIOChannel.idl \
|
||||
.\nsIRequestObserver.idl \
|
||||
.\nsIRequestObserverProxy.idl \
|
||||
.\nsIStreamListener.idl \
|
||||
.\nsIStreamProvider.idl \
|
||||
.\nsIStreamLoader.idl \
|
||||
.\nsIStreamProvider.idl \
|
||||
.\nsITransport.idl \
|
||||
.\nsIDownloader.idl \
|
||||
.\nsIURI.idl \
|
||||
.\nsIURL.idl \
|
||||
.\nsIURLParser.idl \
|
||||
.\nsIWebFilters.idl \
|
||||
.\nsISecurityEventSink.idl \
|
||||
.\nsISecretDecoderRing.idl \
|
||||
.\nsISecureBrowserUI.idl \
|
||||
.\nsISecurityManagerComponent.idl \
|
||||
.\nsICachingChannel.idl \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
$(DEPTH)\netwerk\dist\include:
|
||||
-mkdir $(DEPTH)\netwerk\dist
|
||||
-mkdir $(DEPTH)\netwerk\dist\include
|
||||
|
||||
install::
|
||||
$(MAKE_INSTALL) .\security-prefs.js $(DIST)\bin\defaults\pref
|
||||
71
mozilla/netwerk/base/public/netCore.h
Normal file
71
mozilla/netwerk/base/public/netCore.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __netCore_h__
|
||||
#define __netCore_h__
|
||||
|
||||
#include "nsError.h"
|
||||
|
||||
/* networking error codes */
|
||||
|
||||
// NET RANGE: 1 -20
|
||||
// FTP RANGE: 21-30
|
||||
// HTTP RANGE: 31-40
|
||||
// DNS RANGE: 41-50
|
||||
// SOCKET RANGE 51-60
|
||||
// CACHE RANGE: 61-70
|
||||
|
||||
// XXX Why can't we put all Netwerk error codes in one file to help avoid collisions?
|
||||
|
||||
#define NS_ERROR_ALREADY_CONNECTED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 11)
|
||||
|
||||
#define NS_ERROR_NOT_CONNECTED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 12)
|
||||
|
||||
/* NS_ERROR_CONNECTION_REFUSED and NS_ERROR_NET_TIMEOUT moved to nsISocketTransportService.idl */
|
||||
|
||||
#define NS_ERROR_IN_PROGRESS \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 15)
|
||||
|
||||
#define NS_ERROR_OFFLINE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 16)
|
||||
|
||||
#undef NS_NET
|
||||
#ifdef _IMPL_NS_NET
|
||||
#if defined(XP_PC) && !defined(XP_OS2)
|
||||
#define NS_NET _declspec(dllexport)
|
||||
#else /* !XP_PC */
|
||||
#define NS_NET
|
||||
#endif /* !XP_PC */
|
||||
#else /* !_IMPL_NS_NET */
|
||||
#if defined(XP_PC) && !defined(XP_OS2)
|
||||
#define NS_NET _declspec(dllimport)
|
||||
#else /* !XP_PC */
|
||||
#define NS_NET
|
||||
#endif /* !XP_PC */
|
||||
#endif /* !_IMPL_NS_NET */
|
||||
|
||||
// Where most necko status messages come from:
|
||||
#define NECKO_MSGS_URL "chrome://necko/locale/necko.properties"
|
||||
|
||||
#endif // __netCore_h__
|
||||
65
mozilla/netwerk/base/public/nsIAuthPrompt.idl
Normal file
65
mozilla/netwerk/base/public/nsIAuthPrompt.idl
Normal file
@@ -0,0 +1,65 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIPrompt;
|
||||
|
||||
[scriptable, uuid(2f977d45-5485-11d4-87e2-0010a4e75ef2)]
|
||||
interface nsIAuthPrompt : nsISupports
|
||||
{
|
||||
const PRUint32 SAVE_PASSWORD_NEVER = 0;
|
||||
const PRUint32 SAVE_PASSWORD_FOR_SESSION = 1;
|
||||
const PRUint32 SAVE_PASSWORD_PERMANENTLY = 2;
|
||||
|
||||
/**
|
||||
* Puts up a text input dialog with OK and Cancel buttons.
|
||||
* @return true for OK, false for Cancel
|
||||
*/
|
||||
boolean prompt(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in wstring passwordRealm,
|
||||
in PRUint32 savePassword,
|
||||
in wstring defaultText,
|
||||
out wstring result);
|
||||
|
||||
/**
|
||||
* Puts up a username/password dialog with OK and Cancel buttons.
|
||||
* @return true for OK, false for Cancel
|
||||
*/
|
||||
boolean promptUsernameAndPassword(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in wstring passwordRealm,
|
||||
in PRUint32 savePassword,
|
||||
out wstring user,
|
||||
out wstring pwd);
|
||||
|
||||
/**
|
||||
* Puts up a password dialog with OK and Cancel buttons.
|
||||
* @return true for OK, false for Cancel
|
||||
*/
|
||||
boolean promptPassword(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in wstring passwordRealm,
|
||||
in PRUint32 savePassword,
|
||||
out wstring pwd);
|
||||
};
|
||||
78
mozilla/netwerk/base/public/nsIAuthenticator.idl
Normal file
78
mozilla/netwerk/base/public/nsIAuthenticator.idl
Normal file
@@ -0,0 +1,78 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Zero-Knowledge Systems,
|
||||
* Inc. Portions created by Zero-Knowledge are Copyright (C) 2000
|
||||
* Zero-Knowledge Systems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIAuthPrompt.idl"
|
||||
#include "nsIURL.idl"
|
||||
|
||||
[scriptable,uuid(adf74d2a-1dd1-11b2-b129-f3154be37959)]
|
||||
interface nsIAuthenticator : nsISupports
|
||||
{
|
||||
/**
|
||||
* @param uri The URI for which authentication is required.
|
||||
* @param uri The protocol, for selecting authentication-style. Variant
|
||||
* protocols, such as http/https and imap/imaps will likely all
|
||||
* use the primary protocol name ("http", "imap"), to reduce
|
||||
*
|
||||
* @param challenge The complete value of the WWW-Authenticate header from
|
||||
* the response.
|
||||
* @param username The username provided in the prehost portion of the URI,
|
||||
* if any.
|
||||
* @param password The password provided in the prehost portion of the URI,
|
||||
* if any.
|
||||
* @param prompter The standard prompter for interacting with the user.
|
||||
* @param
|
||||
* @return The complete authentication value to return. For Basic HTTP
|
||||
* auth, as an example, the returned string would be
|
||||
* "Basic BASE64(<user>:<pass>)". The format is dependent on the
|
||||
* provided protocol parameter.
|
||||
*/
|
||||
string authenticate(in nsIURI uri, in string protocol, in string challenge,
|
||||
in wstring username, in wstring password,
|
||||
in nsIAuthPrompt prompter);
|
||||
|
||||
/**
|
||||
* No interaction with the user required. This indicates that the
|
||||
* authenticate method can be called with a null prompter argument, though
|
||||
* calling code should strive to provide it if at all possible. (While
|
||||
* interaction with the user may not be _required_, it might still be
|
||||
* desire
|
||||
*/
|
||||
const PRUint32 INTERACTION_NONE = 0;
|
||||
|
||||
/**
|
||||
* Standard username and optional password required, and the caller should
|
||||
* prompt for it.
|
||||
*/
|
||||
const PRUint32 INTERACTION_STANDARD = 1;
|
||||
|
||||
/**
|
||||
* Custom interaction required: Mozilla must provide a non-null prompter
|
||||
* argument when calling authenticate.
|
||||
*/
|
||||
const PRUint32 INTERACTION_CUSTOM = 2;
|
||||
|
||||
/**
|
||||
* What kind of interaction with the user does this authentication method
|
||||
* require?
|
||||
*/
|
||||
readonly attribute PRUint32 interactionType;
|
||||
};
|
||||
88
mozilla/netwerk/base/public/nsICachingChannel.idl
Normal file
88
mozilla/netwerk/base/public/nsICachingChannel.idl
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@netscape.com> (original author)
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIFile;
|
||||
|
||||
/**
|
||||
* A channel may optionally implement this interface to allow clients
|
||||
* to effect its behavior with respect to how it uses the cache service.
|
||||
*
|
||||
* This interface provides:
|
||||
* 1) Support for "stream as file" semantics (for JAR and plugins).
|
||||
* 2) Support for "pinning" cached data in the cache (for printing and save-as).
|
||||
*/
|
||||
[scriptable, uuid(b1f95f5e-ee05-4434-9d34-89a935d7feef)]
|
||||
interface nsICachingChannel : nsISupports
|
||||
{
|
||||
/**
|
||||
* Set/get the cache token... uniquely identifies the data in the cache.
|
||||
* Holding a reference to this token prevents the cached data from being
|
||||
* removed. A cache token retrieved from a particular instance of
|
||||
* nsICachingChannel could be set on another instance of nsICachingChannel
|
||||
* provided the underlying implementations are compatible. The implemen-
|
||||
* tation of nsICachingChannel would be expected to only read from the
|
||||
* cache entry identified by the cache token and not try to validate it.
|
||||
*
|
||||
* The cache token can be treated as an opaque object; however, it can be
|
||||
* QI'd to a nsICacheEntryDescriptor if more detailed information about the
|
||||
* cache entry is needed.
|
||||
*/
|
||||
attribute nsISupports cacheToken;
|
||||
|
||||
/**
|
||||
* Set/get the cache key... uniquely identifies the data in the cache.
|
||||
* Holding a reference to this key DOES NOT prevent the cached data from
|
||||
* being removed. It is otherwise similar to the cacheToken.
|
||||
*
|
||||
* The fromCacheOnly flag inhibits fetching from the net if the data in the
|
||||
* cache has been evicted. An error of NS_ERROR_DOCUMENT_NOT_CACHED will
|
||||
* be sent to the listener's onStopRequest in this case.
|
||||
*/
|
||||
nsISupports getCacheKey();
|
||||
void setCacheKey(in nsISupports cacheKey, in boolean fromCacheOnly);
|
||||
|
||||
/**
|
||||
* Specifies whether or not the data should be cached to a file. This
|
||||
* may fail if the disk cache is not present. The value of this attribute
|
||||
* is usually only settable during the processing of a channel's
|
||||
* OnStartRequest. The default value of this attribute depends on the
|
||||
* particular implementation of nsICachingChannel.
|
||||
*/
|
||||
attribute boolean cacheAsFile;
|
||||
|
||||
/**
|
||||
* Get the "file" where the cached data can be found. This is valid for
|
||||
* as long as a reference to the cache token is held. This may return
|
||||
* an error if cacheAsFile is false.
|
||||
*/
|
||||
readonly attribute nsIFile cacheFile;
|
||||
};
|
||||
|
||||
%{C++
|
||||
/**
|
||||
* nsresult passed through onStopRequest if the document could not be fetched from the cache.
|
||||
*/
|
||||
#define NS_ERROR_DOCUMENT_NOT_CACHED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 70)
|
||||
%}
|
||||
143
mozilla/netwerk/base/public/nsIChannel.idl
Normal file
143
mozilla/netwerk/base/public/nsIChannel.idl
Normal file
@@ -0,0 +1,143 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIRequest.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIInterfaceRequestor;
|
||||
interface nsIInputStream;
|
||||
interface nsIStreamListener;
|
||||
|
||||
/**
|
||||
* The nsIChannel interface allows the user to construct GET requests for
|
||||
* specific protocols, and manage them in a uniform way. Once a channel
|
||||
* is created (via nsIIOService::NewChannel), parameters for that request
|
||||
* may be set by using the channel attributes, or by QI'ing to a subclass
|
||||
* of nsIChannel for protocol-specific parameters. Then the actual request
|
||||
* can be issued via Open or AsyncOpen.
|
||||
*
|
||||
* After a request has been completed, the channel is still valid for
|
||||
* accessing protocol-specific results. For example, QI'ing to nsIHTTPChannel
|
||||
* allows response headers to be retrieved for the http transaction.
|
||||
*/
|
||||
[scriptable, uuid(1788e79e-f947-11d3-8cda-0060b0fc14a3)]
|
||||
interface nsIChannel : nsIRequest
|
||||
{
|
||||
/**
|
||||
* Returns the original URL used to construct the channel.
|
||||
* This is used in the case of a redirect or URI "resolution" (e.g.
|
||||
* resolving a resource: URI to a file: URI) so that the original
|
||||
* pre-redirect URI can still be obtained.
|
||||
*
|
||||
* Note that this is distinctly different from the http referrer
|
||||
* (referring URI) which is typically the page that contained the
|
||||
* original URI (accessible from nsIHTTPChannel).
|
||||
*/
|
||||
attribute nsIURI originalURI;
|
||||
|
||||
/**
|
||||
* Returns the URL to which the channel currently refers. If a redirect
|
||||
* or URI resolution occurs, this accessor returns the current location
|
||||
* to which the channel is referring.
|
||||
*/
|
||||
readonly attribute nsIURI URI;
|
||||
|
||||
/**
|
||||
* Accesses the owner corresponding to the entity that is
|
||||
* responsible for this channel. Used by security code to grant
|
||||
* or deny privileges to mobile code loaded from this channel.
|
||||
*
|
||||
* Note: This is a strong reference to the owner, so if the owner is also
|
||||
* holding a pointer to the channel, care must be taken to explicitly drop
|
||||
* its reference to the channel -- otherwise a leak will result.
|
||||
*/
|
||||
attribute nsISupports owner;
|
||||
|
||||
/**
|
||||
* Accesses the capabilities callbacks of the channel. This is set by clients
|
||||
* who wish to provide a means to receive progress, status and protocol-specific
|
||||
* notifications. Interfaces commonly requested include: nsIProgressEventSink
|
||||
* and nsIPrompt.
|
||||
*/
|
||||
attribute nsIInterfaceRequestor notificationCallbacks;
|
||||
|
||||
/**
|
||||
* Any security information about this channel. This can be null.
|
||||
*/
|
||||
readonly attribute nsISupports securityInfo;
|
||||
|
||||
/**
|
||||
* Returns the content MIME type of the channel if available. Note that the
|
||||
* content type can often be wrongly specified (wrong file extension, wrong
|
||||
* MIME type, wrong document type stored on a server, etc.) and the caller
|
||||
* most likely wants to verify with the actual data.
|
||||
*/
|
||||
attribute string contentType;
|
||||
|
||||
/**
|
||||
* Returns the length of the data associated with the channel if available.
|
||||
* If the length is unknown then -1 is returned.
|
||||
*/
|
||||
attribute long contentLength;
|
||||
|
||||
/**
|
||||
* Synchronously open this channel. Returns a blocking input stream to this
|
||||
* channel's data.
|
||||
*/
|
||||
nsIInputStream open();
|
||||
|
||||
/**
|
||||
* Asynchronously open this channel. Data is fed to the specified stream
|
||||
* listener as it becomes available.
|
||||
*/
|
||||
void asyncOpen(in nsIStreamListener listener, in nsISupports ctxt);
|
||||
|
||||
/**************************************************************************
|
||||
* Channel specific load flags:
|
||||
*/
|
||||
|
||||
/**
|
||||
* Used exclusively by the uriloader and docshell to indicate whether or
|
||||
* not this request corresponds to the toplevel document.
|
||||
*/
|
||||
const unsigned long LOAD_DOCUMENT_URI = 1 << 16;
|
||||
|
||||
/**
|
||||
* If the end consumer for this load has been retargeted after discovering
|
||||
* it's content, this flag will be set:
|
||||
*/
|
||||
const unsigned long LOAD_RETARGETED_DOCUMENT_URI = 1 << 17;
|
||||
|
||||
/**
|
||||
* This flag is set to indicate that onStopRequest may be followed by
|
||||
* another onStartRequest/onStopRequest pair. This flag is, for example,
|
||||
* used by the multipart/replace stream converter.
|
||||
*/
|
||||
const unsigned long LOAD_REPLACE = 1 << 18;
|
||||
|
||||
/**************************************************************************
|
||||
* This flag is OBSOLETE and will be removed once the old cache is
|
||||
* removed from the code base. Support for CACHE_AS_FILE is now provided
|
||||
* via nsICachingChannel.
|
||||
*/
|
||||
const unsigned long CACHE_AS_FILE = 1 << 19;
|
||||
};
|
||||
50
mozilla/netwerk/base/public/nsIDownloader.idl
Normal file
50
mozilla/netwerk/base/public/nsIDownloader.idl
Normal file
@@ -0,0 +1,50 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIRequest.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsILoadGroup;
|
||||
interface nsIInterfaceRequestor;
|
||||
interface nsIFile;
|
||||
interface nsIDownloader;
|
||||
|
||||
[scriptable, uuid(6e0fc962-4a6f-4fa6-831f-8c26c554407f)]
|
||||
interface nsIDownloadObserver : nsISupports
|
||||
{
|
||||
void onDownloadComplete(in nsIDownloader downloader,
|
||||
in nsISupports ctxt,
|
||||
in nsresult status,
|
||||
in nsIFile result);
|
||||
};
|
||||
|
||||
[scriptable, uuid(9632cc0d-864d-4f92-b7e5-bd8097c4e9a5)]
|
||||
interface nsIDownloader : nsISupports
|
||||
{
|
||||
void init(in nsIURI uri,
|
||||
in nsIDownloadObserver completionObserver,
|
||||
in nsISupports ctxt,
|
||||
in boolean synchronous,
|
||||
in nsILoadGroup loadGroup,
|
||||
in nsIInterfaceRequestor notificationCallbacks,
|
||||
in nsLoadFlags loadAttributes);
|
||||
};
|
||||
30
mozilla/netwerk/base/public/nsIEventSinkGetter.idl
Normal file
30
mozilla/netwerk/base/public/nsIEventSinkGetter.idl
Normal file
@@ -0,0 +1,30 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(fb65fd70-1881-11d3-9337-00104ba0fd40)]
|
||||
interface nsIEventSinkGetter : nsISupports
|
||||
{
|
||||
nsISupports getEventSink(in string command, in nsIIDRef eventSinkIID);
|
||||
};
|
||||
|
||||
82
mozilla/netwerk/base/public/nsIFileChannel.idl
Normal file
82
mozilla/netwerk/base/public/nsIFileChannel.idl
Normal file
@@ -0,0 +1,82 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
interface nsIFile;
|
||||
#include "nsIChannel.idl"
|
||||
#include "nsIURL.idl"
|
||||
|
||||
/**
|
||||
* nsIFileURL is used for the file: protocol, and gives access to the
|
||||
* underlying nsIFile object.
|
||||
*/
|
||||
[scriptable, uuid(d26b2e2e-1dd1-11b2-88f3-8545a7ba7949)]
|
||||
interface nsIFileURL : nsIURL
|
||||
{
|
||||
attribute nsIFile file;
|
||||
};
|
||||
|
||||
/**
|
||||
* nsIFileChannel is an interface that allows for the initialization
|
||||
* of a simple nsIChannel that is constructed from a single nsIFile and
|
||||
* associated content type.
|
||||
*/
|
||||
[scriptable, uuid(68a26506-f947-11d3-8cda-0060b0fc14a3)]
|
||||
interface nsIFileChannel : nsIChannel
|
||||
{
|
||||
/**
|
||||
* Values for ioFlags parameters to be or'd together.
|
||||
* (From prio.h)
|
||||
*/
|
||||
const long NS_RDONLY = 0x01;
|
||||
const long NS_WRONLY = 0x02;
|
||||
const long NS_RDWR = 0x04;
|
||||
const long NS_CREATE_FILE = 0x08;
|
||||
const long NS_APPEND = 0x10;
|
||||
const long NS_TRUNCATE = 0x20;
|
||||
const long NS_SYNC = 0x40;
|
||||
const long NS_EXCL = 0x80;
|
||||
|
||||
void init(in nsIFile file,
|
||||
in long ioFlags,
|
||||
in long perm);
|
||||
|
||||
readonly attribute nsIFile file;
|
||||
attribute long ioFlags;
|
||||
attribute long permissions;
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
#define NS_LOCALFILECHANNEL_CLASSNAME "Local File Channel"
|
||||
#define NS_LOCALFILECHANNEL_CONTRACTID "@mozilla.org/network/local-file-channel;1"
|
||||
|
||||
#define NS_LOCALFILECHANNEL_CID \
|
||||
{ /* 6d5b2d44-f947-11d3-8cda-0060b0fc14a3 */ \
|
||||
0x6d5b2d44, \
|
||||
0xf947, \
|
||||
0x11d3, \
|
||||
{0x8c, 0xda, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
241
mozilla/netwerk/base/public/nsIFileStreams.idl
Normal file
241
mozilla/netwerk/base/public/nsIFileStreams.idl
Normal file
@@ -0,0 +1,241 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIInputStream.idl"
|
||||
#include "nsIOutputStream.idl"
|
||||
#include "nsILocalFile.idl"
|
||||
|
||||
[scriptable, uuid(e3d56a20-c7ec-11d3-8cda-0060b0fc14a3)]
|
||||
interface nsIFileInputStream : nsIInputStream
|
||||
{
|
||||
void init(in nsIFile file, in long ioFlags, in long perm);
|
||||
};
|
||||
|
||||
[scriptable, uuid(e6f68040-c7ec-11d3-8cda-0060b0fc14a3)]
|
||||
interface nsIFileOutputStream : nsIOutputStream
|
||||
{
|
||||
void init(in nsIFile file, in long ioFlags, in long perm);
|
||||
};
|
||||
|
||||
[scriptable, uuid(e9de5df0-c7ec-11d3-8cda-0060b0fc14a3)]
|
||||
interface nsISeekableStream : nsISupports
|
||||
{
|
||||
// correspond to PRSeekWhence values
|
||||
const long NS_SEEK_SET = 0;
|
||||
const long NS_SEEK_CUR = 1;
|
||||
const long NS_SEEK_END = 2;
|
||||
|
||||
void seek(in long whence, in long offset);
|
||||
unsigned long tell();
|
||||
};
|
||||
|
||||
[scriptable, uuid(616f5b48-da09-11d3-8cda-0060b0fc14a3)]
|
||||
interface nsIBufferedInputStream : nsIInputStream
|
||||
{
|
||||
void init(in nsIInputStream fillFromStream,
|
||||
in unsigned long bufferSize);
|
||||
};
|
||||
|
||||
[scriptable, uuid(6476378a-da09-11d3-8cda-0060b0fc14a3)]
|
||||
interface nsIBufferedOutputStream : nsIOutputStream
|
||||
{
|
||||
void init(in nsIOutputStream sinkToStream,
|
||||
in unsigned long bufferSize);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NS_LOCALFILEINPUTSTREAM_CLASSNAME "Local File Input Stream"
|
||||
#define NS_LOCALFILEINPUTSTREAM_CONTRACTID "@mozilla.org/network/file-input-stream;1"
|
||||
|
||||
#define NS_LOCALFILEINPUTSTREAM_CID \
|
||||
{ /* be9a53ae-c7e9-11d3-8cda-0060b0fc14a3 */ \
|
||||
0xbe9a53ae, \
|
||||
0xc7e9, \
|
||||
0x11d3, \
|
||||
{0x8c, 0xda, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
||||
}
|
||||
|
||||
#define NS_LOCALFILEOUTPUTSTREAM_CLASSNAME "Local File Output Stream"
|
||||
#define NS_LOCALFILEOUTPUTSTREAM_CONTRACTID "@mozilla.org/network/file-output-stream;1"
|
||||
|
||||
#define NS_LOCALFILEOUTPUTSTREAM_CID \
|
||||
{ /* c272fee0-c7e9-11d3-8cda-0060b0fc14a3 */ \
|
||||
0xc272fee0, \
|
||||
0xc7e9, \
|
||||
0x11d3, \
|
||||
{0x8c, 0xda, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NS_BUFFEREDINPUTSTREAM_CLASSNAME "Buffered Input Stream"
|
||||
#define NS_BUFFEREDINPUTSTREAM_CONTRACTID "@mozilla.org/network/buffered-input-stream;1"
|
||||
|
||||
#define NS_BUFFEREDINPUTSTREAM_CID \
|
||||
{ /* 9226888e-da08-11d3-8cda-0060b0fc14a3 */ \
|
||||
0x9226888e, \
|
||||
0xda08, \
|
||||
0x11d3, \
|
||||
{0x8c, 0xda, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
||||
}
|
||||
|
||||
#define NS_BUFFEREDOUTPUTSTREAM_CLASSNAME "Buffered Output Stream"
|
||||
#define NS_BUFFEREDOUTPUTSTREAM_CONTRACTID "@mozilla.org/network/buffered-output-stream;1"
|
||||
|
||||
#define NS_BUFFEREDOUTPUTSTREAM_CID \
|
||||
{ /* 9868b4ce-da08-11d3-8cda-0060b0fc14a3 */ \
|
||||
0x9868b4ce, \
|
||||
0xda08, \
|
||||
0x11d3, \
|
||||
{0x8c, 0xda, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// move to nsNetUtil.h later...
|
||||
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "prio.h" // for read/write flags, permissions, etc.
|
||||
|
||||
// This will QI the file argument to an nsILocalFile in the Init method.
|
||||
inline nsresult
|
||||
NS_NewLocalFileChannel(nsIFileChannel **result,
|
||||
nsIFile* file,
|
||||
PRInt32 ioFlags = -1,
|
||||
PRInt32 perm = -1)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFileChannel> channel;
|
||||
static NS_DEFINE_CID(kLocalFileChannelCID, NS_LOCALFILECHANNEL_CID);
|
||||
rv = nsComponentManager::CreateInstance(kLocalFileChannelCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIFileChannel),
|
||||
getter_AddRefs(channel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = channel->Init(file, ioFlags, perm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = channel;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// This will QI the file argument to an nsILocalFile in the Init method.
|
||||
inline nsresult
|
||||
NS_NewLocalFileInputStream(nsIInputStream* *result,
|
||||
nsIFile* file,
|
||||
PRInt32 ioFlags = -1,
|
||||
PRInt32 perm = -1)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFileInputStream> in;
|
||||
static NS_DEFINE_CID(kLocalFileInputStreamCID, NS_LOCALFILEINPUTSTREAM_CID);
|
||||
rv = nsComponentManager::CreateInstance(kLocalFileInputStreamCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIFileInputStream),
|
||||
getter_AddRefs(in));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = in->Init(file, ioFlags, perm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = in;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// This will QI the file argument to an nsILocalFile in the Init method.
|
||||
inline nsresult
|
||||
NS_NewLocalFileOutputStream(nsIOutputStream* *result,
|
||||
nsIFile* file,
|
||||
PRInt32 ioFlags = -1,
|
||||
PRInt32 perm = -1)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFileOutputStream> out;
|
||||
static NS_DEFINE_CID(kLocalFileOutputStreamCID, NS_LOCALFILEOUTPUTSTREAM_CID);
|
||||
rv = nsComponentManager::CreateInstance(kLocalFileOutputStreamCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIFileOutputStream),
|
||||
getter_AddRefs(out));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = out->Init(file, ioFlags, perm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = out;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline nsresult
|
||||
NS_NewBufferedInputStream(nsIInputStream* *result,
|
||||
nsIInputStream* str,
|
||||
PRUint32 bufferSize)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIBufferedInputStream> in;
|
||||
static NS_DEFINE_CID(kBufferedInputStreamCID, NS_BUFFEREDINPUTSTREAM_CID);
|
||||
rv = nsComponentManager::CreateInstance(kBufferedInputStreamCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIBufferedInputStream),
|
||||
getter_AddRefs(in));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = in->Init(str, bufferSize);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = in;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
NS_NewBufferedOutputStream(nsIOutputStream* *result,
|
||||
nsIOutputStream* str,
|
||||
PRUint32 bufferSize)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIBufferedOutputStream> out;
|
||||
static NS_DEFINE_CID(kBufferedOutputStreamCID, NS_BUFFEREDOUTPUTSTREAM_CID);
|
||||
rv = nsComponentManager::CreateInstance(kBufferedOutputStreamCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIBufferedOutputStream),
|
||||
getter_AddRefs(out));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = out->Init(str, bufferSize);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = out;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
%}
|
||||
85
mozilla/netwerk/base/public/nsIFileTransportService.idl
Normal file
85
mozilla/netwerk/base/public/nsIFileTransportService.idl
Normal file
@@ -0,0 +1,85 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
%{C++
|
||||
#include "nsFileSpec.h"
|
||||
%}
|
||||
|
||||
interface nsITransport;
|
||||
interface nsIEventSinkGetter;
|
||||
interface nsIInputStream;
|
||||
interface nsIRunnable;
|
||||
interface nsIFile;
|
||||
interface nsIStreamIO;
|
||||
|
||||
[scriptable, uuid(57211a60-8c45-11d3-93ac-00104ba0fd40)]
|
||||
interface nsIFileTransportService : nsISupports
|
||||
{
|
||||
nsITransport createTransport(in nsIFile file,
|
||||
in long ioFlags,
|
||||
in long perm);
|
||||
|
||||
// This version can be used with an existing input stream to serve
|
||||
// as a data pump:
|
||||
nsITransport createTransportFromStream(in string name,
|
||||
in nsIInputStream fromStream,
|
||||
in string contentType,
|
||||
in long contentLength,
|
||||
in boolean closeStreamWhenDone);
|
||||
|
||||
nsITransport createTransportFromStreamIO(in nsIStreamIO io);
|
||||
|
||||
void dispatchRequest(in nsIRunnable runnable);
|
||||
void processPendingRequests();
|
||||
void shutdown();
|
||||
|
||||
/**
|
||||
* Total number of transports currently alive
|
||||
*/
|
||||
readonly attribute unsigned long totalTransportCount;
|
||||
/**
|
||||
* A number of transports with I/O operation currently in-progress
|
||||
*/
|
||||
readonly attribute unsigned long inUseTransportCount;
|
||||
/**
|
||||
* A number of transports connected/opened
|
||||
*/
|
||||
readonly attribute unsigned long connectedTransportCount;
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_FILETRANSPORTSERVICE_CID \
|
||||
{ /* 2bb2b250-ea35-11d2-931b-00104ba0fd40 */ \
|
||||
0x2bb2b250, \
|
||||
0xea35, \
|
||||
0x11d2, \
|
||||
{0x93, 0x1b, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Status nsresult codes: used with nsIProgressEventSink::OnStatus
|
||||
*/
|
||||
#define NS_NET_STATUS_READ_FROM NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 8)
|
||||
#define NS_NET_STATUS_WROTE_TO NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 9)
|
||||
|
||||
%}
|
||||
171
mozilla/netwerk/base/public/nsIIOService.idl
Normal file
171
mozilla/netwerk/base/public/nsIIOService.idl
Normal file
@@ -0,0 +1,171 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIProtocolHandler;
|
||||
interface nsIChannel;
|
||||
interface nsIURI;
|
||||
|
||||
[scriptable, uuid(ab7c3a84-d488-11d3-8cda-0060b0fc14a3)]
|
||||
interface nsIIOService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Returns a protocol handler for a given URI scheme.
|
||||
*
|
||||
* @param scheme URI scheme
|
||||
* @return reference to nsIProtcolHandler
|
||||
*/
|
||||
nsIProtocolHandler getProtocolHandler(in string scheme);
|
||||
|
||||
/**
|
||||
* This method constructs a new URI by first determining the scheme
|
||||
* of the URI spec, and then delegating the construction of the URI
|
||||
* to the protocol handler for that scheme. QueryInterface can be used
|
||||
* on the resulting URI object to obtain a more specific type of URI.
|
||||
*
|
||||
* @param aSpec URI spec (http, ftp, etc)
|
||||
* @param aBaseURI nsIURI to construct the actual URI from
|
||||
* @return reference to a new nsIURI object
|
||||
*/
|
||||
nsIURI newURI(in string aSpec, in nsIURI aBaseURI);
|
||||
|
||||
/**
|
||||
* Creates a channel for a given URI. The notificationCallbacks argument
|
||||
* is used to obtain the appropriate callbacks for the URI's protocol from the
|
||||
* application.
|
||||
*
|
||||
* @param originalURI - Specifies the original URI which caused the creation
|
||||
* of this channel. This can occur when the construction of one channel
|
||||
* (e.g. for resource:) causes another channel to be created on its behalf
|
||||
* (e.g. a file: channel), or if a redirect occurs, causing the current
|
||||
* URL to become different from the original URL. If NULL, the aURI parameter
|
||||
* will be used as the originalURI instead.
|
||||
*
|
||||
* @param aURI - nsIURI to make a channel from
|
||||
* @return a reference to the new nsIChannel object
|
||||
*/
|
||||
nsIChannel newChannelFromURI(in nsIURI aURI);
|
||||
|
||||
/**
|
||||
* Convenience routine that first creates a URI by calling NewURI, and
|
||||
* then passes the URI to NewChannelFromURI.
|
||||
*
|
||||
* @param originalURI - Specifies the original URI which caused the creation
|
||||
* of this channel. This can occur when the construction of one channel
|
||||
* (e.g. for resource:) causes another channel to be created on its behalf
|
||||
* (e.g. a file: channel), or if a redirect occurs, causing the current
|
||||
* URL to become different from the original URL. If NULL, the aURI parameter
|
||||
* will be used as the originalURI instead.
|
||||
*
|
||||
* @param aSpec URI spec to select the appropriate protocol handler
|
||||
* @param aBaseURI a base URI to create a channel to
|
||||
* @return a reference to the new nsIChannel object
|
||||
*/
|
||||
nsIChannel newChannel(in string aSpec, in nsIURI aBaseURI);
|
||||
|
||||
/**
|
||||
* Returns true if networking is in "offline" mode. When in offline mode, attempts
|
||||
* to access the network will fail (although this is not necessarily corrolated with
|
||||
* whether there is actually a network available -- that's hard to detect without
|
||||
* causing the dialer to come up).
|
||||
*/
|
||||
attribute boolean offline;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// URL parsing utilities
|
||||
|
||||
/**
|
||||
* Utility for protocol implementors -- extracts the scheme from a URL
|
||||
* string, consistently and according to spec.
|
||||
* @param urlString - the URL string to parse
|
||||
* @param schemeStartPos - the resulting starting position of the scheme substring
|
||||
* (may skip over whitespace)
|
||||
* @param schemeEndPos - the resulting ending position of the scheme substring
|
||||
* (the position of the colon)
|
||||
* @param scheme - an allocated substring containing the scheme. If this parameter
|
||||
* is null going into the routine, then the scheme is not allocated and
|
||||
* returned. Free with nsCRT::free.
|
||||
*
|
||||
* @return NS_OK - if successful
|
||||
* @return NS_ERROR_MALFORMED_URI - if the urlString is not of the right form
|
||||
*/
|
||||
void extractScheme(in string urlString,
|
||||
out unsigned long schemeStartPos,
|
||||
out unsigned long schemeEndPos,
|
||||
out string scheme);
|
||||
|
||||
/**
|
||||
* Constants for the mask in the call to Escape
|
||||
*/
|
||||
const short url_Scheme = (1<<0);
|
||||
const short url_Username = (1<<1);
|
||||
const short url_Password = (1<<2);
|
||||
const short url_Host = (1<<3);
|
||||
const short url_Directory = (1<<4);
|
||||
const short url_FileBaseName = (1<<5);
|
||||
const short url_FileExtension = (1<<6);
|
||||
const short url_Param = (1<<7);
|
||||
const short url_Query = (1<<8);
|
||||
const short url_Ref = (1<<9);
|
||||
const short url_Forced = (1<<10);
|
||||
|
||||
/**
|
||||
* Encode characters into % escaped hexcodes.
|
||||
*
|
||||
* @param str a string to convert from
|
||||
* @param mask a mask of flags to tell the converter which part of the url to escape
|
||||
* @return escaped string
|
||||
*/
|
||||
string escape(in string str, in short mask);
|
||||
|
||||
/**
|
||||
* Decode % escaped hex codes into character values.
|
||||
*
|
||||
* @param str a string to unescape from
|
||||
* @return resulted unescaped string
|
||||
*/
|
||||
string unescape(in string str);
|
||||
|
||||
/**
|
||||
* Get port from string.
|
||||
*
|
||||
* @param str URI-style string
|
||||
* @return port number
|
||||
*/
|
||||
long extractPort(in string str);
|
||||
|
||||
/**
|
||||
* Resolves a relative path string containing "." and ".."
|
||||
* with respect to a base path (assumed to already be resolved).
|
||||
* For example, resolving "../../foo/./bar/../baz.html" w.r.t.
|
||||
* "/a/b/c/d/e/" yields "/a/b/c/foo/baz.html". Attempting to
|
||||
* ascend above the base results in the NS_ERROR_MALFORMED_URI
|
||||
* exception. If basePath is null, it treats it as "/".
|
||||
*
|
||||
* @param relativePath a relative URI
|
||||
* @param basePath a base URI
|
||||
* @return a new string, representing canonical uri
|
||||
*/
|
||||
string resolveRelativePath(in string relativePath,
|
||||
in string basePath);
|
||||
};
|
||||
82
mozilla/netwerk/base/public/nsILoadGroup.idl
Normal file
82
mozilla/netwerk/base/public/nsILoadGroup.idl
Normal file
@@ -0,0 +1,82 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIRequest.idl"
|
||||
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsIRequestObserver;
|
||||
interface nsIInterfaceRequestor;
|
||||
|
||||
/**
|
||||
* A load group maintains a collection of active URL requests.
|
||||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
[scriptable, uuid(19845248-29ab-11d3-8cce-0060b0fc14a3)]
|
||||
interface nsILoadGroup : nsIRequest
|
||||
{
|
||||
/**
|
||||
* The group observer is notified when requests are added to and removed
|
||||
* from this load group. The groupObserver is weak referenced.
|
||||
*/
|
||||
attribute nsIRequestObserver groupObserver;
|
||||
|
||||
/**
|
||||
* Accesses the default load request for the group. Each time a number
|
||||
* of requests are added to a group, the defaultLoadRequest may be set
|
||||
* to indicate that all of the requests are related to a base request.
|
||||
*/
|
||||
attribute nsIRequest defaultLoadRequest;
|
||||
|
||||
/**
|
||||
* Adds a new request to the group. This will cause the default load
|
||||
* attributes to be applied to the request. If this is a foreground
|
||||
* request then the groupObserver's onStartRequest will be called.
|
||||
*/
|
||||
void addRequest(in nsIRequest request,
|
||||
in nsISupports ctxt);
|
||||
|
||||
/**
|
||||
* Removes a request from the group. If this is a foreground request
|
||||
* then the groupObserver's onStopRequest will be called.
|
||||
*/
|
||||
void removeRequest(in nsIRequest request,
|
||||
in nsISupports ctxt,
|
||||
in nsresult status);
|
||||
|
||||
/**
|
||||
* Returns the requests contained directly in this group.
|
||||
* Enumerator element type: nsIRequest.
|
||||
*/
|
||||
readonly attribute nsISimpleEnumerator requests;
|
||||
|
||||
/**
|
||||
* Returns the count of "active" requests (ie. requests without the
|
||||
* LOAD_BACKGROUND bit set).
|
||||
*/
|
||||
readonly attribute unsigned long activeCount;
|
||||
|
||||
/**
|
||||
* Notification callbacks for the load group.
|
||||
*/
|
||||
attribute nsIInterfaceRequestor notificationCallbacks;
|
||||
};
|
||||
47
mozilla/netwerk/base/public/nsINetModRegEntry.idl
Normal file
47
mozilla/netwerk/base/public/nsINetModRegEntry.idl
Normal file
@@ -0,0 +1,47 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/* This interface defines a registry entry for the networking libraries
|
||||
* external module registry. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsINetNotify.idl"
|
||||
|
||||
interface nsIEventQueue;
|
||||
interface nsINetModRegEntry;
|
||||
interface nsINetNotify;
|
||||
|
||||
%{ C++
|
||||
// {F126BD90-1472-11d3-A15A-0050041CAF44}
|
||||
#define NS_NETMODREGENTRY_CID \
|
||||
{ 0xf126bd90, 0x1472, 0x11d3, { 0xa1, 0x5a, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } }
|
||||
%}
|
||||
|
||||
[scriptable, uuid(9F482BD0-1476-11d3-A15A-0050041CAF44)]
|
||||
interface nsINetModRegEntry : nsISupports
|
||||
{
|
||||
readonly attribute nsINetNotify syncProxy;
|
||||
readonly attribute nsINetNotify asyncProxy;
|
||||
readonly attribute string topic;
|
||||
|
||||
boolean equals(in nsINetModRegEntry aEntry);
|
||||
};
|
||||
80
mozilla/netwerk/base/public/nsINetModuleMgr.idl
Normal file
80
mozilla/netwerk/base/public/nsINetModuleMgr.idl
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/* The nsINetModuleMgr singleton service allows external module to register
|
||||
* themselves with the networking library to receive events they want to
|
||||
* receive.
|
||||
*
|
||||
* An external module that is interested in being notified when a particular
|
||||
* networking level event occurs would register with this service, and
|
||||
* implement the appropriate interface(s) that correspond to the events they
|
||||
* want to receive. These interfaces are defined by networking internal
|
||||
* components (for example, http would define a notification interface that
|
||||
* the external cookies module would implement).
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIEnumerator.idl"
|
||||
#include "nsINetNotify.idl"
|
||||
|
||||
interface nsIEventQueue;
|
||||
|
||||
%{ C++
|
||||
|
||||
// {4EBDAFE0-13BA-11d3-A15A-0050041CAF44}
|
||||
#define NS_NETMODULEMGR_CID \
|
||||
{ 0x4ebdafe0, 0x13ba, 0x11d3, { 0xa1, 0x5a, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } }
|
||||
|
||||
// The list of available CONTRACTIDS to register for notification on.
|
||||
#define NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_CONTRACTID "@mozilla.org/network/moduleMgr/http/request;1"
|
||||
#define NS_NETWORK_MODULE_MANAGER_HTTP_RESPONSE_CONTRACTID "@mozilla.org/network/moduleMgr/http/response;1"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(ff9ead40-0ef2-11d3-9de6-0010a4053fd0)]
|
||||
interface nsINetModuleMgr : nsISupports {
|
||||
|
||||
// Register the external module to receive notifications.
|
||||
//
|
||||
// ARGUMENTS:
|
||||
// aTopic: The internal component that the external module wants to monitor.
|
||||
// aNotify: The external module interface methods to be called when an event is fired.
|
||||
//
|
||||
// RETURNS: nsresult
|
||||
void registerModule(in string aTopic, in nsINetNotify aNotify);
|
||||
|
||||
// Unregister the external module. Removes the nsINetModuleMgr binding between
|
||||
// internal component and external module.
|
||||
//
|
||||
// ARGUMENTS:
|
||||
// aTopic: The internal component being monitored.
|
||||
// aNotify: The external modules notification module.
|
||||
//
|
||||
// RETURNS: nsresult
|
||||
void unregisterModule(in string aTopic, in nsINetNotify aNotify);
|
||||
|
||||
// Enumerates all the registered modules for the specified topic.
|
||||
//
|
||||
// ARGUMENTS:
|
||||
// aTopic: the component to get all the notifiers for.
|
||||
// aEnumerator: the array of notifiers.
|
||||
void enumerateModules(in string aTopic, out nsISimpleEnumerator aEnumerator);
|
||||
};
|
||||
28
mozilla/netwerk/base/public/nsINetNotify.idl
Normal file
28
mozilla/netwerk/base/public/nsINetNotify.idl
Normal file
@@ -0,0 +1,28 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[uuid(4A3019E0-1CF3-11d3-A15B-0050041CAF44)]
|
||||
interface nsINetNotify : nsISupports {
|
||||
|
||||
};
|
||||
38
mozilla/netwerk/base/public/nsIPasswordManager.idl
Normal file
38
mozilla/netwerk/base/public/nsIPasswordManager.idl
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Zero-Knowledge
|
||||
* Systems, Inc. Portions created by Zero-Knowledge are Copyright
|
||||
* (C) 2000 Zero-Knowledge Systems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* Interface for password management (aka single-signon) componentry.
|
||||
*/
|
||||
|
||||
/* XXXshaver these came from the old wallet interfaces, and seem questionable */
|
||||
native nsAutoString(nsAutoString);
|
||||
[ref] native nsAutoStringRef(nsAutoString);
|
||||
|
||||
[scriptable, uuid(110c808c-1dd2-11b2-8de5-814d4485c444)]
|
||||
interface nsIPasswordManager : nsISupports {
|
||||
void removeUser(in string key, in wstring user);
|
||||
void storePassword(in string key, in wstring user, in wstring pass);
|
||||
[noscript] void getSignonListForViewer(in nsAutoStringRef aSignonList);
|
||||
[noscript] void getRejectListForViewer(in nsAutoStringRef aRejectList);
|
||||
};
|
||||
30
mozilla/netwerk/base/public/nsIPasswordManagerUtils.h
Normal file
30
mozilla/netwerk/base/public/nsIPasswordManagerUtils.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Zero-Knowledge
|
||||
* Systems, Inc. Portions created by Zero-Knowledge are Copyright
|
||||
* (C) 2000 Zero-Knowledge Systems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef NSIPASSWORDMANAGERUTILS_H__
|
||||
#define NSIPASSWORDMANAGERUTILS_H__
|
||||
|
||||
#include "nsIPasswordManager.h"
|
||||
|
||||
/* XXX love me, rayw, love me true */
|
||||
#define PASSWORDMANAGER_CONTRACTID "@mozilla.org/network/password-manager;1"
|
||||
|
||||
#endif /* NSIPASSWORDMANAGERUTILS_H__ */
|
||||
60
mozilla/netwerk/base/public/nsIProgressEventSink.idl
Normal file
60
mozilla/netwerk/base/public/nsIProgressEventSink.idl
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIRequest;
|
||||
|
||||
/**
|
||||
* An instance of nsIFfpEventSink should be passed as the eventSink
|
||||
* argument of nsINetService::NewConnection for ftp URLs. It defines
|
||||
* the callbacks to the application program (the html parser).
|
||||
*/
|
||||
[scriptable, uuid(dd47ee00-18c2-11d3-9337-00104ba0fd40)]
|
||||
interface nsIProgressEventSink : nsISupports
|
||||
{
|
||||
/**
|
||||
* Notify the EventSink that progress has occurred for the URL load.<BR>
|
||||
*/
|
||||
void onProgress(in nsIRequest request,
|
||||
in nsISupports ctxt,
|
||||
in unsigned long aProgress,
|
||||
in unsigned long aProgressMax);
|
||||
|
||||
/**
|
||||
* Notify the EventSink with a status message for the URL load.<BR>
|
||||
* @param status - A status code denoting the type of notification. This
|
||||
* can be a message to be displayed (e.g. for file I/O,
|
||||
* STATUS_READ_FROM, or STATUS_WROTE_TO), or can be an event
|
||||
* to be programmatically handled.
|
||||
* @param statusArg - An argument or arguments to the status notification.
|
||||
* These arguments will be formatted into any status or error
|
||||
* message. Multiple arguments can be passed by delimiting them
|
||||
* with newline ('\n') characters.
|
||||
*/
|
||||
void onStatus(in nsIRequest request,
|
||||
in nsISupports ctxt,
|
||||
in nsresult status,
|
||||
in wstring statusArg);
|
||||
|
||||
};
|
||||
107
mozilla/netwerk/base/public/nsIPrompt.idl
Normal file
107
mozilla/netwerk/base/public/nsIPrompt.idl
Normal file
@@ -0,0 +1,107 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/**
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is the prompt interface which can be used without knowlege of a
|
||||
* parent window. The parentage is hidden by the GetInterface though
|
||||
* which it is gotten. This interface is identical to nsIPromptService
|
||||
* but without the parent nsIDOMWindow parameter. See nsIPromptService
|
||||
* for all documentation.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(a63f70c0-148b-11d3-9333-00104ba0fd40)]
|
||||
interface nsIPrompt : nsISupports
|
||||
{
|
||||
void alert(in wstring dialogTitle,
|
||||
in wstring text);
|
||||
|
||||
void alertCheck(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue);
|
||||
|
||||
boolean confirm(in wstring dialogTitle,
|
||||
in wstring text);
|
||||
|
||||
boolean confirmCheck(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue);
|
||||
|
||||
const unsigned long BUTTON_POS_0 = 1;
|
||||
const unsigned long BUTTON_POS_1 = 1 << 8;
|
||||
const unsigned long BUTTON_POS_2 = 1 << 16;
|
||||
|
||||
const unsigned long BUTTON_TITLE_OK = 1;
|
||||
const unsigned long BUTTON_TITLE_CANCEL = 2;
|
||||
const unsigned long BUTTON_TITLE_YES = 3;
|
||||
const unsigned long BUTTON_TITLE_NO = 4;
|
||||
const unsigned long BUTTON_TITLE_SAVE = 5;
|
||||
const unsigned long BUTTON_TITLE_DONT_SAVE = 6;
|
||||
const unsigned long BUTTON_TITLE_REVERT = 7;
|
||||
|
||||
const unsigned long BUTTON_TITLE_IS_STRING = 127;
|
||||
|
||||
const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) +
|
||||
(BUTTON_TITLE_CANCEL * BUTTON_POS_1);
|
||||
|
||||
void confirmEx(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in unsigned long buttonFlags,
|
||||
in wstring button0Title,
|
||||
in wstring button1Title,
|
||||
in wstring button2Title,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue,
|
||||
out PRInt32 buttonPressed);
|
||||
|
||||
boolean prompt(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
inout wstring value,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue);
|
||||
|
||||
boolean promptPassword(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
inout wstring password,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue);
|
||||
|
||||
boolean promptUsernameAndPassword(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
inout wstring username,
|
||||
inout wstring password,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue);
|
||||
|
||||
boolean select(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in PRUint32 count,
|
||||
[array, size_is(count)] in wstring selectList,
|
||||
out long outSelection);
|
||||
};
|
||||
71
mozilla/netwerk/base/public/nsIProtocolHandler.idl
Normal file
71
mozilla/netwerk/base/public/nsIProtocolHandler.idl
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIChannel.idl"
|
||||
|
||||
interface nsIURI;
|
||||
|
||||
[scriptable, uuid(15fd6940-8ea7-11d3-93ad-00104ba0fd40)]
|
||||
interface nsIProtocolHandler : nsISupports
|
||||
{
|
||||
readonly attribute string scheme;
|
||||
|
||||
/**
|
||||
* Default Port will be the port that this protocol normally
|
||||
* uses. If a port does not make sense for the protocol (eg about://)
|
||||
* -1 will be returned.
|
||||
*/
|
||||
|
||||
readonly attribute long defaultPort;
|
||||
|
||||
/**
|
||||
* Makes a URI object that is suitable for loading by this protocol.
|
||||
* In the usual case (when only the accessors provided by nsIURI are
|
||||
* needed), this method just constructs a standard URI using the
|
||||
* component manager with kStandardURLCID. aBaseURI may be nsnull.
|
||||
*/
|
||||
nsIURI newURI(in string aSpec, in nsIURI aBaseURI);
|
||||
|
||||
/**
|
||||
* Constructs a new channel for this protocol handler.
|
||||
*
|
||||
* @param originalURI - Specifies the original URI which caused the creation
|
||||
* of this channel. This can occur when the construction of one channel
|
||||
* (e.g. for resource:) causes another channel to be created on its behalf
|
||||
* (e.g. a file: channel), or if a redirect occurs, causing the current
|
||||
* URL to become different from the original URL. If NULL, the aURI parameter
|
||||
* will be used as the originalURI instead.
|
||||
*/
|
||||
nsIChannel newChannel(in nsIURI aURI);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
#define NS_NETWORK_PROTOCOL_CONTRACTID "@mozilla.org/network/protocol;1"
|
||||
#define NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX NS_NETWORK_PROTOCOL_CONTRACTID "?name="
|
||||
#define NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX_LENGTH 37 // nsCRT::strlen(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX)
|
||||
|
||||
// Unknown Protocol Error
|
||||
#define NS_ERROR_UNKNOWN_PROTOCOL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 18)
|
||||
|
||||
%}
|
||||
47
mozilla/netwerk/base/public/nsIProtocolProxyService.idl
Normal file
47
mozilla/netwerk/base/public/nsIProtocolProxyService.idl
Normal file
@@ -0,0 +1,47 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIURI.idl"
|
||||
|
||||
%{C++
|
||||
#define NS_PROTOCOLPROXYSERVICE_CID \
|
||||
{ /* E9B301C0-E0E4-11d3-A1A8-0050041CAF44 */ \
|
||||
0xe9b301c0, 0xe0e4, 0x11d3, { 0xa1, 0xa8, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } }
|
||||
%}
|
||||
|
||||
[scriptable, uuid(495CC980-E0D4-11d3-A1A8-0050041CAF44)]
|
||||
interface nsIProtocolProxyService : nsISupports
|
||||
{
|
||||
readonly attribute PRBool proxyEnabled;
|
||||
|
||||
void examineForProxy(in nsIURI aURI, out string host, out long port, out string type);
|
||||
|
||||
/**
|
||||
* Add additional items in the "No proxy for" list. This is above
|
||||
* the list specified the user-pref.
|
||||
*/
|
||||
void addNoProxyFor(in string host, in long port);
|
||||
void removeNoProxyFor(in string host, in long port);
|
||||
|
||||
};
|
||||
|
||||
39
mozilla/netwerk/base/public/nsIProxy.idl
Normal file
39
mozilla/netwerk/base/public/nsIProxy.idl
Normal file
@@ -0,0 +1,39 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/*
|
||||
The nsIProxy interface allows setting and getting of proxy host and port.
|
||||
This is for use by protocol handlers. If you are writing a protocol handler
|
||||
and would like to support proxy behaviour then derive from this as well as
|
||||
the nsIProtocolHandler class.
|
||||
|
||||
-Gagan Saksena 02/25/99
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(0492D011-CD2F-11d2-B013-006097BFC036)]
|
||||
interface nsIProxy : nsISupports
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
64
mozilla/netwerk/base/public/nsIProxyAutoConfig.idl
Normal file
64
mozilla/netwerk/base/public/nsIProxyAutoConfig.idl
Normal file
@@ -0,0 +1,64 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/**
|
||||
The nsIProxyAutoConfig interface is used for setting arbitrary proxy
|
||||
configurations based on the specified URL.
|
||||
|
||||
Note this interface wraps (at least in a the implementation) the older
|
||||
hacks of proxy auto config.
|
||||
|
||||
- Gagan Saksena 04/23/00
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIIOService;
|
||||
|
||||
[scriptable, uuid(26fae72a-1dd2-11b2-9dd9-cb3e0c2c79ba)]
|
||||
interface nsIProxyAutoConfig : nsISupports
|
||||
{
|
||||
/**
|
||||
* Get the proxy for the specified host
|
||||
*/
|
||||
void ProxyForURL(in nsIURI uri, out string host, out long port, out string type);
|
||||
|
||||
/**
|
||||
* Load the PAC file from the specified URI
|
||||
*/
|
||||
void LoadPACFromURL(in nsIURI uri, in nsIIOService ioService);
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_PROXY_AUTO_CONFIG_CID \
|
||||
{ /* 63ac8c66-1dd2-11b2-b070-84d00d3eaece */ \
|
||||
0x63ac8c66, \
|
||||
0x1dd2, \
|
||||
0x11b2, \
|
||||
{0xb0, 0x70, 0x84, 0xd0, 0x0d, 0x3e, 0xae, 0xce} \
|
||||
}
|
||||
|
||||
#define NS_PROXY_AUTO_CONFIG_CONTRACTID \
|
||||
"@mozilla.org/network/proxy_autoconfig;1"
|
||||
|
||||
%}
|
||||
59
mozilla/netwerk/base/public/nsIProxyAutoConfigUtils.idl
Normal file
59
mozilla/netwerk/base/public/nsIProxyAutoConfigUtils.idl
Normal file
@@ -0,0 +1,59 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/**
|
||||
* The nsIProxyAutoConfigUtils interface is used for the proxy auto config
|
||||
* utility functions like isPlainHostName, dnsDomainIs, etc.
|
||||
*
|
||||
* This interface wraps the older hacks of proxy auto config utility
|
||||
* functions. Most of the string comparisons are now deprecated.
|
||||
*
|
||||
* For more information look at-
|
||||
* TODO - put the correct URL here...!
|
||||
* http://www.mozilla.org/docs/netlib/pac.html
|
||||
*
|
||||
* - Gagan Saksena 04/23/00
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(fe3896e8-1dd1-11b2-821f-83b84e1466f6)]
|
||||
interface nsIProxyAutoConfigUtils : nsISupports
|
||||
{
|
||||
/**
|
||||
* Hostname based conditions.
|
||||
*/
|
||||
void isResolvable(in string host,
|
||||
out PRBool result);
|
||||
void isInNet(in string host,
|
||||
in string pattern,
|
||||
in string mask,
|
||||
out PRBool result);
|
||||
|
||||
/**
|
||||
* Utility functions.
|
||||
*/
|
||||
void DNSResolve(in string host,
|
||||
out string ipaddress);
|
||||
void myIPAddress(out string ipaddress);
|
||||
|
||||
};
|
||||
167
mozilla/netwerk/base/public/nsIRequest.idl
Normal file
167
mozilla/netwerk/base/public/nsIRequest.idl
Normal file
@@ -0,0 +1,167 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsILoadGroup;
|
||||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
/**
|
||||
* nsIRequest
|
||||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
[scriptable, uuid(F2CAABA0-2F25-11d3-A164-0050041CAF44)]
|
||||
interface nsIRequest : nsISupports
|
||||
{
|
||||
/**
|
||||
* Returns the name of the request. Often this is the URL of the request.
|
||||
*/
|
||||
readonly attribute wstring name;
|
||||
|
||||
/**
|
||||
* Returns true if the request is pending (active). Returns false
|
||||
* after completion or successful calling Cancel. Suspended requests
|
||||
* are still considered pending.
|
||||
*/
|
||||
boolean isPending();
|
||||
|
||||
/**
|
||||
* Returns any error status associated with the request.
|
||||
*/
|
||||
readonly attribute nsresult status;
|
||||
|
||||
/**
|
||||
* Cancels the current request. This will close any open input or
|
||||
* output streams and terminate any async requests. Users should
|
||||
* normally pass NS_BINDING_ABORTED, although other errors may also
|
||||
* be passed. The error passed in will become the value of the
|
||||
* status attribute.
|
||||
*/
|
||||
void cancel(in nsresult status);
|
||||
|
||||
/**
|
||||
* Suspends the current requests. This may have the effect of closing
|
||||
* any underlying transport (in order to free up resources), although
|
||||
* any open streams remain logically opened and will continue delivering
|
||||
* data when the transport is resumed.
|
||||
*/
|
||||
void suspend();
|
||||
|
||||
/**
|
||||
* Resumes the current request. This may have the effect of re-opening
|
||||
* any underlying transport and will resume the delivery of data to
|
||||
* any open streams.
|
||||
*/
|
||||
void resume();
|
||||
|
||||
/**
|
||||
* Accesses the load group in which this request is currently a member.
|
||||
*/
|
||||
attribute nsILoadGroup loadGroup;
|
||||
|
||||
/**
|
||||
* Accesses the load flags for this request. Bits 0-15 are defined (or
|
||||
* reserved) by nsIRequest. When added to a load group, this request's
|
||||
* load flags are merged with the load flags of the load group.
|
||||
*/
|
||||
attribute nsLoadFlags loadFlags;
|
||||
|
||||
/**************************************************************************
|
||||
* Listed below are the various load flags which may be or'd together.
|
||||
*/
|
||||
|
||||
/**
|
||||
* No special load flags:
|
||||
*/
|
||||
const unsigned long LOAD_NORMAL = 0;
|
||||
|
||||
/**
|
||||
* Don't deliver status notifications to the nsIProgressEventSink, or keep
|
||||
* this load from completing the nsILoadGroup it may belong to.
|
||||
*/
|
||||
const unsigned long LOAD_BACKGROUND = 1 << 0;
|
||||
|
||||
/**************************************************************************
|
||||
* The following flags control the flow of data into the cache.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This flag prevents caching of any kind. It does not, however, prevent
|
||||
* cached content from being used to satisfy this request.
|
||||
*/
|
||||
const unsigned long INHIBIT_CACHING = 1 << 7;
|
||||
|
||||
/**
|
||||
* This flag prevents caching on disk (or other persistent media), which
|
||||
* may be needed to preserve privacy. For HTTPS, this flag is set auto-
|
||||
* matically.
|
||||
*/
|
||||
const unsigned long INHIBIT_PERSISTENT_CACHING = 1 << 8;
|
||||
|
||||
/**************************************************************************
|
||||
* The following flags control what happens when the cache contains data
|
||||
* that could perhaps satisfy this request. They are listed in descending
|
||||
* order of precidence.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Force an end-to-end download of content data from the origin server.
|
||||
* This flag is used for a shift-reload.
|
||||
*/
|
||||
const unsigned long LOAD_BYPASS_CACHE = 1 << 9;
|
||||
|
||||
/**
|
||||
* Load from the cache, bypassing protocol specific validation logic. This
|
||||
* flag is used when browsing via history. It is not recommended for normal
|
||||
* browsing as it may likely violate reasonable assumptions made by the
|
||||
* server and confuse users.
|
||||
*/
|
||||
const unsigned long LOAD_FROM_CACHE = 1 << 10;
|
||||
|
||||
/**
|
||||
* The following flags control the frequency of cached content validation
|
||||
* when neither LOAD_BYPASS_CACHE or LOAD_FROM_CACHE are set. By default,
|
||||
* cached content is automatically validated if necessary before reuse.
|
||||
*
|
||||
* VALIDATE_ALWAYS forces validation of any cached content independent of
|
||||
* its expiration time.
|
||||
*
|
||||
* VALIDATE_NEVER disables validation of expired content.
|
||||
*
|
||||
* VALIDATE_ONCE_PER_SESSION disables validation of expired content,
|
||||
* provided it has already been validated (at least once) since the start
|
||||
* of this session.
|
||||
*
|
||||
* NOTE TO IMPLEMENTORS:
|
||||
* These flags are intended for normal browsing, and they should therefore
|
||||
* not apply to content that must be validated before each use. Consider,
|
||||
* for example, a HTTP response with a "Cache-control: no-cache" header.
|
||||
* According to RFC2616, this response must be validated before it can
|
||||
* be taken from a cache. Breaking this requirement could result in
|
||||
* incorrect and potentially unpleasant side-effects.
|
||||
*/
|
||||
const unsigned long VALIDATE_ALWAYS = 1 << 11;
|
||||
const unsigned long VALIDATE_NEVER = 1 << 12;
|
||||
const unsigned long VALIDATE_ONCE_PER_SESSION = 1 << 13;
|
||||
};
|
||||
73
mozilla/netwerk/base/public/nsIRequestObserver.idl
Normal file
73
mozilla/netwerk/base/public/nsIRequestObserver.idl
Normal file
@@ -0,0 +1,73 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIRequest;
|
||||
|
||||
/**
|
||||
* nsIRequestObserver
|
||||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
[scriptable, uuid(fd91e2e0-1481-11d3-9333-00104ba0fd40)]
|
||||
interface nsIRequestObserver : nsISupports
|
||||
{
|
||||
/**
|
||||
* Called to signify the beginning of an asynchronous request.
|
||||
*
|
||||
* @param request - request being observed
|
||||
* @param ctxt - user defined context
|
||||
*
|
||||
* A failure code returned from onStartRequest has the side-effect of
|
||||
* causing the request to be canceled.
|
||||
*/
|
||||
void onStartRequest(in nsIRequest request,
|
||||
in nsISupports ctxt);
|
||||
|
||||
/**
|
||||
* Called to signify the end of an asynchronous request. This
|
||||
* call is always preceded by a call to onStartRequest.
|
||||
*
|
||||
* @param request - request being observed
|
||||
* @param ctxt - user defined context
|
||||
* @param statusCode - reason for stopping (NS_OK if completed successfully)
|
||||
*
|
||||
* A failure code returned from onStopRequest is generally ignored.
|
||||
*/
|
||||
void onStopRequest(in nsIRequest request,
|
||||
in nsISupports ctxt,
|
||||
in nsresult statusCode);
|
||||
};
|
||||
|
||||
%{C++
|
||||
// Generic status codes for OnStopRequest:
|
||||
#define NS_BINDING_SUCCEEDED NS_OK
|
||||
#define NS_BINDING_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 1)
|
||||
#define NS_BINDING_ABORTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 2)
|
||||
|
||||
// The binding has been moved to another request in the same load group:
|
||||
#define NS_BINDING_REDIRECTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 3)
|
||||
|
||||
// The binding has been moved to another request in a different load group:
|
||||
#define NS_BINDING_RETARGETED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 4)
|
||||
%}
|
||||
47
mozilla/netwerk/base/public/nsIRequestObserverProxy.idl
Normal file
47
mozilla/netwerk/base/public/nsIRequestObserverProxy.idl
Normal file
@@ -0,0 +1,47 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@netscape.com> (original author)
|
||||
*/
|
||||
|
||||
#include "nsIRequestObserver.idl"
|
||||
|
||||
interface nsIEventQueue;
|
||||
|
||||
/**
|
||||
* A request observer proxy is used to ship data over to another thread specified
|
||||
* by the thread's event queue. The "true" request observer's methods are
|
||||
* invoked on the other thread.
|
||||
*
|
||||
* This interface only provides the initialization needed after construction. Otherwise,
|
||||
* these objects are used simply as nsIRequestObserver's.
|
||||
*/
|
||||
[scriptable, uuid(3c9b532e-db84-4ecf-aa6a-4d38a9c4c5f0)]
|
||||
interface nsIRequestObserverProxy : nsIRequestObserver
|
||||
{
|
||||
/**
|
||||
* Initializes an nsIRequestObserverProxy.
|
||||
*
|
||||
* @param observer - receives observer notifications on the other thread
|
||||
* @param eventQ - may be NULL indicating the calling thread's event queue
|
||||
*/
|
||||
void init(in nsIRequestObserver observer,
|
||||
in nsIEventQueue eventQ);
|
||||
};
|
||||
66
mozilla/netwerk/base/public/nsISecretDecoderRing.idl
Normal file
66
mozilla/netwerk/base/public/nsISecretDecoderRing.idl
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* thayes@netscape.com
|
||||
* bryner@netscape.com
|
||||
*
|
||||
* This is a generic security interface to encrypt and decrypt buffers.
|
||||
* Specific security extensions will need to implement this.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/* Buffer type - for storing 8-bit octet values */
|
||||
[ptr] native buffer(unsigned char);
|
||||
|
||||
[scriptable, uuid(0EC80360-075C-11d4-9FD4-00C04F1B83D8)]
|
||||
interface nsISecretDecoderRing: nsISupports {
|
||||
|
||||
/* Encrypt a buffer - callable only from C++ */
|
||||
[noscript] long encrypt(in buffer data, in long dataLen, out buffer result);
|
||||
|
||||
/* Decrypt a buffer - callable only from C++ */
|
||||
[noscript] long decrypt(in buffer data, in long dataLen, out buffer result);
|
||||
|
||||
/* Encrypt nul-terminated string to BASE64 output */
|
||||
string encryptString(in string text);
|
||||
|
||||
/* Decrypt BASE64 input to nul-terminated string output */
|
||||
/* There is no check for embedded nul values in the decrypted output */
|
||||
string decryptString(in string crypt);
|
||||
|
||||
/* Prompt the user to change the password on the SDR key */
|
||||
void changePassword();
|
||||
|
||||
/* Logout of the security device that protects the SDR key */
|
||||
void logout();
|
||||
};
|
||||
|
||||
/*
|
||||
* Configuration interface for the Secret Decoder Ring
|
||||
* - this interface allows setting the window that will be
|
||||
* used as parent for dialog windows (such as password prompts)
|
||||
*/
|
||||
[scriptable, uuid(01D8C0F0-0CCC-11d4-9FDD-000064657374)]
|
||||
interface nsISecretDecoderRingConfig: nsISupports {
|
||||
void setWindow(in nsISupports w);
|
||||
};
|
||||
|
||||
|
||||
40
mozilla/netwerk/base/public/nsISecureBrowserUI.idl
Normal file
40
mozilla/netwerk/base/public/nsISecureBrowserUI.idl
Normal file
@@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Hubbie Shaw
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMWindow;
|
||||
interface nsIDOMElement;
|
||||
|
||||
[scriptable, uuid(081e31e0-a144-11d3-8c7c-00609792278c)]
|
||||
interface nsISecureBrowserUI : nsISupports
|
||||
{
|
||||
void init(in nsIDOMWindow window, in nsIDOMElement button);
|
||||
void displayPageInfoUI();
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_SECURE_BROWSER_UI_CONTRACTID "@mozilla.org/secure_browser_ui;1"
|
||||
#define NS_SECURE_BROWSER_UI_CLASSNAME "Mozilla Secure Browser UI Handler"
|
||||
%}
|
||||
43
mozilla/netwerk/base/public/nsISecurityEventSink.idl
Normal file
43
mozilla/netwerk/base/public/nsISecurityEventSink.idl
Normal file
@@ -0,0 +1,43 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
interface nsIURI;
|
||||
|
||||
[scriptable, uuid(a71aee68-dd38-4736-bd79-035fea1a1ec6)]
|
||||
interface nsISecurityEventSink : nsISupports
|
||||
{
|
||||
|
||||
/**
|
||||
* Fired when a security change occurs due to page transitions,
|
||||
* or end document load. This interface should be called by
|
||||
* a security package (eg Netscape Personal Security Manager)
|
||||
* to notify nwIWebProgressListeners that security state has
|
||||
* changed. State flags are in nsIWebProgressListener.idl
|
||||
*/
|
||||
|
||||
void onSecurityChange(in nsISupports i_Context, in long state);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
46
mozilla/netwerk/base/public/nsISecurityManagerComponent.idl
Normal file
46
mozilla/netwerk/base/public/nsISecurityManagerComponent.idl
Normal file
@@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Hubbie Shaw
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
* Mitch Stoltz <mstoltz@netscape.com>
|
||||
* Brian Ryner <bryner@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(3ef604be-1dd2-11b2-92cc-faae57e1901a)]
|
||||
interface nsISecurityManagerComponent : nsISupports
|
||||
{
|
||||
|
||||
/**
|
||||
* Display the Security Advisor.
|
||||
*/
|
||||
|
||||
string GetPassword();
|
||||
void displaySecurityAdvisor();
|
||||
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define PSM_COMPONENT_CONTRACTID "@mozilla.org/psm;1"
|
||||
#define PSM_COMPONENT_CLASSNAME "Mozilla PSM Component"
|
||||
%}
|
||||
|
||||
73
mozilla/netwerk/base/public/nsISocketTransport.idl
Normal file
73
mozilla/netwerk/base/public/nsISocketTransport.idl
Normal file
@@ -0,0 +1,73 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsITransport.idl"
|
||||
|
||||
[scriptable, uuid(785CA0F0-C39E-11d3-9ED6-0010A4053FD0)]
|
||||
interface nsISocketTransport : nsITransport
|
||||
{
|
||||
readonly attribute string host;
|
||||
readonly attribute long port;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
attribute boolean reuseConnection;
|
||||
|
||||
/**
|
||||
* socket read/write timeout in seconds; 0 = no timeout
|
||||
*/
|
||||
attribute unsigned long socketTimeout;
|
||||
|
||||
/**
|
||||
* socket connect timeout in seconds; 0 = no timeout
|
||||
*/
|
||||
attribute unsigned long socketConnectTimeout;
|
||||
|
||||
/**
|
||||
* Is used to tell the channel to stop reading data after a certain point;
|
||||
* needed by HTTP/1.1
|
||||
*/
|
||||
attribute long bytesExpected;
|
||||
attribute unsigned long reuseCount;
|
||||
|
||||
/**
|
||||
* Checks if the socket is still alive
|
||||
*
|
||||
* @param seconds amount of time after which the socket is always deemed to be
|
||||
* dead (no further checking is done in this case); seconds = 0
|
||||
* will cause it not to do the timeout checking at all
|
||||
*/
|
||||
boolean isAlive (in unsigned long seconds);
|
||||
|
||||
/**
|
||||
* maximum amount of time in seconds the transport is allowed to stay alive
|
||||
* while connected (0 - default; no maximum idle timeout)
|
||||
*/
|
||||
attribute unsigned long idleTimeout;
|
||||
|
||||
/**
|
||||
* the string representation of the underlying ip address. Caller
|
||||
* is responsible for de-allocating the returned string.
|
||||
*/
|
||||
[noscript] string GetIPStr(in unsigned long aStrLen);
|
||||
};
|
||||
112
mozilla/netwerk/base/public/nsISocketTransportService.idl
Normal file
112
mozilla/netwerk/base/public/nsISocketTransportService.idl
Normal file
@@ -0,0 +1,112 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsITransport;
|
||||
interface nsIEventSinkGetter;
|
||||
interface nsIChannel;
|
||||
|
||||
[scriptable, uuid(05331390-6884-11d3-9382-00104ba0fd40)]
|
||||
interface nsISocketTransportService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Creates a transport for a specified host and port.
|
||||
* The eventSinkGetter is used to get the appropriate callbacks
|
||||
* for the socket activity from the application. These include
|
||||
* the progress and the status messages like "Contacting host.."
|
||||
* etc. The printHost contains the actual hostname (and not the
|
||||
* proxy) for displaying in status messages.
|
||||
*/
|
||||
nsITransport createTransport(in string host,
|
||||
in long port,
|
||||
in string proxyHost,
|
||||
in long proxyPort,
|
||||
in unsigned long bufferSegmentSize,
|
||||
in unsigned long bufferMaxSize);
|
||||
|
||||
nsITransport createTransportOfType(in string socketType,
|
||||
in string host,
|
||||
in long port,
|
||||
in string proxyHost,
|
||||
in long proxyPort,
|
||||
in unsigned long bufferSegmentSize,
|
||||
in unsigned long bufferMaxSize);
|
||||
|
||||
nsITransport createTransportOfTypes(in unsigned long typeCount,
|
||||
[array, size_is(typeCount)] in string socketTypes,
|
||||
in string host,
|
||||
in long port,
|
||||
in string proxyHost,
|
||||
in long proxyPort,
|
||||
in unsigned long bufferSegmentSize,
|
||||
in unsigned long bufferMaxSize);
|
||||
|
||||
/**
|
||||
* Returns true if the specified transport is good enough for
|
||||
* being used again. The situations in which this may return false
|
||||
* include- an error including server resets, an explicit
|
||||
* Connection: close header (for HTTP) and timeouts!
|
||||
*/
|
||||
boolean reuseTransport(in nsITransport i_Transport);
|
||||
|
||||
void init ();
|
||||
void shutdown();
|
||||
void wakeup (in nsITransport i_Transport);
|
||||
|
||||
/**
|
||||
* Total number of nsSocketTransport objects currently alive
|
||||
*/
|
||||
readonly attribute unsigned long totalTransportCount;
|
||||
/**
|
||||
* A number of nsSocketTransport objects with I/O operation currently in-progress
|
||||
*/
|
||||
readonly attribute unsigned long inUseTransportCount;
|
||||
/**
|
||||
* A number of nsSocketTransport objects connected (this may include keep-alive idle connections)
|
||||
*/
|
||||
readonly attribute unsigned long connectedTransportCount;
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_SOCKETTRANSPORTSERVICE_CID \
|
||||
{ /* c07e81e0-ef12-11d2-92b6-00105a1b0d64 */ \
|
||||
0xc07e81e0, \
|
||||
0xef12, \
|
||||
0x11d2, \
|
||||
{0x92, 0xb6, 0x00, 0x10, 0x5a, 0x1b, 0x0d, 0x64} \
|
||||
}
|
||||
|
||||
#define NS_ERROR_CONNECTION_REFUSED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 13)
|
||||
|
||||
#define NS_ERROR_NET_TIMEOUT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 14)
|
||||
|
||||
/**
|
||||
* Status nsresult codes: used with nsIProgressEventSink::OnStatus
|
||||
*/
|
||||
#define NS_NET_STATUS_RESOLVING_HOST NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 3)
|
||||
#define NS_NET_STATUS_CONNECTED_TO NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 4)
|
||||
#define NS_NET_STATUS_SENDING_TO NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 5)
|
||||
#define NS_NET_STATUS_RECEIVING_FROM NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 6)
|
||||
#define NS_NET_STATUS_CONNECTING_TO NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 7)
|
||||
|
||||
%}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user