File: | activesyncd/eas-daemon/libeas/eas-get-email-body-req.c |
Warning: | line 402, column 6 Value stored to 'chunkAccumulated' is never read |
1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8; show-trailing-whitespace: t -*- */ |
2 | /* |
3 | * ActiveSync core protocol library |
4 | * |
5 | * Copyright © 2011 Intel Corporation. |
6 | * |
7 | * Authors: Mobica Ltd. <www.mobica.com> |
8 | * |
9 | * This file is provided under a dual Apache/LGPLv2.1 licence. When |
10 | * using or redistributing this file, you may do so under either |
11 | * licence. |
12 | * |
13 | * |
14 | * LGPLv2.1 LICENCE SUMMARY |
15 | * |
16 | * Copyright © Intel Corporation, dates as above. |
17 | * |
18 | * This library is free software; you can redistribute it and/or |
19 | * modify it under the terms of the GNU Lesser General Public |
20 | * License as published by the Free Software Foundation; either |
21 | * version 2.1 of the License, or (at your option) any later |
22 | * version. |
23 | * |
24 | * This library is distributed in the hope that it will be useful, |
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
27 | * Lesser General Public License for more details. |
28 | * |
29 | * You should have received a copy of the GNU Lesser General Public |
30 | * License along with this library; if not, write to the Free |
31 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
32 | * Boston, MA 02110-1301 USA |
33 | * |
34 | * |
35 | * APACHE LICENCE SUMMARY |
36 | * |
37 | * Copyright © Intel Corporation, dates as above. |
38 | * |
39 | * Licensed under the Apache License, Version 2.0 (the "License"); |
40 | * you may not use this file except in compliance with the License. |
41 | * You may obtain a copy of the License at |
42 | * |
43 | * http://www.apache.org/licenses/LICENSE-2.0 |
44 | * |
45 | * Unless required by applicable law or agreed to in writing, software |
46 | * distributed under the License is distributed on an "AS IS" BASIS, |
47 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
48 | * See the License for the specific language governing permissions and |
49 | * limitations under the License. |
50 | * |
51 | */ |
52 | |
53 | #include "eas-get-email-body-msg.h" |
54 | #include "eas-get-email-body-req.h" |
55 | #include <string.h> |
56 | |
57 | struct _EasGetEmailBodyReqPrivate { |
58 | EasGetEmailBodyMsg* emailBodyMsg; |
59 | gchar* accountUid; |
60 | gchar* serverId; |
61 | gchar* collectionId; |
62 | gchar* mimeDirectory; |
63 | EasItemType item_type; |
64 | |
65 | gboolean gotMetadata; |
66 | guchar* accumulationBuffer; |
67 | gsize accBufSize; |
68 | guint numParts; |
69 | GSList *parts; |
70 | }; |
71 | |
72 | #define EAS_GET_EMAIL_BODY_REQ_PRIVATE(o)(((EasGetEmailBodyReqPrivate*) g_type_instance_get_private (( GTypeInstance*) ((o)), ((eas_get_email_body_req_get_type ())) ))) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EAS_TYPE_GET_EMAIL_BODY_REQ, EasGetEmailBodyReqPrivate)((EasGetEmailBodyReqPrivate*) g_type_instance_get_private ((GTypeInstance *) ((o)), ((eas_get_email_body_req_get_type ()))))) |
73 | |
74 | typedef struct _EasMultipartTuple { |
75 | guint32 startPos; |
76 | guint32 itemsize; |
77 | } EasMultipartTuple; |
78 | |
79 | G_DEFINE_TYPE (EasGetEmailBodyReq, eas_get_email_body_req, EAS_TYPE_REQUEST_BASE)static void eas_get_email_body_req_init (EasGetEmailBodyReq * self); static void eas_get_email_body_req_class_init (EasGetEmailBodyReqClass *klass); static gpointer eas_get_email_body_req_parent_class = ((void*)0); static gint EasGetEmailBodyReq_private_offset; static void eas_get_email_body_req_class_intern_init (gpointer klass) { eas_get_email_body_req_parent_class = g_type_class_peek_parent (klass); if (EasGetEmailBodyReq_private_offset != 0) g_type_class_adjust_private_offset (klass, &EasGetEmailBodyReq_private_offset); eas_get_email_body_req_class_init ((EasGetEmailBodyReqClass*) klass); } __attribute__((__unused__ )) static inline gpointer eas_get_email_body_req_get_instance_private (EasGetEmailBodyReq *self) { return (((gpointer) ((guint8*) ( self) + (glong) (EasGetEmailBodyReq_private_offset)))); } GType eas_get_email_body_req_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_4[(sizeof *(&g_define_type_id__volatile ) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)) ; (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_5 [(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer )) ? 1 : -1] __attribute__((__unused__)); __sync_synchronize ( ); (gpointer) *(&g_define_type_id__volatile); })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = g_type_register_static_simple ((eas_request_base_get_type ()), g_intern_static_string ("EasGetEmailBodyReq"), sizeof ( EasGetEmailBodyReqClass), (GClassInitFunc) eas_get_email_body_req_class_intern_init , sizeof (EasGetEmailBodyReq), (GInstanceInitFunc) eas_get_email_body_req_init , (GTypeFlags) 0); { {{};} } (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_6 [(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer )) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(& g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id )); })); } return g_define_type_id__volatile; }; |
80 | |
81 | static void |
82 | eas_get_email_body_req_init (EasGetEmailBodyReq *object) |
83 | { |
84 | EasGetEmailBodyReqPrivate* priv; |
85 | g_debug ("eas_get_email_body_req_init++"); |
86 | object->priv = priv = EAS_GET_EMAIL_BODY_REQ_PRIVATE (object)(((EasGetEmailBodyReqPrivate*) g_type_instance_get_private (( GTypeInstance*) ((object)), ((eas_get_email_body_req_get_type ()))))); |
87 | |
88 | eas_request_base_SetRequestType (&object->parent_instance, |
89 | EAS_REQ_GET_EMAIL_BODY); |
90 | |
91 | priv->emailBodyMsg = NULL((void*)0); |
92 | priv->accountUid = NULL((void*)0); |
93 | priv->mimeDirectory = NULL((void*)0); |
94 | priv->serverId = NULL((void*)0); |
95 | priv->collectionId = NULL((void*)0); |
96 | |
97 | priv->accumulationBuffer = NULL((void*)0); |
98 | priv->accBufSize = 0; |
99 | priv->numParts = 0; |
100 | priv->parts = NULL((void*)0); |
101 | priv->gotMetadata = FALSE(0); |
102 | |
103 | g_debug ("eas_get_email_body_req_init--"); |
104 | } |
105 | |
106 | static void |
107 | eas_get_email_body_req_dispose (GObject *object) |
108 | { |
109 | EasGetEmailBodyReq* self = EAS_GET_EMAIL_BODY_REQ (object)((((EasGetEmailBodyReq*) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((eas_get_email_body_req_get_type ())))))); |
110 | EasGetEmailBodyReqPrivate *priv = self->priv; |
111 | |
112 | g_debug ("eas_get_email_body_req_dispose++"); |
113 | |
114 | if (priv->emailBodyMsg) { |
115 | g_object_unref (priv->emailBodyMsg); |
116 | priv->emailBodyMsg = NULL((void*)0); |
117 | } |
118 | |
119 | G_OBJECT_CLASS (eas_get_email_body_req_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((eas_get_email_body_req_parent_class )), (((GType) ((20) << (2))))))))->dispose (object); |
120 | |
121 | g_debug ("eas_get_email_body_req_dispose--"); |
122 | } |
123 | |
124 | |
125 | static void |
126 | eas_get_email_body_req_finalize (GObject *object) |
127 | { |
128 | EasGetEmailBodyReq* self = EAS_GET_EMAIL_BODY_REQ (object)((((EasGetEmailBodyReq*) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((eas_get_email_body_req_get_type ())))))); |
129 | EasGetEmailBodyReqPrivate *priv = self->priv; |
130 | |
131 | g_debug ("eas_get_email_body_req_finalize++"); |
132 | |
133 | g_free (priv->serverId); |
134 | g_free (priv->collectionId); |
135 | g_free (priv->mimeDirectory); |
136 | g_free (priv->accountUid); |
137 | |
138 | g_slist_foreach (priv->parts, (GFunc) g_free, NULL((void*)0)); |
139 | g_slist_free (priv->parts); |
140 | |
141 | g_free (priv->accumulationBuffer); |
142 | |
143 | G_OBJECT_CLASS (eas_get_email_body_req_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((eas_get_email_body_req_parent_class )), (((GType) ((20) << (2))))))))->finalize (object); |
144 | g_debug ("eas_get_email_body_req_finalize--"); |
145 | } |
146 | |
147 | static void |
148 | eas_get_email_body_req_class_init (EasGetEmailBodyReqClass *klass) |
149 | { |
150 | GObjectClass* object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((klass )), (((GType) ((20) << (2)))))))); |
151 | EasRequestBaseClass *base_class = EAS_REQUEST_BASE_CLASS (klass)((((EasRequestBaseClass*) g_type_check_class_cast ((GTypeClass *) ((klass)), ((eas_request_base_get_type ())))))); |
152 | |
153 | g_debug ("eas_get_email_body_req_class_init++"); |
154 | |
155 | g_type_class_add_private (klass, sizeof (EasGetEmailBodyReqPrivate)); |
156 | |
157 | base_class->do_MessageComplete = (EasRequestBaseMessageCompleteFp) eas_get_email_body_req_MessageComplete; |
158 | base_class->do_GotChunk = (EasRequestBaseGotChunkFp) eas_get_email_body_req_GotChunk; |
159 | |
160 | object_class->finalize = eas_get_email_body_req_finalize; |
161 | object_class->dispose = eas_get_email_body_req_dispose; |
162 | g_debug ("eas_get_email_body_req_class_init--"); |
163 | } |
164 | |
165 | |
166 | EasGetEmailBodyReq* |
167 | eas_get_email_body_req_new (const gchar* account_uid, |
168 | const gchar *collection_id, |
169 | const gchar *server_id, |
170 | const gchar *mime_directory, |
171 | const EasItemType item_type, |
172 | DBusGMethodInvocation* context) |
173 | { |
174 | EasGetEmailBodyReq* req = NULL((void*)0); |
175 | EasGetEmailBodyReqPrivate *priv = NULL((void*)0); |
176 | |
177 | g_debug ("eas_get_email_body_req_new++"); |
178 | |
179 | req = g_object_new (EAS_TYPE_GET_EMAIL_BODY_REQ(eas_get_email_body_req_get_type ()), NULL((void*)0)); |
180 | priv = req->priv; |
181 | |
182 | priv->accountUid = g_strdup (account_uid); |
183 | priv->collectionId = g_strdup (collection_id); |
184 | priv->serverId = g_strdup (server_id); |
185 | priv->mimeDirectory = g_strdup (mime_directory); |
186 | priv->item_type = item_type; |
187 | eas_request_base_SetContext (&req->parent_instance, context); |
188 | |
189 | if (priv->item_type == EAS_ITEM_MAIL) |
190 | eas_request_base_Set_UseMultipart (EAS_REQUEST_BASE (req)((((EasRequestBase*) g_type_check_instance_cast ((GTypeInstance *) ((req)), ((eas_request_base_get_type ())))))), TRUE(!(0))); |
191 | |
192 | g_debug ("eas_get_email_body_req_new--"); |
193 | return req; |
194 | } |
195 | |
196 | gboolean |
197 | eas_get_email_body_req_Activate (EasGetEmailBodyReq* self, GError** error) |
198 | { |
199 | gboolean ret; |
200 | EasGetEmailBodyReqPrivate *priv = self->priv; |
201 | xmlDoc *doc = NULL((void*)0); |
202 | EasRequestBase *parent = EAS_REQUEST_BASE (&self->parent_instance)((((EasRequestBase*) g_type_check_instance_cast ((GTypeInstance *) ((&self->parent_instance)), ((eas_request_base_get_type ())))))); |
203 | |
204 | g_debug ("eas_get_email_body_req_Activate++"); |
205 | |
206 | g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do{ if (__builtin_expect (__extension__ ({ int _g_boolean_var_ ; if ((error == ((void*)0) || *error == ((void*)0))) _g_boolean_var_ = 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1)) { } else { g_return_if_fail_warning ("libeas", ((const char*) (__func__ )), "error == NULL || *error == NULL"); return ((0)); }; }while (0); |
207 | |
208 | if (priv->collectionId == NULL((void*)0) || strlen (priv->collectionId) <= 0) { |
209 | EasAccount *acc; |
210 | acc = eas_connection_get_account (eas_request_base_GetConnection (EAS_REQUEST_BASE (self)((((EasRequestBase*) g_type_check_instance_cast ((GTypeInstance *) ((self)), ((eas_request_base_get_type ())))))))); |
211 | switch (priv->item_type) { |
212 | case EAS_ITEM_CALENDAR: |
213 | g_free (priv->collectionId); |
214 | priv->collectionId = g_strdup (eas_account_get_calendar_folder (acc)); |
215 | break; |
216 | case EAS_ITEM_CONTACT: |
217 | g_free (priv->collectionId); |
218 | priv->collectionId = g_strdup (eas_account_get_contact_folder (acc)); |
219 | break; |
220 | default: |
221 | g_warning ("trying to get default folder for unspecified item type"); |
222 | } |
223 | g_object_unref (acc); |
224 | } |
225 | |
226 | priv->emailBodyMsg = eas_get_email_body_msg_new (priv->serverId, priv->collectionId, priv->mimeDirectory); |
227 | doc = eas_get_email_body_msg_build_message (priv->emailBodyMsg); |
228 | if (!doc) { |
229 | g_set_error (error, EAS_CONNECTION_ERROR(eas_connection_error_quark ()), |
230 | EAS_CONNECTION_ERROR_NOTENOUGHMEMORY, |
231 | ("out of memory")); |
232 | ret = FALSE(0); |
233 | goto finish; |
234 | } |
235 | ret = eas_request_base_SendRequest (parent, |
236 | "ItemOperations", |
237 | doc, // full transfer |
238 | FALSE(0), |
239 | error); |
240 | |
241 | g_debug ("eas_get_email_body_req_Activate--"); |
242 | |
243 | finish: |
244 | if (!ret) { |
245 | g_assert (error == NULL || *error != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_ ; if ((error == ((void*)0) || *error != ((void*)0))) _g_boolean_var_ = 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr ("libeas", "/data/runtests/work/sources/activesyncd/eas-daemon/libeas/eas-get-email-body-req.c" , 245, ((const char*) (__func__)), "error == NULL || *error != NULL" ); } while (0); |
246 | } |
247 | return ret; |
248 | } |
249 | |
250 | gboolean |
251 | eas_get_email_body_req_MessageComplete (EasGetEmailBodyReq* self, xmlDoc *doc, GError* error_in) |
252 | { |
253 | gboolean ret = TRUE(!(0)); |
254 | GError *error = NULL((void*)0); |
255 | EasGetEmailBodyReqPrivate *priv = self->priv; |
256 | EasRequestBase *parent = EAS_REQUEST_BASE (&self->parent_instance)((((EasRequestBase*) g_type_check_instance_cast ((GTypeInstance *) ((&self->parent_instance)), ((eas_request_base_get_type ())))))); |
257 | gchar* item = NULL((void*)0); |
258 | |
259 | g_debug ("eas_get_email_body_req_MessageComplete++"); |
260 | |
261 | // if an error occurred, store it and signal client |
262 | if (error_in) { |
263 | ret = FALSE(0); |
264 | error = error_in; |
265 | goto finish; |
266 | } |
267 | |
268 | ret = eas_get_email_body_msg_parse_response (priv->emailBodyMsg, doc, &error); |
269 | item = eas_get_email_body_msg_get_item (priv->emailBodyMsg); |
270 | |
271 | // Nothing to do we've already grabbed the email in the chunking |
272 | |
273 | finish: |
274 | xmlFreeDoc (doc); |
275 | if (!ret) { |
276 | g_assert (error != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_ ; if ((error != ((void*)0))) _g_boolean_var_ = 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr ("libeas", "/data/runtests/work/sources/activesyncd/eas-daemon/libeas/eas-get-email-body-req.c" , 276, ((const char*) (__func__)), "error != NULL"); } while ( 0); |
277 | g_warning ("eas_mail_fetch_email_body - failed to get data from message"); |
278 | dbus_g_method_return_error (eas_request_base_GetContext (parent), error); |
279 | g_error_free (error); |
280 | } else { |
281 | g_debug ("eas_mail_fetch_email_body - return for dbus"); |
282 | dbus_g_method_return (eas_request_base_GetContext (parent), item); |
283 | } |
284 | |
285 | g_debug ("eas_get_email_body_req_MessageComplete--"); |
286 | //this is a one step request, so always needs cleaning up |
287 | return TRUE(!(0)); |
288 | } |
289 | |
290 | void |
291 | eas_get_email_body_req_GotChunk (EasGetEmailBodyReq* self, SoupMessage *msg, SoupBuffer *chunk) |
292 | { |
293 | EasGetEmailBodyReqPrivate *priv = EAS_GET_EMAIL_BODY_REQ_PRIVATE (self)(((EasGetEmailBodyReqPrivate*) g_type_instance_get_private (( GTypeInstance*) ((self)), ((eas_get_email_body_req_get_type ( )))))); |
294 | EasRequestBase *parent = EAS_REQUEST_BASE (&self->parent_instance)((((EasRequestBase*) g_type_check_instance_cast ((GTypeInstance *) ((&self->parent_instance)), ((eas_request_base_get_type ())))))); |
295 | gboolean chunkAccumulated = FALSE(0); |
296 | |
297 | g_debug ("eas_get_email_body_req_GotChunk++"); |
298 | |
299 | // If we are a multipart message ie we're an email being received |
300 | if (eas_request_base_UseMultipart (parent) && chunk->length > 0) |
301 | { |
302 | g_debug (" GotChunk - Dealing with multipart response"); |
303 | if (!priv->gotMetadata) |
304 | { |
305 | guint offset = priv->accBufSize; |
306 | |
307 | g_debug (" GotChunk - Accumulating Metadata"); |
308 | |
309 | priv->accBufSize += chunk->length; |
310 | priv->accumulationBuffer = g_realloc (priv->accumulationBuffer, |
311 | priv->accBufSize); |
312 | |
313 | memcpy ( (priv->accumulationBuffer + offset), chunk->data, chunk->length); |
314 | |
315 | chunkAccumulated = TRUE(!(0)); |
316 | |
317 | if (0 == priv->numParts && priv->accBufSize >= 4) |
318 | { |
319 | priv->numParts = priv->accumulationBuffer[ 3 ] << 24 | |
320 | priv->accumulationBuffer[ 2 ] << 16 | |
321 | priv->accumulationBuffer[ 1 ] << 8 | |
322 | priv->accumulationBuffer[ 0 ]; |
323 | g_debug (" GotChunk - parts = [%d]",priv->numParts); |
324 | } |
325 | |
326 | // Wait until we have all the part size info. |
327 | if (priv->numParts > 0 && priv->accBufSize >= (4 + (priv->numParts * 8))) |
328 | { |
329 | gint i = 0; |
330 | gsize excess = 0; |
331 | |
332 | g_debug (" GotChunk - All Metadata accumulated"); |
333 | |
334 | for (; i < priv->numParts; ++i) |
335 | { |
336 | EasMultipartTuple* item = g_new (EasMultipartTuple, 1)(EasMultipartTuple *) (__extension__ ({ gsize __n = (gsize) ( 1); gsize __s = sizeof (EasMultipartTuple); gpointer __p; if ( __s == 1) __p = g_malloc (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p = g_malloc (__n * __s); else __p = g_malloc_n (__n, __s); __p; })); |
337 | //j is start position for this tuple |
338 | gint j = (4 + (i * 8)); |
339 | |
340 | item->startPos = priv->accumulationBuffer[ (j + 3) ] << 24 | |
341 | priv->accumulationBuffer[ (j + 2) ] << 16 | |
342 | priv->accumulationBuffer[ (j + 1) ] << 8 | |
343 | priv->accumulationBuffer[ (j + 0) ]; |
344 | |
345 | item->itemsize = priv->accumulationBuffer[ (j + 7) ] << 24 | |
346 | priv->accumulationBuffer[ (j + 6) ] << 16 | |
347 | priv->accumulationBuffer[ (j + 5) ] << 8 | |
348 | priv->accumulationBuffer[ (j + 4) ]; |
349 | |
350 | priv->parts = g_slist_append (priv->parts, item); |
351 | g_debug (" GotChunk - Metadata [%d]:Offset[%u], Size[%u]", i, item->startPos, item->itemsize); |
352 | } |
353 | |
354 | priv->gotMetadata = TRUE(!(0)); |
355 | excess = priv->accBufSize - (4 + priv->numParts * 8); |
356 | |
357 | g_debug (" GotChunk - Size of excess after Metadata = [%zu]", excess); |
358 | |
359 | // We have more than just the meta data buffered |
360 | if (excess > 0) |
361 | { |
362 | guchar *tmp = g_malloc0 (excess); |
363 | |
364 | g_debug (" GotChunk - Adjust buffer to just hold excess"); |
365 | |
366 | memcpy (tmp, (priv->accumulationBuffer + (4 + priv->numParts * 8)), excess); |
367 | g_free (priv->accumulationBuffer); |
368 | priv->accumulationBuffer = tmp; |
369 | priv->accBufSize = excess; |
370 | } |
371 | else |
372 | { |
373 | g_debug (" GotChunk - No excess clear buffer"); |
374 | g_free (priv->accumulationBuffer); |
375 | priv->accumulationBuffer = NULL((void*)0); |
376 | priv->accBufSize = 0; |
377 | } |
378 | } |
379 | } |
380 | |
381 | if (priv->gotMetadata) |
382 | { |
383 | g_debug (" GotChunk - We have all our Metadata"); |
384 | if (!eas_request_base_GetWbxmlFromChunking (parent)) |
385 | { |
386 | EasMultipartTuple* item = g_slist_nth_data (priv->parts, 0); |
387 | |
388 | g_debug (" GotChunk - WBXML Part of message has not been accumulated"); |
389 | |
390 | if (!chunkAccumulated) |
391 | { |
392 | guint offset = priv->accBufSize; |
393 | |
394 | g_debug (" GotChunk - WBXML extends after initial chunk, need to extend accumulation buffer"); |
395 | |
396 | priv->accBufSize += chunk->length; |
397 | priv->accumulationBuffer = g_realloc (priv->accumulationBuffer, |
398 | priv->accBufSize); |
399 | |
400 | memcpy ( (priv->accumulationBuffer + offset), chunk->data, chunk->length); |
401 | |
402 | chunkAccumulated = TRUE(!(0)); |
Value stored to 'chunkAccumulated' is never read | |
403 | } |
404 | |
405 | if (priv->accBufSize >= item->itemsize) |
406 | { |
407 | gsize excess = 0; |
408 | |
409 | g_debug (" GotChunk - All of WBXML is now held in the accumulation buffer"); |
410 | eas_request_base_SetWbxmlFromChunking (parent, priv->accumulationBuffer, item->itemsize); |
411 | |
412 | excess = priv->accBufSize - item->itemsize; |
413 | g_debug (" GotChunk - Size of excess after WBXML = [%zu]", excess); |
414 | if (excess > 0) |
415 | { |
416 | guchar* tmp = g_malloc (excess); |
417 | g_debug (" GotChunk - Adjust buffer to hold just excess"); |
418 | memcpy (tmp, (priv->accumulationBuffer + item->itemsize), excess); |
419 | g_free (priv->accumulationBuffer); |
420 | priv->accumulationBuffer = tmp; |
421 | priv->accBufSize = excess; |
422 | } |
423 | else |
424 | { |
425 | g_debug (" GotChunk - No excess clear buffer"); |
426 | g_free (priv->accumulationBuffer); |
427 | priv->accumulationBuffer = NULL((void*)0); |
428 | priv->accBufSize = 0; |
429 | } |
430 | } |
431 | } |
432 | |
433 | if (eas_request_base_GetWbxmlFromChunking (parent)) // We've got the wbxml, stream the rest of the data (The mime email) to file. |
434 | { |
435 | g_debug (" GotChunk - We've got the Metadata & WBXML, now stream MIME data to file"); |
436 | if (priv->accBufSize > 0) |
437 | { |
438 | g_debug (" GotChunk - Write any data held in the accumulation buffer to file and then clear the buffer"); |
439 | eas_get_email_msg_write_chunk_to_file(priv->emailBodyMsg, |
440 | priv->accumulationBuffer, |
441 | priv->accBufSize); |
442 | |
443 | g_free (priv->accumulationBuffer); |
444 | priv->accumulationBuffer = NULL((void*)0); |
445 | priv->accBufSize = 0; |
446 | } |
447 | else |
448 | { |
449 | g_debug (" GotChunk - MIME Data, Don't accumulate, write straight to file"); |
450 | eas_get_email_msg_write_chunk_to_file(priv->emailBodyMsg, |
451 | (const guchar *)chunk->data, |
452 | chunk->length); |
453 | } |
454 | } |
455 | } |
456 | } |
457 | g_debug ("eas_get_email_body_req_GotChunk--"); |
458 | } |