author | Myhailo Danylenko <isbear@ukrpost.net> |
Thu, 13 Nov 2014 22:39:40 +0200 | |
changeset 33 | c7259f0fac72 |
parent 31 | 55395c6ef7ea |
child 34 | 1820e2dc90ef |
permissions | -rw-r--r-- |
1
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
1 |
/* |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
2 |
* marking.c -- Actions on multiple buddies |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
3 |
* |
27
b51de2faa028
Cosmetic changes, copyright update
Mikael Berthe <mikael@lilotux.net>
parents:
26
diff
changeset
|
4 |
* Copyright (C) 2009-2012 Myhailo Danylenko <isbear@ukrpost.net> |
b51de2faa028
Cosmetic changes, copyright update
Mikael Berthe <mikael@lilotux.net>
parents:
26
diff
changeset
|
5 |
* Copyright (C) 2012 Mikael Berthe <mikael@lilotux.net> |
1
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
6 |
* |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
7 |
* This program is free software; you can redistribute it and/or modify |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
8 |
* it under the terms of the GNU General Public License as published by |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
9 |
* the Free Software Foundation; either version 2 of the License, or (at |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
10 |
* your option) any later version. |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
11 |
* |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
12 |
* This program is distributed in the hope that it will be useful, but |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
15 |
* General Public License for more details. |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
16 |
* |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
18 |
* along with this program; if not, write to the Free Software |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
20 |
* USA |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
21 |
*/ |
0 | 22 |
|
23 |
#include <glib.h> |
|
24 |
#include <string.h> |
|
25 |
||
2
30b66610f86a
Change mcabber headers naming scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
26 |
#include <mcabber/hbuf.h> |
30b66610f86a
Change mcabber headers naming scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
27 |
#include <mcabber/screen.h> |
30b66610f86a
Change mcabber headers naming scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
28 |
#include <mcabber/commands.h> |
30b66610f86a
Change mcabber headers naming scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
29 |
#include <mcabber/compl.h> |
30b66610f86a
Change mcabber headers naming scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
30 |
#include <mcabber/utils.h> |
30b66610f86a
Change mcabber headers naming scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1
diff
changeset
|
31 |
#include <mcabber/logprint.h> |
10
b84d72957c06
New module loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
2
diff
changeset
|
32 |
#include <mcabber/modules.h> |
b84d72957c06
New module loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
2
diff
changeset
|
33 |
|
11
f7c76b2c9900
Use new module struct with api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
34 |
#include "config.h" |
f7c76b2c9900
Use new module struct with api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
35 |
|
19
c7e7218be611
Update versions and add AVV description
Myhailo Danylenko <isbear@ukrpost.net>
parents:
16
diff
changeset
|
36 |
void marking_init (void); |
c7e7218be611
Update versions and add AVV description
Myhailo Danylenko <isbear@ukrpost.net>
parents:
16
diff
changeset
|
37 |
void marking_uninit (void); |
10
b84d72957c06
New module loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
2
diff
changeset
|
38 |
|
27
b51de2faa028
Cosmetic changes, copyright update
Mikael Berthe <mikael@lilotux.net>
parents:
26
diff
changeset
|
39 |
#define DESCRIPTION ( "Actions on multiple marked buddies\n" \ |
b51de2faa028
Cosmetic changes, copyright update
Mikael Berthe <mikael@lilotux.net>
parents:
26
diff
changeset
|
40 |
"Provides commands /mark and /marked" ) |
11
f7c76b2c9900
Use new module struct with api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
41 |
|
22
cbae62eecb1d
Use build-time api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
21
diff
changeset
|
42 |
module_info_t info_marking = { |
cbae62eecb1d
Use build-time api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
21
diff
changeset
|
43 |
.branch = MCABBER_BRANCH, |
cbae62eecb1d
Use build-time api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
21
diff
changeset
|
44 |
.api = MCABBER_API_VERSION, |
11
f7c76b2c9900
Use new module struct with api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
45 |
.version = PROJECT_VERSION, |
f7c76b2c9900
Use new module struct with api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
46 |
.description = DESCRIPTION, |
f7c76b2c9900
Use new module struct with api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
47 |
.requires = NULL, |
f7c76b2c9900
Use new module struct with api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
48 |
.init = marking_init, |
f7c76b2c9900
Use new module struct with api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
49 |
.uninit = marking_uninit, |
f7c76b2c9900
Use new module struct with api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
50 |
.next = NULL, |
f7c76b2c9900
Use new module struct with api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
51 |
}; |
f7c76b2c9900
Use new module struct with api version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
52 |
|
19
c7e7218be611
Update versions and add AVV description
Myhailo Danylenko <isbear@ukrpost.net>
parents:
16
diff
changeset
|
53 |
#ifdef MCABBER_API_HAVE_CMD_ID |
15
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
54 |
static gpointer mark_cmid = NULL; |
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
55 |
static gpointer marked_cmid = NULL; |
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
56 |
#endif |
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
57 |
|
0 | 58 |
static GSList *marked_jids = NULL; |
59 |
||
60 |
// mark set jid |
|
61 |
// mark clear jid |
|
62 |
// mark toggle jid |
|
63 |
static void do_mark (char *arg) |
|
64 |
{ |
|
65 |
char **args = split_arg (arg, 2, 1); |
|
66 |
char *cmd = NULL; |
|
67 |
char *jid = NULL; |
|
68 |
gboolean jfree = FALSE; |
|
69 |
int marked = -1; |
|
26
24ed43268d29
Display a message when marking/unmarking a contact
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
70 |
guint len; |
0 | 71 |
|
72 |
if (args[0]) { |
|
73 |
cmd = args[0]; |
|
74 |
||
23
66455f258c64
Check user-supplied JID, change memory allocation tracking logic
Mikael Berthe <mikael@lilotux.net>
parents:
22
diff
changeset
|
75 |
if (args[1]) { |
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
76 |
const char *j = args[1]; |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
77 |
if (check_jid_syntax(j)) { |
30 | 78 |
scr_log_print(LPRINT_NORMAL|LPRINT_NOTUTF8, |
79 |
"<%s> is not a valid Jabber ID.", j); |
|
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
80 |
return; |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
81 |
} |
29 | 82 |
jid = g_strdup(j); |
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
83 |
if (!jid) { |
30 | 84 |
scr_log_print (LPRINT_NORMAL|LPRINT_NOTUTF8, |
85 |
"Unexpected error."); |
|
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
86 |
return; |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
87 |
} |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
88 |
jfree = TRUE; |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
89 |
} |
0 | 90 |
} else |
91 |
cmd = "set"; |
|
23
66455f258c64
Check user-supplied JID, change memory allocation tracking logic
Mikael Berthe <mikael@lilotux.net>
parents:
22
diff
changeset
|
92 |
|
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
93 |
if (!jid) { |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
94 |
// JID was not provided |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
95 |
const char *j = NULL; |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
96 |
|
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
97 |
if (current_buddy) |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
98 |
j = CURRENT_JID; |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
99 |
|
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
100 |
if (!j) { |
30 | 101 |
scr_log_print (LPRINT_NORMAL, "No buddy is currently selected."); |
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
102 |
return; |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
103 |
} |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
104 |
|
30 | 105 |
jid = g_strdup (j); |
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
106 |
jfree = TRUE; |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
107 |
} |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
108 |
|
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
109 |
|
0 | 110 |
if (!strcmp (cmd, "set")) { |
111 |
||
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
112 |
if (!g_slist_find_custom (marked_jids, jid, (GCompareFunc) g_strcmp0)) { |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
113 |
marked_jids = g_slist_append (marked_jids, jid); |
30 | 114 |
marked = 1; |
115 |
jfree = FALSE; |
|
23
66455f258c64
Check user-supplied JID, change memory allocation tracking logic
Mikael Berthe <mikael@lilotux.net>
parents:
22
diff
changeset
|
116 |
} |
0 | 117 |
|
118 |
} else if (!strcmp (cmd, "clear")) { |
|
119 |
||
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
120 |
GSList *mel = g_slist_find_custom (marked_jids, jid, (GCompareFunc) g_strcmp0); |
0 | 121 |
|
122 |
if (mel) { |
|
123 |
g_free (mel->data); |
|
124 |
marked_jids = g_slist_delete_link (marked_jids, mel); |
|
30 | 125 |
marked = 0; |
0 | 126 |
} |
127 |
||
128 |
} else if (!strcmp (cmd, "toggle")) { |
|
129 |
||
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
130 |
GSList *mel = g_slist_find_custom (marked_jids, jid, (GCompareFunc) g_strcmp0); |
0 | 131 |
|
132 |
if (mel) { |
|
133 |
g_free (mel->data); |
|
134 |
marked_jids = g_slist_delete_link (marked_jids, mel); |
|
30 | 135 |
marked = 0; |
0 | 136 |
} else { |
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
137 |
marked_jids = g_slist_append (marked_jids, jid); |
30 | 138 |
marked = 1; |
139 |
jfree = FALSE; |
|
0 | 140 |
} |
31 | 141 |
} else |
142 |
scr_log_print (LPRINT_NORMAL, "Unknown subcommand."); |
|
0 | 143 |
|
26
24ed43268d29
Display a message when marking/unmarking a contact
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
144 |
len = g_slist_length(marked_jids); |
24
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
145 |
if (marked == 1) { |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
146 |
scr_write_incoming_message (jid, "Marked", 0, |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
147 |
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
148 |
} else if (marked == 0) { |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
149 |
scr_write_incoming_message (jid, "Mark cleared", 0, |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
150 |
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
5254ab4a5f24
Do more checks when JID isn't explicitly specified
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
151 |
} |
26
24ed43268d29
Display a message when marking/unmarking a contact
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
152 |
if (marked >= 0) { |
30 | 153 |
scr_log_print (LPRINT_NORMAL, "<%s> is now %s (%u mark%s).", jid, |
154 |
marked == 1 ? "marked" : "unmarked", |
|
155 |
len, len > 1 ? "s" : ""); |
|
26
24ed43268d29
Display a message when marking/unmarking a contact
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
156 |
} |
0 | 157 |
|
158 |
if (jfree && jid) |
|
159 |
g_free (jid); |
|
160 |
||
161 |
free_arg_lst (args); |
|
162 |
} |
|
163 |
||
1
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
164 |
// marked clear |
c8473c43ce72
Cosmetics, install help
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
165 |
// marked do cmd |
0 | 166 |
void do_marked (char *arg) |
167 |
{ |
|
168 |
char **args = split_arg (arg, 2, 1); |
|
169 |
char *cmd = args[0]; |
|
170 |
||
171 |
if (!cmd) |
|
172 |
cmd = "list"; |
|
173 |
||
174 |
if (!strcmp (cmd, "list")) { |
|
175 |
||
176 |
GSList *mel; |
|
30 | 177 |
guint len = g_slist_length (marked_jids); |
0 | 178 |
|
25
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
179 |
if (!marked_jids) { |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
180 |
scr_log_print (LPRINT_NORMAL, "No marked JIDs."); |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
181 |
} else { |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
182 |
scr_log_print (LPRINT_NORMAL, "%d marked JIDs:", len); |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
183 |
for (mel = marked_jids; mel; mel = mel->next) { |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
184 |
char *jid = (char *) mel->data; |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
185 |
scr_log_print (LPRINT_NORMAL, " * %s", jid); |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
186 |
} |
30 | 187 |
// XXX Smartly set the status flag if we have more marks than the log |
25
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
188 |
// window height. |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
189 |
if (len + 1 > scr_getlogwinheight()) { |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
190 |
scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
191 |
scr_setattentionflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE, |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
192 |
ROSTER_UI_PRIO_STATUS_WIN_MESSAGE, prio_max); |
39d261f589d0
Improve listing of marked JIDs
Mikael Berthe <mikael@lilotux.net>
parents:
24
diff
changeset
|
193 |
} |
0 | 194 |
} |
195 |
||
196 |
} else if (!strcmp (cmd, "clear")) { |
|
197 |
||
198 |
GSList *mel; |
|
199 |
||
200 |
for (mel = marked_jids; mel; mel = mel->next) |
|
201 |
g_free (mel->data); |
|
202 |
||
203 |
g_slist_free (marked_jids); |
|
204 |
marked_jids = NULL; |
|
205 |
||
31 | 206 |
scr_log_print (LPRINT_NORMAL, "List cleared. No marked JIDs."); |
207 |
||
0 | 208 |
} else if (!strcmp (cmd, "do")) { |
209 |
char *format = args[1]; |
|
210 |
||
211 |
if (!format) |
|
27
b51de2faa028
Cosmetic changes, copyright update
Mikael Berthe <mikael@lilotux.net>
parents:
26
diff
changeset
|
212 |
scr_log_print (LPRINT_NORMAL, |
b51de2faa028
Cosmetic changes, copyright update
Mikael Berthe <mikael@lilotux.net>
parents:
26
diff
changeset
|
213 |
"You must specify action to do with marked JIDs"); |
0 | 214 |
else { |
215 |
char *pos = format; |
|
216 |
gboolean found = FALSE; |
|
217 |
gboolean error = FALSE; |
|
218 |
||
219 |
for (pos = strchr (pos, '%'); pos; pos = strchr (pos, '%')) { |
|
220 |
if (*(pos + 1) == 's') |
|
221 |
found = TRUE; |
|
222 |
else if (*(pos + 1) == '%') |
|
223 |
++pos; |
|
224 |
else { |
|
27
b51de2faa028
Cosmetic changes, copyright update
Mikael Berthe <mikael@lilotux.net>
parents:
26
diff
changeset
|
225 |
scr_log_print (LPRINT_NORMAL, |
b51de2faa028
Cosmetic changes, copyright update
Mikael Berthe <mikael@lilotux.net>
parents:
26
diff
changeset
|
226 |
"Action string must not contain any other %%-sequences!"); |
0 | 227 |
error = TRUE; |
228 |
break; |
|
229 |
} |
|
230 |
||
231 |
++pos; |
|
232 |
} |
|
233 |
||
234 |
if (!found) |
|
27
b51de2faa028
Cosmetic changes, copyright update
Mikael Berthe <mikael@lilotux.net>
parents:
26
diff
changeset
|
235 |
scr_log_print (LPRINT_NORMAL, |
b51de2faa028
Cosmetic changes, copyright update
Mikael Berthe <mikael@lilotux.net>
parents:
26
diff
changeset
|
236 |
"Action string must contain one %%s!"); |
0 | 237 |
else if (!error) { |
238 |
GSList *mel; |
|
239 |
||
240 |
for (mel = marked_jids; mel; mel = mel->next) { |
|
241 |
char *jid = (char *) mel->data; |
|
242 |
char *command = g_strdup_printf (format, jid); |
|
243 |
process_command (command, TRUE); |
|
244 |
g_free (command); |
|
245 |
} |
|
246 |
} |
|
247 |
} |
|
31 | 248 |
} else |
249 |
scr_log_print (LPRINT_NORMAL, "Unknown subcommand."); |
|
0 | 250 |
|
251 |
free_arg_lst (args); |
|
252 |
} |
|
253 |
||
19
c7e7218be611
Update versions and add AVV description
Myhailo Danylenko <isbear@ukrpost.net>
parents:
16
diff
changeset
|
254 |
void marking_init (void) |
0 | 255 |
{ |
19
c7e7218be611
Update versions and add AVV description
Myhailo Danylenko <isbear@ukrpost.net>
parents:
16
diff
changeset
|
256 |
#ifndef MCABBER_API_HAVE_CMD_ID |
30 | 257 |
cmd_add ("mark", "", 0, COMPL_JID, do_mark, NULL); |
0 | 258 |
cmd_add ("marked", "", 0, COMPL_CMD, do_marked, NULL); |
15
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
259 |
#else |
30 | 260 |
mark_cmid = cmd_add ("mark", "", 0, COMPL_JID, do_mark, NULL); |
15
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
261 |
marked_cmid = cmd_add ("marked", "", 0, COMPL_CMD, do_marked, NULL); |
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
262 |
#endif |
0 | 263 |
} |
264 |
||
19
c7e7218be611
Update versions and add AVV description
Myhailo Danylenko <isbear@ukrpost.net>
parents:
16
diff
changeset
|
265 |
void marking_uninit (void) |
0 | 266 |
{ |
19
c7e7218be611
Update versions and add AVV description
Myhailo Danylenko <isbear@ukrpost.net>
parents:
16
diff
changeset
|
267 |
#ifndef MCABBER_API_HAVE_CMD_ID |
0 | 268 |
cmd_del ("mark"); |
269 |
cmd_del ("marked"); |
|
15
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
270 |
#else |
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
271 |
if (mark_cmid) |
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
272 |
cmd_del (mark_cmid); |
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
273 |
if (marked_cmid) |
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
274 |
cmd_del (marked_cmid); |
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
275 |
#endif |
0 | 276 |
|
277 |
{ |
|
278 |
GSList *mel; |
|
279 |
||
280 |
for (mel = marked_jids; mel; mel = mel->next) |
|
281 |
g_free (mel->data); |
|
282 |
||
283 |
g_slist_free (marked_jids); |
|
284 |
marked_jids = NULL; |
|
285 |
} |
|
286 |
} |
|
287 |
||
15
522a4193ef2f
Use id to delete commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
14
diff
changeset
|
288 |
/* vim: se ts=4 sw=4: */ |