source: buddy.c @ 2c79eae

release-1.10release-1.8release-1.9
Last change on this file since 2c79eae 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
RevLine 
[f4d0975]1#include "owl.h"
2
[e19eb97]3void 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]10const char *owl_buddy_get_name(const owl_buddy *b)
[f4d0975]11{
12  if (b->name) return(b->name);
13  return("");
14}
15
[476faed]16int owl_buddy_is_idle(const owl_buddy *b)
[f4d0975]17{
18  if (b->isidle) return(1);
19  return(0);
20}
21
22void owl_buddy_set_idle(owl_buddy *b)
23{
24  b->isidle=1;
25}
26
27void owl_buddy_set_unidle(owl_buddy *b)
28{
29  b->isidle=0;
30}
31
[476faed]32int owl_buddy_get_proto(const owl_buddy *b)
[f4d0975]33{
34  return(b->proto);
35}
36
[476faed]37int 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 */
45void 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]55int 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]66void owl_buddy_cleanup(owl_buddy *b)
[f4d0975]67{
[ddbbcffa]68  if (b->name) g_free(b->name);
[f4d0975]69}
[80b5c42]70
71void 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.