add in blist request, fake home dir

Anatoliy Belsky thinker at online.de
Sun Feb 10 05:11:35 EST 2008


On Sunday 10 February 2008, Mark Doliner wrote:
> On Sun, 10 Feb 2008 08:40:48 +0100, Anatoliy Belsky wrote
>
> > On Saturday 09 February 2008, Mark Doliner wrote:
> > > I think you could use purple_find_buddies() or purple_find_buddy().  If
> > > it returns NULL then the person is not in your buddy list.
> >
> > pbuddy = purple_find_buddy(paccount, !who ?
> > purple_conversation_get_name(conv) : who);
> >
> > if(!pbuddy) {
> > 	pbuddy = purple_buddy_new(paccount, !who ?
> > purple_conversation_get_name(conv) : who, NULL);
> > }
> >
> > if(purple_find_buddy(paccount, !who ?
> > purple_conversation_get_name(conv) : who)) { 	/*shouldn't come into
> > this*/ php_printf("the buddy is found\n");
> > }
> >
> > so this piece of code worked, but I don't understand why ...) the
> > buddy was created but isn't on the blist and will not be
> > automatically saved... this is the case, where we become messages
> > from the buddies, which aren't in our blist .. ok, this is exactly
> > what i need
>
> I'm confused.  Why would you want to call purple_buddy_new()?  Why would
> you create a PurpleBuddy object for someone not in your buddy list?  It
> seems like it would be better if your code just handled the case where
> pbuddy is NULL.

damn, your'e right ... so it looks as follows - in the php binding i do 
allways deliver a buddy object, so in php we have something like this:

class PurpleClient extends Client
{
	protected function writeIM($conversation, $buddy, $message, $flags, $time)
	{
		if(PurpleClient::MESSAGE_RECV == $flags) {
			printf(	"(%s) %s %s: %s\n",
					$conversation->getName(),
					date("H:i:s", $time),
					$buddy->getAlias(),
					$message
					);
		}
	}
}

and for this i'm storing buddies and groups links internal in php. So i can't 
simply store the name, i really need the buddy. Because of this schema i'm 
trying allways to create a buddy first, and then create a php object ... But 
you've lead me onto some other idea - i'll deliver an object only if the 
buddy in the blist, and the who string otherwise ...: so it will look like 
this:

class PurpleClient extends Client
{
	protected function writeIM($conversation, $buddy, $message, $flags, $time)
	{
		if(PurpleClient::MESSAGE_RECV == $flags) {
			printf(	"(%s) %s %s: %s\n",
					$conversation->getName(),
					date("H:i:s", $time),
					is_string($buddy) ? $buddy : $buddy->getAlias(),
					$message
					);
		}
	}
}

>
> > i would ask a couple of questions more:
> >
> > - while creating an account one must provide the password/username
> > pair and use purple_account_new, purple_account_set_password and so
> > on. One thing i can't find is - how i could set the server address
> > and port. Or is this read from the xml only?
>
> It sounds like you're talking about PRPL-specific account settings.  You
> can see the list of available settings for a given protocol by looking at
> prpl_info->protocol_options, and you can set settings using
> purple_account_set_string(), purple_account_set_int() and
> purple_account_set_bool().

yeah, it's so ... while it works for example for msn with username/password 
and standard settings only, jabber or irc need more data...

Regards

Anatoliy





More information about the Devel mailing list