Changeset 7733b8c
- Timestamp:
- 2015-02-21T06:10:54Z (10 years ago)
- Children:
- 75ad761
- Parents:
- 5ebff60
- git-author:
- dequis <dx@…> (19-07-14 04:51:58)
- git-committer:
- dequis <dx@…> (21-02-15 06:10:54)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/account.c
r5ebff60 r7733b8c 83 83 } else { 84 84 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");92 85 } 93 86 } -
protocols/jabber/jabber.c
r5ebff60 r7733b8c 54 54 }; 55 55 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 56 64 static void jabber_init(account_t *acc) 57 65 { 58 66 set_t *s; 59 67 char str[16]; 68 jabber_subproto_desc_t *subproto = acc->prpl->data; 60 69 61 70 s = set_add(&acc->set, "activity_timeout", "600", set_eval_int, acc); 62 71 63 s = set_add(&acc->set, "oauth", "false", set_eval_oauth, acc);64 65 72 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 } 66 77 67 78 g_snprintf(str, sizeof(str), "%d", jabber_port_list[0]); … … 100 111 acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE | 101 112 ACC_FLAG_HANDLE_DOMAINS; 113 114 if (subproto->server) { 115 set_setstr(&acc->set, "server", (char *) subproto->server); 116 } 102 117 } 103 118 … … 108 123 struct im_connection *ic = imcb_new(acc); 109 124 struct jabber_data *jd = g_new0(struct jabber_data, 1); 125 jabber_subproto_desc_t *subproto = acc->prpl->data; 110 126 char *s; 111 127 … … 117 133 jd->ic = ic; 118 134 ic->proto_data = jd; 135 jd->subproto = subproto->id; 119 136 120 137 jabber_set_me(ic, acc->user); … … 141 158 jd->buddies = g_hash_table_new(g_str_hash, g_str_equal); 142 159 143 if (s et_getbool(&acc->set, "oauth")) {160 if (subproto->oauth2_service && set_getbool(&acc->set, "oauth")) { 144 161 GSList *p_in = NULL; 145 162 const char *tok; … … 147 164 jd->fd = jd->r_inpa = jd->w_inpa = -1; 148 165 149 if (strstr(jd->server, ".facebook.com")) { 150 jd->oauth2_service = &oauth2_service_facebook; 151 } else { 152 jd->oauth2_service = &oauth2_service_google; 153 } 166 jd->oauth2_service = subproto->oauth2_service; 154 167 155 168 oauth_params_parse(&p_in, ic->acc->pass); … … 655 668 void jabber_initmodule() 656 669 { 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 } 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 } -
protocols/jabber/jabber.h
r5ebff60 r7733b8c 77 77 } jabber_chat_flags_t; 78 78 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 79 93 struct jabber_data { 80 94 struct im_connection *ic; … … 88 102 struct xt_parser *xt; 89 103 jabber_flags_t flags; 104 jabber_subproto_t subproto; 90 105 91 106 char *username; /* USERNAME@server */ -
root_commands.c
r5ebff60 r7733b8c 395 395 if (len >= 1 && g_strncasecmp(cmd[1], "add", len) == 0) { 396 396 struct prpl *prpl; 397 char *protocol_name = cmd[2]; 397 398 398 399 MIN_ARGS(3); … … 410 411 } 411 412 412 prpl = find_protocol(cmd[2]); 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); 413 424 414 425 if (prpl == NULL) {
Note: See TracChangeset
for help on using the changeset viewer.