Changeset d93c8beb for protocols


Ignore:
Timestamp:
2015-03-02T03:27:16Z (10 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
56985aa
Parents:
ce70e88
git-author:
Antoine Pietri <antoine.pietri@…> (01-03-15 17:47:15)
git-committer:
dequis <dx@…> (02-03-15 03:27:16)
Message:

purple: move PurpleAccount from proto_data in a struct purple_data

Location:
protocols/purple
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/purple/ft-direct.c

    rce70e88 rd93c8beb  
    2828
    2929#include "bitlbee.h"
     30#include "bpurple.h"
    3031
    3132#include <stdarg.h>
     
    207208void purple_transfer_request(struct im_connection *ic, file_transfer_t *ft, char *handle)
    208209{
    209         PurpleAccount *pa = ic->proto_data;
     210        struct purple_data *pd = ic->proto_data;
    210211        struct prpl_xfer_data *px;
    211212
     
    213214           multi-threaded anyway. */
    214215        next_ft = ft;
    215         serv_send_file(purple_account_get_connection(pa), handle, ft->file_name);
     216        serv_send_file(purple_account_get_connection(pd->account), handle,
     217                       ft->file_name);
    216218
    217219        ft->write = prpl_xfer_write;
  • protocols/purple/ft.c

    rce70e88 rd93c8beb  
    2828
    2929#include "bitlbee.h"
     30#include "bpurple.h"
    3031
    3132#include <stdarg.h>
     
    285286{
    286287        struct prpl_xfer_data *px = ft->data;
    287         PurpleAccount *pa = px->ic->proto_data;
     288        struct purple_data *pd = px->ic->proto_data;
    288289
    289290        /* xfer_new() will pick up this variable. It's a hack but we're not
    290291           multi-threaded anyway. */
    291292        next_ft = ft;
    292         serv_send_file(purple_account_get_connection(pa), px->handle, px->fn);
     293        serv_send_file(purple_account_get_connection(pd->account),
     294                   px->handle, px->fn);
    293295}
    294296
  • protocols/purple/purple.c

    rce70e88 rd93c8beb  
    2323
    2424#include "bitlbee.h"
     25#include "bpurple.h"
    2526#include "help.h"
    2627
     
    4243{
    4344        GSList *i;
     45        struct purple_data *pd;
    4446
    4547        for (i = purple_connections; i; i = i->next) {
    46                 if (((struct im_connection *) i->data)->proto_data == pa) {
     48                pd = ((struct im_connection *) i->data)->proto_data;
     49                if (pd->account == pa) {
    4750                        return i->data;
    4851                }
     
    290293{
    291294        struct im_connection *ic = imcb_new(acc);
    292         PurpleAccount *pa;
     295        struct purple_data *pd;
    293296
    294297        if ((local_bee != NULL && local_bee != acc->bee) ||
     
    306309        purple_connections = g_slist_prepend(purple_connections, ic);
    307310
    308         ic->proto_data = pa = purple_account_new(acc->user, (char *) acc->prpl->data);
    309         purple_account_set_password(pa, acc->pass);
    310         purple_sync_settings(acc, pa);
    311 
    312         purple_account_set_enabled(pa, "BitlBee", TRUE);
     311        ic->proto_data = pd = g_new0(struct purple_data, 1);
     312        pd->account = purple_account_new(acc->user, (char *) acc->prpl->data);
     313        purple_account_set_password(pd->account, acc->pass);
     314        purple_sync_settings(acc, pd->account);
     315
     316        purple_account_set_enabled(pd->account, "BitlBee", TRUE);
    313317}
    314318
    315319static void purple_logout(struct im_connection *ic)
    316320{
    317         PurpleAccount *pa = ic->proto_data;
    318 
    319         purple_account_set_enabled(pa, "BitlBee", FALSE);
     321        struct purple_data *pd = ic->proto_data;
     322
     323        purple_account_set_enabled(pd->account, "BitlBee", FALSE);
    320324        purple_connections = g_slist_remove(purple_connections, ic);
    321         purple_accounts_remove(pa);
     325        purple_accounts_remove(pd->account);
     326        g_free(pd);
    322327}
    323328
     
    325330{
    326331        PurpleConversation *conv;
     332        struct purple_data *pd = ic->proto_data;
    327333
    328334        if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
    329                                                           who, ic->proto_data)) == NULL) {
     335                                                          who, pd->account)) == NULL) {
    330336                conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
    331                                                ic->proto_data, who);
     337                                               pd->account, who);
    332338        }
    333339
     
    339345static GList *purple_away_states(struct im_connection *ic)
    340346{
    341         PurpleAccount *pa = ic->proto_data;
     347        struct purple_data *pd = ic->proto_data;
    342348        GList *st, *ret = NULL;
    343349
    344         for (st = purple_account_get_status_types(pa); st; st = st->next) {
     350        for (st = purple_account_get_status_types(pd->account); st; st = st->next) {
    345351                PurpleStatusPrimitive prim = purple_status_type_get_primitive(st->data);
    346352                if (prim != PURPLE_STATUS_AVAILABLE && prim != PURPLE_STATUS_OFFLINE) {
     
    354360static void purple_set_away(struct im_connection *ic, char *state_txt, char *message)
    355361{
    356         PurpleAccount *pa = ic->proto_data;
    357         GList *status_types = purple_account_get_status_types(pa), *st;
     362        struct purple_data *pd = ic->proto_data;
     363        GList *status_types = purple_account_get_status_types(pd->account), *st;
    358364        PurpleStatusType *pst = NULL;
    359365        GList *args = NULL;
     
    378384        }
    379385
    380         purple_account_set_status_list(pa, st ? purple_status_type_get_id(pst) : "away",
     386        purple_account_set_status_list(pd->account,
     387                                       st ? purple_status_type_get_id(pst) : "away",
    381388                                       TRUE, args);
    382389
     
    447454        PurpleBuddy *pb;
    448455        PurpleGroup *pg = NULL;
     456        struct purple_data *pd = ic->proto_data;
    449457
    450458        if (group && !(pg = purple_find_group(group))) {
     
    453461        }
    454462
    455         pb = purple_buddy_new((PurpleAccount *) ic->proto_data, who, NULL);
     463        pb = purple_buddy_new(pd->account, who, NULL);
    456464        purple_blist_add_buddy(pb, NULL, pg, NULL);
    457         purple_account_add_buddy((PurpleAccount *) ic->proto_data, pb);
    458 
    459         purple_gg_buddylist_export(((PurpleAccount *) ic->proto_data)->gc);
     465        purple_account_add_buddy(pd->account, pb);
     466
     467        purple_gg_buddylist_export(pd->account->gc);
    460468}
    461469
     
    463471{
    464472        PurpleBuddy *pb;
    465 
    466         pb = purple_find_buddy((PurpleAccount *) ic->proto_data, who);
     473        struct purple_data *pd = ic->proto_data;
     474
     475        pb = purple_find_buddy(pd->account, who);
    467476        if (pb != NULL) {
    468477                PurpleGroup *group;
    469478
    470479                group = purple_buddy_get_group(pb);
    471                 purple_account_remove_buddy((PurpleAccount *) ic->proto_data, pb, group);
     480                purple_account_remove_buddy(pd->account, pb, group);
    472481
    473482                purple_blist_remove_buddy(pb);
    474483        }
    475484
    476         purple_gg_buddylist_export(((PurpleAccount *) ic->proto_data)->gc);
     485        purple_gg_buddylist_export(pd->account->gc);
    477486}
    478487
    479488static void purple_add_permit(struct im_connection *ic, char *who)
    480489{
    481         PurpleAccount *pa = ic->proto_data;
    482 
    483         purple_privacy_permit_add(pa, who, FALSE);
     490        struct purple_data *pd = ic->proto_data;
     491
     492        purple_privacy_permit_add(pd->account, who, FALSE);
    484493}
    485494
    486495static void purple_add_deny(struct im_connection *ic, char *who)
    487496{
    488         PurpleAccount *pa = ic->proto_data;
    489 
    490         purple_privacy_deny_add(pa, who, FALSE);
     497        struct purple_data *pd = ic->proto_data;
     498
     499        purple_privacy_deny_add(pd->account, who, FALSE);
    491500}
    492501
    493502static void purple_rem_permit(struct im_connection *ic, char *who)
    494503{
    495         PurpleAccount *pa = ic->proto_data;
    496 
    497         purple_privacy_permit_remove(pa, who, FALSE);
     504        struct purple_data *pd = ic->proto_data;
     505
     506        purple_privacy_permit_remove(pd->account, who, FALSE);
    498507}
    499508
    500509static void purple_rem_deny(struct im_connection *ic, char *who)
    501510{
    502         PurpleAccount *pa = ic->proto_data;
    503 
    504         purple_privacy_deny_remove(pa, who, FALSE);
     511        struct purple_data *pd = ic->proto_data;
     512
     513        purple_privacy_deny_remove(pd->account, who, FALSE);
    505514}
    506515
    507516static void purple_get_info(struct im_connection *ic, char *who)
    508517{
    509         serv_get_info(purple_account_get_connection(ic->proto_data), who);
     518        struct purple_data *pd = ic->proto_data;
     519
     520        serv_get_info(purple_account_get_connection(pd->account), who);
    510521}
    511522
     
    517528{
    518529        PurpleTypingState state = PURPLE_NOT_TYPING;
    519         PurpleAccount *pa = ic->proto_data;
     530        struct purple_data *pd = ic->proto_data;
    520531
    521532        if (flags & OPT_TYPING) {
     
    525536        }
    526537
    527         serv_send_typing(purple_account_get_connection(pa), who, state);
     538        serv_send_typing(purple_account_get_connection(pd->account), who, state);
    528539
    529540        return 1;
     
    559570        /* There went my nice afternoon. :-( */
    560571
    561         PurpleAccount *pa = ic->proto_data;
    562         PurplePlugin *prpl = purple_plugins_find_with_id(pa->protocol_id);
     572        struct purple_data *pd = ic->proto_data;
     573        PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id);
    563574        PurplePluginProtocolInfo *pi = prpl->info->extra_info;
    564         PurpleBuddy *pb = purple_find_buddy((PurpleAccount *) ic->proto_data, who);
     575        PurpleBuddy *pb = purple_find_buddy(pd->account, who);
    565576        PurpleMenuAction *mi;
    566577        GList *menu;
     
    597608        PurpleConversation *pc = gc->data;
    598609        PurpleConvChat *pcc = PURPLE_CONV_CHAT(pc);
    599 
    600         serv_chat_invite(purple_account_get_connection(gc->ic->proto_data),
     610        struct purple_data *pd = gc->ic->proto_data;
     611
     612        serv_chat_invite(purple_account_get_connection(pd->account),
    601613                         purple_conv_chat_get_id(pcc),
    602614                         message && *message ? message : "Please join my chat",
     
    623635                                   set_t **sets)
    624636{
    625         PurpleAccount *pa = ic->proto_data;
    626         PurplePlugin *prpl = purple_plugins_find_with_id(pa->protocol_id);
     637        struct purple_data *pd = ic->proto_data;
     638        PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id);
    627639        PurplePluginProtocolInfo *pi = prpl->info->extra_info;
    628640        GHashTable *chat_hash;
     
    631643
    632644        if (!pi->chat_info || !pi->chat_info_defaults ||
    633             !(info = pi->chat_info(purple_account_get_connection(pa)))) {
     645            !(info = pi->chat_info(purple_account_get_connection(pd->account)))) {
    634646                imcb_error(ic, "Joining chatrooms not supported by this protocol");
    635647                return NULL;
    636648        }
    637649
    638         if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, room, pa))) {
     650        if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
     651                                                          room, pd->account))) {
    639652                purple_conversation_destroy(conv);
    640653        }
    641654
    642         chat_hash = pi->chat_info_defaults(purple_account_get_connection(pa), room);
     655        chat_hash = pi->chat_info_defaults(
     656                purple_account_get_connection(pd->account), room
     657        );
    643658
    644659        for (l = info; l; l = l->next) {
     
    654669        }
    655670
    656         serv_join_chat(purple_account_get_connection(pa), chat_hash);
     671        serv_join_chat(purple_account_get_connection(pd->account), chat_hash);
    657672
    658673        return NULL;
Note: See TracChangeset for help on using the changeset viewer.