Changeset ac6855b3 for protocols/jabber
- Timestamp:
- 2015-04-05T21:44:05Z (10 years ago)
- Children:
- 9dc67f4
- Parents:
- 830864d
- Location:
- protocols/jabber
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
r830864d rac6855b3 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 64 56 static void jabber_init(account_t *acc) 65 57 { 66 58 set_t *s; 67 59 char str[16]; 68 jabber_subproto_desc_t *subproto = acc->prpl->data;69 60 70 61 s = set_add(&acc->set, "activity_timeout", "600", set_eval_int, acc); 71 62 63 s = set_add(&acc->set, "oauth", "false", set_eval_oauth, acc); 64 72 65 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 }77 66 78 67 g_snprintf(str, sizeof(str), "%d", jabber_port_list[0]); … … 111 100 acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE | 112 101 ACC_FLAG_HANDLE_DOMAINS; 113 114 if (subproto->server) {115 set_setstr(&acc->set, "server", (char *) subproto->server);116 }117 102 } 118 103 … … 123 108 struct im_connection *ic = imcb_new(acc); 124 109 struct jabber_data *jd = g_new0(struct jabber_data, 1); 125 jabber_subproto_desc_t *subproto = acc->prpl->data;126 110 char *s; 127 111 … … 133 117 jd->ic = ic; 134 118 ic->proto_data = jd; 135 jd->subproto = subproto->id;136 119 137 120 jabber_set_me(ic, acc->user); … … 158 141 jd->buddies = g_hash_table_new(g_str_hash, g_str_equal); 159 142 160 if (s ubproto->oauth2_service && set_getbool(&acc->set, "oauth")) {143 if (set_getbool(&acc->set, "oauth")) { 161 144 GSList *p_in = NULL; 162 145 const char *tok; … … 164 147 jd->fd = jd->r_inpa = jd->w_inpa = -1; 165 148 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 } 167 154 168 155 oauth_params_parse(&p_in, ic->acc->pass); … … 668 655 void jabber_initmodule() 669 656 { 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 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 93 79 struct jabber_data { 94 80 struct im_connection *ic; … … 102 88 struct xt_parser *xt; 103 89 jabber_flags_t flags; 104 jabber_subproto_t subproto;105 90 106 91 char *username; /* USERNAME@server */
Note: See TracChangeset
for help on using the changeset viewer.