2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
1999-11-08 00:55:12 +03:00
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-11-08 00:55:12 +03:00
|
|
|
|
|
|
|
#ifndef nsJARURI_h__
|
|
|
|
#define nsJARURI_h__
|
|
|
|
|
|
|
|
#include "nsIJARURI.h"
|
2001-07-31 23:05:34 +04:00
|
|
|
#include "nsISerializable.h"
|
2004-12-02 10:00:25 +03:00
|
|
|
#include "nsIClassInfo.h"
|
1999-11-08 00:55:12 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2002-03-06 10:48:55 +03:00
|
|
|
#include "nsString.h"
|
2006-05-02 22:54:19 +04:00
|
|
|
#include "nsINestedURI.h"
|
2017-11-20 19:11:30 +03:00
|
|
|
#include "nsIURIMutator.h"
|
1999-11-08 00:55:12 +03:00
|
|
|
|
2004-05-21 03:29:52 +04:00
|
|
|
#define NS_THIS_JARURI_IMPL_CID \
|
|
|
|
{ /* 9a55f629-730b-4d08-b75b-fa7d9570a691 */ \
|
|
|
|
0x9a55f629, 0x730b, 0x4d08, { \
|
|
|
|
0xb7, 0x5b, 0xfa, 0x7d, 0x95, 0x70, 0xa6, 0x91 \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2004-12-02 10:00:25 +03:00
|
|
|
#define NS_JARURI_CID \
|
|
|
|
{ /* 245abae2-b947-4ded-a46d-9829d3cca462 */ \
|
|
|
|
0x245abae2, 0xb947, 0x4ded, { \
|
|
|
|
0xa4, 0x6d, 0x98, 0x29, 0xd3, 0xcc, 0xa4, 0x62 \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2017-11-20 19:11:30 +03:00
|
|
|
#define NS_JARURIMUTATOR_CID \
|
|
|
|
{ /* 19d9161b-a2a9-4518-b2c9-fcb8296d6dcd */ \
|
|
|
|
0x19d9161b, 0xa2a9, 0x4518, { \
|
|
|
|
0xb2, 0xc9, 0xfc, 0xb8, 0x29, 0x6d, 0x6d, 0xcd \
|
|
|
|
} \
|
|
|
|
}
|
2004-12-02 10:00:25 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsJARURI final : public nsIJARURI,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsISerializable,
|
|
|
|
public nsIClassInfo,
|
2019-01-25 16:32:36 +03:00
|
|
|
public nsINestedURI {
|
2012-08-23 23:33:46 +04:00
|
|
|
public:
|
2013-07-19 06:23:44 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
1999-11-08 00:55:12 +03:00
|
|
|
NS_DECL_NSIURI
|
2003-11-17 00:43:43 +03:00
|
|
|
NS_DECL_NSIURL
|
1999-11-08 00:55:12 +03:00
|
|
|
NS_DECL_NSIJARURI
|
2001-07-31 23:05:34 +04:00
|
|
|
NS_DECL_NSISERIALIZABLE
|
2004-12-02 10:00:25 +03:00
|
|
|
NS_DECL_NSICLASSINFO
|
2006-05-02 22:54:19 +04:00
|
|
|
NS_DECL_NSINESTEDURI
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_THIS_JARURI_IMPL_CID)
|
2018-11-30 13:46:48 +03:00
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
// nsJARURI
|
2003-10-04 02:15:24 +04:00
|
|
|
nsresult FormatSpec(const nsACString &entryPath, nsACString &result,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIncludeScheme = true);
|
2003-11-17 00:43:43 +03:00
|
|
|
nsresult CreateEntryURL(const nsACString &entryFilename, const char *charset,
|
|
|
|
nsIURL **url);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
protected:
|
2018-03-20 14:52:47 +03:00
|
|
|
nsJARURI();
|
2014-06-25 06:09:14 +04:00
|
|
|
virtual ~nsJARURI();
|
2018-01-24 00:04:33 +03:00
|
|
|
nsresult SetJAREntry(const nsACString &entryPath);
|
2018-03-20 14:52:47 +03:00
|
|
|
nsresult Init(const char *charsetHint);
|
|
|
|
nsresult SetSpecWithBase(const nsACString &aSpec, nsIURI *aBaseURL);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-05-22 05:12:45 +04:00
|
|
|
// enum used in a few places to specify how .ref attribute should be handled
|
|
|
|
enum RefHandlingEnum { eIgnoreRef, eHonorRef, eReplaceRef };
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-05-22 05:12:45 +04:00
|
|
|
// Helper to share code between Equals methods.
|
|
|
|
virtual nsresult EqualsInternal(nsIURI *other,
|
|
|
|
RefHandlingEnum refHandlingMode,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool *result);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
nsCOMPtr<nsIURI> mJARFile;
|
2003-11-17 00:43:43 +03:00
|
|
|
// mJarEntry stored as a URL so that we can easily access things
|
|
|
|
// like extensions, refs, etc.
|
|
|
|
nsCOMPtr<nsIURL> mJAREntry;
|
2002-03-06 10:48:55 +03:00
|
|
|
nsCString mCharsetHint;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-02-27 02:07:48 +03:00
|
|
|
private:
|
2018-06-14 14:05:43 +03:00
|
|
|
nsresult Clone(nsIURI **aURI);
|
2018-02-27 02:07:48 +03:00
|
|
|
nsresult SetSpecInternal(const nsACString &input);
|
|
|
|
nsresult SetScheme(const nsACString &input);
|
|
|
|
nsresult SetUserPass(const nsACString &input);
|
|
|
|
nsresult SetUsername(const nsACString &input);
|
|
|
|
nsresult SetPassword(const nsACString &input);
|
|
|
|
nsresult SetHostPort(const nsACString &aValue);
|
|
|
|
nsresult SetHost(const nsACString &input);
|
|
|
|
nsresult SetPort(int32_t port);
|
|
|
|
nsresult SetPathQueryRef(const nsACString &input);
|
|
|
|
nsresult SetRef(const nsACString &input);
|
|
|
|
nsresult SetFilePath(const nsACString &input);
|
|
|
|
nsresult SetQuery(const nsACString &input);
|
2018-05-12 05:25:19 +03:00
|
|
|
nsresult SetQueryWithEncoding(const nsACString &input,
|
|
|
|
const mozilla::Encoding *encoding);
|
2018-03-05 06:14:44 +03:00
|
|
|
bool Deserialize(const mozilla::ipc::URIParams &);
|
2018-03-19 22:22:32 +03:00
|
|
|
nsresult ReadPrivate(nsIObjectInputStream *aStream);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-02-27 02:07:48 +03:00
|
|
|
nsresult SetFileNameInternal(const nsACString &fileName);
|
|
|
|
nsresult SetFileBaseNameInternal(const nsACString &fileBaseName);
|
|
|
|
nsresult SetFileExtensionInternal(const nsACString &fileExtension);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-20 19:11:30 +03:00
|
|
|
public:
|
|
|
|
class Mutator final : public nsIURIMutator,
|
|
|
|
public BaseURIMutator<nsJARURI>,
|
2018-01-31 04:32:27 +03:00
|
|
|
public nsIURLMutator,
|
2018-03-19 22:22:32 +03:00
|
|
|
public nsISerializable,
|
2018-03-20 14:52:47 +03:00
|
|
|
public nsIJARURIMutator {
|
2017-11-20 19:11:30 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
2017-12-05 04:35:21 +03:00
|
|
|
NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI)
|
2017-11-20 19:11:30 +03:00
|
|
|
NS_DEFINE_NSIMUTATOR_COMMON
|
2018-01-31 04:32:27 +03:00
|
|
|
NS_DECL_NSIURLMUTATOR
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-19 22:22:32 +03:00
|
|
|
NS_IMETHOD
|
|
|
|
Write(nsIObjectOutputStream *aOutputStream) override {
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-19 22:22:32 +03:00
|
|
|
MOZ_MUST_USE NS_IMETHOD Read(nsIObjectInputStream *aStream) override {
|
|
|
|
return InitFromInputStream(aStream);
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-20 14:52:47 +03:00
|
|
|
NS_IMETHOD
|
|
|
|
SetSpecBaseCharset(const nsACString &aSpec, nsIURI *aBaseURI,
|
|
|
|
const char *aCharset) override {
|
|
|
|
RefPtr<nsJARURI> uri;
|
|
|
|
if (mURI) {
|
|
|
|
mURI.swap(uri);
|
|
|
|
} else {
|
|
|
|
uri = new nsJARURI();
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-20 14:52:47 +03:00
|
|
|
nsresult rv = uri->Init(aCharset);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-20 14:52:47 +03:00
|
|
|
rv = uri->SetSpecWithBase(aSpec, aBaseURI);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-20 14:52:47 +03:00
|
|
|
mURI.swap(uri);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-20 19:11:30 +03:00
|
|
|
explicit Mutator() {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-20 19:11:30 +03:00
|
|
|
private:
|
|
|
|
virtual ~Mutator() {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-20 19:11:30 +03:00
|
|
|
friend class nsJARURI;
|
|
|
|
};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-02-27 02:07:48 +03:00
|
|
|
friend BaseURIMutator<nsJARURI>;
|
1999-11-08 00:55:12 +03:00
|
|
|
};
|
|
|
|
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsJARURI, NS_THIS_JARURI_IMPL_CID)
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
#endif // nsJARURI_h__
|