What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » Q. for Patchou: thread-safety in plugins

Q. for Patchou: thread-safety in plugins
Author: Message:
PsychoMark
Full Member
***

Avatar

Posts: 151
40 / – / –
Joined: Apr 2002
O.P. Q. for Patchou: thread-safety in plugins
This is a question for Patchou (or anyone who has a good knowledge of the internal workings of Plus)... in what way are plugins called? Specifically, do I need to take synchronization into account?

The reason I ask is because I need a global variable in my plugin. My plugin is written in Delphi, thus follows the C rules. I can declare a variable which'll work throughout the DLL, but if the plugins are called in a seperate thread it could in very rare situations lead to a horrible crash... in this case I'd either use a memory mapped file or protect the data using a critical section...


Information on which functions are called in which contexts would be nice. For example; between two calls, are we still in the same thread or is a new one created?


Thanks in advance!
10-02-2003 11:38 AM
Profile E-Mail PM Web Find Quote Report
Whacko
Full Member
***

Avatar

Posts: 209
Reputation: 1
40 / Male / –
Joined: Apr 2002
RE: Q. for Patchou: thread-safety in plugins
As far as i know the plugins are loaded in the main thread. in an earlier version of Plus! the Initialize() function was called in a seperate thread, but this didnt work right, cos after Initialize was done everything dynamically created in there (forms etc) were free'd automatically :P so since a few versions, evrything is called in the mainthread again :P

btw Nice to see a fellow Delphi coder in here ;)

I also made a plugin template for delphi, its posted here on the forum :P
I code in:
C
C++
Delphi
Visual Basic
Pascal :P
10-02-2003 02:18 PM
Profile PM Web Find Quote Report
Whacko
Full Member
***

Avatar

Posts: 209
Reputation: 1
40 / Male / –
Joined: Apr 2002
RE: Q. for Patchou: thread-safety in plugins
the template is a bit messy, i must confess :P
I code in:
C
C++
Delphi
Visual Basic
Pascal :P
10-02-2003 02:19 PM
Profile PM Web Find Quote Report
PsychoMark
Full Member
***

Avatar

Posts: 151
40 / – / –
Joined: Apr 2002
O.P. RE: Q. for Patchou: thread-safety in plugins
I did my own translation of the header, but yours was helpfull in ironing out a few bugs, thanks for that! Nice to see not everyone is using VB (or C) here :)


I've tried using the global variable, set it in Initialize, but it was empty in the tag/command processing functions :(. So I went for the memory mapped file instead. It's created in Initialize, destroyed in Uninitialize and whenever I need it I use OpenFileMapping to get the data. It's used to store the email address btw, so I can save per-account settings. The contact's friendly name is not an option, and I'd rather leave the messenger interface that is passed in the parameters alone... just let Plus sort out all the MSN-specific stuff ;)
10-02-2003 02:28 PM
Profile E-Mail PM Web Find Quote Report
lopardo
Veteran Member
*****


Posts: 1395
Reputation: 33
37 / Male / Flag
Joined: Nov 2002
Status: Away
RE: Q. for Patchou: thread-safety in plugins
Hi guys. Sorry for bringing this old thread up...
Could you tell me where can I get your latest templates for making plugins with Delphi?
I'm gonna check if I can integrate my Log Viewer as a plugin and I also want to make a little one for putting Winamp's song in Messenger's nickname :)
[Image: userbar452797dd.gif]
12-06-2003 06:47 AM
Profile PM Find Quote Report
PsychoMark
Full Member
***

Avatar

Posts: 151
40 / – / –
Joined: Apr 2002
O.P. RE: Q. for Patchou: thread-safety in plugins
I'm not sure if it's the latest or best, but I'll just post my version of the headers. These have been used in WMPlus and SOF2Plus (which hasn't been very publicly released, but if any SOF2 fans want yet another sounds plugin, just shout). Note that these do not yet contain the Unicode declarations for the functions, only the structures for that have been converted. The prototypes for the functions are in comments in the unit, you can copy these to your DLL project and export them... if you want an example on how to use this just let me know and I'll fix something... or take a look at the other Delphi translation posted here on these forums...


P.S. Just noticed these aren't actually the latest version. I will grab the original "SDK" and convert the new funtions, maybe include the Unicode ones as well this time... but for now, this'll get you started, as you won't likely need the new popup functionality...

.zip File Attachment: MPPlugin.zip (4.55 KB)
This file has been downloaded 211 time(s).
12-06-2003 01:48 PM
Profile E-Mail PM Web Find Quote Report
lopardo
Veteran Member
*****


Posts: 1395
Reputation: 33
37 / Male / Flag
Joined: Nov 2002
Status: Away
RE: Q. for Patchou: thread-safety in plugins
OK, thanks a lot. And keep us informed if you do anything new :)
[Image: userbar452797dd.gif]
12-06-2003 05:05 PM
Profile PM Find Quote Report
lopardo
Veteran Member
*****


Posts: 1395
Reputation: 33
37 / Male / Flag
Joined: Nov 2002
Status: Away
RE: Q. for Patchou: thread-safety in plugins
Hey, do you know how could I get the Winamp song title from Plus (the (!WAT) tag) and how could I set the nickname through Plus (/nick xxx)? I really couldn't find that out for myself :(
[Image: userbar452797dd.gif]
12-07-2003 12:21 AM
Profile PM Find Quote Report
PsychoMark
Full Member
***

Avatar

Posts: 151
40 / – / –
Joined: Apr 2002
O.P. RE: Q. for Patchou: thread-safety in plugins
Getting the Winamp song isn't that hard, there's an example posted on the NSDN (here, at the bottom, just have to convert it to Delphi). If I'm correct (but don't quote me on this though) you can return commands from your plugin which will be processed by Plus!. I have not yet tried this, so I can't be 100% sure. The problem with nickname changers is that plugins react only on commands typed by the user, so for the song-nickname to work they'd have to type in "/xyourcommand" every time they want to update it... this would make your plugin quite obsolete, as they can just use "/nick (!WAT)"...

I ran into the same problem when people started asking me about nickname-changing for WMPlus. Since I didn't want that option anyways I out-sourced it to a friend, which will create a standalone application to do it. The other option might be to create a new thread in Initialize and have it check for song changes every once in a while. I haven't verified if this does indeed work, but in theory it should...
12-07-2003 09:45 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