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

system.verbs.builtins.radio.thread.agents.startup

<<Changes
	<<12/22/02; 1:00:32 PM by JES
		<<Respect user.radio.prefs.flOpenHomePageAtStartup.
	<<7/31/02; 3:06:43 PM by JES
		<<Don't open the home page at startup when offline.
	<<5/29/02; 6:22:54 PM by DW
		<<Redirect partner urls that changed. Here's why. Infoworld is in our default set of feeds, so a lot of people subscribe. They just started their own feed, and asked NewsIsFree to turn off the one that Radio users are getting. So I started a table, radio.data.partnerUrls.redirects, with one item in it, that maps old urls to new ones. For certain important feeds that disappear, we'll now have a way to redirect them without bothering users.
	<<1/22/02; 8:18:53 PM by JES
		<<Call radio.userInterface.saveImages to make sure all system image files have been installed.
	<<1/3/02; 12:26:42 PM by DW
		<<Empty the Logs folder on startup.
	<<1/2/02; 7:59:47 PM by DW
		<<Nuke the Tutorial Files folder.
	<<1/2/02; 7:43:45 PM by DW
		<<If Guest Databases folder is empty, delete it.
	<<12/4/01; 12:53:21 PM by DW
		<<Remove code that scans at startup. It now does the scan in xml.aggregator.everyMinute.
	<<12/3/01; 7:56:35 PM by DW
		<<Empty the aggregator trash at startup.
	<<12/2/01; 1:45:53 AM by JES
		<<Respect offline status.
	<<11/30/01; 1:56:14 PM by DW
		<<If the feature is enabled, do a News Aggregator scan at startup time.
	<<11/1/01; 6:51:24 PM by JES
		<<Created. Do things that happen at startup: Open the desktop website.
if not defined (system.temp.radio.flStarted) {
	system.temp.radio.flStarted = false;
	bundle { //make sure image files all exist
		radio.userInterface.saveImages ()};
	bundle { //open the initial page
		if not tcp.isOffline () {
			if defined (user.radio.prefs.usernum) { //open the home page
				if user.radio.prefs.flOpenHomePageAtStartup {
					radio.menuCommands.openPage (radio.data.systemUrls.homePage)}}
			else { //open the setup page
				radio.menuCommands.openPage (radio.data.systemUrls.setupRadio)}}};
	bundle { //empty the aggregator trash
		local (adrdata = xml.aggregator.init ());
		table.emptyTable (@adrdata^.trash)};
	bundle { //if the Guest Databases folder is empty, delete it
		try {
			local (folder = frontier.pathstring + "Guest Databases" + file.getpathchar ());
			if file.exists (folder) {
				local (f, flempty = true);
				fileloop (f in folder, infinity) {
					flempty = false;
					break};
				if flempty {
					try {file.deletefolder (folder)}}}}};
	bundle { //nuke the Tutorial Files folder
		try {
			local (folder = frontier.pathstring + "Tutorial Files" + file.getpathchar ());
			if file.exists (folder) {
				local (f);
				fileloop (f in folder) {
					file.delete (f)};
				file.deletefolder (folder)}}};
	bundle { //empty the Logs folder
		if user.radio.prefs.flEmptyLogsFolderOnStartup {
			local (folder = frontier.pathstring + "Logs" + file.getpathchar ());
			if file.exists (folder) {
				local (currentfile, f);
				bundle { //set currentfile
					local (day, month, year, hour, minute, second);
					date.get (clock.now (), @day, @month, @year, @hour, @minute, @second);
					month = string.padwithzeros (month, 2);
					day = string.padwithzeros (day, 2);
					currentfile = string.lower (folder + year + "-" + month + "-" + day + ".root")};
				fileloop (f in folder) {
					if string.lower (f) != currentfile {
						try {file.delete (f)}}}}}};
	bundle { //redirect partner urls that changed, 5/29/02 by DW
		local (adrdata = xml.aggregator.init (), adr, adrservice);
		for adr in @radio.data.partnerUrls.redirects {
			adrservice = @adrdata^.services.[nameof (adr^)];
			if defined (adrservice^) {
				try {
					table.rename (adrservice, adr^)}}}}}



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.