1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 2003
20
* the Initial Developer. All Rights Reserved.
23
* Roy Yokoyama <yokoyama@netscape.com> (original author)
24
* Johnny Stenback <jst@netscape.com>
27
* Alternatively, the contents of this file may be used under the terms of
28
* either the GNU General Public License Version 2 or later (the "GPL"), or
29
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30
* in which case the provisions of the GPL or the LGPL are applicable instead
31
* of those above. If you wish to allow use of your version of this file only
32
* under the terms of either the GPL or the LGPL, and not to allow others to
33
* use your version of this file under the terms of the NPL, indicate your
34
* decision by deleting the provisions above and replace them with the notice
35
* and other provisions required by the GPL or the LGPL. If you do not delete
36
* the provisions above, a recipient may use your version of this file under
37
* the terms of any one of the NPL, the GPL or the LGPL.
39
* ***** END LICENSE BLOCK ***** */
43
#include "nsISupports.h"
46
#include "nsNetUtil.h"
47
#include "DotNETNetworking.h"
49
using namespace Mozilla::Embedding::Networking;
51
URI::URI(nsIURI *aURI)
57
URI::URI(String *aSpec)
61
CopyString(aSpec, spec);
64
nsresult rv = NS_NewURI(getter_AddRefs(uri), spec.get());
79
nsCOMPtr<nsIURI> uriClone;
82
nsresult rv = mURI->Clone(getter_AddRefs(uriClone));
86
return new URI(uriClone);
94
GC::SuppressFinalize(this);
101
nsresult rv = mURI->GetSpec(spec);
104
return CopyString(spec);
108
URI::set_Spec(String *aSpec)
111
CopyString(aSpec, spec);
113
nsresult rv = mURI->SetSpec(spec);
120
nsCAutoString prePath;
121
nsresult rv = mURI->GetPrePath(prePath);
124
return CopyString(prePath);
130
nsCAutoString scheme;
131
nsresult rv = mURI->GetScheme(scheme);
134
return CopyString(scheme);
138
URI::set_Scheme(String *aScheme)
140
nsCAutoString scheme;
141
CopyString(aScheme, scheme);
143
nsresult rv = mURI->SetScheme(scheme);
150
nsCAutoString userPass;
151
nsresult rv = mURI->GetUserPass(userPass);
154
return CopyString(userPass);
158
URI::set_UserPass(String *aUserPass)
160
nsCAutoString userPass;
161
CopyString(aUserPass, userPass);
163
nsresult rv = mURI->SetUserPass(userPass);
170
nsCAutoString username;
171
nsresult rv = mURI->GetUsername(username);
174
return CopyString(username);
178
URI::set_Username(String *aUsername)
180
nsCAutoString username;
181
CopyString(aUsername, username);
183
nsresult rv = mURI->SetUsername(username);
190
nsCAutoString password;
191
nsresult rv = mURI->GetPassword(password);
194
return CopyString(password);
198
URI::set_Password(String *aPassword)
200
nsCAutoString password;
201
CopyString(aPassword, password);
203
nsresult rv = mURI->SetPassword(password);
210
nsCAutoString hostPort;
211
nsresult rv = mURI->GetHostPort(hostPort);
214
return CopyString(hostPort);
218
URI::set_HostPort(String *aHostPort)
220
nsCAutoString hostPort;
221
CopyString(aHostPort, hostPort);
223
nsresult rv = mURI->SetHostPort(hostPort);
231
nsresult rv = mURI->GetHost(host);
234
return CopyString(host);
238
URI::set_Host(String *aHost)
241
CopyString(aHost, host);
243
nsresult rv = mURI->SetHost(host);
251
nsresult rv = mURI->GetPort(&port);
258
URI::set_Port(Int32 aPort)
260
nsresult rv = mURI->SetPort(aPort);
268
nsresult rv = mURI->GetPath(path);
271
return CopyString(path);
275
URI::set_Path(String *aPath)
278
CopyString(aPath, path);
280
nsresult rv = mURI->SetPath(path);
285
URI::Equals(URI *aOther)
288
if (!aOther || !aOther->mURI) {
296
nsresult rv = mURI->Equals(aOther->mURI, &equals);
303
URI::SchemeIs(String *aScheme)
305
nsCAutoString scheme;
306
CopyString(aScheme, scheme);
308
PRBool isScheme = PR_FALSE;
310
nsresult rv = mURI->SchemeIs(scheme.get(), &isScheme);
317
URI::Resolve(String *aRelativePath)
319
nsCAutoString relativePath, resolvedPath;
320
CopyString(aRelativePath, relativePath);
322
nsresult rv = mURI->Resolve(relativePath, resolvedPath);
325
return CopyString(resolvedPath);
331
nsCAutoString asciiSpec;
332
nsresult rv = mURI->GetAsciiSpec(asciiSpec);
335
return CopyString(asciiSpec);
341
nsCAutoString asciiHost;
342
nsresult rv = mURI->GetAsciiHost(asciiHost);
345
return CopyString(asciiHost);
349
URI::get_OriginCharset()
351
nsCAutoString originalCharset;
352
nsresult rv = mURI->GetOriginCharset(originalCharset);
355
return CopyString(originalCharset);