source: messagelist.c @ b20de4f

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since b20de4f was bd3f232, checked in by James M. Kretchmar <kretch@mit.edu>, 22 years ago
Styles implemented It's still a little buggy ... if a format_msg(); is used in perl admin messages (or maybe just the first admin message) are not formatted.
  • Property mode set to 100644
File size: 2.3 KB
Line 
1#include "owl.h"
2#include <stdlib.h>
3#include <string.h>
4
5static const char fileIdent[] = "$Id$";
6
7int owl_messagelist_create(owl_messagelist *ml)
8{
9  owl_list_create(&(ml->list));
10  return(0);
11}
12
13int owl_messagelist_get_size(owl_messagelist *ml)
14{
15  return(owl_list_get_size(&(ml->list)));
16}
17
18void *owl_messagelist_get_element(owl_messagelist *ml, int n)
19{
20  return(owl_list_get_element(&(ml->list), n));
21}
22
23owl_message *owl_messagelist_get_by_id(owl_messagelist *ml, int id)
24{
25  /* return the message with id == 'id'.  If it doesn't exist return NULL. */
26  /* we could make this much more efficient at some point */
27  int i, j;
28  owl_message *m;
29
30  j=owl_list_get_size(&(ml->list));
31  for (i=0; i<j; i++) {
32    m=owl_list_get_element(&(ml->list), i);
33    if (owl_message_get_id(m)==id) return(m);
34
35    /* the message id's have to be sequential.  If we've passed the
36       one we're looking for just bail */
37    if (owl_message_get_id(m) > id) return(NULL);
38  }
39  return(NULL);
40}
41
42int owl_messagelist_append_element(owl_messagelist *ml, void *element)
43{
44  return(owl_list_append_element(&(ml->list), element));
45}
46
47/* do we really still want this? */
48int owl_messagelist_delete_element(owl_messagelist *ml, int n)
49{
50  /* mark a message as deleted */
51  owl_message_mark_delete(owl_list_get_element(&(ml->list), n));
52  return(0);
53}
54
55int owl_messagelist_undelete_element(owl_messagelist *ml, int n)
56{
57  /* mark a message as deleted */
58  owl_message_unmark_delete(owl_list_get_element(&(ml->list), n));
59  return(0);
60}
61
62int owl_messagelist_expunge(owl_messagelist *ml)
63{
64  /* expunge deleted messages */
65  int i, j;
66  owl_list newlist;
67  owl_message *m;
68
69  owl_list_create(&newlist);
70  /*create a new list without messages marked as deleted */
71  j=owl_list_get_size(&(ml->list));
72  for (i=0; i<j; i++) {
73    m=owl_list_get_element(&(ml->list), i);
74    if (owl_message_is_delete(m)) {
75      owl_message_free(m);
76    } else {
77      owl_list_append_element(&newlist, m);
78    }
79  }
80
81  /* free the old list */
82  owl_list_free_simple(&(ml->list));
83
84  /* copy the new list to the old list */
85  memcpy(&(ml->list), &newlist, sizeof(owl_list));
86
87  return(0);
88}
89
90void owl_messagelist_invalidate_formats(owl_messagelist *ml)
91{
92  int i, j;
93  owl_message *m;
94
95  j=owl_list_get_size(&(ml->list));
96  for (i=0; i<j; i++) {
97    m=owl_list_get_element(&(ml->list), i);
98    owl_message_invalidate_format(m);
99  }
100}
Note: See TracBrowser for help on using the repository browser.