What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » Delphi Plugin Framework

Delphi Plugin Framework
Author: Message:
PsychoMark
Full Member
***

Avatar

Posts: 151
41 / – / –
Joined: Apr 2002
O.P. Delphi Plugin Framework
(sticky maybe?)

For anyone interested in writing Plus! plugins in Delphi, there has been the Delphi Template kindly provided by Whacko. However, while writing several plugins I noted the same pattern over and over again, and got tired of it. So today I wrote a framework for Delphi plugins, and I'm releasing it as open-source...

So what's so special about it? Well, here goes:

  • Full translation of the latest SDK C++ source, including some corrections over Whacko's version
  • Object Orientated way of writing plugins
  • Several wrapper functions for formatting your output, including smart TColor to Plus! color conversion


And what is missing:

  • Implementation of Unicode functions (due to a lack of experience in that area)



The way it's implemented you must create a class descending from TMPPlugin and call RegisterPlugin in the DLL's entry point (the default begin-end you get when creating a DLL project). Override the Initialize function, register your commands (including tags or notifications) and the framework will take over from there, adding your commands to the Plus! plugins menu, calling your callback functions when a command is found. Need more processing? Override the various Execute methods to tap into the processing since all functions are declared as virtual!

Didn't understand a word I was just saying? Not to worry, I've included a demo project showing a plugin with two commands, one tag and a notification.

The advantage of this framework is you no longer have to copy and paste all the code to keep it C++-compatible, the framework takes care of that. No worrying about exports, pointers, correct calling conventions or returning strings longer than the Plus! buffers can handle... all taken care of :)


Before I start to sound like a Tel-Sell comercial, I'll just attach the demo plugin, Plus! SDK conversion and framework. Hope it helps someone as much as it helps me :)




Any feedback, bugs, fixes or Unicode implementations are of course appreciated, what else did I open-source it for eh? :)

.zip File Attachment: DelphiMPPluginSDK.zip (103.28 KB)
This file has been downloaded 1700 time(s).

This post was edited on 05-24-2004 at 11:26 AM by PsychoMark.
02-19-2004 03:34 PM
Profile E-Mail PM Web Find Quote Report
PsychoMark
Full Member
***

Avatar

Posts: 151
41 / – / –
Joined: Apr 2002
O.P. RE: Delphi Plugin Framework
Updated the attachment with a newer version. One change in the code: fixed a bug with the menu leaving out the X and for tags even the (!...) part. The X is also no longer added automatically, so I updated the demo project as well to reflect that. The reason is simple: now you can just specify 'xdemo' as the command or tag, which turned out to be easier for the programmer because it resembles the actual command more...
02-19-2004 05:07 PM
Profile E-Mail PM Web Find Quote Report
tiojoca
Junior Member
**


Posts: 24
Joined: Feb 2004
RE: Delphi Plugin Framework

Hadn't had the chance to try it yet but the source code is looking good (y) ;)

[off-topic]like your cow avatar too :)[/off-topic]
02-19-2004 06:07 PM
Profile E-Mail PM Find Quote Report
PsychoMark
Full Member
***

Avatar

Posts: 151
41 / – / –
Joined: Apr 2002
O.P. RE: Delphi Plugin Framework
I replaced the attachment above with a new version, implemented the following changes:

  • Fixed ColorToPlus for RGB values, Plus! wants 3 digits per value
  • Messenger interface is passed in the Messenger property of the plugin now as IDispatch, so you're responsible for checking it's assigned and supports the IMessenger interface...
  • Added support for filters. Explanation below.


Filters

I've seen several people struggling with the fact that Plus! plugins can't output tags like (!IP). Well, they can, but Plus! won't parse 'em so you just get (!IP) in the message instead of the actual IP address. Although this may change in future versions of Plus!, I added filters to the framework to solve it until then. A filter is basically a function which needs to be registered, and gets called whenever the plugin generates output (tags, commands, notifications). These filters may do whatever they like to the output, in the case of the supplied filters I'm using it to emulate the Plus! tags such as (!IP), (!N) and (!FCx). As far as I know all but three tags are supported: (!CN), (!VER) and (!WAT). WAT can be added quite easily, CN hasn't been added because I noticed Patchou scrambled the contact's email addresses (which is good for preventing abuse of course, but bad for me, now I can't read the custom names :)).

The filters included have been split into various units. The way they're designed all you have to do to include the filter is add it to your project, they will register themselves. This makes it easy to exclude tags you don't need...

Because the Pos() function in Delphi is quite limited and StringReplace() is slow, I've used FastStrings for the filters. When you are not using the filters, it's not required to get FastStrings. If you do, FastStrings is easy to install, just dump the files in a directory and make sure that directory is in your library path (Tools -> Environment Options -> Library).


The demo project has also been updated with a /xtags command to show the use of filters.
02-22-2004 04:10 PM
Profile E-Mail PM Web Find Quote Report
quietbritishjim
New Member
*

Avatar

Posts: 6
– / Male / –
Joined: Jun 2003
RE: Delphi Plugin Framework
Looks good.  I've written quite a few trillian plugins in Delphi (see homepage) and I might just use this to create a couple for messenger plus :)  Will it be updated when ver 3 comes out?

Out of interest, why have you wrapped TMPPlugin in {$M} tags?  This compiler directive only effects classes with published properties and methods, and this class doesn't have any (and presumably its children won't either).

This post was edited on 05-22-2004 at 01:58 PM by quietbritishjim.
05-22-2004 01:55 PM
Profile E-Mail PM Web Find Quote Report
Whacko
Full Member
***

Avatar

Posts: 209
Reputation: 1
40 / Male / –
Joined: Apr 2002
RE: Delphi Plugin Framework
Looks nice :)

its been a while since i was here :)

its nice to see someone finally made another template :) i made mine in just a few hours as a proof of concept at the time. just so others could start making plugins too :)
I code in:
C
C++
Delphi
Visual Basic
Pascal :P
05-23-2004 12:23 PM
Profile PM Web Find Quote Report
PsychoMark
Full Member
***

Avatar

Posts: 151
41 / – / –
Joined: Apr 2002
O.P. RE: Delphi Plugin Framework
@quietbritishjim: yes, I will update it now Plus! 3 is out. Of course plugins are still compatible, with at least the Configure option added I know of... as for the rest, shouldn't take long to figure out, got Plus! 3 installed and loving it...

And as for the RTTI directives; I have no clue why they're there! Presumably I added those as part of some earlier tests which didn't work out... safe to remove 'em, none of the MPPlugin units use 'em...

@Whacko: yeah, used your template as a reference when I was having trouble with the menu items, good work on that earlier...
05-23-2004 07:03 PM
Profile E-Mail PM Web Find Quote Report
PsychoMark
Full Member
***

Avatar

Posts: 151
41 / – / –
Joined: Apr 2002
O.P. RE: Delphi Plugin Framework
And here's the update for Plus! 3, thanks to Patchou keeping it all compatible it was easy...


Changes

  • Added mp300 to TMPPlugin.Version
  • Added support for Configure function
  • Filters no longer required! MP3 parses the output of the plugin (even "/xdemo (!xdemo)" works, great job Patchou!). Still keeping the filters in, might come in handy (like WMPlus using it to parse it's custom tags for example :)), but the included filters are now basically useless :)
  • Demo plugin updated, and includes an InstallPlugin application to make installing the plugin while testing easier...


Enjoy!



Edit: attachment removed, instead I updated the attachment in the first post...

This post was edited on 05-24-2004 at 11:27 AM by PsychoMark.
05-24-2004 11:25 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On