Open AIM: How to register a plugin command

Hello again. I am back. Today I am starting a new series of posts on Open AIM. For this first post, I will start by introducing a handy little function similar to the one I wrote for my plug-ins that makes it easy to register commands that your plug-in will handle.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// The following code is public domain. Written by Gus Verdun
static void RegisterPluginCommand(IAccPluginInfo * pluginInfo, 
                                               int id, UINT flags, 
                                               LPCWSTR pCommand)
{
    CComPtr <IAccCommand> spCommand;
    pluginInfo->AddCommand(id, &spCommand);
    if (spCommand)
    {
        CComBSTR str(pCommand);
        put_Text(spCommand, str);
        put_Flags(spCommand, (AccCommandFlags)flags);
    }
}

I normally call this function from the IAccPlugin::Init method, but you can call it at any time you want to add a command. The first parameter is the IAccPluginInfo interface pointer that is passed to you on the Init() call. The second parameter is the command identifier that is assigned by you and handled in your plugin’s IAccCommandTarget methods. The third parameter, flags, are the AccCommandFlags that let you indicate where you want this command to appear in the UI. Finally, the fourth parameter is the actual text that will be displayed in the client’s UI.

Here is a simple example to define a command that will show only in the plug-in settings page.

RegisterPluginCommand(pPluginInfo, -1, 
     AccCommandFlags_PreferencesUi, 
     OLESTR("Settings...") );

For localization purposes, you can easily change this function to load the command string from a resource. I will leave that as an exercise for you to try.

Hope this helps. Comments? Questions?

3 Responses to “Open AIM: How to register a plugin command”

  1. Neo Says:

    Hey Gus,
    It keeps saying “?’s offline IM storage is full.” for my friend.
    How do you get it empty? Could you help?
    Thanks in advance!

  2. Beth Says:

    I am having this problem where I hear this ONE buddy sound (happens to be a sound a friend that is on my buddylist uses).. but when I hear the sound - no one that uses that sound is showing at ALL on my buddylist. What is this problem and how do I fix this?

  3. Integer Originator Says:

    Beth Says:

    December 29th, 2007 at 8:08 am
    I am having this problem where I hear this ONE buddy sound (happens to be a sound a friend that is on my buddylist uses).. but when I hear the sound - no one that uses that sound is showing at ALL on my buddylist. What is this problem and how do I fix this?
    ———————
    me 2!
    !!

Leave a Reply

Powered by WP Hashcash