Add a plugin method to allow updating stored passwords on master password change.
[claws.git] / src / plugins / mailmbox / mailmbox_types.h
1 /*
2  * libEtPan! -- a mail stuff library
3  *
4  * Copyright (C) 2001, 2002 - DINH Viet Hoa
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the libEtPan! project nor the names of its
16  *    contributors may be used to endorse or promote products derived
17  *    from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31
32 #ifndef MAILMBOX_TYPES_H
33
34 #define MAILMBOX_TYPES_H
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 #include <sys/types.h>
41 #include <limits.h>
42
43 /* The Hurd doesn't have this limit */
44 #ifndef PATH_MAX
45   #define PATH_MAX 4196
46 #endif
47
48 #include "mailimf.h"
49 #include "carray.h"
50 #include "chash.h"
51
52 enum {
53   MAILMBOX_NO_ERROR = 0,
54   MAILMBOX_ERROR_PARSE,
55   MAILMBOX_ERROR_INVAL,
56   MAILMBOX_ERROR_FILE_NOT_FOUND,
57   MAILMBOX_ERROR_MEMORY,
58   MAILMBOX_ERROR_TEMPORARY_FILE,
59   MAILMBOX_ERROR_FILE,
60   MAILMBOX_ERROR_MSG_NOT_FOUND,
61   MAILMBOX_ERROR_READONLY,
62 };
63
64
65 struct claws_mailmbox_folder {
66   char mb_filename[PATH_MAX];
67
68   time_t mb_mtime;
69
70   int mb_fd;
71   int mb_read_only;
72   int mb_no_uid;
73
74   int mb_changed;
75   unsigned int mb_deleted_count;
76   
77   char * mb_mapping;
78   size_t mb_mapping_size;
79
80   uint32_t mb_written_uid;
81   uint32_t mb_max_uid;
82
83   chash * mb_hash;
84   carray * mb_tab;
85 };
86
87 struct claws_mailmbox_folder * claws_mailmbox_folder_new(const char * mb_filename);
88 void claws_mailmbox_folder_free(struct claws_mailmbox_folder * folder);
89
90
91 struct claws_mailmbox_msg_info {
92   unsigned int msg_index;
93   uint32_t msg_uid;
94   int msg_written_uid;
95   int msg_deleted;
96
97   size_t msg_start;
98   size_t msg_start_len;
99
100   size_t msg_headers;
101   size_t msg_headers_len;
102
103   size_t msg_body;
104   size_t msg_body_len;
105
106   size_t msg_size;
107
108   size_t msg_padding;
109 };
110
111
112 int claws_mailmbox_msg_info_update(struct claws_mailmbox_folder * folder,
113                              size_t msg_start, size_t msg_start_len,
114                              size_t msg_headers, size_t msg_headers_len,
115                              size_t msg_body, size_t msg_body_len,
116                              size_t msg_size, size_t msg_padding,
117                              uint32_t msg_uid);
118
119 struct claws_mailmbox_msg_info *
120 claws_mailmbox_msg_info_new(size_t msg_start, size_t msg_start_len,
121                       size_t msg_headers, size_t msg_headers_len,
122                       size_t msg_body, size_t msg_body_len,
123                       size_t msg_size, size_t msg_padding,
124                       uint32_t msg_uid);
125
126 void claws_mailmbox_msg_info_free(struct claws_mailmbox_msg_info * info);
127
128 struct claws_mailmbox_append_info {
129   const char * ai_message;
130   size_t ai_size;
131 };
132
133 struct claws_mailmbox_append_info *
134 claws_mailmbox_append_info_new(const char * ai_message, size_t ai_size);
135
136 void claws_mailmbox_append_info_free(struct claws_mailmbox_append_info * info);
137
138 #ifdef __cplusplus
139 }
140 #endif
141
142 #endif