Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/commands.c @ 1598:a087125d8fc8
Replace libjabber with loudmouth
author | franky |
---|---|
date | Sun, 11 Oct 2009 15:38:32 +0200 |
parents | 1802b926e3fa |
children | dcd5d4c75199 |
comparison
equal
deleted
inserted
replaced
1597:4f59a414217e | 1598:a087125d8fc8 |
---|---|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 * USA | 19 * USA |
20 */ | 20 */ |
21 | 21 |
22 #include <string.h> | 22 #include <string.h> |
23 #include <stdlib.h> | |
23 #include <sys/types.h> | 24 #include <sys/types.h> |
24 #include <sys/stat.h> | 25 #include <sys/stat.h> |
25 #include <unistd.h> | 26 #include <unistd.h> |
26 | 27 |
27 #include "commands.h" | 28 #include "commands.h" |
28 #include "help.h" | 29 #include "help.h" |
29 #include "jabglue.h" | |
30 #include "roster.h" | 30 #include "roster.h" |
31 #include "screen.h" | 31 #include "screen.h" |
32 #include "compl.h" | 32 #include "compl.h" |
33 #include "hooks.h" | 33 #include "hooks.h" |
34 #include "hbuf.h" | 34 #include "hbuf.h" |
35 #include "utils.h" | 35 #include "utils.h" |
36 #include "settings.h" | 36 #include "settings.h" |
37 #include "events.h" | 37 #include "events.h" |
38 #include "otr.h" | 38 #include "otr.h" |
39 #include "utf8.h" | 39 #include "utf8.h" |
40 #include "xmpp.h" | |
40 | 41 |
41 #define IMSTATUS_AWAY "away" | 42 #define IMSTATUS_AWAY "away" |
42 #define IMSTATUS_ONLINE "online" | 43 #define IMSTATUS_ONLINE "online" |
43 #define IMSTATUS_OFFLINE "offline" | 44 #define IMSTATUS_OFFLINE "offline" |
44 #define IMSTATUS_FREE4CHAT "free" | 45 #define IMSTATUS_FREE4CHAT "free" |
573 } | 574 } |
574 | 575 |
575 static void display_all_annotations(void) | 576 static void display_all_annotations(void) |
576 { | 577 { |
577 GSList *notes; | 578 GSList *notes; |
578 notes = jb_get_all_storage_rosternotes(); | 579 notes = xmpp_get_all_storage_rosternotes(); |
579 | 580 |
580 if (!notes) | 581 if (!notes) |
581 return; | 582 return; |
582 | 583 |
583 // Call display_and_free_note() for each note, | 584 // Call display_and_free_note() for each note, |
618 msg = to_utf8(arg); | 619 msg = to_utf8(arg); |
619 if (!strcmp(msg, "-")) | 620 if (!strcmp(msg, "-")) |
620 notetxt = NULL; // delete note | 621 notetxt = NULL; // delete note |
621 else | 622 else |
622 notetxt = msg; | 623 notetxt = msg; |
623 jb_set_storage_rosternotes(bjid, notetxt); | 624 xmpp_set_storage_rosternotes(bjid, notetxt); |
624 g_free(msg); | 625 g_free(msg); |
625 } else { // Display a note | 626 } else { // Display a note |
626 struct annotation *note = jb_get_storage_rosternotes(bjid, FALSE); | 627 struct annotation *note = xmpp_get_storage_rosternotes(bjid, FALSE); |
627 if (note) { | 628 if (note) { |
628 display_and_free_note(note, bjid); | 629 display_and_free_note(note, bjid); |
629 } else { | 630 } else { |
630 scr_WriteIncomingMessage(bjid, "This item doesn't have a note.", 0, | 631 scr_WriteIncomingMessage(bjid, "This item doesn't have a note.", 0, |
631 HBB_PREFIX_INFO, 0); | 632 HBB_PREFIX_INFO, 0); |
817 char **paramlst; | 818 char **paramlst; |
818 char *status; | 819 char *status; |
819 char *msg; | 820 char *msg; |
820 enum imstatus st; | 821 enum imstatus st; |
821 | 822 |
822 if (!jb_getonline()) { | 823 if (!lm_connection_is_authenticated(lconnection)) { |
823 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); | 824 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
824 return; | 825 return; |
825 } | 826 } |
826 | 827 |
827 // It makes sense to reset autoaway before changing the status | 828 // It makes sense to reset autoaway before changing the status |
852 // We want a message. If there's none, we give up. | 853 // We want a message. If there's none, we give up. |
853 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); | 854 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
854 free_arg_lst(paramlst); | 855 free_arg_lst(paramlst); |
855 return; | 856 return; |
856 } | 857 } |
857 st = jb_getstatus(); // Preserve current status | 858 st = xmpp_getstatus(); // Preserve current status |
858 } else { | 859 } else { |
859 scr_LogPrint(LPRINT_NORMAL, "Unrecognized status!"); | 860 scr_LogPrint(LPRINT_NORMAL, "Unrecognized status!"); |
860 free_arg_lst(paramlst); | 861 free_arg_lst(paramlst); |
861 return; | 862 return; |
862 } | 863 } |
868 | 869 |
869 // If a recipient is specified, let's don't use default status messages | 870 // If a recipient is specified, let's don't use default status messages |
870 if (recipient && !msg) | 871 if (recipient && !msg) |
871 msg = ""; | 872 msg = ""; |
872 | 873 |
873 jb_setstatus(st, recipient, msg, FALSE); | 874 xmpp_setstatus(st, recipient, msg, FALSE); |
874 | 875 |
875 free_arg_lst(paramlst); | 876 free_arg_lst(paramlst); |
876 } | 877 } |
877 | 878 |
878 static void do_status(char *arg) | 879 static void do_status(char *arg) |
879 { | 880 { |
880 if (!*arg) { | 881 if (!*arg) { |
881 const char *sm = jb_getstatusmsg(); | 882 const char *sm = xmpp_getstatusmsg(); |
882 scr_LogPrint(LPRINT_NORMAL, "Your status is: [%c] %s", | 883 scr_LogPrint(LPRINT_NORMAL, "Your status is: [%c] %s", |
883 imstatus2char[jb_getstatus()], | 884 imstatus2char[xmpp_getstatus()], |
884 (sm ? sm : "")); | 885 (sm ? sm : "")); |
885 return; | 886 return; |
886 } | 887 } |
887 arg = to_utf8(arg); | 888 arg = to_utf8(arg); |
888 cmd_setstatus(NULL, arg); | 889 cmd_setstatus(NULL, arg); |
951 { | 952 { |
952 char **paramlst; | 953 char **paramlst; |
953 char *id, *nick; | 954 char *id, *nick; |
954 char *jid_utf8 = NULL; | 955 char *jid_utf8 = NULL; |
955 | 956 |
956 if (!jb_getonline()) { | 957 if (!lm_connection_is_authenticated(lconnection)) { |
957 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); | 958 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
958 return; | 959 return; |
959 } | 960 } |
960 | 961 |
961 paramlst = split_arg(arg, 2, 0); // jid, [nickname] | 962 paramlst = split_arg(arg, 2, 0); // jid, [nickname] |
990 if (nick) | 991 if (nick) |
991 nick = to_utf8(nick); | 992 nick = to_utf8(nick); |
992 | 993 |
993 if (id) { | 994 if (id) { |
994 // 2nd parameter = optional nickname | 995 // 2nd parameter = optional nickname |
995 jb_addbuddy(id, nick, NULL); | 996 xmpp_addbuddy(id, nick, NULL); |
996 scr_LogPrint(LPRINT_LOGNORM, "Sent presence notification request to <%s>.", | 997 scr_LogPrint(LPRINT_LOGNORM, "Sent presence notification request to <%s>.", |
997 id); | 998 id); |
998 } | 999 } |
999 | 1000 |
1000 g_free(jid_utf8); | 1001 g_free(jid_utf8); |
1028 | 1029 |
1029 // Close the buffer | 1030 // Close the buffer |
1030 scr_BufferPurge(1, NULL); | 1031 scr_BufferPurge(1, NULL); |
1031 | 1032 |
1032 scr_LogPrint(LPRINT_LOGNORM, "Removing <%s>...", bjid); | 1033 scr_LogPrint(LPRINT_LOGNORM, "Removing <%s>...", bjid); |
1033 jb_delbuddy(bjid); | 1034 xmpp_delbuddy(bjid); |
1034 scr_UpdateBuddyWindow(); | 1035 scr_UpdateBuddyWindow(); |
1035 } | 1036 } |
1036 | 1037 |
1037 static void do_group(char *arg) | 1038 static void do_group(char *arg) |
1038 { | 1039 { |
1104 do_group_return: | 1105 do_group_return: |
1105 free_arg_lst(paramlst); | 1106 free_arg_lst(paramlst); |
1106 } | 1107 } |
1107 | 1108 |
1108 static int send_message_to(const char *fjid, const char *msg, const char *subj, | 1109 static int send_message_to(const char *fjid, const char *msg, const char *subj, |
1109 const char *type_overwrite, bool quiet) | 1110 LmMessageSubType type_overwrite, bool quiet) |
1110 { | 1111 { |
1111 char *bare_jid, *rp; | 1112 char *bare_jid, *rp; |
1112 char *hmsg; | 1113 char *hmsg; |
1113 gint crypted; | 1114 gint crypted; |
1114 gint retval = 0; | 1115 gint retval = 0; |
1115 int isroom; | 1116 int isroom; |
1116 | 1117 |
1117 if (!jb_getonline()) { | 1118 if (!lm_connection_is_authenticated(lconnection)) { |
1118 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); | 1119 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
1119 return 1; | 1120 return 1; |
1120 } | 1121 } |
1121 if (!fjid || !*fjid) { | 1122 if (!fjid || !*fjid) { |
1122 scr_LogPrint(LPRINT_NORMAL, "You must specify a Jabber ID."); | 1123 scr_LogPrint(LPRINT_NORMAL, "You must specify a Jabber ID."); |
1158 hmsg = g_strdup_printf("[%s]\n%s", subj, msg); | 1159 hmsg = g_strdup_printf("[%s]\n%s", subj, msg); |
1159 else | 1160 else |
1160 hmsg = (char*)msg; | 1161 hmsg = (char*)msg; |
1161 | 1162 |
1162 // Network part | 1163 // Network part |
1163 jb_send_msg(fjid, msg, (isroom ? ROSTER_TYPE_ROOM : ROSTER_TYPE_USER), | 1164 xmpp_send_msg(fjid, msg, (isroom ? ROSTER_TYPE_ROOM : ROSTER_TYPE_USER), |
1164 subj, NULL, &crypted, type_overwrite); | 1165 subj, FALSE, &crypted, type_overwrite); |
1165 | 1166 |
1166 if (crypted == -1) { | 1167 if (crypted == -1) { |
1167 scr_LogPrint(LPRINT_LOGNORM, "Encryption error. Message was not sent."); | 1168 scr_LogPrint(LPRINT_LOGNORM, "Encryption error. Message was not sent."); |
1168 retval = 1; | 1169 retval = 1; |
1169 goto send_message_to_return; | 1170 goto send_message_to_return; |
1181 | 1182 |
1182 // send_message(msg, subj, type_overwrite) | 1183 // send_message(msg, subj, type_overwrite) |
1183 // Write the message in the buddy's window and send the message on | 1184 // Write the message in the buddy's window and send the message on |
1184 // the network. | 1185 // the network. |
1185 static void send_message(const char *msg, const char *subj, | 1186 static void send_message(const char *msg, const char *subj, |
1186 const char *type_overwrite) | 1187 LmMessageSubType type_overwrite) |
1187 { | 1188 { |
1188 const char *bjid; | 1189 const char *bjid; |
1189 | 1190 |
1190 if (!current_buddy) { | 1191 if (!current_buddy) { |
1191 scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected."); | 1192 scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected."); |
1199 } | 1200 } |
1200 | 1201 |
1201 send_message_to(bjid, msg, subj, type_overwrite, FALSE); | 1202 send_message_to(bjid, msg, subj, type_overwrite, FALSE); |
1202 } | 1203 } |
1203 | 1204 |
1204 static const char *scan_mtype(char **arg) | 1205 static LmMessageSubType scan_mtype(char **arg) |
1205 { | 1206 { |
1206 //Try splitting it | 1207 //Try splitting it |
1207 char **parlist = split_arg(*arg, 2, 1); | 1208 char **parlist = split_arg(*arg, 2, 1); |
1208 const char *result = NULL; | 1209 LmMessageSubType result = LM_MESSAGE_SUB_TYPE_NOT_SET; |
1209 //Is it any good parameter? | 1210 //Is it any good parameter? |
1210 if (parlist && *parlist) { | 1211 if (parlist && *parlist) { |
1211 if (!strcmp("-n", *parlist)) { | 1212 if (!strcmp("-n", *parlist)) { |
1212 result = TMSG_NORMAL; | 1213 result = LM_MESSAGE_SUB_TYPE_NORMAL; |
1213 } else if (!strcmp("-h", *parlist)) { | 1214 } else if (!strcmp("-h", *parlist)) { |
1214 result = TMSG_HEADLINE; | 1215 result = LM_MESSAGE_SUB_TYPE_HEADLINE; |
1215 } | 1216 } |
1216 if (result || (!strcmp("--", *parlist))) | 1217 if (result != LM_MESSAGE_SUB_TYPE_NOT_SET || (!strcmp("--", *parlist))) |
1217 *arg += strlen(*arg) - (parlist[1] ? strlen(parlist[1]) : 0); | 1218 *arg += strlen(*arg) - (parlist[1] ? strlen(parlist[1]) : 0); |
1218 } | 1219 } |
1219 //Anything found? -> skip it | 1220 //Anything found? -> skip it |
1220 free_arg_lst(parlist); | 1221 free_arg_lst(parlist); |
1221 return result; | 1222 return result; |
1222 } | 1223 } |
1223 | 1224 |
1224 static void do_say_internal(char *arg, int parse_flags) | 1225 static void do_say_internal(char *arg, int parse_flags) |
1225 { | 1226 { |
1226 gpointer bud; | 1227 gpointer bud; |
1227 const char *msgtype = NULL; | 1228 LmMessageSubType msgtype = LM_MESSAGE_SUB_TYPE_NOT_SET; |
1228 | 1229 |
1229 scr_set_chatmode(TRUE); | 1230 scr_set_chatmode(TRUE); |
1230 scr_ShowBuddyWindow(); | 1231 scr_ShowBuddyWindow(); |
1231 | 1232 |
1232 if (!current_buddy) { | 1233 if (!current_buddy) { |
1328 scr_ShowBuddyWindow(); | 1329 scr_ShowBuddyWindow(); |
1329 | 1330 |
1330 if (!strcasecmp(subcmd, "send_to")) { | 1331 if (!strcasecmp(subcmd, "send_to")) { |
1331 int err = FALSE; | 1332 int err = FALSE; |
1332 gchar *msg_utf8; | 1333 gchar *msg_utf8; |
1333 const char *msg_type = scan_mtype(&arg); | 1334 LmMessageSubType msg_type = scan_mtype(&arg); |
1334 // Let's send to the specified JID. We leave now if there | 1335 // Let's send to the specified JID. We leave now if there |
1335 // has been an error (so we don't leave multi-line mode). | 1336 // has been an error (so we don't leave multi-line mode). |
1336 arg = to_utf8(arg); | 1337 arg = to_utf8(arg); |
1337 msg_utf8 = to_utf8(scr_get_multiline()); | 1338 msg_utf8 = to_utf8(scr_get_multiline()); |
1338 if (msg_utf8) { | 1339 if (msg_utf8) { |
1454 static void do_say_to(char *arg) | 1455 static void do_say_to(char *arg) |
1455 { | 1456 { |
1456 char **paramlst; | 1457 char **paramlst; |
1457 char *fjid, *msg; | 1458 char *fjid, *msg; |
1458 char *file = NULL; | 1459 char *file = NULL; |
1459 const char *msg_type = NULL; | 1460 LmMessageSubType msg_type = LM_MESSAGE_SUB_TYPE_NOT_SET; |
1460 bool quiet = FALSE; | 1461 bool quiet = FALSE; |
1461 | 1462 |
1462 if (!jb_getonline()) { | 1463 if (!lm_connection_is_authenticated(lconnection)) { |
1463 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); | 1464 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
1464 return; | 1465 return; |
1465 } | 1466 } |
1466 | 1467 |
1467 msg_type = scan_mtype(&arg); | 1468 msg_type = scan_mtype(&arg); |
1797 | 1798 |
1798 // Tell the user if this item has an annotation. | 1799 // Tell the user if this item has an annotation. |
1799 if (type == ROSTER_TYPE_USER || | 1800 if (type == ROSTER_TYPE_USER || |
1800 type == ROSTER_TYPE_ROOM || | 1801 type == ROSTER_TYPE_ROOM || |
1801 type == ROSTER_TYPE_AGENT) { | 1802 type == ROSTER_TYPE_AGENT) { |
1802 struct annotation *note = jb_get_storage_rosternotes(bjid, TRUE); | 1803 struct annotation *note = xmpp_get_storage_rosternotes(bjid, TRUE); |
1803 if (note) { | 1804 if (note) { |
1804 // We do not display the note, we just tell the user. | 1805 // We do not display the note, we just tell the user. |
1805 g_free(note->text); | 1806 g_free(note->text); |
1806 g_free(note->jid); | 1807 g_free(note->jid); |
1807 g_free(note); | 1808 g_free(note); |
1906 groupname = (char *)groupnamedata; | 1907 groupname = (char *)groupnamedata; |
1907 | 1908 |
1908 bjid = buddy_getjid(bud); | 1909 bjid = buddy_getjid(bud); |
1909 name = buddy_getname(bud); | 1910 name = buddy_getname(bud); |
1910 | 1911 |
1911 jb_updatebuddy(bjid, name, *groupname ? groupname : NULL); | 1912 xmpp_updatebuddy(bjid, name, *groupname ? groupname : NULL); |
1912 } | 1913 } |
1913 | 1914 |
1914 static void do_rename(char *arg) | 1915 static void do_rename(char *arg) |
1915 { | 1916 { |
1916 gpointer bud; | 1917 gpointer bud; |
1940 | 1941 |
1941 if (!(type & ROSTER_TYPE_GROUP) && !on_srv) { | 1942 if (!(type & ROSTER_TYPE_GROUP) && !on_srv) { |
1942 scr_LogPrint(LPRINT_NORMAL, | 1943 scr_LogPrint(LPRINT_NORMAL, |
1943 "Note: this item will be added to your server roster."); | 1944 "Note: this item will be added to your server roster."); |
1944 // If this is a MUC room w/o bookmark, let's give a small hint... | 1945 // If this is a MUC room w/o bookmark, let's give a small hint... |
1945 if (!jb_is_bookmarked(bjid)) { | 1946 if (!xmpp_is_bookmarked(bjid)) { |
1946 scr_LogPrint(LPRINT_NORMAL, | 1947 scr_LogPrint(LPRINT_NORMAL, |
1947 "You should add a room bookmark or it will not be " | 1948 "You should add a room bookmark or it will not be " |
1948 "recognized as a MUC room next time you run mcabber."); | 1949 "recognized as a MUC room next time you run mcabber."); |
1949 } | 1950 } |
1950 } | 1951 } |
1968 // Rename a single buddy | 1969 // Rename a single buddy |
1969 guint del_name = 0; | 1970 guint del_name = 0; |
1970 if (!*newname || !strcmp(arg, "-")) | 1971 if (!*newname || !strcmp(arg, "-")) |
1971 del_name = TRUE; | 1972 del_name = TRUE; |
1972 buddy_setname(bud, (del_name ? (char*)bjid : name_utf8)); | 1973 buddy_setname(bud, (del_name ? (char*)bjid : name_utf8)); |
1973 jb_updatebuddy(bjid, (del_name ? NULL : name_utf8), group); | 1974 xmpp_updatebuddy(bjid, (del_name ? NULL : name_utf8), group); |
1974 } | 1975 } |
1975 | 1976 |
1976 g_free(name_utf8); | 1977 g_free(name_utf8); |
1977 g_free(newname); | 1978 g_free(newname); |
1978 update_roster = TRUE; | 1979 update_roster = TRUE; |
2014 | 2015 |
2015 group_utf8 = to_utf8(newgroupname); | 2016 group_utf8 = to_utf8(newgroupname); |
2016 if (strcmp(oldgroupname, group_utf8)) { | 2017 if (strcmp(oldgroupname, group_utf8)) { |
2017 guint msgflag; | 2018 guint msgflag; |
2018 | 2019 |
2019 jb_updatebuddy(bjid, name, *group_utf8 ? group_utf8 : NULL); | 2020 xmpp_updatebuddy(bjid, name, *group_utf8 ? group_utf8 : NULL); |
2020 scr_RosterUpDown(-1, 1); | 2021 scr_RosterUpDown(-1, 1); |
2021 | 2022 |
2022 // If the buddy has a pending message flag, | 2023 // If the buddy has a pending message flag, |
2023 // we remove it temporarily in order to reset the global group | 2024 // we remove it temporarily in order to reset the global group |
2024 // flag. We set it back once the buddy is in the new group, | 2025 // flag. We set it back once the buddy is in the new group, |
2165 static void do_rawxml(char *arg) | 2166 static void do_rawxml(char *arg) |
2166 { | 2167 { |
2167 char **paramlst; | 2168 char **paramlst; |
2168 char *subcmd; | 2169 char *subcmd; |
2169 | 2170 |
2170 if (!jb_getonline()) { | 2171 if (!lm_connection_is_authenticated(lconnection)) { |
2171 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); | 2172 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
2172 return; | 2173 return; |
2173 } | 2174 } |
2174 | 2175 |
2175 paramlst = split_arg(arg, 2, 1); // subcmd, arg | 2176 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
2196 // the user to escape quotes in a XML stream... | 2197 // the user to escape quotes in a XML stream... |
2197 | 2198 |
2198 buffer = to_utf8(arg); | 2199 buffer = to_utf8(arg); |
2199 if (buffer) { | 2200 if (buffer) { |
2200 scr_LogPrint(LPRINT_NORMAL, "Sending XML string"); | 2201 scr_LogPrint(LPRINT_NORMAL, "Sending XML string"); |
2201 jb_send_raw(buffer); | 2202 lm_connection_send_raw(lconnection, buffer, NULL); |
2202 g_free(buffer); | 2203 g_free(buffer); |
2203 } else { | 2204 } else { |
2204 scr_LogPrint(LPRINT_NORMAL, "Conversion error in XML string."); | 2205 scr_LogPrint(LPRINT_NORMAL, "Conversion error in XML string."); |
2205 } | 2206 } |
2206 } else { | 2207 } else { |
2288 return; | 2289 return; |
2289 } | 2290 } |
2290 | 2291 |
2291 pass_utf8 = to_utf8(pass); | 2292 pass_utf8 = to_utf8(pass); |
2292 | 2293 |
2293 jb_room_join(roomname, nick, pass_utf8); | 2294 xmpp_room_join(roomname, nick, pass_utf8); |
2294 | 2295 |
2295 scr_LogPrint(LPRINT_LOGNORM, "Sent a join request to <%s>...", roomname); | 2296 scr_LogPrint(LPRINT_LOGNORM, "Sent a join request to <%s>...", roomname); |
2296 | 2297 |
2297 g_free(roomname_tmp); | 2298 g_free(roomname_tmp); |
2298 g_free(nick); | 2299 g_free(nick); |
2322 return; | 2323 return; |
2323 } | 2324 } |
2324 | 2325 |
2325 roomname = buddy_getjid(bud); | 2326 roomname = buddy_getjid(bud); |
2326 reason_utf8 = to_utf8(arg); | 2327 reason_utf8 = to_utf8(arg); |
2327 jb_room_invite(roomname, fjid, reason_utf8); | 2328 xmpp_room_invite(roomname, fjid, reason_utf8); |
2328 scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>.", fjid); | 2329 scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>.", fjid); |
2329 g_free(reason_utf8); | 2330 g_free(reason_utf8); |
2330 free_arg_lst(paramlst); | 2331 free_arg_lst(paramlst); |
2331 } | 2332 } |
2332 | 2333 |
2356 | 2357 |
2357 if (ra.val.affil < imaffiliation_size) { | 2358 if (ra.val.affil < imaffiliation_size) { |
2358 gchar *jid_utf8, *reason_utf8; | 2359 gchar *jid_utf8, *reason_utf8; |
2359 jid_utf8 = to_utf8(fjid); | 2360 jid_utf8 = to_utf8(fjid); |
2360 reason_utf8 = to_utf8(arg); | 2361 reason_utf8 = to_utf8(arg); |
2361 jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); | 2362 xmpp_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); |
2362 g_free(jid_utf8); | 2363 g_free(jid_utf8); |
2363 g_free(reason_utf8); | 2364 g_free(reason_utf8); |
2364 } else | 2365 } else |
2365 scr_LogPrint(LPRINT_NORMAL, "Wrong affiliation parameter."); | 2366 scr_LogPrint(LPRINT_NORMAL, "Wrong affiliation parameter."); |
2366 | 2367 |
2393 | 2394 |
2394 if (ra.val.role < imrole_size) { | 2395 if (ra.val.role < imrole_size) { |
2395 gchar *jid_utf8, *reason_utf8; | 2396 gchar *jid_utf8, *reason_utf8; |
2396 jid_utf8 = to_utf8(fjid); | 2397 jid_utf8 = to_utf8(fjid); |
2397 reason_utf8 = to_utf8(arg); | 2398 reason_utf8 = to_utf8(arg); |
2398 jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); | 2399 xmpp_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); |
2399 g_free(jid_utf8); | 2400 g_free(jid_utf8); |
2400 g_free(reason_utf8); | 2401 g_free(reason_utf8); |
2401 } else | 2402 } else |
2402 scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter."); | 2403 scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter."); |
2403 | 2404 |
2449 banjid = jid_utf8; | 2450 banjid = jid_utf8; |
2450 | 2451 |
2451 scr_LogPrint(LPRINT_NORMAL, "Requesting a ban for %s", banjid); | 2452 scr_LogPrint(LPRINT_NORMAL, "Requesting a ban for %s", banjid); |
2452 | 2453 |
2453 reason_utf8 = to_utf8(arg); | 2454 reason_utf8 = to_utf8(arg); |
2454 jb_room_setattrib(roomid, banjid, NULL, ra, reason_utf8); | 2455 xmpp_room_setattrib(roomid, banjid, NULL, ra, reason_utf8); |
2455 g_free(reason_utf8); | 2456 g_free(reason_utf8); |
2456 | 2457 |
2457 room_ban_return: | 2458 room_ban_return: |
2458 g_free(bjid); | 2459 g_free(bjid); |
2459 g_free(jid_utf8); | 2460 g_free(jid_utf8); |
2475 | 2476 |
2476 ra.type = type_affil; | 2477 ra.type = type_affil; |
2477 ra.val.affil = affil_none; | 2478 ra.val.affil = affil_none; |
2478 | 2479 |
2479 jid_utf8 = to_utf8(fjid); | 2480 jid_utf8 = to_utf8(fjid); |
2480 jb_room_setattrib(roomid, jid_utf8, NULL, ra, NULL); | 2481 xmpp_room_setattrib(roomid, jid_utf8, NULL, ra, NULL); |
2481 g_free(jid_utf8); | 2482 g_free(jid_utf8); |
2482 } | 2483 } |
2483 | 2484 |
2484 // The expected argument is a nickname | 2485 // The expected argument is a nickname |
2485 static void room_kick(gpointer bud, char *arg) | 2486 static void room_kick(gpointer bud, char *arg) |
2503 ra.type = type_role; | 2504 ra.type = type_role; |
2504 ra.val.affil = role_none; | 2505 ra.val.affil = role_none; |
2505 | 2506 |
2506 nick_utf8 = to_utf8(nick); | 2507 nick_utf8 = to_utf8(nick); |
2507 reason_utf8 = to_utf8(arg); | 2508 reason_utf8 = to_utf8(arg); |
2508 jb_room_setattrib(roomid, NULL, nick_utf8, ra, reason_utf8); | 2509 xmpp_room_setattrib(roomid, NULL, nick_utf8, ra, reason_utf8); |
2509 g_free(nick_utf8); | 2510 g_free(nick_utf8); |
2510 g_free(reason_utf8); | 2511 g_free(reason_utf8); |
2511 | 2512 |
2512 free_arg_lst(paramlst); | 2513 free_arg_lst(paramlst); |
2513 } | 2514 } |
2523 return; | 2524 return; |
2524 } | 2525 } |
2525 | 2526 |
2526 roomid = g_strdup_printf("%s/%s", buddy_getjid(bud), nickname); | 2527 roomid = g_strdup_printf("%s/%s", buddy_getjid(bud), nickname); |
2527 desc = to_utf8(arg); | 2528 desc = to_utf8(arg); |
2528 jb_setstatus(offline, roomid, desc, TRUE); | 2529 xmpp_setstatus(offline, roomid, desc, TRUE); |
2529 g_free(desc); | 2530 g_free(desc); |
2530 g_free(roomid); | 2531 g_free(roomid); |
2531 } | 2532 } |
2532 | 2533 |
2533 static void room_nick(gpointer bud, char *arg) | 2534 static void room_nick(gpointer bud, char *arg) |
2551 g_free(roomname_tmp); | 2552 g_free(roomname_tmp); |
2552 | 2553 |
2553 nick = to_utf8(arg); | 2554 nick = to_utf8(arg); |
2554 strip_arg_special_chars(nick); | 2555 strip_arg_special_chars(nick); |
2555 | 2556 |
2556 jb_room_join(roomname, nick, NULL); | 2557 xmpp_room_join(roomname, nick, NULL); |
2557 g_free(roomname); | 2558 g_free(roomname); |
2558 g_free(nick); | 2559 g_free(nick); |
2559 } | 2560 } |
2560 } | 2561 } |
2561 | 2562 |
2576 } | 2577 } |
2577 | 2578 |
2578 fjid = g_strdup_printf("%s/%s", buddy_getjid(bud), nick); | 2579 fjid = g_strdup_printf("%s/%s", buddy_getjid(bud), nick); |
2579 fjid_utf8 = to_utf8(fjid); | 2580 fjid_utf8 = to_utf8(fjid); |
2580 msg = to_utf8(arg); | 2581 msg = to_utf8(arg); |
2581 send_message_to(fjid_utf8, msg, NULL, NULL, FALSE); | 2582 send_message_to(fjid_utf8, msg, NULL, LM_MESSAGE_SUB_TYPE_NOT_SET, FALSE); |
2582 g_free(fjid); | 2583 g_free(fjid); |
2583 g_free(fjid_utf8); | 2584 g_free(fjid_utf8); |
2584 g_free(msg); | 2585 g_free(msg); |
2585 free_arg_lst(paramlst); | 2586 free_arg_lst(paramlst); |
2586 } | 2587 } |
2626 if (!strcmp(arg, "-")) | 2627 if (!strcmp(arg, "-")) |
2627 arg = NULL; | 2628 arg = NULL; |
2628 | 2629 |
2629 arg = to_utf8(arg); | 2630 arg = to_utf8(arg); |
2630 // Set the topic | 2631 // Set the topic |
2631 jb_send_msg(buddy_getjid(bud), NULL, ROSTER_TYPE_ROOM, arg ? arg : "", | 2632 xmpp_send_msg(buddy_getjid(bud), NULL, ROSTER_TYPE_ROOM, arg ? arg : "", |
2632 NULL, NULL, NULL); | 2633 FALSE, NULL, LM_MESSAGE_SUB_TYPE_NOT_SET); |
2633 g_free(arg); | 2634 g_free(arg); |
2634 } | 2635 } |
2635 | 2636 |
2636 static void room_destroy(gpointer bud, char *arg) | 2637 static void room_destroy(gpointer bud, char *arg) |
2637 { | 2638 { |
2640 if (arg && *arg) | 2641 if (arg && *arg) |
2641 msg = to_utf8(arg); | 2642 msg = to_utf8(arg); |
2642 else | 2643 else |
2643 msg = NULL; | 2644 msg = NULL; |
2644 | 2645 |
2645 jb_room_destroy(buddy_getjid(bud), NULL, msg); | 2646 xmpp_room_destroy(buddy_getjid(bud), NULL, msg); |
2646 g_free(msg); | 2647 g_free(msg); |
2647 } | 2648 } |
2648 | 2649 |
2649 static void room_unlock(gpointer bud, char *arg) | 2650 static void room_unlock(gpointer bud, char *arg) |
2650 { | 2651 { |
2651 if (*arg) { | 2652 if (*arg) { |
2652 scr_LogPrint(LPRINT_NORMAL, "Unknown parameter."); | 2653 scr_LogPrint(LPRINT_NORMAL, "Unknown parameter."); |
2653 return; | 2654 return; |
2654 } | 2655 } |
2655 | 2656 |
2656 jb_room_unlock(buddy_getjid(bud)); | 2657 xmpp_room_unlock(buddy_getjid(bud)); |
2657 } | 2658 } |
2658 | 2659 |
2659 static void room_setopt(gpointer bud, char *arg) | 2660 static void room_setopt(gpointer bud, char *arg) |
2660 { | 2661 { |
2661 char **paramlst; | 2662 char **paramlst; |
2846 nick = buddy_getnickname(bud); | 2847 nick = buddy_getnickname(bud); |
2847 printstatus = buddy_getprintstatus(bud); | 2848 printstatus = buddy_getprintstatus(bud); |
2848 autowhois = buddy_getautowhois(bud); | 2849 autowhois = buddy_getautowhois(bud); |
2849 } | 2850 } |
2850 | 2851 |
2851 jb_set_storage_bookmark(roomid, name, nick, NULL, autojoin, | 2852 xmpp_set_storage_bookmark(roomid, name, nick, NULL, autojoin, |
2852 printstatus, autowhois); | 2853 printstatus, autowhois); |
2853 } | 2854 } |
2854 | 2855 |
2855 static void display_all_bookmarks(void) | 2856 static void display_all_bookmarks(void) |
2856 { | 2857 { |
2857 GSList *bm, *bmp; | 2858 GSList *bm, *bmp; |
2858 GString *sbuf; | 2859 GString *sbuf; |
2859 struct bookmark *bm_elt; | 2860 struct bookmark *bm_elt; |
2860 | 2861 |
2861 bm = jb_get_all_storage_bookmarks(); | 2862 bm = xmpp_get_all_storage_bookmarks(); |
2862 | 2863 |
2863 if (!bm) | 2864 if (!bm) |
2864 return; | 2865 return; |
2865 | 2866 |
2866 sbuf = g_string_new(""); | 2867 sbuf = g_string_new(""); |
2895 { | 2896 { |
2896 char **paramlst; | 2897 char **paramlst; |
2897 char *subcmd; | 2898 char *subcmd; |
2898 gpointer bud; | 2899 gpointer bud; |
2899 | 2900 |
2900 if (!jb_getonline()) { | 2901 if (!lm_connection_is_authenticated(lconnection)) { |
2901 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); | 2902 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
2902 return; | 2903 return; |
2903 } | 2904 } |
2904 | 2905 |
2905 paramlst = split_arg(arg, 2, 1); // subcmd, arg | 2906 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
2992 { | 2993 { |
2993 char **paramlst; | 2994 char **paramlst; |
2994 char *subcmd; | 2995 char *subcmd; |
2995 char *jid_utf8; | 2996 char *jid_utf8; |
2996 | 2997 |
2997 if (!jb_getonline()) { | 2998 if (!lm_connection_is_authenticated(lconnection)) { |
2998 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); | 2999 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
2999 return; | 3000 return; |
3000 } | 3001 } |
3001 | 3002 |
3002 paramlst = split_arg(arg, 2, 0); // subcmd, [jid] | 3003 paramlst = split_arg(arg, 2, 0); // subcmd, [jid] |
3040 } else { | 3041 } else { |
3041 jid_utf8 = to_utf8(arg); | 3042 jid_utf8 = to_utf8(arg); |
3042 } | 3043 } |
3043 | 3044 |
3044 if (!strcasecmp(subcmd, "allow")) { | 3045 if (!strcasecmp(subcmd, "allow")) { |
3045 jb_subscr_send_auth(jid_utf8); | 3046 xmpp_send_s10n(jid_utf8, LM_MESSAGE_SUB_TYPE_SUBSCRIBED); |
3046 scr_LogPrint(LPRINT_LOGNORM, | 3047 scr_LogPrint(LPRINT_LOGNORM, |
3047 "<%s> is now allowed to receive your presence updates.", | 3048 "<%s> is now allowed to receive your presence updates.", |
3048 jid_utf8); | 3049 jid_utf8); |
3049 } else if (!strcasecmp(subcmd, "cancel")) { | 3050 } else if (!strcasecmp(subcmd, "cancel")) { |
3050 jb_subscr_cancel_auth(jid_utf8); | 3051 xmpp_send_s10n(jid_utf8, LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED); |
3051 scr_LogPrint(LPRINT_LOGNORM, | 3052 scr_LogPrint(LPRINT_LOGNORM, |
3052 "<%s> will no longer receive your presence updates.", | 3053 "<%s> will no longer receive your presence updates.", |
3053 jid_utf8); | 3054 jid_utf8); |
3054 } else if (!strcasecmp(subcmd, "request")) { | 3055 } else if (!strcasecmp(subcmd, "request")) { |
3055 jb_subscr_request_auth(jid_utf8); | 3056 xmpp_send_s10n(jid_utf8, LM_MESSAGE_SUB_TYPE_SUBSCRIBE); |
3056 scr_LogPrint(LPRINT_LOGNORM, | 3057 scr_LogPrint(LPRINT_LOGNORM, |
3057 "Sent presence notification request to <%s>.", jid_utf8); | 3058 "Sent presence notification request to <%s>.", jid_utf8); |
3058 } else if (!strcasecmp(subcmd, "request_unsubscribe")) { | 3059 } else if (!strcasecmp(subcmd, "request_unsubscribe")) { |
3059 jb_subscr_request_cancel(jid_utf8); | 3060 xmpp_send_s10n(jid_utf8, LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE); |
3060 scr_LogPrint(LPRINT_LOGNORM, | 3061 scr_LogPrint(LPRINT_LOGNORM, |
3061 "Sent presence notification unsubscription request to <%s>.", | 3062 "Sent presence notification unsubscription request to <%s>.", |
3062 jid_utf8); | 3063 jid_utf8); |
3063 } else { | 3064 } else { |
3064 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); | 3065 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
3097 numtype = iqreq_time; | 3098 numtype = iqreq_time; |
3098 else if (!strcasecmp(type, "last")) | 3099 else if (!strcasecmp(type, "last")) |
3099 numtype = iqreq_last; | 3100 numtype = iqreq_last; |
3100 else if (!strcasecmp(type, "vcard")) | 3101 else if (!strcasecmp(type, "vcard")) |
3101 numtype = iqreq_vcard; | 3102 numtype = iqreq_vcard; |
3102 else if (!strcasecmp(type, "show_list")) { | |
3103 // Undocumented command, for debugging purposes only | |
3104 jb_iqs_display_list(); | |
3105 free_arg_lst(paramlst); | |
3106 return; | |
3107 } | |
3108 } | 3103 } |
3109 | 3104 |
3110 if (!type || !numtype) { | 3105 if (!type || !numtype) { |
3111 scr_LogPrint(LPRINT_NORMAL, | 3106 scr_LogPrint(LPRINT_NORMAL, |
3112 "Please specify a query type (version, time...)."); | 3107 "Please specify a query type (version, time...)."); |
3113 free_arg_lst(paramlst); | 3108 free_arg_lst(paramlst); |
3114 return; | 3109 return; |
3115 } | 3110 } |
3116 | 3111 |
3117 if (!jb_getonline()) { | 3112 if (!lm_connection_is_authenticated(lconnection)) { |
3118 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); | 3113 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
3119 free_arg_lst(paramlst); | 3114 free_arg_lst(paramlst); |
3120 return; | 3115 return; |
3121 } | 3116 } |
3122 | 3117 |
3149 switch (numtype) { | 3144 switch (numtype) { |
3150 case iqreq_version: | 3145 case iqreq_version: |
3151 case iqreq_time: | 3146 case iqreq_time: |
3152 case iqreq_last: | 3147 case iqreq_last: |
3153 case iqreq_vcard: | 3148 case iqreq_vcard: |
3154 jb_request(fjid, numtype); | 3149 xmpp_request(fjid, numtype); |
3155 break; | 3150 break; |
3156 default: | 3151 default: |
3157 break; | 3152 break; |
3158 } | 3153 } |
3159 } | 3154 } |
3460 scr_LogPrint(LPRINT_NORMAL, "Please recompile mcabber with libotr enabled."); | 3455 scr_LogPrint(LPRINT_NORMAL, "Please recompile mcabber with libotr enabled."); |
3461 #endif /* HAVE_LIBOTR */ | 3456 #endif /* HAVE_LIBOTR */ |
3462 } | 3457 } |
3463 | 3458 |
3464 #ifdef HAVE_LIBOTR | 3459 #ifdef HAVE_LIBOTR |
3465 static char * string_for_otrpolicy(enum otr_policy p) | 3460 static char *string_for_otrpolicy(enum otr_policy p) |
3466 { | 3461 { |
3467 switch (p) { | 3462 switch (p) { |
3468 case plain: return "plain"; | 3463 case plain: return "plain"; |
3469 case opportunistic: return "opportunistic"; | 3464 case opportunistic: return "opportunistic"; |
3470 case manual: return "manual"; | 3465 case manual: return "manual"; |
3471 case always: return "always"; | 3466 case always: return "always"; |
3472 default: return "unknown"; | 3467 default: return "unknown"; |
3473 } | 3468 } |
3474 } | 3469 } |
3475 | 3470 |
3476 static void dump_otrpolicy(char * k, char * v, void * nothing) | 3471 static void dump_otrpolicy(char *k, char *v, void *nothing) |
3477 { | 3472 { |
3478 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, "otrpolicy for %s: %s", k, | 3473 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, "otrpolicy for %s: %s", k, |
3479 string_for_otrpolicy(*(enum otr_policy*)v)); | 3474 string_for_otrpolicy(*(enum otr_policy*)v)); |
3480 } | 3475 } |
3481 #endif | 3476 #endif |
3668 g_free(expfname); | 3663 g_free(expfname); |
3669 } | 3664 } |
3670 | 3665 |
3671 static void do_connect(char *arg) | 3666 static void do_connect(char *arg) |
3672 { | 3667 { |
3673 mcabber_connect(); | 3668 xmpp_connect(); |
3674 } | 3669 } |
3675 | 3670 |
3676 static void do_disconnect(char *arg) | 3671 static void do_disconnect(char *arg) |
3677 { | 3672 { |
3678 jb_disconnect(); | 3673 xmpp_disconnect(); |
3679 AutoConnection = FALSE; | |
3680 } | 3674 } |
3681 | 3675 |
3682 static void do_help(char *arg) | 3676 static void do_help(char *arg) |
3683 { | 3677 { |
3684 help_process(arg); | 3678 help_process(arg); |