Posts Tagged ‘preferences’

CoreWitness 1.3.0

Monday, March 9th, 2009

CoreWitness Plug-inI just released an update to my CoreWitness plugin. This minor release adds the showing of the current preference value in the OnPreferenceChanged and OnPreferenceInvalid events. Here is a sample trace I get when I toggle all the check boxes in the privacy tab off, click apply, and then check them again and click save:

01:58.754 [gusblog  ] DAccEvents::OnPreferenceChange - 'aimcc.Privacy.DiscloseTypingStatus'
   new value = No
01:58.755 [gusblog  ] DAccEvents::OnPreferenceChange - 'aimcc.privacy.discloseBuddyFeed'
   new value = No
01:58.764 [gusblog  ] DAccEvents::OnPreferenceChange - 'aimcc.Privacy.DiscloseIdleTime'
   new value = No
01:58.777 [gusblog  ] DAccEvents::OnPreferenceChange - 'aimcc.privacy.disclosePluginsToBuddyFeed'
   new value = No
01:58.777 [gusblog  ] DAccEvents::OnPreferenceChange - 'aimcc.Privacy.DiscloseWireless'
   new value = No
02:03.859 [gusblog  ] DAccEvents::OnPreferenceChange - 'aimcc.Privacy.DiscloseTypingStatus'
   new value = Yes
02:03.860 [gusblog  ] DAccEvents::OnPreferenceChange - 'aimcc.privacy.discloseBuddyFeed'
   new value = Yes
02:03.868 [gusblog  ] DAccEvents::OnPreferenceChange - 'aimcc.Privacy.DiscloseIdleTime'
   new value = Yes
02:03.869 [gusblog  ] DAccEvents::OnPreferenceChange - 'aimcc.Privacy.DiscloseWireless'
   new value = Yes
02:03.869 [gusblog  ] DAccEvents::OnPreferenceChange - 'aimcc.privacy.disclosePluginsToBuddyFeed'
   new value = Yes

You can get the latest version here.

Please note that activation of the CoreWitness plugin is now automatic. No registration is needed.

This is a free plugin for Open AIM developers.

Reading an AIM SDK Preference via JavaScript

Thursday, January 15th, 2009

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.

Reading an AIM SDK Preference via C++

Wednesday, January 14th, 2009

The AIM SDK (AIMcc) has an interface called IAccPreferences that is used for reading and writing preferences. Preferences are associated with a session so they can only be accessed once you have an IAccSession object.

It is up to clients to implement the actual data store behind these preferences by registering an object that implements either IAccPreferencesHook or IAccPreferencesHook2. You can find more information about these interfaces in technote 3 of the AIM SDK.

In this two-part series I will provide some sample code for reading preferences. This first post provides an ATL/C++ example and my next post will provide a JavaScript example.

In the process of making easy to use sample code, I will need to create some helper classes. These classes will be part of an evolving distribution called AccEx which I am hereby placing in the public domain. I will start by distributing these as source files only until I have more classes. AccEx distributions will be available here.

For this post, I created a helper class in AccEx called CAccExPreferences in order to make it easy to read and write preferences in C++. This class has overloaded methods to help you read a preference in various native formats like bool, int, float, etc. and one method to write a preference from a CComVariant.

So let’s use this thing. Like I said above, the IAccPreferences interface is implemented by AIMcc and associated with the IAccSession since they are (mostly) per-user preferences. Therefore, the only thing you need to initialize a CAccExPreferences object is an IAccSession pointer. The class will take care of acquiring the IAccPreferences interface for you. Here is a simple use-case that reads a real AIMcc preference.

// This sample source is public domain
#include <stdafx.h>
#include "AccExPreferences.h"
 
static WCHAR kDisclosePluginsToBuddyFeed[] = 
    OLESTR("aimcc.privacy.disclosePluginsToBuddyFeed");
 
HRESULT CanDisclosePluginsToBuddyFeed(IAccSession *pIAccSession)
{
    bool enabled;
    AccEx::CAccExPreferences prefs(pIAccSession);
 
    if ( SUCCEEDED( 
            prefs.GetPref(kDisclosePluginsToBuddyFeed, enabled) 
         ) && enabled )
    {
        // preference is enabled.
        return S_OK;
    }
    return S_FALSE;
}

Stay tuned for my next post where I will do the same using JavaScript.

Tip on Finding Preferences in Open AIM

Tuesday, January 13th, 2009

Every now and then I have to look up a preference specifier in AIM in order to use it in a plugin.

For example, the other day I wanted to determine if the user has enabled the pushing of AIM Plugins to their buddy feed. I usually check in technote 10 on preferences in the AIM SDK technotes. However, you can also do this empirically in AIM with my CoreWitness plugin. All ‘aimcc.*’ preference changes will cause the OnPreferenceChanged event to fire on all listeners so you can simply make a change in the client to see what preference specifier is changing.

To make it easier, the latest version of my CoreWitness plugin lets you filter the messages being logged by pressing the * button in the title bar. To filter the log to just the OnPreferenceChanged event, open the filter dialog and proceed as follows. Click on the ‘clear all’ button and then start typing the word “preference” in the filter edit box until you see “OnPreferenceChange” appear in the list. Select this event and click OK. Here is a screen shot of this step:

DAccEvents Monitor Filter

After doing the above, I changed the ‘I have installed a new AIM Plugin’ check box in the privacy tab of AIM 6.9’s Settings and clicked apply. Here is a screen shot of my results:

As you can see the preference is called ‘aimcc.privacy.disclosePluginsToBuddyFeed’. Finding the preference specifier is only the beginning. I will cover how to read it in a future post.

NOTE: This will only work for aimcc.* preferences. So it is possible that you can make a change in the settings that does not get notified via OnPreferenceChange because it is internal to the client. Internal preferences are not available to pluigns at this time.