Changeset ac6855b3


Ignore:
Timestamp:
2015-04-05T21:44:05Z (5 years ago)
Author:
dequis <dx@…>
Children:
9dc67f4
Parents:
830864d
Message:

Revert "Add the concept of jabber sub-protocols"

This reverts commit 7733b8c95abbac26f5cbf02a9874a9d96c23bf0d.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/account.c

    r830864d rac6855b3  
    8383                } else {
    8484                        strcpy(tag, "aim");
     85                }
     86        } else if (strcmp(prpl->name, "jabber") == 0) {
     87                if (strstr(a->user, "@gmail.com") ||
     88                    strstr(a->user, "@googlemail.com")) {
     89                        strcpy(tag, "gtalk");
     90                } else if (strstr(a->user, "@chat.facebook.com")) {
     91                        strcpy(tag, "fb");
    8592                }
    8693        }
  • protocols/jabber/jabber.c

    r830864d rac6855b3  
    5454};
    5555
    56 static jabber_subproto_desc_t jabber_subproto_list[] = {
    57         { "jabber", JSUB_NONE, NULL, NULL },
    58         { "gtalk", JSUB_GTALK, &oauth2_service_google, "talk.google.com" },
    59         { "fb", JSUB_FACEBOOK, &oauth2_service_facebook, "chat.facebook.com" },
    60         { "hipchat", JSUB_HIPCHAT, NULL, "chat.hipchat.com" },
    61         { NULL },
    62 };
    63 
    6456static void jabber_init(account_t *acc)
    6557{
    6658        set_t *s;
    6759        char str[16];
    68         jabber_subproto_desc_t *subproto = acc->prpl->data;
    6960
    7061        s = set_add(&acc->set, "activity_timeout", "600", set_eval_int, acc);
    7162
     63        s = set_add(&acc->set, "oauth", "false", set_eval_oauth, acc);
     64
    7265        s = set_add(&acc->set, "display_name", NULL, NULL, acc);
    73 
    74         if (subproto->oauth2_service) {
    75                 s = set_add(&acc->set, "oauth", "false", set_eval_oauth, acc);
    76         }
    7766
    7867        g_snprintf(str, sizeof(str), "%d", jabber_port_list[0]);
     
    111100        acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE |
    112101                      ACC_FLAG_HANDLE_DOMAINS;
    113 
    114         if (subproto->server) {
    115                 set_setstr(&acc->set, "server", (char *) subproto->server);
    116         }
    117102}
    118103
     
    123108        struct im_connection *ic = imcb_new(acc);
    124109        struct jabber_data *jd = g_new0(struct jabber_data, 1);
    125         jabber_subproto_desc_t *subproto = acc->prpl->data;
    126110        char *s;
    127111
     
    133117        jd->ic = ic;
    134118        ic->proto_data = jd;
    135         jd->subproto = subproto->id;
    136119
    137120        jabber_set_me(ic, acc->user);
     
    158141        jd->buddies = g_hash_table_new(g_str_hash, g_str_equal);
    159142
    160         if (subproto->oauth2_service && set_getbool(&acc->set, "oauth")) {
     143        if (set_getbool(&acc->set, "oauth")) {
    161144                GSList *p_in = NULL;
    162145                const char *tok;
     
    164147                jd->fd = jd->r_inpa = jd->w_inpa = -1;
    165148
    166                 jd->oauth2_service = subproto->oauth2_service;
     149                if (strstr(jd->server, ".facebook.com")) {
     150                        jd->oauth2_service = &oauth2_service_facebook;
     151                } else {
     152                        jd->oauth2_service = &oauth2_service_google;
     153                }
    167154
    168155                oauth_params_parse(&p_in, ic->acc->pass);
     
    668655void jabber_initmodule()
    669656{
    670         int i;
    671         struct prpl funcs;
    672 
    673         memset(&funcs, 0, sizeof(funcs));
    674 
    675         funcs.mms = 0;                        /* no limit */
    676         funcs.login = jabber_login;
    677         funcs.init = jabber_init;
    678         funcs.logout = jabber_logout;
    679         funcs.buddy_msg = jabber_buddy_msg;
    680         funcs.away_states = jabber_away_states;
    681         funcs.set_away = jabber_set_away;
    682         funcs.get_info = jabber_get_info;
    683         funcs.add_buddy = jabber_add_buddy;
    684         funcs.remove_buddy = jabber_remove_buddy;
    685         funcs.chat_msg = jabber_chat_msg_;
    686         funcs.chat_topic = jabber_chat_topic_;
    687         funcs.chat_invite = jabber_chat_invite_;
    688         funcs.chat_leave = jabber_chat_leave_;
    689         funcs.chat_join = jabber_chat_join_;
    690         funcs.chat_with = jabber_chat_with_;
    691         funcs.chat_add_settings = jabber_chat_add_settings;
    692         funcs.chat_free_settings = jabber_chat_free_settings;
    693         funcs.keepalive = jabber_keepalive;
    694         funcs.send_typing = jabber_send_typing;
    695         funcs.handle_cmp = g_strcasecmp;
    696         funcs.handle_is_self = jabber_handle_is_self;
    697         funcs.transfer_request = jabber_si_transfer_request;
    698         funcs.buddy_action_list = jabber_buddy_action_list;
    699         funcs.buddy_action = jabber_buddy_action;
    700 
    701         for (i = 0; jabber_subproto_list[i].name; i++) {
    702                 struct prpl *subproto = g_memdup(&funcs, sizeof(funcs));
    703                 subproto->name = jabber_subproto_list[i].name;
    704                 subproto->data = &jabber_subproto_list[i];
    705                 register_protocol(subproto);
    706         }
    707 }
     657        struct prpl *ret = g_new0(struct prpl, 1);
     658
     659        ret->name = "jabber";
     660        ret->mms = 0;                        /* no limit */
     661        ret->login = jabber_login;
     662        ret->init = jabber_init;
     663        ret->logout = jabber_logout;
     664        ret->buddy_msg = jabber_buddy_msg;
     665        ret->away_states = jabber_away_states;
     666        ret->set_away = jabber_set_away;
     667//      ret->set_info = jabber_set_info;
     668        ret->get_info = jabber_get_info;
     669        ret->add_buddy = jabber_add_buddy;
     670        ret->remove_buddy = jabber_remove_buddy;
     671        ret->chat_msg = jabber_chat_msg_;
     672        ret->chat_topic = jabber_chat_topic_;
     673        ret->chat_invite = jabber_chat_invite_;
     674        ret->chat_leave = jabber_chat_leave_;
     675        ret->chat_join = jabber_chat_join_;
     676        ret->chat_with = jabber_chat_with_;
     677        ret->chat_add_settings = jabber_chat_add_settings;
     678        ret->chat_free_settings = jabber_chat_free_settings;
     679        ret->keepalive = jabber_keepalive;
     680        ret->send_typing = jabber_send_typing;
     681        ret->handle_cmp = g_strcasecmp;
     682        ret->handle_is_self = jabber_handle_is_self;
     683        ret->transfer_request = jabber_si_transfer_request;
     684        ret->buddy_action_list = jabber_buddy_action_list;
     685        ret->buddy_action = jabber_buddy_action;
     686
     687        register_protocol(ret);
     688}
  • protocols/jabber/jabber.h

    r830864d rac6855b3  
    7777} jabber_chat_flags_t;
    7878
    79 typedef enum {
    80         JSUB_NONE = 0,
    81         JSUB_GTALK,
    82         JSUB_FACEBOOK,
    83         JSUB_HIPCHAT,
    84 } jabber_subproto_t;
    85 
    86 typedef struct {
    87         const char *name;
    88         jabber_subproto_t id;
    89         const struct oauth2_service *oauth2_service;
    90         const char *server;
    91 } jabber_subproto_desc_t;
    92 
    9379struct jabber_data {
    9480        struct im_connection *ic;
     
    10288        struct xt_parser *xt;
    10389        jabber_flags_t flags;
    104         jabber_subproto_t subproto;
    10590
    10691        char *username;         /* USERNAME@server */
  • root_commands.c

    r830864d rac6855b3  
    395395        if (len >= 1 && g_strncasecmp(cmd[1], "add", len) == 0) {
    396396                struct prpl *prpl;
    397                 char *protocol_name = cmd[2];
    398397
    399398                MIN_ARGS(3);
     
    411410                }
    412411
    413                 /* These used to be just hardcoded account tag guesses,
    414                  * now they are promoted to hardecoded subprotocol guesses */
    415                 if (strcmp(protocol_name, "jabber") == 0) {
    416                         if (strstr(cmd[3], "@gmail.com") || strstr(cmd[3], "@googlemail.com")) {
    417                                 protocol_name = "gtalk";
    418                         } else if (strstr(cmd[3], "@chat.facebook.com")) {
    419                                 protocol_name = "fb";
    420                         }
    421                 }
    422 
    423                 prpl = find_protocol(protocol_name);
     412                prpl = find_protocol(cmd[2]);
    424413
    425414                if (prpl == NULL) {
Note: See TracChangeset for help on using the changeset viewer.