|
From: creecode <icr...@us...> - 2006-03-03 19:40:47
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/rootUpdates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15716 Modified Files: update Log Message: minor script formatting tweaks if the value of adrCallback is of type string, coerce to address, allows for partial addresses Index: update =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/rootUpdates/update,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** update 19 Feb 2006 22:51:15 -0000 1.5 --- update 3 Mar 2006 19:40:26 -0000 1.6 *************** *** 1,3 **** ! FrontierVcsFile:1:scpt:system.verbs.builtins.rootUpdates.update ! on update (adrInRoot = table.getcursoraddress (), flQuietMode=false, adrCtNewParts=nil) { ÇChanges Ç2/19/06; 1:49:03 PM by TAC Çwhen initializing a server use Frontier.data.initialLastUpdateTime to set lastupdate Çminor script formatting tweaks Çmake sure path to new part exists before trying to assign it, accommodate using a cvs repository as a backend Ç2/16/06; 6:27:30 PM by TAC Çwhen getting an update for the host database (@root) send paramaters just like when updating a guest database, except dbName is any empty string Ç12/23/05; 9:45:17 PM by TAC Çupdated root update code Ç6/13/05; 12:53:52 PM by TAC Çdisabled trial version and serial number checks Ç1/12/04; 12:48:36 AM by JES ÇChanged default updates server from madrid.userland.com to updates.userland.com. Ç2002 Ç8/28/02; 10:48:23 PM by JES ÇAdded support for two new callbacks: Çuser.rootUpdates.callbacks.beforeInstallPart -- scripts in this table are called with two parameters: the address of the part, and the change note. If any script returns false, then the part is not installed. No error is generated -- it's up to the callback script to provide feedback to the user. Çuser.rootUpdates.callbacks.afterInstallPart -- scripts in this table are called with two parameters: the address of the part, and the change note. The return value is ignored. Ç4/16/02; 4:34:53 PM by JES ÇBug fix: Store the new part count in adrCtNewParts^ even if no new parts were loaded. Ç1/21/02; 2:25:42 PM by JES ÇUse a string comparison to determine whether we're getting updates from radioupdates.userland.com, instead of a call to tcp.equalNames, since tcp.equalNames fails for some proxy server users. Ç1/7/02; 9:09:40 PM by PBS ÇIf getting Radio updates from radioupdates.userland.com, send your usernum as an additional parameter. Ç8/6/01; 2:22:37 PM by PBS ÇWhen updating Manila or mainResponder, send the serial number. Ç01/21/01; 6:03:11 PM by JES ÇAdded optional parameter, adrCtNewParts. If not nil, the number of updated parts is assigned to adrCtNewParts^. Ç08/20/00; 11:49:35 AM by PBS ÇIf the server returns a last update time, use that instead of clock.now (). This fixes problems with people missing updates due to having clocks out-of-synch with the server. This way, the server's time is always used. Ç06/17/00; 11:16:23 PM by PBS ÇUse new root updates timeout pref. Ç11/16/99; 1:43:53 AM AM by AR ÇMake sure backup folder exists before backing up GDBs. ÇAdded flQuietMode parameter, defaulting to false. If it's true, we suppress all server-unfriendly interaction like putting up dialogs or opening the outline of new parts, regardless of the settings in user.rootUpdates. Ç10/7/99; 6:43:29 PM by DW ÇNew pref, user.rootupdates.prefs.flShowUpdatesToUser, defaults true, initialized in rootUpdates.init. ÇNew pref, user.rootupdates.prefs.adrOutlineForUser, defaults to @user.rootUpdates.updateOutline. Çif flShowUpdatesToUser is true, we create the outline if it doesn't exist and add a top-level headline with the date and time and the name of the database being updated. Each subordinate entry is the address of an object that's been updated. Underneath the address is the explanation of the change, if available. Çbundle // trial Çif defined (userland.trialVersionCheck) Çif userland.trialVersionCheck () ÇscriptError ("Can't update the database because the trial period has expired.") rootUpdates.init (); local (adrroot = table.getrootaddress (adrInRoot)); local (alist = string.parseaddress (adrroot)); local (f = window.getFile (alist [1])); local (fname = file.filefrompath (f)); if not string.lower (fname) endswith ".root" { scripterror ("Can't update the file because its name doesn't end with .root.")}; local (channelname = string.mid (fname, 1, sizeof (fname) - 5)); local (adrtable = @user.rootUpdates.servers.[channelname]); if not defined (adrtable^) { new (tabletype, adrtable); adrtable^.server = "rootUpdates.frontierOpenSource.editHere.com"; adrtable^.port = 8081; adrtable^.method = "mainResponder.subscriptions.update"; adrtable^.dbname = fname; adrtable^.lastupdate = Frontier.data.initialLastUpdateTime; //indicate that it's never been updated adrtable^.autobackup = true; //if true the backup will be of docServer.root, not Frontier.root adrtable^.dialogs = true; //set this false if you're updating automatically thru the scheduler adrtable^.openLog = true; //show the log file of changes adrtable^.URL = ""}; Çelse Çif string.lower (adrtable^.server) == "madrid.userland.com" Çadrtable^.server = "updates.userland.com" Çbundle //the responder name on the server changed Çif adrtable^.method == "mainResponder.subscriptions.update" Çadrtable^.method = "nirvanaServer.subscriptions.update" on getUpdate (serverName, adrInRoot = nil) { //an enhanced version of rootupdates.getUpdate Ç10/18/98; 11:33:30 AM by DW ÇMade it guest database-aware. ÇIf adrInRoot is specified, it's assumed to point into the guest db that's getting updated ÇAdded a field to the prefs record, dbname, which names the guest database that's being shared ÇIt's an index into user.mainresponder.databases on the server. ÇThe handler for this is at mainresponder.rpchandlers.subscriptions.update. local (frontierVersion = Frontier.version ()); local (platform = string.mid (sys.os (), 1, 3)); local (ctnewparts = 0); local (flDialogs = true); local (flLogOutlineOpened = false, flNewLogOutline = false); local (adrPrefs = @user.rootUpdates.servers.[serverName]); local (flGuestDb = false, addressprefixstring); //10/18/98 DW bundle { //gather info about guest database if adrInRoot != nil and string.lower (channelname) != "frontier" { addressprefixstring = string (table.getRootAddress (adrInRoot)); flGuestDb = true}}; if defined (adrPrefs^.dialogs) and not adrPrefs^.dialogs { flDialogs = false}; if flQuietMode { //AR 11/15/1999 flDialogs = false}; Çif not defined (user.prefs.serialNumber) // 6/13/05; 12:53:52 PM by TAC - disabled Çuser.prefs.serialNumber = "" try { //try to get the root update from the server if flDialogs { local (prompt = "Connect with " + adrPrefs^.server + " to get latest update"); if flGuestDb { prompt = prompt + " of " + adrPrefs^.dbname}; prompt = prompt + "?"; if not dialog.confirm (prompt) { return (false)}}; window.about (); local (sn = 0); Çif adrPrefs == @user.rootUpdates.servers.Frontier ÇOnly send Frontier serial number when getting Frontier.root udpate. ÇThu, Mar 18, 1999 at 3:21:10 PM by PBS Çsn = user.prefs.serialNumber local (rpcPath = user.betty.prefs.rpcClientDefaultPath); Çbundle // 6/13/05; 12:53:52 PM by TAC - disabled, no serial number check needed for open source release Çcase true //PBS 08/06/01: send serial number for Frontier, Manila, and mainResponder ÇadrPrefs == @user.rootUpdates.servers.Radio ÇadrPrefs == @user.rootUpdates.servers.radioCommunityServer ÇadrPrefs == @user.rootUpdates.servers.serverMonitor ÇadrPrefs == @user.rootUpdates.servers.Prefs ÇadrPrefs == @user.rootUpdates.servers.Frontier ÇadrPrefs == @user.rootUpdates.servers.Manila ÇadrPrefs == @user.rootUpdates.servers.mainResponder Çsn = user.prefs.serialNumber Çif string.lower (adrPrefs^.server) endswith ".userland.com" Çtry //add path args to rpcPath Çlocal (args); new (tableType, @args) Çargs.org (xn--args-zoa.org) = user.prefs.organization Çargs.name = user.prefs.name Çargs.email = user.prefs.mailAddress Çargs.sn = user.prefs.serialNumber Çif defined (config.mainResponder.domains) Çargs.domains = sizeOf (config.mainResponder.domains) Çelse Çargs.domains = 0 Çif defined (config.manila.sites) Çargs.sites = sizeOf (config.manila.sites) Çelse Çargs.sites = 0 Çif defined (radioCommunityServerData.users) Çargs.rcsUsers = sizeOf (radioCommunityServerData.users) Çelse Çargs.rcsUsers = 0 ÇrpcPath = rpcPath + "?" + webserver.encodeArgs (@args) Çelse Çif defined (adrPrefs^.serialNum) Çsn = adrPrefs^.serialNum Çelse Çsn = 0 local (paramlist = {tcp.addressDecode (tcp.myAddress ()), adrPrefs^.lastupdate, platform, sn, user.prefs.name, user.prefs.mailAddress, frontierVersion}); bundle { //PBS 01/07/02: send usernum to radioupdates.userland.com Çif tcp.equalNames (adrPrefs^.server, "radioupdates.userland.com") Çparamlist = paramlist + user.radio.prefs.usernum if string.lower (adrPrefs^.server) == "radioupdates.userland.com" { paramlist = paramlist + user.radio.prefs.usernum}}; if flGuestDb { paramlist = {adrPrefs^.dbname} + paramlist} else { paramlist = {""} + paramlist}; // empty string indicates get host database (@root) update local (newpartstable); local (i); msg ("Connecting to " + adrPrefs^.server + " to get " + serverName + " update..."); newpartstable = betty.rpc.client (adrPrefs^.server, adrPrefs^.port, adrPrefs^.method, @paramlist, false, rpcPath:rpcPath, ticksToTimeOut:user.rootUpdates.prefs.timeout); Çbundle //original call Çnewpartstable = betty.rpc.client (adrPrefs^.server, adrPrefs^.port, adrPrefs^.method, @paramlist, false, ticksToTimeOut:user.rootUpdates.prefs.timeout) if not defined (newPartsTable.parts) { if newPartsTable beginsWith "There are no new or changed parts available." or newPartsTable beginsWith "Your root is already updated" { msg (""); if flDialogs { dialog.notify (newPartsTable)} else { msg (newPartsTable)}; if adrCtNewParts != nil { //4/16/02; 4:33:24 PM by JES: make the new part count available to the caller, even if there are no new parts adrCtNewParts^ = ctNewParts}; return (true)}}; if adrPrefs^.autobackup { //10/18/98; 11:36:58 AM by DW if flGuestDb { backups.init (); //make sure user.backups.folder is set local (alist = string.parseaddress (adrInRoot)); local (source = alist [1]); filemenu.save (source); local (dest); bundle { //set dest to point at the destination file dest = file.filefrompath (source); if string.lower (dest) endswith ".root" { dest = string.delete (dest, sizeof (dest) - 4, 5); //pop off .root dest = dest + "." + user.backups.nextBackup + ".root"} else { dest = dest + "." + user.backups.nextBackup}; dest = user.backups.folder + dest; user.backups.nextBackup++}; file.sureFilePath (dest); //AR 11/15/1999 file.copy (source, dest); filemenu.save (); msg (dest + " is " + string.megabytestring (file.size (dest)))} else { backups.backuproot ()}}; for i = 1 to sizeof (newpartstable.parts) { local (adrnewpart = @newpartstable.parts [i]); local (bytes = binary (base64.decode (adrnewpart^))); local (flpartinstalled = true); setBinaryType (@bytes, tableType); unpack (@bytes, adrnewpart); on installPart (adrPart) { if defined (user.rootUpdates.protected) { //Don't import into these places. local (j); for j = 1 to sizeOf (user.rootUpdates.protected) { local (oneItem = address (user.rootUpdates.protected [j])); if table.tableContains (oneItem, adrPart^.adr) { //Don't install. flpartinstalled = false; return (true)}}}; if defined (adrPart^.platform) { if string.lower (adrPart^.platform) != "both" { // Only install parts for this platform. if string.lower (adrPart^.platform) != string.lower (platform) { return (true)}}}; try { if flGuestDb { //we got a relative address, convert it to a real address adrPart^.adr = address (addressprefixstring + "." + adrPart^.adr)}; msg ("Importing " + adrPart^.adr + "."); local (adrcallback, ixcallback, ctcallbacks, flInstallPart = true); bundle { //call beforeInstallPart callbacks ctcallbacks = sizeOf (user.rootUpdates.callbacks.beforeInstallPart); for ixcallback = 1 to ctcallbacks { local (adrcallback = @user.rootUpdates.callbacks.beforeInstallPart[ixcallback] ); try { while typeOf (adrcallback^) == addressType { adrcallback = adrcallback^}; if not adrcallback^ (adrPart^.adr, string (adrPart^.changes) ) { flInstallPart = false; break}}}}; if flInstallPart { if not (defined (@adrPart^.adr^)) { // make sure path to item exists local (addressList = string.parseAddress (adrPart^.adr), ct, item, nomad); bundle { // prime nomad if flGuestDb { nomad = @[addressList [1]]; delete (@addressList [1])} else { nomad = @root}}; ct = sizeOf (addressList); if ct != 1 { delete (@addressList [ct])}; for item in addressList { nomad = @nomad^.[item]; if not (defined (nomad^)) { new (tableType, nomad)}}}; adrPart^.adr^ = adrPart^.data}; bundle { //call afterInstallPart callbacks ctcallbacks = sizeOf (user.rootUpdates.callbacks.afterInstallPart); for ixcallback = 1 to ctcallbacks { local (adrcallback = @user.rootUpdates.callbacks.afterInstallPart[ixcallback] ); try { while typeOf (adrcallback^) == addressType { adrcallback = adrcallback^}; adrcallback^ (adrPart^.adr, string (adrPart^.changes) )}}}} else { flpartinstalled = false; if flDialogs { if not dialog.yesNo ("Installation of \"" + adrPart^.adr + "\" failed. Continue installation?") { return (false)}}}; local (logline); bundle { //clean up address so you can 2click on it logline = string (adrPart^.adr); local (ix = string.patternmatch ("].", logline)); if ix != 0 { logline = string.delete (logline, 1, ix + 1)}}; bundle { //log the update on cleanNote (s) { if s != "" { s = string.replaceAll (s, "\r\n", "\r"); s = string.replace (s, ": ", ":\r"); s = string.replaceAll (s, ". ", ".\r"); s = string.replaceAll (s, "-- ", "--\r"); s = "Changed " + s; s = string.replaceAll (s, "\r\r\r\r", "\r\r"); s = string.replaceAll (s, "\r\r\r", "\r\r"); s = string.popTrailing (s, "\r")}; return (s)}; local (changenote = cleanNote (string (adrPart^.changes))); export.addToLog (logline, adrPrefs^.url, changenote); if user.rootupdates.prefs.flShowUpdatesToUser { if not flLogOutlineOpened { if not defined (user.rootupdates.prefs.adrOutlineForUser^) { new (outlinetype, user.rootupdates.prefs.adrOutlineForUser); local (oldtarget = target.set (user.rootupdates.prefs.adrOutlineForUser)); op.setLineText (user.rootupdates.prefs.adrOutlineForUser + " created on " + clock.now ()); target.set (oldtarget); flNewLogOutline = true}; local (oldtarget = target.set (user.rootupdates.prefs.adrOutlineForUser)); op.firstSummit (); op.insert ("Updated " + fname + " on " + clock.now (), up); target.set (oldtarget); flLogOutlineOpened = true}; local (oldtarget = target.set (user.rootupdates.prefs.adrOutlineForUser)); op.insert (logline, right); if sizeof (changenote) > 0 { op.insert (changenote, right); op.go (left, 1); op.collapse ()}; op.go (left, 1); target.set (oldtarget)}}; return (true)}; if not installPart (adrnewpart) { break}; if flpartinstalled { ctnewparts++}}; if defined (newPartsTable.lastUpdateTime) { //PBS 08/20/00: get last update time from server, if supplied adrPrefs^.lastUpdate = newPartsTable.lastUpdateTime} else { //PBS 08/20/00: fallback -- use clock.now () to set last update time adrPrefs^.lastUpdate = date.netStandardString (clock.now ())}; adrPrefs^.serialNum = newPartsTable.serialNum; if flGuestDb { msg ("Saving " + adrPrefs^.dbname + "..."); fileMenu.saveMyRoot (adrInRoot); msg ("")} else { menu.installMainMenu (); system.menus.buildSuitesSubMenu (); //re-build in case any new suites were imported. msg ("Saving Frontier.root..."); fileMenu.save (); msg ("")}; if flLogOutlineOpened and not flQuietMode { edit (user.rootupdates.prefs.adrOutlineForUser); if flNewLogOutline { window.zoom (user.rootupdates.prefs.adrOutlineForUser)}} else { thread.sleepFor (0); if ctnewparts == 1 { if flDialogs { dialog.alert ("1 new part loaded from \"" + adrPrefs^.server + "\".")} else { msg ("1 new part loaded from \"" + adrPrefs^.server + "\".")}} else { if flDialogs { dialog.alert (ctnewparts + " new parts loaded from \"" + adrPrefs^.server + "\".")} else { msg (ctnewparts + " new parts loaded from \"" + adrPrefs^.server + "\".")}}}} else { //handle errors on alert (message) { if flDialogs { return (dialog.alert (message))}; scriptError (message)}; local (lowerError = string.lower (tryerror)); local (errmsg = "Can't update the root because "); case true { lowerError contains "socket is not connected" { alert (errmsg + "the server is not responding.")}; lowerError contains "can't get the address of"; lowerError contains "poorly formed xml text"; lowerError contains "missing tag" { alert (errmsg + "the server timed out.")}} else { alert (errmsg + "\"" + tryError + ".\"")}; return (false)}; if adrCtNewParts != nil { //01/21/01 JES: make the new part count available to the caller adrCtNewParts^ = ctNewParts}; return (true)}; getUpdate (channelname, adrroot)}; Çbundle // testing Çupdate (@root) \ No newline at end of file --- 1,421 ---- ! FrontierVcsFile:2:scpt:system.verbs.builtins.rootUpdates.update ! on update (adrInRoot = table.getcursoraddress (), flQuietMode=false, adrCtNewParts=nil) { ! «Changes ! «3/1/06; 9:33:38 AM by TAC ! «minor script formatting tweaks ! «if the value of adrCallback is of type string, coerce to address, allows for partial addresses ! «2/19/06; 1:49:03 PM by TAC ! «when initializing a server use Frontier.data.initialLastUpdateTime to set lastupdate ! «minor script formatting tweaks ! «make sure path to new part exists before trying to assign it, accommodate using a cvs repository as a backend ! «2/16/06; 6:27:30 PM by TAC ! «when getting an update for the host database (@root) send paramaters just like when updating a guest database, except dbName is any empty string ! «12/23/05; 9:45:17 PM by TAC ! «updated root update code ! «6/13/05; 12:53:52 PM by TAC ! «disabled trial version and serial number checks ! «1/12/04; 12:48:36 AM by JES ! «Changed default updates server from madrid.userland.com to updates.userland.com. ! «2002 ! «8/28/02; 10:48:23 PM by JES ! «Added support for two new callbacks: ! «user.rootUpdates.callbacks.beforeInstallPart -- scripts in this table are called with two parameters: the address of the part, and the change note. If any script returns false, then the part is not installed. No error is generated -- it's up to the callback script to provide feedback to the user. ! «user.rootUpdates.callbacks.afterInstallPart -- scripts in this table are called with two parameters: the address of the part, and the change note. The return value is ignored. ! «4/16/02; 4:34:53 PM by JES ! «Bug fix: Store the new part count in adrCtNewParts^ even if no new parts were loaded. ! «1/21/02; 2:25:42 PM by JES ! «Use a string comparison to determine whether we're getting updates from radioupdates.userland.com, instead of a call to tcp.equalNames, since tcp.equalNames fails for some proxy server users. ! «1/7/02; 9:09:40 PM by PBS ! «If getting Radio updates from radioupdates.userland.com, send your usernum as an additional parameter. ! «8/6/01; 2:22:37 PM by PBS ! «When updating Manila or mainResponder, send the serial number. ! «01/21/01; 6:03:11 PM by JES ! «Added optional parameter, adrCtNewParts. If not nil, the number of updated parts is assigned to adrCtNewParts^. ! «08/20/00; 11:49:35 AM by PBS ! «If the server returns a last update time, use that instead of clock.now (). This fixes problems with people missing updates due to having clocks out-of-synch with the server. This way, the server's time is always used. ! «06/17/00; 11:16:23 PM by PBS ! «Use new root updates timeout pref. ! «11/16/99; 1:43:53 AM AM by AR ! «Make sure backup folder exists before backing up GDBs. ! «Added flQuietMode parameter, defaulting to false. If it's true, we suppress all server-unfriendly interaction like putting up dialogs or opening the outline of new parts, regardless of the settings in user.rootUpdates. ! «10/7/99; 6:43:29 PM by DW ! «New pref, user.rootupdates.prefs.flShowUpdatesToUser, defaults true, initialized in rootUpdates.init. ! «New pref, user.rootupdates.prefs.adrOutlineForUser, defaults to @user.rootUpdates.updateOutline. ! «if flShowUpdatesToUser is true, we create the outline if it doesn't exist and add a top-level headline with the date and time and the name of the database being updated. Each subordinate entry is the address of an object that's been updated. Underneath the address is the explanation of the change, if available. ! ! «bundle // trial ! «if defined (userland.trialVersionCheck) ! «if userland.trialVersionCheck () ! «scriptError ("Can't update the database because the trial period has expired.") ! ! rootUpdates.init (); ! ! local (adrroot = table.getrootaddress (adrInRoot)); ! local (alist = string.parseaddress (adrroot)); ! local (f = window.getFile (alist [1])); ! local (fname = file.filefrompath (f)); ! ! if not string.lower (fname) endswith ".root" { ! scripterror ("Can't update the file because its name doesn't end with .root.")}; ! ! local (channelname = string.mid (fname, 1, sizeof (fname) - 5)); ! local (adrtable = @user.rootUpdates.servers.[channelname]); ! ! if not defined (adrtable^) { ! new (tabletype, adrtable); ! ! adrtable^.server = "rootUpdates.frontierOpenSource.editHere.com"; ! adrtable^.port = 8081; ! adrtable^.method = "mainResponder.subscriptions.update"; ! adrtable^.dbname = fname; ! ! adrtable^.lastupdate = Frontier.data.initialLastUpdateTime; //indicate that it's never been updated ! ! adrtable^.autobackup = true; //if true the backup will be of docServer.root, not Frontier.root ! adrtable^.dialogs = true; //set this false if you're updating automatically thru the scheduler ! adrtable^.openLog = true; //show the log file of changes ! ! adrtable^.URL = ""}; ! «else ! «if string.lower (adrtable^.server) == "madrid.userland.com" ! «adrtable^.server = "updates.userland.com" ! «bundle //the responder name on the server changed ! «if adrtable^.method == "mainResponder.subscriptions.update" ! «adrtable^.method = "nirvanaServer.subscriptions.update" ! on getUpdate (serverName, adrInRoot = nil) { //an enhanced version of rootupdates.getUpdate ! «10/18/98; 11:33:30 AM by DW ! «Made it guest database-aware. ! «If adrInRoot is specified, it's assumed to point into the guest db that's getting updated ! «Added a field to the prefs record, dbname, which names the guest database that's being shared ! «It's an index into user.mainresponder.databases on the server. ! «The handler for this is at mainresponder.rpchandlers.subscriptions.update. ! ! local (frontierVersion = Frontier.version ()); ! local (platform = string.mid (sys.os (), 1, 3)); ! local (ctnewparts = 0); ! local (flDialogs = true); ! local (flLogOutlineOpened = false, flNewLogOutline = false); ! ! local (adrPrefs = @user.rootUpdates.servers.[serverName]); ! ! local (flGuestDb = false, addressprefixstring); //10/18/98 DW ! bundle { //gather info about guest database ! if adrInRoot != nil and string.lower (channelname) != "frontier" { ! addressprefixstring = string (table.getRootAddress (adrInRoot)); ! flGuestDb = true}}; ! ! if defined (adrPrefs^.dialogs) and not adrPrefs^.dialogs { ! flDialogs = false}; ! if flQuietMode { //AR 11/15/1999 ! flDialogs = false}; ! ! «if not defined (user.prefs.serialNumber) // 6/13/05; 12:53:52 PM by TAC - disabled ! «user.prefs.serialNumber = "" ! ! try { //try to get the root update from the server ! if flDialogs { ! local (prompt = "Connect with " + adrPrefs^.server + " to get latest update"); ! if flGuestDb { ! prompt = prompt + " of " + adrPrefs^.dbname}; ! prompt = prompt + "?"; ! if not dialog.confirm (prompt) { ! return (false)}}; ! window.about (); ! local (sn = 0); ! «if adrPrefs == @user.rootUpdates.servers.Frontier ! «Only send Frontier serial number when getting Frontier.root udpate. ! «Thu, Mar 18, 1999 at 3:21:10 PM by PBS ! «sn = user.prefs.serialNumber ! local (rpcPath = user.betty.prefs.rpcClientDefaultPath); ! «bundle // 6/13/05; 12:53:52 PM by TAC - disabled, no serial number check needed for open source release ! «case true //PBS 08/06/01: send serial number for Frontier, Manila, and mainResponder ! «adrPrefs == @user.rootUpdates.servers.Radio ! «adrPrefs == @user.rootUpdates.servers.radioCommunityServer ! «adrPrefs == @user.rootUpdates.servers.serverMonitor ! «adrPrefs == @user.rootUpdates.servers.Prefs ! «adrPrefs == @user.rootUpdates.servers.Frontier ! «adrPrefs == @user.rootUpdates.servers.Manila ! «adrPrefs == @user.rootUpdates.servers.mainResponder ! «sn = user.prefs.serialNumber ! «if string.lower (adrPrefs^.server) endswith ".userland.com" ! «try //add path args to rpcPath ! «local (args); new (tableType, @args) ! «args.org = user.prefs.organization ! «args.name = user.prefs.name ! «args.email = user.prefs.mailAddress ! «args.sn = user.prefs.serialNumber ! «if defined (config.mainResponder.domains) ! «args.domains = sizeOf (config.mainResponder.domains) ! «else ! «args.domains = 0 ! «if defined (config.manila.sites) ! «args.sites = sizeOf (config.manila.sites) ! «else ! «args.sites = 0 ! «if defined (radioCommunityServerData.users) ! «args.rcsUsers = sizeOf (radioCommunityServerData.users) ! «else ! «args.rcsUsers = 0 ! «rpcPath = rpcPath + "?" + webserver.encodeArgs (@args) ! «else ! «if defined (adrPrefs^.serialNum) ! «sn = adrPrefs^.serialNum ! «else ! «sn = 0 ! ! local (paramlist = {tcp.addressDecode (tcp.myAddress ()), adrPrefs^.lastupdate, platform, sn, user.prefs.name, user.prefs.mailAddress, frontierVersion}); ! ! bundle { //PBS 01/07/02: send usernum to radioupdates.userland.com ! «if tcp.equalNames (adrPrefs^.server, "radioupdates.userland.com") ! «paramlist = paramlist + user.radio.prefs.usernum ! if string.lower (adrPrefs^.server) == "radioupdates.userland.com" { ! paramlist = paramlist + user.radio.prefs.usernum}}; ! ! if flGuestDb { ! paramlist = {adrPrefs^.dbname} + paramlist} ! else { ! paramlist = {""} + paramlist}; // empty string indicates get host database (@root) update ! ! local (newpartstable); ! local (i); ! msg ("Connecting to " + adrPrefs^.server + " to get " + serverName + " update..."); ! newpartstable = betty.rpc.client (adrPrefs^.server, adrPrefs^.port, adrPrefs^.method, @paramlist, false, rpcPath:rpcPath, ticksToTimeOut:user.rootUpdates.prefs.timeout); ! «bundle //original call ! «newpartstable = betty.rpc.client (adrPrefs^.server, adrPrefs^.port, adrPrefs^.method, @paramlist, false, ticksToTimeOut:user.rootUpdates.prefs.timeout) ! if not defined (newPartsTable.parts) { ! if newPartsTable beginsWith "There are no new or changed parts available." or newPartsTable beginsWith "Your root is already updated" { ! msg (""); ! if flDialogs { ! dialog.notify (newPartsTable)} ! else { ! msg (newPartsTable)}; ! if adrCtNewParts != nil { //4/16/02; 4:33:24 PM by JES: make the new part count available to the caller, even if there are no new parts ! adrCtNewParts^ = ctNewParts}; ! return (true)}}; ! if adrPrefs^.autobackup { //10/18/98; 11:36:58 AM by DW ! if flGuestDb { ! backups.init (); //make sure user.backups.folder is set ! local (alist = string.parseaddress (adrInRoot)); ! local (source = alist [1]); ! filemenu.save (source); ! ! local (dest); ! bundle { //set dest to point at the destination file ! dest = file.filefrompath (source); ! if string.lower (dest) endswith ".root" { ! dest = string.delete (dest, sizeof (dest) - 4, 5); //pop off .root ! dest = dest + "." + user.backups.nextBackup + ".root"} ! else { ! dest = dest + "." + user.backups.nextBackup}; ! dest = user.backups.folder + dest; ! user.backups.nextBackup++}; ! file.sureFilePath (dest); //AR 11/15/1999 ! file.copy (source, dest); ! filemenu.save (); ! msg (dest + " is " + string.megabytestring (file.size (dest)))} ! else { ! backups.backuproot ()}}; ! for i = 1 to sizeof (newpartstable.parts) { ! local (adrnewpart = @newpartstable.parts [i]); ! local (bytes = binary (base64.decode (adrnewpart^))); ! local (flpartinstalled = true); ! ! setBinaryType (@bytes, tableType); ! unpack (@bytes, adrnewpart); ! ! on installPart (adrPart) { ! if defined (user.rootUpdates.protected) { //Don't import into these places. ! local (j); ! ! for j = 1 to sizeOf (user.rootUpdates.protected) { ! local (oneItem = address (user.rootUpdates.protected [j])); ! ! if table.tableContains (oneItem, adrPart^.adr) { //Don't install. ! flpartinstalled = false; ! ! return (true)}}}; ! ! if defined (adrPart^.platform) { ! if string.lower (adrPart^.platform) != "both" { // Only install parts for this platform. ! if string.lower (adrPart^.platform) != string.lower (platform) { ! return (true)}}}; ! try { ! if flGuestDb { //we got a relative address, convert it to a real address ! adrPart^.adr = address (addressprefixstring + "." + adrPart^.adr)}; ! ! msg ("Importing " + adrPart^.adr + "."); ! ! local (adrCallback, ixCallback, ctCallbacks, flInstallPart = true); ! ! bundle { //call beforeInstallPart callbacks ! ctCallbacks = sizeOf (user.rootUpdates.callbacks.beforeInstallPart); ! ! for ixCallback = 1 to ctCallbacks { ! local (adrCallback = @user.rootUpdates.callbacks.beforeInstallPart [ixCallback]); ! ! try { ! if typeOf (adrCallback^) == stringType { ! adrCallback^ = address (adrCallback^)}; ! ! while typeOf (adrCallback^) == addressType { ! adrCallback = adrCallback^}; ! ! if not (adrCallback^ (adrPart^.adr, string (adrPart^.changes))) { ! flInstallPart = false; ! break}}}}; ! ! if flInstallPart { ! if not (defined (@adrPart^.adr^)) { // make sure path to item exists ! local (addressList = string.parseAddress (adrPart^.adr), ct, item, nomad); ! ! bundle { // prime nomad ! if flGuestDb { ! nomad = @[addressList [1]]; ! delete (@addressList [1])} ! else { ! nomad = @root}}; ! ! ct = sizeOf (addressList); ! ! if ct != 1 { ! delete (@addressList [ct])}; ! ! for item in addressList { ! nomad = @nomad^.[item]; ! ! if not (defined (nomad^)) { ! new (tableType, nomad)}}}; ! ! adrPart^.adr^ = adrPart^.data}; ! ! bundle { //call afterInstallPart callbacks ! ctCallbacks = sizeOf (user.rootUpdates.callbacks.afterInstallPart); ! ! for ixCallback = 1 to ctCallbacks { ! local (adrCallback = @user.rootUpdates.callbacks.afterInstallPart [ixCallback]); ! ! try { ! if typeOf (adrCallback^) == stringType { ! adrCallback^ = address (adrCallback^)}; ! ! while typeOf (adrCallback^) == addressType { ! adrCallback = adrCallback^}; ! ! adrCallback^ (adrPart^.adr, string (adrPart^.changes) )}}}} ! else { ! flpartinstalled = false; ! ! if flDialogs { ! if not dialog.yesNo ("Installation of \"" + adrPart^.adr + "\" failed. Continue installation?") { ! return (false)}}}; ! ! local (logline); ! ! bundle { //clean up address so you can 2click on it ! logline = string (adrPart^.adr); ! local (ix = string.patternmatch ("].", logline)); ! if ix != 0 { ! logline = string.delete (logline, 1, ix + 1)}}; ! bundle { //log the update ! on cleanNote (s) { ! if s != "" { ! s = string.replaceAll (s, "\r\n", "\r"); ! s = string.replace (s, ": ", ":\r"); ! s = string.replaceAll (s, ". ", ".\r"); ! s = string.replaceAll (s, "-- ", "--\r"); ! s = "Changed " + s; ! s = string.replaceAll (s, "\r\r\r\r", "\r\r"); ! s = string.replaceAll (s, "\r\r\r", "\r\r"); ! s = string.popTrailing (s, "\r")}; ! return (s)}; ! local (changenote = cleanNote (string (adrPart^.changes))); ! export.addToLog (logline, adrPrefs^.url, changenote); ! ! if user.rootupdates.prefs.flShowUpdatesToUser { ! if not flLogOutlineOpened { ! if not defined (user.rootupdates.prefs.adrOutlineForUser^) { ! new (outlinetype, user.rootupdates.prefs.adrOutlineForUser); ! local (oldtarget = target.set (user.rootupdates.prefs.adrOutlineForUser)); ! op.setLineText (user.rootupdates.prefs.adrOutlineForUser + " created on " + clock.now ()); ! target.set (oldtarget); ! flNewLogOutline = true}; ! local (oldtarget = target.set (user.rootupdates.prefs.adrOutlineForUser)); ! op.firstSummit (); ! op.insert ("Updated " + fname + " on " + clock.now (), up); ! target.set (oldtarget); ! flLogOutlineOpened = true}; ! ! local (oldtarget = target.set (user.rootupdates.prefs.adrOutlineForUser)); ! op.insert (logline, right); ! if sizeof (changenote) > 0 { ! op.insert (changenote, right); ! op.go (left, 1); ! op.collapse ()}; ! op.go (left, 1); ! target.set (oldtarget)}}; ! ! return (true)}; ! if not installPart (adrnewpart) { ! break}; ! if flpartinstalled { ! ctnewparts++}}; ! if defined (newPartsTable.lastUpdateTime) { //PBS 08/20/00: get last update time from server, if supplied ! adrPrefs^.lastUpdate = newPartsTable.lastUpdateTime} ! else { //PBS 08/20/00: fallback -- use clock.now () to set last update time ! adrPrefs^.lastUpdate = date.netStandardString (clock.now ())}; ! ! adrPrefs^.serialNum = newPartsTable.serialNum; ! ! if flGuestDb { ! msg ("Saving " + adrPrefs^.dbname + "..."); ! fileMenu.saveMyRoot (adrInRoot); ! msg ("")} ! else { ! menu.installMainMenu (); ! system.menus.buildSuitesSubMenu (); //re-build in case any new suites were imported. ! msg ("Saving Frontier.root..."); ! fileMenu.save (); ! msg ("")}; ! ! if flLogOutlineOpened and not flQuietMode { ! edit (user.rootupdates.prefs.adrOutlineForUser); ! if flNewLogOutline { ! window.zoom (user.rootupdates.prefs.adrOutlineForUser)}} ! else { ! thread.sleepFor (0); ! if ctnewparts == 1 { ! if flDialogs { ! dialog.alert ("1 new part loaded from \"" + adrPrefs^.server + "\".")} ! else { ! msg ("1 new part loaded from \"" + adrPrefs^.server + "\".")}} ! else { ! if flDialogs { ! dialog.alert (ctnewparts + " new parts loaded from \"" + adrPrefs^.server + "\".")} ! else { ! msg (ctnewparts + " new parts loaded from \"" + adrPrefs^.server + "\".")}}}} ! else { //handle errors ! on alert (message) { ! if flDialogs { ! return (dialog.alert (message))}; ! scriptError (message)}; ! local (lowerError = string.lower (tryerror)); ! local (errmsg = "Can't update the root because "); ! case true { ! lowerError contains "socket is not connected" { ! alert (errmsg + "the server is not responding.")}; ! lowerError contains "can't get the address of"; ! lowerError contains "poorly formed xml text"; ! lowerError contains "missing tag" { ! alert (errmsg + "the server timed out.")}} ! else { ! alert (errmsg + "\"" + tryError + ".\"")}; ! return (false)}; ! ! if adrCtNewParts != nil { //01/21/01 JES: make the new part count available to the caller ! adrCtNewParts^ = ctNewParts}; ! return (true)}; ! getUpdate (channelname, adrroot)}; ! ! «bundle // testing ! «update (@root) \ No newline at end of file |