Porting libpurple plugin: newbie question

Christopher Forsythe chris at growl.info
Mon Nov 9 16:07:51 UTC 2009


On Mon, Nov 9, 2009 at 9:43 AM, Matt Meissner <meissnem at gmail.com> wrote:

>
> On Nov 9, 2009, at 9:18 AM, Christopher Forsythe wrote:
>
>
>>
>> On Mon, Nov 9, 2009 at 8:39 AM, Matt Meissner <meissnem at gmail.com> wrote:
>>
>> On Nov 6, 2009, at 10:25 AM, Matt Meissner wrote:
>>
>>
>> On Nov 5, 2009, at 7:05 AM, Evan Schoenberg, M.D. wrote:
>>
>> Matt,
>>
>>
>> On Nov 4, 2009, at 4:32 PM, Matt Meissner wrote:
>>
>> It would be very helpful for my day job to have SIPE <http://sipe.sf.net/>
>> in Adium.  So I'm attempting to port it -- never having used Cocoa before,
>> there's no better way to learn I guess.
>>
>> Here's my current state of affairs:
>>       <http://dl.getdropbox.com/u/535204/pidgin-sipe-1.7.0.zip> (545 KB)
>> My plugin is in pidgin-sipe-1.7.0/contrib/SIPEAdiumPlugin.  I'm building
>> against Adium 1.4b12.
>>
>> My problem right now is that after adding a SIPE account, Adium crashes
>> hard.  Here's what's in system.log:
>>
>> Nov  1 21:59:12 Scooter [0x0-0x1f06f05].com.adiumX.adiumX[24744]: **
>> (process:24744): CRITICAL **: purple_accounts_add: assertion `account !=
>> NULL' failed
>>
>> Peter's correct about the other problem, but changing that alone isn't
>> enough to get you up and running.
>>
>> 1. Use [ESSIPEService registerService] to do your service registration.
>>  alloc/init is coincidentally okay, but you should use Adium's public API
>> wherever possible to avoid fragility.
>>
>> 2. in -[ESSIPEService installLibpurplePlugin], you need to ask libpurple
>> to load the libpurple component of the plugin.  Doing it in installPlugin is
>> too soon, as libpurple is not guaranteed to be loaded and ready to listen
>> yet.
>>
>> Currently, you do this:
>>       PurplePlugin *prpl = purple_plugin_new(TRUE, NULL);
>>       purple_init_plugin(prpl);
>> Looking at the docs for purple_plugin_new, we see:
>> /**
>> * Creates a new plugin structure.
>> *
>> * @param native Whether or not the plugin is native.
>> * @param path   The path to the plugin, or @c NULL if statically compiled.
>> *
>> * @return A new PurplePlugin structure.
>> */
>> PurplePlugin *purple_plugin_new(gboolean native, const char *path);
>>
>> So this definitely isn't what you want, and doing it with a NULL path is
>> not going to load anything.
>>
>> Instead, what you need to do is to link statically against the built
>> plugin (that is, against the .a file that is produced when building it) and
>> call
>> purple_init_##x##_plugin()
>> from -[ESSIPEService installLibpurplePlugin].
>>
>> where ##x## is the prpl's name, sipe.
>>
>> This, on the other hand, does require the plugin not be broken for static
>> compilation. sipe is... because, at the bottom of the sipe.c file, it says:
>> /* I had to redefined the function for it load, but works */
>> gboolean purple_init_plugin(PurplePlugin *plugin){
>>       plugin->info = &(info);
>>       init_plugin((plugin));
>>       sipe_plugin_load((plugin));
>>       return purple_plugin_register(plugin);
>> }
>>
>> Programmers: If you have to redefine something you shouldn't, you're doing
>> it wrong.  That's a pasted-in version of PURPLE_INIT_PLUGIN() from
>> plugin.h... which just has the non-static-compilation bit.  That'll need to
>> be changed to call PURPLE_INIT_PLUGIN() as other plugins do in order for
>> static loading to be possible.
>>
>> Hope that helps you get off on the right foot!
>>
>> Cheers,
>> Evan
>>
>>
>> Evan and Peter,
>>
>> Thanks for the ideas and help -- I'm crashing in a different place now, so
>> that's progress.
>>
>> I'll have more time to look over the weekend.
>>
>> Thanks again,
>> Matt
>>
>> Thanks to the help from Evan and Peter, I'm successfully connecting and
>> chatting using Adium and my SIPE server.  Most recent source code is at <
>> http://dl.dropbox.com/u/535204/pidgin-sipe-1.7.0.zip>
>>
>> There are still a few outstanding items that I know about -- I need to
>> figure out how to modify the account preferences panel to allow for
>> protocol-specific settings and I've hardcoded a setting or two for my server
>> just to get things moving -- but I'm encouraged.
>>
>> Thanks again Evan and Peter and all of the Adium developers for their hard
>> work on the project.
>>
>>
>>
>>
>> This connects to LCS 2005 or 2007 or both?
>>
>>
> The SIPE pidgin plugin connects to both.  I only have access to Reuters
> Messaging, so I honestly do not know if the Adium version works with LCS at
> all.
>
> Also, it's not exactly stable -- I just had it crash after an hour of use.
>  But it's a start...
>


I've been using the plugin to connect to lcs for a bit now. It's been pretty
stable in pidgin on the 2.6.x range.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20091109/8092750a/attachment-0002.html>


More information about the devel mailing list