Help starting out with a new Notification Plugin

Writing and using PopTray plug-ins

Moderators: KY Dave, jojobear99, Rdsok

Locked
AlexV
Still here
Posts: 7
Joined: Wed Mar 09, 2005 4:05 pm

Help starting out with a new Notification Plugin

Post by AlexV » Fri Mar 11, 2005 9:34 pm

Hello all!

I want to start work on a notification plugin, but I could use some help kicking off, and I was hoping here would be the place to ask.

First off, a bit about the plugin I want to write: the idea is for a very simple notification plugin that will simply report the number of emails (as displayed on the taskpane icon) to an external LCD display, using LCD Smartie. I will work out how to communicate to that either as or through a separate plugin later, first I want to get notifications from PopTray working properly.

OK, some info about me, now: I am a competent VB and C# developer, but have only rudimentary knowledge of C++. I have no knowledge of Delphi.

So, what I am looking for is a start for a Notification plugin in C++, as neither VB nor C# will be capable of producing the DLL with export functions that is required to be a plugin. I have tried the C++ framework download, but I couldn't get it to work for notifications. Is there some sort of stripped down basic notification plugin code that I could use available anywhere?

Something like the KeyboardLights plugin in C++ would be perfect, looking at the source to that it seemed simple to start from. Unfortunately I don't have a copy of Delphi, or I would have used that and started from KeyboardLights instead!

Any help getting started with this would be greatly appreciated. I think once I can get something that I can compile that will, for example, pop up a message box displaying the message count every time it changes, I will be in a good position to get communication with LCD Smartie working.

Thanks,

Alex

User avatar
jskinner
Groupie
Posts: 55
Joined: Wed Mar 09, 2005 9:25 pm
Contact:

Post by jskinner » Fri Mar 11, 2005 10:18 pm

There is a fully compiling skeleton version of a plugin in the SDK. The only think that you need to do is switch it from a protocol type to the notification type (one line change) It should be everthing you need to get started.

Cheers, -James

AlexV
Still here
Posts: 7
Joined: Wed Mar 09, 2005 4:05 pm

Post by AlexV » Fri Mar 11, 2005 11:01 pm

Is that the C++_Plugin_Framework_2.0.zip one?

I tried that, and while it would compile as downloaded, it wasn't behaving as a notification plugin.

I found the line which appeared to be setting the plugin type to Protocol and changed it to Notify, which unfortunately prevented the project from compiling. It seems there is a function called Notify which clashes with the name of the enum value. I tried renaming the enum values to PluginType_Notify, etc. then using that, which let the project compile, but it still did not appear to recieve any notifications, or at least did not put any in the log file (which reading the code, I expected it to).

User avatar
jskinner
Groupie
Posts: 55
Joined: Wed Mar 09, 2005 9:25 pm
Contact:

Post by jskinner » Fri Mar 11, 2005 11:08 pm

The only thing you need to do is to change the return code of the function TPlugin::PluginType()

Switch it to 'return piNotify;' rather than 'return piProtocol;'

It compiles fine for me.

Cheers, -james

AlexV
Still here
Posts: 7
Joined: Wed Mar 09, 2005 4:05 pm

Post by AlexV » Fri Mar 11, 2005 11:32 pm

I think we must be looking at different code... there is no TPlugin::PluginType() in the code I am looking at. What I have is:

Code: Select all

int Poptray_Plugin::PluginType()
{
	_bstr_t bsLog;
	char sTemp[20];

	bsLog  = "- PluginType [";
	bsLog += itoa(g_iPluginType, sTemp, 10);
	bsLog += "]";
	g_pTools->LogWrite( bsLog );

	return g_iPluginType;
}
and earlier, in the constructor for PopTray_Plugin:

Code: Select all

	// Set PluginType (Notify, Protocol or RuleAction)
	g_iPluginType = Protocol;
It was that line that I had tried changing.

This is in the file "PopTrayPlugin.cpp" from the zip file "C++_Plugin_Framework_2.0.zip". Am I looking in the wrong place?

User avatar
jskinner
Groupie
Posts: 55
Joined: Wed Mar 09, 2005 9:25 pm
Contact:

Post by jskinner » Sat Mar 12, 2005 4:55 am

That appears to be an old version of the API (not sure why its still avaliable) I belive you want PopTray_Plug-in_SDK-02.2004.nov.01.zip

Cheers, -james

AlexV
Still here
Posts: 7
Joined: Wed Mar 09, 2005 4:05 pm

Post by AlexV » Sat Mar 12, 2005 11:16 am

Aah, that would explain it, thanks!

I've decided the best way to communicate between the two plugins (the one for PopTray and the one for LCD Smartie) would be through the registry, which leaves it nice and generic in case I want to plug anything else to read pop tray info, or use the LCD Smartie plugin to read info from any other source.

So this plugin writes out the new mail stats to HKEY_CURRENT_USER\Software\PopTray\Status (and sub folders for each account), which is then available for the LCD Smartie plugin (coming soon) to read.

This is very much hack-quality code, but if anyone wants it, or wants to take it further, I've made it available from http://www.byalexv.co.uk/RegistryWriter.zip

Thanks for the help!

AlexV
Still here
Posts: 7
Joined: Wed Mar 09, 2005 4:05 pm

Post by AlexV » Sat Mar 12, 2005 1:52 pm

Oh, one more thing, while I remember. I think there may be a typo in the SDK, in the file plugin.h, line 76:

Code: Select all

if (seconds > 0) return NULL;
should probably be

Code: Select all

if (seconds < 0) return NULL;
otherwise it doesn't return converted times for me.

Locked

Who is online

Users browsing this forum: No registered users and 3 guests