Ignore:
Timestamp:
2015-03-12T09:10:16Z (9 years ago)
Author:
dequis <dx@…>
Children:
fc650a8
Parents:
0e4c3dd (diff), 3bb333c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'develop' into feat/hip-cat

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/purple/purple.c

    r0e4c3dd r89db90e  
    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;
     
    10331048}
    10341049
     1050/* So it turns out some requests have no account context at all, because
     1051 * libpurple hates us. This means that query_del_by_conn() won't remove those
     1052 * on logout, and will segfault if the user replies. That's why this exists.
     1053 */
     1054static void prplcb_close_request(PurpleRequestType type, void *data)
     1055{
     1056        if (type == PURPLE_REQUEST_ACTION) {
     1057                struct prplcb_request_action_data *pqad = data;
     1058                query_del(local_bee->ui_data, pqad->bee_data);
     1059        }
     1060        /* Add the request input handler here when that becomes a thing */
     1061}
     1062
    10351063/*
    10361064static void prplcb_request_test()
     
    10471075        NULL,
    10481076        NULL,
    1049         NULL,
     1077        prplcb_close_request,
    10501078        NULL,
    10511079};
Note: See TracChangeset for help on using the changeset viewer.