set_user_info API not working

Anthony m3000 at binaryfusion.net
Tue Nov 13 23:56:10 EST 2007


Hi,
  I'm trying to create a perl script that updates my AIM profile
automatically. I'd created one back for Gaim, and finally got around to
updating it for Pidgin. But I'm running into an issue that I can't
figure out. I'm using Pidgin 2.2.2 on Fedora Core 5.

I call the $account->set_user_info() function, with $account being set
to my current logged in account, but it doesn't update my profile as
seen by right clicking on my name in the buddy list and selecting "Get
Info". However if I call $account->get_user_info() in my script, and
display the result in the debug window, it shows my profile as having
updated. 

The other oddity is that if I shutdown Pidgin and reopen it with the
script enabled, it does update my profile that first time. But it only
occurs that first time, none of the other timeout calls have any effect.

In what may be related, I was never able to get the find function to
work:
 $account = Purple::Accounts::find("my_aim_user_name","prpl-oscar");
It would always return null. I got around this by using the
get_all_active() function and grabbing my account that way.

The pertinent code is as follows:
sub update_profile {
   my $plugin = shift;
   my $protocol = "prpl-oscar";
   my $account_name = "my_aim_user_name";

   @accounts=Purple::Accounts::get_all_active();

   foreach $account (@accounts)
   {
       $name=Purple::Account::get_username($account);
       Purple::Debug::info("musicplugin","Account name: $name\n");
   
       Purple::Debug::info("musicplugin","Account is $account\n");

       $time=time();
       $current=$account->get_user_info();
       Purple::Debug::info("musicplugin","Current profile: $current\n");
       Purple::Debug::info("musicplugin","Updating profile with: $time
\n");
       $account->set_user_info("$time");
    }

    # Reschedule timeout
    Purple::timeout_add($plugin, 10, \&update_profile, $plugin);
}

And this is the output I get in the debug window:
(22:53:14) musicplugin: Account name: my_aim_user_name
(22:53:14) musicplugin: Account is Purple::Account=HASH(0x884f4d0)
(22:53:14) musicplugin: Current profile: 1195015984
(22:53:14) musicplugin: Updating profile with: 1195015994

(22:53:24) musicplugin: Account name: my_aim_user_name
(22:53:24) musicplugin: Account is Purple::Account=HASH(0x87dffd0)
(22:53:24) musicplugin: Current profile: 1195015994
(22:53:24) musicplugin: Updating profile with: 1195016004

etc etc.





More information about the Devel mailing list