1 /* |
1 /* |
2 * Module "killpresence" -- Ignore current presence of an item |
2 * Module "killpresence" -- Ignore current presence of an item |
3 * |
3 * |
4 * /killpresence fulljid |
4 * /killpresence fulljid |
5 * Ignore current presence for the provided JID |
5 * Ignore current presence for the provided JID |
|
6 * Useful for kicking ghosts from the roster... |
|
7 * Shortcuts can be used for the full jid. Example: |
|
8 * /killpresence ./resource |
|
9 * Also, resource '*' stands for all resources. |
|
10 * |
6 * /killchatstates fulljid |
11 * /killchatstates fulljid |
7 * Reset chat states for the provided JID |
12 * Reset chat states for the provided JID |
|
13 * |
8 * |
14 * |
9 * Copyright (C) 2010 Mikael Berthe <mikael@lilotux.net> |
15 * Copyright (C) 2010 Mikael Berthe <mikael@lilotux.net> |
10 * |
16 * |
11 * This module is free software; you can redistribute it and/or modify |
17 * This module is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by |
18 * it under the terms of the GNU General Public License as published by |
36 |
42 |
37 /* Module description */ |
43 /* Module description */ |
38 module_info_t info_killpresence = { |
44 module_info_t info_killpresence = { |
39 .branch = MCABBER_BRANCH, |
45 .branch = MCABBER_BRANCH, |
40 .api = MCABBER_API_VERSION, |
46 .api = MCABBER_API_VERSION, |
41 .version = "0.02", |
47 .version = "0.03", |
42 .description = "Ignore an item's current presence(s)\n" |
48 .description = "Ignore an item's current presence(s)\n" |
43 " Provides the following commands:\n" |
49 " Provides the following commands:\n" |
44 " /killpresence $fulljid\n" |
50 " /killpresence $fulljid\n" |
45 " /killchatstates $fulljid", |
51 " /killchatstates $fulljid", |
46 .requires = NULL, |
52 .requires = NULL, |
67 return; |
74 return; |
68 |
75 |
69 res = strchr(jid_utf8, JID_RESOURCE_SEPARATOR); |
76 res = strchr(jid_utf8, JID_RESOURCE_SEPARATOR); |
70 if (res) { |
77 if (res) { |
71 *res++ = '\0'; |
78 *res++ = '\0'; |
72 } else { |
79 if (!strcmp(jid_utf8, ".")) { |
|
80 if (current_buddy) |
|
81 targetjid = CURRENT_JID; |
|
82 } else { |
|
83 targetjid = jid_utf8; |
|
84 } |
|
85 } |
|
86 |
|
87 if (!targetjid) { |
73 scr_log_print(LPRINT_NORMAL, "I need a /full/ JID."); |
88 scr_log_print(LPRINT_NORMAL, "I need a /full/ JID."); |
74 return; |
89 g_free(jid_utf8); |
75 } |
90 return; |
|
91 } |
|
92 |
76 |
93 |
77 if (!strcmp(res, "*")) { |
94 if (!strcmp(res, "*")) { |
78 // Kill all resources! |
95 // Kill all resources! |
79 GSList *sl_user = roster_find(jid_utf8, jidsearch, ROSTER_TYPE_USER); |
96 GSList *sl_user = roster_find(targetjid, jidsearch, ROSTER_TYPE_USER); |
80 if (sl_user) { |
97 if (sl_user) { |
81 scr_log_print(LPRINT_NORMAL, |
98 scr_log_print(LPRINT_NORMAL, |
82 "Killing all resources from <%s> now!", jid_utf8); |
99 "Killing all resources from <%s> now!", targetjid); |
83 buddy_del_all_resources(sl_user->data); |
100 buddy_del_all_resources(sl_user->data); |
84 } else { |
101 } else { |
85 scr_log_print(LPRINT_NORMAL, "Cannot find <%s>...", jid_utf8); |
102 scr_log_print(LPRINT_NORMAL, "Cannot find <%s>...", targetjid); |
86 } |
103 } |
87 } else { |
104 } else { |
88 roster_setstatus(jid_utf8, res, 0, |
105 roster_setstatus(targetjid, res, 0, |
89 offline, "Killed by killpresence.", |
106 offline, "Killed by killpresence.", |
90 0L, role_none, affil_none, NULL); |
107 0L, role_none, affil_none, NULL); |
91 } |
108 } |
92 buddylist_build(); |
109 buddylist_build(); |
93 scr_draw_roster(); |
110 scr_draw_roster(); |