69 |
69 |
70 if (args[0]) { |
70 if (args[0]) { |
71 cmd = args[0]; |
71 cmd = args[0]; |
72 |
72 |
73 if (args[1]) { |
73 if (args[1]) { |
74 const char *j = args[1]; |
74 const char *j = args[1]; |
75 if (check_jid_syntax(j)) { |
75 if (check_jid_syntax(j)) { |
76 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
76 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
77 "<%s> is not a valid Jabber ID.", j); |
77 "<%s> is not a valid Jabber ID.", j); |
78 return; |
78 return; |
79 } |
79 } |
80 jid = jidtodisp(j); |
80 jid = jidtodisp(j); |
81 jfree = TRUE; |
81 if (!jid) { |
82 } |
82 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
|
83 "Unexpected error."); |
|
84 return; |
|
85 } |
|
86 jfree = TRUE; |
|
87 } |
83 } else |
88 } else |
84 cmd = "set"; |
89 cmd = "set"; |
85 |
90 |
|
91 if (!jid) { |
|
92 // JID was not provided |
|
93 const char *j = NULL; |
|
94 |
|
95 if (current_buddy) |
|
96 j = CURRENT_JID; |
|
97 |
|
98 if (!j) { |
|
99 scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected."); |
|
100 return; |
|
101 } |
|
102 |
|
103 jid = g_strdup(j); |
|
104 jfree = TRUE; |
|
105 |
|
106 // TODO: handle group marking :) |
|
107 } |
|
108 |
|
109 |
86 if (!strcmp (cmd, "set")) { |
110 if (!strcmp (cmd, "set")) { |
87 |
111 |
88 if (!g_slist_find_custom (marked_jids, jid ? jid : CURRENT_JID, (GCompareFunc) g_strcmp0)) { |
112 if (!g_slist_find_custom (marked_jids, jid, (GCompareFunc) g_strcmp0)) { |
89 marked_jids = g_slist_append (marked_jids, jid ? jid : g_strdup (CURRENT_JID)); |
113 marked_jids = g_slist_append (marked_jids, jid); |
90 marked = 1; |
114 marked = 1; |
91 jfree = FALSE; |
115 jfree = FALSE; |
92 } |
116 } |
93 |
117 |
94 } else if (!strcmp (cmd, "clear")) { |
118 } else if (!strcmp (cmd, "clear")) { |
95 |
119 |
96 GSList *mel = g_slist_find_custom (marked_jids, jid ? jid : CURRENT_JID, (GCompareFunc) g_strcmp0); |
120 GSList *mel = g_slist_find_custom (marked_jids, jid, (GCompareFunc) g_strcmp0); |
97 |
121 |
98 if (mel) { |
122 if (mel) { |
99 g_free (mel->data); |
123 g_free (mel->data); |
100 marked_jids = g_slist_delete_link (marked_jids, mel); |
124 marked_jids = g_slist_delete_link (marked_jids, mel); |
101 marked = 0; |
125 marked = 0; |
102 } |
126 } |
103 |
127 |
104 } else if (!strcmp (cmd, "toggle")) { |
128 } else if (!strcmp (cmd, "toggle")) { |
105 |
129 |
106 GSList *mel = g_slist_find_custom (marked_jids, jid ? jid : CURRENT_JID, (GCompareFunc) g_strcmp0); |
130 GSList *mel = g_slist_find_custom (marked_jids, jid, (GCompareFunc) g_strcmp0); |
107 |
131 |
108 if (mel) { |
132 if (mel) { |
109 g_free (mel->data); |
133 g_free (mel->data); |
110 marked_jids = g_slist_delete_link (marked_jids, mel); |
134 marked_jids = g_slist_delete_link (marked_jids, mel); |
111 marked = 0; |
135 marked = 0; |
112 } else { |
136 } else { |
113 marked_jids = g_slist_append (marked_jids, jid ? jid : g_strdup (CURRENT_JID)); |
137 marked_jids = g_slist_append (marked_jids, jid); |
114 marked = 1; |
138 marked = 1; |
115 jfree = FALSE; |
139 jfree = FALSE; |
116 } |
140 } |
117 } |
141 } |
118 |
142 |
119 if (marked == 1) |
143 if (marked == 1) { |
120 scr_write_incoming_message (jid ? jid : CURRENT_JID, "Marked", 0, HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
144 scr_write_incoming_message (jid, "Marked", 0, |
121 else if (marked == 0) |
145 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
122 scr_write_incoming_message (jid ? jid : CURRENT_JID, "Mark cleared", 0, HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
146 } else if (marked == 0) { |
|
147 scr_write_incoming_message (jid, "Mark cleared", 0, |
|
148 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
|
149 } |
123 |
150 |
124 if (jfree && jid) |
151 if (jfree && jid) |
125 g_free (jid); |
152 g_free (jid); |
126 |
153 |
127 free_arg_lst (args); |
154 free_arg_lst (args); |