Porting libpurple plugin: newbie question

Matt Meissner meissnem at gmail.com
Mon Nov 9 14:39:50 UTC 2009


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.

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/20091109/239adb30/attachment.p7s>


More information about the devel mailing list