|
From: creedon <icr...@us...> - 2006-02-18 18:53:05
|
Update of /cvsroot/frontierkernel/odbs/mainResponderRoot/mainResponder/subscriptions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21934 Modified Files: server Log Message: on the Admin web page clarify that the email address is later used to access the Admin web site Index: server =================================================================== RCS file: /cvsroot/frontierkernel/odbs/mainResponderRoot/mainResponder/subscriptions/server,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** server 25 Dec 2005 01:51:07 -0000 1.3 --- server 18 Feb 2006 18:52:57 -0000 1.4 *************** *** 1,3 **** FrontierVcsFile:1:scpt:mainResponder.subscriptions.server ! on server (dbName, ipAddress, lastUpdate, userName, mailAddress, serialNumber) { ÇChanges Ç12/24/05; 10:39:17 AM by TAC Çchanged local adrGuestDatabase to adrSubscribedDatabase to better describe it function Çnow works with host database (@root), the open source release didn't come with the rpc handler script rootUpdates.public.getUpdate, so I adapted this script to do the job Çnote: the root update server needs to have a table at user.datbases with the name of the host database (i.e. "Frontier.root") with the following items... Çf string: Frontier.root ÇopenOnStartup boolean: false ÇrunStartupScript boolean: false ÇsupportsSubscribe boolean: true Çsupport relative paths in user.rootUpdates.servers.x.f Çno longer need to pop the file off an address as what is now stored as a relative address Ç8/12/04; 3:12:31 AM by JES ÇAdditional logging: Errors are now logged. When an update is successful, ctPartsSent (in the log sub-table) is set to the number of parts sent to the client. Ç12/7/03; 11:52:32 PM by JES ÇAdd callback support. Callbacks are in config.mainResponder.callbacks.subscriptionsServer. They take the same parameters as this RPC handler. If any callback returns false, then an error is generated. Ç11/04/00; 5:55:40 PM by PBS ÇReturn the time on the server of the last update, so clients don't miss updates. ÇReturn new and changed parts of a database since the last update. local (adrTable = log.addToGuestDatabase ("subscriptions")); bundle { //add a record to the subscription log adrTable^.dbName = dbName; adrTable^.ipAddress = ipAddress; adrTable^.lastUpdate = lastUpdate; adrTable^.userName = userName; adrTable^.mailAddress = mailAddress; adrTable^.serialNumber = serialNumber}; bundle { //call callbacks local (adrCallbacks = @config.mainResponder.callbacks.subscriptionsServer); if not defined (adrCallbacks^) { new (tableType, adrCallbacks)}; local (adr, ct = sizeOf (adrCallbacks^), i, flSendUpdate = true); for i = 1 to ct { adr = @adrCallbacks^[i]; try { while typeOf (adr^) == addressType { adr = adr^}; if not adr^ (dbName, ipAddress, lastUpdate, userName, mailAddress, serialNumber) { flSendUpdate = false}}; if not flSendUpdate { scriptError ("Can't update because you are not authorized for updates to this database.")}}}; local (adrDb = @user.databases.[dbName]); if not defined (adrDb^) { adrTable^.error = "The sysop hasn't registered a database named \"" + dbName + "\"."; //02/04/07, 08:22:52 by DAB scriptError ("Can't send you an update because the sysop hasn't registered a database named \"" + dbName + "\".")}; if not (adrDb^.supportsSubscribe) { adrTable^.error = "The database \"" + dbName + "\" doesn't support subscriptions."; //02/04/07, 08:22:48 by DAB scriptError ("Can't send you an update because the database \"" + dbName + "\" doesn't support subscriptions.")}; local (adrSubscribedDatabase, flGuestDatabase = true); if window.getFile (@root) == fileSpec (adrDb^.f) { flGuestDatabase = false; adrSubscribedDatabase = @root} else { adrSubscribedDatabase = @[fileSpec (adrDb^.f)]}; if flGuestDatabase { table.sureDatabaseOpen (adrSubscribedDatabase)}; lastUpdate = date (lastUpdate); //convert from a net-standard-string local (frontierVersion = Frontier.version ()); local (adrChanges = @adrSubscribedDatabase^.["#changes"]); local (sizeChanges = sizeOf (adrChanges^)); local (parts); new (tabletype, @parts); parts.serialNum = sizeChanges; //it's synthetic! parts.lastUpdateTime = date.netStandardString (clock.now ()); //PBS 11/4/00: save server time on client, to avoid missing updates new (tabletype, @parts.parts); local (i, addedItems = {}); for i = sizeChanges downto 1 { local (adrItem = @adrChanges^ [i]); if adrItem^.when < lastUpdate { break}; if addedItems contains adrItem^.what { //we've already included this continue}; local (name = "part" + string.padwithzeros (i, 4)); local (adrNewPart = @parts.parts.[name]); new (tabletype, adrNewPart); bundle { //2/14/99; 9:01:26 AM by DW, customized error if object doesn't exist if not defined (adrItem^.what^) { adrTable^.error = "The #changes table in \"" + dbName + "\" on the server says that \"" + adrItem^.what + "\" has changed, but the object isn't in the database."; //02/04/07, 08:22:41 by DAB scriptError ("Can't do the update because the #changes table in \"" + dbName + "\" on the server says that \"" + adrItem^.what + "\" has changed, but the object isn't in the database.")}; adrNewPart^.data = adrItem^.what^}; adrNewPart^.timeStamp = adrItem^.when; adrNewPart^.userName = adrItem^.who; adrNewPart^.adr = adrItem^.what; Çbundle //put the relative address into adr field Çlocal (s = string (adrItem^.what)) Çlocal (ix = string.patternMatch ("].", s)) Çs = string.delete (s, 1, ix + 1) ÇadrNewPart^.adr = s wp.newtextobject ("", @adrNewPart^.changes); adrNewPart^.platform = "both"; adrNewPart^.version = frontierVersion; local (bytes); pack (adrNewPart^, @bytes); bytes = base64.encode (bytes, infinity); delete (adrNewPart); adrNewPart^ = bytes; addedItems = addedItems + {adrItem^.what}; sys.systemTask ()}; adrTable^.ctPartsSent = sizeof (addedItems); //02/04/07, 08:22:36 by DAB return (parts)}; Çbundle // testing Çserver ("Frontier.root", tcp.dns.getMyDottedId (), date.prevMonth (clock.now ()), "Thomas A. Creedon", "icr...@ya...", 0) Çserver ("prefs.root", tcp.dns.getMyDottedId (), clock.now (), "Jake", "ja...@us...", 10) \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:mainResponder.subscriptions.server ! on server (dbName, ipAddress, lastUpdate, userName, mailAddress, serialNumber) { ÇChanges Ç2/16/06; 6:17:36 PM by TAC Çif dbName == "" then set it to host database (@root) name Ç12/24/05; 10:39:17 AM by TAC Çchanged local adrGuestDatabase to adrSubscribedDatabase to better describe it function Çnow works with host database (@root), the open source release didn't come with the rpc handler script rootUpdates.public.getUpdate, so I adapted this script to do the job Çnote: the root update server needs to have a table at user.datbases with the name of the host database (i.e. "Frontier.root") with the following items... Çf string: Frontier.root ÇopenOnStartup boolean: false ÇrunStartupScript boolean: false ÇsupportsSubscribe boolean: true Çsupport relative paths in user.rootUpdates.servers.x.f Çno longer need to pop the file off an address as what is now stored as a relative address Ç8/12/04; 3:12:31 AM by JES ÇAdditional logging: Errors are now logged. When an update is successful, ctPartsSent (in the log sub-table) is set to the number of parts sent to the client. Ç12/7/03; 11:52:32 PM by JES ÇAdd callback support. Callbacks are in config.mainResponder.callbacks.subscriptionsServer. They take the same parameters as this RPC handler. If any callback returns false, then an error is generated. Ç11/04/00; 5:55:40 PM by PBS ÇReturn the time on the server of the last update, so clients don't miss updates. ÇReturn new and changed parts of a database since the last update. local (adrTable = log.addToGuestDatabase ("subscriptions")); bundle { //add a record to the subscription log adrTable^.dbName = dbName; adrTable^.ipAddress = ipAddress; adrTable^.lastUpdate = lastUpdate; adrTable^.userName = userName; adrTable^.mailAddress = mailAddress; adrTable^.serialNumber = serialNumber}; bundle { //call callbacks local (adrCallbacks = @config.mainResponder.callbacks.subscriptionsServer); if not defined (adrCallbacks^) { new (tableType, adrCallbacks)}; local (adr, ct = sizeOf (adrCallbacks^), i, flSendUpdate = true); for i = 1 to ct { adr = @adrCallbacks^[i]; try { while typeOf (adr^) == addressType { adr = adr^}; if not adr^ (dbName, ipAddress, lastUpdate, userName, mailAddress, serialNumber) { flSendUpdate = false}}; if not flSendUpdate { scriptError ("Can't update because you are not authorized for updates to this database.")}}}; if dbName == "" { dbName = file.fileFromPath (window.getFile (@root))}; local (adrDb = @user.databases.[dbName]); if not defined (adrDb^) { adrTable^.error = "The sysop hasn't registered a database named \"" + dbName + "\"."; //02/04/07, 08:22:52 by DAB scriptError ("Can't send you an update because the sysop hasn't registered a database named \"" + dbName + "\".")}; if not (adrDb^.supportsSubscribe) { adrTable^.error = "The database \"" + dbName + "\" doesn't support subscriptions."; //02/04/07, 08:22:48 by DAB scriptError ("Can't send you an update because the database \"" + dbName + "\" doesn't support subscriptions.")}; local (adrSubscribedDatabase, flGuestDatabase = true); if window.getFile (@root) == fileSpec (adrDb^.f) { flGuestDatabase = false; adrSubscribedDatabase = @root} else { adrSubscribedDatabase = @[fileSpec (adrDb^.f)]}; if flGuestDatabase { table.sureDatabaseOpen (adrSubscribedDatabase)}; lastUpdate = date (lastUpdate); //convert from a net-standard-string local (frontierVersion = Frontier.version ()); local (adrChanges = @adrSubscribedDatabase^.["#changes"]); local (sizeChanges = sizeOf (adrChanges^)); local (parts); new (tabletype, @parts); parts.serialNum = sizeChanges; //it's synthetic! parts.lastUpdateTime = date.netStandardString (clock.now ()); //PBS 11/4/00: save server time on client, to avoid missing updates new (tabletype, @parts.parts); local (i, addedItems = {}); for i = sizeChanges downto 1 { local (adrItem = @adrChanges^ [i]); if adrItem^.when < lastUpdate { break}; if addedItems contains adrItem^.what { //we've already included this continue}; local (name = "part" + string.padwithzeros (i, 4)); local (adrNewPart = @parts.parts.[name]); new (tabletype, adrNewPart); bundle { //2/14/99; 9:01:26 AM by DW, customized error if object doesn't exist if not defined (adrItem^.what^) { adrTable^.error = "The #changes table in \"" + dbName + "\" on the server says that \"" + adrItem^.what + "\" has changed, but the object isn't in the database."; //02/04/07, 08:22:41 by DAB scriptError ("Can't do the update because the #changes table in \"" + dbName + "\" on the server says that \"" + adrItem^.what + "\" has changed, but the object isn't in the database.")}; adrNewPart^.data = adrItem^.what^}; adrNewPart^.timeStamp = adrItem^.when; adrNewPart^.userName = adrItem^.who; adrNewPart^.adr = adrItem^.what; Çbundle //put the relative address into adr field Çlocal (s = string (adrItem^.what)) Çlocal (ix = string.patternMatch ("].", s)) Çs = string.delete (s, 1, ix + 1) ÇadrNewPart^.adr = s wp.newtextobject ("", @adrNewPart^.changes); adrNewPart^.platform = "both"; adrNewPart^.version = frontierVersion; local (bytes); pack (adrNewPart^, @bytes); bytes = base64.encode (bytes, infinity); delete (adrNewPart); adrNewPart^ = bytes; addedItems = addedItems + {adrItem^.what}; sys.systemTask ()}; adrTable^.ctPartsSent = sizeof (addedItems); //02/04/07, 08:22:36 by DAB return (parts)}; Çbundle // testing Çserver ("Frontier.root", tcp.dns.getMyDottedId (), date.prevMonth (clock.now ()), "Thomas A. Creedon", "icr...@ya...", 0) Çserver ("prefs.root", tcp.dns.getMyDottedId (), clock.now (), "Jake", "ja...@us...", 10) \ No newline at end of file |