source: buddylist.c @ d559df9

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since d559df9 was d559df9, checked in by James M. Kretchmar <kretch@mit.edu>, 21 years ago
AIM messages now go through format_msg() in .owlconf if it exists. Additional Perl variables will need to be added so users can distinguish AIM login/logout messages from normal messages.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1#include "owl.h"
2
3void owl_buddylist_init(owl_buddylist *b)
4{
5  owl_list_create(&(b->buddies));
6}
7
8/* Deal with an "oncoming" message.  This means recognizing the user
9 * has logged in, and sending a message if they were not already
10 * logged in.
11 */
12void owl_buddylist_oncoming(owl_buddylist *b, char *screenname)
13{
14  int i, j, found;
15  owl_message *m;
16
17  found=0;
18  j=owl_list_get_size(&(b->buddies));
19  for (i=0; i<j; i++) {
20    if (!strcasecmp(owl_list_get_element(&(b->buddies), i), screenname)) {
21      found=1;
22      break;
23    }
24  }
25
26  if (!found) {
27    owl_list_append_element(&(b->buddies), owl_strdup(screenname));
28
29    m=owl_malloc(sizeof(owl_message));
30    owl_message_create_aim(m,
31                           screenname,
32                           owl_global_get_aim_screenname(&g),
33                           "",
34                           OWL_MESSAGE_DIRECTION_IN,
35                           1);
36    owl_global_messagequeue_addmsg(&g, m);
37  }
38}
39   
40
41
42/* Deal with an "offgoing" message.  This means recognizing the user
43 * has logged out, and sending a message if they were logged in.
44 */
45void owl_buddylist_offgoing(owl_buddylist *b, char *screenname)
46{
47  int i, j, found;
48  owl_message *m;
49
50  found=0;
51  j=owl_list_get_size(&(b->buddies));
52  for (i=0; i<j; i++) {
53    if (!strcasecmp(owl_list_get_element(&(b->buddies), i), screenname)) {
54      found=1;
55      owl_free(owl_list_get_element(&(b->buddies), i));
56      owl_list_remove_element(&(b->buddies), i);
57      break;
58    }
59  }
60
61  if (found) {
62    m=owl_malloc(sizeof(owl_message));
63    owl_message_create_aim(m,
64                           screenname,
65                           owl_global_get_aim_screenname(&g),
66                           "",
67                           OWL_MESSAGE_DIRECTION_IN,
68                           -1);
69
70    owl_global_messagequeue_addmsg(&g, m);
71  }
72}
73
74int owl_buddylist_get_size(owl_buddylist *b)
75{
76  return(owl_list_get_size(&(b->buddies)));
77}
78
79char *owl_buddylist_get_buddy(owl_buddylist *b, int n)
80{
81  return(owl_list_get_element(&(b->buddies), n));
82}
83
84void owl_buddylist_clear(owl_buddylist *b) {
85  owl_list_free_all(&(b->buddies), owl_free);
86  owl_list_create(&(b->buddies));
87}
Note: See TracBrowser for help on using the repository browser.