release-1.10release-1.8release-1.9
Last change
on this file since 00adc24 was
d4927a7,
checked in by Anders Kaseorg <andersk@mit.edu>, 14 years ago
|
Replace owl_strdup with g_strdup.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Karl Ramm <kcr@mit.edu>
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | #include "owl.h" |
---|
2 | |
---|
3 | void owl_buddy_create(owl_buddy *b, int proto, const char *name) |
---|
4 | { |
---|
5 | b->proto=proto; |
---|
6 | b->name=g_strdup(name); |
---|
7 | b->idlesince=0; |
---|
8 | } |
---|
9 | |
---|
10 | const char *owl_buddy_get_name(const owl_buddy *b) |
---|
11 | { |
---|
12 | if (b->name) return(b->name); |
---|
13 | return(""); |
---|
14 | } |
---|
15 | |
---|
16 | int owl_buddy_is_idle(const owl_buddy *b) |
---|
17 | { |
---|
18 | if (b->isidle) return(1); |
---|
19 | return(0); |
---|
20 | } |
---|
21 | |
---|
22 | void owl_buddy_set_idle(owl_buddy *b) |
---|
23 | { |
---|
24 | b->isidle=1; |
---|
25 | } |
---|
26 | |
---|
27 | void owl_buddy_set_unidle(owl_buddy *b) |
---|
28 | { |
---|
29 | b->isidle=0; |
---|
30 | } |
---|
31 | |
---|
32 | int owl_buddy_get_proto(const owl_buddy *b) |
---|
33 | { |
---|
34 | return(b->proto); |
---|
35 | } |
---|
36 | |
---|
37 | int owl_buddy_is_proto_aim(const owl_buddy *b) |
---|
38 | { |
---|
39 | if (b->proto==OWL_PROTOCOL_AIM) return(1); |
---|
40 | return(0); |
---|
41 | } |
---|
42 | |
---|
43 | /* Set the buddy to have been idle since 'diff' minutes ago |
---|
44 | */ |
---|
45 | void owl_buddy_set_idle_since(owl_buddy *b, int diff) |
---|
46 | { |
---|
47 | time_t now; |
---|
48 | |
---|
49 | now=time(NULL); |
---|
50 | b->idlesince=now-(diff*60); |
---|
51 | } |
---|
52 | |
---|
53 | /* return the number of minutes the buddy has been idle |
---|
54 | */ |
---|
55 | int owl_buddy_get_idle_time(const owl_buddy *b) |
---|
56 | { |
---|
57 | time_t now; |
---|
58 | |
---|
59 | if (b->isidle) { |
---|
60 | now=time(NULL); |
---|
61 | return((now - b->idlesince)/60); |
---|
62 | } |
---|
63 | return(0); |
---|
64 | } |
---|
65 | |
---|
66 | void owl_buddy_cleanup(owl_buddy *b) |
---|
67 | { |
---|
68 | if (b->name) g_free(b->name); |
---|
69 | } |
---|
70 | |
---|
71 | void owl_buddy_delete(owl_buddy *b) |
---|
72 | { |
---|
73 | owl_buddy_cleanup(b); |
---|
74 | g_free(b); |
---|
75 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.