source:
buddy.c
@
249bbbe
Last change on this file since 249bbbe was d4927a7, checked in by Anders Kaseorg <andersk@mit.edu>, 14 years ago | |
---|---|
|
|
File size: 1.2 KB |
Rev | Line | |
---|---|---|
[f4d0975] | 1 | #include "owl.h" |
2 | ||
[e19eb97] | 3 | void owl_buddy_create(owl_buddy *b, int proto, const char *name) |
[f4d0975] | 4 | { |
5 | b->proto=proto; | |
[d4927a7] | 6 | b->name=g_strdup(name); |
[f4d0975] | 7 | b->idlesince=0; |
8 | } | |
9 | ||
[476faed] | 10 | const char *owl_buddy_get_name(const owl_buddy *b) |
[f4d0975] | 11 | { |
12 | if (b->name) return(b->name); | |
13 | return(""); | |
14 | } | |
15 | ||
[476faed] | 16 | int owl_buddy_is_idle(const owl_buddy *b) |
[f4d0975] | 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 | ||
[476faed] | 32 | int owl_buddy_get_proto(const owl_buddy *b) |
[f4d0975] | 33 | { |
34 | return(b->proto); | |
35 | } | |
36 | ||
[476faed] | 37 | int owl_buddy_is_proto_aim(const owl_buddy *b) |
[f4d0975] | 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 | */ | |
[476faed] | 55 | int owl_buddy_get_idle_time(const owl_buddy *b) |
[f4d0975] | 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 | ||
[a038c2a3] | 66 | void owl_buddy_cleanup(owl_buddy *b) |
[f4d0975] | 67 | { |
[ddbbcffa] | 68 | if (b->name) g_free(b->name); |
[f4d0975] | 69 | } |
[80b5c42] | 70 | |
71 | void owl_buddy_delete(owl_buddy *b) | |
72 | { | |
[a038c2a3] | 73 | owl_buddy_cleanup(b); |
[ddbbcffa] | 74 | g_free(b); |
[80b5c42] | 75 | } |
Note: See TracBrowser
for help on using the repository browser.