Compare commits

..

692 Commits

Author SHA1 Message Date
alecf%netscape.com
772d95df80 put this here
git-svn-id: svn://10.0.0.236/branches/alecf_fastfolder_branch@51617 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-23 01:30:58 +00:00
alecf%netscape.com
c92789df10 add assertions
git-svn-id: svn://10.0.0.236/branches/alecf_fastfolder_branch@51599 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-23 00:06:49 +00:00
alecf%netscape.com
147b80a705 put these here for now
git-svn-id: svn://10.0.0.236/branches/alecf_fastfolder_branch@51594 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 23:34:00 +00:00
(no author)
0bd57c4468 This commit was manufactured by cvs2svn to create branch
'alecf_fastfolder_branch'.

git-svn-id: svn://10.0.0.236/branches/alecf_fastfolder_branch@51472 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 01:02:09 +00:00
alecf%netscape.com
6b7dfaa5e0 start to consolidate URL and URI parsing into the base classes: remove a whole bunch of protocol-specific code in favor of generalization
basically, more fixes for #14437
r=scottip


git-svn-id: svn://10.0.0.236/trunk@51471 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 01:02:08 +00:00
dougt%netscape.com
a0ac058370 fix for bug 13894. Hooks up the notification from necko. r=cathleen.
git-svn-id: svn://10.0.0.236/trunk@51470 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 00:53:01 +00:00
endico%mozilla.org
596192f62c the names of the files to be wrapped must be given relative to the root of the tree. in this case: "../newsbot/newsbot.html"
git-svn-id: svn://10.0.0.236/trunk@51469 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 00:45:56 +00:00
evaughan%netscape.com
997f5f6291 Fixed bug 9442. reviewed by Hyatt.
git-svn-id: svn://10.0.0.236/trunk@51468 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 00:38:22 +00:00
mjudge%netscape.com
64c9150aab massive checkin for underlying implementation of key handling from javascript and home/end breakage and.. selecting around NON-text frames. like arrowing around an image for example. 16636,16655 and another i cannot find. r=kin r=hyatt a=me
git-svn-id: svn://10.0.0.236/trunk@51467 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 00:19:18 +00:00
endico%mozilla.org
6cb5db5eff escape quotes around ALIGN=\"right\"
git-svn-id: svn://10.0.0.236/trunk@51466 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 00:14:43 +00:00
kipp%netscape.com
845644f460 Alloc another iid
git-svn-id: svn://10.0.0.236/trunk@51465 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 00:12:31 +00:00
scc%netscape.com
9d0d4095c3 remove "nsVariant.cpp" from the project, and "nsIVariant.h" from the MANIFEST, as per bug #16987, r=sfraser
git-svn-id: svn://10.0.0.236/trunk@51464 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 00:12:03 +00:00
kipp%netscape.com
b9ad416be8 Clean up other dirt
git-svn-id: svn://10.0.0.236/trunk@51463 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 00:11:54 +00:00
kipp%netscape.com
7944188008 Whoops, missed this during my checkin :-(
git-svn-id: svn://10.0.0.236/trunk@51462 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 00:11:31 +00:00
davidm%netscape.com
302f64fb59 2425 [PP] Mac: Apprunner doesn't gracefully quit at shutdown or r
r = sdagley


git-svn-id: svn://10.0.0.236/trunk@51461 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-22 00:01:45 +00:00
beard%netscape.com
56b367cb81 added parent links, so you can go to the objects referring to a given link.
git-svn-id: svn://10.0.0.236/trunk@51460 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 23:58:28 +00:00
beard%netscape.com
dfaa46c552 broke out from leaksoup.java so it can be used by tracesoup.
git-svn-id: svn://10.0.0.236/trunk@51459 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 23:55:25 +00:00
beard%netscape.com
f8e8fae5ce annotates refcount traces with blame/lxr URLs
git-svn-id: svn://10.0.0.236/trunk@51458 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 23:54:39 +00:00
endico%mozilla.org
62819eff8a align bottom row to the right. <TR ALIGN="right"> doesn't seem to work in mozilla
git-svn-id: svn://10.0.0.236/trunk@51457 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 23:52:41 +00:00
terry%mozilla.org
575dc47298 Make "checkins in last 7 days" link work better in worlds with
multiple repositories.


git-svn-id: svn://10.0.0.236/trunk@51454 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 23:42:39 +00:00
nisheeth%netscape.com
9888b796b2 Fixing Unix warnings. r=harishd
git-svn-id: svn://10.0.0.236/trunk@51452 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 23:27:02 +00:00
akkana%netscape.com
0ab9b94827 Fix a runtime error message -- r= (and suggested by) dp
git-svn-id: svn://10.0.0.236/trunk@51451 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 23:12:31 +00:00
karnaze%netscape.com
9ecfbb54e1 new regression tests
git-svn-id: svn://10.0.0.236/trunk@51450 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:52:00 +00:00
terry%mozilla.org
2df0186c7f Wasn't working right with multiple repositories.
git-svn-id: svn://10.0.0.236/trunk@51449 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:51:50 +00:00
wtc%netscape.com
096120daf6 Fixed a small mistake in the previous checkin.
git-svn-id: svn://10.0.0.236/trunk@51448 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:51:06 +00:00
danm%netscape.com
4e8be85212 removing (unused) references to nsIWebShell.h. requested by buster@netscape.com, bug 16510, r:me
git-svn-id: svn://10.0.0.236/trunk@51447 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:47:50 +00:00
leaf%mozilla.org
b541cbb7e8 adding !endif to complete !if
git-svn-id: svn://10.0.0.236/trunk@51446 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:40:16 +00:00
endico%mozilla.org
a85345a59b get rid of the <DIV>s and <SPAN>s since we have the rdf file now. the <SPAN> around the article link was messing up the link because they were intertwined <SPAN><A></SPAN>text</A>
git-svn-id: svn://10.0.0.236/trunk@51445 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:38:21 +00:00
wtc%netscape.com
358dfee800 Bugsplat bug #365031: moved the definition of PRStack from pratom.h
to primpl.h so that it is not exported.
Bugsplat bug #364813: declare 'prstk_head' volatile, to prevent compiler
from optimizing away references in a loop.
r=larryh,srinivas@netscape.com


git-svn-id: svn://10.0.0.236/trunk@51444 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:36:35 +00:00
karnaze%netscape.com
a2ae4b6656 bug 5799 - width of auto width table considers percentage cells when they are small relative to the rest of the table. r=dcone
git-svn-id: svn://10.0.0.236/trunk@51443 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:36:21 +00:00
karnaze%netscape.com
ed05316f46 bug 12012 - RemoveFrame was using stale style display. r=dcone
git-svn-id: svn://10.0.0.236/trunk@51442 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:33:30 +00:00
mscott%netscape.com
83fec44fd6 Bug #16538 --> FetchMessage takes a stream listener and we should try to create a necko channel for the url,
and call AsyncRead on the channel, passing in the stream listener instead of trying to run the imap url
through the normal means. This fixes the problem where the channel wasn't properly initialized when
copying a imap message to a local folder.
r=jefft,bienvenu


git-svn-id: svn://10.0.0.236/trunk@51441 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:33:24 +00:00
wtc%netscape.com
646d7cec23 Temporary depend:clean hack.
git-svn-id: svn://10.0.0.236/trunk@51440 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:32:14 +00:00
mscott%netscape.com
fb7a12a36e Bug #16538 --> we need to add nsIStreamObserver to the QI method for this class in order to avoid an assertion
with my fix to bug #16538. I also replaced the handle rolled QueryInterface method with macro.
r=jefft,bienvenu


git-svn-id: svn://10.0.0.236/trunk@51438 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:31:27 +00:00
wtc%netscape.com
c2f76119ac Bugzilla bug #16994: fixed compilation problems on platforms without
long longs. r=larryh@netscape.com.  Thanks to Chris Seawood
<cls@seawood.org> for the bug report.


git-svn-id: svn://10.0.0.236/trunk@51437 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:28:14 +00:00
cata%netscape.com
dd434afd5e bug #16754, r=erik, fixing memory leak
git-svn-id: svn://10.0.0.236/trunk@51436 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:25:44 +00:00
braddr%puremagic.com
8c0a2f84e7 Remove references to nsVariant.cpp and nsIVariant.h.
r=scc


git-svn-id: svn://10.0.0.236/trunk@51435 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:24:17 +00:00
bienvenu%netscape.com
f52e7bdb86 fix syncing of imap flags change to db r=mscott,16839
git-svn-id: svn://10.0.0.236/trunk@51434 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:23:25 +00:00
pnunn%netscape.com
62438f020b bug#13505. Replacing str functions with nsCRT functions, nspr functions.
pnunn@netscape.com  r:jfrancis@netscape.com


git-svn-id: svn://10.0.0.236/trunk@51433 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:23:24 +00:00
rods%netscape.com
c33c65e90f changed the padding so it is adding in the correct left right instead of top bottom
r=kmcclusk, Bug #16936


git-svn-id: svn://10.0.0.236/trunk@51432 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:22:32 +00:00
bienvenu%netscape.com
612130b82a check for null when marking header read, r=mscott
git-svn-id: svn://10.0.0.236/trunk@51431 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:22:07 +00:00
jst%citec.fi
953ba7bb6a Make printing use only enabled stylesheets. No bug, r=kipp@netscape.com and dcone@netscape.com.
git-svn-id: svn://10.0.0.236/trunk@51430 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:20:37 +00:00
rogerl%netscape.com
605c46e143 Loop from 1 instead of 0 since the test result parsing gets messed up by
the null strings not containing 'PASSED'. The 0 case isn't all that
important for upperCase testing.


git-svn-id: svn://10.0.0.236/trunk@51429 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:18:52 +00:00
terry%mozilla.org
3b70db325d Add some more debugging output.
git-svn-id: svn://10.0.0.236/trunk@51428 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:04:13 +00:00
ftang%netscape.com
908e81fe11 change the input method highligh code from 2 style to 4 styles. r=mjudge
git-svn-id: svn://10.0.0.236/trunk@51427 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 22:01:18 +00:00
jevering%netscape.com
1e20da8f66 Enabling boehm leak detector, r=dp bug#15906
git-svn-id: svn://10.0.0.236/trunk@51426 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:59:15 +00:00
jevering%netscape.com
42df555a0b Enabling GC detector, r=dp, bug #15906
git-svn-id: svn://10.0.0.236/trunk@51425 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:56:47 +00:00
srinivas%netscape.com
52c617580c Invoke the native acknowledge notify routine only when queue is non-empty.
Checkin for kipp@netscape.com.


git-svn-id: svn://10.0.0.236/trunk@51424 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:52:02 +00:00
akkana%netscape.com
e6c9a60dab 16706: Call the rules code to delete the bogus node before inserting html, to fix the new mail reply code. r=jfrancis
git-svn-id: svn://10.0.0.236/trunk@51423 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:51:47 +00:00
kipp%netscape.com
adc0fff019 Added two new tests
git-svn-id: svn://10.0.0.236/trunk@51422 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:46:52 +00:00
endico%mozilla.org
f535016cde oops use '&', not '%'
git-svn-id: svn://10.0.0.236/trunk@51421 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:44:39 +00:00
cata%netscape.com
6499857292 bug #15690, r=ftang, removing bogus rules which were affecting the menu template
git-svn-id: svn://10.0.0.236/trunk@51420 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:42:40 +00:00
danm%netscape.com
5ecf5615a7 observe EventQueue creation and deletion. r:hyatt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51419 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:36:25 +00:00
ramiro%fateware.com
1a2e9974f2 Use "(NSINSTALL) -D" instead of direct "mkdir" r=shaver.
git-svn-id: svn://10.0.0.236/trunk@51418 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:35:37 +00:00
danm%netscape.com
49ae6251f8 adding method ListenToEventQueue (moving EventQueue observation from appshells to appshellservice) r:hyatt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51417 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:34:57 +00:00
dp%netscape.com
32ccfffb02 bug#14656 Circular release problem of component manager. Fixed by
adding shutdown() method that gets called before the last
release. Enabled only for dp & shaver until we resolve js coredump.


git-svn-id: svn://10.0.0.236/trunk@51416 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:34:39 +00:00
dp%netscape.com
a87080011d Making sample better by using COMPtr r=waterson
git-svn-id: svn://10.0.0.236/trunk@51415 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:32:17 +00:00
dp%netscape.com
480412f60c Addding xpcom init and shutdown. r=waterson
git-svn-id: svn://10.0.0.236/trunk@51414 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:31:53 +00:00
nisheeth%netscape.com
dd57891add Install util.lib to the dist directory in the libs phase rather than the install phase.
git-svn-id: svn://10.0.0.236/trunk@51413 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:31:26 +00:00
endico%mozilla.org
35cedcf521 html escape gt and lt symbols in the View Article url
git-svn-id: svn://10.0.0.236/trunk@51412 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:22:44 +00:00
rhp%netscape.com
7889a5e148 Fix for duplicate body text in Multipart related message - Bug #16992 - r: mscott
git-svn-id: svn://10.0.0.236/trunk@51411 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:18:54 +00:00
mcafee%netscape.com
220ec361b8 Fixing evaughan's last change. r=law
git-svn-id: svn://10.0.0.236/trunk@51410 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:14:59 +00:00
brade%netscape.com
1706386f49 add nsTextContentDataChange.cpp a=leaf@mozilla.org
git-svn-id: svn://10.0.0.236/trunk@51409 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:14:19 +00:00
ramiro%fateware.com
5244db774f More rpm packaging work in progress. Not part of anything.
git-svn-id: svn://10.0.0.236/trunk@51408 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:12:50 +00:00
edburns%acm.org
24e8fb82df Bug: 15606
r=shaver
approver=av

I would like to take the time to personally thank Mike Shaver for all the hard
work he has done to make this bugfix possible.


git-svn-id: svn://10.0.0.236/trunk@51407 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:09:21 +00:00
rickg%netscape.com
3e6139004b changed default font-size for viewsource; r=none;
git-svn-id: svn://10.0.0.236/trunk@51406 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:05:17 +00:00
mcafee%netscape.com
e9e6fdee20 Backing out evaughan's change which broke linux/solaris. a=mcafee
git-svn-id: svn://10.0.0.236/trunk@51405 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 21:05:02 +00:00
troy%netscape.com
46c5c77d91 Removed unused 4-byte "mMaxElementSize" member data
git-svn-id: svn://10.0.0.236/trunk@51404 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:51:04 +00:00
kipp%netscape.com
e4442e8177 r=troy; added nsTextContentChangeData to the build
git-svn-id: svn://10.0.0.236/trunk@51403 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:48:43 +00:00
kipp%netscape.com
1e9fb71c5d Support navigators built-in image types internal-gopher-*
git-svn-id: svn://10.0.0.236/trunk@51402 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:48:04 +00:00
kipp%netscape.com
e5f0e5328b Fixed percolation of nbsp's into the transformed buffer (bug 16886)
git-svn-id: svn://10.0.0.236/trunk@51401 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:47:36 +00:00
kipp%netscape.com
c54e23defe r=troy; Optimize append text reflows to only reflow the new part of the text
git-svn-id: svn://10.0.0.236/trunk@51400 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:46:05 +00:00
kipp%netscape.com
fee0551895 moved debug logic for dumping reflow commands so that we can dump them without requiring the incremental reflow verification logic to run
git-svn-id: svn://10.0.0.236/trunk@51399 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:45:39 +00:00
kipp%netscape.com
6b290bc673 r=troy; bug: 15153; fixed problem with style-change reflows not being propogated properly
git-svn-id: svn://10.0.0.236/trunk@51398 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:44:58 +00:00
kipp%netscape.com
57dac66f2e r=troy; bugs: 13196; fixed floating table reflow issues found in 13196 by storing floater max-element-size for later retrieval
git-svn-id: svn://10.0.0.236/trunk@51397 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:44:22 +00:00
locka%iol.ie
9ff1e618b5 Changed scope of some helper methods
git-svn-id: svn://10.0.0.236/trunk@51396 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:44:06 +00:00
kipp%netscape.com
88d3d6afe1 r=troy; bugs: 15153, 13196; fixed problem with style-change reflows not being propogated properly; also fixed floating table reflow issues found in 13196 by storing floater max-element-size for later retrieval
git-svn-id: svn://10.0.0.236/trunk@51395 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:43:48 +00:00
kipp%netscape.com
6156c0fb7a Export the gopher images
git-svn-id: svn://10.0.0.236/trunk@51394 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:42:18 +00:00
kipp%netscape.com
199585b860 Use nsTextContentChangeData to pass down to the reflow logic the effect on the text
git-svn-id: svn://10.0.0.236/trunk@51393 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:40:51 +00:00
kipp%netscape.com
6ef7b73278 new file for text reflow optimiziation
git-svn-id: svn://10.0.0.236/trunk@51392 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:40:25 +00:00
bienvenu%netscape.com
90299835ef fix addrbook mem leaks and mismatched delete r=mscott\
git-svn-id: svn://10.0.0.236/trunk@51391 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:36:02 +00:00
bienvenu%netscape.com
9b4f0c0032 fix msg compose and send mem leaks, ipw, and mismatched delete r=mscott
git-svn-id: svn://10.0.0.236/trunk@51390 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:35:26 +00:00
rickg%netscape.com
eb5f25dfe9 changed default font-size for viewsource; r=none;
git-svn-id: svn://10.0.0.236/trunk@51389 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:34:02 +00:00
locka%iol.ie
f4438b41e1 Added support for drag and drop of Internet Shortcut files
git-svn-id: svn://10.0.0.236/trunk@51388 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:32:52 +00:00
kipp%netscape.com
90d4423420 r=troy; Added a property for max-element-size storage for fixing bug 13196
git-svn-id: svn://10.0.0.236/trunk@51387 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:23:05 +00:00
kipp%netscape.com
4fe7cefb4a r=troy; Added nsITextContetChangeData to help optimize modifications of large text elements
git-svn-id: svn://10.0.0.236/trunk@51386 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:22:02 +00:00
evaughan%netscape.com
f1d7499417 Fixed some warnings: reviewed -hyatt
git-svn-id: svn://10.0.0.236/trunk@51385 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 20:17:51 +00:00
ramiro%fateware.com
0fed380744 Fix #ifdef DEBUG_ramiro build bustage.
git-svn-id: svn://10.0.0.236/trunk@51384 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 19:56:05 +00:00
matt%netscape.com
426f9c3ea3 Adding manual proxies -r by bill
git-svn-id: svn://10.0.0.236/trunk@51383 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 19:53:19 +00:00
ssu%netscape.com
f923fbd1b1 fixed bug #15309. r=dbragg. it now creates an empty Plugins directory within Seamonkey. Not part of tinderbox. would only affect windows.
git-svn-id: svn://10.0.0.236/trunk@51382 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 19:50:36 +00:00
ramiro%fateware.com
ced5d07b70 Fix #ifdef DEBUG_ramiro build bustage.
git-svn-id: svn://10.0.0.236/trunk@51381 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 19:30:29 +00:00
selmer%netscape.com
206cd25152 Fix enabling when last NCIfile is deleted
git-svn-id: svn://10.0.0.236/trunk@51379 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 18:39:26 +00:00
terry%mozilla.org
49666a52cb Fix perl warning.
git-svn-id: svn://10.0.0.236/trunk@51378 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 18:19:48 +00:00
kipp%netscape.com
da5a072040 new
git-svn-id: svn://10.0.0.236/trunk@51374 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 16:20:53 +00:00
briano%netscape.com
363f0cb92d Automated update
git-svn-id: svn://10.0.0.236/trunk@51373 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 15:00:22 +00:00
ramiro%fateware.com
a3613fc446 Work in progress to add reasonable rpm packaging support for the beast.
NOT PART OF THE SEAMONKEY BUILD.


git-svn-id: svn://10.0.0.236/trunk@51372 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 14:57:38 +00:00
ssu%netscape.com
d5686c3a21 fixing bug #16470. Not part of Tinderbox. Not part of seamonkey core code. r=pavlov. Would affect only windows.
git-svn-id: svn://10.0.0.236/trunk@51371 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 07:24:46 +00:00
tbogard%aol.net
8cf4ca3ed6 Added changes from buster.
git-svn-id: svn://10.0.0.236/trunk@51370 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 06:59:48 +00:00
ssu%netscape.com
ef19fe31d7 removing editor from install build process. Not part of Tinderbox. Not part of seamonkey code. Would affect only windows platforms.
git-svn-id: svn://10.0.0.236/trunk@51369 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 06:44:27 +00:00
tbogard%aol.net
2f9603aabc Added nsITextScroll.idl.
git-svn-id: svn://10.0.0.236/trunk@51368 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 06:41:03 +00:00
pierre%netscape.com
2123a4d227 Fix build bustage
git-svn-id: svn://10.0.0.236/trunk@51367 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 06:40:00 +00:00
tbogard%aol.net
75207bcf9a More changes from buster.
git-svn-id: svn://10.0.0.236/trunk@51366 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 05:52:54 +00:00
pierre%netscape.com
6b7990dcc7 Enabled MOZ_PERF_METRICS in the Mac build:
- updated DefinesMozilla.h
- fixed stopwatch.cpp
- created libutilIDL.mcp
- added StopWatch exports to libutil.exp
- added xpcom.shlb to libutil.mcp
- added libutil.shlb to htmlparser.mcp, layout.mcp, webshell.mcp


git-svn-id: svn://10.0.0.236/trunk@51365 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 05:41:45 +00:00
sfraser%netscape.com
68467cb1bb File Removed.
git-svn-id: svn://10.0.0.236/trunk@51364 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 05:37:53 +00:00
sfraser%netscape.com
7bac435457 Removed nsEditorFactory.cpp and nsEditorShellFactory.cpp which are no longer needed. r=pavlov
git-svn-id: svn://10.0.0.236/trunk@51363 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 05:37:04 +00:00
sfraser%netscape.com
a627d5676e Removal of calls to PR_MumbleMonitor, which were way too heavy-handed for the job. Replaced with PR_AtomicInc/Decrement. part of module sweep, r=morse, pavlov
git-svn-id: svn://10.0.0.236/trunk@51362 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 05:36:21 +00:00
pierre%netscape.com
1e94740a0f First Checked In.
git-svn-id: svn://10.0.0.236/trunk@51361 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 05:35:26 +00:00
mcafee%netscape.com
ca26c9bcab Moved to mozilla/tools/tinderbox (client-side script).
git-svn-id: svn://10.0.0.236/trunk@51360 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 05:20:02 +00:00
mcafee%netscape.com
f7f718532b Added bloat test. Also added --testonly to skip building process. Fixed bloatdiff to put its output to stdout. r=warren
git-svn-id: svn://10.0.0.236/trunk@51359 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 05:16:54 +00:00
troy%netscape.com
dced08401d r=kipp@netscape.com
Added API to get/set properties on frames. Also changed nsContainerFrame
to use a property to implement the frame overflow list. This saves 4 bytes
per container frames


git-svn-id: svn://10.0.0.236/trunk@51358 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 05:11:43 +00:00
waterson%netscape.com
41c3d0afa5 Fix solaris (and other unsupported platforms).
git-svn-id: svn://10.0.0.236/trunk@51357 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 04:28:07 +00:00
waterson%netscape.com
a8195254ae Change nsTraceRefCnt::WalkTheStack() to accept stream.
git-svn-id: svn://10.0.0.236/trunk@51355 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 03:45:38 +00:00
sfraser%netscape.com
aed61fd72a Removed an errant semicolon in a IID declaration. r=floppy moose
git-svn-id: svn://10.0.0.236/trunk@51354 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 03:45:20 +00:00
waterson%netscape.com
035b04b87b Change nsTraceRefcnt::WalkTheStack() to accept stream.
git-svn-id: svn://10.0.0.236/trunk@51353 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 03:45:12 +00:00
waterson%netscape.com
21abead461 Modify nsTraceRefcnt::WalkTheStack() to accept a stream. Other misc formatting fixup. work really done by beard, r=waterson.
git-svn-id: svn://10.0.0.236/trunk@51352 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 03:44:37 +00:00
tbogard%aol.net
ce03f0d9f0 More additions suggested by buster. Not all final, still working out the interfaces.
git-svn-id: svn://10.0.0.236/trunk@51351 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 03:23:31 +00:00
tbogard%aol.net
c8d824834b More changes to the interface. Merging in changes from buster.
git-svn-id: svn://10.0.0.236/trunk@51350 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 03:01:33 +00:00
tbogard%aol.net
619f3992f7 Added new nsIDocShellContainer.idl to the build list.
git-svn-id: svn://10.0.0.236/trunk@51349 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 03:01:10 +00:00
tbogard%aol.net
3b01cf0bec First Check-in.
git-svn-id: svn://10.0.0.236/trunk@51348 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 03:00:07 +00:00
nisheeth%netscape.com
205adceff6 Should not affect build. Include stopwatch object code if MOZ_PERF is defined.
git-svn-id: svn://10.0.0.236/trunk@51347 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 02:47:56 +00:00
dveditz%netscape.com
7d2157e059 mac bustage
git-svn-id: svn://10.0.0.236/trunk@51346 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 02:46:21 +00:00
nisheeth%netscape.com
569e1a2fb1 Fixed warnings. Enabled code to build on UNIX. r=pollmann
git-svn-id: svn://10.0.0.236/trunk@51345 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 02:32:01 +00:00
endico%mozilla.org
8f060eb994 remove the full path names on newsbot.html and wrapped.html so wrap.pl doesn't add "../" to everything. communicator doesn't mind this but it breaks msie and probably mozilla
git-svn-id: svn://10.0.0.236/trunk@51344 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 02:30:21 +00:00
briano%netscape.com
4f1d9b3a36 Automated update
git-svn-id: svn://10.0.0.236/trunk@51343 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 02:15:10 +00:00
nisheeth%netscape.com
3871dd508d Will not affect build. Add support for --enable-perf-metrics autoconf flag that will switch on the reporting of timing information about gecko's layout processes.
git-svn-id: svn://10.0.0.236/trunk@51342 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 02:01:49 +00:00
varada%netscape.com
6475343232 changing all edit fields with browse buttons to non editable scripts
git-svn-id: svn://10.0.0.236/trunk@51341 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 01:56:54 +00:00
dveditz%netscape.com
92654b5840 Missed a test
git-svn-id: svn://10.0.0.236/trunk@51340 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 01:47:28 +00:00
selmer%netscape.com
bea6cdd46f Don't need -MDd in CFLAGS
git-svn-id: svn://10.0.0.236/trunk@51339 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 01:42:48 +00:00
bienvenu%netscape.com
4e7faff324 fix memory leaks and mismatched frees r=jefft
git-svn-id: svn://10.0.0.236/trunk@51338 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 01:42:00 +00:00
bienvenu%netscape.com
4392913cc3 fix mismatched free
git-svn-id: svn://10.0.0.236/trunk@51337 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 01:40:08 +00:00
bienvenu%netscape.com
10931ccb41 another memory leak fix for mime
git-svn-id: svn://10.0.0.236/trunk@51336 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 01:37:03 +00:00
beard%netscape.com
6bfc31a469 fix :: bustage.
git-svn-id: svn://10.0.0.236/trunk@51334 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 01:07:50 +00:00
dveditz%netscape.com
6b0912645b Changing nsFileSpec Copy and Move function names to match their
functionality, and also to free up the namespace for a *real* Copy
and Move that allow renaming the leaf name rather than just copying
into different directories (i.e. to make backup files). r=ssu


git-svn-id: svn://10.0.0.236/trunk@51333 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:40:39 +00:00
hoa.nguyen%intel.com
ed3c26548f Optimized decoder. Removed warnings.
git-svn-id: svn://10.0.0.236/trunk@51332 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:17:48 +00:00
beard%netscape.com
a27e6a0c95 when GC_DEBUG is off, try to use GC_malloc_ignore_off_page for large blocks. Since GC_MALLOC always returns cleared blocks, don't bother clearning. r=gordon, bug=15906
git-svn-id: svn://10.0.0.236/trunk@51331 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:17:28 +00:00
dp%netscape.com
af64d101fa Fixed crash on -f file on quit by using async proxy post event as
opposed to calling quit directly. r=dougt


git-svn-id: svn://10.0.0.236/trunk@51330 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:15:30 +00:00
beard%netscape.com
72a36eba4b use nsILeakDetector service. r=gordon, bug=15906
git-svn-id: svn://10.0.0.236/trunk@51329 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:13:07 +00:00
karnaze%netscape.com
fb5466f5e4 bug 14915 - fix crash.
git-svn-id: svn://10.0.0.236/trunk@51328 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:11:55 +00:00
beard%netscape.com
b582d5259b added GC_address_to_source, MWUnmangle exports. r=gordon, bug=15906
git-svn-id: svn://10.0.0.236/trunk@51327 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:09:14 +00:00
beard%netscape.com
eb87b84391 added nsEnvironment.cpp. r=gordon, bug=15906
git-svn-id: svn://10.0.0.236/trunk@51326 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:08:13 +00:00
rods%netscape.com
3133a0f78a removed the PR_MAX forcing the y offset to be zero or greater. Not sure why it was doing this.
r=kmcclusk Bug #16152


git-svn-id: svn://10.0.0.236/trunk@51325 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:06:23 +00:00
beard%netscape.com
abf884842d added GC_address_to_source, MWUnmangle stubs. r=gordon, bug=15906
git-svn-id: svn://10.0.0.236/trunk@51324 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:06:13 +00:00
sspitzer%netscape.com
81245102fa fix for #15231, r=mscott. get the fixed_width pref to stick.
the problem was we had it as an int pref, when it was a bool pref.


git-svn-id: svn://10.0.0.236/trunk@51323 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:05:50 +00:00
hoa.nguyen%intel.com
4b7e9a7a5a Optimized decoder.
git-svn-id: svn://10.0.0.236/trunk@51322 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:05:16 +00:00
beard%netscape.com
b12276db98 First Checked In.
git-svn-id: svn://10.0.0.236/trunk@51321 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:05:05 +00:00
hoa.nguyen%intel.com
b52252a4aa Correctly check for the HZ converter engine state.
git-svn-id: svn://10.0.0.236/trunk@51320 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-21 00:03:52 +00:00
nhotta%netscape.com
dbcb2cc74d Fix a warning, it was assigning NULL to char type, r=ftang.
git-svn-id: svn://10.0.0.236/trunk@51319 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 23:55:31 +00:00
nhotta%netscape.com
3e99f5b0b8 Adding a wrapper function for a new i18n interface, part of bug fix 15475, r=rhp.
git-svn-id: svn://10.0.0.236/trunk@51318 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 23:51:25 +00:00
cmanske%netscape.com
661bf267b9 Fixed bug 16923. r=mjudge
git-svn-id: svn://10.0.0.236/trunk@51317 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 23:50:20 +00:00
rods%netscape.com
dd80c9dd09 added check for null frame. The child frame can be null when a comment node exists as
one of the children of the select. r=kmcclusk, Bug #16355


git-svn-id: svn://10.0.0.236/trunk@51316 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 23:35:38 +00:00
endico%mozilla.org
48d6ca301e clairify that the 'mozilla' module contains the entire 'current' repository, not everything including all the branches.
git-svn-id: svn://10.0.0.236/trunk@51315 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 23:30:50 +00:00
pierre%netscape.com
a7cee2ccb1 #15636 "Cleanup build warnings". Some compilers issued a "hidden virtual method" warning because only one of the two implementations of GetDesiredSize() was overridden. r=slamm.
git-svn-id: svn://10.0.0.236/trunk@51314 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 23:30:29 +00:00
hoa.nguyen%intel.com
cfe11b1fd4 Changed from char types to PRUint8.
git-svn-id: svn://10.0.0.236/trunk@51313 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 23:21:56 +00:00
wtc%netscape.com
e0c8d6770c Made comments match code.
git-svn-id: svn://10.0.0.236/trunk@51312 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 23:19:31 +00:00
harishd%netscape.com
6cd114ddff Fix for the bustage.
r=pollmann


git-svn-id: svn://10.0.0.236/trunk@51311 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 23:14:50 +00:00
wtc%netscape.com
eacb3c22ae Bugsplat bug #366840: PR_StringToNetAddr needs to set the address family
field of the PRNetAddr structure. Added a new test str2addr.c for this
bug. r=larryh@netscape.com
Modified files: prnetdb.c, pr/tests/runtests.ksh, pr/tests/Makefile,
    pr/tests/Makefile.in
Added file: pr/tests/str2addr.c


git-svn-id: svn://10.0.0.236/trunk@51310 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 23:07:38 +00:00
mcafee%netscape.com
9fa424b571 Moving bloatdiff.pl from webtools/tinderbox (server) to here (client).
git-svn-id: svn://10.0.0.236/trunk@51309 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 22:35:48 +00:00
harishd%netscape.com
676f148787 Fixed Bug 16285 - Replaced char* with nsCAutoString for mBuffer.
This fixes the crash on doing Ctrl-c in editor.

r=akkana


git-svn-id: svn://10.0.0.236/trunk@51308 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 22:35:12 +00:00
harishd%netscape.com
8cccb6a457 Fixed Bug 16014 - Rectifed a glitch in illegal-content handling code.
r=pollmann


git-svn-id: svn://10.0.0.236/trunk@51307 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 22:32:10 +00:00
alecf%netscape.com
e0db5266e6 turn news into a nsIModule
r=sspitzer
(porkjockey work)


git-svn-id: svn://10.0.0.236/trunk@51306 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 22:30:02 +00:00
akkana%netscape.com
49f4e5d7aa 16726: don't print the doctype information in plaintext output. r=cmanske
git-svn-id: svn://10.0.0.236/trunk@51305 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 22:27:14 +00:00
edburns%acm.org
25735aa125 bug: 16842
reviewer: edburns
approver: edburns

Changed raptor to gk in makefile as appropriate.


git-svn-id: svn://10.0.0.236/trunk@51304 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 22:02:34 +00:00
rods%netscape.com
54bbcb0dfd added code to the destructor to make sure the list get rolled up.
r=kmcclusk bug 15912


git-svn-id: svn://10.0.0.236/trunk@51303 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:59:04 +00:00
alecf%netscape.com
8d5865d224 clean up nsIMsgFolder API in preparation for fixing a number of bugs, most importantly #14437
r=scottip


git-svn-id: svn://10.0.0.236/trunk@51302 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:58:21 +00:00
dmose%mozilla.org
9cdfa509fd macfe lives on in the MozillaClassic branch, but there's no longer a need for it on the trunk. a=smfr@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51301 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:53:27 +00:00
endico%mozilla.org
47e168172c add m10 tree for the Design Patterns contest
git-svn-id: svn://10.0.0.236/trunk@51300 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:52:08 +00:00
endico%mozilla.org
3d25df00ed merge old changes from when we moved to komodo
git-svn-id: svn://10.0.0.236/trunk@51299 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:48:49 +00:00
mscott%netscape.com
2faa0c76f6 optimize nsImapBuildMessageURI to use a nsCAutoString. This saves us an extra allocation of the string later on.
r=sspitzer


git-svn-id: svn://10.0.0.236/trunk@51298 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:41:18 +00:00
scc%netscape.com
a83d58083d Now InstallFromManifest "xpcom/components/MANIFEST_COMPONENTS" to get some javascript installed in the apps "Components" directory. This corresponds to work shaver has already done on the other platforms. r=sfraser
git-svn-id: svn://10.0.0.236/trunk@51297 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:31:46 +00:00
srinivas%netscape.com
ecb0569df7 The "-mno-486" compiler option is no longer relevant and not supported
in new gcc compilers (v2.95). Bug #15975.


git-svn-id: svn://10.0.0.236/trunk@51296 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:19:53 +00:00
bienvenu%netscape.com
0169c2df6e more memory leak fixes, r=mscott
git-svn-id: svn://10.0.0.236/trunk@51295 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:18:25 +00:00
bienvenu%netscape.com
3d780d6859 fix rdf resource value leaks r=jefft
git-svn-id: svn://10.0.0.236/trunk@51294 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:12:00 +00:00
scc%netscape.com
b029ca73a2 First Checked In.
git-svn-id: svn://10.0.0.236/trunk@51293 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:03:21 +00:00
mscott%netscape.com
899ebce13b Bug #16814 --> i found a problem which may be causing us to block in the imap protocol when downloading larger
attachments or images. Basically, the nsMsgLineStreamBuffer class had a fence post bug when determining
if it had enough room to read in more bytes. If the # of free bytes in the stream buffer was 1 byte and we
had just one byte of data left to read in from the incoming stream, we would fail to read in that one byte.
r=sspitzer


git-svn-id: svn://10.0.0.236/trunk@51292 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:01:58 +00:00
ftang%netscape.com
c683bbd987 do not do TypedText if the character code is 0. r=brade. Fix bug 16570 and 16811
git-svn-id: svn://10.0.0.236/trunk@51291 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:01:20 +00:00
bienvenu%netscape.com
d6cfea3e69 fix mime memory leaks, mostly strings, r=rhp
git-svn-id: svn://10.0.0.236/trunk@51290 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 21:00:02 +00:00
waldemar%netscape.com
28941388eb Changed bottom expressions to syntax error throws
git-svn-id: svn://10.0.0.236/trunk@51289 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:58:07 +00:00
waldemar%netscape.com
8a4ea2ca19 Added upper-case Greek letters
git-svn-id: svn://10.0.0.236/trunk@51288 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:57:37 +00:00
danm%netscape.com
fe06bcf74b no longer used
git-svn-id: svn://10.0.0.236/trunk@51287 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:51:16 +00:00
bienvenu%netscape.com
21c7cb6d78 fix memory leaks of uri's and a progress string r=mscott
git-svn-id: svn://10.0.0.236/trunk@51286 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:49:45 +00:00
briano%netscape.com
bd0b8a085b Automated update
git-svn-id: svn://10.0.0.236/trunk@51285 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:45:41 +00:00
bienvenu%netscape.com
004de2f422 fix memory leaks in address book r=mscott
git-svn-id: svn://10.0.0.236/trunk@51284 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:41:27 +00:00
mcafee%netscape.com
8d734dfcc2 Adding support for --enable-logrefcnt; off by default in optimized builds, we need this for tinderbox. code=dp, r=mcafee
git-svn-id: svn://10.0.0.236/trunk@51283 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:40:01 +00:00
law%netscape.com
64d7ceb5a2 Fix for bug #9131; add dependent=yes feature on find dialog so it behaves properly; r=matt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51282 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:36:08 +00:00
bienvenu%netscape.com
f1140e8c6e fix memory leak of notification uri r=dougt
git-svn-id: svn://10.0.0.236/trunk@51281 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:30:42 +00:00
akkana%netscape.com
b05d4de40d 15777: Don't declare the same function-static symbol twice in the same file, because some versions of gcc can't deal with it. r=mcafee
git-svn-id: svn://10.0.0.236/trunk@51280 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:20:38 +00:00
mcafee%netscape.com
f097b7a2a4 Reviewing and applying pavlov's fix for extra row in color palette. (14315)
git-svn-id: svn://10.0.0.236/trunk@51279 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:14:13 +00:00
akkana%netscape.com
2a83eeebf7 16795: Make arrow keys work again.
The gtk event for arrow keys has length=0, but we still need to generate
KeyDown, KeyPress, etc. events for these keys.  r=pavlov


git-svn-id: svn://10.0.0.236/trunk@51277 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:04:40 +00:00
dougt%netscape.com
48fd2584d2 removing an extra release (16832)
Now doing a QI when getting a proxy so that the IID matches the |in| real
object.

r=jud


git-svn-id: svn://10.0.0.236/trunk@51276 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:04:20 +00:00
akkana%netscape.com
60d8465f63 16844: modifier key presses shouldn't insert anything into the editor. r=brade
git-svn-id: svn://10.0.0.236/trunk@51275 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 20:02:44 +00:00
varada%netscape.com
459ff2f953 fixes for bug #14014 changed EditBox types to Text in the widgets
git-svn-id: svn://10.0.0.236/trunk@51274 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 19:59:00 +00:00
putterman%netscape.com
3a0d0bf033 Fixes 15771 and 10603. Scrolling up in tree widget doesn't lose treeitems. r=hyatt.
git-svn-id: svn://10.0.0.236/trunk@51273 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 19:48:58 +00:00
bienvenu%netscape.com
6b88f85516 fix memory leak of literal string creating rdf node r=scottip
git-svn-id: svn://10.0.0.236/trunk@51272 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 19:06:53 +00:00
scc%netscape.com
0d129de64e eliminate warnings, r=shaver
git-svn-id: svn://10.0.0.236/trunk@51271 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 18:59:00 +00:00
waterson%netscape.com
95123cee1f Bug 15146. Factor nsXULElement's members into prototype and optional 'slots' for heavyweight elements. r=hyatt.
git-svn-id: svn://10.0.0.236/trunk@51270 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 18:55:32 +00:00
cmanske%netscape.com
353d58e800 Fixed bug 16868. r=brade
git-svn-id: svn://10.0.0.236/trunk@51269 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 18:43:56 +00:00
nisheeth%netscape.com
ddb8cb8f28 Changes should not affect build. Ongoing work to make the stopwatch code build on Unix.
git-svn-id: svn://10.0.0.236/trunk@51268 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 18:43:34 +00:00
bienvenu%netscape.com
b205486bc1 fix memory leak of default pref dir file spec r=sspitzer
git-svn-id: svn://10.0.0.236/trunk@51267 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 18:42:30 +00:00
bienvenu%netscape.com
09d199c08a fix memory leaks with mime string bundles and v-cards r=rhp
git-svn-id: svn://10.0.0.236/trunk@51266 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 18:41:49 +00:00
sspitzer%netscape.com
ee0c7447a5 fix for #16820, #16821. r=alecf, a=leaf. fix the pre-select the compose "From" identity
based on the selection in the folder pane.  it broken when I removed the FindServerUsingURI()
method a few days ago.  all better now.


git-svn-id: svn://10.0.0.236/trunk@51265 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 18:31:26 +00:00
leila.garin%eng.sun.com
74762b6d76 Added BWTestThread.java in makefiles, removed print stmt. from TestLoader
git-svn-id: svn://10.0.0.236/trunk@51264 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 17:21:23 +00:00
terry%mozilla.org
3e3cacb732 Ignore the "shadow" and "temp" directories.
git-svn-id: svn://10.0.0.236/trunk@51263 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 16:26:04 +00:00
kipp%netscape.com
deab3a6af2 new
git-svn-id: svn://10.0.0.236/trunk@51262 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 15:31:51 +00:00
kipp%netscape.com
aecc167cc9 Use local images
git-svn-id: svn://10.0.0.236/trunk@51261 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 15:31:26 +00:00
kipp%netscape.com
d4e0127173 Made test run locally without a net
git-svn-id: svn://10.0.0.236/trunk@51260 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 15:31:11 +00:00
terry%mozilla.org
970e03fe63 Fix perl warning.
git-svn-id: svn://10.0.0.236/trunk@51259 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 15:17:37 +00:00
dcone%netscape.com
9abd146c48 Fixed the rounded border rendering code to obey solid, and none style types.
Also bumped all the rounded rects onto pixel boundaries before rendering.


git-svn-id: svn://10.0.0.236/trunk@51258 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 14:46:27 +00:00
law%netscape.com
df6e65595b Fix for bug #?????; Avoid false positive on check for -f cmd line option; r=warren@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51257 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 14:40:25 +00:00
karnaze%netscape.com
6418d90654 Remove caching cell spacing as margin on cells, reducing 16 bytes and avoiding potentially unique style contexts; simplified cell margin calculations; r=troy
git-svn-id: svn://10.0.0.236/trunk@51256 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 14:18:56 +00:00
cmanske%netscape.com
5e0a77611f Fixed bugs 12515, 16493,16494,16495,16692,16794,most of 9758. Replaced old 'target' icon with interim 'anchor' icon. r=sfraser
git-svn-id: svn://10.0.0.236/trunk@51255 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 14:15:25 +00:00
terry%mozilla.org
bf28c3efd8 Fix perl warning.
git-svn-id: svn://10.0.0.236/trunk@51254 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 14:12:43 +00:00
mscott%netscape.com
2f8bc8e00f Bug #16843 and #16832 where we were crashing when dismissing dialogs. this may not be the final
fix but in an earlier change to this file today, this class stopped addreffing an event queue member variable.
But the dtor still released a reference to the event queue that it didn't have!
The eventual fix may be to put the addref back in there but I need to talk to dougt about this.

this is real danm's fix. i'm the reviewer.


git-svn-id: svn://10.0.0.236/trunk@51253 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 08:35:36 +00:00
danm%netscape.com
f98e5e2bc8 fixing obvious flaw in Unlink. r:waterson@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51252 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 08:35:04 +00:00
tbogard%aol.net
501277d9f2 Integrated some changes made by buster. Still talking some them over, but here for now.
git-svn-id: svn://10.0.0.236/trunk@51251 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 07:37:37 +00:00
cls%seawood.org
47d0316267 Some compilers complain if you declare variables after a potential goto call so move the declarations to the top of the function. Should fix the linux libc5 SM-Ports tinderbox & gcc 2.95 builds.
a=mscott


git-svn-id: svn://10.0.0.236/trunk@51250 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 05:40:05 +00:00
cls%seawood.org
31fb034e97 Use PRBool instead of bool as some compilers do not understand bool. Should fix a couple of SM-Ports tinderboxen.
r=sfraser a=mscott


git-svn-id: svn://10.0.0.236/trunk@51249 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 05:37:18 +00:00
waldemar%netscape.com
e9e8df96c5 Removed types from bottom expressions
git-svn-id: svn://10.0.0.236/trunk@51245 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 02:27:53 +00:00
waldemar%netscape.com
ed5c56be64 First Checked In.
git-svn-id: svn://10.0.0.236/trunk@51244 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 02:27:34 +00:00
law%netscape.com
95fc4f832f Fixes for bug #16789; permit OpenDialog to work on hidden window even if document load has not completed yet; r=norris@netscape.com, r=danm@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51243 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 01:25:41 +00:00
cmanske%netscape.com
a978b9e92b Changed a comment. This and last checkin were reviewed by mjudge
git-svn-id: svn://10.0.0.236/trunk@51241 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 01:06:05 +00:00
cmanske%netscape.com
22bf05aebd Adding menu item to start Composer from Browser debug menu as workaround for bug 16789 (can't start editor on command line). Also removed editor init page from code that's not even run?
git-svn-id: svn://10.0.0.236/trunk@51240 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 01:03:39 +00:00
edburns%acm.org
8af706c11b Added Swing webclient test code and windows makefile mods.
Author=Ann Sunhachawee
r=edburns@acm.org
Approver=edburns@acm.org
Bug=http://bugzilla.mozilla.org/show_bug.cgi?id=16842


git-svn-id: svn://10.0.0.236/trunk@51239 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:49:28 +00:00
waldemar%netscape.com
cc0c52492a Changed syntax of getters and setters to "get name" and "set name". Relaxed grammar constraints on definitions. Changed over to colon syntax for types. Added local visibility and block modifiers.
git-svn-id: svn://10.0.0.236/trunk@51238 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:46:31 +00:00
evaughan%netscape.com
e5f071ac53 fixed numerous warnings. Reviewed by Hyatt.
git-svn-id: svn://10.0.0.236/trunk@51237 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:46:21 +00:00
waldemar%netscape.com
83bc932793 Removed octal escapes. Replaced bottom by throw of syntax error.
git-svn-id: svn://10.0.0.236/trunk@51236 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:43:58 +00:00
waldemar%netscape.com
db1c1b6e5e Removed octals. Removed rational-to-integer, which was replaced by semantic subtyping. Replaced bottom by throw of syntax error.
git-svn-id: svn://10.0.0.236/trunk@51235 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:43:22 +00:00
waldemar%netscape.com
11aeb1c87d Removed rational-to-integer and types in bottom calls, which were replaced by semantic subtyping
git-svn-id: svn://10.0.0.236/trunk@51234 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:42:17 +00:00
waldemar%netscape.com
f02f9a2f0c Removed rational-to-integer, which was replaced by semantic subtyping
git-svn-id: svn://10.0.0.236/trunk@51233 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:41:59 +00:00
waldemar%netscape.com
1234934b00 Added semantic subtyping, throw, and catch
git-svn-id: svn://10.0.0.236/trunk@51232 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:40:55 +00:00
waldemar%netscape.com
bc5b327059 Fixed bug that would sometimes emit a newline between a backslash and its following escaped character
git-svn-id: svn://10.0.0.236/trunk@51231 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:40:04 +00:00
terry%mozilla.org
60beb90ee5 Fixed stupid perl warning.
git-svn-id: svn://10.0.0.236/trunk@51230 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:27:16 +00:00
alecf%netscape.com
30aa1d1d5c remove old gifs
git-svn-id: svn://10.0.0.236/trunk@51229 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:19:23 +00:00
alecf%netscape.com
ba963eb07e remove old gif
git-svn-id: svn://10.0.0.236/trunk@51228 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:18:32 +00:00
alecf%netscape.com
1bfdda92a8 remove unused images
git-svn-id: svn://10.0.0.236/trunk@51227 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:15:50 +00:00
mcafee%netscape.com
fcf9fe791f minor whitespace
git-svn-id: svn://10.0.0.236/trunk@51226 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:14:23 +00:00
larryh%netscape.com
2efaf6b409 BugSplat 367096
git-svn-id: svn://10.0.0.236/trunk@51225 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:12:37 +00:00
norris%netscape.com
b2e9644e2b Work on 1646 [DOGFOOD] javascript: URLs aren't working
r=mstoltz


git-svn-id: svn://10.0.0.236/trunk@51224 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:12:04 +00:00
alecf%netscape.com
59c413637f remove old gifs
git-svn-id: svn://10.0.0.236/trunk@51223 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:11:46 +00:00
larryh%netscape.com
eb823e8216 BugSplat 367096
git-svn-id: svn://10.0.0.236/trunk@51222 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:07:01 +00:00
terry%mozilla.org
11426df64d Fixed stupid perl warning.
git-svn-id: svn://10.0.0.236/trunk@51221 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:06:41 +00:00
kipp%netscape.com
7903586ee4 Removed some silly warnings
git-svn-id: svn://10.0.0.236/trunk@51220 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-20 00:06:12 +00:00
despotdaemon%netscape.com
4f6f8b68b0 Pseudo-automatic update of changes made by jmas@softcatala.org.
git-svn-id: svn://10.0.0.236/trunk@51219 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:58:29 +00:00
kipp%netscape.com
32b2148862 Added new test
git-svn-id: svn://10.0.0.236/trunk@51218 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:53:31 +00:00
despotdaemon%netscape.com
fc8c4bd300 Pseudo-automatic update of changes made by leaf@mozilla.org.
git-svn-id: svn://10.0.0.236/trunk@51217 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:51:38 +00:00
pollmann%netscape.com
e0757a21ca Bug 15729: Fall back to content when getting text value; r=vidur
git-svn-id: svn://10.0.0.236/trunk@51216 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:43:58 +00:00
selmer%netscape.com
b2360b9a85 fix for crash on cancel newconfig dialog
git-svn-id: svn://10.0.0.236/trunk@51215 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:43:13 +00:00
alecf%netscape.com
959275c4ac return null identity on null or empty key
no bug
r=sspitzer


git-svn-id: svn://10.0.0.236/trunk@51214 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:37:54 +00:00
dveditz%netscape.com
c097cd276c reenabling 6986-fix for the mac, r-dougt
git-svn-id: svn://10.0.0.236/trunk@51213 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:17:54 +00:00
despotdaemon%netscape.com
efa03bb824 Pseudo-automatic update of changes made by jmas@softcatala.org.
git-svn-id: svn://10.0.0.236/trunk@51212 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:13:07 +00:00
leaf%mozilla.org
843c7df9fb adding mozilla/embedding and mozilla/docshell to SeaMonkeyCore
git-svn-id: svn://10.0.0.236/trunk@51211 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:09:34 +00:00
kipp%netscape.com
3096ad4a52 r=ftang; fixed off by one error that made return value oPrev inconsistent
git-svn-id: svn://10.0.0.236/trunk@51210 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:06:27 +00:00
kipp%netscape.com
4befc8fe5e Added more tests
git-svn-id: svn://10.0.0.236/trunk@51209 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:04:55 +00:00
kipp%netscape.com
2d9044ac40 new
git-svn-id: svn://10.0.0.236/trunk@51208 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:04:33 +00:00
kipp%netscape.com
9c72c46de9 Fixed O(N^2) debug logic bug; speed up paint loop by avoiding painting too much now that we have combined-area (bug 7455, 12297)
git-svn-id: svn://10.0.0.236/trunk@51207 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:04:19 +00:00
kipp%netscape.com
bbbab95269 update to new nsTextTransformer api
git-svn-id: svn://10.0.0.236/trunk@51206 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:01:58 +00:00
kipp%netscape.com
6b051cc38a r=ftang; rewrite to fix 16656, parts of 7455
git-svn-id: svn://10.0.0.236/trunk@51205 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:01:45 +00:00
kipp%netscape.com
d6884c9b41 Init text-transformer during module setup to save cycles (bug 7455)
git-svn-id: svn://10.0.0.236/trunk@51204 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 23:01:23 +00:00
amusil%netscape.com
1d95656844 Fixed bug in editing anonymous attributes in database. Now all attributes get modified instead
of only the first.


git-svn-id: svn://10.0.0.236/trunk@51203 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:46:29 +00:00
tbogard%aol.net
c820ac974d More documentation and clean-up of the interfaces.
git-svn-id: svn://10.0.0.236/trunk@51202 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:40:28 +00:00
tbogard%aol.net
e5684d8a64 Added some documentation.
git-svn-id: svn://10.0.0.236/trunk@51201 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:39:57 +00:00
nisheeth%netscape.com
fedd700745 Checkin does not affect build. If MOZ_PERF is set to 1 define the compiler define MOZ_PERF_METRICS for the windows build.
git-svn-id: svn://10.0.0.236/trunk@51200 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:37:53 +00:00
valeski%netscape.com
cc447b7234 14659, r=gagan&warren&dougt
Misc. FTP changes:
*increased FTP buffer read/write size from 4k to 8k.
*removed un-needed (for now) SetPASV() for FTP connection thread
*string optimizations
*FTP Connection thread now uses the NS_IMPL_ISUPPORTS4 macro for addref, rel, and QI methods.
*connection cache key api consolidation (Get()/Remove() combo turned into Remove(key)).

Authentication dialog changes:
*Authentication dialog now includes host name the user is trying to connect to.

nsIRequest support:
*FTP Connection thread now maintains a member variable pointing to it's event queue. It also pumps the event queue in the main loop.
*FTP Connection thread now implemented the nsIRequest interface (never called directly; only via the nsFTPChannel api)
*FTP Channel now uses an xpcom proxy object to make the nsIRequest api calls on the FTP Connection thread.

FTP protocol interpretation changes:
*FTP now handles servers that send multi-line greetings in the first Read() (we blocked indefinately before)
*FTP now parses the parent working directory properly (used to always treat it as '/')


git-svn-id: svn://10.0.0.236/trunk@51199 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:37:47 +00:00
dougt%netscape.com
0377b9291c Fix for bug 16818. xpcom proxy does not handle classes with two or more
interfaces correctly.  What happens is the real object is addref
incorrectly and will never be deleted.

r=jud


git-svn-id: svn://10.0.0.236/trunk@51198 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:35:54 +00:00
dp%netscape.com
fabbeba48e Fixed warnings. r=pam nunn
git-svn-id: svn://10.0.0.236/trunk@51197 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:28:38 +00:00
nisheeth%netscape.com
b7fab4e31c Changes should not affect the build. Renaming the RAPTOR_PERF_METRICS ifdef to MOZ_PERF_METRICS.
git-svn-id: svn://10.0.0.236/trunk@51196 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:27:20 +00:00
dp%netscape.com
bf856b8053 Converting implementations of QueryInterface() to the std one. This
fixes bugs in the previous implementation that caused unbalanced
refcounts and premature releases. Thanks for rpotts for the heads
up. r=pam nunn


git-svn-id: svn://10.0.0.236/trunk@51195 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:27:08 +00:00
cathleen%netscape.com
1f3c5b3ef3 add txmgr.xpt to core list, like the rest of the editor files.
also removed a couple of obsolete files from the list


git-svn-id: svn://10.0.0.236/trunk@51194 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:03:29 +00:00
pnunn%netscape.com
c88ef4fe6e clean up associated with bug#15817, gif decoder. r: dp@netscape.com.
Removing obsolete file.


git-svn-id: svn://10.0.0.236/trunk@51193 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:02:49 +00:00
warren%netscape.com
077b0c94d4 Added 'PageCycler' code so that we can iterate through URL loads (by calling mozilla.exe -f <file-of-urls>). We need this for adding bloat/leaks info to tinderbox. r=law
git-svn-id: svn://10.0.0.236/trunk@51192 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:01:28 +00:00
danm%netscape.com
855118ba4a retire event queues even on Windows when they're no longer used. part of bug 15856. r:hyatt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51191 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 22:00:12 +00:00
rods%netscape.com
2a900deed8 The code that checked to see whether it should explicitly set focus on the gfx's containing widget
now uget the new focused content's frame instead of using the mCurrentTarget. The mCurrentTarget
is correct for a mouse down but incorrect for a "tab". This is because the mCurrentTarget points at
the currently focused content for a tab event, instead of the new content.
r=joki, bug 11162


git-svn-id: svn://10.0.0.236/trunk@51190 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:57:43 +00:00
pnunn%netscape.com
cc3d6490a5 bug# 16785. r: dp, valeski, neeti. Send mimetype info from channel to imglib.
If no decoder, sniff data stream for mime info.


git-svn-id: svn://10.0.0.236/trunk@51189 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:49:20 +00:00
alla%lysator.liu.se
cba2b194ce Update the GtkMozilla widget so it works. Also updated the streaming interface
so that it works with Necko. Small cleanups.
Fixes 16576 and 14975. r=shaver


git-svn-id: svn://10.0.0.236/trunk@51188 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:46:33 +00:00
norris%netscape.com
0b51721d30 Remove references to unsupported JVM_ calls. Needed for bug 16577.
r=shaver


git-svn-id: svn://10.0.0.236/trunk@51187 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:45:29 +00:00
dp%netscape.com
41b9a6b713 Removing prototype of NS_NewDocumentElementFrame. r=evaughan
git-svn-id: svn://10.0.0.236/trunk@51186 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:40:54 +00:00
locka%iol.ie
1e319234e1 Implemented ShowContextMenu so that CBrowse can display custom popup menus in response to right mouse clicks
git-svn-id: svn://10.0.0.236/trunk@51185 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:39:42 +00:00
tbogard%aol.net
ab0c88be9a Ooops, last night removing one warning uncovered another. r=gimpy
git-svn-id: svn://10.0.0.236/trunk@51184 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:34:21 +00:00
terry%mozilla.org
d1fca29577 Need to value_quote() things that go into VALUE attributes in HTML.
git-svn-id: svn://10.0.0.236/trunk@51183 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:27:41 +00:00
despotdaemon%netscape.com
a0b1fe8617 Pseudo-automatic update of changes made by paw@netscape.com.
git-svn-id: svn://10.0.0.236/trunk@51182 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:26:55 +00:00
endico%mozilla.org
2e29901945 align "edit products" at the top so its not lost 3 screens down in the products list.
git-svn-id: svn://10.0.0.236/trunk@51181 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:26:39 +00:00
bienvenu%netscape.com
bad04c3403 fix nsImapProtocol leaks r=mscott, no bug #
git-svn-id: svn://10.0.0.236/trunk@51180 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:24:31 +00:00
pierre%netscape.com
9264bc9c89 added stopwatch.cpp to the mac build for nisheeth
git-svn-id: svn://10.0.0.236/trunk@51179 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:12:14 +00:00
slamm%netscape.com
4481922240 Handle clicks properly. Fix for 14857 and 11986. r=rjc
git-svn-id: svn://10.0.0.236/trunk@51178 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:11:39 +00:00
cathleen%netscape.com
2d960ed1c1 additional cleanup, and previous checked in added wallet chrome files, partial fix for bug 15220
git-svn-id: svn://10.0.0.236/trunk@51177 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:09:04 +00:00
rogerl%netscape.com
4e16b4e094 r=norris
Delayed functionDef from creating property until after the body parses
succesfully.


git-svn-id: svn://10.0.0.236/trunk@51176 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:07:45 +00:00
mscott%netscape.com
2fc150a6c8 no bug number. I found that we were making an extra copy of the message body before writing it to the stream.
I was able to fix this by using a nsCString instead of an nsString for the message body. Also, audited the file
to use nsCAutoString instead of nsString to save some extra copying. Used NS_WITH_SERVICE macros for componenet
mananager and register service. Added some com ptr useage too.
r=rhp


git-svn-id: svn://10.0.0.236/trunk@51175 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:06:42 +00:00
rogerl%netscape.com
d0725e4d4e r=norris
Fixed bug #12951 - var if for..in statement should always be of type
string.


git-svn-id: svn://10.0.0.236/trunk@51174 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:06:03 +00:00
neeti%netscape.com
ee6aa2ffd0 updating status
git-svn-id: svn://10.0.0.236/trunk@51172 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:03:33 +00:00
cathleen%netscape.com
0fffda37f6 *** empty log message ***
git-svn-id: svn://10.0.0.236/trunk@51170 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:02:43 +00:00
mscott%netscape.com
6823e8565b Bug #16538 --> pass the emitter into NS_NewPipe as a pipe observer.
r=jefft


git-svn-id: svn://10.0.0.236/trunk@51169 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:02:27 +00:00
mscott%netscape.com
7524389c82 Bug #16538 --> the emitter now supports nsIPipeObserver and we'll now flush our output stream when we are told
it is full. This fixes the problem where large attachements were truncated at 32K.
r=jefft


git-svn-id: svn://10.0.0.236/trunk@51168 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 21:01:54 +00:00
Jerry.Kirk%Nexwarecorp.com
c40a73a776 Fixes to correct lots of extra drawing because of incorrectly clipped regions
Bug #16698 r=kedl


git-svn-id: svn://10.0.0.236/trunk@51167 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 20:50:17 +00:00
selmer%netscape.com
2ff1cb0969 CheckListBox supports descriptions (bug #4884)
git-svn-id: svn://10.0.0.236/trunk@51166 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 20:30:18 +00:00
norris%netscape.com
d201925571 7261 Connect XPConnect visibility filter to query principals
Reviewed by mstoltz.


git-svn-id: svn://10.0.0.236/trunk@51165 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 20:28:24 +00:00
rods%netscape.com
15f62c11c2 cleaned up warning, result hidding another, r=kmcclusk, (no bug)
git-svn-id: svn://10.0.0.236/trunk@51164 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:59:06 +00:00
rods%netscape.com
959963c9b8 fixed several warning and fixed setting the wrap property enum to off r=kmcclusk, bug 16770
git-svn-id: svn://10.0.0.236/trunk@51163 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:58:07 +00:00
rods%netscape.com
88de486c18 removed comma after last enum, warning clean up, r=kmcclusk (no bug)
git-svn-id: svn://10.0.0.236/trunk@51162 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:56:35 +00:00
varada%netscape.com
0d2cedd9ae setting focus in edit boxes in dialog boxeson init
git-svn-id: svn://10.0.0.236/trunk@51161 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:53:40 +00:00
beard%netscape.com
45cf1dc448 for JBindery runner, added System.exit()
git-svn-id: svn://10.0.0.236/trunk@51160 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:43:31 +00:00
rpotts%netscape.com
0f75f32b71 bug #15560. Changed the LoadGroup to fire notifications via PLEvents to stop reenterency.
git-svn-id: svn://10.0.0.236/trunk@51159 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:42:55 +00:00
terry%mozilla.org
d49cc3e1d1 Fixed perl warning.
git-svn-id: svn://10.0.0.236/trunk@51158 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:42:49 +00:00
rpotts%netscape.com
cd23316388 bug #15560. Changed the LoadGroup to fire notifications via PLEvents to stop reenterency.
git-svn-id: svn://10.0.0.236/trunk@51157 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:36:07 +00:00
danm%netscape.com
88e77696a0 added CreateFromIThread. r:valeski@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51156 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:18:27 +00:00
troy%netscape.com
36419b7094 b=16781, r=vidur@netscape.com
Re-ordered destructor to delete maps after destroying the frame hierarchy


git-svn-id: svn://10.0.0.236/trunk@51154 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:06:37 +00:00
locka%iol.ie
1468b5f4ac Updated to include new registry entries
git-svn-id: svn://10.0.0.236/trunk@51153 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:06:31 +00:00
selmer%netscape.com
3fd4887790 Removing Recede...
git-svn-id: svn://10.0.0.236/trunk@51152 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:06:29 +00:00
selmer%netscape.com
5bdff5a335 Putting button names back
git-svn-id: svn://10.0.0.236/trunk@51151 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:04:11 +00:00
shaver%netscape.com
2d88ea3522 corrected assembly, from Ulrich Drepper <drepper@cygnus.com> (16612, r=shaver)
git-svn-id: svn://10.0.0.236/trunk@51150 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:03:01 +00:00
pollmann%netscape.com
7c466fda74 Bug 16725: Enable align attribute for iframe; r=harishd
git-svn-id: svn://10.0.0.236/trunk@51149 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 19:01:49 +00:00
selmer%netscape.com
7dac51627e Interpret functions moved to interpret.cpp; memory allocations cleaned up
git-svn-id: svn://10.0.0.236/trunk@51148 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 18:58:38 +00:00
leila.garin%eng.sun.com
46abc39ebf New perl automated script.
git-svn-id: svn://10.0.0.236/trunk@51147 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 18:48:53 +00:00
despotdaemon%netscape.com
494eaeb121 Pseudo-automatic update of changes made by leaf@mozilla.org.
git-svn-id: svn://10.0.0.236/trunk@51146 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 17:34:13 +00:00
despotdaemon%netscape.com
8b64d99548 Pseudo-automatic update of changes made by exv@randomc.com.
git-svn-id: svn://10.0.0.236/trunk@51145 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 17:20:25 +00:00
terry%mozilla.org
9195dc1900 Fixed perl warnings.
git-svn-id: svn://10.0.0.236/trunk@51144 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 16:41:40 +00:00
norris%netscape.com
bd1c7245f6 Fixed bug. We weren't loading classes in bottom-up dependency order.
Subject:
            Re: another getClassLoader exception
       Date:
            Mon, 18 Oct 1999 22:01:24 -0400
      From:
            Andrew Wason <aw@softcom.com>
        To:
            norris@netscape.com (Norris Boyd)
        CC:
            Howard Lin <howard@softcom.com>
 References:
            1 , 2




At 05:03 PM 10/18/99 -0700, Norris Boyd wrote:
>Are you still seeing this problem?


Yes.  I just did a CVS update to get the latest stuff and we still have
this problem.

I wrote a standalone sample program that duplicates the problem.  Run
JSSupport and you should get this exception:

defineClass org.mozilla.javascript.gen.c2
Exception in thread "main" java.lang.NoClassDefFoundError:
org/mozilla/javascript/gen/c1
         at java.lang.ClassLoader.resolveClass0(Native Method)
         at java.lang.ClassLoader.resolveClass(ClassLoader.java:545)
         at
JSSupport$MySecuritySupport$DataClassLoader.loadClass(JSSupport.java:89)
         at JSSupport$MySecuritySupport.defineClass(JSSupport.java:47)
         at org.mozilla.javascript.optimizer.Codegen.compile(Codegen.java,
Compiled Code)
         at org.mozilla.javascript.Context.compile(Context.java:1761)
         at org.mozilla.javascript.Context.compile(Context.java:1691)
         at org.mozilla.javascript.Context.compileReader(Context.java:810)
         at org.mozilla.javascript.Context.evaluateReader(Context.java:725)
         at org.mozilla.javascript.Context.evaluateString(Context.java:692)
         at JSSupport.<init>(JSSupport.java:20)
         at JSSupport.main(JSSupport.java:9)



Andrew



>--N
>
>Andrew Wason wrote:
>
> > At 04:54 PM 10/12/99 -0700, Norris Boyd wrote:
> > >I just checked in changes so that the class calling ScriptRuntime (c5
> in your
> > >case) will load the class itself using the normal Java classloading
> mechanism
> > >rather than an explicit call to the class loader. I pushed the bits up
> to the
> > >ftp site, but it takes a bit to propagate.
> >
> > I get this exception now (debugging statements are from my code):
> >
> > SecuritySupport.defineClass org.mozilla.javascript.gen.c5
> > DataClassLoader.loadClass org.mozilla.javascript.gen.c5
> > DataClassLoader.loadClass org.mozilla.javascript.gen.c4
> > using default loader com.softcom.realjava.PluginClassLoader@da9486a0
> > java.lang.NoClassDefFoundError: org/mozilla/javascript/gen/c4
> >          at java.lang.ClassLoader.resolveClass0(Native Method)
> >          at java.lang.ClassLoader.resolveClass(ClassLoader.java:545)
> >          at
> >
> com.softcom.realjava.plugins.RealJavaScript$RealJavaScriptSecuritySupport$Da
> > taClassLoader.loadClass(RealJavaScript.java:410)
> >          at
> >
> com.softcom.realjava.plugins.RealJavaScript$RealJavaScriptSecuritySupport.de
> > fineClass(RealJavaScript.java:352)
> >          at org.mozilla.javascript.optimizer.Codegen.compile(Codegen.java,
> > Compiled Code)
> >          at org.mozilla.javascript.Context.compile(Context.java:1761)
> >          at org.mozilla.javascript.Context.compile(Context.java:1691)
> >          at org.mozilla.javascript.Context.compileReader(Context.java:810)
> >
> > So when c5 is being loaded by my SecuritySupport, it also needs to load c4.
> > I decompiled org.mozilla.javascript.gen.c5 and it's constant pool
> > references CLASS org.mozilla.javascript.gen.c4, so c5 is dependent on c4
> > being loadable.  Is the problem that c5 is being loaded before the
> > optimizer has defined c4?
> >
> > I get the above exception for some classes and not others.  It seems
> > consistent that I always get it for classes with dependencies on other
> > optimizer classes that haven't been generated yet.
> >
> > Andrew
> >
> > --
> > Andrew Wason
> > SoftCom, Inc.
> > aw@softcom.com

--
Andrew Wason
SoftCom, Inc.
aw@softcom.com



   JSSupport.java

                  Name:
                         JSSupport.java
                   Type:
                         Java Source File (text/java)
                Encoding:
                         base64


git-svn-id: svn://10.0.0.236/trunk@51143 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 16:38:23 +00:00
terry%mozilla.org
c94f0dfbd5 Fixed perl warnings.
git-svn-id: svn://10.0.0.236/trunk@51142 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 16:33:06 +00:00
terry%mozilla.org
4d41190cf3 This was using complicated perl features I don't understand, so I simplified it and it works now...
git-svn-id: svn://10.0.0.236/trunk@51141 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 16:24:48 +00:00
terry%mozilla.org
fae1be4423 Fixed perl warning.
git-svn-id: svn://10.0.0.236/trunk@51140 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 15:07:27 +00:00
terry%mozilla.org
c51e515d06 Fix perl warnings.
git-svn-id: svn://10.0.0.236/trunk@51139 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 15:05:16 +00:00
brade%netscape.com
736ea51be4 add images from Dan Haddix (r=pavlov@pavlov.net)
git-svn-id: svn://10.0.0.236/trunk@51138 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 14:53:55 +00:00
bienvenu%netscape.com
22abb4e345 fix ref count logging on nsMimeImpl r=warren
git-svn-id: svn://10.0.0.236/trunk@51137 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 14:50:09 +00:00
brade%netscape.com
d885aed29d add images from Dan Haddix (r=rods@netscape.com)
git-svn-id: svn://10.0.0.236/trunk@51136 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 14:44:01 +00:00
troy%netscape.com
0bdf9140d7 Changes to frame property API (code's not being used yet)
git-svn-id: svn://10.0.0.236/trunk@51135 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 14:41:55 +00:00
rods%netscape.com
186216cd35 changed font-family and margin settings for input text and textareas
r-kmcclusk, Bug #4072


git-svn-id: svn://10.0.0.236/trunk@51134 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 13:39:59 +00:00
brade%netscape.com
f27c8ca4ba function for image map editor added (contributed by Dan Haddix)
git-svn-id: svn://10.0.0.236/trunk@51133 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 13:34:34 +00:00
brade%netscape.com
156010fda2 First Checked In.
git-svn-id: svn://10.0.0.236/trunk@51132 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 13:32:22 +00:00
brade%netscape.com
2eaffc0b34 add images for Dan Haddix (image map editor)
git-svn-id: svn://10.0.0.236/trunk@51131 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 13:31:25 +00:00
rods%netscape.com
d3a58b07b8 Changed the sizing comparison for NavQuirks in debug mode to get the font family and size
for the input text  and textarea, I also changed the border calc for only when the
the size is explicitly set.
r=kmcclusk, Bug #3040,11285


git-svn-id: svn://10.0.0.236/trunk@51130 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 11:59:01 +00:00
rods%netscape.com
701a5f632f Moved GetWrapProperty to nsFormControlHelper
Changed add the added of scrollbar sizes for Standard mode
r=kmcclusk, Bug #3040,11285


git-svn-id: svn://10.0.0.236/trunk@51129 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 11:58:53 +00:00
rods%netscape.com
94117fe06b Added methods for getting a frame's current font and
for calculating the nsIFormControlFrame's NavQuirks size
Added two methods for getting the "wrap" property and andded a new enum
for for testing against instead of a string
Added a method for calculating the size when in NavQuirks modes, this currently
duplicates the algorithms for for input text and textareas
r=kmcclusk, Bug #3040,11285


git-svn-id: svn://10.0.0.236/trunk@51128 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 11:58:50 +00:00
rods%netscape.com
4df3a52095 Removed old commented out code and unused comments. r=kmcclusk, (no bug)
git-svn-id: svn://10.0.0.236/trunk@51127 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 11:35:17 +00:00
rods%netscape.com
7df83f9c8c Added a method in the debug build to return the Navigator size for a given
for control for a given font family and size. Used for NavQuirks testing only.
r=kmcclusk, Bugs #3040, 4072


git-svn-id: svn://10.0.0.236/trunk@51126 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 11:34:00 +00:00
rickg%netscape.com
6dafd0deac fixed bug 16584; CRCRLF not handled correctly. r=syd
git-svn-id: svn://10.0.0.236/trunk@51125 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 08:52:30 +00:00
tbogard%aol.net
b70777ae81 Removed the last of gimpy's warnings. r=gimpy.
git-svn-id: svn://10.0.0.236/trunk@51124 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 08:03:11 +00:00
jband%netscape.com
88ae89c00d trivial fix to get rid of warning from copy/paste error - was passing unused argument to printf
git-svn-id: svn://10.0.0.236/trunk@51123 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 08:00:29 +00:00
tbogard%aol.net
4d16c8e921 Another warning. r=gimpy.
git-svn-id: svn://10.0.0.236/trunk@51122 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 07:59:20 +00:00
tbogard%aol.net
b17c3685f5 Fixed a few more of gimpy's warnings..... Oh, we found a bug there. r=gimpy Total warnings now under 200!
git-svn-id: svn://10.0.0.236/trunk@51121 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 07:57:51 +00:00
tbogard%aol.net
8b7f08fbc0 Removing gimpy's warnings. r=gimpy. This brings us down to 200. :)
git-svn-id: svn://10.0.0.236/trunk@51120 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 07:50:55 +00:00
tbogard%aol.net
ceae1958d8 Removed border from the XUL browser, editor, and iframe tags. This allows content coming up in chromeless pop-up windows not be visually cluttered with a needless border. r=hyatt.
git-svn-id: svn://10.0.0.236/trunk@51119 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 07:40:44 +00:00
cls%seawood.org
beb3488154 Add newline at end of file for broken compilers.
git-svn-id: svn://10.0.0.236/trunk@51118 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 06:40:25 +00:00
beard%netscape.com
8af0179bfb changed NSLibraryStartup.o to NSComponentStartup.o, since it's really a component. r=jband
git-svn-id: svn://10.0.0.236/trunk@51117 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 06:31:49 +00:00
jband%netscape.com
defd5464f8 fixing brendan's copy/paste bug that broke gc. r=shaver
git-svn-id: svn://10.0.0.236/trunk@51116 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 05:58:07 +00:00
dp%netscape.com
ab76ab5c8c Fixing warning. Moved declaration into if 0 block.
git-svn-id: svn://10.0.0.236/trunk@51115 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 05:49:04 +00:00
cls%seawood.org
8644b9e14b Use PR_TRUE instead of c++ keyword "true" in case of broken/out-of-date compilers.
r=syd


git-svn-id: svn://10.0.0.236/trunk@51114 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 05:38:27 +00:00
cls%seawood.org
0d7e9393fb Syncing Makefile.ins with srinivas' previous checkin.
r=shaver


git-svn-id: svn://10.0.0.236/trunk@51113 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 05:30:36 +00:00
troy%netscape.com
85565b9667 Changed a comment
git-svn-id: svn://10.0.0.236/trunk@51112 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 05:00:30 +00:00
troy%netscape.com
670fa6c8d6 Change to code that's not currently being used. Before it gets used it
will get code reviewed


git-svn-id: svn://10.0.0.236/trunk@51111 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 04:52:33 +00:00
troy%netscape.com
a34fdc41e1 Didn't actually change anything. Just moved two functions up higher in the
file to make the Solaris compiler happy...


git-svn-id: svn://10.0.0.236/trunk@51110 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 04:50:34 +00:00
selmer%netscape.com
727f93afc4 Minor cleanup
git-svn-id: svn://10.0.0.236/trunk@51109 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 03:46:54 +00:00
alecf%netscape.com
5e8b124880 event targets for checkboxes now reflect reality
(just a test, not part of product)


git-svn-id: svn://10.0.0.236/trunk@51108 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 03:16:45 +00:00
jefft%netscape.com
668bbc4967 removed obsolete menubar xul tag; fixed bug 16145; r=rhp, ducarroz; a=dp
git-svn-id: svn://10.0.0.236/trunk@51107 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 03:08:43 +00:00
waterson%netscape.com
6a8fd22671 Obsolete.
git-svn-id: svn://10.0.0.236/trunk@51106 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 03:05:25 +00:00
beard%netscape.com
de43edf0b2 fixed histogram sorting.
git-svn-id: svn://10.0.0.236/trunk@51105 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 03:03:12 +00:00
pierre%netscape.com
bdfce7679a Fix build in Mac embedding apps after last week's changes in nsIWebShell.
git-svn-id: svn://10.0.0.236/trunk@51104 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 03:02:01 +00:00
pierre%netscape.com
f1aa92ba58 Fix a crash in Mac embedding apps: HasGfxScrollBars() checks for null pointer after calling GetPrefs().
git-svn-id: svn://10.0.0.236/trunk@51103 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 03:00:47 +00:00
alecf%netscape.com
de2e6cfb95 land new DOMViewer branch
no reviewer, not part of product, just a test


git-svn-id: svn://10.0.0.236/trunk@51102 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 02:46:45 +00:00
selmer%netscape.com
7f47a31e88 Fixes to make enable/disable work in checklist.ini
git-svn-id: svn://10.0.0.236/trunk@51100 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 02:41:48 +00:00
Jerry.Kirk%Nexwarecorp.com
9518fbd96c moving Push/PopThreadEventQueue to nsIEventQueueService.
This is required to get anythinbg to work now...
r=danm@netscape.com


git-svn-id: svn://10.0.0.236/trunk@51099 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 02:26:53 +00:00
endico%mozilla.org
b6decda29b search patterns are limited to 29 characters due to the -n option in glimpse
git-svn-id: svn://10.0.0.236/trunk@51098 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 02:14:09 +00:00
despotdaemon%netscape.com
77a9ed2910 Pseudo-automatic update of changes made by pfong@julian.uwo.ca.
git-svn-id: svn://10.0.0.236/trunk@51097 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 02:04:40 +00:00
alecf%netscape.com
6557db6b98 Start to land DOMViewer branch (extension - not part of product)
git-svn-id: svn://10.0.0.236/trunk@51096 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 02:01:40 +00:00
selmer%netscape.com
e654e9fdbb Changed interpretation & initialization to use onInit and onCommand INI file directives
git-svn-id: svn://10.0.0.236/trunk@51094 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 01:30:18 +00:00
slamm%netscape.com
0bbf0c1cfd Fix build bustage
git-svn-id: svn://10.0.0.236/trunk@51093 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 01:29:44 +00:00
sspitzer%netscape.com
ed6cbe944d other part of fix for #15235. fix send later. r=alecf
git-svn-id: svn://10.0.0.236/trunk@51092 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 01:24:25 +00:00
sspitzer%netscape.com
a8b4e077c5 part of fix for #15235. get send later to work again. r=alecf
git-svn-id: svn://10.0.0.236/trunk@51091 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 01:23:54 +00:00
despotdaemon%netscape.com
49bc011b9b Pseudo-automatic update of changes made by jfalzon@julian.uwo.ca.
git-svn-id: svn://10.0.0.236/trunk@51090 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 01:11:16 +00:00
dougt%netscape.com
fa7e2137bd Fix for bug 14784. Moved pref item up. r=cathleen.
git-svn-id: svn://10.0.0.236/trunk@51089 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 01:01:51 +00:00
despotdaemon%netscape.com
569c5aba2d Pseudo-automatic update of changes made by scosta@julian.uwo.ca.
git-svn-id: svn://10.0.0.236/trunk@51088 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:51:34 +00:00
srinivas%netscape.com
263860675d Update with post-3.5 fixes on the tip
git-svn-id: svn://10.0.0.236/trunk@51087 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:40:39 +00:00
pierre%netscape.com
51196f76b4 Fix #12737 "-moz-fixed should be compat mode only". Overwrites the fixed font family with the normal font family in navQuirks mode only. r=pollmann.
git-svn-id: svn://10.0.0.236/trunk@51086 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:31:45 +00:00
Jerry.Kirk%Nexwarecorp.com
3b650617aa Removed some hacks that were no longer necessary because of fixes made
on GFX side to fix nsRegion and the double buffer routines. Also
removed the DOUBLE_CLICK messages as directed by someone, I forget now who.
Bug 16698 r=Michael.Kedl@Nexwarecorp.com


git-svn-id: svn://10.0.0.236/trunk@51085 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:29:33 +00:00
Jerry.Kirk%Nexwarecorp.com
03c368d1b3 Various fixes to correct bugs in nsRegionPh and to correct clipping
done by the double buffer routines.
Bug# 16698 r=Michael.Kedl@Nexwarecorp.com


git-svn-id: svn://10.0.0.236/trunk@51084 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:27:56 +00:00
selmer%netscape.com
a711824bea Enable/Disable for Network builds
git-svn-id: svn://10.0.0.236/trunk@51083 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:27:21 +00:00
terry%mozilla.org
c4afb2ebc0 Fixed perl warning.
git-svn-id: svn://10.0.0.236/trunk@51082 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:25:42 +00:00
terry%mozilla.org
42d190d77d Fixed stupid perl warning.
git-svn-id: svn://10.0.0.236/trunk@51081 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:20:52 +00:00
terry%mozilla.org
877a31dd8a Fix potential security hole (and I think some perl warnings.)
git-svn-id: svn://10.0.0.236/trunk@51080 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:17:54 +00:00
larryh%netscape.com
a6a41c799e BugZilla 16566
git-svn-id: svn://10.0.0.236/trunk@51079 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:15:05 +00:00
terry%mozilla.org
2249323ac8 Fixed perl warnings -- this module no longer defines its own "die" routine.
git-svn-id: svn://10.0.0.236/trunk@51078 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:07:23 +00:00
despotdaemon%netscape.com
4654177ca6 Pseudo-automatic update of changes made by jhuntley@julian.uwo.ca.
git-svn-id: svn://10.0.0.236/trunk@51077 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:05:52 +00:00
terry%mozilla.org
a4508fd4ea Fixed stupid perl warning.
git-svn-id: svn://10.0.0.236/trunk@51076 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:04:59 +00:00
nhotta%netscape.com
a310c234a4 Fixing the linux build bustage.
git-svn-id: svn://10.0.0.236/trunk@51075 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:03:57 +00:00
edburns%acm.org
d2f14fa650 r=neeti@netscape.com
bug: 16679
approved by: neeti@netscape.com

Return NS_ERROR_FAILURE when a cookie is not found.


git-svn-id: svn://10.0.0.236/trunk@51074 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:03:33 +00:00
terry%mozilla.org
35043c37a6 Fixed stupid perl warning.
git-svn-id: svn://10.0.0.236/trunk@51073 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 00:02:42 +00:00
terry%mozilla.org
282909ff22 Fixed stupid perl warnings.
git-svn-id: svn://10.0.0.236/trunk@51072 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:57:58 +00:00
despotdaemon%netscape.com
0f0eb4c9e6 Pseudo-automatic update of changes made by shaver@netscape.com.
git-svn-id: svn://10.0.0.236/trunk@51070 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:53:02 +00:00
srinivas%netscape.com
fcf52e9477 Initial version
git-svn-id: svn://10.0.0.236/trunk@51068 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:46:10 +00:00
jband%netscape.com
039dd4adee checking in code to fix bug 12768 submitted by Dan.Oscarsson@trab.se. Needed a 'const char*' tmp varible to work with a 'const char*' buffer that was passed in. The same problem is in both js.c and xpcshell.cpp. r=jband
git-svn-id: svn://10.0.0.236/trunk@51066 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:45:39 +00:00
terry%mozilla.org
f8f7d2f6fc Fixed stupid perl warning.
git-svn-id: svn://10.0.0.236/trunk@51065 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:42:25 +00:00
terry%mozilla.org
565f556bd3 Fixed stupid perl warning.
git-svn-id: svn://10.0.0.236/trunk@51064 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:35:57 +00:00
alecf%netscape.com
bd2182e45d add big comment describing how this dialog works
(no reviewer, no bug, just comments)


git-svn-id: svn://10.0.0.236/trunk@51063 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:35:53 +00:00
alecf%netscape.com
dd194c9fb7 fix for #15685
r=sspitzer
rdf: prefix on XML attributes was confusing the template


git-svn-id: svn://10.0.0.236/trunk@51062 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:35:22 +00:00
nhotta%netscape.com
fc73fd2088 Checking in a fix for the linux build bastage,
git-svn-id: svn://10.0.0.236/trunk@51061 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:32:45 +00:00
terry%mozilla.org
94c58cd2a0 Oops; fixed perl error.
git-svn-id: svn://10.0.0.236/trunk@51060 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:32:03 +00:00
terry%mozilla.org
6856a7ee21 Fixed stupid perl warning.
git-svn-id: svn://10.0.0.236/trunk@51059 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:23:08 +00:00
jband%netscape.com
fb63cac2a5 checking in bug 16629 fix to cbegle's xpconnect tests submitted by green@FreeBSD.org. This fixes screwy longlong test methods. r=jband
git-svn-id: svn://10.0.0.236/trunk@51058 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:20:16 +00:00
alecf%netscape.com
88779549b8 fix typedef so this compiles with boehm's own makefile or mozilla's makefile.in
git-svn-id: svn://10.0.0.236/trunk@51057 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:17:02 +00:00
alecf%netscape.com
35edd9a187 we should actually be using generic threads so unhide this stuff
git-svn-id: svn://10.0.0.236/trunk@51056 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:15:44 +00:00
briano%netscape.com
2f40b34ffb Automated update
git-svn-id: svn://10.0.0.236/trunk@51055 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:15:10 +00:00
alecf%netscape.com
ad85636e7f build boehm when flag is used r=sspitzer
(last checkin also r=sspitzer)


git-svn-id: svn://10.0.0.236/trunk@51054 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:14:16 +00:00
alecf%netscape.com
a6598d4a1c add flag for boehm (doesn't quite work yet)
git-svn-id: svn://10.0.0.236/trunk@51053 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:13:47 +00:00
waterson%netscape.com
ffa36fb99e Move nsXULElement declaration into the header file.
git-svn-id: svn://10.0.0.236/trunk@51052 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:05:35 +00:00
terry%mozilla.org
8662f77243 Fixed stupid perl warning.
git-svn-id: svn://10.0.0.236/trunk@51051 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 23:04:40 +00:00
terry%mozilla.org
93cd29ad2b Massive spank to put "use strict" in all Bonsai code.
git-svn-id: svn://10.0.0.236/trunk@51050 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:55:01 +00:00
alecf%netscape.com
36d234884e remove makefiles that arent' part of the module anymore
git-svn-id: svn://10.0.0.236/trunk@51049 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:49:05 +00:00
rickg%netscape.com
217ed89f11 fixed bug16624; r=buster. Buffer used to translate unicode entities in forms wasn't being truncated.
git-svn-id: svn://10.0.0.236/trunk@51048 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:39:58 +00:00
ducarroz%netscape.com
4f836323d6 Fix for bug 15313 & 15536. .txt files are now interpreted as XML document. Therefore we need to load a .html file even if it content is purely plain text. R=rhp
git-svn-id: svn://10.0.0.236/trunk@51047 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:38:54 +00:00
sspitzer%netscape.com
01d0e55136 fix for #16259, r=alecf. use the right line endings on the mac. now, instead of putting the LINEBREAK in every string, and then
writing every string to the stream, we do the line ending when we write to the stream.


git-svn-id: svn://10.0.0.236/trunk@51046 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:38:53 +00:00
slamm%netscape.com
3981b8f2c8 Update checkout target. Add logging. Stop on conflicts. r=dougt
git-svn-id: svn://10.0.0.236/trunk@51045 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:33:32 +00:00
nhotta%netscape.com
25c87328ce Changed interface and implementation of nsIEntityConverter,
more entity support (before Latin1 only), added a string based interface. Bug fix 8865, r=ftang.


git-svn-id: svn://10.0.0.236/trunk@51044 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:33:14 +00:00
cata%netscape.com
76ebba554f Conversion to Module. Reviewed by dp. Bug #15589.
git-svn-id: svn://10.0.0.236/trunk@51043 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:23:28 +00:00
troy%netscape.com
c8965f4626 r=kipp@netscape.com Moved ownership of root frame (and frame hierarchy) over to
the frame manager


git-svn-id: svn://10.0.0.236/trunk@51042 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:20:37 +00:00
ftang%netscape.com
2476a575cf fix bug 16656, change the test condiction for NS_PRECONDICTION. also add some error checking code for null ptr. r=erik
git-svn-id: svn://10.0.0.236/trunk@51041 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:17:16 +00:00
waterson%netscape.com
911c570602 Remove nsRDFElement.cpp
git-svn-id: svn://10.0.0.236/trunk@51040 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:08:39 +00:00
waterson%netscape.com
7a9241890d Rename nsRDFElement to nsXULElement; rename nsXULElement to nsXULAggregateElement.
git-svn-id: svn://10.0.0.236/trunk@51039 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:08:15 +00:00
waterson%netscape.com
ce617a2441 Rename nsRDFElement to nsXULElement.
git-svn-id: svn://10.0.0.236/trunk@51038 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:07:36 +00:00
rhp%netscape.com
eff48efacc Change for separating inline attachments - Bug #16367 - r: bienvenu
git-svn-id: svn://10.0.0.236/trunk@51037 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 22:07:02 +00:00
buster%netscape.com
a8ec8337df some extremely minor cleanup of bugs found by ftang. Thanks, frank.
git-svn-id: svn://10.0.0.236/trunk@51036 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:59:19 +00:00
akhil.arora%sun.com
b931259907 16427 r=akhil.arora@sun.com fixed by Denis Sharypov <sdv@sparc.spb.su>
Found some more instances where the DOM spec says that it is not an error
  to return a NULL. Do not throw exceptions in these cases.


git-svn-id: svn://10.0.0.236/trunk@51035 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:53:20 +00:00
pavlov%netscape.com
b8fadf3327 clean up wizard code a bit
git-svn-id: svn://10.0.0.236/trunk@51034 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:52:03 +00:00
rods%netscape.com
ef34fa6834 Links will now scroll into view when they get focus and anchors now respond
to the .focus call from script. r=kmcclusk, Bug #15198


git-svn-id: svn://10.0.0.236/trunk@51033 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:49:38 +00:00
rods%netscape.com
a1a74387d0 Move code to handle focus event into the correct switch statement
r=kmcclusk, bug 7133


git-svn-id: svn://10.0.0.236/trunk@51032 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:47:31 +00:00
akhil.arora%sun.com
479581e81f 16488 r=akhil.arora@sun.com fixed by Denis Sharypov <sdv@sparc.spb.su>
Copy/Paste error- createEntityReference was calling the wrong coreDOM method


git-svn-id: svn://10.0.0.236/trunk@51031 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:44:57 +00:00
pavlov%netscape.com
9bfe6151f6 new files
git-svn-id: svn://10.0.0.236/trunk@51030 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:44:15 +00:00
law%netscape.com
25e63cd81a Bug #14999; stop using toolkit app core; r=sfraser@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51029 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:39:18 +00:00
law%netscape.com
45245a0e3f Bug #14999; stop using toolkit app core (added JavaScript[Debug].shlb to this project); r=sfraser@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51028 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:36:57 +00:00
norris%netscape.com
cb1dcdbdc6 Part of bug 7261 "Connect XPConnect visibility filter to query principals"
Reviewed by rhp@netscape.com.


git-svn-id: svn://10.0.0.236/trunk@51027 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:35:52 +00:00
waterson%netscape.com
08c93a00f3 Bug 15558. Fix personal toolbar style rules (patch courtesy dbaron@fas.harvard.edu). r=matt
git-svn-id: svn://10.0.0.236/trunk@51026 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:35:28 +00:00
law%netscape.com
c4ca3de4e5 Bug #14999; stop using toolkit app core; r=davidm@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51025 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:33:29 +00:00
pavlov%netscape.com
329e721fff update file list
git-svn-id: svn://10.0.0.236/trunk@51024 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:30:40 +00:00
law%netscape.com
1c3ac7d8fe Bug #14999; stop using toolkit app core; r=ducarroz@netscape.com
git-svn-id: svn://10.0.0.236/trunk@51023 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:29:54 +00:00
bienvenu%netscape.com
cf9daf3b34 change shutdown code to go through nsMessengerBootstrap instead of relying on service shutdown listener or destructors getting called r=alecf
git-svn-id: svn://10.0.0.236/trunk@51022 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:16:23 +00:00
ssu%netscape.com
ef93fdf802 fixing bug #16694. fixes crash bug in the select components dialog in the windows installer. r=sgehani. Affects only windows platform.
git-svn-id: svn://10.0.0.236/trunk@51021 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 21:15:09 +00:00
dp%netscape.com
068b895d74 Removing extra backslashes at the end of the install lines. Fixing
build.


git-svn-id: svn://10.0.0.236/trunk@51020 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 20:43:11 +00:00
sspitzer%netscape.com
80c75c7ae1 fix warnings. following alecf's recommendations, remove the FindServerUsingURI() method from the nsIMsgAccountManager, remove CreateFolderInDatasource() from nsIMsgFolder, change several methods in nsMsgCopy to return nsresult, and have nsIMsgFolder ** as an outparam, use GetResource() instead of CreateFolderInDatasource(). use NS_SUCCEEDED() instead of comparing against NS_OK directly.
git-svn-id: svn://10.0.0.236/trunk@51019 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 20:42:06 +00:00
brade%netscape.com
f24babcd8f make doEditor create an html editor rather than the plaintext editor. (bug #16681; r=sfraser@netscape.com)
git-svn-id: svn://10.0.0.236/trunk@51018 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 20:27:14 +00:00
harishd%netscape.com
cd72403513 Fix for Bug 16126 -- Error message was not getting propagated
to the parser ( CNavDTD::AddLeaf() )
Related to bug 16578 - Throwing userdefined tags to the floor
( what we used to do before ). This will avoid people from being
blocked.   Will work on a fix later.

r=nisheeth


git-svn-id: svn://10.0.0.236/trunk@51017 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 20:23:27 +00:00
selmer%netscape.com
f641e35434 Enable BoldText type
git-svn-id: svn://10.0.0.236/trunk@51016 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 20:22:21 +00:00
troy%netscape.com
16faac45a3 Removed delete operators (they had no implementation, they were private so
they wern't accidently called), because HP compiler generated an error if
new operator was public but delete operator was private


git-svn-id: svn://10.0.0.236/trunk@51015 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 20:16:49 +00:00
nhotta%netscape.com
83699f202b Add new propertie files for html entity, part of bug fix 8865, r=ftang.
git-svn-id: svn://10.0.0.236/trunk@51014 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 20:02:20 +00:00
tonyr%fbdesigns.com
b46af177f3 Added string bundles for the mailnews import tools
git-svn-id: svn://10.0.0.236/trunk@51013 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:58:07 +00:00
dougt%netscape.com
921610c409 Fix for 16700. Isolating CreateTransport into new function.
r=gagan.


git-svn-id: svn://10.0.0.236/trunk@51012 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:43:34 +00:00
warren%netscape.com
895b2679fc Made bloatdiff distinguish between no change in leaks, and infinite leakage (no leak before, but leak now).
git-svn-id: svn://10.0.0.236/trunk@51011 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:43:29 +00:00
selmer%netscape.com
ef18489b86 Corrected tab sort order
git-svn-id: svn://10.0.0.236/trunk@51010 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:39:42 +00:00
Jerry.Kirk%Nexwarecorp.com
614348b081 Installed our own PtMainLoop() function that can be exited to allow
the Create Profile Manager to display a dialog, then exit the GUI and display
a different dialog.
Bug# 16667 r=Michael.Kedl@Nexwarecorp.com


git-svn-id: svn://10.0.0.236/trunk@51009 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:34:07 +00:00
selmer%netscape.com
fb6169fb87 Temporary fixes for tab ordering
git-svn-id: svn://10.0.0.236/trunk@51008 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:23:11 +00:00
warren%netscape.com
91a872ec09 Took out redundant MOZ_COUNT_CTOR/DTOR calls.
git-svn-id: svn://10.0.0.236/trunk@51007 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:21:53 +00:00
slamm%netscape.com
900a118dd2 Landing of SIDEBAR_19991007_BRANCH. r=waterson
git-svn-id: svn://10.0.0.236/trunk@51006 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:21:52 +00:00
radha%netscape.com
b1aa689e2b Mail news regresion with replying to a message. r=mscott bug # 16550
git-svn-id: svn://10.0.0.236/trunk@51005 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:09:27 +00:00
warren%netscape.com
0ae271237a Made it implement nsIURL as well as nsIURI.
git-svn-id: svn://10.0.0.236/trunk@51004 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:07:16 +00:00
warren%netscape.com
671c8baf13 Cleanup to use nsCOMPtrs.
git-svn-id: svn://10.0.0.236/trunk@51003 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:06:57 +00:00
warren%netscape.com
a270067a3a Took out redundant MOZ_COUNT_CTOR/DTOR calls.
git-svn-id: svn://10.0.0.236/trunk@51002 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:06:21 +00:00
troy%netscape.com
a431ec5d07 b=16615. Two line change. Added check for case of root node being a leaf.
The rest of the changes are NOT yet in use. They willbe reviewed by Kipp before
they're turned on


git-svn-id: svn://10.0.0.236/trunk@51001 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:02:09 +00:00
akkana%netscape.com
ae4dba7c09 Remove two ifdef DEBUG_akkana lines that were left in when someone
changed the implementation of ConvertContentToXIF, so that I can
compile again.  This won't affect anyone but me.  r=kipp


git-svn-id: svn://10.0.0.236/trunk@51000 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:01:56 +00:00
troy%netscape.com
3a3c120af6 b=16652, r=troy@netscape.com
Patch from Johnny Stenback that breaks a weak link reference


git-svn-id: svn://10.0.0.236/trunk@50999 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:00:49 +00:00
shaver%netscape.com
408093c6c7 fix // comment in C file (r=brade)
git-svn-id: svn://10.0.0.236/trunk@50998 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 19:00:18 +00:00
rogerl%netscape.com
b4ac2f29ae Changed tests for ECMA 3 definition of array.length handling.
git-svn-id: svn://10.0.0.236/trunk@50995 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 16:55:44 +00:00
pavlov%netscape.com
2a38ab0914 revert some key code to pre branch landing so that typing works correctly
git-svn-id: svn://10.0.0.236/trunk@50993 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 16:08:16 +00:00
danm%netscape.com
21960bf642 adding PR_LOGging to event queue handling. r:hyatt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50992 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 15:09:50 +00:00
danm%netscape.com
c4ec5e4d7e moving Push/PopThreadEventQueue to nsIEventQueueService. r:hyatt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50991 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 15:08:45 +00:00
danm%netscape.com
5bb4aa8eb3 synching with nsWebShellWindow 1.219 (nsIModalWindowSupport removed). r:hyatt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50990 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 15:06:38 +00:00
danm%netscape.com
2d0400db89 removing nsIModalWindowSupport r:hyatt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50989 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 15:05:17 +00:00
danm%netscape.com
8e456a4690 moving Push/PopThreadEventQueue to nsIEventQueueService r:hyatt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50988 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 15:04:18 +00:00
danm%netscape.com
1dff151de6 patch nsEventQueue leak in GetProxyObject r:hyatt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50987 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 15:01:40 +00:00
danm%netscape.com
0b71323316 event queues own and delete themselves when they're done. bug 15856 r:hyatt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50986 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 14:59:57 +00:00
danm%netscape.com
e200e99d65 new r:hyatt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50985 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 14:57:07 +00:00
ftang%netscape.com
c18bf1d357 1. add asserting code to check null ptr
2. add if code and return NS_ERROR_NULL_POINTER if the ptr is null
3. add code to check return value 
r=myself


git-svn-id: svn://10.0.0.236/trunk@50984 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 14:48:41 +00:00
karnaze%netscape.com
905268d150 added #ifdef for debug printing.
git-svn-id: svn://10.0.0.236/trunk@50983 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 13:48:19 +00:00
karnaze%netscape.com
0b5271c1c7 bug 15958(partial) - uses mComputedWidth instead of availableSize.width. r=buster; asked hook for permission, got no response.
git-svn-id: svn://10.0.0.236/trunk@50982 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 13:47:01 +00:00
karnaze%netscape.com
aef57f8136 bug 15993 - in quirks mode allocates space for a 1 pixel border if the content is empty and the table has a border. It was incorrectly, doing this even if the content was not empty. r=buster; asked permission from hook and got no response.
git-svn-id: svn://10.0.0.236/trunk@50981 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 13:45:41 +00:00
dveditz%netscape.com
038ada687d stopgap for mysterious Mac bustage
git-svn-id: svn://10.0.0.236/trunk@50980 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 12:58:58 +00:00
dveditz%netscape.com
ddf8086d83 generate unique regkeys (6986)
git-svn-id: svn://10.0.0.236/trunk@50979 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 12:06:19 +00:00
srinivas%netscape.com
e8fb19a369 Include fcntl.h always. Bugizlla #16630.
git-svn-id: svn://10.0.0.236/trunk@50978 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 11:13:23 +00:00
dveditz%netscape.com
48a1d530ed variable name change to silence warning
git-svn-id: svn://10.0.0.236/trunk@50977 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 08:35:39 +00:00
dveditz%netscape.com
64356116f8 cleaning up warnings 15626; removing RegisterService/UnregisterService calls per request from dp
git-svn-id: svn://10.0.0.236/trunk@50976 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 05:56:15 +00:00
rickg%netscape.com
756b010b94 another WIP for bug 13536; added charset notification back in; r=harish
git-svn-id: svn://10.0.0.236/trunk@50975 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 05:14:38 +00:00
buster%netscape.com
7653742295 fixed bug 16486, r=brade@netscape.com
windows widget code handles control-key combinations correctly.


git-svn-id: svn://10.0.0.236/trunk@50974 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 03:39:48 +00:00
jband%netscape.com
8013d6bb78 fix typo in comment
git-svn-id: svn://10.0.0.236/trunk@50972 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 02:54:26 +00:00
jband%netscape.com
0a174a879e r=mccabe (I'll be adding more comments to the headers as requested)
Implement nsIXPCNativeCallContext to meet user feature
requirements. This allows simpler implementation of reflection of
native classes into JavaScript in cases where they need to
support legacy interfaces that include optional parameters and
method name overloading. This also provides a general mechanism
for native methods to discover if they were called from JS code,
exactly what JS parameters were passed, explicitly return jsvals,
and throw explicit jsvals without interference from xpconnect.
With test cases.


git-svn-id: svn://10.0.0.236/trunk@50971 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 02:53:04 +00:00
mcafee%netscape.com
6d347761bd Adding perl-path to match other tinderbox files.
git-svn-id: svn://10.0.0.236/trunk@50970 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 01:34:45 +00:00
rickg%netscape.com
c1b9043596 forgot to check this in for viewsource; bug13536; r=harish
git-svn-id: svn://10.0.0.236/trunk@50969 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 00:46:33 +00:00
dveditz%netscape.com
57ed2f138a hoping this fixes the mac bustage
git-svn-id: svn://10.0.0.236/trunk@50968 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 23:55:56 +00:00
pavlov%netscape.com
0d172a490d work around for not being able to type in text fields on unix without them closing your apps.
16564 and 16542 r=smfr


git-svn-id: svn://10.0.0.236/trunk@50966 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 23:27:50 +00:00
karnaze%netscape.com
a06cb090a4 new regression tests. does not affect build.
git-svn-id: svn://10.0.0.236/trunk@50965 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 23:26:02 +00:00
bienvenu%netscape.com
3f482a5e18 fix leak of profile dir in addr book session
git-svn-id: svn://10.0.0.236/trunk@50964 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 22:16:32 +00:00
shaver%netscape.com
b2f619e9fa fixing build by removing leftover #endif
git-svn-id: svn://10.0.0.236/trunk@50963 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 22:15:34 +00:00
dveditz%netscape.com
ea80c313d6 Added NR_RegFlush (14909, required for 16283/16600); warning cleanup (15626) r=shaver
git-svn-id: svn://10.0.0.236/trunk@50962 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 21:47:53 +00:00
karnaze%netscape.com
cf41a16010 new regression test, doesn't affect build.
git-svn-id: svn://10.0.0.236/trunk@50961 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 21:46:13 +00:00
dveditz%netscape.com
9d59534945 Added nsIRegistry::Flush (bug 16283, required for 16600), r=shaver
git-svn-id: svn://10.0.0.236/trunk@50960 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 21:45:53 +00:00
morse%netscape.com
04d5d271eb fix bug 16319, stop assertion failure, r=dp
git-svn-id: svn://10.0.0.236/trunk@50959 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 21:41:50 +00:00
shaver%netscape.com
8c73db21d3 make View->Use Stylesheet use type=radio. (r=hyatt)
git-svn-id: svn://10.0.0.236/trunk@50958 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 21:38:21 +00:00
shaver%netscape.com
f2a09249da Added support for type="radio" (pick-one) XP menus.
Cleaned up nsFrame class declaration a bit.
Added some API entries to nsIMenuFrame in support of type="radio"'s
pick-one behaviour.
Renamed UpdateMenuChecked to UpdateMenuSpecialState.
Removed stale string-splitting code in CreateAnonymousContent.
(r=hyatt,mcafee)


git-svn-id: svn://10.0.0.236/trunk@50957 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 21:37:37 +00:00
mscott%netscape.com
ee5e86e569 Bug #16394 --> no longer need to call intialize after creating a url
r=jefft


git-svn-id: svn://10.0.0.236/trunk@50956 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 20:04:59 +00:00
mscott%netscape.com
e396ccade3 Bug #16394 --> extract user name from the url spec. Don't force us to pass it in on initialize.
r=jefft


git-svn-id: svn://10.0.0.236/trunk@50955 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 20:04:40 +00:00
mscott%netscape.com
79e9036238 Bug #16394 --> Initialize now has no arguments.
r=jefft


git-svn-id: svn://10.0.0.236/trunk@50954 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 20:04:08 +00:00
mscott%netscape.com
71ebac111b Bug #16394 --> call Initialize function on url after we create one
r=jefft


git-svn-id: svn://10.0.0.236/trunk@50953 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 20:03:37 +00:00
briano%netscape.com
81d0f9cde9 Automated update
git-svn-id: svn://10.0.0.236/trunk@50952 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 15:30:18 +00:00
cls%seawood.org
3f3f4e0c22 r=pavlov
Add temporary --enable-nspr-autoconf option to allow platforms to test the newly added autoconf setup for nspr (bug 11893) before turning it on as default.


git-svn-id: svn://10.0.0.236/trunk@50951 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 15:16:47 +00:00
cls%seawood.org
5e7ffdc098 Bug 11893. r=shaver
Sync the autoconf Makefile.ins.


git-svn-id: svn://10.0.0.236/trunk@50950 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 15:12:41 +00:00
warren%netscape.com
a53c95056f Added .txt to delta file name.
git-svn-id: svn://10.0.0.236/trunk@50949 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 07:57:45 +00:00
warren%netscape.com
a0fc33207e Changed format slightly.
git-svn-id: svn://10.0.0.236/trunk@50948 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 07:52:19 +00:00
warren%netscape.com
990cda09f3 Changed format slightly.
git-svn-id: svn://10.0.0.236/trunk@50947 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 07:50:09 +00:00
warren%netscape.com
6a7c1e6176 Added bloat log diffing program.
git-svn-id: svn://10.0.0.236/trunk@50946 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 07:42:27 +00:00
warren%netscape.com
bc35fd61d0 Accidently got added in the wrong directory.
git-svn-id: svn://10.0.0.236/trunk@50945 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 07:30:25 +00:00
rickg%netscape.com
d16fa469ea removed warnings; no material code affected
git-svn-id: svn://10.0.0.236/trunk@50944 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 07:01:10 +00:00
karnaze%netscape.com
c96e8acd42 new regression test. does not affect code.
git-svn-id: svn://10.0.0.236/trunk@50943 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 05:17:41 +00:00
karnaze%netscape.com
0ee3058ec4 new regression test
git-svn-id: svn://10.0.0.236/trunk@50942 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 03:42:37 +00:00
troy%netscape.com
c04a6a88dc r=karnaze@netscape.com Cc'd hyatt@netscape.com
Space optimization. mBorderEdges is no longer an embedded object. Now it's
allocated when needed (for collapsing border model tables only). This saves
80 bytes per table cell frame for the normal HTML case of adjacent border
model


git-svn-id: svn://10.0.0.236/trunk@50941 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 03:30:11 +00:00
karnaze%netscape.com
84d23e1d2e bug 11321 - Renamed kidMaxElementSize to localKidMaxElementSize and renamed pKidMaxElementSize to kidMaxElementSize and fixed the incorrect usage.
git-svn-id: svn://10.0.0.236/trunk@50940 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 03:17:53 +00:00
karnaze%netscape.com
906709b8b6 bug 11321 - the frame constructor sets the primary frame when an anonymous table or row group frame is involved.
git-svn-id: svn://10.0.0.236/trunk@50939 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 03:15:13 +00:00
rickg%netscape.com
1a6a40a3c6 Fix (perf) bug 13536 dealing with viewsource; r=kmcclusk.
Viewsource is now based on XML. These changes make viewsource 2X faster,
30% smaller (in obj code), and uses between 30-60% less markup overhead.
This update also enables stylesheet usage on viewsource, which is controlled
by the viewsource namespace  in html.css.

Also, note that viewsource remains (and always has been) fully incremental.
Remaining performance issues are in contentsink as shown in quantify runs.


git-svn-id: svn://10.0.0.236/trunk@50938 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 02:50:38 +00:00
rickg%netscape.com
7f8bd4a5fc improve debug timing code for ongoing perf work; not enabled in normal build. r=peterl
git-svn-id: svn://10.0.0.236/trunk@50937 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 02:45:26 +00:00
sgehani%netscape.com
9868a31060 First Checked In.
git-svn-id: svn://10.0.0.236/trunk@50936 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 01:39:40 +00:00
sgehani%netscape.com
0c1e14a45f File Removed.
git-svn-id: svn://10.0.0.236/trunk@50935 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 01:36:14 +00:00
warren%netscape.com
c81e025f6f Added bloat log diffing program.
git-svn-id: svn://10.0.0.236/trunk@50934 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-17 00:19:29 +00:00
morse%netscape.com
f4c14fbc7e remove build warning, r=jar
git-svn-id: svn://10.0.0.236/trunk@50933 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 23:37:28 +00:00
morse%netscape.com
2464d177c4 fix bug 15137, open->openDialog, r=jar
git-svn-id: svn://10.0.0.236/trunk@50932 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 23:36:22 +00:00
bienvenu%netscape.com
65fd934be9 fix memory leak of user name r=mscott
git-svn-id: svn://10.0.0.236/trunk@50931 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 22:44:55 +00:00
bienvenu%netscape.com
170bb762af fix leaks in mime xul emitters r=rhp
git-svn-id: svn://10.0.0.236/trunk@50930 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 20:49:06 +00:00
bienvenu%netscape.com
a6a7ff9957 fix memory leak in install notifier r=dougt
git-svn-id: svn://10.0.0.236/trunk@50929 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 20:48:36 +00:00
morse%netscape.com
051b2edf1a fix bug 10434, memory leak detection, r=sfraser
git-svn-id: svn://10.0.0.236/trunk@50928 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 19:34:10 +00:00
rickg%netscape.com
b03845b337 updated FAQ section of nsString documentation
git-svn-id: svn://10.0.0.236/trunk@50927 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 18:45:18 +00:00
rickg%netscape.com
3169a02cfa WIP bug13536; r=peterl; this code is not used yet
git-svn-id: svn://10.0.0.236/trunk@50926 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 18:22:24 +00:00
bienvenu%netscape.com
21e8b134dc fix build bustage
git-svn-id: svn://10.0.0.236/trunk@50925 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 18:16:21 +00:00
bienvenu%netscape.com
0ddfb1fd70 remove unused all threads table r=davidmc
git-svn-id: svn://10.0.0.236/trunk@50924 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 17:55:59 +00:00
troy%netscape.com
3e862c4fc9 Space optimization, r=karnaze@netscape.com Cc'd hyatt@netscape.com
Save 4 bytes by eliminating the mCalculated data member which wasn't being used


git-svn-id: svn://10.0.0.236/trunk@50923 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 16:17:07 +00:00
bienvenu%netscape.com
74fc660d77 fix memory leaks r=mscott
git-svn-id: svn://10.0.0.236/trunk@50922 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 15:43:26 +00:00
karnaze%netscape.com
60203265cd added 2 additional file lists to regression tests to work around new javascript bug.
git-svn-id: svn://10.0.0.236/trunk@50921 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 05:26:22 +00:00
peterl%netscape.com
be312e3eea Made style rules work against nsIMutableStyleContext
r=troy


git-svn-id: svn://10.0.0.236/trunk@50920 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 04:06:04 +00:00
peterl%netscape.com
f3c05f912b Added new style data accessors.
Added nsIMutableStyleContext interface.
Made style rules work against nsIMutableStyleContext
r=troy


git-svn-id: svn://10.0.0.236/trunk@50919 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 04:05:59 +00:00
neeti%netscape.com
a279c2f778 updating status
git-svn-id: svn://10.0.0.236/trunk@50918 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 03:07:59 +00:00
neeti%netscape.com
f3b4c01e52 Converted dll to use nsIModule - bug 14034, r=dp
git-svn-id: svn://10.0.0.236/trunk@50916 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 03:05:55 +00:00
neeti%netscape.com
a87ba00c59 Converted dll to use nsIModule -bug 14034, r=jband
git-svn-id: svn://10.0.0.236/trunk@50915 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 03:04:16 +00:00
rhp%netscape.com
5839f11126 Changes to display when a message is coming from a 5.0 client - Bug #7518 - r: mscott
git-svn-id: svn://10.0.0.236/trunk@50914 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 02:38:24 +00:00
selmer%netscape.com
347b70512d CheckListBox used
git-svn-id: svn://10.0.0.236/trunk@50913 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 02:01:01 +00:00
selmer%netscape.com
9a7f96144c CheckListBox incorporated
git-svn-id: svn://10.0.0.236/trunk@50912 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 02:00:18 +00:00
warren%netscape.com
5cf514e9ae Added total/summary information to bloat log. Made LogNewXPCOM/LogDeleteXPCOM only be needed for losing architectures.
git-svn-id: svn://10.0.0.236/trunk@50911 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 01:57:18 +00:00
jevering%netscape.com
70a261fb73 The nsLeakDetector.cpp file now requires a few extra header files which weren't being exported on win
git-svn-id: svn://10.0.0.236/trunk@50910 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 01:44:52 +00:00
jevering%netscape.com
f66066c2c8 Removed a define I shouldn't have checked in.
git-svn-id: svn://10.0.0.236/trunk@50909 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 01:41:14 +00:00
varada%netscape.com
6f328194ff fixes to bug#7717 on exiting the wizard you get a message stating that data has been saved
git-svn-id: svn://10.0.0.236/trunk@50908 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 01:40:06 +00:00
jevering%netscape.com
6660a0bc5b Hooking up the Boehm collector.
Can we please call this thing the Bone Collector?  That would be much cooler.
Thank you drive through.


git-svn-id: svn://10.0.0.236/trunk@50907 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 01:22:01 +00:00
troy%netscape.com
6722de88b9 Added some new code that's not in use yet
git-svn-id: svn://10.0.0.236/trunk@50906 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 00:55:48 +00:00
rickg%netscape.com
85a81f49a8 WIP for bug13536; r=plinss
git-svn-id: svn://10.0.0.236/trunk@50905 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 00:39:24 +00:00
varada%netscape.com
54ba582bb1 new struct in header file
git-svn-id: svn://10.0.0.236/trunk@50904 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 00:16:36 +00:00
beard%netscape.com
7bd68dd578 added code to initialize/shutdown the leak detector. bug=15906, r=alecf
git-svn-id: svn://10.0.0.236/trunk@50903 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 00:06:37 +00:00
beard%netscape.com
774e39f024 renamed NSInitGarbageCollector/NSShutdownGarbageCollector to NS_, and returning nsresult. Moved leak report file to nsLeakDetector.cpp. bug=15906, r=alecf
git-svn-id: svn://10.0.0.236/trunk@50902 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 00:06:36 +00:00
beard%netscape.com
371afc89ab added nsLeakDetector.cpp to build. bug=15906, r=alecf
git-svn-id: svn://10.0.0.236/trunk@50901 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 00:03:45 +00:00
beard%netscape.com
a743954b5c maded entire file conditionally compile #if defined(GC_LEAK_DETECTOR). bug=15906, r=alecf
git-svn-id: svn://10.0.0.236/trunk@50900 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-16 00:02:26 +00:00
jevering%netscape.com
f820994c06 More windows porting of the boehm collector.
git-svn-id: svn://10.0.0.236/trunk@50899 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:45:47 +00:00
bienvenu%netscape.com
7ce48293df fix memory leak of registry location r=warren
git-svn-id: svn://10.0.0.236/trunk@50898 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:45:45 +00:00
cyeh%netscape.com
942579f723 proxy checkin for terry@mozilla.org. quiet warnings about uninitialized
variables at runtime


git-svn-id: svn://10.0.0.236/trunk@50897 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:43:52 +00:00
nisheeth%netscape.com
c916cc6da1 Changes do not get built in regular build. Fix timing hooks in the parser.
git-svn-id: svn://10.0.0.236/trunk@50896 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:42:09 +00:00
kipp%netscape.com
66125fa907 r=troy; revised nsITextContent api to simplify it and the consumers; this is done as prep work for bug 9101
git-svn-id: svn://10.0.0.236/trunk@50895 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:36:07 +00:00
sdagley%netscape.com
8916be1144 Fix #15740 - now check for immediate errors from async i/o calls. Also ensure that io_pending flag for the thread is cleared if we complete the async call before calling WaitOnThisThread(). r=sfraser
git-svn-id: svn://10.0.0.236/trunk@50894 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:35:27 +00:00
kipp%netscape.com
a1aaea4959 r=troy; fixed bug 7093 by carefully pre-computed the collapsed top margin before reflowing the child block and then using that value to properly acquire the available space; In addition, I had to fix an incremental reflow bug associated with this problem
git-svn-id: svn://10.0.0.236/trunk@50893 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:35:10 +00:00
terry%mozilla.org
6f2641b237 Fixed what I believe is just a stupid typo. (This code really needs to have
"use strict" added to it all, and with all the resulting cleanup.)


git-svn-id: svn://10.0.0.236/trunk@50892 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:31:22 +00:00
kipp%netscape.com
17b485a261 Wiped out another warning
git-svn-id: svn://10.0.0.236/trunk@50891 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:29:21 +00:00
kipp%netscape.com
ae469e66fe new
git-svn-id: svn://10.0.0.236/trunk@50890 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:25:02 +00:00
peterl%netscape.com
e8a5d2e937 Added namespace ID to the AttributeChanged notification
Part of the fix for Bug 15153
r=troy


git-svn-id: svn://10.0.0.236/trunk@50889 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:17:53 +00:00
peterl%netscape.com
bba68903df Added namespace ID to the AttributeChanged notification
Part fo the fix for Bug 15153
r=troy


git-svn-id: svn://10.0.0.236/trunk@50888 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:16:45 +00:00
terry%mozilla.org
762178f097 Fixed a bunch of "undefined variable" warnings.
git-svn-id: svn://10.0.0.236/trunk@50887 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:16:32 +00:00
peterl%netscape.com
5e2e0d9a32 Changed reported namespace of attributes from HTML to None.
r=vidur
Also added namespace ID to the AttributeChanged method
Part of the fix for Bug 15153
r=troy


git-svn-id: svn://10.0.0.236/trunk@50886 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:15:17 +00:00
peterl%netscape.com
48baad18a6 Added code to detect generated content that depends on attributes and reflow when the attribute changes
Fix for Bug 15153
r=pierre
Also added namespace ID to the AttributeChanged method
r=troy


git-svn-id: svn://10.0.0.236/trunk@50885 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 23:14:44 +00:00
varada%netscape.com
d237a54c3d fixes to bug #5987 changed the values of the buttons in the ini files
git-svn-id: svn://10.0.0.236/trunk@50884 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 22:56:37 +00:00
varada%netscape.com
15123c9a18 fixing bug #5987 - introduced three new fields in VARS in the ini files - cancel back and next - use those to change the text on the buttons
git-svn-id: svn://10.0.0.236/trunk@50883 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 22:55:06 +00:00
troy%netscape.com
52071cf0b1 Added some new code that isn't being used
git-svn-id: svn://10.0.0.236/trunk@50882 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 22:53:24 +00:00
gagan%netscape.com
7c5bb7d019 Added "resolving host" status notification for eSocketState_Created. No bug number. r=law.
git-svn-id: svn://10.0.0.236/trunk@50881 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 22:47:24 +00:00
jefft%netscape.com
f34b34e8a2 back out unneed changes which cause downloading messages to hang; bug 16338, r=bienvenu
git-svn-id: svn://10.0.0.236/trunk@50880 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 22:26:32 +00:00
sfraser%netscape.com
a529a81529 Added nsJSXULEditorElement and nsXULEditorElement for travis. r=travis.
git-svn-id: svn://10.0.0.236/trunk@50879 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 22:21:43 +00:00
waqar%netscape.com
2e88f3fb20 #9777
r vidur@netscape.com
d The issue was resolved by DOM commitie to allow SplitText to give an error
only on if the start of split is larger than the length. If it is same lenght
it is allowed.


git-svn-id: svn://10.0.0.236/trunk@50878 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 22:18:23 +00:00
beard%netscape.com
b457512e99 added nsLeakDetector.idl. bug=15906, r=alecf
git-svn-id: svn://10.0.0.236/trunk@50877 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 22:17:53 +00:00
cmanske%netscape.com
d3b17dbcb9 Fixed bugs 16316, 16494, 16495, all relating to editor file open, saving, and window title issues. r=law
git-svn-id: svn://10.0.0.236/trunk@50876 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 22:06:41 +00:00
tbogard%aol.net
a7ed2ac01b Changed TextEditorAppShell.xul to use the new XUL editor tag instead of html:iframe. Changed EditorStartup to take an element. Changed EditorStartup to request the EditorShell from the editorElement rather than doing a createInstance and QI. r=hyatt
git-svn-id: svn://10.0.0.236/trunk@50875 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:58:49 +00:00
jevering%netscape.com
19f7cec6df Windows makefile for boehm collector.
git-svn-id: svn://10.0.0.236/trunk@50874 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:57:31 +00:00
jevering%netscape.com
7a40245954 Forget continuation line - boehm collector work.
git-svn-id: svn://10.0.0.236/trunk@50873 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:56:51 +00:00
tbogard%aol.net
2aa2164659 Changed html:iframe to the new XUL editor tag. r=hyatt
git-svn-id: svn://10.0.0.236/trunk@50872 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:54:42 +00:00
norris%netscape.com
0ad2206225 Fix 16166 setTimeout() security problem
r=mstoltz


git-svn-id: svn://10.0.0.236/trunk@50871 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:52:37 +00:00
cls%seawood.org
84b2db2829 Files not used by build. Attempting to resolve cvs checkin problem. a=srinivas,leaf
git-svn-id: svn://10.0.0.236/trunk@50870 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:42:20 +00:00
Jerry.Kirk%Nexwarecorp.com
777d2a990a Fix for viewer bustage on Neutrino. Added call to nsIThread::SetMainThread
in main() of viewer so that it can retrieved in other cases. R=vidur


git-svn-id: svn://10.0.0.236/trunk@50869 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:39:30 +00:00
fur%netscape.com
1242a2627f Renamed variable to avoid a compiler warning. R: mccabe
git-svn-id: svn://10.0.0.236/trunk@50868 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:38:04 +00:00
shaver%netscape.com
a8a9b25086 Make View->Sidebar a type=checkbox menuitem (r=slamm)
git-svn-id: svn://10.0.0.236/trunk@50867 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:37:53 +00:00
cls%seawood.org
b8f8ee7596 Files not used by build. Attempting to resolve cvs checkin problem. a=srinivas,leaf
git-svn-id: svn://10.0.0.236/trunk@50866 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:36:53 +00:00
beard%netscape.com
c69becfcc9 First Checked In.
git-svn-id: svn://10.0.0.236/trunk@50865 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:36:04 +00:00
bienvenu%netscape.com
cb256a41dc fix shutdown leak by resetting host session list r=jefft
git-svn-id: svn://10.0.0.236/trunk@50864 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:35:55 +00:00
beard%netscape.com
ef31ca76db using dumpMemoryLeaks() instead of about:bloat?leaks. bug=15906, r=hyatt
git-svn-id: svn://10.0.0.236/trunk@50863 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:35:18 +00:00
beard%netscape.com
202835974e added dumpMemoryLeaks(). bug=15906, r=hyatt
git-svn-id: svn://10.0.0.236/trunk@50862 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:35:11 +00:00
akhil.arora%sun.com
e3af9ebeab 13260 r=akhil.arora@sun.com Fixed by Denis Sharypov <sdv@sparc.spb.su>
Added checks for integer arguments being outside of legal range and
  throw exceptions if not.


git-svn-id: svn://10.0.0.236/trunk@50861 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:25:56 +00:00
cmanske%netscape.com
b3ffd2ef95 Fixed bug 15442 - use about:blank for empty doc URL for editor. r=law
git-svn-id: svn://10.0.0.236/trunk@50860 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:24:45 +00:00
mccabe%netscape.com
dc9018f2ee Fix line editing support for the standalone XPCOM-enabled JavaScript shell. To aid debugging on unix platforms.
To use, define JS_READLINE when compiling mozilla/js/src/xpconnect/shell.

r=shaver


git-svn-id: svn://10.0.0.236/trunk@50859 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:23:53 +00:00
tbogard%aol.net
bb54504747 Adding support for retrieving the EditorShell from editor element. r=hyatt
git-svn-id: svn://10.0.0.236/trunk@50858 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:21:10 +00:00
brade%netscape.com
cb5f04d59d use the proper function calls to get the status for alt, shift and meta keys. bug #16486. reviewed valeski@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50857 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:20:57 +00:00
kipp%netscape.com
6b0a23c77d Nuke some more warnings
git-svn-id: svn://10.0.0.236/trunk@50855 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:18:32 +00:00
scc%netscape.com
38a4215c26 Bug #15292, r=dp. Made the component manager inherit from |nsSupportsWeakReference|, fixed its |QueryInterface()| appropriately, and added casts in two places that became ambiguous now that the component manager had multiple |nsISupports| in it. Now one can hold a weak reference to the component manager using |nsIWeakReference|.
git-svn-id: svn://10.0.0.236/trunk@50853 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:14:43 +00:00
law%netscape.com
d169b3d37b Fix for bugs #16525 and #16527, Remove menu separator when not link or frame, add back in missing items; r=matt@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50850 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:13:31 +00:00
shaver%netscape.com
130160f659 Add support for type="checkbox" in <menuitem>.
Converted small pile of PRBool to PRPackedBool for space savings.
r=hyatt


git-svn-id: svn://10.0.0.236/trunk@50849 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:13:24 +00:00
law%netscape.com
fbce7337a4 Fix for bug #16269, add resizable feature to view-source window, r=danm@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50848 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:11:22 +00:00
Jerry.Kirk%Nexwarecorp.com
bee1ad520f Handles KeyEvents the new way, not completely finished...
Bug # 16539 r=Michael.Kedl@Nexwarecorp.com


git-svn-id: svn://10.0.0.236/trunk@50847 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:10:36 +00:00
vidur%netscape.com
6fb05929c2 Fix for viewer bustage on Windows. Added call to nsIThread::SetMainThread in main() of viewer so that it can retrieved in other cases. R=kipp
git-svn-id: svn://10.0.0.236/trunk@50846 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:09:46 +00:00
tbogard%aol.net
a469976da4 Adding support for retrieving the EditorShell from editor element. r=hyatt
git-svn-id: svn://10.0.0.236/trunk@50845 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:07:27 +00:00
jefft%netscape.com
ce92446784 remove the size limit for downloading Pop3 message; bug 16338; r=bienvenu
git-svn-id: svn://10.0.0.236/trunk@50844 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 21:02:27 +00:00
waterson%netscape.com
d6562a99e8 Darnit. Didn't mean to FORCE_PR_LOG. Removing that #define.
git-svn-id: svn://10.0.0.236/trunk@50843 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 20:55:54 +00:00
tbogard%aol.net
a4dcc5f6fe First Check-in.
git-svn-id: svn://10.0.0.236/trunk@50842 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 20:51:58 +00:00
shaver%netscape.com
82e40a8366 Fix case and return value in nsIModule.idl.
Add deleteCategoryEntry and deleteCategory to nsICategoryManager.
Update nsCategoryManager.js to use new nsIModule case, and talk to the registry.
r=brendan


git-svn-id: svn://10.0.0.236/trunk@50841 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 20:51:38 +00:00
ssu%netscape.com
2c8714f0fe fixes bugs #15884 and #16220. r=dbragg. fixes Install.FileExecute for the
1 parameter format and also the function gets logged correctly in
install.log.


git-svn-id: svn://10.0.0.236/trunk@50840 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 20:50:49 +00:00
waterson%netscape.com
55b0508a7b Bug 9764. Fix HTML templates to ensure that attribute adding is namespace-agnostic. Add local variable for isUnique so that BuildContentFromTemplate will work if resource- and non-resource elements are siblings in a template. Add logging capability for debug. r=rjc.
git-svn-id: svn://10.0.0.236/trunk@50839 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 20:47:19 +00:00
ssu%netscape.com
8be86d2e54 fixes bug #6408 and #15393. r=dbragg. fixes windows installer xpinstall
error detection.  Windows platform only"


git-svn-id: svn://10.0.0.236/trunk@50838 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 20:47:15 +00:00
despotdaemon%netscape.com
3ff30eed90 Pseudo-automatic update of changes made by leaf@mozilla.org.
git-svn-id: svn://10.0.0.236/trunk@50837 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 20:06:46 +00:00
kipp%netscape.com
54422e686a Eliminate need for networked loaded images
git-svn-id: svn://10.0.0.236/trunk@50836 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 19:44:09 +00:00
slamm%netscape.com
5203f99e62 Need to quote parentheses in ignore pattern.
git-svn-id: svn://10.0.0.236/trunk@50835 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 18:42:27 +00:00
despotdaemon%netscape.com
4e198d349e Pseudo-automatic update of changes made by jst@citec.fi.
git-svn-id: svn://10.0.0.236/trunk@50834 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 17:14:41 +00:00
kipp%netscape.com
93d0d8d38f nuked
git-svn-id: svn://10.0.0.236/trunk@50833 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 16:58:21 +00:00
bienvenu%netscape.com
bc725fb9b5 fix crash reading messages with new profiles
git-svn-id: svn://10.0.0.236/trunk@50831 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 16:09:49 +00:00
beard%netscape.com
4afa5bff04 improved report format, included root list
git-svn-id: svn://10.0.0.236/trunk@50830 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 15:56:05 +00:00
brade%netscape.com
6f185f7761 fixes to handle for control keys (off by 1) (bug #15693) r=kin@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50829 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 14:56:33 +00:00
brade%netscape.com
a7ee842442 don't allow other modifiers when cut/copy/pasting (bug #15693); this missed the keyEvent branch. r=kin@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50828 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 14:52:45 +00:00
kipp%netscape.com
a41c4bbacd Removed old netlib code; changed url loading when crawling to use the event queue to fix some re-entrancy issues somewhat
git-svn-id: svn://10.0.0.236/trunk@50827 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 14:09:19 +00:00
kipp%netscape.com
f3b0bfeedb Added sorting to the debug dump data for show-frame-size and show-content-size
git-svn-id: svn://10.0.0.236/trunk@50826 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 14:08:14 +00:00
buster%netscape.com
34185693a8 bug 12221 [Dogfood] Gfx text controls need to notify on mouse events
r=rods@netscape.com
also did some associated performance work, factoring code and collapsing multiple listener
objects down to 1.  This saves a few allocations and about 60 bytes per text control.

bug 11803 Need new event for text value changing
r=hyatt@netscape.com
not dogfood approved, but the fix has been sitting in my tree for 2 weeks


git-svn-id: svn://10.0.0.236/trunk@50825 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 13:38:29 +00:00
buster%netscape.com
4225108b72 bug 11803 Need new event for text value changing
r=hyatt@netscape.com
not dogfood approved, but the fix has been sitting in my tree for 2 weeks


git-svn-id: svn://10.0.0.236/trunk@50824 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 13:37:06 +00:00
buster%netscape.com
dc3e971a7e bug 11803 Need new event for text value changing
r=hyatt@netscape.com
not dogfood, but the fix has been sitting in my tree for 2 weeks


git-svn-id: svn://10.0.0.236/trunk@50823 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 13:36:23 +00:00
buster%netscape.com
ab0550c29d no bug number, part of webshell cleanup. nsIWebShell.h was needlessly included, so I removed it
trivial change, no reviewer.


git-svn-id: svn://10.0.0.236/trunk@50822 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 13:34:45 +00:00
rods%netscape.com
a38b9c0061 Fixed focus processing, this new code is very close to version 1.54 but more robust,
this fixes bug #7133. It has been compiled and tested on Win, Mac, and Linux.
r=buster,dcone


git-svn-id: svn://10.0.0.236/trunk@50821 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 13:20:32 +00:00
despotdaemon%netscape.com
b4b7016433 Pseudo-automatic update of changes made by tomk@mitre.org.
git-svn-id: svn://10.0.0.236/trunk@50820 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 11:54:29 +00:00
hyatt%netscape.com
6c5c58d1e8 Fix for 16479. r=waterson
git-svn-id: svn://10.0.0.236/trunk@50819 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 07:54:43 +00:00
tbogard%aol.net
f56f56047f Fixed a couple of typos.
git-svn-id: svn://10.0.0.236/trunk@50818 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 07:52:50 +00:00
varada%netscape.com
818b65a0d4 inform function has been changed to take in two parameters to show the filename as well as the directory with absolute path
git-svn-id: svn://10.0.0.236/trunk@50817 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 07:45:20 +00:00
varada%netscape.com
23669a0409 changes from relative path to absolute path in interpret.cpp and validation of empty entry in ncidialog
git-svn-id: svn://10.0.0.236/trunk@50816 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 07:43:57 +00:00
jevering%netscape.com
e8deb39b49 Adding boehm collector to windows.
(not part of the build yet)


git-svn-id: svn://10.0.0.236/trunk@50815 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 07:41:54 +00:00
jevering%netscape.com
8c8649671d Adding boehm collector linkages to the windows build.
(not part of the build yet)


git-svn-id: svn://10.0.0.236/trunk@50813 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 07:40:13 +00:00
tbogard%aol.net
8fef749953 Changed the nativeWindowParent's to be a nativeWindow instead of a long. nativeWindow is a typedef'd voidStar.
git-svn-id: svn://10.0.0.236/trunk@50807 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 07:31:28 +00:00
tbogard%aol.net
9565067a46 First landing.
git-svn-id: svn://10.0.0.236/trunk@50805 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 07:23:53 +00:00
dp%netscape.com
8b5b037caf bug# 5085 Eliminating some checks at autoreg time to improve startup
performance. r=sfraser


git-svn-id: svn://10.0.0.236/trunk@50803 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 07:12:08 +00:00
waterson%netscape.com
9f70f9cb52 Add xpcnativecallcontext.cpp for jband.
git-svn-id: svn://10.0.0.236/trunk@50802 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 07:08:15 +00:00
varada%netscape.com
1882311d32 removing relative paths and evaluating absolute ones
git-svn-id: svn://10.0.0.236/trunk@50801 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 06:51:03 +00:00
dveditz%netscape.com
20b7b8aa72 expose libreg ability to delete named values in nsIRegistry. Patch from
Jonas Utterström <jonas.utterstrom@vittran.norrnod.se>, r=dveditz


git-svn-id: svn://10.0.0.236/trunk@50800 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 06:47:58 +00:00
rjc%netscape.com
9621ab20bf Fix leak in nsXULSortService (found by Boehm GC). Also, remove CTOR_COUNT stuff. Review: waterson@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50798 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 06:27:02 +00:00
brendan%mozilla.org
f2330eb459 1. Fixed missing JS_LOCK_GC in JS_YieldRequest, commented other badness there.
2.  Cleaned up ugly JS_GC_Flag typedef name and put XXXbe comment in there for
    next time: someone seems to have patched around a deadlock that has since
    bit chouck@geocast.com.
3.  Fixed gcDisabled by moving it from cx to rt and updating it atomically.
4.  Fixed ECMA violation where for (var i, j in o) ... was permitted; only one
    variable is allowed.
(Item 4 was a bug on rogerl's list, since closed?  r=shaver@mozilla.org.)


git-svn-id: svn://10.0.0.236/trunk@50795 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 05:46:42 +00:00
sspitzer%netscape.com
37928e864b fix possible solaris bustage by including the nsIFoo.h files when we have nsCOMPtr<nsIFoo> foo;
git-svn-id: svn://10.0.0.236/trunk@50794 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 05:10:28 +00:00
jband%netscape.com
32f352bb68 adding new empty placeholder file to the build. Will also add it to Mac project via camelot and put real stuff in it after all is stable. r=jband :)
git-svn-id: svn://10.0.0.236/trunk@50793 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 05:09:08 +00:00
sspitzer%netscape.com
b3c21470de more fixes to get copies and sent folder prefs to work right.
now, mailbox:// urls work.
change the logic of LocateMessageFolder() to be:

if (the target folder is not "anyfolder://") then {
	find the folder and return it if your find it.
	if you can't find it, create it in the datasource and return the folder.  see bug #14591
}
else {
	look for the default folder in any server associated with the current identity.
	if you find it, return it.
}


git-svn-id: svn://10.0.0.236/trunk@50790 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 05:03:03 +00:00
waterson%netscape.com
daa650308d Unclutter stuff by using nsCOMPtr in the nsElementMap::ContentListItem. Add leakenmacros to ContentListItem. Fix a leak in the the internal enumerator routine. Comment the internal enumerator routine since it's kinda funky. Add 'tag name' to the log messages.
git-svn-id: svn://10.0.0.236/trunk@50789 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:45:43 +00:00
sspitzer%netscape.com
f6806b13d3 remove unused variablable to fix a couple warnings.
git-svn-id: svn://10.0.0.236/trunk@50788 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:33:21 +00:00
shaver%netscape.com
103a22ed8e fix obj_getCount to property destroy state and propagate error (r=jband)
git-svn-id: svn://10.0.0.236/trunk@50787 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:32:46 +00:00
kin%netscape.com
9af25b17a4 Fix for bug #15360: Drag Selecting, Clicking, then Clicking leaves caret cruft.
r=troy@netscape.com,kipp@netscape.com,evaughan@netscape.com,beard@netscape.com

layout/html/base/src/nsGfxScrollFrame.cpp
    - Renamed all occurrences of ScrollPositionChanged() to
      to ScrollPositionDidChange() to match changes made
      to nsIScrollPositionListener.
    - Added ScrollPositionWillChange() stub method.

layout/html/base/src/nsPresShell.cpp
    - Added PresShellViewEventListener class that implements the
      nsIScrollPositionListener and nsICompositeListener view
      interfaces. This allows us to turn caret rendering on and off
      when scrolling and repainting to prevent leaving caret cruft
      on the screen.
    - PresShellViewEventListener is created in InitialReflow(), and
      released in ~PresShell().

view/public/Makefile.in
view/public/makefile.win
view/public/MANIFEST
    - Added nsICompositeListener to list of files to be exported.

view/public/nsICompositeListener.h
    - New file. Implementers of this interface can register themselves
      with the view manager to receive notification before and after
      a view is composited/refreshed.

view/public/nsIScrollPositionListener.h
    - Added a ScrollPositionWillChange() method.
    - Changed ScrollPositionChanged() to ScrollPositionDidChange().

view/public/nsIViewManager.h
    - Added AddCompositeListener() and RemoveCompositeListener methods.

view/src/nsScrollingView.cpp
view/src/nsScrollingView.h
    - Added NotifyScrollPositionWillChange() and
      NotifyScrollPositionDidChange() methods.
    - Modified HandleScrollEvent() to call NotifyScrollPositionWill/DidChange()
      methods. Added temporary offsetX and offsetY variables to allow us
      to calculate new offsets without changing mOffsetX and mOffsetY before
      notifications are sent out.

view/src/nsScrollPortView.cpp
    - Changed ScrollPositionChanged() to ScrollPositionDidChange().
    - Modified ScrollTo() to call the listener's ScrollPositionWillChange()
      method.

view/src/nsViewManager.cpp
view/src/nsViewManager.h
    - Added AddCompositeListener() and RemoveCompositeListener() methods.
    - Added support for CompositeListener notifications in the Refresh()
      methods for regions and rects.
    - Fix for bug #15901: [DOGFOOD] Selected text does not clear when you type
      Modified UpdateView() so that rects with zero width and height are
      no longer added to our damage region.
      r=beard@netscape.com


git-svn-id: svn://10.0.0.236/trunk@50786 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:29:30 +00:00
karnaze%netscape.com
dcf8e1f205 new regression test.
git-svn-id: svn://10.0.0.236/trunk@50785 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:29:09 +00:00
waterson%netscape.com
033d3bbd40 Fix compiler warning; r=rjc.
git-svn-id: svn://10.0.0.236/trunk@50784 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:26:46 +00:00
neeti%netscape.com
34b93b8117 updating status
git-svn-id: svn://10.0.0.236/trunk@50783 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:20:40 +00:00
karnaze%netscape.com
ef61c5a72c pass2 reflow doesn't request max element sizes to help with bug 14855. Reviewers didn't respond.
git-svn-id: svn://10.0.0.236/trunk@50782 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:09:22 +00:00
brendan%mozilla.org
7c13a9f3b1 Rename ToSource to uneval (r=shaver@mozilla.org,terry@geocast.com).
git-svn-id: svn://10.0.0.236/trunk@50781 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:07:59 +00:00
neeti%netscape.com
898eb50d34 Converted to use nsIModule to prepare for memory leaks fixing. Bug# 14034. r=sspitzer
git-svn-id: svn://10.0.0.236/trunk@50780 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:06:43 +00:00
neeti%netscape.com
6b6c7716c8 Converted to use nsIModule to prepare for memory leaks fixing. Bug# 14034. r=alecf
git-svn-id: svn://10.0.0.236/trunk@50779 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:06:14 +00:00
neeti%netscape.com
351b6ca2c6 Converted to use nsIModule to prepare for memory leaks fixing. Bug# 14034. r=waterson
git-svn-id: svn://10.0.0.236/trunk@50778 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 04:05:22 +00:00
beard%netscape.com
08cd03a169 fixed 2 string memory leaks (bug #15380). r=saari
git-svn-id: svn://10.0.0.236/trunk@50777 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 03:57:45 +00:00
radha%netscape.com
d7784c7d67 Send out OnStartDocumentLoad(0 notifications for visits to
anchors in a page. bug # 11631 15441. r=law. Got clearance from travis too


git-svn-id: svn://10.0.0.236/trunk@50776 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 03:50:47 +00:00
bienvenu%netscape.com
78b763db4d more of addrbook memory leak fixes r=mscott
git-svn-id: svn://10.0.0.236/trunk@50774 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 03:50:21 +00:00
radha%netscape.com
d6dbd3db1f fixing session history for frames. I accidently broke the behavior in
my monday's checkin. No bug #. r=law


git-svn-id: svn://10.0.0.236/trunk@50773 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 03:49:29 +00:00
troy%netscape.com
be2abd7a2c Patch from jst@citec.fi r=troy@netscape.com
Part of a fix for crash when expanding/collapsing toolbars. Change to
DeletingFrameSubtree() to make sure it examines the additional child
list as well as the principal child list


git-svn-id: svn://10.0.0.236/trunk@50772 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 03:37:10 +00:00
waterson%netscape.com
1464bedb39 Bug 16402. Make sure that literals addref (and release) the RDF service. Make sure to deal with edge Unregister[Resource|Literal] conditions; e.g., being called to unregister a literal when none was ever registered. r=rjc
git-svn-id: svn://10.0.0.236/trunk@50771 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 03:36:04 +00:00
jband%netscape.com
df5ae28aef r=shaver
- Fixed two similar cases where code was missing one level of
pointer dereference in terminating a copied string. Was trashing
data further up the stack.
- Use 'nsAllocator::Free' in two similar cases where 'delete' was
mistakenly used. Error pointed out by Purify.


git-svn-id: svn://10.0.0.236/trunk@50770 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 03:31:09 +00:00
rhp%netscape.com
2caa1592a8 Fix for email names with embedded &'s - Bug #16383 r=jefft
git-svn-id: svn://10.0.0.236/trunk@50769 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 03:27:33 +00:00
troy%netscape.com
8ec1b4ee83 Space savings. r=kipp@netscape.com
Re-implemented DST code to use separate objects for leaf nodes and
internal nodes. This reduces the per node size from 16 bytes to (on
average) 13 bytes per node


git-svn-id: svn://10.0.0.236/trunk@50768 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 03:18:28 +00:00
troy%netscape.com
9c1337b86f Space savings. r=karnaze@netscape.com Cc'd hyatt@netscape.com
Eliminated member data mIsContentEmpty and now we use a frame state bit
instead. This saves 4 bytes of space per table cell frame


git-svn-id: svn://10.0.0.236/trunk@50767 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 03:14:59 +00:00
shaver%netscape.com
9a4de938e7 make xpcshell use jsrtsvc, and let jsrtsvc handle JS_Shutdown (r=jband)
git-svn-id: svn://10.0.0.236/trunk@50766 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 03:05:48 +00:00
bienvenu%netscape.com
0eddf3358e fix memory leak of nsIURI in Set and GetAttribute r=waterson
git-svn-id: svn://10.0.0.236/trunk@50765 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 02:59:37 +00:00
srinivas%netscape.com
cc0b044bfe Autoconf for NSPR. Checkin for cls@seawood.org. Bugzilla #11893.
git-svn-id: svn://10.0.0.236/trunk@50764 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 02:42:36 +00:00
srinivas%netscape.com
6f136bc3f5 Autoconf for NSPR. Checkin for cls@seawood.org. Bugzilla #11893.
git-svn-id: svn://10.0.0.236/trunk@50763 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 02:36:40 +00:00
peterl%netscape.com
06471a021a moved toggle and tri-state from user-modify to user-select to stay in sync with CSS3
no bug #
r=pierre


git-svn-id: svn://10.0.0.236/trunk@50762 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 02:11:09 +00:00
cls%seawood.org
e381009988 Fix for bug #13412. r=shaver
If configured using --with-extensions or --with-extension=all, enable all of the non-default extensions rather than extension "yes" or "all".


git-svn-id: svn://10.0.0.236/trunk@50761 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 02:04:09 +00:00
akhil.arora%sun.com
047329ce0a 16426 r=akhil.arora@sun.com fixed by Denis Sharypov <sdv@sparc.spb.su>
The class java.lang.RuntimeException was not being pinned


git-svn-id: svn://10.0.0.236/trunk@50760 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 01:47:04 +00:00
akhil.arora%sun.com
4e04c99aad 16427 r=akhil.arora@sun.com fixed by Denis Sharypov <sdv@sparc.spb.su>
Check before dereferencing a NULL pointer.


git-svn-id: svn://10.0.0.236/trunk@50759 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 01:43:24 +00:00
varada%netscape.com
b2e2e2a6bc change from relative to absolute path
git-svn-id: svn://10.0.0.236/trunk@50758 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 01:39:32 +00:00
sspitzer%netscape.com
0d6acc8491 fix for #14892, automatically migrate if we only have one 4.x profile and no 5.0 profiles.
r=mscott.


git-svn-id: svn://10.0.0.236/trunk@50757 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 01:38:54 +00:00
akhil.arora%sun.com
0e030fdb50 16424 r=akhil.arora@sun.com fixed by Denis Sharypov <sdv@sparc.spb.su>
Fix two problems that kept the code from compiling on Win32


git-svn-id: svn://10.0.0.236/trunk@50756 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 01:38:42 +00:00
varada%netscape.com
cbaf31ef98 getting rid of relative paths in wizardmachine.cpp and wizardui.cpp for generate lists
git-svn-id: svn://10.0.0.236/trunk@50755 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 01:38:25 +00:00
varada%netscape.com
0e04699ad6 getting rid of relative paths in accountsetup and checklist inifiles
git-svn-id: svn://10.0.0.236/trunk@50754 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 01:19:25 +00:00
despotdaemon%netscape.com
6e4309cd35 Pseudo-automatic update of changes made by endico@mozilla.org.
git-svn-id: svn://10.0.0.236/trunk@50753 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:57:31 +00:00
wtc%netscape.com
ef278f909e Bugsplat bug #358401: created a separate .rc file for each DLL. The
product name is "Netscape Portable Runtime" and the file descriptions
are "NSPR Library", "PLDS Library", "PLC Library", and "PRSTRMS Library".
A debug build is indicated in the file description.  The copyright years
changed to 1996-1999.
Modified files: rules.mk, lib/ds/Makefile, lib/ds/Makefile.in,
lib/libc/src/Makefile, lib/libc/src/Makefile.in,
lib/prstreams/Makefile, lib/prstreams/Makefile.in,
prinit.h, nspr.rc
Added files: plds.rc, plc.rc, prstrms.rc
Removed file: resource.h


git-svn-id: svn://10.0.0.236/trunk@50752 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:51:41 +00:00
mcafee%netscape.com
981a0b415a Add #status option so you don't have to scroll down to the tree status.
git-svn-id: svn://10.0.0.236/trunk@50751 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:50:58 +00:00
sspitzer%netscape.com
13ef2ec53a more fixes to the 4.x uri -> 5.0 uri (copies and folders) code, for windows and mac.
#14951.  r=mscott


git-svn-id: svn://10.0.0.236/trunk@50750 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:50:34 +00:00
rpotts%netscape.com
fa27c68f3e bug #16328. Share a single nsToolkit instance among all widgets.
git-svn-id: svn://10.0.0.236/trunk@50749 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:49:11 +00:00
fur%netscape.com
69272dcfcd Initial version of net data cache APIs
git-svn-id: svn://10.0.0.236/trunk@50748 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:46:41 +00:00
kipp%netscape.com
f23d12f0ae Removed two more warnings
git-svn-id: svn://10.0.0.236/trunk@50747 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:29:28 +00:00
leaf%mozilla.org
1388fcf255 adding lib/mac/embedding for pierre -leaf
git-svn-id: svn://10.0.0.236/trunk@50746 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:19:06 +00:00
cathleen%netscape.com
1ba2750fb6 adds jsurl.xpt and html.css to windows packager list
git-svn-id: svn://10.0.0.236/trunk@50745 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:14:44 +00:00
wtc%netscape.com
974a9a3d5c Backed out the Windows resource file stuff checked in in the autoconf
branch merge.  It has two problems: 1. RESOBJ is not being used.  It
has the same meaning as the existing variable RES.  2. $(RES) is added
to OBJS twice on Win32.


git-svn-id: svn://10.0.0.236/trunk@50744 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:14:09 +00:00
nhotta%netscape.com
0cbcded17a Hooking up nsISaveAsCharset to the build, part of bug fix 8865, r=ftang.
git-svn-id: svn://10.0.0.236/trunk@50743 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:13:00 +00:00
bienvenu%netscape.com
f9c5bba278 fix memory leaks opening and closing dbs r=mscott
git-svn-id: svn://10.0.0.236/trunk@50742 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:11:58 +00:00
nhotta%netscape.com
dbcdcc135b Changed to get a charset name from a locale instead of hard code, also fixed a memory leak, bug=10816, r=tague
git-svn-id: svn://10.0.0.236/trunk@50741 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:11:38 +00:00
nhotta%netscape.com
54747068e8 Additional fallback for not charset labeled input, bug=15766, r=rhp
git-svn-id: svn://10.0.0.236/trunk@50740 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:08:42 +00:00
nhotta%netscape.com
58752631d9 Hooking up nsISaveAsCharset to the build, part of bug fix 8865, r=ftang.
git-svn-id: svn://10.0.0.236/trunk@50739 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:05:23 +00:00
bienvenu%netscape.com
284cea9db5 fix mork linked list which was disabling more than one table change from getting recorded r=davidmc
git-svn-id: svn://10.0.0.236/trunk@50738 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-15 00:05:10 +00:00
shaver%netscape.com
62dca335b0 Fix for 15480 (menu reflow from content change).
Use <titledbutton>, not <div>, for accelerator text to fix alignment
and improve performance _ever_ so slightly.
Initial support for checked menus (needs more magic).
(r=hyatt)


git-svn-id: svn://10.0.0.236/trunk@50737 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-14 23:59:18 +00:00
wtc%netscape.com
ad9bb8908b Removed the rule for $(PURE_LIBRARY), which was accidentally
resurrected in the autoconf checkin.


git-svn-id: svn://10.0.0.236/trunk@50736 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-14 23:55:27 +00:00
182 changed files with 10216 additions and 54405 deletions

View File

@@ -1,617 +0,0 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsAVLTree.h"
enum eLean {eLeft,eNeutral,eRight};
struct NS_COM nsAVLNode {
public:
nsAVLNode(void* aValue) {
mLeft=0;
mRight=0;
mSkew=eNeutral;
mValue=aValue;
}
nsAVLNode* mLeft;
nsAVLNode* mRight;
eLean mSkew;
void* mValue;
};
/************************************************************
Now begin the tree class. Don't forget that the comparison
between nodes must occur via the comparitor function,
otherwise all you're testing is pointer addresses.
************************************************************/
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
nsAVLTree::nsAVLTree(nsAVLNodeComparitor& aComparitor,
nsAVLNodeFunctor* aDeallocator) :
mComparitor(aComparitor), mDeallocator(aDeallocator) {
mRoot=0;
mCount=0;
}
static void
avlDeleteTree(nsAVLNode* aNode){
if (aNode) {
avlDeleteTree(aNode->mLeft);
avlDeleteTree(aNode->mRight);
delete aNode;
}
}
/**
*
* @update gess12/27/98
* @param
* @return
*/
nsAVLTree::~nsAVLTree(){
if (mDeallocator) {
ForEachDepthFirst(*mDeallocator);
}
avlDeleteTree(mRoot);
}
class CDoesntExist: public nsAVLNodeFunctor {
public:
CDoesntExist(const nsAVLTree& anotherTree) : mOtherTree(anotherTree) {
}
virtual void* operator()(void* anItem) {
void* result=mOtherTree.FindItem(anItem);
if(result)
return nsnull;
return anItem;
}
protected:
const nsAVLTree& mOtherTree;
};
/**
* This method compares two trees (members by identity).
* @update gess12/27/98
* @param tree to compare against
* @return true if they are identical (contain same stuff).
*/
PRBool nsAVLTree::operator==(const nsAVLTree& aCopy) const{
CDoesntExist functor(aCopy);
void* theItem=FirstThat(functor);
PRBool result=PRBool(!theItem);
return result;
}
/**
*
* @update gess12/27/98
* @param
* @return
*/
static void
avlRotateRight(nsAVLNode*& aRootNode){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
ptr2=aRootNode->mRight;
if(ptr2->mSkew==eRight) {
aRootNode->mRight=ptr2->mLeft;
ptr2->mLeft=aRootNode;
aRootNode->mSkew=eNeutral;
aRootNode=ptr2;
}
else {
ptr3=ptr2->mLeft;
ptr2->mLeft=ptr3->mRight;
ptr3->mRight=ptr2;
aRootNode->mRight=ptr3->mLeft;
ptr3->mLeft=aRootNode;
if(ptr3->mSkew==eLeft)
ptr2->mSkew=eRight;
else ptr2->mSkew=eNeutral;
if(ptr3->mSkew==eRight)
aRootNode->mSkew=eLeft;
else aRootNode->mSkew=eNeutral;
aRootNode=ptr3;
}
aRootNode->mSkew=eNeutral;
return;
}
/**
*
* @update gess12/27/98
* @param
* @return
*/
static void
avlRotateLeft(nsAVLNode*& aRootNode){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
ptr2=aRootNode->mLeft;
if(ptr2->mSkew==eLeft) {
aRootNode->mLeft=ptr2->mRight;
ptr2->mRight=aRootNode;
aRootNode->mSkew=eNeutral;
aRootNode=ptr2;
}
else {
ptr3=ptr2->mRight;
ptr2->mRight=ptr3->mLeft;
ptr3->mLeft=ptr2;
aRootNode->mLeft=ptr3->mRight;
ptr3->mRight=aRootNode;
if(ptr3->mSkew==eRight)
ptr2->mSkew=eLeft;
else ptr2->mSkew=eNeutral;
if(ptr3->mSkew==eLeft)
aRootNode->mSkew=eRight;
else aRootNode->mSkew=eNeutral;
aRootNode=ptr3;
}
aRootNode->mSkew=eNeutral;
return;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static eAVLStatus
avlInsert(nsAVLNode*& aRootNode, nsAVLNode* aNewNode,
nsAVLNodeComparitor& aComparitor) {
eAVLStatus result=eAVL_unknown;
if(!aRootNode) {
aRootNode = aNewNode;
return eAVL_ok;
}
if(aNewNode==aRootNode->mValue) {
return eAVL_duplicate;
}
PRInt32 theCompareResult=aComparitor(aRootNode->mValue,aNewNode->mValue);
if(0 < theCompareResult) { //if(anItem<aRootNode->mValue)
result=avlInsert(aRootNode->mLeft,aNewNode,aComparitor);
if(eAVL_ok==result) {
switch(aRootNode->mSkew){
case eLeft:
avlRotateLeft(aRootNode);
result=eAVL_fail;
break;
case eRight:
aRootNode->mSkew=eNeutral;
result=eAVL_fail;
break;
case eNeutral:
aRootNode->mSkew=eLeft;
break;
} //switch
}//if
} //if
else {
result=avlInsert(aRootNode->mRight,aNewNode,aComparitor);
if(eAVL_ok==result) {
switch(aRootNode->mSkew){
case eLeft:
aRootNode->mSkew=eNeutral;
result=eAVL_fail;
break;
case eRight:
avlRotateRight(aRootNode);
result=eAVL_fail;
break;
case eNeutral:
aRootNode->mSkew=eRight;
break;
} //switch
}
} //if
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static void
avlBalanceLeft(nsAVLNode*& aRootNode, PRBool& delOk){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
eLean balnc2;
eLean balnc3;
switch(aRootNode->mSkew){
case eLeft:
ptr2=aRootNode->mLeft;
balnc2=ptr2->mSkew;
if(balnc2!=eRight) {
aRootNode->mLeft=ptr2->mRight;
ptr2->mRight=aRootNode;
if(balnc2==eNeutral){
aRootNode->mSkew=eLeft;
ptr2->mSkew=eRight;
delOk=PR_FALSE;
}
else{
aRootNode->mSkew=eNeutral;
ptr2->mSkew=eNeutral;
}
aRootNode=ptr2;
}
else{
ptr3=ptr2->mRight;
balnc3=ptr3->mSkew;
ptr2->mRight=ptr3->mLeft;
ptr3->mLeft=ptr2;
aRootNode->mLeft=ptr3->mRight;
ptr3->mRight=aRootNode;
if(balnc3==eRight) {
ptr2->mSkew=eLeft;
}
else {
ptr2->mSkew=eNeutral;
}
if(balnc3==eLeft) {
aRootNode->mSkew=eRight;
}
else {
aRootNode->mSkew=eNeutral;
}
aRootNode=ptr3;
ptr3->mSkew=eNeutral;
}
break;
case eRight:
aRootNode->mSkew=eNeutral;
break;
case eNeutral:
aRootNode->mSkew=eLeft;
delOk=PR_FALSE;
break;
}//switch
return;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static void
avlBalanceRight(nsAVLNode*& aRootNode, PRBool& delOk){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
eLean balnc2;
eLean balnc3;
switch(aRootNode->mSkew){
case eLeft:
aRootNode->mSkew=eNeutral;
break;
case eRight:
ptr2=aRootNode->mRight;
balnc2=ptr2->mSkew;
if(balnc2!=eLeft) {
aRootNode->mRight=ptr2->mLeft;
ptr2->mLeft=aRootNode;
if(balnc2==eNeutral){
aRootNode->mSkew=eRight;
ptr2->mSkew=eLeft;
delOk=PR_FALSE;
}
else{
aRootNode->mSkew=eNeutral;
ptr2->mSkew=eNeutral;
}
aRootNode=ptr2;
}
else{
ptr3=ptr2->mLeft;
balnc3=ptr3->mSkew;
ptr2->mLeft=ptr3->mRight;
ptr3->mRight=ptr2;
aRootNode->mRight=ptr3->mLeft;
ptr3->mLeft=aRootNode;
if(balnc3==eLeft) {
ptr2->mSkew=eRight;
}
else {
ptr2->mSkew=eNeutral;
}
if(balnc3==eRight) {
aRootNode->mSkew=eLeft;
}
else {
aRootNode->mSkew=eNeutral;
}
aRootNode=ptr3;
ptr3->mSkew=eNeutral;
}
break;
case eNeutral:
aRootNode->mSkew=eRight;
delOk=PR_FALSE;
break;
}//switch
return;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static eAVLStatus
avlRemoveChildren(nsAVLNode*& aRootNode,nsAVLNode*& anotherNode, PRBool& delOk){
eAVLStatus result=eAVL_ok;
if(!anotherNode->mRight){
aRootNode->mValue=anotherNode->mValue; //swap
anotherNode=anotherNode->mLeft;
delOk=PR_TRUE;
}
else{
avlRemoveChildren(aRootNode,anotherNode->mRight,delOk);
if(delOk)
avlBalanceLeft(anotherNode,delOk);
}
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static eAVLStatus
avlRemove(nsAVLNode*& aRootNode, void* anItem, PRBool& delOk,
nsAVLNodeComparitor& aComparitor){
eAVLStatus result=eAVL_ok;
if(!aRootNode)
delOk=PR_FALSE;
else {
PRInt32 cmp=aComparitor(anItem,aRootNode->mValue);
if(cmp<0){
avlRemove(aRootNode->mLeft,anItem,delOk,aComparitor);
if(delOk)
avlBalanceRight(aRootNode,delOk);
}
else if(cmp>0){
avlRemove(aRootNode->mRight,anItem,delOk,aComparitor);
if(delOk)
avlBalanceLeft(aRootNode,delOk);
}
else{ //they match...
nsAVLNode* temp=aRootNode;
if(!aRootNode->mRight) {
aRootNode=aRootNode->mLeft;
delOk=PR_TRUE;
delete temp;
}
else if(!aRootNode->mLeft) {
aRootNode=aRootNode->mRight;
delOk=PR_TRUE;
delete temp;
}
else {
avlRemoveChildren(aRootNode,aRootNode->mLeft,delOk);
if(delOk)
avlBalanceRight(aRootNode,delOk);
}
}
}
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
eAVLStatus
nsAVLTree::AddItem(void* anItem){
eAVLStatus result=eAVL_ok;
nsAVLNode* theNewNode=new nsAVLNode(anItem);
result=avlInsert(mRoot,theNewNode,mComparitor);
if(eAVL_duplicate!=result)
mCount++;
else {
delete theNewNode;
}
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
void* nsAVLTree::FindItem(void* aValue) const{
nsAVLNode* result=mRoot;
PRInt32 count=0;
while(result) {
count++;
PRInt32 cmp=mComparitor(aValue,result->mValue);
if(0==cmp) {
//we matched...
break;
}
else if(0>cmp){
//theNode was greater...
result=result->mLeft;
}
else {
//aValue is greater...
result=result->mRight;
}
}
if(result) {
return result->mValue;
}
return nsnull;
}
/**
*
* @update gess12/30/98
* @param
* @return
*/
eAVLStatus
nsAVLTree::RemoveItem(void* aValue){
PRBool delOk=PR_TRUE;
eAVLStatus result=avlRemove(mRoot,aValue,delOk,mComparitor);
if(eAVL_ok==result)
mCount--;
return result;
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
static void
avlForEachDepthFirst(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor){
if(aNode) {
avlForEachDepthFirst(aNode->mLeft,aFunctor);
avlForEachDepthFirst(aNode->mRight,aFunctor);
aFunctor(aNode->mValue);
}
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
void
nsAVLTree::ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const{
::avlForEachDepthFirst(mRoot,aFunctor);
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
static void
avlForEach(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
if(aNode) {
avlForEach(aNode->mLeft,aFunctor);
aFunctor(aNode->mValue);
avlForEach(aNode->mRight,aFunctor);
}
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
void
nsAVLTree::ForEach(nsAVLNodeFunctor& aFunctor) const{
::avlForEach(mRoot,aFunctor);
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
static void*
avlFirstThat(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
void* result=nsnull;
if(aNode) {
result = avlFirstThat(aNode->mLeft,aFunctor);
if (result) {
return result;
}
result = aFunctor(aNode->mValue);
if (result) {
return result;
}
result = avlFirstThat(aNode->mRight,aFunctor);
}
return result;
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
void*
nsAVLTree::FirstThat(nsAVLNodeFunctor& aFunctor) const{
return ::avlFirstThat(mRoot,aFunctor);
}

View File

@@ -1,74 +0,0 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsAVLTree_h___
#define nsAVLTree_h___
#include "nscore.h"
enum eAVLStatus {eAVL_unknown,eAVL_ok,eAVL_fail,eAVL_duplicate};
struct nsAVLNode;
/**
*
* @update gess12/26/98
* @param anObject1 is the first object to be compared
* @param anObject2 is the second object to be compared
* @return -1,0,1 if object1 is less, equal, greater than object2
*/
class NS_COM nsAVLNodeComparitor {
public:
virtual PRInt32 operator()(void* anItem1,void* anItem2)=0;
};
class NS_COM nsAVLNodeFunctor {
public:
virtual void* operator()(void* anItem)=0;
};
class NS_COM nsAVLTree {
public:
nsAVLTree(nsAVLNodeComparitor& aComparitor, nsAVLNodeFunctor* aDeallocator);
~nsAVLTree(void);
PRBool operator==(const nsAVLTree& aOther) const;
PRInt32 GetCount(void) const {return mCount;}
//main functions...
eAVLStatus AddItem(void* anItem);
eAVLStatus RemoveItem(void* anItem);
void* FindItem(void* anItem) const;
void ForEach(nsAVLNodeFunctor& aFunctor) const;
void ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const;
void* FirstThat(nsAVLNodeFunctor& aFunctor) const;
protected:
nsAVLNode* mRoot;
PRInt32 mCount;
nsAVLNodeComparitor& mComparitor;
nsAVLNodeFunctor* mDeallocator;
};
#endif /* nsAVLTree_h___ */

View File

@@ -0,0 +1,298 @@
/* -*- 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.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 "msgCore.h" // for pre-compiled headers
//#include "nsIMsgIdentity.h"
#include "nsIMsgAccountManager.h"
//#include "nsIPop3IncomingServer.h"
#include "nsMsgMailSession.h"
#include "nsMsgLocalCID.h"
#include "nsMsgBaseCID.h"
#include "nsCOMPtr.h"
#include "nsMsgFolderCache.h"
#include "nsIFileLocator.h"
#include "nsFileLocations.h"
#include "nsIMsgStatusFeedback.h"
NS_IMPL_ISUPPORTS(nsMsgMailSession, nsCOMTypeInfo<nsIMsgMailSession>::GetIID());
static NS_DEFINE_CID(kMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID);
static NS_DEFINE_CID(kMsgFolderCacheCID, NS_MSGFOLDERCACHE_CID);
static NS_DEFINE_IID(kIFileLocatorIID, NS_IFILELOCATOR_IID);
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
//static NS_DEFINE_CID(kMsgIdentityCID, NS_MSGIDENTITY_CID);
//static NS_DEFINE_CID(kPop3IncomingServerCID, NS_POP3INCOMINGSERVER_CID);
//static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
nsMsgMailSession::nsMsgMailSession():
mRefCnt(0),
m_accountManager(0),
m_msgFolderCache(0)
{
NS_INIT_REFCNT();
}
nsMsgMailSession::~nsMsgMailSession()
{
Shutdown();
}
nsresult nsMsgMailSession::Init()
{
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mListeners));
return rv;
}
nsresult nsMsgMailSession::Shutdown()
{
if(m_accountManager)
{
if (m_msgFolderCache)
m_accountManager->WriteToFolderCache(m_msgFolderCache);
m_accountManager->CloseCachedConnections();
m_accountManager->UnloadAccounts();
}
NS_IF_RELEASE(m_accountManager);
NS_IF_RELEASE(m_msgFolderCache);
return NS_OK;
}
// nsIMsgMailSession
nsresult nsMsgMailSession::GetCurrentIdentity(nsIMsgIdentity ** aIdentity)
{
nsresult rv;
nsCOMPtr<nsIMsgAccountManager> accountManager;
rv = GetAccountManager(getter_AddRefs(accountManager));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgAccount> defaultAccount;
rv = accountManager->GetDefaultAccount(getter_AddRefs(defaultAccount));
if (NS_FAILED(rv)) return rv;
rv = defaultAccount->GetDefaultIdentity(aIdentity);
if (NS_SUCCEEDED(rv))
NS_ADDREF(*aIdentity);
return rv;
}
nsresult nsMsgMailSession::GetCurrentServer(nsIMsgIncomingServer ** aServer)
{
nsresult rv=NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIMsgAccountManager> accountManager;
rv = GetAccountManager(getter_AddRefs(accountManager));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgAccount> defaultAccount;
rv = accountManager->GetDefaultAccount(getter_AddRefs(defaultAccount));
if (NS_FAILED(rv)) return rv;
//if successful aServer will be addref'd by GetIncomingServer
rv = defaultAccount->GetIncomingServer(aServer);
return rv;
}
nsresult nsMsgMailSession::GetAccountManager(nsIMsgAccountManager* *aAM)
{
NS_ENSURE_ARG_POINTER(aAM);
nsresult rv;
NS_WITH_SERVICE(nsIMsgAccountManager, accountManager, kMsgAccountManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
accountManager->LoadAccounts();
*aAM = accountManager;
NS_IF_ADDREF(*aAM);
return NS_OK;
}
nsresult nsMsgMailSession::GetFolderCache(nsIMsgFolderCache* *aFolderCache)
{
if (!aFolderCache) return NS_ERROR_NULL_POINTER;
nsresult rv = NS_OK;
if (!m_msgFolderCache)
{
rv = nsComponentManager::CreateInstance(kMsgFolderCacheCID,
NULL,
nsCOMTypeInfo<nsIMsgFolderCache>::GetIID(),
(void **)&m_msgFolderCache);
if (NS_FAILED(rv))
return rv;
nsCOMPtr <nsIFileSpec> cacheFile;
NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = locator->GetFileLocation(nsSpecialFileSpec::App_MessengerFolderCache50, getter_AddRefs(cacheFile));
if (NS_FAILED(rv)) return rv;
m_msgFolderCache->Init(cacheFile);
}
*aFolderCache = m_msgFolderCache;
NS_IF_ADDREF(*aFolderCache);
return rv;
}
nsresult nsMsgMailSession::GetTemporaryMsgStatusFeedback(nsIMsgStatusFeedback* *aMsgStatusFeedback)
{
if (!aMsgStatusFeedback) return NS_ERROR_NULL_POINTER;
*aMsgStatusFeedback = m_temporaryMsgStatusFeedback;
NS_IF_ADDREF(*aMsgStatusFeedback);
return NS_OK;
}
nsresult nsMsgMailSession::SetTemporaryMsgStatusFeedback(nsIMsgStatusFeedback* aMsgStatusFeedback)
{
m_temporaryMsgStatusFeedback = do_QueryInterface(aMsgStatusFeedback);
return NS_OK;
}
NS_IMETHODIMP nsMsgMailSession::AddFolderListener(nsIFolderListener * listener)
{
mListeners->AppendElement(listener);
return NS_OK;
}
NS_IMETHODIMP nsMsgMailSession::RemoveFolderListener(nsIFolderListener * listener)
{
mListeners->RemoveElement(listener);
return NS_OK;
}
NS_IMETHODIMP
nsMsgMailSession::NotifyFolderItemPropertyChanged(nsISupports *item,
const char *property,
const char* oldValue,
const char* newValue)
{
nsresult rv;
PRUint32 count;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
{
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
listener->OnItemPropertyChanged(item, property, oldValue, newValue);
}
return NS_OK;
}
NS_IMETHODIMP
nsMsgMailSession::NotifyFolderItemPropertyFlagChanged(nsISupports *item,
const char *property,
PRUint32 oldValue,
PRUint32 newValue)
{
nsresult rv;
PRUint32 count;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
{
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
listener->OnItemPropertyFlagChanged(item, property, oldValue, newValue);
}
return NS_OK;
}
NS_IMETHODIMP nsMsgMailSession::NotifyFolderItemAdded(nsIFolder *folder, nsISupports *item)
{
nsresult rv;
PRUint32 count;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
{
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
listener->OnItemAdded(folder, item);
}
return NS_OK;
}
NS_IMETHODIMP nsMsgMailSession::NotifyFolderItemDeleted(nsIFolder *folder, nsISupports *item)
{
nsresult rv;
PRUint32 count;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
{
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
listener->OnItemRemoved(folder, item);
}
return NS_OK;
}
NS_IMETHODIMP nsMsgMailSession::NotifyFolderLoaded(nsIFolder *folder)
{
nsresult rv;
PRUint32 count;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
{
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
listener->OnFolderLoaded(folder);
}
return NS_OK;
}

View File

@@ -0,0 +1,35 @@
# 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.
#
# This is a list of local files which get copied to the mozilla:dist:mailnews directory
#
nsMsgLineBuffer.h
nsMsgGroupRecord.h
nsUInt32Array.h
nsMsgKeySet.h
nsMsgFolder.h
nsMsgDBFolder.h
nsLocalFolderSummarySpec.h
nsMsgIdentity.h
nsMsgIncomingServer.h
nsNewsSummarySpec.h
nsMsgUtils.h
nsMessage.h
nsMsgProtocol.h
nsMsgTxn.h
nsMsgMailNewsUrl.h
nsMsgI18N.h

View File

@@ -0,0 +1,75 @@
#
# 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.
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = msgbaseutil
LIBRARY_NAME = msgbaseutil
CPPSRCS = \
nsMsgGroupRecord.cpp \
nsMsgLineBuffer.cpp \
nsMsgFolder.cpp \
nsMsgDBFolder.cpp \
nsUInt32Array.cpp \
nsMsgKeySet.cpp \
nsLocalFolderSummarySpec.cpp \
nsNewsSummarySpec.cpp \
nsMsgIdentity.cpp \
nsMsgIncomingServer.cpp \
nsMsgUtils.cpp \
nsMessage.cpp \
nsMsgProtocol.cpp \
nsMsgMailNewsUrl.cpp \
nsMsgTxn.cpp \
nsMsgI18N.cpp \
$(NULL)
EXPORTS = \
nsMsgGroupRecord.h \
nsMsgLineBuffer.h \
nsUInt32Array.h \
nsMsgKeySet.h \
nsMsgFolder.h \
nsMsgDBFolder.h \
nsLocalFolderSummarySpec.h \
nsNewsSummarySpec.h \
nsMsgIdentity.h \
nsMsgIncomingServer.h \
nsMsgUtils.h \
nsMessage.h \
nsMsgProtocol.h \
nsMsgMailNewsUrl.h \
nsMsgTxn.h \
nsMsgI18N.h \
$(NULL)
EXTRA_DSO_LDOPTS = \
-L$(DIST)/bin \
-L$(DIST)/lib \
-lxpcom \
-lrdfutil_s \
$(NSPR_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

Binary file not shown.

View File

@@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
@@ -16,11 +16,6 @@
* Reserved.
*/
#ifndef nsISimpleEnumerator_h__
#define nsISimpleEnumerator_h__
// This file is needed to pacify the xpidl-generated header files.
#include "nsIEnumerator.h"
#endif // nsISimpleEnumerator_h__
#include "MacPrefix.h"

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
/* -*- 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.0 (the "NPL"); you may not use this file except in
@@ -16,12 +16,6 @@
* Reserved.
*/
#include "nsIEnumerator.idl"
interface nsIFile;
[scriptable, uuid(D7BEA930-59D7-11d3-8C46-00609792278C)]
interface nsIDirectoryEnumerator : nsISimpleEnumerator
{
void Init(in nsIFile parent, in boolean resolveSymlinks);
};
#include "MacPrefix_debug.h"

View File

@@ -0,0 +1,87 @@
#!nmake
#
# 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.
DEPTH=..\..\..
MODULE= msgbsutl
include <$(DEPTH)\config\config.mak>
################################################################################
## exports
EXPORTS= \
nsMsgLineBuffer.h \
nsMsgGroupRecord.h \
nsUInt32Array.h \
nsMsgKeySet.h \
nsMsgFolder.h \
nsMsgDBFolder.h \
nsLocalFolderSummarySpec.h \
nsMsgIdentity.h \
nsMsgIncomingServer.h \
nsNewsSummarySpec.h \
nsMsgUtils.h \
nsMessage.h \
nsMsgProtocol.h \
nsMsgMailNewsUrl.h \
nsMsgTxn.h \
nsMsgI18N.h \
$(NULL)
################################################################################
## library
LIBNAME = .\$(OBJDIR)\msgbsutl
DLL = $(LIBNAME).dll
DEFINES=-D_IMPL_NS_MSG_BASE
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsMsgGroupRecord.obj \
.\$(OBJDIR)\nsMsgLineBuffer.obj \
.\$(OBJDIR)\nsUInt32Array.obj \
.\$(OBJDIR)\nsMsgKeySet.obj \
.\$(OBJDIR)\nsMsgFolder.obj \
.\$(OBJDIR)\nsMsgDBFolder.obj \
.\$(OBJDIR)\nsLocalFolderSummarySpec.obj \
.\$(OBJDIR)\nsMsgIdentity.obj \
.\$(OBJDIR)\nsMsgIncomingServer.obj \
.\$(OBJDIR)\nsNewsSummarySpec.obj \
.\$(OBJDIR)\nsMsgUtils.obj \
.\$(OBJDIR)\nsMessage.obj \
.\$(OBJDIR)\nsMsgProtocol.obj \
.\$(OBJDIR)\nsMsgMailNewsUrl.obj \
.\$(OBJDIR)\nsMsgTxn.obj \
.\$(OBJDIR)\nsMsgI18N.obj \
$(NULL)
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\rdfutil_s.lib \
$(LIBNSPR) \
$(NULL)
include <$(DEPTH)/config/rules.mak>
libs:: $(DLL)
$(MAKE_INSTALL) $(LIBNAME).$(DLL_SUFFIX) $(DIST)\bin
$(MAKE_INSTALL) $(LIBNAME).$(LIB_SUFFIX) $(DIST)\lib

View File

@@ -0,0 +1,76 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsLocalFolderSummarySpec.h"
#include "plstr.h"
#include "nsString.h"
MOZ_DECL_CTOR_COUNTER(nsLocalFolderSummarySpec);
nsLocalFolderSummarySpec::~nsLocalFolderSummarySpec()
{
MOZ_COUNT_DTOR(nsLocalFolderSummarySpec);
}
nsLocalFolderSummarySpec::nsLocalFolderSummarySpec()
{
MOZ_COUNT_CTOR(nsLocalFolderSummarySpec);
}
nsLocalFolderSummarySpec::nsLocalFolderSummarySpec(const char *folderPath, PRBool create)
: nsFileSpec(folderPath, create)
{
MOZ_COUNT_CTOR(nsLocalFolderSummarySpec);
CreateSummaryFileName();
}
nsLocalFolderSummarySpec::nsLocalFolderSummarySpec(const nsFileSpec& inFolderPath)
: nsFileSpec(inFolderPath)
{
MOZ_COUNT_CTOR(nsLocalFolderSummarySpec);
CreateSummaryFileName();
}
nsLocalFolderSummarySpec::nsLocalFolderSummarySpec(const nsFilePath &inFolderPath, PRBool create) : nsFileSpec(inFolderPath, create)
{
MOZ_COUNT_CTOR(nsLocalFolderSummarySpec);
CreateSummaryFileName();
}
void nsLocalFolderSummarySpec::SetFolderName(const char *folderPath)
{
*this = folderPath;
}
void nsLocalFolderSummarySpec:: CreateSummaryFileName()
{
char *leafName = GetLeafName();
nsString fullLeafName(leafName);
// Append .msf (msg summary file) this is what windows will want.
// Mac and Unix can decide for themselves.
fullLeafName += ".msf"; // message summary file
char *cLeafName = fullLeafName.ToNewCString();
SetLeafName(cLeafName);
nsAllocator::Free(cLeafName);
PL_strfree(leafName);
}

View File

@@ -0,0 +1,46 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsLocalFolderSummarySpec_H
#define _nsLocalFolderSummarySpec_H
#include "msgCore.h"
#include "nsFileSpec.h"
// Class to name a summary file for a local mail folder,
// given a full folder file spec. For windows, this just means tacking .msf on the end.
// For Unix, it might mean something like putting a '.' on the front and .msgsummary on the end.
// Note this class expects the invoking code to fully specify the folder path.
// This class does NOT prepend the local folder directory, or put .sbd on the containing
// directory names.
class NS_MSG_BASE nsLocalFolderSummarySpec : public nsFileSpec
{
public:
virtual ~nsLocalFolderSummarySpec();
nsLocalFolderSummarySpec();
nsLocalFolderSummarySpec(const char *folderPath, PRBool create = PR_FALSE);
nsLocalFolderSummarySpec(const nsFileSpec& inFolderPath);
nsLocalFolderSummarySpec(const nsFilePath &inFolderPath, PRBool create = PR_FALSE);
void SetFolderName(const char *folderPath);
protected:
void CreateSummaryFileName();
};
#endif

View File

@@ -0,0 +1,509 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "msgCore.h" // precompiled header...
#include "nsMessage.h"
#include "nsIMsgFolder.h"
nsMessage::nsMessage(void)
: nsRDFResource(), mFolder(nsnull)
{
}
nsMessage::~nsMessage(void)
{
//Member variables are either nsCOMPtr's or ptrs we don't want to own.
}
NS_IMPL_ADDREF_INHERITED(nsMessage, nsRDFResource)
NS_IMPL_RELEASE_INHERITED(nsMessage, nsRDFResource)
NS_IMETHODIMP nsMessage::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (!aInstancePtr) return NS_ERROR_NULL_POINTER;
*aInstancePtr = nsnull;
if (aIID.Equals(nsCOMTypeInfo<nsIMessage>::GetIID()) || aIID.Equals(nsCOMTypeInfo<nsIDBMessage>::GetIID()))
{
*aInstancePtr = NS_STATIC_CAST(nsIDBMessage*, this);
}
if(*aInstancePtr)
{
AddRef();
return NS_OK;
}
return nsRDFResource::QueryInterface(aIID, aInstancePtr);
}
NS_IMETHODIMP
nsMessage::Init(const char* aURI)
{
return nsRDFResource::Init(aURI);
}
NS_IMETHODIMP nsMessage::GetProperty(const char *propertyName, nsString &resultProperty)
{
if(mMsgHdr)
return mMsgHdr->GetProperty(propertyName, resultProperty);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetProperty(const char *propertyName, nsString &propertyStr)
{
if(mMsgHdr)
return mMsgHdr->SetProperty(propertyName, propertyStr);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetUint32Property(const char *propertyName, PRUint32 *pResult)
{
if(mMsgHdr)
return mMsgHdr->GetUint32Property(propertyName, pResult);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetUint32Property(const char *propertyName, PRUint32 propertyVal)
{
if(mMsgHdr)
return mMsgHdr->SetUint32Property(propertyName, propertyVal);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetNumReferences(PRUint16 *result)
{
if(mMsgHdr)
return mMsgHdr->GetNumReferences(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetStringReference(PRInt32 refNum, nsCString &resultReference)
{
if(mMsgHdr)
return mMsgHdr->GetStringReference(refNum, resultReference);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetDate(PRTime *result)
{
if(mMsgHdr)
return mMsgHdr->GetDate(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetDate(PRTime date)
{
if(mMsgHdr)
return mMsgHdr->SetDate(date);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetMessageId(const char *messageId)
{
if(mMsgHdr)
return mMsgHdr->SetMessageId(messageId);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetReferences(const char *references)
{
if(mMsgHdr)
return mMsgHdr->SetReferences(references);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetCCList(const char *ccList)
{
if(mMsgHdr)
return mMsgHdr->SetCCList(ccList);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetRecipients(const char *recipients, PRBool recipientsIsNewsgroup)
{
if(mMsgHdr)
return mMsgHdr->SetRecipients(recipients, recipientsIsNewsgroup);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetRecipientsArray(const char *names, const char *addresses, PRUint32 numAddresses)
{
if(mMsgHdr)
return mMsgHdr->SetRecipientsArray(names, addresses, numAddresses);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetCCListArray(const char *names, const char *addresses, PRUint32 numAddresses)
{
if(mMsgHdr)
return mMsgHdr->SetCCListArray(names, addresses, numAddresses);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetAuthor(const char *author)
{
if(mMsgHdr)
return mMsgHdr->SetAuthor(author);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetSubject(const char *subject)
{
if(mMsgHdr)
return mMsgHdr->SetSubject(subject);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetStatusOffset(PRUint32 statusOffset)
{
if(mMsgHdr)
return mMsgHdr->SetStatusOffset(statusOffset);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetAuthor(nsString *resultAuthor)
{
if(mMsgHdr)
return mMsgHdr->GetAuthor(resultAuthor);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetSubject(nsString *resultSubject)
{
if(mMsgHdr)
return mMsgHdr->GetSubject(resultSubject);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetRecipients(nsString *resultRecipients)
{
if(mMsgHdr)
return mMsgHdr->GetRecipients(resultRecipients);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetCCList(nsString *ccList)
{
if(mMsgHdr)
return mMsgHdr->GetCCList(ccList);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetMessageId(nsCString *resultMessageId)
{
if(mMsgHdr)
return mMsgHdr->GetMessageId(resultMessageId);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetMime2DecodedAuthor(nsString *resultAuthor)
{
if(mMsgHdr)
return mMsgHdr->GetMime2DecodedAuthor(resultAuthor);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetMime2DecodedSubject(nsString *resultSubject)
{
if(mMsgHdr)
return mMsgHdr->GetMime2DecodedSubject(resultSubject);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetMime2DecodedRecipients(nsString *resultRecipients)
{
if(mMsgHdr)
return mMsgHdr->GetMime2DecodedRecipients(resultRecipients);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetAuthorCollationKey(nsString *resultAuthor)
{
if(mMsgHdr)
return mMsgHdr->GetAuthorCollationKey(resultAuthor);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetSubjectCollationKey(nsString *resultSubject)
{
if(mMsgHdr)
return mMsgHdr->GetSubjectCollationKey(resultSubject);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetRecipientsCollationKey(nsString *resultRecipients)
{
if(mMsgHdr)
return mMsgHdr->GetRecipientsCollationKey(resultRecipients);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetFlags(PRUint32 *result)
{
if(mMsgHdr)
return mMsgHdr->GetFlags(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetFlags(PRUint32 flags)
{
if(mMsgHdr)
return mMsgHdr->SetFlags(flags);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::OrFlags(PRUint32 flags, PRUint32 *result)
{
if(mMsgHdr)
return mMsgHdr->OrFlags(flags, result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::AndFlags(PRUint32 flags, PRUint32 *result)
{
if(mMsgHdr)
return mMsgHdr->AndFlags(flags, result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::MarkRead(PRBool bRead)
{
if(mMsgHdr)
return mMsgHdr->MarkRead(bRead);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::MarkFlagged(PRBool bFlagged)
{
if(mMsgHdr)
return mMsgHdr->MarkFlagged(bFlagged);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetMessageKey(nsMsgKey *result)
{
if(mMsgHdr)
return mMsgHdr->GetMessageKey(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetThreadId(nsMsgKey *result)
{
if(mMsgHdr)
return mMsgHdr->GetThreadId(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetThreadId(nsMsgKey inKey)
{
if(mMsgHdr)
return mMsgHdr->SetThreadId(inKey);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetMessageKey(nsMsgKey inKey)
{
if(mMsgHdr)
return mMsgHdr->SetMessageKey(inKey);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetMessageSize(PRUint32 *result)
{
if(mMsgHdr)
return mMsgHdr->GetMessageSize(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetLineCount(PRUint32 *result)
{
if(mMsgHdr)
return mMsgHdr->GetLineCount(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetMessageSize(PRUint32 messageSize)
{
if(mMsgHdr)
return mMsgHdr->SetMessageSize(messageSize);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetLineCount(PRUint32 lineCount)
{
if(mMsgHdr)
return mMsgHdr->SetLineCount(lineCount);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetPriority(nsMsgPriority priority)
{
if(mMsgHdr)
return mMsgHdr->SetPriority(priority);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetPriority(const char *priority)
{
if(mMsgHdr)
return mMsgHdr->SetPriority(priority);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetPriority(nsMsgPriority *result)
{
if(mMsgHdr)
return mMsgHdr->GetPriority(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetMessageOffset(PRUint32 *result)
{
if(mMsgHdr)
return mMsgHdr->GetMessageOffset(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetStatusOffset(PRUint32 *result)
{
if(mMsgHdr)
return mMsgHdr->GetStatusOffset(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetCharSet(nsString *result)
{
if(mMsgHdr)
return mMsgHdr->GetCharSet(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetThreadParent(nsMsgKey *result)
{
if(mMsgHdr)
return mMsgHdr->GetThreadParent(result);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetThreadParent(nsMsgKey inKey)
{
if(mMsgHdr)
return mMsgHdr->SetThreadParent(inKey);
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetMsgFolder(nsIMsgFolder **folder)
{
if(!folder)
return NS_ERROR_NULL_POINTER;
*folder = mFolder;
if(mFolder)
{
NS_ADDREF(mFolder);
return NS_OK;
}
else
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsMessage::SetMsgFolder(nsIMsgFolder *folder)
{
mFolder = folder;
//We don't want to own folder, so don't AddRef
return NS_OK;
}
NS_IMETHODIMP nsMessage::SetMsgDBHdr(nsIMsgDBHdr *hdr)
{
mMsgHdr = dont_QueryInterface(hdr);
return NS_OK;
}
NS_IMETHODIMP nsMessage::GetMsgDBHdr(nsIMsgDBHdr **hdr)
{
*hdr = mMsgHdr;
if(*hdr)
{
NS_ADDREF(*hdr);
return NS_OK;
}
else
return NS_ERROR_NULL_POINTER;
}

View File

@@ -0,0 +1,113 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
/********************************************************************************************************
Interface for representing Messenger folders.
*********************************************************************************************************/
#ifndef nsMessage_h__
#define nsMessage_h__
#include "msgCore.h"
#include "nsIMessage.h" /* include the interface we are going to support */
#include "nsRDFResource.h"
#include "nsIMsgHdr.h"
#include "nsCOMPtr.h"
class NS_MSG_BASE nsMessage: public nsRDFResource, public nsIDBMessage
{
public:
nsMessage(void);
virtual ~nsMessage(void);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIMESSAGE
NS_DECL_NSIDBMESSAGE
NS_IMETHOD Init(const char *aURI);
//nsIMsgHdr
NS_IMETHOD GetProperty(const char *propertyName, nsString &resultProperty);
NS_IMETHOD SetProperty(const char *propertyName, nsString &propertyStr);
NS_IMETHOD GetUint32Property(const char *propertyName, PRUint32 *pResult);
NS_IMETHOD SetUint32Property(const char *propertyName, PRUint32 propertyVal);
NS_IMETHOD GetNumReferences(PRUint16 *result);
NS_IMETHOD GetStringReference(PRInt32 refNum, nsCString &resultReference);
NS_IMETHOD GetDate(PRTime *result);
NS_IMETHOD SetDate(PRTime date);
NS_IMETHOD SetMessageId(const char *messageId);
NS_IMETHOD SetReferences(const char *references);
NS_IMETHOD SetCCList(const char *ccList);
NS_IMETHOD SetRecipients(const char *recipients, PRBool recipientsIsNewsgroup);
NS_IMETHOD SetRecipientsArray(const char *names, const char *addresses, PRUint32 numAddresses);
NS_IMETHOD SetCCListArray(const char *names, const char *addresses, PRUint32 numAddresses);
NS_IMETHOD SetAuthor(const char *author);
NS_IMETHOD SetSubject(const char *subject);
NS_IMETHOD SetStatusOffset(PRUint32 statusOffset);
NS_IMETHOD GetAuthor(nsString *resultAuthor);
NS_IMETHOD GetSubject(nsString *resultSubject);
NS_IMETHOD GetRecipients(nsString *resultRecipients);
NS_IMETHOD GetCCList(nsString *ccList);
NS_IMETHOD GetMessageId(nsCString *resultMessageId);
NS_IMETHOD GetMime2DecodedAuthor(nsString *resultAuthor);
NS_IMETHOD GetMime2DecodedSubject(nsString *resultSubject);
NS_IMETHOD GetMime2DecodedRecipients(nsString *resultRecipients);
NS_IMETHOD GetAuthorCollationKey(nsString *resultAuthor);
NS_IMETHOD GetSubjectCollationKey(nsString *resultSubject);
NS_IMETHOD GetRecipientsCollationKey(nsString *resultRecipients);
// flag handling routines
NS_IMETHOD GetFlags(PRUint32 *result);
NS_IMETHOD SetFlags(PRUint32 flags);
NS_IMETHOD OrFlags(PRUint32 flags, PRUint32 *result);
NS_IMETHOD AndFlags(PRUint32 flags, PRUint32 *result);
// Mark message routines
NS_IMETHOD MarkRead(PRBool bRead);
NS_IMETHOD MarkFlagged(PRBool bFlagged);
NS_IMETHOD GetMessageKey(nsMsgKey *result);
NS_IMETHOD GetThreadId(nsMsgKey *result);
NS_IMETHOD SetThreadId(nsMsgKey inKey);
NS_IMETHOD SetMessageKey(nsMsgKey inKey);
NS_IMETHOD GetMessageSize(PRUint32 *result);
NS_IMETHOD SetMessageSize(PRUint32 messageSize);
NS_IMETHOD GetLineCount(PRUint32 *result);
NS_IMETHOD SetLineCount(PRUint32 lineCount);
NS_IMETHOD SetPriority(nsMsgPriority priority);
NS_IMETHOD SetPriority(const char *priority);
NS_IMETHOD GetMessageOffset(PRUint32 *result);
NS_IMETHOD GetStatusOffset(PRUint32 *result);
NS_IMETHOD GetCharSet(nsString *result);
NS_IMETHOD GetPriority(nsMsgPriority *result);
NS_IMETHOD GetThreadParent(nsMsgKey *result);
NS_IMETHOD SetThreadParent(nsMsgKey inKey);
protected:
nsIMsgFolder *mFolder;
nsCOMPtr<nsIMsgDBHdr> mMsgHdr;
};
#endif //nsMessage_h__

View File

@@ -0,0 +1,530 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "msgCore.h"
#include "nsIMessage.h"
#include "nsMsgDBFolder.h"
#include "nsMsgFolderFlags.h"
#include "nsIPref.h"
#include "nsIMsgFolderCache.h"
#include "nsIMsgFolderCacheElement.h"
#include "nsIMsgMailSession.h"
#include "nsMsgBaseCID.h"
#include "nsIMsgMailNewsUrl.h"
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
NS_IMPL_ADDREF_INHERITED(nsMsgDBFolder, nsMsgFolder)
NS_IMPL_RELEASE_INHERITED(nsMsgDBFolder, nsMsgFolder)
NS_IMETHODIMP nsMsgDBFolder::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (!aInstancePtr) return NS_ERROR_NULL_POINTER;
*aInstancePtr = nsnull;
if (aIID.Equals(nsCOMTypeInfo<nsIDBChangeListener>::GetIID()))
{
*aInstancePtr = NS_STATIC_CAST(nsIDBChangeListener*, this);
}
else if (aIID.Equals(nsCOMTypeInfo<nsIUrlListener>::GetIID()))
{
*aInstancePtr = NS_STATIC_CAST(nsIUrlListener*, this);
}
if(*aInstancePtr)
{
AddRef();
return NS_OK;
}
return nsRDFResource::QueryInterface(aIID, aInstancePtr);
}
nsMsgDBFolder::nsMsgDBFolder(void)
: mCharset(""), mAddListener(PR_TRUE)
{
}
nsMsgDBFolder::~nsMsgDBFolder(void)
{
if(mDatabase)
{
mDatabase->RemoveListener(this);
mDatabase->Close(PR_TRUE);
}
}
NS_IMETHODIMP nsMsgDBFolder::StartFolderLoading(void)
{
if(mDatabase)
mDatabase->RemoveListener(this);
mAddListener = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsMsgDBFolder::EndFolderLoading(void)
{
if(mDatabase)
mDatabase->AddListener(this);
mAddListener = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP nsMsgDBFolder::GetThreads(nsISimpleEnumerator** threadEnumerator)
{
nsresult rv = GetDatabase();
if(NS_SUCCEEDED(rv))
return mDatabase->EnumerateThreads(threadEnumerator);
else
return rv;
}
NS_IMETHODIMP
nsMsgDBFolder::GetThreadForMessage(nsIMessage *message, nsIMsgThread **thread)
{
nsresult rv = GetDatabase();
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMsgDBHdr> msgDBHdr;
nsCOMPtr<nsIDBMessage> dbMessage(do_QueryInterface(message, &rv));
if(NS_SUCCEEDED(rv))
rv = dbMessage->GetMsgDBHdr(getter_AddRefs(msgDBHdr));
if(NS_SUCCEEDED(rv))
{
rv = mDatabase->GetThreadContainingMsgHdr(msgDBHdr, thread);
}
}
return rv;
}
NS_IMETHODIMP
nsMsgDBFolder::HasMessage(nsIMessage *message, PRBool *hasMessage)
{
if(!hasMessage)
return NS_ERROR_NULL_POINTER;
nsresult rv = GetDatabase();
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMsgDBHdr> msgDBHdr, msgDBHdrForKey;
nsCOMPtr<nsIDBMessage> dbMessage(do_QueryInterface(message, &rv));
nsMsgKey key;
if(NS_SUCCEEDED(rv))
rv = dbMessage->GetMsgDBHdr(getter_AddRefs(msgDBHdr));
if(NS_SUCCEEDED(rv))
rv = msgDBHdr->GetMessageKey(&key);
if(NS_SUCCEEDED(rv))
rv = mDatabase->ContainsKey(key, hasMessage);
}
return rv;
}
NS_IMETHODIMP nsMsgDBFolder::GetCharset(PRUnichar * *aCharset)
{
nsresult rv = NS_OK;
if(!aCharset)
return NS_ERROR_NULL_POINTER;
if(mCharset == "")
{
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
char *prefCharset = nsnull;
if (NS_SUCCEEDED(rv))
{
rv = prefs->CopyCharPref("intl.character_set_name", &prefCharset);
}
nsString prefCharsetStr;
if(prefCharset)
{
prefCharsetStr = prefCharset;
PR_Free(prefCharset);
}
else
{
prefCharsetStr = "us-ascii";
}
*aCharset = prefCharsetStr.ToNewUnicode();
}
else
{
*aCharset = mCharset.ToNewUnicode();
}
return rv;
}
NS_IMETHODIMP nsMsgDBFolder::SetCharset(const PRUnichar * aCharset)
{
nsresult rv;
nsCOMPtr<nsIDBFolderInfo> folderInfo;
nsCOMPtr<nsIMsgDatabase> db;
rv = GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(db));
if(NS_SUCCEEDED(rv))
{
nsString charset(aCharset);
rv = folderInfo->SetCharacterSet(&charset);
db->Commit(nsMsgDBCommitType::kLargeCommit);
}
return rv;
}
nsresult nsMsgDBFolder::ReadDBFolderInfo(PRBool force)
{
// Since it turns out to be pretty expensive to open and close
// the DBs all the time, if we have to open it once, get everything
// we might need while we're here
nsresult result;
nsCOMPtr <nsIMsgFolderCache> folderCache;
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &result);
if(NS_SUCCEEDED(result))
{
result = mailSession->GetFolderCache(getter_AddRefs(folderCache));
if (NS_SUCCEEDED(result) && folderCache)
{
char *uri;
result = GetURI(&uri);
if (NS_SUCCEEDED(result) && uri)
{
nsCOMPtr <nsIMsgFolderCacheElement> cacheElement;
result = folderCache->GetCacheElement(uri, PR_FALSE, getter_AddRefs(cacheElement));
if (NS_SUCCEEDED(result) && cacheElement)
{
result = ReadFromFolderCache(cacheElement);
}
PR_Free(uri);
}
}
}
// if (m_master->InitFolderFromCache (this))
// return err;
if (force || !(mPrefFlags & MSG_FOLDER_PREF_CACHED))
{
nsCOMPtr<nsIDBFolderInfo> folderInfo;
nsCOMPtr<nsIMsgDatabase> db;
result = GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(db));
if(NS_SUCCEEDED(result))
{
mIsCachable = PR_TRUE;
if (folderInfo)
{
folderInfo->GetFlags(&mPrefFlags);
mPrefFlags |= MSG_FOLDER_PREF_CACHED;
folderInfo->SetFlags(mPrefFlags);
folderInfo->GetNumMessages(&mNumTotalMessages);
folderInfo->GetNumNewMessages(&mNumUnreadMessages);
//These should be put in IMAP folder only.
//folderInfo->GetImapTotalPendingMessages(&mNumPendingTotalMessages);
//folderInfo->GetImapUnreadPendingMessages(&mNumPendingUnreadMessages);
folderInfo->GetCharacterSet(&mCharset);
if (db) {
PRBool hasnew;
nsresult rv;
rv = db->HasNew(&hasnew);
if (NS_FAILED(rv)) return rv;
if (!hasnew && mNumPendingUnreadMessages <= 0) {
ClearFlag(MSG_FOLDER_FLAG_GOT_NEW);
}
}
}
}
if (db)
db->Close(PR_FALSE);
}
return result;
}
nsresult nsMsgDBFolder::SendFlagNotifications(nsISupports *item, PRUint32 oldFlags, PRUint32 newFlags)
{
nsresult rv = NS_OK;
PRUint32 changedFlags = oldFlags ^ newFlags;
if((changedFlags & MSG_FLAG_READ) || (changedFlags & MSG_FLAG_REPLIED)
|| (changedFlags & MSG_FLAG_FORWARDED)|| (changedFlags & MSG_FLAG_NEW))
{
rv = NotifyPropertyFlagChanged(item, "Status", oldFlags, newFlags);
}
else if((changedFlags & MSG_FLAG_MARKED))
{
rv = NotifyPropertyFlagChanged(item, "Flagged", oldFlags, newFlags);
}
return rv;
}
NS_IMETHODIMP
nsMsgDBFolder::GetMsgDatabase(nsIMsgDatabase** aMsgDatabase)
{
if (!aMsgDatabase || !mDatabase)
return NS_ERROR_NULL_POINTER;
*aMsgDatabase = mDatabase;
NS_ADDREF(*aMsgDatabase);
return NS_OK;
}
NS_IMETHODIMP nsMsgDBFolder::OnKeyChange(nsMsgKey aKeyChanged, PRUint32 aOldFlags, PRUint32 aNewFlags,
nsIDBChangeListener * aInstigator)
{
nsCOMPtr<nsIMsgDBHdr> pMsgDBHdr;
nsresult rv = mDatabase->GetMsgHdrForKey(aKeyChanged, getter_AddRefs(pMsgDBHdr));
if(NS_SUCCEEDED(rv) && pMsgDBHdr)
{
nsCOMPtr<nsIMessage> message;
rv = CreateMessageFromMsgDBHdr(pMsgDBHdr, getter_AddRefs(message));
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISupports> msgSupports(do_QueryInterface(message, &rv));
if(NS_SUCCEEDED(rv))
{
SendFlagNotifications(msgSupports, aOldFlags, aNewFlags);
}
UpdateSummaryTotals(PR_TRUE);
}
}
return NS_OK;
}
NS_IMETHODIMP nsMsgDBFolder::OnKeyDeleted(nsMsgKey aKeyChanged, nsMsgKey aParentKey, PRInt32 aFlags,
nsIDBChangeListener * aInstigator)
{
nsCOMPtr<nsIMsgDBHdr> pMsgDBHdr;
nsresult rv = mDatabase->GetMsgHdrForKey(aKeyChanged, getter_AddRefs(pMsgDBHdr));
if(NS_SUCCEEDED(rv) && pMsgDBHdr)
{
nsCOMPtr<nsIMessage> message;
rv = CreateMessageFromMsgDBHdr(pMsgDBHdr, getter_AddRefs(message));
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISupports> msgSupports(do_QueryInterface(message, &rv));
if(NS_SUCCEEDED(rv))
{
NotifyItemDeleted(msgSupports);
}
UpdateSummaryTotals(PR_TRUE);
}
}
return NS_OK;
}
NS_IMETHODIMP nsMsgDBFolder::OnKeyAdded(nsMsgKey aKeyChanged, nsMsgKey aParentKey , PRInt32 aFlags,
nsIDBChangeListener * aInstigator)
{
nsresult rv;
nsCOMPtr<nsIMsgDBHdr> msgDBHdr;
rv = mDatabase->GetMsgHdrForKey(aKeyChanged, getter_AddRefs(msgDBHdr));
if(NS_SUCCEEDED(rv) && msgDBHdr)
{
nsCOMPtr<nsIMessage> message;
rv = CreateMessageFromMsgDBHdr(msgDBHdr, getter_AddRefs(message));
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISupports> msgSupports(do_QueryInterface(message));
if(msgSupports)
{
NotifyItemAdded(msgSupports);
}
UpdateSummaryTotals(PR_TRUE);
}
}
return NS_OK;
}
NS_IMETHODIMP nsMsgDBFolder::OnParentChanged(nsMsgKey aKeyChanged, nsMsgKey oldParent, nsMsgKey newParent,
nsIDBChangeListener * aInstigator)
{
return NS_OK;
}
NS_IMETHODIMP nsMsgDBFolder::OnAnnouncerGoingAway(nsIDBChangeAnnouncer *
instigator)
{
if (mDatabase)
{
mDatabase->RemoveListener(this);
mDatabase = null_nsCOMPtr();
}
return NS_OK;
}
NS_IMETHODIMP nsMsgDBFolder::ManyHeadersToDownload(PRBool *retval)
{
PRInt32 numTotalMessages;
if (!retval)
return NS_ERROR_NULL_POINTER;
if (!mDatabase)
*retval = PR_TRUE;
else if (NS_SUCCEEDED(GetTotalMessages(PR_FALSE, &numTotalMessages)) && numTotalMessages <= 0)
*retval = PR_TRUE;
else
*retval = PR_FALSE;
return NS_OK;
}
nsresult nsMsgDBFolder::ReadFromFolderCache(nsIMsgFolderCacheElement *element)
{
nsresult rv = NS_OK;
char *charset;
element->GetInt32Property("flags", &mPrefFlags);
element->GetInt32Property("totalMsgs", &mNumTotalMessages);
element->GetInt32Property("totalUnreadMsgs", &mNumUnreadMessages);
element->GetStringProperty("charset", &charset);
#ifdef DEBUG_bienvenu1
char *uri;
GetURI(&uri);
printf("read total %ld for %s\n", mNumTotalMessages, uri);
PR_Free(uri);
#endif
mCharset = charset;
PR_FREEIF(charset);
mPrefFlags |= MSG_FOLDER_PREF_CACHED;
return rv;
}
NS_IMETHODIMP nsMsgDBFolder::WriteToFolderCache(nsIMsgFolderCache *folderCache)
{
nsCOMPtr <nsIEnumerator> aEnumerator;
nsresult rv = GetSubFolders(getter_AddRefs(aEnumerator));
if(NS_FAILED(rv))
return rv;
char *uri = nsnull;
rv = GetURI(&uri);
if (folderCache)
{
nsCOMPtr <nsIMsgFolderCacheElement> cacheElement;
rv = folderCache->GetCacheElement(uri, PR_TRUE, getter_AddRefs(cacheElement));
if (NS_SUCCEEDED(rv) && cacheElement)
rv = WriteToFolderCacheElem(cacheElement);
}
PR_FREEIF(uri);
nsCOMPtr<nsISupports> aItem;
rv = aEnumerator->First();
if (!NS_SUCCEEDED(rv))
return NS_OK; // it's OK, there are no sub-folders.
while(NS_SUCCEEDED(rv))
{
rv = aEnumerator->CurrentItem(getter_AddRefs(aItem));
if (NS_FAILED(rv)) break;
nsCOMPtr<nsIMsgFolder> aMsgFolder(do_QueryInterface(aItem, &rv));
if (NS_SUCCEEDED(rv))
{
if (folderCache)
{
rv = aMsgFolder->WriteToFolderCache(folderCache);
if (!NS_SUCCEEDED(rv))
break;
}
}
rv = aEnumerator->Next();
if (!NS_SUCCEEDED(rv))
{
rv = NS_OK;
break;
}
}
return rv;
}
NS_IMETHODIMP nsMsgDBFolder::WriteToFolderCacheElem(nsIMsgFolderCacheElement *element)
{
nsresult rv = NS_OK;
element->SetInt32Property("flags", mPrefFlags);
element->SetInt32Property("totalMsgs", mNumTotalMessages);
element->SetInt32Property("totalUnreadMsgs", mNumUnreadMessages);
element->SetStringProperty("charset", (const char *) nsCAutoString(mCharset));
#ifdef DEBUG_bienvenu1
char *uri;
GetURI(&uri);
printf("writing total %ld for %s\n", mNumTotalMessages, uri);
PR_Free(uri);
#endif
return rv;
}
NS_IMETHODIMP
nsMsgDBFolder::MarkAllMessagesRead(void)
{
nsresult rv = GetDatabase();
if(NS_SUCCEEDED(rv))
return mDatabase->MarkAllRead(nsnull);
return rv;
}
NS_IMETHODIMP
nsMsgDBFolder::OnStartRunningUrl(nsIURI *aUrl)
{
NS_PRECONDITION(aUrl, "just a sanity check");
return NS_OK;
}
NS_IMETHODIMP
nsMsgDBFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
{
NS_PRECONDITION(aUrl, "just a sanity check");
nsCOMPtr<nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(aUrl);
if (mailUrl)
{
PRBool updatingFolder = PR_FALSE;
if (NS_SUCCEEDED(mailUrl->GetUpdatingFolder(&updatingFolder)) && updatingFolder)
{
NotifyFolderLoaded();
}
}
return NS_OK;
}

View File

@@ -0,0 +1,80 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsMsgDBFolder_h__
#define nsMsgDBFolder_h__
#include "msgCore.h"
#include "nsMsgFolder.h"
#include "nsIDBFolderInfo.h"
#include "nsIMsgDatabase.h"
#include "nsIMessage.h"
#include "nsCOMPtr.h"
#include "nsIDBChangeListener.h"
#include "nsIUrlListener.h"
class nsIMsgFolderCacheElement;
/*
* nsMsgDBFolder
* class derived from nsMsgFolder for those folders that use an nsIMsgDatabase
*/
class NS_MSG_BASE nsMsgDBFolder: public nsMsgFolder,
public nsIDBChangeListener,
public nsIUrlListener
{
public:
nsMsgDBFolder(void);
virtual ~nsMsgDBFolder(void);
NS_DECL_NSIDBCHANGELISTENER
NS_IMETHOD StartFolderLoading(void);
NS_IMETHOD EndFolderLoading(void);
NS_IMETHOD GetThreads(nsISimpleEnumerator** threadEnumerator);
NS_IMETHOD GetThreadForMessage(nsIMessage *message, nsIMsgThread **thread);
NS_IMETHOD HasMessage(nsIMessage *message, PRBool *hasMessage);
NS_IMETHOD GetCharset(PRUnichar * *aCharset);
NS_IMETHOD SetCharset(const PRUnichar * aCharset);
NS_IMETHOD GetMsgDatabase(nsIMsgDatabase** aMsgDatabase);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIURLLISTENER
NS_IMETHOD WriteToFolderCache(nsIMsgFolderCache *folderCache);
NS_IMETHOD WriteToFolderCacheElem(nsIMsgFolderCacheElement *element);
NS_IMETHOD ManyHeadersToDownload(PRBool *_retval);
NS_IMETHOD MarkAllMessagesRead(void);
protected:
virtual nsresult ReadDBFolderInfo(PRBool force);
virtual nsresult GetDatabase() = 0;
virtual nsresult SendFlagNotifications(nsISupports *item, PRUint32 oldFlags, PRUint32 newFlags);
nsresult ReadFromFolderCache(nsIMsgFolderCacheElement *element);
protected:
nsCOMPtr<nsIMsgDatabase> mDatabase;
nsString mCharset;
PRBool mAddListener;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,268 @@
/* -*- 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.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.
*/
/********************************************************************************************************
Interface for representing Messenger folders.
*********************************************************************************************************/
#ifndef nsMsgFolder_h__
#define nsMsgFolder_h__
#include "msgCore.h"
#include "nsIMsgFolder.h" /* include the interface we are going to support */
#include "nsRDFResource.h"
#include "nsIDBFolderInfo.h"
#include "nsIMsgDatabase.h"
#include "nsIMsgIncomingServer.h"
#include "nsCOMPtr.h"
#include "nsIURL.h"
/*
* MsgFolder
*/
class NS_MSG_BASE nsMsgFolder: public nsRDFResource, public nsIMsgFolder
{
public:
nsMsgFolder(void);
virtual ~nsMsgFolder(void);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSICOLLECTION
NS_DECL_NSIFOLDER
// eventually this will be an instantiable class, and we should
// use this macro:
// NS_DECL_NSIMSGFOLDER
// right now a few of these methods are left abstract, and
// are commented out below
// begin NS_DECL_NSIMSGFOLDER
NS_IMETHOD AddUnique(nsISupports *element);
NS_IMETHOD ReplaceElement(nsISupports *element, nsISupports *newElement);
NS_IMETHOD GetMessages(nsISimpleEnumerator **_retval);
NS_IMETHOD GetThreads(nsISimpleEnumerator **_retval);
NS_IMETHOD StartFolderLoading(void);
NS_IMETHOD EndFolderLoading(void);
NS_IMETHOD UpdateFolder(void);
NS_IMETHOD GetThreadForMessage(nsIMessage *message, nsIMsgThread **_retval);
NS_IMETHOD HasMessage(nsIMessage *message, PRBool *_retval);
NS_IMETHOD GetVisibleSubFolders(nsIEnumerator **_retval);
NS_IMETHOD GetPrettiestName(PRUnichar * *aPrettiestName);
NS_IMETHOD GetFolderURL(char * *aFolderURL);
NS_IMETHOD GetDeleteIsMoveToTrash(PRBool *aDeleteIsMoveToTrash);
NS_IMETHOD GetShowDeletedMessages(PRBool *aShowDeletedMessages);
NS_IMETHOD GetServer(nsIMsgIncomingServer * *aServer);
NS_IMETHOD GetIsServer(PRBool *aIsServer);
NS_IMETHOD OnCloseFolder(void);
NS_IMETHOD Delete(void);
NS_IMETHOD DeleteSubFolders(nsISupportsArray *folders);
NS_IMETHOD PropagateDelete(nsIMsgFolder *folder, PRBool deleteStorage);
NS_IMETHOD RecursiveDelete(PRBool deleteStorage);
NS_IMETHOD CreateSubfolder(const char *folderName);
NS_IMETHOD Compact(void);
NS_IMETHOD EmptyTrash(void);
NS_IMETHOD Rename(const char *name);
NS_IMETHOD Adopt(nsIMsgFolder *srcFolder, PRUint32 *outPos);
NS_IMETHOD ContainsChildNamed(const char *name, PRBool *_retval);
NS_IMETHOD IsAncestorOf(nsIMsgFolder *folder, PRBool *_retval);
NS_IMETHOD GenerateUniqueSubfolderName(const char *prefix, nsIMsgFolder *otherFolder, char **_retval);
NS_IMETHOD UpdateSummaryTotals(PRBool force);
NS_IMETHOD SummaryChanged(void);
NS_IMETHOD GetNumUnread(PRBool deep, PRInt32 *_retval);
NS_IMETHOD GetTotalMessages(PRBool deep, PRInt32 *_retval);
NS_IMETHOD GetExpungedBytesCount(PRUint32 *aExpungedBytesCount);
NS_IMETHOD GetDeletable(PRBool *aDeletable);
NS_IMETHOD GetCanCreateChildren(PRBool *aCanCreateChildren);
NS_IMETHOD GetCanBeRenamed(PRBool *aCanBeRenamed);
NS_IMETHOD GetRequiresCleanup(PRBool *aRequiresCleanup);
NS_IMETHOD ClearRequiresCleanup(void);
NS_IMETHOD ManyHeadersToDownload(PRBool *_retval);
NS_IMETHOD GetKnowsSearchNntpExtension(PRBool *aKnowsSearchNntpExtension);
NS_IMETHOD GetAllowsPosting(PRBool *aAllowsPosting);
NS_IMETHOD GetDisplayRecipients(PRBool *aDisplayRecipients);
NS_IMETHOD GetRelativePathName(char * *aRelativePathName);
NS_IMETHOD GetSizeOnDisk(PRUint32 *aSizeOnDisk);
NS_IMETHOD RememberPassword(const char *password);
NS_IMETHOD GetRememberedPassword(char * *aRememberedPassword);
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *_retval);
NS_IMETHOD GetUsername(char * *aUsername);
NS_IMETHOD GetHostname(char * *aHostname);
NS_IMETHOD SetFlag(PRUint32 flag);
NS_IMETHOD ClearFlag(PRUint32 flag);
NS_IMETHOD GetFlag(PRUint32 flag, PRBool *_retval);
NS_IMETHOD ToggleFlag(PRUint32 flag);
NS_IMETHOD OnFlagChange(PRUint32 flag);
NS_IMETHOD GetFlags(PRUint32 *aFlags);
NS_IMETHOD GetFoldersWithFlag(PRUint32 flags, nsIMsgFolder **result, PRUint32 resultsize, PRUint32 *numFolders);
NS_IMETHOD GetExpansionArray(nsISupportsArray *expansionArray);
// NS_IMETHOD DeleteMessages(nsISupportsArray *message, nsITransactionManager *txnMgr, PRBool deleteStorage);
NS_IMETHOD CopyMessages(nsIMsgFolder *srcFolder, nsISupportsArray *messages, PRBool isMove, nsITransactionManager *txnMgr, nsIMsgCopyServiceListener *listener);
NS_IMETHOD CopyFileMessage(nsIFileSpec *fileSpec, nsIMessage *msgToReplace, PRBool isDraft, nsITransactionManager *txnMgr, nsIMsgCopyServiceListener *listener);
NS_IMETHOD AcquireSemaphore(nsISupports *semHolder);
NS_IMETHOD ReleaseSemaphore(nsISupports *semHolder);
NS_IMETHOD TestSemaphore(nsISupports *semHolder, PRBool *_retval);
NS_IMETHOD GetLocked(PRBool *aLocked);
// NS_IMETHOD CreateMessageFromMsgDBHdr(nsIMsgDBHdr *msgDBHdr, nsIMessage **_retval);
NS_IMETHOD GetNewMessages(void);
// NS_IMETHOD WriteToFolderCache(nsIMsgFolderCache *folderCache);
// NS_IMETHOD GetCharset(PRUnichar * *aCharset);
// NS_IMETHOD SetCharset(const PRUnichar * aCharset);
NS_IMETHOD GetBiffState(PRUint32 *aBiffState);
NS_IMETHOD SetBiffState(PRUint32 aBiffState);
NS_IMETHOD GetNumNewMessages(PRInt32 *aNumNewMessages);
NS_IMETHOD SetNumNewMessages(PRInt32 aNumNewMessages);
NS_IMETHOD GetNewMessagesNotificationDescription(PRUnichar * *aNewMessagesNotificationDescription);
NS_IMETHOD GetRootFolder(nsIMsgFolder * *aRootFolder);
NS_IMETHOD GetMsgDatabase(nsIMsgDatabase * *aMsgDatabase);
NS_IMETHOD GetPath(nsIFileSpec * *aPath);
NS_IMETHOD MarkMessagesRead(nsISupportsArray *messages, PRBool markRead);
NS_IMETHOD MarkAllMessagesRead(void);
NS_IMETHOD MarkMessagesFlagged(nsISupportsArray *messages, PRBool markFlagged);
NS_IMETHOD GetChildWithURI(const char *uri, PRBool deep, nsIMsgFolder **_retval);
// end NS_DECL_NSIMSGFOLDER
// nsRDFResource overrides
NS_IMETHOD Init(const char* aURI);
#if 0
static nsresult GetRoot(nsIMsgFolder* *result);
#endif
// Gets the URL that represents the given message. Returns a newly
// created string that must be free'd using XP_FREE().
// If the db is NULL, then returns a URL that represents the entire
// folder as a whole.
#ifdef HAVE_DB
NS_IMETHOD BuildUrl(nsMsgDatabase *db, nsMsgKey key, char ** url);
// updates num messages and num unread - should be pure virtual
// when I get around to implementing in all subclasses?
NS_IMETHOD GetTotalMessagesInDB(PRUint32 *totalMessages) const; // How many messages in database.
// These functions are used for tricking the front end into thinking that we have more
// messages than are really in the DB. This is usually after and IMAP message copy where
// we don't want to do an expensive select until the user actually opens that folder
// These functions are called when MSG_Master::GetFolderLineById is populating a MSG_FolderLine
// struct used by the FE
int32 GetNumPendingUnread(PRBool deep = PR_FALSE);
int32 GetNumPendingTotalMessages(PRBool deep = PR_FALSE);
void ChangeNumPendingUnread(int32 delta);
void ChangeNumPendingTotalMessages(int32 delta);
NS_IMETHOD SetFolderPrefFlags(PRUint32 flags);
NS_IMETHOD GetFolderPrefFlags(PRUint32 *flags);
NS_IMETHOD SetLastMessageLoaded(nsMsgKey lastMessageLoaded);
NS_IMETHOD GetLastMessageLoaded();
#endif
#ifdef HAVE_ADMINURL
NS_IMETHOD GetAdminUrl(MWContext *context, MSG_AdminURLType type);
NS_IMETHOD HaveAdminUrl(MSG_AdminURLType type, PRBool *hadAdminUrl);
#endif
#ifdef HAVE_PANE
NS_IMETHOD MarkAllRead(MSG_Pane *pane, PRBool deep);
NS_IMETHOD SetFlagInAllFolderPanes(PRUint32 which);
#endif
#ifdef HAVE_NET
NS_IMETHOD EscapeMessageId(const char *messageId, const char **escapeMessageID);
NS_IMETHOD ShouldPerformOperationOffline(PRBool *performOffline);
#endif
#ifdef HAVE_CACHE
virtual nsresult WriteToCache(XP_File);
virtual nsresult ReadFromCache(char *);
virtual PRBool IsCachable();
void SkipCacheTokens(char **ppBuf, int numTokens);
#endif
#ifdef DOES_FOLDEROPERATIONS
int DownloadToTempFileAndUpload(MessageCopyInfo *copyInfo, nsMsgKeyArray &keysToSave, MSG_FolderInfo *dstFolder, nsMsgDatabase *sourceDB);
void UpdateMoveCopyStatus(MWContext *context, PRBool isMove, int32 curMsgCount, int32 totMessages);
#endif
virtual nsresult GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsIMsgDatabase **db) = 0;
NS_IMETHOD MatchName(nsString *name, PRBool *matches);
protected:
nsresult NotifyPropertyChanged(char *property, char* oldValue, char* newValue);
nsresult NotifyPropertyFlagChanged(nsISupports *item, char *property, PRUint32 oldValue,
PRUint32 newValue);
nsresult NotifyItemAdded(nsISupports *item);
nsresult NotifyItemDeleted(nsISupports *item);
nsresult NotifyFolderLoaded();
// this is a little helper function that is not part of the public interface.
// we use it to get the IID of the incoming server for the derived folder.
// w/out a function like this we would have to implement GetServer in each
// derived folder class.
virtual const char* GetIncomingServerType() = 0;
protected:
PRUint32 mFlags;
nsIFolder *mParent; //This won't be refcounted for ownership reasons.
PRInt32 mNumUnreadMessages; /* count of unread messages (-1 means
unknown; -2 means unknown but we already
tried to find out.) */
PRInt32 mNumTotalMessages; /* count of existing messages. */
nsCOMPtr<nsISupportsArray> mSubFolders;
nsVoidArray *mListeners; //This can't be an nsISupportsArray because due to
//ownership issues, listeners can't be AddRef'd
PRInt32 mPrefFlags; // prefs like MSG_PREF_OFFLINE, MSG_PREF_ONE_PANE, etc
nsISupports *mSemaphoreHolder; // set when the folder is being written to
//Due to ownership issues, this won't be AddRef'd.
nsIMsgIncomingServer* m_server; //this won't be addrefed....ownership issue here
#ifdef HAVE_DB
nsMsgKey m_lastMessageLoaded;
#endif
// These values are used for tricking the front end into thinking that we have more
// messages than are really in the DB. This is usually after and IMAP message copy where
// we don't want to do an expensive select until the user actually opens that folder
PRInt32 mNumPendingUnreadMessages;
PRInt32 mNumPendingTotalMessages;
PRUint32 mBiffState;
PRInt32 mNumNewBiffMessages;
PRBool mIsCachable;
//
// stuff from the uri
//
PRBool mIsServer;
nsString mName;
};
#endif

View File

@@ -0,0 +1,598 @@
/* -*- 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 "msgCore.h" // precompiled header...
#include "prlog.h"
#include "nsMsgGroupRecord.h"
#include "plstr.h"
#include "prmem.h"
#include "nsEscape.h"
#include "nsCRT.h"
// mscott: this is lame...I know....
#define MK_OUT_OF_MEMORY 1
const PRUint32 F_ISGROUP = 0x00000001;
const PRUint32 F_EXPANDED = 0x00000002;
const PRUint32 F_CATCONT = 0x00000004;
const PRUint32 F_VIRTUAL = 0x00000008;
const PRUint32 F_DIRTY = 0x00000010;
const PRUint32 F_DESCENDENTSLOADED = 0x00000020;
const PRUint32 F_HTMLOKGROUP = 0x00000040;
const PRUint32 F_HTMLOKTREE = 0x00000080;
const PRUint32 F_NEEDEXTRAINFO = 0x00000100;
const PRUint32 F_DOESNOTEXIST = 0x00000200;
const PRUint32 RUNTIMEFLAGS = // Flags to be sure *not* to write to disk.
F_DIRTY | F_DESCENDENTSLOADED | F_EXPANDED;
int
nsMsgGroupRecord::GroupNameCompare(const char* name1, const char* name2,
char delimiter, PRBool caseInsensitive)
{
if (caseInsensitive)
{
while (*name1 && (nsCRT::ToUpper(*name1) == nsCRT::ToUpper(*name2))) {
name1++;
name2++;
}
}
else
{
while (*name1 && *name1 == *name2) {
name1++;
name2++;
}
}
if (*name1 && *name2) {
if (*name1 == delimiter) return -1;
if (*name2 == delimiter) return 1;
}
if (caseInsensitive)
return int(nsCRT::ToUpper(*name1)) - int(nsCRT::ToUpper(*name2));
else
return int(*name1) - int(*name2);
}
nsMsgGroupRecord*
nsMsgGroupRecord::Create(nsMsgGroupRecord* parent, const char* partname,
PRInt64 aTime, PRInt32 uniqueid, PRInt32 fileoffset)
{
nsMsgGroupRecord* result = new nsMsgGroupRecord(parent, partname,
aTime, uniqueid, fileoffset);
if (result && partname && !result->m_partname) {
// We ran out of memory.
delete result;
result = NULL;
}
result->InitializeSibling();
return result;
}
MOZ_DECL_CTOR_COUNTER(nsMsgGroupRecord);
nsMsgGroupRecord::nsMsgGroupRecord(nsMsgGroupRecord* parent, const char* partname,
PRInt64 aTime, PRInt32 uniqueid, PRInt32 fileoffset,
char delimiter /* = '.' */)
{
MOZ_COUNT_CTOR(nsMsgGroupRecord);
int length;
m_prettyname = NULL;
m_parent = parent;
m_children = NULL;
m_sibling = NULL;
m_flags = 0;
m_partname = NULL;
m_addtime = aTime;
m_uniqueId = uniqueid;
m_fileoffset = fileoffset;
m_delimiter = delimiter;
if (partname) {
length = PL_strlen(partname);
// PR_ASSERT(parent != NULL);
m_partname = new char [length + 1];
if (!m_partname) {
m_parent = NULL;
return;
}
PL_strcpy(m_partname, partname);
}
}
nsMsgGroupRecord::~nsMsgGroupRecord()
{
MOZ_COUNT_DTOR(nsMsgGroupRecord);
delete [] m_partname;
m_partname = NULL;
delete [] m_prettyname;
m_prettyname = NULL;
while (m_children) {
delete m_children;
}
m_children = NULL;
if (m_parent) {
nsMsgGroupRecord** ptr;
for (ptr = &(m_parent->m_children);
*ptr;
ptr = &((*ptr)->m_sibling)) {
if (*ptr == this) {
*ptr = m_sibling;
break;
}
}
}
}
void nsMsgGroupRecord::InitializeSibling()
{
if (m_parent) {
PR_ASSERT(m_partname != NULL);
nsMsgGroupRecord** ptr;
for (ptr = &(m_parent->m_children) ; *ptr ; ptr = &((*ptr)->m_sibling)) {
int comp = GroupNameCompare((*ptr)->m_partname, m_partname, m_delimiter, IsIMAPGroupRecord());
PR_ASSERT(comp != 0);
if (comp >= 0) break;
}
m_sibling = *ptr;
*ptr = this;
}
}
nsMsgGroupRecord*
nsMsgGroupRecord::FindDescendant(const char* name)
{
if (!name || !*name) return this;
char* ptr = PL_strchr(name, m_delimiter);
if (ptr) *ptr = '\0';
nsMsgGroupRecord* child;
for (child = m_children ; child ; child = child->m_sibling) {
if (PL_strcmp(child->m_partname, name) == 0) {
break;
}
}
if (ptr) {
*ptr++ = m_delimiter;
if (child) {
return child->FindDescendant(ptr);
}
}
return child;
}
nsMsgGroupRecord*
nsMsgGroupRecord::GetSiblingOrAncestorSibling()
{
if (m_sibling) return m_sibling;
if (m_parent) return m_parent->GetSiblingOrAncestorSibling();
return NULL;
}
nsMsgGroupRecord*
nsMsgGroupRecord::GetNextAlphabetic()
{
nsMsgGroupRecord* result;
if (m_children) result = m_children;
else result = GetSiblingOrAncestorSibling();
#ifdef DEBUG_slowAndParanoid
if (result) {
char* ptr1 = GetFullName();
char* ptr2 = result->GetFullName();
PR_ASSERT(GroupNameCompare(ptr1, ptr2) < 0);
delete [] ptr1;
delete [] ptr2;
}
#endif
return result;
}
nsMsgGroupRecord*
nsMsgGroupRecord::GetNextAlphabeticNoCategories()
{
if (IsCategoryContainer()) {
return GetSiblingOrAncestorSibling();
} else {
return GetNextAlphabetic();
}
}
char*
nsMsgGroupRecord::GetFullName()
{
int length = 0;
nsMsgGroupRecord* ptr;
for (ptr = this ; ptr ; ptr = ptr->m_parent) {
if (ptr->m_partname) length += PL_strlen(ptr->m_partname) + 1;
}
PR_ASSERT(length > 0);
if (length <= 0) return NULL;
char* result = new char [length];
if (result) {
SuckInName(result);
PR_ASSERT(int(PL_strlen(result)) + 1 == length);
}
return result;
}
char*
nsMsgGroupRecord::SuckInName(char* ptr)
{
if (m_parent && m_parent->m_partname) {
ptr = m_parent->SuckInName(ptr);
*ptr++ = m_delimiter;
}
PL_strcpy(ptr, m_partname);
return ptr + PL_strlen(ptr);
}
int
nsMsgGroupRecord::SetPrettyName(const char* name)
{
if (name == NULL && m_prettyname == NULL) return 0;
m_flags |= F_DIRTY;
delete [] m_prettyname;
m_prettyname = NULL;
if (!name || !*name) {
return 0;
}
int length = PL_strlen(name);
m_prettyname = new char [length + 1];
if (!m_prettyname) {
return MK_OUT_OF_MEMORY;
}
PL_strcpy(m_prettyname, name);
return 1;
}
PRBool
nsMsgGroupRecord::IsCategory()
{
return GetCategoryContainer() != NULL;
}
PRBool
nsMsgGroupRecord::IsCategoryContainer()
{
return (m_flags & F_CATCONT) != 0;
}
PRBool
nsMsgGroupRecord::NeedsExtraInfo()
{
return (m_flags & F_NEEDEXTRAINFO) != 0;
}
int
nsMsgGroupRecord::SetNeedsExtraInfo(PRBool value)
{
return TweakFlag(F_NEEDEXTRAINFO, value);
}
int
nsMsgGroupRecord::SetIsCategoryContainer(PRBool value)
{
// refuse to set a group to be a category container if it has a parent
// that's a category container.
if (! (value && GetCategoryContainer()))
return TweakFlag(F_CATCONT, value);
else
return 0;
}
nsMsgGroupRecord*
nsMsgGroupRecord::GetCategoryContainer()
{
if (IsCategoryContainer()) return NULL;
for (nsMsgGroupRecord* ptr = m_parent ; ptr ; ptr = ptr->m_parent) {
if (ptr->IsCategoryContainer()) return ptr;
}
return NULL;
}
nsresult
nsMsgGroupRecord::IsVirtual(PRBool *retval)
{
*retval =( (m_flags & F_VIRTUAL) != 0);
return NS_OK;
}
nsresult
nsMsgGroupRecord::SetIsVirtual(PRBool value)
{
TweakFlag(F_VIRTUAL, value);
return NS_OK;
}
PRBool
nsMsgGroupRecord::IsExpanded()
{
return (m_flags & F_EXPANDED) != 0;
}
int
nsMsgGroupRecord::SetIsExpanded(PRBool value)
{
return TweakFlag(F_EXPANDED, value);
}
PRBool
nsMsgGroupRecord::IsHTMLOKGroup()
{
return (m_flags & F_HTMLOKGROUP) != 0;
}
int
nsMsgGroupRecord::SetIsHTMLOKGroup(PRBool value)
{
return TweakFlag(F_HTMLOKGROUP, value);
}
PRBool
nsMsgGroupRecord::IsHTMLOKTree()
{
return (m_flags & F_HTMLOKTREE) != 0;
}
int
nsMsgGroupRecord::SetIsHTMLOKTree(PRBool value)
{
return TweakFlag(F_HTMLOKTREE, value);
}
PRBool
nsMsgGroupRecord::IsGroup()
{
return (m_flags & F_ISGROUP) != 0;
}
int
nsMsgGroupRecord::SetIsGroup(PRBool value)
{
return TweakFlag(F_ISGROUP, value);
}
PRBool
nsMsgGroupRecord::IsDescendentsLoaded()
{
return (m_flags & F_DESCENDENTSLOADED) != 0;
}
int
nsMsgGroupRecord::SetIsDescendentsLoaded(PRBool value)
{
PR_ASSERT(value); // No reason we'd ever unset this.
TweakFlag(F_DESCENDENTSLOADED, PR_TRUE);
nsMsgGroupRecord* child;
for (child = m_children ; child ; child = child->m_sibling) {
child->SetIsDescendentsLoaded(value);
}
return 0;
}
PRBool nsMsgGroupRecord::DoesNotExistOnServer()
{
return (m_flags & F_DOESNOTEXIST) != 0;
}
int nsMsgGroupRecord::SetDoesNotExistOnServer(PRBool value)
{
if (value) // turn off group flag if doesn't exist on server.
TweakFlag(F_ISGROUP, PR_FALSE);
return TweakFlag(F_DOESNOTEXIST, value);
}
int
nsMsgGroupRecord::TweakFlag(PRUint32 flagbit, PRBool value)
{
if (value) {
if (!(m_flags & flagbit)) {
m_flags |= flagbit;
if (flagbit & ~RUNTIMEFLAGS)
m_flags |= F_DIRTY;
return 1;
}
} else {
if (m_flags & flagbit) {
m_flags &= ~flagbit;
if (flagbit & ~RUNTIMEFLAGS)
m_flags |= F_DIRTY;
return 1;
}
}
return 0;
}
PRInt32
nsMsgGroupRecord::GetNumKids()
{
PRInt32 result = 0;
nsMsgGroupRecord* child;
for (child = m_children ; child ; child = child->m_sibling) {
if (IsIMAPGroupRecord())
result++;
else
if (child->m_flags & F_ISGROUP) result++;
if (!IsIMAPGroupRecord())
result += child->GetNumKids();
}
return result;
}
char*
nsMsgGroupRecord::GetSaveString()
{
char* pretty = NULL;
char* result = nsnull;
if (m_prettyname) {
pretty = nsEscape(m_prettyname, url_XAlphas);
if (!pretty) return NULL;
}
char* fullname = GetFullName();
if (!fullname) return NULL; {
long nAddTime;
LL_L2I(nAddTime, m_addtime);
result = PR_smprintf("%s,%s,%lx,%lx,%lx" MSG_LINEBREAK,
fullname, pretty ? pretty : "",
(long) (m_flags & ~RUNTIMEFLAGS),
nAddTime,
(long) m_uniqueId);
}
delete [] fullname;
if (pretty) nsCRT::free(pretty);
m_flags &= ~F_DIRTY;
return result;
}
PRBool
nsMsgGroupRecord::IsDirty()
{
return (m_flags & F_DIRTY) != 0;
}
PRInt32
nsMsgGroupRecord::GetDepth()
{
PRInt32 result = 0;
nsMsgGroupRecord* tmp = m_parent;
while (tmp) {
tmp = tmp->m_parent;
result++;
}
return result;
}
nsMsgGroupRecord*
nsMsgGroupRecord::Create(nsMsgGroupRecord* parent, const char* saveline,
PRInt32 savelinelength, PRInt32 fileoffset)
{
char* tmp;
char* ptr;
char* endptr;
char* partname;
char* prettyname;
PRInt32 flags;
PRInt32 addtime;
PRInt32 uniqueid;
nsMsgGroupRecord* result = NULL;
if (savelinelength < 0) savelinelength = PL_strlen(saveline);
tmp = (char*) PR_Malloc(savelinelength + 1);
if (!tmp) return NULL;
PL_strncpy(tmp, saveline, savelinelength);
tmp[savelinelength] = '\0';
ptr = PL_strchr(tmp, ',');
PR_ASSERT(ptr);
if (!ptr) goto FAIL;
*ptr++ = '\0';
partname = PL_strrchr(tmp, '.');
if (!partname) partname = tmp;
else partname++;
#ifdef DEBUG_slowAndParanoid
if (parent->m_partname) {
char* parentname = parent->GetFullName();
PR_ASSERT(partname > tmp && partname[-1] == '.');
partname[-1] = '\0';
PR_ASSERT(PL_strcmp(parentname, tmp) == 0);
partname[-1] = '.';
delete [] parentname;
parentname = NULL;
} else {
PR_ASSERT(partname == tmp);
}
#endif
endptr = PL_strchr(ptr, ',');
PR_ASSERT(endptr);
if (!endptr) goto FAIL;
*endptr++ = '\0';
prettyname = nsUnescape(ptr);
ptr = endptr;
endptr = PL_strchr(ptr, ',');
PR_ASSERT(endptr);
if (!endptr) goto FAIL;
*endptr++ = '\0';
flags = strtol(ptr, NULL, 16);
ptr = endptr;
endptr = PL_strchr(ptr, ',');
PR_ASSERT(endptr);
if (!endptr) goto FAIL;
*endptr++ = '\0';
addtime = strtol(ptr, NULL, 16);
ptr = endptr;
uniqueid = strtol(ptr, NULL, 16);
PRInt64 llAddtime;
LL_I2L(llAddtime, addtime);
result = Create(parent, partname, llAddtime, uniqueid, fileoffset);
if (result) {
PRBool maybeCategoryContainer = flags & F_CATCONT;
flags &= ~F_CATCONT;
result->m_flags = flags;
if (maybeCategoryContainer)
result->SetIsCategoryContainer(PR_TRUE);
if (prettyname && *prettyname) result->SetPrettyName(prettyname);
}
FAIL:
PR_Free(tmp);
return result;
}

View File

@@ -0,0 +1,160 @@
/* -*- 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.
*/
// This class should only be used by the subscribe UI and by newshost.cpp.
// And, well, a bit by the category code. Everyone else should use the stuff
// in newshost.h.
#ifndef _nsMsgGroupRecord_h_
#define _nsMsgGroupRecord_h__
#include "msgCore.h"
#include "prtypes.h"
#include "nsISupports.h"
class nsIMAPGroupRecord;
class NS_MSG_BASE nsMsgGroupRecord {
public:
static nsMsgGroupRecord* Create(nsMsgGroupRecord* parent,
const char* partname,
PRInt64 m_addtime,
PRInt32 uniqueid,
PRInt32 fileoffset);
static nsMsgGroupRecord* Create(nsMsgGroupRecord* parent,
const char* saveline,
PRInt32 savelinelength,
PRInt32 fileoffset);
virtual void InitializeSibling();
virtual PRBool IsIMAPGroupRecord() { return PR_FALSE; }
virtual nsIMAPGroupRecord *GetIMAPGroupRecord() { return 0; }
// This is just like PL_strcmp(), except it works on news group names.
// A container groupname is always less than any contained groups.
// So, "netscape.devs-client-technical" > "netscape.devs.directory", even
// though PL_strcmp says otherwise. (YICK!)
static int GroupNameCompare(const char* name1,
const char* name2,
char delimiter = '.',
PRBool caseInsensitive = PR_FALSE);
virtual ~nsMsgGroupRecord();
nsMsgGroupRecord* FindDescendant(const char* name);
nsMsgGroupRecord* GetParent() {return m_parent;}
nsMsgGroupRecord* GetChildren() {return m_children;}
nsMsgGroupRecord* GetSibling() {return m_sibling;}
nsMsgGroupRecord* GetSiblingOrAncestorSibling();
nsMsgGroupRecord* GetNextAlphabetic();
nsMsgGroupRecord* GetNextAlphabeticNoCategories();
const char* GetPartName() {return m_partname;}
// The resulting string must be free'd using delete[].
char* GetFullName();
const char* GetPrettyName() {return m_prettyname;}
int SetPrettyName(const char* prettyname);
PRInt64 GetAddTime() {return m_addtime;}
virtual PRBool IsCategory();
virtual PRBool IsCategoryContainer();
virtual int SetIsCategoryContainer(PRBool value);
nsMsgGroupRecord* GetCategoryContainer();
// Get/Set whether this is a virtual newsgroup.
nsresult IsVirtual(PRBool *retval);
nsresult SetIsVirtual(PRBool value);
// Get/Set whether this is really a newsgroup (and not just a container
// for newsgroups).
virtual PRBool IsGroup();
int SetIsGroup(PRBool value);
PRBool IsDescendentsLoaded();
int SetIsDescendentsLoaded(PRBool value);
PRBool IsExpanded();
int SetIsExpanded(PRBool value);
PRBool IsHTMLOKGroup();
int SetIsHTMLOKGroup(PRBool value);
PRBool IsHTMLOKTree();
int SetIsHTMLOKTree(PRBool value);
PRBool NeedsExtraInfo();
int SetNeedsExtraInfo(PRBool value);
PRBool DoesNotExistOnServer();
int SetDoesNotExistOnServer(PRBool value);
PRInt32 GetUniqueID() {return m_uniqueId;}
PRInt32 GetFileOffset() {return m_fileoffset;}
int SetFileOffset(PRInt32 value) {m_fileoffset = value; return 0;}
// Get the number of descendents (not including ourself) that are
// really newsgroups.
PRInt32 GetNumKids();
// Gets the string that represents this group in the save file. The
// resulting string must be free'd with PR_Free().
char* GetSaveString();
PRBool IsDirty(); // Whether this record has had changes made
// to it. Cleared by calls to GetSaveString().
PRInt32 GetDepth(); // Returns how deep in the heirarchy we are.
// Basically, the number of dots in the full
// newsgroup name, plus 1.
virtual char GetHierarchySeparator() { return '.'; }
protected:
nsMsgGroupRecord(nsMsgGroupRecord* parent,
const char* partname,
PRInt64 m_addtime,
PRInt32 uniqueid,
PRInt32 fileoffset,
char delimiter = '.');
int TweakFlag(PRUint32 flagbit, PRBool value);
char* SuckInName(char* ptr);
char* m_partname;
char* m_prettyname;
nsMsgGroupRecord* m_parent;
nsMsgGroupRecord* m_children;
nsMsgGroupRecord* m_sibling;
PRUint32 m_flags;
PRInt64 m_addtime;
PRInt32 m_uniqueId;
PRInt32 m_fileoffset;
char m_delimiter;
};
#endif /* _grec_h_ */

View File

@@ -0,0 +1,363 @@
/* -*- 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.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.
*/
// as does this
#define NS_IMPL_IDS
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "nsISupports.h"
#include "nsIPref.h"
#include "nsIMimeConverter.h"
#include "msgCore.h"
#include "rosetta_mailnews.h"
#include "nsMsgI18N.h"
#include "nsFileSpec.h"
#include "nsFileStream.h"
#include "nsMsgMimeCID.h"
#include "nsMimeTypes.h"
#include "nsIEntityConverter.h"
#include "nsISaveAsCharset.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kCMimeConverterCID, NS_MIME_CONVERTER_CID);
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
static NS_DEFINE_CID(kEntityConverterCID, NS_ENTITYCONVERTER_CID);
static NS_DEFINE_CID(kSaveAsCharsetCID, NS_SAVEASCHARSET_CID);
//
// International functions necessary for composition
//
// Convert an unicode string to a C string with a given charset.
nsresult ConvertFromUnicode(const nsString& aCharset,
const nsString& inString,
char** outCString)
{
nsresult res;
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
if(NS_SUCCEEDED(res) && (nsnull != ccm)) {
nsIUnicodeEncoder* encoder = nsnull;
nsString convCharset;
// map to converter charset
if (aCharset.EqualsIgnoreCase("us-ascii")) {
convCharset.SetString("iso-8859-1");
}
else {
convCharset = aCharset;
}
// get an unicode converter
res = ccm->GetUnicodeEncoder(&convCharset, &encoder);
if(NS_SUCCEEDED(res) && (nsnull != encoder)) {
PRUnichar *unichars = (PRUnichar *) inString.GetUnicode();
PRInt32 unicharLength = inString.Length();
PRInt32 dstLength;
res = encoder->GetMaxLength(unichars, unicharLength, &dstLength);
// allocale an output buffer
*outCString = (char *) PR_Malloc(dstLength + 1);
if (nsnull != *outCString) {
PRInt32 oldUnicharLength = unicharLength;
char *tempCString = *outCString;
PRInt32 totalCLength = 0;
while (1) {
res = encoder->Convert(unichars, &unicharLength, tempCString, &dstLength);
// increment for destination
tempCString += dstLength;
totalCLength += dstLength;
// break: this is usually the case
// source length <= zero and no error or unrecoverable error
if (0 >= unicharLength || NS_ERROR_UENC_NOMAPPING != res) {
break;
}
// could not map unicode to the destination charset, skip one unichar and continue
// increment for source unicode, skip one unichar
unichars += unicharLength + 1;
oldUnicharLength -= (unicharLength + 1);
unicharLength = oldUnicharLength;
// estimate target length again
(void) encoder->GetMaxLength(unichars, unicharLength, &dstLength);
}
(*outCString)[totalCLength] = '\0';
}
else {
res = NS_ERROR_OUT_OF_MEMORY;
}
NS_IF_RELEASE(encoder);
}
}
return res;
}
// Convert a C string to an unicode string.
nsresult ConvertToUnicode(const nsString& aCharset,
const char* inCString,
nsString& outString)
{
nsresult res;
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
if(NS_SUCCEEDED(res) && (nsnull != ccm)) {
nsIUnicodeDecoder* decoder = nsnull;
PRUnichar *unichars;
PRInt32 unicharLength;
nsString convCharset;
// map to converter charset
if (aCharset.EqualsIgnoreCase("us-ascii")) {
convCharset.SetString("iso-8859-1");
}
else {
convCharset = aCharset;
}
// get an unicode converter
res = ccm->GetUnicodeDecoder(&convCharset, &decoder);
if(NS_SUCCEEDED(res) && (nsnull != decoder)) {
PRInt32 srcLen = PL_strlen(inCString);
res = decoder->GetMaxLength(inCString, srcLen, &unicharLength);
// allocale an output buffer
unichars = (PRUnichar *) PR_Malloc(unicharLength * sizeof(PRUnichar));
if (unichars != nsnull) {
// convert to unicode
res = decoder->Convert(inCString, &srcLen, unichars, &unicharLength);
outString.SetString(unichars, unicharLength);
PR_Free(unichars);
}
else {
res = NS_ERROR_OUT_OF_MEMORY;
}
NS_IF_RELEASE(decoder);
}
}
return res;
}
// Charset to be used for the internatl processing.
const char *msgCompHeaderInternalCharset()
{
// UTF-8 is a super set of us-ascii.
// We can use the same string manipulation methods as us-ascii without breaking non us-ascii characters.
return "UTF-8";
}
// MIME encoder, output string should be freed by PR_FREE
char * nsMsgI18NEncodeMimePartIIStr(const char *header, const char *charset, PRBool bUseMime)
{
// No MIME, just duplicate the string.
if (PR_FALSE == bUseMime) {
return PL_strdup(header);
}
char *encodedString = nsnull;
nsIMimeConverter *converter;
nsresult res = nsComponentManager::CreateInstance(kCMimeConverterCID, nsnull,
nsCOMTypeInfo<nsIMimeConverter>::GetIID(), (void **)&converter);
if (NS_SUCCEEDED(res) && nsnull != converter) {
res = converter->EncodeMimePartIIStr_UTF8(header, charset, kMIME_ENCODED_WORD_SIZE, &encodedString);
NS_RELEASE(converter);
}
return NS_SUCCEEDED(res) ? encodedString : nsnull;
}
// MIME decoder
nsresult nsMsgI18NDecodeMimePartIIStr(const nsString& header, nsString& charset, nsString& decodedString)
{
nsIMimeConverter *converter;
nsresult res = nsComponentManager::CreateInstance(kCMimeConverterCID, nsnull,
nsCOMTypeInfo<nsIMimeConverter>::GetIID(), (void **)&converter);
if (NS_SUCCEEDED(res) && nsnull != converter) {
res = converter->DecodeMimePartIIStr(header, charset, decodedString);
NS_RELEASE(converter);
}
return res;
}
// Get a default mail character set.
char * nsMsgI18NGetDefaultMailCharset()
{
nsresult res = NS_OK;
char * retVal = nsnull;
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &res);
if (nsnull != prefs && NS_SUCCEEDED(res))
{
char *prefValue;
res = prefs->CopyCharPref("intl.character_set_name", &prefValue);
if (NS_SUCCEEDED(res))
{
//TODO: map to mail charset (e.g. Shift_JIS -> ISO-2022-JP) bug#3941.
retVal = prefValue;
}
else
retVal = PL_strdup("iso-8859-1");
}
return (nsnull != retVal) ? retVal : PL_strdup("iso-8859-1");
}
// Return True if a charset is stateful (e.g. JIS).
PRBool nsMsgI18Nstateful_charset(const char *charset)
{
//TODO: use charset manager's service
return (PL_strcasecmp(charset, "iso-2022-jp") == 0);
}
// Check 7bit in a given buffer.
// This is expensive (both memory and performance).
// The check would be very simple if applied to an unicode text (e.g. nsString or utf-8).
// Possible optimazaion is to search ESC(0x1B) in case of iso-2022-jp and iso-2022-kr.
// Or convert and check line by line.
PRBool nsMsgI18N7bit_data_part(const char *charset, const char *inString, const PRUint32 size)
{
char *aCString;
nsString aCharset(charset);
nsString outString;
nsresult res;
aCString = (char *) PR_Malloc(size + 1);
if (nsnull != aCString) {
PL_strncpy(aCString, inString, size); // make a C string
res = ConvertToUnicode(aCharset, aCString, outString);
PR_Free(aCString);
if (NS_SUCCEEDED(res)) {
for (PRInt32 i = 0; i < outString.Length(); i++) {
if (outString.CharAt(i) > 127) {
return PR_FALSE;
}
}
}
}
return PR_TRUE; // all 7 bit
}
// Simple parser to parse META charset.
// It only supports the case when the description is within one line.
const char *
nsMsgI18NParseMetaCharset(nsFileSpec* fileSpec)
{
static char charset[65];
char buffer[512];
nsInputFileStream fileStream(*fileSpec);
*charset = '\0';
while (!fileStream.eof() && !fileStream.failed() &&
fileStream.is_open()) {
fileStream.readline(buffer, 512);
if (*buffer == CR || *buffer == LF || *buffer == 0)
continue;
for (int i = 0; i < (int)PL_strlen(buffer); i++) {
buffer[i] = toupper(buffer[i]);
}
if (PL_strstr(buffer, "/HEAD"))
break;
if (PL_strstr(buffer, "META") &&
PL_strstr(buffer, "HTTP-EQUIV") &&
PL_strstr(buffer, "CONTENT-TYPE") &&
PL_strstr(buffer, "CHARSET")
)
{
char *cp = PL_strstr(PL_strstr(buffer, "CHARSET"), "=") + 1;
char seps[] = " \"\'";
char *token;
char* newStr;
token = nsCRT::strtok(cp, seps, &newStr);
if (token != NULL)
{
PL_strcpy(charset, token);
}
}
}
return charset;
}
nsresult nsMsgI18NConvertToEntity(const nsString& inString, nsString* outString)
{
nsresult res;
outString->SetString("");
nsCOMPtr <nsIEntityConverter> entityConv;
res = nsComponentManager::CreateInstance(kEntityConverterCID, NULL,
nsIEntityConverter::GetIID(), getter_AddRefs(entityConv));
if(NS_SUCCEEDED(res)) {
PRUnichar *entities = NULL;
res = entityConv->ConvertToEntities(inString.GetUnicode(), nsIEntityConverter::html40Latin1, &entities);
if (NS_SUCCEEDED(res) && (NULL != entities)) {
outString->SetString(entities);
nsAllocator::Free(entities);
}
}
return res;
}
nsresult nsMsgI18NSaveAsCharset(const char* contentType, const char *charset, const PRUnichar* inString, char** outString)
{
NS_ASSERTION(contentType, "null ptr- contentType");
NS_ASSERTION(charset, "null ptr- charset");
NS_ASSERTION(outString, "null ptr- outString");
if(!contentType || !charset || !outString)
return NS_ERROR_NULL_POINTER;
*outString = NULL;
PRBool bTEXT_HTML = PR_FALSE;
nsresult res;
if (!nsCRT::strcasecmp(contentType, TEXT_HTML)) {
bTEXT_HTML = PR_TRUE;
}
else if (nsCRT::strcasecmp(contentType, TEXT_PLAIN)) {
return NS_ERROR_ILLEGAL_VALUE; // not supported type
}
nsCOMPtr <nsISaveAsCharset> aConv; // charset converter plus entity, NCR generation
res = nsComponentManager::CreateInstance(kSaveAsCharsetCID, NULL,
nsISaveAsCharset::GetIID(), getter_AddRefs(aConv));
if(NS_SUCCEEDED(res)) {
// attribute:
// html text - charset conv then fallback to entity or NCR
// plain text - charset conv then fallback to '?'
res = aConv->Init(charset,
bTEXT_HTML ?
nsISaveAsCharset::attr_EntityAfterCharsetConv + nsISaveAsCharset::attr_FallbackDecimalNCR :
nsISaveAsCharset::attr_plainTextDefault + nsISaveAsCharset::attr_FallbackQuestionMark,
nsIEntityConverter::html40);
if (NS_SUCCEEDED(res)) {
res = aConv->Convert(inString, outString);
}
}
return res;
}
// RICHIE - not sure about this one?? need to see what it did in the old
// world.
char *
nsMsgI18NGetAcceptLanguage(void)
{
return "en";
}

View File

@@ -0,0 +1,49 @@
/* -*- 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.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 _nsMsgI18N_H_
#define _nsMsgI18N_H_
#include "nscore.h"
#include "msgCore.h"
NS_MSG_BASE char *nsMsgI18NEncodeMimePartIIStr(const char *header, const char *charset, PRBool bUseMime);
NS_MSG_BASE PRBool nsMsgI18Nstateful_charset(const char *charset);
NS_MSG_BASE PRBool nsMsgI18N7bit_data_part(const char *charset, const char *string, const PRUint32 size);
NS_MSG_BASE char *nsMsgI18NGetAcceptLanguage(void);
NS_MSG_BASE const char *msgCompHeaderInternalCharset(void);
NS_MSG_BASE char * nsMsgI18NGetDefaultMailCharset(void);
NS_MSG_BASE nsresult ConvertFromUnicode(const nsString& aCharset,
const nsString& inString,
char** outCString);
NS_MSG_BASE nsresult ConvertToUnicode(const nsString& aCharset,
const char* inCString,
nsString& outString);
NS_MSG_BASE nsresult nsMsgI18NDecodeMimePartIIStr(const nsString& header, nsString& charset, nsString& decodedString);
NS_MSG_BASE const char *nsMsgI18NParseMetaCharset(nsFileSpec* fileSpec);
NS_MSG_BASE nsresult nsMsgI18NConvertToEntity(const nsString& inString, nsString* outString);
NS_MSG_BASE nsresult nsMsgI18NSaveAsCharset(const char* contentType, const char* charset, const PRUnichar* inString, char** outString);
#endif /* _nsMsgI18N_H_ */

View File

@@ -0,0 +1,356 @@
/* -*- 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.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 "msgCore.h" // for pre-compiled headers
#include "nsMsgIdentity.h"
#include "nsIPref.h"
#include "nsXPIDLString.h"
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
NS_IMPL_ISUPPORTS2(nsMsgIdentity,
nsIMsgIdentity,
nsIShutdownListener)
nsMsgIdentity::nsMsgIdentity():
m_signature(0),
m_vCard(0),
m_identityKey(0),
m_prefs(0)
{
NS_INIT_REFCNT();
}
nsMsgIdentity::~nsMsgIdentity()
{
PR_FREEIF(m_identityKey);
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID,
m_prefs,
nsnull);
}
nsresult
nsMsgIdentity::getPrefService()
{
if (m_prefs) return NS_OK;
return nsServiceManager::GetService(kPrefServiceCID,
nsCOMTypeInfo<nsIPref>::GetIID(),
(nsISupports**)&m_prefs,
this);
}
/* called if the prefs service goes offline */
NS_IMETHODIMP
nsMsgIdentity::OnShutdown(const nsCID& aClass, nsISupports *service)
{
if (aClass.Equals(kPrefServiceCID)) {
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID, m_prefs);
m_prefs = nsnull;
}
return NS_OK;
}
/*
* accessors for pulling values directly out of preferences
* instead of member variables, etc
*/
/* convert an identity key and preference name
to mail.identity.<identityKey>.<prefName>
*/
char *
nsMsgIdentity::getPrefName(const char *identityKey,
const char *prefName)
{
return PR_smprintf("mail.identity.%s.%s", identityKey, prefName);
}
// this will be slightly faster than the above, and allows
// the "default" identity preference root to be set in one place
char *
nsMsgIdentity::getDefaultPrefName(const char *fullPrefName)
{
return PR_smprintf("mail.identity.default.%s", fullPrefName);
}
/* The following are equivalent to the nsIPref's Get/CopyXXXPref
except they construct the preference name with the above function
*/
nsresult
nsMsgIdentity::getBoolPref(const char *prefname,
PRBool *val)
{
nsresult rv = getPrefService();
if (NS_FAILED(rv)) return rv;
char *fullPrefName = getPrefName(m_identityKey, prefname);
rv = m_prefs->GetBoolPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv))
rv = getDefaultBoolPref(prefname, val);
return rv;
}
nsresult
nsMsgIdentity::getDefaultBoolPref(const char *prefname,
PRBool *val) {
nsresult rv = getPrefService();
if (NS_FAILED(rv)) return rv;
char *fullPrefName = getDefaultPrefName(prefname);
rv = m_prefs->GetBoolPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv)) {
*val = PR_FALSE;
rv = NS_OK;
}
return rv;
}
nsresult
nsMsgIdentity::setBoolPref(const char *prefname,
PRBool val)
{
nsresult rv = getPrefService();
if (NS_FAILED(rv)) return rv;
char *prefName = getPrefName(m_identityKey, prefname);
rv = m_prefs->SetBoolPref(prefName, val);
PR_Free(prefName);
return rv;
}
nsresult
nsMsgIdentity::getCharPref(const char *prefname,
char **val)
{
nsresult rv = getPrefService();
if (NS_FAILED(rv)) return rv;
char *fullPrefName = getPrefName(m_identityKey, prefname);
rv = m_prefs->CopyCharPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv))
rv = getDefaultCharPref(prefname, val);
return rv;
}
nsresult
nsMsgIdentity::getDefaultCharPref(const char *prefname,
char **val)
{
nsresult rv = getPrefService();
if (NS_FAILED(rv)) return rv;
char *fullPrefName = getDefaultPrefName(prefname);
rv = m_prefs->CopyCharPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv)) {
*val = nsnull; // null is ok to return here
rv = NS_OK;
}
return rv;
}
nsresult
nsMsgIdentity::setCharPref(const char *prefname,
const char *val)
{
nsresult rv = getPrefService();
if (NS_FAILED(rv)) return rv;
rv = NS_OK;
char *prefName = getPrefName(m_identityKey, prefname);
if (val)
rv = m_prefs->SetCharPref(prefName, val);
else
m_prefs->ClearUserPref(prefName);
PR_Free(prefName);
return rv;
}
nsresult
nsMsgIdentity::getIntPref(const char *prefname,
PRInt32 *val)
{
nsresult rv = getPrefService();
if (NS_FAILED(rv)) return rv;
char *fullPrefName = getPrefName(m_identityKey, prefname);
rv = m_prefs->GetIntPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv))
rv = getDefaultIntPref(prefname, val);
return rv;
}
nsresult
nsMsgIdentity::getDefaultIntPref(const char *prefname,
PRInt32 *val) {
nsresult rv = getPrefService();
if (NS_FAILED(rv)) return rv;
char *fullPrefName = getDefaultPrefName(prefname);
rv = m_prefs->GetIntPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv)) {
*val = 0;
rv = NS_OK;
}
return rv;
}
nsresult
nsMsgIdentity::setIntPref(const char *prefname,
PRInt32 val)
{
nsresult rv = getPrefService();
if (NS_FAILED(rv)) return rv;
char *prefName = getPrefName(m_identityKey, prefname);
rv = m_prefs->SetIntPref(prefName, val);
PR_Free(prefName);
return rv;
}
nsresult
nsMsgIdentity::SetKey(const char* identityKey)
{
PR_FREEIF(m_identityKey);
m_identityKey = PL_strdup(identityKey);
return NS_OK;
}
nsresult
nsMsgIdentity::GetIdentityName(char **idName) {
if (!idName) return NS_ERROR_NULL_POINTER;
*idName = nsnull;
nsresult rv = getCharPref("identityName",idName);
if (NS_FAILED(rv)) return rv;
// there's probably a better way of doing this
// thats unicode friendly?
if (!(*idName)) {
nsXPIDLCString fullName;
rv = GetFullName(getter_Copies(fullName));
if (NS_FAILED(rv)) return rv;
nsXPIDLCString email;
rv = GetEmail(getter_Copies(email));
if (NS_FAILED(rv)) return rv;
*idName = PR_smprintf("%s <%s>", (const char*)fullName,
(const char*)email);
rv = NS_OK;
}
return rv;
}
nsresult nsMsgIdentity::SetIdentityName(const char *idName) {
return setCharPref("identityName", idName);
}
NS_IMETHODIMP
nsMsgIdentity::ToString(PRUnichar **aResult)
{
nsString idname("[nsIMsgIdentity: ");
idname += m_identityKey;
idname += "]";
*aResult = idname.ToNewUnicode();
return NS_OK;
}
/* Identity attribute accessors */
// XXX - these are a COM objects, use NS_ADDREF
//NS_IMPL_GETSET(nsMsgIdentity, Signature, nsIMsgSignature*, m_signature);
NS_IMETHODIMP
nsMsgIdentity::GetSignature(nsIFileSpec **sig) {
nsresult rv = getPrefService();
if (NS_FAILED(rv)) return rv;
char *prefName = getPrefName(m_identityKey, "sig_file");
rv = m_prefs->GetFilePref(prefName, sig);
if (NS_FAILED(rv))
*sig = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsMsgIdentity::SetSignature(nsIFileSpec *sig)
{
nsresult rv = getPrefService();
if (NS_FAILED(rv)) return rv;
rv = NS_OK;
char *prefName = getPrefName(m_identityKey, "sig_file");
if (sig)
rv = m_prefs->SetFilePref(NS_CONST_CAST(const char*,prefName), sig,
PR_FALSE);
/*
else
m_prefs->ClearFilePref(prefName);
*/
PR_Free(prefName);
return rv;
return NS_OK;
}
NS_IMPL_GETSET(nsMsgIdentity, VCard, nsIMsgVCard*, m_vCard);
NS_IMPL_GETTER_STR(nsMsgIdentity::GetKey, m_identityKey);
NS_IMPL_IDPREF_STR(FullName, "fullName");
NS_IMPL_IDPREF_STR(Email, "useremail");
NS_IMPL_IDPREF_STR(ReplyTo, "reply_to");
NS_IMPL_IDPREF_STR(Organization, "organization");
NS_IMPL_IDPREF_BOOL(ComposeHtml, "compose_html");
NS_IMPL_IDPREF_BOOL(AttachVCard, "attach_vcard");
NS_IMPL_IDPREF_BOOL(AttachSignature, "attach_signature");
NS_IMPL_IDPREF_BOOL(DoFcc, "fcc");
NS_IMPL_IDPREF_STR(FccFolder, "fcc_folder");
NS_IMPL_IDPREF_BOOL(BccSelf, "bcc_self");
NS_IMPL_IDPREF_BOOL(BccOthers, "bcc_other");
NS_IMPL_IDPREF_STR (BccList, "bcc_other_list");
NS_IMPL_IDPREF_STR (DraftFolder, "draft_folder");
NS_IMPL_IDPREF_STR (StationaryFolder, "stationary_folder");
NS_IMPL_IDPREF_STR (JunkMailFolder, "spam_folder");

View File

@@ -0,0 +1,110 @@
/* -*- 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.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 nsMsgIdentity_h___
#define nsMsgIdentity_h___
#include "nsIMsgIdentity.h"
#include "nsIPref.h"
#include "msgCore.h"
///////////////////////////////////////////////////////////////////////////////////
// an identity is an object designed to encapsulate all the information we need
// to know about a user identity. I expect this interface to grow and change a lot
// as we flesh out our thoughts on multiple identities and what properties go into
// these identities.
//////////////////////////////////////////////////////////////////////////////////
class NS_MSG_BASE nsMsgIdentity : public nsIMsgIdentity,
public nsIShutdownListener
{
public:
nsMsgIdentity();
virtual ~nsMsgIdentity();
NS_DECL_ISUPPORTS
NS_DECL_NSIMSGIDENTITY
// nsIShutdownListener
NS_IMETHOD OnShutdown(const nsCID& aClass, nsISupports *service);
private:
nsIMsgSignature* m_signature;
nsIMsgVCard* m_vCard;
char *m_identityKey;
nsIPref *m_prefs;
protected:
nsresult getPrefService();
char *getPrefName(const char *identityKey, const char *pref);
char *getDefaultPrefName(const char *pref);
nsresult getCharPref(const char *pref, char **);
nsresult getDefaultCharPref(const char *pref, char **);
nsresult setCharPref(const char *pref, const char *);
nsresult getBoolPref(const char *pref, PRBool *);
nsresult getDefaultBoolPref(const char *pref, PRBool *);
nsresult setBoolPref(const char *pref, PRBool);
nsresult getIntPref(const char *pref, PRInt32 *);
nsresult getDefaultIntPref(const char *pref, PRInt32 *);
nsresult setIntPref(const char *pref, PRInt32);
};
#define NS_IMPL_IDPREF_STR(_postfix, _prefname) \
NS_IMETHODIMP \
nsMsgIdentity::Get##_postfix(char **retval) \
{ \
return getCharPref(_prefname, retval); \
} \
NS_IMETHODIMP \
nsMsgIdentity::Set##_postfix(const char *value) \
{ \
return setCharPref(_prefname, value);\
}
#define NS_IMPL_IDPREF_BOOL(_postfix, _prefname)\
NS_IMETHODIMP \
nsMsgIdentity::Get##_postfix(PRBool *retval) \
{ \
return getBoolPref(_prefname, retval); \
} \
NS_IMETHODIMP \
nsMsgIdentity::Set##_postfix(PRBool value) \
{ \
return setBoolPref(_prefname, value); \
}
#define NS_IMPL_IDPREF_INT(_postfix, _prefname) \
NS_IMETHODIMP \
nsMsgIdentity::Get##_postfix(PRInt32 *retval) \
{ \
return getIntPref(_prefname, retval); \
} \
NS_IMETHODIMP \
nsMsgIdentity::Set##_postfix(PRInt32 value) \
{ \
return setIntPref(_prefname, value); \
}
#endif /* nsMsgIdentity_h___ */

View File

@@ -0,0 +1,603 @@
/* -*- 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 "nsMsgIncomingServer.h"
#include "nscore.h"
#include "nsCom.h"
#include "plstr.h"
#include "prmem.h"
#include "prprf.h"
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "nsCOMPtr.h"
#include "nsIMsgFolder.h"
#include "nsIMsgFolderCache.h"
#include "nsIMsgFolderCacheElement.h"
#include "nsINetSupportDialogService.h"
#include "nsIPrompt.h"
#include "nsXPIDLString.h"
#include "nsIRDFService.h"
#include "nsIMsgProtocolInfo.h"
#include "nsRDFCID.h"
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
MOZ_DECL_CTOR_COUNTER(nsMsgIncomingServer);
nsMsgIncomingServer::nsMsgIncomingServer():
m_prefs(0),
m_serverKey(0),
m_rootFolder(0)
{
MOZ_COUNT_CTOR(nsMsgIncomingServer);
NS_INIT_REFCNT();
m_serverBusy = PR_FALSE;
m_password = "";
}
nsMsgIncomingServer::~nsMsgIncomingServer()
{
MOZ_COUNT_DTOR(nsMsgIncomingServer);
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID,
m_prefs,
nsnull);
PR_FREEIF(m_serverKey)
}
NS_IMPL_ISUPPORTS1(nsMsgIncomingServer, nsIMsgIncomingServer)
NS_IMPL_GETSET(nsMsgIncomingServer, ServerBusy, PRBool, m_serverBusy)
NS_IMPL_GETTER_STR(nsMsgIncomingServer::GetKey, m_serverKey)
NS_IMETHODIMP
nsMsgIncomingServer::SetKey(const char * serverKey)
{
nsresult rv = NS_OK;
// in order to actually make use of the key, we need the prefs
if (!m_prefs)
rv = nsServiceManager::GetService(kPrefServiceCID,
nsCOMTypeInfo<nsIPref>::GetIID(),
(nsISupports**)&m_prefs);
PR_FREEIF(m_serverKey);
m_serverKey = PL_strdup(serverKey);
return rv;
}
NS_IMETHODIMP
nsMsgIncomingServer::SetRootFolder(nsIFolder * aRootFolder)
{
m_rootFolder = aRootFolder;
return NS_OK;
}
NS_IMETHODIMP
nsMsgIncomingServer::GetRootFolder(nsIFolder * *aRootFolder)
{
if (!aRootFolder)
return NS_ERROR_NULL_POINTER;
if (m_rootFolder) {
*aRootFolder = m_rootFolder;
NS_ADDREF(*aRootFolder);
} else {
nsresult rv = CreateRootFolder();
if (NS_FAILED(rv)) return rv;
*aRootFolder = m_rootFolder;
NS_IF_ADDREF(*aRootFolder);
}
return NS_OK;
}
NS_IMETHODIMP
nsMsgIncomingServer::PerformBiff()
{
//This had to be implemented in the derived class, but in case someone doesn't implement it
//just return not implemented.
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgIncomingServer::WriteToFolderCache(nsIMsgFolderCache *folderCache)
{
nsresult rv = NS_OK;
if (m_rootFolder)
{
nsCOMPtr <nsIMsgFolder> msgFolder = do_QueryInterface(m_rootFolder, &rv);
if (NS_SUCCEEDED(rv) && msgFolder)
rv = msgFolder->WriteToFolderCache(folderCache);
}
return rv;
}
NS_IMETHODIMP
nsMsgIncomingServer::CloseCachedConnections()
{
// derived class should override if they cache connections.
return NS_OK;
}
NS_IMETHODIMP
nsMsgIncomingServer::GetServerURI(char **)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsMsgIncomingServer::CreateRootFolder()
{
nsresult rv;
// get the URI from the incoming server
nsXPIDLCString serverUri;
rv = GetServerURI(getter_Copies(serverUri));
if (NS_FAILED(rv)) return rv;
NS_WITH_SERVICE(nsIRDFService, rdf,
kRDFServiceCID, &rv);
// get the corresponding RDF resource
// RDF will create the server resource if it doesn't already exist
nsCOMPtr<nsIRDFResource> serverResource;
rv = rdf->GetResource(serverUri, getter_AddRefs(serverResource));
if (NS_FAILED(rv)) return rv;
// make incoming server know about its root server folder so we
// can find sub-folders given an incoming server.
m_rootFolder = do_QueryInterface(serverResource, &rv);
return rv;
}
char *
nsMsgIncomingServer::getPrefName(const char *serverKey,
const char *fullPrefName)
{
return PR_smprintf("mail.server.%s.%s", serverKey, fullPrefName);
}
// this will be slightly faster than the above, and allows
// the "default" server preference root to be set in one place
char *
nsMsgIncomingServer::getDefaultPrefName(const char *fullPrefName)
{
return PR_smprintf("mail.server.default.%s", fullPrefName);
}
nsresult
nsMsgIncomingServer::GetBoolValue(const char *prefname,
PRBool *val)
{
char *fullPrefName = getPrefName(m_serverKey, prefname);
nsresult rv = m_prefs->GetBoolPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv))
rv = getDefaultBoolPref(prefname, val);
return rv;
}
nsresult
nsMsgIncomingServer::getDefaultBoolPref(const char *prefname,
PRBool *val) {
char *fullPrefName = getDefaultPrefName(prefname);
nsresult rv = m_prefs->GetBoolPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv)) {
*val = PR_FALSE;
rv = NS_OK;
}
return rv;
}
nsresult
nsMsgIncomingServer::SetBoolValue(const char *prefname,
PRBool val)
{
nsresult rv;
char *fullPrefName = getPrefName(m_serverKey, prefname);
PRBool defaultValue;
rv = getDefaultBoolPref(prefname, &defaultValue);
if (NS_SUCCEEDED(rv) &&
val == defaultValue)
m_prefs->ClearUserPref(fullPrefName);
else
rv = m_prefs->SetBoolPref(fullPrefName, val);
PR_Free(fullPrefName);
return rv;
}
nsresult
nsMsgIncomingServer::GetIntValue(const char *prefname,
PRInt32 *val)
{
char *fullPrefName = getPrefName(m_serverKey, prefname);
nsresult rv = m_prefs->GetIntPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv))
rv = getDefaultIntPref(prefname, val);
return rv;
}
nsresult
nsMsgIncomingServer::GetFileValue(const char* prefname,
nsIFileSpec **spec)
{
char *fullPrefName = getPrefName(m_serverKey, prefname);
nsresult rv = m_prefs->GetFilePref(fullPrefName, spec);
PR_Free(fullPrefName);
return rv;
}
nsresult
nsMsgIncomingServer::SetFileValue(const char* prefname,
nsIFileSpec *spec)
{
char *fullPrefName = getPrefName(m_serverKey, prefname);
nsresult rv = m_prefs->SetFilePref(fullPrefName, spec, PR_FALSE);
PR_Free(fullPrefName);
return rv;
}
nsresult
nsMsgIncomingServer::getDefaultIntPref(const char *prefname,
PRInt32 *val) {
char *fullPrefName = getDefaultPrefName(prefname);
nsresult rv = m_prefs->GetIntPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv)) {
*val = 0;
rv = NS_OK;
}
return rv;
}
nsresult
nsMsgIncomingServer::SetIntValue(const char *prefname,
PRInt32 val)
{
nsresult rv;
char *fullPrefName = getPrefName(m_serverKey, prefname);
PRInt32 defaultVal;
rv = getDefaultIntPref(prefname, &defaultVal);
if (NS_SUCCEEDED(rv) && defaultVal == val)
m_prefs->ClearUserPref(fullPrefName);
else
rv = m_prefs->SetIntPref(fullPrefName, val);
PR_Free(fullPrefName);
return rv;
}
nsresult
nsMsgIncomingServer::GetCharValue(const char *prefname,
char **val)
{
char *fullPrefName = getPrefName(m_serverKey, prefname);
nsresult rv = m_prefs->CopyCharPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv))
rv = getDefaultCharPref(prefname, val);
return rv;
}
nsresult
nsMsgIncomingServer::getDefaultCharPref(const char *prefname,
char **val) {
char *fullPrefName = getDefaultPrefName(prefname);
nsresult rv = m_prefs->CopyCharPref(fullPrefName, val);
PR_Free(fullPrefName);
if (NS_FAILED(rv)) {
*val = nsnull; // null is ok to return here
rv = NS_OK;
}
return rv;
}
nsresult
nsMsgIncomingServer::SetCharValue(const char *prefname,
const char * val)
{
nsresult rv;
char *fullPrefName = getPrefName(m_serverKey, prefname);
if (!val) {
m_prefs->ClearUserPref(fullPrefName);
return NS_OK;
}
char *defaultVal=nsnull;
rv = getDefaultCharPref(prefname, &defaultVal);
if (NS_SUCCEEDED(rv) &&
PL_strcmp(defaultVal, val) == 0)
m_prefs->ClearUserPref(fullPrefName);
else
rv = m_prefs->SetCharPref(fullPrefName, val);
PR_FREEIF(defaultVal);
PR_Free(fullPrefName);
return rv;
}
// pretty name is the display name to show to the user
NS_IMETHODIMP
nsMsgIncomingServer::GetPrettyName(PRUnichar **retval) {
char *val=nsnull;
nsresult rv = GetCharValue("name", &val);
if (NS_FAILED(rv)) return rv;
nsString prettyName;
// if there's no name, then just return the hostname
if (val) {
prettyName = val;
} else {
nsXPIDLCString username;
rv = GetUsername(getter_Copies(username));
if (NS_FAILED(rv)) return rv;
if ((const char*)username &&
PL_strcmp((const char*)username, "")!=0) {
prettyName = username;
prettyName += " on ";
}
nsXPIDLCString hostname;
rv = GetHostName(getter_Copies(hostname));
if (NS_FAILED(rv)) return rv;
prettyName += hostname;
}
*retval = prettyName.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
nsMsgIncomingServer::SetPrettyName(const PRUnichar *value) {
// this is lossy. Not sure what to do.
nsCString str(value);
return SetCharValue("name", str.GetBuffer());
}
NS_IMETHODIMP
nsMsgIncomingServer::ToString(PRUnichar** aResult) {
nsString servername("[nsIMsgIncomingServer: ");
servername += m_serverKey;
servername += "]";
*aResult = servername.ToNewUnicode();
NS_ASSERTION(*aResult, "no server name!");
return NS_OK;
}
NS_IMETHODIMP nsMsgIncomingServer::SetPassword(const char * aPassword)
{
// if remember password is turned on, write the password to preferences
// otherwise, just set the password so we remember it for the rest of the current
// session.
PRBool rememberPassword = PR_FALSE;
GetRememberPassword(&rememberPassword);
if (rememberPassword)
{
SetPrefPassword((char *) aPassword);
}
m_password = aPassword;
return NS_OK;
}
NS_IMETHODIMP nsMsgIncomingServer::GetPassword(char ** aPassword)
{
nsresult rv = NS_OK;
PRBool rememberPassword = PR_FALSE;
// okay, here's the scoop for this messs...
// (1) if we have a password already, go ahead and use it!
// (2) if remember password is turned on, try reading in from the prefs and if we have one, go ahead
// and use it
// (3) otherwise prompt the user for a password and then remember that password in the server
if (m_password.IsEmpty())
{
// case (2)
GetRememberPassword(&rememberPassword);
if (rememberPassword)
{
nsXPIDLCString password;
GetPrefPassword(getter_Copies(password));
m_password = password;
}
}
*aPassword = m_password.ToNewCString();
return rv;
}
NS_IMETHODIMP
nsMsgIncomingServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, char **aPassword)
{
nsXPIDLCString prefvalue;
GetPassword(getter_Copies(prefvalue));
nsresult rv = NS_OK;
if (m_password.IsEmpty()) {
// prompt the user for the password
NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv);
if (NS_SUCCEEDED(rv))
{
PRUnichar * uniPassword;
PRBool okayValue = PR_TRUE;
dialog->PromptPassword(aPromptMessage, &uniPassword, &okayValue);
if (!okayValue) // if the user pressed cancel, just return NULL;
{
*aPassword = nsnull;
return rv;
}
// we got a password back...so remember it
nsCString aCStr(uniPassword);
SetPassword((const char *) aCStr);
} // if we got a prompt dialog
} // if the password is empty
*aPassword = m_password.ToNewCString();
return rv;
}
NS_IMETHODIMP
nsMsgIncomingServer::SetDefaultLocalPath(nsIFileSpec *aDefaultLocalPath)
{
nsresult rv;
nsXPIDLCString type;
GetType(getter_Copies(type));
nsCAutoString progid(NS_MSGPROTOCOLINFO_PROGID_PREFIX);
progid += type;
NS_WITH_SERVICE(nsIMsgProtocolInfo, protocolInfo, progid, &rv);
if (NS_FAILED(rv)) return rv;
rv = protocolInfo->SetDefaultLocalPath(aDefaultLocalPath);
return rv;
}
NS_IMETHODIMP
nsMsgIncomingServer::GetLocalPath(nsIFileSpec **aLocalPath)
{
nsresult rv;
// if the local path has already been set, use it
rv = GetFileValue("directory", aLocalPath);
if (NS_SUCCEEDED(rv) && *aLocalPath) return rv;
// otherwise, create the path using. note we are using the
// server key instead of the hostname
//
// TODO: handle the case where they migrated a server of hostname "server4"
// and we create a server (with the account wizard) with key "server4"
// we'd get a collision.
// need to modify the code that creates keys to check for disk collision
nsXPIDLCString type;
GetType(getter_Copies(type));
nsCAutoString progid(NS_MSGPROTOCOLINFO_PROGID_PREFIX);
progid += type;
NS_WITH_SERVICE(nsIMsgProtocolInfo, protocolInfo, progid, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIFileSpec> path;
rv = protocolInfo->GetDefaultLocalPath(getter_AddRefs(path));
if (NS_FAILED(rv)) return rv;
path->CreateDir();
nsXPIDLCString key;
rv = GetKey(getter_Copies(key));
if (NS_FAILED(rv)) return rv;
rv = path->AppendRelativeUnixPath(key);
if (NS_FAILED(rv)) return rv;
rv = SetLocalPath(path);
if (NS_FAILED(rv)) return rv;
*aLocalPath = path;
NS_ADDREF(*aLocalPath);
return NS_OK;
}
NS_IMETHODIMP
nsMsgIncomingServer::SetLocalPath(nsIFileSpec *spec)
{
if (spec) {
spec->CreateDir();
return SetFileValue("directory", spec);
}
else {
return NS_ERROR_NULL_POINTER;
}
}
NS_IMETHODIMP
nsMsgIncomingServer::SetRememberPassword(PRBool value)
{
if (value)
SetPrefPassword(m_password);
else
SetPrefPassword(nsnull);
return SetBoolValue("remember_password", value);
}
NS_IMETHODIMP
nsMsgIncomingServer::GetRememberPassword(PRBool* value)
{
return GetBoolValue("remember_password", value);
}
// use the convenience macros to implement the accessors
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, HostName, "hostname");
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, Username, "userName");
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, PrefPassword, "password");
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer, DoBiff, "check_new_mail");
NS_IMPL_SERVERPREF_INT(nsMsgIncomingServer, BiffMinutes, "check_time");
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, Type, "type");
/* what was this called in 4.x? */
// pref("mail.pop3_gets_new_mail", true);
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer, DownloadOnBiff, "download_on_biff");

View File

@@ -0,0 +1,70 @@
/* -*- 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.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 nsMsgIncomingServer_h__
#define nsMsgIncomingServer_h__
#include "nsIMsgIncomingServer.h"
#include "nsIPref.h"
#include "msgCore.h"
#include "nsIFolder.h"
#include "nsCOMPtr.h"
class nsIMsgFolderCache;
/*
* base class for nsIMsgIncomingServer - derive your class from here
* if you want to get some free implementation
*
* this particular implementation is not meant to be used directly.
*/
class NS_MSG_BASE nsMsgIncomingServer : public nsIMsgIncomingServer {
public:
nsMsgIncomingServer();
virtual ~nsMsgIncomingServer();
NS_DECL_ISUPPORTS
NS_DECL_NSIMSGINCOMINGSERVER
private:
nsIPref *m_prefs;
char *m_serverKey;
nsCString m_password;
PRBool m_serverBusy;
protected:
char *getPrefName(const char *serverKey, const char *pref);
char *getDefaultPrefName(const char *pref);
// these are private pref getters and setters for the password
// field. Callers should be using Get/Set Password
NS_IMETHOD GetPrefPassword(char * *aPassword);
NS_IMETHOD SetPrefPassword(const char * aPassword);
nsCOMPtr <nsIFolder> m_rootFolder;
nsresult getDefaultCharPref(const char *pref, char **);
nsresult getDefaultBoolPref(const char *pref, PRBool *);
nsresult getDefaultIntPref(const char *pref, PRInt32 *);
nsresult CreateRootFolder();
};
#endif // nsMsgIncomingServer_h__

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
/* -*- 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.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 _nsMsgKeySet_H_
#define _nsMsgKeySet_H_
#include "msgCore.h"
// nsMsgKeySet represents a set of articles. Typically, it is the set of
// read articles from a .newsrc file, but it can be used for other purposes
// too.
#if 0
// If a MSG_NewsHost* is supplied to the creation routine, then that
// MSG_NewsHost will be notified whenever a change is made to set.
class MSG_NewsHost;
#endif
class NS_MSG_BASE nsMsgKeySet {
public:
// Creates an empty set.
static nsMsgKeySet* Create(/* MSG_NewsHost* host = NULL*/);
// Creates a set from the list of numbers, as might be found in a
// newsrc file.
static nsMsgKeySet* Create(const char* str/* , MSG_NewsHost* host = NULL*/);
~nsMsgKeySet();
// FirstNonMember() returns the lowest non-member of the set that is
// greater than 0.
PRInt32 FirstNonMember();
// Output() converts to a string representation suitable for writing to a
// .newsrc file. (The result must be freed by the caller using delete[].)
char* Output();
// IsMember() returns whether the given article is a member of this set.
PRBool IsMember(PRInt32 art);
// Add() adds the given article to the set. (Returns 1 if a change was
// made, 0 if it was already there, and negative on error.)
int Add(PRInt32 art);
// Remove() removes the given article from the set.
int Remove(PRInt32 art);
// AddRange() adds the (inclusive) given range of articles to the set.
int AddRange(PRInt32 first, PRInt32 last);
// CountMissingInRange() takes an inclusive range of articles and returns
// the number of articles in that range which are not in the set.
PRInt32 CountMissingInRange(PRInt32 start, PRInt32 end);
// FirstMissingRange() takes an inclusive range and finds the first range
// of articles that are not in the set. If none, return zeros.
int FirstMissingRange(PRInt32 min, PRInt32 max, PRInt32* first, PRInt32* last);
// LastMissingRange() takes an inclusive range and finds the last range
// of articles that are not in the set. If none, return zeros.
int LastMissingRange(PRInt32 min, PRInt32 max, PRInt32* first, PRInt32* last);
PRInt32 GetLastMember();
PRInt32 GetFirstMember();
void SetLastMember(PRInt32 highWaterMark);
// For debugging only...
PRInt32 getLength() {return m_length;}
#ifdef DEBUG
static void RunTests();
#endif
protected:
nsMsgKeySet(/* MSG_NewsHost* host */);
nsMsgKeySet(const char* /* , MSG_NewsHost* host */);
PRBool Grow();
PRBool Optimize();
#ifdef DEBUG
static void test_decoder(const char*);
static void test_adder();
static void test_ranges();
static void test_member(PRBool with_cache);
#endif
PRInt32 *m_data; /* the numbers composing the `chunks' */
PRInt32 m_data_size; /* size of that malloc'ed block */
PRInt32 m_length; /* active area */
PRInt32 m_cached_value; /* a potential set member, or -1 if unset*/
PRInt32 m_cached_value_index; /* the index into `data' at which a search
to determine whether `cached_value' was
a member of the set ended. */
#ifdef NEWSRC_DOES_HOST_STUFF
MSG_NewsHost* m_host;
#endif
};
#endif /* _nsMsgKeySet_H_ */

View File

@@ -0,0 +1,384 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "msgCore.h"
#include "prlog.h"
#include "nsMsgLineBuffer.h"
#include "nsIInputStream.h" // used by nsMsgLineStreamBuffer
MOZ_DECL_CTOR_COUNTER(nsByteArray);
nsByteArray::nsByteArray()
{
MOZ_COUNT_CTOR(nsByteArray);
m_buffer = NULL;
m_bufferSize = 0;
m_bufferPos = 0;
}
nsByteArray::~nsByteArray()
{
MOZ_COUNT_DTOR(nsByteArray);
PR_FREEIF(m_buffer);
}
nsresult nsByteArray::GrowBuffer(PRUint32 desired_size, PRUint32 quantum)
{
if (m_bufferSize < desired_size)
{
char *new_buf;
PRUint32 increment = desired_size - m_bufferSize;
if (increment < quantum) /* always grow by a minimum of N bytes */
increment = quantum;
new_buf = (m_buffer
? (char *) PR_REALLOC (m_buffer, (m_bufferSize + increment))
: (char *) PR_MALLOC (m_bufferSize + increment));
if (! new_buf)
return NS_ERROR_OUT_OF_MEMORY;
m_buffer = new_buf;
m_bufferSize += increment;
}
return 0;
}
nsresult nsByteArray::AppendString(const char *string)
{
PRUint32 strLength = (string) ? PL_strlen(string) : 0;
return AppendBuffer(string, strLength);
}
nsresult nsByteArray::AppendBuffer(const char *buffer, PRUint32 length)
{
nsresult ret = NS_OK;
if (m_bufferPos + length > m_bufferSize)
ret = GrowBuffer(m_bufferPos + length, 1024);
if (ret == NS_OK)
{
memcpy(m_buffer + m_bufferPos, buffer, length);
m_bufferPos += length;
}
return ret;
}
MOZ_DECL_CTOR_COUNTER(nsMsgLineBuffer);
nsMsgLineBuffer::nsMsgLineBuffer(nsMsgLineBufferHandler *handler, PRBool convertNewlinesP)
{
MOZ_COUNT_CTOR(nsMsgLineBuffer);
m_handler = handler;
m_convertNewlinesP = convertNewlinesP;
m_lookingForCRLF = PR_TRUE;
}
nsMsgLineBuffer::~nsMsgLineBuffer()
{
MOZ_COUNT_DTOR(nsMsgLineBuffer);
}
void
nsMsgLineBuffer::SetLookingForCRLF(PRBool b)
{
m_lookingForCRLF = b;
}
PRInt32 nsMsgLineBuffer::BufferInput(const char *net_buffer, PRInt32 net_buffer_size)
{
int status = 0;
if (m_bufferPos > 0 && m_buffer && m_buffer[m_bufferPos - 1] == CR &&
net_buffer_size > 0 && net_buffer[0] != LF) {
/* The last buffer ended with a CR. The new buffer does not start
with a LF. This old buffer should be shipped out and discarded. */
PR_ASSERT(m_bufferSize > m_bufferPos);
if (m_bufferSize <= m_bufferPos) return -1;
status = ConvertAndSendBuffer();
if (status < 0)
return status;
m_bufferPos = 0;
}
while (net_buffer_size > 0)
{
const char *net_buffer_end = net_buffer + net_buffer_size;
const char *newline = 0;
const char *s;
for (s = net_buffer; s < net_buffer_end; s++)
{
if (m_lookingForCRLF) {
/* Move forward in the buffer until the first newline.
Stop when we see CRLF, CR, or LF, or the end of the buffer.
*But*, if we see a lone CR at the *very end* of the buffer,
treat this as if we had reached the end of the buffer without
seeing a line terminator. This is to catch the case of the
buffers splitting a CRLF pair, as in "FOO\r\nBAR\r" "\nBAZ\r\n".
*/
if (*s == CR || *s == LF) {
newline = s;
if (newline[0] == CR) {
if (s == net_buffer_end - 1) {
/* CR at end - wait for the next character. */
newline = 0;
break;
}
else if (newline[1] == LF) {
/* CRLF seen; swallow both. */
newline++;
}
}
newline++;
break;
}
}
else {
/* if not looking for a CRLF, stop at CR or LF. (for example, when parsing the newsrc file). this fixes #9896, where we'd lose the last line of anything we'd parse that used CR as the line break. */
if (*s == CR || *s == LF) {
newline = s;
newline++;
break;
}
}
}
/* Ensure room in the net_buffer and append some or all of the current
chunk of data to it. */
{
const char *end = (newline ? newline : net_buffer_end);
PRUint32 desired_size = (end - net_buffer) + m_bufferPos + 1;
if (desired_size >= m_bufferSize)
{
status = GrowBuffer (desired_size, 1024);
if (status < 0)
return status;
}
memcpy (m_buffer + m_bufferPos, net_buffer, (end - net_buffer));
m_bufferPos += (end - net_buffer);
}
/* Now m_buffer contains either a complete line, or as complete
a line as we have read so far.
If we have a line, process it, and then remove it from `m_buffer'.
Then go around the loop again, until we drain the incoming data.
*/
if (!newline)
return 0;
status = ConvertAndSendBuffer();
if (status < 0) return status;
net_buffer_size -= (newline - net_buffer);
net_buffer = newline;
m_bufferPos = 0;
}
#ifdef DEBUG_bienvenu
printf("returning from buffer input m_bufferPos = %ld\n", m_bufferPos);
#endif
return 0;
}
PRInt32 nsMsgLineBuffer::HandleLine(char *line, PRUint32 line_length)
{
NS_ASSERTION(PR_FALSE, "must override this method if you don't provide a handler");
return 0;
}
PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
{
/* Convert the line terminator to the native form.
*/
char *buf = m_buffer;
PRInt32 length = m_bufferPos;
char* newline;
PR_ASSERT(buf && length > 0);
if (!buf || length <= 0)
return -1;
newline = buf + length;
PR_ASSERT(newline[-1] == CR || newline[-1] == LF);
if (newline[-1] != CR && newline[-1] != LF)
return -1;
if (!m_convertNewlinesP)
{
}
#if (MSG_LINEBREAK_LEN == 1)
else if ((newline - buf) >= 2 &&
newline[-2] == CR &&
newline[-1] == LF)
{
/* CRLF -> CR or LF */
buf [length - 2] = MSG_LINEBREAK[0];
length--;
}
else if (newline > buf + 1 &&
newline[-1] != MSG_LINEBREAK[0])
{
/* CR -> LF or LF -> CR */
buf [length - 1] = MSG_LINEBREAK[0];
}
#else
else if (((newline - buf) >= 2 && newline[-2] != CR) ||
((newline - buf) >= 1 && newline[-1] != LF))
{
/* LF -> CRLF or CR -> CRLF */
length++;
buf[length - 2] = MSG_LINEBREAK[0];
buf[length - 1] = MSG_LINEBREAK[1];
}
#endif
return (m_handler) ? m_handler->HandleLine(buf, length) : HandleLine(buf, length);
}
// If there's still some data (non CRLF terminated) flush it out
PRInt32 nsMsgLineBuffer::FlushLastLine()
{
char *buf = m_buffer + m_bufferPos;
PRInt32 length = m_bufferPos - 1;
if (length > 0)
return (m_handler) ? m_handler->HandleLine(buf, length) : HandleLine(buf, length);
else
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// This is a utility class used to efficiently extract lines from an input stream by buffering
// read but unprocessed stream data in a buffer.
///////////////////////////////////////////////////////////////////////////////////////////////////
nsMsgLineStreamBuffer::nsMsgLineStreamBuffer(PRUint32 aBufferSize, const char * aEndOfLineToken,
PRBool aAllocateNewLines, PRBool aEatCRLFs)
: m_eatCRLFs(aEatCRLFs), m_allocateNewLines(aAllocateNewLines),
m_endOfLineToken(aEndOfLineToken)
{
NS_PRECONDITION(aBufferSize > 0, "invalid buffer size!!!");
m_dataBuffer = nsnull;
m_startPos = nsnull;
// used to buffer incoming data by ReadNextLineFromInput
if (aBufferSize > 0)
{
m_dataBuffer = (char *) PR_CALLOC(sizeof(char) * aBufferSize);
m_startPos = m_dataBuffer;
}
m_dataBufferSize = aBufferSize;
}
nsMsgLineStreamBuffer::~nsMsgLineStreamBuffer()
{
PR_FREEIF(m_dataBuffer); // release our buffer...
}
// the design for this method has an inherit bug: if the length of the line is greater than the size of m_dataBufferSize,
// then we'll never find the next line because we can't hold the whole line in memory.
// aInputStream - the input stream we want to read a line from
// aPauseForMoreData is returned as PR_TRUE if the stream does not yet contain a line and we must wait for more
// data to come into the stream.
// Note to people wishing to modify this function: Be *VERY CAREFUL* this is a critical function used by all of
// our mail protocols including imap, nntp, and pop. If you screw it up, you could break a lot of stuff.....
char * nsMsgLineStreamBuffer::ReadNextLine(nsIInputStream * aInputStream, PRUint32 &aNumBytesInLine, PRBool &aPauseForMoreData)
{
// try to extract a line from m_inputBuffer. If we don't have an entire line,
// then read more bytes out from the stream. If the stream is empty then wait
// on the monitor for more data to come in.
NS_PRECONDITION(m_startPos && m_dataBufferSize > 0, "invalid input arguments for read next line from input");
// initialize out values
aPauseForMoreData = PR_FALSE;
aNumBytesInLine = 0;
char * endOfLine = nsnull;
PRUint32 numBytesInBuffer = PL_strlen(m_startPos);
if (numBytesInBuffer > 0) // any data in our internal buffer?
endOfLine = PL_strstr(m_startPos, m_endOfLineToken); // see if we already have a line ending...
// it's possible that we got here before the first time we receive data from the server
// so aInputStream will be nsnull...
if (!endOfLine && aInputStream) // get some more data from the server
{
PRUint32 numBytesInStream = 0;
PRUint32 numBytesCopied = 0;
aInputStream->Available(&numBytesInStream);
// if the number of bytes we want to read from the stream, is greater than the number
// of bytes left in our buffer, then we need to shift the start pos and its contents
// down to the beginning of m_dataBuffer...
PRUint32 numFreeBytesInBuffer = (m_dataBuffer + m_dataBufferSize) - (m_startPos + numBytesInBuffer);
if (numBytesInStream >= numFreeBytesInBuffer)
{
nsCRT::memcpy(m_dataBuffer, m_startPos, numBytesInBuffer);
m_dataBuffer[numBytesInBuffer] = '\0'; // make sure the end of the buffer is terminated
m_startPos = m_dataBuffer; // update the new start position
// update the number of free bytes in the buffer
numFreeBytesInBuffer = m_dataBufferSize - numBytesInBuffer;
}
PRUint32 numBytesToCopy = PR_MIN(numFreeBytesInBuffer - 1 /* leave one for a null terminator */, numBytesInStream);
// read the data into the end of our data buffer
if (numBytesToCopy > 0)
{
aInputStream->Read(m_startPos + numBytesInBuffer, numBytesToCopy, &numBytesCopied);
m_startPos[numBytesInBuffer + numBytesCopied] = '\0';
}
// okay, now that we've tried to read in more data from the stream, look for another end of line
// character
endOfLine = PL_strstr(m_startPos, m_endOfLineToken);
}
// okay, now check again for endOfLine.
if (endOfLine)
{
if (!m_eatCRLFs)
endOfLine += PL_strlen(m_endOfLineToken); // count for CRLF
// PR_CALLOC zeros out the allocated line
char* newLine = (char*) PR_CALLOC(endOfLine-m_startPos+1);
if (!newLine)
return nsnull;
nsCRT::memcpy(newLine, m_startPos, endOfLine-m_startPos); // copy the string into the new line buffer
aNumBytesInLine = endOfLine - m_startPos;
if (m_eatCRLFs)
endOfLine += PL_strlen(m_endOfLineToken); // advance past CRLF if we haven't already done so...
// now we need to update the data buffer to go past the line we just read out.
if (PL_strlen(endOfLine) <= 0) // if no more data in the buffer, then just zero out the buffer...
m_startPos[0] = '\0';
else // advance
m_startPos = endOfLine; // move us up to the end of the line
return newLine;
}
aPauseForMoreData = PR_TRUE;
return nsnull; // if we somehow got here. we don't have another line in the buffer yet...need to wait for more data...
}

View File

@@ -0,0 +1,113 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsMsgLineBuffer_H
#define _nsMsgLineBuffer_H
#include "msgCore.h" // precompiled header...
// I can't believe I have to have this stupid class, but I can't find
// anything suitable (nsStrImpl might be, when its done). nsIByteBuffer
// would do, if I had a stream for input, which I don't.
class NS_MSG_BASE nsByteArray
{
public:
nsByteArray();
virtual ~nsByteArray();
PRUint32 GetSize() {return m_bufferSize;}
PRUint32 GetBufferPos() {return m_bufferPos;}
nsresult GrowBuffer(PRUint32 desired_size, PRUint32 quantum = 1024);
nsresult AppendString(const char *string);
nsresult AppendBuffer(const char *buffer, PRUint32 length);
void ResetWritePos() {m_bufferPos = 0;}
char *GetBuffer() {return m_buffer;}
protected:
char *m_buffer;
PRUint32 m_bufferSize;
PRUint32 m_bufferPos; // write Pos in m_buffer - where the next byte should go.
};
class NS_MSG_BASE nsMsgLineBufferHandler : public nsByteArray
{
public:
virtual PRInt32 HandleLine(char *line, PRUint32 line_length) = 0;
};
class NS_MSG_BASE nsMsgLineBuffer : public nsByteArray
{
public:
nsMsgLineBuffer(nsMsgLineBufferHandler *handler, PRBool convertNewlinesP);
virtual ~nsMsgLineBuffer();
PRInt32 BufferInput(const char *net_buffer, PRInt32 net_buffer_size);
// Not sure why anyone cares, by NNTPHost seems to want to know the buf pos.
PRUint32 GetBufferPos() {return m_bufferPos;}
virtual PRInt32 HandleLine(char *line, PRUint32 line_length);
// flush last line, though it won't be CRLF terminated.
virtual PRInt32 FlushLastLine();
protected:
nsMsgLineBuffer(PRBool convertNewlinesP);
PRInt32 ConvertAndSendBuffer();
void SetLookingForCRLF(PRBool b);
nsMsgLineBufferHandler *m_handler;
PRBool m_convertNewlinesP;
PRBool m_lookingForCRLF;
};
// I'm adding this utility class here for lack of a better place. This utility class is similar to nsMsgLineBuffer
// except it works from an input stream. It is geared towards efficiently parsing new lines out of a stream by storing
// read but unprocessed bytes in a buffer. I envision the primary use of this to be our mail protocols such as imap, news and
// pop which need to process line by line data being returned in the form of a proxied stream from the server.
class nsIInputStream;
class NS_MSG_BASE nsMsgLineStreamBuffer
{
public:
// aBufferSize -- size of the buffer you want us to use for buffering stream data
// aEndOfLinetoken -- The delimeter string to be used for determining the end of line. This
// allows us to parse platform specific end of line endings by making it
// a parameter.
// aAllocateNewLines -- PR_TRUE if you want calls to ReadNextLine to allocate new memory for the line.
// if false, the char * returned is just a ptr into the buffer. Subsequent calls to
// ReadNextLine will alter the data so your ptr only has a life time of a per call.
// aEatCRLFs -- PR_TRUE if you don't want to see the CRLFs on the lines returned by ReadNextLine.
// PR_FALSE if you do want to see them.
nsMsgLineStreamBuffer(PRUint32 aBufferSize, const char * aEndOfLineToken, PRBool aAllocateNewLines, PRBool aEatCRLFs = PR_TRUE); // specify the size of the buffer you want the class to use....
virtual ~nsMsgLineStreamBuffer();
// Caller must free the line returned using PR_Free
// aEndOfLinetoken -- delimeter used to denote the end of a line.
// aNumBytesInLine -- The number of bytes in the line returned
// aPauseForMoreData -- There is not enough data in the stream to make a line at this time...
char * ReadNextLine(nsIInputStream * aInputStream, PRUint32 &anumBytesInLine, PRBool &aPauseForMoreData);
protected:
PRBool m_eatCRLFs;
PRBool m_allocateNewLines;
char * m_dataBuffer;
char * m_startPos;
const char * m_endOfLineToken;
PRUint32 m_dataBufferSize;
};
#endif

View File

@@ -0,0 +1,399 @@
/* -*- 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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "msgCore.h"
#include "nsMsgMailNewsUrl.h"
#include "nsMsgBaseCID.h"
#include "nsIMsgMailSession.h"
#include "nsXPIDLString.h"
static NS_DEFINE_CID(kUrlListenerManagerCID, NS_URLLISTENERMANAGER_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
nsMsgMailNewsUrl::nsMsgMailNewsUrl()
{
NS_INIT_REFCNT();
// nsIURI specific state
m_errorMessage = nsnull;
m_runningUrl = PR_FALSE;
m_updatingFolder = PR_FALSE;
nsComponentManager::CreateInstance(kUrlListenerManagerCID, nsnull, nsCOMTypeInfo<nsIUrlListenerManager>::GetIID(), (void **) getter_AddRefs(m_urlListeners));
nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, nsCOMTypeInfo<nsIURL>::GetIID(), (void **) getter_AddRefs(m_baseURL));
}
nsMsgMailNewsUrl::~nsMsgMailNewsUrl()
{
PR_FREEIF(m_errorMessage);
}
NS_IMPL_ADDREF(nsMsgMailNewsUrl);
NS_IMPL_RELEASE(nsMsgMailNewsUrl);
nsresult nsMsgMailNewsUrl::QueryInterface(const nsIID &aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(nsCOMTypeInfo<nsIURI>::GetIID())) {
*aInstancePtr = (void*) ((nsIURI*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsIURL>::GetIID())) {
*aInstancePtr = (void*) ((nsIURL*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsIMsgMailNewsUrl>::GetIID()))
{
*aInstancePtr = (void *) ((nsIMsgMailNewsUrl*) this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
{
*aInstancePtr = (void *) ((nsIMsgMailNewsUrl*) this);
NS_ADDREF_THIS();
return NS_OK;
}
#if defined(NS_DEBUG)
/*
* Check for the debug-only interface indicating thread-safety
*/
static NS_DEFINE_IID(kIsThreadsafeIID, NS_ISTHREADSAFE_IID);
if (aIID.Equals(kIsThreadsafeIID)) {
return NS_OK;
}
#endif
return NS_NOINTERFACE;
}
////////////////////////////////////////////////////////////////////////////////////
// Begin nsIMsgMailNewsUrl specific support
////////////////////////////////////////////////////////////////////////////////////
nsresult nsMsgMailNewsUrl::GetUrlState(PRBool * aRunningUrl)
{
if (aRunningUrl)
*aRunningUrl = m_runningUrl;
return NS_OK;
}
nsresult nsMsgMailNewsUrl::SetUrlState(PRBool aRunningUrl, nsresult aExitCode)
{
m_runningUrl = aRunningUrl;
nsCOMPtr <nsIMsgStatusFeedback> statusFeedback;
if (NS_SUCCEEDED(GetStatusFeedback(getter_AddRefs(statusFeedback))) && statusFeedback)
{
if (m_runningUrl)
statusFeedback->StartMeteors();
else
{
statusFeedback->ShowProgress(0);
statusFeedback->StopMeteors();
}
}
if (m_urlListeners)
{
if (m_runningUrl)
{
m_urlListeners->OnStartRunningUrl(this);
}
else
{
m_urlListeners->OnStopRunningUrl(this, aExitCode);
}
}
return NS_OK;
}
nsresult nsMsgMailNewsUrl::RegisterListener (nsIUrlListener * aUrlListener)
{
if (m_urlListeners)
m_urlListeners->RegisterListener(aUrlListener);
return NS_OK;
}
nsresult nsMsgMailNewsUrl::UnRegisterListener (nsIUrlListener * aUrlListener)
{
if (m_urlListeners)
m_urlListeners->UnRegisterListener(aUrlListener);
return NS_OK;
}
nsresult nsMsgMailNewsUrl::SetErrorMessage (const char * errorMessage)
{
// functionality has been moved to nsIMsgStatusFeedback
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult nsMsgMailNewsUrl::GetErrorMessage (char ** errorMessage)
{
// functionality has been moved to nsIMsgStatusFeedback
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetServer(nsIMsgIncomingServer ** aIncomingServer)
{
// mscott --> we could cache a copy of the server here....but if we did, we run
// the risk of leaking the server if any single url gets leaked....of course that
// shouldn't happen...but it could. so i'm going to look it up every time and
// we can look at caching it later.
nsXPIDLCString host;
nsXPIDLCString scheme;
nsresult rv = GetHost(getter_Copies(host));
rv = GetScheme(getter_Copies(scheme));
if (NS_SUCCEEDED(rv))
{
NS_WITH_SERVICE(nsIMsgMailSession, session, kMsgMailSessionCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgAccountManager> accountManager;
rv = session->GetAccountManager(getter_AddRefs(accountManager));
if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgIncomingServer> server;
rv = accountManager->FindServer(GetUserName(),
host,
scheme,
aIncomingServer);
}
return rv;
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetStatusFeedback(nsIMsgStatusFeedback *aMsgFeedback)
{
if (aMsgFeedback)
m_statusFeedback = do_QueryInterface(aMsgFeedback);
return NS_OK;
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetStatusFeedback(nsIMsgStatusFeedback **aMsgFeedback)
{
nsresult rv = NS_OK;
// note: it is okay to return a null status feedback and not return an error
// it's possible the url really doesn't have status feedback
if (!m_statusFeedback)
{
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
if(NS_SUCCEEDED(rv))
mailSession->GetTemporaryMsgStatusFeedback(getter_AddRefs(m_statusFeedback));
}
if (aMsgFeedback)
{
*aMsgFeedback = m_statusFeedback;
NS_IF_ADDREF(*aMsgFeedback);
}
else
rv = NS_ERROR_NULL_POINTER;
return rv;
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetUpdatingFolder(PRBool *aResult)
{
if (!aResult)
return NS_ERROR_NULL_POINTER;
*aResult = m_updatingFolder;
return NS_OK;
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetUpdatingFolder(PRBool updatingFolder)
{
m_updatingFolder = updatingFolder;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////////
// End nsIMsgMailNewsUrl specific support
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
// Begin nsIURI support
////////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsMsgMailNewsUrl::GetSpec(char * *aSpec)
{
return m_baseURL->GetSpec(aSpec);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetSpec(const char * aSpec)
{
return m_baseURL->SetSpec(aSpec);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetScheme(char * *aScheme)
{
return m_baseURL->GetScheme(aScheme);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetScheme(const char * aScheme)
{
return m_baseURL->SetScheme(aScheme);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetPreHost(char * *aPreHost)
{
return m_baseURL->GetPreHost(aPreHost);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetPreHost(const char * aPreHost)
{
return m_baseURL->SetPreHost(aPreHost);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetHost(char * *aHost)
{
return m_baseURL->GetHost(aHost);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetHost(const char * aHost)
{
return m_baseURL->SetHost(aHost);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetPort(PRInt32 *aPort)
{
return m_baseURL->GetPort(aPort);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetPort(PRInt32 aPort)
{
return m_baseURL->SetPort(aPort);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetPath(char * *aPath)
{
return m_baseURL->GetPath(aPath);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetPath(const char * aPath)
{
return m_baseURL->SetPath(aPath);
}
NS_IMETHODIMP nsMsgMailNewsUrl::Equals(nsIURI *other, PRBool *_retval)
{
return m_baseURL->Equals(other, _retval);
}
NS_IMETHODIMP nsMsgMailNewsUrl::Clone(nsIURI **_retval)
{
return m_baseURL->Clone(_retval);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetRelativePath(const char *i_RelativePath)
{
return m_baseURL->SetRelativePath(i_RelativePath);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetDirectory(char * *aDirectory)
{
return m_baseURL->GetDirectory(aDirectory);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetDirectory(const char *aDirectory)
{
return m_baseURL->SetDirectory(aDirectory);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetFileName(char * *aFileName)
{
return m_baseURL->GetFileName(aFileName);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetFileBaseName(char * *aFileBaseName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetFileBaseName(const char * aFileBaseName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetFileExtension(char * *aFileExtension)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetFileExtension(const char * aFileExtension)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetFileName(const char * aFileName)
{
return m_baseURL->SetFileName(aFileName);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetParam(char * *aParam)
{
return m_baseURL->GetParam(aParam);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetParam(const char *aParam)
{
return m_baseURL->SetParam(aParam);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetQuery(char * *aQuery)
{
return m_baseURL->GetQuery(aQuery);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetQuery(const char *aQuery)
{
return m_baseURL->SetQuery(aQuery);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetRef(char * *aRef)
{
return m_baseURL->GetRef(aRef);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetRef(const char *aRef)
{
return m_baseURL->SetRef(aRef);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetFilePath(char **o_DirFile)
{
return m_baseURL->GetFilePath(o_DirFile);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetFilePath(const char *i_DirFile)
{
return m_baseURL->SetFilePath(i_DirFile);
}

View File

@@ -0,0 +1,66 @@
/* -*- 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.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 nsMsgMailNewsUrl_h___
#define nsMsgMailNewsUrl_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nsIUrlListener.h"
#include "nsIUrlListenerManager.h"
#include "nsIMsgStatusFeedback.h"
#include "nsCOMPtr.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsIURL.h"
///////////////////////////////////////////////////////////////////////////////////
// Okay, I found that all of the mail and news url interfaces needed to support
// several common interfaces (in addition to those provided through nsIURI).
// So I decided to group them all in this implementation so we don't have to
// duplicate the code.
//
//////////////////////////////////////////////////////////////////////////////////
class NS_MSG_BASE nsMsgMailNewsUrl : public nsIMsgMailNewsUrl
{
public:
nsMsgMailNewsUrl();
NS_DECL_ISUPPORTS
NS_DECL_NSIMSGMAILNEWSURL
NS_DECL_NSIURI
NS_DECL_NSIURL
protected:
virtual ~nsMsgMailNewsUrl();
// a helper function I needed from derived urls...
virtual const char * GetUserName() = 0;
nsCOMPtr<nsIURL> m_baseURL;
nsCOMPtr<nsIMsgStatusFeedback> m_statusFeedback;
char *m_errorMessage;
PRBool m_runningUrl;
PRBool m_updatingFolder;
// manager of all of current url listeners....
nsCOMPtr<nsIUrlListenerManager> m_urlListeners;
};
#endif /* nsMsgMailNewsUrl_h___ */

View File

@@ -0,0 +1,369 @@
/* -*- 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 "msgCore.h"
#include "nsMsgProtocol.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsISocketTransportService.h"
#include "nsXPIDLString.h"
#include "nsSpecialSystemDirectory.h"
#include "nsILoadGroup.h"
#include "nsIIOService.h"
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
NS_IMPL_ISUPPORTS3(nsMsgProtocol, nsIStreamListener, nsIStreamObserver, nsIChannel)
nsMsgProtocol::nsMsgProtocol()
{
NS_INIT_REFCNT();
m_flags = 0;
m_startPosition = 0;
m_readCount = 0;
m_socketIsOpen = PR_FALSE;
m_tempMsgFileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory);
m_tempMsgFileSpec += "tempMessage.eml";
}
nsMsgProtocol::~nsMsgProtocol()
{}
nsresult nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL) // open a connection on this url
{
nsresult rv = NS_OK;
nsXPIDLCString hostName;
PRInt32 port = 0;
m_readCount = -1; // with socket connections we want to read as much data as arrives
m_startPosition = 0;
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
if (NS_SUCCEEDED(rv) && aURL)
{
aURL->GetPort(&port);
aURL->GetHost(getter_Copies(hostName));
rv = socketService->CreateTransport(hostName, port, nsnull, getter_AddRefs(m_channel));
if (NS_SUCCEEDED(rv) && m_channel)
{
m_socketIsOpen = PR_FALSE;
rv = SetupTransportState();
}
}
return rv;
}
nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSpec, PRUint32 aStartPosition, PRInt32 aReadCount)
{
// mscott - file needs to be encoded directly into aURL. I should be able to get
// rid of this method completely.
nsresult rv = NS_OK;
m_startPosition = aStartPosition;
m_readCount = aReadCount;
NS_WITH_SERVICE(nsIIOService, netService, kIOServiceCID, &rv);
if (NS_SUCCEEDED(rv) && aURL)
{
// extract the file path from the uri...
nsXPIDLCString filePath;
aURL->GetPath(getter_Copies(filePath));
char * urlSpec = PR_smprintf("file://%s", (const char *) filePath);
rv = netService->NewChannel("Load", urlSpec,
nsnull, // null base URI
nsnull, // null load group
nsnull, // null eventsink getter
getter_AddRefs(m_channel));
PR_FREEIF(urlSpec);
if (NS_SUCCEEDED(rv) && m_channel)
{
m_socketIsOpen = PR_FALSE;
// rv = SetupTransportState();
}
}
return rv;
}
nsresult nsMsgProtocol::SetupTransportState()
{
nsresult rv = NS_OK;
if (!m_socketIsOpen && m_channel)
{
rv = m_channel->OpenOutputStream(0 /* start position */, getter_AddRefs(m_outputStream));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create an output stream");
// we want to open the stream
} // if m_transport
return rv;
}
nsresult nsMsgProtocol::CloseSocket()
{
// release all of our socket state
m_socketIsOpen = PR_FALSE;
m_outputStream = null_nsCOMPtr();
m_channel = null_nsCOMPtr();
return NS_OK;
}
/*
* Writes the data contained in dataBuffer into the current output stream. It also informs
* the transport layer that this data is now available for transmission.
* Returns a positive number for success, 0 for failure (not all the bytes were written to the
* stream, etc). We need to make another pass through this file to install an error system (mscott)
*/
PRInt32 nsMsgProtocol::SendData(nsIURI * aURL, const char * dataBuffer)
{
PRUint32 writeCount = 0;
PRInt32 status = 0;
// NS_PRECONDITION(m_outputStream, "oops....we don't have an output stream...how did that happen?");
if (dataBuffer && m_outputStream)
{
status = m_outputStream->Write(dataBuffer, PL_strlen(dataBuffer), &writeCount);
}
return status;
}
// Whenever data arrives from the connection, core netlib notifices the protocol by calling
// OnDataAvailable. We then read and process the incoming data from the input stream.
NS_IMETHODIMP nsMsgProtocol::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
{
// right now, this really just means turn around and churn through the state machine
nsCOMPtr<nsIURI> uri = do_QueryInterface(ctxt);
return ProcessProtocolState(uri, inStr, sourceOffset, count);
}
NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt)
{
nsresult rv = NS_OK;
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(ctxt, &rv);
if (NS_SUCCEEDED(rv) && aMsgUrl)
rv = aMsgUrl->SetUrlState(PR_TRUE, NS_OK);
// if we are set up as a channel, we should notify our channel listener that we are starting...
// so pass in ourself as the channel and not the underlying socket or file channel the protocol
// happens to be using
if (m_channelListener)
rv = m_channelListener->OnStartRequest(this, m_channelContext);
return rv;
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg)
{
nsresult rv = NS_OK;
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(ctxt, &rv);
if (NS_SUCCEEDED(rv) && aMsgUrl)
rv = aMsgUrl->SetUrlState(PR_FALSE, aStatus);
// if we are set up as a channel, we should notify our channel listener that we are starting...
// so pass in ourself as the channel and not the underlying socket or file channel the protocol
// happens to be using
if (m_channelListener)
rv = m_channelListener->OnStopRequest(this, m_channelContext, aStatus, aMsg);
return rv;
}
nsresult nsMsgProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
{
// okay now kick us off to the next state...
// our first state is a process state so drive the state machine...
nsresult rv = NS_OK;
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(aURL);
if (NS_SUCCEEDED(rv))
{
rv = aMsgUrl->SetUrlState(PR_TRUE, NS_OK); // set the url as a url currently being run...
// if the url is given a stream consumer then we should use it to forward calls to...
if (!m_channelListener && aConsumer) // if we don't have a registered listener already
{
m_channelListener = do_QueryInterface(aConsumer);
if (!m_channelContext)
m_channelContext = do_QueryInterface(aURL);
}
if (!m_socketIsOpen)
{
nsCOMPtr<nsISupports> urlSupports = do_QueryInterface(aURL);
// put us in a state where we are always notified of incoming data
m_channel->AsyncRead(m_startPosition, m_readCount, urlSupports ,this /* stream observer */);
m_socketIsOpen = PR_TRUE; // mark the channel as open
} // if we got an event queue service
else // the connection is already open so we should begin processing our new url...
rv = ProcessProtocolState(aURL, nsnull, 0, 0);
}
return rv;
}
///////////////////////////////////////////////////////////////////////
// The rest of this file is mostly nsIChannel mumbo jumbo stuff
///////////////////////////////////////////////////////////////////////
nsresult nsMsgProtocol::SetUrl(nsIURI * aURL)
{
m_url = dont_QueryInterface(aURL);
return NS_OK;
}
nsresult nsMsgProtocol::SetLoadGroup(nsILoadGroup * aLoadGroup)
{
m_loadGroup = dont_QueryInterface(aLoadGroup);
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::GetURI(nsIURI * *aURI)
{
nsresult rv = NS_OK;
if (aURI)
{
if (m_url)
rv = m_url->QueryInterface(NS_GET_IID(nsIURI), (void **) aURI);
else
*aURI = nsnull;
}
else
rv = NS_ERROR_NULL_POINTER;
return rv;
}
NS_IMETHODIMP nsMsgProtocol::OpenInputStream(PRUint32 startPosition, PRInt32 readCount, nsIInputStream **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::OpenOutputStream(PRUint32 startPosition, nsIOutputStream **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::AsyncRead(PRUint32 startPosition, PRInt32 readCount, nsISupports *ctxt, nsIStreamListener *listener)
{
// set the stream listener and then load the url
m_channelContext = ctxt;
m_channelListener = listener;
// the following load group code is completely bogus....
nsresult rv = NS_OK;
if (m_loadGroup)
{
nsCOMPtr<nsILoadGroupListenerFactory> factory;
//
// Create a load group "proxy" listener...
//
rv = m_loadGroup->GetGroupListenerFactory(getter_AddRefs(factory));
if (factory)
{
nsCOMPtr<nsIStreamListener> newListener;
rv = factory->CreateLoadGroupListener(m_channelListener, getter_AddRefs(newListener));
if (NS_SUCCEEDED(rv))
m_channelListener = newListener;
}
} // if aLoadGroup
return LoadUrl(m_url, nsnull);
}
NS_IMETHODIMP nsMsgProtocol::AsyncWrite(nsIInputStream *fromStream, PRUint32 startPosition, PRInt32 writeCount, nsISupports *ctxt, nsIStreamObserver *observer)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::GetLoadAttributes(nsLoadFlags *aLoadAttributes)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::SetLoadAttributes(nsLoadFlags aLoadAttributes)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::GetContentType(char * *aContentType)
{
*aContentType = nsCRT::strdup("message/rfc822");
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::GetContentLength(PRInt32 * aContentLength)
{
*aContentLength = -1;
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::GetOwner(nsISupports * *aPrincipal)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::SetOwner(nsISupports * aPrincipal)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::GetLoadGroup(nsILoadGroup * *aLoadGroup)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
////////////////////////////////////////////////////////////////////////////////
// From nsIRequest
////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsMsgProtocol::IsPending(PRBool *result)
{
*result = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::Cancel()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::Suspend()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::Resume()
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@@ -0,0 +1,108 @@
/* -*- 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.
*/
#ifndef nsMsgProtocol_h__
#define nsMsgProtocol_h__
#include "nsIStreamListener.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsIEventQueue.h"
#include "nsIChannel.h"
#include "nsIURL.h"
#include "nsILoadGroup.h"
#include "nsCOMPtr.h"
// This is a helper class used to encapsulate code shared between all of the
// mailnews protocol objects (imap, news, pop, smtp, etc.) In particular,
// it unifies the core networking code for the protocols. My hope is that
// this will make unification with Necko easier as we'll only have to change
// this class and not all of the mailnews protocols.
class NS_MSG_BASE nsMsgProtocol : public nsIStreamListener, public nsIChannel
{
public:
nsMsgProtocol();
virtual ~nsMsgProtocol();
NS_DECL_ISUPPORTS
// nsIChannel support
NS_DECL_NSICHANNEL
NS_DECL_NSIREQUEST
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSISTREAMOBSERVER
// LoadUrl -- A protocol typically overrides this function, sets up any local state for the url and
// then calls the base class which opens the socket if it needs opened. If the socket is
// already opened then we just call ProcessProtocolState to start the churning process.
// aConsumer is the consumer for the url. It can be null if this argument is not appropriate
virtual nsresult LoadUrl(nsIURI * aURL, nsISupports * aConsumer = nsnull);
virtual nsresult SetUrl(nsIURI * aURL); // sometimes we want to set the url before we load it
virtual nsresult SetLoadGroup(nsILoadGroup * aLoadGroup);
// Flag manipulators
PRBool TestFlag (PRUint32 flag) {return flag & m_flags;}
void SetFlag (PRUint32 flag) { m_flags |= flag; }
void ClearFlag (PRUint32 flag) { m_flags &= ~flag; }
protected:
// methods for opening and closing a socket with core netlib....
// mscott -okay this is lame. I should break this up into a file protocol and a socket based
// protocool class instead of cheating and putting both methods here...
virtual nsresult OpenNetworkSocket(nsIURI * aURL); // open a connection on this url
virtual nsresult OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSpec, PRUint32 aStartPosition, PRInt32 aReadCount); // used to open a file socket connection
// a Protocol typically overrides this method. They free any of their own connection state and then
// they call up into the base class to free the generic connection objects
virtual nsresult CloseSocket();
virtual nsresult SetupTransportState(); // private method used by OpenNetworkSocket and OpenFileSocket
// ProcessProtocolState - This is the function that gets churned by calls to OnDataAvailable.
// As data arrives on the socket, OnDataAvailable calls ProcessProtocolState.
virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
PRUint32 sourceOffset, PRUint32 length) = 0;
// SendData -- Writes the data contained in dataBuffer into the current output stream.
// It also informs the transport layer that this data is now available for transmission.
// Returns a positive number for success, 0 for failure (not all the bytes were written to the
// stream, etc).
virtual PRInt32 SendData(nsIURI * aURL, const char * dataBuffer);
// Ouput stream for writing commands to the socket
nsCOMPtr<nsIChannel> m_channel;
nsCOMPtr<nsIOutputStream> m_outputStream; // this will be obtained from the transport interface
PRBool m_socketIsOpen; // mscott: we should look into keeping this state in the nsSocketTransport...
// I'm using it to make sure I open the socket the first time a URL is loaded into the connection
PRUint32 m_flags; // used to store flag information
PRUint32 m_startPosition;
PRInt32 m_readCount;
nsFileSpec m_tempMsgFileSpec; // we currently have a hack where displaying a msg involves writing it to a temp file first
// the following is a catch all for nsIChannel related data
nsCOMPtr<nsIURI> m_url; // the running url
nsCOMPtr<nsIStreamListener> m_channelListener;
nsCOMPtr<nsISupports> m_channelContext;
nsCOMPtr<nsILoadGroup> m_loadGroup;
};
#endif /* nsMsgProtocol_h__ */

View File

@@ -0,0 +1,99 @@
/* -*- 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, 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsMsgTxn.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kITransactionIID, NS_ITRANSACTION_IID);
NS_IMPL_ADDREF(nsMsgTxn)
NS_IMPL_RELEASE(nsMsgTxn)
// note that aEditor is not refcounted
nsMsgTxn::nsMsgTxn()
{
NS_INIT_REFCNT();
}
nsMsgTxn::~nsMsgTxn()
{
}
NS_IMETHODIMP nsMsgTxn::Do(void)
{
return NS_OK;
}
NS_IMETHODIMP nsMsgTxn::GetIsTransient(PRBool *aIsTransient)
{
if (nsnull!=aIsTransient)
*aIsTransient = PR_FALSE;
else
return NS_ERROR_NULL_POINTER;
return NS_OK;
}
NS_IMETHODIMP nsMsgTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgTxn::Write(nsIOutputStream *aOutputStream)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
*aString="Undo";
else
return NS_ERROR_NULL_POINTER;
return NS_OK;
}
NS_IMETHODIMP nsMsgTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
*aString="Redo";
else
return NS_ERROR_NULL_POINTER;
return NS_OK;
}
NS_IMETHODIMP
nsMsgTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kITransactionIID)) {
*aInstancePtr = (void*)(nsITransaction*)this;
NS_ADDREF_THIS();
return NS_OK;
}
*aInstancePtr = 0;
return NS_NOINTERFACE;
}

View File

@@ -0,0 +1,57 @@
/* -*- 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, 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsMsgTxn_h__
#define nsMsgTxn_h__
#include "nsITransaction.h"
#include "msgCore.h"
#define NS_MESSAGETRANSACTION_IID \
{ /* da621b30-1efc-11d3-abe4-00805f8ac968 */ \
0xda621b30, 0x1efc, 0x11d3, \
{ 0xab, 0xe4, 0x00, 0x80, 0x5f, 0x8a, 0xc9, 0x68 } }
/**
* base class for all message undo/redo transactions.
*/
class NS_MSG_BASE nsMsgTxn : public nsITransaction
{
NS_DECL_ISUPPORTS
nsMsgTxn();
virtual ~nsMsgTxn();
NS_IMETHOD Do(void);
NS_IMETHOD Undo(void) = 0;
NS_IMETHOD Redo(void) = 0;
NS_IMETHOD GetIsTransient(PRBool *aIsTransient);
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
};
#endif

View File

@@ -0,0 +1,326 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "msgCore.h"
#include "nsIMessage.h"
#include "nsIMsgHdr.h"
#include "nsMsgUtils.h"
#include "nsString.h"
#include "nsFileSpec.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIImapUrl.h"
#include "nsIMailboxUrl.h"
#include "nsINntpUrl.h"
#include "nsMsgNewsCID.h"
#include "nsMsgLocalCID.h"
#include "nsMsgBaseCID.h"
#include "nsMsgImapCID.h"
static NS_DEFINE_CID(kImapUrlCID, NS_IMAPURL_CID);
static NS_DEFINE_CID(kCMailboxUrl, NS_MAILBOXURL_CID);
static NS_DEFINE_CID(kCNntpUrlCID, NS_NNTPURL_CID);
#if defined(DEBUG_sspitzer_) || defined(DEBUG_seth_)
#define DEBUG_NS_MsgHashIfNecessary 1
#endif
nsresult GetMessageServiceProgIDForURI(const char *uri, nsString &progID)
{
nsresult rv = NS_OK;
//Find protocol
nsString uriStr = uri;
PRInt32 pos = uriStr.FindChar(':');
if(pos == -1)
return NS_ERROR_FAILURE;
nsString protocol;
uriStr.Left(protocol, pos);
//Build message service progid
progID = "component://netscape/messenger/messageservice;type=";
progID += protocol;
return rv;
}
nsresult GetMessageServiceFromURI(const char *uri, nsIMsgMessageService **messageService)
{
nsAutoString progID;
nsresult rv;
rv = GetMessageServiceProgIDForURI(uri, progID);
if(NS_SUCCEEDED(rv))
{
rv = nsServiceManager::GetService((const char *) nsCAutoString(progID), nsCOMTypeInfo<nsIMsgMessageService>::GetIID(),
(nsISupports**)messageService, nsnull);
}
return rv;
}
nsresult ReleaseMessageServiceFromURI(const char *uri, nsIMsgMessageService *messageService)
{
nsAutoString progID;
nsresult rv;
rv = GetMessageServiceProgIDForURI(uri, progID);
if(NS_SUCCEEDED(rv))
rv = nsServiceManager::ReleaseService(nsCAutoString(progID), messageService);
return rv;
}
nsresult CreateStartupUrl(char *uri, nsIURI** aUrl)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (!uri || !*uri || !aUrl) return rv;
*aUrl = nsnull;
if (PL_strncasecmp(uri, "imap", 4) == 0)
{
nsCOMPtr<nsIImapUrl> imapUrl;
rv = nsComponentManager::CreateInstance(kImapUrlCID, nsnull,
nsIImapUrl::GetIID(),
getter_AddRefs(imapUrl));
if (NS_SUCCEEDED(rv) && imapUrl)
rv = imapUrl->QueryInterface(nsCOMTypeInfo<nsIURI>::GetIID(),
(void**) aUrl);
}
else if (PL_strncasecmp(uri, "mailbox", 7) == 0)
{
nsCOMPtr<nsIMailboxUrl> mailboxUrl;
rv = nsComponentManager::CreateInstance(kCMailboxUrl, nsnull,
nsIMailboxUrl::GetIID(),
getter_AddRefs(mailboxUrl));
if (NS_SUCCEEDED(rv) && mailboxUrl)
rv = mailboxUrl->QueryInterface(nsCOMTypeInfo<nsIURI>::GetIID(),
(void**) aUrl);
}
else if (PL_strncasecmp(uri, "news", 4) == 0)
{
nsCOMPtr<nsINntpUrl> nntpUrl;
rv = nsComponentManager::CreateInstance(kCNntpUrlCID, nsnull,
nsINntpUrl::GetIID(),
getter_AddRefs(nntpUrl));
if (NS_SUCCEEDED(rv) && nntpUrl)
rv = nntpUrl->QueryInterface(nsCOMTypeInfo<nsIURI>::GetIID(),
(void**) aUrl);
}
if (*aUrl)
(*aUrl)->SetSpec(uri);
return rv;
}
NS_IMPL_ISUPPORTS(nsMessageFromMsgHdrEnumerator, nsCOMTypeInfo<nsISimpleEnumerator>::GetIID())
nsMessageFromMsgHdrEnumerator::nsMessageFromMsgHdrEnumerator(nsISimpleEnumerator *srcEnumerator,
nsIMsgFolder *folder)
{
NS_INIT_REFCNT();
mSrcEnumerator = dont_QueryInterface(srcEnumerator);
mFolder = dont_QueryInterface(folder);
}
nsMessageFromMsgHdrEnumerator::~nsMessageFromMsgHdrEnumerator()
{
//member variables are nsCOMPtr's
}
NS_IMETHODIMP nsMessageFromMsgHdrEnumerator::GetNext(nsISupports **aItem)
{
nsCOMPtr<nsISupports> currentItem;
nsCOMPtr<nsIMsgDBHdr> msgDBHdr;
nsCOMPtr<nsIMessage> message;
nsresult rv;
rv = mSrcEnumerator->GetNext(getter_AddRefs(currentItem));
if(NS_SUCCEEDED(rv))
{
msgDBHdr = do_QueryInterface(currentItem, &rv);
}
if(NS_SUCCEEDED(rv))
{
rv = mFolder->CreateMessageFromMsgDBHdr(msgDBHdr, getter_AddRefs(message));
}
if(NS_SUCCEEDED(rv))
{
currentItem = do_QueryInterface(message, &rv);
*aItem = currentItem;
NS_IF_ADDREF(*aItem);
}
NS_ASSERTION(NS_SUCCEEDED(rv),"getnext shouldn't fail");
return rv;
}
NS_IMETHODIMP nsMessageFromMsgHdrEnumerator::HasMoreElements(PRBool *aResult)
{
return mSrcEnumerator->HasMoreElements(aResult);
}
nsresult NS_NewMessageFromMsgHdrEnumerator(nsISimpleEnumerator *srcEnumerator,
nsIMsgFolder *folder,
nsMessageFromMsgHdrEnumerator **messageEnumerator)
{
if(!messageEnumerator)
return NS_ERROR_NULL_POINTER;
*messageEnumerator = new nsMessageFromMsgHdrEnumerator(srcEnumerator, folder);
if(!messageEnumerator)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*messageEnumerator);
return NS_OK;
}
// Where should this live? It's a utility used to convert a string priority, e.g., "High, Low, Normal" to an enum.
// Perhaps we should have an interface that groups together all these utilities...
nsresult NS_MsgGetPriorityFromString(const char *priority, nsMsgPriority *outPriority)
{
if (!outPriority)
return NS_ERROR_NULL_POINTER;
nsMsgPriority retPriority = nsMsgPriorityNormal;
if (PL_strcasestr(priority, "Normal") != NULL)
retPriority = nsMsgPriorityNormal;
else if (PL_strcasestr(priority, "Lowest") != NULL)
retPriority = nsMsgPriorityLowest;
else if (PL_strcasestr(priority, "Highest") != NULL)
retPriority = nsMsgPriorityHighest;
else if (PL_strcasestr(priority, "High") != NULL ||
PL_strcasestr(priority, "Urgent") != NULL)
retPriority = nsMsgPriorityHigh;
else if (PL_strcasestr(priority, "Low") != NULL ||
PL_strcasestr(priority, "Non-urgent") != NULL)
retPriority = nsMsgPriorityLow;
else if (PL_strcasestr(priority, "1") != NULL)
retPriority = nsMsgPriorityHighest;
else if (PL_strcasestr(priority, "2") != NULL)
retPriority = nsMsgPriorityHigh;
else if (PL_strcasestr(priority, "3") != NULL)
retPriority = nsMsgPriorityNormal;
else if (PL_strcasestr(priority, "4") != NULL)
retPriority = nsMsgPriorityLow;
else if (PL_strcasestr(priority, "5") != NULL)
retPriority = nsMsgPriorityLowest;
else
retPriority = nsMsgPriorityNormal;
*outPriority = retPriority;
return NS_OK;
//return nsMsgNoPriority;
}
nsresult NS_MsgGetUntranslatedPriorityName (nsMsgPriority p, nsString *outName)
{
if (!outName)
return NS_ERROR_NULL_POINTER;
switch (p)
{
case nsMsgPriorityNotSet:
case nsMsgPriorityNone:
*outName = "None";
break;
case nsMsgPriorityLowest:
*outName = "Lowest";
break;
case nsMsgPriorityLow:
*outName = "Low";
break;
case nsMsgPriorityNormal:
*outName = "Normal";
break;
case nsMsgPriorityHigh:
*outName = "High";
break;
case nsMsgPriorityHighest:
*outName = "Highest";
break;
default:
NS_ASSERTION(PR_FALSE, "invalid priority value");
}
return NS_OK;
}
/* this used to be XP_StringHash2 from xp_hash.c */
/* phong's linear congruential hash */
static PRUint32 StringHash(const char *ubuf)
{
unsigned char * buf = (unsigned char*) ubuf;
PRUint32 h=1;
while(*buf) {
h = 0x63c63cd9*h + 0x9c39c33d + (int32)*buf;
buf++;
}
return h;
}
nsresult NS_MsgHashIfNecessary(nsCAutoString &name)
{
#if defined(XP_WIN16) || defined(XP_OS2)
const PRUint32 MAX_LEN = 8;
#elif defined(XP_MAC)
const PRUint32 MAX_LEN = 25;
#elif defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS)
const PRUint32 MAX_LEN = 55;
#else
#error need_to_define_your_max_filename_length
#endif
nsCAutoString str(name);
#ifdef DEBUG_NS_MsgHashIfNecessary
printf("in: %s\n",str.GetBuffer());
#endif
// Given a name, use either that name, if it fits on our
// filesystem, or a hashified version of it, if the name is too
// long to fit.
char hashedname[MAX_LEN + 1];
PRBool needshash = PL_strlen(str.GetBuffer()) > MAX_LEN;
#if defined(XP_WIN16) || defined(XP_OS2)
if (!needshash) {
needshash = PL_strchr(str.GetBuffer(), '.') != NULL ||
PL_strchr(str.GetBuffer(), ':') != NULL;
}
#endif
PL_strncpy(hashedname, str.GetBuffer(), MAX_LEN + 1);
if (needshash) {
PR_snprintf(hashedname + MAX_LEN - 8, 9, "%08lx",
(unsigned long) StringHash(str.GetBuffer()));
}
name = hashedname;
#ifdef DEBUG_NS_MsgHashIfNecessary
printf("out: %s\n",hashedname);
#endif
return NS_OK;
}

View File

@@ -0,0 +1,67 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _NSMSGUTILS_H
#define _NSMSGUTILS_H
#include "nsIURL.h"
#include "nsIMsgMessageService.h"
#include "nsString.h"
#include "nsIEnumerator.h"
#include "nsIMsgFolder.h"
#include "msgCore.h"
#include "nsCOMPtr.h"
//These are utility functions that can used throughout the mailnews code
//Utilities for getting a message service.
NS_MSG_BASE nsresult GetMessageServiceProgIDForURI(const char *uri, nsString &progID);
//Use ReleaseMessageServiceFromURI to release the service.
NS_MSG_BASE nsresult GetMessageServiceFromURI(const char *uri, nsIMsgMessageService **messageService);
NS_MSG_BASE nsresult ReleaseMessageServiceFromURI(const char *uri, nsIMsgMessageService *messageService);
NS_MSG_BASE nsresult CreateStartupUrl(char *uri, nsIURI** aUrl);
//An enumerator for converting nsIMsgHdrs to nsIMessages.
class NS_MSG_BASE nsMessageFromMsgHdrEnumerator: public nsISimpleEnumerator
{
protected:
nsCOMPtr<nsISimpleEnumerator> mSrcEnumerator;
nsCOMPtr<nsIMsgFolder> mFolder;
public:
NS_DECL_ISUPPORTS
nsMessageFromMsgHdrEnumerator(nsISimpleEnumerator *srcEnumerator, nsIMsgFolder *folder);
nsMessageFromMsgHdrEnumerator(){} //Default constructor that does nothing so nsComPtr will work.
virtual ~nsMessageFromMsgHdrEnumerator();
NS_DECL_NSISIMPLEENUMERATOR
};
NS_MSG_BASE nsresult NS_NewMessageFromMsgHdrEnumerator(nsISimpleEnumerator *srcEnumerator,
nsIMsgFolder *folder,
nsMessageFromMsgHdrEnumerator **messageEnumerator);
NS_MSG_BASE nsresult NS_MsgGetPriorityFromString(const char *priority, nsMsgPriority *outPriority);
NS_MSG_BASE nsresult NS_MsgGetUntranslatedPriorityName (nsMsgPriority p, nsString *outName);
NS_MSG_BASE nsresult NS_MsgHashIfNecessary(nsCAutoString &name);
#endif

View 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsNewsSummarySpec.h"
#include "plstr.h"
#include "nsString.h"
MOZ_DECL_CTOR_COUNTER(nsNewsSummarySpec);
nsNewsSummarySpec::~nsNewsSummarySpec()
{
MOZ_COUNT_DTOR(nsNewsSummarySpec);
}
nsNewsSummarySpec::nsNewsSummarySpec()
{
MOZ_COUNT_CTOR(nsNewsSummarySpec);
}
nsNewsSummarySpec::nsNewsSummarySpec(const char *folderPath)
: nsFileSpec(folderPath)
{
MOZ_COUNT_CTOR(nsNewsSummarySpec);
CreateSummaryFileName();
}
nsNewsSummarySpec::nsNewsSummarySpec(const nsFileSpec& inFolderPath)
: nsFileSpec(inFolderPath)
{
MOZ_COUNT_CTOR(nsNewsSummarySpec);
CreateSummaryFileName();
}
nsNewsSummarySpec::nsNewsSummarySpec(const nsFilePath &inFolderPath) : nsFileSpec(inFolderPath)
{
MOZ_COUNT_CTOR(nsNewsSummarySpec);
CreateSummaryFileName();
}
void nsNewsSummarySpec::SetFolderName(const char *folderPath)
{
*this = folderPath;
}
void nsNewsSummarySpec::CreateSummaryFileName()
{
char *leafName = GetLeafName();
nsCAutoString fullLeafName((const char*)leafName);
// Append .msf (message summary file)
fullLeafName += ".msf";
SetLeafName(fullLeafName.GetBuffer());
PL_strfree(leafName);
}

View File

@@ -0,0 +1,45 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsNewsSummarySpec_H
#define _nsNewsSummarySpec_H
#include "nsFileSpec.h"
#include "msgCore.h"
// Class to name a summary file for a newsgroup,
// given a full folder file spec.
// Note this class expects the invoking code to fully specify the folder path.
// This class does NOT prepend the local folder directory, or put .sbd on the containing
// directory names.
class NS_MSG_BASE nsNewsSummarySpec : public nsFileSpec
{
public:
nsNewsSummarySpec();
nsNewsSummarySpec(const char *folderPath);
nsNewsSummarySpec(const nsFileSpec& inFolderPath);
nsNewsSummarySpec(const nsFilePath &inFolderPath);
~nsNewsSummarySpec();
void SetFolderName(const char *folderPath);
protected:
void CreateSummaryFileName();
};
#endif /* _nsNewsSummarySpec_H */

View File

@@ -0,0 +1,277 @@
/* -*- 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.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 "msgCore.h" // precompiled header...
#include "prlog.h"
#include "MailNewsTypes.h"
#include "nsUInt32Array.h"
#include "nsQuickSort.h"
MOZ_DECL_CTOR_COUNTER(nsUInt32Array);
nsUInt32Array::nsUInt32Array()
{
MOZ_COUNT_CTOR(nsUInt32Array);
m_nSize = 0;
m_nMaxSize = 0;
m_nGrowBy = 0;
m_pData = NULL;
}
nsUInt32Array::~nsUInt32Array()
{
MOZ_COUNT_DTOR(nsUInt32Array);
SetSize(0);
}
/////////////////////////////////////////////////////////////////////////////
PRUint32 nsUInt32Array::GetSize() const
{
return m_nSize;
}
PRBool nsUInt32Array::SetSize(PRUint32 nSize,
PRBool adjustGrowth,
PRUint32 nGrowBy)
{
if (adjustGrowth)
m_nGrowBy = nGrowBy;
#ifdef MAX_ARR_ELEMS
if (nSize > MAX_ARR_ELEMS);
{
PR_ASSERT(nSize <= MAX_ARR_ELEMS); // Will fail
return PR_FALSE;
}
#endif
if (nSize == 0)
{
// Remove all elements
PR_Free(m_pData);
m_nSize = 0;
m_nMaxSize = 0;
m_pData = NULL;
}
else if (m_pData == NULL)
{
// Create a new array
m_nMaxSize = PR_MAX(8, nSize);
m_pData = (PRUint32 *)PR_Calloc(1, m_nMaxSize * sizeof(PRUint32));
if (m_pData)
m_nSize = nSize;
else
m_nSize = m_nMaxSize = 0;
}
else if (nSize <= m_nMaxSize)
{
// The new size is within the current maximum size, make sure new
// elements are to initialized to zero
if (nSize > m_nSize)
nsCRT::memset(&m_pData[m_nSize], 0, (nSize - m_nSize) * sizeof(PRUint32));
m_nSize = nSize;
}
else
{
// The array needs to grow, figure out how much
PRUint32 nMaxSize;
nGrowBy = PR_MAX(m_nGrowBy, PR_MIN(1024, PR_MAX(8, m_nSize / 8)));
nMaxSize = PR_MAX(nSize, m_nMaxSize + nGrowBy);
#ifdef MAX_ARR_ELEMS
nMaxSize = PR_MIN(MAX_ARR_ELEMS, nMaxSize);
#endif
PRUint32 *pNewData = (PRUint32 *)PR_Malloc(nMaxSize * sizeof(PRUint32));
if (pNewData)
{
// Copy the data from the old array to the new one
nsCRT::memcpy(pNewData, m_pData, m_nSize * sizeof(PRUint32));
// Zero out the remaining elements
nsCRT::memset(&pNewData[m_nSize], 0, (nSize - m_nSize) * sizeof(PRUint32));
m_nSize = nSize;
m_nMaxSize = nMaxSize;
// Free the old array
PR_Free(m_pData);
m_pData = pNewData;
}
}
return nSize == m_nSize;
}
/////////////////////////////////////////////////////////////////////////////
PRUint32 &nsUInt32Array::ElementAt(PRUint32 nIndex)
{
PR_ASSERT(nIndex < m_nSize);
return m_pData[nIndex];
}
PRUint32 nsUInt32Array::GetAt(PRUint32 nIndex) const
{
PR_ASSERT(nIndex < m_nSize);
return m_pData[nIndex];
}
PRUint32 *nsUInt32Array::GetData()
{
return m_pData;
}
void nsUInt32Array::SetAt(PRUint32 nIndex, PRUint32 newElement)
{
PR_ASSERT(nIndex < m_nSize);
m_pData[nIndex] = newElement;
}
/////////////////////////////////////////////////////////////////////////////
PRUint32 nsUInt32Array::Add(PRUint32 newElement)
{
PRUint32 nIndex = m_nSize;
#ifdef MAX_ARR_ELEMS
if (nIndex >= MAX_ARR_ELEMS)
return -1;
#endif
SetAtGrow(nIndex, newElement);
return nIndex;
}
PRUint32 nsUInt32Array::Add(PRUint32 *elementPtr, PRUint32 numElements)
{
if (SetSize(m_nSize + numElements))
nsCRT::memcpy(m_pData + m_nSize, elementPtr, numElements * sizeof(PRUint32));
return m_nSize;
}
PRUint32 *nsUInt32Array::CloneData()
{
PRUint32 *copyOfData = (PRUint32 *)PR_Malloc(m_nSize * sizeof(PRUint32));
if (copyOfData)
nsCRT::memcpy(copyOfData, m_pData, m_nSize * sizeof(PRUint32));
return copyOfData;
}
void nsUInt32Array::InsertAt(PRUint32 nIndex, PRUint32 newElement, PRUint32 nCount)
{
PR_ASSERT(nCount > 0);
if (nIndex >= m_nSize)
{
// If the new element is after the end of the array, grow the array
SetSize(nIndex + nCount);
}
else
{
// The element is being insert inside the array
int nOldSize = m_nSize;
SetSize(m_nSize + nCount);
// Move the data after the insertion point
nsCRT::memmove(&m_pData[nIndex + nCount], &m_pData[nIndex],
(nOldSize - nIndex) * sizeof(PRUint32));
}
// Insert the new elements
PR_ASSERT(nIndex + nCount <= m_nSize);
while (nCount--)
m_pData[nIndex++] = newElement;
}
void nsUInt32Array::InsertAt(PRUint32 nStartIndex, const nsUInt32Array *pNewArray)
{
PR_ASSERT(pNewArray != NULL);
if (pNewArray->GetSize() > 0)
{
InsertAt(nStartIndex, pNewArray->GetAt(0), pNewArray->GetSize());
for (PRUint32 i = 1; i < pNewArray->GetSize(); i++)
m_pData[nStartIndex + i] = pNewArray->GetAt(i);
}
}
void nsUInt32Array::RemoveAll()
{
SetSize(0);
}
void nsUInt32Array::RemoveAt(PRUint32 nIndex, PRUint32 nCount)
{
PR_ASSERT(nIndex + nCount <= m_nSize);
if (nCount > 0)
{
// Make sure not to overstep the end of the array
int nMoveCount = m_nSize - (nIndex + nCount);
if (nCount && nMoveCount)
nsCRT::memmove(&m_pData[nIndex], &m_pData[nIndex + nCount],
nMoveCount * sizeof(PRUint32));
m_nSize -= nCount;
}
}
void nsUInt32Array::SetAtGrow(PRUint32 nIndex, PRUint32 newElement)
{
if (nIndex >= m_nSize)
SetSize(nIndex+1);
m_pData[nIndex] = newElement;
}
/////////////////////////////////////////////////////////////////////////////
void nsUInt32Array::CopyArray(nsUInt32Array *oldA)
{
CopyArray(*oldA);
}
void nsUInt32Array::CopyArray(nsUInt32Array &oldA)
{
if (m_pData)
PR_Free(m_pData);
m_nSize = oldA.m_nSize;
m_nMaxSize = oldA.m_nMaxSize;
m_pData = (PRUint32 *)PR_Malloc(m_nSize * sizeof(PRUint32));
if (m_pData)
nsCRT::memcpy(m_pData, oldA.m_pData, m_nSize * sizeof(PRUint32));
}
/////////////////////////////////////////////////////////////////////////////
static int CompareDWord (const void *v1, const void *v2, void *)
{
// QuickSort callback to compare array values
PRUint32 i1 = *(PRUint32 *)v1;
PRUint32 i2 = *(PRUint32 *)v2;
return i1 - i2;
}
void nsUInt32Array::QuickSort (int (*compare) (const void *elem1, const void *elem2, void *data))
{
if (m_nSize > 1)
NS_QuickSort(m_pData, m_nSize, sizeof(void*), compare ? compare : CompareDWord, nsnull);
}

View 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.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 _nsUInt32Array_H_
#define _nsUInt32Array_H_
#include "nscore.h"
#include "nsCRT.h"
#include "prmem.h"
#include "msgCore.h"
class NS_MSG_BASE nsUInt32Array
{
public:
// Construction/destruction
nsUInt32Array();
virtual ~nsUInt32Array();
// State/attribute member functions
PRUint32 GetSize() const;
PRBool SetSize(PRUint32 nNewSize, PRBool AdjustGrowth=PR_FALSE, PRUint32 nGrowBy = 0);
// Accessor member functions
PRUint32 &ElementAt(PRUint32 nIndex);
PRUint32 GetAt(PRUint32 nIndex) const;
PRUint32 *GetData();
void SetAt(PRUint32 nIndex, PRUint32 newElement);
// Insertion/deletion member functions
PRUint32 Add(PRUint32 newElement);
PRUint32 Add(PRUint32 *elementPtr, PRUint32 numElements);
void InsertAt(PRUint32 nIndex, PRUint32 newElement, PRUint32 nCount = 1);
void InsertAt(PRUint32 nStartIndex, const nsUInt32Array *pNewArray);
void RemoveAll();
void RemoveAt(PRUint32 nIndex, PRUint32 nCount = 1);
void SetAtGrow(PRUint32 nIndex, PRUint32 newElement);
// Sorting member functions
void QuickSort(int (*compare) (const void *elem1, const void *elem2, void *) = NULL);
// Overloaded operators
PRUint32 operator[](PRUint32 nIndex) const { return GetAt(nIndex); }
PRUint32 &operator[](PRUint32 nIndex) { return ElementAt(nIndex); }
// Miscellaneous member functions
PRUint32 *CloneData();
void CopyArray(nsUInt32Array *oldA);
void CopyArray(nsUInt32Array &oldA);
protected:
// Member data
PRUint32 m_nSize;
PRUint32 m_nMaxSize;
PRUint32 m_nGrowBy;
PRUint32* m_pData;
};
#endif // _DWordArray_H_

View File

@@ -1,617 +0,0 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsAVLTree.h"
enum eLean {eLeft,eNeutral,eRight};
struct NS_COM nsAVLNode {
public:
nsAVLNode(void* aValue) {
mLeft=0;
mRight=0;
mSkew=eNeutral;
mValue=aValue;
}
nsAVLNode* mLeft;
nsAVLNode* mRight;
eLean mSkew;
void* mValue;
};
/************************************************************
Now begin the tree class. Don't forget that the comparison
between nodes must occur via the comparitor function,
otherwise all you're testing is pointer addresses.
************************************************************/
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
nsAVLTree::nsAVLTree(nsAVLNodeComparitor& aComparitor,
nsAVLNodeFunctor* aDeallocator) :
mComparitor(aComparitor), mDeallocator(aDeallocator) {
mRoot=0;
mCount=0;
}
static void
avlDeleteTree(nsAVLNode* aNode){
if (aNode) {
avlDeleteTree(aNode->mLeft);
avlDeleteTree(aNode->mRight);
delete aNode;
}
}
/**
*
* @update gess12/27/98
* @param
* @return
*/
nsAVLTree::~nsAVLTree(){
if (mDeallocator) {
ForEachDepthFirst(*mDeallocator);
}
avlDeleteTree(mRoot);
}
class CDoesntExist: public nsAVLNodeFunctor {
public:
CDoesntExist(const nsAVLTree& anotherTree) : mOtherTree(anotherTree) {
}
virtual void* operator()(void* anItem) {
void* result=mOtherTree.FindItem(anItem);
if(result)
return nsnull;
return anItem;
}
protected:
const nsAVLTree& mOtherTree;
};
/**
* This method compares two trees (members by identity).
* @update gess12/27/98
* @param tree to compare against
* @return true if they are identical (contain same stuff).
*/
PRBool nsAVLTree::operator==(const nsAVLTree& aCopy) const{
CDoesntExist functor(aCopy);
void* theItem=FirstThat(functor);
PRBool result=PRBool(!theItem);
return result;
}
/**
*
* @update gess12/27/98
* @param
* @return
*/
static void
avlRotateRight(nsAVLNode*& aRootNode){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
ptr2=aRootNode->mRight;
if(ptr2->mSkew==eRight) {
aRootNode->mRight=ptr2->mLeft;
ptr2->mLeft=aRootNode;
aRootNode->mSkew=eNeutral;
aRootNode=ptr2;
}
else {
ptr3=ptr2->mLeft;
ptr2->mLeft=ptr3->mRight;
ptr3->mRight=ptr2;
aRootNode->mRight=ptr3->mLeft;
ptr3->mLeft=aRootNode;
if(ptr3->mSkew==eLeft)
ptr2->mSkew=eRight;
else ptr2->mSkew=eNeutral;
if(ptr3->mSkew==eRight)
aRootNode->mSkew=eLeft;
else aRootNode->mSkew=eNeutral;
aRootNode=ptr3;
}
aRootNode->mSkew=eNeutral;
return;
}
/**
*
* @update gess12/27/98
* @param
* @return
*/
static void
avlRotateLeft(nsAVLNode*& aRootNode){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
ptr2=aRootNode->mLeft;
if(ptr2->mSkew==eLeft) {
aRootNode->mLeft=ptr2->mRight;
ptr2->mRight=aRootNode;
aRootNode->mSkew=eNeutral;
aRootNode=ptr2;
}
else {
ptr3=ptr2->mRight;
ptr2->mRight=ptr3->mLeft;
ptr3->mLeft=ptr2;
aRootNode->mLeft=ptr3->mRight;
ptr3->mRight=aRootNode;
if(ptr3->mSkew==eRight)
ptr2->mSkew=eLeft;
else ptr2->mSkew=eNeutral;
if(ptr3->mSkew==eLeft)
aRootNode->mSkew=eRight;
else aRootNode->mSkew=eNeutral;
aRootNode=ptr3;
}
aRootNode->mSkew=eNeutral;
return;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static eAVLStatus
avlInsert(nsAVLNode*& aRootNode, nsAVLNode* aNewNode,
nsAVLNodeComparitor& aComparitor) {
eAVLStatus result=eAVL_unknown;
if(!aRootNode) {
aRootNode = aNewNode;
return eAVL_ok;
}
if(aNewNode==aRootNode->mValue) {
return eAVL_duplicate;
}
PRInt32 theCompareResult=aComparitor(aRootNode->mValue,aNewNode->mValue);
if(0 < theCompareResult) { //if(anItem<aRootNode->mValue)
result=avlInsert(aRootNode->mLeft,aNewNode,aComparitor);
if(eAVL_ok==result) {
switch(aRootNode->mSkew){
case eLeft:
avlRotateLeft(aRootNode);
result=eAVL_fail;
break;
case eRight:
aRootNode->mSkew=eNeutral;
result=eAVL_fail;
break;
case eNeutral:
aRootNode->mSkew=eLeft;
break;
} //switch
}//if
} //if
else {
result=avlInsert(aRootNode->mRight,aNewNode,aComparitor);
if(eAVL_ok==result) {
switch(aRootNode->mSkew){
case eLeft:
aRootNode->mSkew=eNeutral;
result=eAVL_fail;
break;
case eRight:
avlRotateRight(aRootNode);
result=eAVL_fail;
break;
case eNeutral:
aRootNode->mSkew=eRight;
break;
} //switch
}
} //if
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static void
avlBalanceLeft(nsAVLNode*& aRootNode, PRBool& delOk){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
eLean balnc2;
eLean balnc3;
switch(aRootNode->mSkew){
case eLeft:
ptr2=aRootNode->mLeft;
balnc2=ptr2->mSkew;
if(balnc2!=eRight) {
aRootNode->mLeft=ptr2->mRight;
ptr2->mRight=aRootNode;
if(balnc2==eNeutral){
aRootNode->mSkew=eLeft;
ptr2->mSkew=eRight;
delOk=PR_FALSE;
}
else{
aRootNode->mSkew=eNeutral;
ptr2->mSkew=eNeutral;
}
aRootNode=ptr2;
}
else{
ptr3=ptr2->mRight;
balnc3=ptr3->mSkew;
ptr2->mRight=ptr3->mLeft;
ptr3->mLeft=ptr2;
aRootNode->mLeft=ptr3->mRight;
ptr3->mRight=aRootNode;
if(balnc3==eRight) {
ptr2->mSkew=eLeft;
}
else {
ptr2->mSkew=eNeutral;
}
if(balnc3==eLeft) {
aRootNode->mSkew=eRight;
}
else {
aRootNode->mSkew=eNeutral;
}
aRootNode=ptr3;
ptr3->mSkew=eNeutral;
}
break;
case eRight:
aRootNode->mSkew=eNeutral;
break;
case eNeutral:
aRootNode->mSkew=eLeft;
delOk=PR_FALSE;
break;
}//switch
return;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static void
avlBalanceRight(nsAVLNode*& aRootNode, PRBool& delOk){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
eLean balnc2;
eLean balnc3;
switch(aRootNode->mSkew){
case eLeft:
aRootNode->mSkew=eNeutral;
break;
case eRight:
ptr2=aRootNode->mRight;
balnc2=ptr2->mSkew;
if(balnc2!=eLeft) {
aRootNode->mRight=ptr2->mLeft;
ptr2->mLeft=aRootNode;
if(balnc2==eNeutral){
aRootNode->mSkew=eRight;
ptr2->mSkew=eLeft;
delOk=PR_FALSE;
}
else{
aRootNode->mSkew=eNeutral;
ptr2->mSkew=eNeutral;
}
aRootNode=ptr2;
}
else{
ptr3=ptr2->mLeft;
balnc3=ptr3->mSkew;
ptr2->mLeft=ptr3->mRight;
ptr3->mRight=ptr2;
aRootNode->mRight=ptr3->mLeft;
ptr3->mLeft=aRootNode;
if(balnc3==eLeft) {
ptr2->mSkew=eRight;
}
else {
ptr2->mSkew=eNeutral;
}
if(balnc3==eRight) {
aRootNode->mSkew=eLeft;
}
else {
aRootNode->mSkew=eNeutral;
}
aRootNode=ptr3;
ptr3->mSkew=eNeutral;
}
break;
case eNeutral:
aRootNode->mSkew=eRight;
delOk=PR_FALSE;
break;
}//switch
return;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static eAVLStatus
avlRemoveChildren(nsAVLNode*& aRootNode,nsAVLNode*& anotherNode, PRBool& delOk){
eAVLStatus result=eAVL_ok;
if(!anotherNode->mRight){
aRootNode->mValue=anotherNode->mValue; //swap
anotherNode=anotherNode->mLeft;
delOk=PR_TRUE;
}
else{
avlRemoveChildren(aRootNode,anotherNode->mRight,delOk);
if(delOk)
avlBalanceLeft(anotherNode,delOk);
}
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static eAVLStatus
avlRemove(nsAVLNode*& aRootNode, void* anItem, PRBool& delOk,
nsAVLNodeComparitor& aComparitor){
eAVLStatus result=eAVL_ok;
if(!aRootNode)
delOk=PR_FALSE;
else {
PRInt32 cmp=aComparitor(anItem,aRootNode->mValue);
if(cmp<0){
avlRemove(aRootNode->mLeft,anItem,delOk,aComparitor);
if(delOk)
avlBalanceRight(aRootNode,delOk);
}
else if(cmp>0){
avlRemove(aRootNode->mRight,anItem,delOk,aComparitor);
if(delOk)
avlBalanceLeft(aRootNode,delOk);
}
else{ //they match...
nsAVLNode* temp=aRootNode;
if(!aRootNode->mRight) {
aRootNode=aRootNode->mLeft;
delOk=PR_TRUE;
delete temp;
}
else if(!aRootNode->mLeft) {
aRootNode=aRootNode->mRight;
delOk=PR_TRUE;
delete temp;
}
else {
avlRemoveChildren(aRootNode,aRootNode->mLeft,delOk);
if(delOk)
avlBalanceRight(aRootNode,delOk);
}
}
}
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
eAVLStatus
nsAVLTree::AddItem(void* anItem){
eAVLStatus result=eAVL_ok;
nsAVLNode* theNewNode=new nsAVLNode(anItem);
result=avlInsert(mRoot,theNewNode,mComparitor);
if(eAVL_duplicate!=result)
mCount++;
else {
delete theNewNode;
}
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
void* nsAVLTree::FindItem(void* aValue) const{
nsAVLNode* result=mRoot;
PRInt32 count=0;
while(result) {
count++;
PRInt32 cmp=mComparitor(aValue,result->mValue);
if(0==cmp) {
//we matched...
break;
}
else if(0>cmp){
//theNode was greater...
result=result->mLeft;
}
else {
//aValue is greater...
result=result->mRight;
}
}
if(result) {
return result->mValue;
}
return nsnull;
}
/**
*
* @update gess12/30/98
* @param
* @return
*/
eAVLStatus
nsAVLTree::RemoveItem(void* aValue){
PRBool delOk=PR_TRUE;
eAVLStatus result=avlRemove(mRoot,aValue,delOk,mComparitor);
if(eAVL_ok==result)
mCount--;
return result;
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
static void
avlForEachDepthFirst(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor){
if(aNode) {
avlForEachDepthFirst(aNode->mLeft,aFunctor);
avlForEachDepthFirst(aNode->mRight,aFunctor);
aFunctor(aNode->mValue);
}
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
void
nsAVLTree::ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const{
::avlForEachDepthFirst(mRoot,aFunctor);
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
static void
avlForEach(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
if(aNode) {
avlForEach(aNode->mLeft,aFunctor);
aFunctor(aNode->mValue);
avlForEach(aNode->mRight,aFunctor);
}
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
void
nsAVLTree::ForEach(nsAVLNodeFunctor& aFunctor) const{
::avlForEach(mRoot,aFunctor);
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
static void*
avlFirstThat(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
void* result=nsnull;
if(aNode) {
result = avlFirstThat(aNode->mLeft,aFunctor);
if (result) {
return result;
}
result = aFunctor(aNode->mValue);
if (result) {
return result;
}
result = avlFirstThat(aNode->mRight,aFunctor);
}
return result;
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
void*
nsAVLTree::FirstThat(nsAVLNodeFunctor& aFunctor) const{
return ::avlFirstThat(mRoot,aFunctor);
}

View File

@@ -1,74 +0,0 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsAVLTree_h___
#define nsAVLTree_h___
#include "nscore.h"
enum eAVLStatus {eAVL_unknown,eAVL_ok,eAVL_fail,eAVL_duplicate};
struct nsAVLNode;
/**
*
* @update gess12/26/98
* @param anObject1 is the first object to be compared
* @param anObject2 is the second object to be compared
* @return -1,0,1 if object1 is less, equal, greater than object2
*/
class NS_COM nsAVLNodeComparitor {
public:
virtual PRInt32 operator()(void* anItem1,void* anItem2)=0;
};
class NS_COM nsAVLNodeFunctor {
public:
virtual void* operator()(void* anItem)=0;
};
class NS_COM nsAVLTree {
public:
nsAVLTree(nsAVLNodeComparitor& aComparitor, nsAVLNodeFunctor* aDeallocator);
~nsAVLTree(void);
PRBool operator==(const nsAVLTree& aOther) const;
PRInt32 GetCount(void) const {return mCount;}
//main functions...
eAVLStatus AddItem(void* anItem);
eAVLStatus RemoveItem(void* anItem);
void* FindItem(void* anItem) const;
void ForEach(nsAVLNodeFunctor& aFunctor) const;
void ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const;
void* FirstThat(nsAVLNodeFunctor& aFunctor) const;
protected:
nsAVLNode* mRoot;
PRInt32 mCount;
nsAVLNodeComparitor& mComparitor;
nsAVLNodeFunctor* mDeallocator;
};
#endif /* nsAVLTree_h___ */

View File

@@ -1,717 +0,0 @@
/* -*- 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.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.
*/
/******************************************************************************************
MODULE NOTES:
This file contains the nsStr data structure.
This general purpose buffer management class is used as the basis for our strings.
It's benefits include:
1. An efficient set of library style functions for manipulating nsStrs
2. Support for 1 and 2 byte character strings (which can easily be increased to n)
3. Unicode awareness and interoperability.
*******************************************************************************************/
#include "nsStr.h"
#include "bufferRoutines.h"
#include "stdio.h" //only used for printf
#include "nsCRT.h"
#include "nsDeque.h"
//static const char* kCallFindChar = "For better performance, call FindChar() for targets whose length==1.";
//static const char* kCallRFindChar = "For better performance, call RFindChar() for targets whose length==1.";
static const PRUnichar gCommonEmptyBuffer[1] = {0};
/**
* This method initializes all the members of the nsStr structure
*
* @update gess10/30/98
* @param
* @return
*/
void nsStr::Initialize(nsStr& aDest,eCharSize aCharSize) {
aDest.mStr=(char*)gCommonEmptyBuffer;
aDest.mLength=0;
aDest.mCapacity=0;
aDest.mCharSize=aCharSize;
aDest.mOwnsBuffer=0;
}
/**
* This method initializes all the members of the nsStr structure
* @update gess10/30/98
* @param
* @return
*/
void nsStr::Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer){
aDest.mStr=(aCString) ? aCString : (char*)gCommonEmptyBuffer;
aDest.mLength=aLength;
aDest.mCapacity=aCapacity;
aDest.mCharSize=aCharSize;
aDest.mOwnsBuffer=aOwnsBuffer;
}
/**
* This member destroys the memory buffer owned by an nsStr object (if it actually owns it)
* @update gess10/30/98
* @param
* @return
*/
void nsStr::Destroy(nsStr& aDest) {
if((aDest.mStr) && (aDest.mStr!=(char*)gCommonEmptyBuffer)) {
Free(aDest);
}
}
/**
* This method gets called when the internal buffer needs
* to grow to a given size. The original contents are not preserved.
* @update gess 3/30/98
* @param aNewLength -- new capacity of string in charSize units
* @return void
*/
PRBool nsStr::EnsureCapacity(nsStr& aString,PRUint32 aNewLength) {
PRBool result=PR_TRUE;
if(aNewLength>aString.mCapacity) {
result=Realloc(aString,aNewLength);
if(aString.mStr)
AddNullTerminator(aString);
}
return result;
}
/**
* This method gets called when the internal buffer needs
* to grow to a given size. The original contents ARE preserved.
* @update gess 3/30/98
* @param aNewLength -- new capacity of string in charSize units
* @return void
*/
PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
PRBool result=PR_TRUE;
if(aNewLength>aDest.mCapacity) {
nsStr theTempStr;
nsStr::Initialize(theTempStr,aDest.mCharSize);
result=EnsureCapacity(theTempStr,aNewLength);
if(result) {
if(aDest.mLength) {
Append(theTempStr,aDest,0,aDest.mLength);
}
Free(aDest);
aDest.mStr = theTempStr.mStr;
theTempStr.mStr=0; //make sure to null this out so that you don't lose the buffer you just stole...
aDest.mLength=theTempStr.mLength;
aDest.mCapacity=theTempStr.mCapacity;
aDest.mOwnsBuffer=theTempStr.mOwnsBuffer;
}
}
return result;
}
/**
* Replaces the contents of aDest with aSource, up to aCount of chars.
* @update gess10/30/98
* @param aDest is the nsStr that gets changed.
* @param aSource is where chars are copied from
* @param aCount is the number of chars copied from aSource
*/
void nsStr::Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
if(&aDest!=&aSource){
Truncate(aDest,0);
Append(aDest,aSource,anOffset,aCount);
}
}
/**
* This method appends the given nsStr to this one. Note that we have to
* pay attention to the underlying char-size of both structs.
* @update gess10/30/98
* @param aDest is the nsStr to be manipulated
* @param aSource is where char are copied from
* @aCount is the number of bytes to be copied
*/
void nsStr::Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
if(anOffset<aSource.mLength){
PRUint32 theRealLen=(aCount<0) ? aSource.mLength : MinInt(aCount,aSource.mLength);
PRUint32 theLength=(anOffset+theRealLen<aSource.mLength) ? theRealLen : (aSource.mLength-anOffset);
if(0<theLength){
PRBool isBigEnough=PR_TRUE;
if(aDest.mLength+theLength > aDest.mCapacity) {
isBigEnough=GrowCapacity(aDest,aDest.mLength+theLength);
}
if(isBigEnough) {
//now append new chars, starting at offset
(*gCopyChars[aSource.mCharSize][aDest.mCharSize])(aDest.mStr,aDest.mLength,aSource.mStr,anOffset,theLength);
aDest.mLength+=theLength;
AddNullTerminator(aDest);
}
}
}
}
/**
* This method inserts up to "aCount" chars from a source nsStr into a dest nsStr.
* @update gess10/30/98
* @param aDest is the nsStr that gets changed
* @param aDestOffset is where in aDest the insertion is to occur
* @param aSource is where chars are copied from
* @param aSrcOffset is where in aSource chars are copied from
* @param aCount is the number of chars from aSource to be inserted into aDest
*/
void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount){
//there are a few cases for insert:
// 1. You're inserting chars into an empty string (assign)
// 2. You're inserting onto the end of a string (append)
// 3. You're inserting onto the 1..n-1 pos of a string (the hard case).
if(0<aSource.mLength){
if(aDest.mLength){
if(aDestOffset<aDest.mLength){
PRInt32 theRealLen=(aCount<0) ? aSource.mLength : MinInt(aCount,aSource.mLength);
PRInt32 theLength=(aSrcOffset+theRealLen<aSource.mLength) ? theRealLen : (aSource.mLength-aSrcOffset);
if(aSrcOffset<aSource.mLength) {
//here's the only new case we have to handle.
//chars are really being inserted into our buffer...
if(aDest.mLength+theLength > aDest.mCapacity) {
nsStr theTempStr;
nsStr::Initialize(theTempStr,aDest.mCharSize);
PRBool isBigEnough=EnsureCapacity(theTempStr,aDest.mLength+theLength); //grow the temp buffer to the right size
if(isBigEnough) {
if(aDestOffset) {
Append(theTempStr,aDest,0,aDestOffset); //first copy leftmost data...
}
Append(theTempStr,aSource,0,aSource.mLength); //next copy inserted (new) data
PRUint32 theRemains=aDest.mLength-aDestOffset;
if(theRemains) {
Append(theTempStr,aDest,aDestOffset,theRemains); //next copy rightmost data
}
Free(aDest);
aDest.mStr = theTempStr.mStr;
theTempStr.mStr=0; //make sure to null this out so that you don't lose the buffer you just stole...
aDest.mCapacity=theTempStr.mCapacity;
aDest.mOwnsBuffer=theTempStr.mOwnsBuffer;
}
}
else {
//shift the chars right by theDelta...
(*gShiftChars[aDest.mCharSize][KSHIFTRIGHT])(aDest.mStr,aDest.mLength,aDestOffset,theLength);
//now insert new chars, starting at offset
(*gCopyChars[aSource.mCharSize][aDest.mCharSize])(aDest.mStr,aDestOffset,aSource.mStr,aSrcOffset,theLength);
}
//finally, make sure to update the string length...
aDest.mLength+=theLength;
AddNullTerminator(aDest);
}//if
//else nothing to do!
}
else Append(aDest,aSource,0,aCount);
}
else Append(aDest,aSource,0,aCount);
}
}
/**
* This method deletes up to aCount chars from aDest
* @update gess10/30/98
* @param aDest is the nsStr to be manipulated
* @param aDestOffset is where in aDest deletion is to occur
* @param aCount is the number of chars to be deleted in aDest
*/
void nsStr::Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount){
if(aDestOffset<aDest.mLength){
PRUint32 theDelta=aDest.mLength-aDestOffset;
PRUint32 theLength=(theDelta<aCount) ? theDelta : aCount;
if(aDestOffset+theLength<aDest.mLength) {
//if you're here, it means we're cutting chars out of the middle of the string...
//so shift the chars left by theLength...
(*gShiftChars[aDest.mCharSize][KSHIFTLEFT])(aDest.mStr,aDest.mLength,aDestOffset,theLength);
aDest.mLength-=theLength;
AddNullTerminator(aDest);
}
else Truncate(aDest,aDestOffset);
}//if
}
/**
* This method truncates the given nsStr at given offset
* @update gess10/30/98
* @param aDest is the nsStr to be truncated
* @param aDestOffset is where in aDest truncation is to occur
*/
void nsStr::Truncate(nsStr& aDest,PRUint32 aDestOffset){
if(aDestOffset<aDest.mLength){
aDest.mLength=aDestOffset;
AddNullTerminator(aDest);
}
}
/**
* This method forces the given string to upper or lowercase
* @update gess1/7/99
* @param aDest is the string you're going to change
* @param aToUpper: if TRUE, then we go uppercase, otherwise we go lowercase
* @return
*/
void nsStr::ChangeCase(nsStr& aDest,PRBool aToUpper) {
// somehow UnicharUtil return failed, fallback to the old ascii only code
gCaseConverters[aDest.mCharSize](aDest.mStr,aDest.mLength,aToUpper);
}
/**
*
* @update gess1/7/99
* @param
* @return
*/
void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){
if((aDest.mLength>0) && aSet){
PRInt32 theIndex=-1;
PRInt32 theMax=aDest.mLength;
PRInt32 theSetLen=nsCRT::strlen(aSet);
if(aEliminateLeading) {
while(++theIndex<=theMax) {
PRUnichar theChar=GetCharAt(aDest,theIndex);
PRInt32 thePos=gFindChars[eOneByte](aSet,theSetLen,0,theChar,PR_FALSE);
if(kNotFound==thePos)
break;
}
if(0<theIndex) {
if(theIndex<theMax) {
Delete(aDest,0,theIndex);
}
else Truncate(aDest,0);
}
}
if(aEliminateTrailing) {
theIndex=aDest.mLength;
PRInt32 theNewLen=theIndex;
while(--theIndex>0) {
PRUnichar theChar=GetCharAt(aDest,theIndex); //read at end now...
PRInt32 thePos=gFindChars[eOneByte](aSet,theSetLen,0,theChar,PR_FALSE);
if(kNotFound<thePos)
theNewLen=theIndex;
else break;
}
if(theNewLen<theMax) {
Truncate(aDest,theNewLen);
}
}
}
}
/**
*
* @update gess1/7/99
* @param
* @return
*/
void nsStr::CompressSet(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){
Trim(aDest,aSet,aEliminateLeading,aEliminateTrailing);
PRUint32 aNewLen=gCompressChars[aDest.mCharSize](aDest.mStr,aDest.mLength,aSet);
aDest.mLength=aNewLen;
}
/**
*
* @update gess1/7/99
* @param
* @return
*/
void nsStr::StripChars(nsStr& aDest,const char* aSet){
if((0<aDest.mLength) && (aSet)) {
PRUint32 aNewLen=gStripChars[aDest.mCharSize](aDest.mStr,aDest.mLength,aSet);
aDest.mLength=aNewLen;
}
}
/**************************************************************
Searching methods...
**************************************************************/
/**
* This searches aDest for a given substring
*
* @update gess 3/25/98
* @param aDest string to search
* @param aTarget is the substring you're trying to find.
* @param aIgnorecase indicates case sensitivity of search
* @param anOffset tells us where to start the search
* @return index in aDest where member of aSet occurs, or -1 if not found
*/
PRInt32 nsStr::FindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset) {
// NS_PRECONDITION(aTarget.mLength!=1,kCallFindChar);
PRInt32 result=kNotFound;
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
PRInt32 theMax=aDest.mLength-aTarget.mLength;
PRInt32 index=(0<=anOffset) ? anOffset : 0;
if((aDest.mLength>=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){
PRInt32 theTargetMax=aTarget.mLength;
while(index<=theMax) {
PRInt32 theSubIndex=-1;
PRBool matches=PR_TRUE;
while((++theSubIndex<theTargetMax) && (matches)){
PRUnichar theChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aDest,index+theSubIndex)) : GetCharAt(aDest,index+theSubIndex);
PRUnichar theTargetChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aTarget,theSubIndex)) : GetCharAt(aTarget,theSubIndex);
matches=PRBool(theChar==theTargetChar);
}
if(matches) {
result=index;
break;
}
index++;
} //while
}//if
}//if
return result;
}
/**
* This searches aDest for a given character
*
* @update gess 3/25/98
* @param aDest string to search
* @param char is the character you're trying to find.
* @param aIgnorecase indicates case sensitivity of search
* @param anOffset tells us where to start the search
* @return index in aDest where member of aSet occurs, or -1 if not found
*/
PRInt32 nsStr::FindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset) {
PRInt32 result=kNotFound;
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
PRUint32 index=(0<=anOffset) ? (PRUint32)anOffset : 0;
result=gFindChars[aDest.mCharSize](aDest.mStr,aDest.mLength,index,aChar,aIgnoreCase);
}
return result;
}
/**
* This searches aDest for a character found in aSet.
*
* @update gess 3/25/98
* @param aDest string to search
* @param aSet contains a list of chars to be searched for
* @param aIgnorecase indicates case sensitivity of search
* @param anOffset tells us where to start the search
* @return index in aDest where member of aSet occurs, or -1 if not found
*/
PRInt32 nsStr::FindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset) {
//NS_PRECONDITION(aSet.mLength!=1,kCallFindChar);
PRInt32 index=(0<=anOffset) ? anOffset-1 : -1;
PRInt32 thePos;
//Note that the search is inverted here. We're scanning aDest, one char at a time
//but doing the search against the given set. That's why we use 0 as the offset below.
if((0<aDest.mLength) && (0<aSet.mLength)){
while(++index<(PRInt32)aDest.mLength) {
PRUnichar theChar=GetCharAt(aDest,index);
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
if(kNotFound!=thePos)
return index;
} //while
}
return kNotFound;
}
/**************************************************************
Reverse Searching methods...
**************************************************************/
/**
* This searches aDest (in reverse) for a given substring
*
* @update gess 3/25/98
* @param aDest string to search
* @param aTarget is the substring you're trying to find.
* @param aIgnorecase indicates case sensitivity of search
* @param anOffset tells us where to start the search (counting from left)
* @return index in aDest where member of aSet occurs, or -1 if not found
*/
PRInt32 nsStr::RFindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset) {
//NS_PRECONDITION(aTarget.mLength!=1,kCallRFindChar);
PRInt32 result=kNotFound;
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
PRInt32 index=(0<=anOffset) ? anOffset : aDest.mLength-1;
if((aDest.mLength>=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){
nsStr theCopy;
nsStr::Initialize(theCopy,eOneByte);
nsStr::Assign(theCopy,aTarget,0,aTarget.mLength);
if(aIgnoreCase){
nsStr::ChangeCase(theCopy,PR_FALSE); //force to lowercase
}
PRInt32 theTargetMax=theCopy.mLength;
while(index>=0) {
PRInt32 theSubIndex=-1;
PRBool matches=PR_FALSE;
if(index+theCopy.mLength<=aDest.mLength) {
matches=PR_TRUE;
while((++theSubIndex<theTargetMax) && (matches)){
PRUnichar theDestChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aDest,index+theSubIndex)) : GetCharAt(aDest,index+theSubIndex);
PRUnichar theTargetChar=GetCharAt(theCopy,theSubIndex);
matches=PRBool(theDestChar==theTargetChar);
} //while
} //if
if(matches) {
result=index;
break;
}
index--;
} //while
nsStr::Destroy(theCopy);
}//if
}//if
return result;
}
/**
* This searches aDest (in reverse) for a given character
*
* @update gess 3/25/98
* @param aDest string to search
* @param char is the character you're trying to find.
* @param aIgnorecase indicates case sensitivity of search
* @param anOffset tells us where to start the search
* @return index in aDest where member of aSet occurs, or -1 if not found
*/
PRInt32 nsStr::RFindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset) {
PRInt32 result=kNotFound;
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
PRUint32 index=(0<=anOffset) ? anOffset : aDest.mLength-1;
result=gRFindChars[aDest.mCharSize](aDest.mStr,aDest.mLength,index,aChar,aIgnoreCase);
}
return result;
}
/**
* This searches aDest (in reverese) for a character found in aSet.
*
* @update gess 3/25/98
* @param aDest string to search
* @param aSet contains a list of chars to be searched for
* @param aIgnorecase indicates case sensitivity of search
* @param anOffset tells us where to start the search
* @return index in aDest where member of aSet occurs, or -1 if not found
*/
PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset) {
//NS_PRECONDITION(aSet.mLength!=1,kCallRFindChar);
PRInt32 index=(0<=anOffset) ? anOffset : aDest.mLength;
PRInt32 thePos;
//note that the search is inverted here. We're scanning aDest, one char at a time
//but doing the search against the given set. That's why we use 0 as the offset below.
if(0<aDest.mLength) {
while(--index>=0) {
PRUnichar theChar=GetCharAt(aDest,index);
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
if(kNotFound!=thePos)
return index;
} //while
}
return kNotFound;
}
/**
* Compare source and dest strings, up to an (optional max) number of chars
* @param aDest is the first str to compare
* @param aSource is the second str to compare
* @param aCount -- if (-1), then we use length of longer string; if (0<aCount) then it gives the max # of chars to compare
* @param aIgnorecase tells us whether to search with case sensitivity
* @return aDest<aSource=-1;aDest==aSource==0;aDest>aSource=1
*/
PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
PRInt32 result=0;
if(aCount) {
PRInt32 minlen=(aSource.mLength<aDest.mLength) ? aSource.mLength : aDest.mLength;
if(0==minlen) {
if ((aDest.mLength == 0) && (aSource.mLength == 0))
return 0;
if (aDest.mLength == 0)
return -1;
return 1;
}
PRInt32 maxlen=(aSource.mLength<aDest.mLength) ? aDest.mLength : aSource.mLength;
aCount = (aCount<0) ? maxlen : MinInt(aCount,maxlen);
result=(*gCompare[aDest.mCharSize][aSource.mCharSize])(aDest.mStr,aSource.mStr,aCount,aIgnoreCase);
}
return result;
}
//----------------------------------------------------------------------------------------
PRBool nsStr::Alloc(nsStr& aDest,PRUint32 aCount) {
static int mAllocCount=0;
mAllocCount++;
//we're given the acount value in charunits; now scale up to next multiple.
PRUint32 theNewCapacity=kDefaultStringSize;
while(theNewCapacity<aCount){
theNewCapacity<<=1;
}
aDest.mCapacity=theNewCapacity++;
PRUint32 theSize=(theNewCapacity<<aDest.mCharSize);
aDest.mStr = (char*)nsAllocator::Alloc(theSize);
PRBool result=PR_FALSE;
if(aDest.mStr) {
aDest.mOwnsBuffer=1;
result=PR_TRUE;
}
return result;
}
PRBool nsStr::Free(nsStr& aDest){
if(aDest.mStr){
if(aDest.mOwnsBuffer){
nsAllocator::Free(aDest.mStr);
}
aDest.mStr=0;
aDest.mOwnsBuffer=0;
return PR_TRUE;
}
return PR_FALSE;
}
PRBool nsStr::Realloc(nsStr& aDest,PRUint32 aCount){
nsStr temp;
memcpy(&temp,&aDest,sizeof(aDest));
PRBool result=Alloc(temp,aCount);
if(result) {
Free(aDest);
aDest.mStr=temp.mStr;
aDest.mCapacity=temp.mCapacity;
aDest.mOwnsBuffer=temp.mOwnsBuffer;
}
return result;
}
//----------------------------------------------------------------------------------------
CBufDescriptor::CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
mBuffer=aString;
mCharSize=eOneByte;
mStackBased=aStackBased;
mIsConst=PR_FALSE;
mLength=mCapacity=0;
if(aString && aCapacity>1) {
mCapacity=aCapacity-1;
mLength=(-1==aLength) ? strlen(aString) : aLength;
if(mLength>PRInt32(mCapacity))
mLength=mCapacity;
}
}
CBufDescriptor::CBufDescriptor(const char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
mBuffer=(char*)aString;
mCharSize=eOneByte;
mStackBased=aStackBased;
mIsConst=PR_TRUE;
mLength=mCapacity=0;
if(aString && aCapacity>1) {
mCapacity=aCapacity-1;
mLength=(-1==aLength) ? strlen(aString) : aLength;
if(mLength>PRInt32(mCapacity))
mLength=mCapacity;
}
}
CBufDescriptor::CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
mBuffer=(char*)aString;
mCharSize=eTwoByte;
mStackBased=aStackBased;
mLength=mCapacity=0;
mIsConst=PR_FALSE;
if(aString && aCapacity>1) {
mCapacity=aCapacity-1;
mLength=(-1==aLength) ? nsCRT::strlen(aString) : aLength;
if(mLength>PRInt32(mCapacity))
mLength=mCapacity;
}
}
CBufDescriptor::CBufDescriptor(const PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
mBuffer=(char*)aString;
mCharSize=eTwoByte;
mStackBased=aStackBased;
mLength=mCapacity=0;
mIsConst=PR_TRUE;
if(aString && aCapacity>1) {
mCapacity=aCapacity-1;
mLength=(-1==aLength) ? nsCRT::strlen(aString) : aLength;
if(mLength>PRInt32(mCapacity))
mLength=mCapacity;
}
}
//----------------------------------------------------------------------------------------

View File

@@ -1,450 +0,0 @@
/* -*- 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.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.
*/
/***********************************************************************
MODULE NOTES:
1. There are two philosophies to building string classes:
A. Hide the underlying buffer & offer API's allow indirect iteration
B. Reveal underlying buffer, risk corruption, but gain performance
We chose the option B for performance reasons.
2 Our internal buffer always holds capacity+1 bytes.
The nsStr struct is a simple structure (no methods) that contains
the necessary info to be described as a string. This simple struct
is manipulated by the static methods provided in this class.
(Which effectively makes this a library that works on structs).
There are also object-based versions called nsString and nsAutoString
which use nsStr but makes it look at feel like an object.
***********************************************************************/
/***********************************************************************
ASSUMPTIONS:
1. nsStrings and nsAutoString are always null terminated.
2. If you try to set a null char (via SetChar()) a new length is set
3. nsCStrings can be upsampled into nsString without data loss
4. Char searching is faster than string searching. Use char interfaces
if your needs will allow it.
5. It's easy to use the stack for nsAutostring buffer storage (fast too!).
See the CBufDescriptor class in this file.
6. It's ONLY ok to provide non-null-terminated buffers to Append() and Insert()
provided you specify a 0<n value for the optional count argument.
7. Downsampling from nsString to nsCString is lossy -- avoid it if possible!
8. Calls to ToNewCString() and ToNewUnicode() should be matched with calls to Recycle().
***********************************************************************/
/**********************************************************************************
AND NOW FOR SOME GENERAL DOCUMENTATION ON STRING USAGE...
The fundamental datatype in the string library is nsStr. It's a structure that
provides the buffer storage and meta-info. It also provides a C-style library
of functions for direct manipulation (for those of you who prefer K&R to Bjarne).
Here's a diagram of the class hierarchy:
nsStr
|___nsString
| |
| ------nsAutoString
|
|___nsCString
|
------nsCAutoString
Why so many string classes? The 4 variants give you the control you need to
determine the best class for your purpose. There are 2 dimensions to this
flexibility: 1) stack vs. heap; and 2) 1-byte chars vs. 2-byte chars.
Note: While nsAutoString and nsCAutoString begin life using stack-based storage,
they may not stay that way. Like all nsString classes, autostrings will
automatically grow to contain the data you provide. When autostrings
grow beyond their intrinsic buffer, they switch to heap based allocations.
(We avoid alloca to avoid considerable platform difficulties; see the
GNU documentation for more details).
I should also briefly mention that all the string classes use a "memory agent"
object to perform memory operations. This class proxies the standard nsAllocator
for actual memory calls, but knows the structure of nsStr making heap operations
more localized.
CHOOSING A STRING CLASS:
In order to choose a string class for you purpose, use this handy table:
heap-based stack-based
-----------------------------------
ascii data | nsCString nsCAutoString |
|----------------------------------
unicode data | nsString nsAutoString |
-----------------------------------
Note: The i18n folks will stenuously object if we get too carried away with the
use of nsCString's that pass interface boundaries. Try to limit your
use of these to external interfaces that demand them, or for your own
private purposes in cases where they'll never be seen by humans.
PERFORMANCE CONSIDERATIONS:
Here are a few tricks to know in order to get better string performance:
1) Try to limit conversions between ascii and unicode; By sticking with nsString
wherever possible your code will be i18n-compliant.
2) Preallocating your string buffer cuts down trips to the allocator. So if you
have need for an arbitrarily large buffer, pre-size it like this:
{
nsString mBuffer;
mBuffer.SetCapacity(aReasonableSize);
}
3) Allocating nsAutoString or nsCAutoString on the heap is memory inefficient
(after all, the whole point is to avoid a heap allocation of the buffer).
4) Consider using an autoString to write into your arbitrarily-sized stack buffers, rather
than it's own buffers.
For example, let's say you're going to call printf() to emit pretty-printed debug output
of your object. You know from experience that the pretty-printed version of your object
exceeds the capacity of an autostring. Ignoring memory considerations, you could simply
use nsCString, appending the stringized version of each of your class's data members.
This will probably result in calls to the heap manager.
But there's a way to do this without necessarily having to call the heap manager.
All you do is declare a stack based buffer and instruct nsCString to use that instead
of it's own internal buffer by using the CBufDescriptor class:
{
char theBuffer[256];
CBufDescritor theBufDecriptor( theBuffer, PR_TRUE, sizeof(theBuffer), 0);
nsCAutoString s3( theBufDescriptor );
s3="HELLO, my name is inigo montoya, you killed my father, prepare to die!.";
}
The assignment statment to s3 will cause the given string to be written to your
stack-based buffer via the normal nsString/nsCString interfaces. Cool, huh?
Note however that just like any other nsStringXXX use, if you write more data
than will fit in the buffer, a visit to the heap manager will be in order.
**********************************************************************************/
#ifndef _nsStr
#define _nsStr
#include "nscore.h"
#include "nsIAllocator.h"
#include <string.h>
//----------------------------------------------------------------------------------------
enum eCharSize {eOneByte=0,eTwoByte=1};
#define kDefaultCharSize eTwoByte
#define kRadix10 (10)
#define kRadix16 (16)
#define kAutoDetect (100)
#define kRadixUnknown (kAutoDetect+1)
const PRInt32 kDefaultStringSize = 64;
const PRInt32 kNotFound = -1;
//----------------------------------------------------------------------------------------
class NS_COM CBufDescriptor {
public:
CBufDescriptor(char* aString, PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CBufDescriptor(const char* aString, PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CBufDescriptor(PRUnichar* aString, PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CBufDescriptor(const PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
char* mBuffer;
eCharSize mCharSize;
PRUint32 mCapacity;
PRInt32 mLength;
PRBool mStackBased;
PRBool mIsConst;
};
//----------------------------------------------------------------------------------------
struct NS_COM nsStr {
//----------------------------------------------------------------------------------------
nsStr() {
MOZ_COUNT_CTOR(nsStr);
}
~nsStr() {
MOZ_COUNT_DTOR(nsStr);
}
/**
* This method initializes an nsStr for use
*
* @update gess 01/04/99
* @param aString is the nsStr to be initialized
* @param aCharSize tells us the requested char size (1 or 2 bytes)
*/
static void Initialize(nsStr& aDest,eCharSize aCharSize);
/**
* This method initializes an nsStr for use
*
* @update gess 01/04/99
* @param aString is the nsStr to be initialized
* @param aCharSize tells us the requested char size (1 or 2 bytes)
*/
static void Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer);
/**
* This method destroys the given nsStr, and *MAY*
* deallocate it's memory depending on the setting
* of the internal mOwnsBUffer flag.
*
* @update gess 01/04/99
* @param aString is the nsStr to be manipulated
* @param anAgent is the allocator to be used to the nsStr
*/
static void Destroy(nsStr& aDest);
/**
* These methods are where memory allocation/reallocation occur.
*
* @update gess 01/04/99
* @param aString is the nsStr to be manipulated
* @param anAgent is the allocator to be used on the nsStr
* @return
*/
static PRBool EnsureCapacity(nsStr& aString,PRUint32 aNewLength);
static PRBool GrowCapacity(nsStr& aString,PRUint32 aNewLength);
/**
* These methods are used to append content to the given nsStr
*
* @update gess 01/04/99
* @param aDest is the nsStr to be appended to
* @param aSource is the buffer to be copied from
* @param anOffset tells us where in source to start copying
* @param aCount tells us the (max) # of chars to copy
* @param anAgent is the allocator to be used for alloc/free operations
*/
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
/**
* These methods are used to assign contents of a source string to dest string
*
* @update gess 01/04/99
* @param aDest is the nsStr to be appended to
* @param aSource is the buffer to be copied from
* @param anOffset tells us where in source to start copying
* @param aCount tells us the (max) # of chars to copy
* @param anAgent is the allocator to be used for alloc/free operations
*/
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
/**
* These methods are used to insert content from source string to the dest nsStr
*
* @update gess 01/04/99
* @param aDest is the nsStr to be appended to
* @param aDestOffset tells us where in dest to start insertion
* @param aSource is the buffer to be copied from
* @param aSrcOffset tells us where in source to start copying
* @param aCount tells us the (max) # of chars to insert
* @param anAgent is the allocator to be used for alloc/free operations
*/
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount);
/**
* This method deletes chars from the given str.
* The given allocator may choose to resize the str as well.
*
* @update gess 01/04/99
* @param aDest is the nsStr to be deleted from
* @param aDestOffset tells us where in dest to start deleting
* @param aCount tells us the (max) # of chars to delete
* @param anAgent is the allocator to be used for alloc/free operations
*/
static void Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount);
/**
* This method is used to truncate the given string.
* The given allocator may choose to resize the str as well (but it's not likely).
*
* @update gess 01/04/99
* @param aDest is the nsStr to be appended to
* @param aDestOffset tells us where in dest to start insertion
* @param aSource is the buffer to be copied from
* @param aSrcOffset tells us where in source to start copying
* @param anAgent is the allocator to be used for alloc/free operations
*/
static void Truncate(nsStr& aDest,PRUint32 aDestOffset);
/**
* This method is used to perform a case conversion on the given string
*
* @update gess 01/04/99
* @param aDest is the nsStr to be case shifted
* @param toUpper tells us to go upper vs. lower
*/
static void ChangeCase(nsStr& aDest,PRBool aToUpper);
/**
* This method trims chars (given in aSet) from the edges of given buffer
*
* @update gess 01/04/99
* @param aDest is the buffer to be manipulated
* @param aSet tells us which chars to remove from given buffer
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
*/
static void Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing);
/**
* This method compresses duplicate runs of a given char from the given buffer
*
* @update gess 01/04/99
* @param aDest is the buffer to be manipulated
* @param aSet tells us which chars to compress from given buffer
* @param aChar is the replacement char
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
*/
static void CompressSet(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing);
/**
* This method removes all occurances of chars in given set from aDest
*
* @update gess 01/04/99
* @param aDest is the buffer to be manipulated
* @param aSet tells us which chars to compress from given buffer
* @param aChar is the replacement char
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
*/
static void StripChars(nsStr& aDest,const char* aSet);
/**
* This method compares the data bewteen two nsStr's
*
* @update gess 01/04/99
* @param aStr1 is the first buffer to be compared
* @param aStr2 is the 2nd buffer to be compared
* @param aCount is the number of chars to compare
* @param aIgnorecase tells us whether to use a case-sensitive comparison
* @return -1,0,1 depending on <,==,>
*/
static PRInt32 Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase);
/**
* These methods scan the given string for 1 or more chars in a given direction
*
* @update gess 01/04/99
* @param aDest is the nsStr to be searched to
* @param aSource (or aChar) is the substr we're looking to find
* @param aIgnoreCase tells us whether to search in a case-sensitive manner
* @param anOffset tells us where in the dest string to start searching
* @return the index of the source (substr) in dest, or -1 (kNotFound) if not found.
*/
static PRInt32 FindSubstr(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset);
static PRInt32 FindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset);
static PRInt32 FindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
static PRInt32 RFindSubstr(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset);
static PRInt32 RFindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset);
static PRInt32 RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
PRUint32 mLength;
PRUint32 mCapacity;
eCharSize mCharSize;
PRBool mOwnsBuffer;
union {
char* mStr;
PRUnichar* mUStr;
};
private:
static PRBool Alloc(nsStr& aString,PRUint32 aCount);
static PRBool Realloc(nsStr& aString,PRUint32 aCount);
static PRBool Free(nsStr& aString);
};
/**************************************************************
A couple of tiny helper methods used in the string classes.
**************************************************************/
inline PRInt32 MinInt(PRInt32 anInt1,PRInt32 anInt2){
return (anInt1<anInt2) ? anInt1 : anInt2;
}
inline PRInt32 MaxInt(PRInt32 anInt1,PRInt32 anInt2){
return (anInt1<anInt2) ? anInt2 : anInt1;
}
inline void AddNullTerminator(nsStr& aDest) {
if(eTwoByte==aDest.mCharSize)
aDest.mUStr[aDest.mLength]=0;
else aDest.mStr[aDest.mLength]=0;
}
/**
* Return the given buffer to the heap manager. Calls allocator::Free()
* @return string length
*/
inline void Recycle( char* aBuffer) { nsAllocator::Free(aBuffer); }
inline void Recycle( PRUnichar* aBuffer) { nsAllocator::Free(aBuffer); }
/**
* This method is used to access a given char in the given string
*
* @update gess 01/04/99
* @param aDest is the nsStr to be appended to
* @param anIndex tells us where in dest to get the char from
* @return the given char, or 0 if anIndex is out of range
*/
inline PRUnichar GetCharAt(const nsStr& aDest,PRUint32 anIndex){
if(anIndex<aDest.mLength) {
return (eTwoByte==aDest.mCharSize) ? aDest.mUStr[anIndex] : aDest.mStr[anIndex];
}//if
return 0;
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,747 +0,0 @@
/* -*- 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.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.
*/
/***********************************************************************
MODULE NOTES:
See nsStr.h for a more general description of string classes.
This version of the nsString class offers many improvements over the
original version:
1. Wide and narrow chars
2. Allocators
3. Much smarter autostrings
4. Subsumable strings
***********************************************************************/
#ifndef _nsCString_
#define _nsCString_
#include "nsString2.h"
#include "prtypes.h"
#include "nscore.h"
#include <stdio.h>
#include "nsStr.h"
#include "nsIAtom.h"
class NS_COM nsSubsumeCStr;
class NS_COM nsCString : public nsStr {
public:
/**
* Default constructor.
*/
nsCString();
/**
* This constructor accepts an isolatin string
* @param aCString is a ptr to a 1-byte cstr
*/
nsCString(const char* aCString,PRInt32 aLength=-1);
/**
* This constructor accepts a unichar string
* @param aCString is a ptr to a 2-byte cstr
*/
nsCString(const PRUnichar* aString,PRInt32 aLength=-1);
/**
* This is a copy constructor that accepts an nsStr
* @param reference to another nsCString
*/
nsCString(const nsStr&);
/**
* This is our copy constructor
* @param reference to another nsCString
*/
nsCString(const nsCString& aString);
/**
* This constructor takes a subsumestr
* @param reference to subsumestr
*/
nsCString(nsSubsumeCStr& aSubsumeStr);
/**
* Destructor
*
*/
virtual ~nsCString();
/**
* Retrieve the length of this string
* @return string length
*/
inline PRInt32 Length() const { return (PRInt32)mLength; }
/**
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
/**
* Call this method if you want to force a different string capacity
* @update gess7/30/98
* @param aLength -- contains new length for mStr
* @return
*/
void SetLength(PRUint32 aLength) {
Truncate(aLength);
}
/**
* Sets the new length of the string.
* @param aLength is new string length.
* @return nada
*/
void SetCapacity(PRUint32 aLength);
/**
* This method truncates this string to given length.
*
* @param anIndex -- new length of string
* @return nada
*/
void Truncate(PRInt32 anIndex=0);
/**
* Determine whether or not the characters in this
* string are in sorted order.
*
* @return TRUE if ordered.
*/
PRBool IsOrdered(void) const;
/**
* Determine whether or not this string has a length of 0
*
* @return TRUE if empty.
*/
PRBool IsEmpty(void) const {
return PRBool(0==mLength);
}
/**********************************************************************
Accessor methods...
*********************************************************************/
/**
* Retrieve const ptr to internal buffer; DO NOT TRY TO FREE IT!
*/
const char* GetBuffer(void) const;
/**
* Get nth character.
*/
PRUnichar operator[](PRUint32 anIndex) const;
PRUnichar CharAt(PRUint32 anIndex) const;
PRUnichar First(void) const;
PRUnichar Last(void) const;
PRBool SetCharAt(PRUnichar aChar,PRUint32 anIndex);
/**********************************************************************
String creation methods...
*********************************************************************/
/**
* Create a new string by appending given string to this
* @param aString -- 2nd string to be appended
* @return new string
*/
nsSubsumeCStr operator+(const nsCString& aString);
/**
* create a new string by adding this to the given char*.
* @param aCString is a ptr to cstring to be added to this
* @return newly created string
*/
nsSubsumeCStr operator+(const char* aCString);
/**
* create a new string by adding this to the given char.
* @param aChar is a char to be added to this
* @return newly created string
*/
nsSubsumeCStr operator+(PRUnichar aChar);
nsSubsumeCStr operator+(char aChar);
/**********************************************************************
Lexomorphic transforms...
*********************************************************************/
/**
* Converts chars in this to lowercase
* @update gess 7/27/98
*/
void ToLowerCase();
/**
* Converts chars in this to lowercase, and
* stores them in aOut
* @update gess 7/27/98
* @param aOut is a string to contain result
*/
void ToLowerCase(nsCString& aString) const;
/**
* Converts chars in this to uppercase
* @update gess 7/27/98
*/
void ToUpperCase();
/**
* Converts chars in this to lowercase, and
* stores them in a given output string
* @update gess 7/27/98
* @param aOut is a string to contain result
*/
void ToUpperCase(nsCString& aString) const;
/**
* This method is used to remove all occurances of the
* characters found in aSet from this string.
*
* @param aSet -- characters to be cut from this
* @return *this
*/
nsCString& StripChars(const char* aSet);
nsCString& StripChar(char aChar);
/**
* This method strips whitespace throughout the string
*
* @return this
*/
nsCString& StripWhitespace();
/**
* swaps occurence of 1 string for another
*
* @return this
*/
nsCString& ReplaceChar(PRUnichar aOldChar,PRUnichar aNewChar);
nsCString& ReplaceChar(const char* aSet,PRUnichar aNewChar);
PRInt32 CountChar(PRUnichar aChar);
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
*
* @param aTrimSet -- contains chars to be trimmed from
* both ends
* @return this
*/
nsCString& Trim(const char* aSet,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
/**
* This method strips whitespace from string.
* You can control whether whitespace is yanked from
* start and end of string as well.
*
* @param aEliminateLeading controls stripping of leading ws
* @param aEliminateTrailing controls stripping of trailing ws
* @return this
*/
nsCString& CompressSet(const char* aSet, PRUnichar aChar,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
/**
* This method strips whitespace from string.
* You can control whether whitespace is yanked from
* start and end of string as well.
*
* @param aEliminateLeading controls stripping of leading ws
* @param aEliminateTrailing controls stripping of trailing ws
* @return this
*/
nsCString& CompressWhitespace( PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
/**********************************************************************
string conversion methods...
*********************************************************************/
operator char*() {return mStr;}
operator const char*() const {return (const char*)mStr;}
/**
* This method constructs a new nsCString that is a clone
* of this string.
*
*/
nsCString* ToNewString() const;
/**
* Creates an ISOLatin1 clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* @return ptr to new isolatin1 string
*/
char* ToNewCString() const;
/**
* Creates a unicode clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* @return ptr to new unicode string
*/
PRUnichar* ToNewUnicode() const;
/**
* Copies data from internal buffer onto given char* buffer
* NOTE: This only copies as many chars as will fit in given buffer (clips)
* @param aBuf is the buffer where data is stored
* @param aBuflength is the max # of chars to move to buffer
* @return ptr to given buffer
*/
char* ToCString(char* aBuf,PRUint32 aBufLength,PRUint32 anOffset=0) const;
/**
* Perform string to float conversion.
* @param aErrorCode will contain error if one occurs
* @return float rep of string value
*/
float ToFloat(PRInt32* aErrorCode) const;
/**
* Try to derive the radix from the value contained in this string
* @return kRadix10, kRadix16 or kAutoDetect (meaning unknown)
*/
PRUint32 DetermineRadix(void);
/**
* Perform string to int conversion.
* @param aErrorCode will contain error if one occurs
* @return int rep of string value
*/
PRInt32 ToInteger(PRInt32* aErrorCode,PRUint32 aRadix=kRadix10) const;
/**********************************************************************
String manipulation methods...
*********************************************************************/
/**
* Functionally equivalent to assign or operator=
*
*/
nsCString& SetString(const char* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
nsCString& SetString(const nsStr& aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
/**
* assign given string to this string
* @param aStr: buffer to be assigned to this
* @param alength is the length of the given str (or -1)
if you want me to determine its length
* @return this
*/
nsCString& Assign(const nsStr& aString,PRInt32 aCount=-1);
nsCString& Assign(const char* aString,PRInt32 aCount=-1);
nsCString& Assign(const PRUnichar* aString,PRInt32 aCount=-1);
nsCString& Assign(PRUnichar aChar);
nsCString& Assign(char aChar);
/**
* here come a bunch of assignment operators...
* @param aString: string to be added to this
* @return this
*/
nsCString& operator=(const nsCString& aString) {return Assign(aString);}
nsCString& operator=(const nsStr& aString) {return Assign(aString);}
nsCString& operator=(PRUnichar aChar) {return Assign(aChar);}
nsCString& operator=(char aChar) {return Assign(aChar);}
nsCString& operator=(const char* aCString) {return Assign(aCString);}
nsCString& operator=(const PRUnichar* aString) {return Assign(aString);}
#ifdef AIX
nsCString& operator=(const nsSubsumeCStr& aSubsumeString); // AIX requires a const here
#else
nsCString& operator=(nsSubsumeCStr& aSubsumeString);
#endif
/**
* Here's a bunch of methods that append varying types...
* @param various...
* @return this
*/
nsCString& operator+=(const nsCString& aString){return Append(aString,aString.mLength);}
nsCString& operator+=(const char* aCString) {return Append(aCString);}
nsCString& operator+=(PRUnichar aChar){return Append(aChar);}
nsCString& operator+=(char aChar){return Append(aChar);}
/*
* Appends n characters from given string to this,
* This version computes the length of your given string
*
* @param aString is the source to be appended to this
* @return number of chars copied
*/
nsCString& Append(const nsCString& aString) {return Append(aString,aString.mLength);}
/*
* Appends n characters from given string to this,
*
* @param aString is the source to be appended to this
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* @return number of chars copied
*/
nsCString& Append(const nsCString& aString,PRInt32 aCount);
nsCString& Append(const nsStr& aString,PRInt32 aCount=-1);
nsCString& Append(const char* aString,PRInt32 aCount=-1);
nsCString& Append(PRUnichar aChar);
nsCString& Append(char aChar);
nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
nsCString& Append(float aFloat);
/*
* Copies n characters from this string to given string,
* starting at the leftmost offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Left(nsCString& aCopy,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at the given offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @param anOffset -- position where copying begins
* @return number of chars copied
*/
PRUint32 Mid(nsCString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at rightmost char.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
/*
* This method inserts n chars from given string into this
* string at str[anOffset].
*
* @param aCopy -- String to be inserted into this
* @param anOffset -- insertion position within this str
* @param aCount -- number of chars to be copied from aCopy
* @return number of chars inserted into this.
*/
nsCString& Insert(const nsCString& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
/**
* Insert a given string into this string at
* a specified offset.
*
* @param aString* to be inserted into this string
* @param anOffset is insert pos in str
* @return the number of chars inserted into this string
*/
nsCString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
/**
* Insert a single char into this string at
* a specified offset.
*
* @param character to be inserted into this string
* @param anOffset is insert pos in str
* @return the number of chars inserted into this string
*/
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset);
nsCString& Insert(char aChar,PRUint32 anOffset);
/*
* This method is used to cut characters in this string
* starting at anOffset, continuing for aCount chars.
*
* @param anOffset -- start pos for cut operation
* @param aCount -- number of chars to be cut
* @return *this
*/
nsCString& Cut(PRUint32 anOffset,PRInt32 aCount);
/**********************************************************************
Searching methods...
*********************************************************************/
/**
* Search for given character within this string.
* This method does so by using a binary search,
* so your string HAD BETTER BE ORDERED!
*
* @param aChar is the unicode char to be found
* @return offset in string, or -1 (kNotFound)
*/
PRInt32 BinarySearch(PRUnichar aChar) const;
/**
* Search for given substring within this string
*
* @param aString is substring to be sought in this
* @param aIgnoreCase selects case sensitivity
* @param anOffset tells us where in this strig to start searching
* @return offset in string, or -1 (kNotFound)
*/
PRInt32 Find(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
/**
* Search for given char within this string
*
* @param aString is substring to be sought in this
* @param anOffset tells us where in this strig to start searching
* @param aIgnoreCase selects case sensitivity
* @return find pos in string, or -1 (kNotFound)
*/
PRInt32 FindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
/**
* This method searches this string for the first character
* found in the given charset
* @param aString contains set of chars to be found
* @param anOffset tells us where to start searching in this
* @return -1 if not found, else the offset in this
*/
PRInt32 FindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
PRInt32 FindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
PRInt32 FindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
/**
* This methods scans the string backwards, looking for the given string
* @param aString is substring to be sought in this
* @param aIgnoreCase tells us whether or not to do caseless compare
* @return offset in string, or -1 (kNotFound)
*/
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
PRInt32 RFind(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
/**
* Search for given char within this string
*
* @param aString is substring to be sought in this
* @param anOffset tells us where in this strig to start searching
* @param aIgnoreCase selects case sensitivity
* @return find pos in string, or -1 (kNotFound)
*/
PRInt32 RFindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
/**
* This method searches this string for the last character
* found in the given string
* @param aString contains set of chars to be found
* @param anOffset tells us where to start searching in this
* @return -1 if not found, else the offset in this
*/
PRInt32 RFindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
PRInt32 RFindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
PRInt32 RFindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
/**********************************************************************
Comparison methods...
*********************************************************************/
/**
* Compares a given string type to this string.
* @update gess 7/27/98
* @param S is the string to be compared
* @param aIgnoreCase tells us how to treat case
* @param aCount tells us how many chars to compare
* @return -1,0,1
*/
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
/**
* These methods compare a given string type to this one
* @param aString is the string to be compared to this
* @return TRUE or FALSE
*/
PRBool operator==(const nsStr &aString) const;
PRBool operator==(const char* aString) const;
PRBool operator==(const PRUnichar* aString) const;
/**
* These methods perform a !compare of a given string type to this
* @param aString is the string to be compared to this
* @return TRUE
*/
PRBool operator!=(const nsStr &aString) const;
PRBool operator!=(const char* aString) const;
PRBool operator!=(const PRUnichar* aString) const;
/**
* These methods test if a given string is < than this
* @param aString is the string to be compared to this
* @return TRUE or FALSE
*/
PRBool operator<(const nsStr &aString) const;
PRBool operator<(const char* aString) const;
PRBool operator<(const PRUnichar* aString) const;
/**
* These methods test if a given string is > than this
* @param aString is the string to be compared to this
* @return TRUE or FALSE
*/
PRBool operator>(const nsStr &S) const;
PRBool operator>(const char* aString) const;
PRBool operator>(const PRUnichar* aString) const;
/**
* These methods test if a given string is <= than this
* @param aString is the string to be compared to this
* @return TRUE or FALSE
*/
PRBool operator<=(const nsStr &S) const;
PRBool operator<=(const char* aString) const;
PRBool operator<=(const PRUnichar* aString) const;
/**
* These methods test if a given string is >= than this
* @param aString is the string to be compared to this
* @return TRUE or FALSE
*/
PRBool operator>=(const nsStr &S) const;
PRBool operator>=(const char* aString) const;
PRBool operator>=(const PRUnichar* aString) const;
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars in given string you want to compare
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const nsStr& aString) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aCount=-1) const;
static void Recycle(nsCString* aString);
static nsCString* CreateString(void);
};
extern NS_COM int fputs(const nsCString& aString, FILE* out);
//ostream& operator<<(ostream& aStream,const nsCString& aString);
//virtual void DebugDump(ostream& aStream) const;
/**************************************************************
Here comes the AutoString class which uses internal memory
(typically found on the stack) for its default buffer.
If the buffer needs to grow, it gets reallocated on the heap.
**************************************************************/
class NS_COM nsCAutoString : public nsCString {
public:
nsCAutoString();
nsCAutoString(const char* aString,PRInt32 aLength=-1);
nsCAutoString(const CBufDescriptor& aBuffer);
nsCAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
nsCAutoString(const nsStr& aString);
nsCAutoString(const nsCAutoString& aString);
#ifdef AIX
nsCAutoString(const nsSubsumeCStr& aSubsumeStr); // AIX requires a const
#else
nsCAutoString(nsSubsumeCStr& aSubsumeStr);
#endif // AIX
nsCAutoString(PRUnichar aChar);
virtual ~nsCAutoString();
nsCAutoString& operator=(const nsCString& aString) {nsCString::Assign(aString); return *this;}
nsCAutoString& operator=(const char* aCString) {nsCString::Assign(aCString); return *this;}
nsCAutoString& operator=(PRUnichar aChar) {nsCString::Assign(aChar); return *this;}
nsCAutoString& operator=(char aChar) {nsCString::Assign(aChar); return *this;}
/**
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
char mBuffer[kDefaultStringSize];
};
/***************************************************************
The subsumestr class is very unusual.
It differs from a normal string in that it doesn't use normal
copy semantics when another string is assign to this.
Instead, it "steals" the contents of the source string.
This is very handy for returning nsString classes as part of
an operator+(...) for example, in that it cuts down the number
of copy operations that must occur.
You should probably not use this class unless you really know
what you're doing.
***************************************************************/
class NS_COM nsSubsumeCStr : public nsCString {
public:
nsSubsumeCStr(nsStr& aString);
nsSubsumeCStr(PRUnichar* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
nsSubsumeCStr(char* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,840 +0,0 @@
/* -*- 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.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.
*/
/***********************************************************************
MODULE NOTES:
See nsStr.h for a more general description of string classes.
This version of the nsString class offers many improvements over the
original version:
1. Wide and narrow chars
2. Allocators
3. Much smarter autostrings
4. Subsumable strings
***********************************************************************/
#ifndef _nsString_
#define _nsString_
#include "prtypes.h"
#include "nscore.h"
#include <stdio.h>
#include "nsString.h"
#include "nsIAtom.h"
#include "nsStr.h"
#include "nsCRT.h"
class nsISizeOfHandler;
#define nsString2 nsString
#define nsAutoString2 nsAutoString
class NS_COM nsSubsumeStr;
class NS_COM nsString : public nsStr {
public:
/**
* Default constructor.
*/
nsString();
/**
* This constructor accepts an isolatin string
* @param aCString is a ptr to a 1-byte cstr
*/
nsString(const char* aCString);
/**
* This constructor accepts a unichar string
* @param aCString is a ptr to a 2-byte cstr
*/
nsString(const PRUnichar* aString);
/**
* This is a copy constructor that accepts an nsStr
* @param reference to another nsString
*/
nsString(const nsStr&);
/**
* This is our copy constructor
* @param reference to another nsString
*/
nsString(const nsString& aString);
/**
* This constructor takes a subsumestr
* @param reference to subsumestr
*/
nsString(nsSubsumeStr& aSubsumeStr);
/**
* Destructor
*
*/
virtual ~nsString();
/**
* Retrieve the length of this string
* @return string length
*/
inline PRInt32 Length() const { return (PRInt32)mLength; }
/**
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
/**
* Call this method if you want to force a different string length
* @update gess7/30/98
* @param aLength -- contains new length for mStr
* @return
*/
void SetLength(PRUint32 aLength) {
Truncate(aLength);
}
/**
* Sets the new length of the string.
* @param aLength is new string length.
* @return nada
*/
void SetCapacity(PRUint32 aLength);
/**
* This method truncates this string to given length.
*
* @param anIndex -- new length of string
* @return nada
*/
void Truncate(PRInt32 anIndex=0);
/**
* Determine whether or not the characters in this
* string are in sorted order.
*
* @return TRUE if ordered.
*/
PRBool IsOrdered(void) const;
/**
* Determine whether or not the characters in this
* string are in store as 1 or 2 byte (unicode) strings.
*
* @return TRUE if ordered.
*/
PRBool IsUnicode(void) const {
PRBool result=PRBool(mCharSize==eTwoByte);
return result;
}
/**
* Determine whether or not this string has a length of 0
*
* @return TRUE if empty.
*/
PRBool IsEmpty(void) const {
return PRBool(0==mLength);
}
/**********************************************************************
Getters/Setters...
*********************************************************************/
/**
* Retrieve const ptr to internal buffer; DO NOT TRY TO FREE IT!
*/
const char* GetBuffer(void) const;
const PRUnichar* GetUnicode(void) const;
/**
* Get nth character.
*/
PRUnichar operator[](PRUint32 anIndex) const;
PRUnichar CharAt(PRUint32 anIndex) const;
PRUnichar First(void) const;
PRUnichar Last(void) const;
/**
* Set nth character.
*/
PRBool SetCharAt(PRUnichar aChar,PRUint32 anIndex);
/**********************************************************************
String concatenation methods...
*********************************************************************/
/**
* Create a new string by appending given string to this
* @param aString -- 2nd string to be appended
* @return new subsumable string
*/
nsSubsumeStr operator+(const nsStr& aString);
nsSubsumeStr operator+(const nsString& aString);
/**
* create a new string by adding this to the given cstring
* @param aCString is a ptr to cstring to be added to this
* @return newly created string
*/
nsSubsumeStr operator+(const char* aCString);
/**
* create a new string by adding this to the given prunichar*.
* @param aString is a ptr to UC-string to be added to this
* @return newly created string
*/
nsSubsumeStr operator+(const PRUnichar* aString);
/**
* create a new string by adding this to the given char.
* @param aChar is a char to be added to this
* @return newly created string
*/
nsSubsumeStr operator+(char aChar);
/**
* create a new string by adding this to the given char.
* @param aChar is a unichar to be added to this
* @return newly created string
*/
nsSubsumeStr operator+(PRUnichar aChar);
/**********************************************************************
Lexomorphic transforms...
*********************************************************************/
/**
* Converts chars in this to lowercase
* @update gess 7/27/98
*/
void ToLowerCase();
/**
* Converts chars in this to lowercase, and
* stores them in aOut
* @update gess 7/27/98
* @param aOut is a string to contain result
*/
void ToLowerCase(nsString& aString) const;
/**
* Converts chars in this to uppercase
* @update gess 7/27/98
*/
void ToUpperCase();
/**
* Converts chars in this to lowercase, and
* stores them in a given output string
* @update gess 7/27/98
* @param aOut is a string to contain result
*/
void ToUpperCase(nsString& aString) const;
/**
* This method is used to remove all occurances of the
* characters found in aSet from this string.
*
* @param aSet -- characters to be cut from this
* @return *this
*/
nsString& StripChars(const char* aSet);
nsString& StripChar(char aChar);
/**
* This method strips whitespace throughout the string
*
* @return this
*/
nsString& StripWhitespace();
/**
* swaps occurence of 1 string for another
*
* @return this
*/
nsString& ReplaceChar(PRUnichar anOldChar,PRUnichar aNewChar);
nsString& ReplaceChar(const char* aSet,PRUnichar aNewChar);
PRInt32 CountChar(PRUnichar aChar);
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
*
* @param aTrimSet -- contains chars to be trimmed from
* both ends
* @return this
*/
nsString& Trim(const char* aSet,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
/**
* This method strips whitespace from string.
* You can control whether whitespace is yanked from
* start and end of string as well.
*
* @param aEliminateLeading controls stripping of leading ws
* @param aEliminateTrailing controls stripping of trailing ws
* @return this
*/
nsString& CompressSet(const char* aSet, PRUnichar aChar,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
/**
* This method strips whitespace from string.
* You can control whether whitespace is yanked from
* start and end of string as well.
*
* @param aEliminateLeading controls stripping of leading ws
* @param aEliminateTrailing controls stripping of trailing ws
* @return this
*/
nsString& CompressWhitespace( PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
/**********************************************************************
string conversion methods...
*********************************************************************/
/**
* This method constructs a new nsString is a clone of this string.
*
*/
nsString* ToNewString() const;
/**
* Creates an ISOLatin1 clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* @return ptr to new isolatin1 string
*/
char* ToNewCString() const;
/**
* Creates an UTF8 clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* @return ptr to new isolatin1 string
*/
char* ToNewUTF8String() const;
/**
* Creates a unicode clone of this string
* Note that calls to this method should be matched with calls to Recycle().
* @return ptr to new unicode string
*/
PRUnichar* ToNewUnicode() const;
/**
* Copies data from internal buffer onto given char* buffer
* NOTE: This only copies as many chars as will fit in given buffer (clips)
* @param aBuf is the buffer where data is stored
* @param aBuflength is the max # of chars to move to buffer
* @return ptr to given buffer
*/
char* ToCString(char* aBuf,PRUint32 aBufLength,PRUint32 anOffset=0) const;
/**
* Perform string to float conversion.
* @param aErrorCode will contain error if one occurs
* @return float rep of string value
*/
float ToFloat(PRInt32* aErrorCode) const;
/**
* Try to derive the radix from the value contained in this string
* @return kRadix10, kRadix16 or kAutoDetect (meaning unknown)
*/
PRUint32 DetermineRadix(void);
/**
* Perform string to int conversion.
* @param aErrorCode will contain error if one occurs
* @return int rep of string value
*/
PRInt32 ToInteger(PRInt32* aErrorCode,PRUint32 aRadix=kRadix10) const;
/**********************************************************************
String manipulation methods...
*********************************************************************/
/**
* Functionally equivalent to assign or operator=
*
*/
nsString& SetString(const char* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
nsString& SetString(const PRUnichar* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
nsString& SetString(const nsString& aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
/**
* assign given string to this string
* @param aStr: buffer to be assigned to this
* @param alength is the length of the given str (or -1)
if you want me to determine its length
* @return this
*/
nsString& Assign(const nsStr& aString,PRInt32 aCount=-1);
nsString& Assign(const char* aString,PRInt32 aCount=-1);
nsString& Assign(const PRUnichar* aString,PRInt32 aCount=-1);
nsString& Assign(char aChar);
nsString& Assign(PRUnichar aChar);
/**
* here come a bunch of assignment operators...
* @param aString: string to be added to this
* @return this
*/
nsString& operator=(const nsString& aString) {return Assign(aString);}
nsString& operator=(const nsStr& aString) {return Assign(aString);}
nsString& operator=(char aChar) {return Assign(aChar);}
nsString& operator=(PRUnichar aChar) {return Assign(aChar);}
nsString& operator=(const char* aCString) {return Assign(aCString);}
nsString& operator=(const PRUnichar* aString) {return Assign(aString);}
#ifdef AIX
nsString& operator=(const nsSubsumeStr& aSubsumeString); // AIX requires a const here
#else
nsString& operator=(nsSubsumeStr& aSubsumeString);
#endif
/**
* Here's a bunch of methods that append varying types...
* @param various...
* @return this
*/
nsString& operator+=(const nsStr& aString){return Append(aString,aString.mLength);}
nsString& operator+=(const nsString& aString){return Append(aString,aString.mLength);}
nsString& operator+=(const char* aCString) {return Append(aCString);}
//nsString& operator+=(char aChar){return Append(aChar);}
nsString& operator+=(const PRUnichar* aUCString) {return Append(aUCString);}
nsString& operator+=(PRUnichar aChar){return Append(aChar);}
/*
* Appends n characters from given string to this,
* This version computes the length of your given string
*
* @param aString is the source to be appended to this
* @return number of chars copied
*/
nsString& Append(const nsStr& aString) {return Append(aString,aString.mLength);}
nsString& Append(const nsString& aString) {return Append(aString,aString.mLength);}
/*
* Appends n characters from given string to this,
*
* @param aString is the source to be appended to this
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* @return number of chars copied
*/
nsString& Append(const nsStr& aString,PRInt32 aCount);
nsString& Append(const nsString& aString,PRInt32 aCount);
nsString& Append(const char* aString,PRInt32 aCount=-1);
nsString& Append(const PRUnichar* aString,PRInt32 aCount=-1);
nsString& Append(char aChar);
nsString& Append(PRUnichar aChar);
nsString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
nsString& Append(float aFloat);
/*
* Copies n characters from this string to given string,
* starting at the leftmost offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Left(nsString& aCopy,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at the given offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @param anOffset -- position where copying begins
* @return number of chars copied
*/
PRUint32 Mid(nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at rightmost char.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Right(nsString& aCopy,PRInt32 aCount) const;
/*
* This method inserts n chars from given string into this
* string at str[anOffset].
*
* @param aCopy -- String to be inserted into this
* @param anOffset -- insertion position within this str
* @param aCount -- number of chars to be copied from aCopy
* @return number of chars inserted into this.
*/
nsString& Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
/**
* Insert a given string into this string at
* a specified offset.
*
* @param aString* to be inserted into this string
* @param anOffset is insert pos in str
* @return the number of chars inserted into this string
*/
nsString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
nsString& Insert(const PRUnichar* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
/**
* Insert a single char into this string at
* a specified offset.
*
* @param character to be inserted into this string
* @param anOffset is insert pos in str
* @return the number of chars inserted into this string
*/
//nsString& Insert(char aChar,PRUint32 anOffset);
nsString& Insert(PRUnichar aChar,PRUint32 anOffset);
/*
* This method is used to cut characters in this string
* starting at anOffset, continuing for aCount chars.
*
* @param anOffset -- start pos for cut operation
* @param aCount -- number of chars to be cut
* @return *this
*/
nsString& Cut(PRUint32 anOffset,PRInt32 aCount);
/**********************************************************************
Searching methods...
*********************************************************************/
/**
* Search for given character within this string.
* This method does so by using a binary search,
* so your string HAD BETTER BE ORDERED!
*
* @param aChar is the unicode char to be found
* @return offset in string, or -1 (kNotFound)
*/
PRInt32 BinarySearch(PRUnichar aChar) const;
/**
* Search for given substring within this string
*
* @param aString is substring to be sought in this
* @param aIgnoreCase selects case sensitivity
* @param anOffset tells us where in this strig to start searching
* @return offset in string, or -1 (kNotFound)
*/
PRInt32 Find(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
PRInt32 Find(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
/**
* Search for given char within this string
*
* @param aString is substring to be sought in this
* @param anOffset tells us where in this strig to start searching
* @param aIgnoreCase selects case sensitivity
* @return find pos in string, or -1 (kNotFound)
*/
//PRInt32 Find(PRUnichar aChar,PRInt32 offset=-1,PRBool aIgnoreCase=PR_FALSE) const;
PRInt32 FindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
/**
* This method searches this string for the first character
* found in the given charset
* @param aString contains set of chars to be found
* @param anOffset tells us where to start searching in this
* @return -1 if not found, else the offset in this
*/
PRInt32 FindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
PRInt32 FindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
PRInt32 FindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
/**
* This methods scans the string backwards, looking for the given string
* @param aString is substring to be sought in this
* @param aIgnoreCase tells us whether or not to do caseless compare
* @param anOffset tells us where in this strig to start searching (counting from left)
*/
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
PRInt32 RFind(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
PRInt32 RFind(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
/**
* Search for given char within this string
*
* @param aString is substring to be sought in this
* @param anOffset tells us where in this strig to start searching (counting from left)
* @param aIgnoreCase selects case sensitivity
* @return find pos in string, or -1 (kNotFound)
*/
//PRInt32 RFind(PRUnichar aChar,PRInt32 offset=-1,PRBool aIgnoreCase=PR_FALSE) const;
PRInt32 RFindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
/**
* This method searches this string for the last character
* found in the given string
* @param aString contains set of chars to be found
* @param anOffset tells us where in this strig to start searching (counting from left)
* @return -1 if not found, else the offset in this
*/
PRInt32 RFindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
PRInt32 RFindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
PRInt32 RFindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
/**********************************************************************
Comparison methods...
*********************************************************************/
/**
* Compares a given string type to this string.
* @update gess 7/27/98
* @param S is the string to be compared
* @param aIgnoreCase tells us how to treat case
* @param aCount tells us how many chars to compare
* @return -1,0,1
*/
virtual PRInt32 Compare(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
/**
* These methods compare a given string type to this one
* @param aString is the string to be compared to this
* @return TRUE or FALSE
*/
PRBool operator==(const nsString &aString) const;
PRBool operator==(const nsStr &aString) const;
PRBool operator==(const char *aString) const;
PRBool operator==(const PRUnichar* aString) const;
/**
* These methods perform a !compare of a given string type to this
* @param aString is the string to be compared to this
* @return TRUE
*/
PRBool operator!=(const nsString &aString) const;
PRBool operator!=(const nsStr &aString) const;
PRBool operator!=(const char* aString) const;
PRBool operator!=(const PRUnichar* aString) const;
/**
* These methods test if a given string is < than this
* @param aString is the string to be compared to this
* @return TRUE or FALSE
*/
PRBool operator<(const nsString &aString) const;
PRBool operator<(const nsStr &aString) const;
PRBool operator<(const char* aString) const;
PRBool operator<(const PRUnichar* aString) const;
/**
* These methods test if a given string is > than this
* @param aString is the string to be compared to this
* @return TRUE or FALSE
*/
PRBool operator>(const nsString &aString) const;
PRBool operator>(const nsStr &S) const;
PRBool operator>(const char* aString) const;
PRBool operator>(const PRUnichar* aString) const;
/**
* These methods test if a given string is <= than this
* @param aString is the string to be compared to this
* @return TRUE or FALSE
*/
PRBool operator<=(const nsString &aString) const;
PRBool operator<=(const nsStr &S) const;
PRBool operator<=(const char* aString) const;
PRBool operator<=(const PRUnichar* aString) const;
/**
* These methods test if a given string is >= than this
* @param aString is the string to be compared to this
* @return TRUE or FALSE
*/
PRBool operator>=(const nsString &aString) const;
PRBool operator>=(const nsStr &S) const;
PRBool operator>=(const char* aString) const;
PRBool operator>=(const PRUnichar* aString) const;
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars to be compared.
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(/*FIX: const */nsIAtom* anAtom,PRBool aIgnoreCase) const;
PRBool Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreCase=PR_FALSE) const;
PRBool EqualsIgnoreCase(const nsString& aString) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const;
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
/**
* Determine if given buffer is plain ascii
*
* @param aBuffer -- if null, then we test *this, otherwise we test given buffer
* @return TRUE if is all ascii chars or if strlen==0
*/
PRBool IsASCII(const PRUnichar* aBuffer=0);
/**
* Determine if given char is a valid space character
*
* @param aChar is character to be tested
* @return TRUE if is valid space char
*/
static PRBool IsSpace(PRUnichar ch);
/**
* Determine if given char in valid alpha range
*
* @param aChar is character to be tested
* @return TRUE if in alpha range
*/
static PRBool IsAlpha(PRUnichar ch);
/**
* Determine if given char is valid digit
*
* @param aChar is character to be tested
* @return TRUE if char is a valid digit
*/
static PRBool IsDigit(PRUnichar ch);
static void Recycle(nsString* aString);
static nsString* CreateString(void);
};
extern NS_COM int fputs(const nsString& aString, FILE* out);
//ostream& operator<<(ostream& aStream,const nsString& aString);
//virtual void DebugDump(ostream& aStream) const;
/**************************************************************
Here comes the AutoString class which uses internal memory
(typically found on the stack) for its default buffer.
If the buffer needs to grow, it gets reallocated on the heap.
**************************************************************/
class NS_COM nsAutoString : public nsString {
public:
nsAutoString();
nsAutoString(const char* aCString,PRInt32 aLength=-1);
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
nsAutoString(const CBufDescriptor& aBuffer);
nsAutoString(const nsStr& aString);
nsAutoString(const nsAutoString& aString);
#ifdef AIX
nsAutoString(const nsSubsumeStr& aSubsumeStr); // AIX requires a const
#else
nsAutoString(nsSubsumeStr& aSubsumeStr);
#endif // AIX
nsAutoString(PRUnichar aChar);
virtual ~nsAutoString();
nsAutoString& operator=(const nsStr& aString) {nsString::Assign(aString); return *this;}
nsAutoString& operator=(const nsAutoString& aString) {nsString::Assign(aString); return *this;}
nsAutoString& operator=(const char* aCString) {nsString::Assign(aCString); return *this;}
nsAutoString& operator=(char aChar) {nsString::Assign(aChar); return *this;}
nsAutoString& operator=(const PRUnichar* aBuffer) {nsString::Assign(aBuffer); return *this;}
nsAutoString& operator=(PRUnichar aChar) {nsString::Assign(aChar); return *this;}
/**
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
char mBuffer[kDefaultStringSize<<eTwoByte];
};
/***************************************************************
The subsumestr class is very unusual.
It differs from a normal string in that it doesn't use normal
copy semantics when another string is assign to this.
Instead, it "steals" the contents of the source string.
This is very handy for returning nsString classes as part of
an operator+(...) for example, in that it cuts down the number
of copy operations that must occur.
You should probably not use this class unless you really know
what you're doing.
***************************************************************/
class NS_COM nsSubsumeStr : public nsString {
public:
nsSubsumeStr(nsStr& aString);
nsSubsumeStr(PRUnichar* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
nsSubsumeStr(char* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
};
#endif

View File

@@ -1,179 +0,0 @@
/* -*- 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 "nsDebug.h"
#include "nsIAllocator.h"
#include "nsXPIDLString.h"
#include "plstr.h"
// If the allocator changes, fix it here.
#define XPIDL_STRING_ALLOC(__len) ((PRUnichar*) nsAllocator::Alloc((__len) * sizeof(PRUnichar)))
#define XPIDL_CSTRING_ALLOC(__len) ((char*) nsAllocator::Alloc((__len) * sizeof(char)))
#define XPIDL_FREE(__ptr) (nsAllocator::Free(__ptr))
////////////////////////////////////////////////////////////////////////
// nsXPIDLString
nsXPIDLString::nsXPIDLString()
: mBuf(0),
mBufOwner(PR_FALSE)
{
}
nsXPIDLString::~nsXPIDLString()
{
if (mBufOwner && mBuf)
XPIDL_FREE(mBuf);
}
nsXPIDLString::operator const PRUnichar*()
{
return mBuf;
}
PRUnichar*
nsXPIDLString::Copy(const PRUnichar* aString)
{
NS_ASSERTION(aString, "null ptr");
if (! aString)
return 0;
PRInt32 len = 0;
{
const PRUnichar* p = aString;
while (*p++)
len++;
}
PRUnichar* result = XPIDL_STRING_ALLOC(len + 1);
if (result) {
PRUnichar* q = result;
while (*aString) {
*q = *aString;
q++;
aString++;
}
*q = '\0';
}
return result;
}
PRUnichar**
nsXPIDLString::StartAssignmentByValue()
{
if (mBufOwner && mBuf)
XPIDL_FREE(mBuf);
mBuf = 0;
mBufOwner = PR_TRUE;
return &mBuf;
}
const PRUnichar**
nsXPIDLString::StartAssignmentByReference()
{
if (mBufOwner && mBuf)
XPIDL_FREE(mBuf);
mBuf = 0;
mBufOwner = PR_FALSE;
return (const PRUnichar**) &mBuf;
}
////////////////////////////////////////////////////////////////////////
// nsXPIDLCString
nsXPIDLCString::nsXPIDLCString()
: mBuf(0),
mBufOwner(PR_FALSE)
{
}
nsXPIDLCString::~nsXPIDLCString()
{
if (mBufOwner && mBuf)
XPIDL_FREE(mBuf);
}
nsXPIDLCString& nsXPIDLCString::operator =(const char* aCString)
{
if (mBufOwner && mBuf)
XPIDL_FREE(mBuf);
mBuf = Copy(aCString);
mBufOwner = PR_TRUE;
return *this;
}
nsXPIDLCString::operator const char*()
{
return mBuf;
}
char*
nsXPIDLCString::Copy(const char* aCString)
{
NS_ASSERTION(aCString, "null ptr");
if (! aCString)
return 0;
PRInt32 len = PL_strlen(aCString);
char* result = XPIDL_CSTRING_ALLOC(len + 1);
if (result)
PL_strcpy(result, aCString);
return result;
}
char**
nsXPIDLCString::StartAssignmentByValue()
{
if (mBufOwner && mBuf)
XPIDL_FREE(mBuf);
mBuf = 0;
mBufOwner = PR_TRUE;
return &mBuf;
}
const char**
nsXPIDLCString::StartAssignmentByReference()
{
if (mBufOwner && mBuf)
XPIDL_FREE(mBuf);
mBuf = 0;
mBufOwner = PR_FALSE;
return (const char**) &mBuf;
}

View File

@@ -1,302 +0,0 @@
/* -*- 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.
*/
/*
A set of string wrapper classes that ease transition to use of XPIDL
interfaces. nsXPIDLString and nsXPIDLCString are to XPIDL `wstring'
and `string' out params as nsCOMPtr is to generic XPCOM interface
pointers. They help you deal with object ownership.
Consider the following interface:
interface nsIFoo {
attribute string Bar;
};
This will generate the following C++ header file:
class nsIFoo {
NS_IMETHOD SetBar(const PRUnichar* aValue);
NS_IMETHOD GetBar(PRUnichar* *aValue);
};
The GetBar() method will allocate a copy of the nsIFoo object's
"bar" attribute, and leave you to deal with freeing it:
nsIFoo* aFoo; // assume we get this somehow
PRUnichar* bar;
aFoo->GetFoo(&bar);
// Use bar here...
printf("bar is %s!\n", bar);
nsAllocator::Free(bar);
This makes your life harder, because you need to convolute your code
to ensure that you don't leak `bar'.
Enter nsXPIDLString, which manages the ownership of the allocated
string, and automatically destroys it when the nsXPIDLString goes
out of scope:
nsIFoo* aFoo;
nsXPIDLString bar;
aFoo->GetFoo( getter_Copies(bar) );
// Use bar here...
printf("bar is %s!\n", (const char*) bar);
// no need to remember to nsAllocator::Free().
Like nsCOMPtr, nsXPIDLString uses some syntactic sugar to make it
painfully clear exactly what the code expects. You need to wrap an
nsXPIDLString object with either `getter_Copies()' or
`getter_Shares()' before passing it to a getter: these tell the
nsXPIDLString how ownership is being handled.
In the case of `getter_Copies()', the callee is allocating a copy
(which is usually the case). In the case of `getter_Shares()', the
callee is returning a const reference to `the real deal' (this can
be done using the [shared] attribute in XPIDL).
*/
#ifndef nsXPIDLString_h__
#define nsXPIDLString_h__
#include "nsCom.h"
#include "prtypes.h"
#ifndef __PRUNICHAR__
#define __PRUNICHAR__
typedef PRUint16 PRUnichar;
#endif /* __PRUNICHAR__ */
////////////////////////////////////////////////////////////////////////
// nsXPIDLString
//
// A wrapper for Unicode strings. With the |getter_Copies()| and
// |getter_Shares()| helper functions, this can be used instead of
// the "naked" |PRUnichar*| interface for |wstring| parameters in
// XPIDL interfaces.
//
class NS_COM nsXPIDLString {
private:
PRUnichar* mBuf;
PRBool mBufOwner;
PRUnichar** StartAssignmentByValue();
const PRUnichar** StartAssignmentByReference();
public:
/**
* Construct a new, uninitialized wrapper for a Unicode string.
*/
nsXPIDLString();
virtual ~nsXPIDLString();
/**
* Return a reference to the immutable Unicode string.
*/
operator const PRUnichar*();
/**
* Make a copy of the Unicode string. Use this function in the
* callee to ensure that the correct memory allocator is used.
*/
static PRUnichar* Copy(const PRUnichar* aString);
// A helper class for assignment-by-value. This class is an
// implementation detail and should not be considered part of the
// public interface.
class NS_COM GetterCopies {
private:
nsXPIDLString& mXPIDLString;
public:
GetterCopies(nsXPIDLString& aXPIDLString)
: mXPIDLString(aXPIDLString) {}
operator PRUnichar**() {
return mXPIDLString.StartAssignmentByValue();
}
friend GetterCopies getter_Copies(nsXPIDLString& aXPIDLString);
};
friend class GetterCopies;
// A helper class for assignment-by-reference. This class is an
// implementation detail and should not be considered part of the
// public interface.
class NS_COM GetterShares {
private:
nsXPIDLString& mXPIDLString;
public:
GetterShares(nsXPIDLString& aXPIDLString)
: mXPIDLString(aXPIDLString) {}
operator const PRUnichar**() {
return mXPIDLString.StartAssignmentByReference();
}
friend GetterShares getter_Shares(nsXPIDLString& aXPIDLString);
};
friend class GetterShares;
private:
// not to be implemented
nsXPIDLString(nsXPIDLString& /* aXPIDLString */) {}
nsXPIDLString& operator =(nsXPIDLString& /* aXPIDLString */) { return *this; }
};
/**
* Use this function to "wrap" the nsXPIDLString object that is to
* receive an |out| value.
*/
inline nsXPIDLString::GetterCopies
getter_Copies(nsXPIDLString& aXPIDLString)
{
return nsXPIDLString::GetterCopies(aXPIDLString);
}
/**
* Use this function to "wrap" the nsXPIDLString object that is to
* receive a |[shared] out| value.
*/
inline nsXPIDLString::GetterShares
getter_Shares(nsXPIDLString& aXPIDLString)
{
return nsXPIDLString::GetterShares(aXPIDLString);
}
////////////////////////////////////////////////////////////////////////
// nsXPIDLCString
//
// A wrapper for Unicode strings. With the |getter_Copies()| and
// |getter_Shares()| helper functions, this can be used instead of
// the "naked" |char*| interface for |string| parameters in XPIDL
// interfaces.
//
class NS_COM nsXPIDLCString {
private:
char* mBuf;
PRBool mBufOwner;
char** StartAssignmentByValue();
const char** StartAssignmentByReference();
public:
/**
* Construct a new, uninitialized wrapper for a single-byte string.
*/
nsXPIDLCString();
virtual ~nsXPIDLCString();
/**
* Assign a single-byte string to this wrapper. Copies and owns the result.
*/
nsXPIDLCString& operator =(const char* aString);
/**
* Return a reference to the immutable single-byte string.
*/
operator const char*();
/**
* Make a copy of the single-byte string. Use this function in the
* callee to ensure that the correct memory allocator is used.
*/
static char* Copy(const char* aString);
// A helper class for assignment-by-value. This class is an
// implementation detail and should not be considered part of the
// public interface.
class NS_COM GetterCopies {
private:
nsXPIDLCString& mXPIDLString;
public:
GetterCopies(nsXPIDLCString& aXPIDLString)
: mXPIDLString(aXPIDLString) {}
operator char**() {
return mXPIDLString.StartAssignmentByValue();
}
friend GetterCopies getter_Copies(nsXPIDLCString& aXPIDLString);
};
friend class GetterCopies;
// A helper class for assignment-by-reference. This class is an
// implementation detail and should not be considered part of the
// public interface.
class NS_COM GetterShares {
private:
nsXPIDLCString& mXPIDLString;
public:
GetterShares(nsXPIDLCString& aXPIDLString)
: mXPIDLString(aXPIDLString) {}
operator const char**() {
return mXPIDLString.StartAssignmentByReference();
}
friend GetterShares getter_Shares(nsXPIDLCString& aXPIDLString);
};
friend class GetterShares;
private:
// not to be implemented
nsXPIDLCString(nsXPIDLCString& /* aXPIDLString */) {}
nsXPIDLCString& operator =(nsXPIDLCString& /* aXPIDLCString */) { return *this; }
};
/**
* Use this function to "wrap" the nsXPIDLCString object that is to
* receive an |out| value.
*/
inline nsXPIDLCString::GetterCopies
getter_Copies(nsXPIDLCString& aXPIDLString)
{
return nsXPIDLCString::GetterCopies(aXPIDLString);
}
/**
* Use this function to "wrap" the nsXPIDLCString object that is to
* receive a |[shared] out| value.
*/
inline nsXPIDLCString::GetterShares
getter_Shares(nsXPIDLCString& aXPIDLString)
{
return nsXPIDLCString::GetterShares(aXPIDLString);
}
#endif // nsXPIDLString_h__

View File

@@ -1,30 +0,0 @@
nsAVLTree.h
nsCppSharedAllocator.h
nsCRT.h
nsDeque.h
nsEnumeratorUtils.h
nsHashtable.h
nsHashtableEnumerator.h
nsIArena.h
nsIBuffer.h
nsIByteBuffer.h
nsIObserverList.h
nsIPageManager.h
nsIProperties.h
nsISimpleEnumerator.h
nsISizeOfHandler.h
nsIUnicharBuffer.h
nsIVariant.h
nsInt64.h
nsQuickSort.h
nsStr.h
nsString.h
nsString2.h
nsSupportsPrimitives.h
nsTime.h
nsUnitConversion.h
nsVector.h
nsVoidArray.h
nsXPIDLString.h
plvector.h
nsTextFormater.h

View File

@@ -1,6 +0,0 @@
nsIAtom.idl
nsICollection.idl
nsIEnumerator.idl
nsIObserver.idl
nsIObserverService.idl
nsISupportsArray.idl

View File

@@ -1,113 +0,0 @@
#
# 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.
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xpcom
XPIDL_MODULE = xpcom_ds
LIBRARY_NAME = xpcomds_s
REQUIRES = xpcom uconv unicharutil
CPPSRCS = \
nsArena.cpp \
nsAtomTable.cpp \
nsAVLTree.cpp \
nsByteBuffer.cpp \
nsCRT.cpp \
nsConjoiningEnumerator.cpp \
nsDeque.cpp \
nsEmptyEnumerator.cpp \
nsEnumeratorUtils.cpp \
nsHashtable.cpp \
nsHashtableEnumerator.cpp \
nsObserver.cpp \
nsObserverList.cpp \
nsObserverService.cpp \
nsProperties.cpp \
nsQuickSort.cpp \
nsSizeOfHandler.cpp \
nsStr.cpp \
nsString.cpp \
nsString2.cpp \
nsSupportsArray.cpp \
nsSupportsArrayEnumerator.cpp \
nsSupportsPrimitives.cpp \
nsUnicharBuffer.cpp \
nsVariant.cpp \
nsVoidArray.cpp \
nsXPIDLString.cpp \
plvector.cpp \
nsTextFormater.cpp \
$(NULL)
EXPORTS = \
nsAVLTree.h \
nsCppSharedAllocator.h \
nsCRT.h \
nsDeque.h \
nsEnumeratorUtils.h \
nsHashtable.h \
nsHashtableEnumerator.h \
nsIArena.h \
nsIByteBuffer.h \
nsIObserverList.h \
nsIProperties.h \
nsISimpleEnumerator.h \
nsISizeOfHandler.h \
nsIUnicharBuffer.h \
nsIVariant.h \
nsInt64.h \
nsQuickSort.h \
nsStr.h \
nsString.h \
nsString2.h \
nsSupportsPrimitives.h \
nsTime.h \
nsUnitConversion.h \
nsVector.h \
nsVoidArray.h \
nsXPIDLString.h \
plvector.h \
nsTextFormater.h \
$(NULL)
XPIDLSRCS = \
nsIAtom.idl \
nsICollection.idl \
nsIEnumerator.idl \
nsIObserver.idl \
nsIObserverService.idl \
nsISupportsArray.idl \
nsISupportsPrimitives.idl \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
# 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
DEFINES += -D_IMPL_NS_COM -D_IMPL_NS_BASE

View File

@@ -1,758 +0,0 @@
/* -*- 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.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.
*/
/******************************************************************************************
MODULE NOTES:
This file contains the workhorse copy and shift functions used in nsStrStruct.
Ultimately, I plan to make the function pointers in this system available for
use by external modules. They'll be able to install their own "handlers".
Not so, today though.
*******************************************************************************************/
#ifndef _BUFFERROUTINES_H
#define _BUFFERROUTINES_H
#include "nsCRT.h"
#ifndef RICKG_TESTBED
#include "nsUnicharUtilCIID.h"
#include "nsIServiceManager.h"
#include "nsICaseConversion.h"
#endif
#define KSHIFTLEFT (0)
#define KSHIFTRIGHT (1)
inline PRUnichar GetUnicharAt(const char* aString,PRUint32 anIndex) {
return ((PRUnichar*)aString)[anIndex];
}
inline PRUnichar GetCharAt(const char* aString,PRUint32 anIndex) {
return (PRUnichar)aString[anIndex];
}
//----------------------------------------------------------------------------------------
//
// This set of methods is used to shift the contents of a char buffer.
// The functions are differentiated by shift direction and the underlying charsize.
//
/**
* This method shifts single byte characters left by a given amount from an given offset.
* @update gess 01/04/99
* @param aDest is a ptr to a cstring where left-shift is to be performed
* @param aLength is the known length of aDest
* @param anOffset is the index into aDest where shifting shall begin
* @param aCount is the number of chars to be "cut"
*/
void ShiftCharsLeft(char* aDest,PRUint32 aLength,PRUint32 anOffset,PRUint32 aCount) {
char* dst = aDest+anOffset;
char* src = aDest+anOffset+aCount;
memmove(dst,src,aLength-(aCount+anOffset));
}
/**
* This method shifts single byte characters right by a given amount from an given offset.
* @update gess 01/04/99
* @param aDest is a ptr to a cstring where the shift is to be performed
* @param aLength is the known length of aDest
* @param anOffset is the index into aDest where shifting shall begin
* @param aCount is the number of chars to be "inserted"
*/
void ShiftCharsRight(char* aDest,PRUint32 aLength,PRUint32 anOffset,PRUint32 aCount) {
char* src = aDest+anOffset;
char* dst = aDest+anOffset+aCount;
memmove(dst,src,aLength-anOffset);
}
/**
* This method shifts unicode characters by a given amount from an given offset.
* @update gess 01/04/99
* @param aDest is a ptr to a cstring where the shift is to be performed
* @param aLength is the known length of aDest
* @param anOffset is the index into aDest where shifting shall begin
* @param aCount is the number of chars to be "cut"
*/
void ShiftDoubleCharsLeft(char* aDest,PRUint32 aLength,PRUint32 anOffset,PRUint32 aCount) {
PRUnichar* root=(PRUnichar*)aDest;
PRUnichar* dst = root+anOffset;
PRUnichar* src = root+anOffset+aCount;
memmove(dst,src,(aLength-(aCount+anOffset))*sizeof(PRUnichar));
}
/**
* This method shifts unicode characters by a given amount from an given offset.
* @update gess 01/04/99
* @param aDest is a ptr to a cstring where the shift is to be performed
* @param aLength is the known length of aDest
* @param anOffset is the index into aDest where shifting shall begin
* @param aCount is the number of chars to be "inserted"
*/
void ShiftDoubleCharsRight(char* aDest,PRUint32 aLength,PRUint32 anOffset,PRUint32 aCount) {
PRUnichar* root=(PRUnichar*)aDest;
PRUnichar* src = root+anOffset;
PRUnichar* dst = root+anOffset+aCount;
memmove(dst,src,sizeof(PRUnichar)*(aLength-anOffset));
}
typedef void (*ShiftChars)(char* aDest,PRUint32 aLength,PRUint32 anOffset,PRUint32 aCount);
ShiftChars gShiftChars[2][2]= {
{&ShiftCharsLeft,&ShiftCharsRight},
{&ShiftDoubleCharsLeft,&ShiftDoubleCharsRight}
};
//----------------------------------------------------------------------------------------
//
// This set of methods is used to copy one buffer onto another.
// The functions are differentiated by the size of source and dest character sizes.
// WARNING: Your destination buffer MUST be big enough to hold all the source bytes.
// We don't validate these ranges here (this should be done in higher level routines).
//
/**
* Going 1 to 1 is easy, since we assume ascii. No conversions are necessary.
* @update gess 01/04/99
* @param aDest is the destination buffer
* @param aDestOffset is the pos to start copy to in the dest buffer
* @param aSource is the source buffer
* @param anOffset is the offset to start copying from in the source buffer
* @param aCount is the (max) number of chars to copy
*/
void CopyChars1To1(char* aDest,PRInt32 anDestOffset,const char* aSource,PRUint32 anOffset,PRUint32 aCount) {
char* dst = aDest+anDestOffset;
char* src = (char*)aSource+anOffset;
memcpy(dst,src,aCount);
}
/**
* Going 1 to 2 requires a conversion from ascii to unicode. This can be expensive.
* @param aDest is the destination buffer
* @param aDestOffset is the pos to start copy to in the dest buffer
* @param aSource is the source buffer
* @param anOffset is the offset to start copying from in the source buffer
* @param aCount is the (max) number of chars to copy
*/
void CopyChars1To2(char* aDest,PRInt32 anDestOffset,const char* aSource,PRUint32 anOffset,PRUint32 aCount) {
PRUnichar* theDest=(PRUnichar*)aDest;
PRUnichar* to = theDest+anDestOffset;
const unsigned char* first= (const unsigned char*)aSource+anOffset;
const unsigned char* last = first+aCount;
//now loop over characters, shifting them left...
while(first<last) {
*to=(PRUnichar)(*first);
to++;
first++;
}
}
/**
* Going 2 to 1 requires a conversion from unicode down to ascii. This can be lossy.
* @update gess 01/04/99
* @param aDest is the destination buffer
* @param aDestOffset is the pos to start copy to in the dest buffer
* @param aSource is the source buffer
* @param anOffset is the offset to start copying from in the source buffer
* @param aCount is the (max) number of chars to copy
*/
void CopyChars2To1(char* aDest,PRInt32 anDestOffset,const char* aSource,PRUint32 anOffset,PRUint32 aCount) {
char* to = aDest+anDestOffset;
PRUnichar* theSource=(PRUnichar*)aSource;
const PRUnichar* first= theSource+anOffset;
const PRUnichar* last = first+aCount;
//now loop over characters, shifting them left...
while(first<last) {
if(*first<256)
*to=(char)*first;
else *to='.';
to++;
first++;
}
}
/**
* Going 2 to 2 is fast and efficient.
* @update gess 01/04/99
* @param aDest is the destination buffer
* @param aDestOffset is the pos to start copy to in the dest buffer
* @param aSource is the source buffer
* @param anOffset is the offset to start copying from in the source buffer
* @param aCount is the (max) number of chars to copy
*/
void CopyChars2To2(char* aDest,PRInt32 anDestOffset,const char* aSource,PRUint32 anOffset,PRUint32 aCount) {
PRUnichar* theDest=(PRUnichar*)aDest;
PRUnichar* to = theDest+anDestOffset;
PRUnichar* theSource=(PRUnichar*)aSource;
PRUnichar* from= theSource+anOffset;
memcpy((void*)to,(void*)from,aCount*sizeof(PRUnichar));
}
//--------------------------------------------------------------------------------------
typedef void (*CopyChars)(char* aDest,PRInt32 anDestOffset,const char* aSource,PRUint32 anOffset,PRUint32 aCount);
CopyChars gCopyChars[2][2]={
{&CopyChars1To1,&CopyChars1To2},
{&CopyChars2To1,&CopyChars2To2}
};
//----------------------------------------------------------------------------------------
//
// This set of methods is used to search a buffer looking for a char.
//
/**
* This methods cans the given buffer for the given char
*
* @update gess 3/25/98
* @param aDest is the buffer to be searched
* @param aLength is the size (in char-units, not bytes) of the buffer
* @param anOffset is the start pos to begin searching
* @param aChar is the target character we're looking for
* @param aIgnorecase tells us whether to use a case sensitive search
* @return index of pos if found, else -1 (kNotFound)
*/
inline PRInt32 FindChar1(const char* aDest,PRUint32 aLength,PRUint32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase) {
if(aIgnoreCase) {
char theChar=(char)nsCRT::ToUpper(aChar);
const char* ptr=aDest+(anOffset-1);
const char* last=aDest+aLength;
while(++ptr<last){
if(nsCRT::ToUpper(*ptr)==theChar)
return ptr-aDest;
}
}
else {
const char* ptr = aDest+anOffset;
char theChar=(char)aChar;
const char* result=(const char*)memchr(ptr, theChar,aLength-anOffset);
if(result) {
return result-aDest;
}
}
return kNotFound;
}
/**
* This methods cans the given buffer for the given char
*
* @update gess 3/25/98
* @param aDest is the buffer to be searched
* @param aLength is the size (in char-units, not bytes) of the buffer
* @param anOffset is the start pos to begin searching
* @param aChar is the target character we're looking for
* @param aIgnorecase tells us whether to use a case sensitive search
* @return index of pos if found, else -1 (kNotFound)
*/
inline PRInt32 FindChar2(const char* aDest,PRUint32 aLength,PRUint32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase) {
const PRUnichar* root=(PRUnichar*)aDest;
const PRUnichar* ptr=root+(anOffset-1);
const PRUnichar* last=root+aLength;
if(aIgnoreCase) {
PRUnichar theChar=nsCRT::ToUpper(aChar);
while(++ptr<last){
if(nsCRT::ToUpper(*ptr)==theChar)
return ptr-root;
}
}
else {
while(++ptr<last){
if(*ptr==aChar)
return (ptr-root);
}
}
return kNotFound;
}
/**
* This methods cans the given buffer (in reverse) for the given char
*
* @update gess 3/25/98
* @param aDest is the buffer to be searched
* @param aLength is the size (in char-units, not bytes) of the buffer
* @param anOffset is the start pos to begin searching
* @param aChar is the target character we're looking for
* @param aIgnorecase tells us whether to use a case sensitive search
* @return index of pos if found, else -1 (kNotFound)
*/
inline PRInt32 RFindChar1(const char* aDest,PRUint32 aDestLength,PRUint32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase) {
PRInt32 theIndex=0;
if(aIgnoreCase) {
PRUnichar theChar=nsCRT::ToUpper(aChar);
for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){
if(nsCRT::ToUpper(aDest[theIndex])==theChar)
return theIndex;
}
}
else {
for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){
if(aDest[theIndex]==aChar)
return theIndex;
}
}
return kNotFound;
}
/**
* This methods cans the given buffer for the given char
*
* @update gess 3/25/98
* @param aDest is the buffer to be searched
* @param aLength is the size (in char-units, not bytes) of the buffer
* @param anOffset is the start pos to begin searching
* @param aChar is the target character we're looking for
* @param aIgnorecase tells us whether to use a case sensitive search
* @return index of pos if found, else -1 (kNotFound)
*/
inline PRInt32 RFindChar2(const char* aDest,PRUint32 aDestLength,PRUint32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase) {
PRInt32 theIndex=0;
PRUnichar* theBuf=(PRUnichar*)aDest;
if(aIgnoreCase) {
PRUnichar theChar=nsCRT::ToUpper(aChar);
for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){
if(nsCRT::ToUpper(theBuf[theIndex])==theChar)
return theIndex;
}
}
else {
for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){
if(theBuf[theIndex]==aChar)
return theIndex;
}
}
return kNotFound;
}
typedef PRInt32 (*FindChars)(const char* aDest,PRUint32 aDestLength,PRUint32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase);
FindChars gFindChars[]={&FindChar1,&FindChar2};
FindChars gRFindChars[]={&RFindChar1,&RFindChar2};
//----------------------------------------------------------------------------------------
//
// This set of methods is used to compare one buffer onto another.
// The functions are differentiated by the size of source and dest character sizes.
// WARNING: Your destination buffer MUST be big enough to hold all the source bytes.
// We don't validate these ranges here (this should be done in higher level routines).
//
/**
* This method compares the data in one buffer with another
* @update gess 01/04/99
* @param aStr1 is the first buffer to be compared
* @param aStr2 is the 2nd buffer to be compared
* @param aCount is the number of chars to compare
* @param aIgnorecase tells us whether to use a case-sensitive comparison
* @return -1,0,1 depending on <,==,>
*/
PRInt32 Compare1To1(const char* aStr1,const char* aStr2,PRUint32 aCount,PRBool aIgnoreCase){
PRInt32 result=0;
if(aIgnoreCase)
result=nsCRT::strncasecmp(aStr1,aStr2,aCount);
else result=strncmp(aStr1,aStr2,aCount);
return result;
}
/**
* This method compares the data in one buffer with another
* @update gess 01/04/99
* @param aStr1 is the first buffer to be compared
* @param aStr2 is the 2nd buffer to be compared
* @param aCount is the number of chars to compare
* @param aIgnorecase tells us whether to use a case-sensitive comparison
* @return -1,0,1 depending on <,==,>
*/
PRInt32 Compare2To2(const char* aStr1,const char* aStr2,PRUint32 aCount,PRBool aIgnoreCase){
PRInt32 result=0;
if(aIgnoreCase)
result=nsCRT::strncasecmp((PRUnichar*)aStr1,(PRUnichar*)aStr2,aCount);
else result=nsCRT::strncmp((PRUnichar*)aStr1,(PRUnichar*)aStr2,aCount);
return result;
}
/**
* This method compares the data in one buffer with another
* @update gess 01/04/99
* @param aStr1 is the first buffer to be compared
* @param aStr2 is the 2nd buffer to be compared
* @param aCount is the number of chars to compare
* @param aIgnorecase tells us whether to use a case-sensitive comparison
* @return -1,0,1 depending on <,==,>
*/
PRInt32 Compare2To1(const char* aStr1,const char* aStr2,PRUint32 aCount,PRBool aIgnoreCase){
PRInt32 result;
if(aIgnoreCase)
result=nsCRT::strncasecmp((PRUnichar*)aStr1,aStr2,aCount);
else result=nsCRT::strncmp((PRUnichar*)aStr1,aStr2,aCount);
return result;
}
/**
* This method compares the data in one buffer with another
* @update gess 01/04/99
* @param aStr1 is the first buffer to be compared
* @param aStr2 is the 2nd buffer to be compared
* @param aCount is the number of chars to compare
* @param aIgnorecase tells us whether to use a case-sensitive comparison
* @return -1,0,1 depending on <,==,>
*/
PRInt32 Compare1To2(const char* aStr1,const char* aStr2,PRUint32 aCount,PRBool aIgnoreCase){
PRInt32 result;
if(aIgnoreCase)
result=nsCRT::strncasecmp((PRUnichar*)aStr2,aStr1,aCount)*-1;
else result=nsCRT::strncmp((PRUnichar*)aStr2,aStr1,aCount)*-1;
return result;
}
typedef PRInt32 (*CompareChars)(const char* aStr1,const char* aStr2,PRUint32 aCount,PRBool aIgnoreCase);
CompareChars gCompare[2][2]={
{&Compare1To1,&Compare1To2},
{&Compare2To1,&Compare2To2},
};
//----------------------------------------------------------------------------------------
//
// This set of methods is used to convert the case of strings...
//
/**
* This method performs a case conversion the data in the given buffer
*
* @update gess 01/04/99
* @param aString is the buffer to be case shifted
* @param aCount is the number of chars to compare
* @param aToUpper tells us whether to convert to upper or lower
* @return 0
*/
PRInt32 ConvertCase1(char* aString,PRUint32 aCount,PRBool aToUpper){
PRInt32 result=0;
typedef char chartype;
chartype* cp = (chartype*)aString;
chartype* end = cp + aCount-1;
while (cp <= end) {
chartype ch = *cp;
if(aToUpper) {
if ((ch >= 'a') && (ch <= 'z')) {
*cp = 'A' + (ch - 'a');
}
}
else {
if ((ch >= 'A') && (ch <= 'Z')) {
*cp = 'a' + (ch - 'A');
}
}
cp++;
}
return result;
}
//----------------------------------------------------------------------------------------
#ifndef RICKG_TESTBED
class HandleCaseConversionShutdown3 : public nsIShutdownListener {
public :
NS_IMETHOD OnShutdown(const nsCID& cid, nsISupports* service);
HandleCaseConversionShutdown3(void) { NS_INIT_REFCNT(); }
virtual ~HandleCaseConversionShutdown3(void) {}
NS_DECL_ISUPPORTS
};
static NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
static NS_DEFINE_IID(kICaseConversionIID, NS_ICASECONVERSION_IID);
static NS_DEFINE_IID(kIShutdownListenerIID, NS_ISHUTDOWNLISTENER_IID);
static nsICaseConversion * gCaseConv = 0;
NS_IMPL_ISUPPORTS(HandleCaseConversionShutdown3, kIShutdownListenerIID);
nsresult HandleCaseConversionShutdown3::OnShutdown(const nsCID& cid, nsISupports* service) {
if (cid.Equals(kUnicharUtilCID)) {
NS_ASSERTION(service == gCaseConv, "wrong service!");
if(gCaseConv){
gCaseConv->Release();
gCaseConv = 0;
}
}
return NS_OK;
}
class CCaseConversionServiceInitializer {
public:
CCaseConversionServiceInitializer(){
mListener = new HandleCaseConversionShutdown3();
if(mListener){
mListener->AddRef();
nsServiceManager::GetService(kUnicharUtilCID, kICaseConversionIID,(nsISupports**) &gCaseConv, mListener);
}
}
protected:
HandleCaseConversionShutdown3* mListener;
};
#endif
//----------------------------------------------------------------------------------------
/**
* This method performs a case conversion the data in the given buffer
*
* @update gess 01/04/99
* @param aString is the buffer to be case shifted
* @param aCount is the number of chars to compare
* @param aToUpper tells us whether to convert to upper or lower
* @return 0
*/
PRInt32 ConvertCase2(char* aString,PRUint32 aCount,PRBool aToUpper){
PRUnichar* cp = (PRUnichar*)aString;
PRUnichar* end = cp + aCount-1;
PRInt32 result=0;
#ifndef RICKG_TESTBED
static CCaseConversionServiceInitializer gCaseConversionServiceInitializer;
// I18N code begin
if(gCaseConv) {
nsresult err=(aToUpper) ? gCaseConv->ToUpper(cp, cp, aCount) : gCaseConv->ToLower(cp, cp, aCount);
if(NS_SUCCEEDED(err))
return 0;
}
// I18N code end
#endif
while (cp <= end) {
PRUnichar ch = *cp;
if(aToUpper) {
if ((ch >= 'a') && (ch <= 'z')) {
*cp = 'A' + (ch - 'a');
}
}
else {
if ((ch >= 'A') && (ch <= 'Z')) {
*cp = 'a' + (ch - 'A');
}
}
cp++;
}
return result;
}
typedef PRInt32 (*CaseConverters)(char*,PRUint32,PRBool);
CaseConverters gCaseConverters[]={&ConvertCase1,&ConvertCase2};
//----------------------------------------------------------------------------------------
//
// This set of methods is used compress char sequences in a buffer...
//
/**
* This method compresses duplicate runs of a given char from the given buffer
*
* @update gess 01/04/99
* @param aString is the buffer to be manipulated
* @param aLength is the length of the buffer
* @param aSet tells us which chars to compress from given buffer
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
* @return the new length of the given buffer
*/
PRInt32 CompressChars1(char* aString,PRUint32 aLength,const char* aSet){
typedef char chartype;
chartype* from = aString;
chartype* end = aString + aLength-1;
chartype* to = from;
//this code converts /n, /t, /r into normal space ' ';
//it also compresses runs of whitespace down to a single char...
if(aSet && aString && (0 < aLength)){
PRUint32 aSetLen=strlen(aSet);
while (from <= end) {
chartype theChar = *from++;
if(kNotFound!=FindChar1(aSet,aSetLen,0,theChar,PR_FALSE)){
*to++=theChar;
while (from <= end) {
theChar = *from++;
if(kNotFound==FindChar1(aSet,aSetLen,0,theChar,PR_FALSE)){
*to++ = theChar;
break;
}
}
} else {
*to++ = theChar;
}
}
*to = 0;
}
return to - (chartype*)aString;
}
/**
* This method compresses duplicate runs of a given char from the given buffer
*
* @update gess 01/04/99
* @param aString is the buffer to be manipulated
* @param aLength is the length of the buffer
* @param aSet tells us which chars to compress from given buffer
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
* @return the new length of the given buffer
*/
PRInt32 CompressChars2(char* aString,PRUint32 aLength,const char* aSet){
typedef PRUnichar chartype;
chartype* from = (chartype*)aString;
chartype* end = from + aLength-1;
chartype* to = from;
//this code converts /n, /t, /r into normal space ' ';
//it also compresses runs of whitespace down to a single char...
if(aSet && aString && (0 < aLength)){
PRUint32 aSetLen=strlen(aSet);
while (from <= end) {
chartype theChar = *from++;
if(kNotFound!=FindChar1(aSet,aSetLen,0,theChar,PR_FALSE)){
*to++=theChar;
while (from <= end) {
theChar = *from++;
if(kNotFound==FindChar1(aSet,aSetLen,0,theChar,PR_FALSE)){
*to++ = theChar;
break;
}
}
} else {
*to++ = theChar;
}
}
*to = 0;
}
return to - (chartype*)aString;
}
typedef PRInt32 (*CompressChars)(char* aString,PRUint32 aCount,const char* aSet);
CompressChars gCompressChars[]={&CompressChars1,&CompressChars2};
/**
* This method strips chars in a given set from the given buffer
*
* @update gess 01/04/99
* @param aString is the buffer to be manipulated
* @param aLength is the length of the buffer
* @param aSet tells us which chars to compress from given buffer
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
* @return the new length of the given buffer
*/
PRInt32 StripChars1(char* aString,PRUint32 aLength,const char* aSet){
typedef char chartype;
chartype* to = aString;
chartype* from = aString-1;
chartype* end = aString + aLength;
if(aSet && aString && (0 < aLength)){
PRUint32 aSetLen=strlen(aSet);
while (++from < end) {
chartype theChar = *from;
if(kNotFound==FindChar1(aSet,aSetLen,0,theChar,PR_FALSE)){
*to++ = theChar;
}
}
*to = 0;
}
return to - (chartype*)aString;
}
/**
* This method strips chars in a given set from the given buffer
*
* @update gess 01/04/99
* @param aString is the buffer to be manipulated
* @param aLength is the length of the buffer
* @param aSet tells us which chars to compress from given buffer
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
* @return the new length of the given buffer
*/
PRInt32 StripChars2(char* aString,PRUint32 aLength,const char* aSet){
typedef PRUnichar chartype;
chartype* to = (chartype*)aString;
chartype* from = (chartype*)aString-1;
chartype* end = to + aLength;
if(aSet && aString && (0 < aLength)){
PRUint32 aSetLen=strlen(aSet);
while (++from < end) {
chartype theChar = *from;
if(kNotFound==FindChar1(aSet,aSetLen,0,theChar,PR_FALSE)){
*to++ = theChar;
}
}
*to = 0;
}
return to - (chartype*)aString;
}
typedef PRInt32 (*StripChars)(char* aString,PRUint32 aCount,const char* aSet);
StripChars gStripChars[]={&StripChars1,&StripChars2};
#endif

View File

@@ -1,120 +0,0 @@
#!nmake
#
# 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.
DEPTH=..\..
MODULE = xpcom
################################################################################
## exports
EXPORTS = \
nsTextFormater.h \
nsAVLTree.h \
nsCppSharedAllocator.h \
nsCRT.h \
nsDeque.h \
nsEnumeratorUtils.h \
nsHashtable.h \
nsHashtableEnumerator.h \
nsIArena.h \
nsIByteBuffer.h \
nsIObserverList.h \
nsIProperties.h \
nsISimpleEnumerator.h \
nsISizeOfHandler.h \
nsIUnicharBuffer.h \
nsIVariant.h \
nsInt64.h \
nsQuickSort.h \
nsStr.h \
nsString.h \
nsString2.h \
nsSupportsPrimitives.h \
nsTime.h \
nsUnitConversion.h \
nsVector.h \
nsVoidArray.h \
nsXPIDLString.h \
plvector.h \
$(NULL)
XPIDL_MODULE = xpcom_ds
XPIDLSRCS = \
.\nsIAtom.idl \
.\nsICollection.idl \
.\nsIEnumerator.idl \
.\nsIObserver.idl \
.\nsIObserverService.idl \
.\nsISupportsArray.idl \
.\nsISupportsPrimitives.idl \
$(NULL)
################################################################################
## library
LIBRARY_NAME=xpcomds_s
LINCS = \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\uconv \
-I$(PUBLIC)\unicharutil \
$(NULL)
LCFLAGS = -D_IMPL_NS_COM -D_IMPL_NS_BASE -DWIN32_LEAN_AND_MEAN
CPP_OBJS = \
.\$(OBJDIR)\nsTextFormater.obj \
.\$(OBJDIR)\nsArena.obj \
.\$(OBJDIR)\nsAtomTable.obj \
.\$(OBJDIR)\nsAVLTree.obj \
.\$(OBJDIR)\nsByteBuffer.obj \
.\$(OBJDIR)\nsCRT.obj \
.\$(OBJDIR)\nsConjoiningEnumerator.obj \
.\$(OBJDIR)\nsDeque.obj \
.\$(OBJDIR)\nsEmptyEnumerator.obj \
.\$(OBJDIR)\nsEnumeratorUtils.obj \
.\$(OBJDIR)\nsHashtable.obj \
.\$(OBJDIR)\nsHashtableEnumerator.obj \
.\$(OBJDIR)\nsObserver.obj \
.\$(OBJDIR)\nsObserverList.obj \
.\$(OBJDIR)\nsObserverService.obj \
.\$(OBJDIR)\nsProperties.obj \
.\$(OBJDIR)\nsQuickSort.obj \
.\$(OBJDIR)\nsSizeOfHandler.obj \
.\$(OBJDIR)\nsStr.obj \
.\$(OBJDIR)\nsString.obj \
.\$(OBJDIR)\nsString2.obj \
.\$(OBJDIR)\nsSupportsArray.obj \
.\$(OBJDIR)\nsSupportsArrayEnumerator.obj \
.\$(OBJDIR)\nsSupportsPrimitives.obj \
.\$(OBJDIR)\nsUnicharBuffer.obj \
.\$(OBJDIR)\nsVariant.obj \
.\$(OBJDIR)\nsVoidArray.obj \
.\$(OBJDIR)\nsXPIDLString.obj \
.\$(OBJDIR)\plvector.obj \
$(NULL)
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib

View File

@@ -1,617 +0,0 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsAVLTree.h"
enum eLean {eLeft,eNeutral,eRight};
struct NS_COM nsAVLNode {
public:
nsAVLNode(void* aValue) {
mLeft=0;
mRight=0;
mSkew=eNeutral;
mValue=aValue;
}
nsAVLNode* mLeft;
nsAVLNode* mRight;
eLean mSkew;
void* mValue;
};
/************************************************************
Now begin the tree class. Don't forget that the comparison
between nodes must occur via the comparitor function,
otherwise all you're testing is pointer addresses.
************************************************************/
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
nsAVLTree::nsAVLTree(nsAVLNodeComparitor& aComparitor,
nsAVLNodeFunctor* aDeallocator) :
mComparitor(aComparitor), mDeallocator(aDeallocator) {
mRoot=0;
mCount=0;
}
static void
avlDeleteTree(nsAVLNode* aNode){
if (aNode) {
avlDeleteTree(aNode->mLeft);
avlDeleteTree(aNode->mRight);
delete aNode;
}
}
/**
*
* @update gess12/27/98
* @param
* @return
*/
nsAVLTree::~nsAVLTree(){
if (mDeallocator) {
ForEachDepthFirst(*mDeallocator);
}
avlDeleteTree(mRoot);
}
class CDoesntExist: public nsAVLNodeFunctor {
public:
CDoesntExist(const nsAVLTree& anotherTree) : mOtherTree(anotherTree) {
}
virtual void* operator()(void* anItem) {
void* result=mOtherTree.FindItem(anItem);
if(result)
return nsnull;
return anItem;
}
protected:
const nsAVLTree& mOtherTree;
};
/**
* This method compares two trees (members by identity).
* @update gess12/27/98
* @param tree to compare against
* @return true if they are identical (contain same stuff).
*/
PRBool nsAVLTree::operator==(const nsAVLTree& aCopy) const{
CDoesntExist functor(aCopy);
void* theItem=FirstThat(functor);
PRBool result=PRBool(!theItem);
return result;
}
/**
*
* @update gess12/27/98
* @param
* @return
*/
static void
avlRotateRight(nsAVLNode*& aRootNode){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
ptr2=aRootNode->mRight;
if(ptr2->mSkew==eRight) {
aRootNode->mRight=ptr2->mLeft;
ptr2->mLeft=aRootNode;
aRootNode->mSkew=eNeutral;
aRootNode=ptr2;
}
else {
ptr3=ptr2->mLeft;
ptr2->mLeft=ptr3->mRight;
ptr3->mRight=ptr2;
aRootNode->mRight=ptr3->mLeft;
ptr3->mLeft=aRootNode;
if(ptr3->mSkew==eLeft)
ptr2->mSkew=eRight;
else ptr2->mSkew=eNeutral;
if(ptr3->mSkew==eRight)
aRootNode->mSkew=eLeft;
else aRootNode->mSkew=eNeutral;
aRootNode=ptr3;
}
aRootNode->mSkew=eNeutral;
return;
}
/**
*
* @update gess12/27/98
* @param
* @return
*/
static void
avlRotateLeft(nsAVLNode*& aRootNode){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
ptr2=aRootNode->mLeft;
if(ptr2->mSkew==eLeft) {
aRootNode->mLeft=ptr2->mRight;
ptr2->mRight=aRootNode;
aRootNode->mSkew=eNeutral;
aRootNode=ptr2;
}
else {
ptr3=ptr2->mRight;
ptr2->mRight=ptr3->mLeft;
ptr3->mLeft=ptr2;
aRootNode->mLeft=ptr3->mRight;
ptr3->mRight=aRootNode;
if(ptr3->mSkew==eRight)
ptr2->mSkew=eLeft;
else ptr2->mSkew=eNeutral;
if(ptr3->mSkew==eLeft)
aRootNode->mSkew=eRight;
else aRootNode->mSkew=eNeutral;
aRootNode=ptr3;
}
aRootNode->mSkew=eNeutral;
return;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static eAVLStatus
avlInsert(nsAVLNode*& aRootNode, nsAVLNode* aNewNode,
nsAVLNodeComparitor& aComparitor) {
eAVLStatus result=eAVL_unknown;
if(!aRootNode) {
aRootNode = aNewNode;
return eAVL_ok;
}
if(aNewNode==aRootNode->mValue) {
return eAVL_duplicate;
}
PRInt32 theCompareResult=aComparitor(aRootNode->mValue,aNewNode->mValue);
if(0 < theCompareResult) { //if(anItem<aRootNode->mValue)
result=avlInsert(aRootNode->mLeft,aNewNode,aComparitor);
if(eAVL_ok==result) {
switch(aRootNode->mSkew){
case eLeft:
avlRotateLeft(aRootNode);
result=eAVL_fail;
break;
case eRight:
aRootNode->mSkew=eNeutral;
result=eAVL_fail;
break;
case eNeutral:
aRootNode->mSkew=eLeft;
break;
} //switch
}//if
} //if
else {
result=avlInsert(aRootNode->mRight,aNewNode,aComparitor);
if(eAVL_ok==result) {
switch(aRootNode->mSkew){
case eLeft:
aRootNode->mSkew=eNeutral;
result=eAVL_fail;
break;
case eRight:
avlRotateRight(aRootNode);
result=eAVL_fail;
break;
case eNeutral:
aRootNode->mSkew=eRight;
break;
} //switch
}
} //if
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static void
avlBalanceLeft(nsAVLNode*& aRootNode, PRBool& delOk){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
eLean balnc2;
eLean balnc3;
switch(aRootNode->mSkew){
case eLeft:
ptr2=aRootNode->mLeft;
balnc2=ptr2->mSkew;
if(balnc2!=eRight) {
aRootNode->mLeft=ptr2->mRight;
ptr2->mRight=aRootNode;
if(balnc2==eNeutral){
aRootNode->mSkew=eLeft;
ptr2->mSkew=eRight;
delOk=PR_FALSE;
}
else{
aRootNode->mSkew=eNeutral;
ptr2->mSkew=eNeutral;
}
aRootNode=ptr2;
}
else{
ptr3=ptr2->mRight;
balnc3=ptr3->mSkew;
ptr2->mRight=ptr3->mLeft;
ptr3->mLeft=ptr2;
aRootNode->mLeft=ptr3->mRight;
ptr3->mRight=aRootNode;
if(balnc3==eRight) {
ptr2->mSkew=eLeft;
}
else {
ptr2->mSkew=eNeutral;
}
if(balnc3==eLeft) {
aRootNode->mSkew=eRight;
}
else {
aRootNode->mSkew=eNeutral;
}
aRootNode=ptr3;
ptr3->mSkew=eNeutral;
}
break;
case eRight:
aRootNode->mSkew=eNeutral;
break;
case eNeutral:
aRootNode->mSkew=eLeft;
delOk=PR_FALSE;
break;
}//switch
return;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static void
avlBalanceRight(nsAVLNode*& aRootNode, PRBool& delOk){
nsAVLNode* ptr2;
nsAVLNode* ptr3;
eLean balnc2;
eLean balnc3;
switch(aRootNode->mSkew){
case eLeft:
aRootNode->mSkew=eNeutral;
break;
case eRight:
ptr2=aRootNode->mRight;
balnc2=ptr2->mSkew;
if(balnc2!=eLeft) {
aRootNode->mRight=ptr2->mLeft;
ptr2->mLeft=aRootNode;
if(balnc2==eNeutral){
aRootNode->mSkew=eRight;
ptr2->mSkew=eLeft;
delOk=PR_FALSE;
}
else{
aRootNode->mSkew=eNeutral;
ptr2->mSkew=eNeutral;
}
aRootNode=ptr2;
}
else{
ptr3=ptr2->mLeft;
balnc3=ptr3->mSkew;
ptr2->mLeft=ptr3->mRight;
ptr3->mRight=ptr2;
aRootNode->mRight=ptr3->mLeft;
ptr3->mLeft=aRootNode;
if(balnc3==eLeft) {
ptr2->mSkew=eRight;
}
else {
ptr2->mSkew=eNeutral;
}
if(balnc3==eRight) {
aRootNode->mSkew=eLeft;
}
else {
aRootNode->mSkew=eNeutral;
}
aRootNode=ptr3;
ptr3->mSkew=eNeutral;
}
break;
case eNeutral:
aRootNode->mSkew=eRight;
delOk=PR_FALSE;
break;
}//switch
return;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static eAVLStatus
avlRemoveChildren(nsAVLNode*& aRootNode,nsAVLNode*& anotherNode, PRBool& delOk){
eAVLStatus result=eAVL_ok;
if(!anotherNode->mRight){
aRootNode->mValue=anotherNode->mValue; //swap
anotherNode=anotherNode->mLeft;
delOk=PR_TRUE;
}
else{
avlRemoveChildren(aRootNode,anotherNode->mRight,delOk);
if(delOk)
avlBalanceLeft(anotherNode,delOk);
}
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
static eAVLStatus
avlRemove(nsAVLNode*& aRootNode, void* anItem, PRBool& delOk,
nsAVLNodeComparitor& aComparitor){
eAVLStatus result=eAVL_ok;
if(!aRootNode)
delOk=PR_FALSE;
else {
PRInt32 cmp=aComparitor(anItem,aRootNode->mValue);
if(cmp<0){
avlRemove(aRootNode->mLeft,anItem,delOk,aComparitor);
if(delOk)
avlBalanceRight(aRootNode,delOk);
}
else if(cmp>0){
avlRemove(aRootNode->mRight,anItem,delOk,aComparitor);
if(delOk)
avlBalanceLeft(aRootNode,delOk);
}
else{ //they match...
nsAVLNode* temp=aRootNode;
if(!aRootNode->mRight) {
aRootNode=aRootNode->mLeft;
delOk=PR_TRUE;
delete temp;
}
else if(!aRootNode->mLeft) {
aRootNode=aRootNode->mRight;
delOk=PR_TRUE;
delete temp;
}
else {
avlRemoveChildren(aRootNode,aRootNode->mLeft,delOk);
if(delOk)
avlBalanceRight(aRootNode,delOk);
}
}
}
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
eAVLStatus
nsAVLTree::AddItem(void* anItem){
eAVLStatus result=eAVL_ok;
nsAVLNode* theNewNode=new nsAVLNode(anItem);
result=avlInsert(mRoot,theNewNode,mComparitor);
if(eAVL_duplicate!=result)
mCount++;
else {
delete theNewNode;
}
return result;
}
/** ------------------------------------------------
*
*
* @update gess 4/22/98
* @param
* @return
*/ //----------------------------------------------
void* nsAVLTree::FindItem(void* aValue) const{
nsAVLNode* result=mRoot;
PRInt32 count=0;
while(result) {
count++;
PRInt32 cmp=mComparitor(aValue,result->mValue);
if(0==cmp) {
//we matched...
break;
}
else if(0>cmp){
//theNode was greater...
result=result->mLeft;
}
else {
//aValue is greater...
result=result->mRight;
}
}
if(result) {
return result->mValue;
}
return nsnull;
}
/**
*
* @update gess12/30/98
* @param
* @return
*/
eAVLStatus
nsAVLTree::RemoveItem(void* aValue){
PRBool delOk=PR_TRUE;
eAVLStatus result=avlRemove(mRoot,aValue,delOk,mComparitor);
if(eAVL_ok==result)
mCount--;
return result;
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
static void
avlForEachDepthFirst(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor){
if(aNode) {
avlForEachDepthFirst(aNode->mLeft,aFunctor);
avlForEachDepthFirst(aNode->mRight,aFunctor);
aFunctor(aNode->mValue);
}
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
void
nsAVLTree::ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const{
::avlForEachDepthFirst(mRoot,aFunctor);
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
static void
avlForEach(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
if(aNode) {
avlForEach(aNode->mLeft,aFunctor);
aFunctor(aNode->mValue);
avlForEach(aNode->mRight,aFunctor);
}
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
void
nsAVLTree::ForEach(nsAVLNodeFunctor& aFunctor) const{
::avlForEach(mRoot,aFunctor);
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
static void*
avlFirstThat(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
void* result=nsnull;
if(aNode) {
result = avlFirstThat(aNode->mLeft,aFunctor);
if (result) {
return result;
}
result = aFunctor(aNode->mValue);
if (result) {
return result;
}
result = avlFirstThat(aNode->mRight,aFunctor);
}
return result;
}
/**
*
* @update gess9/11/98
* @param
* @return
*/
void*
nsAVLTree::FirstThat(nsAVLNodeFunctor& aFunctor) const{
return ::avlFirstThat(mRoot,aFunctor);
}

View File

@@ -1,74 +0,0 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsAVLTree_h___
#define nsAVLTree_h___
#include "nscore.h"
enum eAVLStatus {eAVL_unknown,eAVL_ok,eAVL_fail,eAVL_duplicate};
struct nsAVLNode;
/**
*
* @update gess12/26/98
* @param anObject1 is the first object to be compared
* @param anObject2 is the second object to be compared
* @return -1,0,1 if object1 is less, equal, greater than object2
*/
class NS_COM nsAVLNodeComparitor {
public:
virtual PRInt32 operator()(void* anItem1,void* anItem2)=0;
};
class NS_COM nsAVLNodeFunctor {
public:
virtual void* operator()(void* anItem)=0;
};
class NS_COM nsAVLTree {
public:
nsAVLTree(nsAVLNodeComparitor& aComparitor, nsAVLNodeFunctor* aDeallocator);
~nsAVLTree(void);
PRBool operator==(const nsAVLTree& aOther) const;
PRInt32 GetCount(void) const {return mCount;}
//main functions...
eAVLStatus AddItem(void* anItem);
eAVLStatus RemoveItem(void* anItem);
void* FindItem(void* anItem) const;
void ForEach(nsAVLNodeFunctor& aFunctor) const;
void ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const;
void* FirstThat(nsAVLNodeFunctor& aFunctor) const;
protected:
nsAVLNode* mRoot;
PRInt32 mCount;
nsAVLNodeComparitor& mComparitor;
nsAVLNodeFunctor* mDeallocator;
};
#endif /* nsAVLTree_h___ */

View File

@@ -1,97 +0,0 @@
/* -*- 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.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 "nsArena.h"
#include "nsCRT.h"
ArenaImpl::ArenaImpl(void)
: mInitialized(PR_FALSE)
{
NS_INIT_REFCNT();
nsCRT::memset(&mPool, 0, sizeof(PLArenaPool));
}
NS_IMETHODIMP
ArenaImpl::Init(PRUint32 aBlockSize)
{
if (aBlockSize < NS_MIN_ARENA_BLOCK_SIZE) {
aBlockSize = NS_DEFAULT_ARENA_BLOCK_SIZE;
}
PL_INIT_ARENA_POOL(&mPool, "nsIArena", aBlockSize);
mBlockSize = aBlockSize;
mInitialized = PR_TRUE;
return NS_OK;
}
NS_IMPL_ISUPPORTS1(ArenaImpl, nsIArena)
ArenaImpl::~ArenaImpl()
{
if (mInitialized)
PL_FinishArenaPool(&mPool);
mInitialized = PR_FALSE;
}
NS_IMETHODIMP_(void*)
ArenaImpl::Alloc(PRUint32 size)
{
// Adjust size so that it's a multiple of sizeof(double)
PRUint32 align = size & (sizeof(double) - 1);
if (0 != align) {
size += sizeof(double) - align;
}
void* p;
PL_ARENA_ALLOCATE(p, &mPool, size);
return p;
}
NS_METHOD
ArenaImpl::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
ArenaImpl* it = new ArenaImpl();
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(it);
nsresult rv = it->QueryInterface(aIID, aResult);
NS_RELEASE(it);
return rv;
}
NS_COM nsresult NS_NewHeapArena(nsIArena** aInstancePtrResult,
PRUint32 aArenaBlockSize)
{
nsresult rv;
nsIArena* arena;
rv = ArenaImpl::Create(NULL, nsIArena::GetIID(), (void**)&arena);
if (NS_FAILED(rv)) return rv;
rv = arena->Init(aArenaBlockSize);
if (NS_FAILED(rv)) {
NS_RELEASE(arena);
return rv;
}
*aInstancePtrResult = arena;
return rv;
}

View File

@@ -1,50 +0,0 @@
/* -*- 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.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 nsArena_h__
#define nsArena_h__
#include "nsIArena.h"
#define PL_ARENA_CONST_ALIGN_MASK 7
#include "plarena.h"
// Simple arena implementation layered on plarena
class ArenaImpl : public nsIArena {
public:
ArenaImpl(void);
virtual ~ArenaImpl();
NS_DECL_ISUPPORTS
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
NS_IMETHOD Init(PRUint32 arenaBlockSize);
NS_IMETHOD_(void*) Alloc(PRUint32 size);
protected:
PLArenaPool mPool;
PRUint32 mBlockSize;
private:
PRBool mInitialized;
};
#endif // nsArena_h__

View File

@@ -1,172 +0,0 @@
/* -*- 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.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 "nsAtomTable.h"
#include "nsString.h"
#include "nsCRT.h"
#include "plhash.h"
#include "nsISizeOfHandler.h"
/**
* The shared hash table for atom lookups.
*/
static nsrefcnt gAtoms;
static struct PLHashTable* gAtomHashTable;
#if defined(DEBUG) && (defined(XP_UNIX) || defined(XP_PC))
static PRIntn
DumpAtomLeaks(PLHashEntry *he, PRIntn index, void *arg)
{
AtomImpl* atom = (AtomImpl*) he->value;
if (atom) {
nsAutoString tmp;
atom->ToString(tmp);
fputs(tmp, stdout);
fputs("\n", stdout);
}
return HT_ENUMERATE_NEXT;
}
#endif
NS_COM void NS_PurgeAtomTable(void)
{
if (gAtomHashTable) {
#if defined(DEBUG) && (defined(XP_UNIX) || defined(XP_PC))
if (gAtoms) {
if (getenv("MOZ_DUMP_ATOM_LEAKS")) {
printf("*** leaking %d atoms\n", gAtoms);
PL_HashTableEnumerateEntries(gAtomHashTable, DumpAtomLeaks, 0);
}
}
#endif
PL_HashTableDestroy(gAtomHashTable);
gAtomHashTable = nsnull;
}
}
AtomImpl::AtomImpl()
{
NS_INIT_REFCNT();
// Every live atom holds a reference on the atom hashtable
gAtoms++;
}
AtomImpl::~AtomImpl()
{
NS_PRECONDITION(nsnull != gAtomHashTable, "null atom hashtable");
if (nsnull != gAtomHashTable) {
PL_HashTableRemove(gAtomHashTable, mString);
nsrefcnt cnt = --gAtoms;
if (0 == cnt) {
// When the last atom is destroyed, the atom arena is destroyed
NS_ASSERTION(0 == gAtomHashTable->nentries, "bad atom table");
PL_HashTableDestroy(gAtomHashTable);
gAtomHashTable = nsnull;
}
}
}
NS_IMPL_ISUPPORTS1(AtomImpl, nsIAtom)
void* AtomImpl::operator new(size_t size, const PRUnichar* us, PRInt32 uslen)
{
size = size + uslen * sizeof(PRUnichar);
AtomImpl* ii = (AtomImpl*) ::operator new(size);
nsCRT::memcpy(ii->mString, us, uslen * sizeof(PRUnichar));
ii->mString[uslen] = 0;
return ii;
}
NS_IMETHODIMP
AtomImpl::ToString(nsString& aBuf) /*FIX: const */
{
aBuf.SetLength(0);
aBuf.Append(mString, nsCRT::strlen(mString));
return NS_OK;
}
NS_IMETHODIMP
AtomImpl::GetUnicode(const PRUnichar **aResult) /*FIX: const */
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = mString;
return NS_OK;
}
NS_IMETHODIMP
AtomImpl::SizeOf(nsISizeOfHandler* aHandler, PRUint32* _retval) /*FIX: const */
{
NS_ENSURE_ARG_POINTER(_retval);
PRUint32 sum = sizeof(*this) + nsCRT::strlen(mString) * sizeof(PRUnichar);
*_retval = sum;
return NS_OK;
}
//----------------------------------------------------------------------
static PLHashNumber HashKey(const PRUnichar* k)
{
return (PLHashNumber) nsCRT::HashValue(k);
}
static PRIntn CompareKeys(const PRUnichar* k1, const PRUnichar* k2)
{
return nsCRT::strcmp(k1, k2) == 0;
}
NS_COM nsIAtom* NS_NewAtom(const char* isolatin1)
{
nsAutoString tmp(isolatin1);
return NS_NewAtom(tmp.GetUnicode());
}
NS_COM nsIAtom* NS_NewAtom(const nsString& aString)
{
return NS_NewAtom(aString.GetUnicode());
}
NS_COM nsIAtom* NS_NewAtom(const PRUnichar* us)
{
if (nsnull == gAtomHashTable) {
gAtomHashTable = PL_NewHashTable(8, (PLHashFunction) HashKey,
(PLHashComparator) CompareKeys,
(PLHashComparator) nsnull,
nsnull, nsnull);
}
PRUint32 uslen;
PRUint32 hashCode = nsCRT::HashValue(us, &uslen);
PLHashEntry** hep = PL_HashTableRawLookup(gAtomHashTable, hashCode, us);
PLHashEntry* he = *hep;
if (nsnull != he) {
nsIAtom* id = (nsIAtom*) he->value;
NS_ADDREF(id);
return id;
}
AtomImpl* id = new(us, uslen) AtomImpl();
PL_HashTableRawAdd(gAtomHashTable, hep, hashCode, id->mString, id);
NS_ADDREF(id);
return id;
}
NS_COM nsrefcnt NS_GetNumberOfAtoms(void)
{
if (nsnull != gAtomHashTable) {
NS_PRECONDITION(nsrefcnt(gAtomHashTable->nentries) == gAtoms, "bad atom table");
}
return gAtoms;
}

View File

@@ -1,43 +0,0 @@
/* -*- 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.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 nsAtomTable_h__
#define nsAtomTable_h__
#include "nsIAtom.h"
class AtomImpl : public nsIAtom {
public:
AtomImpl();
virtual ~AtomImpl();
NS_DECL_ISUPPORTS
NS_DECL_NSIATOM
void* operator new(size_t size, const PRUnichar* us, PRInt32 uslen);
void operator delete(void* ptr) {
::operator delete(ptr);
}
// Actually more; 0 terminated. This slot is reserved for the
// terminating zero.
PRUnichar mString[1];
};
#endif // nsAtomTable_h__

View File

@@ -1,723 +0,0 @@
/* -*- 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 "nsBuffer.h"
#include "nsAutoLock.h"
#include "nsCRT.h"
#include "nsIInputStream.h"
#include "nsIServiceManager.h"
#include "nsIPageManager.h"
////////////////////////////////////////////////////////////////////////////////
nsBuffer::nsBuffer()
: mGrowBySize(0),
mMaxSize(0),
mAllocator(nsnull),
mObserver(nsnull),
mBufferSize(0),
mReadSegment(nsnull),
mReadCursor(0),
mWriteSegment(nsnull),
mWriteCursor(0),
mReaderClosed(PR_FALSE),
mCondition(NS_OK)
{
NS_INIT_REFCNT();
PR_INIT_CLIST(&mSegments);
}
NS_IMETHODIMP
nsBuffer::Init(PRUint32 growBySize, PRUint32 maxSize,
nsIBufferObserver* observer, nsIAllocator* allocator)
{
NS_ASSERTION(sizeof(PRCList) <= SEGMENT_OVERHEAD,
"need to change SEGMENT_OVERHEAD size");
NS_ASSERTION(growBySize > SEGMENT_OVERHEAD, "bad growBySize");
mGrowBySize = growBySize;
mMaxSize = maxSize;
mObserver = observer;
NS_IF_ADDREF(mObserver);
mAllocator = allocator;
NS_ADDREF(mAllocator);
return NS_OK;
}
nsBuffer::~nsBuffer()
{
// Free any allocated pages...
while (!PR_CLIST_IS_EMPTY(&mSegments)) {
PRCList* header = (PRCList*)mSegments.next;
char* segment = (char*)header;
PR_REMOVE_LINK(header); // unlink from mSegments
(void) mAllocator->Free(segment);
}
NS_IF_RELEASE(mObserver);
NS_IF_RELEASE(mAllocator);
}
NS_IMPL_ISUPPORTS1(nsBuffer, nsIBuffer)
NS_METHOD
nsBuffer::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsBuffer* buf = new nsBuffer();
if (buf == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(buf);
nsresult rv = buf->QueryInterface(aIID, aResult);
NS_RELEASE(buf);
return rv;
}
////////////////////////////////////////////////////////////////////////////////
nsresult
nsBuffer::PushWriteSegment()
{
nsAutoCMonitor mon(this); // protect mSegments
if (mBufferSize >= mMaxSize) {
if (mObserver) {
nsresult rv = mObserver->OnFull(this);
if (NS_FAILED(rv)) return rv;
}
return NS_BASE_STREAM_WOULD_BLOCK;
}
// allocate a new segment to write into
PRCList* header;
header = (PRCList*)mAllocator->Alloc(mGrowBySize);
if (header == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
mBufferSize += mGrowBySize;
PR_INSERT_BEFORE(header, &mSegments); // insert at end
// initialize the write segment
mWriteSegment = header;
mWriteSegmentEnd = (char*)mWriteSegment + mGrowBySize;
mWriteCursor = (char*)mWriteSegment + sizeof(PRCList);
return NS_OK;
}
nsresult
nsBuffer::PopReadSegment()
{
nsresult rv;
nsAutoCMonitor mon(this); // protect mSegments
PRCList* header = (PRCList*)mSegments.next;
char* segment = (char*)header;
NS_ASSERTION(mReadSegment == header, "wrong segment");
// make sure that the writer isn't still in this segment (that the
// reader is removing)
NS_ASSERTION(!(segment <= mWriteCursor && mWriteCursor < segment + mGrowBySize),
"removing writer's segment");
PR_REMOVE_LINK(header); // unlink from mSegments
mBufferSize -= mGrowBySize;
rv = mAllocator->Free(segment);
if (NS_FAILED(rv)) return rv;
// initialize the read segment
if (PR_CLIST_IS_EMPTY(&mSegments)) {
mReadSegment = nsnull;
mReadSegmentEnd = nsnull;
mReadCursor = nsnull;
if (mObserver) {
rv = mObserver->OnEmpty(this);
if (NS_FAILED(rv)) return rv;
}
return NS_BASE_STREAM_WOULD_BLOCK;
}
else {
mReadSegment = mSegments.next;
mReadSegmentEnd = (char*)mReadSegment + mGrowBySize;
mReadCursor = (char*)mReadSegment + sizeof(PRCList);
}
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsIBuffer methods:
NS_IMETHODIMP
nsBuffer::ReadSegments(nsWriteSegmentFun writer, void* closure, PRUint32 count,
PRUint32 *readCount)
{
NS_ASSERTION(!mReaderClosed, "state change error");
nsAutoCMonitor mon(this);
nsresult rv = NS_OK;
PRUint32 readBufferLen;
const char* readBuffer;
*readCount = 0;
while (count > 0) {
rv = GetReadSegment(0, &readBuffer, &readBufferLen);
if (NS_FAILED(rv) || readBufferLen == 0) {
return *readCount == 0 ? rv : NS_OK;
}
readBufferLen = PR_MIN(readBufferLen, count);
while (readBufferLen > 0) {
PRUint32 writeCount;
rv = writer(closure, readBuffer, *readCount, readBufferLen, &writeCount);
NS_ASSERTION(rv != NS_BASE_STREAM_EOF, "Write should not return EOF");
if (rv == NS_BASE_STREAM_WOULD_BLOCK || NS_FAILED(rv) || writeCount == 0) {
// if we failed to write just report what we were
// able to read so far
return *readCount == 0 ? rv : NS_OK;
}
NS_ASSERTION(writeCount <= readBufferLen, "writer returned bad writeCount");
readBuffer += writeCount;
readBufferLen -= writeCount;
*readCount += writeCount;
count -= writeCount;
if (mReadCursor + writeCount == mReadSegmentEnd) {
rv = PopReadSegment();
if (NS_FAILED(rv)) {
return *readCount == 0 ? rv : NS_OK;
}
}
else {
mReadCursor += writeCount;
}
}
}
return NS_OK;
}
static NS_METHOD
nsWriteToRawBuffer(void* closure,
const char* fromRawSegment,
PRUint32 offset,
PRUint32 count,
PRUint32 *writeCount)
{
char* toBuf = (char*)closure;
nsCRT::memcpy(&toBuf[offset], fromRawSegment, count);
*writeCount = count;
return NS_OK;
}
NS_IMETHODIMP
nsBuffer::Read(char* toBuf, PRUint32 bufLen, PRUint32 *readCount)
{
return ReadSegments(nsWriteToRawBuffer, toBuf, bufLen, readCount);
}
NS_IMETHODIMP
nsBuffer::GetReadSegment(PRUint32 segmentLogicalOffset,
const char* *resultSegment,
PRUint32 *resultSegmentLen)
{
nsAutoCMonitor mon(this);
// set the read segment and cursor if not already set
if (mReadSegment == nsnull) {
if (PR_CLIST_IS_EMPTY(&mSegments)) {
*resultSegmentLen = 0;
*resultSegment = nsnull;
return mCondition;
}
else {
mReadSegment = mSegments.next;
mReadSegmentEnd = (char*)mReadSegment + mGrowBySize;
mReadCursor = (char*)mReadSegment + sizeof(PRCList);
}
}
// now search for the segment starting from segmentLogicalOffset and return it
PRCList* curSeg = mReadSegment;
char* curSegStart = mReadCursor;
char* curSegEnd = mReadSegmentEnd;
PRInt32 amt;
PRInt32 offset = (PRInt32)segmentLogicalOffset;
while (offset >= 0) {
// snapshot the write cursor into a local variable -- this allows
// a writer to freely change it while we're reading while avoiding
// using a lock
char* snapshotWriteCursor = mWriteCursor; // atomic
// next check if the write cursor is in our segment
if (curSegStart <= snapshotWriteCursor &&
snapshotWriteCursor < curSegEnd) {
// same segment -- read up to the snapshotWriteCursor
curSegEnd = snapshotWriteCursor;
amt = curSegEnd - curSegStart;
if (offset < amt) {
// segmentLogicalOffset is in this segment, so read up to its end
*resultSegmentLen = amt - offset;
*resultSegment = curSegStart + offset;
return NS_OK;
}
else {
// don't continue past the write segment
*resultSegmentLen = 0;
*resultSegment = nsnull;
return mCondition;
}
}
else {
amt = curSegEnd - curSegStart;
if (offset < amt) {
// segmentLogicalOffset is in this segment, so read up to its end
*resultSegmentLen = amt - offset;
*resultSegment = curSegStart + offset;
return NS_OK;
}
else {
curSeg = PR_NEXT_LINK(curSeg);
if (curSeg == mReadSegment) {
// been all the way around
*resultSegmentLen = 0;
*resultSegment = nsnull;
return mCondition;
}
curSegEnd = (char*)curSeg + mGrowBySize;
curSegStart = (char*)curSeg + sizeof(PRCList);
offset -= amt;
}
}
}
NS_NOTREACHED("nsBuffer::GetReadSegment failed");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsBuffer::GetReadableAmount(PRUint32 *result)
{
NS_ASSERTION(!mReaderClosed, "state change error");
nsAutoCMonitor mon(this);
*result = 0;
// first set the read segment and cursor if not already set
if (mReadSegment == nsnull) {
if (PR_CLIST_IS_EMPTY(&mSegments)) {
return NS_OK;
}
else {
mReadSegment = mSegments.next;
mReadSegmentEnd = (char*)mReadSegment + mGrowBySize;
mReadCursor = (char*)mReadSegment + sizeof(PRCList);
}
}
// now search for the segment starting from segmentLogicalOffset and return it
PRCList* curSeg = mReadSegment;
char* curSegStart = mReadCursor;
char* curSegEnd = mReadSegmentEnd;
PRInt32 amt;
while (PR_TRUE) {
// snapshot the write cursor into a local variable -- this allows
// a writer to freely change it while we're reading while avoiding
// using a lock
char* snapshotWriteCursor = mWriteCursor; // atomic
// next check if the write cursor is in our segment
if (curSegStart <= snapshotWriteCursor &&
snapshotWriteCursor < curSegEnd) {
// same segment -- read up to the snapshotWriteCursor
curSegEnd = snapshotWriteCursor;
amt = curSegEnd - curSegStart;
*result += amt;
return NS_OK;
}
else {
amt = curSegEnd - curSegStart;
*result += amt;
curSeg = PR_NEXT_LINK(curSeg);
if (curSeg == mReadSegment) {
// been all the way around
return NS_OK;
}
curSegEnd = (char*)curSeg + mGrowBySize;
curSegStart = (char*)curSeg + sizeof(PRCList);
}
}
return NS_ERROR_FAILURE;
}
#define COMPARE(s1, s2, i) ignoreCase ? nsCRT::strncasecmp((const char *)s1, (const char *)s2, (PRUint32)i) : nsCRT::strncmp((const char *)s1, (const char *)s2, (PRUint32)i)
NS_IMETHODIMP
nsBuffer::Search(const char* string, PRBool ignoreCase,
PRBool *found, PRUint32 *offsetSearchedTo)
{
NS_ASSERTION(!mReaderClosed, "state change error");
nsresult rv;
const char* bufSeg1;
PRUint32 bufSegLen1;
PRUint32 segmentPos = 0;
PRUint32 strLen = nsCRT::strlen(string);
rv = GetReadSegment(segmentPos, &bufSeg1, &bufSegLen1);
if (NS_FAILED(rv) || bufSegLen1 == 0) {
*found = PR_FALSE;
*offsetSearchedTo = segmentPos;
return NS_OK;
}
while (PR_TRUE) {
PRUint32 i;
// check if the string is in the buffer segment
for (i = 0; i < bufSegLen1 - strLen + 1; i++) {
if (COMPARE(&bufSeg1[i], string, strLen) == 0) {
*found = PR_TRUE;
*offsetSearchedTo = segmentPos + i;
return NS_OK;
}
}
// get the next segment
const char* bufSeg2;
PRUint32 bufSegLen2;
segmentPos += bufSegLen1;
rv = GetReadSegment(segmentPos, &bufSeg2, &bufSegLen2);
if (NS_FAILED(rv) || bufSegLen2 == 0) {
*found = PR_FALSE;
if (mCondition != NS_OK) // XXX NS_FAILED?
*offsetSearchedTo = segmentPos - bufSegLen1;
else
*offsetSearchedTo = segmentPos - bufSegLen1 - strLen + 1;
return NS_OK;
}
// check if the string is straddling the next buffer segment
PRUint32 limit = PR_MIN(strLen, bufSegLen2 + 1);
for (i = 0; i < limit; i++) {
PRUint32 strPart1Len = strLen - i - 1;
PRUint32 strPart2Len = strLen - strPart1Len;
const char* strPart2 = &string[strLen - strPart2Len];
PRUint32 bufSeg1Offset = bufSegLen1 - strPart1Len;
if (COMPARE(&bufSeg1[bufSeg1Offset], string, strPart1Len) == 0 &&
COMPARE(bufSeg2, strPart2, strPart2Len) == 0) {
*found = PR_TRUE;
*offsetSearchedTo = segmentPos - strPart1Len;
return NS_OK;
}
}
// finally continue with the next buffer
bufSeg1 = bufSeg2;
bufSegLen1 = bufSegLen2;
}
NS_NOTREACHED("can't get here");
return NS_ERROR_FAILURE; // keep compiler happy
}
NS_IMETHODIMP
nsBuffer::ReaderClosed()
{
nsresult rv = NS_OK;
nsAutoCMonitor mon(this); // protect mSegments
// first prevent any more writing
mReaderClosed = PR_TRUE;
// then free any unread segments...
// first set the read segment and cursor if not already set
if (mReadSegment == nsnull) {
if (!PR_CLIST_IS_EMPTY(&mSegments)) {
mReadSegment = mSegments.next;
mReadSegmentEnd = (char*)mReadSegment + mGrowBySize;
mReadCursor = (char*)mReadSegment + sizeof(PRCList);
}
}
while (mReadSegment) {
// snapshot the write cursor into a local variable -- this allows
// a writer to freely change it while we're reading while avoiding
// using a lock
char* snapshotWriteCursor = mWriteCursor; // atomic
// next check if the write cursor is in our segment
if (mReadCursor <= snapshotWriteCursor &&
snapshotWriteCursor < mReadSegmentEnd) {
// same segment -- we've discarded all the unread segments we
// can, so just updatethe read cursor
mReadCursor = mWriteCursor;
break;
}
// else advance to the next segment, freeing this one
rv = PopReadSegment();
if (NS_FAILED(rv)) break;
}
#ifdef DEBUG
PRUint32 amt;
const char* buf;
rv = GetReadSegment(0, &buf, &amt);
NS_ASSERTION(rv == NS_BASE_STREAM_EOF ||
(NS_SUCCEEDED(rv) && amt == 0), "ReaderClosed failed");
#endif
return rv;
}
NS_IMETHODIMP
nsBuffer::GetCondition(nsresult *result)
{
*result = mCondition;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsBuffer::WriteSegments(nsReadSegmentFun reader, void* closure, PRUint32 count,
PRUint32 *writeCount)
{
nsresult rv = NS_OK;
nsAutoCMonitor mon(this);
*writeCount = 0;
if (mReaderClosed) {
rv = NS_BASE_STREAM_CLOSED;
goto done;
}
if (NS_FAILED(mCondition)) {
rv = mCondition;
goto done;
}
while (count > 0) {
PRUint32 writeBufLen;
char* writeBuf;
rv = GetWriteSegment(&writeBuf, &writeBufLen);
if (NS_FAILED(rv) || writeBufLen == 0) {
// if we failed to allocate a new segment, we're probably out
// of memory, but we don't care -- just report what we were
// able to write so far
rv = (*writeCount == 0) ? rv : NS_OK;
goto done;
}
writeBufLen = PR_MIN(writeBufLen, count);
while (writeBufLen > 0) {
PRUint32 readCount = 0;
rv = reader(closure, writeBuf, *writeCount, writeBufLen, &readCount);
if (rv == NS_BASE_STREAM_WOULD_BLOCK || readCount == 0) {
// if the place we're putting the data would block (probably ran
// out of room) just return what we were able to write so far
rv = (*writeCount == 0) ? rv : NS_OK;
goto done;
}
if (NS_FAILED(rv)) {
// save the failure condition so that we can get it again later
nsresult rv2 = SetCondition(rv);
NS_ASSERTION(NS_SUCCEEDED(rv2), "SetCondition failed");
// if we failed to read just report what we were
// able to write so far
rv = (*writeCount == 0) ? rv : NS_OK;
goto done;
}
NS_ASSERTION(readCount <= writeBufLen, "reader returned bad readCount");
writeBuf += readCount;
writeBufLen -= readCount;
*writeCount += readCount;
count -= readCount;
// set the write cursor after the data is valid
if (mWriteCursor + readCount == mWriteSegmentEnd) {
mWriteSegment = nsnull; // allocate a new segment next time around
mWriteSegmentEnd = nsnull;
mWriteCursor = nsnull;
}
else
mWriteCursor += readCount;
}
}
done:
if (mObserver && *writeCount) {
mObserver->OnWrite(this, *writeCount);
}
return rv;
}
static NS_METHOD
nsReadFromRawBuffer(void* closure,
char* toRawSegment,
PRUint32 offset,
PRUint32 count,
PRUint32 *readCount)
{
const char* fromBuf = (const char*)closure;
nsCRT::memcpy(toRawSegment, &fromBuf[offset], count);
*readCount = count;
return NS_OK;
}
NS_IMETHODIMP
nsBuffer::Write(const char* fromBuf, PRUint32 bufLen, PRUint32 *writeCount)
{
return WriteSegments(nsReadFromRawBuffer, (void*)fromBuf, bufLen, writeCount);
}
static NS_METHOD
nsReadFromInputStream(void* closure,
char* toRawSegment,
PRUint32 offset,
PRUint32 count,
PRUint32 *readCount)
{
nsIInputStream* fromStream = (nsIInputStream*)closure;
return fromStream->Read(toRawSegment, count, readCount);
}
NS_IMETHODIMP
nsBuffer::WriteFrom(nsIInputStream* fromStream, PRUint32 count, PRUint32 *writeCount)
{
return WriteSegments(nsReadFromInputStream, fromStream, count, writeCount);
}
NS_IMETHODIMP
nsBuffer::GetWriteSegment(char* *resultSegment,
PRUint32 *resultSegmentLen)
{
nsAutoCMonitor mon(this);
if (mReaderClosed)
return NS_BASE_STREAM_CLOSED;
nsresult rv;
*resultSegmentLen = 0;
*resultSegment = nsnull;
if (mWriteSegment == nsnull) {
rv = PushWriteSegment();
if (NS_FAILED(rv) || rv == NS_BASE_STREAM_WOULD_BLOCK) return rv;
NS_ASSERTION(mWriteSegment != nsnull, "failed to allocate segment");
}
*resultSegmentLen = mWriteSegmentEnd - mWriteCursor;
*resultSegment = mWriteCursor;
NS_ASSERTION(*resultSegmentLen > 0, "Failed to get write segment.");
return NS_OK;
}
NS_IMETHODIMP
nsBuffer::GetWritableAmount(PRUint32 *amount)
{
if (mReaderClosed)
return NS_BASE_STREAM_CLOSED;
nsresult rv;
PRUint32 readableAmount;
rv = GetReadableAmount(&readableAmount);
if (NS_FAILED(rv)) return rv;
*amount = mMaxSize - readableAmount;
return NS_OK;
}
NS_IMETHODIMP
nsBuffer::GetReaderClosed(PRBool *result)
{
*result = mReaderClosed;
return NS_OK;
}
NS_IMETHODIMP
nsBuffer::SetCondition(nsresult condition)
{
nsAutoCMonitor mon(this);
if (mReaderClosed)
return NS_BASE_STREAM_CLOSED;
mCondition = condition;
mWriteSegment = nsnull; // allows reader to free last segment w/o asserting
mWriteSegmentEnd = nsnull;
// don't reset mWriteCursor here -- we need it for the EOF point in the buffer
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
static NS_DEFINE_CID(kAllocatorCID, NS_ALLOCATOR_CID);
NS_COM nsresult
NS_NewBuffer(nsIBuffer* *result,
PRUint32 growBySize, PRUint32 maxSize,
nsIBufferObserver* observer)
{
nsresult rv;
NS_WITH_SERVICE(nsIAllocator, alloc, kAllocatorCID, &rv);
if (NS_FAILED(rv)) return rv;
nsBuffer* buf;
rv = nsBuffer::Create(NULL, nsIBuffer::GetIID(), (void**)&buf);
if (NS_FAILED(rv)) return rv;
rv = buf->Init(growBySize, maxSize, observer, alloc);
if (NS_FAILED(rv)) {
NS_RELEASE(buf);
return rv;
}
*result = buf;
return NS_OK;
}
static NS_DEFINE_CID(kPageManagerCID, NS_PAGEMANAGER_CID);
NS_COM nsresult
NS_NewPageBuffer(nsIBuffer* *result,
PRUint32 growBySize, PRUint32 maxSize,
nsIBufferObserver* observer)
{
nsresult rv;
NS_WITH_SERVICE(nsIAllocator, alloc, kPageManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
nsBuffer* buf;
rv = nsBuffer::Create(NULL, nsIBuffer::GetIID(), (void**)&buf);
if (NS_FAILED(rv)) return rv;
rv = buf->Init(growBySize, maxSize, observer, alloc);
if (NS_FAILED(rv)) {
NS_RELEASE(buf);
return rv;
}
*result = buf;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,87 +0,0 @@
/* -*- 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.
*/
#ifndef nsBuffer_h___
#define nsBuffer_h___
#include "nsIBuffer.h"
#include "nscore.h"
#include "prclist.h"
#include "nsIAllocator.h"
class nsBuffer : public nsIBuffer {
public:
NS_DECL_ISUPPORTS
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
// nsIBuffer methods:
NS_IMETHOD Init(PRUint32 growBySize, PRUint32 maxSize,
nsIBufferObserver* observer, nsIAllocator* allocator);
NS_IMETHOD Read(char* toBuf, PRUint32 bufLen, PRUint32 *readCount);
NS_IMETHOD ReadSegments(nsWriteSegmentFun writer, void* closure, PRUint32 count,
PRUint32 *readCount);
NS_IMETHOD GetReadSegment(PRUint32 segmentLogicalOffset,
const char* *resultSegment,
PRUint32 *resultSegmentLen);
NS_IMETHOD GetReadableAmount(PRUint32 *amount);
NS_IMETHOD Search(const char* forString, PRBool ignoreCase,
PRBool *found, PRUint32 *offsetSearchedTo);
NS_IMETHOD ReaderClosed(void);
NS_IMETHOD GetCondition(nsresult *result);
NS_IMETHOD Write(const char* fromBuf, PRUint32 bufLen, PRUint32 *writeCount);
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count, PRUint32 *writeCount);
NS_IMETHOD WriteSegments(nsReadSegmentFun reader, void* closure, PRUint32 count,
PRUint32 *writeCount);
NS_IMETHOD GetWriteSegment(char* *resultSegment,
PRUint32 *resultSegmentLen);
NS_IMETHOD GetWritableAmount(PRUint32 *amount);
NS_IMETHOD GetReaderClosed(PRBool *result);
NS_IMETHOD SetCondition(nsresult condition);
// nsBuffer methods:
nsBuffer();
virtual ~nsBuffer();
nsresult PushWriteSegment();
nsresult PopReadSegment();
protected:
PRUint32 mGrowBySize;
PRUint32 mMaxSize;
nsIAllocator* mAllocator;
nsIBufferObserver* mObserver;
PRCList mSegments;
PRUint32 mBufferSize;
PRCList* mReadSegment;
char* mReadSegmentEnd;
char* mReadCursor;
PRCList* mWriteSegment;
char* mWriteSegmentEnd;
char* mWriteCursor;
PRBool mReaderClosed;
nsresult mCondition;
};
#endif // nsBuffer_h___

View File

@@ -1,40 +0,0 @@
/* -*- 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.
*/
#ifndef nsBufferPoolService_h___
#define nsBufferPoolService_h___
#include "nsIBufferPoolService.h"
class nsBufferPoolService : public nsIBufferPoolService {
public:
NS_DECL_ISUPPORTS
// nsIBufferPoolService methods:
NS_IMETHOD NewBuffer(PRUint32 minSize, PRUint32 maxSize,
nsIByteBuffer* *result);
// nsBufferPoolService methods:
nsBufferPoolService();
virtual ~nsBufferPoolService();
protected:
};
#endif // nsBufferPoolService_h___

View File

@@ -1,151 +0,0 @@
/* -*- 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.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 "nsByteBuffer.h"
#include "nsIInputStream.h"
#include "nsCRT.h"
#define MIN_BUFFER_SIZE 32
ByteBufferImpl::ByteBufferImpl(void)
: mBuffer(NULL), mSpace(0), mLength(0)
{
NS_INIT_REFCNT();
}
NS_IMETHODIMP
ByteBufferImpl::Init(PRUint32 aBufferSize)
{
if (aBufferSize < MIN_BUFFER_SIZE) {
aBufferSize = MIN_BUFFER_SIZE;
}
mSpace = aBufferSize;
mLength = 0;
mBuffer = new char[aBufferSize];
return mBuffer ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
NS_IMPL_ISUPPORTS1(ByteBufferImpl,nsIByteBuffer)
ByteBufferImpl::~ByteBufferImpl()
{
if (nsnull != mBuffer) {
delete[] mBuffer;
mBuffer = nsnull;
}
mLength = 0;
}
NS_METHOD
ByteBufferImpl::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
ByteBufferImpl* it = new ByteBufferImpl();
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(it);
nsresult rv = it->QueryInterface(aIID, (void**)aResult);
NS_RELEASE(it);
return rv;
}
NS_IMETHODIMP_(PRUint32)
ByteBufferImpl::GetLength(void) const
{
return mLength;
}
NS_IMETHODIMP_(PRUint32)
ByteBufferImpl::GetBufferSize(void) const
{
return mSpace;
}
NS_IMETHODIMP_(char*)
ByteBufferImpl::GetBuffer(void) const
{
return mBuffer;
}
NS_IMETHODIMP_(PRBool)
ByteBufferImpl::Grow(PRUint32 aNewSize)
{
if (aNewSize < MIN_BUFFER_SIZE) {
aNewSize = MIN_BUFFER_SIZE;
}
char* newbuf = new char[aNewSize];
if (nsnull != newbuf) {
if (0 != mLength) {
nsCRT::memcpy(newbuf, mBuffer, mLength);
}
delete[] mBuffer;
mBuffer = newbuf;
return PR_TRUE;
}
return PR_FALSE;
}
NS_IMETHODIMP_(PRInt32)
ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream,
PRUint32 aKeep)
{
NS_PRECONDITION(nsnull != aStream, "null stream");
NS_PRECONDITION(aKeep <= mLength, "illegal keep count");
if ((nsnull == aStream) || (PRUint32(aKeep) > PRUint32(mLength))) {
// whoops
*aErrorCode = NS_BASE_STREAM_ILLEGAL_ARGS;
return -1;
}
if (0 != aKeep) {
// Slide over kept data
nsCRT::memmove(mBuffer, mBuffer + (mLength - aKeep), aKeep);
}
// Read in some new data
mLength = aKeep;
PRUint32 nb;
*aErrorCode = aStream->Read(mBuffer + aKeep, mSpace - aKeep, &nb);
if (NS_SUCCEEDED(*aErrorCode)) {
mLength += nb;
}
else
nb = 0;
return nb;
}
NS_COM nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult,
nsISupports* aOuter,
PRUint32 aBufferSize)
{
nsresult rv;
nsIByteBuffer* buf;
rv = ByteBufferImpl::Create(aOuter, nsIByteBuffer::GetIID(), (void**)&buf);
if (NS_FAILED(rv)) return rv;
rv = buf->Init(aBufferSize);
if (NS_FAILED(rv)) {
NS_RELEASE(buf);
return rv;
}
*aInstancePtrResult = buf;
return rv;
}

View File

@@ -1,47 +0,0 @@
/* -*- 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.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 nsByteBuffer_h__
#define nsByteBuffer_h__
#include "nsIByteBuffer.h"
class ByteBufferImpl : public nsIByteBuffer {
public:
ByteBufferImpl(void);
virtual ~ByteBufferImpl();
NS_DECL_ISUPPORTS
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
NS_IMETHOD Init(PRUint32 aBufferSize);
NS_IMETHOD_(PRUint32) GetLength(void) const;
NS_IMETHOD_(PRUint32) GetBufferSize(void) const;
NS_IMETHOD_(char*) GetBuffer() const;
NS_IMETHOD_(PRBool) Grow(PRUint32 aNewSize);
NS_IMETHOD_(PRInt32) Fill(nsresult* aErrorCode, nsIInputStream* aStream,
PRUint32 aKeep);
char* mBuffer;
PRUint32 mSpace;
PRUint32 mLength;
};
#endif // nsByteBuffer_h__

View File

@@ -1,555 +0,0 @@
/* -*- 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.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.
*/
/**
* MODULE NOTES:
* @update gess7/30/98
*
* Much as I hate to do it, we were using string compares wrong.
* Often, programmers call functions like strcmp(s1,s2), and pass
* one or more null strings. Rather than blow up on these, I've
* added quick checks to ensure that cases like this don't cause
* us to fail.
*
* In general, if you pass a null into any of these string compare
* routines, we simply return 0.
*/
#include "nsCRT.h"
#include "nsUnicharUtilCIID.h"
#include "nsIServiceManager.h"
#include "nsICaseConversion.h"
// XXX Bug: These tables don't lowercase the upper 128 characters properly
// This table maps uppercase characters to lower case characters;
// characters that are neither upper nor lower case are unaffected.
static const unsigned char kUpper2Lower[256] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64,
// upper band mapped to lower [A-Z] => [a-z]
97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,
91, 92, 93, 94, 95,
96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
};
static const unsigned char kLower2Upper[256] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96,
// lower band mapped to upper [a-z] => [A-Z]
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
123,124,125,126,127,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
};
// XXX bug: this doesn't map 0x80 to 0x9f properly
const PRUnichar kIsoLatin1ToUCS2[256] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
};
//----------------------------------------------------------------------
#define TOLOWER(_ucs2) \
(((_ucs2) < 128) ? PRUnichar(kUpper2Lower[_ucs2]) : _ToLower(_ucs2))
#define TOUPPER(_ucs2) \
(((_ucs2) < 128) ? PRUnichar(kLower2Upper[_ucs2]) : _ToUpper(_ucs2))
class HandleCaseConversionShutdown : public nsIShutdownListener {
public :
NS_IMETHOD OnShutdown(const nsCID& cid, nsISupports* service);
HandleCaseConversionShutdown(void) { NS_INIT_REFCNT(); }
virtual ~HandleCaseConversionShutdown(void) {}
NS_DECL_ISUPPORTS
};
static NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
static nsICaseConversion * gCaseConv = NULL;
NS_IMPL_ISUPPORTS1(HandleCaseConversionShutdown, nsIShutdownListener)
nsresult
HandleCaseConversionShutdown::OnShutdown(const nsCID& cid,
nsISupports* aService)
{
if (cid.Equals(kUnicharUtilCID)) {
NS_ASSERTION(aService == gCaseConv, "wrong service!");
gCaseConv->Release();
gCaseConv = NULL;
}
return NS_OK;
}
static HandleCaseConversionShutdown* gListener = NULL;
static void StartUpCaseConversion()
{
nsresult err;
if ( NULL == gListener )
{
gListener = new HandleCaseConversionShutdown();
gListener->AddRef();
}
err = nsServiceManager::GetService(kUnicharUtilCID, NS_GET_IID(nsICaseConversion),
(nsISupports**) &gCaseConv, gListener);
}
static void CheckCaseConversion()
{
if(NULL == gCaseConv )
StartUpCaseConversion();
NS_ASSERTION( gCaseConv != NULL , "cannot obtain UnicharUtil");
}
static PRUnichar _ToLower(PRUnichar aChar)
{
PRUnichar oLower;
CheckCaseConversion();
nsresult err = gCaseConv->ToLower(aChar, &oLower);
NS_ASSERTION( NS_SUCCEEDED(err), "failed to communicate to UnicharUtil");
return ( NS_SUCCEEDED(err) ) ? oLower : aChar ;
}
static PRUnichar _ToUpper(PRUnichar aChar)
{
nsresult err;
PRUnichar oUpper;
CheckCaseConversion();
err = gCaseConv->ToUpper(aChar, &oUpper);
NS_ASSERTION( NS_SUCCEEDED(err), "failed to communicate to UnicharUtil");
return ( NS_SUCCEEDED(err) ) ? oUpper : aChar ;
}
//----------------------------------------------------------------------
PRUnichar nsCRT::ToUpper(PRUnichar aChar)
{
return TOUPPER(aChar);
}
PRUnichar nsCRT::ToLower(PRUnichar aChar)
{
return TOLOWER(aChar);
}
PRBool nsCRT::IsUpper(PRUnichar aChar)
{
return aChar != nsCRT::ToLower(aChar);
}
PRBool nsCRT::IsLower(PRUnichar aChar)
{
return aChar != nsCRT::ToUpper(aChar);
}
////////////////////////////////////////////////////////////////////////////////
// My lovely strtok routine
#define IS_DELIM(m, c) ((m)[(c) >> 3] & (1 << ((c) & 7)))
#define SET_DELIM(m, c) ((m)[(c) >> 3] |= (1 << ((c) & 7)))
#define DELIM_TABLE_SIZE 32
char* nsCRT::strtok(char* string, const char* delims, char* *newStr)
{
NS_ASSERTION(string, "Unlike regular strtok, the first argument cannot be null.");
char delimTable[DELIM_TABLE_SIZE];
PRUint32 i;
char* result;
char* str = string;
for (i = 0; i < DELIM_TABLE_SIZE; i++)
delimTable[i] = '\0';
for (i = 0; i < DELIM_TABLE_SIZE && delims[i]; i++) {
SET_DELIM(delimTable, delims[i]);
}
NS_ASSERTION(delims[i] == '\0', "too many delimiters");
// skip to beginning
while (*str && IS_DELIM(delimTable, *str)) {
str++;
}
result = str;
// fix up the end of the token
while (*str) {
if (IS_DELIM(delimTable, *str)) {
*str++ = '\0';
break;
}
str++;
}
*newStr = str;
return str == result ? NULL : result;
}
////////////////////////////////////////////////////////////////////////////////
PRUint32 nsCRT::strlen(const PRUnichar* s)
{
PRUint32 len = 0;
if(s) {
while (*s++ != 0) {
len++;
}
}
return len;
}
/**
* Compare unichar string ptrs, stopping at the 1st null
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @param s1 and s2 both point to unichar strings
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strcmp(const PRUnichar* s1, const PRUnichar* s2)
{
if(s1 && s2) {
for (;;) {
PRUnichar c1 = *s1++;
PRUnichar c2 = *s2++;
if (c1 != c2) {
if (c1 < c2) return -1;
return 1;
}
if ((0==c1) || (0==c2)) break;
}
}
return 0;
}
/**
* Compare unichar string ptrs, stopping at the 1st null or nth char.
* NOTE: If either is null, we return 0.
* @update gess7/30/98
* @param s1 and s2 both point to unichar strings
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n)
{
if(s1 && s2) {
if(n != 0) {
do {
PRUnichar c1 = *s1++;
PRUnichar c2 = *s2++;
if (c1 != c2) {
if (c1 < c2) return -1;
return 1;
}
if ((0==c1) || (0==c2)) break;
} while (--n != 0);
}
}
return 0;
}
/**
* Compare unichar string ptrs without regard to case
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @param s1 and s2 both point to unichar strings
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2)
{
if(s1 && s2) {
for (;;) {
PRUnichar c1 = *s1++;
PRUnichar c2 = *s2++;
if (c1 != c2) {
c1 = TOLOWER(c1);
c2 = TOLOWER(c2);
if (c1 != c2) {
if (c1 < c2) return -1;
return 1;
}
}
if ((0==c1) || (0==c2)) break;
}
}
return 0;
}
/**
* Compare unichar string ptrs, stopping at the 1st null or nth char;
* also ignoring the case of characters.
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @param s1 and s2 both point to unichar strings
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n)
{
if(s1 && s2) {
if(n != 0){
do {
PRUnichar c1 = *s1++;
PRUnichar c2 = *s2++;
if (c1 != c2) {
c1 = TOLOWER(c1);
c2 = TOLOWER(c2);
if (c1 != c2) {
if (c1 < c2) return -1;
return 1;
}
}
if ((0==c1) || (0==c2)) break;
} while (--n != 0);
}
}
return 0;
}
/**
* Compare a unichar string ptr to cstring.
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @param s1 points to unichar string
* @param s2 points to cstring
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strcmp(const PRUnichar* s1, const char* s2)
{
if(s1 && s2) {
for (;;) {
PRUnichar c1 = *s1++;
PRUnichar c2 = kIsoLatin1ToUCS2[*(const unsigned char*)s2++];
if (c1 != c2) {
if (c1 < c2) return -1;
return 1;
}
if ((0==c1) || (0==c2)) break;
}
}
return 0;
}
/**
* Compare a unichar string ptr to cstring, up to N chars.
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @param s1 points to unichar string
* @param s2 points to cstring
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRUint32 n)
{
if(s1 && s2) {
if(n != 0){
do {
PRUnichar c1 = *s1++;
PRUnichar c2 = kIsoLatin1ToUCS2[*(const unsigned char*)s2++];
if (c1 != c2) {
if (c1 < c2) return -1;
return 1;
}
if ((0==c1) || (0==c2)) break;
} while (--n != 0);
}
}
return 0;
}
/**
* Compare a unichar string ptr to cstring without regard to case
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @param s1 points to unichar string
* @param s2 points to cstring
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const char* s2)
{
if(s1 && s2) {
for (;;) {
PRUnichar c1 = *s1++;
PRUnichar c2 = kIsoLatin1ToUCS2[*(const unsigned char*)s2++];
if (c1 != c2) {
c1 = TOLOWER(c1);
c2 = TOLOWER(c2);
if (c1 != c2) {
if (c1 < c2) return -1;
return 1;
}
}
if ((0==c1) || (0==c2)) break;
}
}
return 0;
}
/**
* Caseless compare up to N chars between unichar string ptr to cstring.
* NOTE: If both are null, we return 0.
* @update gess7/30/98
* @param s1 points to unichar string
* @param s2 points to cstring
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRUint32 n)
{
if(s1 && s2){
if(n != 0){
do {
PRUnichar c1 = *s1++;
PRUnichar c2 = kIsoLatin1ToUCS2[*(const unsigned char*)s2++];
if (c1 != c2) {
c1 = TOLOWER(c1);
c2 = TOLOWER(c2);
if (c1 != c2) {
if (c1 < c2) return -1;
return 1;
}
}
if (c1 == 0) break;
} while (--n != 0);
}
}
return 0;
}
PRUnichar* nsCRT::strdup(const PRUnichar* str)
{
PRUint32 len = nsCRT::strlen(str) + 1; // add one for null
nsCppSharedAllocator<PRUnichar> shared_allocator;
PRUnichar* rslt = shared_allocator.allocate(len);
// PRUnichar* rslt = new PRUnichar[len];
if (rslt == NULL) return NULL;
nsCRT::memcpy(rslt, str, len * sizeof(PRUnichar));
return rslt;
}
PRUint32 nsCRT::HashValue(const char* us)
{
PRUint32 rv = 0;
if(us) {
char ch;
while ((ch = *us++) != 0) {
// FYI: rv = rv*37 + ch
rv = ((rv << 5) + (rv << 2) + rv) + ch;
}
}
return rv;
}
PRUint32 nsCRT::HashValue(const char* us, PRUint32* uslenp)
{
PRUint32 rv = 0;
PRUint32 len = 0;
char ch;
while ((ch = *us++) != 0) {
// FYI: rv = rv*37 + ch
rv = ((rv << 5) + (rv << 2) + rv) + ch;
len++;
}
*uslenp = len;
return rv;
}
PRUint32 nsCRT::HashValue(const PRUnichar* us)
{
PRUint32 rv = 0;
if(us) {
PRUnichar ch;
while ((ch = *us++) != 0) {
// FYI: rv = rv*37 + ch
rv = ((rv << 5) + (rv << 2) + rv) + ch;
}
}
return rv;
}
PRUint32 nsCRT::HashValue(const PRUnichar* us, PRUint32* uslenp)
{
PRUint32 rv = 0;
PRUint32 len = 0;
PRUnichar ch;
while ((ch = *us++) != 0) {
// FYI: rv = rv*37 + ch
rv = ((rv << 5) + (rv << 2) + rv) + ch;
len++;
}
*uslenp = len;
return rv;
}
PRInt32 nsCRT::atoi( const PRUnichar *string )
{
return atoi(string);
}

View File

@@ -1,239 +0,0 @@
/* -*- 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.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 nsCRT_h___
#define nsCRT_h___
#include <stdlib.h>
#include <string.h>
#include "plstr.h"
#include "nscore.h"
#include "prtypes.h"
#include "nsCppSharedAllocator.h"
#define CR '\015'
#define LF '\012'
#define VTAB '\013'
#define FF '\014'
#define TAB '\011'
#define CRLF "\015\012" /* A CR LF equivalent string */
#ifdef XP_MAC
# define NS_LINEBREAK "\015"
# define NS_LINEBREAK_LEN 1
#else
# ifdef XP_PC
# define NS_LINEBREAK "\015\012"
# define NS_LINEBREAK_LEN 2
# else
# if defined(XP_UNIX) || defined(XP_BEOS)
# define NS_LINEBREAK "\012"
# define NS_LINEBREAK_LEN 1
# endif /* XP_UNIX */
# endif /* XP_PC */
#endif /* XP_MAC */
extern const PRUnichar kIsoLatin1ToUCS2[256];
// This macro can be used in a class declaration for classes that want
// to ensure that their instance memory is zeroed.
#define NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW \
void* operator new(size_t sz) { \
void* rv = ::operator new(sz); \
if (rv) { \
nsCRT::zero(rv, sz); \
} \
return rv; \
} \
void operator delete(void* ptr) { \
::operator delete(ptr); \
}
// This macro works with the next macro to declare a non-inlined
// version of the above.
#define NS_DECL_ZEROING_OPERATOR_NEW \
void* operator new(size_t sz); \
void operator delete(void* ptr);
#define NS_IMPL_ZEROING_OPERATOR_NEW(_class) \
void* _class::operator new(size_t sz) { \
void* rv = ::operator new(sz); \
if (rv) { \
nsCRT::zero(rv, sz); \
} \
return rv; \
} \
void _class::operator delete(void* ptr) { \
::operator delete(ptr); \
}
// Freeing helper
#define CRTFREEIF(x) if (x) { nsCRT::free(x); x = 0; }
/// This is a wrapper class around all the C runtime functions.
class NS_COM nsCRT {
public:
/** Copy bytes from aSrc to aDest.
@param aDest the destination address
@param aSrc the source address
@param aCount the number of bytes to copy
*/
static void memcpy(void* aDest, const void* aSrc, PRUint32 aCount) {
::memcpy(aDest, aSrc, (size_t)aCount);
}
static void memmove(void* aDest, const void* aSrc, PRUint32 aCount) {
::memmove(aDest, aSrc, (size_t)aCount);
}
static void memset(void* aDest, PRUint8 aByte, PRUint32 aCount) {
::memset(aDest, aByte, aCount);
}
static void zero(void* aDest, PRUint32 aCount) {
::memset(aDest, 0, (size_t)aCount);
}
/** Compute the string length of s
@param s the string in question
@return the length of s
*/
static PRUint32 strlen(const char* s) {
return PRUint32(::strlen(s));
}
/// Compare s1 and s2.
static PRInt32 strcmp(const char* s1, const char* s2) {
return PRUint32(PL_strcmp(s1, s2));
}
static PRInt32 strncmp(const char* s1, const char* s2,
PRUint32 aMaxLen) {
return PRInt32(PL_strncmp(s1, s2, aMaxLen));
}
/// Case-insensitive string comparison.
static PRInt32 strcasecmp(const char* s1, const char* s2) {
return PRInt32(PL_strcasecmp(s1, s2));
}
/// Case-insensitive string comparison with length
static PRInt32 strncasecmp(const char* s1, const char* s2, PRUint32 aMaxLen) {
return PRInt32(PL_strncasecmp(s1, s2, aMaxLen));
}
static PRInt32 strncmp(const char* s1, const char* s2, PRInt32 aMaxLen) {
// inline the first test (assumes strings are not null):
PRInt32 diff = ((const unsigned char*)s1)[0] - ((const unsigned char*)s2)[0];
if (diff != 0) return diff;
return PRInt32(PL_strncmp(s1,s2,aMaxLen));
}
static char* strdup(const char* str) {
return PL_strdup(str);
}
static void free(char* str) {
PL_strfree(str);
}
/**
How to use this fancy (thread-safe) version of strtok:
void main( void ) {
printf( "%s\n\nTokens:\n", string );
// Establish string and get the first token:
char* newStr;
token = nsCRT::strtok( string, seps, &newStr );
while( token != NULL ) {
// While there are tokens in "string"
printf( " %s\n", token );
// Get next token:
token = nsCRT::strtok( newStr, seps, &newStr );
}
}
* WARNING - STRTOK WHACKS str THE FIRST TIME IT IS CALLED *
* MAKE A COPY OF str IF YOU NEED TO USE IT AFTER strtok() *
*/
static char* strtok(char* str, const char* delims, char* *newStr);
/// Like strlen except for ucs2 strings
static PRUint32 strlen(const PRUnichar* s);
/// Like strcmp except for ucs2 strings
static PRInt32 strcmp(const PRUnichar* s1, const PRUnichar* s2);
/// Like strcmp except for ucs2 strings
static PRInt32 strncmp(const PRUnichar* s1, const PRUnichar* s2,
PRUint32 aMaxLen);
/// Like strcasecmp except for ucs2 strings
static PRInt32 strcasecmp(const PRUnichar* s1, const PRUnichar* s2);
/// Like strncasecmp except for ucs2 strings
static PRInt32 strncasecmp(const PRUnichar* s1, const PRUnichar* s2,
PRUint32 aMaxLen);
/// Like strcmp with a char* and a ucs2 string
static PRInt32 strcmp(const PRUnichar* s1, const char* s2);
/// Like strncmp with a char* and a ucs2 string
static PRInt32 strncmp(const PRUnichar* s1, const char* s2,
PRUint32 aMaxLen);
/// Like strcasecmp with a char* and a ucs2 string
static PRInt32 strcasecmp(const PRUnichar* s1, const char* s2);
/// Like strncasecmp with a char* and a ucs2 string
static PRInt32 strncasecmp(const PRUnichar* s1, const char* s2,
PRUint32 aMaxLen);
// Note: uses new[] to allocate memory, so you must use delete[] to
// free the memory
static PRUnichar* strdup(const PRUnichar* str);
static void free(PRUnichar* str) {
nsCppSharedAllocator<PRUnichar> shared_allocator;
shared_allocator.deallocate(str, 0 /*we never new or kept the size*/);
}
/// Compute a hashcode for a C string
static PRUint32 HashValue(const char* s1);
/// Same as above except that we return the length in s1len
static PRUint32 HashValue(const char* s1, PRUint32* s1len);
/// Compute a hashcode for a ucs2 string
static PRUint32 HashValue(const PRUnichar* s1);
/// Same as above except that we return the length in s1len
static PRUint32 HashValue(const PRUnichar* s1, PRUint32* s1len);
/// String to integer.
static PRInt32 atoi( const PRUnichar *string );
static PRUnichar ToUpper(PRUnichar aChar);
static PRUnichar ToLower(PRUnichar aChar);
static PRBool IsUpper(PRUnichar aChar);
static PRBool IsLower(PRUnichar aChar);
};
#endif /* nsCRT_h___ */

View File

@@ -1,365 +0,0 @@
/* -*- 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.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 "nsIEnumerator.h"
////////////////////////////////////////////////////////////////////////////////
// Intersection Enumerators
////////////////////////////////////////////////////////////////////////////////
class nsConjoiningEnumerator : public nsIBidirectionalEnumerator
{
public:
NS_DECL_ISUPPORTS
// nsIEnumerator methods:
NS_DECL_NSIENUMERATOR
// nsIBidirectionalEnumerator methods:
NS_DECL_NSIBIDIRECTIONALENUMERATOR
// nsConjoiningEnumerator methods:
nsConjoiningEnumerator(nsIEnumerator* first, nsIEnumerator* second);
virtual ~nsConjoiningEnumerator(void);
protected:
nsIEnumerator* mFirst;
nsIEnumerator* mSecond;
nsIEnumerator* mCurrent;
};
nsConjoiningEnumerator::nsConjoiningEnumerator(nsIEnumerator* first, nsIEnumerator* second)
: mFirst(first), mSecond(second), mCurrent(first)
{
NS_ADDREF(mFirst);
NS_ADDREF(mSecond);
}
nsConjoiningEnumerator::~nsConjoiningEnumerator(void)
{
NS_RELEASE(mFirst);
NS_RELEASE(mSecond);
}
NS_IMPL_ISUPPORTS2(nsConjoiningEnumerator, nsIBidirectionalEnumerator, nsIEnumerator)
NS_IMETHODIMP
nsConjoiningEnumerator::First(void)
{
mCurrent = mFirst;
return mCurrent->First();
}
NS_IMETHODIMP
nsConjoiningEnumerator::Next(void)
{
nsresult rv = mCurrent->Next();
if (NS_FAILED(rv) && mCurrent == mFirst) {
mCurrent = mSecond;
rv = mCurrent->First();
}
return rv;
}
NS_IMETHODIMP
nsConjoiningEnumerator::CurrentItem(nsISupports **aItem)
{
return mCurrent->CurrentItem(aItem);
}
NS_IMETHODIMP
nsConjoiningEnumerator::IsDone(void)
{
return (mCurrent == mFirst && mCurrent->IsDone() == NS_OK)
|| (mCurrent == mSecond && mCurrent->IsDone() == NS_OK)
? NS_OK : NS_COMFALSE;
}
////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsConjoiningEnumerator::Last(void)
{
nsresult rv;
nsIBidirectionalEnumerator* be;
rv = mSecond->QueryInterface(nsIBidirectionalEnumerator::GetIID(), (void**)&be);
if (NS_FAILED(rv)) return rv;
mCurrent = mSecond;
rv = be->Last();
NS_RELEASE(be);
return rv;
}
NS_IMETHODIMP
nsConjoiningEnumerator::Prev(void)
{
nsresult rv;
nsIBidirectionalEnumerator* be;
rv = mCurrent->QueryInterface(nsIBidirectionalEnumerator::GetIID(), (void**)&be);
if (NS_FAILED(rv)) return rv;
rv = be->Prev();
NS_RELEASE(be);
if (NS_FAILED(rv) && mCurrent == mSecond) {
rv = mFirst->QueryInterface(nsIBidirectionalEnumerator::GetIID(), (void**)&be);
if (NS_FAILED(rv)) return rv;
mCurrent = mFirst;
rv = be->Last();
NS_RELEASE(be);
}
return rv;
}
////////////////////////////////////////////////////////////////////////////////
extern "C" NS_COM nsresult
NS_NewConjoiningEnumerator(nsIEnumerator* first, nsIEnumerator* second,
nsIBidirectionalEnumerator* *aInstancePtrResult)
{
if (aInstancePtrResult == 0)
return NS_ERROR_NULL_POINTER;
nsConjoiningEnumerator* e = new nsConjoiningEnumerator(first, second);
if (e == 0)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(e);
*aInstancePtrResult = e;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
static nsresult
nsEnumeratorContains(nsIEnumerator* e, nsISupports* item)
{
nsresult rv;
for (e->First(); e->IsDone() != NS_OK; e->Next()) {
nsISupports* other;
rv = e->CurrentItem(&other);
if (NS_FAILED(rv)) return rv;
if (item == other) {
NS_RELEASE(other);
return NS_OK; // true -- exists in enumerator
}
NS_RELEASE(other);
}
return NS_COMFALSE; // false -- doesn't exist
}
////////////////////////////////////////////////////////////////////////////////
// Intersection Enumerators
////////////////////////////////////////////////////////////////////////////////
class nsIntersectionEnumerator : public nsIEnumerator
{
public:
NS_DECL_ISUPPORTS
// nsIEnumerator methods:
NS_DECL_NSIENUMERATOR
// nsIntersectionEnumerator methods:
nsIntersectionEnumerator(nsIEnumerator* first, nsIEnumerator* second);
virtual ~nsIntersectionEnumerator(void);
protected:
nsIEnumerator* mFirst;
nsIEnumerator* mSecond;
};
nsIntersectionEnumerator::nsIntersectionEnumerator(nsIEnumerator* first, nsIEnumerator* second)
: mFirst(first), mSecond(second)
{
NS_ADDREF(mFirst);
NS_ADDREF(mSecond);
}
nsIntersectionEnumerator::~nsIntersectionEnumerator(void)
{
NS_RELEASE(mFirst);
NS_RELEASE(mSecond);
}
NS_IMPL_ISUPPORTS1(nsIntersectionEnumerator, nsIEnumerator)
NS_IMETHODIMP
nsIntersectionEnumerator::First(void)
{
nsresult rv = mFirst->First();
if (NS_FAILED(rv)) return rv;
return Next();
}
NS_IMETHODIMP
nsIntersectionEnumerator::Next(void)
{
nsresult rv;
// find the first item that exists in both
for (; mFirst->IsDone() != NS_OK; mFirst->Next()) {
nsISupports* item;
rv = mFirst->CurrentItem(&item);
if (NS_FAILED(rv)) return rv;
// see if it also exists in mSecond
rv = nsEnumeratorContains(mSecond, item);
if (NS_FAILED(rv)) return rv;
NS_RELEASE(item);
if (rv == NS_OK) {
// found in both, so return leaving it as the current item of mFirst
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsIntersectionEnumerator::CurrentItem(nsISupports **aItem)
{
return mFirst->CurrentItem(aItem);
}
NS_IMETHODIMP
nsIntersectionEnumerator::IsDone(void)
{
return mFirst->IsDone();
}
////////////////////////////////////////////////////////////////////////////////
extern "C" NS_COM nsresult
NS_NewIntersectionEnumerator(nsIEnumerator* first, nsIEnumerator* second,
nsIEnumerator* *aInstancePtrResult)
{
if (aInstancePtrResult == 0)
return NS_ERROR_NULL_POINTER;
nsIntersectionEnumerator* e = new nsIntersectionEnumerator(first, second);
if (e == 0)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(e);
*aInstancePtrResult = e;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// Union Enumerators
////////////////////////////////////////////////////////////////////////////////
class nsUnionEnumerator : public nsIEnumerator
{
public:
NS_DECL_ISUPPORTS
// nsIEnumerator methods:
NS_DECL_NSIENUMERATOR
// nsUnionEnumerator methods:
nsUnionEnumerator(nsIEnumerator* first, nsIEnumerator* second);
virtual ~nsUnionEnumerator(void);
protected:
nsIEnumerator* mFirst;
nsIEnumerator* mSecond;
};
nsUnionEnumerator::nsUnionEnumerator(nsIEnumerator* first, nsIEnumerator* second)
: mFirst(first), mSecond(second)
{
NS_ADDREF(mFirst);
NS_ADDREF(mSecond);
}
nsUnionEnumerator::~nsUnionEnumerator(void)
{
NS_RELEASE(mFirst);
NS_RELEASE(mSecond);
}
NS_IMPL_ISUPPORTS1(nsUnionEnumerator, nsIEnumerator)
NS_IMETHODIMP
nsUnionEnumerator::First(void)
{
nsresult rv = mFirst->First();
if (NS_FAILED(rv)) return rv;
return Next();
}
NS_IMETHODIMP
nsUnionEnumerator::Next(void)
{
nsresult rv;
// find the first item that exists in both
for (; mFirst->IsDone() != NS_OK; mFirst->Next()) {
nsISupports* item;
rv = mFirst->CurrentItem(&item);
if (NS_FAILED(rv)) return rv;
// see if it also exists in mSecond
rv = nsEnumeratorContains(mSecond, item);
if (NS_FAILED(rv)) return rv;
NS_RELEASE(item);
if (rv != NS_OK) {
// if it didn't exist in mSecond, return, making it the current item
return NS_OK;
}
// each time around, make sure that mSecond gets reset to the beginning
// so that when mFirst is done, we'll be ready to enumerate mSecond
rv = mSecond->First();
if (NS_FAILED(rv)) return rv;
}
return mSecond->Next();
}
NS_IMETHODIMP
nsUnionEnumerator::CurrentItem(nsISupports **aItem)
{
if (mFirst->IsDone() != NS_OK)
return mFirst->CurrentItem(aItem);
else
return mSecond->CurrentItem(aItem);
}
NS_IMETHODIMP
nsUnionEnumerator::IsDone(void)
{
return (mFirst->IsDone() == NS_OK && mSecond->IsDone() == NS_OK)
? NS_OK : NS_COMFALSE;
}
////////////////////////////////////////////////////////////////////////////////
extern "C" NS_COM nsresult
NS_NewUnionEnumerator(nsIEnumerator* first, nsIEnumerator* second,
nsIEnumerator* *aInstancePtrResult)
{
if (aInstancePtrResult == 0)
return NS_ERROR_NULL_POINTER;
nsUnionEnumerator* e = new nsUnionEnumerator(first, second);
if (e == 0)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(e);
*aInstancePtrResult = e;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,122 +0,0 @@
#ifndef nsCppSharedAllocator_h__
#define nsCppSharedAllocator_h__
#include "nsIAllocator.h" // for |nsAllocator|
#include "nscore.h" // for |NS_XXX_CAST|
#include <new.h> // to allow placement |new|
// under Metrowerks (Mac), we don't have autoconf yet
#ifdef __MWERKS__
#define HAVE_CPP_MEMBER_TEMPLATES
#define HAVE_CPP_NUMERIC_LIMITS
#endif
#ifdef HAVE_CPP_NUMERIC_LIMITS
#include <limits>
#else
#include <limits.h>
#endif
template <class T>
class nsCppSharedAllocator
/*
...allows Standard Library containers, et al, to use our global shared
(XP)COM-aware allocator.
*/
{
public:
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
nsCppSharedAllocator() { }
#ifdef HAVE_CPP_MEMBER_TEMPLATES
template <class U>
nsCppSharedAllocator( const nsCppSharedAllocator<U>& ) { }
#endif
~nsCppSharedAllocator() { }
pointer
address( reference r ) const
{
return &r;
}
const_pointer
address( const_reference r ) const
{
return &r;
}
pointer
allocate( size_type n, const void* /*hint*/=0 )
{
return NS_REINTERPRET_CAST(pointer, nsAllocator::Alloc(NS_STATIC_CAST(PRUint32, n*sizeof(T))));
}
void
deallocate( pointer p, size_type /*n*/ )
{
nsAllocator::Free(p);
}
void
construct( pointer p, const T& val )
{
new (p) T(val);
}
void
destroy( pointer p )
{
p->~T();
}
size_type
max_size() const
{
#ifdef HAVE_CPP_NUMERIC_LIMITS
return numeric_limits<size_type>::max() / sizeof(T);
#else
return ULONG_MAX / sizeof(T);
#endif
}
#ifdef HAVE_CPP_MEMBER_TEMPLATES
template <class U>
struct rebind
{
typedef nsCppSharedAllocator<U> other;
};
#endif
};
template <class T>
PRBool
operator==( const nsCppSharedAllocator<T>&, const nsCppSharedAllocator<T>& )
{
return PR_TRUE;
}
template <class T>
PRBool
operator!=( const nsCppSharedAllocator<T>&, const nsCppSharedAllocator<T>& )
{
return PR_FALSE;
}
#endif /* !defined(nsCppSharedAllocator_h__) */

View File

@@ -1,594 +0,0 @@
/* -*- 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.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 "nsDeque.h"
#include "nsCRT.h"
#include <stdio.h>
//#define _SELFTEST_DEQUE 1
#undef _SELFTEST_DEQUE
/**
* Standard constructor
* @update gess4/18/98
* @return new deque
*/
nsDeque::nsDeque(nsDequeFunctor* aDeallocator) {
mDeallocator=aDeallocator;
mOrigin=mSize=0;
mData=mBuffer; // don't allocate space until you must
mCapacity=sizeof(mBuffer)/sizeof(mBuffer[0]);
nsCRT::zero(mData,mCapacity*sizeof(mBuffer[0]));
}
/**
* Destructor
* @update gess4/18/98
*/
nsDeque::~nsDeque() {
#if 0
char buffer[30];
printf("Capacity: %i\n",mCapacity);
static int mCaps[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
switch(mCapacity) {
case 4: mCaps[0]++; break;
case 8: mCaps[1]++; break;
case 16: mCaps[2]++; break;
case 32: mCaps[3]++; break;
case 64: mCaps[4]++; break;
case 128: mCaps[5]++; break;
case 256: mCaps[6]++; break;
case 512: mCaps[7]++; break;
case 1024: mCaps[8]++; break;
case 2048: mCaps[9]++; break;
case 4096: mCaps[10]++; break;
default:
break;
}
#endif
Erase();
if(mData && (mData!=mBuffer))
delete [] mData;
mData=0;
if(mDeallocator) {
delete mDeallocator;
}
mDeallocator=0;
}
/**
*
* @update gess4/18/98
* @param
* @return
*/
void nsDeque::SetDeallocator(nsDequeFunctor* aDeallocator){
if(mDeallocator) {
delete mDeallocator;
}
mDeallocator=aDeallocator;
}
/**
* Remove all items from container without destroying them.
*
* @update gess4/18/98
* @param
* @return
*/
nsDeque& nsDeque::Empty() {
if((0<mCapacity) && (mData)) {
nsCRT::zero(mData,mCapacity*sizeof(mData));
}
mSize=0;
mOrigin=0;
return *this;
}
/**
* Remove and delete all items from container
*
* @update gess4/18/98
* @return this
*/
nsDeque& nsDeque::Erase() {
if(mDeallocator && mSize) {
ForEach(*mDeallocator);
}
return Empty();
}
/**
* This method adds an item to the end of the deque.
* This operation has the potential to cause the
* underlying buffer to resize.
*
* @update gess4/18/98
* @param anItem: new item to be added to deque
* @return nada
*/
nsDeque& nsDeque::GrowCapacity(void) {
PRInt32 theNewSize = mCapacity<<2;
void** temp=new void*[theNewSize];
//Here's the interesting part: You can't just move the elements
//directy (in situ) from the old buffer to the new one.
//Since capacity has changed, the old origin doesn't make
//sense anymore. It's better to resequence the elements now.
if(mData) {
int tempi=0;
int i=0;
int j=0;
for(i=mOrigin;i<mCapacity;i++) temp[tempi++]=mData[i]; //copy the leading elements...
for(j=0;j<mOrigin;j++) temp[tempi++]=mData[j]; //copy the trailing elements...
if(mData!=mBuffer)
delete [] mData;
}
mCapacity=theNewSize;
mOrigin=0; //now realign the origin...
mData=temp;
return *this;
}
/**
* This method adds an item to the end of the deque.
* This operation has the potential to cause the
* underlying buffer to resize.
*
* @update gess4/18/98
* @param anItem: new item to be added to deque
* @return nada
*/
nsDeque& nsDeque::Push(void* anItem) {
if(mSize==mCapacity) {
GrowCapacity();
}
int offset=mOrigin+mSize;
if(offset<mCapacity)
mData[offset]=anItem;
else mData[offset-mCapacity]=anItem;
mSize++;
return *this;
}
/**
* This method adds an item to the front of the deque.
* This operation has the potential to cause the
* underlying buffer to resize.
*
* @update gess4/18/98
* @param anItem: new item to be added to deque
* @return nada
*/
nsDeque& nsDeque::PushFront(void* anItem) {
if(mSize==mCapacity) {
GrowCapacity();
}
if(0==mOrigin){ //case1: [xxx..]
//mOrigin=mCapacity-1-mSize++;
mOrigin=mCapacity-1;
mData[mOrigin]=anItem;
}
else {// if(mCapacity==(mOrigin+mSize-1)){ //case2: [..xxx] and case3: [.xxx.]
mData[--mOrigin]=anItem;
}
mSize++;
return *this;
}
/**
* Remove and return the last item in the container.
*
* @update gess4/18/98
* @param none
* @return ptr to last item in container
*/
void* nsDeque::Pop(void) {
void* result=0;
if(mSize>0) {
int offset=mOrigin+mSize-1;
if(offset>=mCapacity)
offset-=mCapacity;
result=mData[offset];
mData[offset]=0;
mSize--;
if(0==mSize)
mOrigin=0;
}
return result;
}
/**
* This method gets called you want to remove and return
* the first member in the container.
*
* @update gess4/18/98
* @param nada
* @return last item in container
*/
void* nsDeque::PopFront() {
void* result=0;
if(mSize>0) {
NS_ASSERTION(mOrigin<mCapacity,"Error: Bad origin");
result=mData[mOrigin];
mData[mOrigin++]=0; //zero it out for debugging purposes.
mSize--;
if(mCapacity==mOrigin) //you popped off the end, so cycle back around...
mOrigin=0;
if(0==mSize)
mOrigin=0;
}
return result;
}
/**
* This method gets called you want to peek at the topmost
* member without removing it.
*
* @update gess4/18/98
* @param nada
* @return last item in container
*/
void* nsDeque::Peek() {
void* result=0;
if(mSize>0) {
result=mData[mOrigin];
}
return result;
}
/**
* Call this to retrieve the ith element from this container.
* Keep in mind that accessing the underlying elements is
* done in a relative fashion. Object 0 is not necessarily
* the first element (the first element is at mOrigin).
*
* @update gess4/18/98
* @param anIndex : 0 relative offset of item you want
* @return void* or null
*/
void* nsDeque::ObjectAt(PRInt32 anIndex) const {
void* result=0;
if((anIndex>=0) && (anIndex<mSize))
{
if(anIndex<(mCapacity-mOrigin)) {
result=mData[mOrigin+anIndex];
}
else {
result=mData[anIndex-(mCapacity-mOrigin)];
}
}
return result;
}
/**
* Create and return an iterator pointing to
* the beginning of the queue. Note that this
* takes the circular buffer semantics into account.
*
* @update gess4/18/98
* @return new deque iterator, init'ed to 1st item
*/
nsDequeIterator nsDeque::Begin(void) const{
return nsDequeIterator(*this,0);
}
/**
* Create and return an iterator pointing to
* the last of the queue. Note that this
* takes the circular buffer semantics into account.
*
* @update gess4/18/98
* @return new deque iterator, init'ed to last item
*/
nsDequeIterator nsDeque::End(void) const{
return nsDequeIterator(*this,mSize);
}
/**
* Call this method when you wanto to iterate all the
* members of the container, passing a functor along
* to call your code.
*
* @update gess4/20/98
* @param aFunctor object to call for each member
* @return *this
*/
void nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
int i=0;
for(i=0;i<mSize;i++){
void* obj=ObjectAt(i);
obj=aFunctor(obj);
}
}
/**
* Call this method when you wanto to iterate all the
* members of the container, passing a functor along
* to call your code. Iteration continues until your
* functor returns a non-null.
*
* @update gess4/20/98
* @param aFunctor object to call for each member
* @return *this
*/
const void* nsDeque::FirstThat(nsDequeFunctor& aFunctor) const{
int i=0;
for(i=0;i<mSize;i++){
void* obj=ObjectAt(i);
obj=aFunctor(obj);
if(obj)
return obj;
}
return 0;
}
/******************************************************
* Here comes the nsDequeIterator class...
******************************************************/
/**
* DequeIterator is an object that knows how to iterate (forward and backward)
* a Deque. Normally, you don't need to do this, but there are some special
* cases where it is pretty handy, so here you go.
*
* This is a standard dequeiterator constructor
*
* @update gess4/18/98
* @param aQueue is the deque object to be iterated
* @param anIndex is the starting position for your iteration
*/
nsDequeIterator::nsDequeIterator(const nsDeque& aQueue,int anIndex): mIndex(anIndex), mDeque(aQueue) {
}
/**
* Copy construct a new iterator beginning with given
*
* @update gess4/20/98
* @param aCopy is another iterator to copy from
* @return
*/
nsDequeIterator::nsDequeIterator(const nsDequeIterator& aCopy) : mIndex(aCopy.mIndex), mDeque(aCopy.mDeque) {
}
/**
* Moves iterator to first element in deque
* @update gess4/18/98
* @return this
*/
nsDequeIterator& nsDequeIterator::First(void){
mIndex=0;
return *this;
}
/**
* Standard assignment operator for dequeiterator
*
* @update gess4/18/98
* @param aCopy is an iterator to be copied from
* @return *this
*/
nsDequeIterator& nsDequeIterator::operator=(const nsDequeIterator& aCopy) {
//queue's are already equal.
mIndex=aCopy.mIndex;
return *this;
}
/**
* preform ! operation against to iterators to test for equivalence
* (or lack thereof)!
*
* @update gess4/18/98
* @param anIter is the object to be compared to
* @return TRUE if NOT equal.
*/
PRBool nsDequeIterator::operator!=(nsDequeIterator& anIter) {
return PRBool(!this->operator==(anIter));
}
/**
* Compare 2 iterators for equivalence.
*
* @update gess4/18/98
* @param anIter is the other iterator to be compared to
* @return TRUE if EQUAL
*/
PRBool nsDequeIterator::operator<(nsDequeIterator& anIter) {
return PRBool(((mIndex<anIter.mIndex) && (&mDeque==&anIter.mDeque)));
}
/**
* Compare 2 iterators for equivalence.
*
* @update gess4/18/98
* @param anIter is the other iterator to be compared to
* @return TRUE if EQUAL
*/
PRBool nsDequeIterator::operator==(nsDequeIterator& anIter) {
return PRBool(((mIndex==anIter.mIndex) && (&mDeque==&anIter.mDeque)));
}
/**
* Compare 2 iterators for equivalence.
*
* @update gess4/18/98
* @param anIter is the other iterator to be compared to
* @return TRUE if EQUAL
*/
PRBool nsDequeIterator::operator>=(nsDequeIterator& anIter) {
return PRBool(((mIndex>=anIter.mIndex) && (&mDeque==&anIter.mDeque)));
}
/**
* Pre-increment operator
*
* @update gess4/18/98
* @return object at preincremented index
*/
void* nsDequeIterator::operator++() {
return mDeque.ObjectAt(++mIndex);
}
/**
* Post-increment operator
*
* @update gess4/18/98
* @param param is ignored
* @return object at post-incremented index
*/
void* nsDequeIterator::operator++(int) {
return mDeque.ObjectAt(mIndex++);
}
/**
* Pre-decrement operator
*
* @update gess4/18/98
* @return object at pre-decremented index
*/
void* nsDequeIterator::operator--() {
return mDeque.ObjectAt(--mIndex);
}
/**
* Post-decrement operator
*
* @update gess4/18/98
* @param param is ignored
* @return object at post-decremented index
*/
void* nsDequeIterator::operator--(int) {
return mDeque.ObjectAt(mIndex--);
}
/**
* Dereference operator
*
* @update gess4/18/98
* @return object at ith index
*/
void* nsDequeIterator::GetCurrent(void) {
return mDeque.ObjectAt(mIndex);
}
/**
* Call this method when you wanto to iterate all the
* members of the container, passing a functor along
* to call your code.
*
* @update gess4/20/98
* @param aFunctor object to call for each member
* @return *this
*/
void nsDequeIterator::ForEach(nsDequeFunctor& aFunctor) const{
mDeque.ForEach(aFunctor);
}
/**
* Call this method when you wanto to iterate all the
* members of the container, passing a functor along
* to call your code.
*
* @update gess4/20/98
* @param aFunctor object to call for each member
* @return *this
*/
const void* nsDequeIterator::FirstThat(nsDequeFunctor& aFunctor) const{
return mDeque.FirstThat(aFunctor);
}
#ifdef _SELFTEST_DEQUE
/**************************************************************
Now define the token deallocator class...
**************************************************************/
class _SelfTestDeallocator: public nsDequeFunctor{
public:
_SelfTestDeallocator::_SelfTestDeallocator() {
nsDeque::SelfTest();
}
virtual void* operator()(void* anObject) {
return 0;
}
};
static _SelfTestDeallocator gDeallocator;
#endif
/**
* conduct automated self test for this class
*
* @update gess4/18/98
* @param
* @return
*/
void nsDeque::SelfTest(void) {
#ifdef _SELFTEST_DEQUE
{
nsDeque theDeque(gDeallocator); //construct a simple one...
int ints[200];
int count=sizeof(ints)/sizeof(int);
int i=0;
for(i=0;i<count;i++){ //initialize'em
ints[i]=10*(1+i);
}
for(i=0;i<70;i++){
theDeque.Push(&ints[i]);
}
for(i=0;i<56;i++){
int* temp=(int*)theDeque.Pop();
}
for(i=0;i<55;i++){
theDeque.Push(&ints[i]);
}
for(i=0;i<35;i++){
int* temp=(int*)theDeque.Pop();
}
for(i=0;i<35;i++){
theDeque.Push(&ints[i]);
}
for(i=0;i<38;i++){
int* temp=(int*)theDeque.Pop();
}
}
int x;
x=10;
#endif
}

View File

@@ -1,410 +0,0 @@
/* -*- 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.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.
*/
/**
* MODULE NOTES:
* @update gess 4/15/98 (tax day)
*
* The Deque is a very small, very efficient container object
* than can hold elements of type void*, offering the following features:
* It's interface supports pushing and poping of children.
* It can iterate (via an interator class) it's children.
* When full, it can efficently resize dynamically.
*
*
* NOTE: The only bit of trickery here is that this deque is
* built upon a ring-buffer. Like all ring buffers, the first
* element may not be at index[0]. The mOrigin member determines
* where the first child is. This point is quietly hidden from
* customers of this class.
*
*/
#ifndef _NSDEQUE
#define _NSDEQUE
#include "nscore.h"
/**
* The nsDequefunctor class is used when you want to create
* callbacks between the deque and your generic code.
* Use these objects in a call to ForEach();
*
* @update gess4/20/98
*/
class NS_COM nsDequeFunctor{
public:
virtual void* operator()(void* anObject)=0;
};
/******************************************************
* Here comes the nsDeque class itself...
******************************************************/
/**
* The deque (double-ended queue) class is a common container type,
* whose behavior mimics a line in your favorite checkout stand.
* Classic CS describes the common behavior of a queue as FIFO.
* A Deque allows items to be added and removed from either end of
* the queue.
*
* @update gess4/20/98
*/
class NS_COM nsDeque {
friend class nsDequeIterator;
public:
nsDeque(nsDequeFunctor* aDeallocator);
~nsDeque();
/**
* Returns the number of elements currently stored in
* this deque.
*
* @update gess4/18/98
* @param
* @return int contains element count
*/
inline PRInt32 GetSize() const { return mSize;}
/**
* Pushes new member onto the end of the deque
*
* @update gess4/18/98
* @param ptr to object to store
* @return *this
*/
nsDeque& Push(void* anItem);
/**
* Pushes new member onto the front of the deque
*
* @update gess4/18/98
* @param ptr to object to store
* @return *this
*/
nsDeque& PushFront(void* anItem);
/**
* Remove and return the first item in the container.
*
* @update gess4/18/98
* @param none
* @return ptr to first item in container
*/
void* Pop(void);
/**
* Remove and return the first item in the container.
*
* @update gess4/18/98
* @param none
* @return ptr to first item in container
*/
void* PopFront(void);
/**
* Return topmost item without removing it.
*
* @update gess4/18/98
* @param none
* @return ptr to first item in container
*/
void* Peek(void);
/**
* method used to retrieve ptr to
* ith member in container. DOesn't remove
* that item.
*
* @update gess4/18/98
* @param index of desired item
* @return ptr to ith element in list
*/
void* ObjectAt(int anIndex) const;
/**
* Remove all items from container without destroying them
*
* @update gess4/18/98
* @param
* @return
*/
nsDeque& Empty();
/**
* Remove and delete all items from container
*
* @update gess4/18/98
* @param
* @return
*/
nsDeque& Erase();
/**
* Creates a new iterator, init'ed to start of container
*
* @update gess4/18/98
* @return new dequeIterator
*/
nsDequeIterator Begin() const;
/**
* Creates a new iterator, init'ed to end of container
*
* @update gess4/18/98
* @return new dequeIterator
*/
nsDequeIterator End() const;
/**
* Call this method when you wanto to iterate all the
* members of the container, passing a functor along
* to call your code.
*
* @update gess4/20/98
* @param aFunctor object to call for each member
* @return *this
*/
void ForEach(nsDequeFunctor& aFunctor) const;
/**
* Call this method when you wanto to iterate all the
* members of the container, passing a functor along
* to call your code. This process will interupt if
* your function returns a null to this iterator.
*
* @update gess4/20/98
* @param aFunctor object to call for each member
* @return *this
*/
const void* FirstThat(nsDequeFunctor& aFunctor) const;
void SetDeallocator(nsDequeFunctor* aDeallocator);
/**
* Perform automated selftest on the deque
*
* @update gess4/18/98
* @param
* @return
*/
static void SelfTest();
protected:
PRInt32 mSize;
PRInt32 mCapacity;
PRInt32 mOrigin;
nsDequeFunctor* mDeallocator;
void* mBuffer[8];
void** mData;
private:
/**
* Simple default constructor (PRIVATE)
*
* @update gess4/18/98
* @param
* @return
*/
nsDeque();
/**
* Copy constructor (PRIVATE)
*
* @update gess4/18/98
* @param
* @return
*/
nsDeque(const nsDeque& other);
/**
* Deque assignment operator (PRIVATE)
*
* @update gess4/18/98
* @param another deque
* @return *this
*/
nsDeque& operator=(const nsDeque& anOther);
nsDeque& GrowCapacity(void);
};
/******************************************************
* Here comes the nsDequeIterator class...
******************************************************/
class NS_COM nsDequeIterator {
public:
/**
* DequeIterator is an object that knows how to iterate (forward and backward)
* a Deque. Normally, you don't need to do this, but there are some special
* cases where it is pretty handy, so here you go.
*
* @update gess4/18/98
* @param aQueue is the deque object to be iterated
* @param anIndex is the starting position for your iteration
*/
nsDequeIterator(const nsDeque& aQueue,int anIndex=0);
/**
* DequeIterator is an object that knows how to iterate (forward and backward)
* a Deque. Normally, you don't need to do this, but there are some special
* cases where it is pretty handy, so here you go.
*
* @update gess4/18/98
* @param aQueue is the deque object to be iterated
* @param anIndex is the starting position for your iteration
*/
nsDequeIterator(const nsDequeIterator& aCopy);
/**
* Moves iterator to first element in deque
* @update gess4/18/98
* @return this
*/
nsDequeIterator& First(void);
/**
* Standard assignment operator for deque
* @update gess4/18/98
* @param
* @return
*/
nsDequeIterator& operator=(const nsDequeIterator& aCopy);
/**
* preform ! operation against to iterators to test for equivalence
* (or lack thereof)!
*
* @update gess4/18/98
* @param anIter is the object to be compared to
* @return TRUE if NOT equal.
*/
PRBool operator!=(nsDequeIterator& anIter);
/**
* Compare 2 iterators for equivalence.
*
* @update gess4/18/98
* @param anIter is the other iterator to be compared to
* @return TRUE if EQUAL
*/
PRBool operator<(nsDequeIterator& anIter);
/**
* Compare 2 iterators for equivalence.
*
* @update gess4/18/98
* @param anIter is the other iterator to be compared to
* @return TRUE if EQUAL
*/
PRBool operator==(nsDequeIterator& anIter);
/**
* Compare 2 iterators for equivalence.
*
* @update gess4/18/98
* @param anIter is the other iterator to be compared to
* @return TRUE if EQUAL
*/
PRBool operator>=(nsDequeIterator& anIter);
/**
* Pre-increment operator
*
* @update gess4/18/98
* @return object at preincremented index
*/
void* operator++();
/**
* Post-increment operator
*
* @update gess4/18/98
* @param param is ignored
* @return object at post-incremented index
*/
void* operator++(int);
/**
* Pre-decrement operator
*
* @update gess4/18/98
* @return object at pre-decremented index
*/
void* operator--();
/**
* Post-decrement operator
*
* @update gess4/18/98
* @param param is ignored
* @return object at post-decremented index
*/
void* operator--(int);
/**
* Retrieve the ptr to the iterators notion of current node
*
* @update gess4/18/98
* @return object at ith index
*/
void* GetCurrent(void);
/**
* Call this method when you wanto to iterate all the
* members of the container, passing a functor along
* to call your code.
*
* @update gess4/20/98
* @param aFunctor object to call for each member
* @return *this
*/
void ForEach(nsDequeFunctor& aFunctor) const;
/**
* Call this method when you wanto to iterate all the
* members of the container, passing a functor along
* to call your code.
*
* @update gess4/20/98
* @param aFunctor object to call for each member
* @return *this
*/
const void* FirstThat(nsDequeFunctor& aFunctor) const;
protected:
PRInt32 mIndex;
const nsDeque& mDeque;
};
#endif

View File

@@ -1,75 +0,0 @@
/* -*- 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.
*/
/*
An empty enumerator.
*/
#include "nsIEnumerator.h"
////////////////////////////////////////////////////////////////////////
class EmptyEnumeratorImpl : public nsISimpleEnumerator
{
public:
EmptyEnumeratorImpl(void) {};
virtual ~EmptyEnumeratorImpl(void) {};
// nsISupports interface
NS_IMETHOD_(nsrefcnt) AddRef(void) {
return 2;
}
NS_IMETHOD_(nsrefcnt) Release(void) {
return 1;
}
NS_IMETHOD QueryInterface(REFNSIID iid, void** result) {
if (! result)
return NS_ERROR_NULL_POINTER;
if (iid.Equals(nsISimpleEnumerator::GetIID()) ||
iid.Equals(NS_GET_IID(nsISupports))) {
*result = (nsISimpleEnumerator*) this;
NS_ADDREF(this);
return NS_OK;
}
return NS_NOINTERFACE;
}
// nsISimpleEnumerator
NS_IMETHOD HasMoreElements(PRBool* aResult) {
*aResult = PR_FALSE;
return NS_OK;
}
NS_IMETHOD GetNext(nsISupports** aResult) {
return NS_ERROR_UNEXPECTED;
}
};
extern "C" NS_COM nsresult
NS_NewEmptyEnumerator(nsISimpleEnumerator** aResult)
{
static EmptyEnumeratorImpl gEmptyEnumerator;
*aResult = &gEmptyEnumerator;
return NS_OK;
}

View File

@@ -1,228 +0,0 @@
/* -*- 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 "nsEnumeratorUtils.h"
nsArrayEnumerator::nsArrayEnumerator(nsISupportsArray* aValueArray)
: mValueArray(aValueArray),
mIndex(0)
{
NS_INIT_REFCNT();
NS_IF_ADDREF(mValueArray);
}
nsArrayEnumerator::~nsArrayEnumerator(void)
{
NS_IF_RELEASE(mValueArray);
}
NS_IMPL_ISUPPORTS1(nsArrayEnumerator, nsISimpleEnumerator)
NS_IMETHODIMP
nsArrayEnumerator::HasMoreElements(PRBool* aResult)
{
NS_PRECONDITION(aResult != 0, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
PRUint32 cnt;
nsresult rv = mValueArray->Count(&cnt);
if (NS_FAILED(rv)) return rv;
*aResult = (mIndex < (PRInt32) cnt);
return NS_OK;
}
NS_IMETHODIMP
nsArrayEnumerator::GetNext(nsISupports** aResult)
{
NS_PRECONDITION(aResult != 0, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
PRUint32 cnt;
nsresult rv = mValueArray->Count(&cnt);
if (NS_FAILED(rv)) return rv;
if (mIndex >= (PRInt32) cnt)
return NS_ERROR_UNEXPECTED;
*aResult = mValueArray->ElementAt(mIndex++);
return NS_OK;
}
extern "C" NS_COM nsresult
NS_NewArrayEnumerator(nsISimpleEnumerator* *result,
nsISupportsArray* array)
{
nsArrayEnumerator* enumer = new nsArrayEnumerator(array);
if (enumer == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(enumer);
*result = enumer;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
nsSingletonEnumerator::nsSingletonEnumerator(nsISupports* aValue)
: mValue(aValue)
{
NS_INIT_REFCNT();
NS_IF_ADDREF(mValue);
mConsumed = (mValue ? PR_FALSE : PR_TRUE);
}
nsSingletonEnumerator::~nsSingletonEnumerator()
{
NS_IF_RELEASE(mValue);
}
NS_IMPL_ISUPPORTS1(nsSingletonEnumerator, nsISimpleEnumerator)
NS_IMETHODIMP
nsSingletonEnumerator::HasMoreElements(PRBool* aResult)
{
NS_PRECONDITION(aResult != 0, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
*aResult = !mConsumed;
return NS_OK;
}
NS_IMETHODIMP
nsSingletonEnumerator::GetNext(nsISupports** aResult)
{
NS_PRECONDITION(aResult != 0, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
if (mConsumed)
return NS_ERROR_UNEXPECTED;
mConsumed = PR_TRUE;
NS_ADDREF(mValue);
*aResult = mValue;
return NS_OK;
}
extern "C" NS_COM nsresult
NS_NewSingletonEnumerator(nsISimpleEnumerator* *result,
nsISupports* singleton)
{
nsSingletonEnumerator* enumer = new nsSingletonEnumerator(singleton);
if (enumer == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(enumer);
*result = enumer;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
nsAdapterEnumerator::nsAdapterEnumerator(nsIEnumerator* aEnum)
: mEnum(aEnum), mCurrent(0), mStarted(PR_FALSE)
{
NS_INIT_REFCNT();
NS_ADDREF(mEnum);
}
nsAdapterEnumerator::~nsAdapterEnumerator()
{
NS_RELEASE(mEnum);
NS_IF_RELEASE(mCurrent);
}
NS_IMPL_ISUPPORTS1(nsAdapterEnumerator, nsISimpleEnumerator)
NS_IMETHODIMP
nsAdapterEnumerator::HasMoreElements(PRBool* aResult)
{
nsresult rv;
if (mCurrent) {
*aResult = PR_TRUE;
return NS_OK;
}
if (! mStarted) {
mStarted = PR_TRUE;
rv = mEnum->First();
if (rv == NS_OK) {
mEnum->CurrentItem(&mCurrent);
*aResult = PR_TRUE;
}
else {
*aResult = PR_FALSE;
}
}
else {
*aResult = PR_FALSE;
rv = mEnum->IsDone();
if (rv != NS_OK) {
// We're not done. Advance to the next one.
rv = mEnum->Next();
if (rv == NS_OK) {
mEnum->CurrentItem(&mCurrent);
*aResult = PR_TRUE;
}
}
}
return NS_OK;
}
NS_IMETHODIMP
nsAdapterEnumerator::GetNext(nsISupports** aResult)
{
nsresult rv;
PRBool hasMore;
rv = HasMoreElements(&hasMore);
if (NS_FAILED(rv)) return rv;
if (! hasMore)
return NS_ERROR_UNEXPECTED;
// No need to addref, we "transfer" the ownership to the caller.
*aResult = mCurrent;
mCurrent = 0;
return NS_OK;
}
extern "C" NS_COM nsresult
NS_NewAdapterEnumerator(nsISimpleEnumerator* *result,
nsIEnumerator* enumerator)
{
nsAdapterEnumerator* enumer = new nsAdapterEnumerator(enumerator);
if (enumer == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(enumer);
*result = enumer;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,97 +0,0 @@
/* -*- 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.
*/
#ifndef nsEnumeratorUtils_h__
#define nsEnumeratorUtils_h__
#include "nsIEnumerator.h"
#include "nsISupportsArray.h"
class NS_COM nsArrayEnumerator : public nsISimpleEnumerator
{
public:
// nsISupports interface
NS_DECL_ISUPPORTS
// nsISimpleEnumerator interface
NS_IMETHOD HasMoreElements(PRBool* aResult);
NS_IMETHOD GetNext(nsISupports** aResult);
// nsRDFArrayEnumerator methods
nsArrayEnumerator(nsISupportsArray* aValueArray);
virtual ~nsArrayEnumerator(void);
protected:
nsISupportsArray* mValueArray;
PRInt32 mIndex;
};
extern "C" NS_COM nsresult
NS_NewArrayEnumerator(nsISimpleEnumerator* *result,
nsISupportsArray* array);
////////////////////////////////////////////////////////////////////////////////
class NS_COM nsSingletonEnumerator : public nsISimpleEnumerator
{
public:
NS_DECL_ISUPPORTS
// nsISimpleEnumerator methods
NS_IMETHOD HasMoreElements(PRBool* aResult);
NS_IMETHOD GetNext(nsISupports** aResult);
nsSingletonEnumerator(nsISupports* aValue);
virtual ~nsSingletonEnumerator();
protected:
nsISupports* mValue;
PRBool mConsumed;
};
extern "C" NS_COM nsresult
NS_NewSingletonEnumerator(nsISimpleEnumerator* *result,
nsISupports* singleton);
////////////////////////////////////////////////////////////////////////////////
class NS_COM nsAdapterEnumerator : public nsISimpleEnumerator
{
public:
NS_DECL_ISUPPORTS
// nsISimpleEnumerator methods
NS_IMETHOD HasMoreElements(PRBool* aResult);
NS_IMETHOD GetNext(nsISupports** aResult);
nsAdapterEnumerator(nsIEnumerator* aEnum);
virtual ~nsAdapterEnumerator();
protected:
nsIEnumerator* mEnum;
nsISupports* mCurrent;
PRBool mStarted;
};
extern "C" NS_COM nsresult
NS_NewAdapterEnumerator(nsISimpleEnumerator* *result,
nsIEnumerator* enumerator);
////////////////////////////////////////////////////////////////////////
#endif /* nsEnumeratorUtils_h__ */

View File

@@ -1,67 +0,0 @@
/* -*- 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.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 nsIArena_h___
#define nsIArena_h___
#include "nscore.h"
#include "nsISupports.h"
#define NS_MIN_ARENA_BLOCK_SIZE 64
#define NS_DEFAULT_ARENA_BLOCK_SIZE 4096
/// Interface IID for nsIArena
#define NS_IARENA_IID \
{ 0xa24fdad0, 0x93b4, 0x11d1, \
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
#define NS_ARENA_PROGID "component://netscape/arena"
#define NS_ARENA_CLASSNAME "Arena"
/** Interface to a memory arena abstraction. Arena's use large blocks
* of memory to allocate smaller objects. Arena's provide no free
* operator; instead, all of the objects in the arena are deallocated
* by deallocating the arena (e.g. when it's reference count goes to
* zero)
*/
class nsIArena : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IARENA_IID; return iid; }
NS_IMETHOD Init(PRUint32 arenaBlockSize) = 0;
NS_IMETHOD_(void*) Alloc(PRUint32 size) = 0;
};
/**
* Create a new arena using the desired block size for allocating the
* underlying memory blocks. The underlying memory blocks are allocated
* using the PR heap.
*/
extern NS_COM nsresult NS_NewHeapArena(nsIArena** aInstancePtrResult,
PRUint32 aArenaBlockSize = 0);
#define NS_ARENA_CID \
{ /* 9832ec80-0d6b-11d3-9331-00104ba0fd40 */ \
0x9832ec80, \
0x0d6b, \
0x11d3, \
{0x93, 0x31, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
#endif /* nsIArena_h___ */

View File

@@ -1,82 +0,0 @@
/* -*- 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.0 (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,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All Rights
* Reserved.
*
* Contributors:
*
*/
#include "nsISupports.idl"
interface nsISizeOfHandler;
[ref] native nsStringRef(nsString);
%{ C++
class nsString;
%}
[uuid(3d1b15b0-93b4-11d1-895b-006008911b81)]
interface nsIAtom : nsISupports
{
/**
* Translate the unicode string into the stringbuf.
*/
void ToString(in nsStringRef aString);
/**
* Return a pointer to a zero terminated unicode string.
*/
void GetUnicode([shared, retval] out wstring aResult);
/**
* Get the size, in bytes, of the atom.
*/
PRUint32 SizeOf(in nsISizeOfHandler aHandler);
};
%{C++
/**
* Find an atom that matches the given iso-latin1 C string. The
* C string is translated into it's unicode equivalent.
*/
extern NS_COM nsIAtom* NS_NewAtom(const char* isolatin1);
/**
* Find an atom that matches the given unicode string. The string is assumed
* to be zero terminated.
*/
extern NS_COM nsIAtom* NS_NewAtom(const PRUnichar* unicode);
/**
* Find an atom that matches the given string.
*/
extern NS_COM nsIAtom* NS_NewAtom(const nsString& aString);
/**
* Return a count of the total number of atoms currently
* alive in the system.
*/
extern NS_COM nsrefcnt NS_GetNumberOfAtoms(void);
extern NS_COM void NS_PurgeAtomTable(void);
%}

View File

@@ -1,312 +0,0 @@
/* -*- 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.
*/
#ifndef nsIBuffer_h___
#define nsIBuffer_h___
/**
* nsIBuffer is something that we use to implement pipes (buffered
* input/output stream pairs). It might be useful to you for other
* purposes, but if not, oh well.
*
* One of the important things to understand about pipes is how
* they work with respect to EOF and result values. The following
* table describes:
*
* | empty & not EOF | full | reader closed | writer closed |
* -------------------------------------------------------------------------------------------------------------
* buffer Read | readCount == 0 | readCount == N | N/A | readCount == N, return NS_OK -or- |
* operations | return WOULD_BLOCK | return NS_OK | | readCount == 0, return EOF |
* -------------------------------------------------------------------------------------------------------------
* buffer Write | writeCount == N | writeCount == 0 | N/A | assertion! |
* operations | return NS_OK | return WOULD_BLOCK | | |
* -------------------------------------------------------------------------------------------------------------
* input stream | readCount == 0 | readCount == N | assertion! | readCount == N, return NS_OK -or- |
* Read ops | return WOULD_BLOCK | return NS_OK | | readCount == 0, return EOF |
* -------------------------------------------------------------------------------------------------------------
* output stream | writeCount == N | writeCount == 0 | return | assertion! |
* Write ops | return NS_OK | return WOULD_BLOCK | STREAM_CLOSED | |
* -------------------------------------------------------------------------------------------------------------
*/
#include "nsISupports.h"
#include "nscore.h"
class nsIInputStream;
class nsIAllocator;
class nsIBufferInputStream;
class nsIBufferOutputStream;
class nsIBufferObserver;
#define NS_IBUFFER_IID \
{ /* 1eebb300-fb8b-11d2-9324-00104ba0fd40 */ \
0x1eebb300, \
0xfb8b, \
0x11d2, \
{0x93, 0x24, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
#define NS_BUFFER_CID \
{ /* 5dbe4de0-fbab-11d2-9324-00104ba0fd40 */ \
0x5dbe4de0, \
0xfbab, \
0x11d2, \
{0x93, 0x24, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
#define NS_BUFFER_PROGID "component://netscape/buffer"
#define NS_BUFFER_CLASSNAME "Buffer"
/**
* The signature for the reader function passed to WriteSegment. This
* specifies where the data should come from that gets written into the buffer.
* Implementers should return the following:
* @return NS_OK and readCount - if successfully read something
* @return NS_BASE_STREAM_EOF - if no more to read
* @return NS_BASE_STREAM_WOULD_BLOCK - if there is currently no data (in
* a non-blocking mode)
* @return <other-error> - on failure
*/
typedef NS_CALLBACK(nsReadSegmentFun)(void* closure,
char* toRawSegment,
PRUint32 fromOffset,
PRUint32 count,
PRUint32 *readCount);
/**
* The signature of the writer function passed to ReadSegments. This
* specifies where the data should go that gets read from the buffer.
* Implementers should return the following:
* @return NS_OK and writeCount - if successfully wrote something
* @return NS_BASE_STREAM_CLOSED - if no more can be written
* @return NS_BASE_STREAM_WOULD_BLOCK - if there is currently space to write (in
* a non-blocking mode)
* @return <other-error> - on failure
*/
typedef NS_CALLBACK(nsWriteSegmentFun)(void* closure,
const char* fromRawSegment,
PRUint32 toOffset,
PRUint32 count,
PRUint32 *writeCount);
class nsIBuffer : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IBUFFER_IID);
/**
* The segment overhead is the amount of space chopped out of each
* segment for implementation purposes. The remainder of the segment
* is available for data, e.g.:
* segmentDataSize = growBySize - SEGMENT_OVERHEAD;
*/
enum { SEGMENT_OVERHEAD = 8 };
/**
* Initializes a buffer. The segment size (including overhead) will
* start from and increment by the growBySize, until reaching maxSize.
* The size of the data that can fit in a segment will be the growBySize
* minus SEGMENT_OVERHEAD bytes.
*/
NS_IMETHOD Init(PRUint32 growBySize, PRUint32 maxSize,
nsIBufferObserver* observer, nsIAllocator* allocator) = 0;
////////////////////////////////////////////////////////////////////////////
// Methods for Readers
/**
* Reads from the read cursor into a char buffer up to a specified length.
*/
NS_IMETHOD Read(char* toBuf, PRUint32 bufLen, PRUint32 *readCount) = 0;
/**
* This read method allows you to pass a callback function that gets called
* repeatedly for each buffer segment until the entire amount is read.
* This avoids the need to copy data to/from and intermediate buffer.
*/
NS_IMETHOD ReadSegments(nsWriteSegmentFun writer, void* closure, PRUint32 count,
PRUint32 *readCount) = 0;
/**
* Returns the raw char buffer segment and its length available for reading.
* @param segmentLogicalOffset - The offset from the current read cursor for
* the segment to be returned. If this is beyond the available written area,
* NULL is returned for the resultSegment.
* @param resultSegment - The resulting read segment.
* @param resultSegmentLength - The resulting read segment length.
*
* @return NS_OK - if a read segment is successfully returned, or if
* the requested offset is at or beyond the write cursor (in which case
* the resultSegment will be nsnull and the resultSegmentLen will be 0)
* @return NS_BASE_STREAM_WOULD_BLOCK - if the buffer size becomes 0
* @return any error set by SetCondition if the requested offset is at
* or beyond the write cursor (in which case the resultSegment will be
* nsnull and the resultSegmentLen will be 0). Note that NS_OK will be
* returned if SetCondition has not been called.
* @return any error returned by OnEmpty
*/
NS_IMETHOD GetReadSegment(PRUint32 segmentLogicalOffset,
const char* *resultSegment,
PRUint32 *resultSegmentLen) = 0;
/**
* Returns the amount of data currently in the buffer available for reading.
*/
NS_IMETHOD GetReadableAmount(PRUint32 *amount) = 0;
/**
* Searches for a string in the buffer. Since the buffer has a notion
* of EOF, it is possible that the string may at some time be in the
* buffer, but is is not currently found up to some offset. Consequently,
* both the found and not found cases return an offset:
* if found, return offset where it was found
* if not found, return offset of the first byte not searched
* In the case the buffer is at EOF and the string is not found, the first
* byte not searched will correspond to the length of the buffer.
*/
NS_IMETHOD Search(const char* forString, PRBool ignoreCase,
PRBool *found, PRUint32 *offsetSearchedTo) = 0;
/**
* Sets that the reader has closed their end of the stream.
*/
NS_IMETHOD ReaderClosed(void) = 0;
/**
* Tests whether EOF marker is set. Note that this does not necessarily mean that
* all the data in the buffer has yet been consumed.
*/
NS_IMETHOD GetCondition(nsresult *result) = 0;
////////////////////////////////////////////////////////////////////////////
// Methods for Writers
/**
* Writes from a char buffer up to a specified length.
* @param writeCount - The amount that could be written. If the buffer becomes full,
* this could be less then the specified bufLen.
*/
NS_IMETHOD Write(const char* fromBuf, PRUint32 bufLen, PRUint32 *writeCount) = 0;
/**
* Writes from an input stream up to a specified count of bytes.
* @param writeCount - The amount that could be written. If the buffer becomes full,
* this could be less then the specified count.
*/
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count, PRUint32 *writeCount) = 0;
/**
* This write method allows you to pass a callback function that gets called
* repeatedly for each buffer segment until the entire amount is written.
* This avoids the need to copy data to/from and intermediate buffer.
*/
NS_IMETHOD WriteSegments(nsReadSegmentFun reader, void* closure, PRUint32 count,
PRUint32 *writeCount) = 0;
/**
* Returns the raw char buffer segment and its length available for writing.
* @param resultSegment - The resulting write segment.
* @param resultSegmentLength - The resulting write segment length.
*
* @return NS_OK - if there is a segment available to write to
* @return NS_BASE_STREAM_CLOSED - if ReaderClosed has been called
* @return NS_BASE_STREAM_WOULD_BLOCK - if the max buffer size is exceeded
* @return NS_ERROR_OUT_OF_MEMORY - if a new segment could not be allocated
* @return any error returned by OnFull
*/
NS_IMETHOD GetWriteSegment(char* *resultSegment,
PRUint32 *resultSegmentLen) = 0;
/**
* Returns the amount of space currently in the buffer available for writing.
*/
NS_IMETHOD GetWritableAmount(PRUint32 *amount) = 0;
/**
* Returns whether the reader has closed their end of the stream.
*/
NS_IMETHOD GetReaderClosed(PRBool *result) = 0;
/**
* Sets an EOF marker (typcially done by the writer) so that a reader can be informed
* when all the data in the buffer is consumed. After the EOF marker has been
* set, all subsequent calls to the above write methods will return NS_BASE_STREAM_EOF.
*/
NS_IMETHOD SetCondition(nsresult condition) = 0;
};
////////////////////////////////////////////////////////////////////////////////
#define NS_IBUFFEROBSERVER_IID \
{ /* 0c18bef0-22a8-11d3-9349-00104ba0fd40 */ \
0x0c18bef0, \
0x22a8, \
0x11d3, \
{0x93, 0x49, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
/**
* A buffer observer is used to detect when the buffer becomes completely full
* or completely empty.
*/
class nsIBufferObserver : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IBUFFEROBSERVER_IID);
NS_IMETHOD OnFull(nsIBuffer* buffer) = 0;
NS_IMETHOD OnWrite(nsIBuffer*, PRUint32 amount) = 0;
NS_IMETHOD OnEmpty(nsIBuffer* buffer) = 0;
};
////////////////////////////////////////////////////////////////////////////////
/**
* Creates a new buffer.
* @param observer - may be null
*/
extern NS_COM nsresult
NS_NewBuffer(nsIBuffer* *result,
PRUint32 growBySize, PRUint32 maxSize,
nsIBufferObserver* observer);
/**
* Creates a new buffer, allocating segments from virtual memory pages.
*/
extern NS_COM nsresult
NS_NewPageBuffer(nsIBuffer* *result,
PRUint32 growBySize, PRUint32 maxSize,
nsIBufferObserver* observer);
extern NS_COM nsresult
NS_NewBufferInputStream(nsIBufferInputStream* *result,
nsIBuffer* buffer, PRBool blocking = PR_FALSE);
extern NS_COM nsresult
NS_NewBufferOutputStream(nsIBufferOutputStream* *result,
nsIBuffer* buffer, PRBool blocking = PR_FALSE);
extern NS_COM nsresult
NS_NewPipe(nsIBufferInputStream* *inStrResult,
nsIBufferOutputStream* *outStrResult,
PRUint32 growBySize, PRUint32 maxSize,
PRBool blocking, nsIBufferObserver* observer);
////////////////////////////////////////////////////////////////////////////////
#endif // nsIBuffer_h___

View File

@@ -1,76 +0,0 @@
/* -*- 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.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 nsIByteBuffer_h___
#define nsIByteBuffer_h___
#include "nscore.h"
#include "nsISupports.h"
class nsIInputStream;
#define NS_IBYTE_BUFFER_IID \
{ 0xe4a6e4b0, 0x93b4, 0x11d1, \
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
#define NS_IBYTEBUFFER_IID \
{ 0xe4a6e4b0, 0x93b4, 0x11d1, \
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
#define NS_BYTEBUFFER_PROGID "component://netscape/byte-buffer"
#define NS_BYTEBUFFER_CLASSNAME "Byte Buffer"
/** Interface to a buffer that holds bytes */
class nsIByteBuffer : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IBYTEBUFFER_IID; return iid; }
NS_IMETHOD Init(PRUint32 aBufferSize) = 0;
/** @return length of buffer, i.e. how many bytes are currently in it. */
NS_IMETHOD_(PRUint32) GetLength(void) const = 0;
/** @return number of bytes allocated in the buffer */
NS_IMETHOD_(PRUint32) GetBufferSize(void) const = 0;
/** @return the buffer */
NS_IMETHOD_(char*) GetBuffer(void) const = 0;
/** Grow buffer to aNewSize bytes. */
NS_IMETHOD_(PRBool) Grow(PRUint32 aNewSize) = 0;
/** Fill the buffer with data from aStream. Don't grow the buffer, only
* read until length of buffer equals buffer size. */
NS_IMETHOD_(PRInt32) Fill(nsresult* aErrorCode, nsIInputStream* aStream,
PRUint32 aKeep) = 0;
};
#define NS_BYTEBUFFER_CID \
{ /* a49d5280-0d6b-11d3-9331-00104ba0fd40 */ \
0xa49d5280, \
0x0d6b, \
0x11d3, \
{0x93, 0x31, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
/** Create a new byte buffer using the given buffer size. */
extern NS_COM nsresult
NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult,
nsISupports* aOuter,
PRUint32 aBufferSize = 0);
#endif /* nsIByteBuffer_h___ */

View File

@@ -1,38 +0,0 @@
/* -*- 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 "nsISupports.idl"
#include "nsIEnumerator.idl"
[scriptable, uuid(83b6019c-cbc4-11d2-8cca-0060b0fc14a3)]
interface nsICollection : nsISupports
{
PRUint32 Count();
nsISupports GetElementAt(in PRUint32 index);
void QueryElementAt(in PRUint32 index, in nsIIDRef uuid,
[iid_is(uuid),retval] out nsQIResult result);
void SetElementAt(in PRUint32 index, in nsISupports item);
void AppendElement(in nsISupports item);
void RemoveElement(in nsISupports item);
nsIEnumerator Enumerate();
void Clear();
};

View File

@@ -1,95 +0,0 @@
/* -*- 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 "nsISupports.idl"
[scriptable, uuid(D1899240-F9D2-11D2-BDD6-000064657374)]
interface nsISimpleEnumerator : nsISupports {
boolean HasMoreElements();
nsISupports GetNext();
};
/*
* DO NOT USE THIS INTERFACE. IT IS HORRIBLY BROKEN, USES NS_COMFALSE
* AND IS BASICALLY IMPOSSIBLE TO USE CORRECTLY THROUGH PROXIES OR
* XPCONNECT. IF YOU SEE NEW USES OF THIS INTERFACE IN CODE YOU ARE
* REVIEWING, YOU SHOULD INSIST ON nsISimpleEnumerator.
*
* DON'T MAKE ME COME OVER THERE.
*/
[scriptable, uuid(ad385286-cbc4-11d2-8cca-0060b0fc14a3)]
interface nsIEnumerator : nsISupports {
/** First will reset the list. will return NS_FAILED if no items
*/
void first();
/** Next will advance the list. will return failed if already at end
*/
void next();
/** CurrentItem will return the CurrentItem item it will fail if the
* list is empty
*/
nsISupports currentItem();
/** return if the collection is at the end. that is the beginning following
* a call to Prev and it is the end of the list following a call to next
*/
void isDone();
};
[uuid(75f158a0-cadd-11d2-8cca-0060b0fc14a3)]
interface nsIBidirectionalEnumerator : nsIEnumerator {
/** Last will reset the list to the end. will return NS_FAILED if no items
*/
void Last();
/** Prev will decrement the list. will return failed if already at beginning
*/
void Prev();
};
%{C++
extern "C" NS_COM nsresult
NS_NewEmptyEnumerator(nsISimpleEnumerator** aResult);
// Construct and return an implementation of a "conjoining enumerator." This
// enumerator lets you string together two other enumerators into one sequence.
// The result is an nsIBidirectionalEnumerator, but if either input is not
// also bidirectional, the Last and Prev operations will fail.
extern "C" NS_COM nsresult
NS_NewConjoiningEnumerator(nsIEnumerator* first, nsIEnumerator* second,
nsIBidirectionalEnumerator* *aInstancePtrResult);
// Construct and return an implementation of a "union enumerator." This
// enumerator will only return elements that are found in both constituent
// enumerators.
extern "C" NS_COM nsresult
NS_NewUnionEnumerator(nsIEnumerator* first, nsIEnumerator* second,
nsIEnumerator* *aInstancePtrResult);
// Construct and return an implementation of an "intersection enumerator." This
// enumerator will return elements that are found in either constituent
// enumerators, eliminating duplicates.
extern "C" NS_COM nsresult
NS_NewIntersectionEnumerator(nsIEnumerator* first, nsIEnumerator* second,
nsIEnumerator* *aInstancePtrResult);
%}

View File

@@ -1,44 +0,0 @@
/* -*- 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 "nsISupports.idl"
[scriptable, uuid(DB242E01-E4D9-11d2-9DDE-000064657374)]
interface nsIObserver : nsISupports {
/*------------------------------- Observe ----------------------------------
| Called when aTopic changes for aSubject (presumably; it is actually |
| called whenever anyone calls nsIObserverService::Notify for aTopic). |
| |
| Implement this in your class to handle the event appropriately. If |
| your observer objects can respond to multiple topics and/or subjects, |
| then you will have to filter accordingly. |
--------------------------------------------------------------------------*/
void Observe( in nsISupports aSubject,
in wstring aTopic,
in wstring someData );
};
%{C++
#define NS_OBSERVER_PROGID "component://netscape/xpcom/observer"
#define NS_OBSERVER_CLASSNAME "Observer"
%}

View File

@@ -1,48 +0,0 @@
/* -*- 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.
*/
#ifndef nsIObserverList_h__
#define nsIObserverList_h__
#include "nsISupports.h"
#include "nsIObserver.h"
#include "nsIEnumerator.h"
#include "nscore.h"
// {E777D482-E6E3-11d2-8ACD-00105A1B8860}
#define NS_IOBSERVERLIST_IID \
{ 0xe777d482, 0xe6e3, 0x11d2, { 0x8a, 0xcd, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } }
// {E777D484-E6E3-11d2-8ACD-00105A1B8860}
#define NS_OBSERVERLIST_CID \
{ 0xe777d484, 0xe6e3, 0x11d2, { 0x8a, 0xcd, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } }
class nsIObserverList : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IOBSERVERLIST_IID; return iid; }
NS_IMETHOD AddObserver(nsIObserver** anObserver) = 0;
NS_IMETHOD RemoveObserver(nsIObserver** anObserver) = 0;
NS_IMETHOD EnumerateObserverList(nsIEnumerator** anEnumerator) = 0;
};
extern NS_COM nsresult NS_NewObserverList(nsIObserverList** anObserverList);
#endif /* nsIObserverList_h__ */

View File

@@ -1,41 +0,0 @@
/* -*- 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 "nsISupports.idl"
#include "nsIObserver.idl"
#include "nsIEnumerator.idl"
[scriptable, uuid(D07F5192-E3D1-11d2-8ACD-00105A1B8860)]
interface nsIObserverService : nsISupports {
void AddObserver( in nsIObserver anObserver, in wstring aTopic );
void RemoveObserver( in nsIObserver anObserver, in wstring nsString );
nsIEnumerator EnumerateObserverList( in wstring aTopic );
void Notify( in nsISupports aSubject,
in wstring aTopic,
in wstring someData );
};
%{C++
#define NS_OBSERVERSERVICE_PROGID "component://netscape/observer-service"
#define NS_OBSERVERSERVICE_CLASSNAME "Observer Service"
%}

View File

@@ -1,57 +0,0 @@
/* -*- 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.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 nsIPageManager_h__
#define nsIPageManager_h__
#include "nsISupports.h"
#define NS_PAGEMGR_PAGE_BITS 12 // 4k pages
#define NS_PAGEMGR_PAGE_SIZE (1 << NS_PAGEMGR_PAGE_BITS)
#define NS_PAGEMGR_PAGE_MASK (NS_PAGEMGR_PAGE_SIZE - 1)
#define NS_PAGEMGR_PAGE_COUNT(bytes) (((bytes) + NS_PAGEMGR_PAGE_MASK) >> NS_PAGEMGR_PAGE_BITS)
#define NS_IPAGEMANAGER_IID \
{ /* bea98210-fb7b-11d2-9324-00104ba0fd40 */ \
0xbea98210, \
0xfb7b, \
0x11d2, \
{0x93, 0x24, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
#define NS_PAGEMANAGER_CID \
{ /* cac907e0-fb7b-11d2-9324-00104ba0fd40 */ \
0xcac907e0, \
0xfb7b, \
0x11d2, \
{0x93, 0x24, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
#define NS_PAGEMANAGER_PROGID "component://netscape/page-manager"
#define NS_PAGEMANAGER_CLASSNAME "Page Manager"
class nsIPageManager : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPAGEMANAGER_IID);
NS_IMETHOD AllocPages(PRUint32 pageCount, void* *result) = 0;
NS_IMETHOD DeallocPages(PRUint32 pageCount, void* pages) = 0;
};
#endif // nsIPageManager_h__

View File

@@ -1,150 +0,0 @@
/* -*- 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.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 nsIProperties_h___
#define nsIProperties_h___
#include "nsISupports.h"
#include "nsIEnumerator.h"
#include "nsISupportsArray.h"
#define NS_IPROPERTIES_IID \
{ /* f42bc870-dc17-11d2-9311-00e09805570f */ \
0xf42bc870, \
0xdc17, \
0x11d2, \
{0x93, 0x11, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \
}
#define NS_PROPERTIES_CID \
{ /* b3efe4d0-0d6b-11d3-9331-00104ba0fd40 */ \
0xb3efe4d0, \
0x0d6b, \
0x11d3, \
{0x93, 0x31, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
#define NS_PROPERTIES_PROGID "component://netscape/properties"
#define NS_PROPERTIES_CLASSNAME "Properties"
class nsIProperties : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPROPERTIES_IID; return iid; }
/**
* Defines a new property.
* @return NS_ERROR_FAILURE if a property is already defined.
*/
NS_IMETHOD DefineProperty(const char* prop, nsISupports* initialValue) = 0;
/**
* Undefines a property.
* @return NS_ERROR_FAILURE if a property is not already defined.
*/
NS_IMETHOD UndefineProperty(const char* prop) = 0;
/**
* Gets a property.
* @return NS_ERROR_FAILURE if a property is not already defined.
*/
NS_IMETHOD GetProperty(const char* prop, nsISupports* *result) = 0;
/**
* Sets a property.
* @return NS_ERROR_FAILURE if a property is not already defined.
*/
NS_IMETHOD SetProperty(const char* prop, nsISupports* value) = 0;
/**
* @return NS_OK if the property exists with the specified value
* @return NS_COMFALSE if the property does not exist, or doesn't have
* the specified value (values are compared with ==)
*/
NS_IMETHOD HasProperty(const char* prop, nsISupports* value) = 0;
};
// Returns a default implementation of an nsIProperties object.
extern nsresult
NS_NewIProperties(nsIProperties* *result);
////////////////////////////////////////////////////////////////////////////////
#include "nsID.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsString.h"
// {1A180F60-93B2-11d2-9B8B-00805F8A16D9}
#define NS_IPERSISTENTPROPERTIES_IID \
{ 0x1a180f60, 0x93b2, 0x11d2, \
{ 0x9b, 0x8b, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } }
// {2245E573-9464-11d2-9B8B-00805F8A16D9}
NS_DECLARE_ID(kPersistentPropertiesCID,
0x2245e573, 0x9464, 0x11d2, 0x9b, 0x8b, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9);
#define NS_PERSISTENTPROPERTIES_PROGID "component://netscape/persistent-properties"
#define NS_PERSISTENTPROPERTIES_CLASSNAME "Persistent Properties"
class nsIPersistentProperties : public nsIProperties
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPERSISTENTPROPERTIES_IID; return iid; }
NS_IMETHOD Load(nsIInputStream* aIn) = 0;
NS_IMETHOD Save(nsIOutputStream* aOut, const nsString& aHeader) = 0;
NS_IMETHOD Subclass(nsIPersistentProperties* aSubclass) = 0;
/**
* Enumerates the properties in the supplied enumerator.
* @return NS_ERROR_FAILURE if no properties to enumerate
*/
NS_IMETHOD EnumerateProperties(nsIBidirectionalEnumerator** aResult) = 0;
// XXX these 2 methods will be subsumed by the ones from
// nsIProperties once we figure this all out
NS_IMETHOD GetStringProperty(const nsString& aKey, nsString& aValue) = 0;
NS_IMETHOD SetStringProperty(const nsString& aKey, nsString& aNewValue,
nsString& aOldValue) = 0;
};
////////////////////////////////////////////////////////////////////////////////
// {C23C10B3-0E1A-11d3-A430-0060B0EB5963}
#define NS_IPROPERTYELEMENT_IID \
{ 0xc23c10b3, 0xe1a, 0x11d3, \
{ 0xa4, 0x30, 0x0, 0x60, 0xb0, 0xeb, 0x59, 0x63 } }
// {579C0568-0E1B-11d3-A430-0060B0EB5963}
NS_DECLARE_ID(kPropertyElementCID,
0x579c0568, 0xe1b, 0x11d3, 0xa4, 0x30, 0x0, 0x60, 0xb0, 0xeb, 0x59, 0x63);
class nsIPropertyElement : public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPROPERTYELEMENT_IID; return iid; }
NS_IMETHOD SetKey(nsString* aKey) = 0;
NS_IMETHOD SetValue(nsString* aValue) = 0;
NS_IMETHOD GetKey(nsString** aReturnKey) = 0;
NS_IMETHOD GetValue(nsString** aReturnValue) = 0;
};
////////////////////////////////////////////////////////////////////////////////
#endif // nsIProperties_h___

View File

@@ -1,100 +0,0 @@
/* -*- 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.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 nsISizeOfHandler_h___
#define nsISizeOfHandler_h___
#include "nscore.h"
#include "nsISupports.h"
/* c028d1f0-fc9e-11d1-89e4-006008911b81 */
#define NS_ISIZEOF_HANDLER_IID \
{ 0xc028d1f0, 0xfc9e, 0x11d1, {0x89, 0xe4, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81}}
class nsIAtom;
class nsISizeOfHandler;
/**
* Function used by the Report method to report data gathered during
* a collection of data.
*/
typedef void (*nsISizeofReportFunc)(nsISizeOfHandler* aHandler,
nsIAtom* aKey,
PRUint32 aCount,
PRUint32 aTotalSize,
PRUint32 aMinSize,
PRUint32 aMaxSize,
void* aArg);
/**
* An API to managing a sizeof computation of an arbitrary graph.
* The handler is responsible for remembering which objects have been
* seen before (using RecordObject). Note that the handler doesn't
* hold references to nsISupport's objects; the assumption is that the
* objects being sized are stationary and will not be modified during
* the sizing computation and therefore do not need an extra reference
* count.
*
* Users of this API are responsible for the actual graph/tree walking.
*/
class nsISizeOfHandler : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISIZEOF_HANDLER_IID)
/**
* Initialize the handler for a new collection of data. This empties
* out the object prescence table and the keyed size table.
*/
NS_IMETHOD Init() = 0;
/**
* Record the sizing status of a given object. The first time
* aObject is recorded, aResult will be PR_FALSE. Subsequent times,
* aResult will be PR_TRUE.
*/
NS_IMETHOD RecordObject(void* aObject, PRBool* aResult) = 0;
/**
* Add size information to the running size data. The atom is used
* as a key to keep type specific running totals of size
* information. This increments the total count and the total size
* as well as updates the minimum, maximum and total size for aKey's
* type.
*/
NS_IMETHOD AddSize(nsIAtom* aKey, PRUint32 aSize) = 0;
/**
* Enumerate data collected for each type and invoke the
* reporting function with the data gathered.
*/
NS_IMETHOD Report(nsISizeofReportFunc aFunc, void* aArg) = 0;
/**
* Get the current totals - the number of total objects sized (not
* necessarily anything to do with RecordObject's tracking of
* objects) and the total number of bytes that those object use. The
* counters are not reset by this call (use Init to reset
* everything).
*/
NS_IMETHOD GetTotals(PRUint32* aTotalCountResult,
PRUint32* aTotalSizeResult) = 0;
};
extern NS_COM nsresult
NS_NewSizeOfHandler(nsISizeOfHandler** aInstancePtrResult);
#endif /* nsISizeofHandler_h___ */

View File

@@ -1,104 +0,0 @@
/* -*- 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 "nsISupports.idl"
#include "nsICollection.idl"
native nsISupportsArrayEnumFunc(nsISupportsArrayEnumFunc);
%{C++
class nsIBidirectionalEnumerator;
#define NS_SUPPORTSARRAY_CID \
{ /* bda17d50-0d6b-11d3-9331-00104ba0fd40 */ \
0xbda17d50, \
0x0d6b, \
0x11d3, \
{0x93, 0x31, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
#define NS_SUPPORTSARRAY_PROGID "component://netscape/supports-array"
#define NS_SUPPORTSARRAY_CLASSNAME "Supports Array"
// Enumerator callback function. Return PR_FALSE to stop
typedef PRBool (*nsISupportsArrayEnumFunc)(nsISupports* aElement, void *aData);
%}
[scriptable, uuid(791eafa0-b9e6-11d1-8031-006008159b5a)]
interface nsISupportsArray : nsICollection {
[notxpcom] boolean Equals([const] in nsISupportsArray other);
[notxpcom] nsISupports ElementAt(in unsigned long aIndex);
[notxpcom] long IndexOf([const] in nsISupports aPossibleElement);
[notxpcom] long IndexOfStartingAt([const] in nsISupports aPossibleElement,
in unsigned long aStartIndex);
[notxpcom] long LastIndexOf([const] in nsISupports aPossibleElement);
// xpcom-compatible versions
long GetIndexOf(in nsISupports aPossibleElement);
long GetIndexOfStartingAt(in nsISupports aPossibleElement,
in unsigned long aStartIndex);
long GetLastIndexOf(in nsISupports aPossibleElement);
[notxpcom] boolean InsertElementAt(in nsISupports aElement,
in unsigned long aIndex);
[notxpcom] boolean ReplaceElementAt(in nsISupports aElement,
in unsigned long aIndex);
[notxpcom] boolean RemoveElementAt(in unsigned long aIndex);
[notxpcom] boolean RemoveLastElement([const] in nsISupports aElement);
// xpcom-compatible versions
void DeleteLastElement(in nsISupports aElement);
void DeleteElementAt(in unsigned long aIndex);
[notxpcom] boolean AppendElements(in nsISupportsArray aElements);
void Compact();
[notxpcom, noscript]
boolean EnumerateForwards(in nsISupportsArrayEnumFunc aFunc,
in voidStar aData);
[notxpcom, noscript]
boolean EnumerateBackwards(in nsISupportsArrayEnumFunc aFunc,
in voidStar aData);
%{C++
private:
// NS_IMETHOD_(nsISupportsArray&) operator=(const nsISupportsArray& other) = 0;
NS_IMETHOD_(PRBool) operator==(const nsISupportsArray& other) = 0;
NS_IMETHOD_(nsISupports*) operator[](PRUint32 aIndex) = 0;
%}
};
%{C++
// Construct and return a default implementation of nsISupportsArray:
extern NS_COM nsresult
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult);
// Construct and return a default implementation of an enumerator for nsISupportsArrays:
extern NS_COM nsresult
NS_NewISupportsArrayEnumerator(nsISupportsArray* array,
nsIBidirectionalEnumerator* *aInstancePtrResult);
%}

View File

@@ -1,263 +0,0 @@
/* -*- 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.
*/
/* nsISupports wrappers for single primitive pieces of data. */
#include "nsISupports.idl"
/**
* These first three are pointer types and do data copying
* using the nsIAllocator. Be careful!
*/
[scriptable, uuid(d18290a0-4a1c-11d3-9890-006008962422)]
interface nsISupportsID : nsISupports
{
attribute nsIDPtr data;
string toString();
};
[scriptable, uuid(d65ff270-4a1c-11d3-9890-006008962422)]
interface nsISupportsString : nsISupports
{
attribute string data;
string toString();
};
[scriptable, uuid(d79dc970-4a1c-11d3-9890-006008962422)]
interface nsISupportsWString : nsISupports
{
attribute wstring data;
wstring toString();
};
/**
* The rest are truly primitive and are passed by value
*/
[scriptable, uuid(ddc3b490-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRBool : nsISupports
{
attribute PRBool data;
string toString();
};
[scriptable, uuid(dec2e4e0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint8 : nsISupports
{
attribute PRUint8 data;
string toString();
};
[scriptable, uuid(dfacb090-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint16 : nsISupports
{
attribute PRUint16 data;
string toString();
};
[scriptable, uuid(e01dc470-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint32 : nsISupports
{
attribute PRUint32 data;
string toString();
};
[scriptable, uuid(e13567c0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint64 : nsISupports
{
attribute PRUint64 data;
string toString();
};
[scriptable, uuid(e2563630-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRTime : nsISupports
{
attribute PRTime data;
string toString();
};
[scriptable, uuid(e2b05e40-4a1c-11d3-9890-006008962422)]
interface nsISupportsChar : nsISupports
{
attribute char data;
string toString();
};
[scriptable, uuid(e30d94b0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRInt16 : nsISupports
{
attribute PRInt16 data;
string toString();
};
[scriptable, uuid(e36c5250-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRInt32 : nsISupports
{
attribute PRInt32 data;
string toString();
};
[scriptable, uuid(e3cb0ff0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRInt64 : nsISupports
{
attribute PRInt64 data;
string toString();
};
[scriptable, uuid(abeaa390-4ac0-11d3-baea-00805f8a5dd7)]
interface nsISupportsFloat : nsISupports
{
attribute float data;
string toString();
};
[scriptable, uuid(b32523a0-4ac0-11d3-baea-00805f8a5dd7)]
interface nsISupportsDouble : nsISupports
{
attribute double data;
string toString();
};
[scriptable, uuid(464484f0-568d-11d3-baf8-00805f8a5dd7)]
interface nsISupportsVoid : nsISupports
{
/*
* This would be: "[noscript] attribute voidStar data;" but for...
* http://bugzilla.mozilla.org/show_bug.cgi?id=11454
*/
[noscript] void GetData([shared,retval] out voidStar aData);
[noscript] void SetData(in voidStar aData);
string toString();
};
/////////////////////////////////////////////////////////////////////////
%{C++
// {ACF8DC40-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_ID_CID \
{ 0xacf8dc40, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_ID_PROGID "component://netscape/supports-id"
#define NS_SUPPORTS_ID_CLASSNAME "Supports ID"
// {ACF8DC41-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_STRING_CID \
{ 0xacf8dc41, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_STRING_PROGID "component://netscape/supports-string"
#define NS_SUPPORTS_STRING_CLASSNAME "Supports String"
// {ACF8DC42-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_WSTRING_CID \
{ 0xacf8dc42, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_WSTRING_PROGID "component://netscape/supports-wstring"
#define NS_SUPPORTS_WSTRING_CLASSNAME "Supports WString"
// {ACF8DC43-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_PRBOOL_CID \
{ 0xacf8dc43, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_PRBOOL_PROGID "component://netscape/supports-PRBool"
#define NS_SUPPORTS_PRBOOL_CLASSNAME "Supports PRBool"
// {ACF8DC44-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_PRUINT8_CID \
{ 0xacf8dc44, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_PRUINT8_PROGID "component://netscape/supports-PRUint8"
#define NS_SUPPORTS_PRUINT8_CLASSNAME "Supports PRUint8"
// {ACF8DC46-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_PRUINT16_CID \
{ 0xacf8dc46, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_PRUINT16_PROGID "component://netscape/supports-PRUint16"
#define NS_SUPPORTS_PRUINT16_CLASSNAME "Supports PRUint16"
// {ACF8DC47-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_PRUINT32_CID \
{ 0xacf8dc47, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_PRUINT32_PROGID "component://netscape/supports-PRUint32"
#define NS_SUPPORTS_PRUINT32_CLASSNAME "Supports PRUint32"
// {ACF8DC48-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_PRUINT64_CID \
{ 0xacf8dc48, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_PRUINT64_PROGID "component://netscape/supports-PRUint64"
#define NS_SUPPORTS_PRUINT64_CLASSNAME "Supports PRUint64"
// {ACF8DC49-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_PRTIME_CID \
{ 0xacf8dc49, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_PRTIME_PROGID "component://netscape/supports-PRTime"
#define NS_SUPPORTS_PRTIME_CLASSNAME "Supports PRTime"
// {ACF8DC4A-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_CHAR_CID \
{ 0xacf8dc4a, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_CHAR_PROGID "component://netscape/supports-char"
#define NS_SUPPORTS_CHAR_CLASSNAME "Supports Char"
// {ACF8DC4B-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_PRINT16_CID \
{ 0xacf8dc4b, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_PRINT16_PROGID "component://netscape/supports-PRInt16"
#define NS_SUPPORTS_PRINT16_CLASSNAME "Supports PRInt16"
// {ACF8DC4C-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_PRINT32_CID \
{ 0xacf8dc4c, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_PRINT32_PROGID "component://netscape/supports-PRInt32"
#define NS_SUPPORTS_PRINT32_CLASSNAME "Supports PRInt32"
// {ACF8DC4D-4A25-11d3-9890-006008962422}
#define NS_SUPPORTS_PRINT64_CID \
{ 0xacf8dc4d, 0x4a25, 0x11d3, \
{ 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
#define NS_SUPPORTS_PRINT64_PROGID "component://netscape/supports-PRInt64"
#define NS_SUPPORTS_PRINT64_CLASSNAME "Supports PRInt64"
// {CBF86870-4AC0-11d3-BAEA-00805F8A5DD7}
#define NS_SUPPORTS_FLOAT_CID \
{ 0xcbf86870, 0x4ac0, 0x11d3, \
{ 0xba, 0xea, 0x0, 0x80, 0x5f, 0x8a, 0x5d, 0xd7 } }
#define NS_SUPPORTS_FLOAT_PROGID "component://netscape/supports-float"
#define NS_SUPPORTS_FLOAT_CLASSNAME "Supports float"
// {CBF86871-4AC0-11d3-BAEA-00805F8A5DD7}
#define NS_SUPPORTS_DOUBLE_CID \
{ 0xcbf86871, 0x4ac0, 0x11d3, \
{ 0xba, 0xea, 0x0, 0x80, 0x5f, 0x8a, 0x5d, 0xd7 } }
#define NS_SUPPORTS_DOUBLE_PROGID "component://netscape/supports-double"
#define NS_SUPPORTS_DOUBLE_CLASSNAME "Supports double"
// {AF10F3E0-568D-11d3-BAF8-00805F8A5DD7}
#define NS_SUPPORTS_VOID_CID \
{ 0xaf10f3e0, 0x568d, 0x11d3, \
{ 0xba, 0xf8, 0x0, 0x80, 0x5f, 0x8a, 0x5d, 0xd7 } }
#define NS_SUPPORTS_VOID_PROGID "component://netscape/supports-void"
#define NS_SUPPORTS_VOID_CLASSNAME "Supports void"
%}

View File

@@ -1,57 +0,0 @@
/* -*- 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.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 nsIUnicharBuffer_h___
#define nsIUnicharBuffer_h___
#include "nscore.h"
#include "nsISupports.h"
class nsIUnicharInputStream;
#define NS_IUNICHARBUFFER_IID \
{ 0x14cf6970, 0x93b5, 0x11d1, \
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
/// Interface to a buffer that holds unicode characters
class nsIUnicharBuffer : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IUNICHARBUFFER_IID);
NS_IMETHOD Init(PRUint32 aBufferSize) = 0;
NS_IMETHOD_(PRInt32) GetLength() const = 0;
NS_IMETHOD_(PRInt32) GetBufferSize() const = 0;
NS_IMETHOD_(PRUnichar*) GetBuffer() const = 0;
NS_IMETHOD_(PRBool) Grow(PRInt32 aNewSize) = 0;
NS_IMETHOD_(PRInt32) Fill(nsresult* aErrorCode, nsIUnicharInputStream* aStream,
PRInt32 aKeep) = 0;
};
/// Factory method for nsIUnicharBuffer.
extern NS_COM nsresult
NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult,
nsISupports* aOuter,
PRUint32 aBufferSize = 0);
#define NS_UNICHARBUFFER_CID \
{ /* c81fd8f0-0d6b-11d3-9331-00104ba0fd40 */ \
0xc81fd8f0, \
0x0d6b, \
0x11d3, \
{0x93, 0x31, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
#endif /* nsIUnicharBuffer_h___ */

View File

@@ -1,340 +0,0 @@
/* -*- 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.
*/
#ifndef nsInt64_h__
#define nsInt64_h__
#include "prlong.h"
#include "nscore.h"
/**
* This class encapsulates full 64-bit integer functionality and
* provides simple arithmetic and conversion operations.
*/
// If you ever decide that you need to add a non-inline method to this
// class, be sure to change the class declaration to "class NS_BASE
// nsInt64".
class nsInt64
{
private:
PRInt64 mValue;
public:
/**
* Construct a new 64-bit integer.
*/
nsInt64(void) : mValue(LL_ZERO) {
}
/**
* Construct a new 64-bit integer from a 32-bit signed integer
*/
nsInt64(const PRInt32 aInt32) {
LL_I2L(mValue, aInt32);
}
/**
* Construct a new 64-bit integer from a 32-bit unsigned integer
*/
nsInt64(const PRUint32 aUint32) {
LL_UI2L(mValue, aUint32);
}
/**
* Construct a new 64-bit integer from a floating point value.
*/
nsInt64(const PRFloat64 aFloat64) {
LL_D2L(mValue, aFloat64);
}
/**
* Construct a new 64-bit integer from a native 64-bit integer
*/
nsInt64(const PRInt64 aInt64) : mValue(aInt64) {
}
/**
* Construct a new 64-bit integer from another 64-bit integer
*/
nsInt64(const nsInt64& aObject) : mValue(aObject.mValue) {
}
// ~nsInt64(void) -- XXX destructor unnecessary
/**
* Assign a 64-bit integer to another 64-bit integer
*/
const nsInt64& operator =(const nsInt64& aObject) {
mValue = aObject.mValue;
return *this;
}
/**
* Convert a 64-bit integer to a signed 32-bit value
*/
operator PRInt32(void) const {
PRInt32 result;
LL_L2I(result, mValue);
return result;
}
/**
* Convert a 64-bit integer to an unsigned 32-bit value
*/
operator PRUint32(void) const {
PRUint32 result;
LL_L2UI(result, mValue);
return result;
}
/**
* Convert a 64-bit integer to a floating point value
*/
operator PRFloat64(void) const {
PRFloat64 result;
LL_L2D(result, mValue);
return result;
}
/**
* Convert a 64-bit integer to a native 64-bit integer.
*/
operator PRInt64(void) const {
return mValue;
}
/**
* Perform unary negation on a 64-bit integer.
*/
const nsInt64 operator -(void) {
nsInt64 result;
LL_NEG(result.mValue, mValue);
return result;
}
// Arithmetic operators
friend const nsInt64 operator +(const nsInt64& aObject1, const nsInt64& aObject2);
friend const nsInt64 operator -(const nsInt64& aObject1, const nsInt64& aObject2);
friend const nsInt64 operator *(const nsInt64& aObject1, const nsInt64& aObject2);
friend const nsInt64 operator /(const nsInt64& aObject1, const nsInt64& aObject2);
friend const nsInt64 operator %(const nsInt64& aObject1, const nsInt64& aObject2);
/**
* Increment a 64-bit integer by a 64-bit integer amount.
*/
nsInt64& operator +=(const nsInt64& aObject) {
LL_ADD(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Decrement a 64-bit integer by a 64-bit integer amount.
*/
nsInt64& operator -=(const nsInt64& aObject) {
LL_SUB(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Multiply a 64-bit integer by a 64-bit integer amount.
*/
nsInt64& operator *=(const nsInt64& aObject) {
LL_MUL(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Divide a 64-bit integer by a 64-bit integer amount.
*/
nsInt64& operator /=(const nsInt64& aObject) {
LL_DIV(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Compute the modulus of a 64-bit integer to a 64-bit value.
*/
nsInt64& operator %=(const nsInt64& aObject) {
LL_MOD(mValue, mValue, aObject.mValue);
return *this;
}
// Comparison operators
friend PRBool operator ==(const nsInt64& aObject1, const nsInt64& aObject2);
friend PRBool operator !=(const nsInt64& aObject1, const nsInt64& aObject2);
friend PRBool operator >(const nsInt64& aObject1, const nsInt64& aObject2);
friend PRBool operator >=(const nsInt64& aObject1, const nsInt64& aObject2);
friend PRBool operator <(const nsInt64& aObject1, const nsInt64& aObject2);
friend PRBool operator <=(const nsInt64& aObject1, const nsInt64& aObject2);
// Bitwise operators
friend const nsInt64 operator &(const nsInt64& aObject1, const nsInt64& aObject2);
friend const nsInt64 operator |(const nsInt64& aObject1, const nsInt64& aObject2);
friend const nsInt64 operator ^(const nsInt64& aObject1, const nsInt64& aObject2);
/**
* Compute the bitwise NOT of a 64-bit integer
*/
const nsInt64 operator ~(void) {
nsInt64 result;
LL_NOT(result.mValue, mValue);
return result;
}
/**
* Compute the bitwise AND with another 64-bit integer
*/
nsInt64& operator &=(const nsInt64& aObject) {
LL_AND(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Compute the bitwise OR with another 64-bit integer
*/
nsInt64& operator |=(const nsInt64& aObject) {
LL_OR(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Compute the bitwise XOR with another 64-bit integer
*/
nsInt64& operator ^=(const nsInt64& aObject) {
LL_XOR(mValue, mValue, aObject.mValue);
return *this;
}
};
/**
* Add two 64-bit integers.
*/
inline const nsInt64
operator +(const nsInt64& aObject1, const nsInt64& aObject2) {
return nsInt64(aObject1) += aObject2;
}
/**
* Subtract one 64-bit integer from another.
*/
inline const nsInt64
operator -(const nsInt64& aObject1, const nsInt64& aObject2) {
return nsInt64(aObject1) -= aObject2;
}
/**
* Multiply two 64-bit integers
*/
inline const nsInt64
operator *(const nsInt64& aObject1, const nsInt64& aObject2) {
return nsInt64(aObject1) *= aObject2;
}
/**
* Divide one 64-bit integer by another
*/
inline const nsInt64
operator /(const nsInt64& aObject1, const nsInt64& aObject2) {
return nsInt64(aObject1) /= aObject2;
}
/**
* Compute the modulus of two 64-bit integers
*/
inline const nsInt64
operator %(const nsInt64& aObject1, const nsInt64& aObject2) {
return nsInt64(aObject1) %= aObject2;
}
/**
* Determine if two 64-bit integers are equal
*/
inline PRBool
operator ==(const nsInt64& aObject1, const nsInt64& aObject2) {
return LL_EQ(aObject1.mValue, aObject2.mValue);
}
/**
* Determine if two 64-bit integers are not equal
*/
inline PRBool
operator !=(const nsInt64& aObject1, const nsInt64& aObject2) {
return LL_NE(aObject1.mValue, aObject2.mValue);
}
/**
* Determine if one 64-bit integer is strictly greater than another, using signed values
*/
inline PRBool
operator >(const nsInt64& aObject1, const nsInt64& aObject2) {
return LL_CMP(aObject1.mValue, >, aObject2.mValue);
}
/**
* Determine if one 64-bit integer is greater than or equal to another, using signed values
*/
inline PRBool
operator >=(const nsInt64& aObject1, const nsInt64& aObject2) {
return LL_CMP(aObject1.mValue, >=, aObject2.mValue);
}
/**
* Determine if one 64-bit integer is strictly less than another, using signed values
*/
inline PRBool
operator <(const nsInt64& aObject1, const nsInt64& aObject2) {
return LL_CMP(aObject1.mValue, <, aObject2.mValue);
}
/**
* Determine if one 64-bit integers is less than or equal to another, using signed values
*/
inline PRBool
operator <=(const nsInt64& aObject1, const nsInt64& aObject2) {
return LL_CMP(aObject1.mValue, <=, aObject2.mValue);
}
/**
* Perform a bitwise AND of two 64-bit integers
*/
inline const nsInt64
operator &(const nsInt64& aObject1, const nsInt64& aObject2) {
return nsInt64(aObject1) &= aObject2;
}
/**
* Perform a bitwise OR of two 64-bit integers
*/
inline const nsInt64
operator |(const nsInt64& aObject1, const nsInt64& aObject2) {
return nsInt64(aObject1) |= aObject2;
}
/**
* Perform a bitwise XOR of two 64-bit integers
*/
inline const nsInt64
operator ^(const nsInt64& aObject1, const nsInt64& aObject2) {
return nsInt64(aObject1) ^= aObject2;
}
#endif // nsInt64_h__

View File

@@ -1,92 +0,0 @@
/* -*- 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.
*/
#define NS_IMPL_IDS
#include "pratom.h"
#include "nsIFactory.h"
#include "nsIServiceManager.h"
#include "nsRepository.h"
#include "nsIObserver.h"
#include "nsObserver.h"
#include "nsString.h"
static NS_DEFINE_CID(kObserverCID, NS_OBSERVER_CID);
////////////////////////////////////////////////////////////////////////////////
// nsObserver Implementation
NS_IMPL_AGGREGATED(nsObserver)
NS_COM nsresult NS_NewObserver(nsIObserver** anObserver, nsISupports* outer)
{
return nsObserver::Create(outer, NS_GET_IID(nsIObserver), (void**)anObserver);
}
NS_METHOD
nsObserver::Create(nsISupports* outer, const nsIID& aIID, void* *anObserver)
{
NS_ENSURE_ARG_POINTER(anObserver);
NS_ENSURE_PROPER_AGGREGATION(outer, aIID);
nsObserver* it = new nsObserver(outer);
if (it == NULL)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = it->AggregatedQueryInterface(aIID, anObserver);
if (NS_FAILED(rv)) {
delete it;
return rv;
}
return rv;
}
nsObserver::nsObserver(nsISupports* outer)
{
NS_INIT_AGGREGATED(outer);
}
nsObserver::~nsObserver(void)
{
}
NS_IMETHODIMP
nsObserver::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
{
NS_ENSURE_ARG_POINTER(aInstancePtr);
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
*aInstancePtr = GetInner();
else if(aIID.Equals(nsIObserver::GetIID()))
*aInstancePtr = NS_STATIC_CAST(nsIObserver*, this);
else {
*aInstancePtr = nsnull;
return NS_NOINTERFACE;
}
NS_ADDREF((nsISupports*)*aInstancePtr);
return NS_OK;
}
NS_IMETHODIMP
nsObserver::Observe( nsISupports *, const PRUnichar *, const PRUnichar * ) {
nsresult rv = NS_OK;
return rv;
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,50 +0,0 @@
/* -*- 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.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 nsObserver_h___
#define nsObserver_h___
#include "nsIObserver.h"
#include "nsAgg.h"
// {DB242E03-E4D9-11d2-9DDE-000064657374}
#define NS_OBSERVER_CID \
{ 0xdb242e03, 0xe4d9, 0x11d2, { 0x9d, 0xde, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
class nsObserver : public nsIObserver {
public:
NS_DEFINE_STATIC_CID_ACCESSOR( NS_OBSERVER_CID )
NS_DECL_NSIOBSERVER
nsObserver(nsISupports* outer);
virtual ~nsObserver(void);
static NS_METHOD
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
NS_DECL_AGGREGATED
private:
};
extern NS_COM nsresult NS_NewObserver(nsIObserver** anObserver, nsISupports* outer = NULL);
#endif /* nsObserver_h___ */

View File

@@ -1,133 +0,0 @@
/* -*- 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.
*/
#define NS_IMPL_IDS
#include "pratom.h"
#include "nsIObserverList.h"
#include "nsObserverList.h"
#include "nsString.h"
#include "nsAutoLock.h"
#define NS_AUTOLOCK(__monitor) nsAutoLock __lock(__monitor)
static NS_DEFINE_CID(kObserverListCID, NS_OBSERVERLIST_CID);
////////////////////////////////////////////////////////////////////////////////
// nsObserverList Implementation
NS_IMPL_ISUPPORTS1(nsObserverList, nsIObserverList)
NS_COM nsresult NS_NewObserverList(nsIObserverList** anObserverList)
{
if (anObserverList == NULL)
{
return NS_ERROR_NULL_POINTER;
}
nsObserverList* it = new nsObserverList();
if (it == 0) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(NS_GET_IID(nsIObserverList), (void **) anObserverList);
}
nsObserverList::nsObserverList()
: mLock(nsnull),
mObserverList(NULL)
{
NS_INIT_REFCNT();
mLock = PR_NewLock();
}
nsObserverList::~nsObserverList(void)
{
PR_DestroyLock(mLock);
NS_IF_RELEASE(mObserverList);
}
nsresult nsObserverList::AddObserver(nsIObserver** anObserver)
{
nsresult rv;
PRBool inserted;
NS_AUTOLOCK(mLock);
if (anObserver == NULL)
{
return NS_ERROR_NULL_POINTER;
}
if(!mObserverList) {
rv = NS_NewISupportsArray(&mObserverList);
if (NS_FAILED(rv)) return rv;
}
if(*anObserver) {
inserted = mObserverList->AppendElement(*anObserver);
return inserted ? NS_OK : NS_ERROR_FAILURE;
}
return NS_ERROR_FAILURE;
}
nsresult nsObserverList::RemoveObserver(nsIObserver** anObserver)
{
PRBool removed;
NS_AUTOLOCK(mLock);
if (anObserver == NULL)
{
return NS_ERROR_NULL_POINTER;
}
if(!mObserverList) {
return NS_ERROR_FAILURE;
}
if(*anObserver) {
removed = mObserverList->RemoveElement(*anObserver);
return removed ? NS_OK : NS_ERROR_FAILURE;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsObserverList::EnumerateObserverList(nsIEnumerator** anEnumerator)
{
NS_AUTOLOCK(mLock);
if (anEnumerator == NULL)
{
return NS_ERROR_NULL_POINTER;
}
if(!mObserverList) {
return NS_ERROR_FAILURE;
}
return mObserverList->Enumerate(anEnumerator);
}

View File

@@ -1,51 +0,0 @@
/* -*- 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.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 nsObserverList_h___
#define nsObserverList_h___
#include "nsIObserverList.h"
#include "nsIEnumerator.h"
#include "nsISupportsArray.h"
class nsObserverList : public nsIObserverList {
public:
NS_IMETHOD AddObserver(nsIObserver** anObserver);
NS_IMETHOD RemoveObserver(nsIObserver** anObserver);
NS_IMETHOD EnumerateObserverList(nsIEnumerator** anEnumerator);
nsObserverList();
virtual ~nsObserverList(void);
// This is ObserverList monitor object.
PRLock* mLock;
NS_DECL_ISUPPORTS
private:
nsISupportsArray *mObserverList;
};
#endif /* nsObserverList_h___ */

View File

@@ -1,249 +0,0 @@
/* -*- 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.
*/
#define NS_IMPL_IDS
#include "prlock.h"
#include "nsIFactory.h"
#include "nsIServiceManager.h"
#include "nsRepository.h"
#include "nsIObserverService.h"
#include "nsObserverService.h"
#include "nsIObserverList.h"
#include "nsObserverList.h"
#include "nsHashtable.h"
#include "nsString.h"
static NS_DEFINE_CID(kObserverServiceCID, NS_OBSERVERSERVICE_CID);
////////////////////////////////////////////////////////////////////////////////
static nsObserverService* gObserverService = nsnull; // The one-and-only ObserverService
////////////////////////////////////////////////////////////////////////////////
// nsObserverService Implementation
NS_IMPL_ISUPPORTS1(nsObserverService, nsIObserverService)
NS_COM nsresult NS_NewObserverService(nsIObserverService** anObserverService)
{
return nsObserverService::GetObserverService(anObserverService);
}
nsObserverService::nsObserverService()
: mObserverTopicTable(NULL)
{
NS_INIT_REFCNT();
mObserverTopicTable = nsnull;
}
nsObserverService::~nsObserverService(void)
{
if(mObserverTopicTable)
delete mObserverTopicTable;
gObserverService = nsnull;
}
NS_METHOD
nsObserverService::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
{
nsresult rv;
nsObserverService* os = new nsObserverService();
if (os == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(os);
rv = os->QueryInterface(aIID, aInstancePtr);
NS_RELEASE(os);
return rv;
}
nsresult nsObserverService::GetObserverService(nsIObserverService** anObserverService)
{
if (! gObserverService) {
nsObserverService* it = new nsObserverService();
if (! it)
return NS_ERROR_OUT_OF_MEMORY;
gObserverService = it;
}
NS_ADDREF(gObserverService);
*anObserverService = gObserverService;
return NS_OK;
}
static PRBool
ReleaseObserverList(nsHashKey *aKey, void *aData, void* closure)
{
nsIObserverList* observerList = NS_STATIC_CAST(nsIObserverList*, aData);
NS_RELEASE(observerList);
return PR_TRUE;
}
nsresult nsObserverService::GetObserverList(const nsString& aTopic, nsIObserverList** anObserverList)
{
if (anObserverList == NULL)
{
return NS_ERROR_NULL_POINTER;
}
if(mObserverTopicTable == NULL) {
mObserverTopicTable = new nsObjectHashtable(nsnull, nsnull, // should never be cloned
ReleaseObserverList, nsnull,
256, PR_TRUE);
if (mObserverTopicTable == NULL)
return NS_ERROR_OUT_OF_MEMORY;
}
nsStringKey key(aTopic);
nsIObserverList *topicObservers = nsnull;
if (mObserverTopicTable->Exists(&key)) {
topicObservers = (nsIObserverList *) mObserverTopicTable->Get(&key);
if (topicObservers != NULL) {
*anObserverList = topicObservers;
} else {
NS_NewObserverList(&topicObservers);
mObserverTopicTable->Put(&key, topicObservers);
}
} else {
NS_NewObserverList(&topicObservers);
*anObserverList = topicObservers;
mObserverTopicTable->Put(&key, topicObservers);
}
return NS_OK;
}
nsresult nsObserverService::AddObserver(nsIObserver* anObserver, const PRUnichar* aTopic)
{
nsIObserverList* anObserverList;
nsresult rv;
if (anObserver == NULL)
{
return NS_ERROR_NULL_POINTER;
}
if (aTopic == NULL)
{
return NS_ERROR_NULL_POINTER;
}
nsAutoString topic(aTopic);
rv = GetObserverList(topic, &anObserverList);
if (NS_FAILED(rv)) return rv;
if (anObserverList) {
return anObserverList->AddObserver(&anObserver);
}
return NS_ERROR_FAILURE;
}
nsresult nsObserverService::RemoveObserver(nsIObserver* anObserver, const PRUnichar* aTopic)
{
nsIObserverList* anObserverList;
nsresult rv;
if (anObserver == NULL)
{
return NS_ERROR_NULL_POINTER;
}
if (aTopic == NULL)
{
return NS_ERROR_NULL_POINTER;
}
nsAutoString topic(aTopic);
rv = GetObserverList(topic, &anObserverList);
if (NS_FAILED(rv)) return rv;
if (anObserverList) {
return anObserverList->RemoveObserver(&anObserver);
}
return NS_ERROR_FAILURE;
}
nsresult nsObserverService::EnumerateObserverList(const PRUnichar* aTopic, nsIEnumerator** anEnumerator)
{
nsIObserverList* anObserverList;
nsresult rv;
if (anEnumerator == NULL)
{
return NS_ERROR_NULL_POINTER;
}
if (aTopic == NULL)
{
return NS_ERROR_NULL_POINTER;
}
nsAutoString topic(aTopic);
rv = GetObserverList(topic, &anObserverList);
if (NS_FAILED(rv)) return rv;
if (anObserverList) {
return anObserverList->EnumerateObserverList(anEnumerator);
}
return NS_ERROR_FAILURE;
}
// Enumerate observers of aTopic and call Observe on each.
nsresult nsObserverService::Notify( nsISupports *aSubject,
const PRUnichar *aTopic,
const PRUnichar *someData ) {
nsresult rv = NS_OK;
nsIEnumerator *observers;
// Get observer list enumerator.
rv = this->EnumerateObserverList( aTopic, &observers );
if ( NS_SUCCEEDED( rv ) ) {
// Go to start of observer list.
rv = observers->First();
// Continue until error or end of list.
while ( observers->IsDone() != NS_OK && NS_SUCCEEDED(rv) ) {
// Get current item (observer).
nsISupports *base;
rv = observers->CurrentItem( &base );
if ( NS_SUCCEEDED( rv ) ) {
// Convert item to nsIObserver.
nsIObserver *observer;
rv = base->QueryInterface( nsIObserver::GetIID(), (void**)&observer );
if ( NS_SUCCEEDED( rv ) && observer ) {
// Tell the observer what's up.
observer->Observe( aSubject, aTopic, someData );
// Release the observer.
observer->Release();
}
}
// Go on to next observer in list.
rv = observers->Next();
}
// Release the observer list.
observers->Release();
rv = NS_OK;
}
return rv;
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,56 +0,0 @@
/* -*- 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.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 nsObserverService_h___
#define nsObserverService_h___
#include "nsIObserverService.h"
#include "nsIObserverList.h"
class nsObjectHashtable;
class nsString;
// {D07F5195-E3D1-11d2-8ACD-00105A1B8860}
#define NS_OBSERVERSERVICE_CID \
{ 0xd07f5195, 0xe3d1, 0x11d2, { 0x8a, 0xcd, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } }
class nsObserverService : public nsIObserverService {
public:
NS_DEFINE_STATIC_CID_ACCESSOR( NS_OBSERVERSERVICE_CID )
static nsresult GetObserverService(nsIObserverService** anObserverService);
NS_DECL_NSIOBSERVERSERVICE
nsObserverService();
virtual ~nsObserverService(void);
NS_DECL_ISUPPORTS
static NS_METHOD
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
private:
NS_IMETHOD GetObserverList(const nsString& aTopic, nsIObserverList** anObserverList);
nsObjectHashtable* mObserverTopicTable;
};
#endif /* nsObserverService_h___ */

View File

@@ -1,914 +0,0 @@
/* -*- 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.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 "nsPageMgr.h"
#include "prmem.h"
#if defined(XP_PC)
#include <windows.h>
#elif defined(XP_MAC)
#include <stdlib.h>
#elif defined(XP_BEOS)
#include <fcntl.h>
#elif defined(XP_UNIX)
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <malloc.h>
#ifndef MAP_FAILED
#if defined (__STDC__) && __STDC__
#define MAP_FAILED ((void *) -1)
#else
#define MAP_FAILED ((char *) -1)
#endif
#endif
#if defined(VMS)
#if defined(DEBUG)
#include <stdio.h>
#endif
#include <starlet.h>
#include <ssdef.h>
#include <vadef.h>
#include <va_rangedef.h>
#endif
#endif
/******************************************************************************/
#define NS_PAGEMGR_CLUSTERDESC_CLUMPSIZE 16
void
nsPageMgr::DeleteFreeClusterDesc(nsClusterDesc *desc)
{
desc->mNext = mUnusedClusterDescs;
mUnusedClusterDescs = desc;
}
nsPageMgr::nsClusterDesc*
nsPageMgr::NewFreeClusterDesc(void)
{
nsClusterDesc *desc = mUnusedClusterDescs;
if (desc)
mUnusedClusterDescs = desc->mNext;
else {
/* Allocate a clump of cluster records at once, and link all except
the first onto the list of mUnusedClusterDescs */
desc = (nsClusterDesc*)PR_Malloc(NS_PAGEMGR_CLUSTERDESC_CLUMPSIZE * sizeof(nsClusterDesc));
if (desc) {
nsClusterDesc* desc2 = desc + (NS_PAGEMGR_CLUSTERDESC_CLUMPSIZE - 1);
while (desc2 != desc) {
DeleteFreeClusterDesc(desc2--);
}
}
}
return desc;
}
/* Search the mFreeClusters looking for the first cluster of consecutive free
pages that is at least size bytes long. If there is one, remove these pages
from the free page list and return their address; if not, return nil. */
nsPage*
nsPageMgr::AllocClusterFromFreeList(PRUword nPages)
{
nsClusterDesc **p = &mFreeClusters;
nsClusterDesc *desc;
while ((desc = *p) != NULL) {
if (desc->mPageCount >= nPages) {
nsPage* addr = desc->mAddr;
if (desc->mPageCount == nPages) {
*p = desc->mNext;
DeleteFreeClusterDesc(desc);
}
else {
desc->mAddr += nPages;
desc->mPageCount -= nPages;
}
return addr;
}
p = &desc->mNext;
}
return NULL;
}
/* Add the segment to the nsClusterDesc list, coalescing it with any
clusters already in the list when possible. */
void
nsPageMgr::AddClusterToFreeList(nsPage* addr, PRWord nPages)
{
nsClusterDesc **p = &mFreeClusters;
nsClusterDesc *desc;
nsClusterDesc *newDesc;
while ((desc = *p) != NULL) {
if (desc->mAddr + desc->mPageCount == addr) {
/* Coalesce with the previous cluster. */
nsClusterDesc *next = desc->mNext;
desc->mPageCount += nPages;
if (next && next->mAddr == addr + nPages) {
/* We can coalesce with both the previous and the next cluster. */
desc->mPageCount += next->mPageCount;
desc->mNext = next->mNext;
DeleteFreeClusterDesc(next);
}
return;
}
if (desc->mAddr == addr + nPages) {
/* Coalesce with the next cluster. */
desc->mAddr -= nPages;
desc->mPageCount += nPages;
return;
}
if (desc->mAddr > addr) {
PR_ASSERT(desc->mAddr > addr + nPages);
break;
}
PR_ASSERT(desc->mAddr + desc->mPageCount < addr);
p = &desc->mNext;
}
newDesc = NewFreeClusterDesc();
/* In the unlikely event that this malloc fails, we drop the free cluster
on the floor. The only consequence is that the memory mapping table
becomes slightly larger. */
if (newDesc) {
newDesc->mNext = desc;
newDesc->mAddr = addr;
newDesc->mPageCount = nPages;
*p = newDesc;
}
}
#ifdef NS_PAGEMGR_VERIFYCLUSTERS
#ifndef XP_PC
#define OutputDebugString(x) puts(x)
#endif
void
nsPageMgr::VerifyClusters(PRWord nPagesDelta)
{
static PRUword expectedPagesUsed = 0;
nsPageCount calculatedPagesUsed;
nsPage* lastDescEnd = 0;
nsClusterDesc* desc;
char str[256];
expectedPagesUsed += nPagesDelta;
calculatedPagesUsed = mBoundary - mMemoryBase;
sprintf(str, "[Clusters: %p", mMemoryBase);
OutputDebugString(str);
for (desc = mFreeClusters; desc; desc = desc->mNext) {
PR_ASSERT(desc->mAddr > lastDescEnd);
calculatedPagesUsed -= desc->mPageCount;
lastDescEnd = desc->mAddr + desc->mPageCount;
sprintf(str, "..%p, %p", desc->mAddr-1, desc->mAddr + desc->mPageCount);
OutputDebugString(str);
}
sprintf(str, "..%p]\n", mBoundary);
OutputDebugString(str);
PR_ASSERT(lastDescEnd < mBoundary);
PR_ASSERT(calculatedPagesUsed == expectedPagesUsed);
}
#endif /* NS_PAGEMGR_VERIFYCLUSTERS */
/*******************************************************************************
* Machine-dependent stuff
******************************************************************************/
#if defined(XP_PC)
#define GC_VMBASE 0x40000000 /* XXX move */
#define GC_VMLIMIT 0x0FFFFFFF
#elif defined(XP_MAC)
#define NS_PAGEMGR_MAC_SEGMENT_SIZE
#define NS_PAGEMGR_MAC_SEGMENT_COUNT
#endif
PRStatus
nsPageMgr::InitPages(nsPageCount minPages, nsPageCount maxPages)
{
#if defined(XP_PC)
nsPage* addr = NULL;
nsPageCount size = maxPages;
#ifdef NS_PAGEMGR_DEBUG
/* first try to place the heap at a well-known address for debugging */
addr = (nsPage*)VirtualAlloc((void*)GC_VMBASE, size << NS_PAGEMGR_PAGE_BITS,
MEM_RESERVE, PAGE_READWRITE);
#endif
while (addr == NULL) {
/* let the system place the heap */
addr = (nsPage*)VirtualAlloc(0, size << NS_PAGEMGR_PAGE_BITS,
MEM_RESERVE, PAGE_READWRITE);
if (addr == NULL) {
size--;
if (size < minPages) {
return PR_FAILURE;
}
}
}
PR_ASSERT(NS_PAGEMGR_IS_ALIGNED(addr, NS_PAGEMGR_PAGE_BITS));
mMemoryBase = addr;
mPageCount = size;
mBoundary = addr;
return PR_SUCCESS;
#elif defined(XP_MAC)
OSErr err;
void* seg;
void* segLimit;
Handle h;
PRUword segSize = (minPages + 1) * NS_PAGEMGR_PAGE_SIZE;
nsPage* firstPage;
nsPage* lastPage;
nsSegmentDesc* mSegTable;
int mSegTableCount, otherCount;
h = TempNewHandle(segSize, &err);
if (err || h == NULL) goto fail;
MoveHHi(h);
TempHLock(h, &err);
if (err) goto fail;
seg = *h;
segLimit = (void*)((char*)seg + segSize);
firstPage = NS_PAGEMGR_PAGE_ROUNDUP(seg);
lastPage = NS_PAGEMGR_PAGE_ROUNDDN(((char*)seg + segSize));
/* Put the segment table in the otherwise wasted space at one
end of the segment. We'll put it at which ever end is bigger. */
mSegTable = (nsSegmentDesc*)seg;
mSegTableCount = ((char*)firstPage - (char*)seg) / sizeof(nsSegmentDesc);
otherCount = ((char*)segLimit - (char*)lastPage) / sizeof(nsSegmentDesc);
if (otherCount > mSegTableCount) {
mSegTable = (nsSegmentDesc*)lastPage;
mSegTableCount = otherCount;
}
else if (mSegTableCount == 0) {
mSegTable = (nsSegmentDesc*)firstPage;
firstPage++;
mSegTableCount = NS_PAGEMGR_PAGE_SIZE / sizeof(nsSegmentDesc);
}
PR_ASSERT(mSegTableCount > 0);
mSegTable = mSegTable;
mSegTableCount = mSegTableCount;
mSegTable[0].mHandle = h;
mSegTable[0].mFirstPage = firstPage;
mSegTable[0].mLastPage = lastPage;
/* XXX hack for now -- just one segment */
mMemoryBase = firstPage;
mBoundary = firstPage;
mPageCount = lastPage - firstPage;
return PR_SUCCESS;
fail:
if (h) {
TempDisposeHandle(h, &err);
}
return PR_FAILURE;
#elif defined(XP_BEOS)
nsPage* addr = NULL;
nsPageCount size = maxPages;
#if (1L<<NS_PAGEMGR_PAGE_BITS) != B_PAGE_SIZE
#error can only work with 4096 byte pages
#endif
while(addr == NULL)
{
/* let the system place the heap */
if((mAid = create_area("MozillaHeap", (void **)&addr, B_ANY_ADDRESS,
size << NS_PAGEMGR_PAGE_BITS, B_NO_LOCK,
B_READ_AREA | B_WRITE_AREA)) < 0)
{
addr = NULL;
size--;
if (size < minPages) {
return PR_FAILURE;
}
}
}
PR_ASSERT(NS_PAGEMGR_IS_ALIGNED(addr, NS_PAGEMGR_PAGE_BITS));
mMemoryBase = addr;
mPageCount = size;
mBoundary = addr;
return PR_SUCCESS;
#elif defined(VMS)
nsPage* addr = NULL;
nsPageCount size = maxPages;
struct _va_range retadr, retadr2;
int status;
/*
** The default is 32767 pages. This is quite a lot (the pages are 4k).
** Let's at least make it configurable.
*/
char *tmp;
tmp = getenv("VMS_PAGE_MANAGER_SIZE");
if (tmp)
size=atoi(tmp);
#if defined(DEBUG)
printf("Requested page manager size is %d 4k pages\n",size);
#endif
/*
** $EXPREG will extend the virtual address region by the requested
** number of pages (or pagelets on Alpha). The process must have
** sufficient PGFLQUOTA for the operation, otherwise SS$_EXQUOTA will
** be returned. However, in the case of SS$_EXQUOTA, $EXPREG will have
** grown the region by the largest possible amount. In this case we will
** put back the maximum amount and repeat the $EXPREG requesting half of
** maximum (so as to leave some memory for others), just so long as its
** over our minimum threshold.
*/
status = sys$expreg(size << (NS_PAGEMGR_PAGE_BITS-VA$C_PAGELET_SHIFT_SIZE),
&retadr,0,0);
switch (status) {
case SS$_NORMAL:
break;
case SS$_EXQUOTA:
size = ( (int)retadr.va_range$ps_end_va -
(int)retadr.va_range$ps_start_va + 1
) >> NS_PAGEMGR_PAGE_BITS;
status=sys$deltva(&retadr,&retadr2,0);
size=size/2;
if (size < minPages) {
return PR_FAILURE;
}
status = sys$expreg(
size << (NS_PAGEMGR_PAGE_BITS-VA$C_PAGELET_SHIFT_SIZE),
&retadr,0,0);
if (status != SS$_NORMAL) {
status=sys$deltva(&retadr,&retadr2,0);
return PR_FAILURE;
}
size = ( (int)retadr.va_range$ps_end_va -
(int)retadr.va_range$ps_start_va + 1
) >> NS_PAGEMGR_PAGE_BITS;
break;
default:
return PR_FAILURE;
}
#if defined(DEBUG)
printf("Actual page manager size is %d 4k pages\n",size);
#endif
/* We got at least something */
addr = (nsPage *)retadr.va_range$ps_start_va;
PR_ASSERT(NS_PAGEMGR_IS_ALIGNED(addr, NS_PAGEMGR_PAGE_BITS));
mMemoryBase = addr;
mPageCount = size;
mBoundary = addr;
return PR_SUCCESS;
#else
nsPage* addr = NULL;
nsPageCount size = maxPages;
mZero_fd = 0;
#ifdef HAVE_DEV_ZERO
mZero_fd = open("/dev/zero", O_RDWR);
while (addr == NULL) {
/* let the system place the heap */
addr = (nsPage*)mmap(0, size << NS_PAGEMGR_PAGE_BITS,
PROT_READ | PROT_WRITE,
MAP_PRIVATE,
mZero_fd, 0);
if (addr == (nsPage*)MAP_FAILED) {
addr = NULL;
size--;
if (size < minPages) {
return PR_FAILURE;
}
}
}
#else
#ifdef HAVE_VALLOC
while (addr == NULL) {
addr = (nsPage*)valloc(size << NS_PAGEMGR_PAGE_BITS);
if (NULL == addr) {
size--;
if (size < minPages) {
return PR_FAILURE;
}
}
}
memset(addr, '\0', size << NS_PAGEMGR_PAGE_BITS);
#endif /* HAVE_VALLOC */
#endif /* HAVE_DEV_ZERO */
PR_ASSERT(NS_PAGEMGR_IS_ALIGNED(addr, NS_PAGEMGR_PAGE_BITS));
mMemoryBase = addr;
mPageCount = size;
mBoundary = addr;
return PR_SUCCESS;
#endif
}
void
nsPageMgr::FinalizePages()
{
#if defined(XP_PC)
BOOL ok;
ok = VirtualFree((void*)mMemoryBase, 0, MEM_RELEASE);
PR_ASSERT(ok);
mMemoryBase = NULL;
mPageCount = 0;
nsAutoMonitor::DestroyMonitor(mMonitor);
mMonitor = NULL;
#elif defined(XP_MAC)
OSErr err;
PRUword i;
for (i = 0; i < mSegTableCount; i++) {
if (mSegTable[i].mHandle) {
TempDisposeHandle(mSegTable[i].mHandle, &err);
PR_ASSERT(err == 0);
}
}
#elif defined(XP_BEOS)
delete_area(mAid);
#elif defined(VMS)
struct _va_range retadr, retadr2;
retadr.va_range$ps_start_va = mMemoryBase;
retadr.va_range$ps_end_va = mMemoryBase +
(mPageCount << NS_PAGEMGR_PAGE_BITS) - 1;
sys$deltva(&retadr,&retadr2,0);
#else
#ifdef HAVE_DEV_ZERO
munmap((caddr_t)mMemoryBase, mPageCount << NS_PAGEMGR_PAGE_BITS);
close(mZero_fd);
#else /* HAVE_DEV_ZERO */
#ifdef HAVE_VALLOC
free(mMemoryBase);
#endif /* HAVE_VALLOC */
#endif /* HAVE_DEV_ZERO */
#endif
}
/*******************************************************************************
* Page Manager
******************************************************************************/
nsPageMgr::nsPageMgr()
: mUnusedClusterDescs(nsnull),
mFreeClusters(nsnull),
mInUseClusters(nsnull),
mMonitor(nsnull),
mMemoryBase(nsnull),
mBoundary(nsnull),
#ifdef XP_PC
mLastPageFreed(nsnull),
mLastPageFreedSize(0),
mLastPageTemp(nsnull),
mLastPageTempSize(0),
#ifdef NS_PAGEMGR_DEBUG
mLastPageAllocTries(0),
mLastPageAllocHits(0),
mLastPageFreeTries(0),
mLastPageFreeHits(0),
#endif
#endif
#if defined(XP_MAC)
mSegMap(nsnull),
mSegTable(nsnull),
mSegTableCount(0),
#endif
#if defined(XP_BEOS)
mAid(B_ERROR),
#endif
mPageCount(0)
{
NS_INIT_REFCNT();
}
nsresult
nsPageMgr::Init(nsPageCount minPages, nsPageCount maxPages)
{
PRStatus status;
mMonitor = nsAutoMonitor::NewMonitor("PageMgr");
if (mMonitor == NULL)
return PR_FAILURE;
status = InitPages(minPages, maxPages);
if (status != PR_SUCCESS)
return status;
/* make sure these got set */
PR_ASSERT(mMemoryBase);
PR_ASSERT(mBoundary);
mFreeClusters = NULL;
mInUseClusters = NULL;
return status == PR_SUCCESS ? NS_OK : NS_ERROR_FAILURE;
}
nsPageMgr::~nsPageMgr()
{
#if defined(XP_PC) && defined(NS_PAGEMGR_DEBUG)
if (stderr) {
fprintf(stderr, "Page Manager Cache: alloc hits: %u/%u %u%%, free hits: %u/%u %u%%\n",
mLastPageAllocHits, mLastPageAllocTries,
(mLastPageAllocHits * 100 / mLastPageAllocTries),
mLastPageFreeHits, mLastPageFreeTries,
(mLastPageFreeHits * 100 / mLastPageFreeTries));
}
#endif
FinalizePages();
nsClusterDesc* chain = mUnusedClusterDescs;
while (chain) {
nsClusterDesc* desc = chain;
chain = chain->mNext;
PR_Free(desc);
}
}
NS_METHOD
nsPageMgr::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsPageMgr* pageMgr = new nsPageMgr();
if (pageMgr == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(pageMgr);
nsresult rv = pageMgr->Init();
if (NS_FAILED(rv)) {
NS_RELEASE(pageMgr);
return rv;
}
rv = pageMgr->QueryInterface(aIID, aResult);
NS_RELEASE(pageMgr);
return NS_OK;
}
NS_IMPL_ISUPPORTS2(nsPageMgr, nsIPageManager, nsIAllocator)
/******************************************************************************/
#ifdef XP_PC
#ifdef NS_PAGEMGR_PAGE_HYSTERESIS
#ifdef NS_PAGEMGR_DEBUG
void*
nsPageMgr::NS_PAGEMGR_COMMIT_CLUSTER(void* addr, PRUword size)
{
mLastPageAllocTries++;
if (mLastPageFreed == (void*)(addr) && mLastPageFreedSize == (size)) {
#ifdef NS_PAGEMGR_COMMIT_TRACE
char buf[64];
PR_snprintf(buf, sizeof(buf), "lalloc %p %u\n",
mLastPageFreed, mLastPageFreedSize);
OutputDebugString(buf);
#endif
DBG_MEMSET(mLastPageFreed, NS_PAGEMGR_PAGE_ALLOC_PATTERN, mLastPageFreedSize);
mLastPageTemp = mLastPageFreed;
mLastPageFreed = NULL;
mLastPageFreedSize = 0;
mLastPageAllocHits++;
return mLastPageTemp;
}
else {
/* If the cached pages intersect the current request, we lose.
Just free the cached request instead of trying to split it up. */
if (mLastPageFreed &&
nsOverlapping((char*)mLastPageFreed, ((char*)mLastPageFreed + mLastPageFreedSize),
(char*)(addr), ((char*)(addr) + (size)))
// ((char*)mLastPageFreed < ((char*)(addr) + (size))
// && ((char*)mLastPageFreed + mLastPageFreedSize) > (char*)(addr))
) {
#ifdef NS_PAGEMGR_COMMIT_TRACE
char buf[64];
PR_snprintf(buf, sizeof(buf), "valloc %p %u (vfree %p %u last=%u:%u req=%u:%u)\n",
addr, size,
mLastPageFreed, mLastPageFreedSize,
(char*)mLastPageFreed, ((char*)mLastPageFreed + mLastPageFreedSize),
(char*)(addr), ((char*)(addr) + (size)));
OutputDebugString(buf);
#endif
VirtualFree(mLastPageFreed, mLastPageFreedSize, MEM_DECOMMIT);
mLastPageFreed = NULL;
mLastPageFreedSize = 0;
mLastPageFreeHits--; /* lost after all */
}
else {
#ifdef NS_PAGEMGR_COMMIT_TRACE
char buf[64];
PR_snprintf(buf, sizeof(buf), "valloc %p %u (skipping %p %u)\n",
addr, size,
mLastPageFreed, mLastPageFreedSize);
OutputDebugString(buf);
#endif
}
return VirtualAlloc((void*)(addr), (size), MEM_COMMIT, PAGE_READWRITE);
}
}
int
nsPageMgr::NS_PAGEMGR_DECOMMIT_CLUSTER(void* addr, PRUword size)
{
mLastPageFreeTries++;
PR_ASSERT(mLastPageFreed != (void*)(addr));
if (mLastPageFreed) {
/* If we've already got a cached page, just keep it. Heuristically,
this tends to give us a higher hit rate because of the order in
which pages are decommitted. */
#ifdef NS_PAGEMGR_COMMIT_TRACE
char buf[64];
PR_snprintf(buf, sizeof(buf), "vfree %p %u (cached %p %u)\n",
addr, size, mLastPageFreed, mLastPageFreedSize);
OutputDebugString(buf);
#endif
return VirtualFree(addr, size, MEM_DECOMMIT);
}
mLastPageFreed = (void*)(addr);
mLastPageFreedSize = (size);
DBG_MEMSET(mLastPageFreed, NS_PAGEMGR_PAGE_FREE_PATTERN, mLastPageFreedSize);
#ifdef NS_PAGEMGR_COMMIT_TRACE
{
char buf[64];
PR_snprintf(buf, sizeof(buf), "lfree %p %u\n",
mLastPageFreed, mLastPageFreedSize);
OutputDebugString(buf);
}
#endif
mLastPageFreeHits++;
return 1;
}
#else /* !NS_PAGEMGR_DEBUG */
#define NS_PAGEMGR_COMMIT_CLUSTER(addr, size) \
(PR_ASSERT((void*)(addr) != NULL), \
((mLastPageFreed == (void*)(addr) && mLastPageFreedSize == (size)) \
? (DBG_MEMSET(mLastPageFreed, NS_PAGEMGR_PAGE_ALLOC_PATTERN, mLastPageFreedSize), \
mLastPageTemp = mLastPageFreed, \
mLastPageFreed = NULL, \
mLastPageFreedSize = 0, \
mLastPageTemp) \
: (((mLastPageFreed && \
((char*)mLastPageFreed < ((char*)(addr) + (size)) \
&& ((char*)mLastPageFreed + mLastPageFreedSize) > (char*)(addr))) \
? (VirtualFree(mLastPageFreed, mLastPageFreedSize, MEM_DECOMMIT), \
mLastPageFreed = NULL, \
mLastPageFreedSize = 0) \
: ((void)0)), \
VirtualAlloc((void*)(addr), (size), MEM_COMMIT, PAGE_READWRITE)))) \
#define NS_PAGEMGR_DECOMMIT_CLUSTER(addr, size) \
(PR_ASSERT(mLastPageFreed != (void*)(addr)), \
(mLastPageFreed \
? (VirtualFree(addr, size, MEM_DECOMMIT)) \
: (mLastPageFreed = (addr), \
mLastPageFreedSize = (size), \
DBG_MEMSET(mLastPageFreed, NS_PAGEMGR_PAGE_FREE_PATTERN, mLastPageFreedSize), \
1))) \
#endif /* !NS_PAGEMGR_DEBUG */
#else /* !NS_PAGEMGR_PAGE_HYSTERESIS */
#define NS_PAGEMGR_COMMIT_CLUSTER(addr, size) \
VirtualAlloc((void*)(addr), (size), MEM_COMMIT, PAGE_READWRITE)
#define NS_PAGEMGR_DECOMMIT_CLUSTER(addr, size) \
VirtualFree((void*)(addr), (size), MEM_DECOMMIT)
#endif /* !NS_PAGEMGR_PAGE_HYSTERESIS */
#else /* !XP_PC */
#define NS_PAGEMGR_COMMIT_CLUSTER(addr, size) (addr)
#define NS_PAGEMGR_DECOMMIT_CLUSTER(addr, size) 1
#endif /* !XP_PC */
nsPage*
nsPageMgr::NewCluster(nsPageCount nPages)
{
nsAutoMonitor mon(mMonitor);
nsPage* addr;
PR_ASSERT(nPages > 0);
addr = AllocClusterFromFreeList(nPages);
if (!addr && mBoundary + nPages <= mMemoryBase + mPageCount) {
addr = mBoundary;
mBoundary += nPages;
}
if (addr) {
/* Extend the mapping */
nsPage* vaddr;
PRUword size = nPages << NS_PAGEMGR_PAGE_BITS;
PR_ASSERT(NS_PAGEMGR_IS_ALIGNED(addr, NS_PAGEMGR_PAGE_BITS));
vaddr = (nsPage*)NS_PAGEMGR_COMMIT_CLUSTER((void*)addr, size);
#ifdef NS_PAGEMGR_VERIFYCLUSTERS
VerifyClusters(nPages);
#endif
if (addr) {
PR_ASSERT(vaddr == addr);
}
else {
DestroyCluster(addr, nPages);
}
DBG_MEMSET(addr, NS_PAGEMGR_PAGE_ALLOC_PATTERN, size);
}
return (nsPage*)addr;
}
void
nsPageMgr::DestroyCluster(nsPage* basePage, nsPageCount nPages)
{
nsAutoMonitor mon(mMonitor);
int freeResult;
PRUword size = nPages << NS_PAGEMGR_PAGE_BITS;
PR_ASSERT(nPages > 0);
PR_ASSERT(NS_PAGEMGR_IS_ALIGNED(basePage, NS_PAGEMGR_PAGE_BITS));
PR_ASSERT(mMemoryBase <= basePage);
PR_ASSERT(basePage + nPages <= mMemoryBase + mPageCount);
DBG_MEMSET(basePage, NS_PAGEMGR_PAGE_FREE_PATTERN, size);
freeResult = NS_PAGEMGR_DECOMMIT_CLUSTER((void*)basePage, size);
PR_ASSERT(freeResult);
if (basePage + nPages == mBoundary) {
nsClusterDesc **p;
nsClusterDesc *desc;
/* We deallocated the last set of clusters. Move the mBoundary lower. */
mBoundary = basePage;
/* The last free cluster might now be adjacent to the mBoundary; if so,
move the mBoundary before that cluster and delete that cluster
altogether. */
p = &mFreeClusters;
while ((desc = *p) != NULL) {
if (!desc->mNext && desc->mAddr + desc->mPageCount == mBoundary) {
*p = 0;
mBoundary = desc->mAddr;
DeleteFreeClusterDesc(desc);
}
else {
p = &desc->mNext;
}
}
}
else {
AddClusterToFreeList(basePage, nPages);
}
#ifdef NS_PAGEMGR_VERIFYCLUSTERS
VerifyClusters(-(PRWord)nPages);
#endif
}
////////////////////////////////////////////////////////////////////////////////
// nsIPageManager methods:
NS_IMETHODIMP
nsPageMgr::AllocPages(PRUint32 pageCount, void* *result)
{
nsPage* page = NewCluster(NS_STATIC_CAST(nsPageCount, pageCount));
if (page == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
*result = page;
return NS_OK;
}
NS_IMETHODIMP
nsPageMgr::DeallocPages(PRUint32 pageCount, void* pages)
{
DestroyCluster(NS_STATIC_CAST(nsPage*, pages),
NS_STATIC_CAST(nsPageCount, pageCount));
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsIAllocator methods:
//
// Note: nsIAllocator needs to keep track of the size of the blocks it allocates
// whereas, nsIPageManager doesn't. That means that there's a little extra
// overhead for users of this interface. It also means that things allocated
// with the nsIPageManager interface can't be freed with the nsIAllocator
// interface and vice versa.
NS_IMETHODIMP_(void*)
nsPageMgr::Alloc(PRUint32 size)
{
nsAutoMonitor mon(mMonitor);
nsresult rv;
void* page = nsnull;
PRUint32 pageCount = NS_PAGEMGR_PAGE_COUNT(size);
rv = AllocPages(pageCount, &page);
if (NS_FAILED(rv))
return nsnull;
// Add this cluster to the mInUseClusters list:
nsClusterDesc* desc = NewFreeClusterDesc();
if (desc == nsnull) {
rv = DeallocPages(pageCount, page);
NS_ASSERTION(NS_SUCCEEDED(rv), "DeallocPages failed");
return nsnull;
}
desc->mAddr = (nsPage*)page;
desc->mPageCount = pageCount;
desc->mNext = mInUseClusters;
mInUseClusters = desc;
return page;
}
NS_IMETHODIMP_(void*)
nsPageMgr::Realloc(void* ptr, PRUint32 size)
{
// XXX This realloc implementation could be made smarter by trying to
// append to the current block, but I don't think we really care right now.
nsresult rv;
rv = Free(ptr);
if (NS_FAILED(rv)) return nsnull;
void* newPtr = Alloc(size);
return newPtr;
}
NS_IMETHODIMP
nsPageMgr::Free(void* ptr)
{
nsAutoMonitor mon(mMonitor);
PR_ASSERT(NS_PAGEMGR_IS_ALIGNED(ptr, NS_PAGEMGR_PAGE_BITS));
// Remove the cluster from the mInUseClusters list:
nsClusterDesc** list = &mInUseClusters;
nsClusterDesc* desc;
while ((desc = *list) != nsnull) {
if (desc->mAddr == ptr) {
// found -- unlink the desc and free it
*list = desc->mNext;
nsresult rv = DeallocPages(desc->mPageCount, ptr);
DeleteFreeClusterDesc(desc);
return rv;
}
list = &desc->mNext;
}
NS_ASSERTION(0, "memory not allocated with nsPageMgr::Alloc");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsPageMgr::HeapMinimize(void)
{
// can't compact this heap
return NS_ERROR_FAILURE;
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,203 +0,0 @@
/* -*- 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.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 nsPageMgr_h__
#define nsPageMgr_h__
#include "nsIPageManager.h"
#include "nsIAllocator.h"
#include "nscore.h"
#include "nsAutoLock.h"
#include "prlog.h"
#ifdef XP_MAC
#include <Types.h>
#include <Memory.h>
#endif
#if defined(XP_BEOS)
#include <OS.h>
#endif
/*******************************************************************************
* Configuration/Debugging parameters:
******************************************************************************/
#ifdef NS_DEBUG
//#define NS_PAGEMGR_DEBUG
#endif
#define NS_PAGEMGR_PAGE_HYSTERESIS /* undef if you want to compare */
//#define NS_PAGEMGR_COMMIT_TRACE
#ifdef NS_PAGEMGR_DEBUG
#define NS_PAGEMGR_VERIFYCLUSTERS
#define NS_PAGEMGR_DBG_MEMSET
#endif
#define NS_PAGEMGR_MIN_PAGES 32 // XXX bogus -- this should be a runtime parameter
#define NS_PAGEMGR_MAX_PAGES 2560 // 10 meg XXX bogus -- this should be a runtime parameter
/******************************************************************************/
#ifdef NS_PAGEMGR_DBG_MEMSET
#include <string.h> /* for memset */
#include <stdio.h>
#define DBG_MEMSET(dest, pattern, size) memset(dest, pattern, size)
#define NS_PAGEMGR_PAGE_ALLOC_PATTERN 0xCB
#define NS_PAGEMGR_PAGE_FREE_PATTERN 0xCD
#else
#define DBG_MEMSET(dest, pattern, size) ((void)0)
#endif
#define NS_PAGEMGR_ALIGN(p, nBits) ((PRWord)(p) & ~((1 << nBits) - 1))
#define NS_PAGEMGR_IS_ALIGNED(p, nBits) ((PRWord)(p) == NS_PAGEMGR_ALIGN(p, nBits))
/*******************************************************************************
* Test for overlapping (one-dimensional) regions
******************************************************************************/
inline PRBool nsOverlapping(char* min1, char* max1, char* min2, char* max2)
{
PR_ASSERT(min1 < max1);
PR_ASSERT(min2 < max2);
return (min1 < max2 && max1 > min2);
}
/*******************************************************************************
* Types
******************************************************************************/
typedef PRUint8 nsPage[NS_PAGEMGR_PAGE_SIZE];
typedef PRUword nsPageCount; /* int big enough to count pages */
/*******************************************************************************
* Macros
******************************************************************************/
#define NS_PAGEMGR_PAGE_ROUNDDN(addr) ((nsPage*)NS_PAGEMGR_ALIGN((PRUword)(addr), NS_PAGEMGR_PAGE_BITS))
#define NS_PAGEMGR_PAGE_ROUNDUP(addr) NS_PAGEMGR_PAGE_ROUNDDN((PRUword)(addr) + NS_PAGEMGR_PAGE_SIZE)
/*******************************************************************************
* Page Manager
******************************************************************************/
class nsPageMgr : public nsIPageManager, public nsIAllocator {
public:
NS_DECL_ISUPPORTS
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
// nsIPageManager methods:
NS_IMETHOD AllocPages(PRUint32 pageCount, void* *result);
NS_IMETHOD DeallocPages(PRUint32 pageCount, void* pages);
// nsIAllocator methods:
NS_IMETHOD_(void*) Alloc(PRUint32 size);
NS_IMETHOD_(void*) Realloc(void* ptr, PRUint32 size);
NS_IMETHOD Free(void* ptr);
NS_IMETHOD HeapMinimize(void);
// nsPageMgr methods:
nsPageMgr();
virtual ~nsPageMgr();
nsresult Init(nsPageCount minPages = NS_PAGEMGR_MIN_PAGES,
nsPageCount maxPages = NS_PAGEMGR_MAX_PAGES);
struct nsClusterDesc {
nsClusterDesc* mNext; /* Link to next cluster of free pages */
nsPage* mAddr; /* First page in cluster of free pages */
nsPageCount mPageCount; /* Total size of cluster of free pages in bytes */
};
void DeleteFreeClusterDesc(nsClusterDesc *desc);
nsClusterDesc* NewFreeClusterDesc(void);
nsPage* AllocClusterFromFreeList(PRUword nPages);
void AddClusterToFreeList(nsPage* addr, PRWord nPages);
#ifdef NS_PAGEMGR_VERIFYCLUSTERS
void VerifyClusters(PRWord nPagesDelta);
#endif
#if defined(XP_PC) && defined(NS_PAGEMGR_DEBUG)
void* NS_PAGEMGR_COMMIT_CLUSTER(void* addr, PRUword size);
int NS_PAGEMGR_DECOMMIT_CLUSTER(void* addr, PRUword size);
#endif
// Managing Pages:
PRStatus InitPages(nsPageCount minPages, nsPageCount maxPages);
void FinalizePages();
nsPage* NewCluster(nsPageCount nPages);
void DestroyCluster(nsPage* basePage, nsPageCount nPages);
protected:
nsClusterDesc* mUnusedClusterDescs;
nsClusterDesc* mFreeClusters;
nsClusterDesc* mInUseClusters; // used by nsIAllocator methods
PRMonitor* mMonitor;
nsPage* mMemoryBase;
nsPage* mBoundary;
nsPageCount mPageCount;
#ifdef XP_PC
/* one-page hysteresis */
void* mLastPageFreed;
PRUword mLastPageFreedSize;
void* mLastPageTemp;
PRUword mLastPageTempSize;
# ifdef NS_PAGEMGR_DEBUG
PRUword mLastPageAllocTries;
PRUword mLastPageAllocHits;
PRUword mLastPageFreeTries;
PRUword mLastPageFreeHits;
# endif
#endif
#if defined(XP_MAC)
struct nsSegmentDesc {
Handle mHandle;
nsPage* mFirstPage;
nsPage* mLastPage;
};
PRUint8* mSegMap;
nsSegmentDesc* mSegTable;
PRWord mSegTableCount;
#endif
#if defined(XP_BEOS)
area_id mAid;
#endif
#if (! defined(VMS)) && (! defined(XP_BEOS)) && (! defined(XP_MAC)) && (! defined(XP_PC))
int mZero_fd;
#endif
};
/******************************************************************************/
#endif /* nsPageMgr_h__ */

Some files were not shown because too many files have changed in this diff Show More