Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.thread.agents.pingCloud
on pingCloud () { <<Changes <<9/15/03; 6:10:46 PM by JES <<Send comment notification prefs to the comments server if the feature is supported. <<7/22/03; 5:07:00 PM by JES <<Save weblogData.prefs.trackbackPageUrl in the cloud. Used when setting up a new Radio installation for an existing user. See radio.cloud.registerWithServer under the else block with the comment "connect existing user". <<12/9/02; 2:15:09 PM by JES <<Save weblogData.prefs.commentsPageUrl in the cloud. Used when setting up a new Radio installation for an existing user. See radio.cloud.registerWithServer under the else block with the comment "connect existing user". <<8/31/02; 2:19:48 AM by JES <<Update radio.data.cloudUrls.themesDirectoryOpml if sent from the server. <<8/30/02; 5:31:54 PM by JES <<Add information about the community server's search features or lack thereof to the radio.data.myCommunity table. <<8/30/02; 12:15:51 AM by JES <<Respect radio.data.myCommunity.minutesBetweenPings, if defined. This value is sent by RCS as part of the return struct for the getServerCapabilities call, based on a server-side pref. The default is 5 minutes. <<Changes before 8/1/02 <<7/20/02; 5:11:04 PM by JES <<If the getServerCapabilities return struct contains urlStore, set radio.data.cloudUrls.store to its value. <<5/15/02; 3:18:43 PM by JES <<If the getServerCapabilities return struct contains urlViewDirectory, set radio.data.cloudUrls.viewDirectoryUrl to its value. <<3/14/02; 3:05:10 PM by JES <<In the getServerCapabilities return-struct, it's mailListUrl, not mailList. Commented out debugging code. <<3/14/02; 2:47:02 PM by JES <<Set the systemUrls for the discussion group and mailing list, if present in the getServerCapabilities return-struct. <<3/14/02; 2:36:56 PM by JES <<If the struct returned by the getServerCapabilities call includes the constants in radio.data.myCommunity, patch their values. <<3/7/02; 11:13:45 AM by JES <<Get the cloud info table from user.radio.prefs.defaultCloud, instead of from the upstream spec. <<3/3/02; 7:25:05 PM by JES <<Only set the weblog changesXml url and hotlistOpml url, if they're defined in the staticUrls sub-table returned by getServerCapabilities. <<3/2/02; 3:38:29 PM by JES <<The name of the weblog updates changes xml url, returned by getServerCapabilities, changed to changesXml. Added setting of the hotlist opml url, as returned by getServerCapabilities. <<3/1/02; 3:47:08 PM by JES <<Added weblogTitle to the info table sent to the cloud with a ping. <<3/1/02; 1:58:16 PM by JES <<If the weblog updates url is included in the server capabilities response, set the url in radio.data.cloudLinks. <<3/1/02; 1:04:55 PM by JES <<The name of the weblog updates changes url returned by the getServerCapabilities call has changed from changes.xml to changes. <<2/26/02; 11:28:22 AM by JES <<Copy URLs from the staticUrls table in the server capabilities return value, if present, to their respective locations. Right now, there's only one -- the updated weblogs changes.xml. <<2/25/02; 7:18:14 PM by JES <<Copy various URLs returned from the getServerCapabilities call to their proper locations. <<Dave rewrote this routine. Original code is below: <<if not tcp.isOffline () <<local (now = clock.now (), flping = false) <<bundle //make sure system values are initialized <<if not defined (system.temp.radio.misc.lastPingTime) <<system.temp.radio.misc.lastPingTime = date (0) <<if not defined (system.temp.radio.misc.lastTcpAddress) <<system.temp.radio.misc.lastTcpAddress = 0 <<if (now - system.temp.radio.misc.lastPingTime) >= (5 * 60) <<flping = true <<system.temp.radio.misc.lastPingTime = now <<if system.temp.radio.misc.lastTcpAddress != tcp.myAddress () <<flping = true <<system.temp.radio.misc.lastTcpAddress = tcp.myAddress () <<if flping <<local (usernum = user.radio.prefs.usernum) <<local (password = user.radio.prefs.passwords.default) <<local (info) <<bundle //set up the info table <<new (tabletype, @info) <<info.flBehindFirewall = user.radio.prefs.flBehindFirewall <<info.serialNumber = user.radio.prefs.serialNumber <<info.name = user.prefs.name <<info.email = user.prefs.mailAddress <<info.organization = user.prefs.organization <<bundle //add the home page url to the info table <<local (usernumstring = string.padwithzeros (user.radio.prefs.usernum, 7)) <<local (homeurl = "http://radio.weblogs.com/" + usernumstring + "/") <<bundle //calculate homeurl <<local (upstreamSpecPath = user.radio.prefs.upstream.folder + radio.data.fileNames.upstreamFileName) <<if file.exists (upstreamSpecPath) <<local (adrfile, adrspec) <<if radio.file.getFileAttributes (upstreamSpecPath, @adrfile) <<if radio.upstream.getUpstreamSpec (adrfile, @adrspec) <<case string.lower (adrspec^.type) <<"xmlstoragesystem" <<local (adrcapabilities = @user.radio.prefs.upstream.servers.[adrspec^.server]) <<if not defined (adrcapabilities^) <<radio.upstream.getServerCapabilities (adrspec) <<homeurl = adrcapabilities^.serverCapabilities.yourUpstreamFolderUrl <<"ftp" <<homeurl = adrspec^.url <<local (adrfolder = @user.radio.settings.files.[user.radio.prefs.upstream.folder]) <<if adrfolder^.upstream.url != "" <<homeurl = adrfolder^.upstream.url <<info.url = homeurl <<info.organization = user.prefs.organization <<if not user.radio.settings.flPasswordStoredInCloud <<info.passwordFull = string (user.radio.prefs.passwords.default) <<if xmlStorageSystem.ping (usernum, password, 0, @info, @user.radio.prefs.defaultCloud, adrclouddata:@user.radio.prefs.defaultCloudData) <<if not user.radio.settings.flPasswordStoredInCloud <<user.radio.settings.flPasswordStoredInCloud = true <<bundle //get server capabilities, 2/7/02; 12:33:20 PM by DW <<local (adrserverinfo = @user.radio.prefs.upstream.servers.[user.radio.prefs.defaultCloud.server]) <<local (adrcapabilities = @adrserverinfo^.serverCapabilities) <<xmlStorageSystem.getServerCapabilities (usernum, password, adrcapabilities, adrdata:@user.radio.prefs.defaultCloud, flMessages:false) <<2/25/02; 1:42:53 PM by JES <<Get the server information from the usptream spec, instead of from user.radio.prefs.defaultCloud. <<2/7/02; 12:20:26 PM by DW <<In addition to pinging the cloud, also get the server capabilities. <<1/25/02; 8:36:45 AM by DW <<Update user's name, organization and email address on the community server. <<12/10/01; 11:33:22 AM by JES <<Get the homefolder url via the server capabilities for xss, or from the upstream spec for ftp, instead of from the filetable for the www folder. This fixes a bug where after you switch back from ftp to xss, your home link would still be the ftp link. Also, add user.prefs.organization to the info table sent to the cloud. <<12/8/01; 4:30:43 PM by JES <<Add the user's home folder url to the info table sent to the cloud. <<12/3/01; 10:10:22 AM by DW <<Transmit the serial number as part of the info table. <<12/1/01; 11:37:52 AM by DW <<Transmit the full password to the cloud once so that the cloud can send it back to the user when he or she installs a new version of Radio. <<11/22/01; 8:24:44 PM by DW <<Transmit the value of user.radio.prefs.flBehindFirewall to the cloud so it can percolate to P2P apps such as myWorkgroup.root. <<11/22/01; 6:50:51 PM by DW <<Save cloud data in user.radio.prefs.defaultCloudData. <<11/20/01; 3:45:15 AM by JES <<Changed user.radio.prefs.passwords.defaultXssPassword to user.radio.prefs.passwords.default. <<10/16/01; 11:14:32 AM by DW <<Created. Ping the cloud every five minutes, or when the user's IP address changes. if not tcp.isOffline () { local (flping = false, minutesBetweenPings = 5); if defined (radio.data.myCommunity.minutesBetweenPings) { minutesBetweenPings = radio.data.myCommunity.minutesBetweenPings}; if clock.timerExpired (this, 60 * minutesBetweenPings) { flping = true} else { //ping if IP address changed local (myaddress = tcp.myAddress ()); if not defined (system.temp.radio.misc.lastTcpAddress) { system.temp.radio.misc.lastTcpAddress = 0}; if system.temp.radio.misc.lastTcpAddress != myaddress { system.temp.radio.misc.lastTcpAddress = myaddress; flping = true}}; if flping { local (adrblog = radio.weblog.init ()); local (info, clouddata); bundle { //set up the info table new (tabletype, @info); info.flBehindFirewall = user.radio.prefs.flBehindFirewall; info.serialNumber = user.radio.prefs.serialNumber; info.name = user.prefs.name; info.email = user.prefs.mailAddress; info.organization = user.prefs.organization; bundle { //add the weblog title and commentsPageUrl to the info table info.weblogTitle = adrblog^.prefs.title; info.commentsPageUrl = adrblog^.prefs.commentsPageUrl; info.trackbackPageUrl = adrblog^.prefs.trackback.trackbackPageUrl}; bundle { //add the home page url to the info table local (adrfolder = @user.radio.settings.files.[user.radio.prefs.upstream.folder]); if adrfolder^.upstream.url != "" { info.url = adrfolder^.upstream.url}}; if not user.radio.settings.flPasswordStoredInCloud { info.passwordFull = string (user.radio.prefs.passwords.default)}}; bundle { //set up the clouddata table <<bundle //code broken for FTP users <<new (tableType, @clouddata) <<local (fupstream = user.radio.prefs.wwwFolder + radio.data.filenames.upstreamFileName) <<local (adrfile, adrspec) <<radio.file.getFileAttributes (fupstream, @adrfile) <<radio.upstream.getUpstreamSpec (adrfile, @adrspec) <<clouddata.server = adrspec^.server <<clouddata.port = adrspec^.port <<clouddata.rpcPath = adrspec^.rpcPath <<clouddata.protocol = adrspec^.protocol <<clouddata.soapAction = adrspec^.soapAction clouddata = user.radio.prefs.defaultCloud; clouddata.fldebug = false}; if xmlStorageSystem.ping (user.radio.prefs.usernum, user.radio.prefs.passwords.default, 0, @info, @clouddata, adrclouddata:@user.radio.prefs.defaultCloudData) { if not user.radio.settings.flPasswordStoredInCloud { user.radio.settings.flPasswordStoredInCloud = true}}; bundle { //get server capabilities, 2/7/02; 12:33:20 PM by DW local (adrserverinfo = @user.radio.prefs.upstream.servers.[user.radio.prefs.defaultCloud.server]); if not defined (adrserverinfo^) { new (tabletype, adrserverinfo)}; local (adrcapabilities = @adrserverinfo^.serverCapabilities); xmlStorageSystem.getServerCapabilities (user.radio.prefs.usernum, user.radio.prefs.passwords.default, adrcapabilities, adrdata:@clouddata, flMessages:false); adrserverinfo^.timeLastServerCapabilities = clock.now (); bundle { //copy urls from the server to their proper locations if defined (adrcapabilities^.urlRankingsByPageReads) { radio.data.cloudUrls.rankings = adrcapabilities^.urlRankingsByPageReads}; if defined (adrcapabilities^.urlReferers) { radio.data.cloudUrls.referers = adrcapabilities^.urlReferers}; if defined (adrcapabilities^.webBugUrl) { radio.data.staticSiteStats.imgUrl = adrcapabilities^.webBugUrl}; if defined (adrcapabilities^.urlSpamFreeMailto) { radio.data.cloudUrls.spamFreeMailto = adrcapabilities^.urlSpamFreeMailto}; if defined (adrcapabilities^.urlWeblogUpdates) { radio.data.cloudUrls.weblogUpdates = adrcapabilities^.urlWeblogUpdates}; if defined (adrcapabilities^.weblogUpdates) { user.radio.prefs.weblogUpdates.protocol = adrcapabilities^.weblogUpdates.protocol; user.radio.prefs.weblogUpdates.server = adrcapabilities^.weblogUpdates.server; user.radio.prefs.weblogUpdates.port = adrcapabilities^.weblogUpdates.port; user.radio.prefs.weblogUpdates.rpcPath = adrcapabilities^.weblogUpdates.rpcPath}; if defined (adrcapabilities^.staticUrls) { local (adrWeblogsComData = weblogsCom.init ()); if defined (adrcapabilities^.staticUrls.weblogUpdates) { if defined (adrcapabilities^.staticUrls.weblogUpdates.changesXml) { adrWeblogsComData^.prefs.changesUrl = adrcapabilities^.staticUrls.weblogUpdates.changesXml}}; if defined (adrcapabilities^.staticUrls.rssHotlist) { if defined (adrcapabilities^.staticUrls.rssHotlist.hotlistOpml) { radio.data.cloudUrls.hotlistOpml = adrcapabilities^.staticUrls.rssHotlist.hotlistOpml}}}; if defined (adrcapabilities^.urlViewDirectory) { radio.data.cloudUrls.viewDirectoryUrl = adrcapabilities^.urlViewDirectory}; if defined (adrcapabilities^.urlStore) { radio.data.cloudUrls.store = adrcapabilities^.urlStore}}; bundle { //copy community info to radio.data.myCommunity if defined (adrcapabilities^.community) { radio.data.myCommunity.name = adrcapabilities^.community.name; radio.data.myCommunity.domainName = adrcapabilities^.community.domainName; radio.data.myCommunity.flPublic = adrcapabilities^.community.flPublic; radio.data.myCommunity.flCanHostComments = adrcapabilities^.community.flCanHostComments; if defined (adrcapabilities^.community.flCanHostTrackback) { radio.data.myCommunity.flCanHostTrackback = adrcapabilities^.community.flCanHostTrackback} else { radio.data.myCommunity.flCanHostTrackback = false}; if defined (adrcapabilities^.community.flHasSearch) { radio.data.myCommunity.flHasSearch = adrcapabilities^.community.flHasSearch; radio.data.myCommunity.searchPageUrl = adrcapabilities^.community.urlSearch} else { radio.data.myCommunity.flHasSearch = false; radio.data.myCommunity.searchPageUrl = ""}; radio.data.systemUrls.discussionGroup = adrcapabilities^.community.discussionGroupUrl; radio.data.systemUrls.mailList = adrcapabilities^.community.mailListUrl}}; if defined (adrcapabilities^.minutesBetweenPings) { radio.data.myCommunity.minutesBetweenPings = adrcapabilities^.minutesBetweenPings}; if defined (adrcapabilities^.urlThemesDirectoryOpml) { radio.data.cloudUrls.themesDirectoryOpml = adrcapabilities^.urlThemesDirectoryOpml}}; bundle { //send comment notification prefs local (flSaveCommentPrefs = false); bundle { //set flSaveCommentPrefs -- save once every 24 hours if not defined (user.radio.stats.whenLastCommentPrefsSave) { user.radio.stats.whenLastCommentPrefsSave = date (0)}; local (whenToSave = user.radio.stats.whenLastCommentPrefsSave + (24 * 3600) ); if clock.now () >= whenToSave { flSaveCommentPrefs = true}}; if flSaveCommentPrefs { try { //only try once per 24 hours user.radio.stats.whenLastCommentPrefsSave = clock.now (); local (adrfolder); if radio.file.getFileAttributes (user.radio.prefs.wwwFolder, @adrfolder) { local (adrspec); if radio.upstream.getUpstreamSpec (adrfolder, @adrspec) { local (server, port, path, method, sitename, data); bundle { //get comment server RPC info local (xtext = tcp.httpReadUrl (adrblog^.prefs.commentsPageUrl + "?c=getRpcInfo")); local (xstruct); xml.compile (xtext, @xstruct); local (adrRpcInfo = xml.getAddress (@xstruct, "rpcInfo")); server = xml.getValue (adrRpcInfo, "server"); port = number (xml.getValue (adrRpcInfo, "port")); path = xml.getValue (adrRpcInfo, "path"); method = xml.getValue (adrRpcInfo, "methodName"); sitename = xml.getValue (adrRpcInfo, "siteName")}; bundle { //set up prefs table new (tableType, @data); new (tableType, @data.prefs); data.prefs.flNotifyNewComments = adrblog^.prefs.flCommentNotificationEnabled; data.prefs.sendNotificationTo = adrblog^.prefs.authorMailAddress; new (tableType, @data.communityServer); data.communityServer.server = adrspec^.server; data.communityServer.port = adrspec^.port; data.communityServer.methodName = "xmlStorageSystem.validateUser"; data.communityServer.rpcPath = adrspec^.rpcPath}; bundle { //make the RPC call to set the prefs local (password = string.hashMd5 (string (user.radio.prefs.passwords.[adrspec^.passwordName])) ); local (params = {sitename, adrspec^.usernum, password, data}); xml.rpc (server, port, method, @params)}}}}}}}}} //returns false if there's an error <<bundle //test code <<system.temp.timers.[this] = date (0) <<pingCloud ()
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.