[dab82f29] | 1 | /* Copyright (c) 2002,2003,2004,2009 James M. Kretchmar |
---|
| 2 | * |
---|
| 3 | * This file is part of Owl. |
---|
| 4 | * |
---|
| 5 | * Owl is free software: you can redistribute it and/or modify |
---|
| 6 | * it under the terms of the GNU General Public License as published by |
---|
| 7 | * the Free Software Foundation, either version 3 of the License, or |
---|
| 8 | * (at your option) any later version. |
---|
| 9 | * |
---|
| 10 | * Owl is distributed in the hope that it will be useful, |
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 13 | * GNU General Public License for more details. |
---|
| 14 | * |
---|
| 15 | * You should have received a copy of the GNU General Public License |
---|
| 16 | * along with Owl. If not, see <http://www.gnu.org/licenses/>. |
---|
| 17 | * |
---|
| 18 | * --------------------------------------------------------------- |
---|
| 19 | * |
---|
| 20 | * As of Owl version 2.1.12 there are patches contributed by |
---|
[fa00c5c] | 21 | * developers of the branched BarnOwl project, Copyright (c) |
---|
| 22 | * 2006-2009 The BarnOwl Developers. All rights reserved. |
---|
[dab82f29] | 23 | */ |
---|
| 24 | |
---|
[f4d0975] | 25 | #include "owl.h" |
---|
| 26 | |
---|
| 27 | static const char fileIdent[] = "$Id$"; |
---|
| 28 | |
---|
| 29 | void owl_buddy_create(owl_buddy *b, int proto, char *name) |
---|
| 30 | { |
---|
| 31 | b->proto=proto; |
---|
| 32 | b->name=owl_strdup(name); |
---|
| 33 | b->idlesince=0; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | char *owl_buddy_get_name(owl_buddy *b) |
---|
| 37 | { |
---|
| 38 | if (b->name) return(b->name); |
---|
| 39 | return(""); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | int owl_buddy_is_idle(owl_buddy *b) |
---|
| 43 | { |
---|
| 44 | if (b->isidle) return(1); |
---|
| 45 | return(0); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | void owl_buddy_set_idle(owl_buddy *b) |
---|
| 49 | { |
---|
| 50 | b->isidle=1; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | void owl_buddy_set_unidle(owl_buddy *b) |
---|
| 54 | { |
---|
| 55 | b->isidle=0; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | int owl_buddy_get_proto(owl_buddy *b) |
---|
| 59 | { |
---|
| 60 | return(b->proto); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | int owl_buddy_is_proto_aim(owl_buddy *b) |
---|
| 64 | { |
---|
| 65 | if (b->proto==OWL_PROTOCOL_AIM) return(1); |
---|
| 66 | return(0); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | /* Set the buddy to have been idle since 'diff' minutes ago |
---|
| 70 | */ |
---|
| 71 | void owl_buddy_set_idle_since(owl_buddy *b, int diff) |
---|
| 72 | { |
---|
| 73 | time_t now; |
---|
| 74 | |
---|
| 75 | now=time(NULL); |
---|
| 76 | b->idlesince=now-(diff*60); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | /* return the number of minutes the buddy has been idle |
---|
| 80 | */ |
---|
| 81 | int owl_buddy_get_idle_time(owl_buddy *b) |
---|
| 82 | { |
---|
| 83 | time_t now; |
---|
| 84 | |
---|
| 85 | if (b->isidle) { |
---|
| 86 | now=time(NULL); |
---|
| 87 | return((now - b->idlesince)/60); |
---|
| 88 | } |
---|
| 89 | return(0); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | void owl_buddy_free(owl_buddy *b) |
---|
| 93 | { |
---|
| 94 | if (b->name) owl_free(b->name); |
---|
| 95 | } |
---|