This commit is contained in:
sgehani%netscape.com 1999-08-22 13:40:21 +00:00
Родитель 17cdc659d1
Коммит 74fd681261
19 изменённых файлов: 5072 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,63 @@
[Dialog License]
License File=License
[Dialog Welcome]
Message0= Welcome to Netscape Communicator 5.0
Message1=This is welcome message 2 from the config.ini file. This is additional gunk to test auto text wrapping. This is still more text to aid in the former effort. This is still more text to aid in the former effort. This is still more text to aid in the former effort. This is still more text to aid in the former effort.This is welcome message 2 from the config.ini file. This is additional gunk to test auto text wrapping. This is still more text to aid in the former effort.
Message2=This is welcome message 3 from the config.ini file. This is additional gunk to test auto text wrapping. This is still more text to aid in the former effort. This is still more text to aid in the former effort. This is still more text to aid in the former effort. This is still more text to aid in the former effort.This is welcome message 3 from the config.ini file. This is additional gunk to test auto text wrapping. This is still more text to aid in the former effort.
[Dialog Setup Type]
[Setup Type0]
Description Short=Easy Install
Description Long=Click continue to install the following component: Current Mozilla optimized build
C0=Component0
[Setup Type1]
Description Short=Custom Install
Description Long=Click continue to select from a list of components.
C0=Component0
C1=Component2
C2=Component1
[Dialog Select Components]
Message0=Please select the components you wish to install:
[Component0]
Description Short=Netscape 2000
Description Long=Apprunner, mailnews, and other components
Archive=mozilla.jar
Install Size=5639
URL0=http://dolfin.mcom.com/nsinstall/mac/apprunner/
[Component1]
Description Short=XPInstall Engine
Description Long=The "core file" with xpinstall, xpcom, nspr20, etc.
Archive=xpiengine.jar
URL0=http://dolfin.mcom.com/nsinstall/mac/xpiengine/
URL1=http://dolfin.mcom.com/nsinstall/mac/xpiengine/
Install Size=989
[Component2]
Description Short=Mozilla Binary Internal
Description Long=M9 Mozilla optimized build (from ftp://sweetlou)
Archive=mozilla-mac-M9.sea.bin
Install Size=5751
URL0=ftp://sweetlou.mcom.com/products/client/seamonkey/macos/8.x/ppc/current/
[Dialog Start Install]
Message0=We need some text/graphics from docs/UE here.
[SmartDownload-Netscape Install]
core_file=xpiengine.jar
no_ads=false
silent=false
execution=false
confirm_install=true

Просмотреть файл

@ -0,0 +1,344 @@
MOZILLA 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.
EXHIBIT A.
``The contents of this file are subject to the Mozilla 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/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations under the
License.
The Original Code is ______________________________________.
The Initial Developer of the Original Code is ________________________.
Portions created by ______________________ are Copyright (C) ______
_______________________. All Rights Reserved.
Contributor(s): ______________________________________.''

Двоичные данные
xpinstall/wizard/mac/macbuild/MIW.mcp Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,63 @@
[Dialog License]
License File=License
[Dialog Welcome]
Message0= Welcome to Netscape Communicator 5.0
Message1=This is welcome message 2 from the config.ini file. This is additional gunk to test auto text wrapping. This is still more text to aid in the former effort. This is still more text to aid in the former effort. This is still more text to aid in the former effort. This is still more text to aid in the former effort.This is welcome message 2 from the config.ini file. This is additional gunk to test auto text wrapping. This is still more text to aid in the former effort.
Message2=This is welcome message 3 from the config.ini file. This is additional gunk to test auto text wrapping. This is still more text to aid in the former effort. This is still more text to aid in the former effort. This is still more text to aid in the former effort. This is still more text to aid in the former effort.This is welcome message 3 from the config.ini file. This is additional gunk to test auto text wrapping. This is still more text to aid in the former effort.
[Dialog Setup Type]
[Setup Type0]
Description Short=Easy Install
Description Long=Click continue to install the following component: Current Mozilla optimized build
C0=Component0
[Setup Type1]
Description Short=Custom Install
Description Long=Click continue to select from a list of components.
C0=Component0
C1=Component2
C2=Component1
[Dialog Select Components]
Message0=Please select the components you wish to install:
[Component0]
Description Short=Netscape 2000
Description Long=Apprunner, mailnews, and other components
Archive=mozilla.jar
Install Size=5639
URL0=http://dolfin.mcom.com/nsinstall/mac/apprunner/
[Component1]
Description Short=XPInstall Engine
Description Long=The "core file" with xpinstall, xpcom, nspr20, etc.
Archive=xpiengine.jar
URL0=http://dolfin.mcom.com/nsinstall/mac/xpiengine/
URL1=http://dolfin.mcom.com/nsinstall/mac/xpiengine/
Install Size=989
[Component2]
Description Short=Mozilla Binary Internal
Description Long=M9 Mozilla optimized build (from ftp://sweetlou)
Archive=mozilla-mac-M9.sea.bin
Install Size=5751
URL0=ftp://sweetlou.mcom.com/products/client/seamonkey/macos/8.x/ppc/current/
[Dialog Start Install]
Message0=We need some text/graphics from docs/UE here.
[SmartDownload-Netscape Install]
core_file=xpiengine.jar
no_ads=false
silent=false
execution=false
confirm_install=true

Двоичные данные
xpinstall/wizard/mac/rsrc/MacInstallWizard.rsrc Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,293 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
/*-----------------------------------------------------------*
* Components Window
*-----------------------------------------------------------*/
void
ShowComponentsWin(void)
{
Str255 next, back;
Str255 compDescTitle;
StringPtr selCompMsg;
Handle listBoxRect;
Rect dataBounds, listBoxFrame;
short reserr;
Point cSize;
Boolean bCellSelected;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(gWPtr);
gCurrWin = COMPONENTS;
/* gControls->cw = (CompWin *) NewPtrClear(sizeof(CompWin)); */
GetIndString(next, rStringList, sNextBtn);
GetIndString(back, rStringList, sBackBtn);
// get controls
listBoxRect = Get1Resource('RECT', rCompListBox);
reserr = ResError();
if (reserr == noErr)
{
HLockHi((Handle)listBoxRect);
gControls->cw->compListBox = (Rect) **((Rect **)listBoxRect);
HUnlock((Handle)listBoxRect);
}
else
{
ErrorHandler();
return;
}
gControls->cw->compDescBox = GetNewControl(rCompDescBox, gWPtr);
gControls->cw->compListBox.right -= kScrollBarWidth;
SetRect(&dataBounds, 0, 0, 1, gControls->cfg->numComps);
SetPt( &cSize, 0, 0);
gControls->cw->compList = lnew(&gControls->cw->compListBox, &dataBounds,
&cSize, 0, gWPtr, TRUE, FALSE, FALSE, TRUE);
// populate controls
bCellSelected = PopulateCompInfo();
// show controls
GetIndString(compDescTitle, rStringList, sCompDescTitle);
SetControlTitle(gControls->cw->compDescBox, compDescTitle);
MoveTo( gControls->cw->compListBox.left, gControls->cw->compListBox.top - kInterWidgetPad);
HLockHi(gControls->cfg->selCompMsg);
selCompMsg = CToPascal(*gControls->cfg->selCompMsg);
if (selCompMsg)
DrawString( selCompMsg );
HUnlock(gControls->cfg->selCompMsg);
SetRect(&listBoxFrame, gControls->cw->compListBox.left,
--gControls->cw->compListBox.top,
gControls->cw->compListBox.right += kScrollBarWidth,
++gControls->cw->compListBox.bottom);
FrameRect(&listBoxFrame);
ShowNavButtons( back, next);
if (bCellSelected)
SetOptInfo();
else
DrawDiskSpaceMsgs( gControls->opt->vRefNum );
SetPort(oldPort);
}
Boolean
PopulateCompInfo(void)
{
int i;
char *currDesc;
Point currCell;
Boolean bCellSelected = false;
for (i=0; i<gControls->cfg->numComps; i++)
{
HLockHi(gControls->cfg->comp[i].shortDesc);
currDesc = *gControls->cfg->comp[i].shortDesc;
HUnlock(gControls->cfg->comp[i].shortDesc);
SetPt(&currCell, 0, i);
LSetCell( currDesc, strlen(currDesc), currCell, gControls->cw->compList);
if (gControls->opt->compSelected[i] == kSelected)
{
LSetSelect(true, currCell, gControls->cw->compList);
bCellSelected = true;
}
}
return bCellSelected;
}
void
UpdateCompWin(void)
{
Rect r;
Cell c;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(gWPtr);
MoveTo( gControls->cw->compListBox.left, gControls->cw->compListBox.top - kInterWidgetPad + 1);
HLockHi(gControls->cfg->selCompMsg);
DrawString( CToPascal(*gControls->cfg->selCompMsg));
HUnlock(gControls->cfg->selCompMsg);
LUpdate( (*gControls->cw->compList)->port->visRgn,
gControls->cw->compList);
FrameRect(&gControls->cw->compListBox);
SetPt(&c, 0, 0);
if (LGetSelect(true, &c, gControls->cw->compList))
{
HLockHi((Handle)gControls->cw->compDescTxt);
r = (*gControls->cw->compDescTxt)->viewRect;
HUnlock((Handle)gControls->cw->compDescTxt);
TEUpdate(&r, gControls->cw->compDescTxt);
}
DrawDiskSpaceMsgs( gControls->opt->vRefNum );
SetPort(oldPort);
}
void
InComponentsContent(EventRecord* evt, WindowPtr wCurrPtr)
{
Point localPt;
Rect r;
ControlPartCode part;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(wCurrPtr);
localPt = evt->where;
GlobalToLocal( &localPt);
if (PtInRect( localPt, &gControls->cw->compListBox))
{
LClick(localPt, evt->modifiers, gControls->cw->compList);
SetOptInfo();
}
HLockHi((Handle)gControls->backB);
r = (**(gControls->backB)).contrlRect;
HUnlock((Handle)gControls->backB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->backB, evt->where, NULL);
if (part)
{
/* extra handling since we used DrawString for static text msg
* and framed our own listbox etc.
*/
gControls->cw->compListBox.top = 0;
EraseRect(&gControls->cw->compListBox);
ClearDiskSpaceMsgs();
KillControls(gWPtr);
ShowSetupTypeWin();
return;
}
}
HLockHi((Handle)gControls->nextB);
r = (**(gControls->nextB)).contrlRect;
HUnlock((Handle)gControls->nextB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->nextB, evt->where, NULL);
if (part)
{
gControls->cw->compListBox.top = 0;
EraseRect(&gControls->cw->compListBox);
ClearDiskSpaceMsgs();
KillControls(gWPtr);
ShowTerminalWin();
return;
}
}
SetPort(oldPort);
}
void
SetOptInfo(void)
{
Boolean isCellSelected;
Cell currCell;
int i;
Rect viewRect;
HLockHi((Handle)gControls->cw->compDescBox);
viewRect = (*gControls->cw->compDescBox)->contrlRect;
HUnlock((Handle)gControls->cw->compDescBox);
viewRect.top += kInterWidgetPad;
SetRect(&viewRect, viewRect.left + kTxtRectPad,
viewRect.top + kTxtRectPad,
viewRect.right - kTxtRectPad,
viewRect.bottom - kTxtRectPad);
EraseRect(&viewRect);
for(i=0; i<gControls->cfg->numComps; i++)
{
SetPt(&currCell, 0, i);
if ( (isCellSelected = LGetSelect( false, &currCell, gControls->cw->compList)) == true)
{
if (gControls->opt->compSelected[i] != kSelected)
{
gControls->opt->compSelected[i] = kSelected;
gControls->opt->numCompSelected++;
}
if (!gControls->cw->compDescBox)
{
ErrorHandler();
return;
}
TextFont(applFont);
TextSize(10);
gControls->cw->compDescTxt = TENew(&viewRect, &viewRect);
HLockHi(gControls->cfg->comp[i].longDesc);
TESetText( *gControls->cfg->comp[i].longDesc,
strlen(*gControls->cfg->comp[i].longDesc), gControls->cw->compDescTxt);
TEUpdate( &viewRect, gControls->cw->compDescTxt);
TextFont(systemFont);
TextSize(12);
HUnlock(gControls->cfg->comp[i].longDesc);
}
else if (gControls->opt->compSelected[i] == kSelected)
{
gControls->opt->compSelected[i] = kNotSelected;
gControls->opt->numCompSelected--;
}
}
ClearDiskSpaceMsgs();
DrawDiskSpaceMsgs( gControls->opt->vRefNum );
}
void
EnableComponentsWin(void)
{
EnableNavButtons();
// TO DO
}
void
DisableComponentsWin(void)
{
DisableNavButtons();
// TO DO
}

Просмотреть файл

@ -0,0 +1,245 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code, released March
* 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998-1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
#define STANDALONE 1
#define XP_MAC 1
#include "zipstub.h"
#include "zipfile.h"
#include "nsAppleSingleDecoder.h"
/*-----------------------------------------------------------*
* Deflation
*-----------------------------------------------------------*/
OSErr
ExtractCoreFile(void)
{
OSErr err = noErr;
StringPtr coreFile, coreDirPath, extractedFile, pdir;
short fullPathLen, tgtVRefNum;
Handle fullPathH;
void *hZip, *hFind;
PRInt32 rv;
Boolean bFoundAll = false, isDir;
char filename[255] = "\0", dir[255] = "\0", *lastslash;
FSSpec coreDirFSp, extractedFSp, outFSp, extractedDir;
long coreDirID, tgtDirID, extractedDirID;
// err = GetCWD(&tgtDirID, &tgtVRefNum);
tgtDirID = gControls->opt->dirID;
tgtVRefNum = gControls->opt->vRefNum;
/* if there's a core file... */
HLockHi(gControls->cfg->coreFile);
if (*gControls->cfg->coreFile != NULL)
{
/* make local copy and unlock handle */
coreFile = CToPascal(*gControls->cfg->coreFile);
// XXX memory check
}
else
return fnfErr;
HUnlock(gControls->cfg->coreFile);
/* if there's a relative subdir... */
HLock(gControls->cfg->coreDir);
if (*gControls->cfg->coreDir != NULL)
{
coreDirPath = CToPascal(*gControls->cfg->coreDir);
// XXX memory check
}
HUnlock(gControls->cfg->coreDir);
// if coreDir specified create the core dir
if (coreDirPath[0] > 0)
{
err = FSMakeFSSpec( tgtVRefNum, tgtDirID, coreDirPath, &coreDirFSp );
if (err!=noErr && err!=fnfErr)
return err;
err = FSpDirCreate( &coreDirFSp, smSystemScript, &coreDirID );
if (err!=noErr && err!=dupFNErr)
return err;
// move core file to core dir
ERR_CHECK_RET(ForceMoveFile(tgtVRefNum, tgtDirID, coreFile, coreDirID), err);
ERR_CHECK_RET(GetFullPath(tgtVRefNum, coreDirID, coreFile, &fullPathLen, &fullPathH), err);
}
else
{
ERR_CHECK_RET(GetFullPath(tgtVRefNum, tgtDirID, coreFile, &fullPathLen, &fullPathH), err);
}
HLock(fullPathH);
*(*fullPathH+fullPathLen) = '\0';
rv = ZIP_OpenArchive( *fullPathH, &hZip );
HUnlock(fullPathH);
if (rv!=ZIP_OK) return rv;
hFind = ZIP_FindInit( hZip, NULL ); /* NULL to match all files in archive */
while (!bFoundAll)
{
rv = ZIP_FindNext( hFind, filename, 255 );
if (rv==ZIP_ERR_FNF)
bFoundAll = true;
else if (rv!=ZIP_OK)
return rv;
lastslash = strrchr(filename, '/');
if (lastslash == (&filename[0] + strlen(filename) - 1)) /* dir entry encountered */
continue;
// extract the file
err = GetFullPath(tgtVRefNum, tgtDirID, "\p", &fullPathLen, &fullPathH); /* get dirpath */
if (err!=noErr)
return err;
HLock(fullPathH);
strcat(*fullPathH, filename); /* tack on filename to dirpath */
fullPathLen += strlen(filename);
*(*fullPathH+fullPathLen) = '\0';
rv = ZIP_ExtractFile( hZip, filename, *fullPathH );
HUnlock(fullPathH);
if (rv!=ZIP_OK)
return rv;
// AppleSingle decode if need be
extractedFile = CToPascal(filename);
err = FSMakeFSSpec(tgtVRefNum, tgtDirID, extractedFile, &extractedFSp);
err = FSMakeFSSpec(tgtVRefNum, tgtDirID, extractedFile, &outFSp);
err = AppleSingleDecode(&extractedFSp, &outFSp);
// check if file is leaf or nested in subdir
dir[0] = 0;
ResolveDirs(filename, dir);
if (*dir)
{
pdir = CToPascal(dir);
if (!pstrcmp(extractedFSp.name, outFSp.name))
{
err = FSpDelete(&extractedFSp);
}
}
// if there's a coreDir specified move the file into it
if (coreDirPath[0] > 0)
{
if (*dir) // coreDir:extractedDir:<leaffile>
{
err = DirCreate(coreDirFSp.vRefNum, coreDirID, pdir, &extractedDirID);
if (err!=noErr && err!=dupFNErr)
return err;
ERR_CHECK_RET(ForceMoveFile(outFSp.vRefNum, outFSp.parID, outFSp.name, extractedDirID), err);
}
// else coreDir:<leaffile>
else
ERR_CHECK_RET(ForceMoveFile(outFSp.vRefNum, outFSp.parID, outFSp.name, coreDirID), err);
}
else if (*dir) // extractedDir:<leaffile>
{
err = FSMakeFSSpec(tgtVRefNum, tgtDirID, pdir, &extractedDir);
if (err==noErr) // already created
err = FSpGetDirectoryID(&extractedDir, &extractedDirID, &isDir);
else // otherwise mkdir
err = FSpDirCreate(&extractedDir, smSystemScript, &extractedDirID);
if (err!=noErr && err!=dupFNErr)
return err;
ERR_CHECK_RET(ForceMoveFile(outFSp.vRefNum, outFSp.parID, outFSp.name, extractedDirID), err);
}
if (*dir)
DisposePtr((Ptr) pdir);
DisposePtr((Ptr)extractedFile);
}
// XXX need to make all returns go through cleanup
// cleanup:
// dispose of coreFile, coreDirPath
DisposePtr((Ptr) coreFile);
DisposePtr((Ptr) coreDirPath);
return err;
}
OSErr
AppleSingleDecode(FSSpecPtr fd, FSSpecPtr outfd)
{
OSErr err = noErr;
nsAppleSingleDecoder *decoder;
// if file is AppleSingled
if (nsAppleSingleDecoder::IsAppleSingleFile(fd))
{
// decode it
decoder = new nsAppleSingleDecoder(fd, outfd);
ERR_CHECK_RET(decoder->Decode(), err);
}
return err;
}
void
ResolveDirs(char *fname, char *dir)
{
char *delim, *dirpath;
dirpath = fname;
Boolean delimFound = false;
while( (delim = strchr(dirpath, '/')) != 0)
{
delimFound = true;
*delim = ':';
dirpath = delim;
}
if (delimFound)
{
strncpy(dir, fname, dirpath-fname);
*(dir+ (dirpath-fname)+1) = 0; // NULL terminate
}
}
OSErr
ForceMoveFile(short vRefNum, long parID, ConstStr255Param name, long newDirID)
{
OSErr err = noErr;
FSSpec tmpFSp;
err = CatMove(vRefNum, parID, name, newDirID, nil);
if (err == dupFNErr)
{
// handle for stomping over old file
err = FSMakeFSSpec(vRefNum, parID, name, &tmpFSp);
err = FSpDelete(&tmpFSp);
err = CatMove(vRefNum, parID, name, newDirID, nil);
}
return err;
}

Просмотреть файл

@ -0,0 +1,285 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
/*--------------------------------------------------------------*
* Event Handlers
*--------------------------------------------------------------*/
void HandleNextEvent(EventRecord* nextEvt)
{
switch(nextEvt->what)
{
case mouseDown:
HandleMouseDown(nextEvt);
break;
case keyDown:
HandleKeyDown(nextEvt);
break;
case updateEvt:
HandleUpdateEvt(nextEvt);
break;
case activateEvt:
HandleActivateEvt(nextEvt);
break;
case osEvt:
HandleOSEvt(nextEvt);
break;
case nullEvent:
TEIdle(gControls->lw->licTxt);
break;
}
}
void HandleMouseDown(EventRecord* evt)
{
WindowPtr wCurrPtr;
SInt16 cntlPartCode;
SInt32 menuChoice;
cntlPartCode = FindWindow(evt->where, &wCurrPtr);
switch(cntlPartCode)
{
case inMenuBar:
//AdjustMenus();
menuChoice = MenuSelect(evt->where);
//HandleMenuChoice(menuChoice);
break;
case inContent:
if (wCurrPtr != FrontWindow())
{
/* InvalRect(&qd.screenBits.bounds); */
SelectWindow(wCurrPtr);
}
else
React2InContent(evt, wCurrPtr);
break;
case inDrag:
DragWindow(wCurrPtr, evt->where, &qd.screenBits.bounds);
InvalRect(&qd.screenBits.bounds);
break;
case inGoAway:
// TO DO
break;
}
}
void HandleKeyDown(EventRecord* evt)
{
char keyPressed;
ThreadID tid;
keyPressed = evt->message & charCodeMask;
if ( (keyPressed == 'z') || (keyPressed == 'Z'))
gDone = true; // backdoor exit
if (keyPressed == '\r')
{
switch(gCurrWin)
{
case LICENSE:
KillControls(gWPtr);
ShowWelcomeWin();
return;
case WELCOME:
KillControls(gWPtr);
ShowSetupTypeWin();
return;
case SETUP_TYPE:
KillControls(gWPtr);
/* treat last setup type selection as custom */
if (gControls->opt->instChoice == gControls->cfg->numSetupTypes)
ShowComponentsWin();
else
ShowTerminalWin();
return;
case COMPONENTS:
KillControls(gWPtr);
ShowTerminalWin();
return;
case TERMINAL:
SpawnSDThread(Install, &tid);
return;
default:
break; // never reached
}
}
}
void HandleUpdateEvt(EventRecord* evt)
{
WindowPtr wCurrPtr;
SInt16 cntlPartCode;
Rect bounds;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort( gWPtr );
cntlPartCode = FindWindow( evt->where, &wCurrPtr );
BeginUpdate( gWPtr );
DrawControls( gWPtr );
ShowLogo();
switch(gCurrWin)
{
case LICENSE:
case WELCOME:
ShowTxt();
break;
case SETUP_TYPE:
ShowSetupDescTxt();
break;
case COMPONENTS:
UpdateCompWin();
break;
case TERMINAL:
UpdateTerminalWin();
break;
default:
break;
}
if (gControls->nextB)
{
HLockHi( (Handle) gControls->nextB);
bounds = (*(gControls->nextB))->contrlRect;
PenMode(patCopy);
ForeColor(blackColor);
InsetRect( &bounds, -4, -4 );
FrameGreyButton( &bounds );
HUnlock( (Handle)gControls->nextB );
}
EndUpdate( gWPtr );
SetPort(oldPort);
}
void HandleActivateEvt(EventRecord* evt)
{
// TO DO
}
void HandleOSEvt(EventRecord* evt)
{
switch ( (evt->message >> 24) & 0x000000FF)
{
case suspendResumeMessage:
if ((evt->message & resumeFlag) == 1)
{
switch(gCurrWin)
{
case LICENSE:
EnableLicenseWin();
break;
case WELCOME:
EnableWelcomeWin();
break;
case SETUP_TYPE:
EnableSetupTypeWin();
break;
case COMPONENTS:
EnableComponentsWin();
break;
case TERMINAL:
EnableTerminalWin();
break;
}
InvalRect(&gWPtr->portRect);
}
else
{
switch(gCurrWin)
{
case LICENSE:
DisableLicenseWin();
break;
case WELCOME:
DisableWelcomeWin();
break;
case SETUP_TYPE:
DisableSetupTypeWin();
break;
case COMPONENTS:
DisableComponentsWin();
break;
case TERMINAL:
DisableTerminalWin();
break;
}
InvalRect(&gWPtr->portRect);
}
}
}
void React2InContent(EventRecord* evt, WindowPtr wCurrPtr)
{
switch (gCurrWin)
{
case LICENSE:
InLicenseContent(evt, gWPtr);
break;
case WELCOME:
InWelcomeContent(evt, gWPtr);
break;
case SETUP_TYPE:
InSetupTypeContent(evt, gWPtr);
break;
case COMPONENTS:
InComponentsContent(evt, gWPtr);
break;
case TERMINAL:
InTerminalContent(evt, gWPtr);
break;
default:
gDone = true;
break;
}
}

Просмотреть файл

@ -0,0 +1,128 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Michael C. Amorose
*/
/*---------------------------------------------------------------------*
* Routines for drawing standard AGA pushbutton.
* Loosely based on code by Zig Zichterman.
*---------------------------------------------------------------------*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
pascal void FrameGreyButton( Rect *buttonFrame )
{
InsetRect( buttonFrame, 1, 1 );
PenNormal();
PenSize( 1, 1);
SetFrameGreyButtonColor(0x0000);
MoveTo( buttonFrame->left + 0, buttonFrame->top + 3 );
LineTo( buttonFrame->left + 3, buttonFrame->top + 0 );
LineTo( buttonFrame->right - 4, buttonFrame->top + 0 );
LineTo( buttonFrame->right - 1, buttonFrame->top + 3 );
LineTo( buttonFrame->right - 1, buttonFrame->bottom - 4 );
LineTo( buttonFrame->right - 4, buttonFrame->bottom - 1 );
LineTo( buttonFrame->left + 3, buttonFrame->bottom - 1 );
LineTo( buttonFrame->left + 0, buttonFrame->bottom - 4 );
LineTo( buttonFrame->left + 0, buttonFrame->top + 3 );
SetFrameGreyButtonColor( 0x2222 );
MoveTo( buttonFrame->left + 0, buttonFrame->top + 3 );
LineTo( buttonFrame->left + 0, buttonFrame->top + 3 );
MoveTo( buttonFrame->left + 3, buttonFrame->top + 0 );
LineTo( buttonFrame->left + 3, buttonFrame->top + 0 );
MoveTo( buttonFrame->right - 4, buttonFrame->top + 0 );
LineTo( buttonFrame->right - 4, buttonFrame->top + 0 );
MoveTo( buttonFrame->right - 1, buttonFrame->top + 3 );
LineTo( buttonFrame->right - 1, buttonFrame->top + 3 );
MoveTo( buttonFrame->right - 1, buttonFrame->bottom - 4 );
LineTo( buttonFrame->right - 1, buttonFrame->bottom - 4 );
MoveTo( buttonFrame->right - 4, buttonFrame->bottom - 1 );
LineTo( buttonFrame->right - 4, buttonFrame->bottom - 1 );
MoveTo( buttonFrame->left + 3, buttonFrame->bottom - 1 );
LineTo( buttonFrame->left + 3, buttonFrame->bottom - 1 );
MoveTo( buttonFrame->left + 0, buttonFrame->bottom - 4 );
LineTo( buttonFrame->left + 0, buttonFrame->bottom - 4 );
SetFrameGreyButtonColor( 0xDDDD );
MoveTo( buttonFrame->left + 1, buttonFrame->bottom - 5 );
LineTo( buttonFrame->left + 1, buttonFrame->top + 3 );
LineTo( buttonFrame->left + 3, buttonFrame->top + 1 );
MoveTo( buttonFrame->left + 2, buttonFrame->top + 3 );
LineTo( buttonFrame->left + 4, buttonFrame->top + 1 );
LineTo( buttonFrame->right - 5, buttonFrame->top + 1 );
SetFrameGreyButtonColor( 0xAAAA );
MoveTo( buttonFrame->left + 2, buttonFrame->top + 4 );
LineTo( buttonFrame->left + 4, buttonFrame->top + 2 );
LineTo( buttonFrame->right - 4, buttonFrame->top + 2 );
LineTo( buttonFrame->right - 4, buttonFrame->top + 3 );
LineTo( buttonFrame->right - 3, buttonFrame->top + 3 );
LineTo( buttonFrame->right - 3, buttonFrame->bottom - 5 );
LineTo( buttonFrame->right - 5, buttonFrame->bottom - 3 );
LineTo( buttonFrame->left + 3, buttonFrame->bottom - 3 );
LineTo( buttonFrame->left + 3, buttonFrame->bottom - 4 );
LineTo( buttonFrame->left + 2, buttonFrame->bottom - 4 );
LineTo( buttonFrame->left + 2, buttonFrame->top + 4 );
SetFrameGreyButtonColor( 0x7777 );
MoveTo( buttonFrame->right - 2, buttonFrame->top + 4 );
LineTo( buttonFrame->right - 2, buttonFrame->bottom - 4 );
LineTo( buttonFrame->right - 4, buttonFrame->bottom - 2 );
LineTo( buttonFrame->left + 4, buttonFrame->bottom - 2 );
SetFrameGreyButtonColor( 0x7777 );
MoveTo( buttonFrame->left + 3, buttonFrame->top + 4 );
LineTo( buttonFrame->left + 4, buttonFrame->top + 3 );
MoveTo( buttonFrame->right - 5, buttonFrame->top + 3 );
LineTo( buttonFrame->right - 4, buttonFrame->top + 4 );
MoveTo( buttonFrame->right - 4, buttonFrame->bottom - 5 );
LineTo( buttonFrame->right - 5, buttonFrame->bottom - 4 );
MoveTo( buttonFrame->left + 4, buttonFrame->bottom - 4 );
LineTo( buttonFrame->left + 3, buttonFrame->bottom - 5 );
SetFrameGreyButtonColor( 0xCCCC );
MoveTo( buttonFrame->right - 4, buttonFrame->top + 1 );
LineTo( buttonFrame->right - 4, buttonFrame->top + 1 );
MoveTo( buttonFrame->left + 1, buttonFrame->bottom - 4 );
LineTo( buttonFrame->left + 1, buttonFrame->bottom - 4 );
SetFrameGreyButtonColor( 0xBBBB );
MoveTo( buttonFrame->right - 3, buttonFrame->top + 2 );
LineTo( buttonFrame->right - 3, buttonFrame->top + 2 );
MoveTo( buttonFrame->left + 2, buttonFrame->bottom - 3 );
LineTo( buttonFrame->left + 2, buttonFrame->bottom - 3 );
SetFrameGreyButtonColor( 0x8888 );
MoveTo( buttonFrame->right - 2, buttonFrame->top + 3 );
LineTo( buttonFrame->right - 2, buttonFrame->top + 3 );
MoveTo( buttonFrame->right - 3, buttonFrame->bottom - 4 );
LineTo( buttonFrame->right - 4, buttonFrame->bottom - 3 );
MoveTo( buttonFrame->left + 3, buttonFrame->bottom - 2 );
LineTo( buttonFrame->left + 3, buttonFrame->bottom - 2 );
SetFrameGreyButtonColor( 0x0000 );
}
void SetFrameGreyButtonColor( short color )
{
RGBColor grey;
grey.red =
grey.green =
grey.blue = color;
RGBForeColor( &grey );
}

Просмотреть файл

@ -0,0 +1,344 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
/*-----------------------------------------------------------*
* Install Action
*-----------------------------------------------------------*/
pascal void* Install(void* unused)
{
short vRefNum;
long dirID;
OSErr err;
FSSpec idiSpec, xpiSpec, tgtDirSpec, coreFileSpec;
SDISTRUCT sdistruct;
Str255 pIDIfname;
StringPtr coreFile;
ERR_CHECK_RET( GetCWD(&dirID, &vRefNum), (void*)0 );
GetIndString(pIDIfname, rStringList, sTempIDIName);
/* generate idi */
if (!GenerateIDIFromOpt(pIDIfname, dirID, vRefNum, &idiSpec))
{
ErrorHandler();
return (void*) nil;
}
#if CORRECT_DL_LOCATION == 1
/* get "Temporary Items" folder path */
ERR_CHECK_RET( FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder,
&vRefNum, &dirID)) != noErr), (void*) 0);
#else
vRefNum = gControls->opt->vRefNum;
dirID = gControls->opt->dirID;
#endif /* CORRECT_DL_LOCATION == 1 */
/* populate SDI struct */
sdistruct.dwStructSize = sizeof(SDISTRUCT);
sdistruct.fsIDIFile = idiSpec;
sdistruct.dlDirVRefNum = vRefNum;
sdistruct.dlDirID = dirID;
sdistruct.hwndOwner = NULL;
/* call SDI_NetInstall */
#if SDINST_IS_DLL == 1
gInstFunc(&sdistruct);
#else
SDI_NetInstall(&sdistruct);
#endif
FSpDelete(&idiSpec);
/* check if coreFile was downloaded */
HLock(gControls->cfg->coreFile);
if (*gControls->cfg->coreFile != NULL)
coreFile = CToPascal(*gControls->cfg->coreFile);
HUnlock(gControls->cfg->coreFile);
if (coreFile != NULL && *coreFile > 0) /* core file was specified */
{
err = FSMakeFSSpec(vRefNum, dirID, coreFile, &coreFileSpec);
if (err==noErr) /* core file was downloaded */
{
err = ExtractCoreFile();
if (err!=noErr) SysBeep(10);
#if 0 // XXX commented out for QA buid: LoadXPIStub crashes still...
sleep(15);
/* call XPInstall */
err = FSMakeFSSpec(vRefNum, dirID, "\pmozilla.jar", &xpiSpec);
err = FSMakeFSSpec(vRefNum, dirID, 0, &tgtDirSpec);
if (err==noErr)
err = RunXPI(xpiSpec, tgtDirSpec);
elsesss
ErrorHandler();
#endif
}
}
/* wind down app */
gDone = true;
return (void*) 0;
}
Boolean
GenerateIDIFromOpt(Str255 idiName, long dirID, short vRefNum, FSSpec *idiSpec)
{
Boolean bSuccess = true;
OSErr err;
short refNum, instChoice;
long count, compsDone, i, j;
char *buf, *fnum, *keybuf, ch;
Str255 pfnum, pkeybuf;
err = FSMakeFSSpec(vRefNum, dirID, idiName, idiSpec);
if ((err != noErr) && (err != fnfErr))
{
ErrorHandler();
return false;
}
err = FSpCreate(idiSpec, 'NSCP', 'TEXT', smSystemScript);
if ( (err != noErr) && (err != dupFNErr))
{
ErrorHandler();
return false;
}
ERR_CHECK_RET(FSpOpenDF(idiSpec, fsRdWrPerm, &refNum), false);
// setup buffer to at least 8K
buf = NewPtrClear(kGenIDIFileSize);
compsDone = 0;
instChoice = gControls->opt->instChoice-1;
// loop through 0 to kMaxComponents
for(i=0; i<kMaxComponents; i++)
{
// general test: if component in setup type
if ( (gControls->cfg->st[instChoice].comp[i] == kInSetupType) &&
(compsDone < gControls->cfg->st[instChoice].numComps) )
{
// if custom and selected, or not custom setup type
// add file to buffer
if ( ((instChoice == gControls->cfg->numSetupTypes-1) &&
(gControls->opt->compSelected[i] == kSelected)) ||
(instChoice < gControls->cfg->numSetupTypes-1) )
{
// get file number from STR# resource
GetIndString(pfnum, rIndices, compsDone+1);
fnum = PascalToC(pfnum);
// construct through concatenation [File<num>]\r
GetIndString(pkeybuf, rIDIKeys, sFile);
keybuf = PascalToC(pkeybuf);
ch = '[';
strncat(buf, &ch, 1);
strncat(buf, keybuf, strlen(keybuf));
strncat(buf, fnum, strlen(fnum));
DisposePtr(keybuf);
keybuf = NewPtrClear(2);
keybuf = "]\r";
strncat(buf, keybuf, strlen(keybuf));
DisposePtr(keybuf);
// write out \tdesc=
GetIndString(pkeybuf, rIDIKeys, sDesc);
keybuf = PascalToC(pkeybuf);
ch = '\t';
strncat(buf, &ch, 1); // \t
strncat(buf, keybuf, strlen(keybuf)); // \tdesc
ch = '='; // \tdesc=
strncat(buf, &ch, 1);
DisposePtr(keybuf);
// write out gControls->cfg->comp[i].shortDesc\r
HLockHi(gControls->cfg->comp[i].shortDesc);
strncat(buf, *gControls->cfg->comp[i].shortDesc, strlen(*gControls->cfg->comp[i].shortDesc));
HUnlock(gControls->cfg->comp[i].shortDesc);
ch = '\r';
strncat(buf, &ch, 1);
// iterate over gControls->cfg->comp[i].numURLs
for (j=0; j<gControls->cfg->comp[i].numURLs; j++)
{
// write out \tnumURLs+1= from STR# resource
GetIndString(pkeybuf, rIndices, j+2); // j+2 since 1-based idx, not 0-based
keybuf = PascalToC(pkeybuf);
ch = '\t';
strncat(buf, &ch, 1); // \t
strncat(buf, keybuf, strlen(keybuf)); // \t<n>
ch = '=';
strncat(buf, &ch, 1); // \t<n>=
DisposePtr(keybuf);
// write out gControls->cfg->comp[i].url[j]+archive\r
HLockHi(gControls->cfg->comp[i].url[j]);
strncat(buf, *gControls->cfg->comp[i].url[j], strlen(*gControls->cfg->comp[i].url[j]));
HUnlock(gControls->cfg->comp[i].url[j]);
HLockHi(gControls->cfg->comp[i].archive);
strncat(buf, *gControls->cfg->comp[i].archive, strlen(*gControls->cfg->comp[i].archive));
HUnlock(gControls->cfg->comp[i].archive);
ch = '\r';
strncat(buf, &ch, 1);
}
DisposePtr(fnum);
compsDone++;
}
}
else if (compsDone == gControls->cfg->st[instChoice].numComps)
break;
}
// terminate by entering Netscape Install section
GetIndString(pkeybuf, rIDIKeys, sNSInstall);
keybuf = PascalToC(pkeybuf);
ch = '[';
strncat(buf, &ch, 1); // [
strncat(buf, keybuf, strlen(keybuf)); // [Netscape Install
DisposePtr(keybuf);
keybuf = NewPtrClear(2);
keybuf = "]\r";
strncat(buf, keybuf, strlen(keybuf)); // [Netscape Install]\r
DisposePtr(keybuf);
// write out \tcore_file=<filename>\r
AddKeyToIDI( sCoreFile, gControls->cfg->coreFile, buf );
// write out \tcore_dir=<dirname>\r
AddKeyToIDI( sCoreDir, gControls->cfg->coreDir, buf );
// write out \tno_ads=<boolean>\r
AddKeyToIDI( sNoAds, gControls->cfg->noAds, buf );
// write out \tsilent=<boolean>\r
AddKeyToIDI( sSilent, gControls->cfg->silent, buf );
// write out \texecution=<boolean>\r
AddKeyToIDI( sExecution, gControls->cfg->execution, buf );
// write out \tconfirm_install=<boolean>
AddKeyToIDI( sConfirmInstall, gControls->cfg->confirmInstall, buf );
// write buf to disk
count = strlen(buf);
ERR_CHECK_RET(FSWrite(refNum, &count, buf), false);
// close file
ERR_CHECK_RET(FSClose(refNum), false)
DisposePtr(buf);
return bSuccess;
}
void
AddKeyToIDI(short key, Handle val, char *ostream)
{
Str255 pkeybuf;
char *keybuf, *cval, ch;
HLockHi(val);
cval = *val;
GetIndString(pkeybuf, rIDIKeys, key);
keybuf = PascalToC(pkeybuf);
ch = '\t';
strncat(ostream, &ch, 1); // \t
strncat(ostream, keybuf, strlen(keybuf)); // \t<key>
ch = '=';
strncat(ostream, &ch, 1); // \t<key>=
strncat(ostream, cval, strlen(cval)); // \t<key>=<val>
ch = '\r';
strncat(ostream, &ch, 1); // \t<key>=<val>\r
HUnlock(val);
DisposePtr(keybuf);
}
Boolean
InitSDLib(void)
{
Str255 libName;
FSSpec libSpec;
short vRefNum;
long dirID;
OSErr err;
ERR_CHECK_RET(GetCWD(&dirID, &vRefNum), false);
/* initialize SDI lib and struct */
GetIndString(libName, rStringList, sSDLib);
ERR_CHECK_RET(FSMakeFSSpec(vRefNum, dirID, libName, &libSpec), false);
if (!LoadSDLib(libSpec, &gInstFunc, &gSDIEvtHandler, &gConnID))
{
ErrorHandler();
return false;
}
return true;
}
Boolean
LoadSDLib(FSSpec libSpec, SDI_NETINSTALL *outSDNFunc, EventProc *outEvtProc, CFragConnectionID *outConnID)
{
OSErr err;
Str255 errName;
Ptr mainAddr;
Ptr symAddr;
CFragSymbolClass symClass;
ERR_CHECK_RET(GetDiskFragment(&libSpec, 0, kCFragGoesToEOF, nil, kReferenceCFrag, outConnID, &mainAddr, errName), false);
if (*outConnID != NULL)
{
ERR_CHECK_RET(FindSymbol(*outConnID, "\pSDI_NetInstall", &symAddr, &symClass), false);
*outSDNFunc = (SDI_NETINSTALL) symAddr;
ERR_CHECK_RET(FindSymbol(*outConnID, "\pSDI_HandleEvent", &symAddr, &symClass), false);
*outEvtProc = (EventProc) symAddr;
}
return true;
}
Boolean
UnloadSDLib(CFragConnectionID *connID)
{
if (*connID != NULL)
{
CloseConnection(connID);
*connID = NULL;
}
else
return false;
return true;
}

Просмотреть файл

@ -0,0 +1,482 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
/*-----------------------------------------------------------*
* License Window
*-----------------------------------------------------------*/
void
ShowLicenseWin(void)
{
Str255 accept;
Str255 decline;
Rect sbRect;
int sbWidth;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(gWPtr);
gCurrWin = LICENSE;
/* gControls->lw = (LicWin *) NewPtrClear(sizeof(LicWin)); */
GetIndString(accept, rStringList, sAcceptBtn);
GetIndString(decline, rStringList, sDeclineBtn);
gControls->lw->scrollBar = GetNewControl( rLicScrollBar, gWPtr);
gControls->lw->licBox = GetNewControl( rLicBox, gWPtr);
if(gControls->lw->scrollBar && gControls->lw->licBox)
{
HLockHi( (Handle) gControls->lw->scrollBar);
sbRect = (*(gControls->lw->licBox))->contrlRect;
sbWidth = (*(gControls->lw->scrollBar))->contrlRect.right -
(*(gControls->lw->scrollBar))->contrlRect.left;
(*(gControls->lw->scrollBar))->contrlRect.right = sbRect.right + kScrollBarPad;
(*(gControls->lw->scrollBar))->contrlRect.left = sbRect.right + kScrollBarPad -
sbWidth;
(*(gControls->lw->scrollBar))->contrlRect.top = sbRect.top - kScrollBarPad;
(*(gControls->lw->scrollBar))->contrlRect.bottom = sbRect.bottom + kScrollBarPad;
HUnlock( (Handle) gControls->lw->scrollBar);
}
InitLicTxt();
ShowNavButtons( decline, accept);
ShowControl( gControls->lw->scrollBar);
ShowControl( gControls->lw->licBox);
ShowTxt();
InitScrollBar( gControls->lw->scrollBar);
ShowLogo();
SetPort(oldPort);
}
void
InitLicTxt(void)
{
Rect destRect, viewRect;
FSSpec licFile;
long dirID, dataSize;
short vRefNum, dataRef, resRef;
unsigned char* cLicFName;
Str255 pLicFName;
OSErr err;
Handle text, stylHdl;
ERR_CHECK(GetCWD(&dirID, &vRefNum));
/* open and read license file */
HLockHi(gControls->cfg->licFileName);
if(**gControls->cfg->licFileName != nil)
{
cLicFName = (unsigned char*)NewPtrClear(strlen(*gControls->cfg->licFileName));
cLicFName = CToPascal(*gControls->cfg->licFileName);
ERR_CHECK(FSMakeFSSpec(vRefNum, dirID, cLicFName, &licFile));
DisposePtr((char*)cLicFName);
}
else /* assume default license filename from str rsrc */
{
GetIndString(pLicFName, rStringList, sLicenseFName);
ERR_CHECK(FSMakeFSSpec(vRefNum, dirID, pLicFName, &licFile));
}
HUnlock(gControls->cfg->licFileName);
/* read license text */
ERR_CHECK(FSpOpenDF( &licFile, fsRdPerm, &dataRef));
ERR_CHECK(GetEOF(dataRef, &dataSize));
if (dataSize > 0)
{
if (!(text = NewHandle(dataSize)))
ErrorHandler();
ERR_CHECK(FSRead(dataRef, &dataSize, *text));
}
else
text = nil;
ERR_CHECK(FSClose(dataRef));
/* get 'styl' if license is multistyled */
resRef = FSpOpenResFile( &licFile, fsRdPerm);
ERR_CHECK(ResError());
UseResFile(resRef);
stylHdl = RGetResource('styl', 128);
ERR_CHECK(ResError());
if(stylHdl)
DetachResource(stylHdl);
else
stylHdl = nil;
CloseResFile(resRef);
/* TE specific init */
HLock( (Handle) gControls->lw->licBox);
SetRect(&viewRect, (*(gControls->lw->licBox))->contrlRect.left,
(*(gControls->lw->licBox))->contrlRect.top,
(*(gControls->lw->licBox))->contrlRect.right,
(*(gControls->lw->licBox))->contrlRect.bottom);
HUnlock( (Handle) gControls->lw->licBox);
destRect.left = viewRect.left;
viewRect.right = (*(gControls->lw->scrollBar))->contrlRect.left;
destRect.right = viewRect.right;
destRect.top = viewRect.top;
destRect.bottom = viewRect.bottom * kNumLicScrns;
// gControls->lw->licTxt = (TEHandle) NewPtrClear(sizeof(TEPtr));
TextFont(applFont);
TextFace(normal);
TextSize(9);
HLock(text);
if (stylHdl)
{
gControls->lw->licTxt = TEStyleNew( &destRect, &viewRect );
TEStyleInsert( *text, dataSize, (StScrpRec ** )stylHdl,
gControls->lw->licTxt);
}
else
{
gControls->lw->licTxt = TENew( &destRect, &viewRect);
TEInsert( *text, dataSize, gControls->lw->licTxt);
}
HUnlock(text);
TextFont(systemFont);
TextSize(12);
TESetAlignment(teFlushDefault, gControls->lw->licTxt);
}
void
ShowTxt(void)
{
switch (gCurrWin)
{
case LICENSE:
if(gControls->lw->licTxt)
{
// InvalRect(&(**(gControls->lw->licTxt)).viewRect);
TEUpdate( &(**(gControls->lw->licTxt)).viewRect, gControls->lw->licTxt);
}
break;
case WELCOME:
if(gControls->ww->welcTxt)
{
// InvalRect(&(**(gControls->lw->licTxt)).viewRect);
TEUpdate( &(**(gControls->ww->welcTxt)).viewRect, gControls->ww->welcTxt);
}
break;
default:
ErrorHandler();
break;
}
}
void
ShowLogo(void)
{
short reserr;
Rect derefd, logoRect;
PicHandle logoPicH;
Handle logoRectH;
/* initialize Netscape logo */
logoPicH = GetPicture(rNSLogo);
/* draw Netscape logo */
if (logoPicH != nil)
{
logoRectH = Get1Resource('RECT', rNSLogoBox);
HLockHi(logoRectH);
derefd = (Rect) **((Rect**)logoRectH);
SetRect(&logoRect, derefd.left, derefd.top, derefd.bottom, derefd.right);
HUnlock(logoRectH);
reserr = ResError();
if (reserr == noErr)
{
DrawPicture(logoPicH, &logoRect);
ReleaseResource((Handle)logoPicH);
}
}
}
void
InLicenseContent(EventRecord* evt, WindowPtr wCurrPtr)
{
Point localPt;
Rect r;
ControlPartCode part;
short code, value;
ControlHandle scrollBar;
ControlActionUPP scrollActionFunctionUPP;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(gWPtr);
localPt = evt->where;
GlobalToLocal( &localPt);
code = FindControl(localPt, wCurrPtr, &scrollBar);
switch (code)
{
case kControlUpButtonPart:
case kControlDownButtonPart:
case kControlPageUpPart:
case kControlPageDownPart:
scrollActionFunctionUPP = NewControlActionProc((ProcPtr) DoScrollProc);
value = TrackControl(scrollBar, localPt, scrollActionFunctionUPP);
return;
break; /* <--- what is this for? */
case kControlIndicatorPart:
value = GetControlValue(scrollBar);
code = TrackControl(scrollBar, localPt, nil);
if (code)
{
value -= GetControlValue(scrollBar);
if (value)
{
TEScroll(0, value * kScrollAmount, gControls->lw->licTxt);
}
}
return;
break; /* <--- what is this for? */
}
HLockHi((Handle)gControls->backB);
r = (**(gControls->backB)).contrlRect;
HUnlock((Handle)gControls->backB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->backB, evt->where, NULL);
if (part)
gDone = true; /* Decline pressed */
}
HLockHi((Handle)gControls->nextB);
r = (**(gControls->nextB)).contrlRect;
HUnlock((Handle)gControls->nextB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->nextB, evt->where, NULL);
if (part)
{
KillControls(gWPtr);
ShowWelcomeWin();
return;
}
}
ShowTxt();
// TO DO
SetPort(oldPort);
}
void
EnableLicenseWin(void)
{
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(gWPtr);
EnableNavButtons();
if(gControls->lw->licBox)
HiliteControl(gControls->lw->licBox, kEnableControl);
if(gControls->lw->scrollBar)
HiliteControl(gControls->lw->scrollBar, kEnableControl);
ShowTxt();
SetPort(oldPort);
// TO DO
}
void
DisableLicenseWin(void)
{
//SysBeep(10);
DisableNavButtons();
/*
if(gControls->lw->licBox)
HiliteControl(gControls->lw->licBox, kDisableControl);
*/
if(gControls->lw->scrollBar)
HiliteControl(gControls->lw->scrollBar, kDisableControl);
}
void
InitScrollBar(ControlHandle sb)
{
short lines;
short max;
short height;
TEPtr te;
TEHandle currTE;
switch(gCurrWin)
{
case LICENSE:
currTE = gControls->lw->licTxt;
break;
case WELCOME:
currTE = gControls->ww->welcTxt;
break;
default:
ErrorHandler();
break;
}
lines = TEGetHeight((**currTE).nLines,0,currTE) / kScrollAmount;
te = *currTE; // point to TERec for convenience
height = te->viewRect.bottom - te->viewRect.top;
max = lines - (height / kScrollAmount);
if (height % kScrollAmount) max++;
if ( max < 0 ) max = 0;
SetControlMaximum(sb, max);
}
pascal void
DoScrollProc(ControlHandle theControl, short part)
{
short amount;
TEPtr te;
if ( part != 0 ) {
switch (gCurrWin)
{
case LICENSE:
te = *(gControls->lw->licTxt);
break;
case WELCOME:
te = *(gControls->ww->welcTxt);
break;
default:
ErrorHandler();
break;
}
switch ( part ) {
case kControlUpButtonPart:
case kControlDownButtonPart: // one line
amount = 1;
break;
case kControlPageUpPart: // one page
case kControlPageDownPart:
amount = (te->viewRect.bottom - te->viewRect.top) / kScrollAmount;
break;
}
if ( (part == kControlDownButtonPart) || (part == kControlPageDownPart) )
amount = -amount;
CalcChange(theControl, &amount);
if (amount) {
TEScroll(0, amount * kScrollAmount, &te);
}
}
}
void
CalcChange(ControlHandle theControl, short *amount)
{
short value, max;
value = GetControlValue(theControl); // get current value
max = GetControlMaximum(theControl); // and maximum value
*amount = value - *amount;
if (*amount < 0)
*amount = 0;
else if (*amount > max)
*amount = max;
SetControlValue(theControl, *amount);
*amount = value - *amount; // calculate the change
}
void
ShowNavButtons(unsigned char* backTitle, unsigned char* nextTitle)
{
Rect bounds;
gControls->backB = GetNewControl( rBackBtn, gWPtr);
gControls->nextB = GetNewControl( rNextBtn, gWPtr);
if( gControls->backB != NULL)
{
SetControlTitle( gControls->backB, backTitle);
ShowControl( gControls->backB);
}
if ( gControls->nextB != NULL)
{
SetControlTitle( gControls->nextB, nextTitle);
ShowControl( gControls->nextB);
HLockHi( (Handle) gControls->nextB);
bounds = (*(gControls->nextB))->contrlRect;
PenMode(patCopy);
ForeColor(blackColor);
InsetRect( &bounds, -4, -4 );
FrameGreyButton( &bounds );
HUnlock( (Handle)gControls->nextB );
}
}
void
EnableNavButtons(void)
{
if (gControls->backB)
HiliteControl(gControls->backB, kEnableControl);
if (gControls->nextB)
HiliteControl(gControls->nextB, kEnableControl);
// TO DO
}
void
DisableNavButtons(void)
{
if (gControls->backB)
HiliteControl(gControls->backB, kDisableControl);
if(gControls->nextB)
HiliteControl(gControls->nextB, kDisableControl);
// TO DO
}

Просмотреть файл

@ -0,0 +1,268 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
/*-----------------------------------------------------------*
* globals
*-----------------------------------------------------------*/
Boolean gDone;
WindowPtr gWPtr;
short gCurrWin;
InstWiz *gControls;
EventProc gSDIEvtHandler; /* SDI */
SDI_NETINSTALL gInstFunc;
CFragConnectionID gConnID;
/*-----------------------------------------------------------*
* Application Setup
*-----------------------------------------------------------*/
void main(void)
{
Init();
MainEventLoop();
}
void Init(void)
{
Str255 winTitle;
ThreadID tid;
ThreadState state;
OSErr err;
gDone = false;
InitManagers();
InitControlsObject();
InitOptObject();
#ifdef SDINST_IS_DLL
if (!InitSDLib())
{
ErrorHandler();
return;
}
#endif
#if CFG_IS_REMOTE == 1
if (!SpawnSDThread(PullDownConfig, &tid))
{
ErrorHandler();
return;
}
/* block/busy wait till download finishes */
while (1)
{
GetThreadState(tid, &state);
if (state == kStoppedThreadState)
break;
else
sleep(1);
}
ERR_CHECK(DisposeThread(tid, (void*)nil, false));
#endif /* CFG_IS_REMOTE == 1 */
gWPtr = GetNewCWindow(rRootWin, NULL, (WindowPtr) -1);
GetIndString( winTitle, rStringList, sNSInstTitle);
//pstrcpy(winTitle, "\pNetscape Installer Dude");
SetWTitle( gWPtr, winTitle );
MakeMenus();
ParseConfig();
ShowLicenseWin();
ShowWindow(gWPtr);
}
OSErr
GetCWD(long *outDirID, short *outVRefNum)
{
OSErr err = noErr;
ProcessSerialNumber psn;
ProcessInfoRec pInfo;
FSSpec tmp;
/* get cwd based on curr ps info */
if (!(err = GetCurrentProcess(&psn)))
{
pInfo.processName = nil;
pInfo.processAppSpec = &tmp;
pInfo.processInfoLength = (sizeof(ProcessInfoRec));
if(!(err = GetProcessInformation(&psn, &pInfo)))
{
*outDirID = pInfo.processAppSpec->parID;
*outVRefNum = pInfo.processAppSpec->vRefNum;
}
}
return err;
}
void
InitOptObject(void)
{
int i;
FSSpec tmp;
OSErr err=noErr;
gControls->opt = (Options*)NewPtrClear(sizeof(Options));
/* SetupTypeWin options */
gControls->opt->instChoice = 1;
gControls->opt->folder = (unsigned char *)NewPtrClear(64*sizeof(unsigned char));
ERR_CHECK(GetCWD(&gControls->opt->dirID, &gControls->opt->vRefNum));
ERR_CHECK(FSMakeFSSpec(gControls->opt->vRefNum, gControls->opt->dirID, NULL, &tmp));
pstrcpy( gControls->opt->folder, tmp.name );
/* ComponentsWin options */
for (i=0; i<kMaxComponents; i++)
gControls->opt->compSelected[i] = kNotSelected;
}
void
InitControlsObject(void)
{
gControls = (InstWiz *) NewPtrClear(sizeof(InstWiz));
gControls->lw = (LicWin *) NewPtrClear(sizeof(LicWin));
gControls->ww = (WelcWin *) NewPtrClear(sizeof(WelcWin));
gControls->stw = (SetupTypeWin *) NewPtrClear(sizeof(SetupTypeWin));
gControls->cw = (CompWin *) NewPtrClear(sizeof(CompWin));
gControls->tw = (TermWin*) NewPtrClear(sizeof(TermWin));
}
void InitManagers(void)
{
MaxApplZone();
MoreMasters(); MoreMasters(); MoreMasters();
InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(NULL);
InitCursor();
FlushEvents(everyEvent, 0);
}
void MakeMenus(void)
{
Handle mbarHdl;
MenuHandle menuHdl;
OSErr err;
if ( !(mbarHdl = GetNewMBar( rMBar)) )
ErrorHandler();
SetMenuBar(mbarHdl);
if (menuHdl = GetMenuHandle(mApple))
{
AppendResMenu(menuHdl, 'DRVR');
DisableItem(menuHdl, 0);
}
else
ErrorHandler();
if (menuHdl = GetMenuHandle(mFile))
DisableItem(menuHdl, 0);
else
ErrorHandler();
if (menuHdl = GetMenuHandle(mEdit))
DisableItem(menuHdl, 0);
else
ErrorHandler();
ERR_CHECK(HMGetHelpMenuHandle(&menuHdl));
DisableItem(menuHdl, 1);
DrawMenuBar();
}
void MainEventLoop(void)
{
EventRecord evt;
Boolean notHandled = true;
while (!gDone)
{
YieldToAnyThread(); /* SmartDownload dialog thread */
if (!gDone) /* after cx switch back ensure not done */
{
if(WaitNextEvent(everyEvent, &evt, 0, NULL))
{
#ifdef SDINST_IS_DLL
notHandled = gSDIEvtHandler(&evt);
#else
notHandled = SDI_HandleEvent(&evt);
#endif
if (notHandled)
HandleNextEvent(&evt);
}
}
}
Shutdown();
}
void ErrorHandler(void)
{
SysBeep(10);
gDone = true;
}
void Shutdown(void)
{
/* deallocate config object */
// TO DO
/* deallocate options object */
// TO DO
/* deallocate all controls */
DisposePtr( (char*) gControls->lw);
// DisposeControl(gControls->nextB);
// DisposeControl(gControls->backB);
DisposePtr( (char*) gControls->ww);
DisposePtr( (char*) gControls->stw);
DisposePtr( (char*) gControls->cw);
DisposePtr( (char*) gControls->tw);
DisposePtr( (char*) gControls);
DisposeWindow(gWPtr);
UnloadSDLib(&gConnID);
}

Просмотреть файл

@ -0,0 +1,531 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code, released March
* 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998-1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#define _MIW_H_
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <Navigation.h>
#include <MacTypes.h>
#include <PLStringFuncs.h>
#include "FullPath.h"
#include "MoreFilesExtras.h"
#include "Threads.h"
/*-----------------------------------------------------------*
* SBI: SmartDownload administration
*-----------------------------------------------------------*/
#define WANT_WINTYPES 1
#define MACINTOSH 1
#ifndef _sdinst_h
#include "sdinst.h"
#endif
typedef HRESULT (_cdecl *SDI_NETINSTALL) (LPSDISTRUCT);
typedef Boolean (*EventProc)(const EventRecord*);
/*-----------------------------------------------------------*
* compile time switches [on=1; off=0]
*-----------------------------------------------------------*/
#define CORRECT_DL_LOCATION 0 /* if on, download to "Temporary Items" */
#define CFG_IS_REMOTE 0 /* if on, download remote config.ini file */
#define SDINST_IS_DLL 1 /* if on, load SDInstLib as code fragment */
#define MOZILLA 0 /* if on, draws the Mozilla logo, not NS */
/*-----------------------------------------------------------*
* defines
*-----------------------------------------------------------*/
/* macros */
#define ERR_CHECK(_funcCall) \
err = _funcCall; \
if (err) \
{ \
ErrorHandler(); \
return; \
}
#define ERR_CHECK_RET(_funcCall, _rv) \
err = _funcCall; \
if (err) \
{ \
ErrorHandler(); \
return _rv; \
}
#define NUM_WINS 5
#define LICENSE 0 /* window object ids */
#define WELCOME 1
#define SETUP_TYPE 2
#define COMPONENTS 3
#define TERMINAL 4
#define NGINST 1 /* event handling modes */
#define SDI 2
#define MY_EOF '\0' /* parser constants */
#define MAC_EOL '\r'
#define WIN_EOL '\n'
#define START_SECTION '['
#define END_SECTION ']'
#define KV_DELIM '='
#define kScrollBarPad 3 /* constants */
#define kTxtRectPad 5
#define kInterWidgetPad 12
#define kScrollBarWidth 16
#define kScrollAmount 11
#define kNumLicScrns 4
#define kNumWelcMsgs 3
#define kNumWelcScrns 4
#define kMaxSetupTypes 4
#define kMaxComponents 64
#define kMaxNumKeys 16
#define kKeyMaxLen 128
#define kValueMaxLen 512
#define kSNameMaxLen 128 /* v--- for KV_DELIM char */
#define kSectionMaxLen (kKeyMaxLen+1+kValueMaxLen)*kMaxNumKeys
#define kMaxURLPerComp 8
#define kURLMaxLen 255
#define kArchiveMaxLen 64
#define kGenIDIFileSize 0x2000
#define kEnableControl 0
#define kDisableControl 255
#define kNotSelected 0
#define kSelected 1
#define kNotInSetupType 0
#define kInSetupType 1 /* end constants */
#define rRootWin 128 /* widget rsrc ids */
#define rBackBtn 129
#define rNextBtn 130
#if MOZILLA == 1
#define rNSLogo 141
#else
#define rNSLogo 140
#endif
#define rNSLogoBox 130
#define rLicBox 131
#define rLicScrollBar 132
#define rInstType 140
#define rInstDescBox 141
#define rDestLocBox 142
#define rDestLoc 143
#define rCompListBox 150 /* note: overriden use for list and rect */
#define rCompDescBox 151
#define rStartMsgBox 160
#define rMBar 128 /* menu rsrc ids */
#define mApple 150
#define iAbout 1
#define mFile 151
#define iQuit 1
#define mEdit 152
#define iUndo 1
#define iCut 3
#define iCopy 4
#define iPaste 5
#define iClear 6
#define rStringList 140 /* i18n strings */
#define sBackBtn 1
#define sNextBtn 2
#define sDeclineBtn 3
#define sAcceptBtn 4
#if MOZILLA == 1
#define sNSInstTitle 22
#else
#define sNSInstTitle 5
#endif
#define sInstallBtn 6
#define sLicenseFName 7
#define sInstLocTitle 8
#define sSelectFolder 9
#define sOnDisk 10
#define sInFolder 11
#define sCompDescTitle 12
#define sConfigFName 14
#define sSDLib 15
#define sTempIDIName 16
#define sConfigIDIName 17
#define sFolderDlgMsg 18
#define sDiskSpcAvail 19
#define sDiskSpcNeeded 20
#define sKilobytes 21 /* end i18n strings */
#define rParseKeys 141 /* parse keys in config.ini */
#define sGeneral 1
#define sRunMode 2
#define sProductName 3
#define sProgFolderName 4
#define sProgFoldPath 5
#define sDefaultType 6
#define sShowDlg 7
#define sTitle 8
#define sMsg0 9
#define sMsg1 10
#define sMsg2 11
#define rIndices 142 /* integer indices in string form (0-9) */
#define rIDIKeys 143
#define sFile 1
#define sDesc 2
#define sSDNSInstall 3 /* used when pasring INI */
#define sCoreFile 4
#define sCoreDir 5
#define sNoAds 6
#define sSilent 7
#define sExecution 8
#define sConfirmInstall 9
#define sTrue 10
#define sFalse 11
#define sNSInstall 12 /* used when generating IDI */
#define sWelcDlg 12
#define sLicDlg 14
#define sLicFile 15
#define sSetupTypeDlg 16
#define sSetupType 17
#define sDescShort 18
#define sDescLong 19
#define sC 20
#define sCompDlg 21
#define sComponent 22
#define sArchive 23
#define sInstSize 24
#define sAttr 25
#define sURL 26
#define sTermDlg 27 /* end parse keys */
#define eParseFailed -501 /* errors */
/*-----------------------------------------------------------*
* structs
*-----------------------------------------------------------*/
typedef struct InstComp {
Handle shortDesc;
Handle longDesc;
Handle archive;
long size;
Handle url[kMaxURLPerComp];
short numURLs;
// TO DO: attributes
} InstComp;
typedef struct SetupType {
Handle shortDesc;
Handle longDesc;
short comp[kMaxComponents];
short numComps;
} SetupType;
typedef struct Config {
/* LicenseWin */
Handle licFileName;
/* WelcomeWin */
Handle welcMsg[ kNumWelcMsgs ];
/* SetupTypeWin */
SetupType st[kMaxSetupTypes];
short numSetupTypes;
/* ComponentsWin */
short numComps;
Handle selCompMsg;
InstComp comp[kMaxComponents];
/* TerminalWin */
Handle startMsg;
/* "Tunneled" IDI keys */
Handle coreFile;
Handle coreDir;
Handle noAds;
Handle silent;
Handle execution;
Handle confirmInstall;
} Config;
typedef struct Options {
/* from SetupTypeWin */
short instChoice;
short vRefNum;
long dirID;
unsigned char* folder;
/* from ComponentsWin */
short compSelected[ kMaxComponents ];
short numCompSelected;
/* NOTE: if instChoice is not last (i.e. not Custom) then populate
the compSelected list with the SetupType.comps associated */
} Options;
typedef struct LicWin {
ControlHandle licBox;
ControlHandle scrollBar;
TEHandle licTxt;
} LicWin;
typedef struct WelcWin {
ControlHandle welcBox;
ControlHandle scrollBar;
TEHandle welcTxt;
} WelcWin;
typedef struct SetupTypeWin {
ControlHandle instType; /* pull down */
ControlHandle instDescBox;
TEHandle instDescTxt;
ControlHandle destLocBox; /* destLoc = destination location */
ControlHandle destLoc; /* Select Folder... */
} SetupTypeWin;
typedef struct CompWin {
ControlHandle selCompMsg;
Rect compListBox; /* from 'RECT' resource */
ListHandle compList;
ControlHandle compDescBox;
TEHandle compDescTxt;
} CompWin;
typedef struct TermWin {
TEHandle startMsg;
Rect startMsgBox;
} TermWin;
typedef struct InstWiz {
/* config.ini options parsed */
Config *cfg;
/* user selected Install Wizard-wide persistent options */
Options *opt;
/* Window control-holding abstractions */
LicWin *lw;
WelcWin *ww;
SetupTypeWin *stw;
CompWin *cw;
TermWin *tw;
/* General wizard controls */
ControlHandle backB;
ControlHandle nextB;
} InstWiz;
/*-----------------------------------------------------------*
* globals
*-----------------------------------------------------------*/
extern WindowPtr gWPtr;
extern short gCurrWin;
extern InstWiz *gControls;
extern Boolean gDone;
extern EventProc gSDIEvtHandler;
extern SDI_NETINSTALL gInstFunc;
extern CFragConnectionID gConnID;
/*-----------------------------------------------------------*
* prototypes
*-----------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
void main(void);
void Init(void);
void InitControlsObject(void);
OSErr GetCWD(long *outDirID, short *outVRefNum);
void InitOptObject(void);
void InitManagers(void);
void MakeMenus(void);
void MainEventLoop(void);
void ErrorHandler(void);
void Shutdown(void);
/*-----------------------------------------------------------*
* Parser
*-----------------------------------------------------------*/
pascal void *PullDownConfig(void*);
void ParseConfig(void);
Boolean ReadConfigFile(char **);
OSErr PopulateLicWinKeys(char *);
OSErr PopulateWelcWinKeys(char *);
OSErr PopulateSetupTypeWinKeys(char *);
OSErr PopulateCompWinKeys(char *);
OSErr PopulateTermWinKeys(char *);
OSErr PopulateIDIKeys(char *);
Boolean FillKeyValueForIDIKey(short, Handle, char *);
Boolean FillKeyValueUsingResID(short, short, Handle, char *);
Boolean FillKeyValueUsingSLID(short, short, short, Handle, char *);
Boolean FillKeyValueUsingName(char *, char *, Handle, char *);
Boolean FindKeyValue(const char *, const char *, const char *, char *);
Boolean GetNextSection(char **, char *, char *);
Boolean GetNextKeyVal(char **, char *, char*);
unsigned char *CToPascal(char *);
char * PascalToC(unsigned char *);
/*-----------------------------------------------------------*
* EvtHandlers
*-----------------------------------------------------------*/
void HandleNextEvent(EventRecord *);
void HandleMouseDown(EventRecord *);
void HandleKeyDown(EventRecord *);
void HandleUpdateEvt(EventRecord *);
void HandleActivateEvt(EventRecord *);
void HandleOSEvt(EventRecord *);
void React2InContent(EventRecord *, WindowPtr);
/*-----------------------------------------------------------*
* LicenseWin
*-----------------------------------------------------------*/
void ShowLicenseWin(void);
void InLicenseContent(EventRecord*, WindowPtr);
void EnableLicenseWin(void);
void DisableLicenseWin(void);
void InitLicTxt(void);
void ShowTxt(void);
void ShowLogo(void);
void InitScrollBar(ControlHandle);
pascal void DoScrollProc(ControlHandle, short);
void CalcChange(ControlHandle, short *);
void ShowNavButtons(unsigned char*, unsigned char*);
void EnableNavButtons(void);
void DisableNavButtons(void);
/*-----------------------------------------------------------*
* WelcomeWin
*-----------------------------------------------------------*/
void ShowWelcomeWin(void);
void InitWelcTxt(void);
void InWelcomeContent(EventRecord*, WindowPtr);
void EnableWelcomeWin(void);
void DisableWelcomeWin(void);
/*-----------------------------------------------------------*
* SetupTypeWin
*-----------------------------------------------------------*/
void ShowSetupTypeWin(void);
void ShowSetupDescTxt(void);
void GetAllVInfo(unsigned char **, short *);
pascal void OurNavEventFunction(NavEventCallbackMessage callBackSelector,
NavCBRecPtr callBackParms, NavCallBackUserData callBackUD);
void DrawDiskNFolder(short, unsigned char *);
void DrawDiskSpaceMsgs(short);
char* DiskSpaceNeeded(void);
void ClearDiskSpaceMsgs(void);
char* ltoa(long);
short pstrcmp(unsigned char*, unsigned char*);
unsigned char* pstrcpy(unsigned char*, unsigned char*);
void InSetupTypeContent(EventRecord *, WindowPtr);
void EnableSetupTypeWin(void);
void DisableSetupTypeWin(void);
/*-----------------------------------------------------------*
* ComponentsWin
*-----------------------------------------------------------*/
void ShowComponentsWin(void);
Boolean PopulateCompInfo(void);
void UpdateCompWin(void);
void InComponentsContent(EventRecord*, WindowPtr);
void SetOptInfo(void);
void EnableComponentsWin(void);
void DisableComponentsWin(void);
/*-----------------------------------------------------------*
* TerminalWin
*-----------------------------------------------------------*/
void ShowTerminalWin(void);
void InTerminalContent(EventRecord*, WindowPtr);
void UpdateTerminalWin(void);
Boolean SpawnSDThread(ThreadEntryProcPtr, ThreadID *);
void EnableTerminalWin(void);
void DisableTerminalWin(void);
/*-----------------------------------------------------------*
* InstAction
*-----------------------------------------------------------*/
pascal void *Install(void*);
Boolean GenerateIDIFromOpt(Str255, long, short, FSSpec *);
void AddKeyToIDI(short, Handle, char *);
Boolean InitSDLib(void);
Boolean LoadSDLib(FSSpec, SDI_NETINSTALL *, EventProc *, CFragConnectionID *);
Boolean UnloadSDLib(CFragConnectionID *);
/*-----------------------------------------------------------*
* Deflation
*-----------------------------------------------------------*/
OSErr ExtractCoreFile(void);
OSErr AppleSingleDecode(FSSpecPtr, FSSpecPtr);
void ResolveDirs(char *, char*);
OSErr ForceMoveFile(short, long, ConstStr255Param, long);
/*-----------------------------------------------------------*
* XPInstallGlue
*-----------------------------------------------------------*/
OSErr RunXPI(FSSpec&, FSSpec&);
/* NB:
** See XPInstallGlue.c for rest of prototypes
*/
/*-----------------------------------------------------------*
* GreyButton
*-----------------------------------------------------------*/
pascal void FrameGreyButton( Rect *buttonFrame );
void SetFrameGreyButtonColor( short color );
#ifdef __cplusplus
}
#endif
#endif /* _MIW_H_ */

Просмотреть файл

@ -0,0 +1,705 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
/*-----------------------------------------------------------*
* INI Parser
*-----------------------------------------------------------*/
pascal void *
PullDownConfig(void *unused)
{
short vRefNum;
long dirID;
OSErr err;
FSSpec idiSpec;
SDISTRUCT sdistruct;
Str255 pIDIfname;
ERR_CHECK_RET(GetCWD(&dirID, &vRefNum), (void*)0);
GetIndString(pIDIfname, rStringList, sConfigIDIName);
/* get idi filepath */
ERR_CHECK_RET(FSMakeFSSpec(vRefNum, dirID, pIDIfname, &idiSpec), false);
/* populate SDI struct */
sdistruct.dwStructSize = sizeof(SDISTRUCT);
sdistruct.fsIDIFile = idiSpec;
sdistruct.dlDirVRefNum = vRefNum;
sdistruct.dlDirID = dirID;
sdistruct.hwndOwner = NULL;
/* call SDI_NetInstall */
gInstFunc(&sdistruct);
return (void*)true;
}
void
ParseConfig(void)
{
OSErr err;
char **cfgText;
gControls->cfg = (Config*) NewPtrClear(sizeof(Config));
if(!ReadConfigFile(cfgText))
{
ErrorHandler();
return;
}
ERR_CHECK(PopulateLicWinKeys(*cfgText));
ERR_CHECK(PopulateWelcWinKeys(*cfgText));
ERR_CHECK(PopulateCompWinKeys(*cfgText));
ERR_CHECK(PopulateSetupTypeWinKeys(*cfgText));
ERR_CHECK(PopulateTermWinKeys(*cfgText));
ERR_CHECK(PopulateIDIKeys(*cfgText));
DisposePtr(*cfgText);
}
Boolean
ReadConfigFile(char **text)
{
Boolean bSuccess = true;
OSErr err;
FSSpec cfgFile;
long dirID, dataSize;
short vRefNum;
Str255 fname;
ERR_CHECK_RET(GetCWD(&dirID, &vRefNum), false);
/* open config.ini file */
GetIndString(fname, rStringList, sConfigFName);
if (err = FSMakeFSSpec(vRefNum, dirID, fname, &cfgFile) )
return false;
if (err = FSpOpenDF( &cfgFile, fsRdPerm, &vRefNum))
return false;
/* read in entire text */
if (err = GetEOF(vRefNum, &dataSize))
bSuccess = false;
if (dataSize > 0)
{
*text = (char*) NewPtrClear(dataSize);
if (err = FSRead(vRefNum, &dataSize, *text))
bSuccess = false;
}
else
{
*text = nil;
bSuccess = false;
}
/* close file */
if (err = FSClose(vRefNum))
return false;
return bSuccess;
}
OSErr
PopulateLicWinKeys(char *cfgText)
{
OSErr err = noErr;
/* LicenseWin: license file name */
gControls->cfg->licFileName = NewHandleClear(kValueMaxLen);
if (!FillKeyValueUsingResID(sLicDlg, sLicFile, gControls->cfg->licFileName, cfgText))
err = eParseFailed;
return err;
}
OSErr
PopulateWelcWinKeys(char *cfgText)
{
OSErr err = noErr;
/* WelcomeWin: message strings */
gControls->cfg->welcMsg[0] = NewHandleClear(kValueMaxLen);
if (!FillKeyValueUsingResID(sWelcDlg, sMsg0, gControls->cfg->welcMsg[0], cfgText))
err = eParseFailed;
gControls->cfg->welcMsg[1] = NewHandleClear(kValueMaxLen);
FillKeyValueUsingResID(sWelcDlg, sMsg1, gControls->cfg->welcMsg[1], cfgText);
gControls->cfg->welcMsg[2] = NewHandleClear(kValueMaxLen);
FillKeyValueUsingResID(sWelcDlg, sMsg2, gControls->cfg->welcMsg[2], cfgText);
return err;
}
OSErr
PopulateCompWinKeys(char *cfgText)
{
OSErr err = noErr;
int i, j, hunVal, tenVal, unitVal;
Ptr currSNameBuf, currSName, currKeyBuf, currKey, idxCh;
Str255 pSName, pkey, pidx;
char eof[1];
eof[0] = 0;
/* ComponentsWin: components and their descriptions, and other properties */
gControls->cfg->selCompMsg = NewHandleClear(kValueMaxLen);
FillKeyValueUsingResID(sCompDlg, sMsg0, gControls->cfg->selCompMsg, cfgText);
gControls->cfg->numComps = 0;
for (i=0; i<kMaxComponents; i++)
{
GetIndString(pSName, rParseKeys, sComponent);
currSNameBuf = PascalToC(pSName);
currSName = NewPtrClear(kSNameMaxLen);
strncpy(currSName, currSNameBuf, strlen(currSNameBuf));
if(i>99) // concat 100's digit
{
hunVal = i/100;
GetIndString(pidx, rIndices, hunVal+1);
idxCh = PascalToC(pidx);
strncat(currSName, idxCh, 1);
DisposePtr(idxCh);
}
else
hunVal = 0;
if(i>9) // concat 10's digit
{
tenVal = (i - (hunVal*100))/10;
GetIndString(pidx, rIndices, tenVal+1);
idxCh = PascalToC(pidx);
strncat(currSName, idxCh, 1);
DisposePtr(idxCh);
}
else
tenVal = 0;
unitVal = i - (hunVal*100) - (tenVal*10);
GetIndString(pidx, rIndices, unitVal+1);
idxCh = PascalToC(pidx);
strncat(currSName, idxCh, 1);
DisposePtr(idxCh);
strncat(currSName, eof, 1);
/* short description */
GetIndString(pkey, rParseKeys, sDescShort);
currKey = PascalToC(pkey);
gControls->cfg->comp[i].shortDesc = NewHandleClear(kValueMaxLen);
if (!FillKeyValueUsingName(currSName, currKey, gControls->cfg->comp[i].shortDesc, cfgText))
{
DisposePtr(currKey);
break; // no more Components
}
DisposePtr(currKey);
/* long description */
GetIndString(pkey, rParseKeys, sDescLong);
currKey = PascalToC(pkey);
gControls->cfg->comp[i].longDesc = NewHandleClear(kValueMaxLen);
FillKeyValueUsingName(currSName, currKey, gControls->cfg->comp[i].longDesc, cfgText);
DisposePtr(currKey);
/* archive */
GetIndString(pkey, rParseKeys, sArchive);
currKey = PascalToC(pkey);
gControls->cfg->comp[i].archive = NewHandleClear(kArchiveMaxLen);
FillKeyValueUsingName(currSName, currKey, gControls->cfg->comp[i].archive, cfgText);
DisposePtr(currKey);
/* install size */
GetIndString(pkey, rParseKeys, sInstSize);
currKey = PascalToC(pkey);
Handle sizeH = NewHandleClear(4); // long is four bytes
FillKeyValueUsingName(currSName, currKey, sizeH, cfgText);
HLockHi(sizeH);
gControls->cfg->comp[i].size = atol(*sizeH);
HUnlock(sizeH);
DisposeHandle(sizeH);
DisposePtr(currKey);
/* URLs for redundancy/retry/failover */
gControls->cfg->comp[i].numURLs = 0;
for (j=0; j<kMaxURLPerComp; j++)
{
GetIndString(pkey, rParseKeys, sURL);
currKeyBuf = PascalToC(pkey);
currKey = NewPtrClear(strlen(currKeyBuf)+3); // tens, unit, null termination
strncpy(currKey, currKeyBuf, strlen(currKeyBuf));
gControls->cfg->comp[i].url[j] = NewHandleClear(kURLMaxLen);
GetIndString(pidx, rIndices, j+1);
idxCh = PascalToC(pidx);
strncat(currKey, idxCh, 1);
DisposePtr(idxCh);
strncat(currKey, eof, 1);
if (!FillKeyValueUsingName(currSName, currKey, gControls->cfg->comp[i].url[j], cfgText))
{
DisposePtr(currKey);
break;
}
gControls->cfg->comp[i].numURLs++;
DisposePtr(currKey);
}
}
gControls->cfg->numComps = i;
return err;
}
OSErr
PopulateSetupTypeWinKeys(char *cfgText)
{
OSErr err = noErr;
int i, j, hunVal, tenVal, unitVal, compNum, cNumIdx;
Ptr currSNameBuf, currSName, currKeyBuf, currKey, idxCh, currCompName, compIdx;
Str255 pSName, pkey, pidx;
char eof[1];
Handle currVal;
eof[0] = 0;
/* SetupTypeWin: types and their descriptions */
gControls->cfg->numSetupTypes = 0;
for (i=0;i<kMaxSetupTypes;i++) /* init stComp[][] lists */
{
for(j=0; j<gControls->cfg->numComps; j++)
{
gControls->cfg->st[i].comp[j] = kNotInSetupType;
}
}
for (i=0; i<kMaxSetupTypes; i++)
{
GetIndString(pSName, rParseKeys, sSetupType);
currSNameBuf = PascalToC(pSName);
currSName = NewPtrClear(kKeyMaxLen);
strncpy(currSName, currSNameBuf, strlen(currSNameBuf));
unitVal = i;
GetIndString(pidx, rIndices, unitVal+1);
idxCh = PascalToC(pidx);
strncat(currSName, idxCh, 1);
DisposePtr(idxCh);
strncat(currSName, eof, 1);
/* short description */
GetIndString(pkey, rParseKeys, sDescShort);
currKey = PascalToC(pkey);
gControls->cfg->st[i].shortDesc = NewHandleClear(kValueMaxLen);
if (!FillKeyValueUsingName(currSName, currKey, gControls->cfg->st[i].shortDesc, cfgText))
{
DisposePtr(currKey);
break; // no more SetupTypes
}
DisposePtr(currKey);
/* long description */
GetIndString(pkey, rParseKeys, sDescLong);
currKey = PascalToC(pkey);
gControls->cfg->st[i].longDesc = NewHandleClear(kValueMaxLen);
FillKeyValueUsingName(currSName, currKey, gControls->cfg->st[i].longDesc, cfgText);
DisposePtr(currKey);
/* now search for all components in this SetupType and fill its stComp[][] array */
gControls->cfg->st[i].numComps = 0;
for (j=0; j<gControls->cfg->numComps; j++)
{
GetIndString(pkey, rParseKeys, sC);
currKeyBuf = PascalToC(pkey);
currKey = NewPtrClear(kKeyMaxLen);
strncpy(currKey, currKeyBuf, strlen(currKeyBuf));
if(j>99) // concat 100's digit
{
hunVal = j/100;
GetIndString(pidx, rIndices, hunVal+1);
idxCh = PascalToC(pidx);
strncat(currKey, idxCh, 1);
DisposePtr(idxCh);
}
else
hunVal = 0;
if(j>9) // concat 10's digit
{
tenVal = (j - (hunVal*100))/10;
GetIndString(pidx, rIndices, tenVal+1);
idxCh = PascalToC(pidx);
strncat(currKey, idxCh, 1);
DisposePtr(idxCh);
}
else
tenVal = 0;
unitVal = j - (hunVal*100) - (tenVal*10);
GetIndString(pidx, rIndices, unitVal+1);
idxCh = PascalToC(pidx);
strncat(currKey, idxCh, 1);
DisposePtr(idxCh);
strncat(currKey, eof, 1);
currVal = NewHandleClear(kValueMaxLen);
if (FillKeyValueUsingName(currSName, currKey, currVal, cfgText))
{
/* Parse the value to get the component index */
GetIndString(pSName, rParseKeys, sComponent);
currSNameBuf = PascalToC(pSName);
currCompName = NewPtrClear(kKeyMaxLen);
strncpy(currCompName, currSNameBuf, strlen(currSNameBuf));
HLockHi(currVal);
cNumIdx = strspn(currCompName, *currVal);
compIdx = *currVal+cNumIdx;
compNum = atoi(compIdx);
gControls->cfg->st[i].comp[compNum] = kInSetupType;
gControls->cfg->st[i].numComps++; /* not used? */
HUnlock(currVal);
}
}
DisposePtr(currKey);
DisposePtr(currKeyBuf);
DisposePtr(currSName);
DisposePtr(currSNameBuf);
}
gControls->cfg->numSetupTypes = i;
return err;
}
OSErr
PopulateTermWinKeys(char *cfgText)
{
OSErr err = noErr;
/* TerminalWin: start install msg */
gControls->cfg->startMsg = NewHandleClear(kValueMaxLen);
FillKeyValueUsingResID(sTermDlg, sMsg0, gControls->cfg->startMsg, cfgText);
return err;
}
OSErr
PopulateIDIKeys(char *cfgText)
{
OSErr err = noErr;
/* "Tunneled" IDI Keys */
gControls->cfg->coreFile = NewHandleClear(kValueMaxLen);
FillKeyValueUsingSLID(rIDIKeys, sSDNSInstall, sCoreFile, gControls->cfg->coreFile, cfgText);
gControls->cfg->coreDir = NewHandleClear(kValueMaxLen);
FillKeyValueUsingSLID(rIDIKeys, sSDNSInstall, sCoreDir, gControls->cfg->coreDir, cfgText);
gControls->cfg->noAds = NewHandleClear(kValueMaxLen);
FillKeyValueUsingSLID(rIDIKeys, sSDNSInstall, sNoAds, gControls->cfg->noAds, cfgText);
gControls->cfg->silent = NewHandleClear(kValueMaxLen);
FillKeyValueUsingSLID(rIDIKeys, sSDNSInstall, sSilent, gControls->cfg->silent, cfgText);
gControls->cfg->execution = NewHandleClear(kValueMaxLen);
FillKeyValueUsingSLID(rIDIKeys, sSDNSInstall, sExecution, gControls->cfg->execution, cfgText);
gControls->cfg->confirmInstall = NewHandleClear(kValueMaxLen);
FillKeyValueUsingSLID(rIDIKeys, sSDNSInstall, sConfirmInstall, gControls->cfg->confirmInstall, cfgText);
return err;
}
Boolean
FillKeyValueUsingResID(short dlgID, short keyID, Handle dest, char *cfgText)
{
/* Fill key-value pair using resIDs for the dlg/section name, and the key */
return FillKeyValueUsingSLID(rParseKeys, dlgID, keyID, dest, cfgText);
}
Boolean
FillKeyValueForIDIKey(short keyID, Handle dest, char *cfgText)
{
/* Fill key-value pair in IDI stringlist */
return FillKeyValueUsingSLID(rIDIKeys, sSDNSInstall, keyID, dest, cfgText);
}
Boolean
FillKeyValueUsingSLID(short stringListID, short dlgID, short keyID, Handle dest, char *cfgText)
{
/* Fill key-value pair using stringlist ID */
unsigned char pkey[kKeyMaxLen], psectionName[kSNameMaxLen];
char *key, *sectionName;
Boolean bFound = false;
GetIndString(pkey, stringListID, keyID);
key = PascalToC(pkey);
GetIndString(psectionName, stringListID, dlgID);
sectionName = PascalToC(psectionName);
if (FillKeyValueUsingName(sectionName, key, dest, cfgText))
bFound = true;
DisposePtr(sectionName);
DisposePtr(key);
return bFound;
}
Boolean
FillKeyValueUsingName(char *sectionName, char *keyName, Handle dest, char *cfgText)
{
/* Fill key-value pair using the pascal string section name and key name */
char *value;
long len;
Boolean bFound = false;
value = (char*) NewPtrClear(kValueMaxLen);
if (FindKeyValue(cfgText, sectionName, keyName, value))
{
HLock(dest);
len = strlen(value);
strncpy(*dest, value, len);
HUnlock(dest);
bFound = true;
}
DisposePtr(value);
return bFound;
}
Boolean
FindKeyValue(const char *cfg, const char *inSectionName, const char *inKey, char *outValue)
{
char *sectionName, *section, *key, *cfgPtr[1], *sectionPtr[1];
*cfgPtr = cfg;
sectionName = (char *) NewPtrClear( kSNameMaxLen );
section = (char *) NewPtrClear( kSectionMaxLen );
key = (char *) NewPtrClear( kKeyMaxLen );
/* find next section [cfgPtr moved past next section per iteration] */
while(GetNextSection(cfgPtr, sectionName, section))
{
if (strncmp(sectionName, inSectionName, strlen(inSectionName)) == 0)
{
*sectionPtr = section;
/* find next key [sectionPtr moved past next key per iteration] */
while(GetNextKeyVal(sectionPtr, key, outValue))
{
if (strncmp(key, inKey, strlen(key)) == 0)
{
DisposePtr(key);
DisposePtr(sectionName);
DisposePtr(section);
return true;
}
}
}
}
DisposePtr(key);
DisposePtr(sectionName);
DisposePtr(section);
return false;
}
Boolean
GetNextSection(char **ioTxt, char *outSectionName, char *outSection)
{
Boolean exists = false;
char *txt, *snbuf, *sbuf;
long cnt;
txt = *ioTxt;
while (*txt != START_SECTION)
{
if (*txt == MY_EOF)
return false;
else
txt++;
}
if (*txt == START_SECTION) /* section name start */
{
txt++;
snbuf = outSectionName;
cnt = 0;
while (*txt != END_SECTION) /* section name end */
{
if ((*txt==MAC_EOL) || (*txt==WIN_EOL)) /* incomplete section name so die */
{
return false;
}
if( kSNameMaxLen-1 >= cnt++) /* prevent falling of end of outSectionName buffer */
{
*snbuf = *txt;
snbuf++; txt++;
}
else
txt++;
}
*snbuf = MY_EOF; /* close string */
txt++; /* skip over section name end char ']' */
}
/* adminstration before section contents encountered */
while( (*txt == MAC_EOL) || (*txt == WIN_EOL) || (*txt == ' ') || (*txt == '\t'))
{
txt++;
}
sbuf = outSection;
cnt = 0;
while (*txt != START_SECTION && *txt != MY_EOF) /* next section encountered */
{
if( kSectionMaxLen-1 >= cnt++) /* prevent from falling of end of outSection buffer */
{
*sbuf = *txt;
sbuf++; txt++;
}
else
txt++;
}
*sbuf = MY_EOF; /* close string */
*ioTxt = txt; /* move txt ptr to next section */
exists = true;
return exists;
}
Boolean
GetNextKeyVal(char **inSection, char *outKey, char *outVal)
{
Boolean exists = false;
char *key, *sbuf, *val;
long cnt;
sbuf = *inSection;
/* clear out extra carriage returns above next key */
while( (*sbuf == MAC_EOL) || (*sbuf == WIN_EOL) || (*sbuf == ' ') || (*sbuf == '\t'))
{
if (*sbuf == MY_EOF) /* no more keys */
return false;
else
sbuf++;
}
key = outKey;
cnt = 0;
while((*sbuf != MAC_EOL) && (*sbuf != WIN_EOL))
{
if (*sbuf == KV_DELIM)
{
if (key != nil) /* key not empty */
exists = true;
break;
}
if ( kKeyMaxLen-1 >= cnt++) /* prevent from falling of end of outKey buffer */
{
*key = *sbuf;
key++; sbuf++;
}
else
sbuf++;
}
*key = MY_EOF; /* close string */
sbuf++;
if (exists) /* key found so now get value */
{
val = outVal;
cnt = 0;
while((*sbuf != MAC_EOL) && (*sbuf != WIN_EOL))
{
if ( kValueMaxLen-1 >= cnt++) /* prevent from falling of end of outValue buffer */
{
*val = *sbuf;
val++; sbuf++;
}
else
sbuf++;
}
}
*val = MY_EOF; /* close string */
sbuf++;
*inSection = sbuf; /* capture current position in section for future GetNextKeyValue() */
return exists;
}
/*
* Makes a copy of the C string, converts the copy to a Pascal string,
* and returns the Pascal string copy
*/
unsigned char *CToPascal(char *str)
{
register char *p,*q;
long len;
char* cpy;
len = strlen(str);
cpy = (char*)NewPtrClear(len);
if (!cpy)
return 0;
strncpy(cpy, str, len);
if (len > 255) len = 255;
p = cpy + len;
q = p-1;
while (p != cpy) *p-- = *q--;
*cpy = len;
return((unsigned char *)cpy);
}
char *PascalToC(unsigned char *str)
{
register unsigned char *p,*q,*end;
unsigned char * cpy;
cpy = (unsigned char*)NewPtrClear( ((long)*str+1) );
strncpy((char*)cpy, (char*) str, (long)*str+1);
end = cpy + *cpy;
q = (p=cpy) + 1;
while (p < end) *p++ = *q++;
*p = '\0';
return((char *)cpy);
}

Просмотреть файл

@ -0,0 +1,622 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
/*-----------------------------------------------------------*
* Setup Type Window
*-----------------------------------------------------------*/
void
ShowSetupTypeWin(void)
{
Str255 next;
Str255 back;
MenuHandle popupMenu;
PopupPrivateData ** pvtDataHdl;
unsigned char * currMenuItem;
short i;
/*
short numVols;
unsigned char ** volName;
*/
Rect viewRect;
long txtSize;
Str255 instLocTitle, selectFolder;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(gWPtr);
gCurrWin = SETUP_TYPE;
/* gControls->stw = (SetupTypeWin *) NewPtrClear(sizeof(SetupTypeWin)); */
GetIndString(next, rStringList, sNextBtn);
GetIndString(back, rStringList, sBackBtn);
// malloc and get controls
gControls->stw->instType = GetNewControl( rInstType, gWPtr);
gControls->stw->instDescBox = GetNewControl( rInstDescBox, gWPtr);
gControls->stw->destLocBox = GetNewControl( rDestLocBox, gWPtr);
gControls->stw->destLoc = GetNewControl(rDestLoc, gWPtr);
// populate popup button menus
HLockHi((Handle)gControls->stw->instType);
pvtDataHdl = (PopupPrivateData **) (*(gControls->stw->instType))->contrlData;
popupMenu = (MenuHandle) (**pvtDataHdl).mHandle;
for (i=0; i<gControls->cfg->numSetupTypes; i++)
{
HLockHi(gControls->cfg->st[i].shortDesc);
currMenuItem = CToPascal(*gControls->cfg->st[i].shortDesc);
HUnlock(gControls->cfg->st[i].shortDesc);
InsertMenuItem( popupMenu, currMenuItem, i);
}
HUnlock((Handle)gControls->stw->instType);
SetControlMaximum(gControls->stw->instType, gControls->cfg->numSetupTypes);
SetControlValue(gControls->stw->instType, gControls->opt->instChoice);
//Draw1Control(gControls->stw->instType);
// setup type desc TE init and default item desc display
HLockHi((Handle)gControls->stw->instDescBox);
viewRect = (*(gControls->stw->instDescBox))->contrlRect;
HUnlock((Handle)gControls->stw->instDescBox);
InsetRect(&viewRect, kTxtRectPad, kTxtRectPad);
gControls->stw->instDescTxt = (TEHandle) NewPtrClear(sizeof(TEPtr));
TextFont(systemFont);
TextFace(normal);
TextSize(12);
gControls->stw->instDescTxt = TENew( &viewRect, &viewRect);
HLockHi(gControls->cfg->st[gControls->opt->instChoice - 1].longDesc);
txtSize = strlen(*gControls->cfg->st[gControls->opt->instChoice - 1].longDesc);
TEInsert( *gControls->cfg->st[gControls->opt->instChoice - 1].longDesc, txtSize, gControls->stw->instDescTxt);
TESetAlignment( teFlushDefault, gControls->stw->instDescTxt);
HUnlock(gControls->cfg->st[gControls->opt->instChoice - 1].longDesc);
/*
volName = (unsigned char **)NewPtrClear(sizeof(unsigned char *));
GetAllVInfo(volName, &numVols);
gControls->stw->numVols = numVols;
HLockHi((Handle)gControls->stw->destLoc);
pvtDataHdl = (PopupPrivateData **) (*(gControls->stw->destLoc))->contrlData;
popupMenu = (MenuHandle) (**pvtDataHdl).mHandle;
for (i=0; i<numVols; i++)
{
InsertMenuItem( popupMenu, volName[i], i);
}
InsertMenuItem( popupMenu, "\p-", i);
GetIndString(selectFolder, rStringList, sSelectFolder);
InsertMenuItem( popupMenu, selectFolder, i+1);
HUnlock((Handle)gControls->stw->destLoc);
SetControlMaximum(gControls->stw->destLoc, numVols+2); // 2 extra for divider and "Select Folder..." item
SetControlValue(gControls->stw->destLoc, 1);
*/
GetIndString(selectFolder, rStringList, sSelectFolder);
SetControlTitle(gControls->stw->destLoc, selectFolder);
GetIndString(instLocTitle, rStringList, sInstLocTitle);
SetControlTitle(gControls->stw->destLocBox, instLocTitle);
// show controls
ShowControl(gControls->stw->instType);
ShowControl(gControls->stw->destLoc);
ShowNavButtons( back, next );
DrawDiskNFolder(gControls->opt->vRefNum, gControls->opt->folder);
SetPort(oldPort);
}
void
ShowSetupDescTxt(void)
{
Rect r;
if (gControls->stw->instDescTxt)
{
r = (**(gControls->stw->instDescTxt)).viewRect;
TEUpdate( &r, gControls->stw->instDescTxt);
}
DrawDiskNFolder(gControls->opt->vRefNum, gControls->opt->folder);
}
pascal void
OurNavEventFunction(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms,
NavCallBackUserData callBackUD)
{
WindowPtr windowPtr;
windowPtr = (WindowPtr) callBackParms->eventData.eventDataParms.event->message;
switch(callBackSelector)
{
case kNavCBEvent:
switch(callBackParms->eventData.eventDataParms.event->what)
{
case updateEvt:
if(((WindowPeek) windowPtr)->windowKind != kDialogWindowKind)
HandleUpdateEvt((EventRecord *) callBackParms->eventData.eventDataParms.event);
break;
}
break;
}
}
void
InSetupTypeContent(EventRecord* evt, WindowPtr wCurrPtr)
{
Point localPt;
Rect r;
ControlPartCode part;
short cntlVal;
long len;
ControlHandle currCntl;
/* NavChooseFolder vars */
NavReplyRecord reply;
NavDialogOptions dlgOpts;
NavEventUPP eventProc;
AEDesc resultDesc, initDesc;
FSSpec folderSpec, tmp;
OSErr err;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(wCurrPtr);
localPt = evt->where;
GlobalToLocal( &localPt);
HLockHi((Handle)gControls->stw->instType);
r = (**(gControls->stw->instType)).contrlRect;
HUnlock((Handle)gControls->stw->instType);
if (PtInRect(localPt, &r))
{
part = FindControl(localPt, gWPtr, &currCntl);
part = TrackControl(currCntl, localPt, (ControlActionUPP) -1);
gControls->opt->instChoice = GetControlValue(currCntl);
r = (**(gControls->stw->instDescTxt)).viewRect;
HLockHi(gControls->cfg->st[gControls->opt->instChoice-1].longDesc);
len = strlen(*gControls->cfg->st[gControls->opt->instChoice-1].longDesc);
TESetText( *gControls->cfg->st[gControls->opt->instChoice-1].longDesc, len, gControls->stw->instDescTxt);
HUnlock(gControls->cfg->st[gControls->opt->instChoice-1].longDesc);
EraseRect( &r );
TEUpdate( &r, gControls->stw->instDescTxt);
return;
}
HLockHi((Handle)gControls->stw->destLoc);
r = (**(gControls->stw->destLoc)).contrlRect;
HUnlock((Handle)gControls->stw->destLoc);
if (PtInRect(localPt, &r))
{
part = FindControl(localPt, gWPtr, &currCntl);
part = TrackControl(currCntl, localPt, (ControlActionUPP) -1);
cntlVal = GetControlValue(currCntl);
err = NavLoad();
if (err==noErr) {
err = NavGetDefaultDialogOptions(&dlgOpts);
GetIndString( dlgOpts.message, rStringList, sFolderDlgMsg );
eventProc = NewNavEventProc( (ProcPtr) OurNavEventFunction );
ERR_CHECK(FSMakeFSSpec(gControls->opt->vRefNum, gControls->opt->dirID, NULL, &tmp));
ERR_CHECK(AECreateDesc(typeFSS, (void*) &tmp, sizeof(FSSpec), &initDesc));
err = NavChooseFolder( &initDesc, &reply, &dlgOpts, eventProc, NULL, NULL );
AEDisposeDesc(&initDesc);
DisposeRoutineDescriptor(eventProc);
if((reply.validRecord) && (err == noErr))
{
if((err = AECoerceDesc(&(reply.selection),typeFSS,&resultDesc)) == noErr)
{
BlockMoveData(*resultDesc.dataHandle,&tmp,sizeof(FSSpec));
/* forces name to get filled */
FSMakeFSSpec(tmp.vRefNum, tmp.parID, tmp.name, &folderSpec);
/* NOTE:
** ----
** gControls->opt->parID and gControls->opt->folder refer to the
** same folder. The -dirID- is used by Install() when passing params to
** the SDINST_DLL through its prescribed interface that just takes the
** vRefNum and parID of the FSSpec that describes the folder.
** Whilst, the -folder- string is used by DrawDiskNFolder() in repainting.
*/
pstrcpy(gControls->opt->folder, folderSpec.name);
DrawDiskNFolder(folderSpec.vRefNum, folderSpec.name);
gControls->opt->vRefNum = tmp.vRefNum;
gControls->opt->dirID = tmp.parID;
}
AEDisposeDesc(&resultDesc);
NavDisposeReply(&reply);
}
//err = NavUnload();
//if (err!=noErr) SysBeep(10); // DEBUG
}
return;
}
HLockHi((Handle)gControls->backB);
r = (**(gControls->backB)).contrlRect;
HUnlock((Handle)gControls->backB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->backB, evt->where, NULL);
if (part)
{
ClearDiskSpaceMsgs();
KillControls(gWPtr);
ShowWelcomeWin();
return;
}
}
HLockHi((Handle)gControls->nextB);
r = (**(gControls->nextB)).contrlRect;
HUnlock((Handle)gControls->nextB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->nextB, evt->where, NULL);
if (part)
{
ClearDiskSpaceMsgs();
KillControls(gWPtr);
/* treat last setup type selection as custom */
if (gControls->opt->instChoice == gControls->cfg->numSetupTypes)
ShowComponentsWin();
else
ShowTerminalWin();
return;
}
}
SetPort(oldPort);
}
void
DrawDiskNFolder(short vRefNum, unsigned char *folder)
{
Str255 inFolderMsg, onDiskMsg, volName;
char *cstr;
Rect viewRect, dlb;
TEHandle pathInfo;
short bCmp;
OSErr err = noErr;
/* get vol and folder name */
if ((err = GetVol(volName, &vRefNum)) == noErr)
{
dlb = (*gControls->stw->destLocBox)->contrlRect;
SetRect(&viewRect, dlb.left+10, dlb.top+15, dlb.left+220, dlb.bottom-5);
/* format and draw vol and disk name strings */
TextFace(normal);
TextSize(9);
TextFont(applFont);
EraseRect(&viewRect);
pathInfo = TENew(&viewRect, &viewRect);
if ( (bCmp = pstrcmp(folder, volName)) == 0)
{
cstr = "\t\t\0"; TEInsert(cstr, strlen(cstr), pathInfo);
GetIndString( inFolderMsg, rStringList, sInFolder);
cstr = PascalToC(inFolderMsg);
TEInsert(cstr, strlen(cstr), pathInfo);
DisposePtr(cstr);
cstr = "\r\"\0"; TEInsert(cstr, strlen(cstr), pathInfo);
cstr = PascalToC(folder);
TEInsert(cstr, strlen(cstr), pathInfo);
DisposePtr(cstr);
cstr = "\"\r\0"; TEInsert(cstr, strlen(cstr), pathInfo);
}
cstr = "\t\t\0"; TEInsert(cstr, strlen(cstr), pathInfo);
GetIndString( onDiskMsg, rStringList, sOnDisk);
cstr = PascalToC(onDiskMsg);
TEInsert(cstr, strlen(cstr), pathInfo);
DisposePtr(cstr);
cstr = "\r\"\0"; TEInsert(cstr, strlen(cstr), pathInfo);
cstr = PascalToC(volName);
TEInsert(cstr, strlen(cstr), pathInfo);
DisposePtr(cstr);
cstr = "\"\0"; TEInsert(cstr, strlen(cstr), pathInfo);
TEUpdate(&viewRect, pathInfo);
TextFont(systemFont);
TextSize(12);
}
/* free mem blocks */
TEDispose(pathInfo);
DrawDiskSpaceMsgs(vRefNum);
}
void
DrawDiskSpaceMsgs(short vRefNum)
{
HVolumeParam pb;
OSErr err;
long freeSpace;
TEHandle diskSpaceMsgH;
Rect instDescBox, viewRect;
Handle instDescRectH;
Str255 msg;
Str15 kb;
char *cmsg, *ckb, *cfreeSpace, *cSpaceNeeded;
pb.ioCompletion = NULL;
pb.ioVolIndex = 0;
pb.ioNamePtr = NULL;
pb.ioVRefNum = vRefNum;
ERR_CHECK( PBHGetVInfoSync((HParmBlkPtr)&pb) );
freeSpace = pb.ioVFrBlk * pb.ioVAlBlkSiz; // in bytes
freeSpace /= 1024; // translate to kilobytes
instDescRectH = Get1Resource('RECT', rCompListBox);
HLockHi(instDescRectH);
instDescBox = (Rect) **((Rect**)instDescRectH);
SetRect( &viewRect, instDescBox.left, instDescBox.bottom + 2,
instDescBox.right, instDescBox.bottom + 12 );
HUnlock(instDescRectH);
DetachResource(instDescRectH);
DisposeHandle(instDescRectH);
TextFace(normal);
TextSize(9);
TextFont(applFont);
EraseRect(&viewRect);
diskSpaceMsgH = TENew(&viewRect, &viewRect);
/* Get the "Disk Space Available: " string */
GetIndString( msg, rStringList, sDiskSpcAvail );
cmsg = PascalToC(msg);
/* tack on the actual disk space in KB */
cfreeSpace = ltoa(freeSpace);
strcat( cmsg, cfreeSpace );
/* tack on the "kilobyte" string: generally "K" but is rsrc'd */
GetIndString( kb, rStringList, sKilobytes );
ckb = PascalToC(kb);
strcat( cmsg, ckb );
/* draw the disk space available string */
TEInsert( cmsg, strlen(cmsg), diskSpaceMsgH );
TEUpdate( &viewRect, diskSpaceMsgH );
/* recycle msg pointer and handle */
TEDispose(diskSpaceMsgH);
DisposePtr((char*)cmsg);
SetRect( &viewRect, instDescBox.right - 150, instDescBox.bottom + 2,
instDescBox.right, instDescBox.bottom + 12 );
diskSpaceMsgH = TENew( &viewRect, &viewRect );
/* Get the "Disk Space Needed: " string */
GetIndString( msg, rStringList, sDiskSpcNeeded );
cmsg = PascalToC(msg);
/* tack on space needed in KB */
cSpaceNeeded = DiskSpaceNeeded();
strcat( cmsg, cSpaceNeeded );
/* tack on the "kilobyte" string: generally "K" but is rsrc'd */
GetIndString( kb, rStringList, sKilobytes );
ckb = PascalToC(kb);
strcat( cmsg, ckb );
/* draw the disk space available string */
TEInsert( cmsg, strlen(cmsg), diskSpaceMsgH );
TEUpdate( &viewRect, diskSpaceMsgH );
DisposePtr((char*)ckb);
free(cSpaceNeeded); // malloc'd, not NewPtrClear'd
free(cfreeSpace); // malloc'd, not NewPtrClear'd
DisposePtr((char*)cmsg);
TEDispose(diskSpaceMsgH);
TextFont(systemFont);
TextSize(12);
}
char *
DiskSpaceNeeded(void)
{
char *cSpaceNeeded;
short i;
long spaceNeeded = 0;
/* loop through all components cause they may be scattered through
* the array for this particular setup type
*/
for (i=0; i<kMaxComponents; i++)
{
if (gControls->opt->compSelected[i] == kSelected)
{
spaceNeeded += gControls->cfg->comp[i].size;
}
}
cSpaceNeeded = ltoa(spaceNeeded);
return cSpaceNeeded;
}
void
ClearDiskSpaceMsgs(void)
{
Rect instDescBox, viewRect;
Handle instDescRectH;
instDescRectH = Get1Resource('RECT', rCompListBox);
HLockHi(instDescRectH);
instDescBox = (Rect) **((Rect**)instDescRectH);
SetRect( &viewRect, instDescBox.left, instDescBox.bottom + 2,
instDescBox.right, instDescBox.bottom + 12 );
HUnlock(instDescRectH);
DetachResource(instDescRectH);
DisposeHandle(instDescRectH);
EraseRect( &viewRect );
InvalRect( &viewRect );
}
/*
** ltoa -- long to ascii
**
** Converts a long to a C string. We allocate
** a string of the appropriate size and the caller
** should assume ownership of the returned pointer.
*/
char *
ltoa(long n)
{
char *s;
int i, j, sign, tmp;
/* check sign and convert to positive to stringify numbers */
if ( (sign = n) < 0)
n = -n;
i = 0;
s = (char*) malloc(sizeof(char));
/* grow string as needed to add numbers from powers of 10 down till none left */
do
{
s = (char*) realloc(s, (i+1)*sizeof(char));
s[i++] = n % 10 + '0'; /* '0' or 30 is where ASCII numbers start from */
s[i] = '\0';
}
while( (n /= 10) > 0);
/* tack on minus sign if we found earlier that this was negative */
if (sign < 0)
{
s = (char*) realloc(s, (i+1)*sizeof(char));
s[i++] = '-';
}
s[i] = '\0';
/* pop numbers (and sign) off of string to push back into right direction */
for (i = 0, j = strlen(s) - 1; i < j; i++, j--)
{
tmp = s[i];
s[i] = s[j];
s[j] = tmp;
}
return s;
}
short
pstrcmp(unsigned char* s1, unsigned char* s2)
{
long len;
register short i;
if ( *s1 != *s2) /* different lengths */
return false;
len = *s1;
for (i=0; i<=len; i++)
{
s1++;
s2++;
if (*s1 != *s2)
return false;
}
return true;
}
unsigned char*
pstrcpy(unsigned char* dest, unsigned char* src)
{
long len;
register short i;
unsigned char* origdest;
origdest = dest;
len = *src;
for (i=0; i<=len; i++)
{
*dest = *src;
dest++;
src++;
}
return origdest;
}
void
GetAllVInfo( unsigned char **volName, short *count)
{
QHdrPtr vcbQ;
VCB * currVCB;
register short i;
vcbQ = GetVCBQHdr();
currVCB = (VCB *)vcbQ->qHead;
i = 0;
while(1)
{
volName[i] = currVCB->vcbVN;
/* *vRefNum[i] = currVCB->vcbVRefNum; */
i++; // since i gets incremented pre-break, count is accurate
if (currVCB == (VCB *) vcbQ->qTail)
break;
currVCB = (VCB *)currVCB->qLink;
}
*count = i;
}
void
EnableSetupTypeWin(void)
{
EnableNavButtons();
// TO DO
}
void
DisableSetupTypeWin(void)
{
DisableNavButtons();
// TO DO
}

Просмотреть файл

@ -0,0 +1,180 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
/*-----------------------------------------------------------*
* Terminal Window
*-----------------------------------------------------------*/
void
ShowTerminalWin(void)
{
Str255 next, back;
Handle rectH;
Rect viewRect;
short reserr;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(gWPtr);
gCurrWin = TERMINAL;
/* gControls->tw = (TermWin*) NewPtrClear(sizeof(TermWin)); */
GetIndString(next, rStringList, sInstallBtn);
GetIndString(back, rStringList, sBackBtn);
// malloc and get control
rectH = Get1Resource('RECT', rStartMsgBox);
reserr = ResError();
if (reserr == noErr)
viewRect = (Rect) **((Rect **)rectH);
else
{
ErrorHandler();
return;
}
gControls->tw->startMsgBox = viewRect;
gControls->tw->startMsg = TENew(&viewRect, &viewRect);
// populate control
HLockHi(gControls->cfg->startMsg);
TESetText(*gControls->cfg->startMsg, strlen(*gControls->cfg->startMsg),
gControls->tw->startMsg);
HUnlock(gControls->cfg->startMsg);
// show controls
TEUpdate(&viewRect, gControls->tw->startMsg);
ShowNavButtons( back, next);
SetPort(oldPort);
}
void
UpdateTerminalWin(void)
{
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(gWPtr);
TEUpdate(&gControls->tw->startMsgBox, gControls->tw->startMsg);
SetPort(oldPort);
}
void
InTerminalContent(EventRecord* evt, WindowPtr wCurrPtr)
{
Point localPt;
Rect r;
ControlPartCode part;
ThreadID tid;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(wCurrPtr);
localPt = evt->where;
GlobalToLocal( &localPt);
HLockHi((Handle)gControls->backB);
r = (**(gControls->backB)).contrlRect;
HUnlock((Handle)gControls->backB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->backB, evt->where, NULL);
if (part)
{
KillControls(gWPtr);
if (&gControls->tw->startMsgBox)
{
EraseRect(&gControls->tw->startMsgBox);
InvalRect(&gControls->tw->startMsgBox);
}
else
{
ErrorHandler();
return;
}
/* treat last setup type selection as custom */
if (gControls->opt->instChoice == gControls->cfg->numSetupTypes)
ShowComponentsWin();
else
ShowSetupTypeWin();
return;
}
}
HLockHi((Handle)gControls->nextB);
r = (**(gControls->nextB)).contrlRect;
HUnlock((Handle)gControls->nextB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->nextB, evt->where, NULL);
if (part)
{
SpawnSDThread(Install, &tid);
return;
}
}
SetPort(oldPort);
}
Boolean
SpawnSDThread(ThreadEntryProcPtr threadProc, ThreadID *tid)
{
OSErr err;
err = NewThread(kCooperativeThread, (ThreadEntryProcPtr)threadProc, (void*) nil,
20000, kCreateIfNeeded, (void**)nil, tid);
if (err == noErr)
YieldToThread(*tid); /* force ctx switch */
else
{
return false;
}
return true;
}
void
EnableTerminalWin(void)
{
EnableNavButtons();
// TO DO
}
void
DisableTerminalWin(void)
{
DisableNavButtons();
// TO DO
}

Просмотреть файл

@ -0,0 +1,212 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
/*-----------------------------------------------------------*
* Welcome Window
*-----------------------------------------------------------*/
void
ShowWelcomeWin(void)
{
Str255 next;
Str255 back;
Rect sbRect;
int sbWidth;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(gWPtr);
gCurrWin = WELCOME;
/* gControls->ww = (WelcWin *) NewPtrClear(sizeof(WelcWin)); */
GetIndString(next, rStringList, sNextBtn);
GetIndString(back, rStringList, sBackBtn);
gControls->ww->scrollBar = GetNewControl( rLicScrollBar, gWPtr);
gControls->ww->welcBox = GetNewControl( rLicBox, gWPtr);
if(gControls->ww->scrollBar && gControls->ww->welcBox)
{
HLockHi( (Handle) gControls->ww->scrollBar);
sbRect = (*(gControls->ww->welcBox))->contrlRect;
sbWidth = (*(gControls->ww->scrollBar))->contrlRect.right -
(*(gControls->ww->scrollBar))->contrlRect.left;
(*(gControls->ww->scrollBar))->contrlRect.right = sbRect.right + kScrollBarPad;
(*(gControls->ww->scrollBar))->contrlRect.left = sbRect.right + kScrollBarPad -
sbWidth;
(*(gControls->ww->scrollBar))->contrlRect.top = sbRect.top - kScrollBarPad;
(*(gControls->ww->scrollBar))->contrlRect.bottom = sbRect.bottom + kScrollBarPad;
HUnlock( (Handle) gControls->ww->scrollBar);
}
InitWelcTxt();
ShowNavButtons( back, next);
ShowControl( gControls->ww->scrollBar);
ShowControl( gControls->ww->welcBox);
ShowTxt();
InitScrollBar( gControls->ww->scrollBar);
}
void
InitWelcTxt(void)
{
Rect viewRect, destRect;
long welcStrLen;
int i;
char * newPara;
/* TE specific init */
HLockHi( (Handle) gControls->ww->welcBox);
viewRect = (*(gControls->ww->welcBox))->contrlRect;
HUnlock( (Handle) gControls->ww->welcBox);
destRect.left = viewRect.left;
viewRect.right = (*(gControls->ww->scrollBar))->contrlRect.left;
destRect.right = viewRect.right;
destRect.top = viewRect.top;
destRect.bottom = viewRect.bottom * kNumWelcScrns; /* XXX: hack */
gControls->ww->welcTxt = (TEHandle) NewPtrClear(sizeof(TEPtr));
TextFont(applFont);
TextFace(normal);
TextSize(12);
newPara = "\r\r";
gControls->ww->welcTxt = TENew( &destRect, &viewRect);
for (i=0; i<kNumWelcMsgs; i++)
{
HLockHi(gControls->cfg->welcMsg[i]);
welcStrLen = strlen( *gControls->cfg->welcMsg[i]);
TEInsert( *gControls->cfg->welcMsg[i], welcStrLen, gControls->ww->welcTxt);
HUnlock(gControls->cfg->welcMsg[i]);
TEInsert( newPara, strlen(newPara), gControls->ww->welcTxt);
}
TextFont(systemFont);
TextSize(12);
TESetAlignment(teFlushDefault, gControls->ww->welcTxt);
}
void
InWelcomeContent(EventRecord* evt, WindowPtr wCurrPtr)
{
Point localPt;
Rect r;
short code, value;
ControlPartCode part;
ControlHandle scrollBar;
ControlActionUPP scrollActionFunctionUPP;
GrafPtr oldPort;
GetPort(&oldPort);
SetPort(wCurrPtr);
localPt = evt->where;
GlobalToLocal( &localPt);
code = FindControl(localPt, wCurrPtr, &scrollBar);
switch (code)
{
case kControlUpButtonPart:
case kControlDownButtonPart:
case kControlPageUpPart:
case kControlPageDownPart:
scrollActionFunctionUPP = NewControlActionProc((ProcPtr) DoScrollProc);
value = TrackControl(scrollBar, localPt, scrollActionFunctionUPP);
return;
break;
case kControlIndicatorPart:
value = GetControlValue(scrollBar);
code = TrackControl(scrollBar, localPt, nil);
if (code)
{
value -= GetControlValue(scrollBar);
if (value)
{
TEScroll(0, value * kScrollAmount, gControls->ww->welcTxt);
}
}
return;
break;
}
HLockHi((Handle)gControls->backB);
r = (**(gControls->backB)).contrlRect;
HUnlock((Handle)gControls->backB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->backB, evt->where, NULL);
if (part)
{
KillControls(gWPtr);
ShowLicenseWin();
return;
}
}
HLockHi((Handle)gControls->nextB);
r = (**(gControls->nextB)).contrlRect;
HUnlock((Handle)gControls->nextB);
if (PtInRect( localPt, &r))
{
part = TrackControl(gControls->nextB, evt->where, NULL);
if (part)
{
KillControls(gWPtr);
ShowSetupTypeWin();
return;
}
}
SetPort(oldPort);
}
void
EnableWelcomeWin(void)
{
EnableNavButtons();
if(gControls->ww->scrollBar)
HiliteControl(gControls->ww->scrollBar, kEnableControl);
}
void
DisableWelcomeWin(void)
{
DisableNavButtons();
if(gControls->ww->scrollBar)
HiliteControl(gControls->ww->scrollBar, kDisableControl);
}

Просмотреть файл

@ -0,0 +1,171 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _MIW_H_
#include "MacInstallWizard.h"
#endif
#define XP_MAC 1
#include "xpistub.h"
/*-----------------------------------------------------------*
* XPInstall Glue
*-----------------------------------------------------------*/
/* XPI Stub Entry Points */
typedef nsresult (*XPI_InitProc)(const FSSpec& targetDir,
pfnXPIStart startCB,
pfnXPIProgress progressCB,
pfnXPIFinal finalCB);
typedef nsresult (*XPI_InstallProc)(const FSSpec& file, const char* args,long flags);
typedef nsresult (*XPI_ExitProc)();
/* XPI Stub Load/Unload */
OSErr LoadXPIStub(XPI_InitProc* pfnInit,
XPI_InstallProc* pfnInstall,
XPI_ExitProc* pfnExit,
CFragConnectionID* connID,
FSSpec& aTargetDir);
Boolean UnloadXPIStub(CFragConnectionID* connID);
/* Progress Bar Callbacks */
void xpicbStart(const char *URL, const char* UIName);
void xpicbProgress(const char* msg, PRInt32 val, PRInt32 max);
void xpicbFinal(const char *URL, PRInt32 finalStatus);
#define XPCOM_ERR_CHECK(_call) \
rv = _call; \
if (NS_FAILED(rv)) \
{ \
ErrorHandler(); \
return rv; \
}
#define XPISTUB_DLL "\pxpistubDebug.shlb";
void
xpicbStart(const char *URL, const char* UIName)
{
// TO DO
// SysBeep(10);
return;
}
void
xpicbProgress(const char* msg, PRInt32 val, PRInt32 max)
{
// TO DO
// SysBeep(10);
return;
}
void
xpicbFinal(const char *URL, PRInt32 finalStatus)
{
// TO DO
// SysBeep(10);
return;
}
OSErr
RunXPI(FSSpec& aXPI, FSSpec& aTargetDir)
{
nsresult rv;
OSErr err = noErr;
long flags = 0xFFFF;
XPI_InitProc xpi_initProc;
XPI_InstallProc xpi_installProc;
XPI_ExitProc xpi_exitProc;
CFragConnectionID connID;
ERR_CHECK_RET(LoadXPIStub(&xpi_initProc, &xpi_installProc, &xpi_exitProc, &connID, aTargetDir), err);
XPCOM_ERR_CHECK(xpi_initProc( aTargetDir, xpicbStart, xpicbProgress, xpicbFinal ));
XPCOM_ERR_CHECK(xpi_installProc( aXPI, "", flags ));
xpi_exitProc();
UnloadXPIStub(&connID);
return err;
}
/*-------------------------------------------------------------------
* XPI Stub Load/Unload
*-------------------------------------------------------------------*/
OSErr
LoadXPIStub(XPI_InitProc* pfnInit, XPI_InstallProc* pfnInstall, XPI_ExitProc* pfnExit,
CFragConnectionID* connID, FSSpec& aTargetDir)
{
OSErr err;
FSSpec fslib;
Str63 fragName = XPISTUB_DLL;
Ptr mainAddr, symAddr;
Str255 errName;
long currDirID;
short currVRefNum;
CFragSymbolClass symClass;
err = GetCWD(&currDirID, &currVRefNum);
if (err!=noErr)
return false;
// TO DO use aTargetDir to load XPISTUB_DLL
err = FSMakeFSSpec(currVRefNum, currDirID, fragName, &fslib);
if (err!=noErr)
return err;
err = GetDiskFragment(&fslib, 0, kCFragGoesToEOF, nil, kPrivateCFragCopy/*kReferenceCFrag*/, connID, &mainAddr, errName);
if (err != noErr)
return err;
if ( *connID != NULL)
{
ERR_CHECK_RET( FindSymbol(*connID, "\pXPI_Init", &symAddr, &symClass), err );
*pfnInit = (XPI_InitProc) symAddr;
ERR_CHECK_RET( FindSymbol(*connID, "\pXPI_Install", &symAddr, &symClass), err);
*pfnInstall = (XPI_InstallProc) symAddr;
ERR_CHECK_RET( FindSymbol(*connID, "\pXPI_Exit", &symAddr, &symClass), err);
*pfnExit = (XPI_ExitProc) symAddr;
}
return err;
}
Boolean
UnloadXPIStub(CFragConnectionID* connID)
{
if (*connID != NULL)
{
CloseConnection(connID);
*connID = NULL;
}
else
return false;
return true;
}

Просмотреть файл

@ -0,0 +1,136 @@
#ifndef _sdinst_h
#define _sdinst_h
#include <ConditionalMacros.h>
#include <MacTypes.h>
#include <QuickDraw.h>
#include <MixedMode.h>
#include <Events.h>
#if PRAGMA_ONCE
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if PRAGMA_IMPORT
#pragma import on
#endif
#if PRAGMA_STRUCT_ALIGN
#pragma options align=mac68k
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(push, 2)
#elif PRAGMA_STRUCT_PACK
#pragma pack(2)
#endif
#define DEFAULT_TIMEOUT 60
#define DEFAULT_RETRIES 5
typedef enum
{
idle = 0,
inProgress,
userCanceled,
failure,
success
} DLStatus;
#ifdef WANT_WINTYPES
typedef unsigned long DWORD;
typedef int HINSTANCE;
#define CONST const
typedef char CHAR;
typedef CONST CHAR* LPCSTR;
typedef LPCSTR LPCTSTR;
typedef long LONG;
typedef LONG LPARAM;
typedef void* LPVOID;
typedef long* LPLONG;
#define _cdecl
typedef long HRESULT;
typedef int HWND;
#endif
typedef struct SDI_tag
{
DWORD dwStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
DWORD dwFlags; // see flag definitions below
DWORD dwTimeOut; // timeout for network operations
DWORD dwRetries; // how many times to retry downloading from a URL
#if macintosh
FSSpec fsIDIFile; // The IDI file
short dlDirVRefNum; // where to download components
long dlDirID; // ditto
#else
LPCTSTR lpFileName; // the name of the IDI file
LPCTSTR lpDownloadDir; // where to download components
#endif
LPCTSTR lpTemplate; // not implemented
#if 0 // later ###
DLGPROC lpDlgHookProc; // not implemented
#endif
LPARAM lUserData; // not implemented
DWORD dwReserved;
} SDISTRUCT, *LPSDISTRUCT;
// Flags
#define SDI_STARTOVER 0x00000001
/* Force to start over, even if an interrupted session is detected.
*/
#define SDI_USETEMPLATE 0x00000002
/* If this flag is set, hInstance identifies a module that contains
* a dialog box template named by the lpTemplateName member.
* If silent mode is specified in the IDI file, the flag is ignored.
*/
#define SDI_USEHOOK 0x00000004
/* The hook procedure receives notification messages sent from the dialog.
* The hook procedure also receives messages for any additional controls
* defined by specifying a child dialog template. The hook procedure does
* not receive messages intended for the standard controls of the default
* dialog box.
*/
#define SDI_DEFAULT_RETRIES 0x00000008
#define SDI_DEFAULT_TIMEOUT 0x00000010
HRESULT _cdecl SDI_NetInstall (LPSDISTRUCT);
HRESULT _cdecl SDI_QueryLog ( LPCTSTR,/* item name to query */
LPVOID, /* address of buffer for returned info */
LPLONG);/* address of buffer size */
#if MACINTOSH
Boolean SDI_HandleEvent(const EventRecord* event);
#endif
#if PRAGMA_STRUCT_ALIGN
#pragma options align=reset
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(pop)
#elif PRAGMA_STRUCT_PACK
#pragma pack()
#endif
#ifdef PRAGMA_IMPORT_OFF
#pragma import off
#elif PRAGMA_IMPORT
#pragma import reset
#endif
#ifdef __cplusplus
}
#endif
#endif /* _sdinst_h */