Compare commits

..

87 Commits

Author SHA1 Message Date
law%netscape.com
e23f4f251e Eliminate compiler warnings, from Henry Sobotka
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@6104 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-21 21:04:06 +00:00
law%netscape.com
b4f130677f Henry Sobotka's BE patches
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@6009 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-20 22:12:23 +00:00
law%netscape.com
557c45958d Compiler warning patches from Henry Sobotka
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@6005 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-20 22:09:37 +00:00
law%netscape.com
6ade794096 Compiler warning patches from Henry Sobotka
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5976 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-20 20:23:08 +00:00
law%netscape.com
39c58ede15 Fix nested comments, from Henry Sobotka
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5975 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-20 20:15:44 +00:00
law%netscape.com
280f007aa5 Patch for os2fe, from Henry Sobotka
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5974 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-20 19:50:58 +00:00
law%netscape.com
71643d20cc Compiler warning patches from Henry Sobotka
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5972 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-20 19:48:49 +00:00
law%netscape.com
c2cdb88304 Cleanup warnings; from Henry Sobotka
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5834 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-17 19:34:00 +00:00
law
87836fd2d7 EINPROGRESS handling, from John Fairhurst
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5427 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-13 22:16:46 +00:00
law
32fcb7b87c OS/2 support patch from John Fairhurst
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5426 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-13 22:15:54 +00:00
law
8c69310e99 Added -DXP_OS2 for EMX builds
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5425 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-13 22:15:15 +00:00
law
d7e5ed095d Avoid building allxpstr and xp_intl (for now)
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5424 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-13 22:14:33 +00:00
law
32c53e8898 Added back in xp directory
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5423 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-13 22:13:57 +00:00
law
4a0d86f7eb Last minute patches from Henry Sobotka
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5422 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-13 22:13:05 +00:00
law
4bba3cb140 Henry Sobotka's BE patches
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5244 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-09 18:22:15 +00:00
law
de0cfb1612 Tweaked various compiler flags
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5243 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-09 18:18:39 +00:00
law
86b020583c Added #includes for req'd std C headers and tweaked sprintf call to make arg match format string
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5242 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-09 18:18:05 +00:00
law
41959aa2a9 Added missing return type
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5241 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-09 18:17:06 +00:00
law
165069c935 Added compile options to avoid some nag warnings
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5240 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-09 18:16:26 +00:00
law
ca3f21c475 Henry Sobotka's BE patches
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5124 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-08 00:52:15 +00:00
law
fe41596b2d Fixed test for OS/2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5123 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-08 00:46:51 +00:00
law
0aa05bea7f Omit xp subdirectory for OS/2 (for now)
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5122 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-08 00:41:46 +00:00
law
620bb5d6ce Tweaked display_os2_config actions
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5121 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-08 00:38:52 +00:00
law
dc0fc981ac Removed -I. from compile flags
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@5120 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-08 00:37:54 +00:00
law
8ce7edf832 Henry Sobotka's BE patches
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4963 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-02 23:54:58 +00:00
law
3b94cdb7d1 Henry Sobotka's BE patches
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4927 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-02 21:59:58 +00:00
law
4ef08c11c6 Henry Sobotka's BE patches
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4911 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-02 19:10:23 +00:00
law
16483d24aa Henry Sobotka's BE patches + new rule to display OS/2 build configuration info
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4910 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-02 19:04:42 +00:00
law
cd858437e8 Fix RGB_* redefined problem
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4199 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 02:26:15 +00:00
law
53fb715730 Fixed test for OS2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4194 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 01:01:25 +00:00
law
f98e46a66f Tweak use of MIN/min for EMX
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4193 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 00:50:49 +00:00
law
1f092f0743 Tweak to support EMX
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4192 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 00:49:41 +00:00
law
76f2501835 #include sys/param.h for OS2+EMX, also
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4191 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 00:48:40 +00:00
law
7d516a94ae Use os2file.h for both EMX and VACPP
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4190 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 00:47:55 +00:00
law
88550bfcf9 Force -I../include ahead of other INCLUDES
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4187 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 00:41:59 +00:00
law
934e3cf7b2 Add #includes for OS/2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4185 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 00:31:34 +00:00
law
32dc3ee503 Don't define MAXPATHLEN for OS/2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4184 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 00:29:06 +00:00
law
e40f9d7cca Redefine MAKE_OBJDIR for OS/2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4182 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 00:21:24 +00:00
law
4c43b4600a Add setting for WHOAMI
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4181 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 00:20:32 +00:00
law
a6e7434694 Remove LOCAL_INCLUDES setting for OS/2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4180 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 00:19:47 +00:00
law
75863ed4c3 Omit l10n for OS/2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@4179 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-20 00:17:23 +00:00
danda
24b5249f89 added typedef for FARPROC
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@1285 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-08 02:39:47 +00:00
danda
6de9d7a616 a piece of whitespace was breaking OS/2 gmake
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@1284 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-08 02:37:40 +00:00
danda
d8682592bc Fixed a piece of broken OS/2 code ( missing '}' )
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@1283 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-08 02:36:59 +00:00
danda
62cf9213c5 changed an ifdef to XP_OS2_VACPP
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@1282 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-08 02:34:54 +00:00
danda
c9ed81237a changed XP_OS2 to XP_OS2_EMX
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@1281 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-08 02:33:28 +00:00
danda
63076ae4ee removed some unnecessary OS/2 stuff
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@1280 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-08 02:32:04 +00:00
danda
24bb835e50 removed flipper dependency from VACPP build, and some other misc stuff
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@1279 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-08 02:31:31 +00:00
danda
c0aaa20718 changes submitted by John Fairhurst (mjf35@cam.ac.uk)
- now using _tzset() for VACPP
- no longer calling _endthread() with EMX
CVS:
CVS:


git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@1153 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-05 20:48:41 +00:00
danda
98ffa78946 Fix for MT_safe_localtime() using the OS/2 EMX compiler.
Submitted by John Fairhurst.
CVS:
CVS:


git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@1152 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-05 20:44:48 +00:00
danda
8ec2e3ed34 fixing security library dependency for proper build order on OS/2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@1076 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-03 04:40:11 +00:00
danda
097c6ba029 fixed a build break that occurs when building .a format libraries using EMX on OS/2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@1071 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-02 05:02:23 +00:00
(no author)
704230a89c This commit was manufactured by cvs2svn to create branch 'OS2_BRANCH'.
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@764 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-28 09:09:58 +00:00
danda
9bce33af92 fixing build errors for XP_OS2_EMX
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@707 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-27 20:28:08 +00:00
danda
0e568bdced Fixing for free mozilla on OS/2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@706 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-27 20:27:18 +00:00
danda
1fdff26ccb Fixing LINK_EXE variable, removed OBJS
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@406 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-20 03:36:00 +00:00
danda
f0dee433fc Fixing OS/2 build breaks
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@405 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-20 03:16:37 +00:00
danda
f40317090a Tidying up OS/2 build process
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@404 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-20 03:16:03 +00:00
danda
cc4eec61d3 Fixing OS/2 build breaks. I changed all instances of FALSE to PR_FALSE
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@403 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-20 03:15:15 +00:00
danda
41c8e70043 Removed libcnv from OS/2 build path since other platforms don't seem to be using it
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@402 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-20 03:09:59 +00:00
danda
a8192fd569 Added defines for emacs and rm (necessary for ns/l10/us/xp), and for CCC (needed for .cpp sources)
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@401 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-20 03:05:20 +00:00
danda
6c241731ec added include/md to the include path and added plc21.lib to the list of NSPR libraries.
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@400 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-20 03:04:25 +00:00
danda
ab69f51533 Removed xfe from OS/2 build path for now
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@399 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-20 03:03:33 +00:00
danda
bf82105e8a Removed redefinition of TID to OS2TID. Originally this was done because of a conflict with a TID strcture in sun-java/include/javaThreads.h. However, that has been removed for public Mozilla and the TID rename was causing problems with the EMX compiler on OS/2.
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@398 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-20 01:54:49 +00:00
danda
f582554330 Adding a couple lines to make this compile on OS/2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@396 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 23:48:08 +00:00
danda
72f7442cb9 Added an !XP_OS2 so that we don't try and build this file on OS/2. A cleaner solution would be to get rid of the !WIN32 and !OS2, and simply use a XP_WIN16, but I don't want to break anything...
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@395 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 23:47:30 +00:00
danda
679ee4e24c fixing 2 build breaks
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@387 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 08:43:47 +00:00
danda
2c4fa86980 Made changes to allow choice of either a.out format or omf, for object files
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@386 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 08:34:44 +00:00
danda
c68c4fdd45 Initial bunch of changes to get both EMX and VACPP OS/2 compilers working. New features include: creating DEF files on the fly, generation of static AND import libs, and compiler name inserted into object directory
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@385 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 08:32:55 +00:00
danda
e02a00ccb7 changed XP_OS2 to XP_OS2_VACPP
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@384 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 08:30:07 +00:00
danda
1a5c1e5a1f changed XP_OS2_HACK to XP_OS2
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@383 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 08:29:48 +00:00
danda
a1fff1081f Some OS/2 fixes. Mostly simplifying
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@382 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 08:28:59 +00:00
danda
5a328a6bf9 Added -DOS2 to EMX defines list
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@380 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 03:42:06 +00:00
danda
1b82fe3f40 Adding compiler name to output directory
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@379 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 03:26:44 +00:00
danda
ab7269eb6e Fixing build breaks on OS/2 GNU compiler
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@378 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 03:23:30 +00:00
danda
01b70ea3fd Fixed build break on OS/2 EMX compiler. sys/time needs to be included
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@377 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 03:22:59 +00:00
danda
ea222b1754 Removed unnecessary repetition
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@376 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 03:22:16 +00:00
danda
89528b63fd cleanup spacing and add compiler name to output directory
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@375 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-19 03:21:07 +00:00
law
15e2581318 Warpzilla April09 patches
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@139 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-09 20:33:23 +00:00
law
f719e4a426 April 08 patches
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@135 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-09 17:53:31 +00:00
law
ec5ef5b969 Remove ramsem.o and sem_x86.o
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@93 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-08 04:37:12 +00:00
law
83b9febfcd Add _MD_EXIT
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@92 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-08 04:36:12 +00:00
law
686490c150 Fix MAKE_OBJDIR and use ar under emx
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@91 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-08 04:35:18 +00:00
law
b518852906 Warpzilla patches
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@78 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-08 01:53:17 +00:00
law
c6ae1a5bee Warpzilla patches
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@76 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-08 01:39:25 +00:00
law
b67c87805b Warpzilla patches
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@63 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-07 21:26:52 +00:00
(no author)
05ceb49b94 This commit was manufactured by cvs2svn to create branch 'OS2_BRANCH'.
git-svn-id: svn://10.0.0.236/branches/OS2_BRANCH@55 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-07 00:00:42 +00:00
5468 changed files with 1818006 additions and 9027 deletions

37
mozilla/LEGAL Normal file
View File

@@ -0,0 +1,37 @@
Please be apprised of the following Legal Notices:
A) Wang contends that its U.S. Patent No. 4, 751,669 ("the '669
Patent") disclosing a "video text" system, is infringed by the following
functionality in the Netscape Navigator code: 1) the animated logo and
status line indicators --See Claims 1,8 and 9; 2) the "File Save As"
function --See Claims 23-27; 3) Bookmarks and Rename Bookmarks in the
Properties window --See Claims 20-22; 4) storing HTML, GIF, and JPEG
files and adding filename extensions based on mime types (performed in
Windows OS) --See Claim 38. Netscape believes the '669 Patent is
invalid and non-infringed. Netscape is vigorously defending against
Wang's claims.
B) Intermind owns pending U.S. patent applications on communications
systems which employ metadata ("channel objects") to define a control
structure for information transfer. The Netscape code does not infringe
as released; however, modifications which utilize channel objects as
described by Intermind should be considered carefully. The following is
a statement from Intermind: "Intermind's claims fundamentally involve
the use of a control structure to automate communications. ...The
essence of Intermind's top claim is that two devices sender and
receiver have persistent storage, communicate over a network,
and exchange a control structure including metadata which describes: 1)
what information is to be updated, 2) when to update this information,
and 3) how to transfer the updated information. In addition, at least
the receiving device must be able to process the metadata in order to
perform the update determination and transfer. Any digital
communications system which incorporates all of these elements will be
covered by Intermind's patents." See Intermind.com.
C) Stac, Inc., and its licensing agent Hi/fn, own several patents which
disclose data compression methods implementing an LZS compression
algorithm, including U.S. Patent Nos. 4,701,745 and 5,016, 009 ("the
Stac Patents"). The Netscape Communicator code does not perform
compression. If you modify the Netscape source code to perform
compression, please take notice of the Stac Patents.

421
mozilla/LICENSE Normal file
View File

@@ -0,0 +1,421 @@
NETSCAPE PUBLIC LICENSE
Version 1.0
----------------
1. Definitions.
1.1. ``Contributor'' means each entity that creates or contributes to
the creation of Modifications.
1.2. ``Contributor Version'' means the combination of the Original
Code, prior Modifications used by a Contributor, and the Modifications
made by that particular Contributor.
1.3. ``Covered Code'' means the Original Code or Modifications or the
combination of the Original Code and Modifications, in each case
including portions thereof.
1.4. ``Electronic Distribution Mechanism'' means a mechanism generally
accepted in the software development community for the electronic
transfer of data.
1.5. ``Executable'' means Covered Code in any form other than Source
Code.
1.6. ``Initial Developer'' means the individual or entity identified as
the Initial Developer in the Source Code notice required by Exhibit A.
1.7. ``Larger Work'' means a work which combines Covered Code or
portions thereof with code not governed by the terms of this License.
1.8. ``License'' means this document.
1.9. ``Modifications'' means any addition to or deletion from the
substance or structure of either the Original Code or any previous
Modifications. When Covered Code is released as a series of files, a
Modification is:
A. Any addition to or deletion from the contents of a file
containing Original Code or previous Modifications.
B. Any new file that contains any part of the Original Code or
previous Modifications.
1.10. ``Original Code'' means Source Code of computer software code
which is described in the Source Code notice required by Exhibit A as
Original Code, and which, at the time of its release under this License
is not already Covered Code governed by this License.
1.11. ``Source Code'' means the preferred form of the Covered Code for
making modifications to it, including all modules it contains, plus any
associated interface definition files, scripts used to control
compilation and installation of an Executable, or a list of source code
differential comparisons against either the Original Code or another
well known, available Covered Code of the Contributor's choice. The
Source Code can be in a compressed or archival form, provided the
appropriate decompression or de-archiving software is widely available
for no charge.
1.12. ``You'' means an individual or a legal entity exercising rights
under, and complying with all of the terms of, this License or a future
version of this License issued under Section 6.1. For legal entities,
``You'' includes any entity which controls, is controlled by, or is
under common control with You. For purposes of this definition,
``control'' means (a) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (b) ownership of fifty percent (50%) or more of the
outstanding shares or beneficial ownership of such entity.
2. Source Code License.
2.1. The Initial Developer Grant.
The Initial Developer hereby grants You a world-wide, royalty-free,
non-exclusive license, subject to third party intellectual property
claims:
(a) to use, reproduce, modify, display, perform, sublicense and
distribute the Original Code (or portions thereof) with or without
Modifications, or as part of a Larger Work; and
(b) under patents now or hereafter owned or controlled by Initial
Developer, to make, have made, use and sell (``Utilize'') the
Original Code (or portions thereof), but solely to the extent that
any such patent is reasonably necessary to enable You to Utilize
the Original Code (or portions thereof) and not to any greater
extent that may be necessary to Utilize further Modifications or
combinations.
2.2. Contributor Grant.
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license, subject to third party intellectual property
claims:
(a) to use, reproduce, modify, display, perform, sublicense and
distribute the Modifications created by such Contributor (or
portions thereof) either on an unmodified basis, with other
Modifications, as Covered Code or as part of a Larger Work; and
(b) under patents now or hereafter owned or controlled by
Contributor, to Utilize the Contributor Version (or portions
thereof), but solely to the extent that any such patent is
reasonably necessary to enable You to Utilize the Contributor
Version (or portions thereof), and not to any greater extent that
may be necessary to Utilize further Modifications or combinations.
3. Distribution Obligations.
3.1. Application of License.
The Modifications which You create or to which You contribute are
governed by the terms of this License, including without limitation
Section 2.2. The Source Code version of Covered Code may be distributed
only under the terms of this License or a future version of this
License released under Section 6.1, and You must include a copy of this
License with every copy of the Source Code You distribute. You may not
offer or impose any terms on any Source Code version that alters or
restricts the applicable version of this License or the recipients'
rights hereunder. However, You may include an additional document
offering the additional rights described in Section 3.5.
3.2. Availability of Source Code.
Any Modification which You create or to which You contribute must be
made available in Source Code form under the terms of this License
either on the same media as an Executable version or via an accepted
Electronic Distribution Mechanism to anyone to whom you made an
Executable version available; and if made available via Electronic
Distribution Mechanism, must remain available for at least twelve (12)
months after the date it initially became available, or at least six
(6) months after a subsequent version of that particular Modification
has been made available to such recipients. You are responsible for
ensuring that the Source Code version remains available even if the
Electronic Distribution Mechanism is maintained by a third party.
3.3. Description of Modifications.
You must cause all Covered Code to which you contribute to contain a
file documenting the changes You made to create that Covered Code and
the date of any change. You must include a prominent statement that the
Modification is derived, directly or indirectly, from Original Code
provided by the Initial Developer and including the name of the Initial
Developer in (a) the Source Code, and (b) in any notice in an
Executable version or related documentation in which You describe the
origin or ownership of the Covered Code.
3.4. Intellectual Property Matters
(a) Third Party Claims.
If You have knowledge that a party claims an intellectual property
right in particular functionality or code (or its utilization
under this License), you must include a text file with the source
code distribution titled ``LEGAL'' which describes the claim and
the party making the claim in sufficient detail that a recipient
will know whom to contact. If you obtain such knowledge after You
make Your Modification available as described in Section 3.2, You
shall promptly modify the LEGAL file in all copies You make
available thereafter and shall take other steps (such as notifying
appropriate mailing lists or newsgroups) reasonably calculated to
inform those who received the Covered Code that new knowledge has
been obtained.
(b) Contributor APIs.
If Your Modification is an application programming interface and
You own or control patents which are reasonably necessary to
implement that API, you must also include this information in the
LEGAL file.
3.5. Required Notices.
You must duplicate the notice in Exhibit A in each file of the Source
Code, and this License in any documentation for the Source Code, where
You describe recipients' rights relating to Covered Code. If You
created one or more Modification(s), You may add your name as a
Contributor to the notice described in Exhibit A. If it is not possible
to put such notice in a particular Source Code file due to its
structure, then you must include such notice in a location (such as a
relevant directory file) where a user would be likely to look for such
a notice. You may choose to offer, and to charge a fee for, warranty,
support, indemnity or liability obligations to one or more recipients
of Covered Code. However, You may do so only on Your own behalf, and
not on behalf of the Initial Developer or any Contributor. You must
make it absolutely clear than any such warranty, support, indemnity or
liability obligation is offered by You alone, and You hereby agree to
indemnify the Initial Developer and every Contributor for any liability
incurred by the Initial Developer or such Contributor as a result of
warranty, support, indemnity or liability terms You offer.
3.6. Distribution of Executable Versions.
You may distribute Covered Code in Executable form only if the
requirements of Section 3.1-3.5 have been met for that Covered Code,
and if You include a notice stating that the Source Code version of the
Covered Code is available under the terms of this License, including a
description of how and where You have fulfilled the obligations of
Section 3.2. The notice must be conspicuously included in any notice in
an Executable version, related documentation or collateral in which You
describe recipients' rights relating to the Covered Code. You may
distribute the Executable version of Covered Code under a license of
Your choice, which may contain terms different from this License,
provided that You are in compliance with the terms of this License and
that the license for the Executable version does not attempt to limit
or alter the recipient's rights in the Source Code version from the
rights set forth in this License. If You distribute the Executable
version under a different license You must make it absolutely clear
that any terms which differ from this License are offered by You alone,
not by the Initial Developer or any Contributor. You hereby agree to
indemnify the Initial Developer and every Contributor for any liability
incurred by the Initial Developer or such Contributor as a result of
any such terms You offer.
3.7. Larger Works.
You may create a Larger Work by combining Covered Code with other code
not governed by the terms of this License and distribute the Larger
Work as a single product. In such a case, You must make sure the
requirements of this License are fulfilled for the Covered Code.
4. Inability to Comply Due to Statute or Regulation.
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Code due to statute
or regulation then You must: (a) comply with the terms of this License
to the maximum extent possible; and (b) describe the limitations and
the code they affect. Such description must be included in the LEGAL
file described in Section 3.4 and must be included with all
distributions of the Source Code. Except to the extent prohibited by
statute or regulation, such description must be sufficiently detailed
for a recipient of ordinary skill to be able to understand it.
5. Application of this License.
This License applies to code to which the Initial Developer has
attached the notice in Exhibit A, and to related Covered Code.
6. Versions of the License.
6.1. New Versions.
Netscape Communications Corporation (``Netscape'') may publish revised
and/or new versions of the License from time to time. Each version will
be given a distinguishing version number.
6.2. Effect of New Versions.
Once Covered Code has been published under a particular version of the
License, You may always continue to use it under the terms of that
version. You may also choose to use such Covered Code under the terms
of any subsequent version of the License published by Netscape. No one
other than Netscape has the right to modify the terms applicable to
Covered Code created under this License.
6.3. Derivative Works.
If you create or use a modified version of this License (which you may
only do in order to apply it to code which is not already Covered Code
governed by this License), you must (a) rename Your license so that the
phrases ``Mozilla'', ``MOZILLAPL'', ``MOZPL'', ``Netscape'', ``NPL'' or
any confusingly similar phrase do not appear anywhere in your license
and (b) otherwise make it clear that your version of the license
contains terms which differ from the Mozilla Public License and
Netscape Public License. (Filling in the name of the Initial Developer,
Original Code or Contributor in the notice described in Exhibit A shall
not of themselves be deemed to be modifications of this License.)
7. DISCLAIMER OF WARRANTY.
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN ``AS IS'' BASIS,
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
8. TERMINATION.
This License and the rights granted hereunder will terminate
automatically if You fail to comply with terms herein and fail to cure
such breach within 30 days of becoming aware of the breach. All
sublicenses to the Covered Code which are properly granted shall
survive any termination of this License. Provisions which, by their
nature, must remain in effect beyond the termination of this License
shall survive.
9. LIMITATION OF LIABILITY.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE INITIAL
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO YOU OR ANY OTHER
PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF
GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND
ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE
BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT
EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
10. U.S. GOVERNMENT END USERS.
The Covered Code is a ``commercial item,'' as that term is defined in
48 C.F.R. 2.101 (Oct. 1995), consisting of ``commercial computer
software'' and ``commercial computer software documentation,'' as such
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
all U.S. Government End Users acquire Covered Code with only those
rights set forth herein.
11. MISCELLANEOUS.
This License represents the complete agreement concerning subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. This License shall be governed by
California law provisions (except to the extent applicable law, if any,
provides otherwise), excluding its conflict-of-law provisions. With
respect to disputes in which at least one party is a citizen of, or an
entity chartered or registered to do business in, the United States of
America: (a) unless otherwise agreed in writing, all disputes relating
to this License (excepting any dispute relating to intellectual
property rights) shall be subject to final and binding arbitration,
with the losing party paying all costs of arbitration; (b) any
arbitration relating to this Agreement shall be held in Santa Clara
County, California, under the auspices of JAMS/EndDispute; and (c) any
litigation relating to this Agreement shall be subject to the
jurisdiction of the Federal Courts of the Northern District of
California, with venue lying in Santa Clara County, California, with
the losing party responsible for costs, including without limitation,
court costs and reasonable attorneys fees and expenses. The application
of the United Nations Convention on Contracts for the International
Sale of Goods is expressly excluded. Any law or regulation which
provides that the language of a contract shall be construed against the
drafter shall not apply to this License.
12. RESPONSIBILITY FOR CLAIMS.
Except in cases where another Contributor has failed to comply with
Section 3.4, You are responsible for damages arising, directly or
indirectly, out of Your utilization of rights under this License, based
on the number of copies of Covered Code you made available, the
revenues you received from utilizing such rights, and other relevant
factors. You agree to work with affected parties to distribute
responsibility on an equitable basis.
AMENDMENTS
Additional Terms applicable to the Netscape Public License.
I. Effect.
These additional terms described in this Netscape Public License --
Amendments shall apply to the Mozilla Communicator client code and to
all Covered Code under this License.
II. ``Netscape's Branded Code'' means Covered Code that Netscape
distributes and/or permits others to distribute under one or more
trademark(s) which are controlled by Netscape but which are not
licensed for use under this License.
III. Netscape and logo.
This License does not grant any rights to use the trademark
``Netscape'', the ``Netscape N and horizon'' logo or the Netscape
lighthouse logo, even if such marks are included in the Original Code.
IV. Inability to Comply Due to Contractual Obligation.
Prior to licensing the Original Code under this License, Netscape has
licensed third party code for use in Netscape's Branded Code. To the
extent that Netscape is limited contractually from making such third
party code available under this License, Netscape may choose to
reintegrate such code into Covered Code without being required to
distribute such code in Source Code form, even if such code would
otherwise be considered ``Modifications'' under this License.
V. Use of Modifications and Covered Code by Initial Developer.
V.1. In General.
The obligations of Section 3 apply to Netscape, except to the
extent specified in this Amendment, Section V.2 and V.3.
V.2. Other Products.
Netscape may include Covered Code in products other than the
Netscape's Branded Code which are released by Netscape during the
two (2) years following the release date of the Original Code,
without such additional products becoming subject to the terms of
this License, and may license such additional products on
different terms from those contained in this License.
V.3. Alternative Licensing.
Netscape may license the Source Code of Netscape's Branded Code,
including Modifications incorporated therein, without such
additional products becoming subject to the terms of this License,
and may license such additional products on different terms from
those contained in this License.
VI. Arbitration and Litigation.
Notwithstanding the limitations of Section 11 above, the provisions
regarding arbitration and litigation in Section 11(a), (b) and (c) of
the License shall apply to all disputes relating to this License.
EXHIBIT A.
``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
Netscape Communications Corporation. All Rights Reserved.
Contributor(s): ______________________________________.''
[NOTE: The text of this Exhibit A may differ slightly from the text of
the notices in the Source Code files of the Original Code. This is due
to time constraints encountered in simultaneously finalizing the
License and in preparing the Original Code for release. You should use
the text of this Exhibit A rather than the text found in the Original
Code Source Code for Your Modifications.]

88
mozilla/Makefile Normal file
View File

@@ -0,0 +1,88 @@
#
# 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 = .
NSPRDIR = nsprpub
NSPR20 = 1
MOZILLA_CLIENT = 1
ifndef NO_MOCHA
DIRS_JS = js
endif
DIRS = config coreconf $(NSPRDIR) jpeg dbm xpcom
ifdef MOZ_NETCAST
DIRS += netcast
endif
ifdef MOZ_JAVA
DIRS += sun-java ldap ifc $(DIRS_JS) nav-java ifc/tools js/jsd
else
DIRS += sun-java nav-java $(DIRS_JS)
endif
ifndef NO_SECURITY
DIRS += security
endif
DIRS += modules lib l10n cmd
ifeq ($(STAND_ALONE_JAVA),1)
DIRS = config lib/xp $(NSPRDIR) jpeg modules/zlib sun-java ifc js ifc/tools sun-java/java
endif
ifeq ($(subst /,,$(shell uname -s)),OS2)
# OS/2 don't need generated about-box stuff from l10n.
DIRS := $(filter-out l10n,$(DIRS))
endif
include $(DEPTH)/config/rules.mk
export:: $(OBJS)
# Running this rule assembles all the SDK source pieces into dist/sdk.
# You'll need to run this rule on every platform to get all the
# binaries (e.g. javah) copied there. You'll also have to do special
# magic on a Mac.
sdk-src::
$(SDKINSTALL) include/npapi.h $(SDK)/include/
$(SDKINSTALL) include/jri_md.h $(SDK)/include/
$(SDKINSTALL) include/jritypes.h $(SDK)/include/
$(SDKINSTALL) include/jri.h $(SDK)/include/
$(SDKINSTALL) lib/plugin/npupp.h $(SDK)/include/
$(SDKINSTALL) sdk/common/*.c* $(SDK)/common/
$(SDKINSTALL) sun-java/classsrc/$(ZIP_NAME).x $(SDK)/classes/$(ZIP_NAME)
$(SDKINSTALL) sdk/examples/simple/Source/*.c $(SDK)/examples/simple/Source/
$(SDKINSTALL) sdk/examples/simple/Source/*.java $(SDK)/examples/simple/Source/
$(SDKINSTALL) sdk/examples/simple/Source/*.class $(SDK)/examples/simple/Source/
$(SDKINSTALL) sdk/examples/simple/Source/_gen/*.h $(SDK)/examples/simple/Source/_gen/
$(SDKINSTALL) sdk/examples/simple/Source/_stubs/*.c $(SDK)/examples/simple/Source/_stubs/
$(SDKINSTALL) sdk/examples/simple/Unix/makefile.* $(SDK)/examples/simple/Unix/
$(SDKINSTALL) sdk/examples/simple/Testing/SimpleExample.html $(SDK)/examples/simple/Testing/
$(SDKINSTALL) sdk/examples/simple/readme.html $(SDK)/examples/simple/
$(SDKINSTALL) sdk/examples/UnixTemplate/Source/*.c $(SDK)/examples/UnixTemplate/Source/
$(SDKINSTALL) sdk/examples/UnixTemplate/Testing/Test.html $(SDK)/examples/UnixTemplate/Testing/
$(SDKINSTALL) sdk/examples/UnixTemplate/Unix/makefile.* $(SDK)/examples/UnixTemplate/Unix/
$(SDKINSTALL) sdk/examples/UnixTemplate/readme.html $(SDK)/examples/UnixTemplate/
sdk-bin::
cd sdk; $(MAKE); cd ..
$(SDKINSTALL) $(DIST)/bin/javah$(BIN_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/
$(SDKINSTALL) sdk/examples/simple/Source/$(OBJDIR)/npsimple.$(DLL_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/
$(SDKINSTALL) sdk/examples/UnixTemplate/Source/$(OBJDIR)/nptemplate.$(DLL_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/

View File

@@ -0,0 +1 @@
5009808600

25
mozilla/build/genrc.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/sh
#
# 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.
#
DATATYPE="$1"
INFILE="$2"
echo "${DATATYPE} RCDATA"
sed 's/"/""/g' ${INFILE} | awk 'BEGIN { printf("BEGIN\n") } { printf("\"%s\\r\\n\",\n", $0) } END { printf("\"\\0\"\nEND\n") }'
exit 0

45
mozilla/build/hcc Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/sh
#
# 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.
#
#
# Fix brain-damaged compilers that don't understand -o and -c together
#
DASH_C=0
DASH_O=0
for i in $*
do
case $i in
-c) DASH_C=1;;
-o) DASH_O=1;;
*.c) C_SRC=$i;;
*.s) S_SRC=$i;;
*.o) OBJECT=$i;;
esac
done
cc $* || exit $?
# if there was no -c and -o we're done
[ $DASH_C = 1 -a $DASH_O = 1 ] || exit 0
# cc always creates the .o from the .c name
[ $C_SRC ] && OBJ=`basename $C_SRC .c`.o
# or the .o from the .s name
[ $S_SRC ] && OBJ=`basename $S_SRC .s`.o
[ -f $OBJECT ] || [ -f $OBJ ] && mv -f $OBJ $OBJECT

86
mozilla/build/hcpp Executable file
View File

@@ -0,0 +1,86 @@
#!/bin/sh
#
# 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.
#
#
# Wrapper for brain-damaged compilers that don't understand -o and -c together.
#
DUMMY="XxxXxxX"
DASH_C=0
DASH_O=0
GET_OBJECT=0
C_SRC="${DUMMY}"
CC_SRC="${DUMMY}"
CPP_SRC="${DUMMY}"
S_SRC="${DUMMY}"
OBJECT="${DUMMY}"
for i in $*
do
if [ ${GET_OBJECT} -eq 1 ]; then
OBJECT="$i"
GET_OBJECT=0
fi
case $i in
-c)
DASH_C=1
;;
-o)
DASH_O=1
GET_OBJECT=1
;;
*.c)
C_SRC="$i"
;;
+.*)
;;
*.cpp)
CPP_SRC="$i"
;;
*.cc)
CC_SRC="$i"
;;
*.s)
S_SRC="$i"
;;
esac
done
CC $* || exit $?
# LAME!!!
if [ -f -O ]; then
mv -f -- -O ${OBJECT}
fi
# if there was no -c and -o we're done
[ ${DASH_C} -eq 1 -a ${DASH_O} -eq 1 ] || exit 0
# cc always creates the .o from the .c name
if [ "${C_SRC}" != "${DUMMY}" ]; then
OBJ=`basename ${C_SRC} .c`.o
elif [ "${CPP_SRC}" != "${DUMMY}" ]; then
OBJ=`basename ${CPP_SRC} .cpp`.o
elif [ "${CC_SRC}" != "${DUMMY}" ]; then
OBJ=`basename ${CC_SRC} .cc`.o
# or the .o from the .s name
elif [ "${S_SRC}" != "${DUMMY}" ]; then
OBJ=`basename ${S_SRC} .s`.o
fi
[ -f ${OBJECT} ] || [ -f ${OBJ} ] && mv -f ${OBJ} ${OBJECT}

View File

@@ -0,0 +1,88 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 file overrides all option settings in the IDE. It is an attempt to allow all builds
to have the same options.
Note: We can't use ConditionalMacros.h in this file because it will conflict with
the PowerPlant precompiled headers.
*/
/* warning pragmas */
#pragma warn_hidevirtual on
#pragma check_header_flags on
/* Language features that must be the same across libraries... */
#pragma enumsalwaysint on
#pragma unsigned_char off
#pragma exceptions on
#pragma bool on
/* Save as much space as possible with strings... */
#pragma pool_strings on
#pragma dont_reuse_strings off
#pragma options align=native
#pragma sym on /* Takes no memory. OK in non-debug. */
#ifdef powerc /* ...generating PowerPC */
#pragma toc_data on
#pragma fp_contract on
#pragma readonly_strings on
#ifdef DEBUG
#pragma traceback on
#pragma global_optimizer off
#pragma scheduling off
#pragma peephole off
#pragma optimize_for_size off
#else
#pragma traceback off
#pragma global_optimizer on
#pragma optimization_level 4
#pragma scheduling 604
#pragma peephole on
#pragma optimize_for_size on
#endif
#else /* ...generating 68k */
#pragma code68020 on
#pragma code68881 off
/* Far everything... */
#pragma far_code
#pragma far_data on
#pragma far_strings on
#pragma far_vtables on
#pragma fourbyteints on /* 4-byte ints */
#pragma IEEEdoubles on /* 8-byte doubles (as required by Java and NSPR) */
#ifdef DEBUG
#pragma macsbug on
#pragma oldstyle_symbols off
#else
#pragma macsbug off
#endif
#endif

View File

@@ -0,0 +1,38 @@
/* -*- 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.
*/
#define OLDROUTINELOCATIONS 0
#define XP_MAC 1
#ifndef NSPR20
#define NSPR20 1
#endif
#define _NSPR 1
#define _NO_FAST_STRING_INLINES_ 1
#define HAVE_BOOLEAN 1
#define NETSCAPE 1
#define OTUNIXERRORS 1 /* We want OpenTransport error codes */
/*
This compiles in heap dumping utilities and other good stuff
for developers -- maybe we only want it in for a special SDK
nspr/java runtime(?):
*/
#define DEVELOPER_DEBUG 1
#define MAX(_a,_b) ((_a) < (_b) ? (_b) : (_a))
#define MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))

Binary file not shown.

View File

@@ -1,80 +0,0 @@
#!perl
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Simon Fraser <sfraser@netscape.com>
#
require 5.004;
use strict;
use Cwd;
use Moz::BuildUtils;
use Moz::BuildCore;
#-------------------------------------------------------------
# Where have the build options gone?
#
# The various build flags have been centralized into one place.
# The master list of options is in MozBuildFlags.txt. However,
# you should never need to edit that file, or this one.
#
# To customize what gets built, or where to start the build,
# edit the $prefs_file_name file in
# System Folder:Preferences:Mozilla build prefs:
# Documentation is provided in that file.
#-------------------------------------------------------------
my($prefs_file_name) = "Mozilla opt build prefs";
my($config_header_file_name) = ":mozilla:config:mac:DefinesOptions.h";
#-------------------------------------------------------------
# hashes to hold build options
#-------------------------------------------------------------
my(%build);
my(%options);
my(%filepaths);
my(%optiondefines);
# Hash of input files for this build. Eventually, there will be
# input files for manifests, and projects too.
my(%inputfiles) = (
"buildflags", "MozillaBuildFlags.txt",
"checkoutdata", "MozillaCheckoutList.txt",
"buildprogress", "¥ Mozilla opt progress",
"buildmodule", "MozillaBuildList.pm",
"checkouttime", "Mozilla last checkout"
);
#-------------------------------------------------------------
# end build hashes
#-------------------------------------------------------------
# set the build root directory, which is the the dir above mozilla
SetupBuildRootDir(":mozilla:build:mac:build_scripts");
# Set up all the flags on $main::, like DEBUG, CARBON etc.
# Override the defaults using the preferences files.
SetupDefaultBuildOptions(0, ":mozilla:dist:viewer:", $config_header_file_name);
my($do_checkout) = 0;
my($do_build) = 1;
RunBuild($do_checkout, $do_build, \%inputfiles, $prefs_file_name);

View File

@@ -1,80 +0,0 @@
#!perl
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Simon Fraser <sfraser@netscape.com>
#
require 5.004;
use strict;
use Cwd;
use Moz::BuildUtils;
use Moz::BuildCore;
#-------------------------------------------------------------
# Where have the build options gone?
#
# The various build flags have been centralized into one place.
# The master list of options is in MozBuildFlags.txt. However,
# you should never need to edit that file, or this one.
#
# To customize what gets built, or where to start the build,
# edit the $prefs_file_name file in
# System Folder:Preferences:Mozilla build prefs:
# Documentation is provided in that file.
#-------------------------------------------------------------
my($prefs_file_name) = "Mozilla debug build prefs";
my($config_header_file_name) = ":mozilla:config:mac:DefinesOptionsDebug.h";
#-------------------------------------------------------------
# hashes to hold build options
#-------------------------------------------------------------
my(%build);
my(%options);
my(%filepaths);
my(%optiondefines);
# Hash of input files for this build. Eventually, there will be
# input files for manifests, and projects too.
my(%inputfiles) = (
"buildflags", "MozillaBuildFlags.txt",
"checkoutdata", "MozillaCheckoutList.txt",
"buildprogress", "¥ Mozilla debug progress",
"buildmodule", "MozillaBuildList.pm",
"checkouttime", "Mozilla last checkout"
);
#-------------------------------------------------------------
# end build hashes
#-------------------------------------------------------------
# set the build root directory, which is the the dir above mozilla
SetupBuildRootDir(":mozilla:build:mac:build_scripts");
# Set up all the flags on $main::, like DEBUG, CARBON etc.
# Override the defaults using the preferences files.
SetupDefaultBuildOptions(1, ":mozilla:dist:viewer_debug:", $config_header_file_name);
my($do_pull) = 0; # overridden by flags and prefs
my($do_build) = 1;
RunBuild($do_pull, $do_build, \%inputfiles, $prefs_file_name);

View File

@@ -1,595 +0,0 @@
#!perl -w
package Moz::BuildCore;
require 5.004;
require Exporter;
use strict;
use vars qw( @ISA @EXPORT );
# perl includes
use Cwd;
use POSIX;
use Time::Local;
use File::Basename;
use LWP::Simple;
# homegrown
use Moz::Moz;
use Moz::Jar;
use Moz::BuildFlags;
use Moz::BuildUtils;
use Moz::CodeWarriorLib;
# use MozillaBuildList; # eventually, this should go away, and be replaced by data input
@ISA = qw(Exporter);
@EXPORT = qw(
RunBuild
);
#//--------------------------------------------------------------------------------------------------
#// DoPrebuildCheck
#//
#// Check the build tools etc before running the build.
#//--------------------------------------------------------------------------------------------------
sub DoPrebuildCheck()
{
SanityCheckBuildOptions();
# launch codewarrior and persist its location. Have to call this before first
# call to getCodeWarriorPath().
my($ide_path_file) = $main::filepaths{"idepath"};
$ide_path_file = full_path_to($ide_path_file);
LaunchCodeWarrior($ide_path_file);
}
#//--------------------------------------------------------------------------------------------------
#// SanityCheckBuildOptions
#//--------------------------------------------------------------------------------------------------
sub SanityCheckBuildOptions()
{
my($bad_options) = 0;
# Jar options
if (!$main::options{chrome_jars} && !$main::options{chrome_files})
{
print "Warning: Both \$options{chrome_jars} and \$options{chrome_files} are off. You won't get any chrome.\n";
$bad_options = 1;
}
if (!$main::options{chrome_jars} && $main::options{use_jars})
{
print "Warning: \$options{chrome_jars} is off but \$options{use_jars} is on. Your build won't run (expects jars, got files).\n";
$bad_options = 1;
}
if (!$main::options{chrome_files} && !$main::options{use_jars})
{
print "Warning: \$options{chrome_jars} is off but \$options{chrome_files} is on. Your build won't run (expects files, got jars).\n";
$bad_options = 1;
}
if ($main::options{ldap_experimental} && !$main::options{ldap})
{
print "Warning: \$options{ldap_experimental} is on but \$options{ldap} is off. LDAP experimental features will not be built.\n";
$bad_options = 1;
}
if ($main::options{wsp} && !$main::options{xmlextras})
{
print "Warning: \$options{wsp} is on but \$options{xmlextras} is off. wsp will not be built.\n";
$bad_options = 1;
}
if ($bad_options) {
print "Build will start in 5 seconds. Press command-. to stop\n";
DelayFor(5);
}
}
#//--------------------------------------------------------------------------------------------------
#// GenBuildSystemInfo
#//--------------------------------------------------------------------------------------------------
sub GenBuildSystemInfo()
{
# always rebuild the configuration program.
BuildProjectClean(":mozilla:build:mac:tools:BuildSystemInfo:BuildSystemInfo.mcp", "BuildSystemInfo");
# delete the configuration file.
unlink(":mozilla:build:mac:BuildSystemInfo.pm");
# run the program.
system(":mozilla:build:mac:BuildSystemInfo");
# wait for the file to be created.
while (!(-e ":mozilla:build:mac:BuildSystemInfo.pm")) { WaitNextEvent(); }
# wait for BuildSystemInfo to finish, so that we see correct results.
while (IsProcessRunning("BuildSystemInfo")) { WaitNextEvent(); }
# now, evaluate the contents of the file.
open(F, ":mozilla:build:mac:BuildSystemInfo.pm");
while (<F>) { eval; }
close(F);
}
#//--------------------------------------------------------------------------------------------------
#// Make library aliases
#//--------------------------------------------------------------------------------------------------
sub MakeLibAliases()
{
my($dist_dir) = GetBinDirectory();
#// ProfilerLib
if ($main::PROFILE)
{
my($profilerlibpath) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:Profiler:Profiler Common:ProfilerLib");
MakeAlias("$profilerlibpath", "$dist_dir"."Essential Files:");
}
}
#//--------------------------------------------------------------------------------------------------
#// ConfigureBuildSystem
#//
#// defines some build-system configuration variables.
#//--------------------------------------------------------------------------------------------------
sub ConfigureBuildSystem()
{
#// In the future, we may want to do configurations based on the actual build system itself.
#// GenBuildSystemInfo();
#// For now, if we discover a newer header file than existed in Universal Interfaces 3.2,
#// we'll assume that 3.3 or later is in use.
my($universal_interfaces) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:Universal:Interfaces:CIncludes:");
if (-e ($universal_interfaces . "ControlDefinitions.h")) {
$main::UNIVERSAL_INTERFACES_VERSION = 0x0330;
}
#// Rename IC SDK folder in the Mac OS Support folder
my($ic_sdk_folder) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:ICProgKit2.0.2");
if( -e $ic_sdk_folder)
{
my($new_ic_folder_name) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:(ICProgKit2.0.2)");
rename ($ic_sdk_folder, $new_ic_folder_name);
# note that CodeWarrior doesn't descend into folders with () the name
print "Mozilla no longer needs the Internet Config SDK to build:\n Renaming the 'ICProgKit2.0.2' folder to '(ICProgKit2.0.2)'\n";
}
printf("UNIVERSAL_INTERFACES_VERSION = 0x%04X\n", $main::UNIVERSAL_INTERFACES_VERSION);
# alias required CodeWarrior libs into the Essential Files folder (only the Profiler lib now)
MakeLibAliases();
}
#//--------------------------------------------------------------------------------------------------
#// CheckOutModule. Takes variable number of args; first two are required
#//--------------------------------------------------------------------------------------------------
sub CheckOutModule($$$$)
{
my($session, $module, $revision, $date) = @_;
my($result) = $session->checkout($module, $revision, $date);
# result of 1 is success
if ($result) { return; }
my($checkout_err) = $session->getLastError();
if ($checkout_err == 708) {
die "Error: Checkout was cancelled.\n";
} elsif ($checkout_err == 911) {
die "Error: CVS session settings are incorrect. Check your password, and the CVS root settings.\n";
} elsif ($checkout_err == 703) {
die "Error: CVS checkout failed. Unknown module, unknown tag, bad username, or other CVS error.\n";
} elsif ($checkout_err == 711) {
print "Checkout of '$module' failed.\n";
}
}
#//--------------------------------------------------------------------------------------------------
#// getScriptFolder
#//--------------------------------------------------------------------------------------------------
sub getScriptFolder()
{
return dirname($0);
}
#//--------------------------------------------------------------------------------------------------
#// getScriptFolder
#//--------------------------------------------------------------------------------------------------
sub get_url_contents($)
{
my($url) = @_;
my($url_contents) = LWP::Simple::get($url);
$url_contents =~ s/\r\n/\n/g; # normalize linebreaks
$url_contents =~ s/\r/\n/g; # normalize linebreaks
return $url_contents;
}
#//--------------------------------------------------------------------------------------------------
#// get_files_from_content
#//--------------------------------------------------------------------------------------------------
sub uniq
{
my $lastval;
grep(($_ ne $lastval, $lastval = $_)[$[], @_);
}
#//--------------------------------------------------------------------------------------------------
#// get_files_from_content
#//--------------------------------------------------------------------------------------------------
sub get_files_from_content($)
{
my($content) = @_;
my(@jscalls) = grep (/return js_file_menu[^{]*/, split(/\n/, $content));
my $i;
for ($i = 0; $i < @jscalls ; $i++)
{
$jscalls[$i] =~ s/.*\(|\).*//g;
my(@callparams) = split(/,/, $jscalls[$i]);
my ($repos, $dir, $file, $rev) = grep(s/['\s]//g, @callparams);
$jscalls[$i] = "$dir/$file";
}
&uniq(sort(@jscalls));
}
#//--------------------------------------------------------------------------------------------------
#// getLastUpdateTime
#//
#// Get the last time we updated. Return 0 on failure
#//--------------------------------------------------------------------------------------------------
sub getLastUpdateTime($)
{
my($timestamp_file) = @_;
my($time_string);
local(*TIMESTAMP_FILE);
unless (open(TIMESTAMP_FILE, "< $timestamp_file")) { return 0; }
while (<TIMESTAMP_FILE>)
{
my($line) = $_;
chomp($line);
# ignore comments and empty lines
if ($line =~ /^\#/ || $line =~ /^\s*$/) {
next;
}
$time_string = $line;
}
# get the epoch seconds
my($last_update_secs) = $time_string;
$last_update_secs =~ s/\s#.+$//;
print "FAST_UPDATE found that you last updated at ".localtime($last_update_secs)."\n";
# how long ago was this, in hours?
my($gm_now) = time();
my($update_hours) = 1 + ceil(($gm_now - $last_update_secs) / (60 * 60));
return $update_hours;
}
#//--------------------------------------------------------------------------------------------------
#// saveCheckoutTimestamp
#//
#// Create a file on disk containing the current time. Param is time(), which is an Epoch seconds
#// (and therefore in GMT).
#//
#//--------------------------------------------------------------------------------------------------
sub saveCheckoutTimestamp($$)
{
my($gm_secs, $timestamp_file) = @_;
local(*TIMESTAMP_FILE);
open(TIMESTAMP_FILE, ">$timestamp_file") || die "Failed to open $timestamp_file\n";
print(TIMESTAMP_FILE "# time of last checkout or update, in GMT. Used by FAST_UPDATE\n");
print(TIMESTAMP_FILE "$gm_secs \# around ".localtime()." local time\n");
close(TIMESTAMP_FILE);
}
#//--------------------------------------------------------------------------------------------------
#// FastUpdate
#//
#// Use Bonsai url data to update only those dirs which have new files
#//
#//--------------------------------------------------------------------------------------------------
sub FastUpdate($$)
{
my($modules, $timestamp_file) = @_; # list of modules to check out
my($num_hours) = getLastUpdateTime($timestamp_file);
if ($num_hours == 0 || $num_hours > 170) {
print "Can't fast_update; last update was too long ago, or never. Doing normal checkout.\n";
return 0;
}
print "Doing fast update, pulling files changed in the last $num_hours hours\n";
my($cvsfile) = AskAndPersistFile($main::filepaths{"sessionpath"});
my($session) = Moz::MacCVS->new( $cvsfile );
unless (defined($session)) { die "Error: Checkout aborted. Cannot create session file: $session" }
# activate MacCVS
ActivateApplication('Mcvs');
my($checkout_start_time) = time();
#print "Time now is $checkout_start_time ($checkout_start_time + 0)\n";
my($this_co);
foreach $this_co (@$modules)
{
my($module, $revision, $date) = ($this_co->[0], $this_co->[1], $this_co->[2]);
# assume that things pulled by date wont change
if ($date ne "") {
print "$module is pulled by date, so ignoring in FastUpdate.\n";
next;
}
my($search_type) = "hours";
my($min_date) = "";
my($max_date) = "";
my($url) = "http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=${module}&branch=${revision}&branchtype=match&dir=&file=&filetype=match&who=&whotype=match&sortby=Date&hours=${num_hours}&date=${search_type}&mindate=${min_date}&maxdate=${max_date}&cvsroot=%2Fcvsroot";
if ($revision eq "") {
print "Getting list of checkins to $module from Bonsai...\n";
} else {
print "Getting list of checkins to $module on branch $revision from Bonsai...\n";
}
my(@files) = &get_files_from_content(&get_url_contents($url));
if ($#files > 0)
{
my(@cvs_co_list);
my($co_file);
foreach $co_file (@files)
{
print "Updating $co_file\n";
push(@cvs_co_list, $co_file);
}
my($result) = $session->update($revision, \@cvs_co_list);
# result of 1 is success
if (!$result) { die "Error: Fast update failed\n"; }
} else {
print "No files in this module changed\n";
}
}
saveCheckoutTimestamp($checkout_start_time, $timestamp_file);
return 1;
}
#//--------------------------------------------------------------------------------------------------
#// Checkout
#//--------------------------------------------------------------------------------------------------
sub CheckoutModules($$$)
{
my($modules, $pull_date, $timestamp_file) = @_; # list of modules to check out
my($start_time) = TimeStart();
# assertRightDirectory();
my($cvsfile) = AskAndPersistFile($main::filepaths{"sessionpath"});
my($session) = Moz::MacCVS->new( $cvsfile );
unless (defined($session)) { die "Error: Checkout aborted. Cannot create session file: $session" }
my($checkout_start_time) = time();
# activate MacCVS
ActivateApplication('Mcvs');
my($this_co);
foreach $this_co (@$modules)
{
my($module, $revision, $date) = ($this_co->[0], $this_co->[1], $this_co->[2]);
if ($date eq "") {
$date = $pull_date;
}
CheckOutModule($session, $module, $revision, $date);
# print "Checking out $module with ref $revision, date $date\n";
}
saveCheckoutTimestamp($checkout_start_time, $timestamp_file);
TimeEnd($start_time, "Checkout");
}
#//--------------------------------------------------------------------------------------------------
#// ReadCheckoutModulesFile
#//--------------------------------------------------------------------------------------------------
sub ReadCheckoutModulesFile($$)
{
my($modules_file, $co_list) = @_;
my($checkout_file) = getScriptFolder().":".$modules_file;
local(*CHECKOUT_FILE);
open(CHECKOUT_FILE, "< $checkout_file") || die "Error: failed to open checkout list $checkout_file\n";
while (<CHECKOUT_FILE>)
{
my($line) = $_;
chomp($line);
# ignore comments and empty lines
if ($line =~ /^\#/ || $line =~ /^\s*$/) {
next;
}
my(@cvs_co) = ["", "", ""];
my($module, $revision, $date) = (0, 1, 2);
if ($line =~ /\s*([^#,\s]+)\s*\,\s*([^#,\s]+)\s*\,\s*([^#]+)/)
{
@cvs_co[$module] = $1;
@cvs_co[$revision] = $2;
@cvs_co[$date] = $3;
}
elsif ($line =~ /\s*([^#,\s]+)\s*\,\s*([^#,\s]+)\s*(#.+)?/)
{
@cvs_co[$module] = $1;
@cvs_co[$revision] = $2;
}
elsif ($line =~ /\s*([^#,\s]+)\s*\,\s*,\s*([^#,]+)/)
{
@cvs_co[$module] = $1;
@cvs_co[$date] = $2;
}
elsif ($line =~ /\s*([^#,\s]+)/)
{
@cvs_co[$module] = $1;
}
else
{
die "Error: unrecognized line '$line' in $modules_file\n";
}
# strip surrounding space from date
@cvs_co[$date] =~ s/^\s*|\s*$//g;
# print "Going to check out '@cvs_co[$module]', '@cvs_co[$revision]', '@cvs_co[$date]'\n";
push(@$co_list, \@cvs_co);
}
close(CHECKOUT_FILE);
}
#//--------------------------------------------------------------------------------------------------
#// PullFromCVS
#//--------------------------------------------------------------------------------------------------
sub PullFromCVS($$)
{
unless ( $main::build{pull} ) { return; }
my($modules_file, $timestamp_file) = @_;
StartBuildModule("pull");
my(@cvs_co_list);
ReadCheckoutModulesFile($modules_file, \@cvs_co_list);
if ($main::FAST_UPDATE && $main::options{pull_by_date})
{
die "Error: you can't use FAST_UPDATE if you are pulling by date.\n";
}
my($did_fast_update) = $main::FAST_UPDATE && FastUpdate(\@cvs_co_list, $timestamp_file);
if (!$did_fast_update)
{
my($pull_date) = "";
if ($main::options{pull_by_date})
{
# acceptable CVS date formats are (in local time):
# ISO8601 (e.g. "1972-09-24 20:05") and Internet (e.g. "24 Sep 1972 20:05").
# Perl's localtime() string format also seems to work.
$pull_date = localtime().""; # force string interp.
print "Pulling by date $pull_date\n";
}
CheckoutModules(\@cvs_co_list, $pull_date, $timestamp_file);
}
EndBuildModule("pull");
}
#//--------------------------------------------------------------------------------------------------
#// RunBuild
#//--------------------------------------------------------------------------------------------------
sub RunBuild($$$$)
{
my($do_pull, $do_build, $input_files, $build_prefs) = @_;
InitBuildProgress($input_files->{"buildprogress"});
# if we are pulling, we probably want to do a full build, so clear the build progress
if ($do_pull) {
ClearBuildProgress();
}
# read local prefs, and the build progress file, and set flags to say what to build
SetupBuildParams(\%main::build,
\%main::options,
\%main::optiondefines,
\%main::filepaths,
$input_files->{"buildflags"},
$build_prefs);
# If we were told to pull, make sure we do, overriding prefs etc.
if ($do_pull)
{
$main::build{"pull"} = 1;
}
# transfer this flag
$CodeWarriorLib::CLOSE_PROJECTS_FIRST = $main::CLOSE_PROJECTS_FIRST;
# setup the build log
SetupBuildLog($main::filepaths{"buildlogfilepath"}, $main::USE_TIMESTAMPED_LOGS);
StopForErrors();
if ($main::LOG_TO_FILE) {
RedirectOutputToFile($main::filepaths{"scriptlogfilepath"});
}
# run a pre-build check to see that the tools etc are in order
DoPrebuildCheck();
# do the pull
PullFromCVS($input_files->{"checkoutdata"}, $input_files->{"checkouttime"});
unless ($do_build) { return; }
my($build_start) = TimeStart();
# check the build environment
ConfigureBuildSystem();
# here we load and call methods in the build module indirectly.
# we have to use indirection because the build module can be named
# differently for different builds.
chdir(dirname($0)); # change to the script dir
my($build_module) = $input_files->{"buildmodule"};
# load the build module
require $build_module;
{ # scope for no strict 'refs'
no strict 'refs';
my($package_name) = $build_module;
$package_name =~ s/\.pm$//;
chdir($main::MOZ_SRC);
&{$package_name."::BuildDist"}();
chdir($main::MOZ_SRC);
&{$package_name."::BuildProjects"}();
}
# the build finished, so clear the build progress state
ClearBuildProgress();
TimeEnd($build_start, "Build");
print "Build complete\n";
}
1;

View File

@@ -1,425 +0,0 @@
#!perl -w
package Moz::BuildFlags;
require 5.004;
require Exporter;
# Package that attempts to read a file from the Preferences folder,
# and get build settings out of it
use strict;
use Exporter;
use Cwd;
use File::Basename;
use Moz::Moz;
use Moz::Prefs;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(
SetupBuildParams
InitBuildProgress
WriteBuildProgress
ClearBuildProgress
ReadBuildProgress
);
my(@build_flags);
my(@options_flags);
my(@filepath_flags);
my(%arrays_list) = (
"build_flags", \@build_flags,
"options_flags", \@options_flags,
"filepath_flags", \@filepath_flags
);
my($progress_file) = "¥ÊBuild progress";
#-------------------------------------------------------------------------------
# appendArrayFlag
#
# Set a flag in the array
#-------------------------------------------------------------------------------
sub appendArrayFlag(@)
{
my($array_name) = shift;
my($setting) = shift;
my($value) = shift;
my(@optional_values);
foreach (@_) {
push(@optional_values, $_);
}
my(@this_flag) = [$setting, $value, @optional_values];
my($flags_array) = $arrays_list{$array_name};
if ($flags_array)
{
push(@{$flags_array}, @this_flag) || die "Failed to append\n";
}
else
{
die "Error: unknown build flags array $array_name\n";
}
}
#-------------------------------------------------------------------------------
# readFlagsFile
#
# Read the file of build flags from disk. File path is relative to the
# script directory.
#-------------------------------------------------------------------------------
sub readFlagsFile($)
{
my($flags_file) = @_;
my($file_path) = $0;
$file_path =~ s/[^:]+$/$flags_file/;
print "Reading build flags from '$file_path'\n";
local(*FLAGS_FILE);
open(FLAGS_FILE, "< $file_path") || die "Error: failed to open flags file $file_path\n";
my($cur_array) = "";
while(<FLAGS_FILE>)
{
my($line) = $_;
chomp($line);
# ignore comments and empty lines
if ($line =~ /^\#/ || $line =~ /^\s*$/) {
next;
}
# 1-word line, probably array name
if ($line =~ /^([^#\s]+)\s*$/)
{
$cur_array = $1;
next;
}
elsif ($line =~ /^([^#\s]+)\s+\"(.+)\"(\s+#.+)?$/) # quoted option, possible comment
{
my($flag) = $1;
my($setting) = $2;
appendArrayFlag($cur_array, $flag, $setting);
}
elsif ($line =~ /^([^#\s]+)((\s+[^#\s]+)+)(\s+#.+)?$/) # multiple word line, possible comment
{
my($flag) = $1;
appendArrayFlag($cur_array, $flag, split(' ', $2));
}
else
{
die "Error: unknown build flag at '$line'\n";
}
}
close(FLAGS_FILE);
}
#-------------------------------------------------------------------------------
# flagsArrayToHash
#
# Utility routine to migrate flag from a 2D array to a hash, where
# item[n][0] is the hash entry name, and item[n][1] is the hash entry value.
#-------------------------------------------------------------------------------
sub flagsArrayToHash($$)
{
my($src_array, $dest_hash) = @_;
my($item);
foreach $item (@$src_array)
{
$dest_hash->{$item->[0]} = $item->[1];
}
}
#-----------------------------------------------
# printHash
#
# Utility routine to print a hash
#-----------------------------------------------
sub printHash($)
{
my($hash_ref) = @_;
print "Printing hash:\n";
my($key, $value);
while (($key, $value) = each (%$hash_ref))
{
print " $key $value\n";
}
}
#-----------------------------------------------
# printBuildArray
#
# Utility routine to print a 2D array
#-----------------------------------------------
sub printBuildArray($)
{
my($build_array) = @_;
my($entry);
foreach $entry (@$build_array)
{
print "$entry->[0] = $entry->[1]\n";
}
}
#-------------------------------------------------------------------------------
# SetBuildFlags
#-------------------------------------------------------------------------------
sub SetBuildFlags($)
{
my($build) = @_;
flagsArrayToHash(\@build_flags, $build);
}
#-------------------------------------------------------------------------------
# SetBuildOptions
#-------------------------------------------------------------------------------
sub SetBuildOptions($)
{
my($options) = @_;
flagsArrayToHash(\@options_flags, $options);
}
#-------------------------------------------------------------------------------
# SetFilepathFlags
#-------------------------------------------------------------------------------
sub SetFilepathFlags($)
{
my($filepath) = @_;
flagsArrayToHash(\@filepath_flags, $filepath);
}
#-------------------------------------------------------------------------------
# SetOptionDefines
#-------------------------------------------------------------------------------
sub SetOptionDefines($)
{
my($optiondefines) = @_;
foreach my $entry (@options_flags)
{
if (defined($entry->[2])) {
$optiondefines->{$entry->[0]}{$entry->[2]} = 1;
}
}
}
#-------------------------------------------------------------------------------
# PropagateAllFlags
#-------------------------------------------------------------------------------
sub PropagateAllFlags($)
{
my($build_array) = @_;
# if "all" is set, set all the flags to 1
unless ($build_array->[0][0] eq "all") { die "Error: 'all' must come first in the flags array\n"; }
if ($build_array->[0][1] == 1)
{
my($index);
foreach $index (@$build_array)
{
$index->[1] = 1;
}
}
}
#//--------------------------------------------------------------------------------------------------
#// _getBuildProgressFile
#//--------------------------------------------------------------------------------------------------
sub _getBuildProgressFile()
{
return $progress_file;
}
#//--------------------------------------------------------------------------------------------------
#// setBuildProgressStart
#//
#// This automagically sets $build{"all"} to 0
#//--------------------------------------------------------------------------------------------------
sub setBuildProgressStart($$)
{
my($build_array, $name) = @_;
my($index);
foreach $index (@$build_array)
{
$index->[1] = 0;
if ($index->[0] eq $name) {
last;
}
}
print "Building from module after $name, as specified by build progress\n";
}
#//--------------------------------------------------------------------------------------------------
#// InitBuildProgress
#//--------------------------------------------------------------------------------------------------
sub InitBuildProgress($)
{
my($prog_file) = @_;
if ($prog_file ne "") {
$progress_file = full_path_to($prog_file);
print "Writing build progress to $progress_file\n";
}
}
#//--------------------------------------------------------------------------------------------------
#// WriteBuildProgress
#//--------------------------------------------------------------------------------------------------
sub WriteBuildProgress($)
{
my($module_built) = @_;
my($progress_file) = _getBuildProgressFile();
if ($progress_file ne "")
{
open(PROGRESS_FILE, ">>$progress_file") || die "Failed to open $progress_file\n";
print(PROGRESS_FILE "$module_built\n");
close(PROGRESS_FILE);
}
}
#//--------------------------------------------------------------------------------------------------
#// ClearBuildProgress
#//--------------------------------------------------------------------------------------------------
sub ClearBuildProgress()
{
my($progress_file) = _getBuildProgressFile();
if ($progress_file ne "") {
unlink $progress_file;
}
}
#//--------------------------------------------------------------------------------------------------
#// WipeBuildProgress
#//--------------------------------------------------------------------------------------------------
sub WipeBuildProgress()
{
print "Ignoring build progress\n";
ClearBuildProgress();
$progress_file = "";
}
#//--------------------------------------------------------------------------------------------------
#// ReadBuildProgress
#//--------------------------------------------------------------------------------------------------
sub ReadBuildProgress($)
{
my($build_array) = @_;
my($progress_file) = _getBuildProgressFile();
my($last_module);
if (open(PROGRESS_FILE, "< $progress_file"))
{
print "Getting build progress from $progress_file\n";
while (<PROGRESS_FILE>)
{
my($line) = $_;
chomp($line);
$last_module = $line;
}
close(PROGRESS_FILE);
}
if ($last_module)
{
setBuildProgressStart($build_array, $last_module);
}
}
#-------------------------------------------------------------------------------
# clearOldBuildSettings
#-------------------------------------------------------------------------------
sub clearOldBuildSettings($$$$)
{
my($build, $options, $optiondefines, $filepaths) = @_;
# empty the arrays in case we're being called twice
@build_flags = ();
@options_flags = ();
@filepath_flags = ();
# and empty the hashes
%$build = ();
%$options = ();
%$optiondefines = ();
%$filepaths = ();
}
#-------------------------------------------------------------------------------
# SetupBuildParams
#-------------------------------------------------------------------------------
sub SetupBuildParams($$$$$$)
{
my($build, $options, $optiondefines, $filepaths, $flags_file, $prefs_file) = @_;
# Empty the hashes and arrays, to wipe out any stale data.
# Needed because these structures persist across two build scripts
# called using 'do' from a parent script.
clearOldBuildSettings($build, $options, $optiondefines, $filepaths);
# Read from the flags file, which sets up the various arrays
readFlagsFile($flags_file);
# If 'all' is set in the build array, propagate that to all entries
PropagateAllFlags(\@build_flags);
# read the user pref file, that can change values in the array
ReadMozUserPrefs($prefs_file, \@build_flags, \@options_flags, \@filepath_flags);
# If build progress exists, this clears flags in the array up to a certain point
if ($main::USE_BUILD_PROGRESS) {
ReadBuildProgress(\@build_flags);
} else {
WipeBuildProgress();
}
# printBuildArray(\@build_flags);
# printBuildArray(\@options_flags);
SetBuildFlags($build);
SetBuildOptions($options);
SetOptionDefines($optiondefines);
SetFilepathFlags($filepaths);
# printHash($build);
# printHash($options);
}
1;

View File

@@ -1,786 +0,0 @@
package Moz::BuildUtils;
require 5.004;
require Exporter;
# Package that contains build util functions specific to the Mozilla build
# process.
use strict;
use Exporter;
use Cwd;
use File::Path;
use File::Basename;
use Mac::Events;
use Mac::StandardFile;
use Moz::Moz;
use Moz::BuildFlags;
use Moz::MacCVS;
#use Moz::ProjectXML; #optional; required for static build only
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(
SetupDefaultBuildOptions
SetupBuildRootDir
StartBuildModule
EndBuildModule
GetBinDirectory
BuildOneProjectWithOutput
BuildOneProject
BuildProject
BuildProjectClean
BuildIDLProject
BuildFolderResourceAliases
AskAndPersistFile
DelayFor
TimeStart
TimeEnd
EmptyTree
SetupBuildLog
SetBuildNumber
SetTimeBomb
UpdateConfigHeader
);
#//--------------------------------------------------------------------------------------------------
#// SetupDefaultBuildOptions
#//--------------------------------------------------------------------------------------------------
sub SetupDefaultBuildOptions($$$)
{
my($debug, $bin_dir, $config_header_file_name) = @_;
# Here we set up defaults for the various build flags.
# If you want to override any of these, it's best to do
# so via the relevant preferences file, which lives in
# System Folder:Preferences:Mozilla build prefs:{build prefs file}.
# For the name of the prefs file, see the .pl script that you
# run to start this build. The prefs files are created when
# you run the build, and contain some documentation.
#-------------------------------------------------------------
# configuration variables that globally affect what is built
#-------------------------------------------------------------
$main::DEBUG = $debug;
$main::PROFILE = 0;
$main::RUNTIME = 0; # turn on to just build runtime support and NSPR projects
$main::GC_LEAK_DETECTOR = 0; # turn on to use GC leak detection
$main::MOZILLA_OFFICIAL = 0; # generate build number
$main::LOG_TO_FILE = 0; # write perl output to a file
#-------------------------------------------------------------
# configuration variables that affect the manner of building,
# but possibly affecting the outcome.
#-------------------------------------------------------------
$main::ALIAS_SYM_FILES = $main::DEBUG;
$main::CLOBBER_LIBS = 1; # turn on to clobber existing libs and .xSYM files before
# building each project
# The following two options will delete all dist files (if you have $main::build{dist} turned on),
# but leave the directory structure intact.
$main::CLOBBER_DIST_ALL = 1; # turn on to clobber all aliases/files inside dist (headers/xsym/libs)
$main::CLOBBER_DIST_LIBS = 0; # turn on to clobber only aliases/files for libraries/sym files in dist
$main::CLOBBER_IDL_PROJECTS = 0; # turn on to clobber all IDL projects.
$main::CLOBBER_PROJECTS = 0; # turn on to remove object code from each project before building it
$main::UNIVERSAL_INTERFACES_VERSION = 0x0320;
#-------------------------------------------------------------
# configuration variables that are preferences for the build,
# style and do not affect what is built.
#-------------------------------------------------------------
$main::CLOSE_PROJECTS_FIRST = 0;
# 1 = close then make (for development),
# 0 = make then close (for tinderbox).
$main::USE_TIMESTAMPED_LOGS = 0;
$main::USE_BUILD_PROGRESS = 1; # track build progress for restartable builds
#-------------------------------------------------------------
# END OF CONFIG SWITCHES
#-------------------------------------------------------------
$main::BIN_DIRECTORY = $bin_dir;
$main::DEFINESOPTIONS_FILE = $config_header_file_name;
}
#//--------------------------------------------------------------------------------------------------
#// SetupBuildRootDir
#//--------------------------------------------------------------------------------------------------
sub SetupBuildRootDir($)
{
my($rel_path_to_script) = @_;
my($cur_dir) = cwd();
$cur_dir =~ s/$rel_path_to_script$//;
chdir($cur_dir) || die "Error: failed to set build root directory to '$cur_dir'.\nYou probably need to put 'mozilla' one level down (in a folder).\n";
$main::MOZ_SRC = cwd();
}
#//--------------------------------------------------------------------------------------------------
#// StartBuildModule
#//--------------------------------------------------------------------------------------------------
sub StartBuildModule($)
{
my($module) = @_;
print("---- Start of $module ----\n");
}
#//--------------------------------------------------------------------------------------------------
#// EndBuildModule
#//--------------------------------------------------------------------------------------------------
sub EndBuildModule($)
{
my($module) = @_;
WriteBuildProgress($module);
print("---- End of $module ----\n");
}
#--------------------------------------------------------------------------------------------------
# GetBinDirectory
#--------------------------------------------------------------------------------------------------
sub GetBinDirectory()
{
if ($main::BIN_DIRECTORY eq "") { die "Dist directory not set\n"; }
return $main::BIN_DIRECTORY;
}
#--------------------------------------------------------------------------------------------------
# AskAndPersistFile stores the information about the user pick inside
# the file $session_storage
#--------------------------------------------------------------------------------------------------
sub AskAndPersistFile($)
{
my ($sessionStorage) = @_;
my $cvsfile;
if (( -e $sessionStorage) &&
open( SESSIONFILE, $sessionStorage ))
{
# Read in the path if available
$cvsfile = <SESSIONFILE>;
chomp $cvsfile;
close SESSIONFILE;
if ( ! -e $cvsfile )
{
print STDERR "$cvsfile has disappeared\n";
undef $cvsfile;
}
}
unless (defined ($cvsfile))
{
# make sure that MacPerl is a front process
ActivateApplication('McPL');
MacPerl::Answer("Could not find your MacCVS session file. Please choose one", "OK");
# prompt user for the file name, and store it
my $macFile = StandardGetFile( 0, "McvD");
if ( $macFile->sfGood() )
{
$cvsfile = $macFile->sfFile();
# save the choice if we can
if ( open (SESSIONFILE, ">" . $sessionStorage))
{
printf SESSIONFILE $cvsfile, "\n";
close SESSIONFILE;
}
else
{
print STDERR "Could not open storage file $sessionStorage for saving $cvsfile\n";
}
}
}
return $cvsfile;
}
#--------------------------------------------------------------------------------------------------
# BuildIDLProject
#
#--------------------------------------------------------------------------------------------------
sub BuildIDLProject($$)
{
my ($project_path, $module_name) = @_;
if ($main::CLOBBER_IDL_PROJECTS)
{
my (@suffix_list) = (".mcp", ".xml");
my ($project_name, $project_dir, $suffix) = fileparse($project_path, @suffix_list);
if ($suffix eq "") { die "Error: Project, $project_path must end in .xml or .mcp\n"; }
my($datafolder_path);
if ($suffix eq ".xml")
{
$datafolder_path = $project_dir . "_" . $project_name . " Data:";
}
else {
$datafolder_path = $project_dir . $project_name . " Data:";
}
print STDERR "Deleting IDL data folder: $datafolder_path\n";
EmptyTree($datafolder_path);
}
BuildOneProject($project_path, "headers", 0, 0, 0);
BuildOneProject($project_path, $module_name.".xpt", 1, 0, 1);
}
#--------------------------------------------------------------------------------------------------
# CreateStaticLibTargets
#
#--------------------------------------------------------------------------------------------------
sub CreateXMLStaticLibTargets($)
{
my($xml_path) = @_;
my (@suffix_list) = (".xml");
my ($project_name, $project_dir, $suffix) = fileparse($xml_path, @suffix_list);
if ($suffix eq "") { die "XML munging: $xml_path must end in .xml\n"; }
#sniff the file to see if we need to fix up broken Pro5-exported XML
print "Parsing $xml_path\n";
my $ide_version = Moz::ProjectXML::SniffProjectXMLIDEVersion($xml_path);
if ($ide_version eq "4.0")
{
my $new_file = $project_dir.$project_name."2.xml";
print "Cleaning up Pro 5 xml to $new_file\n";
Moz::ProjectXML::CleanupPro5XML($xml_path, $new_file);
unlink $xml_path;
rename ($new_file, $xml_path);
}
my $doc = Moz::ProjectXML::ParseXMLDocument($xml_path);
my @target_list = Moz::ProjectXML::GetTargetsList($doc);
my $target;
my %target_hash; # for easy lookups below
foreach $target (@target_list) { $target_hash{$target} = 1; }
foreach $target (@target_list)
{
if ($target =~ /(.+).shlb$/) # if this is a shared lib target
{
my $target_base = $1;
my $static_target = $target_base.".o";
# ensure that this does not exist already
if ($target_hash{$static_target}) {
print "Static target $static_target already exists in project. Not making\n";
next;
}
print "Making static target '$static_target' from target '$target'\n";
Moz::ProjectXML::CloneTarget($doc, $target, $static_target);
Moz::ProjectXML::SetAsStaticLibraryTarget($doc, $static_target, $static_target);
}
}
print "Writing XML file to $xml_path\n";
my $temp_path = $project_dir."_".$project_name.".xml";
Moz::ProjectXML::WriteXMLDocument($doc, $temp_path, $ide_version);
Moz::ProjectXML::DisposeXMLDocument($doc);
if (-e $temp_path)
{
unlink $xml_path;
rename ($temp_path, $xml_path);
}
else
{
die "Error: Failed to add new targets to XML project\n";
}
}
#//--------------------------------------------------------------------------------------------------
#// ProcessProjectXML
#//
#// Helper routine to allow for XML pre-processing. This should read in the XML, process it,
#// and replace the original file with the processed version.
#//--------------------------------------------------------------------------------------------------
sub ProcessProjectXML($)
{
my($xml_path) = @_;
# we need to manually load Moz::ProjectXML, becaues not everyone will have the
# required perl modules in their distro.
my($cur_dir) = cwd();
chdir(dirname($0)); # change to the script dir
eval "require Moz::ProjectXML";
if ($@) { die "Error: could not do Project XML munging because you do not have the correct XML modules installed. Error is:\n################\n $@################"; }
chdir($cur_dir);
CreateXMLStaticLibTargets($xml_path);
}
#//--------------------------------------------------------------------------------------------------
#// Build one project, and make the alias. Parameters are project path, target name, shared library
#// name, make shlb alias (boolean), make xSYM alias (boolean), and is component (boolean).
#//--------------------------------------------------------------------------------------------------
sub BuildOneProjectWithOutput($$$$$$)
{
my ($project_path, $target_name, $output_name, $alias_lib, $alias_xSYM, $component) = @_;
unless ($project_path =~ m/^$main::BUILD_ROOT.+/) { return; }
my (@suffix_list) = (".mcp", ".xml");
my ($project_name, $project_dir, $suffix) = fileparse($project_path, @suffix_list);
if ($suffix eq "") { die "Error: Project, $project_path must end in .xml or .mcp\n"; }
my($dist_dir) = GetBinDirectory();
# Put libraries in "Essential Files" folder, Components in "Components" folder
my($output_dir) = $component ? "Components:" : "Essential Files:";
my($output_path) = $dist_dir.$output_dir;
if ($main::options{static_build})
{
if ($output_name =~ /\.o$/ || $output_name =~ /\.[Ll]ib$/)
{
$alias_xSYM = 0;
$alias_lib = 1;
$output_path = $main::DEBUG ? ":mozilla:dist:static_libs_debug:" : ":mozilla:dist:static_libs:";
}
}
# if the flag is on to export projects to XML, export and munge them
if ($main::EXPORT_PROJECTS && !($project_path =~ /IDL\.mcp$/))
{
my $xml_out_path = $project_path;
$xml_out_path =~ s/\.mcp$/\.xml/;
# only do this if project is newer?
if (! -e $xml_out_path)
{
ExportProjectToXML(full_path_to($project_path), full_path_to($xml_out_path));
ProcessProjectXML($xml_out_path);
}
}
# if the flag is set to use XML projects, default to XML if the file
# is present.
if ($main::USE_XML_PROJECTS && !($project_path =~ /IDL\.mcp$/))
{
my $xml_project_path = $project_dir.$project_name.".xml";
if (-e $xml_project_path)
{
$project_path = $xml_project_path;
$suffix = ".xml";
}
}
if ($suffix eq ".xml")
{
my($xml_path) = $project_path;
# Prepend an "_" onto the name of the generated project file so it doesn't conflict
$project_path = $project_dir . "_" . $project_name . ".mcp";
my($project_modtime) = (-e $project_path ? GetFileModDate($project_path) : 0);
my($xml_modtime) = (-e $xml_path ? GetFileModDate($xml_path) : 0);
if ($xml_modtime > $project_modtime)
{
print("Importing $project_path from $project_name.xml.\n");
unlink($project_path);
# Might want to delete the "xxx.mcp Data" dir ???
ImportXMLProject(full_path_to($xml_path), full_path_to($project_path));
}
}
if ($main::CLOBBER_LIBS)
{
unlink "$project_dir$output_name"; # it's OK if these fail
unlink "$project_dir$output_name.xSYM";
}
DoBuildProject($project_path, $target_name, $main::CLOBBER_PROJECTS);
$alias_lib ? MakeAlias("$project_dir$output_name", "$output_path") : 0;
$alias_xSYM ? MakeAlias("$project_dir$output_name.xSYM", "$output_path") : 0;
}
#//--------------------------------------------------------------------------------------------------
#// For compatiblity with existing scripts, BuildOneProject now just calls
#// BuildOneProjectWithOutput, with the output name and target name identical.
#// Note that this routine assumes that the target name and the shared libary name
#// are the same.
#//--------------------------------------------------------------------------------------------------
sub BuildOneProject($$$$$)
{
my ($project_path, $target_name, $alias_lib, $alias_xSYM, $component) = @_;
BuildOneProjectWithOutput($project_path, $target_name, $target_name,
$alias_lib, $alias_xSYM, $component);
}
#//--------------------------------------------------------------------------------------------------
#// For compatiblity with existing scripts, BuildProject now just calls
#// BuildOneProjectWithOutput, with the output name and target name identical.
#// Note that this routine assumes that the target name and the shared libary name
#// are the same. No aliases of the output are made.
#//--------------------------------------------------------------------------------------------------
sub BuildProject($$)
{
my ($project_path, $target_name) = @_;
BuildOneProjectWithOutput($project_path, $target_name, $target_name, 0, 0, 0);
}
#//--------------------------------------------------------------------------------------------------
#// Identical to BuildProject but clobbers the project before building it.
#//--------------------------------------------------------------------------------------------------
sub BuildProjectClean($$)
{
my ($project_path, $target_name) = @_;
my ($save_clobber_flag) = $main::CLOBBER_PROJECTS;
$main::CLOBBER_PROJECTS = 1;
BuildOneProjectWithOutput($project_path, $target_name, $target_name, 0, 0, 0);
$main::CLOBBER_PROJECTS = $save_clobber_flag;
}
#//--------------------------------------------------------------------------------------------------
#// Make resource aliases for one directory
#//--------------------------------------------------------------------------------------------------
sub BuildFolderResourceAliases($$)
{
my($src_dir, $dest_dir) = @_;
# get a list of all the resource files
opendir(SRCDIR, $src_dir) || die("can't open $src_dir");
my(@resource_files) = readdir(SRCDIR);
closedir(SRCDIR);
# make aliases for each one into the dest directory
print("Placing aliases to all files from $src_dir in $dest_dir\n");
for ( @resource_files )
{
next if $_ eq "CVS";
#print(" Doing $_\n");
if (-l $src_dir.$_)
{
print(" $_ is an alias\n");
next;
}
my($file_name) = $src_dir . $_;
MakeAlias($file_name, $dest_dir);
}
}
#//--------------------------------------------------------------------------------------------------
#// DelayFor
#//
#// Delay for the given number of seconds, allowing the script to be cancelled
#//--------------------------------------------------------------------------------------------------
sub DelayFor($)
{
my($delay_secs) = @_;
STDOUT->autoflush(1);
my($end_time) = time() + $delay_secs;
my($last_time) = 0;
my($cur_time) = time();
while ($cur_time < $end_time)
{
$cur_time = time();
if ($cur_time > $last_time)
{
print ".";
$last_time = $cur_time;
}
WaitNextEvent();
}
print "\n";
STDOUT->autoflush(0);
}
#//--------------------------------------------------------------------------------------------------
#// TimeStart
#//--------------------------------------------------------------------------------------------------
sub TimeStart()
{
return time();
}
#//--------------------------------------------------------------------------------------------------
#// TimeEnd
#//--------------------------------------------------------------------------------------------------
sub TimeEnd($$)
{
use integer;
my($start_time, $operation_name) = @_;
my($end_time) = time();
my($tot_sec) = $end_time - $start_time;
my($seconds) = $tot_sec;
my($hours) = $seconds / (60 * 60);
$seconds -= $hours * (60 * 60);
my($minutes) = $seconds / 60;
$seconds -= $minutes * 60;
print "$operation_name took $hours hours $minutes minutes and $seconds seconds\n";
}
#//--------------------------------------------------------------------------------------------------
#// Remove all files from a tree, leaving directories intact (except "CVS").
#//--------------------------------------------------------------------------------------------------
sub EmptyTree($)
{
my ($root) = @_;
#print "EmptyTree($root)\n";
opendir(DIR, $root);
my $sub;
foreach $sub (readdir(DIR))
{
my $fullpathname = $root.$sub; # -f, -d only work on full paths
# Don't call empty tree for the alias of a directory.
# -d returns true for the alias of a directory, false for a broken alias)
if (-d $fullpathname)
{
if (-l $fullpathname) # delete aliases
{
unlink $fullpathname;
next;
}
EmptyTree($fullpathname.":");
if ($sub eq "CVS")
{
#print "rmdir $fullpathname\n";
rmdir $fullpathname;
}
}
else
{
unless (unlink $fullpathname) { die "Failed to delete $fullpathname\n"; }
}
}
closedir(DIR);
}
#//--------------------------------------------------------------------------------------------------
#// Recurse through a directory hierarchy, looking for MANIFEST files.
#// Currently unused.
#//--------------------------------------------------------------------------------------------------
sub ScanForManifestFiles($$$$)
{
my($dir, $theme_root, $theme_name, $dist_dir) = @_;
opendir(DIR, $dir) or die "Cannot open dir $dir\n";
my @files = readdir(DIR);
closedir DIR;
my $file;
foreach $file (@files)
{
my $filepath = $dir.":".$file;
if (-d $filepath)
{
# print "Looking for MANIFEST files in $filepath\n";
ScanForManifestFiles($filepath, $theme_root, $theme_name, $dist_dir);
}
elsif ($file eq "MANIFEST")
{
# print "Doing manifest file $filepath\n";
# Get the dest path from the first line of the file
open(MANIFEST, $filepath) || die "Could not open file $file";
# Read in the path if available
my($dest_line) = <MANIFEST>;
chomp $dest_line;
close MANIFEST;
$dest_line =~ s|^#!dest[\t ]+|| || die "No destination line found in $filepath\n";
my($dest_path) = $dist_dir."chrome:skins:$theme_name:$dest_line";
# print " Destination is $dest_path\n";
InstallResources($filepath, "$dest_path", 0);
}
}
}
#-----------------------------------------------
# SetupBuildLog
#-----------------------------------------------
sub SetupBuildLog($$)
{
my($logfile_path, $timestamped_log) = @_;
my($logdir) = "";
my($logfile) = $logfile_path;
if ($logfile_path =~ /(.+?:)([^:]+)$/) # ? for non-greedy match
{
$logdir = $1;
$logfile = $2;
mkpath($logdir);
}
if ($timestamped_log)
{
#Use time-stamped names so that you don't clobber your previous log file!
my $now = localtime();
while ($now =~ s@:@.@) {} # replace all colons by periods
OpenErrorLog("${logdir}${now}");
}
else
{
OpenErrorLog("${logdir}${logfile}");
}
}
#-----------------------------------------------
# SetBuildNumber
#-----------------------------------------------
sub SetBuildNumber($$)
{
my($build_num_file, $files_to_touch) = @_;
# Make sure we add the config dir to search, to pick up mozBDate.pm
# Need to do this dynamically, because this module can be used before
# mozilla/config has been checked out.
my ($inc_path) = $0; # $0 is the path to the parent script
$inc_path =~ s/:build:mac:build_scripts:.+$/:config/;
push(@INC, $inc_path);
require mozBDate;
mozBDate::UpdateBuildNumber($build_num_file, $main::MOZILLA_OFFICIAL);
my($file);
foreach $file (@$files_to_touch)
{
print "Writing build number to $file from ${file}.in\n";
mozBDate::SubstituteBuildNumber($file, $build_num_file, "${file}.in");
}
}
#-----------------------------------------------
# SetTimeBomb
#-----------------------------------------------
sub SetTimeBomb($$)
{
my ($warn_days, $bomb_days) = @_;
system("perl :mozilla:config:mac-set-timebomb.pl $warn_days $bomb_days");
}
#//--------------------------------------------------------------------------------------------------
#// Regenerate a configuration header file if necessary
#//--------------------------------------------------------------------------------------------------
sub UpdateConfigHeader($)
{
my($config_path) = @_;
my($config, $oldconfig) = ("", "");
my($define, $definevalue, $defines);
my($k, $l,);
foreach $k (keys(%main::options))
{
if ($main::options{$k})
{
foreach $l (keys(%{$main::optiondefines{$k}}))
{
$my::defines{$l} = $main::optiondefines{$k}{$l};
print "Setting up my::defines{$l}\n";
}
}
}
my $config_headerfile = current_directory().$config_path;
if (-e $config_headerfile)
{
open(CONFIG_HEADER, "< $config_headerfile") || die "$config_headerfile: $!\n";
my($line);
while ($line = <CONFIG_HEADER>)
{
if ($line =~ m/#define\s+([^\s]*)\s+([^\s]*)\s*\n/)
{
$define = $1;
$definevalue = $2;
#canonicalize so that whitespace changes are not significant
my $canon_value = "#define " . $define . " " . $definevalue . "\n";
$oldconfig .= $canon_value;
if (exists ($my::defines{$define}) and ($my::defines{$define} == $definevalue))
{
delete $my::defines{$define};
$config .= $canon_value;
}
}
}
close(CONFIG_HEADER);
}
if (%my::defines)
{
foreach $k (keys(%my::defines))
{
$config .= "#define " . $k . " " . $my::defines{$k} . "\n";
}
}
my $file_name = basename($config_headerfile);
if (($config ne $oldconfig) || (!-e $config_headerfile))
{
printf("Writing new configuration header $file_name\n");
open(CONFIG_HEADER, "> $config_headerfile") || die "$config_headerfile: $!\n";
print(CONFIG_HEADER "/* This file is auto-generated based on build options. Do not edit. */\n");
print CONFIG_HEADER ($config);
close(CONFIG_HEADER);
MacPerl::SetFileInfo("CWIE", "TEXT", $config_headerfile);
}
else
{
printf("Configuration header $file_name is up-to-date\n");
}
}
1;

View File

@@ -1,660 +0,0 @@
#!perl
package Moz::CodeWarriorLib;
=pod
=head1 NAME
CodeWarriorLib - supply interface to CodeWarrior
=head1 SYNOPSIS
#!perl
use CodeWarriorLib;
CodeWarriorLib::activate();
$had_errors = CodeWarriorLib::build_project(
$project_path, $target_name, $recent_errors_file, $clean_build
);
=head1 DESCRIPTION
Replaces the AppleScript library I<CodeWarriorLib>.
=over 4
=cut
use strict;
use Cwd;
use File::Basename;
use Mac::Types;
use Mac::Events;
use Mac::AppleEvents;
use Mac::AppleEvents::Simple;
use Mac::Processes;
use Mac::MoreFiles;
use Mac::StandardFile;
use vars qw($VERSION);
$VERSION = '1.02';
my($app) = 'CWIE';
my($scriptDir) = cwd(); # could use $0 for this
my($ide_loc_file) = "";
# 0 == don't switch CWIE to front app in do_event(), 1 == do switch
# note: activate() still switches when called
$Mac::AppleEvents::Simple::SWITCH = 0;
# $Mac::AppleEvents::Simple::WARN = 1;
# supply your own path to the source here
#_test('PowerPudgeIV:mozilla:mozilla:');
# If you want to understand the gobbldeygook that's used to build Apple Events,
# you should start by reading the AEGizmos documentation.
=pod
=item _get_project($full_path)
A private routine returning a reference to the open project with the given name,
or else the empty string (when that project is not open)
full_path is a string identifying the project to be built and is of the form,
e.g., "HD:ProjectFolder:MyProject.mcp". It must be supplied.
=cut
sub _get_project ($) {
my(
$full_path, $candidate_projects
) = @_;
$candidate_projects = _doc_named(basename($full_path, '*'));
if ($candidate_projects) {
my($cps) = _get_dobj($candidate_projects);
my($num) = AECountItems($cps);
if ($num) { # is a list
foreach (1 .. AECountItems($cps)) {
my($cp) = AEGetNthDesc($cps, $_);
if (lc $full_path eq lc _full_path($cp)) {
return($cp);
}
}
} else { # is only one, not a list
if (lc $full_path eq lc _full_path($cps)) {
return($cps);
}
}
}
return;
}
=pod
=item build_project
Build a selected target of a project, saving any errors to a file, if supplied.
full_path is a string identifying the project to be built and is of the form,
e.g., "HD:ProjectFolder:MyProject.mcp". It must be supplied.
If target_name is the empty string, the current target of the selected project
will be built, else, target_name should be a string matching a target name in
the selected project.
If error_path is the empty string, errors will not be saved to a file,
else, error_path should be the full path of a file to save error messages into.
=cut
$CodeWarriorLib::CLOSE_PROJECTS_FIRST = 0; # If true we close then make. If false, make then close.
my $last_project_built = "";
my $last_project_was_closed = 0;
sub build_project ($;$$$) {
my(
$full_path, $target_name, $error_path,
$remove_object, $p, $project_was_closed, $had_errors
) = @_;
_close_errors_window();
if ($CodeWarriorLib::CLOSE_PROJECTS_FIRST && ($last_project_built ne $full_path))
{
# If we're in "close first" mode, we don't close if the current project
# is the same as the previous one.
if ($last_project_was_closed) {
$p = _get_project($last_project_built);
_close($p);
}
$last_project_built = $full_path;
$last_project_was_closed = 0; # now refers to the new project
}
$project_was_closed = 0;
while (1) {
$p = _get_project($full_path);
if (!$p) {
if ($project_was_closed) {
print "### Error - request for project document failed after opening\n";
die "### possibly CW Pro 4 bug: be sure to close your Find window\n";
}
$project_was_closed = 1;
$last_project_was_closed = 1;
_open_file($full_path);
} else {
last;
}
}
$had_errors = 0;
if ($target_name eq '') {
if ($remove_object) {_remove_object($p)}
_build($p);
} else {
if ($remove_object) {_remove_object($p, $target_name)}
_build($p, $target_name);
}
if ($error_path ne '') {
_save_errors_window($error_path);
}
$had_errors = _close_errors_window();
if (!$CodeWarriorLib::CLOSE_PROJECTS_FIRST)
{
if ($project_was_closed) {
$p = _get_project($full_path);
_close($p);
}
}
return($had_errors);
}
=pod
=item appIsRunning()
=cut
sub _appIsRunning($)
{
my ($appSignature) = @_;
my ($psi);
my ($found) = 0;
my ($appPSN);
foreach $psi (values(%Process))
{
if ($psi->processSignature() eq $appSignature)
{
$appPSN = $psi->processNumber();
$found = 1;
last;
}
}
return $found;
}
=pod
=item appIsFrontmost()
=cut
sub _appIsFrontmost($)
{
my ($appSignature) = @_;
my ($psi);
my ($found) = 0;
my ($appPSN);
foreach $psi (values(%Process))
{
if ($psi->processSignature() eq $appSignature)
{
$appPSN = $psi->processNumber();
$found = 1;
last;
}
}
return (GetFrontProcess() == $appPSN);
}
=pod
=item activate()
Launches CodeWarrior and brings it to the front.
Once found, path will be saved in $idepath_file for future reference.
Edit or delete this file to change the location of the IDE. If app is
moved, C<activate()> will prompt for a new location.
First looks for an open CodeWarrior app. Second, tries to open previously
saved location in ':idepath.txt'. Third, tries to find it and allow user
to choose it with Navigation Services (if present). Fourth, uses good old
GUSI routines built-in to MacPerl for a Choose Directory dialog box.
=cut
sub activate ($) {
$ide_loc_file = $_[0]; # save in global
my($filepath, $appath, $psi) = ($ide_loc_file);
foreach $psi (values(%Process)) {
if ($psi->processSignature() eq $app) {
$appath = $psi->processAppSpec();
_save_appath($filepath, $appath);
last;
}
}
if (!$appath || !-x $appath) {
$appath = _read_appath($filepath);
}
if (!$appath || ! -x $appath)
{
# make sure that MacPerl is a front process
#ActivateApplication('McPL');
MacPerl::Answer("Please locate the CodeWarrior application.", "OK");
# prompt user for the file name, and store it
my $macFile = StandardGetFile( 0, "APPL");
if ( $macFile->sfGood() )
{
$appath = $macFile->sfFile();
}
else
{
die "Operation canceled\n";
}
# if (eval {require Mac::Navigation}) {
# my($options, $nav);
# Mac::Navigation->import();
# $options = NavGetDefaultDialogOptions();
# $options->message('Where is CodeWarrior IDE?');
# $options->windowTitle('Find CodeWarrior IDE');
# $nav = NavChooseObject($Application{$app}, $options);
# die "CodeWarrior IDE not found.\n" if (!$nav || !$nav->file(1));
# $appath = $nav->file(1);
# } else {
# local(*D);
# my $cwd = `pwd`;
# $appath = _get_folder(
# 'Where is the CW IDE folder?',
# dirname($Application{$app})
# );
# die "CodeWarrior IDE not found.\n" if !$appath;
# opendir(D, $appath) or die $!;
# chdir($appath);
# foreach my $file (sort readdir (D)) {
# my(@app) = MacPerl::GetFileInfo($file);
# if ($app[0] && $app[1] &&
# $app[1] eq 'APPL' && $app[0] eq $app
# ) {
# $appath .= $file;
# last;
# }
# }
# chomp($cwd);
# chdir($cwd);
# }
_save_appath($filepath, $appath);
}
my($lp) = LaunchParam->new(
launchAppSpec => $appath,
launchControlFlags => launchContinue() + launchNoFileFlags()
);
unless (LaunchApplication($lp)) {
unlink($filepath);
die $^E;
}
# wait for CodeWarrior to show up in the list of processes
while (!_appIsRunning('CWIE'))
{
WaitNextEvent();
}
# wait for CodeWarrior to come to the front
while (!_appIsFrontmost('CWIE'))
{
WaitNextEvent();
}
}
=pod
=item getCodeWarriorPath()
Returns a file path relative to the CodeWarrior folder
=cut
sub getCodeWarriorPath($)
{
my($subfolder)=@_;
my($app_path) = _read_appath($ide_loc_file);
if ($app_path eq "") { die "Error: Failed to get CodeWarrior IDE path\n"; }
my($codewarrior_root) = $app_path;
$codewarrior_root =~ s/[^:]*$//;
return ($codewarrior_root . $subfolder);
}
=pod
=item getCodeWarriorIDEName()
Returns the name of the CodeWarrior application
=cut
sub getCodeWarriorIDEName()
{
my($subfolder)=@_;
my($app_path) = _read_appath($ide_loc_file);
if ($app_path eq "") { die "Error: Failed to get CodeWarrior IDE path\n"; }
my(@codewarrior_path) = split(/:/, $app_path);
return pop(@codewarrior_path);
}
=pod
=item quit()
Quits CodeWarrior.
=cut
sub quit() {
$last_project_built = "";
$last_project_was_closed = 0;
my($evt) = do_event(qw/aevt quit/, $app);
}
sub _build ($;$) {
my($evt);
if ($_[1]) {
my($prm) =
q"'----':obj {form:name, want:type(TRGT), seld:TEXT(@), from:" .
AEPrint($_[0]) . '}';
$evt = do_event(qw/CWIE MAKE/, $app, $prm, $_[1]);
} else {
my($prm) = q"'----':" . AEPrint($_[0]);
$evt = do_event(qw/CWIE MAKE/, $app, $prm);
}
}
sub _remove_object ($;$) {
my($evt);
if ($_[1]) {
my($prm) =
q"'----':obj {form:name, want:type(TRGT), seld:TEXT(@), from:" .
AEPrint($_[0]) . '}';
$evt = do_event(qw/CWIE RMOB/, $app, $prm, $_[1]);
} else {
my($prm) = q"'----':" . AEPrint($_[0]);
$evt = do_event(qw/CWIE RMOB/, $app, $prm);
}
}
sub _open_file ($) {
my($prm) =
q"'----':obj {form:name, want:type(alis), " .
q"seld:TEXT(@), from:'null'()}";
do_event(qw/aevt odoc/, $app, $prm, $_[0]);
}
sub import_project ($$) {
my($xml_file, $project_path) = @_;
my($prm) = "kocl:type(PRJD), rtyp:TEXT(@), data:TEXT(@), &subj:'null'()";
my($evt) = do_event(qw/core crel/, $app, $prm, $project_path, $xml_file);
my($result) = _get_event_result($evt);
if ($result eq "") {
_close(_get_project($project_path));
}
return $result;
}
sub export_project ($$) {
my($project_path, $xml_out_path) = @_;
my($p, $project_was_closed);
$project_was_closed = 0;
while (1) {
$p = _get_project($project_path);
if (!$p) {
if ($project_was_closed) {
print "### Error - request for project document failed after opening\n";
die "### possibly CW bug: be sure to close your Find window\n";
}
$project_was_closed = 1;
_open_file($project_path);
} else {
last;
}
}
# avoid problems with the Project Messages window
_close_named_window("Project Messages");
my($prm) =
q"'----':obj {form:indx, want:type(PRJD), " .
q"seld:1, from:'null'()}, kfil:TEXT(@)";
my($evt) = do_event(qw/CWIE EXPT/, $app, $prm, $xml_out_path);
if ($project_was_closed) {
$p = _get_project($project_path);
_close($p);
}
return _get_event_result($evt);
}
sub _doc_named ($) {
my($prm) =
q"'----':obj {form:test, want:type(docu), from:'null'(), " .
q"seld:cmpd{relo:'= ', 'obj1':obj {form:prop, want:type" .
q"(prop), seld:type(pnam), from:'exmn'()}, 'obj2':TEXT(@)}}";
my($evt) = do_event(qw/core getd/, $app, $prm, $_[0]);
return($evt->{REPLY} eq 'aevt\ansr{}' ? undef : $evt);
}
sub _full_path ($) {
my($obj) = $_[0];
my($prm) =
q"'----':obj {form:prop, want:type(prop), seld:type(FILE), " .
q"from:" . AEPrint($_[0]) . q"}, rtyp:type(TEXT)";
my($evt) = do_event(qw/core getd/, $app, $prm);
return MacPerl::MakePath(
MacUnpack('fss ', (
AEGetParamDesc($evt->{REP}, keyDirectObject()))->data()->get()
)
);
}
sub _save_errors_window ($) {
my($prm) =
q"'----':obj {form:name, want:type(alis), seld:TEXT(@), from:'null'()}";
do_event(qw/MMPR SvMs/, $app, $prm, $_[0]);
}
sub _close_errors_window () {
return _close_named_window('Errors & Warnings');
}
sub _close_named_window ($) {
my($window_name) = @_;
my($prm) =
q"'----':obj {form:name, want:type(cwin), " .
q"seld:TEXT(@), from:'null'()}";
my($evt) = do_event(qw/core clos/, $app, $prm, $window_name);
return($evt->{REPLY} eq 'aevt\ansr{}' ? 1 : 0);
}
sub _close () {
my($prm) = q"'----':" . AEPrint($_[0]);
do_event(qw/core clos/, $app, $prm);
}
sub _get_dobj ($) {
return(AEGetParamDesc($_[0]->{REP}, keyDirectObject()));
}
sub _get_folder ($$) {
require 'GUSI.ph';
my($prompt, $default) = @_;
MacPerl::Choose(
GUSI::AF_FILE(), 0, $prompt, '',
GUSI::CHOOSE_DIR() + ($default ? &GUSI::CHOOSE_DEFAULT : 0),
$default
);
}
sub _get_event_result ($)
{
my($evt) = @_;
my($result) = $evt->{ERROR};
if ( $result eq "" && $evt->{ERRNO} != 0 )
{
$result = "unknown error (".$evt->{ERRNO}.")";
}
return $result;
}
sub _save_appath ($$) {
my($cwd) = cwd(); # remember the current working dir
chdir($scriptDir); # change dir to the script dir
local(*F);
open(F, '>' . $_[0]) or die $!;
print F $_[1];
close(F);
chdir($cwd); # restore the cwd
}
sub _read_appath ($) {
my($filepath) = @_;
my($cwd) = cwd(); # remember the current working dir
chdir($scriptDir); # change dir to the script dir
if (! -e $filepath) {
return "";
}
local(*F);
open(F, $filepath);
my($appath) = <F>;
close(F);
chdir($cwd); # restore the cwd
return($appath);
}
sub _test ($) {
activate($ide_loc_file);
my($path) = $_[0];
build_project(
"${path}modules:xml:macbuild:XML.mcp", '',
"${path}build:mac:Mozilla.BuildLog.part"
);
}
1;
=pod
=back
=head1 HISTORY
=over 4
=item v1.02, September 23, 1998
Made fixes in finding and saving location of CodeWarrior IDE.
=item v1.01, June 1, 1998
Made fixes to C<chdir()> in C<activate()>, made C<activate()> more robust
in finding CodeWarrior IDE, added global variable to NOT switch to IDE
for each sent event, a few other fixes.
=item v1.00, May 30, 1998
First shot
=back
=head1 AUTHORS
Chris Nandor F<E<lt>pudge@pobox.comE<gt>>, and the author of the
original I<CodeWarriorLib>, Scott Collins F<E<lt>scc@netscape.comE<gt>>.
=head1 SEE ALSO
BuildProject L<Moz>.
=head1 COPYRIGHT
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Mozilla Communicator client code, 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.
Contributor(s):
=cut

View File

@@ -1,573 +0,0 @@
#!perl -w
package Moz::Jar;
#
# Module for creating jar files, either using a jar manifest, or
# simply jarring up folders on disk.
#
require 5.004;
require Exporter;
use strict;
use Archive::Zip;
use File::Path;
use Mac::Files;
use Moz::Moz;
use vars qw( @ISA @EXPORT );
@ISA = qw(Exporter);
@EXPORT = qw(
CreateJarFileFromDirectory
CreateJarFromManifest
WriteOutJarFiles
SanityCheckJarOptions
);
#-------------------------------------------------------------------------------
# Add the contents of a directory to the zip file
#
#-------------------------------------------------------------------------------
sub _addDirToJar($$$$)
{
my($dir, $jar_root, $zip, $compress) = @_;
opendir(DIR, $dir) or die "Error: Cannot open dir $dir\n";
my @files = readdir(DIR);
closedir DIR;
my $unix_jar_root = $jar_root;
$unix_jar_root =~ s|:|/|g; # colon to slash conversion
my $file;
foreach $file (@files)
{
my $filepath = $dir.":".$file;
if (-d $filepath)
{
print "Adding files to jar from $filepath\n";
_addDirToJar($filepath, $jar_root, $zip, $compress);
}
else
{
my $member = Archive::Zip::Member->newFromFile($filepath);
die "Error: Failed to create zip file member $filepath\n" unless $member;
my $unixName = $filepath;
$unixName =~ s|:|/|g; # colon to slash conversion
$unixName =~ s|^$unix_jar_root||; # relativise
$member->fileName($unixName);
# print "Adding $file as $unixName\n";
if ($compress) {
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_DEFLATED);
} else {
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_STORED);
}
$zip->addMember($member);
}
}
}
#-------------------------------------------------------------------------------
# Add the contents of a directory to the zip file
#
#-------------------------------------------------------------------------------
sub CreateJarFileFromDirectory($$$)
{
my($srcdir, $jarpath, $compress) = @_;
my $zip = Archive::Zip->new();
_addDirToJar($srcdir, $srcdir, $zip, $compress);
print "Saving zip file...\n";
my $status = $zip->writeToFileNamed($jarpath);
if ($status == 0) {
print "Zipping completed successfully\n";
} else {
print "Error saving zip file\n";
}
# set the file type/creator to something reasonable
MacPerl::SetFileInfo("ZIP ", "ZIP ", $jarpath);
}
#-------------------------------------------------------------------------------
# printZipContents
#
#-------------------------------------------------------------------------------
sub printZipContents($)
{
my($zip) = @_;
my(@members) = $zip->memberNames();
print "Zip contains:\n";
my($member);
foreach $member (@members)
{
print " $member\n";
}
}
#-------------------------------------------------------------------------------
# safeSaveJarFile
#
# Archive::Zip has a problem where you cannot save a zip file on top of
# an existing zip file that it has open, because it holds references
# into that zip. So we have to save to a temp file, then do a swap.
#
# Note that the zip will become invalid after this operation.
# If you want to do further operations on it, you'll have to reread it.
#-------------------------------------------------------------------------------
sub safeSaveJarFile($$)
{
my($zip, $full_dest_path) = @_;
my($temp_file_name) = $full_dest_path."_temp";
($zip->writeToFileNamed($temp_file_name) == Archive::Zip::AZ_OK) || die "Error: died writing jar to temp file $temp_file_name\n";
unlink $full_dest_path;
(rename $temp_file_name, $full_dest_path) || die "Error: Failed to rename $temp_file_name\n";
MacPerl::SetFileInfo("ZIP ", "ZIP ", $full_dest_path);
}
#-------------------------------------------------------------------------------
# addToJarFile
#
# Add a file to a jar file
#
# Parameters:
# 1. Jar ID. Unix path of jar file inside chrome.
# 2. Abs path to jar.mn file (i.e. source) (mac breaks)
# 3. File source, relative to jar.mn path (mac breaks)
# 4. Abs path to the resulting .jar file (mac breaks)
# 5. Relative file path within the jar (unix breaks)
# 6. Reference to hash of jar files
#
#-------------------------------------------------------------------------------
sub addToJarFile($$$$$$$)
{
my($jar_id, $jar_man_dir, $file_src, $jar_path, $file_jar_path, $override, $jars) = @_;
# print "addToJarFile with:\n $jar_man_dir\n $file_src\n $jar_path\n $file_jar_path\n";
unless ($jar_path =~ m/(.+:)([^:]+)$/) { die "Error: Bad jar path $jar_path\n"; }
my($target_dir) = $1;
my($jar_name) = $2;
$target_dir =~ s/[^:]+$//;
# print "¥ $target_dir $jar_name\n";
# find the source file
my($src) = $jar_man_dir.":".$file_src;
if ((!-e $src) && ($file_src =~ m/.+:([^:]+)$/)) # src does not exist. Fall back to looking for src in jar.mn dir
{
$file_src = $1;
$src = $jar_man_dir.":".$file_src;
if (!-e $src) {
die "Error: Can't find chrome file $src\n";
}
}
if ($main::options{chrome_jars})
{
my($zip) = $jars->{$jar_id};
unless ($zip) { die "Error: Can't find Zip entry for $jar_id\n"; }
# print "Adding $file_src to jar file $jar_path at $file_jar_path\n";
my($member) = Archive::Zip::Member->newFromFile($src);
unless ($member) { die "Error: Failed to create zip file member $src\n"; }
$member->fileName($file_jar_path);
my($compress) = 1;
if ($compress) {
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_DEFLATED);
$member->desiredCompressionLevel(Archive::Zip::COMPRESSION_LEVEL_DEFAULT); # defaults to 6
} else {
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_STORED);
}
my($old_member) = $zip->memberNamed($file_jar_path);
if ($override)
{
if ($old_member)
{
# print "Overriding $file_jar_path in jar file $jar_id\n";
# need to compare mod dates or use the + here
$zip->removeMember($old_member);
}
$zip->addMember($member);
}
else
{
if ($old_member)
{
#compare dates here
my($member_moddate) = $old_member->lastModTime();
my($file_moddate) = GetFileModDate($src);
if ($file_moddate > $member_moddate)
{
print "Updating older file $file_jar_path in $jar_id\n";
$zip->removeMember($old_member);
$zip->addMember($member);
}
else
{
print "File $file_jar_path in $jar_id is more recent. Not updating.\n";
}
}
else
{
$zip->addMember($member);
}
}
}
if ($main::options{chrome_files}) # we install raw files too
{
my($rel_path) = $file_jar_path;
$rel_path =~ s|/|:|g; # slash to colons
my($dir_name) = $jar_name;
$dir_name =~ s/\.jar$//;
my($dst) = $target_dir.$dir_name.":".$rel_path;
# print "Aliassing $src\n to\n$dst\n";
if ($override)
{
unlink $dst;
MakeAlias($src, $dst); # don't check errors, otherwise we fail on replacement
}
else
{
if (-e $dst)
{
#compare dates here
my($dst_moddate) = GetFileModDate($dst);
my($file_moddate) = GetFileModDate($src);
if ($file_moddate > $dst_moddate)
{
print "Updating older file $rel_path in $dir_name\n";
unlink $dst;
MakeAlias($src, $dst);
}
else
{
print "File $file_jar_path in $jar_id is more recent. Not updating.\n";
}
}
else
{
MakeAlias($src, $dst);
}
}
}
}
#-------------------------------------------------------------------------------
# setupJarFile
#
# setup a zip for writing
#-------------------------------------------------------------------------------
sub setupJarFile($$$)
{
my($jar_id, $dest_path, $jar_hash) = @_;
# print "Creating jar file $jar_id at $jar_path\n";
my($jar_file) = $jar_id;
$jar_file =~ s|/|:|g; # slash to colons
my($full_jar_path) = full_path_to($dest_path.":".$jar_file);
if ($main::options{chrome_jars})
{
my($zip) = $jar_hash->{$jar_id};
if (!$zip) # if we haven't made it already, do so
{
my($zip) = Archive::Zip->new();
$jar_hash->{$jar_id} = $zip;
# does the jar file exist already? If so, read it in
if (-e $full_jar_path)
{
print "Reading in jar file $jar_id\n";
if ($zip->read($full_jar_path) != Archive::Zip::AZ_OK) { die "Error: Failed to re-read $full_jar_path\n"; }
# printZipContents($zip);
}
}
}
else
{
# installing files.
# nothing to do. MakeAlias creates dirs as needed.
# add this jar to the list
$jar_hash->{$jar_id} = 1;
}
}
#-------------------------------------------------------------------------------
# closeJarFile
#
# We're done with this jar file _for this jar.mn_. We may add more entries
# to it later, so keep it open in the hash.
#-------------------------------------------------------------------------------
sub closeJarFile($$)
{
my($jar_path, $jar_hash) = @_;
# print "Closing jar file $jar_path\n";
if ($main::options{chrome_jars})
{
}
else
{
# installing files.
# nothing to do
}
}
#-------------------------------------------------------------------------------
# WriteOutJarFiles
#
# Now we dump out the jars
#-------------------------------------------------------------------------------
sub WriteOutJarFiles($$)
{
my($chrome_dir, $jars) = @_;
unless ($main::options{chrome_jars}) { return; }
my($full_chrome_path) = full_path_to($chrome_dir);
my($key);
foreach $key (keys %$jars)
{
my($zip) = $jars->{$key};
my($rel_path) = $key;
$rel_path =~ s/\//:/g;
my($output_path) = $full_chrome_path.":".$rel_path;
print "Writing zip file $key to $output_path\n";
# ensure the target dirs exist
my($path) = $output_path;
$path =~ s/[^:]+$//;
mkpath($path);
# unlink $output_path; # remove any existing jar
safeSaveJarFile($zip, $output_path);
# $zip is invalid after this operation, so nuke it here
$jars->{$key} = 0;
}
}
#-------------------------------------------------------------------------------
# registerChromePackage
#
# Enter a chrome package into the installed-chrome.txt file
#-------------------------------------------------------------------------------
sub registerChromePackage($$$$$$)
{
my($jar_file, $file_path, $chrome_dir, $jar_hash, $chrome_type, $pkg_name) = @_;
my($manifest_subdir) = $jar_file;
$manifest_subdir =~ s/:/\//g;
my($chrome_entry);
if ($main::options{use_jars}) {
$chrome_entry = "$chrome_type,install,url,jar:resource:/chrome/$manifest_subdir!/$chrome_type/$pkg_name";
} else {
$manifest_subdir =~ s/\.jar$//;
$chrome_entry = "$chrome_type,install,url,resource:/chrome/$manifest_subdir/$chrome_type/$pkg_name";
}
# print "Entering $chrome_entry in installed-chrome.txt\n";
# ensure chrome_dir exists
mkpath($chrome_dir);
my($inst_chrome) = ${chrome_dir}.":installed-chrome.txt";
if (open(CHROMEFILE, "<$inst_chrome")) {
while (<CHROMEFILE>) {
chomp;
if ($_ eq $chrome_entry) {
# $chrome_entry already appears in installed-chrome.txt file
# just update the mod date
my $now = time;
utime($now, $now, $inst_chrome) || die "Error: Couldn't touch $inst_chrome";
print "+++ updating chrome $inst_chrome\n+++\t\t$chrome_entry\n";
close(CHROMEFILE) || die "Error: can't close $inst_chrome: $!";
return 0;
}
}
close(CHROMEFILE) || die "Error: can't close $inst_chrome: $!";
}
open(CHROMEFILE, ">>${inst_chrome}") || die "Error: Failed to open $inst_chrome\n";
print(CHROMEFILE "${chrome_entry}\n");
close(CHROMEFILE) || die "Error: Failed to close $inst_chrome\n";
print "+++ adding chrome $inst_chrome\n+++\t\t$chrome_entry\n";
}
#-------------------------------------------------------------------------------
# Create or add to a jar file from a jar.mn file.
# Both arguments are relative to the mozilla root dir.
#
#
#-------------------------------------------------------------------------------
sub CreateJarFromManifest($$$)
{
my($jar_man_path, $dest_path, $jars) = @_;
if ($main::options{chrome_jars}) {
print "Jarring from $jar_man_path\n";
}
if ($main::options{chrome_files}) {
print "Installing files from $jar_man_path\n";
}
$jar_man_path = full_path_to($jar_man_path);
$dest_path = full_path_to($dest_path);
# if the jars hash is empty, nuke installed-chrome.txt
if (! scalar(%$jars))
{
print "Nuking installed-chrome.txt\n";
my($installed_chrome) = $dest_path.":installed-chrome.txt";
# unlink $installed_chrome;
}
my $jar_man_dir = "";
my $jar_man_file = "";
if ($jar_man_path =~ /(.+):([^:]+)$/)
{
$jar_man_dir = $1; # no trailing :
$jar_man_file = $2;
}
# Keep a hash of jar files, keyed on relative jar path (e.g. "packages/core.jar")
# Entries are open Archive::Zips (if zipping), and installed-chrome entries.
my($jar_id) = ""; # Current foo/bar.jar from jar.mn file
my($jar_file) = ""; # relative path to jar file (from $dest_path), with mac separators
my($full_jar_path);
open(FILE, "<$jar_man_path") || die "Error: could not open \"$jar_man_path\": $!";
while (<FILE>)
{
my($line) = $_;
chomp($line);
# print "$line\n";
if ($line =~ /^\s*\#.*$/) { # skip comments
next;
}
if ($line =~/^([\w\d.\-\_\\\/]+)\:\s*$/) # line start jar file entries
{
$jar_id = $1;
$jar_file = $jar_id;
$jar_file =~ s|/|:|g; # slash to colons
$full_jar_path = $dest_path.":".$jar_file;
setupJarFile($jar_id, $dest_path, $jars);
}
elsif ($line =~ /^(\+?)\s+([\w\d.\-\_\\\/]+)\s*(\([\w\d.\-\_\\\/]+\))?$\s*/) # jar file entry
{
my($override) = ($1 eq "+");
my($file_dest) = $2;
my($file_src) = $3;
if ($file_src) {
$file_src = substr($file_src, 1, -1); #strip the ()
} else {
$file_src = $file_dest;
}
$file_src =~ s|/|:|g;
if ($jar_file ne "") # if jar is open, add to jar
{
if ($file_dest =~ /([\w\d.\-\_]+)\/([\w\d.\-\_\\\/]+)contents.rdf/)
{
my $chrome_type = $1;
my $pkg_name = $2;
registerChromePackage($jar_file, $file_dest, $dest_path, $jars, $chrome_type, $pkg_name);
}
addToJarFile($jar_id, $jar_man_dir, $file_src, $full_jar_path, $file_dest, $override, $jars);
}
else
{
die "Error: bad jar.mn format at $line\n";
}
}
elsif ($line =~ /^\s*$/ ) # blank line
{
if ($jar_file ne "") #if a jar file is open, close it
{
closeJarFile($full_jar_path, $jars);
$jar_file = "";
$full_jar_path = "";
}
}
}
close(FILE);
if ($jar_file ne "") #if a jar file is open, close it
{
closeJarFile($full_jar_path, $jars);
}
}
1;

View File

@@ -1,228 +0,0 @@
#!perl -w
package Moz::MacCVS;
# package Mac::Apps::MacCVS; this should really be the name of the package
# but due to our directory hierarchy in mozilla, I am not doing it
require 5.004;
require Exporter;
use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT);
use Cwd;
use File::Basename;
use Mac::StandardFile;
use Mac::AppleEvents;
use Mac::AppleEvents::Simple;
@ISA = qw(Exporter);
@EXPORT = qw(new describe checkout update);
$VERSION = "1.00";
# If you want to understand the gobbldeygook that's used to build Apple Events,
# you should start by reading the AEGizmos documentation.
# Architecture:
# cvs session object:
# name - session name
# session_file - session file
#
#
my($last_error) = 0;
my($gAppSig) = 'Mcvs'; # MacCVS Pro
#
# utility routines
#
sub _checkForEventError($)
{
my($evt) = @_;
if ($evt->{ERRNO} != 0)
{
print STDERR "Error. Script returned '$evt->{ERROR} (error $evt->{ERRNO})\n";
$last_error = $evt->{ERRNO};
return 0;
}
return 1; # success
}
#
# Session object methods
#
sub new
{
my ( $proto, $session_file) = @_;
my $class = ref($proto) || $proto;
my $self = {};
if ( defined($session_file) && ( -e $session_file) )
{
$self->{"name"} = basename( $session_file );
$self->{"session_file"} = $session_file;
bless $self, $class;
return $self;
}
else
{
print STDERR "MacCVS->new cvs file < $session_file > does not exist\n";
return;
}
}
# makes sure that the session is open
# assertSessionOpen()
# returns 1 on success
sub assertSessionOpen()
{
my ($self) = shift;
$last_error = 0;
my($prm) =
q"'----':obj {form:name, want:type(alis), seld:TEXT(@), from:'null'()}";
my($evt) = do_event(qw/aevt odoc/, $gAppSig, $prm, $self->{session_file});
return _checkForEventError($evt);
}
# prints the cvs object, used mostly for debugging
sub describe
{
my($self) = shift;
$last_error = 0;
print "MacCVS:: name: ", $self->{name}, " session file: ", $self->{session_file}, "\n";
}
# checkout( self, module, revision, date)
# MacCVS checkout command
# returns 1 on success.
sub checkout()
{
my($self, $module, $revision, $date ) = @_;
unless( defined ($module) ) { $module = ""; } # get rid of the pesky undefined warnings
unless( defined ($revision) ) { $revision = ""; }
unless( defined ($date) ) { $date = ""; }
$last_error = 0;
$self->assertSessionOpen() || die "Error: failed to open MacCVS session file at $self->{session_file}\n";
my($revstring) = ($revision ne "") ? $revision : "(none)";
my($datestring) = ($date ne "") ? $date : "(none)";
print "Checking out $module with revision $revstring, date $datestring\n";
my($prm) =
q"'----':obj {form:name, want:type(docu), seld:TEXT(@), from:'null'()}, ".
q"modl:'TEXT'(@), tagr:'TEXT'(@), tagd:'TEXT'(@) ";
my($evt) = do_event(qw/MCvs cout/, $gAppSig, $prm, $self->{name}, $module, $revision, $date);
return _checkForEventError($evt);
}
# update( self, branch tag, list of paths)
# MacCVS udate command
# returns 1 on success.
# NOTE: MacCVS Pro does not correctly support this stuff yet (as of version 2.7d5).
sub update()
{
my($self, $branch, $paths ) = @_;
$last_error = 0;
$self->assertSessionOpen() || die "Error: failed to open MacCVS session file at $self->{session_file}\n";
if ($branch eq "HEAD") {
$branch = "";
}
my($paths_list) = "";
my($path);
foreach $path (@$paths)
{
if ($paths_list ne "") {
$paths_list = $paths_list.", ";
}
$paths_list = $paths_list."Ò".$path."Ó";
}
my($prm) =
q"'----':obj {form:name, want:type(docu), seld:TEXT(@), from:'null'()}, ".
q"tagr:'TEXT'(@), tFls:[";
$prm = $prm.$paths_list."]";
my($evt) = do_event(qw/MCvs updt/, $gAppSig, $prm, $self->{name}, $branch);
return _checkForEventError($evt);
};
sub getLastError()
{
return $last_error;
}
1;
=pod
=head1 NAME
MacCVS - Interface to MacCVS
=head1 SYNOPSIS
use MacCVS;
$session = MacCVS->new( <session_file_path>) || die "cannot create session";
$session->checkout([module] [revision] [date]) || die "Could not check out";
=head1 DESCRIPTION
This is a MacCVS interface for talking to MacCVS Pro client.
MacCVSSession is the class used to manipulate the session
=item new
MacCVS->new( <cvs session file path>);
Creates a new session. Returns undef on failure.
=item checkout( <module> [revision] [date] )
cvs checkout command. Revision and date are optional
returns 0 on failure
=cut
=head1 SEE ALSO
=over
=item MacCVS Home Page
http://www.maccvs.org/
=back
=head1 AUTHORS
Aleks Totic atotic@netscape.com
Simon Fraser sfraser@netscape.com
=cut
__END__

View File

@@ -1,603 +0,0 @@
=head1 NAME
B<Moz> - routines for automating CodeWarrior builds, and some extra-curricular
activities related to building Mozilla
=head1 SYNOPSIS
use Moz;
OpenErrorLog(":::BuildLog");
StopForErrors();
$Moz::QUIET = 1;
InstallFromManifest(":projects:MANIFEST", $dist_dir);
BuildProjectClean(":projects:SomeProject.mcp", "SomeTarget");
MakeAlias(":projects:SomeProject.shlb", $dist_dir);
DontStopForErrors();
BuildProject(":projects:SomeOtherProject.mcp", "SomeTarget");
=head1 DESCRIPTION
B<Moz> comprises the routines needed to slap CodeWarrior around, force it
to build a sequence of projects, report the results, and a few other things.
This module should only contain functions that are generic to any build,
not just the Mozilla build.
=cut
package Moz::Moz;
require Exporter;
use Cwd;
use File::Copy;
use File::Path;
use File::Basename;
use Mac::Types;
use Mac::Events;
use Mac::Processes;
use ExtUtils::Manifest 'maniread';
use Moz::CodeWarriorLib;
@ISA = qw(Exporter);
@EXPORT = qw( LaunchCodeWarrior
GetCodeWarriorRelativePath
current_directory
full_path_to
DoBuildProject
ImportXMLProject
ExportProjectToXML
OpenErrorLog
MakeAlias
GetFileModDate
StopForErrors
DontStopForErrors
InstallFromManifest
InstallResources
RedirectOutputToFile
Delay
ActivateApplication
IsProcessRunning);
@EXPORT_OK = qw(CloseErrorLog QUIET);
sub current_directory()
{
my $current_directory = cwd();
chop($current_directory) if ( $current_directory =~ m/:$/ );
return $current_directory;
}
sub full_path_to($)
{
my ($path) = @_;
if ( $path =~ m/^[^:]+$/ )
{
$path = ":" . $path;
}
if ( $path =~ m/^:/ )
{
$path = current_directory() . $path;
}
return $path;
}
$logging = 0;
$recent_errors_file = "";
$stop_on_1st_error = 1;
$QUIET = 0;
=head2 Logging all the errors and warnings - C<OpenErrorLog($log_file)>, C<CloseErrorLog()>
The warnings and errors generated in the course of building projects can be logged to a file.
Tinderbox uses this facility to show why a remote build failed.
Logging is off by default.
Start logging at any point in your build process with C<OpenErrorLog($log_file)>.
Stop with C<CloseErrorLog()>.
You never need to close the log explicitly, unless you want to just log a couple of projects in the middle of a big list.
C<CloseErrorLog()> is not exported by default.
=cut
sub CloseErrorLog()
{
if ( $logging )
{
close(ERROR_LOG);
$logging = 0;
StopForErrors() if $stop_on_1st_error;
}
}
sub OpenErrorLog($)
{
my ($log_file) = @_;
CloseErrorLog();
if ( $log_file )
{
$log_file = full_path_to($log_file);
open(ERROR_LOG, ">$log_file") || die "Error: Can't open $log_file\n";
MacPerl::SetFileInfo("CWIE", "TEXT", $log_file);
$log_file =~ m/.+:(.+)/;
$recent_errors_file = full_path_to("$1.part");
$logging = 1;
}
}
=head2 Stopping before it's too late - C<StopForErrors()>, C<DontStopForErrors()>
When building a long list of projects, you decide whether to continue building subsequent projects when one fails.
By default, your build script will C<die> after the first project that generates an error while building.
Change this behavior with C<DontStopForErrors()>.
Re-enable it with C<StopForErrors()>.
=cut
sub StopForErrors()
{
$stop_on_1st_error = 1;
# Can't stop for errors unless we notice them.
# Can't notice them unless we are logging.
# If the user didn't explicitly request logging, log to a temporary file.
if ( ! $recent_errors_file )
{
OpenErrorLog("${TMPDIR}BuildResults");
}
}
sub DontStopForErrors()
{
$stop_on_1st_error = 0;
}
sub log_message($)
{
if ( $logging )
{
my ($message) = @_;
print ERROR_LOG $message;
}
}
sub log_message_with_time($)
{
if ( $logging )
{
my ($message) = @_;
my $time_stamp = localtime();
log_message("$message ($time_stamp)\n");
}
}
sub log_recent_errors($)
{
my ($project_name) = @_;
my $found_errors = 0;
if ( $logging )
{
open(RECENT_ERRORS, "<$recent_errors_file");
while( <RECENT_ERRORS> )
{
if ( /^Error/ || /^CouldnÕt find project file/ || /^Link Error/ )
{
# if (!$found_errors)
# print $_;
$found_errors = 1;
}
print ERROR_LOG $_;
}
close(RECENT_ERRORS);
unlink("$recent_errors_file");
}
if ( $stop_on_1st_error && $found_errors )
{
print ERROR_LOG "### Build failed.\n";
die "### Errors encountered building \"$project_name\".\n";
}
}
sub DoBuildProject($$$)
{
my ($project_path, $target_name, $clean_build) = @_;
$project_path = full_path_to($project_path);
# $project_path =~ m/.+:(.+)/;
# my $project_name = $1;
log_message_with_time("### Building \"$project_path\"");
# Check that the given project exists
if (! -e $project_path)
{
print ERROR_LOG "### Build failed.\n";
die "### Can't find project file \"$project_path\".\n";
}
print "Building \"$project_path\[$target_name\]\"\n";
$had_errors = Moz::CodeWarriorLib::build_project(
$project_path, $target_name, $recent_errors_file, $clean_build
);
WaitNextEvent();
# $had_errors =
#MacPerl::DoAppleScript(<<END_OF_APPLESCRIPT);
# tell (load script file "$CodeWarriorLib") to BuildProject("$project_path", "$project_name", "$target_name", "$recent_errors_file", $clean_build)
#END_OF_APPLESCRIPT
# Append any errors to the globally accumulated log file
# if ( $had_errors ) # Removed this test, because we want warnings, too. -- jrm
{
log_recent_errors($project_path);
}
}
sub ImportXMLProject($$)
{
my ($xml_path, $project_path) = @_;
# my ($codewarrior_ide_name) = Moz::CodeWarriorLib::getCodeWarriorIDEName();
# my $ascript = <<EOS;
# tell application "$codewarrior_ide_name"
# make new (project document) as ("$project_path") with data ("$xml_path")
# end tell
#EOS
# print $ascript."\n";
# my($result) = MacPerl::DoAppleScript($ascript);
# unless ($result) { die "Error: ImportXMLProject AppleScript failed $^E $result\n"; }
#
my($import_error) = Moz::CodeWarriorLib::import_project($xml_path, $project_path);
if ($import_error ne "") {
die "Error: ImportXMLProject failed with error $import_error\n";
}
}
sub ExportProjectToXML($$)
{
my ($project_path, $xml_path) = @_;
my (@suffix_list) = (".mcp");
my ($project_name, $project_dir, $suffix) = fileparse($project_path, @suffix_list);
if ($suffix eq "") { die "Project: $project_path doesn't look like a project file.\n"; }
if (-e $xml_path) {
print "$xml_path exists - not exporting $project_path\n";
}
else {
print "Exporting $project_path to $xml_path\n";
my($export_error) = Moz::CodeWarriorLib::export_project($project_path, $xml_path);
if ($export_error ne "") {
die "Error: export_project failed with error '$export_error'\n";
}
if (! -e $xml_path) {
die "Error: XML export to $xml_path failed\n";
}
}
}
=head2 Miscellaneous
C<MakeAlias($old_file, $new_file)> functions like C<symlink()>, except with better argument defaulting and more explicit error messages.
=cut
sub MakeAlias($$)
{
my ($old_file, $new_file) = @_;
# if the directory to hold $new_file doesn't exist, create it
if ( ($new_file =~ m/(.+:)/) && !-d $1 )
{
mkpath($1);
}
# if a leaf name wasn't specified for $new_file, use the leaf from $old_file
if ( ($new_file =~ m/:$/) && ($old_file =~ m/.+:(.+)/) )
{
$new_file .= $1;
}
my $message = "Can't create a Finder alias (at \"$new_file\")\n for \"$old_file\"; because ";
die "Error: $message \"$old_file\" doesn't exist.\n" unless -e $old_file;
die "Error: $message I won't replace an existing (non-alias) file with an alias.\n" if ( -e $new_file && ! -l $new_file );
# now: $old_file exists; $new_file doesn't (or else, is an alias already)
if ( -l $new_file )
{
# ...then see if it already points to $old_file
my $current_target = full_path_to(readlink($new_file));
my $new_target = full_path_to($old_file);
return if ( $current_target eq $new_target );
# if the desired alias already exists and points to the right thing, then we're done
unlink $new_file;
}
symlink($old_file, $new_file) || die "Error: $message symlink returned an unexpected error.\n";
}
=pod
C<InstallFromManifest()>
=cut
sub InstallFromManifest($;$$)
{
my ($manifest_file, $dest_dir, $flat) = @_;
$flat = 0 unless defined($flat); # if $flat, all rel. paths in MANIFEST get aliased to the root of $dest_dir
$dest_dir ||= ":";
$manifest_file =~ m/(.+):/;
my $source_dir = $1;
chop($dest_dir) if $dest_dir =~ m/:$/;
#Mac::Events->import();
WaitNextEvent();
if ($flat)
{
print "Doing manifest on \"$manifest_file\" FLAT\n" unless $QUIET;
}
else
{
print "Doing manifest on \"$manifest_file\"\n" unless $QUIET;
}
my $read = maniread(full_path_to($manifest_file));
foreach $file (keys %$read)
{
next unless $file;
$subdir = ":";
if (!$flat && ($file =~ /:.+:/ ))
{
$subdir = $&;
}
$file = ":$file" unless $file =~ m/^:/;
MakeAlias("$source_dir$file", "$dest_dir$subdir");
}
}
=pod
C<InstallResources()>
=cut
# parameters are path to MANIFEST file, destination dir, true (to make copies) or false (to make aliases)
sub InstallResources($;$;$)
{
my ($manifest_file, $dest_dir, $copy_files) = @_;
$dest_dir ||= ":";
mkpath($dest_dir) if !-d $dest_dir;
$manifest_file =~ m/(.+):/;
my $source_dir = $1;
chop($dest_dir) if $dest_dir =~ m/:$/;
WaitNextEvent();
print "Installing resources from \"$manifest_file\"\n" unless $QUIET;
my $read = maniread(full_path_to($manifest_file));
foreach $file (keys %$read)
{
next unless $file;
if ($copy_files)
{
copy("$source_dir:$file", "$dest_dir:$file");
}
else
{
MakeAlias("$source_dir:$file", "$dest_dir:$file");
}
}
}
#//--------------------------------------------------------------------------------------------------
#// Delay
#//--------------------------------------------------------------------------------------------------
sub Delay($)
{
my ($delay_seconds) = @_;
$now = time;
$exit_time = $now + $delay_seconds;
while ($exit_time > $now) {
$now = time;
}
}
#//--------------------------------------------------------------------------------------------------
#// GetFileModDate
#//--------------------------------------------------------------------------------------------------
sub GetFileModDate($)
{
my($filePath)=@_;
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = stat($filePath);
return $mtime;
}
#//--------------------------------------------------------------------------------------------------
#// LaunchCodeWarrior
#//--------------------------------------------------------------------------------------------------
sub LaunchCodeWarrior($)
{
my($idepath_file) = @_; # full path to IDE location file
my($cur_dir) = cwd();
# this both launches and writes the IDE path file
Moz::CodeWarriorLib::activate($idepath_file);
chdir($cur_dir);
}
#//--------------------------------------------------------------------------------------------------
#// GetCodeWarriorRelativePath
#//--------------------------------------------------------------------------------------------------
sub GetCodeWarriorRelativePath($)
{
my($rel_path) = @_;
return Moz::CodeWarriorLib::getCodeWarriorPath($rel_path);
}
#//--------------------------------------------------------------------------------------------------
#// RedirectOutputToFile
#//--------------------------------------------------------------------------------------------------
sub RedirectOutputToFile($)
{
my($log_file) = @_;
# ensure that folders in the path exist
my($logdir) = "";
my($logfile) = $log_file;
if ($log_file =~ /(.+?:)([^:]+)$/) # ? for non-greedy match
{
$logdir = $1;
$logfile = $2;
mkpath($logdir);
}
print "Output is now being redirected to the file '$log_file'\n";
open(STDOUT, "> $log_file") || die "Can't redirect stdout";
open(STDERR, ">&STDOUT") || die "Can't dup stdout";
select(STDERR); $| = 1; # make unbuffered
select(STDOUT); $| = 1; # make unbuffered
MacPerl::SetFileInfo("CWIE", "TEXT", $log_file);
}
#//--------------------------------------------------------------------------------------------------
#// ActivateApplication
#//--------------------------------------------------------------------------------------------------
sub ActivateApplication($)
{
my ($appSignature) = @_;
my ($psi, $found);
my ($appPSN);
$found = 0;
foreach $psi (values(%Process))
{
if ($psi->processSignature() eq $appSignature)
{
$appPSN = $psi->processNumber();
$found = 1;
last;
}
}
if ($found == 0 || SameProcess($appPSN, GetFrontProcess()))
{
return;
}
SetFrontProcess($appPSN);
while (GetFrontProcess() != $appPSN)
{
WaitNextEvent();
}
}
#//--------------------------------------------------------------------------------------------------
#// IsProcessRunning
#//--------------------------------------------------------------------------------------------------
sub IsProcessRunning($)
{
my($processName, $psn, $psi) = @_;
while ( ($psn, $psi) = each(%Process) ) {
if ($psi->processName eq $processName) { return 1; }
}
return 0;
}
1;
=head1 AUTHORS
Scott Collins <scc@netscape.com>, Simon Fraser <sfraser@netscape.com>, Chris Yeh <cyeh@netscape.com>
=head1 SEE ALSO
BuildMozillaDebug.pl (et al), BuildList.pm, CodeWarriorLib (an AppleScript library)
=head1 COPYRIGHT
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Mozilla Communicator client code, 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.
Contributor(s):
=cut

View File

@@ -1,272 +0,0 @@
package Moz::Prefs;
require 5.004;
require Exporter;
# Package that attempts to read a file from the Preferences folder,
# and get build settings out of it
use strict;
use Exporter;
use File::Path;
use Mac::Files;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(ReadMozUserPrefs);
#-------------------------------------------------------------------------------
#
# GetPrefsFolder
#
#-------------------------------------------------------------------------------
sub GetPrefsFolder()
{
my($prefs_folder) = FindFolder(kOnSystemDisk, kPreferencesFolderType, 1);
return $prefs_folder.":Mozilla build prefs";
}
#-------------------------------------------------------------------------------
#
# SetArrayValue
#
#-------------------------------------------------------------------------------
sub SetArrayValue($$$)
{
my($array_ref, $index1, $index2) = @_;
my($index);
foreach $index (@$array_ref)
{
if ($index->[0] eq $index1)
{
$index->[1] = $index2;
return 1;
}
}
return 0;
}
#-------------------------------------------------------------------------------
#
# WriteDefaultPrefsFile
#
#-------------------------------------------------------------------------------
sub WriteDefaultPrefsFile($)
{
my($file_path) = @_;
my($file_contents);
$file_contents = <<'EOS';
% You can use this file to customize the Mozilla build system.
% The following kinds of lines are allowable:
% Comment lines, which start with a '%' in the first column
% Lines which modify the default build settings. For the list of flags,
% see MozBuildFlags.pm. Examples are:
%
% build pull 0 % don't pull
% options mng 1 % turn mng on
%
% Line containing the special 'buildfrom' flag, which specifies
% where to start the build. Example:
%
% buildfrom nglayout % where to start the build
%
% Lines which specify the location of the files used to store paths
% to the CodeWarrior IDE, and the MacCVS Pro session file. Note quoting
% of paths containing whitespace. Examples:
%
% filepath idepath ::codewarrior.txt
% filepath sessionpath ":Some folder:MacCVS session path.txt"
%
% Lines which modify the build settings like %main::DEBUG.
% Any lines which do not match either of the above are assumed
% to set variables on $main::. Examples:
%
% MOZILLA_OFFICIAL 1
%
EOS
$file_contents =~ s/%/#/g;
local(*PREFS_FILE);
open(PREFS_FILE, "> $file_path") || die "Could not write default prefs file\n";
print PREFS_FILE ($file_contents);
close(PREFS_FILE);
MacPerl::SetFileInfo("McPL", "TEXT", $file_path);
}
#-------------------------------------------------------------------------------
#
# HandlePrefSet
#
#-------------------------------------------------------------------------------
sub HandlePrefSet($$$$)
{
my($flags, $name, $value, $desc) = @_;
if (SetArrayValue($flags, $name, $value)) {
print "Prefs set $desc flag '$name' to '$value'\n";
} else {
die "$desc setting '$name' is not a valid option\n";
}
}
#-------------------------------------------------------------------------------
#
# HandleBuildFromPref
#
#-------------------------------------------------------------------------------
sub HandleBuildFromPref($$)
{
my($build_array, $name) = @_;
my($setting) = 0;
my($index);
foreach $index (@$build_array)
{
if ($index->[0] eq $name) {
$setting = 1;
}
$index->[1] = $setting;
}
if ($setting == 1) {
print "Building from $name onwards, as specified by prefs\n";
} else {
printf "Failed to find buildfrom setting '$name'\n";
}
}
#-------------------------------------------------------------------------------
#
# ReadPrefsFile
#
#-------------------------------------------------------------------------------
sub ReadPrefsFile($$$$$)
{
my($file_path, $build_flags, $options_flags, $filepath_flags, $create_if_missing) = @_;
local(*PREFS_FILE);
if (open(PREFS_FILE, "< $file_path"))
{
print "Reading build prefs from '$file_path'\n";
while (<PREFS_FILE>)
{
my($line) = $_;
chomp($line);
if ($line =~ /^\#/ || $line =~ /^\s*$/) { # ignore comments and empty lines
next;
}
if (($line =~ /^\s*([^#\s]+)\s+([^#\s]+)\s+\"(.+)\"(\s+#.+)?/) ||
($line =~ /^\s*([^#\s]+)\s+([^#\s]+)\s+\'(.+)\'(\s+#.+)?/) ||
($line =~ /^\s*([^#\s]+)\s+([^#\s]+)\s+([^#\s]+)(\s+#.+)?/))
{
my($array_name) = $1;
my($option_name) = $2;
my($option_value) = $3;
# print "Read '$array_name' '$option_name' '$option_value'\n";
if ($array_name eq "build")
{
HandlePrefSet($build_flags, $option_name, $option_value, "Build");
}
elsif ($array_name eq "options")
{
HandlePrefSet($options_flags, $option_name, $option_value, "Options");
}
elsif ($array_name eq "filepath" && $option_name && $option_value)
{
HandlePrefSet($filepath_flags, $option_name, $option_value, "Filepath");
}
else
{
print "Unknown pref option at $line\n";
}
}
elsif ($line =~ /^\s*buildfrom\s+([^#\s]+)(\s+#.+)?/)
{
my($build_start) = $1;
HandleBuildFromPref($build_flags, $build_start);
}
elsif ($line =~ /^\s*([^#\s]+)\s+([^#\s]+)(\s+#.+)?/)
{
my($build_var) = $1;
my($var_setting) = $2;
print "Setting \$main::$build_var to $var_setting\n";
eval "\$main::$build_var = \"$var_setting\"";
}
else
{
print "Unrecognized input line at $line\n";
}
}
close(PREFS_FILE);
}
elsif ($create_if_missing)
{
print "No prefs file found at $file_path; using defaults\n";
my($folder_path) = $file_path;
$folder_path =~ s/[^:]+$//;
mkpath($folder_path);
WriteDefaultPrefsFile($file_path);
}
}
#-------------------------------------------------------------------------------
#
# ReadMozUserPrefs
#
#-------------------------------------------------------------------------------
sub ReadMozUserPrefs($$$$)
{
my($prefs_file_name, $build_flags, $options_flags, $filepath_flags) = @_;
if ($prefs_file_name eq "") { return; }
# if local prefs exist, just use those. Othewise, look in the prefs folder
if (-e $prefs_file_name)
{
# read local prefs
ReadPrefsFile($prefs_file_name, $build_flags, $options_flags, $filepath_flags, 0);
}
else
{
# first read prefs folder prefs
my($prefs_path) = GetPrefsFolder();
$prefs_path .= ":$prefs_file_name";
ReadPrefsFile($prefs_path, $build_flags, $options_flags, $filepath_flags, 1);
}
}
1;

View File

@@ -1,932 +0,0 @@
#!/usr/bin/perl
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Simon Fraser <sfraser@netscape.com>
#
package Moz::ProjectXML;
require 5.004;
require Exporter;
use strict;
use Exporter;
use Cwd;
use XML::DOM;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(
ParseXMLDocument
DisposeXMLDocument
WriteXMLDocument
CleanupPro5XML
GetTargetsList
CloneTarget
SetAsSharedLibraryTarget
SetAsStaticLibraryTarget
AddTarget
RemoveTarget
GetTargetSetting
SetTargetSetting
getChildElementTextContents
);
#--------------------------------------------------------------------------------------------------
# A module for reading, manipulating, and writing XML-format CodeWarrior project files.
#
# Sample usage:
#
# use ProjectXML;
#
# my $doc = ProjectXML::ParseXMLDocument("Test.mcp.xml");
# ProjectXML::CloneTarget($doc, "Test.shlb", "Test.lib");
# ProjectXML::SetAsStaticLibraryTarget($doc, "Test.lib", "TestOutput.lib");
# ProjectXML::WriteXMLDocument($doc, "Test_out.xml");
# ProjectXML::DisposeXMLDocument($doc);
#
#--------------------------------------------------------------------------------------------------
#//--------------------------------------------------------------------------------------------------
#// ParseXMLDocument
#// Note that the caller must call DisposeXMLDocument on the returned doc
#//--------------------------------------------------------------------------------------------------
sub ParseXMLDocument($)
{
my($doc_path) = @_;
my $parser = new XML::DOM::Parser(ErrorContext => 2);
my $doc = $parser->parsefile($doc_path);
return $doc;
}
#//--------------------------------------------------------------------------------------------------
#// DisposeXMLDocument
#// Needed to avoid memory leaks - cleanup circular references for garbage collection
#//--------------------------------------------------------------------------------------------------
sub DisposeXMLDocument($)
{
my($doc) = @_;
$doc->dispose();
}
#//--------------------------------------------------------------------------------------------------
#// WriteXMLDocument
#//--------------------------------------------------------------------------------------------------
sub _pro5_tag_compression($$)
{
return 1; # Pro 5 is broken and can't import XML with <foo/> style tags
}
sub _pro6plus_tag_compression($$)
{
return 0; # Pro 6 can deal with empty XML tags like <foo/>
}
sub WriteXMLDocument($$$)
{
my($doc, $file_path, $ide_version) = @_;
if ($ide_version eq "4.0")
{
XML::DOM::setTagCompression(\&_pro5_tag_compression);
}
else
{
XML::DOM::setTagCompression(\&_pro6plus_tag_compression);
}
$doc->printToFile($file_path);
}
#//--------------------------------------------------------------------------------------------------
#// CleanupPro5XML
#// XML Projects exported by Pro 5 contain garbage data under the MWMerge_MacOS_skipResources
#// setting. This routine cleans this up, saving the result to a new file
#//--------------------------------------------------------------------------------------------------
sub CleanupPro5XML($$)
{
my($xml_path, $out_path) = @_;
local(*XML_FILE);
open(XML_FILE, "< $xml_path") || die "Error: failed to open file $xml_path\n";
local(*CLEANED_FILE);
open(CLEANED_FILE, "> $out_path") || die "Error: failed to open file $out_path for writing\n";
my $in_skip_resources_settings = 0;
while(<XML_FILE>)
{
my($line) = $_;
if ($line =~ /^<\?codewarrior/) # is processing inst line
{
my $test_line = $line;
chomp($test_line);
my $out_line = $test_line;
if ($test_line =~ /^<\?codewarrior\s+exportversion=\"(.+)\"\s+ideversion=\"(.+)\"\s*\?>$/)
{
my $export_version = $1;
my $ide_version = $2;
$ide_version = "4.0_mozilla"; # pseudo IDE version so we know we touched it
$out_line = "<?codewarrior exportversion=\"".$export_version."\" ideversion=\"".$ide_version."\"?>";
}
print CLEANED_FILE "$out_line\n";
next;
}
if ($line =~ /MWMerge_MacOS_skipResources/)
{
$in_skip_resources_settings = 1;
print CLEANED_FILE "$line";
}
elsif($in_skip_resources_settings && $line =~ /<!-- Settings for/)
{
# leaving bad settings lines. Write closing tag
print CLEANED_FILE " <!-- Corrupted setting entries removed by script -->\n";
print CLEANED_FILE " </SETTING>\n\n";
print CLEANED_FILE "$line";
$in_skip_resources_settings = 0;
}
elsif (!$in_skip_resources_settings)
{
print CLEANED_FILE "$line";
}
}
close(XML_FILE);
close(CLEANED_FILE);
}
#--------------------------------------------------------------------------------------------------
# SniffProjectXMLIDEVersion
#
#--------------------------------------------------------------------------------------------------
sub SniffProjectXMLIDEVersion($)
{
my($xml_path) = @_;
my $found_version = "";
local(*XML_FILE);
open(XML_FILE, "< $xml_path") || die "Error: failed to open file $xml_path\n";
while(<XML_FILE>)
{
my($line) = $_;
chomp($line);
if ($line =~ /^<\?codewarrior/) # is processing inst line
{
unless ($line =~ /^<\?codewarrior\s+exportversion=\"(.+)\"\s+ideversion=\"(.+)\"\s*\?>$/)
{
die "Error: Failed to find ideversion in $xml_path in line $line\n";
}
my $export_version = $1;
my $ide_version = $2;
$found_version = $ide_version;
last;
}
}
close(XML_FILE);
return $found_version;
}
#//--------------------------------------------------------------------------------------------------
#// GetTargetsList
#// Returns an array of target names
#//--------------------------------------------------------------------------------------------------
sub GetTargetsList($)
{
my($doc) = @_;
my $nodes = $doc->getElementsByTagName("TARGET");
my $n = $nodes->getLength;
my @target_names;
for (my $i = 0; $i < $n; $i++)
{
my ($node) = $nodes->item($i);
my($target_name) = getChildElementTextContents($node, "NAME");
push(@target_names, $target_name);
}
return @target_names;
}
#//--------------------------------------------------------------------------------------------------
#// CloneTarget
#// Clone the named target, renaming it to 'new_name'
#//--------------------------------------------------------------------------------------------------
sub CloneTarget($$$)
{
my($doc, $target_name, $new_name) = @_;
my $target_node = getTargetNode($doc, $target_name);
# clone here
my $target_clone = $target_node->cloneNode(1); # deep clone
# -- munge target settings --
# set the target name field
setChildElementTextContents($doc, $target_clone, "NAME", $new_name);
# set the targetname pref
setTargetNodeSetting($doc, $target_clone, "Targetname", $new_name);
# -- insert new target subtree --
my $target_list = $target_node->getParentNode();
$target_list->appendChild($target_clone);
# -- now add to targetorder --
my (@target_order_nodes) = getChildOfDocument($doc, "TARGETORDER");
my $target_order = @target_order_nodes[0];
my $new_order = $doc->createElement("ORDEREDTARGET");
my $order_name = $doc->createElement("NAME");
$new_order->appendChild($order_name);
setChildElementTextContents($doc, $new_order, "NAME", $new_name);
$target_order->appendChild($new_order);
}
#//--------------------------------------------------------------------------------------------------
#// SetAsSharedLibraryTarget
#//
#//--------------------------------------------------------------------------------------------------
sub SetAsSharedLibraryTarget($$$)
{
my($doc, $target_name, $output_name) = @_;
my $target_node = getTargetNode($doc, $target_name);
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_type", "SharedLibrary");
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_filetype", "1936223330"); #'shlb'
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_outfile", $output_name);
}
#//--------------------------------------------------------------------------------------------------
#// AddFileToTarget
#//
#// Add a file to the specified target(s).
#//
#//--------------------------------------------------------------------------------------------------
sub AddFileToTarget($$$)
{
my($doc, $target_list, $file_name) = @_;
# the file must be added in 3 places:
# 1. in <TARGET><FILELIST><FILE> (with linkage flags if necessary)
# 2. in <TARGET><LINKORDER><FILEREF>
# 3. in <GROUPLIST><GROUP><FILEREF>
die "Write me\n";
}
#//--------------------------------------------------------------------------------------------------
#// RemoveFileFromTarget
#//
#// Remove a file from the specified target, removing it from the entire project
#// if no other targets reference it.
#//
#//--------------------------------------------------------------------------------------------------
sub RemoveFileFromTarget($$$)
{
my($doc, $target_node, $file_name) = @_;
# the file must be removed in 3 places:
# 1. in <TARGET><FILELIST><FILE>
# 2. in <TARGET><LINKORDER><FILEREF>
# 3. in <GROUPLIST><GROUP><FILEREF>
# first, remove from <FILELIST>
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
my $file_node = getChildNodeByGrandchildContents($doc, $filelist_node, "FILE", "PATH", $file_name);
unless ($file_node) { return; }
$filelist_node->removeChild($file_node);
# next, remove from <LINKORDER>
my $linkorder_node = getFirstChildElement($target_node, "LINKORDER");
unless ($linkorder_node) { die "Error: failed to find LINKORDER node\n"; }
my $fileref_node = getChildNodeByGrandchildContents($doc, $linkorder_node, "FILEREF", "PATH", $file_name);
unless ($fileref_node) { die "Error: link order node for file $file_name not found\n"; }
$linkorder_node->removeChild($fileref_node);
# last, remove from <GROUPLIST>
# <GROUPLIST> is cross-target, so we have to be careful here.
my $grouplist_node = getChildOfDocument($doc, "GROUPLIST");
unless ($grouplist_node) { die "Error: failed to find GROUPLIST node\n"; }
# if the file isn't in any other targets, remove it from the groups
if (!GetFileInUse($doc, $file_name))
{
print "File $file_name is in no other targest. Removing from project\n";
my @group_nodes;
getChildElementsOfType($doc, $grouplist_node, "GROUP", \@group_nodes);
my $group_node;
foreach $group_node (@group_nodes)
{
my @fileref_nodes;
getChildElementsOfType($doc, $group_node, "FILEREF", \@fileref_nodes);
my $fileref_node;
foreach $fileref_node (@fileref_nodes)
{
my $path_name = getChildElementTextContents($fileref_node, "PATH");
if ($path_name eq $file_name)
{
print "Removing $file_name from project group list\n";
$group_node->removeChild($fileref_node);
last;
}
}
# can a file appear in more than one group?
}
}
}
#//--------------------------------------------------------------------------------------------------
#// SetAsStaticLibraryTarget
#//
#//--------------------------------------------------------------------------------------------------
sub SetAsStaticLibraryTarget($$$)
{
my($doc, $target_name, $output_name) = @_;
my $target_node = getTargetNode($doc, $target_name);
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_type", "Library");
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_filetype", "1061109567"); #'????'
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_outfile", $output_name);
# static targets don't need any library linkage, so we can remove linkage
# with all .shlb and .Lib files.
my(@obsolete_files) = ("NSStdLibStubs", "InterfacesStubs", "InterfaceLib", "InternetConfigLib");
print " Removing libraries etc. from target\n";
# get all files in target
my @target_files = GetTargetFilesList($doc, $target_name);
my $target_file;
foreach $target_file (@target_files)
{
if ($target_file =~ /(\.shlb|\.lib|\.Lib|\.o|\.exp)$/)
{
RemoveFileFromTarget($doc, $target_node, $target_file);
}
}
print " Removing stub libraries from target\n";
# then remove files with known names
my $obs_file;
foreach $obs_file (@obsolete_files)
{
RemoveFileFromTarget($doc, $target_node, $obs_file);
}
}
#//--------------------------------------------------------------------------------------------------
#// AddTarget
#//
#//--------------------------------------------------------------------------------------------------
sub AddTarget($$)
{
my($doc, $target_name) = @_;
die "Write me\n";
}
#//--------------------------------------------------------------------------------------------------
#// RemoveTarget
#//
#//--------------------------------------------------------------------------------------------------
sub RemoveTarget($$)
{
my($doc, $target_name) = @_;
die "Write me\n";
}
#//--------------------------------------------------------------------------------------------------
#// GetTargetSetting
#// Get the value for the specified setting in the specified target
#//--------------------------------------------------------------------------------------------------
sub GetTargetSetting($$$)
{
my($doc, $target_name, $setting_name) = @_;
my $target_node = getTargetNode($doc, $target_name);
return getTargetNodeSetting($target_node, "VALUE");
}
#//--------------------------------------------------------------------------------------------------
#// SetTargetSetting
#// Set the value for the specified setting in the specified target
#//--------------------------------------------------------------------------------------------------
sub SetTargetSetting($$$$)
{
my($doc, $target_name, $setting_name, $new_value) = @_;
my $target_node = getTargetNode($doc, $target_name);
setTargetNodeSetting($doc, $target_node, "VALUE", $new_value);
}
#//--------------------------------------------------------------------------------------------------
#// GetTargetFilesList
#// Return an array of the files in the target (in filelist order)
#//--------------------------------------------------------------------------------------------------
sub GetTargetFilesList($$)
{
my($doc, $target_name) = @_;
my $target_node = getTargetNode($doc, $target_name);
my @files_list;
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
my @file_nodes;
getChildElementsOfType($doc, $filelist_node, "FILE", \@file_nodes);
my $node;
foreach $node (@file_nodes)
{
my $file_name = getChildElementTextContents($node, "PATH");
push(@files_list, $file_name);
}
return @files_list;
}
#//--------------------------------------------------------------------------------------------------
#// FileIsInTarget
#//
#//--------------------------------------------------------------------------------------------------
sub FileIsInTarget($$$)
{
my($doc, $file_name, $target_name) = @_;
my $target_node = getTargetNode($doc, $target_name);
unless ($target_node) { die "Error: no target found called $target_name\n"; }
my $file_node = GetTargetFileNode($doc, $target_node, $file_name);
if ($file_node) {
return 1;
}
return 0;
}
#//--------------------------------------------------------------------------------------------------
#// GetFileTargetsList
#// Return an array of the targets that a file is in (expensive)
#//--------------------------------------------------------------------------------------------------
sub GetFileTargetsList($$)
{
my ($doc, $file_name) = @_;
my @target_list;
my @targets = GetTargetsList($doc);
my $target;
foreach $target (@targets)
{
if (FileIsInTarget($doc, $file_name, $target))
{
push(@target_list, $target);
}
}
return @target_list;
}
#//--------------------------------------------------------------------------------------------------
#// GetTargetFileNode
#//
#//--------------------------------------------------------------------------------------------------
sub GetTargetFileNode($$$)
{
my($doc, $target_node, $file_name) = @_;
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
my $file_node = getChildNodeByGrandchildContents($doc, $filelist_node, "FILE", "PATH", $file_name);
return $file_node;
}
#//--------------------------------------------------------------------------------------------------
#// GetFileInUse
#// Return true if the file is used by any target
#//--------------------------------------------------------------------------------------------------
sub GetFileInUse($$)
{
my($doc, $file_name) = @_;
my $targetlist_node = getChildOfDocument($doc, "TARGETLIST");
my $target_node = $targetlist_node->getFirstChild();
while ($target_node)
{
if ($target_node->getNodeTypeName eq "ELEMENT_NODE" &&
$target_node->getTagName() eq "TARGET")
{
# if this is a target node
my $file_node = GetTargetFileNode($doc, $target_node, $file_name);
if ($file_node) {
return 1; # found it
}
}
$target_node = $target_node->getNextSibling();
}
# not found
return 0;
}
#//--------------------------------------------------------------------------------------------------
#// getChildOfDocument
#//--------------------------------------------------------------------------------------------------
sub getChildOfDocument($$)
{
my($doc, $child_type) = @_;
return getFirstChildElement($doc->getDocumentElement(), $child_type);
}
#//--------------------------------------------------------------------------------------------------
#// getFirstChildElement
#//--------------------------------------------------------------------------------------------------
sub getFirstChildElement($$)
{
my($node, $element_name) = @_;
my $found_node;
unless ($node) { die "getFirstChildElement called with empty node\n"; }
#look for the first "element_name" child
my $child_node = $node->getFirstChild();
while ($child_node)
{
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
$child_node->getTagName() eq $element_name)
{
$found_node = $child_node;
last;
}
$child_node = $child_node->getNextSibling();
}
return $found_node;
}
#//--------------------------------------------------------------------------------------------------
#// getChildElementsOfType
#//
#// Return an array of refs to child nodes of the given type
#//--------------------------------------------------------------------------------------------------
sub getChildElementsOfType($$$$)
{
my($doc, $node, $child_type, $array_ref) = @_;
my $child_node = $node->getFirstChild();
while ($child_node)
{
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
$child_node->getTagName() eq $child_type)
{
push(@$array_ref, $child_node);
}
$child_node = $child_node->getNextSibling();
}
}
#//--------------------------------------------------------------------------------------------------
#// getChildElementTextContents
#//--------------------------------------------------------------------------------------------------
#
# Given <FOOPY><NERD>Hi!</NERD></FOOPY>, where $node is <FOOPY>,
# returns "Hi!". If > 1 <NERD> node, returns the contents of the first.
#
sub getChildElementTextContents($$)
{
my($node, $tag_name) = @_;
my $first_element = getFirstChildElement($node, $tag_name);
my $text_node = $first_element->getFirstChild();
my $text_contents = "";
# concat adjacent text nodes
while ($text_node)
{
if ($text_node->getNodeTypeName() ne "TEXT_NODE")
{
last;
}
$text_contents = $text_contents.$text_node->getData();
$text_node = $text_node->getNextSibling();
}
return $text_contents;
}
#//--------------------------------------------------------------------------------------------------
#// setChildElementTextContents
#//--------------------------------------------------------------------------------------------------
sub setChildElementTextContents($$$$)
{
my($doc, $node, $tag_name, $contents_text) = @_;
my $first_element = getFirstChildElement($node, $tag_name);
my $new_text_node = $doc->createTextNode($contents_text);
# replace all child elements with a text element
removeAllChildren($first_element);
$first_element->appendChild($new_text_node);
}
#//--------------------------------------------------------------------------------------------------
#// getChildNodeByContents
#//
#// Consider <foo><bar><baz>Foopy</baz></bar><bar><baz>Loopy</baz></bar></foo>
#// This function, when called with getChildNodeByContents($foonode, "bar", "baz", "Loopy")
#// returns the second <bar> node.
#//--------------------------------------------------------------------------------------------------
sub getChildNodeByGrandchildContents($$$$$)
{
my($doc, $node, $child_type, $gc_type, $gc_contents) = @_; # gc = grandchild
my $found_node;
my $child_node = $node->getFirstChild();
while ($child_node)
{
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
$child_node->getTagName() eq $child_type)
{
# check for a child of this node of type
my $child_contents = getChildElementTextContents($child_node, $gc_type);
if ($child_contents eq $gc_contents)
{
$found_node = $child_node;
last;
}
}
$child_node = $child_node->getNextSibling();
}
return $found_node;
}
#//--------------------------------------------------------------------------------------------------
#// getTargetNode
#//--------------------------------------------------------------------------------------------------
sub getTargetNode($$)
{
my($doc, $target_name) = @_;
my $targetlist_node = getChildOfDocument($doc, "TARGETLIST");
return getChildNodeByGrandchildContents($doc, $targetlist_node, "TARGET", "NAME", $target_name);
}
#//--------------------------------------------------------------------------------------------------
#// getTargetNamedSettingNode
#//--------------------------------------------------------------------------------------------------
sub getTargetNamedSettingNode($$)
{
my($target_node, $setting_name) = @_;
my $setting_node;
my $settinglist_node = getFirstChildElement($target_node, "SETTINGLIST");
my $child_node = $settinglist_node->getFirstChild();
while ($child_node)
{
if ($child_node->getNodeTypeName ne "ELEMENT_NODE")
{
$child_node = $child_node->getNextSibling();
next;
}
if ($child_node->getTagName() eq "SETTING")
{
my $set_name = getChildElementTextContents($child_node, "NAME");
if ($set_name eq $setting_name)
{
$setting_node = $child_node;
last;
}
}
$child_node = $child_node->getNextSibling();
}
return $setting_node;
}
#//--------------------------------------------------------------------------------------------------
#// getTargetNodeSetting
#//--------------------------------------------------------------------------------------------------
sub getTargetNodeSetting($$)
{
my($target_node, $setting_name) = @_;
my $setting_node = getTargetNamedSettingNode($target_node, $setting_name);
return getChildElementTextContents($setting_node, "VALUE");
}
#//--------------------------------------------------------------------------------------------------
#// setTargetNodeSetting
#//--------------------------------------------------------------------------------------------------
sub setTargetNodeSetting($$$$)
{
my($doc, $target_node, $setting_name, $new_value) = @_;
my $setting_node = getTargetNamedSettingNode($target_node, $setting_name);
setChildElementTextContents($doc, $setting_node, "VALUE", $new_value);
}
#//--------------------------------------------------------------------------------------------------
#// elementInArray
#//--------------------------------------------------------------------------------------------------
sub elementInArray($$)
{
my($element, $array) = @_;
my $test;
foreach $test (@$array)
{
if ($test eq $element) {
return 1;
}
}
return 0;
}
#//--------------------------------------------------------------------------------------------------
#// removeAllChildren
#//--------------------------------------------------------------------------------------------------
sub removeAllChildren($)
{
my($node) = @_;
my $child_node = $node->getFirstChild();
while ($child_node)
{
$node->removeChild($child_node);
$child_node = $node->getFirstChild();
}
}
#//--------------------------------------------------------------------------------------------------
#// dumpNodeData
#//--------------------------------------------------------------------------------------------------
sub dumpNodeData($)
{
my($node) = @_;
unless ($node) { die "Null node passed to dumpNodeData\n"; }
print "Dumping node $node\n";
my($node_type) = $node->getNodeTypeName();
if ($node_type eq "ELEMENT_NODE")
{
my($node_name) = $node->getTagName();
print "Element $node_name\n";
}
elsif ($node_type eq "TEXT_NODE")
{
my($node_data) = $node->getData;
# my(@node_vals) = unpack("C*", $node_data);
print "Text '$node_data'\n"; # may contain LF chars
}
else
{
print "Node $node_type\n";
}
}
#//--------------------------------------------------------------------------------------------------
#// dumpNodeTree
#//--------------------------------------------------------------------------------------------------
sub dumpNodeTree($)
{
my($node) = @_;
my($child_node) = $node->getFirstChild();
unless ($child_node) { return; }
# recurse
dumpNodeData($child_node);
# then go through child nodes
while ($child_node)
{
dumpNodeTree($child_node);
$child_node = $child_node->getNextSibling();
}
}
1;

View File

@@ -1,90 +0,0 @@
#-------------------------------------------------------------------------------
# These 3 lists are the 'master lists' to control what gets built.
#
# Ordering in these arrays is important; it has to reflect the order in
# which the build occurs.
#
# Setting containing spaces must be quoted with double quotes.
#-------------------------------------------------------------------------------
build_flags
all 1
pull 0
dist 0
config 0
xpidl 0
idl 0
stubs 0
runtime 0
common 0
imglib 0
libimg2 0
necko 0
security 0
browserutils 0
intl 0
nglayout 0
accessiblity 0
editor 0
embedding 0
viewer 0
xpapp 0
extensions 0
plugins 0
mailnews 0
apprunner 0
resources 0
options_flags
pull_by_date 0
chrome_jars 1
chrome_files 0
use_jars 1
transformiix 1
mathml 0 MOZ_MATHML
svg 0 MOZ_SVG
# svg requires libart, which is an lgpl library. You need to pull it
# explicitly.
libart_lgpl 0
mng 1
ldap 1 MOZ_LDAP_XPCOM
ldap_experimental 0 MOZ_LDAP_XPCOM_EXPERIMENTAL
xmlextras 1
wsp 0 MOZ_WSP
inspector 1
mailextras 1
xptlink 0
psm 0 MOZ_PSM
embedding_test 1
embedding_chrome 0
embedding_xulprefs 0
embedding_xulsecurity 0
carbon 0 TARGET_CARBON
useimg2 1 USE_IMG2
lowmem 0 MOZ_MAC_LOWMEM
accessible 1 ACCESSIBILITY
bidi 1 IBMBIDI
p3p 0
jsd 1
venkman 1
moz_logging 1 MOZ_LOGGING
chatzilla 1
content_packs 1
xml_rpc 1
cview 1
help 1
timeline 0 MOZ_TIMELINE
static_build 0 MOZ_STATIC_COMPONENT_LIBS
string_debug 0 DEBUG_STRING
string_stats 0 DEBUG_STRING_STATS
xpctools 0 XPC_TOOLS_SUPPORT
smime 1
mdn 1
print_preview 1 NS_PRINT_PREVIEW
moz_xul 1 MOZ_XUL
filepath_flags
idepath ":CodeWarrior IDE Path.txt"
sessionpath ":Mozilla session path.txt"
buildlogfilepath ":Build Logs:Mozilla build log.txt" # this is a path
scriptlogfilepath ":Build Logs:Mozilla script log.txt"

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +0,0 @@
# List of modules to check out. Format is
# module, (tag), (date)
# where tag and date are optional (non-trailing commas are required)
#
# Examples:
# mozilla/nsprpub, NSPRPUB_CLIENT_TAG
# mozilla/gc, , 10/25/2000 12:00:00
#
mozilla/nsprpub, NETSCAPE_7_0_RTM
mozilla/security/nss, NETSCAPE_7_0_RTM
mozilla/security/manager, NETSCAPE_7_0_RTM
mozilla/accessible, NETSCAPE_7_0_RTM
mozilla/directory/c-sdk, NETSCAPE_7_0_RTM
mozilla/lib/mac/Instrumentation, NETSCAPE_7_0_RTM
mozilla/gfx2, NETSCAPE_7_0_RTM
mozilla/modules/libpr0n, NETSCAPE_7_0_RTM
SeaMonkeyAll, NETSCAPE_7_0_RTM
## You need this if you want to be able to use SVG
## Note that this library is under the LGPL, not the MPL
#mozilla/other-licenses/libart_lgpl

View File

@@ -1,79 +0,0 @@
#!perl
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Simon Fraser <sfraser@netscape.com>
#
require 5.004;
use strict;
use Cwd;
use Moz::BuildUtils;
use Moz::BuildCore;
#-------------------------------------------------------------
# Where have the build options gone?
#
# The various build flags have been centralized into one place.
# The master list of options is in MozBuildFlags.txt. However,
# you should never need to edit that file, or this one.
#
# To customize what gets built, or where to start the build,
# edit the $prefs_file_name file in
# System Folder:Preferences:Mozilla build prefs:
# Documentation is provided in that file.
#-------------------------------------------------------------
my($prefs_file_name) = "Mozilla pull prefs";
#-------------------------------------------------------------
# hashes to hold build options
#-------------------------------------------------------------
my(%build);
my(%options);
my(%filepaths);
my(%optiondefines);
# Hash of input files for this build. Eventually, there will be
# input files for manifests, and projects too.
my(%inputfiles) = (
"buildflags", "MozillaBuildFlags.txt",
"checkoutdata", "MozillaCheckoutList.txt",
"buildprogress", "",
"buildmodule", "MozillaBuildList.pm",
"checkouttime", "Mozilla last checkout"
);
#-------------------------------------------------------------
# end build hashes
#-------------------------------------------------------------
# set the build root directory, which is the the dir above mozilla
SetupBuildRootDir(":mozilla:build:mac:build_scripts");
# Set up all the flags on $main::, like DEBUG, CARBON etc.
# Override the defaults using the preferences files.
SetupDefaultBuildOptions(0, ":mozilla:dist:viewer:", "");
my($do_checkout) = 1;
my($do_build) = 0;
RunBuild($do_checkout, $do_build, \%inputfiles, $prefs_file_name);

View File

@@ -1,447 +1,168 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
# 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 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.
# 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 Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# 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.
#
# Contributor(s):
DEPTH=.
!if !defined(MOZ_TOP)
#enable builds from changed top level directories
MOZ_TOP=mozilla
!endif
MOZ_SRC_FLIPPED = $(MOZ_SRC:\=/)
MOZ_DIST_FLIPPED = $(MOZ_SRC_FLIPPED)/mozilla/dist
!ifdef MOZ_DEBUG
MOZ_OBJDIR = WIN32_D.OBJ
!else
MOZ_OBJDIR = WIN32_O.OBJ
!endif
#
# Command macro defines
#
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#//------------------------------------------------------------------------
#// Figure out how to do the pull.
#//------------------------------------------------------------------------
# uncomment these, modify branch tag, and check in to branch for milestones
MOZ_BRANCH=NETSCAPE_7_0_RTM
NSPR_CO_TAG=NETSCAPE_7_0_RTM
PSM_CO_TAG=NETSCAPE_7_0_RTM
NSS_CO_TAG=NETSCAPE_7_0_RTM
LDAPCSDK_CO_TAG=NETSCAPE_7_0_RTM
ACCESSIBLE_CO_TAG=NETSCAPE_7_0_RTM
IMGLIB2_CO_TAG=NETSCAPE_7_0_RTM
GFX2_CO_TAG=NETSCAPE_7_0_RTM
!ifdef MOZ_BRANCH
!if "$(MOZ_BRANCH)" != ""
CVS_BRANCH=-r $(MOZ_BRANCH)
!endif
!ifdef MOZ_DATE
CVS_BRANCH=$(CVS_BRANCH) -D "$(MOZ_DATE)"
!endif
# default pull is "quiet" but it can be overridden with MOZ_CVS_VERBOSE
!ifndef MOZ_CVS_VERBOSE
CVS_FLAGS=-q
!endif
# honor any user-defined CVS flags
!ifdef MOZ_CVS_FLAGS
CVS_FLAGS=$(CVS_FLAGS) $(MOZ_CVS_FLAGS)
!endif
# let's be explicit about CVSROOT... some windows cvs clients
# are too stupid to correctly work without the -d option
#
# if they are too stupid, they should fail. I am
# commenting this out because this does not work
# under 4nt. (%'s are evaluted differently)
#
# If it breaks you, mail dougt@netscape.com
# and leaf@mozilla.org
#
!if 0
!if defined(CVSROOT)
CVS_FLAGS=$(CVS_FLAGS) -d "$(CVSROOT)"
!endif
!endif
!ifndef MOZ_CO_FLAGS
MOZ_CO_FLAGS = -P
!endif
CVSCO = cvs $(CVS_FLAGS) co $(MOZ_CO_FLAGS) $(CVS_BRANCH)
#//------------------------------------------------------------------------
#// Figure out how to pull NSPR.
#// If no NSPR_CO_TAG is specified, use the default static tag
#//------------------------------------------------------------------------
!ifndef NSPR_CO_FLAGS
NSPR_CO_FLAGS=$(MOZ_CO_FLAGS)
!endif
NSPR_CO_FLAGS=$(NSPR_CO_FLAGS) $(CVS_BRANCH)
CVSCO_NSPR = cvs $(CVS_FLAGS) co $(NSPR_CO_FLAGS)
#//------------------------------------------------------------------------
#// Figure out how to pull NSS and PSM libs.
#// If no NSS_CO_TAG or PSM_CO_TAG is specified, use the default static tag
#//------------------------------------------------------------------------
!ifndef NSS_CO_FLAGS
NSS_CO_FLAGS=$(MOZ_CO_FLAGS)
!endif
NSS_CO_FLAGS=$(NSS_CO_FLAGS) $(CVS_BRANCH)
CVSCO_NSS = cvs $(CVS_FLAGS) co $(NSS_CO_FLAGS)
!ifndef PSM_CO_FLAGS
PSM_CO_FLAGS=$(MOZ_CO_FLAGS)
!endif
PSM_CO_FLAGS=$(PSM_CO_FLAGS) $(CVS_BRANCH)
CVSCO_PSM = cvs $(CVS_FLAGS) co $(PSM_CO_FLAGS)
#//------------------------------------------------------------------------
#// Figure out how to pull LDAP C SDK client libs.
#// If no LDAPCSDK_CO_TAG is specified, use the default tag
#//------------------------------------------------------------------------
!ifndef LDAPCSDK_CO_FLAGS
LDAPCSDK_CO_FLAGS=$(MOZ_CO_FLAGS)
!endif
LDAPCSDK_CO_FLAGS=$(LDAPCSDK_CO_FLAGS) $(CVS_BRANCH)
CVSCO_LDAPCSDK = cvs $(CVS_FLAGS) co $(LDAPCSDK_CO_FLAGS)
#//------------------------------------------------------------------------
#// Figure out how to pull accessibility libs.
#// If no ACCESSIBLE_CO_TAG is specified, use the default tag
#//------------------------------------------------------------------------
!ifndef ACCESSIBLE_CO_FLAGS
ACCESSIBLE_CO_FLAGS=$(MOZ_CO_FLAGS)
!endif
ACCESSIBLE_CO_FLAGS=$(ACCESSIBLE_CO_FLAGS) $(CVS_BRANCH)
CVSCO_ACCESSIBLE = cvs $(CVS_FLAGS) co $(ACCESSIBLE_CO_FLAGS)
#//------------------------------------------------------------------------
#// Figure out how to pull new image library.
#// If no IMGLIB2_CO_TAG is specified, use the default tag
#//------------------------------------------------------------------------
!ifndef IMGLIB2_CO_FLAGS
IMGLIB2_CO_FLAGS=$(MOZ_CO_FLAGS)
!endif
IMGLIB2_CO_FLAGS=$(IMGLIB2_CO_FLAGS) $(CVS_BRANCH)
CVSCO_IMGLIB2 = cvs $(CVS_FLAGS) co $(IMGLIB2_CO_FLAGS)
#//------------------------------------------------------------------------
#// Figure out how to pull new image library.
#// If no GFX2_CO_TAG is specified, use the default tag
#//------------------------------------------------------------------------
!ifndef GFX2_CO_FLAGS
GFX2_CO_FLAGS=$(MOZ_CO_FLAGS)
!endif
GFX2_CO_FLAGS=$(GFX2_CO_FLAGS) $(CVS_BRANCH)
CVSCO_GFX2 = cvs $(CVS_FLAGS) co $(GFX2_CO_FLAGS)
#//------------------------------------------------------------------------
#// Figure out how to pull the internal libart
#// (only pulled and built if MOZ_INTERNAL_LIBART_LGPL is set)
#// If no MOZ_INTERNAL_LIBART_CO_TAG is specified, use the default tag
#//------------------------------------------------------------------------
!if defined(MOZ_SVG) && !defined(MOZ_INTERNAL_LIBART_LGPL)
ERR_MESSAGE = ^
You are trying to build Mozilla with SVG support (MOZ_SVG=1), but you ^
haven not specified that mozilla/other-licenses/libart_lgpl should be ^
pulled and built. At the moment Mozilla SVG builds need this patched ^
version of libart. You either need to disable SVG support (unset MOZ_SVG) ^
or enable pulling and building by setting MOZ_INTERNAL_LIBART_LGPL=1.^
^
If you choose to pull and build libart, note that it is only licensed^
under the terms of the LGPL, not the MPL. (Which is why you have to opt^
in explicitly.)
!endif
!if defined(MOZ_INTERNAL_LIBART_LGPL)
!ifndef MOZ_INTERNAL_LIBART_CO_FLAGS
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_CO_FLAGS)
!endif
!if "$(MOZ_INTERNAL_LIBART_CO_TAG)" != ""
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_INTERNAL_LIBART_CO_FLAGS) -r $(MOZ_INTERNAL_LIBART_CO_TAG)
HAVE_BRANCH=1
!else
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_INTERNAL_LIBART_CO_FLAGS) $(CVS_BRANCH)
HAVE_BRANCH=0
!endif
CVSCO_MOZ_INTERNAL_LIBART = cvs $(CVS_FLAGS) co $(MOZ_INTERNAL_LIBART_CO_FLAGS)
#//
#// Temporary hardcode (while we figure out how to do this)
#// to support the Core modularity efforts...
#//
!endif
## The master target
############################################################
pull_and_build_all: pull_all build_all_dep
## Rules for pulling the source from the cvs repository
############################################################
pull_clobber_and_build_all: pull_all clobber_all build_all
!if !defined(MOZ_INTERNAL_LIBART_LGPL)
pull_all: pull_nspr pull_psm pull_ldapcsdk pull_accessible pull_gfx2 pull_imglib2 pull_seamonkey
!ifndef MOZ_JAVAVER
!ifdef MOZ_MEDIUM
MOZ_JAVAVER =-r JAVA_STUB_RELEASE_19980319
!else
pull_all: pull_nspr pull_psm pull_ldapcsdk pull_accessible pull_gfx2 pull_imglib2 pull_moz_internal_libart pull_seamonkey
MOZ_JAVAVER =-r JAVA_RELEASE_19980304
!endif
!endif
pull_nspr: pull_clientmak
cd $(MOZ_SRC)\.
$(CVSCO_NSPR) mozilla/nsprpub
pull_nss:
cd $(MOZ_SRC)\.
$(CVSCO_NSS) mozilla/security/coreconf
$(CVSCO_NSS) mozilla/security/nss
NSPR20_BRANCH =-r NSPR20_RELEASE_19980304_BRANCH
SECURITY_BRANCH=-r SECURITY_RELEASE_19980210
CORECONF_BRANCH=-r CFG_1_6
DBM_BRANCH =-r DBM_RELEASE_19980319
pull_psm: pull_nss
cd $(MOZ_SRC)\.
$(CVSCO_PSM) mozilla/security/manager
$(CVSCO_PSM) mozilla/security/makefile.win
pull_ldapcsdk:
cd $(MOZ_SRC)\.
$(CVSCO_LDAPCSDK) mozilla/directory/c-sdk
pull_accessible:
cd $(MOZ_SRC)\.
$(CVSCO_ACCESSIBLE) mozilla/accessible
pull_gfx2:
cd $(MOZ_SRC)\.
$(CVSCO_GFX2) mozilla/gfx2
pull_imglib2:
cd $(MOZ_SRC)\.
$(CVSCO_IMGLIB2) mozilla/modules/libpr0n
!if defined(MOZ_INTERNAL_LIBART_LGPL)
pull_moz_internal_libart:
cd $(MOZ_SRC)\.
$(CVSCO_MOZ_INTERNAL_LIBART) mozilla/other-licenses/libart_lgpl
!if "$(MOZ_DATE)" != ""
CVS_BRANCH=-D "$(MOZ_DATE)"
HAVE_DATE=1
!else
HAVE_DATE=0
!endif
pull_xpconnect: pull_nspr
cd $(MOZ_SRC)\.
$(CVSCO) mozilla/include
$(CVSCO) mozilla/config
$(CVSCO) -l mozilla/js
$(CVSCO) -l mozilla/js/src
$(CVSCO) mozilla/js/src/fdlibm
$(CVSCO) mozilla/js/src/xpconnect
$(CVSCO) mozilla/modules/libreg
$(CVSCO) mozilla/xpcom
$(CVSCO) mozilla/string
!if $(HAVE_DATE) && $(HAVE_BRANCH)
ERR_MESSAGE=$(ERR_MESSAGE)^
Cannot specify both MOZ_BRANCH and MOZ_DATE
!endif
# pull either layout only or seamonkey the browser
pull_layout:
cd $(MOZ_SRC)\.
$(CVSCO) RaptorWin
NMAKE=@nmake -nologo -$(MAKEFLAGS)
pull_seamonkey: pull_clientmak
cd $(MOZ_SRC)\.
$(CVSCO) SeaMonkeyAll
#//------------------------------------------------------------------------
#//
#// Stuff a do complete pull and build
#//
#//------------------------------------------------------------------------
pull_clientmak:
default:: build_all
pull_and_build_all:: pull_all \
build_all
#// Do this when you pull a new tree, or else you will often get bugs
#// when replaceing an old dist with a new dist.
pull_clobber_build_all:: pull_all \
clobber_all \
build_all
clobber_build_all:: clobber_all \
build_all
# In theory, we should use some symbol in ns/config/liteness.mak,
# but we haven't pulled the file yet. So, refer to MOZ_LITE and
# MOZ_MEDIUM explicitly .
!if defined(MOZ_LITE) || defined(MOZ_MEDIUM)
pull_all:: pull_client_source_product
!else
pull_all:: pull_client
!endif
!ifndef NO_SECURITY
pull_security:
-cvs -q co $(CORECONF_BRANCH) ns/coreconf
-cvs -q co $(SECURITY_BRANCH) CoreSecurity
!else
pull_security:
!endif
pull_client: pull_security
@echo +++ client.mak: checking out the client with "$(CVS_BRANCH)"
cd $(MOZ_SRC)\.
$(CVSCO) mozilla/client.mak
-cvs -q co $(DBM_BRANCH) ns/dbm
-cvs -q co $(CVS_BRANCH) Client50Win
-cvs -q co $(MOZ_JAVAVER) JavaWin
-cvs -q co $(NSPR20_BRANCH) CoreNSPR20
############################################################
pull_client_source_product:
@echo +++ client.mak: checking out the client with "$(CVS_BRANCH)"
cd $(MOZ_SRC)\.
-cvs -q co $(DBM_BRANCH) ns/dbm
-cvs -q co $(CVS_BRANCH) ClientSourceProductWin
-cvs -q co $(MOZ_JAVAVER) JavaStubWin
# nmake has to be hardcoded, or we have to depend on mozilla/config
# being pulled already to figure out what $(NMAKE) should be.
clobber_all: clobber_nspr clobber_ldapcsdk clobber_psm clobber_seamonkey
build_all: build_ldap \
build_dist \
build_client
build_dist:
@echo +++ client.mak: building dist
cd $(MOZ_SRC)\ns
$(NMAKE) -f makefile.win
build_all: build_nspr build_ldapcsdk build_seamonkey
build_all_dep: depend libs
!if defined(MOZ_LITE) || defined(MOZ_MEDIUM)
build_ldap:
!else
build_ldap:
@echo +++ client.mak: building ldap
cd $(MOZ_SRC)\ns\netsite\ldap\libraries\msdos\winsock
$(NMAKE) -f nsldap.mak DEPEND=1
$(NMAKE) -f nsldap.mak
$(NMAKE) -f nsldap.mak EXPORT=1
!endif
distclean:
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
gmake -f gmakefile.win distclean MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
gmake -f gmakefile.win distclean MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
@cd $(MOZ_SRC)\$(MOZ_TOP)
nmake /f client.mak clobber_psm
nmake /f client.mak clobber_seamonkey
clobber_ldapcsdk:
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
gmake -f gmakefile.win clobber_all MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED) \
SHELL=sh
clobber_nspr:
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
gmake -f gmakefile.win clobber_all MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
clobber_psm:
@cd $(MOZ_SRC)\$(MOZ_TOP)\security
nmake -f makefile.win clobber_all
clobber_xpconnect:
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
-rd /s /q dist
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
gmake -f gmakefile.win clobber_all MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
@cd $(MOZ_SRC)\$(MOZ_TOP)\include
nmake -f makefile.win clobber_all
@cd $(MOZ_SRC)\$(MOZ_TOP)\modules\libreg
nmake -f makefile.win clobber_all
@cd $(MOZ_SRC)\$(MOZ_TOP)\string
nmake -f makefile.win clobber_all
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
nmake -f makefile.win clobber_all
@cd $(MOZ_SRC)\$(MOZ_TOP)\js
nmake -f makefile.win clobber_all
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src\xpconnect
nmake -f makefile.win clobber_all
clobber_seamonkey:
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
-rd /s /q dist
nmake -f makefile.win clobber_all
depend: export
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
nmake -f makefile.win depend
depend_xpconnect:
@cd $(MOZ_SRC)\$(MOZ_TOP)\include
nmake -f makefile.win depend
@cd $(MOZ_SRC)\$(MOZ_TOP)\modules\libreg
nmake -f makefile.win depend
@cd $(MOZ_SRC)\$(MOZ_TOP)\string
nmake -f makefile.win depend
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
nmake -f makefile.win depend
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src
nmake -f makefile.win depend
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src\xpconnect
nmake -f makefile.win depend
build_nspr:
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
gmake -f gmakefile.win MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
build_ldapcsdk:
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
gmake -f gmakefile.win MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED) SHELL=sh
build_psm:
@cd $(MOZ_SRC)\$(MOZ_TOP)\security
nmake -f makefile.win
build_xpconnect: build_nspr
@cd $(MOZ_SRC)\$(MOZ_TOP)\include
nmake -f makefile.win all
@cd $(MOZ_SRC)\$(MOZ_TOP)\modules\libreg
nmake -f makefile.win all
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
nmake -f makefile.win export
@cd $(MOZ_SRC)\$(MOZ_TOP)\string
nmake -f makefile.win all
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
nmake -f makefile.win libs
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src
nmake -f makefile.win all
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src\xpconnect
nmake -f makefile.win all
build_seamonkey:
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
nmake -f makefile.win all
build_client:
@cd $(MOZ_SRC)\mozilla\.
nmake -f makefile.win all
@echo +++ client.mak: building client
cd $(MOZ_SRC)\ns\cmd\winfe\mkfiles32
!if "$(MOZ_BITS)" == "16"
$(NMAKE) -f mozilla.mak exports
!endif
$(NMAKE) -f mozilla.mak DEPEND=1
$(NMAKE) -f mozilla.mak
build_layout:
@cd $(MOZ_SRC)\mozilla\.
nmake -f makefile.win all
build_dist:
@cd $(MOZ_SRC)\mozilla\.
nmake -f makefile.win all
#
# remove all source files from the tree and print a report of what was missed
#
clobber_all:
cd $(MOZ_SRC)\ns
$(NMAKE) -f makefile.win clobber_all
cd $(MOZ_SRC)\ns\cmd\winfe\mkfiles32
$(NMAKE) -f mozilla.mak clobber_all
!if !defined(MOZ_MEDIUM)
cd $(MOZ_SRC)\ns\netsite\ldap\libraries\msdos\winsock
$(NMAKE) -f nsldap.mak clobber_all
!endif
libs:
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
nmake -f makefile.win libs
depend:
-del /s /q make.dep
$(NMAKE) -f makefile.win depend
export: build_nspr build_ldapcsdk
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
nmake -f makefile.win export
clobber_dist:
@cd $(MOZ_SRC)\mozilla\.
nmake -f makefile.win clobber_all
clobber_client:
@cd $(MOZ_SRC)\mozilla\.
nmake -f makefile.win clobber_all
clobber_layout:
@cd $(MOZ_SRC)\mozilla\.
nmake -f makefile.win clobber_all
browse_info::
cd $(MOZ_SRC)\$(MOZ_TOP)
-dir /s /b *.sbr > sbrlist.tmp
-bscmake /Es /o mozilla.bsc @sbrlist.tmp
-rm sbrlist.tmp
regchrome::
@cd $(MOZ_SRC)\mozilla\.
nmake /f makefile.win regchrome
deliver::
@cd $(MOZ_SRC)\mozilla\.
nmake /f makefile.win splitsymbols
quick:
@cd $(MOZ_SRC)\.
@cvs -q co ns/quickup
@cd $(MOZ_SRC)\ns\quickup
@$(MOZ_TOOLS)\perl5\perl doupdate.pl
#//------------------------------------------------------------------------
#// Utility stuff...
@@ -452,9 +173,7 @@ deliver::
#//------------------------------------------------------------------------
# Check to see if it is set at all
!if "$(MOZ_SRC)"==""
MOZ_SRC = $(MAKEDIR)\..
!endif
!if "$(MOZ_SRC)"!=""
#
# create a temp file at the root and make sure it is visible from MOZ_SRC
@@ -462,14 +181,20 @@ MOZ_SRC = $(MAKEDIR)\..
!if [copy $(MAKEDIR)\client.mak $(MAKEDIR)\xyzzy.tmp > NUL] == 0
!endif
!if !EXIST( $(MOZ_SRC)\mozilla\xyzzy.tmp )
!if !EXIST( $(MOZ_SRC)\ns\xyzzy.tmp )
ERR_MESSAGE=$(ERR_MESSAGE)^
MOZ_SRC isn't set correctly: [$(MOZ_SRC)\mozilla]!=[$(MAKEDIR)]
MOZ_SRC isn't set correctly: [$(MOZ_SRC)\ns]!=[$(MAKEDIR)]
!endif
!if [del $(MAKEDIR)\xyzzy.tmp]
!endif
!else
# MOZ_SRC isn't set at all
ERR_MESSAGE=$(ERR_MESSAGE)^
Environment variable MOZ_SRC isn't set.
!endif
#//------------------------------------------------------------------------
# Verify that MOZ_BITS is set
#//------------------------------------------------------------------------
@@ -488,6 +213,7 @@ Environment variable MOZ_TOOLS isn't set.
#// Display error
#//------------------------------------------------------------------------
!if "$(ERR_MESSAGE)" != ""
ERR_MESSAGE = ^
client.mak: ^
@@ -499,13 +225,22 @@ nmake -f client.mak [MOZ_BRANCH=<cvs_branch_name>] ^
[MOZ_DATE=<cvs_date>]^
[pull_and_build_all]^
[pull_all]^
[pull_dist]^
[pull_client]^
[build_all]^
[build_dist]^
[build_ldap]^
[build_client]^
^
Environment variables:^
^
MOZ_BITS set to 32^
MOZ_TOOLS set to the directory containing the needed tools ^
MOZ_BITS set to either 32 or 16 ^
MOZ_SRC set to the directory above ns or "$(MAKEDIR)\.."^
MOZ_TOOLS set to the directory containing the java compiler see ^
http://warp/tools/nt^
JAVA_HOME set to the same thing as MOZ_TOOLS^
!ERROR $(ERR_MESSAGE)
!endif

View File

@@ -1,650 +0,0 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Stephen Lamm
# Build the Mozilla client.
#
# This needs CVSROOT set to work, e.g.,
# setenv CVSROOT :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
# or
# setenv CVSROOT :pserver:username%somedomain.org@cvs.mozilla.org:/cvsroot
#
# To checkout and build a tree,
# 1. cvs co mozilla/client.mk
# 2. cd mozilla
# 3. gmake -f client.mk
#
# Other targets (gmake -f client.mk [targets...]),
# checkout
# build
# clean (realclean is now the same as clean)
# distclean
#
# See http://www.mozilla.org/build/unix.html for more information.
#
# Options:
# MOZ_OBJDIR - Destination object directory
# MOZ_CO_DATE - Date tag to use for checkout (default: none)
# MOZ_CO_MODULE - Module to checkout (default: SeaMonkeyAll)
# MOZ_CVS_FLAGS - Flags to pass cvs (default: -q -z3)
# MOZ_CO_FLAGS - Flags to pass after 'cvs co' (default: -P)
# MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
# MOZ_CO_BRANCH - Branch tag (Deprecated. Use MOZ_CO_TAG below.)
#
#######################################################################
# Checkout Tags
#
# For branches, uncomment the MOZ_CO_TAG line with the proper tag,
# and commit this file on that tag.
MOZ_CO_TAG = NETSCAPE_7_0_RTM
NSPR_CO_TAG = NETSCAPE_7_0_RTM
PSM_CO_TAG = NETSCAPE_7_0_RTM
NSS_CO_TAG = NETSCAPE_7_0_RTM
LDAPCSDK_CO_TAG = NETSCAPE_7_0_RTM
ACCESSIBLE_CO_TAG = NETSCAPE_7_0_RTM
GFX2_CO_TAG = NETSCAPE_7_0_RTM
IMGLIB2_CO_TAG = NETSCAPE_7_0_RTM
BUILD_MODULES = all
#######################################################################
# Defines
#
CVS = cvs
CWD := $(shell pwd)
ifeq "$(CWD)" "/"
CWD := /.
endif
ifneq (, $(wildcard client.mk))
# Ran from mozilla directory
ROOTDIR := $(shell dirname $(CWD))
TOPSRCDIR := $(CWD)
else
# Ran from mozilla/.. directory (?)
ROOTDIR := $(CWD)
TOPSRCDIR := $(CWD)/mozilla
endif
# on os2, TOPSRCDIR may have two forward slashes in a row, which doesn't
# work; replace first instance with one forward slash
TOPSRCDIR := $(shell echo "$(TOPSRCDIR)" | sed -e 's%//%/%')
ifndef TOPSRCDIR_MOZ
TOPSRCDIR_MOZ=$(TOPSRCDIR)
endif
# if ROOTDIR equals only drive letter (i.e. "C:"), set to "/"
DIRNAME := $(shell echo "$(ROOTDIR)" | sed -e 's/^.://')
ifeq ($(DIRNAME),)
ROOTDIR := /.
endif
AUTOCONF := autoconf
MKDIR := mkdir
SH := /bin/sh
ifndef MAKE
MAKE := gmake
endif
CONFIG_GUESS_SCRIPT := $(wildcard $(TOPSRCDIR)/build/autoconf/config.guess)
ifdef CONFIG_GUESS_SCRIPT
CONFIG_GUESS = $(shell $(CONFIG_GUESS_SCRIPT))
else
_IS_FIRST_CHECKOUT := 1
endif
####################################
# CVS
# Add the CVS root to CVS_FLAGS if needed
CVS_ROOT_IN_TREE := $(shell cat $(TOPSRCDIR)/CVS/Root 2>/dev/null)
ifneq ($(CVS_ROOT_IN_TREE),)
ifneq ($(CVS_ROOT_IN_TREE),$(CVSROOT))
CVS_FLAGS := -d $(CVS_ROOT_IN_TREE)
endif
endif
CVSCO = $(strip $(CVS) $(CVS_FLAGS) co $(CVS_CO_FLAGS))
CVSCO_LOGFILE := $(ROOTDIR)/cvsco.log
CVSCO_LOGFILE := $(shell echo $(CVSCO_LOGFILE) | sed s%//%/%)
ifdef MOZ_CO_TAG
CVS_CO_FLAGS := -r $(MOZ_CO_TAG)
endif
####################################
# Load mozconfig Options
# See build pages, http://www.mozilla.org/build/unix.html,
# for how to set up mozconfig.
MOZCONFIG_LOADER := mozilla/build/autoconf/mozconfig2client-mk
MOZCONFIG_FINDER := mozilla/build/autoconf/mozconfig-find
MOZCONFIG_MODULES := mozilla/build/unix/modules.mk
run_for_side_effects := \
$(shell cd $(ROOTDIR); \
if test "$(_IS_FIRST_CHECKOUT)"; then \
$(CVSCO) $(MOZCONFIG_FINDER) $(MOZCONFIG_LOADER) $(MOZCONFIG_MODULES); \
else true; \
fi; \
$(MOZCONFIG_LOADER) $(TOPSRCDIR) mozilla/.mozconfig.mk > mozilla/.mozconfig.out)
include $(TOPSRCDIR)/.mozconfig.mk
include $(TOPSRCDIR)/build/unix/modules.mk
####################################
# Options that may come from mozconfig
# Change CVS flags if anonymous root is requested
ifdef MOZ_CO_USE_MIRROR
CVS_FLAGS := -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
endif
# MOZ_CVS_FLAGS - Basic CVS flags
ifeq "$(origin MOZ_CVS_FLAGS)" "undefined"
CVS_FLAGS := $(CVS_FLAGS) -q -z 3
else
CVS_FLAGS := $(MOZ_CVS_FLAGS)
endif
# This option is deprecated. The best way to have client.mk pull a tag
# is to set MOZ_CO_TAG (see above) and commit that change on the tag.
ifdef MOZ_CO_BRANCH
$(warning Use MOZ_CO_TAG instead of MOZ_CO_BRANCH)
CVS_CO_FLAGS := -r $(MOZ_CO_BRANCH)
endif
# MOZ_CO_FLAGS - Anything that we should use on all checkouts
ifeq "$(origin MOZ_CO_FLAGS)" "undefined"
CVS_CO_FLAGS := $(CVS_CO_FLAGS) -P
else
CVS_CO_FLAGS := $(CVS_CO_FLAGS) $(MOZ_CO_FLAGS)
endif
ifdef MOZ_CO_DATE
CVS_CO_DATE_FLAGS := -D "$(MOZ_CO_DATE)"
endif
ifdef MOZ_OBJDIR
OBJDIR := $(MOZ_OBJDIR)
MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
else
OBJDIR := $(TOPSRCDIR)
MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS)
endif
####################################
# CVS defines for PSM
#
PSM_CO_MODULE= mozilla/security/manager
PSM_CO_FLAGS := -P -A
ifdef MOZ_CO_FLAGS
PSM_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
ifdef PSM_CO_TAG
PSM_CO_FLAGS := $(PSM_CO_FLAGS) -r $(PSM_CO_TAG)
endif
CVSCO_PSM = $(CVS) $(CVS_FLAGS) co $(PSM_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(PSM_CO_MODULE)
####################################
# CVS defines for NSS
#
NSS_CO_MODULE = mozilla/security/nss \
mozilla/security/coreconf \
$(NULL)
NSS_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
NSS_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
ifdef NSS_CO_TAG
NSS_CO_FLAGS := $(NSS_CO_FLAGS) -r $(NSS_CO_TAG)
endif
# Cannot pull static tags by date
ifeq ($(NSS_CO_TAG),NSS_CLIENT_TAG)
CVSCO_NSS = $(CVS) $(CVS_FLAGS) co $(NSS_CO_FLAGS) $(NSS_CO_MODULE)
else
CVSCO_NSS = $(CVS) $(CVS_FLAGS) co $(NSS_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSS_CO_MODULE)
endif
####################################
# CVS defines for NSPR
#
NSPR_CO_MODULE = mozilla/nsprpub
NSPR_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
NSPR_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
ifdef NSPR_CO_TAG
NSPR_CO_FLAGS := $(NSPR_CO_FLAGS) -r $(NSPR_CO_TAG)
endif
# Cannot pull static tags by date
ifeq ($(NSPR_CO_TAG),NSPRPUB_CLIENT_TAG)
CVSCO_NSPR = $(CVS) $(CVS_FLAGS) co $(NSPR_CO_FLAGS) $(NSPR_CO_MODULE)
else
CVSCO_NSPR = $(CVS) $(CVS_FLAGS) co $(NSPR_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSPR_CO_MODULE)
endif
####################################
# CVS defines for the C LDAP SDK
#
LDAPCSDK_CO_MODULE = mozilla/directory/c-sdk
LDAPCSDK_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
LDAPCSDK_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
ifdef LDAPCSDK_CO_TAG
LDAPCSDK_CO_FLAGS := $(LDAPCSDK_CO_FLAGS) -r $(LDAPCSDK_CO_TAG)
endif
CVSCO_LDAPCSDK = $(CVS) $(CVS_FLAGS) co $(LDAPCSDK_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(LDAPCSDK_CO_MODULE)
####################################
# CVS defines for the C LDAP SDK
#
ACCESSIBLE_CO_MODULE = mozilla/accessible
ACCESSIBLE_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
ACCESSIBLE_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
ifdef ACCESSIBLE_CO_TAG
ACCESSIBLE_CO_FLAGS := $(ACCESSIBLE_CO_FLAGS) -r $(ACCESSIBLE_CO_TAG)
endif
CVSCO_ACCESSIBLE = $(CVS) $(CVS_FLAGS) co $(ACCESSIBLE_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(ACCESSIBLE_CO_MODULE)
####################################
# CVS defines for gfx2
#
GFX2_CO_MODULE = mozilla/gfx2
GFX2_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
GFX2_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
ifdef GFX2_CO_TAG
GFX2_CO_FLAGS := $(GFX2_CO_FLAGS) -r $(GFX2_CO_TAG)
endif
CVSCO_GFX2 = $(CVS) $(CVS_FLAGS) co $(GFX2_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(GFX2_CO_MODULE)
####################################
# CVS defines for new image library
#
IMGLIB2_CO_MODULE = mozilla/modules/libpr0n
IMGLIB2_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
IMGLIB2_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
ifdef IMGLIB2_CO_TAG
IMGLIB2_CO_FLAGS := $(IMGLIB2_CO_FLAGS) -r $(IMGLIB2_CO_TAG)
endif
CVSCO_IMGLIB2 = $(CVS) $(CVS_FLAGS) co $(IMGLIB2_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(IMGLIB2_CO_MODULE)
####################################
# CVS defines for standalone modules
#
ifneq ($(BUILD_MODULES),all)
MOZ_CO_MODULE := $(filter-out $(NSPRPUB_DIR) security directory/c-sdk, $(BUILD_MODULE_CVS))
MOZ_CO_MODULE += allmakefiles.sh client.mk aclocal.m4 configure configure.in
MOZ_CO_MODULE += Makefile.in
MOZ_CO_MODULE := $(addprefix mozilla/, $(MOZ_CO_MODULE))
NOSUBDIRS_MODULE := $(addprefix mozilla/, $(BUILD_MODULE_CVS_NS))
ifneq ($(NOSUBDIRS_MODULE),)
CVSCO_NOSUBDIRS := $(CVSCO) -l $(CVS_CO_DATE_FLAGS) $(NOSUBDIRS_MODULE)
endif
ifeq (,$(filter $(NSPRPUB_DIR), $(BUILD_MODULE_CVS)))
CVSCO_NSPR :=
endif
ifeq (,$(filter security security/manager, $(BUILD_MODULE_CVS)))
CVSCO_PSM :=
CVSCO_NSS :=
endif
ifeq (,$(filter directory/c-sdk, $(BUILD_MODULE_CVS)))
CVSCO_LDAPCSDK :=
endif
ifeq (,$(filter accessible, $(BUILD_MODULE_CVS)))
CVSCO_ACCESSIBLE :=
endif
ifeq (,$(filter gfx2, $(BUILD_MODULE_CVS)))
CVSCO_GFX2 :=
endif
ifeq (,$(filter modules/libpr0n, $(BUILD_MODULE_CVS)))
CVSCO_IMGLIB2 :=
endif
endif
####################################
# CVS defines for SeaMonkey
#
ifeq ($(MOZ_CO_MODULE),)
MOZ_CO_MODULE := SeaMonkeyAll
endif
CVSCO_SEAMONKEY := $(CVSCO) $(CVS_CO_DATE_FLAGS) $(MOZ_CO_MODULE)
####################################
# CVS defined for libart (pulled and built if MOZ_INTERNAL_LIBART_LGPL is set)
#
CVSCO_LIBART := $(CVSCO) $(CVS_CO_DATE_FLAGS) mozilla/other-licenses/libart_lgpl
ifdef MOZ_INTERNAL_LIBART_LGPL
FASTUPDATE_LIBART := fast_update $(CVSCO_LIBART)
CHECKOUT_LIBART := cvs_co $(CVSCO_LIBART)
else
CHECKOUT_LIBART := true
FASTUPDATE_LIBART := true
endif
####################################
# CVS defines for Calendar (pulled and built if MOZ_CALENDAR is set)
#
CVSCO_CALENDAR := $(CVSCO) $(CVS_CO_DATE_FLAGS) mozilla/calendar
ifdef MOZ_CALENDAR
FASTUPDATE_CALENDAR := fast_update $(CVSCO_CALENDAR)
CHECKOUT_CALENDAR := cvs_co $(CVSCO_CALENDAR)
else
CHECKOUT_CALENDAR := true
FASTUPDATE_CALENDAR := true
endif
# because some cygwin tools can't handle native dos-drive paths & vice-versa
# force configure to use a relative path for --srcdir
# need a better check for win32
# and we need to get OBJDIR earlier
ifdef MOZ_TOOLS
_tmpobjdir := $(shell cygpath -u $(OBJDIR))
_abs2rel := $(shell cygpath -w $(TOPSRCDIR)/build/unix/abs2rel.pl | sed -e 's|\\|/|g')
_OBJ2SRCPATH := $(shell $(_abs2rel) $(TOPSRCDIR) $(_tmpobjdir))
endif
#######################################################################
# Rules
#
# Print out any options loaded from mozconfig.
all build checkout clean depend distclean export libs install realclean::
@if test -f .mozconfig.out; then \
cat .mozconfig.out; \
rm -f .mozconfig.out; \
else true; \
fi
ifdef _IS_FIRST_CHECKOUT
all:: checkout build
else
all:: checkout alldep
endif
# Windows equivalents
pull_all: checkout
build_all: build
build_all_dep: alldep
build_all_depend: alldep
clobber clobber_all: clean
pull_and_build_all: checkout alldep
# Do everything from scratch
everything: checkout clean build
####################################
# CVS checkout
#
checkout::
# @: Backup the last checkout log.
@if test -f $(CVSCO_LOGFILE) ; then \
mv $(CVSCO_LOGFILE) $(CVSCO_LOGFILE).old; \
else true; \
fi
ifdef RUN_AUTOCONF_LOCALLY
@echo "Removing local configures" ; \
cd $(ROOTDIR) && \
$(RM) -f mozilla/configure mozilla/nsprpub/configure \
mozilla/directory/c-sdk/configure
endif
@echo "checkout start: "`date` | tee $(CVSCO_LOGFILE)
@echo '$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk'; \
cd $(ROOTDIR) && \
$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk
@cd $(ROOTDIR) && $(MAKE) -f mozilla/client.mk real_checkout
real_checkout:
# @: Start the checkout. Split the output to the tty and a log file. \
# : If it fails, touch an error file because "tee" hides the error.
@failed=.cvs-failed.tmp; rm -f $$failed*; \
cvs_co() { echo "$$@" ; \
("$$@" || touch $$failed) 2>&1 | tee -a $(CVSCO_LOGFILE) && \
if test -f $$failed; then false; else true; fi; }; \
cvs_co $(CVSCO_NSPR) && \
cvs_co $(CVSCO_NSS) && \
cvs_co $(CVSCO_PSM) && \
cvs_co $(CVSCO_LDAPCSDK) && \
cvs_co $(CVSCO_ACCESSIBLE) && \
cvs_co $(CVSCO_GFX2) && \
cvs_co $(CVSCO_IMGLIB2) && \
$(CHECKOUT_CALENDAR) && \
$(CHECKOUT_LIBART) && \
cvs_co $(CVSCO_SEAMONKEY) && \
cvs_co $(CVSCO_NOSUBDIRS)
@echo "checkout finish: "`date` | tee -a $(CVSCO_LOGFILE)
# @: Check the log for conflicts. ;
@conflicts=`egrep "^C " $(CVSCO_LOGFILE)` ;\
if test "$$conflicts" ; then \
echo "$(MAKE): *** Conflicts during checkout." ;\
echo "$$conflicts" ;\
echo "$(MAKE): Refer to $(CVSCO_LOGFILE) for full log." ;\
false; \
else true; \
fi
ifdef RUN_AUTOCONF_LOCALLY
@echo Generating configures using $(AUTOCONF) ; \
cd $(TOPSRCDIR) && $(AUTOCONF) && \
cd $(TOPSRCDIR)/nsprpub && $(AUTOCONF) && \
cd $(TOPSRCDIR)/directory/c-sdk && $(AUTOCONF)
endif
fast-update:
# @: Backup the last checkout log.
@if test -f $(CVSCO_LOGFILE) ; then \
mv $(CVSCO_LOGFILE) $(CVSCO_LOGFILE).old; \
else true; \
fi
ifdef RUN_AUTOCONF_LOCALLY
@echo "Removing local configures" ; \
cd $(ROOTDIR) && \
$(RM) -f mozilla/configure mozilla/nsprpub/configure \
mozilla/directory/c-sdk/configure
endif
@echo "checkout start: "`date` | tee $(CVSCO_LOGFILE)
@echo '$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk'; \
cd $(ROOTDIR) && \
$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk
@cd $(TOPSRCDIR) && \
$(MAKE) -f client.mk real_fast-update
real_fast-update:
# @: Start the update. Split the output to the tty and a log file. \
# : If it fails, touch an error file because "tee" hides the error.
@failed=.fast_update-failed.tmp; rm -f $$failed*; \
fast_update() { (config/cvsco-fast-update.pl $$@ || touch $$failed) 2>&1 | tee -a $(CVSCO_LOGFILE) && \
if test -f $$failed; then false; else true; fi; }; \
cvs_co() { echo "$$@" ; \
("$$@" || touch $$failed) 2>&1 | tee -a $(CVSCO_LOGFILE) && \
if test -f $$failed; then false; else true; fi; }; \
fast_update $(CVSCO_NSPR) && \
cd $(ROOTDIR) && \
failed=mozilla/.fast_update-failed.tmp && \
cvs_co $(CVSCO_NSS) && \
failed=.fast_update-failed.tmp && \
cd mozilla && \
fast_update $(CVSCO_PSM) && \
fast_update $(CVSCO_LDAPCSDK) && \
fast_update $(CVSCO_ACCESSIBLE) && \
fast_update $(CVSCO_GFX2) && \
fast_update $(CVSCO_IMGLIB2) && \
$(FASTUPDATE_CALENDAR) && \
$(FASTUPDATE_LIBART) && \
fast_update $(CVSCO_SEAMONKEY) && \
fast_update $(CVSCO_NOSUBDIRS)
@echo "fast_update finish: "`date` | tee -a $(CVSCO_LOGFILE)
# @: Check the log for conflicts. ;
@conflicts=`egrep "^C " $(CVSCO_LOGFILE)` ;\
if test "$$conflicts" ; then \
echo "$(MAKE): *** Conflicts during fast-update." ;\
echo "$$conflicts" ;\
echo "$(MAKE): Refer to $(CVSCO_LOGFILE) for full log." ;\
false; \
else true; \
fi
ifdef RUN_AUTOCONF_LOCALLY
@echo Generating configures using $(AUTOCONF) ; \
cd $(TOPSRCDIR) && $(AUTOCONF) && \
cd $(TOPSRCDIR)/nsprpub && $(AUTOCONF) && \
cd $(TOPSRCDIR)/directory/c-sdk && $(AUTOCONF)
endif
####################################
# Web configure
WEBCONFIG_FILE := $(HOME)/.mozconfig
MOZCONFIG2CONFIGURATOR := build/autoconf/mozconfig2configurator
webconfig:
@cd $(TOPSRCDIR); \
url=`$(MOZCONFIG2CONFIGURATOR) $(TOPSRCDIR)`; \
echo Running mozilla with the following url: ;\
echo ;\
echo $$url ;\
mozilla -remote "openURL($$url)" || \
netscape -remote "openURL($$url)" || \
mozilla $$url || \
netscape $$url ;\
echo ;\
echo 1. Fill out the form on the browser. ;\
echo 2. Save the results to $(WEBCONFIG_FILE)
#####################################################
# First Checkout
ifdef _IS_FIRST_CHECKOUT
# First time, do build target in a new process to pick up new files.
build::
$(MAKE) -f $(TOPSRCDIR)/client.mk build
else
#####################################################
# After First Checkout
####################################
# Configure
CONFIG_STATUS := $(wildcard $(OBJDIR)/config.status)
CONFIG_CACHE := $(wildcard $(OBJDIR)/config.cache)
ifdef RUN_AUTOCONF_LOCALLY
EXTRA_CONFIG_DEPS := \
$(TOPSRCDIR)/aclocal.m4 \
$(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
$(NULL)
$(TOPSRCDIR)/configure: $(TOPSRCDIR)/configure.in $(EXTRA_CONFIG_DEPS)
@echo Generating $@ using autoconf
cd $(TOPSRCDIR); $(AUTOCONF)
endif
CONFIG_STATUS_DEPS_L10N := $(wildcard $(TOPSRCDIR)/l10n/makefiles.all)
CONFIG_STATUS_DEPS := \
$(TOPSRCDIR)/configure \
$(TOPSRCDIR)/allmakefiles.sh \
$(TOPSRCDIR)/.mozconfig.mk \
$(wildcard $(TOPSRCDIR)/nsprpub/configure) \
$(wildcard $(TOPSRCDIR)/directory/c-sdk/configure) \
$(wildcard $(TOPSRCDIR)/mailnews/makefiles) \
$(CONFIG_STATUS_DEPS_L10N) \
$(wildcard $(TOPSRCDIR)/themes/makefiles) \
$(NULL)
# configure uses the program name to determine @srcdir@. Calling it without
# $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
# path of $(TOPSRCDIR).
ifeq ($(TOPSRCDIR),$(OBJDIR))
CONFIGURE := ./configure
else
CONFIGURE := $(TOPSRCDIR)/configure
endif
ifdef _OBJ2SRCPATH
CONFIGURE_ARGS := --srcdir=$(_OBJ2SRCPATH) $(CONFIGURE_ARGS)
endif
$(OBJDIR)/Makefile $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
@if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); else true; fi
@echo cd $(OBJDIR);
@echo $(CONFIGURE) $(CONFIGURE_ARGS)
@cd $(OBJDIR) && $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
|| ( echo "*** Fix above errors and then restart with\
\"$(MAKE) -f client.mk build\"" && exit 1 )
@touch $(OBJDIR)/Makefile
ifdef CONFIG_STATUS
$(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
cd $(OBJDIR); \
CONFIG_FILES=config/autoconf.mk ./config.status
endif
####################################
# Depend
depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
$(MOZ_MAKE) export && $(MOZ_MAKE) depend
####################################
# Build it
build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
$(MOZ_MAKE)
####################################
# Other targets
# Pass these target onto the real build system
install export libs clean realclean distclean alldep:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
$(MOZ_MAKE) $@
cleansrcdir:
@cd $(TOPSRCDIR); \
if [ -f webshell/embed/gtk/Makefile ]; then \
$(MAKE) -C webshell/embed/gtk distclean; \
fi; \
if [ -f Makefile ]; then \
$(MAKE) distclean ; \
else \
echo "Removing object files from srcdir..."; \
rm -fr `find . -type d \( -name .deps -print -o -name CVS \
-o -exec test ! -d {}/CVS \; \) -prune \
-o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
build/autoconf/clean-config.sh; \
fi;
# (! IS_FIRST_CHECKOUT)
endif
.PHONY: checkout real_checkout depend build export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything

26
mozilla/cmd/Makefile Normal file
View File

@@ -0,0 +1,26 @@
#
# 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 = ..
ifeq ($(subst /,,$(shell uname -s)),OS2)
# until we have an FE...
DIRS =
else
DIRS = xfe patcher
endif
include $(DEPTH)/config/rules.mk

View File

@@ -0,0 +1,788 @@
/* -*- 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.
*/
// ===========================================================================
// CColorPopup.cp
// ===========================================================================
#include "CColorPopup.h"
#include "UGraphicGizmos.h"
#include "UGraphicsUtilities.h"
#include "CTargetedUpdateMenuRegistry.h"
#include "CEditView.h" // constant for menu string resource
#include "edt.h" // EDT calls
#include "prefapi.h"
#include "StSetBroadcasting.h"
#include "CBrowserContext.h" // MWContext
// prototypes
pascal void
colorPopupMDEFProc( short message, MenuHandle theMenu,
Rect *menuRect, Point hitPt, short *whichItem );
// functionality
static
void
colorPopupGetBox( Rect *menuRect, Rect *itemBox, short numItems, short theItem )
{
Rect box;
SetRect( itemBox, 0, 0, 0, 0 );
if ( theItem <= numItems )
{
if ( theItem == CColorPopup::CURRENT_COLOR_ITEM )
{
box.bottom = menuRect->bottom - CColorPopup::COLOR_FRAME_BORDER;
box.top = box.bottom - CColorPopup::COLOR_BOX_HEIGHT;
box.left = menuRect->left + CColorPopup::COLOR_FRAME_BORDER;
box.right = box.left + CColorPopup::COLOR_BOX_HEIGHT;
}
else if ( theItem == CColorPopup::DEFAULT_COLOR_ITEM )
{
box.bottom = menuRect->bottom - CColorPopup::COLOR_FRAME_BORDER
- CColorPopup::COLOR_BOX_HEIGHT;
box.top = box.bottom - CColorPopup::COLOR_BOX_HEIGHT;
box.left = menuRect->left + CColorPopup::COLOR_FRAME_BORDER;
box.right = box.left + CColorPopup::COLOR_BOX_HEIGHT;
}
else if ( theItem == CColorPopup::LAST_COLOR_PICKED_ITEM )
{
box.top = menuRect->top + CColorPopup::COLOR_FRAME_BORDER;
box.bottom = box.top + CColorPopup::COLOR_BOX_HEIGHT;
box.left = menuRect->left + CColorPopup::COLOR_FRAME_BORDER;
box.right = box.left + CColorPopup::COLOR_BOX_HEIGHT;
}
else
{
box.top = menuRect->top /* + CColorPopup::COLOR_FRAME_BORDER */ + CColorPopup::COLOR_HEX_DISPLAY_SIZE;
box.left = menuRect->left + CColorPopup::COLOR_FRAME_BORDER;
box.bottom = box.top + CColorPopup::COLOR_BOX_HEIGHT;
box.right = box.left + CColorPopup::COLOR_BOX_WIDTH;
while ( --theItem > 1 ) // 1 is # menuItems preceding color chip matrix
{
OffsetRect( &box, CColorPopup::COLOR_BOX_WIDTH, 0 );
if ( box.left >= menuRect->right - CColorPopup::COLOR_FRAME_BORDER )
{
box.left = menuRect->left + CColorPopup::COLOR_FRAME_BORDER;
box.right = box.left + CColorPopup::COLOR_BOX_WIDTH;
OffsetRect( &box, 0, CColorPopup::COLOR_BOX_HEIGHT );
}
}
}
*itemBox = box;
}
}
static
Boolean
colorPopupParseColor( Str255 menuStr, RGBColor *theColor )
{
Boolean foundColorFlag = false;
unsigned short part;
short loop;
theColor->red = theColor->green = theColor->blue = 0;
for ( loop = 1; loop <= (unsigned)menuStr[ 0 ] - 6; ++loop )
{
if ( menuStr[0] > 1
&& ( menuStr[ loop ] == CColorPopup::COLOR_CHIP_CHAR
|| menuStr[ loop ] == CColorPopup::LAST_COLOR_PICKED_CHAR
|| menuStr[ loop ] == CColorPopup::DEFAULT_COLOR_CHAR
|| menuStr[ loop ] == CColorPopup::CURRENT_COLOR_CHAR ) )
{
// Converting from ASCII to Hex
// This is BAD code...
part = menuStr[ loop + 1 ] - '0';
if ( part > 9 )
part = menuStr[ loop + 1 ] - 'A' + 10;
theColor->red = part << 4;
part = menuStr[ loop + 2 ] - '0';
if ( part > 9 )
part = menuStr[ loop + 2 ] - 'A' + 10;
theColor->red |= part;
theColor->red = theColor->red << 8;
part = menuStr[ loop + 3 ] - '0';
if ( part > 9 )
part = menuStr[ loop + 3 ] - 'A' + 10;
theColor->green = part << 4;
part = menuStr[ loop + 4 ] - '0';
if ( part > 9 )
part = menuStr[ loop + 4 ] - 'A' + 10;
theColor->green |= part;
theColor->green = theColor->green << 8;
part = menuStr[ loop + 5 ] - '0';
if ( part > 9 )
part = menuStr[ loop + 5 ] - 'A' + 10;
theColor->blue = part << 4;
part = menuStr[ loop + 6 ] - '0';
if ( part > 9 )
part = menuStr[ loop + 6 ] - 'A' + 10;
theColor->blue |= part;
theColor->blue = theColor->blue << 8;
foundColorFlag = true;
break;
}
}
return foundColorFlag;
}
static
void
colorPopupDrawBox( MenuHandle theMenu, Rect *menuRect, short numItems )
{
Boolean wildcardFlag;
CIconHandle cicnHandle;
RGBColor theColor;
const RGBColor black = {0,0,0}, white = {0xFFFF,0xFFFF,0xFFFF};
Rect box;
Str255 menuStr;
short theItem;
for ( theItem = 1; theItem <= numItems; ++theItem )
{
menuStr[ 0 ] = 0;
GetMenuItemText( theMenu, theItem, menuStr );
wildcardFlag = ((menuStr[0] == 0x01 && menuStr[1] == CColorPopup::COLOR_PICKER_CHAR)) ? true : false;
colorPopupGetBox( menuRect, &box, numItems, theItem );
// text (if any)
int stringNum;
switch ( menuStr[1] )
{
default: stringNum = 0; break;
case CColorPopup::LAST_COLOR_PICKED_CHAR: stringNum = 20; break;
case CColorPopup::DEFAULT_COLOR_CHAR: stringNum = 21; break;
case CColorPopup::CURRENT_COLOR_CHAR: stringNum = 22; break;
}
if ( stringNum )
{
Point baseLinePoint;
baseLinePoint.v = box.top + CColorPopup::COLOR_BOX_HEIGHT - 4;
baseLinePoint.h = box.right + CColorPopup::COLOR_FRAME_BORDER;
Str255 menuItemStr;
menuItemStr[ 0 ] = 0;
::GetIndString( menuItemStr, CEditView::STRPOUND_EDITOR_MENUS, stringNum );
::RGBBackColor( &white );
::RGBForeColor( &black );
::MoveTo( baseLinePoint.h, baseLinePoint.v );
::DrawString( menuItemStr );
}
// draw color chip
if ( (true == wildcardFlag ) || (colorPopupParseColor( menuStr, &theColor ) == true))
{
::InsetRect( &box, 1, 1 );
::RGBForeColor( &black );
::MoveTo( box.left, box.bottom - 1 );
::LineTo( box.left, box.top );
::LineTo( box.right - 1, box.top );
#ifdef THREE_D_EFFECT_ON_COLOR_POPUP
::RGBForeColor( &white );
#endif
::LineTo( box.right - 1, box.bottom - 1 );
::LineTo( box.left, box.bottom - 1 );
if ( true == wildcardFlag )
{
RGBForeColor( &black );
if ( (cicnHandle = GetCIcon(11685)) != NULL )
{
// don't scale, plot into same size rect
Rect r = (**cicnHandle).iconPMap.bounds;
box.bottom = box.top + r.bottom - r.top;
box.right = box.left + r.right - r.left;
::PlotCIcon( &box, cicnHandle );
::DisposeCIcon( cicnHandle );
}
}
else
{
InsetRect( &box, 1, 1 );
RGBForeColor( &theColor );
PaintRect( &box );
::RGBForeColor( &black );
box.left += ( box.right-box.left ) / 2;
box.right = box.left;
box.top += ( box.bottom - box.top ) / 2;
box.bottom = box.top;
InsetRect( &box, -4, -4 );
}
}
}
}
static
void
colorPopupChooseColor( Rect *menuRect, Point hitPt,
short *whichItem, short numItems, RGBColor *backColor )
{
RGBColor aColor;
Rect box, oldBox;
short newItem = 0, loop;
colorPopupGetBox( menuRect, &oldBox, numItems, *whichItem );
if ( PtInRect( hitPt, menuRect ) )
{
for ( loop = 1; loop <= numItems; loop++ )
{
colorPopupGetBox( menuRect, &box, numItems, loop );
if ( PtInRect( hitPt, &box ) )
{
newItem = loop;
break;
}
}
if ( *whichItem != newItem )
{
// deselect old menu item, select new menu item
if ( *whichItem > 0 )
{
RGBForeColor( backColor );
FrameRect( &oldBox );
}
if ( newItem > 0 )
{
aColor.red = aColor.blue = aColor.green = 0;
RGBForeColor( &aColor );
FrameRect( &box );
}
#if COLOR_DISPLAY_TEXT
box = *menuRect;
box.top = box.bottom - COLOR_HEX_DISPLAY_SIZE;
EraseRect( &box );
if ( newItem > 0 )
{
menuStr[ 0 ] = 0;
GetMenuItemText( theMenu, newItem, menuStr );
if ( colorPopupParseColor( menuStr, &aColor ) == true )
{
if ( menuStr[ 0 ] )
{
// XXX should save/restore current font info, and set a particular (system?) font
MoveTo( box.left + ((box.right-box.left) / 2) - ( ::StringWidth(menuStr) / 2),
box.bottom - 4);
DrawString( menuStr );
}
}
}
#endif
*whichItem = newItem;
}
}
else if ( *whichItem > 0 )
{
// deselect old menu item
RGBForeColor( backColor );
FrameRect( &oldBox );
#if COLOR_DISPLAY_TEXT
box = *menuRect;
box.top = box.bottom - COLOR_HEX_DISPLAY_SIZE;
EraseRect( &box );
#endif
*whichItem = 0; // clear old item
}
}
pascal void
colorPopupMDEFProc(short message, MenuHandle theMenu,
Rect *menuRect, Point hitPt, short *whichItem)
{
if ( theMenu == NULL )
return;
PenState pnState;
RGBColor foreColor, backColor;
#if 0
Boolean growRowsFlag = false;
#endif
short numItems, numCols, numRows;
numItems = ::CountMItems( theMenu );
::GetPenState( &pnState );
::GetForeColor( &foreColor );
::PenNormal();
switch( message )
{
case mDrawMsg:
colorPopupDrawBox( theMenu, menuRect, numItems );
break;
case mChooseMsg:
::GetBackColor( &backColor );
colorPopupChooseColor( menuRect, hitPt, whichItem, numItems, &backColor );
::RGBBackColor( &backColor );
break;
case mSizeMsg:
// determine # of rows/cols needed
#if 0
if ( numItems > 0 )
{
numRows = numCols = 1;
while( numItems > (numRows * numCols) )
{
if ( growRowsFlag )
++numRows;
else
++numCols;
growRowsFlag = (!growRowsFlag);
}
}
#endif
#if 1
// hard code these for now
numRows = 10;
numCols = 10;
#endif
// why are the width and height backwards? If they are switched, the menu is wrong shape
(**theMenu).menuHeight = (numRows * CColorPopup::COLOR_BOX_HEIGHT) + (2 * CColorPopup::COLOR_FRAME_BORDER);
(**theMenu).menuWidth = (numCols * CColorPopup::COLOR_BOX_WIDTH) + CColorPopup::COLOR_FRAME_BORDER;
#if COLOR_DISPLAY_TEXT
(**theMenu).menuWidth += CColorPopup::COLOR_HEX_DISPLAY_SIZE;
#endif
break;
case mPopUpMsg:
::SetRect( menuRect, hitPt.v, hitPt.h,
hitPt.v + (**theMenu).menuWidth, hitPt.h + (**theMenu).menuHeight );
break;
/*
case mDrawItemMsg:
break;
case mCalcItemMsg:
break;
*/
}
::RGBForeColor( &foreColor );
SetPenState( &pnState );
}
// This class overrides CPatternButtonPopup to provide a popup menu which
// changes the descriptor based on the menu selection
// assumes left-justified text in DrawButtonTitle()
// ---------------------------------------------------------------------------
// ¥ CColorPopup
// ---------------------------------------------------------------------------
// Stream-based ctor
CColorPopup::CColorPopup(LStream* inStream)
: CPatternButtonPopupText(inStream)
{
}
void CColorPopup::FinishCreateSelf()
{
LView *superview = NULL, *view = GetSuperView();
while ( view )
{
view = view->GetSuperView();
if ( view )
superview = view;
}
mEditView = (CEditView *)superview->FindPaneByID( CEditView::pane_ID );
mDoSetLastPickedPreference = false;
// need to Finish FinishCreateSelf to get menus set for retrieval
super::FinishCreateSelf();
// set the control by adjusting the menu and then getting the current color
// unfortunately, when this is called, the editView doesn't have an mwcontext
// so we can't query to find out what the current color is to set it properly
}
void
CColorPopup::InitializeCurrentColor()
{
MenuHandle menuh;
menuh = GetMenu()->GetMacMenuH();
MWContext *mwcontext;
if ( mEditView )
mwcontext = mEditView->GetNSContext()
? mEditView->GetNSContext()->operator MWContext*()
: NULL;
else
mwcontext = NULL;
char colorstr[9];
LO_Color color;
Boolean isColorFound = false;
// first try to get the color out of the character data
EDT_CharacterData* chardata;
chardata = EDT_GetCharacterData( mwcontext );
if ( chardata && chardata->pColor )
{
isColorFound = true;
color = *chardata->pColor;
XP_SPRINTF( &colorstr[2], "%02X%02X%02X", color.red, color.green, color.blue);
}
if ( chardata )
EDT_FreeCharacterData( chardata );
// if we still haven't found it, let's try the page data
if ( !isColorFound )
{
EDT_PageData *pagedata = EDT_GetPageData( mwcontext );
if ( pagedata && pagedata->pColorText )
{
isColorFound = true;
color = *pagedata->pColorText;
XP_SPRINTF( &colorstr[2], "%02X%02X%02X", color.red, color.green, color.blue);
}
if ( pagedata )
EDT_FreePageData( pagedata );
}
// if we still haven't found the color, get the browser preference
if ( !isColorFound )
{
// editor.text_color
int iSize = 9;
int result = PREF_GetCharPref( "browser.foreground_color", &colorstr[1], &iSize );
if ( result != PREF_NOERROR )
colorstr[1] = 0; // zero string if error is encountered
}
colorstr[1] = CURRENT_COLOR_CHAR; // put in leading character
colorstr[0] = strlen( &colorstr[1] );
::SetMenuItemText( menuh, CURRENT_COLOR_ITEM, (unsigned char *)&colorstr );
// set descriptor of control
if ( GetValue() == CURRENT_COLOR_ITEM )
{
SetDescriptor( (const unsigned char *)colorstr );
Refresh(); // inval the control's visible pane area
}
}
// ---------------------------------------------------------------------------
// ¥ AdjustMenuContents
// ---------------------------------------------------------------------------
// Set last color picked (first item).
void
CColorPopup::AdjustMenuContents()
{
MenuHandle menuh;
menuh = GetMenu()->GetMacMenuH();
// initialize last color picked
char colorstr[9];
int iSize = 9;
int result;
// note hack to avoid converting c-string to p-string
result = PREF_GetCharPref( "editor.last_color_used", &colorstr[1], &iSize );
if ( result == PREF_NOERROR )
{
colorstr[1] = LAST_COLOR_PICKED_CHAR; // replace '#' with '<'
colorstr[0] = strlen( &colorstr[1] );
::SetMenuItemText( menuh, LAST_COLOR_PICKED_ITEM, (unsigned char *)&colorstr );
}
// initialize the default color
result = PREF_GetCharPref( "browser.foreground_color", &colorstr[1], &iSize );
if ( result == PREF_NOERROR )
{
colorstr[1] = DEFAULT_COLOR_CHAR; // replace '#' with '<'
colorstr[0] = strlen( &colorstr[1] );
::SetMenuItemText( menuh, DEFAULT_COLOR_ITEM, (unsigned char *)&colorstr );
}
// initialize the current color
InitializeCurrentColor();
}
void CColorPopup::HandlePopupMenuSelect( Point inPopupLoc, Int16 inCurrentItem,
Int16& outMenuID, Int16& outMenuItem )
{
super::HandlePopupMenuSelect( inPopupLoc, inCurrentItem, outMenuID, outMenuItem );
// check if we need to set the preference here...
mDoSetLastPickedPreference = ( outMenuID && outMenuItem != DEFAULT_COLOR_ITEM );
}
void CColorPopup::SetValue(Int32 inValue)
{
if ( inValue == 0 )
inValue = CURRENT_COLOR_ITEM;
Boolean shouldBroadcast;
// Handle color picker item special
if ( inValue == COLOR_PICKER_ITEM )
{
mValue = inValue; // Store new value to broadcast it
BroadcastValueMessage(); // Inform Listeners of value change
inValue = CURRENT_COLOR_ITEM; // Reset value to current color
shouldBroadcast = false; // Already broadcast above; don't do again
}
else
shouldBroadcast = IsBroadcasting();
// broadcast only if it's not a color picker item (handled above)
StSetBroadcasting setBroadcasting( this, shouldBroadcast );
super::SetValue( inValue );
}
// ---------------------------------------------------------------------------
// ¥ HandleNewValue
// ---------------------------------------------------------------------------
// Hook for handling value changes. Called by SetValue.
// Note that the setting of the new value is done by CPatternButtonPopup::SetValue.
// Therefore, GetValue() will still return the old value here, so the old value is
// still available in this method.
Boolean
CColorPopup::HandleNewValue(Int32 inNewValue)
{
Str255 str;
MenuHandle menuh;
menuh = GetMenu()->GetMacMenuH();
::GetMenuItemText ( menuh, inNewValue, str );
if ( str[1] != COLOR_PICKER_CHAR )
SetDescriptor( str );
if ( mDoSetLastPickedPreference
&& str[1] != LAST_COLOR_PICKED_CHAR && str[1] != COLOR_PICKER_CHAR )
{
mDoSetLastPickedPreference = false;
// skip over any text which might preceed color
int index;
for ( index = 1; index <= str[0]
&& str[index] != LAST_COLOR_PICKED_CHAR
&& str[index] != COLOR_CHIP_CHAR
&& str[index] != COLOR_PICKER_CHAR
&& str[index] != DEFAULT_COLOR_CHAR
&& str[index] != CURRENT_COLOR_CHAR; ++index )
;
if ( index + 7 < str[0] )
str[index + 7] = 0; // null terminate after symbol + 6chars of color
str[ index ] = COLOR_CHIP_CHAR; // prefs assume #-format color
p2cstr( str );
int result;
result = PREF_SetCharPref( "editor.last_color_used", (char *)&str[index-1] );
// skip past initial symbol; index-1 since now c-string
}
return false;
}
const Int16 cPopupArrowHeight = 5; // height of the arrow
const Int16 cPopupArrowWidth = 9; // widest width of the arrow
void
CColorPopup::DrawButtonContent(void)
{
CPatternButtonPopupText::DrawButtonContent();
DrawPopupArrow();
}
void
CColorPopup::DrawButtonTitle(void)
{
}
void
CColorPopup::DrawButtonGraphic(void)
{
ResIDT theSaveID = GetGraphicID();
ResIDT theNewID = theSaveID;
RGBColor foreColor, theColor;
const RGBColor black={0,0,0};
Int32 theValue = GetValue();
if (theValue > 0)
{
if ( theValue == COLOR_PICKER_ITEM )
theValue = CURRENT_COLOR_ITEM;
if (GetMenuItemRGBColor((short)theValue, &theColor) == true)
{
CButton::CalcGraphicFrame();
InsetRect(&mCachedGraphicFrame, (mCachedGraphicFrame.right-mCachedGraphicFrame.left-12)/2,
(mCachedGraphicFrame.bottom-mCachedGraphicFrame.top-12)/2);
::GetForeColor(&foreColor);
::RGBForeColor(&black);
::FrameRect(&mCachedGraphicFrame);
::RGBForeColor(&foreColor);
::InsetRect(&mCachedGraphicFrame,1,1);
::RGBForeColor(&theColor);
::PaintRect(&mCachedGraphicFrame);
}
else
theValue = CURRENT_COLOR_ITEM; // not sure this is the right thing;
// it'd be nice if GetMenuItemRGBColor always returned true
}
}
void
CColorPopup::DrawPopupArrow(void)
{
Rect theFrame;
CalcLocalFrameRect(theFrame);
Int16 width = theFrame.right - theFrame.left;
Int16 height = theFrame.bottom - theFrame.top;
theFrame.top += ((height - cPopupArrowHeight) / 2);
theFrame.left = theFrame.right - cPopupArrowWidth - 7;
theFrame.right = theFrame.left + cPopupArrowWidth - 1;
theFrame.bottom = theFrame.top + cPopupArrowHeight - 1;
// check if we have moved past the right edge of the button
// if so, adjust it back to the right edge of the button
if ( theFrame.right > mCachedButtonFrame.right - 4 )
{
theFrame.right = mCachedButtonFrame.right - 4;
theFrame.left = theFrame.right - cPopupArrowWidth - 1;
}
UGraphicGizmos::DrawPopupArrow(
theFrame,
IsEnabled(),
IsActive(),
IsTrackInside());
}
#pragma mark -
// always call ProcessCommandStatus for popup menus which can change values
void
CColorPopup::HandleEnablingPolicy()
{
LCommander* theTarget = LCommander::GetTarget();
MessageT buttonCommand = GetValueMessage();
Boolean enabled = false;
Boolean usesMark = false;
Str255 outName;
Char16 outMark;
if (!CTargetedUpdateMenuRegistry::UseRegistryToUpdateMenus() ||
CTargetedUpdateMenuRegistry::CommandInRegistry(buttonCommand))
{
if (!IsActive() || !IsVisible())
return;
if (!theTarget)
return;
CPatternButtonPopup::HandleEnablingPolicy();
if (buttonCommand)
theTarget->ProcessCommandStatus(buttonCommand, enabled, usesMark, outMark, outName);
}
CPatternButtonPopup::Enable();
}
Boolean
CColorPopup::GetMenuItemRGBColor(short menuItem, RGBColor *theColor)
{
Str255 str;
MenuHandle menuh;
Boolean colorFoundFlag;
menuh = GetMenu()->GetMacMenuH();
::GetMenuItemText( menuh, menuItem, str );
colorFoundFlag = colorPopupParseColor( str, theColor );
return colorFoundFlag;
}
short
CColorPopup::GetMenuItemFromRGBColor(RGBColor *theColor)
{
MenuHandle menuh;
RGBColor tempColor;
Str255 str;
short loop,numItems,retVal=CURRENT_COLOR_ITEM; // return current color if not found
if ((menuh = GetMenu()->GetMacMenuH()) != NULL)
{
numItems = ::CountMItems(menuh);
for (loop=1; loop<= numItems; loop++)
{
::GetMenuItemText( menuh, loop, str);
if (colorPopupParseColor(str, &tempColor) == true)
{
if ((tempColor.red == theColor->red) && (tempColor.blue == theColor->blue) && (tempColor.green == theColor->green))
{
retVal = loop;
break;
}
}
}
}
return retVal;
}

View File

@@ -0,0 +1,74 @@
/* -*- 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 "CPatternButtonPopupText.h"
class CEditView;
class CColorPopup : public CPatternButtonPopupText
{
public:
enum { class_ID = 'Cpop' };
enum { COLOR_DISPLAY_TEXT = 0, // need to fix "*" bug before turning on (among other things)
COLOR_FRAME_BORDER = 2,
COLOR_BOX_WIDTH = 14,
COLOR_BOX_HEIGHT = 14,
COLOR_HEX_DISPLAY_SIZE = 16
};
enum {
LAST_COLOR_PICKED_CHAR = '<',
LAST_COLOR_PICKED_ITEM = 1,
COLOR_CHIP_CHAR = '#',
COLOR_PICKER_CHAR = '*',
COLOR_PICKER_ITEM = 62,
DEFAULT_COLOR_CHAR = '@',
DEFAULT_COLOR_ITEM = 72,
CURRENT_COLOR_CHAR = '.',
CURRENT_COLOR_ITEM = 73
};
typedef CPatternButtonPopupText super;
static void* CreateCColorPopupStream( LStream *inStream ) {return( new CColorPopup (inStream ));};
CColorPopup( LStream *inStream ); // ¥ Constructor
virtual void FinishCreateSelf();
// ¥ drawing
void DrawButtonContent(void);
void DrawButtonTitle(void);
void DrawPopupArrow(void);
void DrawButtonGraphic(void);
// ¥ hooks
virtual void SetValue( Int32 inValue );
virtual void AdjustMenuContents();
virtual void HandlePopupMenuSelect( Point inPopupLoc, Int16 inCurrentItem,
Int16& outMenuID, Int16& outMenuItem );
virtual Boolean HandleNewValue(Int32 inNewValue);
virtual Boolean GetMenuItemRGBColor(short menuItem, RGBColor *theColor);
virtual short GetMenuItemFromRGBColor(RGBColor *theColor);
void InitializeCurrentColor();
protected:
virtual void HandleEnablingPolicy();
CEditView *mEditView;
Boolean mDoSetLastPickedPreference;
};

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) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
// ===========================================================================
// CComposerDragTask.cp
// ===========================================================================
#include "CComposerDragTask.h"
// ---------------------------------------------------------------------------
// ¥ CComposerDragTask
// ---------------------------------------------------------------------------
CComposerDragTask::CComposerDragTask(
const EventRecord& inEventRecord,
const Rect& inGlobalFrame,
CHTMLView& inHTMLView)
: mGlobalFrame(inGlobalFrame),
mHTMLView(inHTMLView),
super(inEventRecord)
{
}
// ---------------------------------------------------------------------------
// ¥ ~CComposerDragTask
// ---------------------------------------------------------------------------
CComposerDragTask::~CComposerDragTask()
{
}
// ---------------------------------------------------------------------------
// ¥ AddFlavors
// ---------------------------------------------------------------------------
void
CComposerDragTask::AddFlavors( DragReference /* inDragRef */ )
{
OSErr theErr;
theErr = ::AddDragItemFlavor( mDragRef, (ItemReference)this, emComposerNativeDrag,
nil, 0, flavorNotSaved | flavorSenderTranslated );
ThrowIfOSErr_(theErr);
}
void
CComposerDragTask::MakeDragRegion( DragReference /* inDragRef */, RgnHandle /* inDragRegion */ )
{
AddRectDragItem((ItemReference)&mHTMLView, mGlobalFrame);
}

View File

@@ -0,0 +1,56 @@
/* -*- 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.
*/
// ===========================================================================
// CComposerDragTask.h
// ===========================================================================
#ifndef CComposerDragTask_H
#define CComposerDragTask_H
#pragma once
// Includes
#include <LDragTask.h>
class CHTMLView;
#define emComposerNativeDrag 'CNDr' // others defined in "resgui.h"
// Class declaration
class CComposerDragTask : public LDragTask
{
public:
typedef LDragTask super;
CComposerDragTask( const EventRecord& inEventRecord,
const Rect& inGlobalFrame, CHTMLView& inHTMLView );
virtual ~CComposerDragTask();
protected:
virtual void AddFlavors( DragReference inDragRef );
virtual void MakeDragRegion( DragReference inDragRef, RgnHandle inDragRegion );
Rect mGlobalFrame;
CHTMLView& mHTMLView;
};
#endif

View File

@@ -0,0 +1,320 @@
/* -*- 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 "CEditDictionary.h"
#include "CLargeEditField.h" // msg_EditField2
#include "LGAPushButton.h"
#include "resgui.h" // msg_Help
#include "macutil.h" // ShowHelp
#include "CSpellChecker.h" // ISpellChecker
// need to include "ntypes.h" before "xp_help.h" because
// "xp_help.h" doesn't include definition of MWContext though it should
#include "ntypes.h"
#include "xp_help.h" // HELP_SPELL_CHECK
// If user has changed the word field, figure out the length and enable/disable appropriately
void CEditDictionary::ListenToMessage ( MessageT inMessage,
void* ioParam ) {
Assert_(mWordNameField);
Assert_(mAddButton);
// This happens when user types
if (inMessage == msg_EditField2) {
if ((**(mWordNameField->GetMacTEH())).teLength) {
mAddButton->Enable();
} else {
mAddButton->Disable();
}
// User clicked in words table
} else if (inMessage == WordsTableID) {
Boolean atleastoneselected = false;
// Must have at least one cell selected for remove to be valid
STableCell selchecker(0,0);
if (mWordsView->GetNextSelectedCell(selchecker)) {
atleastoneselected = true;
mRemoveButton->Enable();
} else {
mRemoveButton->Disable();
}
// Replace is enabled if there is a valid word in New Word Edit Field
// And exactly one word is selected
if ((**(mWordNameField->GetMacTEH())).teLength && atleastoneselected &&
!mWordsView->GetNextSelectedCell(selchecker) ) {
mReplaceButton->Enable();
} else {
mReplaceButton->Disable();
}
// User left words table
} else if (inMessage == msg_LeaveDictionaryTable) {
mRemoveButton->Disable();
mReplaceButton->Disable();
// If user clicks on Remove Button
} else if (inMessage == RemoveButtonID) {
RemoveSelectedWords();
// If user clicks on Replace Button
} else if (inMessage == ReplaceButtonID) {
ReplaceSelectedWord();
// If user clicks on OK Button
} else if (inMessage == msg_OK) {
MakeDictionaryChangesPermanent();
AttemptClose();
// If user clicks on Cancel Button
} else if (inMessage == msg_Cancel) {
AttemptClose();
// User clicks on Help Button
} else if (inMessage == msg_Help) {
ShowHelp(HELP_SPELL_CHECK);
// This is the case when something important happens (selection, deselection, etc.)
// to the New Word edit field. Check status of word
} else if (inMessage == WordID) {
if ((**(mWordNameField->GetMacTEH())).teLength) {
mAddButton->Enable();
} else {
mAddButton->Disable();
}
// Add word to dictionary
} else if (inMessage == AddButtonID) {
AddNewWord();
} else {
LGADialogBox::ListenToMessage(inMessage, ioParam);
}
}
//-------------------------------------------------------------------------------------
// CEditDictionary::MakeDictionaryChangesPermanent
// Take words in view and set in dictionary
//-------------------------------------------------------------------------------------
void CEditDictionary::MakeDictionaryChangesPermanent() {
STableCell currCellLoc(1,1);
Str255 currCellData;
int maxsize = 255;
mISpellChecker->ResetPersonalDictionary();
for (currCellLoc.row = 1; currCellLoc.row <= mNumWords; currCellLoc.row++) {
maxsize = 255;
mWordsView->GetCellData(currCellLoc, currCellData, maxsize);
mISpellChecker->AddWordToPersonalDictionary(p2cstr(currCellData));
}
}
//-------------------------------------------------------------------------------------
// CEditDictionary::RemoveSelectedWord
// Remove words that are currently selected
//-------------------------------------------------------------------------------------
void CEditDictionary::RemoveSelectedWords() {
STableCell currCellLoc(0,0);
int rowstodelete = 0;
while (mWordsView->GetNextSelectedCell(currCellLoc)) {
rowstodelete++;
}
currCellLoc = mWordsView->GetFirstSelectedCell();
mWordsView->RemoveRows(rowstodelete, currCellLoc.row, true);
mNumWords-=rowstodelete;
}
//-------------------------------------------------------------------------------------
// CEditDictionary::ReplaceSelectedWord
// Remove currently selected word with word in New Word box
//-------------------------------------------------------------------------------------
void CEditDictionary::ReplaceSelectedWord() {
STableCell currCellLoc;
Str255 theWord;
mWordNameField->GetDescriptor(theWord);
currCellLoc = mWordsView->GetFirstSelectedCell();
if (mWordsView->IsValidCell(currCellLoc)) {
mWordsView->SetCellData(currCellLoc, theWord, theWord[0] + 1);
mWordsView->RefreshCell(currCellLoc);
}
}
//-------------------------------------------------------------------------------------
// CEditDictionary::AddNewWord
// Add the word in "New Word" edit field to personal dictionary
//-------------------------------------------------------------------------------------
void CEditDictionary::AddNewWord() {
Str255 theWord;
Str255 currWord;
Assert_(mWordNameField);
Assert_(mISpellChecker);
STableCell cell(1,1);
Uint32 maxbytes;
mWordNameField->GetDescriptor(theWord);
/*
Check to make sure word is not already in the list. If it is, then highlight that word
and return so we don't insert.
*/
for (cell.row = 1; cell.row <= mNumWords; cell.row++) {
maxbytes = 255;
mWordsView->GetCellData(cell, currWord, maxbytes);
if (currWord[0] == theWord[0] &&
!strncmp(reinterpret_cast<const char *>(&(currWord[1])), reinterpret_cast<const char *>(&(theWord[1])), theWord[0]) ) { // If word already exists exit
mWordsView->UnselectAllCells();
mWordsView->SelectCell(cell);
return;
}
}
mWordsView->InsertRows(1, mNumWords, theWord, theWord[0] + 1, Refresh_Yes);
mNumWords++;
cell.row = mNumWords;
mWordsView->UnselectAllCells();
mWordsView->SelectCell(cell);
}
//-------------------------------------------------------------------------------------
// CEditDictionary::FinishCreateSelf
// Setup object references
//-------------------------------------------------------------------------------------
void CEditDictionary::FinishCreateSelf () {
mAddButton = dynamic_cast<LGAPushButton *>(FindPaneByID(AddButtonID));
mReplaceButton = dynamic_cast<LGAPushButton *>(FindPaneByID(ReplaceButtonID));
mRemoveButton = dynamic_cast<LGAPushButton *>(FindPaneByID(RemoveButtonID));
mHelpButton = dynamic_cast<LGAPushButton *>(FindPaneByID(HelpButtonID));
mWordNameField = dynamic_cast<CLargeEditFieldBroadcast *>(FindPaneByID(WordID));
mWordsView = dynamic_cast<CTextTable *>(FindPaneByID( WordsTableID ));
ThrowIfNil_(mAddButton);
ThrowIfNil_(mReplaceButton);
ThrowIfNil_(mRemoveButton);
ThrowIfNil_(mHelpButton);
ThrowIfNil_(mWordNameField);
ThrowIfNil_(mWordsView);
LGADialogBox::FinishCreateSelf();
PenState penState;
::GetPenState( &penState );
mWordsView->AddAttachment( new LColorEraseAttachment( &penState, NULL, NULL, true ) );
mAddButton->Disable(); // Add button should be originally disabled
mReplaceButton->Disable();
mRemoveButton->Disable();
mAddButton->AddListener( this );
mReplaceButton->AddListener( this );
mRemoveButton->AddListener( this );
mWordNameField->AddListener( this );
mWordsView->AddListener( this );
mHelpButton->AddListener( this );
}
// Constructor
CEditDictionary::CEditDictionary(LStream *inStream) : mNumWords(0),
mWordNameField(NULL), mISpellChecker(NULL), mAddButton(NULL), mWordsView(NULL),
mHelpButton(NULL), LGADialogBox (inStream) {
}
//-------------------------------------------------------------------------------------
// CEditDictionary::SetISPellChecker
// Sets personal dictionary and inserts into GUI
//-------------------------------------------------------------------------------------
void CEditDictionary::SetISpellChecker(ISpellChecker *i) {
STableCell cell(0, 1);
int unusedNumber;
char word_buffer[max_word_length];
int curr_word_length;
mISpellChecker = i;
cell.row = 0;
if ((mISpellChecker->GetFirstPersonalDictionaryWord(word_buffer, max_word_length) >= 0) && mWordsView) {
mWordsView->FocusDraw();
do {
mNumWords++;
cell.row++;
curr_word_length = strlen(word_buffer);
CStr255 pascalstring( word_buffer );
mWordsView->InsertRows(1, cell.row-1, NULL ,0, Refresh_Yes);
mWordsView->SetCellData(cell, pascalstring, curr_word_length + 1);
// Insert the words into dialog box here!
} while (mISpellChecker->GetNextPersonalDictionaryWord(word_buffer, max_word_length) >= 0);
}
mWordsView->GetTableSize(mNumWords, unusedNumber);
}
//-------------------------------------------------------------------------------------
// CEditDictionary::GetISPellChecker
// Get the Personal Dictionary
//-------------------------------------------------------------------------------------
ISpellChecker *CEditDictionary::GetISpellChecker() {
return mISpellChecker;
}
//-------------------------------------------------------------------------------------
// CEditDictionaryTable::BeTarget()
// Broadcast messages when we become target so we can setup buttons
//-------------------------------------------------------------------------------------
void CEditDictionaryTable::BeTarget() {
CTextTable::BeTarget();
BroadcastMessage(CEditDictionary::WordsTableID, NULL);
}
//-------------------------------------------------------------------------------------
// CEditDictionaryTable::DontBeTarget()
// Broadcast messages when we lose target so we can setup buttons
//-------------------------------------------------------------------------------------
void CEditDictionaryTable::DontBeTarget() {
CTextTable::DontBeTarget();
BroadcastMessage(CEditDictionary::msg_LeaveDictionaryTable, NULL);
}
//-------------------------------------------------------------------------------------
// HiliteSelection
// Setup back/front colors. Otherwise we sometimes get the de-highlighting
// wrong when switching selection
//-------------------------------------------------------------------------------------
void CEditDictionaryTable::HiliteSelection( Boolean inActively, Boolean inHilite )
{
if (inActively) {
StColorPenState::Normalize();
}
LTableView::HiliteSelection( inActively, inHilite );
}

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) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#pragma once
#include "CTextTable.h"
#include <LGADialogBox.h>
class LGAPushButton;
class CLargeEditFieldBroadcast;
class ISpellChecker;
class CEditDictionary : public LGADialogBox {
public:
virtual void ListenToMessage ( MessageT inMessage,
void* ioParam );
virtual void FinishCreateSelf();
CEditDictionary(LStream *inStream);
void SetISpellChecker(ISpellChecker *i);
ISpellChecker *GetISpellChecker();
enum { class_ID = 'CEdD', res_ID = 5298 };
enum { AddButtonID = 201 , WordID = 200, WordsTableID = 202, ReplaceButtonID = 203,
RemoveButtonID = 204, HelpButtonID = 205, msg_LeaveDictionaryTable = 208 };
enum { max_word_length = 50 }; // Max length of a word
protected:
void MakeDictionaryChangesPermanent();
virtual void AddNewWord();
virtual void RemoveSelectedWords();
virtual void ReplaceSelectedWord();
CLargeEditFieldBroadcast *mWordNameField; // The field where user edits word
LGAPushButton *mAddButton; // Add new word button
LGAPushButton *mReplaceButton;
LGAPushButton *mRemoveButton;
LGAPushButton *mHelpButton;
CTextTable *mWordsView; // The Personal Dictionary view
int mNumWords;
ISpellChecker *mISpellChecker;
};
class CEditDictionaryTable : public CTextTable {
public:
enum {class_ID = 'CEDT' };
virtual void BeTarget();
virtual void DontBeTarget();
CEditDictionaryTable(LStream *inStream) : CTextTable(inStream) { }
void HiliteSelection( Boolean inActively, Boolean inHilite );
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,272 @@
/* -*- 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.
*/
#pragma once
#include <TextServices.h>
#include "CHTMLView.h"
// dangling prototype
Boolean GetCaretPosition(MWContext *context, LO_Element * element, int32 caretPos,
int32* caretX, int32* caretYLow, int32* caretYHigh );
class LGAPopup;
class CPatternButtonPopup;
class CColorPopup;
class CComposeSession;
class CFontMenuPopup;
class HTMLInlineTSMProxy;
class HoldUpdatesProxy;
class CEditView: public CHTMLView
{
#if !defined(__MWERKS__) || (__MWERKS__ >= 0x2000)
typedef CHTMLView inherited;
#endif
public:
enum { pane_ID = 'html', class_ID = 'Edtp', dashMark = '-' };
enum {
STRPOUND_EDITOR_MENUS = 5101,
EDITOR_MENU_SHOW_PARA_SYMBOLS = 1,
EDITOR_MENU_HIDE_PARA_SYMBOLS = 2,
EDITOR_MENU_UNDO = 3,
EDITOR_MENU_REDO = 4,
EDITOR_MENU_SHOW_COMP_TOOLBAR = 5,
EDITOR_MENU_HIDE_COMP_TOOLBAR = 6,
EDITOR_MENU_SHOW_FORMAT_TOOLBAR = 7,
EDITOR_MENU_HIDE_FORMAT_TOOLBAR = 8,
EDITOR_MENU_SHOW_TABLE_BORDERS = 9,
EDITOR_MENU_HIDE_TABLE_BORDERS = 10,
EDITOR_MENU_CHARACTER_ATTRIBS = 11,
EDITOR_MENU_IMAGE_ATTRIBUTES = 12,
EDITOR_MENU_LINK_ATTRIBUTES = 13,
EDITOR_MENU_LINE_ATTRIBUTES = 14,
EDITOR_MENU_TABLE_ATTRIBUTES = 15,
EDITOR_MENU_UNKNOWN_ATTRIBUTES = 16,
EDITOR_MENU_TARGET_ATTRIBUTES = 17
};
enum {
eMouseHysteresis = 6,
eSelectionBorder = 3
};
// ¥¥ Constructors
CEditView(LStream * inStream);
~CEditView();
virtual void FinishCreateSelf(void);
// ¥¥ Command handling
virtual Boolean ObeyCommand( CommandT inCommand, void *ioParam );
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual void FindCommandStatus( CommandT inCommand,
Boolean& outEnabled, Boolean& outUsesMark,
Char16& outMark,Str255 outName );
Boolean FindCommandStatusForContextMenu( CommandT inCommand,
Boolean &outEnabled, Boolean &outUsesMark,
Char16 &outMark, Str255 outName );
Boolean IsPastable(Char16 theChar);
int FindQueuedKeys( char *keys_in_q );
virtual Boolean HandleKeyPress( const EventRecord& inKeyEvent );
virtual void AdaptToSuperFrameSize( Int32 inSurrWidthDelta,
Int32 inSurrHeightDelta, Boolean inRefresh );
virtual void BeTarget();
virtual void DontBeTarget();
void HandleCut();
void HandleCopy();
void HandlePaste();
TSMDocumentID midocID;
virtual void CreateFindWindow();
virtual void SetContext( CBrowserContext* inNewContext );
virtual URL_Struct *GetURLForPrinting( Boolean& outSuppressURLCaption, MWContext *printingContext );
void TakeOffDuty();
virtual void PutOnDuty(LCommander*);
Bool PtInSelectedRegion(SPoint32 cpPoint );
virtual void DrawSelf( void );
virtual Boolean EstablishPort();
virtual void ActivateSelf();
virtual void DeactivateSelf();
Bool SaveDocument();
Bool SaveDocumentAs();
Bool VerifySaveUpToDate();
// ¥¥ cursor calls and caret functionality
virtual void AdjustCursorSelf( Point inPortPt, const EventRecord& inMacEvent );
virtual void SpendTime( const EventRecord& inMacEvent );
void DrawCaret( Boolean doErase );
void EraseCaret();
void HideCaret( Boolean mhide ) { EraseCaret(); mHideCaret = mhide; }
void PlaceCaret(int32 caretX, int32 caretYLow, int32 caretYHigh);
void RemoveCaret();
void DisplayGenericCaret( MWContext *context, LO_Element * pLoAny,
ED_CaretObjectPosition caretPos );
// ¥¥ Drag and Drop
virtual Boolean ItemIsAcceptable (DragReference dragRef, ItemReference itemRef);
virtual void ReceiveDragItem( DragReference inDragRef, DragAttributes inDragAttr,
ItemReference inItemRef, Rect& inItemBounds );
virtual void DoDragSendData( FlavorType inFlavor, ItemReference inItemRef,
DragReference inDragRef );
virtual void ClickSelf (const SMouseDownEvent& where );
virtual Boolean ClickTrackSelection( const SMouseDownEvent& inMouseDown,
CHTMLClickRecord& inClickRecord );
virtual Boolean SetDefaultCSID( Int16 inPreferredCSID );
CBrowserContext *GetNSContext() { return mContext; };
void SetHoldUpdates(HoldUpdatesProxy* inHoldUpdates) {mHoldUpdates = inHoldUpdates;};
Boolean mEditorDoneLoading;
Boolean IsDoneLoading() const { return mEditorDoneLoading; }
// ¥¥ FE_* calls
void DocumentChanged( int32 iStartY, int32 iHeight );
void GetDocAndWindowPosition( SPoint32 &frameLocation, SPoint32 &imageLocation, SDimension16 &frameSize );
// ¥¥ formatting query calls
void UseCharFormattingCache() { CanUseCharFormatting(); mUseCharFormattingCache = true; }
void DontUseCharFormattingCache() { mUseCharFormattingCache = false; }
class StUseCharFormattingCache
{
public:
StUseCharFormattingCache( CEditView& p ) : view(p) { view.UseCharFormattingCache(); }
~StUseCharFormattingCache() { view.DontUseCharFormattingCache(); }
private:
CEditView &view;
};
LGAPopup * mParagraphToolbarPopup;
LGAPopup * mSizeToolbarPopup;
CFontMenuPopup * mFontToolbarPopup;
CPatternButtonPopup * mAlignToolbarPopup;
CColorPopup * mColorPopup;
protected:
virtual Boolean IsGrowCachingEnabled() const { return !mEditorDoneLoading; }
virtual void LayoutNewDocument( URL_Struct *inURL, Int32 *inWidth,
Int32 *inHeight, Int32 *inMarginWidth, Int32 *inMarginHeight );
// ¥¥ FE_* calls
virtual void SetDocPosition( int inLocation, Int32 inX, Int32 inY,
Boolean inScrollEvenIfVisible = false);
virtual void DisplayLineFeed( int inLocation, LO_LinefeedStruct *inLinefeedStruct, XP_Bool inNeedBG );
virtual void DisplayHR( int inLocation, LO_HorizRuleStruct *inRuleStruct );
virtual void DisplaySubtext( int inLocation, LO_TextStruct *inText,
Int32 inStartPos, Int32 inEndPos, XP_Bool inNeedBG );
virtual void EraseBackground( int inLocation, Int32 inX, Int32 inY,
Uint32 inWidth, Uint32 inHeight, LO_Color *inColor );
virtual void GetDefaultBackgroundColor(LO_Color* outColor) const;
virtual void DisplayTable( int inLocation, LO_TableStruct *inTableStruct );
virtual void DisplayCell( int inLocation, LO_CellStruct *inCellStruct );
virtual void InvalidateEntireTableOrCell( LO_Element* inElement );
virtual void DisplayAddRowOrColBorder( XP_Rect* inRect, XP_Bool inDoErase );
virtual void UpdateEnableStates();
virtual void DisplayFeedback( int inLocation, LO_Element *inElement );
virtual void DisplaySelectionFeedback( uint16 ele_attrmask, const Rect &inRect );
virtual void InsideDropArea( DragReference inDragRef );
virtual void EnterDropArea( DragReference inDragRef, Boolean inDragHasLeftSender );
DragReference mDragRef;
enum {
ED_SELECTION_BORDER = 3
};
enum { MAX_Q_SIZE = 12 }; // Used for checking out key strokes waiting in FindQueuedKeys
void InsertDefaultLine();
void DoReload( void );
void ToFromList( intn listType, ED_ListType elementType );
void NoteEditorRepagination( void );
Boolean CanUseCharFormatting();
Boolean IsMouseInSelection( SPoint32 pt, CL_Layer *curLayer, Rect& selectRect );
Boolean mDoContinueSelection;
HTMLInlineTSMProxy* mProxy;
HoldUpdatesProxy* mHoldUpdates;
// more caret blinking and related stuff
Boolean mCaretDrawn, mCaretActive;
Boolean mHideCaret;
Boolean mDisplayParagraphMarks;
Point mOldPoint; // Last place cursor was adjusted. No initializing
long mOldLastElementOver; // id of the last element the cursor was over
unsigned long mLastBlink;
int32 mCaretX;
int32 mCaretYLow;
int32 mCaretYHigh;
Boolean mUseCharFormattingCache;
Boolean mIsCharFormatting;
// these are only to be used during drag of data in composer
char *mDragData; // warning this really isn't a "char" but void* data!!!
int32 mDragDataLength;
}; // class CEditView
//======================================
class CMailEditView : public CEditView
//======================================
{
public:
enum { pane_ID = 'html', class_ID = 'MEdp' };
// ¥¥ Constructors
CMailEditView(LStream * inStream);
virtual void InstallBackgroundColor();
virtual void GetDefaultBackgroundColor(LO_Color* outColor) const;
virtual void InitMailCompose();
void SetComposeSession( CComposeSession *c ) { mComposeSession = c; };
void SetInitialText( const char *textp );
void InsertMessageCompositionText( const char* text,
XP_Bool leaveCursorBeginning, XP_Bool isHTML );
void DisplayDefaultTextBody();
private:
Int32 mStartQuoteOffset;
Int32 mEndQuoteOffset;
Boolean mHasAutoQuoted;
Boolean mHasInsertSignature;
Boolean mCursorSet;
char *mInitialText; // Draft text
CComposeSession *mComposeSession;
}; // class CMailEditView

View File

@@ -0,0 +1,610 @@
/* -*- 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 "CEditorWindow.h"
#include "CBrowserContext.h"
#include "resgui.h"
#include "CFormattingToolBar.h"
#include "CFontMenuAttachment.h"
#include "CToolbarPopup.h"
#include "CPatternButtonPopupText.h"
#include "COpenRecentlyEditedPopup.h"
#include "CColorPopup.h"
#include "CEditDictionary.h"
#include "CTextTable.h"
#include "CTableKeySingleSelector.h"
// macfe
#include "mversion.h" // ID_STRINGS
#include "URobustCreateWindow.h"
#include "uprefd.h"
#include "uerrmgr.h"
#include "uapp.h"
#include "meditdlg.h" // CTabbedDialog
#include "meditor.h" // HandleModalDialog
#include "CEditView.h"
// Netscape
#include "net.h" // NET_cinfo_find_type
#include "proto.h" // XP_IsContextBusy
#include "edt.h"
#include "shist.h"
#include "prefapi.h" // PREF_GetBoolPref
#ifdef PROFILE
#pragma profile on
#endif
// pane id constants - for ShowOneDragBar
const PaneIDT Paragraph_Bar_PaneID = 'DBar';
const PaneIDT Character_Bar_PaneID = 'NBar';
const char* Pref_ShowParagraphBar = "editor.show_paragraph_toolbar";
const char* Pref_ShowCharacterBar = "editor.show_character_toolbar";
enum { eParagraphBar,
eCharacterBar };
CEditorWindow::CEditorWindow( LStream* inStream )
:CBrowserWindow(inStream)
{
SetWindowType( WindowType_Editor );
}
static // PRIVATE
CMediatedWindow* GetFrontWindowByType( OSType windowType )
{
CMediatedWindow* theWindow = NULL;
CWindowIterator iter(windowType);
iter.Next(theWindow);
return theWindow;
}
// given an mwcontext (non-busy, with a history), select the matching editor window
// or open an editor window based on that mwcontext
// if all else fails (and memory is not low), create an empty editor window
void CEditorWindow::MakeEditWindowFromBrowser( MWContext* mwcontext )
{
if ( Memory_MemoryIsLow() )
return;
History_entry* entry = NULL;
if ( mwcontext && !XP_IsContextBusy( mwcontext ) )
entry = SHIST_GetCurrent(&mwcontext->hist);
if ( entry && entry->address)
{
// If there is already an editor window open for this url
// just switch to it and keep this browser window open.
CMediatedWindow * win;
CWindowIterator iter(WindowType_Editor);
while (iter.Next(win))
{
CNSContext* curContext = ((CBrowserWindow *)win)->GetWindowContext();
MWContext* context;
context = curContext ? curContext->operator MWContext*() : NULL;
if (context && EDT_IS_EDITOR(context))
{
History_entry* newEntry = SHIST_GetCurrent(&context->hist);
if (newEntry && newEntry->address && !strcmp(newEntry->address, entry->address))
{
win->Show();
win->Select();
return;
}
}
}
if (CEditorWindow::MakeEditWindow(mwcontext, NULL) == NULL) // new window based on history of this window
return; // don't close this one on error.
}
else
{
CEditorWindow::MakeEditWindow(NULL, NULL); // make a completely new window
}
}
// EDT_PreOpenCallbackFn
static void createEditorWindowCallback( XP_Bool userCanceled, char* pURL, void* hook )
{
if ( !userCanceled )
{
EditorCreationStruct *edtCreatePtr = (EditorCreationStruct *)hook;
if ( hook )
{
if ( edtCreatePtr->existingURLstruct && edtCreatePtr->existingURLstruct->address )
{
XP_FREE( edtCreatePtr->existingURLstruct->address );
edtCreatePtr->existingURLstruct->address = XP_STRDUP( pURL );
}
}
// substitute new URL
CEditorWindow::CreateEditorWindowStage2( edtCreatePtr );
}
}
CEditorWindow* CEditorWindow::MakeEditWindow( MWContext* old_context, URL_Struct* url )
{
Boolean urlCameInNULL = (url == NULL);
// if we don't have an URL, try to get it from the old_context's window history
if (url == NULL && old_context != NULL)
{
CBrowserContext *browserContext = (CBrowserContext *)old_context->fe.newContext;
History_entry* entry = browserContext->GetCurrentHistoryEntry(); // Take the last instead of the first history entry.
if ( entry )
{
url = SHIST_CreateURLStructFromHistoryEntry( old_context, entry );
if ( url )
url->force_reload = NET_NORMAL_RELOAD;
}
// if we don't have a history entry, we're kind of screwed-->just load a blank page
}
// we want to open a new blank edit window
// or we are still having troubles... fall back to our old tried and true blank page
if (url == NULL)
url = NET_CreateURLStruct ("about:editfilenew", NET_NORMAL_RELOAD );
// FIX THIS!!! the above line should use "XP_GetString(XP_EDIT_NEW_DOC_NAME)"
// time of reckoning. We really, really need an URL and address at this point...
// I don't know what an url without an address is anyway...
if (url == NULL || url->address == NULL)
return NULL;
// now make sure that the url is a valid type to edit.
NET_cinfo *cinfo = NET_cinfo_find_type (url->address);
if (cinfo == NULL || cinfo->type == NULL ||
(strcasecomp (cinfo->type, TEXT_HTML)
&& strcasecomp (cinfo->type, UNKNOWN_CONTENT_TYPE)
&& strcasecomp (cinfo->type, TEXT_PLAIN)))
{
ErrorManager::PlainAlert( NOT_HTML );
return NULL;
}
EditorCreationStruct *edtCreatePtr = (EditorCreationStruct *)XP_ALLOC( sizeof( EditorCreationStruct ) );
if ( edtCreatePtr )
{
edtCreatePtr->context = old_context;
edtCreatePtr->existingURLstruct = url;
edtCreatePtr->isEmptyPage = old_context == NULL && urlCameInNULL;
}
if ( urlCameInNULL && old_context == NULL )
{
return CreateEditorWindowStage2( edtCreatePtr );
}
else
{
EDT_PreOpen( old_context, url->address, createEditorWindowCallback, edtCreatePtr );
return NULL;
}
}
CEditorWindow *CEditorWindow::CreateEditorWindowStage2( EditorCreationStruct *edtCreatePtr )
{
// now we can create an editor window since we don't already have one for this url.
/* instead of just calling LWindow::CreateWindow(), we do it ourselves by hand here
* so that we can set the window bounds before we call FinishCreate().
*/
if ( edtCreatePtr == NULL )
return NULL;
CEditorWindow* newWindow = NULL;
SetDefaultCommander(CFrontApp::GetApplication());
try {
OSErr error;
URobustCreateWindow::ReadObjects( 'PPob', CEditorWindow::res_ID, &newWindow, &error );
Assert_(newWindow);
FailOSErr_(error);
if (newWindow == NULL)
{
XP_FREE( edtCreatePtr );
return NULL;
}
newWindow->FinishCreate();
if (newWindow->HasAttribute(windAttr_ShowNew))
newWindow->Show();
UReanimator::LinkListenerToControls( newWindow, newWindow, CEditorWindow::res_ID );
}
catch(...)
{
if ( newWindow )
delete newWindow;
XP_FREE( edtCreatePtr );
return NULL;
}
Boolean hasURLstruct = edtCreatePtr->existingURLstruct && edtCreatePtr->existingURLstruct->address;
CBrowserContext *nscontext = new CBrowserContext();
newWindow->SetWindowContext( nscontext );
CURLDispatcher::DispatchURL( edtCreatePtr->existingURLstruct, nscontext, false, false, CEditorWindow::res_ID );
if ( edtCreatePtr->context )
{
nscontext->InitHistoryFromContext( (CBrowserContext *)edtCreatePtr->context->fe.newContext );
}
else
{
// the url will eventually be freed when the load is complete.
}
// set window title here (esp. for "open")
if ( !edtCreatePtr->isEmptyPage
&& edtCreatePtr->existingURLstruct && edtCreatePtr->existingURLstruct->address )
{
char *pSlash = strrchr( edtCreatePtr->existingURLstruct->address, '/' );
if ( pSlash )
pSlash += 1; // move past '/'
newWindow->NoteDocTitleChanged( pSlash );
}
XP_FREE( edtCreatePtr );
return newWindow;
}
void CEditorWindow::SetWindowContext(CBrowserContext* inContext)
{
if ( inContext )
{
MWContext *context;
context = inContext->operator MWContext*();
if ( context )
{
context->is_editor = true;
NET_CheckForTimeBomb( context );
}
}
CBrowserWindow::SetWindowContext( inContext );
}
void CEditorWindow::NoteDocTitleChanged( const char* inNewTitle )
{
// there is one bogus set-title from layout that we want to skip...
// We are hard coding "editfilenew" here because it is already hardcoded
// a million other places...
if ( inNewTitle && XP_STRCMP( inNewTitle, "editfilenew" ) == 0 )
return;
CNSContext *theContext = GetWindowContext();
CStr255 title( inNewTitle );
char *baseName = LO_GetBaseURL( theContext->operator MWContext*() ); // don't free this...
// strip out username and password so user doesn't see them in window title
char *location = NULL;
if ( baseName )
NET_ParseUploadURL( baseName, &location, NULL, NULL );
CStr255 csBaseURL(location);
// if this page has a local "file:" url, then just show the file name (skip the url and directory crap.)
if ( location && NET_IsLocalFileURL(location) )
{
char *localName = NULL;
XP_ConvertUrlToLocalFile( location, &localName );
if (localName)
{
#if 0
char *pSlash = strrchr(localName, '/');
if (pSlash)
{ // is there is a slash, move everything AFTER the last slash to the front
pSlash++;
XP_STRCPY(localName, pSlash);
}
#endif
csBaseURL = localName;
XP_FREE(localName);
}
}
CStr255 netscapeTitle;
CStr255 subTitle;
::GetIndString( netscapeTitle, ID_STRINGS, APPNAME_STRING_INDEX );
::GetIndString( subTitle, WINDOW_TITLES_RESID, 3 );
netscapeTitle += " ";
netscapeTitle += subTitle;
netscapeTitle += " - [";
if ( inNewTitle && *inNewTitle )
{
netscapeTitle += title;
if (csBaseURL.Length())
netscapeTitle += " : ";
}
netscapeTitle += csBaseURL;
netscapeTitle += "]";
SetDescriptor( netscapeTitle );
if ( location )
XP_FREE( location );
}
void CEditorWindow::RegisterViewTypes()
{
// Registers all its view types
RegisterClass_( CEditorWindow);
RegisterClass_( CEditView);
RegisterClass_( MultipleSelectionSingleColumn); // newer, better class?
RegisterClass_( CTarget);
RegisterClass_( CLineProp);
RegisterClass_( CFormattingToolBar);
RegisterClass_( CToolbarPopup); // newer, better class?
RegisterClass_( CIconToolbarPopup); // newer, better class?
RegisterClass_( CColorPopup);
RegisterClass_( CFontMenuPopup );
RegisterClass_( CChameleonCaption); // newer, better class?
RegisterClass_( CChameleonView); // newer, better class?
CTabbedDialog::RegisterViewTypes();
RegisterClass_( CTextTable); // newer, better class?
RegisterClass_( CTableKeySingleSelector); // newer, better class?
RegisterClass_( CPatternButtonPopupText); // newer, better class?
RegisterClass_( LOffscreenView);
RegisterClass_( COpenRecentlyEditedPopup );
RegisterClass_( CEditDictionary);
RegisterClass_( CEditDictionaryTable);
}
void CEditorWindow::FinishCreateSelf()
{
CBrowserWindow::FinishCreateSelf();
// Show/hide toolbars based on preference settings
XP_Bool value;
PREF_GetBoolPref(Pref_ShowParagraphBar, &value);
mToolbarShown[eParagraphBar] = value;
ShowOneDragBar(Paragraph_Bar_PaneID, value);
PREF_GetBoolPref(Pref_ShowCharacterBar, &value);
mToolbarShown[eCharacterBar] = value;
ShowOneDragBar(Character_Bar_PaneID, value);
}
void CEditorWindow::ListenToMessage( MessageT inMessage, void* ioParam )
{
switch (inMessage)
{
case msg_NSCDocTitleChanged:
NoteDocTitleChanged((const char*)ioParam);
break;
default:
{
if ( inMessage == 'Para' )
{
switch (*(long*)ioParam)
{
case 1: inMessage = cmd_Format_Paragraph_Normal; break;
case 2: inMessage = cmd_Format_Paragraph_Head1; break;
case 3: inMessage = cmd_Format_Paragraph_Head2; break;
case 4: inMessage = cmd_Format_Paragraph_Head3; break;
case 5: inMessage = cmd_Format_Paragraph_Head4; break;
case 6: inMessage = cmd_Format_Paragraph_Head5; break;
case 7: inMessage = cmd_Format_Paragraph_Head6; break;
case 8: inMessage = cmd_Format_Paragraph_Address; break;
case 9: inMessage = cmd_Format_Paragraph_Formatted; break;
case 10: inMessage = cmd_Format_Paragraph_List_Item; break;
case 11: inMessage = cmd_Format_Paragraph_Desc_Title; break;
case 12: inMessage = cmd_Format_Paragraph_Desc_Text; break;
}
}
else if ( inMessage == 'Size' )
{
switch (*(long*)ioParam)
{
case 1: inMessage = cmd_Format_Font_Size_N2; break;
case 2: inMessage = cmd_Format_Font_Size_N1; break;
case 3: inMessage = cmd_Format_Font_Size_0; break;
case 4: inMessage = cmd_Format_Font_Size_P1; break;
case 5: inMessage = cmd_Format_Font_Size_P2; break;
case 6: inMessage = cmd_Format_Font_Size_P3; break;
case 7: inMessage = cmd_Format_Font_Size_P4; break;
}
}
else if ( inMessage == 'Algn' )
{
switch (*(long*)ioParam)
{
case 1: inMessage = cmd_JustifyLeft; break;
case 2: inMessage = cmd_JustifyCenter; break;
case 3: inMessage = cmd_JustifyRight; break;
}
}
// GetHTMLView() guaranteed not to fail
GetHTMLView()->ObeyCommand( inMessage, ioParam );
break;
}
}
}
// EDT_PreCloseCallbackFn
static void closeEditorWindowCallback( void* hook )
{
CEditorWindow *editorWindow = (CEditorWindow *)hook;
if ( editorWindow )
editorWindow->SetPluginDoneClosing();
}
Boolean CEditorWindow::ObeyCommand( CommandT inCommand, void *ioParam )
{
switch ( inCommand )
{
case cmd_NewWindowEditor:
CEditorWindow::MakeEditWindow( NULL, NULL );
break;
case cmd_ViewSource:
// Delegate this to the view.
if ( ((CEditView *)GetHTMLView())->IsDoneLoading() )
GetHTMLView()->ObeyCommand(inCommand, ioParam);
break;
case cmd_Toggle_Paragraph_Toolbar:
ToggleDragBar(Paragraph_Bar_PaneID, eParagraphBar, Pref_ShowParagraphBar);
break;
case cmd_Toggle_Character_Toolbar:
ToggleDragBar(Character_Bar_PaneID, eCharacterBar, Pref_ShowCharacterBar);
break;
case cmd_Close:
case cmd_Quit: // we'll just intercept these and then send them on to the default case
MWContext *mwcontext = GetWindowContext()->operator MWContext*();
History_entry* newEntry = SHIST_GetCurrent(&mwcontext->hist);
CStr255 fileName;
if ( newEntry && newEntry->address )
fileName = newEntry->address;
if ( ((CEditView *)GetHTMLView())->IsDoneLoading() && EDT_DirtyFlag( *GetWindowContext() ) )
{
Select(); // This helps during a quit or "close all"
MessageT itemHit = HandleModalDialog( EDITDLG_SAVE_BEFORE_QUIT, fileName, NULL );
if (itemHit == cancel)
return true;
if (itemHit == ok)
{ // save
if ( !((CEditView *)GetHTMLView())->SaveDocument() )
return true;
}
EDT_SetDirtyFlag( mwcontext, false ); // we have to do this or else when we quit, we will be asked twice to save
}
// need to let this work asynchronously; make our own internal loop
if ( ((CEditView *)GetHTMLView())->IsDoneLoading() && newEntry && newEntry->address )
{
mPluginDoneClosing = false;
EDT_PreClose( mwcontext, newEntry->address, closeEditorWindowCallback, this );
do
{
CFrontApp::GetApplication()->ProcessNextEvent();
} while ( !mPluginDoneClosing );
}
// fall through
default:
{
return CBrowserWindow::ObeyCommand (inCommand, ioParam);
}
}
return TRUE;
}
void CEditorWindow::FindCommandStatus( CommandT inCommand,
Boolean& outEnabled, Boolean& outUsesMark, Char16& outMark,
Str255 outName )
{
short index;
outUsesMark = FALSE;
outEnabled = false;
switch ( inCommand )
{
case cmd_ViewSource:
// Delegate this to the view.
if ( ((CEditView *)GetHTMLView())->IsDoneLoading() )
GetHTMLView()->FindCommandStatus(inCommand, outEnabled, outUsesMark, outMark, outName);
break;
case cmd_Toggle_Character_Toolbar:
outEnabled = ((CEditView *)GetHTMLView())->IsDoneLoading();
index = mToolbarShown[eCharacterBar] ? CEditView::EDITOR_MENU_HIDE_COMP_TOOLBAR
: CEditView::EDITOR_MENU_SHOW_COMP_TOOLBAR;
::GetIndString( outName, CEditView::STRPOUND_EDITOR_MENUS, index );
break;
case cmd_Toggle_Paragraph_Toolbar:
outEnabled = ((CEditView *)GetHTMLView())->IsDoneLoading();
index = mToolbarShown[eParagraphBar] ? CEditView::EDITOR_MENU_HIDE_FORMAT_TOOLBAR
: CEditView::EDITOR_MENU_SHOW_FORMAT_TOOLBAR;
::GetIndString( outName, CEditView::STRPOUND_EDITOR_MENUS, index );
break;
default:
CBrowserWindow::FindCommandStatus(inCommand, outEnabled, outUsesMark, outMark, outName );
}
}
// Called when we are trying to quit the application
Boolean CEditorWindow::AttemptQuitSelf( long inSaveOption )
{
MWContext *mwcontext = GetWindowContext()->operator MWContext*();
if ( EDT_DirtyFlag( mwcontext ) )
{
History_entry* newEntry = SHIST_GetCurrent(&mwcontext->hist);
CStr255 fileName;
if ( newEntry && newEntry->address )
fileName = newEntry->address;
if ( kAEAsk == inSaveOption )
{
MessageT itemHit = HandleModalDialog( EDITDLG_SAVE_BEFORE_QUIT, fileName, NULL );
if ( cancel == itemHit )
return false;
}
// save
if ( !((CEditView *)GetHTMLView())->SaveDocument() )
return false;
}
return true;
}
#ifdef PROFILE
#pragma profile off
#endif

View File

@@ -0,0 +1,67 @@
/* -*- 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.
*/
#pragma once
#include "CBrowserWindow.h"
struct EditorCreationStruct {
MWContext *context; // may be NULL
URL_Struct *existingURLstruct;
Boolean isEmptyPage;
};
/******************************************************************************
* CEditorWindow is really just a CBrowserWindow with some changes for an editor window.
******************************************************************************/
class CEditorWindow: public CBrowserWindow
{
public:
enum {class_ID = 'edtw', res_ID = 10000};
// ¥¥ Constructors
static void RegisterViewTypes(); // Registers all its view types
static CEditorWindow *MakeEditWindow( MWContext* old_context, URL_Struct* url );
static CEditorWindow *CreateEditorWindowStage2( EditorCreationStruct *edtCreatePtr);
static void MakeEditWindowFromBrowser( MWContext* mwcontext );
CEditorWindow(LStream * inStream);
virtual void FinishCreateSelf();
virtual void SetWindowContext(CBrowserContext* inContext);
// ¥¥ Command handling
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual Boolean ObeyCommand( CommandT inCommand, void *ioParam );
virtual void FindCommandStatus( CommandT inCommand,
Boolean& outEnabled, Boolean& outUsesMark,
Char16& outMark,Str255 outName );
virtual void NoteDocTitleChanged( const char* title );
virtual Boolean AttemptQuitSelf( long inSaveOption );
static CEditorWindow* FindAndShow(Boolean inMakeNew = false);
virtual void SetPluginDoneClosing() { mPluginDoneClosing = true; }
protected:
virtual ResIDT GetStatusResID(void) const { return CEditorWindow::res_ID; }
Boolean mPluginDoneClosing;
};

View File

@@ -0,0 +1,299 @@
/* -*- 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 "CFontMenuAttachment.h"
#include "CEditView.h"
#include "CBrowserContext.h" // operator MWContext*()
#include "resgui.h" // cmd_FormatViewerFont, cmd_FormatFixedFont, FONT_MENU_BASE
#include "macutil.h" // CMediatedWindow
#include "edt.h"
LMenu *CFontMenuAttachment::sMenu = NULL;
//===========================================================
// CFontMenuAttachment
//===========================================================
CFontMenuAttachment::CFontMenuAttachment()
{
UpdateMenu();
}
MWContext *CFontMenuAttachment::GetTopWindowContext()
{
// Ok, ok. I know this is skanky,
// but there is no common way to get the context from a window: it depends on the window type.
// So, we look around for a CEditView somewhere in the top window.
// A CEditView we understand (and get an MWContext from).
CMediatedWindow* topWin = NULL; // find the top window to use the plugin in
CWindowIterator iter(WindowType_Any);
iter.Next(topWin);
if (topWin == NULL
|| ! (topWin->GetWindowType() == WindowType_Editor || topWin->GetWindowType() == WindowType_Compose) )
return NULL;
CEditView *editView = (CEditView *)(topWin->FindPaneByID(CEditView::pane_ID));
if (editView == NULL || editView->GetNSContext() == NULL)
return NULL;
return editView->GetNSContext()->operator MWContext*();
}
// Processes:
//
void CFontMenuAttachment::ExecuteSelf( MessageT inMessage, void* ioParam )
{
mExecuteHost = FALSE;
switch ( inMessage )
{
case msg_CommandStatus:
{
SCommandStatus* status = (SCommandStatus*)ioParam;
EDT_CharacterData* better;
if ( status->command == cmd_FormatViewerFont || status->command == cmd_FormatFixedFont
|| ( status->command >= FONT_MENU_BASE && status->command <= FONT_MENU_BASE_LAST ) )
{
*(status->enabled) = true;
*(status->usesMark) = false;
better = NULL;
MWContext *cntxt = GetTopWindowContext();
if ( cntxt )
better = EDT_GetCharacterData( cntxt );
if ( better == NULL )
{
*(status->enabled) = false;
return;
}
}
switch ( status->command )
{
case cmd_FormatViewerFont:
*(status->usesMark) = ( ! ( better->values & TF_FIXED ) && !( better->values & TF_FONT_FACE ) );
*(status->mark) = *(status->usesMark) ? checkMark : 0;
*(status->usesMark) = true;
EDT_FreeCharacterData(better);
mExecuteHost = false;
return;
break;
case cmd_FormatFixedFont:
*(status->usesMark) = ( better->values & TF_FIXED ) != 0;
*(status->mark) = *(status->usesMark) ? checkMark : 0;
*(status->usesMark) = true;
EDT_FreeCharacterData(better);
mExecuteHost = false;
return;
break;
default:
if ( status->command >= FONT_MENU_BASE && status->command <= FONT_MENU_BASE_LAST )
{
// get font menu item
Str255 fontItemString;
fontItemString[0] = 0;
MenuHandle menuh = GetMenu()->GetMacMenuH();
::GetMenuItemText ( menuh, status->command - FONT_MENU_BASE + PERM_FONT_ITEMS + 1, fontItemString );
p2cstr( fontItemString );
// in mixed situation the mask bit will be cleared
*(status->usesMark) = ( better->values & TF_FONT_FACE && better->pFontFace && XP_STRLEN((char *)fontItemString) > 0
&& XP_STRSTR( better->pFontFace, (char *)fontItemString ) != NULL );
*(status->mark) = *(status->usesMark) ? checkMark : 0;
*(status->usesMark) = true;
EDT_FreeCharacterData(better);
mExecuteHost = false;
return;
}
}
}
break;
case cmd_FormatViewerFont:
MWContext *cntxt2 = GetTopWindowContext();
if ( cntxt2 )
EDT_SetFontFace( cntxt2, NULL, 0, NULL );
break;
case cmd_FormatFixedFont:
MWContext *cntxt3 = GetTopWindowContext();
if ( cntxt3 )
EDT_SetFontFace( cntxt3, NULL, 1, NULL );
break;
default:
{
if ( inMessage >= FONT_MENU_BASE && inMessage <= FONT_MENU_BASE_LAST )
{
MWContext *cntxt2 = GetTopWindowContext();
if ( cntxt2 )
{
// get font menu item
Str255 newFontItemString;
newFontItemString[0] = 0;
MenuHandle menuh = GetMenu()->GetMacMenuH();
::GetMenuItemText ( menuh, inMessage - FONT_MENU_BASE + PERM_FONT_ITEMS + 1, newFontItemString );
p2cstr( newFontItemString );
EDT_SetFontFace( cntxt2, NULL, -1, (char *)newFontItemString );
mExecuteHost = false;
return;
}
}
}
break;
}
mExecuteHost = TRUE; // Let application handle it
}
LMenu *CFontMenuAttachment::GetMenu()
{
if (!sMenu)
sMenu = new LMenu(cFontMenuID);
return sMenu;
}
// build the font menu from the system
void CFontMenuAttachment::UpdateMenu()
{
if (!GetMenu() || !LMenuBar::GetCurrentMenuBar())
return;
int i;
// ¥ delete all the menu items after the separator line
MenuHandle menu = sMenu->GetMacMenuH();
if ( menu )
{
for ( i = ::CountMItems( menu ); i > PERM_FONT_ITEMS; i-- )
sMenu->RemoveItem( i );
}
Try_
{
ThrowIfNil_( menu );
// Add fonts to menu
::InsertResMenu( menu, 'FONT', PERM_FONT_ITEMS );
int commandNum = FONT_MENU_BASE;
int newHowMany = ::CountMItems( menu );
for (i = PERM_FONT_ITEMS + 1; i <= newHowMany; i++ )
sMenu->SetCommand( i, commandNum++ );
}
Catch_( inErr )
{
}
EndCatch_
}
void CFontMenuAttachment::RemoveMenus()
{
if (sMenu)
{
LMenuBar *currentMenuBar = LMenuBar::GetCurrentMenuBar();
if (currentMenuBar)
currentMenuBar->RemoveMenu(sMenu);
}
}
void CFontMenuAttachment::InstallMenus()
{
if (sMenu)
{
LMenuBar *currentMenuBar = LMenuBar::GetCurrentMenuBar();
if (currentMenuBar)
{
StValueChanger<EDebugAction> okayToFail(gDebugThrow, debugAction_Nothing);
currentMenuBar->InstallMenu(sMenu, hierMenu);
ResIDT resID;
MenuHandle menuh;
Int16 whichItem;
currentMenuBar->FindMenuItem( cmd_ID_toSearchFor, resID, menuh, whichItem );
if ( menuh )
{
// make it hierarchical
::SetItemCmd( menuh, whichItem, hMenuCmd );
::SetItemMark( menuh, whichItem, menu_ID );
}
}
}
}
#pragma mark -
CFontMenuPopup::CFontMenuPopup( LStream *inStream ) : CPatternButtonPopupText( inStream )
{
}
CFontMenuPopup::~CFontMenuPopup()
{
}
void CFontMenuPopup::FinishCreateSelf( void )
{
CPatternButtonPopupText::FinishCreateSelf();
int i;
// ¥ delete all the menu items after the separator line
LMenu *ppmenu = GetMenu();
MenuHandle menuh = ppmenu ? ppmenu->GetMacMenuH() : NULL;
if ( menuh )
{
for ( i = ::CountMItems( menuh ); i > CFontMenuAttachment::PERM_FONT_ITEMS; i-- )
ppmenu->RemoveItem( i );
}
Try_
{
ThrowIfNil_( menuh );
// Add fonts to menu
::InsertResMenu( menuh, 'FONT', CFontMenuAttachment::PERM_FONT_ITEMS );
int commandNum = FONT_MENU_BASE;
int newHowMany = ::CountMItems( menuh );
for (i = CFontMenuAttachment::PERM_FONT_ITEMS + 1; i <= newHowMany; i++ )
ppmenu->SetCommand( i, commandNum++ );
SetMaxValue( newHowMany );
}
Catch_( inErr )
{
}
EndCatch_
}

View File

@@ -0,0 +1,73 @@
/* -*- 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.
*/
#pragma once
#ifndef CFONTMENUATTACHMENT_H_
#define CFONTMENUATTACHMENT_H_
#include <LAttachment.h>
#include "CPatternButtonPopupText.h"
#include "ntypes.h" // MWContext
class LMenu;
/***********************************************************************************
* CFontMenuAttachment
* Processes Font menu commands -- should be attached to application
* Currently, this menu is only used in the Editor and mail compose window
***********************************************************************************/
class CFontMenuAttachment: public LAttachment
{
public:
enum { menu_ID = 13, PERM_FONT_ITEMS = 3, cmd_ID_toSearchFor = 'FONT' };
// ¥¥ constructors
CFontMenuAttachment();
// ¥¥Êevents
virtual void ExecuteSelf( MessageT inMessage, void* ioParam );
static LMenu* GetMenu();
static void UpdateMenu();
static void RemoveMenus();
static void InstallMenus();
protected:
static MWContext* GetTopWindowContext();
static LMenu* sMenu;
};
class CFontMenuPopup : public CPatternButtonPopupText
{
public:
enum { class_ID = 'Fpop' };
static void* CreateCFontMenuPopupStream( LStream *inStream ) {return( new CFontMenuPopup (inStream ));};
CFontMenuPopup( LStream *inStream ); // ¥ Constructor
~CFontMenuPopup(); // ¥ Destructor
// ¥ drawing
void FinishCreateSelf(void);
};
#endif

View File

@@ -0,0 +1,124 @@
/* -*- 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 "CFormattingToolBar.h"
#include "CEditView.h"
#include "resgui.h"
#include "edt.h"
CFormattingToolBar::CFormattingToolBar(LStream * inStream)
: CPatternBevelView(inStream)
{
}
CFormattingToolBar::~CFormattingToolBar()
{
mEditView = NULL;
}
void CFormattingToolBar::FinishCreateSelf()
{
if ( GetSuperView() )
{
// get SuperView (we start with "this" so we're guaranteed non-0)
LView *superView = (LView *)this;
while (superView->GetSuperView() != NULL)
superView = superView->GetSuperView();
mEditView = dynamic_cast<CEditView*>(superView->FindPaneByID( CEditView::pane_ID ));
}
else
mEditView = dynamic_cast<CEditView*>(FindPaneByID( CEditView::pane_ID ));
// if we have a mailcompose window show insert object popup menu
// check for presence of insert menu within CFormattingToolBar
LPane *pane = FindPaneByID('InsO');
if ( pane )
{
CMailEditView *mailview = dynamic_cast<CMailEditView*>( mEditView );
if ( mailview )
pane->Show();
else
pane->Hide();
}
UReanimator::LinkListenerToControls(this, this, 11616);
}
void CFormattingToolBar::ListenToMessage( MessageT inMessage, void* ioParam )
{
PaneIDT paneID = CEditView::pane_ID;
if ( mEditView == NULL )
return;
if ( inMessage == 'Para' )
{
switch (*(long*)ioParam)
{
case 1: inMessage = cmd_Format_Paragraph_Normal; break;
case 2: inMessage = cmd_Format_Paragraph_Head1; break;
case 3: inMessage = cmd_Format_Paragraph_Head2; break;
case 4: inMessage = cmd_Format_Paragraph_Head3; break;
case 5: inMessage = cmd_Format_Paragraph_Head4; break;
case 6: inMessage = cmd_Format_Paragraph_Head5; break;
case 7: inMessage = cmd_Format_Paragraph_Head6; break;
case 8: inMessage = cmd_Format_Paragraph_Address; break;
case 9: inMessage = cmd_Format_Paragraph_Formatted; break;
case 10: inMessage = cmd_Format_Paragraph_List_Item; break;
case 11: inMessage = cmd_Format_Paragraph_Desc_Title; break;
case 12: inMessage = cmd_Format_Paragraph_Desc_Text; break;
}
}
else if ( inMessage == 'Size' )
{
switch (*(long*)ioParam)
{
case 1: inMessage = cmd_Format_Font_Size_N2; break;
case 2: inMessage = cmd_Format_Font_Size_N1; break;
case 3: inMessage = cmd_Format_Font_Size_0; break;
case 4: inMessage = cmd_Format_Font_Size_P1; break;
case 5: inMessage = cmd_Format_Font_Size_P2; break;
case 6: inMessage = cmd_Format_Font_Size_P3; break;
case 7: inMessage = cmd_Format_Font_Size_P4; break;
}
}
else if ( inMessage == 'Algn' )
{
switch (*(long*)ioParam)
{
case 1: inMessage = cmd_JustifyLeft; break;
case 2: inMessage = cmd_JustifyCenter; break;
case 3: inMessage = cmd_JustifyRight; break;
}
}
else if ( inMessage == 'InsO' )
{
switch (*(long*)ioParam)
{
case 1: inMessage = cmd_Insert_Link; break;
case 2: inMessage = cmd_Insert_Target; break;
case 3: inMessage = cmd_Insert_Image; break;
case 4: inMessage = cmd_Insert_Line; break;
case 5: inMessage = cmd_Insert_Table; break;
}
}
mEditView->ObeyCommand( inMessage, ioParam );
}

View File

@@ -0,0 +1,42 @@
/* -*- 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.
*/
#pragma once
#include "CPatternBevelView.h"
#include <LListener.h>
class CEditView;
// used in Editor window and Mail Compose windows
class CFormattingToolBar : public CPatternBevelView, public LListener
{
public:
enum {class_ID = 'FoTB'};
CFormattingToolBar(LStream * inStream);
~CFormattingToolBar();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual void FinishCreateSelf();
protected:
CEditView* mEditView;
};

View File

@@ -0,0 +1,184 @@
/* -*- 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.
*/
// ===========================================================================
// COpenRecentlyEditedPopup.cp
// ===========================================================================
#include "COpenRecentlyEditedPopup.h"
#include "CWindowMediator.h"
#include "CBrowserContext.h"
#include "CEditorWindow.h"
#include "UMenuUtils.h"
#include "PascalString.h"
#include "net.h" // NET_CreateURLStruct
#include "structs.h" // TagType which is needed in edt.h
#include "edt.h"
// ---------------------------------------------------------------------------
// ¥ CreateNavigationButtonPopupStream [static]
// ---------------------------------------------------------------------------
COpenRecentlyEditedPopup*
COpenRecentlyEditedPopup::CreateOpenRecentlyEditedPopupStream( LStream* inStream )
{
return new COpenRecentlyEditedPopup(inStream);
}
// ---------------------------------------------------------------------------
// ¥ COpenRecentlyEditedPopup
// ---------------------------------------------------------------------------
COpenRecentlyEditedPopup::COpenRecentlyEditedPopup( LStream* inStream )
: mBrowserContext(nil),
super(inStream)
{
}
// ---------------------------------------------------------------------------
// ¥ ~COpenRecentlyEditedPopup
// ---------------------------------------------------------------------------
COpenRecentlyEditedPopup::~COpenRecentlyEditedPopup()
{
}
#pragma mark -
// ---------------------------------------------------------------------------
// ¥ AdjustMenuContents
// ---------------------------------------------------------------------------
void
COpenRecentlyEditedPopup::AdjustMenuContents()
{
if (!GetMenu() || !GetMenu()->GetMacMenuH())
return;
if (!AssertPreconditions())
return;
// Purge the menu
UMenuUtils::PurgeMenuItems(GetMenu()->GetMacMenuH(), PERM_OPEN_ITEMS);
// Fill the menu
int i;
char *urlp = NULL, *titlep = NULL;
for ( i = 0; i < MAX_EDIT_HISTORY_LOCATIONS
&& EDT_GetEditHistory( ((MWContext *)(*mBrowserContext)), i, &urlp, &titlep ); i++ )
{
// strange logic: if we have no URL (then how do we go there???) then use title if it exists
if ( urlp == NULL )
urlp = titlep;
if ( urlp )
{
NET_UnEscape( urlp );
InsertItemIntoMenu( urlp, PERM_OPEN_ITEMS + i );
}
else
break;
}
// delete menu break line if we don't have any history items
if ( i == 0 )
{
::DeleteMenuItem( GetMenu()->GetMacMenuH(), PERM_OPEN_ITEMS );
}
// Set the min/max values of the control since we populated the menu
SetPopupMinMaxValues();
}
// ---------------------------------------------------------------------------
// ¥ InsertItemIntoMenu
// ---------------------------------------------------------------------------
void
COpenRecentlyEditedPopup::InsertItemIntoMenu( char *urlp, Int16 inAfterItem )
{
Assert_(GetMenu() && GetMenu()->GetMacMenuH());
Assert_(mBrowserContext);
CStr255 thePString( urlp );
// Insert a "blank" item first...
::InsertMenuItem( GetMenu()->GetMacMenuH(), "\p ", inAfterItem + 1 );
// Then change it. We do this so that no interpretation of metacharacters will occur.
::SetMenuItemText( GetMenu()->GetMacMenuH(), inAfterItem + 1, thePString );
}
#pragma mark -
// ---------------------------------------------------------------------------
// ¥ HandleNewValue
// ---------------------------------------------------------------------------
Boolean
COpenRecentlyEditedPopup::HandleNewValue( Int32 inNewValue )
{
if ( inNewValue >= 1 && inNewValue < PERM_OPEN_ITEMS )
{
// someone else will handle this
return false;
}
if ( AssertPreconditions() && inNewValue )
{
MWContext *cntxt = ((MWContext *)(*mBrowserContext));
if ( cntxt )
{
char *aURLtoOpen = NULL;
// EDT_GetEditHistory is 0-based so deduct 1 from 2nd parameter
if ( EDT_GetEditHistory( cntxt, inNewValue - PERM_OPEN_ITEMS - 1, &aURLtoOpen, NULL) )
{
URL_Struct* theURL = NET_CreateURLStruct( aURLtoOpen, NET_NORMAL_RELOAD );
if ( theURL )
CEditorWindow::MakeEditWindow( NULL, theURL );
}
}
}
return true;
}
// ---------------------------------------------------------------------------
// ¥ AssertPreconditions
// ---------------------------------------------------------------------------
// Assert preconditions and fill in interesting member data
Boolean
COpenRecentlyEditedPopup::AssertPreconditions()
{
CMediatedWindow* topWindow = CWindowMediator::GetWindowMediator()->FetchTopWindow( WindowType_Any, regularLayerType );
if (!topWindow || topWindow->GetWindowType() != WindowType_Editor)
return false;
CEditorWindow* composerWindow = dynamic_cast<CEditorWindow*>(topWindow);
if ( !composerWindow )
return false;
if ( !(mBrowserContext = (CBrowserContext*)composerWindow->GetWindowContext()) )
return false;
return true;
}

View File

@@ -0,0 +1,63 @@
/* -*- 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.
*/
// ===========================================================================
// COpenRecentlyEditedPopup.h
// ===========================================================================
#ifndef COpenRecentlyEditedPopup_H
#define COpenRecentlyEditedPopup_H
#pragma once
// Includes
#include "CPatternButtonPopup.h"
// Forward declarations
class CBrowserContext;
// Class declaration
class COpenRecentlyEditedPopup : public CPatternButtonPopup
{
public:
enum { class_ID = 'PbRc', PERM_OPEN_ITEMS = 3 };
typedef CPatternButtonPopup super;
static COpenRecentlyEditedPopup* CreateOpenRecentlyEditedPopupStream(LStream* inStream);
COpenRecentlyEditedPopup(LStream* inStream);
virtual ~COpenRecentlyEditedPopup();
protected:
virtual void AdjustMenuContents();
virtual void InsertItemIntoMenu( char *urlp,
Int16 inAfterItem );
virtual Boolean HandleNewValue(Int32 inNewValue);
Boolean AssertPreconditions();
CBrowserContext* mBrowserContext;
};
#endif

View File

@@ -0,0 +1,210 @@
/* -*- 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.
*/
//===========================================================
// CRecentEditMenuAttachment.cp
//===========================================================
#include "CRecentEditMenuAttachment.h"
#include "CEditView.h"
#include "CBrowserContext.h" // operator MWContext*()
#include "resgui.h"
#include "macutil.h" // CMediatedWindow
#include "UMenuUtils.h"
#include "edt.h"
#include "CEditorWindow.h"
LMenu *CRecentEditMenuAttachment::sMenu = NULL;
CRecentEditMenuAttachment::CRecentEditMenuAttachment()
{
UpdateMenu();
}
MWContext *CRecentEditMenuAttachment::GetTopWindowContext()
{
// Ok, ok. I know this is skanky,
// but there is no common way to get the context from a window: it depends on the window type.
// So, we look around for a CEditView somewhere in the top window.
// A CEditView we understand (and get an MWContext from).
CMediatedWindow* topWin = NULL; // find the top window to use the plugin in
CWindowIterator iter(WindowType_Any);
iter.Next(topWin);
if (topWin == NULL
|| ! (topWin->GetWindowType() == WindowType_Editor || topWin->GetWindowType() == WindowType_Compose) )
return NULL;
CEditView *editView = (CEditView *)(topWin->FindPaneByID(CEditView::pane_ID));
if (editView == NULL || editView->GetNSContext() == NULL)
return NULL;
return editView->GetNSContext()->operator MWContext*();
}
// Processes
void CRecentEditMenuAttachment::ExecuteSelf( MessageT inMessage, void* ioParam )
{
switch ( inMessage )
{
case msg_CommandStatus:
{
SCommandStatus* status = (SCommandStatus*)ioParam;
if ( status->command >= RECENT_EDIT_MENU_BASE && status->command <= RECENT_EDIT_MENU_BASE_LAST )
{
*(status->enabled) = true;
mExecuteHost = false;
return;
}
}
break;
default:
{
if ( inMessage >= RECENT_EDIT_MENU_BASE && inMessage <= RECENT_EDIT_MENU_BASE_LAST )
{
MWContext *cntxt2 = GetTopWindowContext();
if ( cntxt2 )
{
char *aURLtoOpen = NULL;
if ( EDT_GetEditHistory( cntxt2, inMessage - RECENT_EDIT_MENU_BASE - 1, &aURLtoOpen, NULL) )
{
URL_Struct* theURL = NET_CreateURLStruct( aURLtoOpen, NET_NORMAL_RELOAD );
if ( theURL )
CEditorWindow::MakeEditWindow( NULL, theURL );
mExecuteHost = false;
return;
}
}
}
}
break;
}
mExecuteHost = true; // Let application handle it
}
LMenu *CRecentEditMenuAttachment::GetMenu()
{
if (!sMenu)
sMenu = new LMenu( menu_ID );
return sMenu;
}
// build the font menu from the system
void CRecentEditMenuAttachment::UpdateMenu()
{
if (!GetMenu() || !LMenuBar::GetCurrentMenuBar())
return;
int i;
// ¥ delete all the menu items after the separator line
MenuHandle menu = sMenu->GetMacMenuH();
if ( menu )
{
for ( i = ::CountMItems( menu ); i > 0; i-- )
sMenu->RemoveItem( i );
}
Try_
{
ThrowIfNil_( menu );
// Add recently edited URLs to menu
int i;
char *urlp = NULL, *titlep = NULL;
for ( i = 0; i < MAX_EDIT_HISTORY_LOCATIONS
&& EDT_GetEditHistory( GetTopWindowContext(), i, &urlp, &titlep ); i++ )
{
NET_UnEscape( urlp );
// convert string to pascal-string for menu
CStr255 menuStr(urlp);
if ( menuStr.IsEmpty() )
menuStr = titlep;
if ( !menuStr.IsEmpty() )
{
// Insert a "blank" item first...
::InsertMenuItem( GetMenu()->GetMacMenuH(), "\p ", i );
// Then change it. We do this so that no interpretation of metacharacters will occur.
::SetMenuItemText( GetMenu()->GetMacMenuH(), i + 1, menuStr );
// SetCommand for menu item
sMenu->SetCommand( i, RECENT_EDIT_MENU_BASE + i );
sMenu->SetUsed( true );
}
else
break;
}
}
Catch_( inErr )
{
}
EndCatch_
}
void CRecentEditMenuAttachment::RemoveMenus()
{
if (sMenu)
{
LMenuBar *currentMenuBar = LMenuBar::GetCurrentMenuBar();
if (currentMenuBar)
currentMenuBar->RemoveMenu(sMenu);
}
}
void CRecentEditMenuAttachment::InstallMenus()
{
if (sMenu)
{
LMenuBar *currentMenuBar = LMenuBar::GetCurrentMenuBar();
if (currentMenuBar)
{
StValueChanger<EDebugAction> okayToFail(gDebugThrow, debugAction_Nothing);
currentMenuBar->InstallMenu(sMenu, hierMenu);
ResIDT resID;
MenuHandle menuh;
Int16 whichItem;
currentMenuBar->FindMenuItem( cmd_ID_toSearchFor, resID, menuh, whichItem );
if ( menuh )
{
// make it hierarchical
::SetItemCmd( menuh, whichItem, hMenuCmd );
::SetItemMark( menuh, whichItem, menu_ID );
}
}
}
}

View File

@@ -0,0 +1,55 @@
/* -*- 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.
*/
#pragma once
#ifndef CRECENTEDITMENUATTACHMENT_H_
#define CRECENTEDITMENUATTACHMENT_H_
#include <LAttachment.h>
#include <LMenu.h>
#include "ntypes.h"
/***********************************************************************************
* CRecentEditMenuAttachment
* Processes Recent-Edited files menu commands -- should be attached to application
* Currently, this menu is only used in the Editor window
***********************************************************************************/
class CRecentEditMenuAttachment: public LAttachment
{
public:
enum { menu_ID = 24, cmd_ID_toSearchFor = 'Rece' };
// ¥¥ constructors
CRecentEditMenuAttachment();
// ¥¥Êevents
virtual void ExecuteSelf( MessageT inMessage, void* ioParam );
static LMenu* GetMenu();
static void UpdateMenu();
static void RemoveMenus();
static void InstallMenus();
protected:
static MWContext* GetTopWindowContext();
static LMenu* sMenu;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,83 @@
/* -*- 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.
*/
#pragma once
#include "spellchk.h"
#include "ntypes.h" // MWContext
class CEditView;
class LEditField;
class CTextTable;
class CSimpleTextView;
// public definitions
void do_spellcheck( MWContext *mwcontext, CEditView *editView, CSimpleTextView *textView );
#define cmd_CheckSpelling 'ChSp'
// internal
const int SpellCheckerResource = 5109;
const int ChangeStringIndex = 1;
const int DoneStringIndex = 2;
const int NSDictionaryNameIndex = 3;
const int UserDictionaryNameIndex = 4;
// UI management class
class CMacSpellChecker
{
public:
enum { class_ID = 'Spel', res_ID = 5299 };
enum { pane_NewWord = 'NewW', pane_SuggestionList = 'AltW',
msg_Change = 'Chng', msg_Change_All = 'CAll',
msg_Ignore = 'Ignr', msg_Ignore_All = 'IAll',
msg_Add_Button = 'AddB', msg_Check = 'Chck',
msg_Stop = 'Stop', msg_NewLanguage = 'Lang',
msg_SelectionChanged = 'SelC', msg_EditDictionary = 'EdDc' };
CMacSpellChecker( MWContext *context,
CEditView *editView, CSimpleTextView *textView );
char *GetTextBuffer();
void GetSelection( int32 &selStart, int32 &selEnd );
void ReplaceHilitedText( char *newText, Boolean doAll );
void IgnoreHilitedText( Boolean doAll );
void SetNextMisspelledWord( char *textP, LEditField *typoField, CTextTable *t, LCommander *c );
Boolean GetNextMisspelledWord( Boolean doFirstWord );
void ClearReplacementWord( LEditField *newWord, CTextTable *table );
void GetAlternativesForWord( LEditField *newWord, CTextTable *table, LCommander *c );
Boolean StartProcessing( Boolean startOver );
void ShowDialog( char *textP );
MWContext *GetMWContext() { return mMWContext; };
ISpellChecker *GetISpellChecker() { return mISpellChecker; };
void SetISpellChecker( ISpellChecker *i ) { mISpellChecker = i; };
Boolean isHTMLeditor() { return mEditView != NULL; };
private:
ISpellChecker *mISpellChecker;
MWContext *mMWContext; // only if mEditView; ignored if mTextView
Str255 mOrigMisspelledWord;
// we should have one and only one of these-->evidence that this class is mis-designed
CEditView *mEditView;
CSimpleTextView *mTextView;
};

View File

@@ -0,0 +1,338 @@
/* -*- 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 "CToolsAttachment.h"
#include "CEditView.h"
#include "CBrowserContext.h" // operator MWContext*()
#include "resgui.h" // TOOLS_MENU_BASE_LAST
#include "macutil.h" // CMediatedWindow
#include "UMenuUtils.h"
#include "edt.h"
//#include "CSpellChecker.h"
#include <LArray.h>
#define PERM_TOOLS_ITEMS 2
#define PERM_TOOLS_END_ITEMS 1
const CommandT cmd_ToolsHierItem = TOOLS_MENU_BASE_LAST;
LMenu *CToolsAttachment::sMenu = NULL;
Boolean CToolsAttachment::sInvalidMenu = true;
LArray CToolsAttachment::sMenusList;
//===========================================================
// CToolsAttachment
//===========================================================
CToolsAttachment::CToolsAttachment()
{
}
MWContext *CToolsAttachment::GetTopWindowContext()
{
// Ok, ok. I know this is skanky,
// but there is no common way to get the context from a window: it depends on the window type.
// So, we look around for a CEditView somewhere in the top window.
// A CEditView we understand (and get an MWContext from).
CMediatedWindow* topWin = NULL; // find the top window to use the plugin in
CWindowIterator iter(WindowType_Any);
// do {
iter.Next(topWin);
// } while (topWin && topWin->GetWindowType() != WindowType_Editor && topWin->GetWindowType() != WindowType_Compose);
if (topWin == NULL)
return NULL;
if ( topWin->GetWindowType() != WindowType_Editor && topWin->GetWindowType() != WindowType_Compose )
return NULL;
CEditView *editView = (CEditView *)(topWin->FindPaneByID(CEditView::pane_ID));
if (editView == NULL || editView->GetNSContext() == NULL)
return NULL;
return editView->GetNSContext()->operator MWContext*();
}
// Processes:
void CToolsAttachment::ExecuteSelf( MessageT inMessage, void* ioParam )
{
mExecuteHost = FALSE;
switch ( inMessage )
{
// case cmd_CheckSpelling: // spell checker
// return;
case cmd_EditorPluginStop:
MWContext *cntxt = GetTopWindowContext();
if (cntxt)
EDT_StopPlugin(cntxt);
return;
case msg_CommandStatus:
{
SCommandStatus* status = (SCommandStatus*)ioParam;
switch ( status->command )
{
case cmd_EditorPluginStop:
MWContext *cntxt = GetTopWindowContext();
*(status->enabled) = cntxt && EDT_IsPluginActive(cntxt);
*(status->usesMark) = FALSE;
return;
default:
if ( status->command >= TOOLS_MENU_BASE && status->command <= TOOLS_MENU_BASE_LAST )
{
*(status->enabled) = TRUE;
*(status->usesMark) = FALSE;
return;
}
break;
}
}
break;
default:
{
if ( inMessage >= TOOLS_MENU_BASE && inMessage <= TOOLS_MENU_BASE_LAST )
{
int32 index = inMessage - TOOLS_MENU_BASE;
for (int32 CategoryIndex = 0; CategoryIndex < EDT_NumberOfPluginCategories(); CategoryIndex++)
for (int32 PluginIndex = 0; PluginIndex < EDT_NumberOfPlugins(CategoryIndex); PluginIndex++)
if (index-- == 0)
{ // count down until we find which one...
MWContext *cntxt = GetTopWindowContext();
if (cntxt)
EDT_PerformPlugin(cntxt, CategoryIndex, PluginIndex, 0, 0); // what is the result for?
return;
}
}
}
break;
}
mExecuteHost = TRUE; // Let application handle it
}
LMenu *CToolsAttachment::GetMenu()
{
if (!sMenu)
sMenu = new LMenu(cToolsMenuID);
return sMenu;
}
void CToolsAttachment::UpdateMenu()
{
if (!sInvalidMenu || !GetMenu() || !LMenuBar::GetCurrentMenuBar())
return;
int i;
// ¥ delete all the dynamically created menus
// ¥Êdelete all the hierarchical menus we have added from the menubar
for ( i = 1; i <= sMenusList.GetCount(); i++ )
{
LMenu* m;
sMenusList.FetchItemAt( i, &m );
if ( m )
LMenuBar::GetCurrentMenuBar()->RemoveMenu( m );
delete m;
}
// ¥ delete all the menu items after the line in Tools menu
MenuHandle menu = sMenu->GetMacMenuH();
if ( menu )
{
int howMany = ::CountMItems( menu );
for ( i = howMany - PERM_TOOLS_END_ITEMS; i > PERM_TOOLS_ITEMS; i-- )
sMenu->RemoveItem( i );
}
sMenusList.RemoveItemsAt( sMenusList.GetCount(), 1 );
int whichItem = PERM_TOOLS_ITEMS;
int commandNum = TOOLS_MENU_BASE;
int nextMenuID = cEditorPluginsFirstHierMenuID;
Try_
{
ThrowIfNil_( sMenu );
MenuHandle mHand = sMenu->GetMacMenuH();
ThrowIfNil_( mHand );
for (int32 CategoryIndex = 0; CategoryIndex < EDT_NumberOfPluginCategories(); CategoryIndex++) {
CStr255 headerName( EDT_GetPluginCategoryName( CategoryIndex ) );
CreateMenuString( headerName ); // make sure it isn't too long
whichItem = UMenuUtils::InsertMenuItem(mHand, headerName, whichItem); // returns actual insert loc
sMenu->SetCommand(whichItem, cmd_ToolsHierItem);
// ¥ Are there actually any menu items to put on this Hierarchical menu?
if (EDT_NumberOfPlugins(CategoryIndex)) {
// ¥ do we have any hierarchical menus left?
if (nextMenuID <= cEditorPluginsLastHierMenuID) {
LMenu* subMenu = (LMenuBar::GetCurrentMenuBar())->FetchMenu( nextMenuID );
if ( !subMenu )
{
StringHandle menuStringH = GetString( NEW_RESID );
Assert_(menuStringH);
if (menuStringH)
{
StHandleLocker locker((Handle)menuStringH);
subMenu = new LMenu( nextMenuID,
(unsigned char *)*menuStringH );
LMenuBar::GetCurrentMenuBar()->InstallMenu( subMenu, hierMenu );
}
}
else
SysBeep( 1 );
nextMenuID++;
if ( subMenu )
{
sMenusList.InsertItemsAt( 1, sMenusList.GetCount(), &subMenu );
// ¥Êmake item hierarchical
::SetItemCmd( mHand, whichItem, hMenuCmd );
::SetItemMark( mHand, whichItem, subMenu->GetMenuID() );
FillMenu(
CategoryIndex,
subMenu,
commandNum,
0 );
}
} else {
// ¥ There are no hierarchical menus left,
// so we will just add these onto the bottom of the main tools menu.
// We have already put the (disabled) category name in the main tools menu
FillMenu(
CategoryIndex,
sMenu,
commandNum,
whichItem );
whichItem += EDT_NumberOfPlugins(CategoryIndex);
}
}
}
// this is a hack. The menu item "Stop Active Plug-in" gets pushed around and loses its command. So, reset it.
sMenu->SetCommand(++whichItem, cmd_EditorPluginStop);
}
Catch_( inErr )
{
}
EndCatch_
sInvalidMenu = true;
}
void CToolsAttachment::FillMenu(
int32 CategoryIndex,
LMenu* newMenu,
int& commandNum, // next menu to create
int whichItem ) // id of the first item to insert
{
Try_
{
ThrowIfNil_( newMenu );
MenuHandle mHand = newMenu->GetMacMenuH();
ThrowIfNil_( mHand );
for (int32 PluginIndex = 0; PluginIndex < EDT_NumberOfPlugins(CategoryIndex); PluginIndex++) {
// ¥ should really convert this to sMenu chars
CStr255 pluginName( EDT_GetPluginName( CategoryIndex, PluginIndex) );
CreateMenuString( pluginName );
whichItem = UMenuUtils::InsertMenuItem(mHand, pluginName, whichItem); // returns actual insert loc
newMenu->SetCommand(whichItem, commandNum++);
}
}
Catch_( inErr )
{
}
EndCatch_
}
void CToolsAttachment::RemoveMenus()
{
if (sMenu)
{
LMenuBar *currentMenuBar = LMenuBar::GetCurrentMenuBar();
if (currentMenuBar)
{
currentMenuBar->RemoveMenu(sMenu);
for (ArrayIndexT index = 1; index <= sMenusList.GetCount(); ++index)
{
LMenu *menu;
sMenusList.FetchItemAt(index, &menu);
if (menu)
currentMenuBar->RemoveMenu(menu);
}
}
}
}
void CToolsAttachment::InstallMenus()
{
if (sMenu)
{
LMenuBar *currentMenuBar = LMenuBar::GetCurrentMenuBar();
if (currentMenuBar)
{
for (ArrayIndexT index = sMenusList.GetCount(); index > 0; --index)
{
LMenu *menu;
sMenusList.FetchItemAt(index, &menu);
if (menu)
{
StValueChanger<EDebugAction> okayToFail(gDebugThrow, debugAction_Nothing);
currentMenuBar->InstallMenu(menu, hierMenu);
}
}
StValueChanger<EDebugAction> okayToFail(gDebugThrow, debugAction_Nothing);
currentMenuBar->InstallMenu(sMenu, InstallMenu_AtEnd);
}
}
}

View File

@@ -0,0 +1,64 @@
/* -*- 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.
*/
#pragma once
#ifndef CTOOLSATTACHMENT_H_
#define CTOOLSATTACHMENT_H_
#include <LAttachment.h>
#include "ntypes.h"
class LMenu;
class LArray;
/***********************************************************************************
* CToolsAttachment
* Processes Tools menu commands -- should be attached to application
* Currently, this menu is only used in the Editor window
***********************************************************************************/
class CToolsAttachment: public LAttachment
{
public:
// ¥¥ constructors
CToolsAttachment();
// ¥¥Êevents
virtual void ExecuteSelf( MessageT inMessage, void* ioParam );
static LMenu* GetMenu();
static void InvalidateMenu() { sInvalidMenu = true; }
static void UpdateMenu();
static void RemoveMenus();
static void InstallMenus();
protected:
static void FillMenu(
int32 CategoryIndex,
LMenu* newMenu,
int& commandNum,
int whichItem );
static MWContext* GetTopWindowContext();
static LMenu* sMenu;
static Boolean sInvalidMenu;
static LArray sMenusList;
};
#endif

Binary file not shown.

View File

@@ -0,0 +1,49 @@
/* -*- 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.
*/
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// Composer_DebugPrefix.h
//
// NOTE:
// You typically won't need to change anything in this file.
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
#include "Moz_DebugConfig.h"
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥ When we split out the procompiled headers seperately, we will not
// be including them here. We will instead define things like
// PowerPlant_PCH and include them at the top of the applicable source
// modules
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
#ifdef __powerc
#ifdef __cplusplus
#include "Composer_HeadersPPC++"
#else
#include "Composer_HeadersPPC"
#endif
#else
#ifdef __cplusplus
#include "Composer_Headers68K++"
#else
#include "Composer_Headers68K"
#endif
#endif

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) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// Composer_Headers.pch
//
// NOTE:
//
// You will typically not need to edit this file. If you want to add
// a file to the C/C++ precompiled header, do it in Comm_Headers.c
// or Borwser_Headers.cp respectively.
//
// If you're doing a non-debug build, use the non-debug project which
// will has pch files that generate non-debug dumps.
//
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
#include "Moz_Config.h"
#ifdef powerc
#pragma precompile_target "Composer_HeadersPPC"
#else
#pragma precompile_target "Composer_Headers68K"
#endif
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥ Include the list of headers.
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
#include "Comm_Headers.c"

View File

@@ -0,0 +1,52 @@
/* -*- 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.
*/
//
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// Composer_Headers.pch++
//
// NOTE:
//
// You will typically not need to edit this file. If you want to add
// a file to the C/C++ precompiled header, do it in Comm_Headers.c
// or Borwser_Headers.cp respectively.
//
// If you're doing a non-debug build, use the non-debug project which
// will has pch files that generate non-debug dumps.
//
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
#include "Moz_Config.h"
#ifdef powerc
#pragma precompile_target "Composer_HeadersPPC++"
#else
#pragma precompile_target "Composer_Headers68K++"
#endif
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥ Include the headers.
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
extern "C" {
#include "Comm_Headers.c"
}
#include "Comm_Headers.cp"

View File

@@ -0,0 +1,49 @@
/* -*- 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.
*/
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// Composer_DebugPrefix.h
//
// NOTE:
// You typically won't need to change anything in this file.
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
#include "Moz_Config.h"
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥ When we split out the procompiled headers seperately, we will not
// be including them here. We will instead define things like
// PowerPlant_PCH and include them at the top of the applicable source
// modules
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
#ifdef __powerc
#ifdef __cplusplus
#include "Composer_HeadersPPC++"
#else
#include "Composer_HeadersPPC"
#endif
#else
#ifdef __cplusplus
#include "Composer_Headers68K++"
#else
#include "Composer_Headers68K"
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,839 @@
/* -*- 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.
*/
#pragma once
#include "CTabSwitcher.h"
#include "ntypes.h" // MWContext
#include "lo_ele.h" // LO_Color
#include "intl_csi.h" // INTL_GetCSIWinCSID
#ifdef COOL_IMAGE_RADIO_BUTTONS
# include "CBevelButton.h"
#endif
class OneRowLListBox;
class CColorButton;
class CTabControl;
class CLargeEditField;
class LGAEditField;
class LGAPopup;
class CChameleonView: public LView
{
public:
enum { class_ID = 'cviw' };
CChameleonView(LStream * inStream) : LView(inStream) {};
virtual void SetColor(RGBColor textColor);
virtual void DrawSelf();
protected:
RGBColor fTextColor;
};
class CChameleonCaption: public LCaption
{
public:
enum {class_ID = 'ccpt' };
CChameleonCaption(LStream * inStream) : LCaption(inStream) {};
virtual void SetColor(RGBColor textColor, RGBColor backColor);
protected:
RGBColor fTextColor;
RGBColor fBackColor;
virtual void DrawSelf();
};
// This class simply creates a dialog and extracts the context from the SuperCommand so
// that we can set the values of the controls in the dialog based on the context which created it.
class CEditDialog: public LDialogBox
{
public:
CEditDialog( LStream* inStream ): LDialogBox( inStream ), mUndoInited(false) { pExtra = NULL; }
~CEditDialog() { XP_FREEIF(pExtra); }
static Boolean Start(ResIDT inWindowID, MWContext * context = NULL, short initTabValue = 0, Boolean insert = FALSE);
Boolean AllowSubRemoval( LCommander *inSub );
void FindCommandStatus( CommandT inCommand, Boolean &outEnabled,
Boolean&, Char16&, Str255);
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual void InitializeDialogControls() = NULL;
void SetContext(MWContext* context) {fContext = context;}
MWContext* GetContext() { return fContext;}
void SetInitTabValue(short initValue) {fInitTabValue = initValue;}
short GetInitTabValue() { return fInitTabValue;}
void SetInWindowID(ResIDT inWindowID) {fInWindowID = inWindowID;}
ResIDT GetInWindowID() { return fInWindowID;}
void SetInsertFlag(Boolean insert) {fInsert = insert;}
Boolean GetInsertFlag() { return fInsert;}
int16 GetWinCSID() { return INTL_GetCSIWinCSID(LO_GetDocumentCharacterSetInfo(fContext)); }
static void ChooseImageFile(CLargeEditField* editField);
protected:
virtual Boolean CommitChanges(Boolean allPanes) = NULL;
virtual void Help() = NULL;
MWContext* fContext;
short fInitTabValue;
Boolean fInsert;
ResIDT fInWindowID;
char* pExtra;
Boolean mUndoInited;
};
class CEditTabSwitcher: public CTabSwitcher
{
public:
enum { class_ID = 'EtSw' };
CEditTabSwitcher(LStream* inStream);
virtual ~CEditTabSwitcher();
virtual void DoPostLoad(LView* inLoadedPage, Boolean inFromCache);
void SetData(MWContext* context, Boolean insert);
void Help();
protected:
MWContext* fContext;
Boolean fInsert;
char* fLinkName; // need to share between link and image pages
};
class CTableInsertDialog: public CEditDialog
{
public:
enum { class_ID = 'ETBT' };
CTableInsertDialog( LStream* inStream );
virtual ~CTableInsertDialog();
virtual Boolean CommitChanges(Boolean allPanes);
void AdjustEnable();
virtual void FinishCreateSelf();
virtual void InitializeDialogControls();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
protected:
virtual void Help();
LGAEditField* fNumRowsEditText;
LGAEditField* fNumColsEditText;
LControl* fBorderCheckBox;
LGAEditField* fBorderWidthEditText;
LGAEditField* fCellSpacingEditText;
LGAEditField* fCellPaddingEditText;
LControl* fCustomWidth;
LGAEditField* fWidthEditText;
LControl* fWidthPopup;
LControl* fCustomHeight;
LGAEditField* fHeightEditText;
LControl* fHeightPopup;
LControl* fCustomColor;
CColorButton* fColorCustomColor;
LControl* fIncludeCaption;
LControl* fCaptionAboveBelow;
LGAPopup* mTableAlignment;
LControl* mFastLayout;
LControl* mUseImage;
CLargeEditField* mImageFileName;
LControl* mLeaveImage;
};
class CFormatMsgColorAndImageDlog: public CEditDialog
{
public:
enum { class_ID = 'Ec+i' };
CFormatMsgColorAndImageDlog( LStream* inStream ) : CEditDialog( inStream ) {;}
virtual ~CFormatMsgColorAndImageDlog() {;}
virtual Boolean CommitChanges(Boolean allPanes);
virtual void InitializeDialogControls();
protected:
virtual void Help();
};
class CTarget: public CEditDialog
{
public:
enum { class_ID = 'ETRG' };
CTarget( LStream* inStream );
virtual ~CTarget();
void CleanUpTargetString(char *target);
Boolean AlreadyExistsInDocument(char *anchor);
virtual Boolean CommitChanges(Boolean allPanes);
virtual void InitializeDialogControls();
protected:
virtual void Help() {;} // Sorry, no help.
char* fOriginalTarget;
CLargeEditField* fTargetName;
};
class CLineProp: public CEditDialog
{
public:
enum { class_ID = 'EDL0' };
CLineProp( LStream* inStream );
virtual ~CLineProp( );
virtual Boolean CommitChanges(Boolean allPanes);
virtual void FinishCreateSelf();
virtual void InitializeDialogControls();
// virtual void ListenToMessage( MessageT inMessage, void* ioParam );
protected:
virtual void Help();
LControl* fLeftAlign;
LControl* fCenterAlign;
LControl* fRightAlign;
LGAEditField* fHeightEditText;
LGAEditField* fWidthEditText;
LControl* fPixelPercent;
LControl* fShading;
};
class CUnknownTag: public CEditDialog
{
public:
enum { class_ID = 'EDUT' };
CUnknownTag( LStream* inStream );
virtual ~CUnknownTag();
virtual Boolean CommitChanges(Boolean allPanes);
virtual void InitializeDialogControls();
virtual void FinishCreateSelf();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
protected:
virtual void Help();
CLargeEditField* fTargetName;
};
class MultipleSelectionSingleColumn: public LListBox
{
public:
enum { class_ID = 'MSSC' };
MultipleSelectionSingleColumn( LStream* inStream );
virtual int16 NumItems();
virtual void DeselectAll();
virtual void SelectAll();
virtual void AddItem( char* data, Boolean isSelected );
virtual StringPtr GetItem(Str255 outDescriptor, int32 rowNum) const; // rowNum is zero based
virtual void RemoveAllItems();
virtual Boolean IsSelected(int32 rowNum); // rowNum is zero based
};
class CPublishHistory
{
public:
// Do we have any history at all?
static Boolean IsTherePublishHistory();
// Get a particular entry
static char* GetPublishHistoryCharPtr(short whichone);
// Set a particular entry
static void SetPublishHistoryCharPtr(char* entry, short whichone);
// Put an entry at the top of the list (and remove any duplicate)
static void AddPublishHistoryEntry(char *entry);
};
class CPublish: public CEditDialog
{
public:
enum { class_ID = 'EPLS' };
CPublish( LStream* inStream );
virtual ~CPublish();
virtual Boolean CommitChanges(Boolean allPanes);
virtual void FinishCreateSelf();
virtual void InitializeDialogControls();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
protected:
virtual void Help();
char * DocName();
LCaption* fLocalLocation;
LControl* fImageFiles;
LControl* fFolderFiles;
LControl* fDefaultLocation;
MultipleSelectionSingleColumn* fFileList;
LGAEditField* fPublishLocation;
LGAEditField* fUserID;
LGAEditField* fPassword;
LControl* fSavePassword;
LGAPopup* mHistoryList;
};
// This is a dialog box which contains a Tab control.
// This code was written using Cmd-C & Cmd-V from the CPrefWindow class.
// We don't need everything in CPrefWindow though, and I'm too lazy to make
// a nice base class for both at the moment.
class CTabbedDialog : public CEditDialog
{
public:
enum {class_ID = 'EDTB'};
CTabbedDialog( LStream* inStream );
virtual ~CTabbedDialog();
static void RegisterViewTypes();
void FinishCreateSelf();
virtual void InitializeDialogControls();
virtual void SavePlace( LStream* ) { }
virtual void RestorePlace( LStream* ) { }
// virtual void ListenToMessage( MessageT inMessage, void* ioParam );
protected:
virtual void Help();
virtual Boolean CommitChanges(Boolean allPanes);
CTabControl* mTabControl;
CEditTabSwitcher* mTabSwitcher;
};
/*****************************************************************************
* class CEditorPrefContain. (used to be CPrefContain)
* Container for a related group of controls (1 pane of preference window)
* and know how to:
* - get proper variables from data, and assign the values to controls
* - get values from controls back into data.
*****************************************************************************/
class CEditorPrefContain : public LView, public LListener, public LTabGroup
{
public:
CEditorPrefContain( LStream* inStream ) : LView( inStream ) {};
virtual ~CEditorPrefContain() { };
// ¥ link to little controls, and reset their values
virtual void FinishCreateSelf() { LView::FinishCreateSelf(); UReanimator::LinkListenerToControls(this, this, GetPaneID()); ControlsFromPref();}
// ¥Êlistens to 'default' message
void ListenToMessage( MessageT, void* ) {};
// ¥ initialize from preferences
virtual void ControlsFromPref() = 0;
virtual void PrefsFromControls() = 0;
virtual void DrawSelf();
};
class CEditContain: public CEditorPrefContain, public LBroadcaster
{
public:
CEditContain(LStream* inStream): CEditorPrefContain( inStream ){ pExtra = NULL; }
~CEditContain(){ XP_FREEIF(pExtra); }
void SetContext(MWContext* context) {fContext = context;}
MWContext* GetContext() { return fContext;}
void SetInsertFlag(Boolean insert) {fInsert = insert;}
Boolean GetInsertFlag() { return fInsert;}
void SetLinkToLinkName(char** LinkNameLink) {fLinkName = LinkNameLink;}
void SetExtraHTMLString(char *s) { pExtra = s; };
virtual void Help() = NULL;
int16 GetWinCSID() { return INTL_GetCSIWinCSID(LO_GetDocumentCharacterSetInfo(fContext)); }
virtual Boolean AllFieldsOK() = NULL;
protected:
MWContext* fContext;
Boolean fInsert;
char** fLinkName;
char* pExtra;
};
class CEDCharacterContain: public CEditContain
{
public:
enum {class_ID = '1edl'};
CEDCharacterContain( LStream* inStream ) : CEditContain( inStream ){};
virtual void FinishCreateSelf();
virtual void PrefsFromControls();
virtual void ControlsFromPref();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual void Help();
virtual Boolean AllFieldsOK() { return TRUE;}
protected:
Boolean fColorChanged;
Boolean fSizeChanged;
LControl* fTextSizePopup;
LControl* mFontMenu;
Boolean mFontChanged;
LControl* fColorDefaultRadio;
LControl* fColorCustomRadio;
CColorButton* fColorCustomColor;
LControl* fTextBoldCheck;
LControl* fTextItalicCheck;
LControl* fTextSuperscriptCheck;
LControl* fTextSubscriptCheck;
LControl* fTextNoBreaksCheck;
LControl* fTextUnderlineCheck;
LControl* fTextStrikethroughCheck;
LControl* fTextBlinkingCheck;
LControl* fClearTextStylesButton;
LControl* fClearAllStylesButton;
};
class CEDParagraphContain: public CEditContain
{
public:
enum {class_ID = '2edl'};
CEDParagraphContain( LStream* inStream ) : CEditContain( inStream ){};
virtual void FinishCreateSelf();
virtual void PrefsFromControls();
virtual void ControlsFromPref();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual void Help();
virtual Boolean AllFieldsOK();
protected:
void AdjustPopupsVisibility();
LControl* fParagraphStylePopup;
LControl* fContainerStylePopup;
LControl* fListStylePopup;
LControl* fNumberPopup;
LControl* fBulletPopup;
LControl* fStartNumberCaption;
LGAEditField* fStartNumberEditText;
LControl* fLeftAlignRadio;
LControl* fCenterAlignRadio;
LControl* fRightAlignRadio;
};
#ifdef COOL_IMAGE_RADIO_BUTTONS
class CImageAlignButton: public CBevelButton
{
public:
enum { class_ID = 'BvRB' };
CImageAlignButton( LStream* inStream ) : CBevelButton( inStream ){};
virtual void SetValue(
Int32 inValue);
private:
virtual void HotSpotAction(
Int16 inHotSpot,
Boolean inCurrInside,
Boolean inPrevInside);
virtual void HotSpotResult(Int16 inHotSpot);
};
#endif
class CEDLinkContain: public CEditContain
{
public:
enum {class_ID = '3edl'};
CEDLinkContain( LStream* inStream ) : CEditContain( inStream ){};
virtual ~CEDLinkContain();
virtual void FinishCreateSelf();
virtual void PrefsFromControls();
virtual void ControlsFromPref();
virtual void Show();
virtual void Hide();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual void Help();
virtual Boolean AllFieldsOK() { return TRUE;}
protected:
void SelectedFileUpdate();
void CurrentFileTargs();
CLargeEditField* fLinkedTextEdit;
LControl* fChooseFileLinkButton;
LControl* fRemoveLinkButton;
CLargeEditField* fLinkPageTextEdit;
LControl* fCurrentDocumentRadio;
LControl* fSelectedFileRadio;
OneRowLListBox* fTargetList;
char* fTargs;
};
class CEDImageContain: public CEditContain
{
public:
enum {class_ID = '4edl'};
CEDImageContain( LStream* inStream );
virtual ~CEDImageContain();
virtual void FinishCreateSelf();
virtual void PrefsFromControls();
virtual void ControlsFromPref();
EDT_ImageData * ImageDataFromControls();
virtual void Show();
virtual void Hide();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual void Help();
virtual Boolean AllFieldsOK();
protected:
void AdjustEnable();
char * fSrcStr;
char * fLowSrcStr;
CLargeEditField* fImageFileName; // was CEditBroadcaster
CLargeEditField* fImageAltFileName;
CLargeEditField* fImageAltTextEdit;
LGAEditField* fHeightTextEdit;
LGAEditField* fWidthTextEdit;
LControl* fImageLockedCheckBox;
int32 fOriginalWidth; /* Width and Height we got on initial loading */
int32 fOriginalHeight;
LGAEditField* fLeftRightBorderTextEdit;
LGAEditField* fTopBottomBorderTextEdit;
LGAEditField* fSolidBorderTextEdit;
LControl* fCopyImageCheck;
LControl* fBackgroundImageCheck;
LControl* fRemoveImageMapButton;
LControl* fEditImageButton;
Boolean fLooseImageMap;
Boolean mBorderUnspecified;
LControl* mImageAlignmentPopup;
};
class CEDDocPropGeneralContain: public CEditContain
{
public:
enum {class_ID = '5edl'};
CEDDocPropGeneralContain( LStream* inStream ) : CEditContain( inStream ){};
virtual void FinishCreateSelf();
virtual void PrefsFromControls();
virtual void ControlsFromPref();
void AddMeta(char *Name, CLargeEditField* value);
// virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual void Help();
virtual Boolean AllFieldsOK() { return TRUE;}
protected:
CLargeEditField* fLocation;
CLargeEditField* fTitle;
CLargeEditField* fAuthor;
CLargeEditField* fDescription;
CLargeEditField* fKeywords;
CLargeEditField* fClassification;
};
// This should be moved to XP code in the future
typedef struct _EDT_ColorSchemeData {
char * pSchemeName;
LO_Color ColorText;
LO_Color ColorLink;
LO_Color ColorActiveLink;
LO_Color ColorFollowedLink;
LO_Color ColorBackground;
char * pBackgroundImage;
} EDT_ColorSchemeData;
class AppearanceContain: public CEditContain
{
AppearanceContain( LStream* inStream ) : CEditContain( inStream ){};
virtual void FinishCreateSelf();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
void ChooseImageFile();
protected:
void UpdateTheWholeDamnDialogBox();
LControl* fCustomColor;
LControl* fBrowserColor;
LControl* fColorScheme;
CChameleonView* fExampleView;
CColorButton* fNormalText;
CColorButton* fLinkedText;
CColorButton* fActiveLinkedText;
CColorButton* fFollowedLinkedText;
CChameleonCaption* fExampleNormalText;
CChameleonCaption* fExampleLinkedTex;
CChameleonCaption* fExampleActiveLinkedText;
CChameleonCaption* fExampleFollowedLinkedText;
CColorButton* fSolidColor;
LControl* fImageFile;
CLargeEditField* fImageFileName;
XP_List* fSchemeData;
};
class CEDDocPropAppearanceContain: public AppearanceContain
{
public:
enum {class_ID = '6edl'};
CEDDocPropAppearanceContain( LStream* inStream ) : AppearanceContain( inStream ){};
virtual ~CEDDocPropAppearanceContain();
virtual void PrefsFromControls();
virtual void ControlsFromPref();
virtual Boolean AllFieldsOK() { return TRUE;}
virtual void Help();
};
class CEDDocAppearanceNoTab: public CEDDocPropAppearanceContain
{
public:
enum {class_ID = '6edL'};
CEDDocAppearanceNoTab( LStream* inStream ) : CEDDocPropAppearanceContain( inStream ){};
virtual ~CEDDocAppearanceNoTab() {;}
virtual void DrawSelf();
};
class CEDDocPropAdvancedContain: public CEditContain
{
public:
enum {class_ID = '7edl'};
CEDDocPropAdvancedContain( LStream* inStream ) : CEditContain( inStream ){};
virtual ~CEDDocPropAdvancedContain();
virtual void FinishCreateSelf();
void PutStringsInBuffer();
Boolean BufferUnique();
virtual void PrefsFromControls();
virtual void ControlsFromPref();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual void Help();
virtual Boolean AllFieldsOK() { return TRUE;}
protected:
int16 fbufferlen;
char* fbuffer;
OneRowLListBox* fSystemVariables;
OneRowLListBox* fUserVariables;
CLargeEditField* fName;
CLargeEditField* fValue;
};
class CEDTableContain: public CEditContain
{
public:
enum {class_ID = '8edl'};
CEDTableContain( LStream* inStream ) : CEditContain( inStream ) { pExtra = NULL; }
~CEDTableContain() { XP_FREEIF(pExtra); }
virtual void FinishCreateSelf();
virtual void Help();
void AdjustEnable();
virtual void PrefsFromControls();
virtual void ControlsFromPref();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual Boolean AllFieldsOK();
protected:
LControl* fBorderCheckBox;
LGAEditField* fBorderWidthEditText;
LGAEditField* fCellSpacingEditText;
LGAEditField* fCellPaddingEditText;
LControl* fCustomWidth;
LGAEditField* fWidthEditText;
LControl* fWidthPopup;
LControl* fCustomHeight;
LGAEditField* fHeightEditText;
LControl* fHeightPopup;
LControl* fCustomColor;
CColorButton* fColorCustomColor;
LControl* fIncludeCaption;
LControl* fCaptionAboveBelow;
LGAPopup* mTableAlignment;
LControl* mFastLayout;
LControl* mUseImage;
CLargeEditField* mImageFileName;
LControl* mLeaveImage;
char* pExtra;
};
class CEDTableCellContain: public CEditContain
{
public:
enum {class_ID = 'aedl'};
CEDTableCellContain( LStream* inStream ) : CEditContain( inStream ) { pExtra = NULL; }
~CEDTableCellContain() { XP_FREEIF(pExtra); }
virtual void FinishCreateSelf();
virtual void Help();
void AdjustEnable();
virtual void PrefsFromControls();
virtual void ControlsFromPref();
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
virtual Boolean AllFieldsOK();
protected:
LGAEditField* fRowSpanEditText;
LGAEditField* fColSpanEditText;
LGAPopup* fHorizontalAlignment;
LGAPopup* fVerticalAlignment;
LControl* fHeaderStyle;
LControl* fWrapText;
LControl* fCustomWidth;
LGAEditField* fWidthEditText;
LControl* fWidthPopup;
LControl* fCustomHeight;
LGAEditField* fHeightEditText;
LControl* fHeightPopup;
LControl* fCustomColor;
CColorButton* fColorCustomColor;
LControl* mUseImage;
CLargeEditField* mImageFileName;
LControl* mLeaveImage;
char* pExtra;
};

View File

@@ -0,0 +1,342 @@
/* -*- 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 "meditor.h" // HandleModalDialog
#include "StBlockingDialogHandler.h"
#include "CEditView.h"
#include "macgui.h" // UGraphics::MakeLOColor
#include "CPaneEnabler.h"
#include "resgui.h" // EDITDLG_AUTOSAVE
#include "edt.h"
#include "fe_proto.h"
#include "prefapi.h" // PREF_GetBoolPref, PREF_GetIntPref
#include "shist.h" // SHIST_GetCurrent
#include "uapp.h" // CFrontApp
#include "CColorPopup.h"
extern "C" {
#include "xpgetstr.h"
#define WANT_ENUM_STRING_IDS
#include "allxpstr.h"
#undef WANT_ENUM_STRING_IDS
}
#include "CNSContext.h" // ExtractHyperView
// takes pascal-strings
MessageT HandleModalDialog( int id, const unsigned char *prompt1, const unsigned char* prompt2)
{
StPrepareForDialog prepare;
StBlockingDialogHandler handler( id, NULL );
LDialogBox* dialog = (LDialogBox *)handler.GetDialog();
if ( prompt1 )
{
LCaption *caption = (LCaption *)dialog->FindPaneByID( '^1 ' );
if ( caption )
caption->SetDescriptor( prompt1 );
}
if ( prompt2 )
{
LCaption *caption = (LCaption *)dialog->FindPaneByID( '^2 ' );
if ( caption )
caption->SetDescriptor( prompt2 );
}
MessageT message;
do {
message = handler.DoDialog();
}
while ( message == 0 );
return message;
}
/* Set default colors, background from user Preferences via the Page Data structure
*/
void FE_SetNewDocumentProperties(MWContext * pContext)
{
if ( pContext && pContext->is_editor && pContext->bIsComposeWindow )
return;
EDT_PageData *pageData = EDT_NewPageData();
if (pageData == NULL) return;
if (CPrefs::GetBoolean(CPrefs::EditorUseCustomColors )) {
LO_Color EditorText = UGraphics::MakeLOColor(CPrefs::GetColor(CPrefs::EditorText));
LO_Color EditorLink = UGraphics::MakeLOColor(CPrefs::GetColor(CPrefs::EditorLink));
LO_Color EditorActiveLink = UGraphics::MakeLOColor(CPrefs::GetColor(CPrefs::EditorActiveLink));
LO_Color EditorFollowedLink = UGraphics::MakeLOColor(CPrefs::GetColor(CPrefs::EditorFollowedLink));
LO_Color EditorBackground = UGraphics::MakeLOColor(CPrefs::GetColor(CPrefs::EditorBackground));
pageData->pColorText = &EditorText;
pageData->pColorLink= &EditorLink;
pageData->pColorActiveLink = &EditorActiveLink;
pageData->pColorFollowedLink = &EditorFollowedLink;
pageData->pColorBackground = &EditorBackground;
} else {
pageData->pColorText = NULL; // I assume this is how we get the browser defaults...
pageData->pColorLink= NULL;
pageData->pColorActiveLink = NULL;
pageData->pColorFollowedLink = NULL;
pageData->pColorBackground = NULL;
}
Bool hasBackgroundImage;
if ( ( PREF_GetBoolPref( "editor.use_background_image", &hasBackgroundImage ) == PREF_NOERROR )
&& hasBackgroundImage )
{
pageData->pBackgroundImage = CPrefs::GetCharPtr(CPrefs::EditorBackgroundImage);
if (pageData->pBackgroundImage && XP_STRLEN(pageData->pBackgroundImage) == 0) // if there is really nothing there, skip it.
pageData->pBackgroundImage = NULL;
}
else
pageData->pBackgroundImage = NULL;
if ( pContext && pContext->title )
pageData->pTitle = XP_STRDUP(pContext->title);
EDT_SetPageData(pContext, pageData);
pageData->pColorText = NULL; // don't free out lacal data!!!
pageData->pColorLink= NULL;
pageData->pColorActiveLink = NULL;
pageData->pColorFollowedLink = NULL;
pageData->pColorBackground = NULL;
pageData->pBackgroundImage = NULL;
EDT_FreePageData(pageData);
// Set Author name:
// CStr255 EditorAuthor(CPrefs::GetString(CPrefs::EditorAuthor));
// FE_UsersFullName();
EDT_MetaData *metaData = EDT_NewMetaData();
if (metaData == NULL) return;
metaData->bHttpEquiv = FALSE;
metaData->pName = XP_STRDUP("Author");
metaData->pContent = XP_STRDUP(CPrefs::GetString(CPrefs::EditorAuthor));
EDT_SetMetaData(pContext, metaData);
EDT_FreeMetaData(metaData);
}
/*
* Brings up a modal image load dialog and returns. Calls
* EDT_ImageLoadCancel() if the cancel button is pressed
*/
void FE_ImageLoadDialog( MWContext * /* pContext */ )
{
}
/*
* called by the editor engine after the image has been loaded
*/
void FE_ImageLoadDialogDestroy( MWContext * /* pContext */ )
{
}
void FE_EditorDocumentLoaded( MWContext *pContext )
{
if (pContext == NULL || !EDT_IS_EDITOR(pContext))
return;
CEditView *editView = (CEditView *)ExtractHyperView(pContext);
int32 iSave;
if ( pContext->bIsComposeWindow )
{
iSave = 0; // auto-save
CMailEditView *mailEditView = dynamic_cast<CMailEditView *>(editView);
if ( mailEditView )
mailEditView->InitMailCompose();
}
else
{
XP_Bool doAutoSave;
PREF_GetBoolPref( "editor.auto_save", &doAutoSave );
if ( doAutoSave )
PREF_GetIntPref( "editor.auto_save_delay", &iSave );
else
iSave = 0;
}
EDT_SetAutoSavePeriod(pContext, iSave );
// remember when the file was (last) modified
// initializes date/time stamp for external editor warning
EDT_IsFileModified(pContext);
// We had disabled everything, now we have to enable it again. This happens automatically on activate, but we might not get an activate
// if we don't have a dialog poping up (like if the user just creates a new document, there is no dialog...)
// set this after calling InitMailCompose
if ( editView )
{
editView->mEditorDoneLoading = true;
// set color popup control to show correct default color (now that we have an mwcontext)
editView->mColorPopup->InitializeCurrentColor();
}
InitCursor();
(CFrontApp::GetApplication())->UpdateMenus();
}
Bool FE_CheckAndAutoSaveDocument(MWContext *pContext)
{
if (pContext == NULL || !EDT_IS_EDITOR(pContext) || ExtractHyperView(pContext) == NULL )
return FALSE;
if ( pContext->bIsComposeWindow )
return FALSE;
CEditView *editView = (CEditView *)ExtractHyperView(pContext);
if ( FrontWindow() != editView->GetMacPort() )
return true;
if (!EDT_DirtyFlag(pContext) && !EDT_IS_NEW_DOCUMENT(pContext))
return TRUE;
History_entry* newEntry = SHIST_GetCurrent(&pContext->hist);
CStr255 fileName;
if ( newEntry && newEntry->address )
fileName = newEntry->address;
MessageT itemHit = HandleModalDialog(EDITDLG_AUTOSAVE, fileName, NULL );
if (itemHit != ok)
return FALSE;
return ((CEditView *)ExtractHyperView(pContext))->SaveDocument();
}
void FE_FinishedSave( MWContext * /* pMWContext */, int /* status */, char * /* pDestURL */, int /* iFileNumber */ )
{
}
// in xp_file.h
// Create a backup filename for renaming current file before saving data
// Input should be be URL file type "file:///..."
// Caller must free the string with XP_FREE
/*
* I don't know what the logic here should be, so I mostly copied this from the Windows code in:
* src/ns/cmd/winfe/fegui.cpp#XP_BackupFileName()
* (I didn't copy all the Windows code which deals with 8.3 filenames.)
*/
char * XP_BackupFileName( const char * szURL )
{
// Must have "file:" URL type and at least 1 character after "///"
if ( szURL == NULL || !NET_IsLocalFileURL((char*)szURL) || XP_STRLEN(szURL) <= 8 )
return NULL;
// Add extra space for '\0' and '.BAK', but subtract space for "file:///"
char *szFileName = (char *)XP_ALLOC((XP_STRLEN(szURL)+1+4-7)*sizeof(char));
if ( szFileName == NULL )
return NULL;
// Get filename but ignore "file:///"
// {
// char* filename = WH_FileName(szURL+7, xpURL);
// if (!filename) return NULL;
// XP_STRCPY(szFileName,filename);
// XP_FREE(filename);
// }
XP_STRCPY(szFileName, szURL+7);
// Add extension to the filename
XP_STRCAT( szFileName, ".BAK" );
return szFileName;
}
// If pszLocalName is not NULL, we return the full pathname
// in local platform syntax, even if file is not found.
// Caller must free this string.
// Returns TRUE if file already exists
//
/*
* I don't know what the logic here should be, so I mostly copied this from the Windows code in:
* src/ns/cmd/winfe/fegui.cpp#XP_ConvertUrlToLocalFile()
* (I didn't copy all the Windows code which deals with 8.3 filenames.)
*/
// The results of this call are passed directly to functions like XP_Stat and XP_FileOpen.
// brade--use xpURL format
Bool XP_ConvertUrlToLocalFile(const char * szURL, char **pszLocalName) // return TRUE if the file exists!! or return FALSE;
{
// Default assumes no file found - no local filename
Boolean bFileFound = FALSE;
if ( pszLocalName )
*pszLocalName = NULL;
// if "file:///Untitled" fail to convert
if ( szURL && XP_STRCMP( szURL, XP_GetString(XP_EDIT_NEW_DOC_NAME) ) == 0 )
return bFileFound;
// Must have "file:" URL type and at least 1 character after "///"
if ( szURL == NULL || !NET_IsLocalFileURL((char*)szURL) || XP_STRLEN(szURL) <= 8 )
return FALSE;
// Extract file path from URL: e.g. "/c|/foo/file.html"
char *szFileName = NET_ParseURL( szURL, GET_PATH_PART);
if (szFileName == NULL)
return FALSE;
// NET_UnEscape(szFileName); This will be done in WH_FileName, so don't unescape twice.
// Test if file exists
XP_StatStruct statinfo;
if ( -1 != XP_Stat(szFileName, &statinfo, xpURL) // if the file exists
&& statinfo.st_mode & S_IFREG ) // and its a normal file
bFileFound = TRUE; // We found it!
if ( pszLocalName )
{
// Pass string to caller
*pszLocalName = WH_FileName(szFileName, xpURL);
if (szFileName)
XP_FREE( szFileName );
}
else
XP_FREE(szFileName);
return bFileFound;
}

View File

@@ -0,0 +1,19 @@
/* -*- 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.
*/
MessageT HandleModalDialog( int id , const unsigned char *prompt0, const unsigned char* prompt1);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,133 @@
/* -*- 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.
*/
#pragma once
#include "np.h"
#include "npapi.h"
#include <Printing.h>
#include <Icons.h>
#include <LView.h>
#include <LPeriodical.h>
#include <LCommander.h>
#include <LDragAndDrop.h>
class StPluginFocus;
//
// Return the "plug-in descriptor" that we pass to XP code
// (this is really just a pointer to a CPluginHandler).
//
class CStr255;
extern void* GetPluginDesc(const CStr255& pluginName);
/*********************************************************************************
* CPluginView
* Embeds the plugin, and passes on the events to it
*********************************************************************************/
class CPluginView : public LView, // Drawing, etc
public LPeriodical, // Idling
public LCommander, // Key events
public LDragAndDrop // Dragging
{
public:
friend class StPluginFocus;
enum { class_ID = 'plug' };
// ¥¥ constructors
CPluginView(LStream *inStream);
virtual ~CPluginView();
void EmbedCreate(MWContext* context, LO_EmbedStruct* embed_struct);
void EmbedFree(MWContext* context, LO_EmbedStruct* embed_struct);
void EmbedSize(LO_EmbedStruct* embed_struct, SDimension16 hyperSize);
void EmbedDisplay(LO_EmbedStruct* embed_struct, Boolean isPrinting);
// ¥¥ access
NPWindow* GetNPWindow() { return &fNPWindow; }
NPEmbeddedApp* GetNPEmbeddedApp() { return fApp; }
// ¥¥ event processing
static CPluginView* sPluginTarget;
static void BroadcastPluginEvent(const EventRecord& event);
static Boolean PluginWindowEvent(const EventRecord& event);
virtual void ClickSelf(const SMouseDownEvent& inMouseDown);
virtual void EventMouseUp(const EventRecord &inMacEvent);
virtual Boolean HandleKeyPress(const EventRecord& inKeyEvent);
virtual void DrawSelf();
virtual void SpendTime(const EventRecord& inMacEvent);
virtual void ActivateSelf();
virtual void DeactivateSelf();
virtual void BeTarget();
virtual void DontBeTarget();
virtual void AdjustCursorSelf(Point inPortPt, const EventRecord& inMacEvent);
Boolean PassEvent(EventRecord& inEvent);
virtual Boolean HandleEmbedEvent(CL_Event *event);
// ¥¥ positioning
virtual void AdaptToNewSurroundings();
virtual void AdaptToSuperFrameSize(Int32 inSurrWidthDelta, Int32 inSurrHeightDelta, Boolean inRefresh);
virtual void MoveBy(Int32 inHorizDelta, Int32 inVertDelta, Boolean inRefresh);
Boolean IsPositioned() const { return fPositioned; }
// ¥¥Êdragging
virtual Boolean DragIsAcceptable(DragReference inDragRef);
virtual void HiliteDropArea(DragReference inDragRef);
virtual void UnhiliteDropArea(DragReference inDragRef);
// ¥¥ printing
Boolean PrintFullScreen(Boolean printOne, THPrint printRecHandle);
void PrintEmbedded();
// ¥¥ broken plugin
void SetBrokenPlugin();
void DrawBroken(Boolean hilite);
void SetPositioned() { fPositioned = true; }
// ¥¥ window control
void RegisterWindow(void* window);
void UnregisterWindow(void* window);
Boolean PassWindowEvent(EventRecord& inEvent, WindowPtr window);
private:
void ResetDrawRect();
NPEmbeddedApp* fApp;
NPWindow fNPWindow;
NP_Port fNPPort;
CPluginView* fOriginalView;
CIconHandle fBrokenIcon;
short fHorizontalOffset;
short fVerticalOffset;
Boolean fBrokenPlugin;
Boolean fPositioned;
Boolean fHidden;
Boolean fWindowed;
LO_EmbedStruct* fEmbedStruct;
Boolean fIsPrinting;
LArray* fWindowList;
static LArray* sPluginList;
};

View File

@@ -0,0 +1,539 @@
/* -*- 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.
*/
// mregistr.cp
// Registry for AppleEvent notifiers
// Pretty clumsy right now, but separating this functionality out of uapp seems
// to be the right thing.
// It is just a collection of routines
// MacNetscape
#include "mregistr.h"
#include "macutil.h"
#include "CAppleEventHandler.h"
#include "resae.h"
#include "resgui.h"
#include "ufilemgr.h"
#include "uprefd.h"
#include "CNSContext.h"
#ifndef MOZ_MAIL_NEWS
#include "InternetConfig.h"
#endif
// xp
#include "client.h"
static LArray sURLEchoHandlers(sizeof(ProcessSerialNumber));
static LArray sProtocolHandlers;
/************************************************************************************
* class CProtocolHelper
* Holds the information about protocol helpers, and knows how to launch them
************************************************************************************/
class CProtocolHelper {
public:
char * fProtocolInfo; // String that specifies the protocol
OSType fApplSig; // Application to launch. Do not use these unless in saving/restoring
// ¥¥ constructors
CProtocolHelper(char * protocolInfo, OSType applSig);
virtual ~CProtocolHelper();
// ¥¥ access
Boolean AttemptLaunch(URL_Struct *url, MWContext *context);
Boolean EqualTo(char * protocolInfo, OSType applSig);
Boolean operator==(CProtocolHelper * p);
static void AddNewHelper(CProtocolHelper * helper);
};
CProtocolHelper::CProtocolHelper(char * protocolInfo, OSType applSig)
{
fProtocolInfo = protocolInfo;
fApplSig = applSig;
}
CProtocolHelper::~CProtocolHelper()
{
if (fProtocolInfo)
XP_FREE(fProtocolInfo);
}
Boolean CProtocolHelper::operator==(CProtocolHelper * p)
{
if (fProtocolInfo && p->fProtocolInfo)
return (strcmp(fProtocolInfo, p->fProtocolInfo) == 0);
return false;
}
// This is used for the helper removal
// It returns true if we do not have the protocol info
Boolean CProtocolHelper::EqualTo(char * protocolInfo, OSType applSig)
{
if (applSig != fApplSig)
return false;
if (protocolInfo && fProtocolInfo)
if (strcmp(protocolInfo, fProtocolInfo) == 0)
return true;
else
return false;
else
return true;
return false;
}
// Finds the running helper application
// Tries to send a OpenURL event to the registered protocol handler
// If this does not work, sends the standard GetURL event
Boolean CProtocolHelper::AttemptLaunch(URL_Struct *url, MWContext */*context*/)
{
if (!url->address)
return false;
if (strncasecomp(url->address, fProtocolInfo, strlen(fProtocolInfo)) != 0)
return false;
ProcessSerialNumber psn;
FSSpec dummy;
OSErr err = FindProcessBySignature(fApplSig,'APPL',psn,&dummy);
if (err != noErr)
{
FSSpec appSpec;
err = CFileMgr::FindApplication(fApplSig, appSpec);
if (err != noErr)
return false;
LaunchParamBlockRec launchParams;
launchParams.launchBlockID = extendedBlock;
launchParams.launchEPBLength = extendedBlockLen;
launchParams.launchFileFlags = 0;
launchParams.launchControlFlags = launchContinue + launchNoFileFlags;
launchParams.launchAppSpec = &appSpec;
launchParams.launchAppParameters = NULL;
err = LaunchApplication(&launchParams);
if (err != noErr)
return false;
err = FindProcessBySignature(fApplSig,'APPL',psn,&dummy);
if (err != noErr)
return false;
}
Try_ // Try the old Spyglass AE suite way first
{
AppleEvent event;
err = AEUtilities::CreateAppleEvent(AE_spy_send_suite, AE_spy_openURL, event, psn);
ThrowIfOSErr_(err);
// put in the URL
StAEDescriptor urlDesc(typeChar, url->address, url->address ? strlen(url->address) : 0);
err = ::AEPutParamDesc(&event,keyDirectObject,&urlDesc.mDesc);
ThrowIfOSErr_(err);
// Send it
AppleEvent reply;
Try_
{
err = ::AESend(&event, &reply, kAEWaitReply,kAENormalPriority,60,nil, nil);
AEDisposeDesc(&event);
err = AEUtilities::EventHasErrorReply(reply);
ThrowIfOSErr_(err);
AEDisposeDesc(&reply);
}
Catch_(inErr)
{
AEDisposeDesc(&reply);
// Bug #86055
// A -1 means the handler didn't want the event, not that it didn't handle it.
// In this case we should just return that the helper can't handle the protocol
// and Communicator/Navigator should handle it rather than also sending a GURL
// event to the helper app. This works around a problem under MacOS 8 where
// sending a GURL event to an app that didn't handle it could result in an infinite
// loop when the OS decided to re-direct the GURL back to us and we promptly sent
// it back to the handler that didn't handle it.
if (err == -1)
return false;
else
Throw_(inErr);
}
EndCatch_
}
Catch_(inErr) // old Spyglass AE suite way failed, try the standard event
{
AppleEvent reply;
Try_
{
AppleEvent event;
err = AEUtilities::CreateAppleEvent(AE_url_suite, AE_url_getURL, event, psn);
// put in the URL
StAEDescriptor urlDesc(typeChar, url->address, url->address ? strlen(url->address) : 0);
err = ::AEPutParamDesc(&event,keyDirectObject,&urlDesc.mDesc);
ThrowIfOSErr_(err);
err = ::AESend(&event, &reply, kAEWaitReply,kAENormalPriority,60,nil, nil);
AEDisposeDesc(&event);
ThrowIfOSErr_(AEUtilities::EventHasErrorReply(reply));
AEDisposeDesc(&reply);
}
Catch_(inErr)
{
AEDisposeDesc(&reply);
return false;
}
EndCatch_
}
EndCatch_
return true;
}
void CProtocolHelper::AddNewHelper(CProtocolHelper* helper)
{
if (helper == NULL)
return;
LArrayIterator iter(sProtocolHandlers);
CProtocolHelper * otherHelper;
while (iter.Next(&otherHelper)) // Delete duplicate registration for this protocol
if (*helper == otherHelper)
{
delete otherHelper;
sProtocolHandlers.Remove(&otherHelper);
}
sProtocolHandlers.InsertItemsAt(1,1, &helper);
NET_AddExternalURLType(helper->fProtocolInfo);
CPrefs::SetModified();
}
// Called from preferences, saves all the protocol handlers
void CNotifierRegistry::ReadProtocolHandlers()
{
// Add the bolo handler
CProtocolHelper *helper = new CProtocolHelper(strdup("bolo"), 'BOLO');
CProtocolHelper::AddNewHelper(helper);
CPrefs::UsePreferencesResFile();
Handle stringListHandle = ::Get1Resource('STR#', PROT_HANDLER_PREFS_RESID);
if (stringListHandle && *stringListHandle)
{
if (::GetHandleSize(stringListHandle) < sizeof(short))
{
::RemoveResource(stringListHandle);
::DisposeHandle(stringListHandle);
return;
}
}
CStringListRsrc stringRsrc(PROT_HANDLER_PREFS_RESID);
Int16 howMany = stringRsrc.CountStrings();
if (howMany == 0)
return;
// Each protocol handler is represented by 2 strings
// 1 - the application sig
// 2 - the protocol string
for (int i=1; i < howMany; i=i+2) // Increment by 2.
{
CStr255 applSigStr, protocol;
stringRsrc.GetString(i, applSigStr);
if (ResError()) return;
stringRsrc.GetString(i+1, protocol);
if (ResError()) return;
OSType appSig;
LString::PStrToFourCharCode(applSigStr, appSig);
CProtocolHelper * newHelper = new CProtocolHelper(XP_STRDUP((char*)protocol), appSig);
CProtocolHelper::AddNewHelper(newHelper);
}
}
// Called from preferences, writes all the protocol handlers
void CNotifierRegistry::WriteProtocolHandlers()
{
Int32 howMany = sProtocolHandlers.GetCount();
if (howMany <= 1)
return;
Handle stringListHandle = ::Get1Resource('STR#', PROT_HANDLER_PREFS_RESID);
if (!stringListHandle) {
stringListHandle = ::NewHandle(0);
::AddResource(stringListHandle, 'STR#',
PROT_HANDLER_PREFS_RESID, CStr255::sEmptyString);
}
if (stringListHandle && *stringListHandle)
{
SInt8 flags = ::HGetState(stringListHandle);
::HNoPurge(stringListHandle);
CStringListRsrc stringRsrc(PROT_HANDLER_PREFS_RESID);
stringRsrc.ClearAll();
for (int i=1; i<=howMany - 1; i++)
{
CProtocolHelper * helper = NULL;
if (sProtocolHandlers.FetchItemAt(i, &helper))
{
CStr255 protocol(helper->fProtocolInfo);
Str255 sig;
LString::FourCharCodeToPStr(helper->fApplSig, sig);
stringRsrc.AppendString(sig);
stringRsrc.AppendString(protocol);
}
}
::WriteResource(stringListHandle);
::HSetState(stringListHandle, flags);
}
}
void CNotifierRegistry::HandleAppleEvent(const AppleEvent &inAppleEvent, AppleEvent &outAEReply,
AEDesc &outResult, long inAENumber)
{
switch(inAENumber) {
case AE_RegisterURLEcho:
HandleRegisterURLEcho(inAppleEvent, outAEReply, outResult, inAENumber);
break;
case AE_UnregisterURLEcho:
HandleUnregisterURLEcho(inAppleEvent, outAEReply, outResult, inAENumber);
break;
case AE_RegisterProtocol:
HandleRegisterProtocol(inAppleEvent, outAEReply, outResult, inAENumber);
break;
case AE_UnregisterProtocol:
HandleUnregisterProtocol(inAppleEvent, outAEReply, outResult, inAENumber);
break;
default:
ThrowOSErr_(errAEEventNotHandled);
}
}
// Always save the PSN
void CNotifierRegistry::HandleRegisterURLEcho(const AppleEvent &inAppleEvent, AppleEvent &outAEReply,
AEDesc &/*outResult*/, long /*inAENumber*/)
{
OSType appSignature;
ProcessSerialNumber psn;
Size realSize;
OSType realType;
OSErr err = ::AEGetParamPtr(&inAppleEvent, keyDirectObject, typeApplSignature, &realType,
&appSignature, sizeof(appSignature), &realSize);
if (err == noErr) // No parameters, extract the signature from the Apple Event
psn = GetPSNBySig(appSignature);
else
psn = MoreExtractFromAEDesc::ExtractAESender(inAppleEvent);
// Each application can register only once
LArrayIterator iter(sURLEchoHandlers);
ProcessSerialNumber newPSN;
while (iter.Next(&newPSN)) // If we are already registered, returns
if ((newPSN.highLongOfPSN == psn.highLongOfPSN) && (newPSN.lowLongOfPSN == psn.lowLongOfPSN))
ThrowOSErr_(errAECoercionFail);
sURLEchoHandlers.InsertItemsAt(1,1, &psn);
{
Boolean success = true;
StAEDescriptor replyDesc(success);
err = ::AEPutParamDesc(&outAEReply, keyAEResult, &replyDesc.mDesc);
}
}
void CNotifierRegistry::HandleUnregisterURLEcho(const AppleEvent &inAppleEvent,
AppleEvent &/*outAEReply*/, AEDesc &/*outResult*/, long /*inAENumber*/)
{
OSType appSignature;
ProcessSerialNumber psn;
Size realSize;
OSType realType;
OSErr err = ::AEGetParamPtr(&inAppleEvent, keyDirectObject, typeApplSignature, &realType,
&appSignature, sizeof(appSignature), &realSize);
if (err == noErr) // No parameters, extract the signature from the Apple Event
psn = GetPSNBySig(appSignature);
else
psn = MoreExtractFromAEDesc::ExtractAESender(inAppleEvent);
LArrayIterator iter(::sURLEchoHandlers);
ProcessSerialNumber newPSN;
while (iter.Next(&newPSN))
if ((newPSN.highLongOfPSN == psn.highLongOfPSN) && (newPSN.lowLongOfPSN == psn.lowLongOfPSN))
sURLEchoHandlers.Remove(&newPSN);
}
// Echoing of the URLs. For each registered application, send them the URLEcho AE
void FE_URLEcho(URL_Struct *url, int /*iStatus*/, MWContext *context)
{
ProcessSerialNumber psn;
OSErr err;
LArrayIterator iter(sURLEchoHandlers);
while (iter.Next(&psn))
Try_
{
// Create the event, fill in all the arguments, and send it
AEAddressDesc target; // Target the event
err = AECreateDesc(typeProcessSerialNumber, &psn,sizeof(psn), &target);
ThrowIfOSErr_(err);
AppleEvent echoEvent;
err = ::AECreateAppleEvent(AE_spy_send_suite, AE_spy_URLecho,
&target,
kAutoGenerateReturnID,
kAnyTransactionID,
&echoEvent);
ThrowIfOSErr_(err);
AEDisposeDesc(&target);
// Add the URL
if (url->address)
{
err = ::AEPutParamPtr(&echoEvent, keyDirectObject, typeChar, url->address, strlen(url->address));
ThrowIfOSErr_(err);
}
// Add the MIME type
if (url->content_type)
{
err = ::AEPutParamPtr(&echoEvent, AE_spy_URLecho_mime, typeChar, url->content_type, strlen(url->content_type));
ThrowIfOSErr_(err);
}
// Add the refererer
if (url->referer)
{
err = ::AEPutParamPtr(&echoEvent, AE_spy_URLecho_referer, typeChar, url->referer, strlen(url->referer));
ThrowIfOSErr_(err);
}
// Add the window ID
CNSContext* nsContext = ExtractNSContext(context);
ThrowIfNil_(context);
Int32 windowID = nsContext->GetContextUniqueID();
err = ::AEPutParamPtr(&echoEvent, AE_spy_URLecho_win, typeLongInteger, &windowID, sizeof(windowID));
ThrowIfOSErr_(err);
AppleEvent reply;
err = ::AESend(&echoEvent, &reply, kAENoReply,kAENormalPriority,0,nil, nil);
AEDisposeDesc(&echoEvent);
ThrowIfOSErr_(err);
}
Catch_(inErr){}
EndCatch_
}
// Registering the protocol
// The protocol is registered by application signature
void CNotifierRegistry::HandleRegisterProtocol(const AppleEvent &inAppleEvent,
AppleEvent &/*outAEReply*/, AEDesc &/*outResult*/, long /*inAENumber*/)
{
Size realSize;
DescType realType;
OSType appSignature;
char * protocol = nil;
CProtocolHelper * volatile helper;
Try_
{
OSErr err = ::AEGetParamPtr(&inAppleEvent, keyDirectObject, typeApplSignature, &realType,
&appSignature, sizeof(appSignature), &realSize);
if (err != noErr) // Signature was not passed appropriately typed, try as type
{
OSErr err = ::AEGetParamPtr(&inAppleEvent, keyDirectObject, typeType, &realType,
&appSignature, sizeof(appSignature), &realSize);
if (err != noErr) // No signature passed, extract it from the Apple Event
{
ProcessSerialNumber psn = MoreExtractFromAEDesc::ExtractAESender(inAppleEvent);
ProcessInfoRec pir;
FSSpec dummy;
pir.processAppSpec = &dummy;
err = ::GetProcessInformation(&psn, &pir);
ThrowIfOSErr_(err);
appSignature = pir.processSignature;
}
}
// Extract the protocol
MoreExtractFromAEDesc::GetCString(inAppleEvent, AE_spy_register_protocol_pro, protocol);
// Have app signature, and protocol, add them to the list
helper = new CProtocolHelper(protocol, appSignature);
CProtocolHelper::AddNewHelper(helper);
}
Catch_(inErr){}
EndCatch_
}
void CNotifierRegistry::HandleUnregisterProtocol(const AppleEvent &inAppleEvent,
AppleEvent &/*outAEReply*/, AEDesc &/*outResult*/, long /*inAENumber*/)
{
Size realSize;
DescType realType;
OSType appSignature;
char * protocol = nil;
Try_
{
OSErr err = ::AEGetParamPtr(&inAppleEvent, keyDirectObject, typeApplSignature, &realType,
&appSignature, sizeof(appSignature), &realSize);
if (err != noErr)
err = ::AEGetParamPtr(&inAppleEvent, keyDirectObject, typeType, &realType,
&appSignature, sizeof(appSignature), &realSize);
if (err != noErr) // No signature passed, extract it from the Apple Event
{
ProcessSerialNumber psn = MoreExtractFromAEDesc::ExtractAESender(inAppleEvent);
ProcessInfoRec pir;
FSSpec dummy;
pir.processAppSpec = &dummy;
err = ::GetProcessInformation(&psn, &pir);
ThrowIfOSErr_(err);
appSignature = pir.processSignature;
}
// Extract the protocol. Not necessary. If we only have the sig, remove all the registered protocols
Try_
{
MoreExtractFromAEDesc::GetCString(inAppleEvent, AE_spy_register_protocol_pro, protocol);
}
Catch_(inErr){}
EndCatch_
// Delete it from the list
LArrayIterator iter(sProtocolHandlers);
CProtocolHelper * helper;
while (iter.Next(&helper)) // Delete duplicate registration for this protocol
if (helper->EqualTo(protocol, appSignature))
{
delete helper;
sProtocolHandlers.Remove(&helper);
}
if (protocol)
NET_DelExternalURLType(protocol);
}
Catch_(inErr){}
EndCatch_
}
XP_Bool FE_UseExternalProtocolModule(MWContext *context,
FO_Present_Types /*iFormatOut*/, URL_Struct *url,
Net_GetUrlExitFunc */*pExitFunc*/)
{
#ifndef MOZ_MAIL_NEWS
if (url->address && CInternetConfigInterface::CurrentlyUsingIC()) {
ICError err = CInternetConfigInterface::SendInternetConfigURL(url->address);
if (err == noErr)
return true;
}
#endif
LArrayIterator iter(sProtocolHandlers);
CProtocolHelper * helper;
while (iter.Next(&helper))
if (helper->AttemptLaunch(url, context))
return true;
return false;
}

View File

@@ -0,0 +1,57 @@
/* -*- 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.
*/
// mregistr.h
// Registry for AppleEvent notifiers
// Pretty clumsy right now, but separating this functionality out of uapp seems
// to be the right thing.
// It is just a collection of routines
#pragma once
#include <LArray.h>
class CNotifierRegistry {
public:
// ¥¥ÊAppleEvent handling
static void HandleAppleEvent(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
static void ReadProtocolHandlers(); // Saving to prefs interface
static void WriteProtocolHandlers();
private:
static void HandleRegisterProtocol(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
static void HandleUnregisterProtocol(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
// ¥¥ url echo
static void HandleRegisterURLEcho(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
static void HandleUnregisterURLEcho(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
};

View File

@@ -0,0 +1,487 @@
/* -*- 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.
*/
// ulaunch.cp
// Launching of external applications through AppleEvents
// Created by atotic, June 14th, 1994
// Based on Apple's LaunchWithDoc example snippet
#include <Folders.h>
#include <AERegistry.h>
#include <Errors.h>
#include "BufferStream.h"
#include "PascalString.h"
#include "macutil.h"
#include "uprefd.h"
#include "ufilemgr.h"
#include "uerrmgr.h"
#include "reserr.h"
#include "ulaunch.h"
// ¥¥ PROTOTYPES
OSErr FindAppOnVolume(OSType sig, short vRefNum, FSSpec& thefile);
// Sends an ODOC event to creator in fndrInfo,
// with file in fileSpec
OSErr SendODOCEvent(OSType appSig,
LFileBufferStream * inFile);
// Launches the application with the given doc
void LaunchWithDoc(FInfo& fndrInfo,
FSSpec& appSpec,
LFileBufferStream * inFile,
const FSSpec inFileSpec);
// Displays a launching error alert.
int LaunchError(ResIDT alertID, OSType creator, const Str63& fileName, OSErr err);
// Creates Finder's OpenSelection event
OSErr BuildOpenSelectionEvent(FSSpec & fileSpec, AppleEvent& theEvent);
// Sends OpenSelection to Finder
OSErr SendOpenSelectionToFinder(FSSpec & fileSpec);
// ¥¥ Implementation
// Builds an ODOC event
OSErr BuildODOCEvent(OSType applSig,
FSSpec fileSpec,
AppleEvent& theEvent) {
// Builds all the arguments for the event
AEDesc myAddress;
AEDesc docDesc;
AEDescList theList;
AliasHandle withThis;
OSErr err;
// Anatomy of the event:
// Event class: kCoreEventClass
// Event ID: kAEOpenDocuments
// Event has target description (in the form of typeApplSignature)
// keyDirectObject is a list of aliases
err = AECreateDesc(typeApplSignature,
(Ptr)&applSig, sizeof(applSig),
&myAddress);
if (err) return err;
err = AECreateAppleEvent(kCoreEventClass, kAEOpenDocuments,
&myAddress,
kAutoGenerateReturnID, kAnyTransactionID,
&theEvent);
if (err) return err;
// create a list for the alaises. In this case, I only have one, but
// you still need a list
err = AECreateList(NULL, 0, FALSE, &theList);
if (err) return err;
/* create an alias out of the file spec */
/* I'm not real sure why I did this, since there is a system coercion handler for */
/* alias to FSSpec, but I'm paranoid */
err = NewAlias(NULL, &fileSpec, &withThis);
if (err) return err;
HLock((Handle)withThis);
/* now create an alias descriptor */
err = AECreateDesc(typeAlias, (Ptr) * withThis, GetHandleSize((Handle)withThis), &docDesc);
if (err) return err;
HUnlock((Handle)withThis);
/* put it in the list */
err = AEPutDesc(&theList, 0, &docDesc);
if (err) return err;
err = AEPutParamDesc(&theEvent, keyDirectObject, &theList);
err = AEDisposeDesc(&myAddress);
err = AEDisposeDesc(&docDesc);
err = AEDisposeDesc(&theList);
return err;
}
// Sends an ODOC event to appliation
OSErr SendODOCEvent(OSType appSig,
LFileBufferStream * inFile)
{
OSErr err;
Try_ {
AppleEvent openEvent;
FSSpec inFileSpec;
inFile->GetSpecifier(inFileSpec);
err = BuildODOCEvent(appSig,
inFileSpec,
openEvent);
ThrowIfOSErr_(err);
AppleEvent result;
err = AESend(&openEvent, &result,
kAENoReply + kAECanSwitchLayer,
kAENormalPriority, kAEDefaultTimeout,
NULL,NULL);
AEDisposeDesc(&openEvent);
// err could be memFullErr, app is out of memory
ThrowIfOSErr_(err);
}
Catch_(inErr) {
return inErr;
} EndCatch_
return err;
}
#define kDelete 2
#define kSave 1
#define kTryAgain 3
// Displays launch error dialogs with appropriate arguments.
// Alerts used are:
// ALRT_ODOCFailed
// ALRT_AppNotFound
// ALRT_AppMemFull
// ALRT_MiscLaunchError
// Returns: kDelete, kSave, or kTryAgain
int LaunchError(ResIDT alertID, OSType creator, const Str63& fileName, OSErr err)
{
CMimeMapper * map = CPrefs::sMimeTypes.FindCreator(creator);
ErrorManager::PrepareToInteract();
ParamText(map->GetAppName(), CStr255(fileName), ErrorManager::OSNumToStr(err), CStr255(""));
UDesktop::Deactivate();
int retVal = ::CautionAlert(alertID, NULL);
UDesktop::Activate();
return retVal;
}
// Launches an application with a given doc
OSErr StartDocInApp(FSSpec theDocument, FSSpec theApplication)
{
FInfo fndrInfo;
OSErr err;
HGetFInfo( theApplication.vRefNum,
theApplication.parID,
theApplication.name,
&fndrInfo);
FSSpec applSpecTemp;
ProcessSerialNumber processSN;
err = FindProcessBySignature(fndrInfo.fdCreator, 'APPL', processSN, &applSpecTemp);
if (err == noErr) // App is running. Send 'odoc'
{
Try_ {
AppleEvent theEvent;
err = BuildODOCEvent(fndrInfo.fdCreator, theDocument, theEvent);
ThrowIfOSErr_(err);
AppleEvent result;
err = AESend(&theEvent, &result,
kAENoReply + kAEAlwaysInteract + kAECanSwitchLayer,
kAENormalPriority, kAEDefaultTimeout,
NULL,NULL);
AEDisposeDesc(&theEvent);
// err could be memFullErr, app is out of memory
ThrowIfOSErr_(err);
if (IsFrontApplication())
SetFrontProcess(&processSN);
}
Catch_(inErr) {
return inErr;
} EndCatch_
return noErr;
}
Try_ {
LaunchParamBlockRec launchThis;
AEDesc launchDesc;
AppleEvent theEvent;
ThrowIfOSErr_(BuildODOCEvent(fndrInfo.fdCreator, theDocument, theEvent));
ThrowIfOSErr_(AECoerceDesc(&theEvent, typeAppParameters, &launchDesc));
launchThis.launchAppSpec = (FSSpecPtr)&theApplication;
launchThis.launchAppParameters = (AppParametersPtr)*(launchDesc.dataHandle);
launchThis.launchBlockID = extendedBlock;
launchThis.launchEPBLength = extendedBlockLen;
launchThis.launchFileFlags = NULL;
launchThis.launchControlFlags = launchContinue + launchNoFileFlags + launchUseMinimum;
if (!IsFrontApplication())
launchThis.launchControlFlags += launchDontSwitch;
err = LaunchApplication(&launchThis);
ThrowIfOSErr_(err);
}
Catch_(inErr)
{
} EndCatch_
return err;
}
// Launches the application with the given doc
void LaunchWithDoc(FInfo& fndrInfo,
FSSpec& appSpec,
LFileBufferStream * inFile,
const FSSpec inFileSpec)
{
OSErr err = CFileMgr::FindApplication(fndrInfo.fdCreator, appSpec);
if (err) // Application not found error
{
int whatToDo = ::LaunchError(ALRT_AppNotFound, fndrInfo.fdCreator,
inFileSpec.name, err);
if (whatToDo == kSave)
CFileMgr::sFileManager.CancelRegister(inFile); // Save the file
else // kDelete
CFileMgr::sFileManager.CancelAndDelete(inFile); // Delete the file
return;
}
Try_ {
LaunchParamBlockRec launchThis;
AEDesc launchDesc;
AppleEvent theEvent;
ThrowIfOSErr_(BuildODOCEvent(fndrInfo.fdCreator, inFileSpec, theEvent));
ThrowIfOSErr_(AECoerceDesc(&theEvent, typeAppParameters, &launchDesc));
launchThis.launchAppSpec = (FSSpecPtr)&appSpec;
launchThis.launchAppParameters = (AppParametersPtr)*(launchDesc.dataHandle);
/* launch the thing */
launchThis.launchBlockID = extendedBlock;
launchThis.launchEPBLength = extendedBlockLen;
launchThis.launchFileFlags = NULL;
launchThis.launchControlFlags = launchContinue + launchNoFileFlags + launchUseMinimum;
if (!IsFrontApplication())
launchThis.launchControlFlags += launchDontSwitch;
do // Launch until we succeed, or user gives up.
{
err = LaunchApplication(&launchThis);
if ((err == memFullErr) || (err == memFragErr))
// Launch failed because of low memory
{
int whatToDo = ::LaunchError(ALRT_AppMemFull, fndrInfo.fdCreator,
inFileSpec.name, err);
switch (whatToDo) {
case kSave:
CFileMgr::sFileManager.CancelRegister(inFile); // Save the file
err = noErr;
break;
case kDelete:
CFileMgr::sFileManager.CancelAndDelete(inFile); // Save the file
err = noErr;
break;
case kTryAgain: // Loop again
break;
}
}
else // Unknown launch error
ThrowIfOSErr_(err);
} while (err != noErr);
}
Catch_(inErr)
{
int whatToDo = ::LaunchError(ALRT_AppMiscError, fndrInfo.fdCreator,
inFileSpec.name, inErr);
if (whatToDo == kSave)
CFileMgr::sFileManager.CancelRegister(inFile); // Save the file
else // kDelete
CFileMgr::sFileManager.CancelAndDelete(inFile); // Delete the file
} EndCatch_
}
OSErr
CreateFinderAppleEvent( AEEventID eventID,
SInt16 returnID,
SInt32 transactionID,
AppleEvent & theEvent)
{
OSErr err;
FSSpec finder;
ProcessSerialNumber psn;
AEDesc finderAddress;
Boolean validAddress = false;
try
{
err = FindProcessBySignature('MACS', 'FNDR', psn, &finder);
ThrowIfOSErr_(err);
err = ::AECreateDesc(typeProcessSerialNumber, (Ptr)&psn, sizeof(psn), &finderAddress);
ThrowIfOSErr_(err);
validAddress = true;
err = ::AECreateAppleEvent( kAEFinderEvents,
eventID,
(const AEAddressDesc *) &finderAddress,
returnID,
transactionID,
&theEvent );
}
catch(long tErr)
{
if (validAddress)
::AEDisposeDesc(&finderAddress);
}
return err;
}
// Builds an OpenSelection event for Finder
OSErr BuildOpenSelectionEvent(FSSpec & fileSpec, AppleEvent& theEvent) {
FSSpec dirSpec, procSpec;
FSSpecPtr theFileToOpen = nil;
CStr63 processName;
AEDesc aeDirDesc, listElem;
AEDesc fileList;
ConstStr255Param * dummy = NULL;
// Create the event
OSErr err;
Try_ {
ProcessInfoRec pir;
pir.processInfoLength = sizeof(ProcessInfoRec);
pir.processName = (StringPtr)&processName;
pir.processAppSpec = &procSpec;
// Find a Finder, and create its description as an address for an apple event
err = CreateFinderAppleEvent(kAEOpenSelection, kAutoGenerateReturnID, kAnyTransactionID, theEvent);
ThrowIfOSErr_(err);
// Create a description of the file, and the enclosing folder
// keyDirectObject is directory description
//
err = CFileMgr::FolderSpecFromFolderID(fileSpec.vRefNum, fileSpec.parID, dirSpec);
ThrowIfOSErr_(err);
err = AECreateList(nil, 0, false, &fileList);
ThrowIfOSErr_(err);
AliasHandle DirAlias, FileAlias;
NewAlias(nil, &dirSpec, &DirAlias);
HLock((Handle)DirAlias);
err = AECreateDesc(typeAlias, (Ptr)*DirAlias, GetHandleSize((Handle)DirAlias), &aeDirDesc);
ThrowIfOSErr_(err);
HUnlock((Handle)DirAlias);
DisposeHandle((Handle)DirAlias);
err = AEPutParamDesc(&theEvent, keyDirectObject, &aeDirDesc);
ThrowIfOSErr_(err);
AEDisposeDesc(&aeDirDesc);
NewAlias(nil, &fileSpec, &FileAlias);
HLock((Handle)FileAlias);
err = AECreateDesc(typeAlias, (Ptr)*FileAlias, GetHandleSize((Handle)FileAlias), &listElem);
ThrowIfOSErr_(err);
HUnlock((Handle)FileAlias);
err = AEPutDesc(&fileList, 0, &listElem);
ThrowIfOSErr_(err);
DisposeHandle((Handle)FileAlias);
err = AEPutParamDesc( &theEvent, keySelection, &fileList);
ThrowIfOSErr_(err);
}
Catch_(inErr)
{
return inErr;
} EndCatch_
return noErr;
}
// Sends 'open selection event to Finder
OSErr SendOpenSelectionToFinder(FSSpec & fileSpec)
{
AppleEvent event;
AppleEvent result;
OSErr err = BuildOpenSelectionEvent(fileSpec, event);
if (err)
return err;
err = AESend(&event, &result,
kAENoReply + kAEAlwaysInteract + kAECanSwitchLayer,
kAENormalPriority, kAEDefaultTimeout,
NULL,NULL);
AEDisposeDesc(&event);
return err;
}
// A somewhat tricky way of opening a foreign document
// Algorithm:
// - if a process is not running, launch it with the document
// - if a process is running and AE aware, send it an AppleEvent
// - if a process is running and is not AE aware, send openSelection to the Finder.
void LaunchFile(LFileBufferStream * inFile)
{
FSSpec applSpec;
FInfo fndrInfo;
// Get file info
FSSpec inFileSpec;
inFile->GetSpecifier(inFileSpec);
HGetFInfo(inFileSpec.vRefNum,
inFileSpec.parID,
inFileSpec.name,
&fndrInfo);
// Find if the application is already running
ProcessSerialNumber processSN;
ProcessInfoRec infoRecToFill;
Str63 processName;
infoRecToFill.processInfoLength = sizeof(ProcessInfoRec);
infoRecToFill.processName = (StringPtr)&processName;
infoRecToFill.processAppSpec = &applSpec;
OSErr err = FindProcessBySignature(fndrInfo.fdCreator, 'APPL', processSN, &applSpec);
if (err == noErr) // App is running. Send 'odoc'
{
err = SendODOCEvent(fndrInfo.fdCreator, inFile);
if (err == noErr)
{
if (IsFrontApplication())
SetFrontProcess(&processSN);
}
else
{
// Application did not accept apple event for some reason (err = connectionInvalid)
// Send 'odoc' to Finder. Finder can figure out how to fake menu events when
// it tries to open the file
err = SendOpenSelectionToFinder(inFileSpec);
if (err == noErr)
{ // If finder launched the application successfully, find it and bring it to front
err = FindProcessBySignature(fndrInfo.fdCreator, 'APPL', processSN, &applSpec);
if (err == noErr && IsFrontApplication())
SetFrontProcess(&processSN);
}
else // Finder launch also failed. Notify the user
{
//Notify the user, try to handle the error
int whatToDo = LaunchError(ALRT_ODOCFailed,
fndrInfo.fdCreator,
inFileSpec.name, err);
if (whatToDo == 1)
CFileMgr::sFileManager.CancelRegister(inFile); // Save the file
else
CFileMgr::sFileManager.CancelAndDelete(inFile); // Delete the file
}
}
}
else // App is not running. Launch it with this file
LaunchWithDoc(fndrInfo, applSpec, inFile, inFileSpec);
}

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) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
// ===========================================================================
// ulaunch.h
// External application launching routines
// ===========================================================================
#pragma once
class LFileBufferStream;
// Opens the file in its creator application
void LaunchFile(LFileBufferStream * inFile);
// Launches an application with a given doc
OSErr StartDocInApp(FSSpec theDocument, FSSpec theApplication);
// Builds an ODOC event for appliation specified by applSig,
// with file in fileSpec
OSErr BuildODOCEvent(OSType applSig,
FSSpec fileSpec,
AppleEvent& theEvent);
OSErr
CreateFinderAppleEvent( AEEventID eventID,
SInt16 returnID,
SInt32 transactionID,
AppleEvent & theEvent);

View File

@@ -0,0 +1,60 @@
/* -*- 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 "BookmarksFile.h"
#include "resgui.h"
#include <LStream.h>
#include <algorithm>
//
// ReadBookmarksFile
//
// Given a file containing a single URL (probably dropped on the Finder), open it and
// create a bookmark entry for it so we can load it.
//
OSErr
ReadBookmarksFile ( vector<char> & oURL, FSSpec & inSpec )
{
FInfo info;
OSErr err = ::FSpGetFInfo (&inSpec, &info);
if (err != noErr)
return err;
if (info.fdType != emBookmarkFile)
return fnfErr;
try {
LFileStream stream(inSpec);
stream.OpenDataFork(fsRdPerm);
Int32 howMuch;
// Read in the URL, which is in the form URL\rTITLE
howMuch = stream.ReadData(oURL.begin(), oURL.size());
char* where = find(oURL.begin(), oURL.end(), '\r');
ThrowIfNil_(where);
*where = 0;
}
catch ( Uint32 inErr )
{
return inErr;
}
return noErr;
}

View File

@@ -0,0 +1,27 @@
/* -*- 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.
*/
#pragma once
#include <Files.h>
#include <vector.h>
OSErr ReadBookmarksFile( vector<char> & oURL, FSSpec & spec);
//OSErr WriteBookmarksFile(BM_Entry * entry, FSSpec & spec);
//OSErr WriteBookmarksFile(char * url, FSSpec & spec);

View File

@@ -0,0 +1,322 @@
/* -*- 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.
*/
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// BrowserClasses.cp
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
#include "BrowserClasses.h"
// ¥¥¥ PowerPlant Classes
#include <URegistrar.h>
#include <LActiveScroller.h>
#include <LButton.h>
#include <LCaption.h>
#include <LDialogBox.h>
#include <LEditField.h>
#include <LGroupBox.h>
#include <LIconPane.h>
#include <LListBox.h>
#include <LPicture.h>
#include <LPlaceHolder.h>
#include <LPrintout.h>
#include <LScroller.h>
#include <LStdControl.h>
#include <LTable.h>
#include <LTextEdit.h>
#include <LWindow.h>
#include <LRadioGroup.h>
#include <LTabGroup.h>
#include <LTextColumn.h>
#include <LSubOverlapView.h>
// ¥¥¥ PowerPlant Grayscale Classes
#include <UGALibRegistry.h>
// ¥¥¥ General Purpose UI Classes
#include "CBevelButton.h"
#include "CPatternButton.h"
#include "CGrayBevelView.h"
#include "CPatternBevelView.h"
#include "CPatternButtonPopup.h"
#include "CGuidePopupMenu.h"
#include "CNavigationButtonPopup.h"
#include "CCloseAllAttachment.h"
#include "CColorEraseAttachment.h"
#include "CGABorderPane.h"
#include "CPatternPane.h"
#include "CIncludeView.h"
#include "CPlaceHolderView.h"
#include "COffscreenCaption.h"
#include "CClusterView.h"
#include "CTabSwitcher.h"
#include "CPatternTabControl.h"
#include "CProgressBar.h"
// #include "CProgressCaption.h"
#include "CTaskBarView.h"
#include "LTableHeader.h"
#include "LTableViewHeader.h"
#include "CSimpleDividedView.h"
#include "CKeyScrollAttachment.h"
#include "CToolTipAttachment.h"
#include "CDynamicTooltips.h"
#include "CPaneEnabler.h"
#include "CStringListToolTipPane.h"
#include "CSaveProgress.h"
#include "CPatternProgressBar.h"
#ifdef MOZ_MAIL_NEWS
#include "CBiffButtonAttachment.h"
#include "CSingleLineEditField.h"
#endif
// ¥¥¥ Browser Specific UI Classes
#include "CDragBar.h"
#include "CDragBarContainer.h"
#include "CDragBarDockControl.h"
#include "CPatternedGrippyPane.h"
#include "CDividerGrippyPane.h"
#include "CSwatchBrokerView.h"
#include "CToolbarDragBar.h"
#include "CToolbarPatternBevelView.h"
#include "CProxyPane.h"
#include "CProxyCaption.h"
#include "PopupBox.h"
#include "CPersonalToolbarTable.h"
#include "CNavCenterWindow.h"
#include "CNavCenterSelectorPane.h"
#include "CNavCenterContextMenuAtt.h"
#include "CNavCenterTitle.h"
#include "CInlineEditField.h"
#include "CConfigActiveScroller.h"
#include "CTSMEditField.h"
// #include "VEditField.h"
// #include "CSimpleTextView.h"
#include "CDownloadProgressWindow.h"
#include "CURLEditField.h"
#include "CURLCaption.h"
#include "CHyperScroller.h"
#include "CButtonEnablerReloadStop.h"
#include "CBrowserWindow.h"
#include "CHTMLView.h"
#include "CBrowserView.h"
#include "CSpinningN.h"
#include "CBrowserSecurityButton.h"
#include "CMiniSecurityButton.h"
#include "mprint.h"
#include "macgui.h"
#include "findw.h"
// #include "prefw.h"
#include "BookmarksDialogs.h"
#include "mplugin.h"
#include "divview.h"
// #include "mattach.h"
#include "UFormElementFactory.h"
#include "CMenuTable.h"
#include "CPrefsMediator.h"
#include "CAssortedMediators.h"
#if defined (JAVA)
#include "mjava.h"
#endif
#include "CEditorWindow.h"
// #include "mhistory.h"
#include "CContextMenuAttachment.h"
#include "CHyperTreeFlexTable.h"
#include "CRDFCoordinator.h"
#include "CHyperTreeHeader.h"
//-----------------------------------
void RegisterAllBrowserClasses(void)
//-----------------------------------
{
// AutoRegister classes
RegisterClass_(CProxyPane);
RegisterClass_(CProxyCaption);
RegisterClass_(CCloseAllAttachment);
RegisterClass_(CColorEraseAttachment);
RegisterClass_(CGABorderPane);
RegisterClass_(CPatternPane);
RegisterClass_(LSubOverlapView);
// ¥¥¥ PowerPlant Classes
RegisterClass_(LButton);
RegisterClass_(LCaption);
RegisterClass_(LDialogBox);
RegisterClass_(LEditField);
RegisterClass_(LListBox);
RegisterClass_(LPane);
RegisterClass_(LPicture);
RegisterClass_(LPlaceHolder);
RegisterClass_(LPrintout);
RegisterClass_(LScroller);
RegisterClass_(LStdControl);
RegisterClass_(LStdButton);
RegisterClass_(LStdCheckBox);
RegisterClass_(LStdRadioButton);
RegisterClass_(LStdPopupMenu);
RegisterClass_(LTextEdit);
RegisterClass_(LView);
RegisterClass_(LWindow);
RegisterClass_(LRadioGroup);
RegisterClass_(LTabGroup);
RegisterClass_(LActiveScroller);
//LRegistrar::RegisterClass('prto', (ClassCreatorFunc);LPrintout::CreateOldPrintoutStream);
#ifdef PP_NewClasses
#include <LCicnButton.h>
#include <LOffscreenView.h>
#include <LTextButton.h>
RegisterClass_(LCicnButton);
RegisterClass_(LOffscreenView);
RegisterClass_(LTextButton);
#endif
RegisterClass_(LTable);
RegisterClass_(LIconPane);
RegisterClass_(LGroupBox);
RegisterClass_(LTextColumn);
RegisterClass_(CGAPopupMenu);
// ¥¥¥ PowerPlant Grayscale Classes
RegisterGALibraryClasses();
// ¥¥¥ General Purpose UI Classes
RegisterClass_(CBevelButton);
RegisterClass_(CDeluxeBevelButton);
RegisterClass_(CPatternButton);
RegisterClass_(CPatternButtonPopup);
RegisterClass_(CGrayBevelView);
RegisterClass_(CPatternBevelView);
RegisterClass_(CIncludeView);
RegisterClass_(CPlaceHolderView);
RegisterClass_(COffscreenCaption);
RegisterClass_(CClusterView);
RegisterClass_(CPatternTabControl);
RegisterClass_(CTabSwitcher);
RegisterClass_(CProgressBar);
RegisterClass_(CKeyScrollAttachment);
RegisterClass_(CToolTipAttachment);
RegisterClass_(CDynamicTooltipPane);
RegisterClass_(CSharedToolTipAttachment);
RegisterClass_(CMenuTable);
RegisterClass_(CPaneEnabler);
RegisterClass_(CSlaveEnabler);
#ifdef MOZ_MAIL_NEWS
RegisterClass_(CSingleLineEditField);
RegisterClass_(CSelectFolderMenu);
//#else
// RegisterClass_(CBiffButtonAttachment);
#endif // MOZ_MAIL_NEWS
RegisterClass_(CSimpleDividedView);
//RegisterClass_(CProgressCaption);
RegisterClass_(CTaskBarView);
RegisterClass_(CToolTipPane);
RegisterClass_(CStringListToolTipPane);
RegisterClass_(LTableHeader);
RegisterClass_(LTableViewHeader);
RegisterClass_(CPatternProgressBar);
RegisterClass_(CPatternProgressCaption);
RegisterClass_(CTextEdit);
RegisterClass_(CEditBroadcaster);
RegisterClass_(CGuidePopupMenu);
RegisterClass_(CNavigationButtonPopup);
// *** Browser Specific UI Classes
RegisterClass_(CDragBar);
RegisterClass_(CDragBarContainer);
RegisterClass_(CDragBarDockControl);
RegisterClass_(CBrokeredView);
RegisterClass_(CSwatchBrokerView);
RegisterClass_(CToolbarDragBar);
RegisterClass_(CToolbarPatternBevelView);
RegisterClass_(CPersonalToolbarTable);
RegisterClass_(CConfigActiveScroller);
RegisterClass_(CTSMEditField);
// REGISTERV(EditField);
RegisterClass_(CDownloadProgressWindow);
RegisterClass_(CBrowserWindow);
RegisterClass_(CHTMLView);
RegisterClass_(CURLEditField);
RegisterClass_(CURLCaption);
RegisterClass_(CSaveProgress);
RegisterClass_(CHyperScroller);
RegisterClass_(CButtonEnablerReloadStop);
RegisterClass_(CBrowserView);
RegisterClass_(CPatternedGrippyPane);
RegisterClass_(CDividerGrippyPane);
RegisterClass_(CSpinningN);
RegisterClass_(CBrowserSecurityButton);
RegisterClass_(CMiniSecurityButton);
RegisterClass_(CHyperTreeFlexTable);
RegisterClass_(CNavCenterSelectorPane);
RegisterClass_(CRDFCoordinator);
RegisterClass_(CHyperTreeHeader);
RegisterClass_(CInlineEditField);
RegisterClass_(CNavCenterWindow);
RegisterClass_(CBookmarksFindDialog);
RegisterClass_(CPluginView);
RegisterClass_(LDividedView);
RegisterClass_(CNavCenterContextMenuAttachment);
RegisterClass_(CNavCenterSelectorContextMenuAttachment);
RegisterClass_(CNavCenterTitle);
#ifdef EDITOR
CEditorWindow::RegisterViewTypes();
#endif // EDITOR
CFindWindow::RegisterViewTypes();
UFormElementFactory::RegisterFormTypes();
UHTMLPrinting::RegisterHTMLPrintClasses();
CPrefsMediator::RegisterViewClasses();
CPrefsDialog::RegisterViewClasses();
UAssortedPrefMediators::RegisterViewClasses();
RegisterClass_(CContextMenuAttachment);
#ifdef JAVA
RegisterClass_(CJavaView);
#endif
} // RegisterAllBrowserClasses

View File

@@ -0,0 +1,25 @@
/* -*- 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.
*/
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// BrowserClasses.h
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
#pragma once
void RegisterAllBrowserClasses(void);

View File

@@ -0,0 +1,144 @@
/* -*- 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 "BufferStream.h"
#include "client.h"
#ifdef PROFILE
#pragma profile on
#endif
#define STREAM_BUFFER_SIZE 32000
LFileBufferStream::LFileBufferStream( FSSpec& inFileSpec ): LFileStream( inFileSpec )
{
fBuffer = NULL;
fBufferSize = 0;
fLastWritten = 0;
fUseBuffer = FALSE;
fURL = NULL;
fWriteFailed = FALSE;
}
LFileBufferStream::~LFileBufferStream()
{
Try_
{
FlushBuffer( FALSE );
}
Catch_(inErr)
{
}
EndCatch_
if ( fURL )
XP_FREE( fURL );
}
OSErr LFileBufferStream::FlushBuffer( Boolean allocateNew )
{
OSErr err = noErr;
if ( !fUseBuffer )
return err;
if ( fBuffer && ( fLastWritten > 0 ) )
{
HLock( fBuffer );
Try_
{
err = LFileStream::PutBytes( *fBuffer, fLastWritten );
ThrowIfOSErr_(err);
HUnlock( fBuffer );
}
Catch_(inErr)
{
HUnlock( fBuffer );
DisposeHandle(fBuffer);
fBuffer = NULL;
fWriteFailed = TRUE;
}
EndCatch_
fLastWritten = 0;
}
if (fWriteFailed)
return err;
if ( allocateNew && ( !fBuffer ) )
{
fBuffer = ::NewHandle( STREAM_BUFFER_SIZE );
fBufferSize = STREAM_BUFFER_SIZE;
fLastWritten = 0;
}
if ( !allocateNew && fBuffer )
{
DisposeHandle( fBuffer );
fBuffer = NULL;
}
return err;
}
Int32 LFileBufferStream::ReadData( void* outBuffer, Int32 inByteCount )
{
return LFileStream::ReadData( outBuffer, inByteCount );
}
void LFileBufferStream::DoUseBuffer()
{
fUseBuffer = TRUE;
}
void LFileBufferStream::CloseDataFork()
{
FlushBuffer( FALSE );
LFileStream::CloseDataFork();
}
Int32 LFileBufferStream::WriteData( const void* inFromBuffer, Int32 inByteCount )
{
OSErr err = noErr;
if ( fUseBuffer && ( fLastWritten + inByteCount ) > fBufferSize )
err = FlushBuffer( TRUE );
ThrowIfOSErr_(err);
if ( ( fBuffer ) && // If we have space, fill up the buffer
( ( fLastWritten + inByteCount ) <= fBufferSize ) )
{
::BlockMoveData( inFromBuffer, &( (*fBuffer)[fLastWritten] ), inByteCount );
fLastWritten += inByteCount;
return inByteCount;
}
// Otherwise, just do a normal write
else
{
err = LFileStream::PutBytes( inFromBuffer, inByteCount );
ThrowIfOSErr_(err);
}
return inByteCount;
}
#ifdef PROFILE
#pragma profile off
#endif

View File

@@ -0,0 +1,54 @@
/* -*- 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 __BUFFERSTREAM__
#define __BUFFERSTREAM__
#include <LFileStream.h>
#include <stddef.h>
// Does plain buffered read/writes
// Buffering strategy:
// reading: read all you can fit in the buffer
// give it to the client in small chunks
// writing: write all you can fit in the buffer
// on overflow, flush everything, then write the rest
// for now, we only buffer writing
class LFileBufferStream: public LFileStream
{
public:
LFileBufferStream( FSSpec& inFileSpec );
virtual ~LFileBufferStream();
virtual Int32 WriteData( const void *inFromBuffer, Int32 inByteCount );
virtual Int32 ReadData( void* outToBuffer, Int32 inByteCount );
virtual void CloseDataFork();
void DoUseBuffer();
void SetURL( char* url ) { fURL = url; }
char* GetURL() { return fURL; }
protected:
OSErr FlushBuffer( Boolean allocateNew );
Boolean fUseBuffer;
Handle fBuffer;
UInt32 fBufferSize;
UInt32 fLastWritten;
Boolean fWriteFailed;
char * fURL;
};
#endif // __BUFFERSTREAM__

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,366 @@
/* -*- 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.
*/
// CAppleEventHandler.h
#include "PascalString.h"
#include "xp_mem.h"
enum KioskEnum {KioskOff = 0, KioskOn = 1};
class CAppleEventHandler
{
public:
static CAppleEventHandler* sAppleEventHandler; // One and only instance of AEvents
// --- Standard Constructors and Destructors
CAppleEventHandler();
virtual ~CAppleEventHandler();
// virtual void Initialize();
// --- Top Level Apple Event Handling
virtual void HandleAppleEvent(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
virtual void GetAEProperty(DescType inProperty,
const AEDesc &inRequestedType,
AEDesc &outPropertyDesc) const;
virtual void SetAEProperty(DescType inProperty,
const AEDesc &inRequestedType,
AEDesc &outPropertyDesc);
// --- AEOM support
void GetSubModelByUniqueID(DescType inModelID,
const AEDesc &inKeyData,
AEDesc &outToken) const;
static KioskEnum GetKioskMode(){return sAppleEventHandler->fKioskMode;}
protected:
private:
KioskEnum fKioskMode;
void HandleOpenURLEvent(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
// spy Apple Event suite
// file/URL opening + misc
void HandleGetURLEvent(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleGetWDEvent(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleShowFile(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleParseAnchor(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
// Progress
void HandleCancelProgress(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
// Spy window events
void HandleSpyActivate(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleSpyListWindows(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleSpyGetWindowInfo(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleWindowRegistration(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
// Netscape suite
void HandleOpenBookmarksEvent(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleReadHelpFileEvent(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleGoEvent( const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleOpenAddressBookEvent(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleOpenComponentEvent(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleCommandEvent(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
void HandleGetActiveProfileEvent(const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
};
/*-------------------------------------------------------------*/
// class EudoraSuite
// Tools used to communicate with Eudora
// The only real use these have is if we are operating in
// Browser-only mode and the user wishes to use Eudora to
// handle mail functions.
//
/*-------------------------------------------------------------*/
// --------------------------------------------------------------
/* Some Constants used by the Eudora Suite */
// --------------------------------------------------------------
#define attachDouble 0
#define attachSingle 1
#define attachBinHex 2
#define attachUUencode 3
#define EU_Norm_Priority 0
#define EU_High_Priority 60
#define EU_Highest_Priority 1
#define EU_Low_Priority 160
#define EU_Lowest_Priority 200
class EudoraSuite
{
public:
// --------------------------------------------------------------
/* This makes a Null AppleEvent descriptor.
*/
// --------------------------------------------------------------
static void MakeNullDesc (AEDesc *theDesc);
// --------------------------------------------------------------
/* This makes a string AppleEvent descriptor.
*/
// --------------------------------------------------------------
static OSErr MakeStringDesc (Str255 theStr,AEDesc *theDesc);
// --------------------------------------------------------------
/* This stuffs the required parameters into the AppleEvent.
*/
// --------------------------------------------------------------
static OSErr CreateObjSpecifier (AEKeyword theClass,AEDesc theContainer,
AEKeyword theForm,AEDesc theData, Boolean disposeInputs,AEDesc *theSpec);
// --------------------------------------------------------------
/* This creates an AEDesc for the current message.
(The current message index = 1)
In: Pointer to AEDesc to return
Out: AEDesc constructed. */
// --------------------------------------------------------------
static OSErr MakeCurrentMsgSpec (AEDesc *theSpec);
// --------------------------------------------------------------
/* Send a given Apple Event. Special case for Eudora, should
be rewritten, but it works for the moment.
In: AppleEvent
Out: Event sent */
// --------------------------------------------------------------
static OSErr SendEvent (AppleEvent *theEvent);
// --------------------------------------------------------------
/* Create an Apple Event to be sent to Eudora
In: Event Class
Event ID
Ptr to Apple Event
Out: Event constructed and returned. */
// --------------------------------------------------------------
static OSErr MakeEvent (AEEventClass eventClass,AEEventID eventID,AppleEvent *theEvent);
// --------------------------------------------------------------
/* This sets the data in a specified field. It operates on the frontmost message
in Eudora. It is the equivalent of sending the following AppleScript:
set field "fieldname" of message 0 to "data"
Examples for setting up a complete mail message:
EudoraSuite::SendSetData("\pto",toRecipientPtr);
EudoraSuite::SendSetData("\pcc",ccRecipientPtr);
EudoraSuite::SendSetData("\pbcc",bccRecipientPtr);
EudoraSuite::SendSetData("\psubject",subjectPtr);
EudoraSuite::SendSetData("\p",bodyPtr);
In: Field to set the data in (Subject, Address, Content, etc)
Pointer to text data.
Size of pointer (allows us to work with XP_Ptrs.
Out: Apple Event sent to Eudora, setting a given field. */
// --------------------------------------------------------------
static OSErr SendSetData(Str31 theFieldName, Ptr thePtr, long thePtrSize);
// --------------------------------------------------------------
/* Everything you need to tell Eudora to construct a new message
and send it.
In: Pointer to the list of e mail addresses to send TO
Pointer to the list of e mail addresses to send CC
Pointer to the list of e mail addresses to send BCC
Pointer to the Subject text
Priority level of message.
XP_HUGE_CHAR_PTR to the contents of the mail
Pointer to an FSSpec (or null if none) for an enclosure.
Out: Apple Events sent to Eudora telling it to construct the
message and send it. */
// --------------------------------------------------------------
static OSErr SendMessage(
Ptr toRecipientPtr,
Ptr ccRecipientPtr,
Ptr bccRecipientPtr,
Ptr subjectPtr,
XP_HUGE_CHAR_PTR bodyPtr,
long thePriority,
FSSpec *theEnclosurePtr);
static OSErr Set_Eudora_Priority(long thePriority);
};
/*-------------------------------------------------------------*/
// class MoreExtractFromAEDesc
// Apple event helpers -- extension of UExtractFromAEDesc.h
// All the miscellaneous AppleEvent helper routines.
/*-------------------------------------------------------------*/
class MoreExtractFromAEDesc
{
public:
// --------------------------------------------------------------
/* Given an AppleEvent, locate a string given a keyword and
return the string
In: Event to search
AEKeyword assocaated with the string
C string ptr
Out: Pointer to a newly created C string returned */
// --------------------------------------------------------------
static void GetCString(const AppleEvent &inAppleEvent, AEKeyword keyword,
char * & s);
// --------------------------------------------------------------
/* Given an AEDesc of type typeChar, return it's string.
In: AEDesc containing a string
C string ptr
Out: Pointer to a newly created C string returned */
// --------------------------------------------------------------
static void TheCString(const AEDesc &inDesc, char * & outPtr);
// --------------------------------------------------------------
/* Add an error string and error code to an AppleEvent.
Typically used when constructing the return event when an
error occured
In: Apple Event to append to
Error string
Error code
Out: keyErrorNum and keyErrorSting AEDescs are added to the Event. */
// --------------------------------------------------------------
static void MakeErrorReturn(AppleEvent &event, const CStr255& errorString,
OSErr errorCode);
// --------------------------------------------------------------
/* Display an error dialog if the given AppleEvent contains
a keyErrorNumber. a keyErrorString is optional and will be
displayed if present
In: Apple Event
Out: Error dialog displayed if error data present. */
// --------------------------------------------------------------
static Boolean DisplayErrorReply(AppleEvent &reply);
// --------------------------------------------------------------
/* Return the process serial number of the sending process.
In: Apple Event send by some app.
Out: ProcessSerialNumber of the sending app. */
// --------------------------------------------------------------
static ProcessSerialNumber ExtractAESender(const AppleEvent &inAppleEvent);
static void DispatchURLDirectly(const AppleEvent &inAppleEvent);
}; // class MoreExtractFromAEDesc
/*-------------------------------------------------------------*/
// class AEUtilities
// Some more simple Apple Event utility routines.
/*-------------------------------------------------------------*/
class AEUtilities
{
public:
// --------------------------------------------------------------
/* CreateAppleEvent
Create a new Apple Event from scratch.
In: Apple Event suite
Apple Event ID
Ptr to return Apple Event
ProcessSerialNumber of the target app to send event to.
Out:A new Apple Event is created. More data may be added to
the event simply by calling AEPutParamDesc or AEPutParamPtr */
// --------------------------------------------------------------
static OSErr CreateAppleEvent(OSType suite, OSType id,
AppleEvent &event, ProcessSerialNumber targetPSN);
// --------------------------------------------------------------
/* Check to see if there is an error in the given AEvent.
We simply return an OSError equiv to the error value
in the event. If none exists (or an error took place
during access) we return 0.
In: Apple Event to test
Out:Error value returned */
// --------------------------------------------------------------
static OSErr EventHasErrorReply(AppleEvent & reply);
};

View File

@@ -0,0 +1,389 @@
/* -*- 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.
*/
// Handle creating and maintaining the top-level bookmarks menu. It pulls the info
// out of the RDF container the user designates as their "quickfile menu" and listens
// to the messages from RDF to update it.
#include "CBookmarksAttachment.h"
#include "htrdf.h"
#include "CNetscapeWindow.h"
#include "net.h"
#include "resgui.h"
#include "uapp.h"
#include "macutil.h"
#include "UMenuUtils.h"
#include <Icons.h>
#include <Sound.h>
#define PERM_BOOKMARK_ITEMS 4
const CommandT cmd_BookmarkHierItem = BOOKMARKS_MENU_BASE_LAST;
LMenu *CBookmarksAttachment::sMenu = NULL;
Boolean CBookmarksAttachment::sInvalidMenu = true;
LArray CBookmarksAttachment::sMenusList; // this will use the default constructor
HT_View CBookmarksAttachment::sQuickfileView = NULL;
//===========================================================
// CBookmarksAttachment
//===========================================================
CBookmarksAttachment::CBookmarksAttachment()
{
InitQuickfileView();
}
//
// InitQuickfileView
//
// Called at startup to get a new view from the HT backend that represents the
// bookmarks menu. This can be called multiple times without problems.
//
void
CBookmarksAttachment :: InitQuickfileView ( )
{
if ( ! sQuickfileView ) {
HT_Notification notifyStruct = CreateNotificationStruct();
HT_Pane quickfilePane = HT_NewQuickFilePane(notifyStruct);
sQuickfileView = HT_GetSelectedView(quickfilePane);
}
} // InitQuickfileView
void
CBookmarksAttachment :: HandleNotification( HT_Notification /* notifyStruct*/,
HT_Resource node, HT_Event event)
{
switch (event) {
case HT_EVENT_NODE_ADDED:
case HT_EVENT_VIEW_REFRESH:
// only update menu if the quickfile view changes
if ( HT_GetView(node) == sQuickfileView ) {
sInvalidMenu = true;
UpdateMenu();
}
break;
case HT_EVENT_NODE_VPROP_CHANGED:
// optimization: only update when the name column changes
break;
case HT_EVENT_NODE_DELETED_DATA:
case HT_EVENT_NODE_DELETED_NODATA:
// free FE data, but don't update the menu yet (HT not in good state)
break;
} // case of which event
} // HandleNotification
// Processes:
//
void CBookmarksAttachment::ExecuteSelf( MessageT inMessage, void* ioParam )
{
mExecuteHost = FALSE;
switch ( inMessage )
{
CNetscapeWindow *bookmarkableWindow = nil;
case msg_CommandStatus:
{
SCommandStatus* status = (SCommandStatus*)ioParam;
switch ( status->command )
{
default:
if (CFrontApp::GetApplication()->HasBookmarksMenu())
{
if ( status->command >= BOOKMARKS_MENU_BASE && status->command <= BOOKMARKS_MENU_BASE_LAST )
{
*(status->enabled) = TRUE;
*(status->usesMark) = FALSE;
return;
}
}
break;
}
}
break;
default:
{
if (CFrontApp::GetApplication()->HasBookmarksMenu())
{
if ( inMessage >= BOOKMARKS_MENU_BASE && inMessage <= BOOKMARKS_MENU_BASE_LAST )
{
Uint32 index = inMessage - BOOKMARKS_MENU_BASE;
char* url = HT_GetNodeURL( HT_GetNthItem(sQuickfileView, index) );
CFrontApp::DoGetURL ( url );
return;
}
}
}
break;
}
mExecuteHost = TRUE; // Let application handle it
}
void CBookmarksAttachment::AddToBookmarks( const char* url, const CStr255& title )
{
HT_Resource topNode = HT_TopNode ( sQuickfileView );
HT_AddBookmark ( const_cast<char*>(url), title );
}
LMenu *CBookmarksAttachment::GetMenu()
{
if (!sMenu)
{
sMenu = new LMenu(cBookmarksMenuID);
if (sMenu)
{
MenuHandle macMenu = sMenu->GetMacMenuH();
if (macMenu)
UMenuUtils::ConvertToIconMenu(macMenu, 15312);
}
}
return sMenu;
}
void CBookmarksAttachment::UpdateMenu()
{
if (CFrontApp::GetApplication()->HasBookmarksMenu())
{
if (!sInvalidMenu || !GetMenu() || !LMenuBar::GetCurrentMenuBar() )
return;
int i;
// ¥ delete all the dynamically created menus
// ¥Êdelete all the hierarchical menus we have added from the menubar
for ( i = 1; i <= sMenusList.GetCount(); i++ )
{
LMenu* m;
sMenusList.FetchItemAt( i, &m );
if ( m )
LMenuBar::GetCurrentMenuBar()->RemoveMenu( m );
delete m;
}
// ¥ delete all the menu items after the line in Bookmark menu
MenuHandle menu = sMenu->GetMacMenuH();
if ( menu )
{
int howMany = ::CountMItems( menu );
for ( i = howMany; i > PERM_BOOKMARK_ITEMS; i-- )
sMenu->RemoveItem( i );
}
sMenusList.RemoveItemsAt( sMenusList.GetCount(), 1 );
// ¥ walk through the list, and let the submenus be inserted recursively
int nextMenuID = cBookmarksFirstHierMenuID;
FillMenuFromList( HT_TopNode(sQuickfileView), sMenu, nextMenuID, PERM_BOOKMARK_ITEMS );
sInvalidMenu = false;
}
}
// ¥Êrecursively create submenus, given a list ptr
// returns NULL if the menu cannot be created
// it creates submenus recursively
void CBookmarksAttachment::FillMenuFromList(
HT_Resource top,
LMenu* newMenu,
int& nextMenuID, // next menu to create
int whichItem ) // id of the first item to insert
{
if (CFrontApp::GetApplication()->HasBookmarksMenu())
{
Try_
{
ThrowIfNil_( newMenu );
MenuHandle mHand = newMenu->GetMacMenuH();
ThrowIfNil_( mHand );
// ¥Êremove all the extra items if they exist
long removeThese = ::CountMItems( mHand ) - whichItem;
for ( long i = 1; i < removeThese; i++ )
newMenu->RemoveItem( whichItem );
MenuHandle theMacMenu = newMenu->GetMacMenuH();
// Open up the container and get an iterator on its contents (we have to open it before
// we can see anything inside it). If the cursor is null, it is probably because the container
// is locked so just put up a leaf item (disabled, of course) and bail.
HT_SetOpenState ( top, PR_TRUE );
HT_Cursor cursor = HT_NewCursor( top );
if ( !cursor ) {
whichItem = UMenuUtils::InsertMenuItem(theMacMenu, "\pLocked", whichItem);
newMenu->SetCommand(whichItem, 0);
return;
}
HT_Resource currNode = HT_GetNextItem(cursor);
while ( currNode )
{
if ( HT_IsSeparator(currNode) )
newMenu->InsertCommand( "\p-", cmd_Nothing, whichItem++ );
else if ( ! HT_IsContainer(currNode) )
{
// ¥ should really convert this to menu chars
CStr255 urlName( HT_GetNodeName(currNode) );
CreateMenuString( urlName );
whichItem = UMenuUtils::InsertMenuItem(theMacMenu, urlName, whichItem); // returns actual insert loc
newMenu->SetCommand(whichItem, BOOKMARKS_MENU_BASE + HT_GetNodeIndex(sQuickfileView, currNode) );
}
else
{
CStr255 headerName( HT_GetNodeName(currNode) );
CreateMenuString( headerName );
whichItem = UMenuUtils::InsertMenuItem(theMacMenu, headerName, whichItem); // returns actual insert loc
newMenu->SetCommand(whichItem, cmd_BookmarkHierItem);
// ¥Êdo we have space to create more?
if ( nextMenuID <= cBookmarksLastHierMenuID)
{
LMenu* subMenu = (LMenuBar::GetCurrentMenuBar())->FetchMenu( nextMenuID );
if ( !subMenu )
{
StringHandle menuStringH = GetString( NEW_RESID );
Assert_(menuStringH);
if (menuStringH)
{
StHandleLocker locker((Handle)menuStringH);
subMenu = new LMenu( nextMenuID,
(unsigned char *)*menuStringH );
LMenuBar::GetCurrentMenuBar()->InstallMenu( subMenu, hierMenu );
}
}
else
SysBeep( 1 );
nextMenuID++;
// Skip the "Apple" menu or we're in deep donuts.
if (nextMenuID == MENU_Apple)
nextMenuID++;
if ( subMenu )
{
sMenusList.InsertItemsAt( 1, LArray::index_Last, &subMenu );
// ¥Êmake item hierarchical
::SetItemCmd( mHand, whichItem, hMenuCmd );
::SetItemMark( mHand, whichItem, subMenu->GetMenuID() );
if ( currNode )
FillMenuFromList( currNode, subMenu, nextMenuID, 0 );
}
}
}
currNode = HT_GetNextItem ( cursor );
} // while
}
Catch_( inErr )
{
}
EndCatch_
}
}
void CBookmarksAttachment::RemoveMenus()
{
if (CFrontApp::GetApplication()->HasBookmarksMenu())
{
if (sMenu)
{
LMenuBar *currentMenuBar = LMenuBar::GetCurrentMenuBar();
if (currentMenuBar)
{
currentMenuBar->RemoveMenu(sMenu);
for (ArrayIndexT index = 1; index <= sMenusList.GetCount(); ++index)
{
LMenu *menu;
sMenusList.FetchItemAt(index, &menu);
if (menu)
currentMenuBar->RemoveMenu(menu);
}
}
}
}
}
void CBookmarksAttachment::InstallMenus()
{
if (CFrontApp::GetApplication()->HasBookmarksMenu())
{
if (GetMenu())
{
LMenuBar *currentMenuBar = LMenuBar::GetCurrentMenuBar();
if (currentMenuBar)
{
for (ArrayIndexT index = sMenusList.GetCount(); index > 0; --index)
{
LMenu *menu;
sMenusList.FetchItemAt(index, &menu);
if (menu)
{
StValueChanger<EDebugAction> okayToFail(gDebugThrow, debugAction_Nothing);
currentMenuBar->InstallMenu(menu, hierMenu);
}
}
StValueChanger<EDebugAction> okayToFail(gDebugThrow, debugAction_Nothing);
currentMenuBar->InstallMenu(sMenu, InstallMenu_AtEnd);
LMenu *directoryMenu = currentMenuBar->FetchMenu(cDirectoryMenuID);
if (directoryMenu)
{
CFrontApp::BuildConfigurableMenu( directoryMenu->GetMacMenuH(), "menu.places.item" );
for (short index2 = CountMItems(directoryMenu->GetMacMenuH()); index2 > 0; --index2)
directoryMenu->SetCommand(index2, DIR_MENU_BASE + index2 - 1);
}
}
}
}
}

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) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
// Handle creating and maintaining the top-level bookmarks menu. It pulls the info
// out of the RDF container the user designates as their "quickfile menu" and listens
// to the messages from RDF to update it.
#pragma once
#ifndef CBOOKMARKSATTACHMENT_H_
#define CBOOKMARKSATTACHMENT_H_
#include "CRDFNotificationHandler.h"
#include "PascalString.h"
#include <LAttachment.h>
#include <LMenu.h>
#include <LArray.h>
/***********************************************************************************
* CBookmarksAttachment
* Processes bookmark menu commands -- should be attached to application
***********************************************************************************/
class CBookmarksAttachment: public LAttachment, public CRDFNotificationHandler
{
public:
// ¥¥ constructors
CBookmarksAttachment();
// ¥¥Êevents
virtual void ExecuteSelf( MessageT inMessage, void* ioParam );
// static void AddToBookmarks( BM_Entry* newBookmark );
static void AddToBookmarks( const char* url, const CStr255& title );
static LMenu* GetMenu();
static void InvalidateMenu() { sInvalidMenu = true; }
static void UpdateMenu();
static void RemoveMenus();
static void InstallMenus();
void InitQuickfileView ( ) ;
protected:
static void FillMenuFromList( HT_Resource top, LMenu* newMenu, int& nextMenuID, int whichItem );
virtual void HandleNotification( HT_Notification notifyStruct, HT_Resource node, HT_Event event);
static LMenu* sMenu;
static Boolean sInvalidMenu;
static LArray sMenusList;
static HT_View sQuickfileView; // called quickfile because of HT API
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,485 @@
/* -*- 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.
*/
// CBrowserContext.h
#pragma once
#include <LBroadcaster.h>
#include <LSharable.h>
#include "CNSContext.h"
#include "structs.h"
#include "ctxtfunc.h"
#include "cstring.h"
class CHTMLView;
class CSharableCompositor;
const MessageT msg_SecurityState = 'SECS'; // ESecurityState
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
//
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
class CBrowserContext : public CNSContext
{
friend class CNSContextCallbacks;
friend class CPlainTextConversionContext;
public:
// history navigation
// these are special indices for LoadHistoryEntry
enum {
index_Reload = -2,
index_GoBack = -1,
index_GoForward = 0
};
CBrowserContext();
CBrowserContext(MWContextType inType);
CBrowserContext(const CBrowserContext& inOriginal);
virtual ~CBrowserContext();
virtual void NoMoreUsers(void);
operator MWContext*();
operator MWContext&();
virtual void SetCurrentView(CHTMLView* inView);
virtual CBrowserContext* GetTopContext();
virtual Boolean HasColorSpace(void) const;
virtual Boolean HasGridParent(void) const;
virtual Boolean HasFullPagePlugin(void) const;
virtual void SetLoadImagesOverride(Boolean inOverride);
virtual Boolean IsLoadImagesOverride(void) const;
virtual void SetDelayImages(Boolean inDelay);
virtual Boolean IsImageLoadingDelayed(void) const;
virtual Boolean IsRestrictedTarget(void) const;
virtual void SetRestrictedTarget(Boolean inIsRestricted);
virtual Boolean IsRootDocInfoContext();
virtual Boolean IsViewSourceContext();
virtual Boolean IsSpecialBrowserContext();
virtual Boolean SupportsPageServices();
// FIX ME!!! ACCESSOR for unique ID
// LAYERS / COMPOSITOR
virtual Boolean HasCompositor(void) const;
virtual CL_Compositor* GetCompositor(void) const;
virtual void SetCompositor(
CSharableCompositor* inCompositor);
virtual PRBool HandleLayerEvent(
CL_Layer* inLayer,
CL_Event* inEvent);
virtual PRBool HandleEmbedEvent(
LO_EmbedStruct* inEmbed,
CL_Event* inEvent);
// HISTORY
virtual void RememberHistoryPosition(
Int32 inX,
Int32 inY);
virtual void InitHistoryFromContext( CBrowserContext *parentContext);
// Image Observer
virtual Boolean IsContextLooping();
Boolean IsMochaLoadingImages() { return mMochaImagesLoading; }
void SetImagesLoading(Boolean inValue);
void SetImagesLooping(Boolean inValue);
void SetImagesDelayed(Boolean inValue);
void SetMochaImagesLoading(Boolean inValue);
void SetMochaImagesLooping(Boolean inValue);
void SetMochaImagesDelayed(Boolean inValue);
protected:
// we don't need to expose these
virtual History_entry* GetNextHistoryEntry(void);
virtual History_entry* GetPreviousHistoryEntry(void);
virtual Boolean IsContextLoopingRecurse();
public:
virtual Boolean CanGoForward(void);
virtual Boolean CanGoBack(void);
virtual Boolean HasGridChildren(void);
virtual Boolean IsGridChild(void);
virtual Boolean IsGridCell();
virtual void GoForwardOneHost();
virtual void GoBackOneHost();
virtual void GoForward(void);
virtual void GoBack(void);
virtual void LoadHistoryEntry( // one-based
Int32 inIndex,
Boolean inSuperReload = false);
virtual Boolean GoForwardInGrid(void);
virtual Boolean GoBackInGrid(void);
/*
// URL MANIPULATION
virtual cstring GetCurrentURL(void);
virtual void SwitchLoadURL(
URL_Struct* inURL,
FO_Present_Types inOutputFormat);
virtual void ImmediateLoadURL(
URL_Struct* inURL,
FO_Present_Types inOutputFormat);
*/
// REPAGINTAION
virtual void Repaginate(NET_ReloadMethod repage = NET_RESIZE_RELOAD);
virtual Boolean IsRepaginating(void) const;
virtual Boolean IsRepagintaitonPending(void) const;
// FRAME MANAGEMENT
virtual MWContext* CreateGridContext(
void* inHistList,
void* inHistEntry,
Int32 inX,
Int32 inY,
Int32 inWidth,
Int32 inHeight,
char* inURLString,
char* inWindowTarget,
Int8 inScrollMode,
NET_ReloadMethod inForceReload,
Bool inNoEdge);
virtual void* DisposeGridContext(
XP_Bool inSaveHistory);
virtual void DisposeGridChild(
CBrowserContext* inChildContext);
virtual void RestructureGridContext(
Int32 inX,
Int32 inY,
Int32 inWidth,
Int32 inHeight);
virtual void GetFullGridSize(
Int32& outWidth,
Int32& outHeight);
virtual void ReloadGridFromHistory(
void* inHistEntry,
NET_ReloadMethod inReload);
virtual Int32 CountGridChildren(void) const;
// save dialog for editor--Paul will fix some time
virtual CSaveProgress* GetSaveDialog() { return fSaveDialog; };
virtual void SetSaveDialog( CSaveProgress* theDialog ) { fSaveDialog = theDialog; };
// override for JavaScript foolishness
virtual void Alert(
const char* inAlertText);
virtual XP_Bool Confirm(
const char* inMessage);
protected:
CSaveProgress* fSaveDialog;
void ConstructJSDialogTitle(LStr255& outTitle);
// CALLBACK IMPLEMENTATION
// FIX ME!!! this needs to become an apple event
// virtual MWContext* CreateNewDocWindow(
// URL_Struct* inURL);
virtual void LayoutNewDocument(
URL_Struct* inURL,
Int32* inWidth,
Int32* inHeight,
Int32* inMarginWidth,
Int32* inMarginHeight);
virtual void SetDocTitle(
char* inTitle);
virtual void FinishedLayout(void);
virtual int GetTextInfo(
LO_TextStruct* inText,
LO_TextInfo* inTextInfo);
virtual int MeasureText(
LO_TextStruct* inText,
short* outCharLocs);
virtual void GetEmbedSize(
LO_EmbedStruct* inEmbedStruct,
NET_ReloadMethod inReloadMethod);
virtual void GetJavaAppSize(
LO_JavaAppStruct* inJavaAppStruct,
NET_ReloadMethod inReloadMethod);
virtual void GetFormElementInfo(
LO_FormElementStruct* inElement);
virtual void GetFormElementValue(
LO_FormElementStruct* inElement,
XP_Bool inHide);
virtual void ResetFormElement(
LO_FormElementStruct* inElement);
virtual void SetFormElementToggle(
LO_FormElementStruct* inElement,
XP_Bool inToggle);
virtual void FreeEmbedElement(
LO_EmbedStruct* inEmbedStruct);
virtual void CreateEmbedWindow(
NPEmbeddedApp* inEmbeddedApp);
virtual void SaveEmbedWindow(
NPEmbeddedApp* inEmbeddedApp);
virtual void RestoreEmbedWindow(
NPEmbeddedApp* inEmbeddedApp);
virtual void DestroyEmbedWindow(
NPEmbeddedApp* inEmbeddedApp);
virtual void FreeJavaAppElement(
LJAppletData* inAppletData);
virtual void HideJavaAppElement(
LJAppletData* inAppletData);
virtual void FreeEdgeElement(
LO_EdgeStruct* inEdgeStruct);
virtual void FormTextIsSubmit(
LO_FormElementStruct* inElement);
virtual void DisplaySubtext(
int inLocation,
LO_TextStruct* inText,
Int32 inStartPos,
Int32 inEndPos,
XP_Bool inNeedBG);
virtual void DisplayText(
int inLocation,
LO_TextStruct* inText,
XP_Bool inNeedBG);
virtual void DisplayEmbed(
int inLocation,
LO_EmbedStruct* inEmbedStruct);
virtual void DisplayJavaApp(
int inLocation,
LO_JavaAppStruct* inJavaAppStruct);
virtual void DisplayEdge (
int inLocation,
LO_EdgeStruct* inEdgeStruct);
virtual void DisplayTable(
int inLocation,
LO_TableStruct* inTableStruct);
virtual void DisplayCell(
int inLocation,
LO_CellStruct* inCellStruct);
virtual void InvalidateEntireTableOrCell(
LO_Element* inElement);
virtual void DisplayAddRowOrColBorder(
XP_Rect* inRect,
XP_Bool inDoErase);
virtual void DisplaySubDoc(
int inLocation,
LO_SubDocStruct* inSubdocStruct);
virtual void DisplayLineFeed(
int inLocation,
LO_LinefeedStruct* inLinefeedStruct,
XP_Bool inNeedBG);
virtual void DisplayHR(
int inLocation,
LO_HorizRuleStruct* inRuleStruct);
virtual void DisplayBullet(
int inLocation,
LO_BullettStruct* inBullettStruct);
virtual void DisplayFormElement(
int inLocation,
LO_FormElementStruct* inFormElement);
virtual void DisplayBorder(
int inLocation,
int inX,
int inY,
int inWidth,
int inHeight,
int inBW,
LO_Color* inColor,
LO_LineStyle inStyle);
virtual void UpdateEnableStates();
virtual void DisplayFeedback(
int inLocation,
LO_Element_struct *inElement);
virtual void ClearView(
int inWhich);
virtual void SetDocDimension(
int inLocation,
Int32 inWidth,
Int32 inLength);
virtual void SetDocPosition(
int inLocation,
Int32 inX,
Int32 inY);
virtual void GetDocPosition(
int inLocation,
Int32* outX,
Int32* outY);
virtual void SetBackgroundColor(
Uint8 inRed,
Uint8 inGreen,
Uint8 inBlue);
virtual void AllConnectionsComplete(void);
virtual void EraseBackground(
int inLocation,
Int32 inX,
Int32 inY,
Uint32 inWidth,
Uint32 inHieght,
LO_Color* inColor);
virtual void SetDrawable(
CL_Drawable* inDrawable);
virtual void GetTextFrame(
LO_TextStruct* inTextStruct,
Int32 inStartPos,
Int32 inEndPos,
XP_Rect* outFrame);
virtual void GetDefaultBackgroundColor(
LO_Color* outColor) const;
virtual void DrawJavaApp(
int inLocation,
LO_JavaAppStruct* inJavaAppStruct);
virtual void HandleClippingView(
struct LJAppletData *appletD,
int x,
int y,
int width,
int height);
virtual char* Prompt(
const char* inMessage,
const char* inDefaultText);
#if 0
Int32 GetTransactionID() { return fProgressID; }
Int32 GetContextUniqueID() { return fWindowID; }
// Window ID. Used to identify the context
static Int32 sWindowID; // Unique ID, incremented for each context
Int32 fWindowID; // ID of this window
private:
#endif
Boolean mIsRepaginating;
Boolean mIsRepaginationPending;
Boolean mLoadImagesOverride;
Boolean mDelayImages;
CSharableCompositor* mCompositor;
IL_GroupContext* mImageGroupContext;
Boolean mImagesLoading;
Boolean mImagesLooping;
Boolean mImagesDelayed;
Boolean mMochaImagesLoading;
Boolean mMochaImagesLooping;
Boolean mMochaImagesDelayed;
Boolean mInNoMoreUsers;
}; // class CBrowserContext
inline CBrowserContext::operator MWContext*()
{ return &mContext; };
inline CBrowserContext::operator MWContext&()
{ return mContext; };
inline CBrowserContext* ExtractBrowserContext(MWContext* inContext)
{ return dynamic_cast<CBrowserContext*>(inContext->fe.newContext); }
class CSharableCompositor : public LSharable
{
public:
CSharableCompositor(CL_Compositor* c = nil) : mCompositor(c) {}
void SetCompositor(CL_Compositor* c) { mCompositor = c; }
virtual ~CSharableCompositor();
operator CL_Compositor*() { return mCompositor; }
CL_Compositor* mCompositor;
}; // class CSharableCompositor

View File

@@ -0,0 +1,157 @@
/* -*- 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.
*/
// CBrowserDragTask.cp
#include "CBrowserDragTask.h"
#include "resgui.h"
// ---------------------------------------------------------------------------
// ¥ CBrowserDragTask
// ---------------------------------------------------------------------------
CBrowserDragTask::CBrowserDragTask(
const EventRecord& inEventRecord)
: super(inEventRecord)
{
}
// ---------------------------------------------------------------------------
// ¥ ~CBrowserDragTask
// ---------------------------------------------------------------------------
CBrowserDragTask::~CBrowserDragTask()
{
}
//
// AddFlavorBookmark
//
// This flavor is currently used by the Proxy Icon and the Personal Toolbar
// to shuttle around url/title information. The data format is plain text in
// the form of URL<cr>Title.
//
// This flavor may or may not contain data. The proxy icon, for example, would want to
// include the data so that if it is dropped in the NavCenter, the NC could
// determine if the drop was allowable based on the URL.
//
// NOTE: THIS FLAVOR WILL NOT BE USED BY THE PERSONAL TOOLBAR IN THE FUTURE
// AND WILL ONLY BE USED BY THE PROXY ICON. AS A RESULT, IT WILL BE MOVED
// INTO CProxyDragTask.
//
void
CBrowserDragTask::AddFlavorBookmark(ItemReference inItemRef, const char* inData)
{
OSErr theErr = ::AddDragItemFlavor(
mDragRef,
inItemRef,
emBookmarkDrag,
inData,
inData ? strlen(inData) + 1 : 0,
flavorSenderTranslated | flavorSenderOnly);
ThrowIfOSErr_(theErr);
}
//
// AddFlavorBookmarkFile
//
// This flavor is used for creating a bookmark file in the Finder instead of a clipping when
// icons are dragged to the desktop.
//
// The data will be fulfilled in a DoSendData proc.
//
void
CBrowserDragTask::AddFlavorBookmarkFile(ItemReference inItemRef)
{
// Promise a file of type emBookmarkFile
PromiseHFSFlavor promise;
promise.fileType = emBookmarkFile;
promise.fileCreator = emSignature;
promise.fdFlags = 0;
promise.promisedFlavor = emBookmarkFileDrag;
// Promise to create a file for the emBookmark flavor, where the actual
// FSSpec is promised in the emBookmark flavor below
OSErr theErr = ::AddDragItemFlavor(
mDragRef,
inItemRef,
flavorTypePromiseHFS,
&promise,
sizeof(PromiseHFSFlavor),
0);
ThrowIfOSErr_(theErr);
theErr = ::AddDragItemFlavor(
mDragRef,
inItemRef,
emBookmarkFileDrag,
nil,
0,
flavorNotSaved | flavorSenderTranslated);
ThrowIfOSErr_(theErr);
}
//
// AddFlavorURL
//
// This flavor is used to communicate the current URL with other applications, such
// as text editors, etc. It is basically the 'TEXT' flavor.
//
// No data is sent with this flavor, relying on a DoDragSendData() to get it out later.
// This prevents us from running into an odd problem where the CTheadView class wants to
// interpret the data as something that it isn't. This won't happen when no data is sent.
//
void
CBrowserDragTask::AddFlavorURL(ItemReference inItemRef)
{
// TEXT flavor (drag an URL within Netscape). Set flavorSenderTranslated
// so that the Finder *won't* try to put this in a clipping file.
// We'd rather save the file itself.
OSErr theErr = ::AddDragItemFlavor(
mDragRef,
inItemRef,
'TEXT',
nil,
0,
flavorSenderTranslated);
ThrowIfOSErr_(theErr);
}
// ---------------------------------------------------------------------------
// ¥ AddFlavors
// ---------------------------------------------------------------------------
void
CBrowserDragTask::AddFlavors( DragReference inDragRef )
{
// NOTE: I'm passing |this| as the item ref because that's the way it was in the past
// and i don't want to break anything.
AddFlavorBookmark(static_cast<ItemReference>(this));
AddFlavorBookmarkFile(static_cast<ItemReference>(this));
AddFlavorURL(static_cast<ItemReference>(this));
}

View File

@@ -0,0 +1,49 @@
/* -*- 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.
*/
// CBrowserDragTask.h
#ifndef CBrowserDragTask_H
#define CBrowserDragTask_H
#pragma once
// Includes
#include <LDragTask.h>
// Class declaration
class CBrowserDragTask : public LDragTask
{
public:
typedef LDragTask super;
CBrowserDragTask( const EventRecord& inEventRecord );
virtual ~CBrowserDragTask();
protected:
void AddFlavorBookmark(ItemReference inItemRef, const char* inData = nil);
void AddFlavorBookmarkFile(ItemReference inItemRef);
void AddFlavorURL(ItemReference inItemRef);
virtual void AddFlavors(DragReference inDragRef);
};
#endif

View File

@@ -0,0 +1,351 @@
/* -*- 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 "CExpandoDivider.h"
#include "prtypes.h"
#include "macutil.h"
#include "CDragBarDockControl.h"
#define kTwistieID 'Twst'
#define kCaptionID 'TwCp'
const Int16 kTwistiePixelDifference = 3; // difference in height (collapsed minus expanded).
//======================================
// CExpandoListener
//======================================
//-----------------------------------
void CExpandoListener::ListenToMessage(MessageT inMessage, void *ioParam)
//-----------------------------------
{
switch (inMessage)
{
case msg_TwistieMessage:
{
Int32 value = *(Int32*)ioParam;
SetExpandState((ExpandStateT)value);
break;
}
}
} // CExpandoListener::ListenToMessage
//======================================
// CExpandable
//======================================
//-----------------------------------
CExpandable::CExpandable(CExpansionData* closedState, CExpansionData* openState)
//-----------------------------------
: mExpandState(closed_state)
{
mStates[0] = closedState;
mStates[1] = openState;
}
//-----------------------------------
void CExpandable::StoreCurrentDimensions()
//-----------------------------------
{
StoreDimensions(*(mStates[GetExpandState()]));
}
//-----------------------------------
void CExpandable::RecallCurrentDimensions()
//-----------------------------------
{
RecallDimensions(*(mStates[GetExpandState()]));
}
//-----------------------------------
void CExpandable::RecallOtherDimensions()
//-----------------------------------
{
RecallDimensions(*mStates[1 - GetExpandState()]);
}
//-----------------------------------
void CExpandable::ReadStatus(LStream* inStream)
//-----------------------------------
{
if (!inStream) return;
*inStream >> mExpandState;
mStates[0]->ReadStatus(inStream);
mStates[1]->ReadStatus(inStream);
// Don't do anything with them here.
} // CExpandable::ReadStatus
//-----------------------------------
void CExpandable::WriteStatus(LStream* inStream)
//-----------------------------------
{
StoreCurrentDimensions();
if (!inStream) return;
*inStream << mExpandState;
mStates[0]->WriteStatus(inStream);
mStates[1]->WriteStatus(inStream);
} // CExpandable::ReadStatus
const Int16 kDefaultTopFrameHeight = 110;
// FIXME. A preference? This value shows 5 full message lines in geneva 9.
//-----------------------------------
inline CDividerData::CDividerData()
//-----------------------------------
: mDividerPosition(kDefaultTopFrameHeight)
{
} // CDividerData::CDividerData
//-----------------------------------
void CDividerData::ReadStatus(LStream* inStream)
//-----------------------------------
{
if (!inStream) return;
*inStream >> mDividerPosition;
} // CDividerData::ReadStatus
//-----------------------------------
void CDividerData::WriteStatus(LStream* inStream)
//-----------------------------------
{
if (!inStream) return;
*inStream << mDividerPosition;
} // CDividerData::WriteStatus
//======================================
// CExpandoDivider
//======================================
//-----------------------------------
CExpandoDivider::CExpandoDivider(LStream* inStream)
//-----------------------------------
: Inherited( inStream )
, CExpandable(&mClosedData, &mOpenData)
{
} // CExpandoDivider::CExpandoDivider
//-----------------------------------
CExpandoDivider::~CExpandoDivider()
//-----------------------------------
{
}
//-----------------------------------
void CExpandoDivider::FinishCreateSelf()
//-----------------------------------
{
Inherited::FinishCreateSelf();
mTwistie = FindPaneByID(kTwistieID);
mCaption = FindPaneByID(kCaptionID);
// CExpandable::InitializeStates();
StoreCurrentDimensions(); // get the closed state from PPOb
// Base class calls SyncFrameBinding which sets the "open" behavior. Undo this, then.
SetStickToBottom(true);
// Record the height of the status bar, so that we can preserve it on expansion.
LWindow* window = LWindow::FetchWindowObject(GetMacPort());
Rect windowRect;
window->CalcPortFrameRect(windowRect); // relative is fine
Rect expandoRect;
this->CalcPortFrameRect(expandoRect);
mDistanceFromWindowBottom = windowRect.bottom - expandoRect.bottom;
Assert_(mDistanceFromWindowBottom >= 0);
mDividerDistanceFromWindowBottom
= windowRect.bottom - (expandoRect.top + GetDividerPosition());
} // CExpandoDivider::FinishCreateSelf
//-----------------------------------
void CExpandoDivider::StoreDimensions(CExpansionData& outState)
//-----------------------------------
{
((CDividerData&)outState).mDividerPosition = GetDividerPosition();
} // CExpandoDivider::StoreDimensions
//-----------------------------------
void CExpandoDivider::RecallDimensions(const CExpansionData& inState)
//-----------------------------------
{
SInt32 dividerPosition = GetDividerPosition();
Int16 dividerDelta = ((CDividerData&)inState).mDividerPosition - dividerPosition;
this->ChangeDividerPosition(dividerDelta);
} // CExpandoDivider::RecallDimensions
//-----------------------------------
void CExpandoDivider::SetStickToBottom(LPane* inPane, Boolean inStick)
//-----------------------------------
{
SBooleanRect bindings;
inPane->GetFrameBinding(bindings);
bindings.bottom = inStick;
inPane->SetFrameBinding(bindings);
} // CExpandoDivider::SetStickToBottom
//-----------------------------------
void CExpandoDivider::SetStickToBottom(Boolean inStick)
//-----------------------------------
{
SetStickToBottom(mTwistie, inStick);
SetStickToBottom(mCaption, inStick);
SetStickToBottom(fFirstView, inStick);
SetStickToBottom(fSecondView, true);
} // CExpandoDivider::SetStickToBottom
//-----------------------------------
void CExpandoDivider::ClickSelf(const SMouseDownEvent& inMouseDown)
//-----------------------------------
{
if (GetExpandState() == open_state) Inherited::ClickSelf(inMouseDown);
}
//-----------------------------------
void CExpandoDivider::AdjustCursorSelf(Point inPortPt, const EventRecord& inMacEvent)
//-----------------------------------
{
if (GetExpandState() == open_state) Inherited::AdjustCursorSelf(inPortPt, inMacEvent);
}
//-----------------------------------
void CExpandoDivider::ChangeTwistiePosition(Int16 delta)
// Move the twistie and caption
//-----------------------------------
{
mTwistie->MoveBy(0, delta, FALSE);
mCaption->MoveBy(0, delta, FALSE);
} // CExpandoDivider::ChangeTwistiePosition
//-----------------------------------
void CExpandoDivider::ChangeDividerPosition(Int16 delta)
//-----------------------------------
{
if (mExpandState == open_state && delta > 0)
{
// If the user drags the divider to the bottom, it should close the twistie.
Int32 dividerPos = this->GetDividerPosition();
Int32 newPos = dividerPos + delta;
Rect secondFrame;
GetSubpaneRect(this, fSecondView, secondFrame);
if (newPos > secondFrame.bottom - 50)
{
mTwistie->SetValue(closed_state);
return;
}
}
Inherited::ChangeDividerPosition(delta);
ChangeTwistiePosition(delta);
} // CExpandoDivider::ChangeDividerPosition
//-----------------------------------
void CExpandoDivider::ResizeFrameBy(
Int16 inWidthDelta,
Int16 inHeightDelta,
Boolean inRefresh)
//-----------------------------------
{
Inherited::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
// Unless we do this, there's no way to enforce the rule that the second pane's TOP
// sticks to the bottom when in the collapsed state.
if (mExpandState == closed_state && fFirstView && fSecondView)
{
SPoint32 loc1, loc2;
SDimension16 siz1, siz2;
fFirstView->GetFrameLocation(loc1);
fFirstView->GetFrameSize(siz1);
fSecondView->GetFrameLocation(loc2);
fSecondView->GetFrameSize(siz2);
Int32 secondViewOffset = siz1.height + loc1.v + mDivSize - loc2.v;
if (secondViewOffset)
{
fSecondView->MoveBy(0, secondViewOffset, false);
fSecondView->ResizeFrameBy(0, -secondViewOffset, false);
}
}
} // CExpandoDivider::ResizeFrameBy
//-----------------------------------
void CExpandoDivider::SetExpandState(ExpandStateT inExpanded)
//-----------------------------------
{
#if 0
// We now assume that the my view's bottom is flush with the bottom of the
// second subview.
SPoint32 locMe, loc2;
SDimension16 sizMe, siz2;
GetFrameSize(sizMe);
GetFrameLocation(locMe);
fSecondView->GetFrameLocation(loc2);
fSecondView->GetFrameSize(siz2);
Assert_(loc2.v + siz2.height == locMe.v + sizMe.height);
#endif // DEBUG
LWindow* win = LWindow::FetchWindowObject(GetMacPort());
Rect winRect;
win->CalcPortFrameRect(winRect); // relative is fine
const Int16 statusBarHeight = this->GetCorrectDistanceFromBottom();
const Int16 dividerDistanceFromBottom
= this->GetCorrectDividerDistanceFromBottom();
Rect expandoRect;
this->CalcPortFrameRect(expandoRect);
if (mExpandState != inExpanded)
StoreCurrentDimensions();
mExpandState = inExpanded;
if (inExpanded)
{
// When expanded, topview, twistie and caption do not stick to the bottom.
mCaption->Hide();
SetStickToBottom(false);
SyncFrameBindings();
// The expanded twistie is not as high as the collapsed one, and the following
// adjustment allows us to have a narrower divider bar.
ChangeTwistiePosition(- kTwistiePixelDifference);
// Now expand. The divider will pull the frame up.
RecallCurrentDimensions();
fSecondView->Show();
}
else
{
ChangeTwistiePosition(+ kTwistiePixelDifference);
fSecondView->Hide();
mCaption->Show();
RecallCurrentDimensions();
}
// The following is a kludge to fix cases where the bottom of Message view
// can disappear under the bottom of the window, or where the divider containing
// the twistie icon can be a one-inch thick grey area just over the bottom of the window.
short vertError = (winRect.bottom - statusBarHeight) - expandoRect.bottom;
if (vertError != 0)
{
this->ResizeFrameBy(0, vertError, false);
}
if (!inExpanded)
{
vertError = (winRect.bottom - (expandoRect.top + dividerDistanceFromBottom))
- this->GetDividerPosition();
if (vertError != 0)
this->ChangeDividerPosition(vertError);
// When collapsed, topview, twistie and caption stick to the bottom.
SetStickToBottom(true); //¥¥¥ this line is not part of the kludge
}
} // CExpandoDivider::SetExpandedState

View File

@@ -0,0 +1,136 @@
/* -*- 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.
*/
#pragma once
#include "divview.h"
//-----------------------------------
class CExpansionData
// persistent data about both states of a CExpandable.
//-----------------------------------
{
public:
virtual void ReadStatus(LStream* inStream) = 0;
virtual void WriteStatus(LStream* inStream) = 0;
}; // class CExpansionData
enum { closed_state = false, open_state = true };
typedef Boolean ExpandStateT;
//======================================
class CExpandable
//======================================
{
public:
virtual void ReadStatus(LStream* inStream);
virtual void WriteStatus(LStream* inStream);
ExpandStateT GetExpandState() const { return mExpandState; }
void NoteExpandState(ExpandStateT inExpanded) { mExpandState = inExpanded; }
protected:
virtual void SetExpandState(ExpandStateT inExpanded) = 0;
private:
virtual void StoreDimensions(CExpansionData& outState) = 0;
virtual void RecallDimensions(const CExpansionData& inState) = 0;
protected:
CExpandable(CExpansionData* closedState, CExpansionData* openState);
// clients that mix this class in should have two members that are
// CExpansionData, and pass the references in here.
protected:
void StoreCurrentDimensions();
void RecallCurrentDimensions();
void RecallOtherDimensions();
protected:
ExpandStateT mExpandState;
CExpansionData* mStates[2];
}; // class CExpandable
//======================================
class CExpandoListener : public LListener, public CExpandable
//======================================
{
public:
enum { msg_TwistieMessage = 'Twst' }; // Broadcast by twistie control
CExpandoListener(
CExpansionData* closedState, CExpansionData* openState)
: CExpandable(closedState, openState) {}
virtual void ListenToMessage(MessageT inMessage, void *ioParam);
// Listen to the twistie
}; // class CExpandoListener
//======================================
class CDividerData : public CExpansionData
//======================================
{
public:
CDividerData();
// default is set for the open state, because the closed state is in the PPOb.
// Overrides
virtual void ReadStatus(LStream* inStream);
virtual void WriteStatus(LStream* inStream);
// Data
SInt32 mDividerPosition;
}; // class CDividerData
//======================================
class CExpandoDivider : public LDividedView, public CExpandable
// This class acts like a divider between two panes, one above the other.
// In addition to the LDividedView behavior, it also has an "expando" twistie, that
// hides/shows the bottom pane.
//======================================
{
private:
typedef LDividedView Inherited;
public:
enum { class_ID = 'Expo' };
CExpandoDivider(LStream* inStream);
virtual ~CExpandoDivider();
// PowerPlant overrides
protected:
virtual void FinishCreateSelf();
virtual void ClickSelf(const SMouseDownEvent& inMouseDown);
virtual void AdjustCursorSelf(Point inPortPt, const EventRecord& inMacEvent);
public:
virtual void ResizeFrameBy(
Int16 inWidthDelta,
Int16 inHeightDelta,
Boolean inRefresh);
// CExpandable overrides
public:
virtual void SetExpandState(ExpandStateT inExpanded);
virtual void StoreDimensions(CExpansionData& outState);
virtual void RecallDimensions(const CExpansionData& inState);
// Special interfaces
public:
Int16 GetCorrectDistanceFromBottom() const { return mDistanceFromWindowBottom; }
Int16 GetCorrectDividerDistanceFromBottom() const
{ return mDividerDistanceFromWindowBottom; }
// Down to business:
protected:
virtual void ChangeDividerPosition(Int16 delta); // also changes the twistie+caption
virtual void ChangeTwistiePosition(Int16 delta); // only changes the twistie+caption
void SetStickToBottom(LPane* inPane, Boolean inStick);
void SetStickToBottom(Boolean inStick);
// Data:
protected:
Int16 mDistanceFromWindowBottom;
Int16 mDividerDistanceFromWindowBottom;
LPane *mTwistie, *mCaption;
CDividerData mClosedData, mOpenData;
}; // class CExpandoDivider

View File

@@ -0,0 +1,336 @@
/* -*- 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.
*/
/*
* macmocha.cp
* MacFE mocha hacks
*
*/
#include "CMochaHacks.h"
#include "lo_ele.h"
#include "fe_proto.h" // for FE_DestroyWindow
#include "proto.h" // 1997-03-02 mjc
#include "layers.h"
#include "macutil.h"
LO_Element* CMochaHacks::sMouseOverElement = NULL; // layout element the cursor is over
MWContext* CMochaHacks::sMouseOverElementContext = NULL; // context associated with sMouseOverElement
LO_AnchorData* CMochaHacks::sMouseOverMapArea = NULL; // AREA tag the cursor is over
// <where> is document-relative
void
CMochaHacks::SendOutOfElementEvent(MWContext * winContext, CL_Layer* layer, SPoint32 where) // add layer param 1997-03-02 mjc
{
Assert_(winContext);
try
{
if ( sMouseOverElement )
{
// ET_SendEvent now takes a JSEvent struct instead of an int type
JSEvent* event = XP_NEW_ZAP(JSEvent);
if (event)
{
// 97-06-21 pkc -- If we have an sMouseOverElementContext then use it
// instead of winContext
MWContext* theContext = sMouseOverElementContext ? sMouseOverElementContext : winContext;
event->type = EVENT_MOUSEOUT;
event->x = where.h;
event->y = where.v;
event->docx = event->x + CL_GetLayerXOrigin(layer);
event->docy = event->y + CL_GetLayerYOrigin(layer);
int32 x_offset, y_offset;
FE_GetWindowOffset(theContext, &x_offset, &y_offset);
event->screenx = event->docx + x_offset;
event->screeny = event->docy + y_offset;
event->layer_id = LO_GetIdFromLayer(theContext, layer);
ET_SendEvent( theContext, sMouseOverElement, event, NULL, NULL );
sMouseOverElement = NULL;
sMouseOverElementContext = NULL;
}
}
}
catch(...)
{
}
}
void
CMochaHacks::SendOutOfMapAreaEvent(MWContext * winContext, CL_Layer* layer, SPoint32 where) // add layer param 1997-03-02 mjc
{
Assert_(winContext);
try
{
if ( sMouseOverMapArea )
{
CMochaEventCallback * cb = new CMochaEventCallback; // Need it because of LO_AnchorData
cb->SendEvent( winContext, sMouseOverMapArea, EVENT_MOUSEOUT, layer, where );
sMouseOverMapArea = NULL;
}
}
catch(...)
{
}
}
//
// CMochaEventCallback
//
void
CMochaHacks::ResetMochaMouse()
{
sMouseOverElement = NULL;
sMouseOverMapArea = NULL;
}
// Returns mocha modifier bitset given mac modifiers.
uint32
CMochaHacks::MochaModifiers(const UInt16 inModifiers)
{
return ((inModifiers & shiftKey) ? EVENT_SHIFT_MASK : 0) |
((inModifiers & controlKey) ? EVENT_CONTROL_MASK : 0) |
((inModifiers & optionKey) ? EVENT_ALT_MASK : 0) |
((inModifiers & cmdKey) ? EVENT_META_MASK : 0);
}
// Returns mocha modifiers by reading the keyboard.
uint32
CMochaHacks::MochaModifiersFromKeyboard(void)
{
union
{
KeyMap asMap;
Byte asBytes[16];
};
::GetKeys(asMap);
return ((asBytes[kShiftKey >> 3] & (1 << (kShiftKey & 0x07))) ? EVENT_SHIFT_MASK : 0) |
((asBytes[kCtlKey >> 3] & (1 << (kCtlKey & 0x07))) ? EVENT_CONTROL_MASK : 0) |
((asBytes[kOptionKey >> 3] & (1 << (kOptionKey & 0x07))) ? EVENT_ALT_MASK : 0) |
((asBytes[kCommandKey >> 3] & (1 << (kCommandKey & 0x07))) ? EVENT_META_MASK : 0);
}
// Returns true if the window is a dependent of another.
// Parameters:
// inContext: the context for this window.
Boolean
CMochaHacks::IsDependent(MWContext* inContext)
{
return (inContext->js_parent != nil);
}
// Add a window as a dependent of another.
// Called in FE_MakeNewWindow.
// Parameters:
// inParent: the parent context.
// inChild: the context for this window which will be made a dependent of the parent.
void
CMochaHacks::AddDependent(MWContext* inParent, MWContext* inChild)
{
// inParent could be a grid context, but dependencies are between windows so find root context.
MWContext* theParentRoot = XP_GetNonGridContext(inParent);
if (theParentRoot != nil && inChild != nil)
{
if (theParentRoot->js_dependent_list == NULL)
theParentRoot->js_dependent_list = XP_ListNew();
if (theParentRoot->js_dependent_list != NULL)
{
XP_ListAddObject(theParentRoot->js_dependent_list, inChild);
inChild->js_parent = theParentRoot;
}
}
}
// Remove dependents of the window.
// Called in destructor for window.
// Parameters:
// inContext: the context for this window.
void
CMochaHacks::RemoveDependents(MWContext* inContext)
{
// FE_DestroyWindow makes this recursive; keep track of how many levels deep we are.
static int recursionLevel = 0;
++recursionLevel;
if (inContext->js_dependent_list)
{
MWContext *depContext;
// destroy windows which are dependent on this window
for (int i = 1; i <= XP_ListCount(inContext->js_dependent_list); i++)
{
depContext = (MWContext *)XP_ListGetObjectNum(inContext->js_dependent_list, i);
FE_DestroyWindow(depContext);
}
XP_ListDestroy(inContext->js_dependent_list);
inContext->js_dependent_list = NULL;
}
--recursionLevel;
// remove self from parent's dependent list but only if we're the window
// at the top of the chain (don't alter lists we're iterating over).
if (recursionLevel == 0 && inContext->js_parent != nil)
{
if (XP_ListCount(inContext->js_parent->js_dependent_list) == 1)
{
// if the last element in the list, destroy the list.
XP_ListDestroy(inContext->js_parent->js_dependent_list);
inContext->js_parent->js_dependent_list = NULL;
}
else XP_ListRemoveObject(inContext->js_parent->js_dependent_list, inContext);
}
}
// Send move event to mocha every time a window or pane is moved.
void
CMochaHacks::SendMoveEvent(MWContext* inContext, int32 inX, int32 inY)
{
JSEvent *event;
event = XP_NEW_ZAP(JSEvent);
if (event)
{
event->type = EVENT_MOVE;
event->x = inX;
event->y = inY;
}
ET_SendEvent(inContext, 0, event, 0, 0);
}
// Send the event specified, with no callback.
void
CMochaHacks::SendEvent(MWContext* inContext, int32 inType, LO_Element* inElement)
{
JSEvent *event;
event = XP_NEW_ZAP(JSEvent);
if (event)
{
event->type = inType;
ET_SendEvent(inContext, inElement, event, 0, 0);
}
}
//
// CMochaEventCallback
//
#ifdef DEBUG
static int sCallbackCount = 0;
#endif
CMochaEventCallback::CMochaEventCallback()
{
#ifdef DEBUG
sCallbackCount++;
#endif
fDummyElement = NULL;
}
CMochaEventCallback::~CMochaEventCallback()
{
#ifdef DEBUG
sCallbackCount--;
#endif
if (fDummyElement != NULL)
XP_FREE( fDummyElement );
}
//
// Plain SendEvent
//
void
CMochaEventCallback::SendEvent(MWContext * context, LO_Element * element, int32 type, CL_Layer* layer, SPoint32 where)
{
// ET_SendEvent now takes a JSEvent struct instead of an int type
JSEvent* event = XP_NEW_ZAP(JSEvent);
if (event)
{
event->type = type;
event->x = where.h;
event->y = where.v;
event->docx = event->x + CL_GetLayerXOrigin(layer);
event->docy = event->y + CL_GetLayerYOrigin(layer);
int32 x_offset, y_offset;
FE_GetWindowOffset(context, &x_offset, &y_offset);
event->screenx = event->docx + x_offset;
event->screeny = event->docy + y_offset;
event->layer_id = LO_GetIdFromLayer(context, layer);
ET_SendEvent( context, element, event, MochaCallback, this);
// PR_Yield(); To speed up processing?
}
}
//
// LO_AnchorData SendEvent
//
void
CMochaEventCallback::SendEvent(MWContext * context, LO_AnchorData * data, int32 type, CL_Layer* layer, SPoint32 where)
{
// Create fake layout element
fDummyElement = XP_NEW_ZAP(LO_Element);
if (fDummyElement)
{
fDummyElement->type = LO_TEXT;
fDummyElement->lo_text.anchor_href = data;
fDummyElement->lo_text.text = data->anchor;
// ET_SendEvent now takes a JSEvent struct instead of an int type
JSEvent* event = XP_NEW_ZAP(JSEvent);
if (event)
{
event->type = type;
event->x = where.h;
event->y = where.v;
event->docx = event->x + CL_GetLayerXOrigin(layer);
event->docy = event->y + CL_GetLayerYOrigin(layer);
int32 x_offset, y_offset;
FE_GetWindowOffset(context, &x_offset, &y_offset);
event->screenx = event->docx + x_offset;
event->screeny = event->docy + y_offset;
event->layer_id = LO_GetIdFromLayer(context, layer);
ET_SendEvent( context, fDummyElement, event, MochaCallback, this);
}
}
}
//
// EventComplete, does nothing
//
void
CMochaEventCallback::Complete(MWContext * /*context*/, LO_Element * /*element*/,
int32 /*type*/, ETEventStatus /*status*/)
{
// EVENT_OK means we should handle the event/
// EVENT_CANCEL, EVENT_PANIC, means mocha has cancelled the click
}
//
// MochaCallback, called by mocha after event is processed
//
void CMochaEventCallback::MochaCallback(MWContext * context, LO_Element * element,
int32 type, void * inCallback, ETEventStatus status)
{
CMochaEventCallback * callback = (CMochaEventCallback *) inCallback;
callback->Complete( context, element, type, status );
delete callback;
}

View File

@@ -0,0 +1,125 @@
/* -*- 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.
*/
/*
* macmocha.h
* MacFE mocha hacks
*
*/
#include "structs.h" // mjc
#include "libevent.h"
/*
* static class that encapsulates most of the Macha hacks
*/
class CMochaHacks
{
private:
static LO_Element* sMouseOverElement; // layout element the cursor is over
static MWContext* sMouseOverElementContext; // context associated with sMouseOverElement
static LO_AnchorData* sMouseOverMapArea; // AREA tag the cursor is over
public:
static void ClearSelectionForContext( MWContext* context )
{
if (context == sMouseOverElementContext)
{
sMouseOverElement = NULL;
sMouseOverElementContext = NULL;
sMouseOverMapArea = NULL;
}
}
static void SendOutOfElementEvent(MWContext * winContext, CL_Layer* layer, SPoint32 where); // add layer param 1997-03-02 mjc
static void SendOutOfMapAreaEvent(MWContext * winContext, CL_Layer* layer, SPoint32 where); // add layer param 1997-03-02 mjc
static void ResetMochaMouse();
static Boolean IsMouseOverElement(LO_Element* inElement)
{ return inElement == sMouseOverElement; }
static Boolean IsMouseOverMapArea(LO_AnchorData* inAnchorData)
{ return inAnchorData == sMouseOverMapArea; }
static void SetMouseOverElement(LO_Element* inElement, MWContext* inElementContext = NULL)
{
sMouseOverElement = inElement;
sMouseOverElementContext = inElementContext;
}
static void RemoveReferenceToMouseOverElementContext(MWContext *context)
{
if (sMouseOverElementContext == context)
sMouseOverElementContext = NULL;
}
static void SetMouseOverMapArea(LO_AnchorData* inAnchorData)
{ sMouseOverMapArea = inAnchorData; }
static LO_Element* GetMouseOverElement()
{ return sMouseOverElement; }
static LO_AnchorData* GetMouseOverMapArea()
{ return sMouseOverMapArea; }
static uint32 MochaModifiers(const UInt16 inModifiers);
static uint32 MochaModifiersFromKeyboard(void);
// manage windows declared as dependent in javascript
static Boolean IsDependent(MWContext* inContext);
static void AddDependent(MWContext* inParent, MWContext* inChild);
static void RemoveDependents(MWContext* inContext);
// Whenever a window or frame moves or resizes send an event to javascript
static void SendMoveEvent(MWContext* inContext, int32 inX, int32 inY);
static void SendEvent(MWContext* inContext, int32 inType, LO_Element* inElement = nil);
// Send navigation events - currently not cancellable
static void SendBackEvent(MWContext* inContext)
{ SendEvent(inContext, EVENT_BACK); }
static void SendForwardEvent(MWContext* inContext)
{ SendEvent(inContext, EVENT_FORWARD); }
};
/*
* CMochaEventCallback
* class that encapsulates sending of mocha events
* Subclasses should override EventComplete
*/
class CMochaEventCallback {
public:
// Constructors
CMochaEventCallback();
virtual ~CMochaEventCallback();
// Mocha interface
void SendEvent(MWContext * context, LO_Element * element, int32 type, CL_Layer* layer, SPoint32 where);
void SendEvent(MWContext * context, LO_AnchorData * data, int32 type, CL_Layer* layer, SPoint32 where);
// MochaCallback calls EventComplete. You'll be deleted after this call
virtual void Complete(MWContext * context, LO_Element * element,
int32 type, ETEventStatus status);
static void MochaCallback(MWContext * context, LO_Element * element,
int32 type, void * inCallback, ETEventStatus status);
private:
// Old Mocha calls used to accept either LO_Element, or LO_AnchorData
// New ones only accept LO_Element, so sometimes we need to create/dispose
// dummy layout elements. This is encapsulated in this class
LO_Element * fDummyElement;
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,520 @@
/* -*- 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.
*/
// CNSContext.h
#pragma once
#include <LBroadcaster.h>
#include <LSharable.h>
#include "structs.h"
#include "cstring.h"
class CHTMLView;
class CNSContext;
inline CNSContext* ExtractNSContext(MWContext* inContext)
{ return inContext->fe.newContext; }
inline const CNSContext* ExtractConstNSContext(const MWContext* inContext)
{ return inContext->fe.newContext; }
inline CHTMLView* ExtractHyperView(const MWContext* inContext)
{ return inContext->fe.newView; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// This enumeration contains all of the possible broadcast messages that
// a CNSContext can give.
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
enum {
// These messages notify thge clients about the layout state.
msg_NSCDocTitleChanged = 'DTCG', // cstring* theNewTitle
msg_NSCLayoutNewDocument = 'LOND', // URL_Struct* theURL
msg_NSCFinishedLayout = 'FNLO', // < none >
// These messages notify thge clients about the repagination state.
msg_NSCPEmptyRepagination = 'NLPG', // < none >
msg_NSCPAboutToRepaginate = 'ABPG', // < none >
msg_NSCPEditorRepaginate = 'EDPG', // < none >
// These messages are key to the whole process of loading a URL.
// The start loading and all connections complete notifications are
// guaranteed to be symmetrical.
msg_NSCStartLoadURL = 'SLUB', // URL_Struct* theURL
msg_NSCConfirmLoadNewURL = 'CLNU', // Boolean*
msg_NSCAllConnectionsComplete = 'ACCP', // < none >
// A message to all context clients that this grid context is about to die.
// Clients should clean up and remove their shared references to the context
// upon receiving this message.
msg_NSCGridContextPreDispose = 'GCPD', // Boolean* isSavingHistory
// A message to all context clients that a child grid context has been
// created or disposed. Clients will want to know if a grid is created
// so that they can add themselves as a listener or add a shared reference
// to the new context.
msg_NSCGridContextCreated = 'GCCR', // CNSContext* new grid
msg_NSCGridContextDisposed = 'GCDP', // < none >
// Progress notifications, like the url loading notifications are
// guaranteed to be symmetric. There will always be one begin,
// n updates, and one end notification.
msg_NSCProgressBegin = 'PGST', // CContextProgress*
msg_NSCProgressUpdate = 'PGUP', // CContextProgress*
msg_NSCProgressEnd = 'PGED', // CContextProgress*
// These are progress messages that are not guaranteed to be sent
// between bind and end progress notifications.
// msg_NSCProgressMessageChanged = 'PGMC', // cstring* theNewMessage
msg_NSCProgressMessageChanged = 'PGMC', // const char* theNewMessage
msg_NSCProgressPercentChanged = 'PGPC' // Int32* theNewPercent
};
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// The progress of a particular url loading operation is encapsulated in the
// following object. Accessors are provided in the context to support this.
// This object is only instantiated during the actual load itself, begining
// with msg_NSCStartLoadURL notification and ending with the
// msg_NSCAllConnectionsComplete notification. At all other (inactive) times
// the accessors for this object will return NULL. See the accessor comments
// for further information.
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
class CContextProgress : public LSharable
{
public:
CContextProgress();
Int32 mTotal; // Total bytes tracked
Int32 mRead; // How many have been read
Int32 mUnknownCount; // How many connections of the unknown length do we have
Int32 mPercent; // Percent complete
Int32 mInitCount;
Uint32 mStartTime;
cstring mAction;
cstring mMessage;
cstring mComment;
};
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
//
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
class CNSContext : public LBroadcaster, public LSharable
{
friend class CNSContextCallbacks;
friend class CPlainTextConversionContext;
public:
CNSContext(MWContextType inType);
CNSContext(const CNSContext& inOriginal);
virtual ~CNSContext();
virtual void NoMoreUsers();
operator MWContext*();
operator const MWContext*() const;
operator MWContext&();
operator const MWContext&() const;
virtual CContextProgress* GetContextProgress();
protected:
virtual void SetContextProgress(CContextProgress* inProgress);
public:
void EnsureContextProgress();
virtual cstring GetDescriptor() const;
virtual void SetDescriptor(const char* inDescriptor);
virtual Boolean IsCloneRequired() const;
virtual void SetRequiresClone(Boolean inClone);
virtual CContextProgress* GetCurrentProgressStats();
virtual void UpdateCurrentProgressStats();
virtual void WaitWhileBusy();
// FIX ME!!! ACCESSOR for unique ID
// CHARACTER SET ACCESSORS
void InitDefaultCSID();
virtual void SetDefaultCSID(Int16 inDefaultCSID);
virtual Int16 GetDefaultCSID() const;
virtual void SetDocCSID(Int16 inDocCSID);
virtual Int16 GetDocCSID() const;
virtual void SetWinCSID(Int16 inWinCSID);
virtual Int16 GetWinCSID() const;
virtual Int16 GetWCSIDFromDocCSID(
Int16 inDocCSID);
class IndexOutOfRangeException { };
virtual History_entry* GetCurrentHistoryEntry();
virtual Int32 GetHistoryListCount();
virtual cstring* GetHistoryEntryTitleByIndex(Int32 inIndex); // one-based index
virtual Int32 GetIndexOfCurrentHistoryEntry();
virtual void GetHistoryURLByIndex(cstring& outURL, Int32 inIndex); // one-based index
// URL MANIPULATION
virtual cstring GetCurrentURL();
virtual void SwitchLoadURL(
URL_Struct* inURL,
FO_Present_Types inOutputFormat);
virtual void ImmediateLoadURL(
URL_Struct* inURL,
FO_Present_Types inOutputFormat);
// Need to make Alert public because we need to be able to call it from FE_Alert
virtual void Alert(
const char* inAlertText);
// STATUS
virtual const char* GetDefaultStatus() const;
virtual void ClearDefaultStatus();
virtual void SetStatus(const char* inStatus);
// STUFF
virtual void CompleteLoad(URL_Struct* inURL, int inStatus);
virtual void ClearMWContextViewPtr();
virtual void CopyListenersToContext(CNSContext* aSubContext); // used when spawning grid contexts
protected:
// CALLBACK IMPLEMENTATION
virtual MWContext* CreateNewDocWindow(
URL_Struct* inURL);
virtual void LayoutNewDocument(
URL_Struct* inURL,
Int32* inWidth,
Int32* inHeight,
Int32* inMarginWidth,
Int32* inMarginHeight);
virtual void SetDocTitle(
char* inTitle);
virtual void FinishedLayout();
virtual char* TranslateISOText(
int inCharset,
char* inISOText);
virtual int GetTextInfo(
LO_TextStruct* inText,
LO_TextInfo* inTextInfo);
virtual int MeasureText(
LO_TextStruct* inText,
short* outCharLocs);
virtual void GetEmbedSize(
LO_EmbedStruct* inEmbedStruct,
NET_ReloadMethod inReloadMethod);
virtual void GetJavaAppSize(
LO_JavaAppStruct* inJavaAppStruct,
NET_ReloadMethod inReloadMethod);
virtual void GetFormElementInfo(
LO_FormElementStruct* inElement);
virtual void GetFormElementValue(
LO_FormElementStruct* inElement,
XP_Bool inHide);
virtual void ResetFormElement(
LO_FormElementStruct* inElement);
virtual void SetFormElementToggle(
LO_FormElementStruct* inElement,
XP_Bool inToggle);
virtual void FreeEmbedElement(
LO_EmbedStruct* inEmbedStruct);
virtual void CreateEmbedWindow(
NPEmbeddedApp* inEmbeddedApp);
virtual void SaveEmbedWindow(
NPEmbeddedApp* inEmbeddedApp);
virtual void RestoreEmbedWindow(
NPEmbeddedApp* inEmbeddedApp);
virtual void DestroyEmbedWindow(
NPEmbeddedApp* inEmbeddedApp);
virtual void FreeJavaAppElement(
LJAppletData* inAppletData);
virtual void HideJavaAppElement(
LJAppletData* inAppletData);
virtual void FreeEdgeElement(
LO_EdgeStruct* inEdgeStruct);
virtual void FormTextIsSubmit(
LO_FormElementStruct* inElement);
virtual void DisplaySubtext(
int inLocation,
LO_TextStruct* inText,
Int32 inStartPos,
Int32 inEndPos,
XP_Bool inNeedBG);
virtual void DisplayText(
int inLocation,
LO_TextStruct* inText,
XP_Bool inNeedBG);
virtual void DisplayEmbed(
int inLocation,
LO_EmbedStruct* inEmbedStruct);
virtual void DisplayJavaApp(
int inLocation,
LO_JavaAppStruct* inJavaAppStruct);
virtual void DisplayEdge (
int inLocation,
LO_EdgeStruct* inEdgeStruct);
virtual void DisplayTable(
int inLocation,
LO_TableStruct* inTableStruct);
virtual void DisplayCell(
int inLocation,
LO_CellStruct* inCellStruct);
virtual void InvalidateEntireTableOrCell(
LO_Element* inElement);
virtual void DisplayAddRowOrColBorder(
XP_Rect* inRect,
XP_Bool inDoErase);
virtual void DisplaySubDoc(
int inLocation,
LO_SubDocStruct* inSubdocStruct);
virtual void DisplayLineFeed(
int inLocation,
LO_LinefeedStruct* inLinefeedStruct,
XP_Bool inNeedBG);
virtual void DisplayHR(
int inLocation,
LO_HorizRuleStruct* inRuleStruct);
virtual void DisplayBullet(
int inLocation,
LO_BullettStruct* inBullettStruct);
virtual void DisplayFormElement(
int inLocation,
LO_FormElementStruct* inFormElement);
virtual void DisplayBorder(
int inLocation,
int inX,
int inY,
int inWidth,
int inHeight,
int inBW,
LO_Color* inColor,
LO_LineStyle inStyle);
virtual void UpdateEnableStates();
virtual void DisplayFeedback(
int inLocation,
LO_Element* inElement);
virtual void ClearView(
int inWhich);
virtual void SetDocDimension(
int inLocation,
Int32 inWidth,
Int32 inLength);
virtual void SetDocPosition(
int inLocation,
Int32 inX,
Int32 inY);
virtual void GetDocPosition(
int inLocation,
Int32* outX,
Int32* outY);
virtual void BeginPreSection();
virtual void EndPreSection();
virtual void SetProgressBarPercent(
Int32 inPercent);
virtual void SetBackgroundColor(
Uint8 inRed,
Uint8 inGreen,
Uint8 inBlue);
public:
virtual void Progress(
const char* inMessageText);
protected:
virtual void SetCallNetlibAllTheTime();
virtual void ClearCallNetlibAllTheTime();
virtual void GraphProgressInit(
URL_Struct* inURL,
Int32 inContentLength);
virtual void GraphProgressDestroy(
URL_Struct* inURL,
Int32 inContentLength,
Int32 inTotalRead);
virtual void GraphProgress(
URL_Struct* inURL,
Int32 inBytesReceived,
Int32 inBytesSinceLast,
Int32 inContentLength);
virtual XP_Bool UseFancyFTP();
virtual XP_Bool UseFancyNewsgroupListing();
virtual int FileSortMethod();
virtual XP_Bool ShowAllNewsArticles();
virtual XP_Bool Confirm(
const char* inMessage);
virtual char* Prompt(
const char* inMessage,
const char* inDefaultText);
virtual char* PromptWithCaption(
const char* inCaption,
const char* inMessage,
const char* inDefaultText);
virtual XP_Bool PromptUsernameAndPassword(
const char* inMessage,
char** outUserName,
char** outPassword);
virtual char* PromptPassword(
const char* inMessage);
virtual void EnableClicking();
virtual void AllConnectionsComplete();
virtual void EraseBackground(
int inLocation,
Int32 inX,
Int32 inY,
Uint32 inWidth,
Uint32 inHieght,
LO_Color* inColor);
virtual void SetDrawable(
CL_Drawable* inDrawable);
virtual void GetTextFrame(
LO_TextStruct* inTextStruct,
Int32 inStartPos,
Int32 inEndPos,
XP_Rect* outFrame);
virtual void GetDefaultBackgroundColor(
LO_Color* outColor) const;
virtual void DrawJavaApp(
int inLocation,
LO_JavaAppStruct* inJavaAppStruct);
virtual void HandleClippingView(
struct LJAppletData *appletD,
int x,
int y,
int width,
int height);
public:
static UInt32 sNSCWindowID; // Unique ID, incremented for each context
UInt32 fNSCWindowID; // ID of this window
Int32 fNSCProgressID; //
Int32 GetTransactionID() { return fNSCProgressID; }
Int32 GetContextUniqueID() { return fNSCWindowID; }
// Window ID. Used to identify the context
// There are listeners that listen to several contexts (eg, in mail windows).
// This works by reference counting, and such listeners assume calls to
// SwitchLoadURL and AllConnectionsComplete are balanced. Each context must
// therefore ensure that they are, even if it is done artificially.
Int32 mLoadRefCount;
protected:
MWContext mContext;
Int16 mDefaultCSID;
Boolean mRequiresClone;
CContextProgress* mProgress;
};
inline CNSContext::operator MWContext*()
{ return &mContext; };
inline CNSContext::operator const MWContext*() const
{ return &mContext; };
inline CNSContext::operator MWContext&()
{ return mContext; };
inline CNSContext::operator const MWContext&() const
{ return mContext; };

View File

@@ -0,0 +1,745 @@
/* -*- 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.
*/
// CNSContextCallbacks.cp
#include "CNSContextCallbacks.h"
#include "CNSContext.h"
CNSContextCallbacks* CNSContextCallbacks::sContextCallbacks = NULL; // singleton class
CNSContextCallbacks::CNSContextCallbacks()
{
#define MAKE_FE_FUNCS_PREFIX(f) CNSContextCallbacks::##f
#define MAKE_FE_FUNCS_ASSIGN mCallbacks.
#include "mk_cx_fn.h"
Assert_(sContextCallbacks == NULL);
sContextCallbacks = this;
}
CNSContextCallbacks::~CNSContextCallbacks()
{
sContextCallbacks = NULL;
}
MWContext* CNSContextCallbacks::CreateNewDocWindow(
MWContext* inContext,
URL_Struct* inURL)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->CreateNewDocWindow(inURL);
}
void CNSContextCallbacks::LayoutNewDocument(
MWContext* inContext,
URL_Struct* inURL,
int32* inWidth,
int32* inHeight,
int32* inMarginWidth,
int32* inMarginHeight)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->LayoutNewDocument(inURL, inWidth, inHeight, inMarginWidth, inMarginHeight);
}
void CNSContextCallbacks::SetDocTitle(
MWContext* inContext,
char* inTitle)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->SetDocTitle(inTitle);
}
void CNSContextCallbacks::FinishedLayout(MWContext* inContext)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->FinishedLayout();
}
char* CNSContextCallbacks::TranslateISOText(
MWContext* inContext,
int inCharset,
char* inISOText)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->TranslateISOText(inCharset, inISOText);
}
int CNSContextCallbacks::GetTextInfo(
MWContext* inContext,
LO_TextStruct* inText,
LO_TextInfo* inTextInfo)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->GetTextInfo(inText, inTextInfo);
}
int CNSContextCallbacks::MeasureText(
MWContext* inContext,
LO_TextStruct* inText,
short* outCharLocs)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->MeasureText(inText, outCharLocs);
}
void CNSContextCallbacks::GetEmbedSize(
MWContext* inContext,
LO_EmbedStruct* inEmbedStruct,
NET_ReloadMethod inReloadMethod)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->GetEmbedSize(inEmbedStruct, inReloadMethod);
}
void CNSContextCallbacks::GetJavaAppSize(
MWContext* inContext,
LO_JavaAppStruct* inJavaAppStruct,
NET_ReloadMethod inReloadMethod)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->GetJavaAppSize(inJavaAppStruct, inReloadMethod);
}
void CNSContextCallbacks::GetFormElementInfo(
MWContext* inContext,
LO_FormElementStruct* inElement)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->GetFormElementInfo(inElement);
}
void CNSContextCallbacks::GetFormElementValue(
MWContext* inContext,
LO_FormElementStruct* inElement,
XP_Bool inHide)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->GetFormElementValue(inElement, inHide);
}
void CNSContextCallbacks::ResetFormElement(
MWContext* inContext,
LO_FormElementStruct* inElement)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->ResetFormElement(inElement);
}
void CNSContextCallbacks::SetFormElementToggle(
MWContext* inContext,
LO_FormElementStruct* inElement,
XP_Bool inToggle)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->SetFormElementToggle(inElement, inToggle);
}
void CNSContextCallbacks::FreeEmbedElement(
MWContext* inContext,
LO_EmbedStruct* inEmbedStruct)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->FreeEmbedElement(inEmbedStruct);
}
void CNSContextCallbacks::CreateEmbedWindow(
MWContext* inContext,
NPEmbeddedApp* inEmbeddedApp)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->CreateEmbedWindow(inEmbeddedApp);
}
void CNSContextCallbacks::SaveEmbedWindow(
MWContext* inContext,
NPEmbeddedApp* inEmbeddedApp)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->SaveEmbedWindow(inEmbeddedApp);
}
void CNSContextCallbacks::RestoreEmbedWindow(
MWContext* inContext,
NPEmbeddedApp* inEmbeddedApp)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->RestoreEmbedWindow(inEmbeddedApp);
}
void CNSContextCallbacks::DestroyEmbedWindow(
MWContext* inContext,
NPEmbeddedApp* inEmbeddedApp)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DestroyEmbedWindow(inEmbeddedApp);
}
void CNSContextCallbacks::FreeJavaAppElement(
MWContext* inContext,
LJAppletData* inAppletData)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->FreeJavaAppElement(inAppletData);
}
void CNSContextCallbacks::HideJavaAppElement(
MWContext* inContext,
LJAppletData* inAppletData)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->HideJavaAppElement(inAppletData);
}
void CNSContextCallbacks::FreeEdgeElement(
MWContext* inContext,
LO_EdgeStruct* inEdgeStruct)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->FreeEdgeElement(inEdgeStruct);
}
void CNSContextCallbacks::FormTextIsSubmit(
MWContext* inContext,
LO_FormElementStruct* inElement)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->FormTextIsSubmit(inElement);
}
void CNSContextCallbacks::DisplaySubtext(
MWContext* inContext,
int inLocation,
LO_TextStruct* inText,
Int32 inStartPos,
Int32 inEndPos,
XP_Bool inNeedBG)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplaySubtext(inLocation, inText, inStartPos, inEndPos, inNeedBG);
}
void CNSContextCallbacks::DisplayText(
MWContext* inContext,
int inLocation,
LO_TextStruct* inText,
XP_Bool inNeedBG)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayText(inLocation, inText, inNeedBG);
}
void CNSContextCallbacks::DisplayEmbed(
MWContext* inContext,
int inLocation,
LO_EmbedStruct* inEmbedStruct)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayEmbed(inLocation, inEmbedStruct);
}
void CNSContextCallbacks::DisplayJavaApp(
MWContext* inContext,
int inLocation,
LO_JavaAppStruct* inJavaAppStruct)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayJavaApp(inLocation, inJavaAppStruct);
}
void CNSContextCallbacks::DisplayEdge(
MWContext* inContext,
int inLocation,
LO_EdgeStruct* inEdgeStruct)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayEdge(inLocation, inEdgeStruct);
}
void CNSContextCallbacks::DisplayTable(
MWContext* inContext,
int inLocation,
LO_TableStruct* inTableStruct)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayTable(inLocation, inTableStruct);
}
void CNSContextCallbacks::DisplayCell(
MWContext* inContext,
int inLocation,
LO_CellStruct* inCellStruct)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayCell(inLocation, inCellStruct);
}
void CNSContextCallbacks::InvalidateEntireTableOrCell(
MWContext* inContext,
LO_Element* inElement)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
if (inElement)
theNSContext->InvalidateEntireTableOrCell(inElement);
}
void CNSContextCallbacks::DisplayAddRowOrColBorder(
MWContext* inContext,
XP_Rect* inRect,
XP_Bool inDoErase)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayAddRowOrColBorder(inRect, inDoErase);
}
void CNSContextCallbacks::DisplaySubDoc(
MWContext* inContext,
int inLocation,
LO_SubDocStruct* inSubdocStruct)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplaySubDoc(inLocation, inSubdocStruct);
}
void CNSContextCallbacks::DisplayLineFeed(
MWContext* inContext,
int inLocation,
LO_LinefeedStruct* inLinefeedStruct,
XP_Bool inNeedBG)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayLineFeed(inLocation, inLinefeedStruct, inNeedBG);
}
void CNSContextCallbacks::DisplayHR(
MWContext* inContext,
int inLocation,
LO_HorizRuleStruct* inRuleStruct)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayHR(inLocation, inRuleStruct);
}
void CNSContextCallbacks::DisplayBullet(
MWContext* inContext,
int inLocation,
LO_BullettStruct* inBullettStruct)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayBullet(inLocation, inBullettStruct);
}
void CNSContextCallbacks::DisplayFormElement(
MWContext* inContext,
int inLocation,
LO_FormElementStruct* inFormElement)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayFormElement(inLocation, inFormElement);
}
void CNSContextCallbacks::DisplayBorder(
MWContext* inContext,
int inLocation,
int inX,
int inY,
int inWidth,
int inHeight,
int inBW,
LO_Color* inColor,
LO_LineStyle inStyle)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayBorder(inLocation, inX, inY, inWidth, inHeight, inBW, inColor, inStyle);
}
void CNSContextCallbacks::UpdateEnableStates( MWContext* inContext )
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->UpdateEnableStates();
}
void CNSContextCallbacks::DisplayFeedback(
MWContext* inContext,
int inLocation,
LO_Element* inElement)
{
// bail out if non-editor context
// this function is to be used only for the editor
if ( !inContext->is_editor )
return;
// called even if the element is not selected
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DisplayFeedback(inLocation, inElement);
}
void CNSContextCallbacks::ClearView(
MWContext* inContext,
int inWhich)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->ClearView(inWhich);
}
void CNSContextCallbacks::SetDocDimension(
MWContext* inContext,
int inLocation,
Int32 inWidth,
Int32 inLength)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->SetDocDimension(inLocation, inWidth, inLength);
}
void CNSContextCallbacks::SetDocPosition(
MWContext* inContext,
int inLocation,
Int32 inX,
Int32 inY)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->SetDocPosition(inLocation, inX, inY);
}
void CNSContextCallbacks::GetDocPosition(
MWContext* inContext,
int inLocation,
Int32* outX,
Int32* outY)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->GetDocPosition(inLocation, outX, outY);
}
void CNSContextCallbacks::BeginPreSection(
MWContext* inContext)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->BeginPreSection();
}
void CNSContextCallbacks::EndPreSection(
MWContext* inContext)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->EndPreSection();
}
void CNSContextCallbacks::SetProgressBarPercent(
MWContext* inContext,
Int32 inPercent)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->SetProgressBarPercent(inPercent);
}
void CNSContextCallbacks::SetBackgroundColor(
MWContext* inContext,
Uint8 inRed,
Uint8 inGreen,
Uint8 inBlue)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->SetBackgroundColor(inRed, inGreen, inBlue);
}
void CNSContextCallbacks::Progress(
MWContext* inContext,
const char* inMessageText)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->Progress(inMessageText);
}
void CNSContextCallbacks::Alert(
MWContext* inContext,
const char* inAlertText)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->Alert(inAlertText);
}
void CNSContextCallbacks::SetCallNetlibAllTheTime(
MWContext* inContext)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->SetCallNetlibAllTheTime();
}
void CNSContextCallbacks::ClearCallNetlibAllTheTime(
MWContext* inContext)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->ClearCallNetlibAllTheTime();
}
void CNSContextCallbacks::GraphProgressInit(
MWContext* inContext,
URL_Struct* inURL,
Int32 inContentLength)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->GraphProgressInit(inURL, inContentLength);
}
void CNSContextCallbacks::GraphProgressDestroy(
MWContext* inContext,
URL_Struct* inURL,
Int32 inContentLength,
Int32 inTotalRead)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->GraphProgressDestroy(inURL, inContentLength, inTotalRead);
}
void CNSContextCallbacks::GraphProgress(
MWContext* inContext,
URL_Struct* inURL,
Int32 inBytesReceived,
Int32 inBytesSinceLast,
Int32 inContentLength)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->GraphProgress(inURL, inBytesReceived, inBytesSinceLast, inContentLength);
}
XP_Bool CNSContextCallbacks::UseFancyFTP(
MWContext* inContext)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->UseFancyFTP();
}
XP_Bool CNSContextCallbacks::UseFancyNewsgroupListing(
MWContext* inContext)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->UseFancyNewsgroupListing();
}
int CNSContextCallbacks::FileSortMethod(
MWContext* inContext)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->FileSortMethod();
}
XP_Bool CNSContextCallbacks::ShowAllNewsArticles(
MWContext* inContext)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->ShowAllNewsArticles();
}
XP_Bool CNSContextCallbacks::Confirm(
MWContext* inContext,
const char* inMessage)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->Confirm(inMessage);
}
char* CNSContextCallbacks::Prompt(
MWContext* inContext,
const char* inMessage,
const char* inDefaultText)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->Prompt(inMessage, inDefaultText);
}
char* CNSContextCallbacks::PromptWithCaption(
MWContext* inContext,
const char* inCaption,
const char* inMessage,
const char* inDefaultText)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->PromptWithCaption(inCaption, inMessage, inDefaultText);
}
XP_Bool CNSContextCallbacks::PromptUsernameAndPassword(
MWContext* inContext,
const char* inMessage,
char** outUserName,
char** outPassword)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->PromptUsernameAndPassword(inMessage, outUserName, outPassword);
}
char* CNSContextCallbacks::PromptPassword(
MWContext* inContext,
const char* inMessage)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
return theNSContext->PromptPassword(inMessage);
}
void CNSContextCallbacks::EnableClicking(
MWContext* inContext)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->EnableClicking();
}
void CNSContextCallbacks::AllConnectionsComplete(
MWContext* inContext)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
if (theNSContext)
theNSContext->AllConnectionsComplete();
}
void CNSContextCallbacks::EraseBackground(
MWContext* inContext,
int inLocation,
Int32 inX,
Int32 inY,
Uint32 inWidth,
Uint32 inHeight,
LO_Color* inColor)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->EraseBackground(inLocation, inX, inY, inWidth, inHeight, inColor);
}
void CNSContextCallbacks::SetDrawable(
MWContext* inContext,
CL_Drawable* inDrawable)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->SetDrawable(inDrawable);
}
void CNSContextCallbacks::GetTextFrame(
MWContext* inContext,
LO_TextStruct* inTextStruct,
Int32 inStartPos,
Int32 inEndPos,
XP_Rect* outFrame)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->GetTextFrame(inTextStruct, inStartPos, inEndPos, outFrame);
}
void CNSContextCallbacks::GetDefaultBackgroundColor(
MWContext* inContext,
LO_Color* outColor)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->GetDefaultBackgroundColor(outColor);
}
void CNSContextCallbacks::DrawJavaApp(
MWContext* inContext,
int inLocation,
LO_JavaAppStruct* inJavaAppStruct)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->DrawJavaApp(inLocation, inJavaAppStruct);
}
void CNSContextCallbacks::HandleClippingView(
MWContext* inContext,
struct LJAppletData *appletD,
int x,
int y,
int width,
int height)
{
CNSContext* theNSContext = ExtractNSContext(inContext);
Assert_(theNSContext != NULL);
theNSContext->HandleClippingView(appletD, x, y, width, height);
}

View File

@@ -0,0 +1,393 @@
/* -*- 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.
*/
// CNSContextCallbacks.h
#pragma once
#include "ntypes.h"
#include "structs.h"
#include "ctxtfunc.h"
class CNSContext;
class CNSContextCallbacks
{
public:
static CNSContextCallbacks* GetContextCallbacks(void); // singleton class accessor
CNSContextCallbacks();
virtual ~CNSContextCallbacks();
ContextFuncs& GetInternalCallbacks(void);
protected:
static MWContext* CreateNewDocWindow(
MWContext* inContext,
URL_Struct* inURL);
static void LayoutNewDocument(
MWContext* inContext,
URL_Struct* inURL,
Int32* inWidth,
Int32* inHeight,
Int32* inMarginWidth,
Int32* inMarginHeight);
static void SetDocTitle(
MWContext* inContext,
char* inTitle);
static void FinishedLayout(
MWContext* inContext);
static char* TranslateISOText(
MWContext* inContext,
int inCharset,
char* inISOText);
static int GetTextInfo(
MWContext* inContext,
LO_TextStruct* inText,
LO_TextInfo* inTextInfo);
static int MeasureText(
MWContext* inContext,
LO_TextStruct* inText,
short* outCharLocs);
static void GetEmbedSize(
MWContext* inContext,
LO_EmbedStruct* inEmbedStruct,
NET_ReloadMethod inReloadMethod);
static void GetJavaAppSize(
MWContext* inContext,
LO_JavaAppStruct* inJavaAppStruct,
NET_ReloadMethod inReloadMethod);
static void GetFormElementInfo(
MWContext* inContext,
LO_FormElementStruct* inElement);
static void GetFormElementValue(
MWContext* inContext,
LO_FormElementStruct* inElement,
XP_Bool inHide);
static void ResetFormElement(
MWContext* inContext,
LO_FormElementStruct* inElement);
static void SetFormElementToggle(
MWContext* inContext,
LO_FormElementStruct* inElement,
XP_Bool inToggle);
static void FreeEmbedElement(
MWContext* inContext,
LO_EmbedStruct* inEmbedStruct);
static void CreateEmbedWindow(
MWContext* inContext,
NPEmbeddedApp* inEmbeddedApp);
static void SaveEmbedWindow(
MWContext* inContext,
NPEmbeddedApp* inEmbeddedApp);
static void RestoreEmbedWindow(
MWContext* inContext,
NPEmbeddedApp* inEmbeddedApp);
static void DestroyEmbedWindow(
MWContext* inContext,
NPEmbeddedApp* inEmbeddedApp);
static void FreeJavaAppElement(
MWContext* inContext,
LJAppletData* inAppletData);
static void HideJavaAppElement(
MWContext* inContext,
LJAppletData* inAppletData);
static void FreeEdgeElement(
MWContext* inContext,
LO_EdgeStruct* inEdgeStruct);
static void FormTextIsSubmit(
MWContext* inContext,
LO_FormElementStruct* inElement);
static void DisplaySubtext(
MWContext* inContext,
int inLocation,
LO_TextStruct* inText,
Int32 inStartPos,
Int32 inEndPos,
XP_Bool inNeedBG);
static void DisplayText(
MWContext* inContext,
int inLocation,
LO_TextStruct* inText,
XP_Bool inNeedBG);
static void DisplayEmbed(
MWContext* inContext,
int inLocation,
LO_EmbedStruct* inEmbedStruct);
static void DisplayJavaApp(
MWContext* inContext,
int inLocation,
LO_JavaAppStruct* inJavaAppStruct);
static void DisplayEdge (
MWContext* inContext,
int inLocation,
LO_EdgeStruct* inEdgeStruct);
static void DisplayTable(
MWContext* inContext,
int inLocation,
LO_TableStruct* inTableStruct);
static void DisplayCell(
MWContext* inContext,
int inLocation,
LO_CellStruct* inCellStruct);
static void InvalidateEntireTableOrCell(
MWContext* inContext,
LO_Element* inElement);
static void DisplayAddRowOrColBorder(
MWContext* inContext,
XP_Rect* inRect,
XP_Bool inErase);
static void DisplaySubDoc(
MWContext* inContext,
int inLocation,
LO_SubDocStruct* inSubdocStruct);
static void DisplayLineFeed(
MWContext* inContext,
int inLocation,
LO_LinefeedStruct* inLinefeedStruct,
XP_Bool inNeedBG);
static void DisplayHR(
MWContext* inContext,
int inLocation,
LO_HorizRuleStruct* inRuleStruct);
static void DisplayBullet(
MWContext* inContext,
int inLocation,
LO_BullettStruct* inBullettStruct);
static void DisplayFormElement(
MWContext* inContext,
int inLocation,
LO_FormElementStruct* inFormElement);
static void DisplayBorder(
MWContext* inContext,
int inLocation,
int inX,
int inY,
int inWidth,
int inHeight,
int inBW,
LO_Color* inColor,
LO_LineStyle inStyle);
static void UpdateEnableStates(
MWContext* inContext);
static void DisplayFeedback(
MWContext* inContext,
int inLocation,
LO_Element* inElement);
static void ClearView(
MWContext* inContext,
int inWhich);
static void SetDocDimension(
MWContext* inContext,
int inLocation,
Int32 inWidth,
Int32 inLength);
static void SetDocPosition(
MWContext* inContext,
int inLocation,
Int32 inX,
Int32 inY);
static void GetDocPosition(
MWContext* inContext,
int inLocation,
Int32* outX,
Int32* outY);
static void BeginPreSection(
MWContext* inContext);
static void EndPreSection(
MWContext* inContext);
static void SetProgressBarPercent(
MWContext* inContext,
Int32 inPercent);
static void SetBackgroundColor(
MWContext* inContext,
Uint8 inRed,
Uint8 inGreen,
Uint8 inBlue);
static void Progress(
MWContext* inContext,
const char* inMessageText);
static void Alert(
MWContext* inContext,
const char* inAlertText);
static void SetCallNetlibAllTheTime(
MWContext* inContext);
static void ClearCallNetlibAllTheTime(
MWContext* inContext);
static void GraphProgressInit(
MWContext* inContext,
URL_Struct* inURL,
Int32 inContentLength);
static void GraphProgressDestroy(
MWContext* inContext,
URL_Struct* inURL,
Int32 inContentLength,
Int32 inTotalRead);
static void GraphProgress(
MWContext* inContext,
URL_Struct* inURL,
Int32 inBytesReceived,
Int32 inBytesSinceLast,
Int32 inContentLength);
static XP_Bool UseFancyFTP(
MWContext* inContext);
static XP_Bool UseFancyNewsgroupListing(
MWContext* inContext);
static int FileSortMethod(
MWContext* inContext);
static XP_Bool ShowAllNewsArticles(
MWContext* inContext);
static XP_Bool Confirm(
MWContext* inContext,
const char* inMessage);
static char* PromptWithCaption(
MWContext* inContext,
const char* inCaption,
const char* inMessage,
const char* inDefaultText);
static char* Prompt(
MWContext* inContext,
const char* inMessage,
const char* inDefaultText);
static XP_Bool PromptUsernameAndPassword(
MWContext* inContext,
const char* inMessage,
char** outUserName,
char** outPassword);
static char* PromptPassword(
MWContext* inContext,
const char* inMessage);
static void EnableClicking(
MWContext* inContext);
static void AllConnectionsComplete(
MWContext* inContext);
static void EraseBackground(
MWContext* inContext,
int inLocation,
Int32 inX,
Int32 inY,
Uint32 inWidth,
Uint32 inHeight,
LO_Color* inColor);
static void SetDrawable(
MWContext* inContext,
CL_Drawable* inDrawable);
static void GetTextFrame(
MWContext* inContext,
LO_TextStruct* inTextStruct,
Int32 inStartPos,
Int32 inEndPos,
XP_Rect* outFrame);
static void GetDefaultBackgroundColor(
MWContext* inContext,
LO_Color* outColor);
static void DrawJavaApp(
MWContext* inContext,
int inLocation,
LO_JavaAppStruct* inJavaAppStruct);
static void HandleClippingView(
MWContext* inContext,
struct LJAppletData *appletD,
int x,
int y,
int width,
int height);
ContextFuncs mCallbacks;
static CNSContextCallbacks* sContextCallbacks; // singleton class
};
inline _ContextFuncs& CNSContextCallbacks::GetInternalCallbacks(void)
{ return mCallbacks; }
inline CNSContextCallbacks* CNSContextCallbacks::GetContextCallbacks(void)
{ return sContextCallbacks; }

View File

@@ -0,0 +1,252 @@
/* -*- 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.
*/
// CPlainTextConversionContext.cp
// This might seem like a lot of work to go around the code in ns/lib/xlate/text.c,
// but doing this allows us not to have to put if (inContext == NULL) inside
// CNSContextCallbacks.cp; and by calling the TXFE_* functions from the overridden
// methods, we pickup any modifcations made for free.
//#include <yvals.h>
#include "CPlainTextConversionContext.h"
#include "xlate.h"
//_EXTERN_C
__extern_c
// prototypes for text.c functions
extern void TXFE_DisplayTable(MWContext *cx, int iLoc, LO_TableStruct *table);
extern void TXFE_DisplayLineFeed(MWContext *cx, int iLocation, LO_LinefeedStruct *line_feed, XP_Bool notused);
extern void TXFE_DisplayHR(MWContext *cx, int iLocation , LO_HorizRuleStruct *HR);
extern char *TXFE_TranslateISOText(MWContext *cx, int charset, char *ISO_Text);
extern void TXFE_DisplayBullet(MWContext *cx, int iLocation, LO_BullettStruct *bullet);
extern void TXFE_FinishedLayout(MWContext *cx);
extern void TXFE_AllConnectionsComplete(MWContext *cx);
extern void TXFE_DisplaySubtext(MWContext *cx, int iLocation, LO_TextStruct *text,
int32 start_pos, int32 end_pos, XP_Bool notused);
extern void TXFE_DisplayText(MWContext *cx, int iLocation, LO_TextStruct *text, XP_Bool needbg);
extern void TXFE_DisplaySubDoc(MWContext *cx, int iLocation, LO_SubDocStruct *subdoc_struct);
extern int TXFE_GetTextInfo(MWContext *cx, LO_TextStruct *text, LO_TextInfo *text_info);
extern void TXFE_LayoutNewDocument(MWContext *cx, URL_Struct *url, int32 *w, int32 *h, int32* mw, int32* mh);
// These are here because the backend files are .c files, which are only
// run through the C compiler. Thus we need to create and destroy the
// CPlainTextConversionContext from a .cp file
MWContext* CreatePlainTextConversionContext(MWContext* inUIContext);
void DisposePlainTextConversionContext(MWContext* inContext);
__end_extern_c
#pragma mark --- CALLBACKS ---
MWContext* CreatePlainTextConversionContext(MWContext* inUIContext)
{
try {
CPlainTextConversionContext* theContext = new CPlainTextConversionContext(inUIContext);
// Very slimey, but somebody needs to have an interest in the context
theContext->AddUser(theContext);
return theContext->operator MWContext*();
} catch (...) {
return NULL;
}
}
void DisposePlainTextConversionContext(MWContext* inContext)
{
CPlainTextConversionContext* theContext =
dynamic_cast<CPlainTextConversionContext*>(ExtractNSContext(inContext));
Assert_(theContext != NULL);
// One of these days, this call might break
theContext->RemoveUser(theContext);
}
CPlainTextConversionContext::CPlainTextConversionContext(MWContext* inUIContext) :
CNSContext(MWContextText)
{
mUIContext = ExtractNSContext(inUIContext);
Assert_(mUIContext != NULL);
}
#pragma mark --- OVERRIDES ---
void CPlainTextConversionContext::LayoutNewDocument(
URL_Struct* inURL,
Int32* inWidth,
Int32* inHeight,
Int32* inMarginWidth,
Int32* inMarginHeight)
{
TXFE_LayoutNewDocument(*this, inURL, inWidth, inHeight, inMarginWidth, inMarginHeight);
}
void CPlainTextConversionContext::DisplaySubtext(
int inLocation,
LO_TextStruct* inText,
Int32 inStartPos,
Int32 inEndPos,
XP_Bool inNeedBG)
{
TXFE_DisplaySubtext(*this, inLocation, inText, inStartPos, inEndPos, inNeedBG);
}
void CPlainTextConversionContext::DisplayText(
int inLocation,
LO_TextStruct* inText,
XP_Bool inNeedBG)
{
TXFE_DisplayText(*this, inLocation, inText, inNeedBG);
}
void CPlainTextConversionContext::DisplaySubDoc(
int inLocation,
LO_SubDocStruct* inSubdocStruct)
{
TXFE_DisplaySubDoc(*this, inLocation, inSubdocStruct);
}
void CPlainTextConversionContext::DisplayTable(
int inLocation,
LO_TableStruct* inTableStruct)
{
TXFE_DisplayTable(*this, inLocation, inTableStruct);
}
void CPlainTextConversionContext::DisplayLineFeed(
int inLocation,
LO_LinefeedStruct* inLinefeedStruct,
XP_Bool inNeedBG)
{
TXFE_DisplayLineFeed(*this, inLocation, inLinefeedStruct, inNeedBG);
}
void CPlainTextConversionContext::DisplayHR(
int inLocation,
LO_HorizRuleStruct* inRuleStruct)
{
TXFE_DisplayHR(*this, inLocation, inRuleStruct);
}
char* CPlainTextConversionContext::TranslateISOText(
int inCharset,
char* inISOText)
{
return TXFE_TranslateISOText(*this, inCharset, inISOText);
}
void CPlainTextConversionContext::DisplayBullet(
int inLocation,
LO_BullettStruct* inBulletStruct)
{
TXFE_DisplayBullet(*this, inLocation, inBulletStruct);
}
void CPlainTextConversionContext::FinishedLayout(void)
{
TXFE_FinishedLayout(*this);
}
int CPlainTextConversionContext::GetTextInfo(
LO_TextStruct* inText,
LO_TextInfo* inTextInfo)
{
return TXFE_GetTextInfo(*this, inText, inTextInfo);
}
int CPlainTextConversionContext::MeasureText(
LO_TextStruct* /*inText*/,
short* /*outCharLocs*/)
{
return 0;
}
void CPlainTextConversionContext::AllConnectionsComplete(void)
{
if (mProgress)
{
mProgress->RemoveUser(this);
mProgress = NULL;
}
TXFE_AllConnectionsComplete(*this);
mUIContext->AllConnectionsComplete();
CNSContext::AllConnectionsComplete();
}
void CPlainTextConversionContext::GraphProgressInit(
URL_Struct* inURL,
Int32 inContentLength)
{
try {
Assert_(mUIContext != NULL);
if (mUIContext && mUIContext->GetContextProgress())
mProgress = mUIContext->GetContextProgress();
else
{
mProgress = new CContextProgress;
mUIContext->SetContextProgress(mProgress);
}
mProgress->AddUser(this);
} catch (...) {
mProgress = NULL;
}
mUIContext->GraphProgressInit(inURL, inContentLength);
}
void CPlainTextConversionContext::Progress(const char* inMessageText )
{
Assert_(mUIContext != NULL);
mUIContext->Progress(inMessageText);
}
void CPlainTextConversionContext::GraphProgressDestroy(
URL_Struct* inURL,
Int32 inContentLength,
Int32 inTotalRead)
{
Assert_(mUIContext != NULL);
mUIContext->GraphProgressDestroy(inURL, inContentLength, inTotalRead);
}
void CPlainTextConversionContext::GraphProgress(
URL_Struct* inURL,
Int32 inBytesReceived,
Int32 inBytesSinceLast,
Int32 inContentLength)
{
Assert_(mUIContext != NULL);
mUIContext->GraphProgress(inURL, inBytesReceived, inBytesSinceLast, inContentLength);
}
#pragma mark --- STUBS ---
// FIX ME? Do we really wan't to override these methods?
void CPlainTextConversionContext::Alert(const char* /* inAlertText */) {}
XP_Bool CPlainTextConversionContext::Confirm(const char* /* inMessage */) { return false; }
char* CPlainTextConversionContext::Prompt(
const char* /* inMessage */,
const char* /* inDefaultText */) { return NULL; }
XP_Bool CPlainTextConversionContext::PromptUsernameAndPassword(
const char* /* inMessage */,
char** /* outUserName */,
char** /* outPassword */) { return false; }
char* CPlainTextConversionContext::PromptPassword(const char* /* inMessage */) { return NULL; }

View File

@@ -0,0 +1,133 @@
/* -*- 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.
*/
// CPlainTextConversionContext.h
// This is a subclass of CNSContext to handle plain text translation.
// This replaces code in ns/lib/xlate/text.c where a new text MWContext is
// created.
#pragma once
#include "CNSContext.h"
class CPlainTextConversionContext : public CNSContext
{
public:
CPlainTextConversionContext(MWContext* inUIContext);
virtual ~CPlainTextConversionContext() { }
protected:
// Overrides of base CNSContext methods
virtual void LayoutNewDocument(
URL_Struct* inURL,
Int32* inWidth,
Int32* inHeight,
Int32* inMarginWidth,
Int32* inMarginHeight);
virtual void DisplaySubtext(
int inLocation,
LO_TextStruct* inText,
Int32 inStartPos,
Int32 inEndPos,
XP_Bool inNeedBG);
virtual void DisplayText(
int inLocation,
LO_TextStruct* inText,
XP_Bool inNeedBG);
virtual void DisplaySubDoc(
int inLocation,
LO_SubDocStruct* inSubdocStruct);
virtual void DisplayTable(
int inLocation,
LO_TableStruct* inTableStruct);
virtual void DisplayLineFeed(
int inLocation,
LO_LinefeedStruct* inLinefeedStruct,
XP_Bool inNeedBG);
virtual void DisplayHR(
int inLocation,
LO_HorizRuleStruct* inRuleStruct);
virtual char* TranslateISOText(
int inCharset,
char* inISOText);
virtual int GetTextInfo(
LO_TextStruct* inText,
LO_TextInfo* inTextInfo);
virtual int MeasureText(
LO_TextStruct* inText,
short* outCharLocs);
virtual void DisplayBullet(
int inLocation,
LO_BulletStruct* inBulletStruct);
virtual void FinishedLayout(void);
virtual void AllConnectionsComplete(void);
virtual void Progress(
const char* inMessageText);
virtual void GraphProgressInit(
URL_Struct* inURL,
Int32 inContentLength);
virtual void GraphProgressDestroy(
URL_Struct* inURL,
Int32 inContentLength,
Int32 inTotalRead);
virtual void GraphProgress(
URL_Struct* inURL,
Int32 inBytesReceived,
Int32 inBytesSinceLast,
Int32 inContentLength);
// Methods to stub out.
virtual void Alert(
const char* inAlertText);
virtual XP_Bool Confirm(
const char* inMessage);
virtual char* Prompt(
const char* inMessage,
const char* inDefaultText);
virtual XP_Bool PromptUsernameAndPassword(
const char* inMessage,
char** outUserName,
char** outPassword);
virtual char* PromptPassword(
const char* inMessage);
CNSContext* mUIContext;
};

View File

@@ -0,0 +1,205 @@
/* -*- 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.
*/
// CProxyDragTask.cp
#include "CProxyDragTask.h"
#include <LDragAndDrop.h>
#include <UException.h>
#include <UTextTraits.h>
#include <UGAColorRamp.h>
#include <LView.h>
#include "CProxyPane.h"
#include "StCaptureView.h"
#include "CGWorld.h"
#include "StRegionHandle.h"
#include "CEnvironment.h"
// ---------------------------------------------------------------------------
// ¥ CProxyDragTask
// ---------------------------------------------------------------------------
CProxyDragTask::CProxyDragTask(
LView& inProxyView,
CProxyPane& inProxyPane,
LCaption& inPageProxyCaption,
const EventRecord& inEventRecord,
CExtraFlavorAdder* inExtraFlavorAdder)
: mProxyView(inProxyView),
mProxyPane(inProxyPane),
mPageProxyCaption(inPageProxyCaption),
mExtraFlavorAdder(inExtraFlavorAdder),
Inherited(inEventRecord)
{
}
// ---------------------------------------------------------------------------
// ¥ ~CProxyDragTask
// ---------------------------------------------------------------------------
CProxyDragTask::~CProxyDragTask()
{
delete mExtraFlavorAdder;
}
// ---------------------------------------------------------------------------
// ¥ DoDrag
// ---------------------------------------------------------------------------
OSErr
CProxyDragTask::DoDrag()
{
MakeDragRegion(mDragRef, mDragRegion);
AddFlavors(mDragRef);
if (UEnvironment::HasFeature(env_HasDragMgrImageSupport))
{
try
{
DoTranslucentDrag();
}
catch (...)
{
DoNormalDrag();
}
}
else
{
DoNormalDrag();
}
return noErr;
}
// ---------------------------------------------------------------------------
// ¥ DoNormalDrag
// ---------------------------------------------------------------------------
void
CProxyDragTask::DoNormalDrag()
{
::TrackDrag(mDragRef, &mEventRecord, mDragRegion);
}
// ---------------------------------------------------------------------------
// ¥ DoTranslucentDrag
// ---------------------------------------------------------------------------
void
CProxyDragTask::DoTranslucentDrag()
{
Rect theFrame;
StColorPortState theColorPortState(mProxyView.GetMacPort());
// Normalize the color state (to make CopyBits happy)
StColorState::Normalize();
// Build a GWorld containing the page proxy icon and title
mProxyView.FocusDraw();
mProxyView.CalcLocalFrameRect(theFrame);
CGWorld theGWorld(theFrame, 0, useTempMem);
StCaptureView theCaptureView(mProxyView);
mPageProxyCaption.Show();
try
{
theCaptureView.Capture(theGWorld);
mProxyView.FocusDraw();
Point theOffsetPoint = topLeft(theFrame);
::LocalToGlobal(&theOffsetPoint);
// Set the drag image
StRegionHandle theTrackMask;
mProxyPane.CalcLocalFrameRect(theFrame);
ThrowIfOSErr_(::IconSuiteToRgn(theTrackMask, &theFrame, kAlignAbsoluteCenter, mProxyPane.GetIconSuiteH()));
mPageProxyCaption.CalcLocalFrameRect(theFrame); // Use frame which bounds the actual text, not the frame bounds
theTrackMask += theFrame;
PixMapHandle theMap = ::GetGWorldPixMap(theGWorld.GetMacGWorld());
OSErr theErr = ::SetDragImage(mDragRef, theMap, theTrackMask, theOffsetPoint, kDragDarkerTranslucency);
ThrowIfOSErr_(theErr);
// Track the drag
::TrackDrag(mDragRef, &mEventRecord, mDragRegion);
}
catch (...)
{
}
mPageProxyCaption.Hide();
}
// ---------------------------------------------------------------------------
// ¥ AddFlavorURL
// ---------------------------------------------------------------------------
void
CProxyDragTask::AddFlavors(DragReference inDragRef)
{
Inherited::AddFlavors(inDragRef);
if (mExtraFlavorAdder)
mExtraFlavorAdder->AddExtraFlavorData(inDragRef, static_cast<ItemReference>(this));
}
// ---------------------------------------------------------------------------
// ¥ MakeDragRegion
// ---------------------------------------------------------------------------
void
CProxyDragTask::MakeDragRegion(
DragReference /*inDragRef*/,
RgnHandle /*inDragRegion*/)
{
Rect theFrame;
// Add the page proxy icon region
StRegionHandle theTrackMask;
mProxyPane.CalcLocalFrameRect(theFrame);
ThrowIfOSErr_(::IconSuiteToRgn(theTrackMask, &theFrame, kAlignAbsoluteCenter, mProxyPane.GetIconSuiteH()));
theFrame = (**(RgnHandle)theTrackMask).rgnBBox;
::LocalToGlobal(&topLeft(theFrame));
::LocalToGlobal(&botRight(theFrame));
AddRectDragItem(static_cast<ItemReference>(&mProxyPane), theFrame);
// Add the page proxy caption region
mPageProxyCaption.CalcLocalFrameRect(theFrame);
::LocalToGlobal(&topLeft(theFrame));
::LocalToGlobal(&botRight(theFrame));
AddRectDragItem(static_cast<ItemReference>(&mPageProxyCaption), theFrame);
}

View File

@@ -0,0 +1,77 @@
/* -*- 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.
*/
// CProxyDragTask.h
#ifndef CProxyDragTask_H
#define CProxyDragTask_H
#pragma once
// Includes
#include "CBrowserDragTask.h"
#include "CProxyPane.h"
// Forward declarations
class LView;
class CProxyPane;
class LCaption;
// Class declaration
class CExtraFlavorAdder // to be called by AddFlavor. Allows a window to add extra flavors.
{
public:
virtual void AddExtraFlavorData(DragReference inDragRef, ItemReference inItemRef) = 0;
};
class CProxyDragTask : public CBrowserDragTask
{
public:
typedef CBrowserDragTask Inherited;
CProxyDragTask(
LView& inProxyView,
CProxyPane& inProxyPane,
LCaption& inPageProxyCaption,
const EventRecord& inEventRecord,
CExtraFlavorAdder* inFlavorAdder = nil);
virtual ~CProxyDragTask();
virtual OSErr DoDrag();
virtual void AddFlavors(DragReference inDragRef);
protected:
virtual void DoNormalDrag();
virtual void DoTranslucentDrag();
virtual void MakeDragRegion(
DragReference inDragRef,
RgnHandle inDragRegion);
LView& mProxyView;
CProxyPane& mProxyPane;
LCaption& mPageProxyCaption;
CExtraFlavorAdder* mExtraFlavorAdder;
};
#endif

View File

@@ -0,0 +1,125 @@
/* -*- 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 "CSaveProgress.h"
#include "fe_proto.h"
#include "CBrowserContext.h"
#include "resgui.h" // needed for EDITDLG_SAVE_PROGRESS
#include "uapp.h"
#include "edt.h"
#include "PascalString.h" // CStr255
#include "proto.h" // XP_InterruptContext
#include "macutil.h" // TrySetCursor
#pragma mark CSaveProgress
void CSaveProgress::FinishCreateSelf()
{
fFilenameText = (LCaption*)this->FindPaneByID( 'flnm' );
LDialogBox::FinishCreateSelf();
}
void CSaveProgress::SetFilename(char *pFileName)
{
if ( fFilenameText && pFileName )
fFilenameText->SetDescriptor( CStr255(pFileName) );
}
void CSaveProgress::ListenToMessage( MessageT inMessage, void* ioParam )
{
switch ( inMessage )
{
case msg_Cancel:
if ( fContext )
{
TrySetCursor( watchCursor );
#ifdef EDITOR
if ( EDT_IS_EDITOR( fContext ) )
EDT_SaveCancel( fContext );
else
#endif // EDITOR
XP_InterruptContext( fContext );
SetCursor( &qd.arrow );
}
break;
default:
LDialogBox::ListenToMessage( inMessage, ioParam );
break;
}
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
//
#pragma mark --- FTP Upload Dialog ---
//
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// FIX ME -- find way to use new CDownloadProgressWindow
// Most likely, we'll duplicate the code from downloading
void FE_SaveDialogCreate( MWContext *pContext, int /*iFileCount*/, ED_SaveDialogType /*saveType*/ )
{
try {
CSaveProgress * newWindow = (CSaveProgress*)LWindow::CreateWindow(
EDITDLG_SAVE_PROGRESS, CFrontApp::GetApplication());
if ( newWindow == NULL )
return;
UReanimator::LinkListenerToControls( newWindow, newWindow, EDITDLG_SAVE_PROGRESS );
newWindow->SetContext( pContext );
ExtractBrowserContext(pContext)->SetSaveDialog( newWindow );
newWindow->Show();
}
catch (...)
{
ExtractBrowserContext(pContext)->SetSaveDialog( NULL );
}
}
#ifdef EDITOR
void FE_SaveDialogSetFilename( MWContext *pContext, char *pFilename )
{
char *better = FE_URLToLocalName( pFilename );
if ( better )
{
if ( pContext && ExtractBrowserContext(pContext) && ExtractBrowserContext(pContext)->GetSaveDialog() )
ExtractBrowserContext(pContext)->GetSaveDialog()->SetFilename( better );
XP_FREE( better );
}
}
#endif // EDITOR
void FE_SaveDialogDestroy( MWContext *pContext, int /*status*/, char */*pFilename*/ )
{
if ( pContext && ExtractBrowserContext(pContext) && ExtractBrowserContext(pContext)->GetSaveDialog() )
{
ExtractBrowserContext(pContext)->GetSaveDialog()->ListenToMessage( cmd_Close, NULL );
ExtractBrowserContext(pContext)->SetSaveDialog( NULL );
}
}

View File

@@ -0,0 +1,40 @@
/* -*- 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.
*/
#pragma once
#include "CNSContext.h"
class CSaveProgress: public LDialogBox
{
public:
enum { class_ID = 'EDL4' };
CSaveProgress( LStream* inStream ): LDialogBox( inStream ){};
virtual void FinishCreateSelf();
void SetFilename( char *pFilename );
virtual void ListenToMessage( MessageT inMessage, void* ioParam );
void SetContext( MWContext* context ) {fContext = context;}
protected:
LCaption* fFilenameText;
MWContext* fContext;
};

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// CSecureAttachment.cp
#pragma once
#include "CSecureAttachment.h"
#include "xp_core.h"
#include "secnav.h"
#include "secrng.h"
CSecureAttachment::CSecureAttachment()
: LAttachment(msg_Event)
{
mTickCounter = 0;
}
void CSecureAttachment::ExecuteSelf(
MessageT inMessage,
void *ioParam)
{
if (mTickCounter < 500)
{
EventRecord* theEvent = (EventRecord*)ioParam;
RNG_RandomUpdate(theEvent, sizeof(EventRecord));
long ticks = ::TickCount();
RNG_RandomUpdate(&ticks, sizeof(long));
mTickCounter++;
}
else
delete this;
}

View File

@@ -0,0 +1,42 @@
/* -*- 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.
*/
// CSecureAttachment.h
// Initializes the random seed of the security library. Add this
// attachment to application startup.
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
#pragma once
#include <LAttachment.h>
class CSecureAttachment : public LAttachment
{
public:
CSecureAttachment();
protected:
virtual void ExecuteSelf(
MessageT inMessage,
void *ioParam);
Uint32 mTickCounter;
};

View File

@@ -0,0 +1,282 @@
/* -*- 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 "CTSMEditField.h"
Boolean CTSMEditField::sInitialized = false;
Boolean CTSMEditField::sHasTSM = false;
TSMTEPreUpdateUPP CTSMEditField::sPreUpdateUPP = NewTSMTEPreUpdateProc( CTSMEditField::PreUpdate );
TSMTEPostUpdateUPP CTSMEditField::sPostUpdateUPP = NewTSMTEPostUpdateProc( CTSMEditField::PostUpdate );
// Default constructor
CTSMEditField::CTSMEditField ()
{
} // CTSMEditField::CTSMEditField
CTSMEditField::CTSMEditField( LStream* inStream )
: LEditField( inStream )
{
if ( !sInitialized )
Initialize();
OSErr result = noErr;
OSType theServiceTypes = kTSMTEInterfaceType;
mTSMDocID = 0;
mTSMTEHandle = NULL;
Try_
{
if ( sHasTSM )
{
result = ::NewTSMDocument( 1, &theServiceTypes, &mTSMDocID, static_cast<long>(&mTSMTEHandle) );
ThrowIfOSErr_( result );
if ( !mTSMTEHandle && mTSMDocID )
{
::DeleteTSMDocument( mTSMDocID );
mTSMDocID = 0;
Throw_( paramErr );
}
(*mTSMTEHandle)->textH = mTextEditH;
(*mTSMTEHandle)->preUpdateProc = sPreUpdateUPP;
(*mTSMTEHandle)->postUpdateProc = sPostUpdateUPP;
(*mTSMTEHandle)->updateFlag = kTSMTEAutoScroll;
(*mTSMTEHandle)->refCon = (Int32)this;
}
}
Catch_( inErr )
{
// Failure just means that this edit field won't support TSMTE
}
EndCatch_;
}
//
// Parameterized constructor
CTSMEditField::CTSMEditField ( const SPaneInfo& inPaneInfo,
Str255 inString,
ResIDT inTextTraitsID,
Int16 inMaxChars,
Uint8 inAttributes,
TEKeyFilterFunc inKeyFilter,
LCommander* inSuper)
: LEditField ( inPaneInfo,
inString,
inTextTraitsID,
inMaxChars,
inAttributes,
inKeyFilter,
inSuper )
{
} // CTSMEditField::CTSMEditField
CTSMEditField::~CTSMEditField()
{
OSErr result = noErr;
try
{
if ( mTSMDocID != 0 )
{
::FixTSMDocument( mTSMDocID );
::DeactivateTSMDocument( mTSMDocID ); // for a bug in TSM. See TE27
result = ::DeleteTSMDocument( mTSMDocID );
Assert_( result == noErr );
mTSMDocID = 0;
}
}
catch ( ... )
{
}
}
pascal void
CTSMEditField::PreUpdate( TEHandle inTEHandle, Int32 inRefCon )
{
CTSMEditField *theOwnerEditField = NULL;
if ( inRefCon != NULL )
{
theOwnerEditField = reinterpret_cast<CTSMEditField *>( inRefCon );
theOwnerEditField->FocusDraw();
}
}
pascal void
CTSMEditField::PostUpdate(
TEHandle inTEHandle,
Int32 fixLen,
Int32 inputAreaStart,
Int32 inputAreaEnd,
Int32 pinStart,
Int32 pinEnd,
Int32 inRefCon )
{
CTSMEditField *theOwnerEditField = NULL;
if ( inRefCon != NULL && fixLen > 0 )
{
theOwnerEditField = reinterpret_cast<CTSMEditField *>( inRefCon );
// Undo of TSM input is currently not supported.
//
if (theOwnerEditField->mTypingAction != NULL)
theOwnerEditField->mTypingAction->Reset();
}
}
void CTSMEditField::BeTarget( void )
{
OSErr result = noErr;
short oldScript = ::GetScriptManagerVariable(smKeyScript);
#ifdef Debug_Signal
OSErr err;
// check to see if a bug in TSM will be encountered
ProcessSerialNumber psn,
csn;
err = GetCurrentProcess(&psn);
err = GetFrontProcess(&csn);
Assert_((psn.highLongOfPSN == csn.highLongOfPSN) && (psn.lowLongOfPSN == csn.lowLongOfPSN));
#endif
FocusDraw();
LEditField::BeTarget();
if ( mTSMDocID != NULL )
{
result = ::ActivateTSMDocument( mTSMDocID );
Assert_( result == noErr );
}
if (oldScript != ::GetScriptManagerVariable(smKeyScript))
::KeyScript(oldScript);
}
void
CTSMEditField::DontBeTarget( void )
{
OSErr result = noErr;
FocusDraw();
if ( mTSMDocID != NULL )
{
::FixTSMDocument( mTSMDocID );
result = ::DeactivateTSMDocument( mTSMDocID );
Assert_( result == noErr );
}
LEditField::DontBeTarget();
}
void
CTSMEditField::Initialize()
{
OSErr result = noErr;
SInt32 gestaltResponse = 0;
Assert_( sInitialized == false );
if ( sInitialized == false )
{
sInitialized = true;
result = ::Gestalt( gestaltTSMgrVersion, &gestaltResponse );
if ( (result == noErr) && (gestaltResponse >= 1) )
{
result = ::Gestalt( gestaltTSMTEAttr, &gestaltResponse );
if ( (result == noErr) && ((gestaltResponse >> gestaltTSMTEPresent) & 1) )
{
sHasTSM = true;
}
}
}
}

View File

@@ -0,0 +1,78 @@
/* -*- 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.
*/
#pragma once
#include <TextEdit.h>
#include <TextServices.h>
#include <TSMTE.h>
#include <LEditField.h>
class CTSMEditField : public LEditField
{
public:
enum
{
class_ID = 'Tedt'
};
CTSMEditField(); // ¥ Default Constructor
CTSMEditField( LStream *inStream); // ¥ Stream Constructor
CTSMEditField ( const SPaneInfo& inPaneInfo,
Str255 inString,
ResIDT inTextTraitsID,
Int16 inMaxChars,
Uint8 inAttributes,
TEKeyFilterFunc inKeyFilter,
LCommander* inSuper);
// ¥ Parameterized Constructor
virtual ~CTSMEditField();
static pascal void PreUpdate( TEHandle inTEHandle,
Int32 inRefCon);
static pascal void PostUpdate(
TEHandle inTEHandle,
Int32 fixLen,
Int32 inputAreaStart,
Int32 inputAreaEnd,
Int32 pinStart,
Int32 pinEnd,
Int32 inRefCon );
protected:
virtual void BeTarget(void);
virtual void DontBeTarget(void);
virtual void Initialize();
TSMDocumentID mTSMDocID;
TSMTERecHandle mTSMTEHandle;
static Boolean sInitialized;
static Boolean sHasTSM;
static TSMTEPreUpdateUPP sPreUpdateUPP;
static TSMTEPostUpdateUPP sPostUpdateUPP;
};

View File

@@ -0,0 +1,92 @@
/* -*- 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.
*/
// CTargetedUpdateMenuRegistry.cp
//
// CTargetedUpdateMenuRegistry is used in conjunction with LEventDispatchers
// which are CTargetedUpdateMenuRegistry-aware to enable a more targeted
// update of menus.
//
// One common example of this is menu items whose text should change when
// certain modifiers are held down (Close -> Close All when optionKey is
// held down, for example).
//
// Usage notes for callers of UpdateMenus:
//
// (1) Call SetCommands with a list of commands which should be updated.
// (2) Call UpdateMenus.
//
// Usage notes for implementors of UpdateMenus:
//
// (1) When looping through commands in menus, determine if the registry
// is active by calling UseRegistryToUpdateMenus.
// (2) If the registry is active, then check to see if the command is
// in the registry by calling CommandInRegistry before processing
// command status for the command.
//
// Note: For the targeted update to be useful, there should generally be
// a very small number of targeted commands. In fact, command lookup will
// slow down if there are too many commands.
#include "CTargetedUpdateMenuRegistry.h"
// === Static Members ===
Boolean CTargetedUpdateMenuRegistry::sUseRegistryToUpdateMenus = false;
list<CommandT> CTargetedUpdateMenuRegistry::sCommands;
// ---------------------------------------------------------------------------
// ¥ SetCommands
// ---------------------------------------------------------------------------
void
CTargetedUpdateMenuRegistry::SetCommands(
const list<CommandT>& inCommands)
{
sCommands = inCommands;
}
// ---------------------------------------------------------------------------
// ¥ UpdateMenus
// ---------------------------------------------------------------------------
void
CTargetedUpdateMenuRegistry::UpdateMenus()
{
if (LEventDispatcher::GetCurrentEventDispatcher())
{
StValueChanger<Boolean> setUseRegistryToUpdateMenus(sUseRegistryToUpdateMenus, true);
LEventDispatcher::GetCurrentEventDispatcher()->UpdateMenus();
}
}
// ---------------------------------------------------------------------------
// ¥ CommandInRegistry
// ---------------------------------------------------------------------------
Boolean
CTargetedUpdateMenuRegistry::CommandInRegistry(CommandT inCommand)
{
list<CommandT>::const_iterator theCommand = find(
sCommands.begin(),
sCommands.end(),
inCommand);
return (theCommand != sCommands.end());
}

View File

@@ -0,0 +1,91 @@
/* -*- 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.
*/
// CTargetedUpdateMenuRegistry.h
//
// CTargetedUpdateMenuRegistry is used in conjunction with LEventDispatchers
// which are CTargetedUpdateMenuRegistry-aware to enable a more targeted
// update of menus.
//
// One common example of this is menu items whose text should change when
// certain modifiers are held down (Close -> Close All when optionKey is
// held down, for example).
//
// Usage notes for callers of UpdateMenus:
//
// (1) Call SetCommands with a list of commands which should be updated.
// (2) Call UpdateMenus.
//
// Usage notes for implementors of UpdateMenus:
//
// (1) When looping through commands in menus, determine if the registry
// is active by calling UseRegistryToUpdateMenus.
// (2) If the registry is active, then check to see if the command is
// in the registry by calling CommandInRegistry before processing
// command status for the command.
//
// Note: For the targeted update to be useful, there should generally be
// a very small number of targeted commands. In fact, command lookup will
// slow down if there are too many commands.
#ifndef CTargetedUpdateMenuRegistry_H
#define CTargetedUpdateMenuRegistry_H
#pragma once
// Includes
#include <list>
#include <algorithm>
#include <LCommander.h>
#include <LEventDispatcher.h>
// Class declaration
class CTargetedUpdateMenuRegistry
{
public:
// Interface for callers of UpdateMenus
static void SetCommands(const list<CommandT>& inCommands);
static void UpdateMenus();
// Interface for implementors of UpdateMenus
static Boolean CommandInRegistry(CommandT inCommand);
static Boolean UseRegistryToUpdateMenus();
private:
static Boolean sUseRegistryToUpdateMenus;
static list<CommandT> sCommands;
};
// Inline methods
inline
Boolean
CTargetedUpdateMenuRegistry::UseRegistryToUpdateMenus()
{
return sUseRegistryToUpdateMenus;
}
#endif

View File

@@ -0,0 +1,883 @@
/* -*- 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.
*/
// CURLDispatcher.cp
#include "CURLDispatcher.h"
#include "CNSContext.h"
#include "CBrowserWindow.h"
#include "CDownloadProgressWindow.h"
#include "CWindowMediator.h"
#include "CBrowserContext.h"
#include "CBrowserWindow.h"
#ifdef MOZ_MAIL_NEWS
#include "CMailNewsWindow.h"
#include "CThreadWindow.h"
#include "CMessageWindow.h"
#endif
#include "URobustCreateWindow.h"
#include "uapp.h"
#include "CHTMLClickRecord.h"
#include "CAutoPtr.h"
#include "CAutoPtrXP.h"
#include "cstring.h"
#include "xp.h"
#include "macutil.h"
#include "umimemap.h"
#include "ufilemgr.h"
#include "uprefd.h"
#include "xlate.h"
#include "msv2dsk.h"
#include "msgcom.h"
#include "uerrmgr.h" // Need for GetCString
#include "resgui.h"
CBrowserWindow* CURLDispatcher::sLastBrowserWindowCreated = NULL;
CAutoPtr<CURLDispatcher> CURLDispatcher::sDispatcher;
CAutoPtr<CBrowserContext> CURLDispatcher::sDispatchContext;
// URL dispatch proc table
// URL types listed in net.h are indices into this table.
// **** NOTE: URL types in net.h start at 1 ****
const Uint32 cNumURLTypes = 39;
static DispatchProcPtr dispatchProcs[] =
{
CURLDispatcher::DispatchToBrowserWindow // Unknown URL type 0
, CURLDispatcher::DispatchToBrowserWindow // FILE_TYPE_URL 1
, CURLDispatcher::DispatchToBrowserWindow // FTP_TYPE_URL 2
, CURLDispatcher::DispatchToBrowserWindow // GOPHER_TYPE_URL 3
, CURLDispatcher::DispatchToBrowserWindow // HTTP_TYPE_URL 4
, CURLDispatcher::DispatchToLibNet // MAILTO_TYPE_URL 5
//, CURLDispatcher::DispatchToMailNewsWindow // NEWS_TYPE_URL 6
, CURLDispatcher::DispatchMailboxURL // NEWS_TYPE_URL 6 (use mailbox code)
, NULL // RLOGIN_TYPE_URL 7
, CURLDispatcher::DispatchToBrowserWindow // TELNET_TYPE_URL 8
, CURLDispatcher::DispatchToBrowserWindow // TN3270_TYPE_URL 9
, NULL // WAIS_TYPE_URL 10
, CURLDispatcher::DispatchToBrowserWindow // ABOUT_TYPE_URL 11
, NULL // FILE_CACHE_TYPE_URL 12
, NULL // MEMORY_CACHE_TYPE_URL 13
, CURLDispatcher::DispatchToBrowserWindow // SECURE_HTTP_TYPE_URL 14
, NULL // INTERNAL_IMAGE_TYPE_URL 15
, NULL // URN_TYPE_URL 16
, NULL // POP3_TYPE_URL 17
, CURLDispatcher::DispatchMailboxURL // MAILBOX_TYPE_URL 18
, NULL // INTERNAL_NEWS_TYPE_URL 19
, CURLDispatcher::DispatchToBrowserWindow // SECURITY_TYPE_URL 20
, CURLDispatcher::DispatchToBrowserWindow // MOCHA_TYPE_URL 21
, CURLDispatcher::DispatchToBrowserWindow // VIEW_SOURCE_TYPE_URL 22
, NULL // HTML_DIALOG_HANDLER_TYPE_URL 23
, NULL // HTML_PANEL_HANDLER_TYPE_URL 24
, NULL // INTERNAL_SECLIB_TYPE_URL 25
, NULL // MSG_SEARCH_TYPE_URL 26
, CURLDispatcher::DispatchMailboxURL // IMAP_TYPE_URL 27
, CURLDispatcher::DispatchToLibNet // LDAP_TYPE_URL 28
, NULL // SECURE_LDAP_TYPE_URL 29
, CURLDispatcher::DispatchToBrowserWindow // WYSIWYG_TYPE_URL 30
, CURLDispatcher::DispatchToLibNet // ADDRESS_BOOK_TYPE_URL 31
, NULL // CLASSID_TYPE_URL 32
, NULL // JAVA_TYPE_URL 33
, NULL // DATA_TYPE_URL 34
, CURLDispatcher::DispatchToLibNet // NETHELP_TYPE_URL 35
, NULL // NFS_TYPE_URL 36
, CURLDispatcher::DispatchToBrowserWindow // MARIMBA_TYPE_URL 37
, NULL // INTERNAL_CERTLDAP_TYPE_URL 38
};
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
CURLDispatcher* CURLDispatcher::GetURLDispatcher() // singleton class
{
if (!sDispatcher.get())
{
sDispatcher.reset(new CURLDispatcher);
}
return sDispatcher.get();
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
CURLDispatcher::CURLDispatcher()
: mDelayedURLs(sizeof(CURLDispatchInfo*))
{
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
CURLDispatcher::~CURLDispatcher()
{
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::DispatchToStorage(
URL_Struct* inURL,
const FSSpec& inDestSpec,
FO_Present_Types inOutputFormat,
Boolean inDelay)
{
Assert_((inOutputFormat == FO_SAVE_AS) || (inOutputFormat == FO_SAVE_AS_TEXT));
if (!inDelay)
{
CURLDispatchInfo* dispatchInfo =
new CURLDispatchInfo(inURL, nil, inOutputFormat, inDelay, false, true);
dispatchInfo->SetFileSpec(inDestSpec);
if (inOutputFormat == FO_SAVE_AS)
{
DispatchToDisk(dispatchInfo);
}
else
DispatchToDiskAsText(dispatchInfo);
}
else
{
CURLDispatchInfo* theDelay =
new CURLDispatchInfo(inURL, nil, inOutputFormat, true, false, true);
theDelay->SetFileSpec(inDestSpec);
GetURLDispatcher()->PostPendingDispatch(theDelay);
}
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::DispatchToStorage(CURLDispatchInfo* inDispatchInfo)
{
Assert_((inDispatchInfo->GetOutputFormat() == FO_SAVE_AS) || (inDispatchInfo->GetOutputFormat() == FO_SAVE_AS_TEXT));
if (!inDispatchInfo->GetDelay())
{
if (inDispatchInfo->GetOutputFormat() == FO_SAVE_AS)
DispatchToDisk(inDispatchInfo);
else
DispatchToDiskAsText(inDispatchInfo);
}
else
{
GetURLDispatcher()->PostPendingDispatch(inDispatchInfo);
}
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::SpendTime(const EventRecord& /*inMacEvent*/)
{
if (mDelayedURLs.GetCount() > 0)
ProcessPendingDispatch();
else
StopIdling();
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::ListenToMessage(
MessageT inMessage,
void* ioParam)
{
if ((inMessage == msg_BroadcasterDied) && (mDelayedURLs.GetCount() > 0))
UpdatePendingDispatch((CNSContext*)ioParam);
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
XP_List* gAppleDoubleSpecList = nil; // for the ad decoder (see ad_decode.c)
void CURLDispatcher::DispatchToDisk(CURLDispatchInfo* inDispatchInfo)
{
CBrowserContext* theContext = NULL;
CDownloadProgressWindow* theProgressWindow = NULL;
FSSpec& destSpec = inDispatchInfo->GetFileSpec();
URL_Struct* inURL = inDispatchInfo->GetURLStruct();
CAutoPtr<CURLDispatchInfo> info(inDispatchInfo);
Assert_(inURL != NULL);
try
{
theContext = new CBrowserContext(MWContextSaveToDisk);
StSharer theShareLock(theContext);
theProgressWindow = dynamic_cast<CDownloadProgressWindow*>(URobustCreateWindow::CreateWindow(WIND_DownloadProgress, LCommander::GetTopCommander()));
ThrowIfNULL_(theProgressWindow);
theProgressWindow->Show();
inURL->fe_data = StructCopy(&destSpec, sizeof(FSSpec));
if (destSpec.name[0] != '\0')
{
// Put the spec into our global variable where the ad decoder will find it.
if (!gAppleDoubleSpecList)
gAppleDoubleSpecList = XP_ListNew();
FSSpec* spec = (FSSpec*)XP_ALLOC(sizeof(FSSpec));
FailNIL_(spec);
OSErr err = CFileMgr::UniqueFileSpec(destSpec, destSpec.name, *spec);
if (err)
throw err;
XP_ListAddObjectToEnd(gAppleDoubleSpecList, spec);
}
theProgressWindow->SetWindowContext(theContext);
// the window will be shown on the first progress call.
theContext->ImmediateLoadURL(inDispatchInfo->ReleaseURLStruct(), FO_SAVE_AS);
}
catch (...)
{
delete theProgressWindow;
XP_ListDestroy(gAppleDoubleSpecList);
gAppleDoubleSpecList = nil;
throw;
}
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
extern "C" void SaveAsCompletionProc( PrintSetup* p );
void CURLDispatcher::DispatchToDiskAsText(CURLDispatchInfo* inDispatchInfo)
{
CNSContext* theContext = NULL;
CDownloadProgressWindow* theProgressWindow = NULL;
FSSpec& destSpec = inDispatchInfo->GetFileSpec();
URL_Struct* inURL = inDispatchInfo->GetURLStruct();
Assert_(inURL != NULL);
try
{
theContext = new CNSContext(MWContextSaveToDisk);
StSharer theShareLock(theContext);
theProgressWindow = dynamic_cast<CDownloadProgressWindow*>(URobustCreateWindow::CreateWindow(WIND_DownloadProgress, LCommander::GetTopCommander()));
ThrowIfNULL_(theProgressWindow);
theProgressWindow->SetWindowContext(theContext);
CMimeMapper *theMapper = CPrefs::sMimeTypes.FindMimeType(CMimeList::HTMLViewer);
OSType creator = emSignature, docType='TEXT';
if (theMapper != NULL && CMimeMapper::Launch == theMapper->GetLoadAction())
{
creator = theMapper->GetAppSig();
docType = theMapper->GetDocType();
}
OSErr theErr = ::FSpCreate(&destSpec, creator, docType, 0);
if ((theErr != noErr) && (theErr != dupFNErr))
ThrowIfOSErr_(theErr);
CFileMgr::FileSetComment(destSpec, NET_URLStruct_Address(inURL));
char* thePath = CFileMgr::EncodedPathNameFromFSSpec(destSpec, TRUE);
ThrowIfNULL_(thePath);
thePath = NET_UnEscape(thePath);
XP_File theFile = XP_FileOpen(thePath, xpURL, XP_FILE_WRITE);
XP_FREE(thePath);
ThrowIfNULL_(theFile);
PrintSetup print;
XL_InitializeTextSetup(&print);
print.width = 76;
print.out = theFile;
print.completion = (XL_CompletionRoutine) SaveAsCompletionProc;
print.carg = (void*)(theContext);
print.filename = nil;
print.url = inURL;
inURL->fe_data = theContext;
MWContext* textContext = (MWContext*) XL_TranslateText(*theContext, inURL, &print);
}
catch(...)
{
}
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::PostPendingDispatch(CURLDispatchInfo* inDispatchInfo)
{
mDelayedURLs.InsertItemsAt(1, LArray::index_Last, &inDispatchInfo, sizeof(CURLDispatchInfo*));
StartIdling();
if (inDispatchInfo->GetTargetContext() != NULL)
inDispatchInfo->GetTargetContext()->AddListener(this);
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::UpdatePendingDispatch(
CNSContext* inForContext)
{
Assert_(inForContext != NULL);
CURLDispatchInfo* theInfo;
LArrayIterator theIter(mDelayedURLs, LArrayIterator::from_Start);
while (theIter.Next(&theInfo))
{
if (theInfo->GetTargetContext() == inForContext)
mDelayedURLs.RemoveItemsAt(1, theIter.GetCurrentIndex());
}
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::ProcessPendingDispatch(void)
{
if (CFrontApp::GetApplication()->HasProperlyStartedUp())
{
CURLDispatchInfo* theInfo;
mDelayedURLs.FetchItemAt(LArray::index_First, &theInfo);
// 97-06-10 pkc -- Hack to workaround trying to dispatch URL's on image
// anchors while mocha is loading image
CBrowserContext* browserContext =
dynamic_cast<CBrowserContext*>(theInfo->GetTargetContext());
if (theInfo->GetIsWaitingForMochaImageLoad() &&
theInfo->GetTargetContext())
{
if (browserContext && browserContext->IsMochaLoadingImages())
{
// The context is loading images for mocha, don't
// perform dispatch
return;
}
}
mDelayedURLs.RemoveItemsAt(1, LArray::index_First);
if (theInfo->GetTargetContext() != NULL)
theInfo->GetTargetContext()->RemoveListener(this);
theInfo->ClearDelay();
if (theInfo->GetIsSaving())
DispatchToStorage(theInfo);
else
{
// See if this delayed URL was for an ftp drag &drop
if (theInfo->GetURLStruct()->files_to_post)
{
// See if the user really meant to upload
if (browserContext && !browserContext->Confirm((const char*)GetCString(MAC_UPLOAD_TO_FTP))) /* l10n */
{
// Delete the info if not
delete theInfo;
}
else
{
// Ship it!
DispatchURL(theInfo);
}
}
else
{
// Plain ordinary delayed URL
DispatchURL(theInfo);
}
}
}
}
// 97-05-13 pkc
// New URL dispatch mechanism.
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::DispatchURL(
const char* inURL,
CNSContext* inTargetContext,
Boolean inDelay,
Boolean inForceCreate,
ResIDT inWindowResID,
Boolean inInitiallyVisible,
FO_Present_Types inOutputFormat,
NET_ReloadMethod inReloadMethod)
{
CURLDispatchInfo* dispatchInfo =
new CURLDispatchInfo(
inURL,
inTargetContext,
inOutputFormat,
inReloadMethod,
inDelay,
inForceCreate,
false,
inWindowResID,
inInitiallyVisible
);
DispatchURL(dispatchInfo);
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::DispatchURL(
URL_Struct* inURLStruct,
CNSContext* inTargetContext,
Boolean inDelay,
Boolean inForceCreate,
ResIDT inWindowResID,
Boolean inInitiallyVisible,
FO_Present_Types inOutputFormat,
Boolean inWaitingForMochaImageLoad)
{
CURLDispatchInfo* dispatchInfo =
new CURLDispatchInfo(
inURLStruct,
inTargetContext,
inOutputFormat,
inDelay,
inForceCreate,
false,
inWindowResID,
inInitiallyVisible,
inWaitingForMochaImageLoad
);
DispatchURL(dispatchInfo);
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::DispatchURL(CURLDispatchInfo* inDispatchInfo)
{
XP_ASSERT(inDispatchInfo != NULL);
// FIX ME??? Does this go here?
sLastBrowserWindowCreated = NULL;
// paranoia
if (inDispatchInfo)
{
if (inDispatchInfo->GetDelay())
{
GetURLDispatcher()->PostPendingDispatch(inDispatchInfo);
}
// Check to make sure URL type index is within dispatch table bounds
else if (inDispatchInfo->GetURLType() < cNumURLTypes)
{
// Get dispatch proc from table
DispatchProcPtr dispatchProc = dispatchProcs[inDispatchInfo->GetURLType()];
if (dispatchProc)
{
(*dispatchProc)(inDispatchInfo);
}
}
}
}
#pragma mark -- Dispatch Procs --
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::DispatchToLibNet(CURLDispatchInfo* inDispatchInfo)
{
CAutoPtr<CURLDispatchInfo> info(inDispatchInfo);
// If someone passed in a context, use it.
if (inDispatchInfo->GetTargetContext())
{
inDispatchInfo->GetTargetContext()->ImmediateLoadURL(inDispatchInfo->ReleaseURLStruct(), inDispatchInfo->GetOutputFormat());
}
else
{
try
{
if (!sDispatchContext.get())
{
sDispatchContext.reset(new CBrowserContext());
}
sDispatchContext->ImmediateLoadURL(inDispatchInfo->ReleaseURLStruct(), inDispatchInfo->GetOutputFormat());
}
catch (...)
{
}
}
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::DispatchToBrowserWindow(CURLDispatchInfo* inDispatchInfo)
{
CAutoPtr<CURLDispatchInfo> info(inDispatchInfo);
if (!inDispatchInfo->GetDelay())
{
if (inDispatchInfo->GetForceCreate())
{
// Must create a new window
DispatchToNewBrowserWindow(info.release());
}
else if (inDispatchInfo->GetTargetContext())
{
// Use target context if passed in
// 97-09-18 pchen -- use target if it's not "_self"
// I found "_current" in npglue.c; do we need to filter that also?
if (inDispatchInfo->GetURLStruct()->window_target &&
XP_STRCASECMP(inDispatchInfo->GetURLStruct()->window_target, "_self"))
{
/* The thinking here is that if the URL specifies a preferred window target,
it's not safe to use the given context. There is a known case where
this is so; it involves a link in a subframe which links to an image
and contains a "target" tag. In this case, we use the only context
always known to be safe: the one belonging to the window itself.
This is precisely correct if the tag is "target = _top". I feel
queasy guaranteeing that it's correct for other values of target
as well, but pchen thinks it will always work. So: */
CBrowserContext *topContext;
topContext = ExtractBrowserContext(*inDispatchInfo->GetTargetContext());
inDispatchInfo->SetTargetContext(topContext->GetTopContext());
}
(inDispatchInfo->GetTargetContext())->SwitchLoadURL(inDispatchInfo->ReleaseURLStruct(), inDispatchInfo->GetOutputFormat());
}
else
{
// Find topmost "regular" browser window and dispatch into that window
CWindowMediator* theMediator = CWindowMediator::GetWindowMediator();
CBrowserWindow* theTopWindow =
dynamic_cast<CBrowserWindow*>(theMediator->FetchTopWindow(WindowType_Browser, regularLayerType, false));
if (theTopWindow)
{
theTopWindow->Select();
CNSContext* theCurrentContext = theTopWindow->GetWindowContext();
theCurrentContext->SwitchLoadURL(inDispatchInfo->ReleaseURLStruct(), inDispatchInfo->GetOutputFormat());
}
else
{
// No "regular" browser window available, so create one
DispatchToNewBrowserWindow(info.release());
}
}
}
else
{
GetURLDispatcher()->PostPendingDispatch(info.release());
}
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::DispatchMailboxURL(CURLDispatchInfo* inDispatchInfo)
{
#ifdef MOZ_MAIL_NEWS
const char* urlAddress = inDispatchInfo->GetURL();
// Test to see if this is an attachment URL
if (XP_STRSTR(urlAddress, "?part=") || XP_STRSTR(urlAddress, "&part="))
{
// This is a mail attachment, dispatch to browser window
CURLDispatcher::DispatchToBrowserWindow(inDispatchInfo);
}
else if (inDispatchInfo->GetForceCreate())
{
CMessageWindow::OpenFromURL (urlAddress);
/* note: we can't handle an internal link (as in the clause just below), so
we don't bother trying. Just load the message and let the user ask again
once that's completed, if it's really important to go to an internal link. */
}
else if (XP_STRCHR(urlAddress, '#'))
{
// 97-06-08 pkc -- handle internal links here
if (inDispatchInfo->GetTargetContext())
inDispatchInfo->GetTargetContext()->SwitchLoadURL(
inDispatchInfo->ReleaseURLStruct(),
inDispatchInfo->GetOutputFormat());
}
else
{
// Otherwise, call DispatchToMailNewsWindow
DispatchToMailNewsWindow(inDispatchInfo);
}
#endif // MOZ_MAIL_NEWS
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::DispatchToMailNewsWindow(CURLDispatchInfo* inDispatchInfo)
{
#ifdef MOZ_MAIL_NEWS
CAutoPtr<CURLDispatchInfo> info(inDispatchInfo);
CAutoPtrXP<char> url(XP_STRDUP(inDispatchInfo->GetURL()));
const char* urlAddress = url.get();
// Otherwise, call CMessageWindow::OpenFromURL
switch (MSG_PaneTypeForURL(urlAddress))
{
case MSG_MAILINGLISTPANE:
// ? Open a list window to allow editing of this list?
// Ask someone. Phil? Michelle?
break;
case MSG_ADDRPANE:
// Can't happen, MSG_PaneTypeForURL doesn't return this type,
// but a future release should, and MSG_NewWindowRequired should
// then return true.
break;
case MSG_FOLDERPANE:
CMailNewsFolderWindow::FindAndShow(true);
break;
case MSG_THREADPANE:
CThreadWindow::OpenFromURL(urlAddress);
break;
case MSG_MESSAGEPANE:
CMessageWindow::OpenFromURL((char*)urlAddress);
break;
case MSG_SUBSCRIBEPANE:
// Can't happen, MSG_PaneTypeForURL doesn't return this type,
// but a future release should, and MSG_NewWindowRequired should
// then return true.
// CSubscribePane::FindAndShow();
break;
case MSG_ANYPANE: // this gets returned for most URLs
case MSG_COMPOSITIONPANE:
// presumably, this is from a mailto:, and we handle this already, below.
case MSG_SEARCHPANE:
// Already handled below.
default:
break;
}
#endif // MOZ_MAIL_NEWS
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CURLDispatcher::DispatchToNewBrowserWindow(CURLDispatchInfo* inDispatchInfo)
{
CAutoPtr<CURLDispatchInfo> info(inDispatchInfo);
CBrowserWindow* theBrowserWindow = NULL;
CNSContext* theContext = NULL;
URL_Struct* theURLStruct = inDispatchInfo->GetURLStruct();
XP_ASSERT(inDispatchInfo != NULL);
if (inDispatchInfo)
{
theBrowserWindow = CreateNewBrowserWindow(inDispatchInfo->GetWindowResID(), false);
if (theBrowserWindow)
{
theContext = theBrowserWindow->GetWindowContext();
if (theURLStruct != nil)
{
if (theURLStruct->window_target && theURLStruct->window_target[0] != '_')
{
// ¥ do not assign special names
theContext->SetDescriptor(theURLStruct->window_target);
}
if (theURLStruct->window_target)
theURLStruct->window_target[0] = 0;
theContext->ImmediateLoadURL(inDispatchInfo->ReleaseURLStruct(), inDispatchInfo->GetOutputFormat());
}
if (inDispatchInfo->GetInitiallyVisible()) theBrowserWindow->Show();
}
}
}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
CBrowserWindow* CURLDispatcher::CreateNewBrowserWindow(
ResIDT inWindowResID,
Boolean inInitiallyVisible)
{
CBrowserWindow* theBrowserWindow = NULL;
CBrowserContext* theContext = NULL;
try
{
theContext = new CBrowserContext();
StSharer theShareLock(theContext);
theBrowserWindow =
dynamic_cast<CBrowserWindow*>(URobustCreateWindow::CreateWindow(inWindowResID, LCommander::GetTopCommander()));
ThrowIfNULL_(theBrowserWindow);
theBrowserWindow->SetWindowContext(theContext);
sLastBrowserWindowCreated = theBrowserWindow;
if (inInitiallyVisible)
theBrowserWindow->Show();
}
catch (...)
{
delete theBrowserWindow;
throw;
}
return theBrowserWindow;
}
#pragma mark -
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
CURLDispatchInfo::CURLDispatchInfo()
: mURLType(HTTP_TYPE_URL),
mURLStruct(NULL),
mTargetContext(NULL),
mOutputFormat(NET_DONT_RELOAD),
mDelayDispatch(false),
mIsSaving(false),
mForceCreate(false),
mInitiallyVisible(true),
mIsWaitingForMochaImageLoad(false),
mWindowResID(1010)
{
}
CURLDispatchInfo::CURLDispatchInfo(
const char* inURL,
CNSContext* inTargetContext,
FO_Present_Types inOutputFormat,
NET_ReloadMethod inReloadMethod,
Boolean inDelay,
Boolean inForceCreate,
Boolean inIsSaving,
ResIDT inWindowResID,
Boolean inInitiallyVisible)
: mTargetContext(NULL),
mOutputFormat(inOutputFormat),
mDelayDispatch(inDelay),
mForceCreate(inForceCreate),
mIsSaving(inIsSaving),
mInitiallyVisible(inInitiallyVisible),
mIsWaitingForMochaImageLoad(false),
mWindowResID(inWindowResID)
{
mURLStruct = NET_CreateURLStruct(inURL, inReloadMethod);
if (inTargetContext)
{
cstring theReferer = inTargetContext->GetCurrentURL();
if (theReferer.length() > 0)
mURLStruct->referer = XP_STRDUP(theReferer);
mTargetContext = inTargetContext;
}
mURLType = NET_URL_Type(inURL);
}
CURLDispatchInfo::CURLDispatchInfo(
URL_Struct* inURLStruct,
CNSContext* inTargetContext,
FO_Present_Types inOutputFormat,
Boolean inDelay,
Boolean inForceCreate,
Boolean inIsSaving,
ResIDT inWindowResID,
Boolean inInitiallyVisible,
Boolean inWaitingForMochaImageLoad)
: mURLStruct(inURLStruct),
mTargetContext(inTargetContext),
mOutputFormat(inOutputFormat),
mDelayDispatch(inDelay),
mForceCreate(inForceCreate),
mIsSaving(inIsSaving),
mInitiallyVisible(inInitiallyVisible),
mIsWaitingForMochaImageLoad(inWaitingForMochaImageLoad),
mWindowResID(inWindowResID)
{
if (inTargetContext && mURLStruct->referer == NULL)
{
cstring theReferer = inTargetContext->GetCurrentURL();
if (theReferer.length() > 0)
mURLStruct->referer = XP_STRDUP(theReferer);
mTargetContext = inTargetContext;
}
if (inURLStruct)
mURLType = NET_URL_Type(NET_URLStruct_Address(inURLStruct));
else
mURLType = 0;
}
CURLDispatchInfo::~CURLDispatchInfo()
{
if (mURLStruct)
{
NET_FreeURLStruct(mURLStruct);
}
}
URL_Struct* CURLDispatchInfo::ReleaseURLStruct()
{
URL_Struct* url = mURLStruct;
mURLStruct = NULL;
return url;
}
char* CURLDispatchInfo::GetURL()
{
if (mURLStruct)
return NET_URLStruct_Address(mURLStruct);
else
return NULL;
}
void CURLDispatchInfo::SetFileSpec(const FSSpec& inFileSpec)
{
mFileSpec = inFileSpec;
}

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