| 16301:45ac8cee1b51 | 16302:eb633ebf84f2 |
|---|---|
| 337 data + ret, len - ret); | 337 data + ret, len - ret); |
| 338 } | 338 } |
| 339 return; | 339 return; |
| 340 } | 340 } |
| 341 | 341 |
| 342 static int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len) | 342 int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len) |
| 343 { | 343 { |
| 344 JabberStream *js = (JabberStream*)gc->proto_data; | 344 JabberStream *js = (JabberStream*)gc->proto_data; |
| 345 jabber_send_raw(js, buf, len); | 345 jabber_send_raw(js, buf, len); |
| 346 return len; | 346 return len; |
| 347 } | 347 } |
| 360 txt = xmlnode_to_str(packet, &len); | 360 txt = xmlnode_to_str(packet, &len); |
| 361 jabber_send_raw(js, txt, len); | 361 jabber_send_raw(js, txt, len); |
| 362 g_free(txt); | 362 g_free(txt); |
| 363 } | 363 } |
| 364 | 364 |
| 365 static void jabber_keepalive(PurpleConnection *gc) | 365 void jabber_keepalive(PurpleConnection *gc) |
| 366 { | 366 { |
| 367 jabber_send_raw(gc->proto_data, "\t", -1); | 367 jabber_send_raw(gc->proto_data, "\t", -1); |
| 368 } | 368 } |
| 369 | 369 |
| 370 static void | 370 static void |
| 533 jabber_login_connect(js, js->user->domain, | 533 jabber_login_connect(js, js->user->domain, |
| 534 purple_account_get_int(js->gc->account, "port", 5222)); | 534 purple_account_get_int(js->gc->account, "port", 5222)); |
| 535 } | 535 } |
| 536 } | 536 } |
| 537 | 537 |
| 538 | 538 void |
| 539 | |
| 540 static void | |
| 541 jabber_login(PurpleAccount *account) | 539 jabber_login(PurpleAccount *account) |
| 542 { | 540 { |
| 543 PurpleConnection *gc = purple_account_get_connection(account); | 541 PurpleConnection *gc = purple_account_get_connection(account); |
| 544 const char *connect_server = purple_account_get_string(account, | 542 const char *connect_server = purple_account_get_string(account, |
| 545 "connect_server", ""); | 543 "connect_server", ""); |
| 885 | 883 |
| 886 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | 884 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); |
| 887 jabber_iq_send(iq); | 885 jabber_iq_send(iq); |
| 888 } | 886 } |
| 889 | 887 |
| 890 static void jabber_register_account(PurpleAccount *account) | 888 void jabber_register_account(PurpleAccount *account) |
| 891 { | 889 { |
| 892 PurpleConnection *gc = purple_account_get_connection(account); | 890 PurpleConnection *gc = purple_account_get_connection(account); |
| 893 JabberStream *js; | 891 JabberStream *js; |
| 894 JabberBuddy *my_jb = NULL; | 892 JabberBuddy *my_jb = NULL; |
| 895 const char *connect_server = purple_account_get_string(account, | 893 const char *connect_server = purple_account_get_string(account, |
| 956 js); | 954 js); |
| 957 } | 955 } |
| 958 } | 956 } |
| 959 } | 957 } |
| 960 | 958 |
| 961 static void jabber_close(PurpleConnection *gc) | 959 void jabber_close(PurpleConnection *gc) |
| 962 { | 960 { |
| 963 JabberStream *js = gc->proto_data; | 961 JabberStream *js = gc->proto_data; |
| 964 | 962 |
| 965 /* Don't perform any actions on the ssl connection | 963 /* Don't perform any actions on the ssl connection |
| 966 * if we were forcibly disconnected because it will crash | 964 * if we were forcibly disconnected because it will crash |
| 1071 { | 1069 { |
| 1072 return g_strdup_printf("purple%x", js->next_id++); | 1070 return g_strdup_printf("purple%x", js->next_id++); |
| 1073 } | 1071 } |
| 1074 | 1072 |
| 1075 | 1073 |
| 1076 static void jabber_idle_set(PurpleConnection *gc, int idle) | 1074 void jabber_idle_set(PurpleConnection *gc, int idle) |
| 1077 { | 1075 { |
| 1078 JabberStream *js = gc->proto_data; | 1076 JabberStream *js = gc->proto_data; |
| 1079 | 1077 |
| 1080 js->idle = idle ? time(NULL) - idle : idle; | 1078 js->idle = idle ? time(NULL) - idle : idle; |
| 1081 } | 1079 } |
| 1082 | 1080 |
| 1083 static const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b) | 1081 const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b) |
| 1084 { | 1082 { |
| 1085 return "jabber"; | 1083 return "jabber"; |
| 1086 } | 1084 } |
| 1087 | 1085 |
| 1088 static const char* jabber_list_emblem(PurpleBuddy *b) | 1086 const char* jabber_list_emblem(PurpleBuddy *b) |
| 1089 { | 1087 { |
| 1090 JabberStream *js; | 1088 JabberStream *js; |
| 1091 JabberBuddy *jb = NULL; | 1089 JabberBuddy *jb = NULL; |
| 1092 | 1090 |
| 1093 if(!b->account->gc) | 1091 if(!b->account->gc) |
| 1103 return "not-authorized"; | 1101 return "not-authorized"; |
| 1104 } | 1102 } |
| 1105 return NULL; | 1103 return NULL; |
| 1106 } | 1104 } |
| 1107 | 1105 |
| 1108 static char *jabber_status_text(PurpleBuddy *b) | 1106 char *jabber_status_text(PurpleBuddy *b) |
| 1109 { | 1107 { |
| 1110 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, | 1108 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
| 1111 FALSE); | 1109 FALSE); |
| 1112 char *ret = NULL; | 1110 char *ret = NULL; |
| 1113 | 1111 |
| 1132 } | 1130 } |
| 1133 | 1131 |
| 1134 return ret; | 1132 return ret; |
| 1135 } | 1133 } |
| 1136 | 1134 |
| 1137 static void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) | 1135 void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) |
| 1138 { | 1136 { |
| 1139 JabberBuddy *jb; | 1137 JabberBuddy *jb; |
| 1140 | 1138 |
| 1141 g_return_if_fail(b != NULL); | 1139 g_return_if_fail(b != NULL); |
| 1142 g_return_if_fail(b->account != NULL); | 1140 g_return_if_fail(b->account != NULL); |
| 1216 purple_notify_user_info_add_pair(user_info, _("Error"), jb->error_msg); | 1214 purple_notify_user_info_add_pair(user_info, _("Error"), jb->error_msg); |
| 1217 } | 1215 } |
| 1218 } | 1216 } |
| 1219 } | 1217 } |
| 1220 | 1218 |
| 1221 static GList *jabber_status_types(PurpleAccount *account) | 1219 GList *jabber_status_types(PurpleAccount *account) |
| 1222 { | 1220 { |
| 1223 PurpleStatusType *type; | 1221 PurpleStatusType *type; |
| 1224 GList *types = NULL; | 1222 GList *types = NULL; |
| 1225 PurpleValue *priority_value; | 1223 PurpleValue *priority_value; |
| 1226 | 1224 |
| 1369 _("Change Jabber Password"), _("Please enter your new password"), | 1367 _("Change Jabber Password"), _("Please enter your new password"), |
| 1370 fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | 1368 fields, _("OK"), G_CALLBACK(jabber_password_change_cb), |
| 1371 _("Cancel"), NULL, js); | 1369 _("Cancel"), NULL, js); |
| 1372 } | 1370 } |
| 1373 | 1371 |
| 1374 static GList *jabber_actions(PurplePlugin *plugin, gpointer context) | 1372 GList *jabber_actions(PurplePlugin *plugin, gpointer context) |
| 1375 { | 1373 { |
| 1376 GList *m = NULL; | 1374 GList *m = NULL; |
| 1377 PurplePluginAction *act; | 1375 PurplePluginAction *act; |
| 1378 | 1376 |
| 1379 act = purple_plugin_action_new(_("Set User Info..."), | 1377 act = purple_plugin_action_new(_("Set User Info..."), |
| 1391 m = g_list_append(m, act); | 1389 m = g_list_append(m, act); |
| 1392 | 1390 |
| 1393 return m; | 1391 return m; |
| 1394 } | 1392 } |
| 1395 | 1393 |
| 1396 static PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name) | 1394 PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name) |
| 1397 { | 1395 { |
| 1398 PurpleBlistNode *gnode, *cnode; | 1396 PurpleBlistNode *gnode, *cnode; |
| 1399 JabberID *jid; | 1397 JabberID *jid; |
| 1400 | 1398 |
| 1401 if(!(jid = jabber_id_new(name))) | 1399 if(!(jid = jabber_id_new(name))) |
| 1425 } | 1423 } |
| 1426 jabber_id_free(jid); | 1424 jabber_id_free(jid); |
| 1427 return NULL; | 1425 return NULL; |
| 1428 } | 1426 } |
| 1429 | 1427 |
| 1430 static void jabber_convo_closed(PurpleConnection *gc, const char *who) | 1428 void jabber_convo_closed(PurpleConnection *gc, const char *who) |
| 1431 { | 1429 { |
| 1432 JabberStream *js = gc->proto_data; | 1430 JabberStream *js = gc->proto_data; |
| 1433 JabberID *jid; | 1431 JabberID *jid; |
| 1434 JabberBuddy *jb; | 1432 JabberBuddy *jb; |
| 1435 JabberBuddyResource *jbr; | 1433 JabberBuddyResource *jbr; |
| 1775 | 1773 |
| 1776 g_free(who); | 1774 g_free(who); |
| 1777 return PURPLE_CMD_RET_OK; | 1775 return PURPLE_CMD_RET_OK; |
| 1778 } | 1776 } |
| 1779 | 1777 |
| 1780 static gboolean jabber_offline_message(const PurpleBuddy *buddy) | 1778 gboolean jabber_offline_message(const PurpleBuddy *buddy) |
| 1781 { | 1779 { |
| 1782 return TRUE; | 1780 return TRUE; |
| 1783 } | 1781 } |
| 1784 | 1782 |
| 1785 static void jabber_register_commands(void) | 1783 void jabber_register_commands(void) |
| 1786 { | 1784 { |
| 1787 purple_cmd_register("config", "", PURPLE_CMD_P_PRPL, | 1785 purple_cmd_register("config", "", PURPLE_CMD_P_PRPL, |
| 1788 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY, | 1786 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY, |
| 1789 "prpl-jabber", jabber_cmd_chat_config, | 1787 "prpl-jabber", jabber_cmd_chat_config, |
| 1790 _("config: Configure a chat room."), NULL); | 1788 _("config: Configure a chat room."), NULL); |
| 1854 "prpl-jabber", jabber_cmd_chat_msg, | 1852 "prpl-jabber", jabber_cmd_chat_msg, |
| 1855 _("msg <user> <message>: Send a private message to another user."), | 1853 _("msg <user> <message>: Send a private message to another user."), |
| 1856 NULL); | 1854 NULL); |
| 1857 } | 1855 } |
| 1858 | 1856 |
| 1859 static PurplePluginProtocolInfo prpl_info = | 1857 void |
| 1860 { | 1858 jabber_init_plugin(PurplePlugin *plugin) |
| 1861 #ifdef HAVE_CYRUS_SASL | 1859 { |
| 1862 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | | 1860 my_protocol = plugin; |
| 1863 OPT_PROTO_MAIL_CHECK | OPT_PROTO_PASSWORD_OPTIONAL, | 1861 } |
| 1864 #else | |
| 1865 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_MAIL_CHECK, | |
| 1866 #endif | |
| 1867 NULL, /* user_splits */ | |
| 1868 NULL, /* protocol_options */ | |
| 1869 {"png,gif,jpeg", 32, 32, 96, 96, 8191, PURPLE_ICON_SCALE_SEND | PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
| 1870 jabber_list_icon, /* list_icon */ | |
| 1871 jabber_list_emblem, /* list_emblems */ | |
| 1872 jabber_status_text, /* status_text */ | |
| 1873 jabber_tooltip_text, /* tooltip_text */ | |
| 1874 jabber_status_types, /* status_types */ | |
| 1875 jabber_blist_node_menu, /* blist_node_menu */ | |
| 1876 jabber_chat_info, /* chat_info */ | |
| 1877 jabber_chat_info_defaults, /* chat_info_defaults */ | |
| 1878 jabber_login, /* login */ | |
| 1879 jabber_close, /* close */ | |
| 1880 jabber_message_send_im, /* send_im */ | |
| 1881 jabber_set_info, /* set_info */ | |
| 1882 jabber_send_typing, /* send_typing */ | |
| 1883 jabber_buddy_get_info, /* get_info */ | |
| 1884 jabber_presence_send, /* set_away */ | |
| 1885 jabber_idle_set, /* set_idle */ | |
| 1886 NULL, /* change_passwd */ | |
| 1887 jabber_roster_add_buddy, /* add_buddy */ | |
| 1888 NULL, /* add_buddies */ | |
| 1889 jabber_roster_remove_buddy, /* remove_buddy */ | |
| 1890 NULL, /* remove_buddies */ | |
| 1891 NULL, /* add_permit */ | |
| 1892 jabber_google_roster_add_deny, /* add_deny */ | |
| 1893 NULL, /* rem_permit */ | |
| 1894 jabber_google_roster_rem_deny, /* rem_deny */ | |
| 1895 NULL, /* set_permit_deny */ | |
| 1896 jabber_chat_join, /* join_chat */ | |
| 1897 NULL, /* reject_chat */ | |
| 1898 jabber_get_chat_name, /* get_chat_name */ | |
| 1899 jabber_chat_invite, /* chat_invite */ | |
| 1900 jabber_chat_leave, /* chat_leave */ | |
| 1901 NULL, /* chat_whisper */ | |
| 1902 jabber_message_send_chat, /* chat_send */ | |
| 1903 jabber_keepalive, /* keepalive */ | |
| 1904 jabber_register_account, /* register_user */ | |
| 1905 jabber_buddy_get_info_chat, /* get_cb_info */ | |
| 1906 NULL, /* get_cb_away */ | |
| 1907 jabber_roster_alias_change, /* alias_buddy */ | |
| 1908 jabber_roster_group_change, /* group_buddy */ | |
| 1909 jabber_roster_group_rename, /* rename_group */ | |
| 1910 NULL, /* buddy_free */ | |
| 1911 jabber_convo_closed, /* convo_closed */ | |
| 1912 jabber_normalize, /* normalize */ | |
| 1913 jabber_set_buddy_icon, /* set_buddy_icon */ | |
| 1914 NULL, /* remove_group */ | |
| 1915 jabber_chat_buddy_real_name, /* get_cb_real_name */ | |
| 1916 jabber_chat_set_topic, /* set_chat_topic */ | |
| 1917 jabber_find_blist_chat, /* find_blist_chat */ | |
| 1918 jabber_roomlist_get_list, /* roomlist_get_list */ | |
| 1919 jabber_roomlist_cancel, /* roomlist_cancel */ | |
| 1920 NULL, /* roomlist_expand_category */ | |
| 1921 NULL, /* can_receive_file */ | |
| 1922 jabber_si_xfer_send, /* send_file */ | |
| 1923 jabber_si_new_xfer, /* new_xfer */ | |
| 1924 jabber_offline_message, /* offline_message */ | |
| 1925 NULL, /* whiteboard_prpl_ops */ | |
| 1926 jabber_prpl_send_raw, /* send_raw */ | |
| 1927 jabber_roomlist_room_serialize, /* roomlist_room_serialize */ | |
| 1928 }; | |
| 1929 | |
| 1930 static gboolean load_plugin(PurplePlugin *plugin) | |
| 1931 { | |
| 1932 purple_signal_register(plugin, "jabber-receiving-xmlnode", | |
| 1933 purple_marshal_VOID__POINTER_POINTER, NULL, 2, | |
| 1934 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), | |
| 1935 purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE)); | |
| 1936 | |
| 1937 purple_signal_register(plugin, "jabber-sending-xmlnode", | |
| 1938 purple_marshal_VOID__POINTER_POINTER, NULL, 2, | |
| 1939 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), | |
| 1940 purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE)); | |
| 1941 | |
| 1942 purple_signal_register(plugin, "jabber-sending-text", | |
| 1943 purple_marshal_VOID__POINTER_POINTER, NULL, 2, | |
| 1944 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), | |
| 1945 purple_value_new_outgoing(PURPLE_TYPE_STRING)); | |
| 1946 | |
| 1947 | |
| 1948 return TRUE; | |
| 1949 } | |
| 1950 | |
| 1951 static gboolean unload_plugin(PurplePlugin *plugin) | |
| 1952 { | |
| 1953 purple_signal_unregister(plugin, "jabber-receiving-xmlnode"); | |
| 1954 | |
| 1955 purple_signal_unregister(plugin, "jabber-sending-xmlnode"); | |
| 1956 | |
| 1957 purple_signal_unregister(plugin, "jabber-sending-text"); | |
| 1958 | |
| 1959 return TRUE; | |
| 1960 } | |
| 1961 | |
| 1962 static PurplePluginInfo info = | |
| 1963 { | |
| 1964 PURPLE_PLUGIN_MAGIC, | |
| 1965 PURPLE_MAJOR_VERSION, | |
| 1966 PURPLE_MINOR_VERSION, | |
| 1967 PURPLE_PLUGIN_PROTOCOL, /**< type */ | |
| 1968 NULL, /**< ui_requirement */ | |
| 1969 0, /**< flags */ | |
| 1970 NULL, /**< dependencies */ | |
| 1971 PURPLE_PRIORITY_DEFAULT, /**< priority */ | |
| 1972 | |
| 1973 "prpl-jabber", /**< id */ | |
| 1974 "Jabber", /**< name */ | |
| 1975 VERSION, /**< version */ | |
| 1976 /** summary */ | |
| 1977 N_("Jabber Protocol Plugin"), | |
| 1978 /** description */ | |
| 1979 N_("Jabber Protocol Plugin"), | |
| 1980 NULL, /**< author */ | |
| 1981 PURPLE_WEBSITE, /**< homepage */ | |
| 1982 | |
| 1983 load_plugin, /**< load */ | |
| 1984 unload_plugin, /**< unload */ | |
| 1985 NULL, /**< destroy */ | |
| 1986 | |
| 1987 NULL, /**< ui_info */ | |
| 1988 &prpl_info, /**< extra_info */ | |
| 1989 NULL, /**< prefs_info */ | |
| 1990 jabber_actions | |
| 1991 }; | |
| 1992 | |
| 1993 static void | |
| 1994 init_plugin(PurplePlugin *plugin) | |
| 1995 { | |
| 1996 PurpleAccountUserSplit *split; | |
| 1997 PurpleAccountOption *option; | |
| 1998 | |
| 1999 split = purple_account_user_split_new(_("Server"), "jabber.org", '@'); | |
| 2000 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); | |
| 2001 | |
| 2002 split = purple_account_user_split_new(_("Resource"), "Home", '/'); | |
| 2003 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); | |
| 2004 | |
| 2005 option = purple_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE); | |
| 2006 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 2007 option); | |
| 2008 | |
| 2009 option = purple_account_option_bool_new( | |
| 2010 _("Allow plaintext auth over unencrypted streams"), | |
| 2011 "auth_plain_in_clear", FALSE); | |
| 2012 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 2013 option); | |
| 2014 | |
| 2015 option = purple_account_option_int_new(_("Connect port"), "port", 5222); | |
| 2016 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 2017 option); | |
| 2018 | |
| 2019 option = purple_account_option_string_new(_("Connect server"), | |
| 2020 "connect_server", NULL); | |
| 2021 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 2022 option); | |
| 2023 | |
| 2024 my_protocol = plugin; | |
| 2025 | |
| 2026 purple_prefs_remove("/plugins/prpl/jabber"); | |
| 2027 | |
| 2028 /* XXX - If any other plugin wants SASL this won't be good ... */ | |
| 2029 #ifdef HAVE_CYRUS_SASL | |
| 2030 sasl_client_init(NULL); | |
| 2031 #endif | |
| 2032 jabber_register_commands(); | |
| 2033 | |
| 2034 jabber_iq_init(); | |
| 2035 } | |
| 2036 | |
| 2037 PURPLE_INIT_PLUGIN(jabber, init_plugin, info); |