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

system.verbs.builtins.radio.thread.agents.trialVersion

<<Changes
	<<12/21/02; 3:25:12 PM by JES
		<<Added support for serial number renewals.
	<<12/2/01; 7:22:19 PM by JES
		<<Clear the menu bar if user.radio.prefs.flExpired is true. Close all windows. Minimize to system-tray (Windows) or hide the app (MacOS). When user.radio.prefs.flExpired changes back to true, rebuild the menubar, and open the About window if user.prefs.openAboutWindow is true.
	<<12/2/01; 8:45:27 AM by DW
		<<Created. 
bundle { //trial checks
	if user.radio.settings.flTrialVersion {
		if (clock.now () - user.radio.settings.whenInstalled) > (30 * 24 * 60 * 60) {
			if not user.radio.settings.flExpired {
				radio.menuCommands.openPage (radio.data.systemUrls.serialNumber);
				temp.radio.misc.flWasExpired = true;
				user.radio.settings.flExpired = true}}};
	if user.radio.settings.flExpired { //disable UI elements if flExpired is true
		temp.radio.misc.flWasExpired = true;
		on closeIt (adr) {
			if defined (adr^) {
				if table.getRootAddress (adr) == adr { //hide the window
					window.hide (adr);
					return (true)}};
			try {
				window.close (adr)}};
		window.visit (@closeIt);
		if defined (Frontier.hideApplication) {
			Frontier.hideApplication ()};
		menu.clearMenuBar ()}
	else { //restore UI elements if flExpired is false
		local (flRestoreUi = false);
		if not user.radio.settings.flTrialVersion {
			if defined (temp.radio.misc.flWasExpired) {
				if temp.radio.misc.flWasExpired {
					flRestoreUi = true}};
			if not menu.isInstalled (@Frontier.tools.menu) {
				flRestoreUi = true}};
		if flRestoreUi {
			menu.noSuite ();
			if user.prefs.openAboutWindow {
				window.about ()};
			temp.radio.misc.flWasExpired = false}}};
bundle { //get SN expiration date
	local (sn = string.upper (user.radio.prefs.serialNumber));
	local (domain = "superhonker.userland.com");
	if sizeof (sn) > 0 { //the user has entered a serial number
		if userland.isValidSerialNumber (sn) { //and it's valid
			if not defined (user.radio.settings.currentSerialNumber) { //remember it in case they change it
				user.radio.settings.currentSerialNumber = sn};
			if user.radio.settings.currentSerialNumber != sn { //user has entered a new serial number, clear exp date
				if defined (user.radio.settings.whenSNExpires) {
					delete (@user.radio.settings.whenSNExpires)};
				user.radio.settings.currentSerialNumber = sn};
			local (now = clock.now ());
			if not defined (user.radio.settings.whenSNExpires) { //call userland and get the expiration date
				on getExpirationDateFromUserLand (adrExpDate) {
					try {
						local (params = {sn}, whenExpires);
						whenExpires = xml.rpc (domain, 80, "digitalRiver.whenSerialNumberExpires", @params, rpcPath:"/RPC2", flShowMessages:false);
						adrExpDate^ = number (whenExpires);
						return (true)};
					return (false)};
				if defined (user.radio.settings.whenToGetSNExpireDate) { //we only try once every 3 days
					if user.radio.settings.whenToGetSNExpireDate <= now {
						if getExpirationDateFromUserLand (@user.radio.settings.whenSNExpires) { //true == success
							if defined (user.radio.settings.whenToGetSNExpireDate) { //no need for this once we have a date
								delete (@user.radio.settings.whenToGetSNExpireDate)}}
						else { //there was an error -- try again in 3 days
							while user.radio.settings.whenToGetSNExpireDate <= now {
								user.radio.settings.whenToGetSNExpireDate = user.radio.settings.whenToGetSNExpireDate + (60 * 60 * 24 * 3)}}}} //3 days
				else { //schedule a call to userland to get the expiration date at midnight on one of the next 3 days
					if not defined (user.radio.settings.whenSNExpires) {
						local (day, month, year, hour, minute, second);
						local (randomday = (60 * 60 * 24 * random (0, 2)));
						date.get (now + randomday, @day, @month, @year, @hour, @minute, @second);
						user.radio.settings.whenToGetSNExpireDate = date.set (day, month, year, 0, 0, 0)}}}}}}



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.