Monday, November 08, 2010 at 12:07 AM.
system.verbs.builtins.xml.aggregator.subscribeService
on subscribeService (xmlUrl, adrerrorstring=nil, adradrservice=nil) {
<<Changes
<<10/18/03; 12:32:21 PM by JES
<<Dereference callback addresses inside a try block. Prevents errors which can occur if the table containing a callback script is no longer defined.
<<10/20/02; 10:48:50 AM by DW
<<When catching urlChanged, we must also set adrserviceredirected.
<<Also, recurse when redirecting, so we read the real data when first subscribing.
<<10/14/02; 9:04:03 AM by DW
<<Allow for the possibility that xml.aggregator.readService could change the address of the service table.
<<5/31/02; 5:12:20 PM by DW
<<If adrservice^.urlChanged is defined, rename the table. It's set in xml.rss.compileService.
<<http://frontier.userland.com/aggregatorAutoDiscovery
<<4/5/02; 4:36:08 PM by DW
<<Add support for callbacks.
<<12/9/01; 10:34:25 AM by DW
<<If the subscription worked, call xml.aggregator.updateSubscriptions to request notification if the channel has a cloud element.
<<12/8/01; 12:18:52 PM by DW
<<This code hasn't been reviewed in a long time.
<<If there was an error subscribing to the service, and if it's new, delete the table. This code was commented.
<<Added optional parameter for returning adrservice, so the caller can provide a meaningful confirmation message for the user.
local (adrdata = xml.aggregator.init ());
local (adrservices = @adrdata^.services);
local (adrservice = @adrservices^.[xmlUrl]);
local (flnew = not defined (adrservice^));
local (adrserviceredirected);
xml.aggregator.readService (xmlUrl, adrservices, @adrserviceredirected); //10/14/02 DW
if defined (adrservice^.error) {
if adrerrorstring != nil {
adrerrorstring^ = adrservice^.error};
if flnew {
delete (adrservice)};
return (false)};
bundle { //check for existence of urlChanged in the service table, 5/31/02 by DW
if defined (adrservice^.urlChanged) {
local (urlChanged = adrservice^.urlChanged);
adrservicenew = @adrservices^.[urlChanged];
if defined (adrservicenew^) { //the user is already subscribed to this service
if adrerrorstring != nil {
adrerrorstring^ = "Hey, don't bother checking the URL. You are already subscribed to this feed. Why would you want to subscribe to it twice? ;->"};
if flnew {
delete (adrservice)};
return (false)};
table.rename (adrservice, urlChanged);
adrservice = adrservicenew;
adrserviceredirected = adrservicenew; //10/20/02; 10:35:30 AM by DW
delete (@adrservice^.urlChanged);
return (xml.aggregator.subscribeService (urlChanged, adrerrorstring, adradrservice))}}; //10/20/02 by DW
xml.aggregator.clearCache ();
xml.aggregator.updateSubscriptions ();
adrdata^.settings.flSubscriptionsChanged = true;
if adradrservice != nil {
adradrservice^ = adrserviceredirected}; //10/14/02 DW
try { //run the callbacks
local (adrscript);
for adrscript in @adrdata^.callbacks.subscribeService {
try { //JES 10/18/03: Prevent errors when dereferencing callback addresses
while typeof (adrscript^) == addresstype {
adrscript = adrscript^};
try {adrscript^ (nameof (adrservice^), adrservice)}}}};
return (true)}
<<bundle //test code
<<local (url = "http://philringnalda.com/scratchpad/redir.php")
<<url = "http://bitworking.org/rss.xml"
<<local (errorstring)
<<if not subscribeService (url, @errorstring)
<<dialog.alert (errorstring)
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.