Diffstat (limited to 'kmicromail/libetpan/generic/mhdriver_message.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libetpan/generic/mhdriver_message.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/kmicromail/libetpan/generic/mhdriver_message.c b/kmicromail/libetpan/generic/mhdriver_message.c index 2c023e7..aafd2d9 100644 --- a/kmicromail/libetpan/generic/mhdriver_message.c +++ b/kmicromail/libetpan/generic/mhdriver_message.c | |||
@@ -99,98 +99,99 @@ static int mh_prefetch(mailmessage * msg_info) | |||
99 | &msg_content, &msg_length); | 99 | &msg_content, &msg_length); |
100 | if (r != MAIL_NO_ERROR) | 100 | if (r != MAIL_NO_ERROR) |
101 | return r; | 101 | return r; |
102 | 102 | ||
103 | msg = msg_info->msg_data; | 103 | msg = msg_info->msg_data; |
104 | 104 | ||
105 | msg->msg_message = msg_content; | 105 | msg->msg_message = msg_content; |
106 | msg->msg_length = msg_length; | 106 | msg->msg_length = msg_length; |
107 | 107 | ||
108 | return MAIL_NO_ERROR; | 108 | return MAIL_NO_ERROR; |
109 | } | 109 | } |
110 | 110 | ||
111 | static void mh_prefetch_free(struct generic_message_t * msg) | 111 | static void mh_prefetch_free(struct generic_message_t * msg) |
112 | { | 112 | { |
113 | if (msg->msg_message != NULL) { | 113 | if (msg->msg_message != NULL) { |
114 | mmap_string_unref(msg->msg_message); | 114 | mmap_string_unref(msg->msg_message); |
115 | msg->msg_message = NULL; | 115 | msg->msg_message = NULL; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | static inline struct mh_session_state_data * get_data(mailmessage * msg) | 119 | static inline struct mh_session_state_data * get_data(mailmessage * msg) |
120 | { | 120 | { |
121 | return msg->msg_session->sess_data; | 121 | return msg->msg_session->sess_data; |
122 | } | 122 | } |
123 | 123 | ||
124 | static inline struct mailmh_folder * get_mh_cur_folder(mailmessage * msg) | 124 | static inline struct mailmh_folder * get_mh_cur_folder(mailmessage * msg) |
125 | { | 125 | { |
126 | return get_data(msg)->mh_cur_folder; | 126 | return get_data(msg)->mh_cur_folder; |
127 | } | 127 | } |
128 | 128 | ||
129 | static int mh_initialize(mailmessage * msg_info) | 129 | static int mh_initialize(mailmessage * msg_info) |
130 | { | 130 | { |
131 | struct generic_message_t * msg; | 131 | struct generic_message_t * msg; |
132 | int r; | 132 | int r; |
133 | char * uid; | 133 | char * uid; |
134 | char static_uid[PATH_MAX]; | 134 | char static_uid[PATH_MAX]; |
135 | struct mailmh_msg_info * mh_msg_info; | 135 | struct mailmh_msg_info * mh_msg_info; |
136 | chashdatum key; | 136 | chashdatum key; |
137 | chashdatum value; | 137 | chashdatum value; |
138 | 138 | ||
139 | key.data = &msg_info->msg_index; | 139 | key.data = &msg_info->msg_index; |
140 | key.len = sizeof(msg_info->msg_index); | 140 | key.len = sizeof(msg_info->msg_index); |
141 | r = chash_get(get_mh_cur_folder(msg_info)->fl_msgs_hash, &key, &value); | 141 | r = chash_get(get_mh_cur_folder(msg_info)->fl_msgs_hash, &key, &value); |
142 | if (r < 0) | 142 | if (r < 0) |
143 | return MAIL_ERROR_INVAL; | 143 | return MAIL_ERROR_INVAL; |
144 | 144 | ||
145 | mh_msg_info = value.data; | 145 | mh_msg_info = value.data; |
146 | 146 | ||
147 | snprintf(static_uid, PATH_MAX, "%u-%lu-%u", msg_info->msg_index, | 147 | snprintf(static_uid, PATH_MAX, "%u-%lu-%lu", msg_info->msg_index, |
148 | mh_msg_info->msg_mtime, mh_msg_info->msg_size); | 148 | (unsigned long) mh_msg_info->msg_mtime, |
149 | (unsigned long) mh_msg_info->msg_size); | ||
149 | uid = strdup(static_uid); | 150 | uid = strdup(static_uid); |
150 | if (uid == NULL) | 151 | if (uid == NULL) |
151 | return MAIL_ERROR_MEMORY; | 152 | return MAIL_ERROR_MEMORY; |
152 | 153 | ||
153 | r = mailmessage_generic_initialize(msg_info); | 154 | r = mailmessage_generic_initialize(msg_info); |
154 | if (r != MAIL_NO_ERROR) { | 155 | if (r != MAIL_NO_ERROR) { |
155 | free(uid); | 156 | free(uid); |
156 | return r; | 157 | return r; |
157 | } | 158 | } |
158 | 159 | ||
159 | msg = msg_info->msg_data; | 160 | msg = msg_info->msg_data; |
160 | msg->msg_prefetch = mh_prefetch; | 161 | msg->msg_prefetch = mh_prefetch; |
161 | msg->msg_prefetch_free = mh_prefetch_free; | 162 | msg->msg_prefetch_free = mh_prefetch_free; |
162 | msg_info->msg_uid = uid; | 163 | msg_info->msg_uid = uid; |
163 | 164 | ||
164 | return MAIL_NO_ERROR; | 165 | return MAIL_NO_ERROR; |
165 | } | 166 | } |
166 | 167 | ||
167 | 168 | ||
168 | static int mh_fetch_size(mailmessage * msg_info, | 169 | static int mh_fetch_size(mailmessage * msg_info, |
169 | size_t * result) | 170 | size_t * result) |
170 | { | 171 | { |
171 | int r; | 172 | int r; |
172 | size_t size; | 173 | size_t size; |
173 | 174 | ||
174 | r = mhdriver_fetch_size(msg_info->msg_session, msg_info->msg_index, &size); | 175 | r = mhdriver_fetch_size(msg_info->msg_session, msg_info->msg_index, &size); |
175 | if (r != MAIL_NO_ERROR) | 176 | if (r != MAIL_NO_ERROR) |
176 | return r; | 177 | return r; |
177 | 178 | ||
178 | * result = size; | 179 | * result = size; |
179 | 180 | ||
180 | return MAIL_NO_ERROR; | 181 | return MAIL_NO_ERROR; |
181 | } | 182 | } |
182 | 183 | ||
183 | 184 | ||
184 | 185 | ||
185 | 186 | ||
186 | static int mh_fetch_header(mailmessage * msg_info, | 187 | static int mh_fetch_header(mailmessage * msg_info, |
187 | char ** result, | 188 | char ** result, |
188 | size_t * result_len) | 189 | size_t * result_len) |
189 | { | 190 | { |
190 | struct generic_message_t * msg; | 191 | struct generic_message_t * msg; |
191 | int r; | 192 | int r; |
192 | char * msg_content; | 193 | char * msg_content; |
193 | size_t msg_length; | 194 | size_t msg_length; |
194 | 195 | ||
195 | msg = msg_info->msg_data; | 196 | msg = msg_info->msg_data; |
196 | if (msg->msg_message != NULL) { | 197 | if (msg->msg_message != NULL) { |