G
G
gibbonchik2016-10-12 14:04:29
C++ / C#
gibbonchik, 2016-10-12 14:04:29

How to programmatically make an authorization request through a plugin for Pidgin?

I'm writing a plugin for Pidgin in C language. I need to make user authorization happen automatically. The very approval of authorization from the user I did. How can I programmatically send a request to be authorized?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gibbonchik, 2016-10-13
@gibbonchik

I found the answer, it's done like this (I cut out the extra, left only what concerns the answer, the one who works with Libpurple will understand at least a little what goes where and where):

static int autoauth(PurpleAccount *account,const char * remote_user)
{
  PurpleBuddy * buddy;
  PurpleGroup*group;
  group=purple_group_new(_("Buddies"));
  if (group==NULL) purple_debug_info("autoauth", "Error group=null\n");
  if (account==NULL) purple_debug_info("autoauth", "Error account=null\n");
  purple_blist_add_group(group,NULL);
  buddy=purple_buddy_new(account,remote_user,NULL);
        if (group!=NULL) {
    purple_blist_add_buddy(buddy,NULL,group,(PurpleBlistNode*)group);
  }
        purple_account_add_buddy(account,buddy);
  return 1; //all accept
}

static gboolean plugin_load(PurplePlugin *plugin) {
  static int handle;
  purple_signal_connect(purple_accounts_get_handle(), "account-authorization-requested", &handle,
        PURPLE_CALLBACK(autoauth),plugin);
  purple_signal_connect(purple_accounts_get_handle(), "account-authorization-requested-with-message", &handle,
        PURPLE_CALLBACK(autoauth),plugin);
    return TRUE;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question