19
|
1 |
/* |
|
2 |
* Copyright (C) 2010 Mikael Berthe <mikael@lilotux.net> |
|
3 |
|
|
4 |
|
|
5 |
Module "libkillpresence" -- Ignore current presence of an item |
|
6 |
|
|
7 |
This module is free software: you can redistribute it and/or modify |
|
8 |
it under the terms of the GNU General Public License as published by |
|
9 |
the Free Software Foundation, either version 2 of the License, or |
|
10 |
(at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
19 |
*/ |
|
20 |
|
|
21 |
#include <string.h> |
|
22 |
|
|
23 |
#include <mcabber/modules.h> |
|
24 |
#include <mcabber/commands.h> |
|
25 |
#include <mcabber/compl.h> |
|
26 |
#include <mcabber/roster.h> |
|
27 |
#include <mcabber/screen.h> |
|
28 |
#include <mcabber/utils.h> |
|
29 |
|
|
30 |
static void killpresence_init(void); |
|
31 |
static void killpresence_uninit(void); |
|
32 |
|
|
33 |
/* Module description */ |
|
34 |
module_info_t info_killpresence = { |
|
35 |
.branch = MCABBER_BRANCH, |
|
36 |
.api = MCABBER_API_VERSION, |
|
37 |
.version = "0.01", |
|
38 |
.description = "Ignore an item's current presence", |
|
39 |
.requires = NULL, |
|
40 |
.init = killpresence_init, |
|
41 |
.uninit = killpresence_uninit, |
|
42 |
.next = NULL, |
|
43 |
}; |
|
44 |
|
|
45 |
static void do_killpresence(char *args) |
|
46 |
{ |
|
47 |
char *jid_utf8, *res; |
|
48 |
|
|
49 |
if (!args || !*args) |
|
50 |
return; |
|
51 |
|
|
52 |
jid_utf8 = to_utf8(args); |
|
53 |
if (!jid_utf8) |
|
54 |
return; |
|
55 |
|
|
56 |
res = strchr(jid_utf8, JID_RESOURCE_SEPARATOR); |
|
57 |
if (res) |
|
58 |
*res++ = '\0'; |
|
59 |
else |
|
60 |
return; |
|
61 |
|
|
62 |
roster_setstatus(jid_utf8, res, 0, |
|
63 |
offline, "Killed by killpresence.", |
|
64 |
0L, role_none, affil_none, NULL); |
|
65 |
buddylist_build(); |
|
66 |
scr_draw_roster(); |
|
67 |
|
|
68 |
g_free(jid_utf8); |
|
69 |
} |
|
70 |
|
|
71 |
/* Initialization */ |
|
72 |
static void killpresence_init(void) |
|
73 |
{ |
|
74 |
/* Add command */ |
|
75 |
cmd_add("killpresence", "Ignore presence", COMPL_JID, 0, |
|
76 |
do_killpresence, NULL); |
|
77 |
} |
|
78 |
|
|
79 |
/* Uninitialization */ |
|
80 |
static void killpresence_uninit(void) |
|
81 |
{ |
|
82 |
/* Unregister command */ |
|
83 |
cmd_del("killpresence"); |
|
84 |
} |
|
85 |
|
|
86 |
/* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2: For Vim users... */ |