home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / Newton Platform Info / Newton 2.0 Sample Code / Modem Setup / Modem Setup-2 / Installer < prev    next >
Encoding:
Text File  |  1995-11-22  |  3.4 KB  |  115 lines  |  [TEXT/NTP1]

  1. // Copyright © 1995 by Apple Computer, Inc.  All rights reserved.
  2.  
  3. DefConst('kRemoveThisPackageFunc, func(objRef) RemovePackage(ObjectPkgRef(objRef)));
  4.  
  5. partData := { fInstaller:
  6. {
  7.     fModemSetup:
  8.         {    modemName:        kModemName,
  9.             version:        kVersion,
  10.             organization:    kOrganization,
  11.             
  12.             modemPrefs: 
  13.             {
  14.                 idModem:                kIdModem,
  15.                 useHardwareCD:            kuseHardwareCD,
  16.                 useConfigString:        kuseConfigString,
  17.                 useDialOptions:            kuseDialOptions,
  18.                 hangUpAtDisconnect:        khangUpAtDisconnect,
  19.             },
  20.             
  21.             modemProfile: 
  22.             {
  23.                 supportsEC:                ksupportsEC,
  24.                 supportsLCS:            ksupportsLCS,
  25.                 directConnectOnly:        kdirectConnectOnly,
  26.                 connectSpeeds:            kconnectSpeeds,
  27.                 configSpeed:            kconfigSpeed,
  28.                 commandTimeout:            kcommandTimeout,
  29.                 maxCharsPerLine:        kmaxCharsPerLine,
  30.                 interCmdDelay:            kinterCmdDelay,
  31.                 modemIdStr:                kModemIdStr,
  32.                 configStrNoEC:            kconfigStrNoEC,
  33.                 configStrECOnly:        kconfigStrECOnly,
  34.                 configStrECAndFallback:    kconfigStrECAndFallback,
  35.                 configStrDirectConnect:    kconfigStrDirectConnect,
  36.             },
  37.             
  38.             faxProfile:
  39.             {
  40.                 serviceClass:            kServiceClass,
  41.                 transmitDataMod:        kTransmitDataMod,
  42.                 receiveDataMod:            kReceiveDataMod,
  43.                 transmitHDLCDataMod:    kTransmitHDLCDataMod,
  44.                 receiveHDLCDataMod:        kReceiveHDLCDataMod,
  45.             },
  46.         },
  47.     
  48.     
  49.     MInstall:
  50.         func()
  51.         begin
  52.             // This function is called from the package's InstallScript and executes from pseudo-ROM.
  53.             // We need a RAM-based frame to hold temporary variables during installation.
  54.             
  55.             local RamBasedSelf :=
  56.                 {    _proto:            self,
  57.                     fEntry:            GetModemSetup(kModemName),
  58.                  };
  59.             
  60.             if RamBasedSelf.fEntry <> nil then
  61.                  begin
  62.                      // if one is installed, check the setup version number
  63.                     local versionInstalled := RamBasedSelf.fEntry.version;
  64.                     local message;
  65.                     
  66.                     if kVersion <> versionInstalled then 
  67.                         if kVersion > versionInstalled then
  68.                             message := LocObj("You are about to install a NEWER version of the \"" & kModemName & "\" modem setup.  Continue?", 'fConfirmNewer);
  69.                         else
  70.                             message := LocObj("You are about to install an OLDER version of the \"" & kModemName & "\" modem setup.  Continue?", 'fConfirmOlder);
  71.                     else
  72.                         message := LocObj("The \"" & kModemName & "\" modem setup is already installed.  Reinstall?", 'fConfirmSame);
  73.                     
  74.                     GetRoot():Confirm(kAppName, message, RamBasedSelf, 'MInstallConfirmScript);
  75.                 end;
  76.             
  77.             else    // there is no modem setup currently installed for this modem, so add one
  78.                  RamBasedSelf:MInstallConfirmScript(true);
  79.         end,
  80.     
  81.     
  82.     MInstallConfirmScript:
  83.         func(confirmed)            // self is the RamBasedSelf frame
  84.         begin
  85.             if confirmed then
  86.                 begin
  87.                     RemoveModemSetup(kModemName);        // remove the old one
  88.                     AddModemSetup(Clone(fModemSetup));    // add the new one
  89.                 end;
  90.             
  91.             AddDeferredCall(EnsureInternal(kRemoveThisPackageFunc), [kModemName]);
  92.         end,
  93. }, };
  94.  
  95.  
  96. SetPartFrameSlot(    'DoNotInstall,
  97.                     func()
  98.                     begin
  99.                         if not GlobalFnExists('AddModemSetup)
  100.                         or not GlobalFnExists('RemoveModemSetup)
  101.                         or not GlobalFnExists('GetModemSetup) then
  102.                             begin
  103.                                 GetRoot():Notify(kNotifyAlert, kAppName, LocObj("The \"" & kModemName & "\" modem setup is not compatible with this unit.", 'fNotifyIncompatible));
  104.                                 return true;
  105.                             end;
  106.                         
  107.                         nil;
  108.                     end    );
  109.  
  110. InstallScript    :=    func(partFrame, removeFrame)
  111.                     AddDeferredCall(    func(base) base:MInstall(),
  112.                                         [partFrame.partData.fInstaller]    );
  113.  
  114. RemoveScript    :=    nil;
  115.