Mercurial > mxe-octave
comparison src/vmime-1-fastforward.patch @ 1118:0466e57f8b20
upgrade package vmime
author | Mark Brand <mabrand@mabrand.nl> |
---|---|
date | Tue, 07 Sep 2010 22:18:52 +0200 |
parents | 6a4d3383c783 |
children | 1eabaf3f1206 |
comparison
equal
deleted
inserted
replaced
1117:6a4d3383c783 | 1118:0466e57f8b20 |
---|---|
17302 + !parserHelpers::isAscii(c) || | 17302 + !parserHelpers::isAscii(c) || |
17303 + alwaysEncode); | 17303 + alwaysEncode); |
17304 | 17304 |
17305 break; | 17305 break; |
17306 } | 17306 } |
17307 | |
17308 commit a5a7e03fd144e6c46e5418f8bdd0e3f754bd980f | |
17309 Author: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009> | |
17310 Date: Tue Sep 7 10:46:24 2010 +0000 | |
17311 | |
17312 Added an option to recognize inline objects as attachments. | |
17313 | |
17314 git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@565 5301114d-f842-0410-bbdd-996ee0417009 | |
17315 | |
17316 diff --git a/src/attachmentHelper.cpp b/src/attachmentHelper.cpp | |
17317 index 65e8c88..c23ee95 100644 | |
17318 --- a/src/attachmentHelper.cpp | |
17319 +++ b/src/attachmentHelper.cpp | |
17320 @@ -36,7 +36,8 @@ namespace vmime | |
17321 | |
17322 | |
17323 // static | |
17324 -bool attachmentHelper::isBodyPartAnAttachment(ref <const bodyPart> part) | |
17325 +bool attachmentHelper::isBodyPartAnAttachment | |
17326 + (ref <const bodyPart> part, const unsigned int options) | |
17327 { | |
17328 try | |
17329 { | |
17330 @@ -49,54 +50,63 @@ bool attachmentHelper::isBodyPartAnAttachment(ref <const bodyPart> part) | |
17331 if (disp.getName() != contentDispositionTypes::INLINE) | |
17332 return true; | |
17333 | |
17334 - // If the Content-Disposition is 'inline' and there is no | |
17335 - // Content-Id or Content-Location field, it may be an attachment | |
17336 - if (!part->getHeader()->hasField(vmime::fields::CONTENT_ID) && | |
17337 - !part->getHeader()->hasField(vmime::fields::CONTENT_LOCATION)) | |
17338 + if ((options & INLINE_OBJECTS) == 0) | |
17339 { | |
17340 - // If this is the root part, it might not be an attachment | |
17341 - if (part->getParentPart() == NULL) | |
17342 - return false; | |
17343 + // If the Content-Disposition is 'inline' and there is no | |
17344 + // Content-Id or Content-Location field, it may be an attachment | |
17345 + if (!part->getHeader()->hasField(vmime::fields::CONTENT_ID) && | |
17346 + !part->getHeader()->hasField(vmime::fields::CONTENT_LOCATION)) | |
17347 + { | |
17348 + // If this is the root part, it might not be an attachment | |
17349 + if (part->getParentPart() == NULL) | |
17350 + return false; | |
17351 | |
17352 - return true; | |
17353 + return true; | |
17354 + } | |
17355 + | |
17356 + return false; | |
17357 } | |
17358 } | |
17359 catch (exceptions::no_such_field&) | |
17360 { | |
17361 - // No "Content-disposition" field: assume "attachment" if | |
17362 - // type is not "text/..." or "multipart/...". | |
17363 - mediaType type; | |
17364 + // Will try using Content-Type | |
17365 + } | |
17366 | |
17367 - try | |
17368 - { | |
17369 - const contentTypeField& ctf = dynamic_cast<contentTypeField&> | |
17370 - (*part->getHeader()->findField(fields::CONTENT_TYPE)); | |
17371 + // Assume "attachment" if type is not "text/..." or "multipart/...". | |
17372 + mediaType type; | |
17373 | |
17374 - type = *ctf.getValue().dynamicCast <const mediaType>(); | |
17375 - } | |
17376 - catch (exceptions::no_such_field&) | |
17377 - { | |
17378 - // If this is the root part and no Content-Type field is present, | |
17379 - // then this may not be a MIME message, so do not assume it is | |
17380 - // an attachment | |
17381 - if (part->getParentPart() == NULL) | |
17382 - return false; | |
17383 + try | |
17384 + { | |
17385 + const contentTypeField& ctf = dynamic_cast<contentTypeField&> | |
17386 + (*part->getHeader()->findField(fields::CONTENT_TYPE)); | |
17387 | |
17388 - // No "Content-type" field: assume "application/octet-stream". | |
17389 - type = mediaType(mediaTypes::APPLICATION, | |
17390 - mediaTypes::APPLICATION_OCTET_STREAM); | |
17391 - } | |
17392 + type = *ctf.getValue().dynamicCast <const mediaType>(); | |
17393 + } | |
17394 + catch (exceptions::no_such_field&) | |
17395 + { | |
17396 + // If this is the root part and no Content-Type field is present, | |
17397 + // then this may not be a MIME message, so do not assume it is | |
17398 + // an attachment | |
17399 + if (part->getParentPart() == NULL) | |
17400 + return false; | |
17401 + | |
17402 + // No "Content-type" field: assume "application/octet-stream". | |
17403 + type = mediaType(mediaTypes::APPLICATION, | |
17404 + mediaTypes::APPLICATION_OCTET_STREAM); | |
17405 + } | |
17406 | |
17407 - if (type.getType() != mediaTypes::TEXT && | |
17408 - type.getType() != mediaTypes::MULTIPART) | |
17409 + if (type.getType() != mediaTypes::TEXT && | |
17410 + type.getType() != mediaTypes::MULTIPART) | |
17411 + { | |
17412 + if ((options & INLINE_OBJECTS) == 0) | |
17413 { | |
17414 // If a "Content-Id" field is present, it might be an | |
17415 // embedded object (MHTML messages) | |
17416 if (part->getHeader()->hasField(vmime::fields::CONTENT_ID)) | |
17417 return false; | |
17418 - | |
17419 - return true; | |
17420 } | |
17421 + | |
17422 + return true; | |
17423 } | |
17424 | |
17425 return false; | |
17426 @@ -104,10 +114,10 @@ bool attachmentHelper::isBodyPartAnAttachment(ref <const bodyPart> part) | |
17427 | |
17428 | |
17429 // static | |
17430 -ref <const attachment> | |
17431 - attachmentHelper::getBodyPartAttachment(ref <const bodyPart> part) | |
17432 +ref <const attachment> attachmentHelper::getBodyPartAttachment | |
17433 + (ref <const bodyPart> part, const unsigned int options) | |
17434 { | |
17435 - if (!isBodyPartAnAttachment(part)) | |
17436 + if (!isBodyPartAnAttachment(part, options)) | |
17437 return NULL; | |
17438 | |
17439 mediaType type; | |
17440 @@ -140,22 +150,24 @@ ref <const attachment> | |
17441 | |
17442 // static | |
17443 const std::vector <ref <const attachment> > | |
17444 - attachmentHelper::findAttachmentsInMessage(ref <const message> msg) | |
17445 + attachmentHelper::findAttachmentsInMessage | |
17446 + (ref <const message> msg, const unsigned int options) | |
17447 { | |
17448 - return findAttachmentsInBodyPart(msg); | |
17449 + return findAttachmentsInBodyPart(msg, options); | |
17450 } | |
17451 | |
17452 | |
17453 // static | |
17454 const std::vector <ref <const attachment> > | |
17455 - attachmentHelper::findAttachmentsInBodyPart(ref <const bodyPart> part) | |
17456 + attachmentHelper::findAttachmentsInBodyPart | |
17457 + (ref <const bodyPart> part, const unsigned int options) | |
17458 { | |
17459 std::vector <ref <const attachment> > atts; | |
17460 | |
17461 // Test this part | |
17462 - if (isBodyPartAnAttachment(part)) | |
17463 + if (isBodyPartAnAttachment(part, options)) | |
17464 { | |
17465 - atts.push_back(getBodyPartAttachment(part)); | |
17466 + atts.push_back(getBodyPartAttachment(part, options)); | |
17467 } | |
17468 // Find in sub-parts | |
17469 else | |
17470 @@ -165,7 +177,7 @@ const std::vector <ref <const attachment> > | |
17471 for (int i = 0 ; i < bdy->getPartCount() ; ++i) | |
17472 { | |
17473 std::vector <ref <const attachment> > partAtts = | |
17474 - findAttachmentsInBodyPart(bdy->getPartAt(i)); | |
17475 + findAttachmentsInBodyPart(bdy->getPartAt(i), options); | |
17476 | |
17477 std::copy(partAtts.begin(), partAtts.end(), std::back_inserter(atts)); | |
17478 } | |
17479 diff --git a/vmime/attachmentHelper.hpp b/vmime/attachmentHelper.hpp | |
17480 index 3ce86c8..a383367 100644 | |
17481 --- a/vmime/attachmentHelper.hpp | |
17482 +++ b/vmime/attachmentHelper.hpp | |
17483 @@ -30,10 +30,6 @@ | |
17484 #include "vmime/attachment.hpp" | |
17485 #include "vmime/message.hpp" | |
17486 | |
17487 -#if VMIME_HAVE_MESSAGING_FEATURES | |
17488 - #include "vmime/net/message.hpp" | |
17489 -#endif | |
17490 - | |
17491 | |
17492 namespace vmime | |
17493 { | |
17494 @@ -45,31 +41,57 @@ class attachmentHelper | |
17495 { | |
17496 public: | |
17497 | |
17498 + /** Options for use with the following functions: | |
17499 + * findAttachmentsInMessage, | |
17500 + * getBodyPartAttachment, | |
17501 + * and isBodyPartAnAttachment. | |
17502 + */ | |
17503 + enum FindOptions | |
17504 + { | |
17505 + INLINE_OBJECTS = (1 << 0) /**< Recognize and return inline objects. The aim is to | |
17506 + consider MHTML objects (parts with a "Content-Id" or | |
17507 + a "Content-Location", such as inline images) as attachments. */ | |
17508 + }; | |
17509 + | |
17510 /** Test whether a body part is an attachment. | |
17511 * | |
17512 * @param part message part to test | |
17513 + * @param options search options (see FindOptions) | |
17514 * @return true if the part is an attachment, false otherwise | |
17515 */ | |
17516 - static bool isBodyPartAnAttachment(ref <const bodyPart> part); | |
17517 + static bool isBodyPartAnAttachment(ref <const bodyPart> part, const unsigned int options = 0); | |
17518 | |
17519 /** Return attachment information in the specified body part. | |
17520 * If the specified body part does not contain attachment | |
17521 * information (ie. is not an attachment), NULL is returned. | |
17522 * | |
17523 * @param part message part in which to search | |
17524 + * @param options search options (see FindOptions) | |
17525 * @return attachment found in the part, or NULL | |
17526 */ | |
17527 static ref <const attachment> | |
17528 - getBodyPartAttachment(ref <const bodyPart> part); | |
17529 + getBodyPartAttachment(ref <const bodyPart> part, const unsigned int options = 0); | |
17530 + | |
17531 + /** Find all attachments contained in the specified part | |
17532 + * and all its children parts. | |
17533 + * This is simply a recursive call to getBodyPartAttachment(). | |
17534 + * | |
17535 + * @param part part in which to search | |
17536 + * @param options search options (see FindOptions) | |
17537 + * @return a list of attachments found | |
17538 + */ | |
17539 + static const std::vector <ref <const attachment> > | |
17540 + findAttachmentsInBodyPart(ref <const bodyPart> part, const unsigned int options = 0); | |
17541 | |
17542 /** Find all attachments contained in the specified message. | |
17543 * This is simply a recursive call to getBodyPartAttachment(). | |
17544 * | |
17545 * @param msg message in which to search | |
17546 + * @param options search options (see FindOptions) | |
17547 * @return a list of attachments found | |
17548 */ | |
17549 static const std::vector <ref <const attachment> > | |
17550 - findAttachmentsInMessage(ref <const message> msg); | |
17551 + findAttachmentsInMessage(ref <const message> msg, const unsigned int options = 0); | |
17552 | |
17553 /** Add an attachment to the specified message. | |
17554 * | |
17555 @@ -87,9 +109,6 @@ public: | |
17556 | |
17557 protected: | |
17558 | |
17559 - static const std::vector <ref <const attachment> > | |
17560 - findAttachmentsInBodyPart(ref <const bodyPart> part); | |
17561 - | |
17562 static ref <bodyPart> findBodyPart | |
17563 (ref <bodyPart> part, const mediaType& type); | |
17564 }; |