Porting libpurple plugin: newbie question
Matt Meissner
meissnem at gmail.com
Fri Nov 6 16:25:53 UTC 2009
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
--
Matt Meissner
meissnem at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3368 bytes
Desc: not available
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20091106/9d91c32d/attachment.p7s>
More information about the devel
mailing list