source: messagelist.c @ ed2412d

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since ed2412d was 1aee7d9, checked in by Erik Nygren <nygren@mit.edu>, 22 years ago
* Added RCS Id strings to all files. * 'show keymaps' shows details of all keymaps after summary list.
  • Property mode set to 100644
File size: 2.1 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  owl_list_create(&(ml->list));
9  return(0);
10}
11
12int owl_messagelist_get_size(owl_messagelist *ml) {
13  return(owl_list_get_size(&(ml->list)));
14}
15
16void *owl_messagelist_get_element(owl_messagelist *ml, int n) {
17  return(owl_list_get_element(&(ml->list), n));
18}
19
20owl_message *owl_messagelist_get_by_id(owl_messagelist *ml, int id) {
21  /* return the message with id == 'id'.  If it doesn't exist return NULL. */
22  /* we could make this much more efficient at some point */
23  int i, j;
24  owl_message *m;
25
26  j=owl_list_get_size(&(ml->list));
27  for (i=0; i<j; i++) {
28    m=owl_list_get_element(&(ml->list), i);
29    if (owl_message_get_id(m)==id) return(m);
30
31    /* the message id's have to be sequential.  If we've passed the
32       one we're looking for just bail */
33    if (owl_message_get_id(m) > id) return(NULL);
34  }
35  return(NULL);
36}
37
38int owl_messagelist_append_element(owl_messagelist *ml, void *element) {
39  return(owl_list_append_element(&(ml->list), element));
40}
41
42/* do we really still want this? */
43int owl_messagelist_delete_element(owl_messagelist *ml, int n) {
44  /* mark a message as deleted */
45  owl_message_mark_delete(owl_list_get_element(&(ml->list), n));
46  return(0);
47}
48
49int owl_messagelist_undelete_element(owl_messagelist *ml, int n) {
50  /* mark a message as deleted */
51  owl_message_unmark_delete(owl_list_get_element(&(ml->list), n));
52  return(0);
53}
54
55int owl_messagelist_expunge(owl_messagelist *ml) {
56  /* expunge deleted messages */
57  int i, j;
58  owl_list newlist;
59  owl_message *m;
60
61  owl_list_create(&newlist);
62  /*create a new list without messages marked as deleted */
63  j=owl_list_get_size(&(ml->list));
64  for (i=0; i<j; i++) {
65    m=owl_list_get_element(&(ml->list), i);
66    if (owl_message_is_delete(m)) {
67      owl_message_free(m);
68    } else {
69      owl_list_append_element(&newlist, m);
70    }
71  }
72
73  /* free the old list */
74  owl_list_free_simple(&(ml->list));
75
76  /* copy the new list to the old list */
77  memcpy(&(ml->list), &newlist, sizeof(owl_list));
78
79  return(0);
80}
Note: See TracBrowser for help on using the repository browser.