Last year AOL released AIM 6.8 which is the first version of AIM to support plugins written in HTML and JavaScript. These plugins are called AIM Modules. They are a zip file that contains the plugin’s manifest, content, and code with a .amo extension. NOTE: a.m.o (addons.mozilla.org) and AMO plugins are not related.
A complete introduction to AMOs is beyond the scope of this post. You can read more about the AIM Module Plugin API on the AIM Developer web site. I have written a few of these plugins under the AMO Factory brand.
In my previous post, I demonstrated how to read a preference via C++. Here is a sample that accomplishes the same in JavaScript.
// Make a shorter name for this. See the AMO API for docs on this class client = window.external.client; // Get the primary IAccSession object. // (primary is the first account that signs on.) session = client.primarySession; // Get the IAccPreferences object for this session prefs = session.prefs; // See the IAccPreferences API function safeGetPref(spec, default) { try { // method names of AIMcc objects are not case sensitive. return prefs.GetValue(spec); } catch (e) {} return default; } function canDisclosePluginsToBuddyFeed() { return safeGetPref("aimcc.privacy.disclosePluginsToBuddyFeed", false); } if (canDisclosePluginsToBuddyFeed()) { alert('preference is true'); }
I recommend that you use try/catch blocks around AIMcc method calls since they can return COM error results that throw exceptions in JavaScript. The safeGetPref() function takes care of this and returns the default value if AIMcc returns any error.
TIP: The e.number property in the catch block has the HRESULT as a negative number. You can find the symbolic name for this error via the Symbol Lookup dialog in my CoreWitness plugin. Just enter the number in the find box to do the reverse lookup.
Tags: AIMcc, AMO, buddy feed, IAccPreferences, JavaScript, Open AIM, preferences, Sample Code, Tips