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 [-p] 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... |
6 * Useful for kicking ghosts from the roster... |
7 * Shortcuts can be used for the full jid. Example: |
7 * Shortcuts can be used for the full jid. Example: |
8 * /killpresence ./resource |
8 * /killpresence ./resource |
9 * Also, resource '*' stands for all resources. |
9 * Also, resource '*' stands for all resources. |
|
10 * If the option -p is given, a presence probe will be sent |
|
11 * to the user after removing the resource(s). |
10 * |
12 * |
11 * /killchatstates fulljid |
13 * /killchatstates fulljid |
12 * Reset chat states for the provided JID |
14 * Reset chat states for the provided JID |
|
15 * |
|
16 * /probe barejid |
|
17 * Send a presence probe to the provided JID |
13 * |
18 * |
14 * |
19 * |
15 * Copyright (C) 2010 Mikael Berthe <mikael@lilotux.net> |
20 * Copyright (C) 2010 Mikael Berthe <mikael@lilotux.net> |
16 * |
21 * |
17 * This module is free software; you can redistribute it and/or modify |
22 * This module is free software; you can redistribute it and/or modify |
39 #include <mcabber/xmpp.h> |
44 #include <mcabber/xmpp.h> |
40 |
45 |
41 static void killpresence_init(void); |
46 static void killpresence_init(void); |
42 static void killpresence_uninit(void); |
47 static void killpresence_uninit(void); |
43 |
48 |
|
49 static void do_probe(char *); |
|
50 |
44 /* Module description */ |
51 /* Module description */ |
45 module_info_t info_killpresence = { |
52 module_info_t info_killpresence = { |
46 .branch = MCABBER_BRANCH, |
53 .branch = MCABBER_BRANCH, |
47 .api = MCABBER_API_VERSION, |
54 .api = MCABBER_API_VERSION, |
48 .version = "0.10", |
55 .version = "0.10", |
49 .description = "Ignore an item's current presence(s)\n" |
56 .description = "Ignore an item's current presence(s)\n" |
50 " Provides the following commands:\n" |
57 " Provides the following commands:\n" |
51 " /killpresence $fulljid\n" |
58 " /killpresence [-p] $fulljid\n" |
52 " /killchatstates $fulljid" |
59 " /killchatstates $fulljid" |
53 " /probe $barejid", |
60 " /probe $barejid", |
54 .requires = NULL, |
61 .requires = NULL, |
55 .init = killpresence_init, |
62 .init = killpresence_init, |
56 .uninit = killpresence_uninit, |
63 .uninit = killpresence_uninit, |
63 |
70 |
64 static void do_killpresence(char *args) |
71 static void do_killpresence(char *args) |
65 { |
72 { |
66 char *jid_utf8, *res; |
73 char *jid_utf8, *res; |
67 const char *targetjid = NULL; |
74 const char *targetjid = NULL; |
|
75 bool probe = false; |
68 |
76 |
69 if (!args || !*args) { |
77 if (!args || !*args) { |
70 scr_log_print(LPRINT_NORMAL, "I need a full JID."); |
78 scr_log_print(LPRINT_NORMAL, "I need a full JID."); |
71 return; |
79 return; |
|
80 } |
|
81 |
|
82 if (!strncmp(args, "-p ", 3)) { |
|
83 for (args += 3; *args && *args == ' '; args++) |
|
84 ; |
|
85 probe = true; |
72 } |
86 } |
73 |
87 |
74 jid_utf8 = to_utf8(args); |
88 jid_utf8 = to_utf8(args); |
75 if (!jid_utf8) |
89 if (!jid_utf8) |
76 return; |
90 return; |
108 offline, "Killed by killpresence.", |
122 offline, "Killed by killpresence.", |
109 0L, role_none, affil_none, NULL); |
123 0L, role_none, affil_none, NULL); |
110 } |
124 } |
111 buddylist_build(); |
125 buddylist_build(); |
112 scr_draw_roster(); |
126 scr_draw_roster(); |
|
127 |
|
128 if (probe) |
|
129 do_probe((char *)targetjid); |
113 |
130 |
114 g_free(jid_utf8); |
131 g_free(jid_utf8); |
115 } |
132 } |
116 |
133 |
117 #if defined XEP0022 || defined XEP0085 |
134 #if defined XEP0022 || defined XEP0085 |