Monday, November 08, 2010 at 12:05 AM.

on pingCloud () {
		<<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 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 under the else block with the comment "connect existing user".
		<<8/31/02; 2:19:48 AM by JES
			<<Update 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 table.
		<<8/30/02; 12:15:51 AM by JES
			<<Respect, 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 to its value.
			<<5/15/02; 3:18:43 PM by JES
				<<If the getServerCapabilities return struct contains urlViewDirectory, set 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, patch their values.
			<<3/7/02; 11:13:45 AM by JES
				<<Get the cloud info table from, 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
			<<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 = (), flping = false)
						<<bundle //make sure system values are initialized
							<<if not defined (
								<< = date (0)
							<<if not defined (
								<< = 0
						<<if (now - >= (5 * 60)
							<<flping = true
							<< = now
						<<if != tcp.myAddress ()
							<<flping = true
							<< = tcp.myAddress ()
						<<if flping
							<<local (usernum =
							<<local (password =
							<<local (info)
							<<bundle //set up the info table
								<<new (tabletype, @info)
								<<info.flBehindFirewall =
								<<info.serialNumber =
								<< =
								<< = user.prefs.mailAddress
								<<info.organization = user.prefs.organization
								<<bundle //add the home page url to the info table
									<<local (usernumstring = string.padwithzeros (, 7))
									<<local (homeurl = "" + usernumstring + "/")
									<<bundle //calculate homeurl
										<<local (upstreamSpecPath = +
										<<if file.exists (upstreamSpecPath)
											<<local (adrfile, adrspec)
											<<if radio.file.getFileAttributes (upstreamSpecPath, @adrfile)
												<<if radio.upstream.getUpstreamSpec (adrfile, @adrspec)
													<<case string.lower (adrspec^.type)
															<<local (adrcapabilities =[adrspec^.server])
															<<if not defined (adrcapabilities^)
																<<radio.upstream.getServerCapabilities (adrspec)
															<<homeurl = adrcapabilities^.serverCapabilities.yourUpstreamFolderUrl
															<<homeurl = adrspec^.url
									<<local (adrfolder =[])
									<<if adrfolder^.upstream.url != ""
										<<homeurl = adrfolder^.upstream.url
									<<info.url = homeurl
									<<info.organization = user.prefs.organization
								<<if not
									<<info.passwordFull = string (
							<<if (usernum, password, 0, @info,,
								<<if not
									<< = true
							<<bundle //get server capabilities, 2/7/02; 12:33:20 PM by DW
								<<local (adrserverinfo =[])
								<<local (adrcapabilities = @adrserverinfo^.serverCapabilities)
								<<xmlStorageSystem.getServerCapabilities (usernum, password, adrcapabilities,, flMessages:false)
			<<2/25/02; 1:42:53 PM by JES
				<<Get the server information from the usptream spec, instead of from
			<<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 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
			<<11/20/01; 3:45:15 AM by JES
				<<Changed to
			<<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 ( {
			minutesBetweenPings =};
		if clock.timerExpired (this, 60 * minutesBetweenPings) {
			flping = true}
		else { //ping if IP address changed
			local (myaddress = tcp.myAddress ());
			if not defined ( { = 0};
			if != myaddress { = myaddress;
				flping = true}};
		if flping {
			local (adrblog = radio.weblog.init ());
			local (info, clouddata);
			bundle { //set up the info table
				new (tabletype, @info);
				info.flBehindFirewall =;
				info.serialNumber =; =; = 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 =[]);
					if adrfolder^.upstream.url != "" {
						info.url = adrfolder^.upstream.url}};
				if not {
					info.passwordFull = string (}};
			bundle { //set up the clouddata table
				<<bundle //code broken for FTP users
					<<new (tableType, @clouddata)
					<<local (fupstream = +
					<<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 =;
				clouddata.fldebug = false};
			if (,, 0, @info, @clouddata, {
				if not { = true}};
			bundle { //get server capabilities, 2/7/02; 12:33:20 PM by DW
				local (adrserverinfo =[]);
				if not defined (adrserverinfo^) {
					new (tabletype, adrserverinfo)};
				local (adrcapabilities = @adrserverinfo^.serverCapabilities);
				xmlStorageSystem.getServerCapabilities (,, adrcapabilities, adrdata:@clouddata, flMessages:false);
				adrserverinfo^.timeLastServerCapabilities = ();
				bundle { //copy urls from the server to their proper locations
					if defined (adrcapabilities^.urlRankingsByPageReads) { = adrcapabilities^.urlRankingsByPageReads};
					if defined (adrcapabilities^.urlReferers) { = adrcapabilities^.urlReferers};
					if defined (adrcapabilities^.webBugUrl) { = adrcapabilities^.webBugUrl};
					if defined (adrcapabilities^.urlSpamFreeMailto) { = adrcapabilities^.urlSpamFreeMailto};
					if defined (adrcapabilities^.urlWeblogUpdates) { = adrcapabilities^.urlWeblogUpdates};
					if defined (adrcapabilities^.weblogUpdates) { = adrcapabilities^.weblogUpdates.protocol; = adrcapabilities^.weblogUpdates.server; = adrcapabilities^.weblogUpdates.port; = 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) { = adrcapabilities^.staticUrls.rssHotlist.hotlistOpml}}};
					if defined (adrcapabilities^.urlViewDirectory) { = adrcapabilities^.urlViewDirectory};
					if defined (adrcapabilities^.urlStore) { = adrcapabilities^.urlStore}};
				bundle { //copy community info to
					if defined (adrcapabilities^.community) { = adrcapabilities^; = adrcapabilities^.community.domainName; = adrcapabilities^.community.flPublic; = adrcapabilities^.community.flCanHostComments;
						if defined (adrcapabilities^.community.flCanHostTrackback) { = adrcapabilities^.community.flCanHostTrackback}
						else { = false};
						if defined (adrcapabilities^.community.flHasSearch) { = adrcapabilities^.community.flHasSearch; = adrcapabilities^.community.urlSearch}
						else { = false; = ""}; = adrcapabilities^.community.discussionGroupUrl; = adrcapabilities^.community.mailListUrl}};
				if defined (adrcapabilities^.minutesBetweenPings) { = adrcapabilities^.minutesBetweenPings};
				if defined (adrcapabilities^.urlThemesDirectoryOpml) { = adrcapabilities^.urlThemesDirectoryOpml}};
			bundle { //send comment notification prefs
				local (flSaveCommentPrefs = false);
				bundle { //set flSaveCommentPrefs -- save once every 24 hours
					if not defined ( { = date (0)};
					local (whenToSave = + (24 * 3600) );
					if () >= whenToSave {
						flSaveCommentPrefs = true}};
				if flSaveCommentPrefs {
					try { //only try once per 24 hours = ();
						local (adrfolder);
						if radio.file.getFileAttributes (, @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 ([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.