Lines 287-299
Link Here
|
287 |
|
287 |
|
288 |
MessageComposer::MessageComposer( KMComposeWin* win, const char* name ) |
288 |
MessageComposer::MessageComposer( KMComposeWin* win, const char* name ) |
289 |
: QObject( win, name ), mComposeWin( win ), mCurrentJob( 0 ), |
289 |
: QObject( win, name ), mComposeWin( win ), mCurrentJob( 0 ), |
290 |
mKeyResolver( 0 ), mIdentityUid( 0 ) |
290 |
mKeyResolver( 0 ), mIdentityUid( 0 ), mPerformingSignOperation( false ) |
291 |
{ |
291 |
{ |
292 |
} |
292 |
} |
293 |
|
293 |
|
294 |
MessageComposer::~MessageComposer() |
294 |
MessageComposer::~MessageComposer() |
295 |
{ |
295 |
{ |
296 |
delete mKeyResolver; mKeyResolver = 0; |
296 |
delete mKeyResolver; mKeyResolver = 0; |
|
|
297 |
delete mNewBodyPart; mNewBodyPart = 0; |
297 |
} |
298 |
} |
298 |
|
299 |
|
299 |
void MessageComposer::applyChanges( bool disableCrypto ) |
300 |
void MessageComposer::applyChanges( bool disableCrypto ) |
Lines 338-344
Link Here
|
338 |
|
339 |
|
339 |
if( mJobs.isEmpty() ) { |
340 |
if( mJobs.isEmpty() ) { |
340 |
// No more jobs. Signal that we're done |
341 |
// No more jobs. Signal that we're done |
341 |
emit done( mRc ); |
342 |
emitDone( mRc ); |
342 |
return; |
343 |
return; |
343 |
} |
344 |
} |
344 |
|
345 |
|
Lines 348-354
Link Here
|
348 |
delete mJobs.front(); |
349 |
delete mJobs.front(); |
349 |
mJobs.pop_front(); |
350 |
mJobs.pop_front(); |
350 |
} |
351 |
} |
351 |
emit done( false ); |
352 |
emitDone( false ); |
352 |
return; |
353 |
return; |
353 |
} |
354 |
} |
354 |
|
355 |
|
Lines 356-361
Link Here
|
356 |
QTimer::singleShot( 0, this, SLOT( slotDoNextJob() ) ); |
357 |
QTimer::singleShot( 0, this, SLOT( slotDoNextJob() ) ); |
357 |
} |
358 |
} |
358 |
|
359 |
|
|
|
360 |
void MessageComposer::emitDone( bool b ) |
361 |
{ |
362 |
// Save memory - before sending the mail |
363 |
mEncodedBody = QByteArray(); |
364 |
delete mNewBodyPart; mNewBodyPart = 0; |
365 |
mOldBodyPart.clear(); |
366 |
emit done( b ); |
367 |
} |
368 |
|
359 |
void MessageComposer::slotDoNextJob() |
369 |
void MessageComposer::slotDoNextJob() |
360 |
{ |
370 |
{ |
361 |
assert( !mCurrentJob ); |
371 |
assert( !mCurrentJob ); |
Lines 495-500
Link Here
|
495 |
mIsRichText = mComposeWin->mEditor->textFormat() == Qt::RichText; |
505 |
mIsRichText = mComposeWin->mEditor->textFormat() == Qt::RichText; |
496 |
mIdentityUid = mComposeWin->identityUid(); |
506 |
mIdentityUid = mComposeWin->identityUid(); |
497 |
mText = breakLinesAndApplyCodec(); |
507 |
mText = breakLinesAndApplyCodec(); |
|
|
508 |
assert( mText.isEmpty() || mText[mText.size()-1] == '\n' ); |
498 |
// Hopefully we can get rid of this eventually, it's needed to be able |
509 |
// Hopefully we can get rid of this eventually, it's needed to be able |
499 |
// to break the plain/text version of a multipart/alternative (html) mail |
510 |
// to break the plain/text version of a multipart/alternative (html) mail |
500 |
// according to the line breaks of the richtext version. |
511 |
// according to the line breaks of the richtext version. |
Lines 1055-1061
Link Here
|
1055 |
static inline const char * nestedContentType( Kleo::CryptoMessageFormat f, bool signing ) { |
1066 |
static inline const char * nestedContentType( Kleo::CryptoMessageFormat f, bool signing ) { |
1056 |
switch ( f ) { |
1067 |
switch ( f ) { |
1057 |
case Kleo::OpenPGPMIMEFormat: |
1068 |
case Kleo::OpenPGPMIMEFormat: |
1058 |
return signing ? "application/pgp-signature" : "application/octet-stream" ; |
1069 |
return signing ? "application/pgp-signature; name=signature.asc \nContent-Description: This is a digitally signed message part." : "application/octet-stream" ; |
1059 |
case Kleo::SMIMEFormat: |
1070 |
case Kleo::SMIMEFormat: |
1060 |
if ( signing ) |
1071 |
if ( signing ) |
1061 |
return "application/pkcs7-signature; name=\"smime.p7s\""; |
1072 |
return "application/pkcs7-signature; name=\"smime.p7s\""; |
Lines 1115-1132
Link Here
|
1115 |
class EncryptMessageJob : public MessageComposerJob { |
1126 |
class EncryptMessageJob : public MessageComposerJob { |
1116 |
public: |
1127 |
public: |
1117 |
EncryptMessageJob( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si, |
1128 |
EncryptMessageJob( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si, |
1118 |
bool doSign, bool doEncrypt, const QCString& encodedBody, |
1129 |
bool doSign, bool doEncrypt, const QByteArray& encodedBody, |
1119 |
int boundaryLevel, const KMMessagePart& oldBodyPart, |
1130 |
int boundaryLevel, /*const KMMessagePart& oldBodyPart,*/ |
1120 |
KMMessagePart* newBodyPart, Kleo::CryptoMessageFormat format, |
1131 |
KMMessagePart* newBodyPart, Kleo::CryptoMessageFormat format, |
1121 |
MessageComposer* composer ) |
1132 |
MessageComposer* composer ) |
1122 |
: MessageComposerJob( composer ), mMsg( msg ), mSplitInfo( si ), |
1133 |
: MessageComposerJob( composer ), mMsg( msg ), mSplitInfo( si ), |
1123 |
mDoSign( doSign ), mDoEncrypt( doEncrypt ), mEncodedBody( encodedBody ), |
1134 |
mDoSign( doSign ), mDoEncrypt( doEncrypt ), mEncodedBody( encodedBody ), |
1124 |
mBoundaryLevel( boundaryLevel ), mOldBodyPart( oldBodyPart ), |
1135 |
mBoundaryLevel( boundaryLevel ), /*mOldBodyPart( oldBodyPart ),*/ |
1125 |
mNewBodyPart( newBodyPart ), mFormat( format ) {} |
1136 |
mNewBodyPart( newBodyPart ), mFormat( format ) {} |
1126 |
|
1137 |
|
1127 |
void execute() { |
1138 |
void execute() { |
1128 |
KMMessagePart tmpNewBodyPart; |
1139 |
KMMessagePart tmpNewBodyPart; |
1129 |
tmpNewBodyPart.duplicate( *mNewBodyPart ); |
1140 |
tmpNewBodyPart.duplicate( *mNewBodyPart ); // slow - we duplicate everything again |
1130 |
|
1141 |
|
1131 |
// TODO: Async call |
1142 |
// TODO: Async call |
1132 |
|
1143 |
|
Lines 1143-1151
Link Here
|
1143 |
KMMessage* mMsg; |
1154 |
KMMessage* mMsg; |
1144 |
Kleo::KeyResolver::SplitInfo mSplitInfo; |
1155 |
Kleo::KeyResolver::SplitInfo mSplitInfo; |
1145 |
bool mDoSign, mDoEncrypt; |
1156 |
bool mDoSign, mDoEncrypt; |
1146 |
QCString mEncodedBody; |
1157 |
QByteArray mEncodedBody; |
1147 |
int mBoundaryLevel; |
1158 |
int mBoundaryLevel; |
1148 |
KMMessagePart mOldBodyPart; |
1159 |
//KMMessagePart mOldBodyPart; |
1149 |
KMMessagePart* mNewBodyPart; |
1160 |
KMMessagePart* mNewBodyPart; |
1150 |
Kleo::CryptoMessageFormat mFormat; |
1161 |
Kleo::CryptoMessageFormat mFormat; |
1151 |
}; |
1162 |
}; |
Lines 1162-1199
Link Here
|
1162 |
} |
1173 |
} |
1163 |
}; |
1174 |
}; |
1164 |
|
1175 |
|
1165 |
QCString MessageComposer::bodyText() |
|
|
1166 |
{ |
1167 |
QCString body = mText; |
1168 |
|
1169 |
if (body.isNull()) return body; |
1170 |
|
1171 |
if (body.isEmpty()) body = "\n"; // don't crash |
1172 |
|
1173 |
// From RFC 3156: |
1174 |
// Note: The accepted OpenPGP convention is for signed data to end |
1175 |
// with a <CR><LF> sequence. Note that the <CR><LF> sequence |
1176 |
// immediately preceding a MIME boundary delimiter line is considered |
1177 |
// to be part of the delimiter in [3], 5.1. Thus, it is not part of |
1178 |
// the signed data preceding the delimiter line. An implementation |
1179 |
// which elects to adhere to the OpenPGP convention has to make sure |
1180 |
// it inserts a <CR><LF> pair on the last line of the data to be |
1181 |
// signed and transmitted (signed message and transmitted message |
1182 |
// MUST be identical). |
1183 |
// So make sure that the body ends with a <LF>. |
1184 |
if( body[body.length()-1] != '\n' ) { |
1185 |
kdDebug(5006) << "Added an <LF> on the last line" << endl; |
1186 |
body += "\n"; |
1187 |
} |
1188 |
return body; |
1189 |
} |
1190 |
|
1191 |
void MessageComposer::composeInlineOpenPGPMessage( KMMessage& theMessage, |
1176 |
void MessageComposer::composeInlineOpenPGPMessage( KMMessage& theMessage, |
1192 |
bool doSign, bool doEncrypt ) |
1177 |
bool doSign, bool doEncrypt ) |
1193 |
{ |
1178 |
{ |
1194 |
// preprocess the body text |
1179 |
// preprocess the body text |
1195 |
QCString body = bodyText(); |
1180 |
const QByteArray bodyData = mText; |
1196 |
if (body.isNull()) { |
1181 |
if (bodyData.isNull()) { |
1197 |
mRc = false; |
1182 |
mRc = false; |
1198 |
return; |
1183 |
return; |
1199 |
} |
1184 |
} |
Lines 1222-1231
Link Here
|
1222 |
QByteArray encryptedBody; |
1207 |
QByteArray encryptedBody; |
1223 |
if ( doSign ) { // Sign and encrypt |
1208 |
if ( doSign ) { // Sign and encrypt |
1224 |
const std::vector<GpgME::Key> signingKeys = mKeyResolver->signingKeys( Kleo::InlineOpenPGPFormat ); |
1209 |
const std::vector<GpgME::Key> signingKeys = mKeyResolver->signingKeys( Kleo::InlineOpenPGPFormat ); |
1225 |
result = pgpSignedAndEncryptedMsg( encryptedBody, body, signingKeys, |
1210 |
result = pgpSignedAndEncryptedMsg( encryptedBody, bodyData, signingKeys, |
1226 |
splitInfo.keys, Kleo::InlineOpenPGPFormat ); |
1211 |
splitInfo.keys, Kleo::InlineOpenPGPFormat ); |
1227 |
} else { // Encrypt but don't sign |
1212 |
} else { // Encrypt but don't sign |
1228 |
result = pgpEncryptedMsg( encryptedBody, body, |
1213 |
result = pgpEncryptedMsg( encryptedBody, bodyData, |
1229 |
splitInfo.keys, Kleo::InlineOpenPGPFormat ); |
1214 |
splitInfo.keys, Kleo::InlineOpenPGPFormat ); |
1230 |
} |
1215 |
} |
1231 |
if ( result != Kpgp::Ok ) { |
1216 |
if ( result != Kpgp::Ok ) { |
Lines 1236-1250
Link Here
|
1236 |
mOldBodyPart.setBodyEncodedBinary( encryptedBody ); |
1221 |
mOldBodyPart.setBodyEncodedBinary( encryptedBody ); |
1237 |
} else { |
1222 |
} else { |
1238 |
if ( doSign ) { // Sign but don't encrypt |
1223 |
if ( doSign ) { // Sign but don't encrypt |
1239 |
pgpSignedMsg( body, Kleo::InlineOpenPGPFormat ); |
1224 |
pgpSignedMsg( bodyData, Kleo::InlineOpenPGPFormat ); |
1240 |
if ( mSignature.isNull() ) { |
1225 |
if ( mSignature.isNull() ) { |
1241 |
mRc = false; |
1226 |
mRc = false; |
1242 |
return; |
1227 |
return; |
1243 |
} |
1228 |
} |
1244 |
mOldBodyPart.setBodyEncodedBinary( mSignature ); |
1229 |
mOldBodyPart.setBodyEncodedBinary( mSignature ); |
1245 |
} else { // don't sign nor encrypt -> nothing to do |
1230 |
} else { // don't sign nor encrypt -> nothing to do |
1246 |
assert( !body.isNull() ); |
1231 |
assert( !bodyData.isNull() ); |
1247 |
mOldBodyPart.setBodyEncoded( body ); |
1232 |
mOldBodyPart.setBodyEncodedBinary( bodyData ); |
1248 |
} |
1233 |
} |
1249 |
} |
1234 |
} |
1250 |
mOldBodyPart.setContentDisposition( "inline" ); |
1235 |
mOldBodyPart.setContentDisposition( "inline" ); |
Lines 1254-1260
Link Here
|
1254 |
mMessageList.push_back( msg ); |
1239 |
mMessageList.push_back( msg ); |
1255 |
if ( it == splitInfos.begin() ) { |
1240 |
if ( it == splitInfos.begin() ) { |
1256 |
if ( doEncrypt && !saveMessagesEncrypted() ) { |
1241 |
if ( doEncrypt && !saveMessagesEncrypted() ) { |
1257 |
mOldBodyPart.setBodyEncoded( body ); |
1242 |
mOldBodyPart.setBodyEncodedBinary( bodyData ); |
1258 |
KMMessage* msgUnenc = new KMMessage( theMessage ); |
1243 |
KMMessage* msgUnenc = new KMMessage( theMessage ); |
1259 |
addBodyAndAttachments( msgUnenc, splitInfo, false, false, mOldBodyPart, Kleo::InlineOpenPGPFormat ); |
1244 |
addBodyAndAttachments( msgUnenc, splitInfo, false, false, mOldBodyPart, Kleo::InlineOpenPGPFormat ); |
1260 |
msg->setUnencryptedMsg( msgUnenc ); |
1245 |
msg->setUnencryptedMsg( msgUnenc ); |
Lines 1274-1281
Link Here
|
1274 |
assert( chiasmus ); // kmcomposewin code should have made sure |
1259 |
assert( chiasmus ); // kmcomposewin code should have made sure |
1275 |
|
1260 |
|
1276 |
// preprocess the body text |
1261 |
// preprocess the body text |
1277 |
QCString body = bodyText(); |
1262 |
const QByteArray bodyData = mText; |
1278 |
if (body.isNull()) { |
1263 |
if (bodyData.isNull()) { |
1279 |
mRc = false; |
1264 |
mRc = false; |
1280 |
return; |
1265 |
return; |
1281 |
} |
1266 |
} |
Lines 1290-1298
Link Here
|
1290 |
theMessage.removeHeaderField("Content-Type"); |
1275 |
theMessage.removeHeaderField("Content-Type"); |
1291 |
theMessage.removeHeaderField("Content-Transfer-Encoding"); |
1276 |
theMessage.removeHeaderField("Content-Transfer-Encoding"); |
1292 |
|
1277 |
|
1293 |
QByteArray plainText; |
|
|
1294 |
plainText.duplicate( body.data(), body.length() ); // hrmpf... |
1295 |
|
1296 |
// This reads strange, but we know that AdjustCryptFlagsJob created a single splitinfo, |
1278 |
// This reads strange, but we know that AdjustCryptFlagsJob created a single splitinfo, |
1297 |
// under the given "format" (usually openpgp/mime; doesn't matter) |
1279 |
// under the given "format" (usually openpgp/mime; doesn't matter) |
1298 |
const std::vector<Kleo::KeyResolver::SplitInfo> splitInfos |
1280 |
const std::vector<Kleo::KeyResolver::SplitInfo> splitInfos |
Lines 1304-1310
Link Here
|
1304 |
KMMessage* msg = new KMMessage( theMessage ); |
1286 |
KMMessage* msg = new KMMessage( theMessage ); |
1305 |
QByteArray encryptedBody; |
1287 |
QByteArray encryptedBody; |
1306 |
|
1288 |
|
1307 |
if ( !encryptWithChiasmus( chiasmus, plainText, encryptedBody ) ) { |
1289 |
if ( !encryptWithChiasmus( chiasmus, bodyData, encryptedBody ) ) { |
1308 |
mRc = false; |
1290 |
mRc = false; |
1309 |
return; |
1291 |
return; |
1310 |
} |
1292 |
} |
Lines 1330-1336
Link Here
|
1330 |
mMessageList.push_back( msg ); |
1312 |
mMessageList.push_back( msg ); |
1331 |
|
1313 |
|
1332 |
if ( it == splitInfos.begin() && !saveMessagesEncrypted() ) { |
1314 |
if ( it == splitInfos.begin() && !saveMessagesEncrypted() ) { |
1333 |
mOldBodyPart.setBodyEncoded( body ); |
1315 |
mOldBodyPart.setBodyEncodedBinary( bodyData ); |
1334 |
KMMessage* msgUnenc = new KMMessage( theMessage ); |
1316 |
KMMessage* msgUnenc = new KMMessage( theMessage ); |
1335 |
addBodyAndAttachments( msgUnenc, splitInfo, false, false, mOldBodyPart, Kleo::InlineOpenPGPFormat ); |
1317 |
addBodyAndAttachments( msgUnenc, splitInfo, false, false, mOldBodyPart, Kleo::InlineOpenPGPFormat ); |
1336 |
msg->setUnencryptedMsg( msgUnenc ); |
1318 |
msg->setUnencryptedMsg( msgUnenc ); |
Lines 1361-1368
Link Here
|
1361 |
theMessage.setBody( "This message is in MIME format." ); |
1343 |
theMessage.setBody( "This message is in MIME format." ); |
1362 |
|
1344 |
|
1363 |
// preprocess the body text |
1345 |
// preprocess the body text |
1364 |
QCString body = bodyText(); |
1346 |
QByteArray bodyData = mText; |
1365 |
if (body.isNull()) { |
1347 |
if (bodyData.isNull()) { |
1366 |
mRc = false; |
1348 |
mRc = false; |
1367 |
return; |
1349 |
return; |
1368 |
} |
1350 |
} |
Lines 1430-1443
Link Here
|
1430 |
QCString newbody; |
1412 |
QCString newbody; |
1431 |
DwMediaType tmpCT; |
1413 |
DwMediaType tmpCT; |
1432 |
tmpCT.CreateBoundary( ++mPreviousBoundaryLevel ); |
1414 |
tmpCT.CreateBoundary( ++mPreviousBoundaryLevel ); |
1433 |
boundaryCStr = tmpCT.Boundary().c_str(); |
1415 |
boundaryCStr = KMail::Util::CString( tmpCT.Boundary() ); |
1434 |
QValueList<int> allowedCTEs; |
1416 |
QValueList<int> allowedCTEs; |
1435 |
|
1417 |
|
1436 |
KMMessagePart textBodyPart; |
1418 |
KMMessagePart textBodyPart; |
1437 |
textBodyPart.setTypeStr("text"); |
1419 |
textBodyPart.setTypeStr("text"); |
1438 |
textBodyPart.setSubtypeStr("plain"); |
1420 |
textBodyPart.setSubtypeStr("plain"); |
1439 |
|
1421 |
|
1440 |
QCString textbody = plainTextFromMarkup( mText ); |
1422 |
QCString textbody = plainTextFromMarkup( mText /* converted to QString */ ); |
1441 |
|
1423 |
|
1442 |
// the signed body must not be 8bit encoded |
1424 |
// the signed body must not be 8bit encoded |
1443 |
textBodyPart.setBodyAndGuessCte( textbody, allowedCTEs, |
1425 |
textBodyPart.setBodyAndGuessCte( textbody, allowedCTEs, |
Lines 1457-1469
Link Here
|
1457 |
KMMessagePart htmlBodyPart; |
1439 |
KMMessagePart htmlBodyPart; |
1458 |
htmlBodyPart.setTypeStr("text"); |
1440 |
htmlBodyPart.setTypeStr("text"); |
1459 |
htmlBodyPart.setSubtypeStr("html"); |
1441 |
htmlBodyPart.setSubtypeStr("html"); |
1460 |
QCString htmlbody = mText; |
1442 |
QByteArray htmlbody = mText; |
1461 |
// the signed body must not be 8bit encoded |
1443 |
// the signed body must not be 8bit encoded |
1462 |
htmlBodyPart.setBodyAndGuessCte( htmlbody, allowedCTEs, |
1444 |
htmlBodyPart.setBodyAndGuessCte( htmlbody, allowedCTEs, |
1463 |
!kmkernel->msgSender()->sendQuotedPrintable() && !doSign, |
1445 |
!kmkernel->msgSender()->sendQuotedPrintable() && !doSign, |
1464 |
doSign ); |
1446 |
doSign ); |
1465 |
htmlBodyPart.setCharset( mCharset ); |
1447 |
htmlBodyPart.setCharset( mCharset ); |
1466 |
htmlBodyPart.setBodyEncoded( htmlbody ); |
1448 |
htmlBodyPart.setBodyEncodedBinary( htmlbody ); |
1467 |
DwBodyPart* htmlDwPart = theMessage.createDWBodyPart( &htmlBodyPart ); |
1449 |
DwBodyPart* htmlDwPart = theMessage.createDWBodyPart( &htmlBodyPart ); |
1468 |
htmlDwPart->Assemble(); |
1450 |
htmlDwPart->Assemble(); |
1469 |
newbody += "\n--"; |
1451 |
newbody += "\n--"; |
Lines 1476-1483
Link Here
|
1476 |
newbody += "--"; |
1458 |
newbody += "--"; |
1477 |
newbody += boundaryCStr; |
1459 |
newbody += boundaryCStr; |
1478 |
newbody += "--\n"; |
1460 |
newbody += "--\n"; |
1479 |
body = newbody; |
1461 |
bodyData = KMail::Util::byteArrayFromQCStringNoDetach( newbody ); |
1480 |
mOldBodyPart.setBodyEncoded( newbody ); |
1462 |
mOldBodyPart.setBodyEncodedBinary( bodyData ); |
1481 |
|
1463 |
|
1482 |
mSaveBoundary = tmpCT.Boundary(); |
1464 |
mSaveBoundary = tmpCT.Boundary(); |
1483 |
} |
1465 |
} |
Lines 1493-1499
Link Here
|
1493 |
// eventually get rid of this: |
1475 |
// eventually get rid of this: |
1494 |
if( it->sign || it->encrypt ) { |
1476 |
if( it->sign || it->encrypt ) { |
1495 |
QCString cte = it->part->cteStr().lower(); |
1477 |
QCString cte = it->part->cteStr().lower(); |
1496 |
if( ( "8bit" == cte ) |
1478 |
if( ( "8bit" == cte && it->part->type() != DwMime::kTypeMessage ) |
1497 |
|| ( ( it->part->type() == DwMime::kTypeText ) |
1479 |
|| ( ( it->part->type() == DwMime::kTypeText ) |
1498 |
&& ( "7bit" == cte ) ) ) { |
1480 |
&& ( "7bit" == cte ) ) ) { |
1499 |
const QByteArray body = it->part->bodyDecodedBinary(); |
1481 |
const QByteArray body = it->part->bodyDecodedBinary(); |
Lines 1518-1545
Link Here
|
1518 |
innerBodyPart.setContentDisposition( "inline" ); |
1500 |
innerBodyPart.setContentDisposition( "inline" ); |
1519 |
QValueList<int> allowedCTEs; |
1501 |
QValueList<int> allowedCTEs; |
1520 |
// the signed body must not be 8bit encoded |
1502 |
// the signed body must not be 8bit encoded |
1521 |
innerBodyPart.setBodyAndGuessCte( body, allowedCTEs, |
1503 |
innerBodyPart.setBodyAndGuessCte( bodyData, allowedCTEs, |
1522 |
!kmkernel->msgSender()->sendQuotedPrintable() && !doSign, |
1504 |
!kmkernel->msgSender()->sendQuotedPrintable() && !doSign, |
1523 |
doSign ); |
1505 |
doSign ); |
1524 |
if ( !mIsRichText ) |
1506 |
if ( !mIsRichText ) |
1525 |
innerBodyPart.setCharset( mCharset ); |
1507 |
innerBodyPart.setCharset( mCharset ); |
1526 |
innerBodyPart.setBodyEncoded( body ); // do we need this, since setBodyAndGuessCte does this already? |
1508 |
innerBodyPart.setBodyEncodedBinary( bodyData ); // do we need this, since setBodyAndGuessCte does this already? |
1527 |
DwBodyPart* innerDwPart = theMessage.createDWBodyPart( &innerBodyPart ); |
1509 |
DwBodyPart* innerDwPart = theMessage.createDWBodyPart( &innerBodyPart ); |
1528 |
innerDwPart->Assemble(); |
1510 |
innerDwPart->Assemble(); |
|
|
1511 |
QByteArray tmpbody = KMail::Util::ByteArray( innerDwPart->AsString() ); |
1529 |
if ( mIsRichText ) { // and add our mp/a boundary |
1512 |
if ( mIsRichText ) { // and add our mp/a boundary |
1530 |
QCString tmpbody = innerDwPart->AsString().c_str(); |
|
|
1531 |
int boundPos = tmpbody.find( '\n' ); |
1513 |
int boundPos = tmpbody.find( '\n' ); |
1532 |
if( -1 < boundPos ) { |
1514 |
if( -1 < boundPos ) { |
1533 |
QCString bStr( ";\n boundary=\"" ); |
1515 |
QCString bStr( ";\n boundary=\"" ); |
1534 |
bStr += mSaveBoundary.c_str(); |
1516 |
bStr += mSaveBoundary.c_str(); |
1535 |
bStr += "\""; |
1517 |
bStr += "\""; |
1536 |
body = innerDwPart->AsString().c_str(); |
1518 |
bodyData = tmpbody; |
1537 |
body.insert( boundPos, bStr ); |
1519 |
KMail::Util::insert( bodyData, boundPos, bStr ); |
1538 |
body = "--" + mMultipartMixedBoundary + "\n" + body; |
1520 |
KMail::Util::insert( bodyData, 0, "--" + mMultipartMixedBoundary + "\n" ); // prepend |
1539 |
} |
1521 |
} |
1540 |
} |
1522 |
} |
1541 |
else |
1523 |
else { |
1542 |
body = "--" + mMultipartMixedBoundary + "\n" + innerDwPart->AsString().c_str(); |
1524 |
bodyData = tmpbody; |
|
|
1525 |
KMail::Util::insert( bodyData, 0, "--" + mMultipartMixedBoundary + "\n" ); // prepend |
1526 |
} |
1543 |
delete innerDwPart; |
1527 |
delete innerDwPart; |
1544 |
innerDwPart = 0; |
1528 |
innerDwPart = 0; |
1545 |
// add all matching Attachments |
1529 |
// add all matching Attachments |
Lines 1548-1569
Link Here
|
1548 |
if ( it->encrypt == doEncryptBody && it->sign == doSignBody ) { |
1532 |
if ( it->encrypt == doEncryptBody && it->sign == doSignBody ) { |
1549 |
innerDwPart = theMessage.createDWBodyPart( it->part ); |
1533 |
innerDwPart = theMessage.createDWBodyPart( it->part ); |
1550 |
innerDwPart->Assemble(); |
1534 |
innerDwPart->Assemble(); |
1551 |
body += "\n--" + mMultipartMixedBoundary + "\n" + innerDwPart->AsString().c_str(); |
1535 |
KMail::Util::append( bodyData, QCString( "\n--" + mMultipartMixedBoundary + "\n" ) ); |
|
|
1536 |
KMail::Util::append( bodyData, innerDwPart->AsString().c_str() ); |
1552 |
delete innerDwPart; |
1537 |
delete innerDwPart; |
1553 |
innerDwPart = 0; |
1538 |
innerDwPart = 0; |
1554 |
} |
1539 |
} |
1555 |
} |
1540 |
} |
1556 |
body += "\n--" + mMultipartMixedBoundary + "--\n"; |
1541 |
KMail::Util::append( bodyData, QCString( "\n--" + mMultipartMixedBoundary + "--\n" ) ); |
1557 |
} else { // !earlyAddAttachments |
1542 |
} else { // !earlyAddAttachments |
1558 |
QValueList<int> allowedCTEs; |
1543 |
QValueList<int> allowedCTEs; |
1559 |
// the signed body must not be 8bit encoded |
1544 |
// the signed body must not be 8bit encoded |
1560 |
mOldBodyPart.setBodyAndGuessCte(body, allowedCTEs, !kmkernel->msgSender()->sendQuotedPrintable() && !doSign, |
1545 |
mOldBodyPart.setBodyAndGuessCte(bodyData, allowedCTEs, !kmkernel->msgSender()->sendQuotedPrintable() && !doSign, |
1561 |
doSign); |
1546 |
doSign); |
1562 |
if ( !mIsRichText ) |
1547 |
if ( !mIsRichText ) |
1563 |
mOldBodyPart.setCharset(mCharset); |
1548 |
mOldBodyPart.setCharset(mCharset); |
1564 |
} |
1549 |
} |
1565 |
// create S/MIME body part for signing and/or encrypting |
1550 |
// create S/MIME body part for signing and/or encrypting |
1566 |
mOldBodyPart.setBodyEncoded( body ); |
1551 |
mOldBodyPart.setBodyEncodedBinary( bodyData ); |
1567 |
|
1552 |
|
1568 |
if( doSignBody || doEncryptBody ) { |
1553 |
if( doSignBody || doEncryptBody ) { |
1569 |
// get string representation of body part (including the attachments) |
1554 |
// get string representation of body part (including the attachments) |
Lines 1577-1589
Link Here
|
1577 |
DwMediaType& ct = headers.ContentType(); |
1562 |
DwMediaType& ct = headers.ContentType(); |
1578 |
ct.SetBoundary(mSaveBoundary); |
1563 |
ct.SetBoundary(mSaveBoundary); |
1579 |
dwPart->Assemble(); |
1564 |
dwPart->Assemble(); |
1580 |
mEncodedBody = dwPart->AsString().c_str(); |
|
|
1581 |
} |
1565 |
} |
1582 |
else { |
1566 |
else { |
1583 |
dwPart = theMessage.createDWBodyPart( &mOldBodyPart ); |
1567 |
dwPart = theMessage.createDWBodyPart( &mOldBodyPart ); |
1584 |
dwPart->Assemble(); |
1568 |
dwPart->Assemble(); |
1585 |
mEncodedBody = dwPart->AsString().c_str(); |
|
|
1586 |
} |
1569 |
} |
|
|
1570 |
mEncodedBody = KMail::Util::ByteArray( dwPart->AsString() ); |
1587 |
delete dwPart; |
1571 |
delete dwPart; |
1588 |
dwPart = 0; |
1572 |
dwPart = 0; |
1589 |
|
1573 |
|
Lines 1595-1601
Link Here
|
1595 |
QCString bStr( ";\n boundary=\"" ); |
1579 |
QCString bStr( ";\n boundary=\"" ); |
1596 |
bStr += mMultipartMixedBoundary; |
1580 |
bStr += mMultipartMixedBoundary; |
1597 |
bStr += "\""; |
1581 |
bStr += "\""; |
1598 |
mEncodedBody.insert( boundPos, bStr ); |
1582 |
KMail::Util::insert( mEncodedBody, boundPos, bStr.data() ); |
1599 |
} |
1583 |
} |
1600 |
} |
1584 |
} |
1601 |
|
1585 |
|
Lines 1606-1613
Link Here
|
1606 |
} |
1590 |
} |
1607 |
|
1591 |
|
1608 |
if ( doSignBody ) { |
1592 |
if ( doSignBody ) { |
|
|
1593 |
mPerformingSignOperation = true; // this lets the KMComposeWin know if it is safe to close the window. |
1609 |
pgpSignedMsg( mEncodedBody, format ); |
1594 |
pgpSignedMsg( mEncodedBody, format ); |
1610 |
|
1595 |
mPerformingSignOperation = false; |
|
|
1596 |
|
1611 |
if ( mSignature.isEmpty() ) { |
1597 |
if ( mSignature.isEmpty() ) { |
1612 |
kdDebug() << "signature was empty" << endl; |
1598 |
kdDebug() << "signature was empty" << endl; |
1613 |
mRc = false; |
1599 |
mRc = false; |
Lines 1655-1661
Link Here
|
1655 |
Kleo::KeyResolver::SplitInfo( splitInfos.front().recipients ), doSign, |
1641 |
Kleo::KeyResolver::SplitInfo( splitInfos.front().recipients ), doSign, |
1656 |
false, mEncodedBody, |
1642 |
false, mEncodedBody, |
1657 |
mPreviousBoundaryLevel, |
1643 |
mPreviousBoundaryLevel, |
1658 |
mOldBodyPart, mNewBodyPart, |
1644 |
/*mOldBodyPart,*/ mNewBodyPart, |
1659 |
format, this ) ); |
1645 |
format, this ) ); |
1660 |
} |
1646 |
} |
1661 |
|
1647 |
|
Lines 1663-1669
Link Here
|
1663 |
mJobs.push_front( new EncryptMessageJob( new KMMessage( theMessage ), *it, doSign, |
1649 |
mJobs.push_front( new EncryptMessageJob( new KMMessage( theMessage ), *it, doSign, |
1664 |
doEncrypt, mEncodedBody, |
1650 |
doEncrypt, mEncodedBody, |
1665 |
mPreviousBoundaryLevel, |
1651 |
mPreviousBoundaryLevel, |
1666 |
mOldBodyPart, mNewBodyPart, |
1652 |
/*mOldBodyPart,*/ mNewBodyPart, |
1667 |
format, this ) ); |
1653 |
format, this ) ); |
1668 |
} |
1654 |
} |
1669 |
|
1655 |
|
Lines 1684-1699
Link Here
|
1684 |
const bool doSignBody = doSign && mSignBody; |
1670 |
const bool doSignBody = doSign && mSignBody; |
1685 |
|
1671 |
|
1686 |
if ( doEncryptBody ) { |
1672 |
if ( doEncryptBody ) { |
1687 |
QCString innerContent; |
1673 |
QByteArray innerContent; |
1688 |
if ( doSignBody ) { |
1674 |
if ( doSignBody ) { |
1689 |
// extract signed body from newBodyPart |
1675 |
// extract signed body from newBodyPart |
1690 |
DwBodyPart* dwPart = msg->createDWBodyPart( &newBodyPart ); |
1676 |
DwBodyPart* dwPart = msg->createDWBodyPart( &newBodyPart ); |
1691 |
dwPart->Assemble(); |
1677 |
dwPart->Assemble(); |
1692 |
innerContent = dwPart->AsString().c_str(); |
1678 |
innerContent = KMail::Util::ByteArray( dwPart->AsString() ); |
1693 |
delete dwPart; |
1679 |
delete dwPart; |
1694 |
dwPart = 0; |
1680 |
dwPart = 0; |
1695 |
} else |
1681 |
} else { |
1696 |
innerContent = mEncodedBody; |
1682 |
innerContent = mEncodedBody; |
|
|
1683 |
} |
1697 |
|
1684 |
|
1698 |
// now do the encrypting: |
1685 |
// now do the encrypting: |
1699 |
// replace simple LFs by CRLFs for all MIME supporting CryptPlugs |
1686 |
// replace simple LFs by CRLFs for all MIME supporting CryptPlugs |
Lines 1784-1790
Link Here
|
1784 |
|
1771 |
|
1785 |
DwBodyPart* innerDwPart = msg->createDWBodyPart( it->part ); |
1772 |
DwBodyPart* innerDwPart = msg->createDWBodyPart( it->part ); |
1786 |
innerDwPart->Assemble(); |
1773 |
innerDwPart->Assemble(); |
1787 |
QCString encodedAttachment = innerDwPart->AsString().c_str(); |
1774 |
QByteArray encodedAttachment = KMail::Util::ByteArray( innerDwPart->AsString() ); |
1788 |
delete innerDwPart; |
1775 |
delete innerDwPart; |
1789 |
innerDwPart = 0; |
1776 |
innerDwPart = 0; |
1790 |
|
1777 |
|
Lines 1795-1804
Link Here
|
1795 |
|
1782 |
|
1796 |
// sign this attachment |
1783 |
// sign this attachment |
1797 |
if( signThisNow ) { |
1784 |
if( signThisNow ) { |
1798 |
|
|
|
1799 |
pgpSignedMsg( encodedAttachment, format ); |
1785 |
pgpSignedMsg( encodedAttachment, format ); |
1800 |
QByteArray signature = mSignature; |
1786 |
mRc = !mSignature.isEmpty(); |
1801 |
mRc = !signature.isEmpty(); |
|
|
1802 |
if( mRc ) { |
1787 |
if( mRc ) { |
1803 |
mRc = processStructuringInfo( "http://www.gnupg.org/aegypten/", |
1788 |
mRc = processStructuringInfo( "http://www.gnupg.org/aegypten/", |
1804 |
it->part->contentDescription(), |
1789 |
it->part->contentDescription(), |
Lines 1808-1821
Link Here
|
1808 |
it->part->contentTransferEncodingStr(), |
1793 |
it->part->contentTransferEncodingStr(), |
1809 |
encodedAttachment, |
1794 |
encodedAttachment, |
1810 |
"signature", |
1795 |
"signature", |
1811 |
signature, |
1796 |
mSignature, |
1812 |
newAttachPart, true, format ); |
1797 |
newAttachPart, true, format ); |
1813 |
if( mRc ) { |
1798 |
if( mRc ) { |
1814 |
if( encryptThisNow ) { |
1799 |
if( encryptThisNow ) { |
1815 |
rEncryptMessagePart = newAttachPart; |
1800 |
rEncryptMessagePart = newAttachPart; |
1816 |
DwBodyPart* dwPart = msg->createDWBodyPart( &newAttachPart ); |
1801 |
DwBodyPart* dwPart = msg->createDWBodyPart( &newAttachPart ); |
1817 |
dwPart->Assemble(); |
1802 |
dwPart->Assemble(); |
1818 |
encodedAttachment = dwPart->AsString().c_str(); |
1803 |
encodedAttachment = KMail::Util::ByteArray( dwPart->AsString() ); |
1819 |
delete dwPart; |
1804 |
delete dwPart; |
1820 |
dwPart = 0; |
1805 |
dwPart = 0; |
1821 |
} |
1806 |
} |
Lines 1880-1886
Link Here
|
1880 |
kdDebug(5006) << "MessageComposer::addBodyAndAttachments() : top level headers and body adjusted" << endl; |
1865 |
kdDebug(5006) << "MessageComposer::addBodyAndAttachments() : top level headers and body adjusted" << endl; |
1881 |
|
1866 |
|
1882 |
// set body content |
1867 |
// set body content |
1883 |
msg->setBody(ourFineBodyPart.body() ); |
1868 |
msg->setBody( ourFineBodyPart.dwBody() ); |
1884 |
|
1869 |
|
1885 |
} |
1870 |
} |
1886 |
|
1871 |
|
Lines 1902-1913
Link Here
|
1902 |
const QCString contentSubtypeClear, |
1887 |
const QCString contentSubtypeClear, |
1903 |
const QCString contentDispClear, |
1888 |
const QCString contentDispClear, |
1904 |
const QCString contentTEncClear, |
1889 |
const QCString contentTEncClear, |
1905 |
const QCString& clearCStr, |
1890 |
const QByteArray& clearCStr, |
1906 |
const QString /*contentDescCiph*/, |
1891 |
const QString /*contentDescCiph*/, |
1907 |
const QByteArray& ciphertext, |
1892 |
const QByteArray& ciphertext, |
1908 |
KMMessagePart& resultingPart, |
1893 |
KMMessagePart& resultingPart, |
1909 |
bool signing, Kleo::CryptoMessageFormat format ) |
1894 |
bool signing, Kleo::CryptoMessageFormat format ) |
1910 |
{ |
1895 |
{ |
|
|
1896 |
assert( clearCStr.isEmpty() || clearCStr[clearCStr.size()-1] != '\0' ); // I was called with a QCString !? |
1911 |
bool bOk = true; |
1897 |
bool bOk = true; |
1912 |
|
1898 |
|
1913 |
if ( makeMimeObject( format, signing ) ) { |
1899 |
if ( makeMimeObject( format, signing ) ) { |
Lines 1955-1966
Link Here
|
1955 |
KMMessage::bodyPart( &mainDwPa, &resultingPart ); |
1941 |
KMMessage::bodyPart( &mainDwPa, &resultingPart ); |
1956 |
if( !makeMultiMime( format, signing ) ) { |
1942 |
if( !makeMultiMime( format, signing ) ) { |
1957 |
if ( signing && includeCleartextWhenSigning( format ) ) { |
1943 |
if ( signing && includeCleartextWhenSigning( format ) ) { |
1958 |
QCString bodyText( clearCStr ); |
1944 |
QByteArray bodyText( clearCStr ); |
1959 |
bodyText += '\n'; |
1945 |
KMail::Util::append( bodyText, "\n" ); |
1960 |
bodyText += QCString( ciphertext.data(), ciphertext.size() + 1 ); |
1946 |
KMail::Util::append( bodyText, ciphertext ); |
1961 |
resultingPart.setBodyEncoded( bodyText ); |
1947 |
resultingPart.setBodyEncodedBinary( bodyText ); |
1962 |
} else |
1948 |
} else { |
1963 |
resultingPart.setBodyEncodedBinary( ciphertext ); |
1949 |
resultingPart.setBodyEncodedBinary( ciphertext ); |
|
|
1950 |
} |
1964 |
} else { |
1951 |
} else { |
1965 |
// Build the encapsulated MIME parts. |
1952 |
// Build the encapsulated MIME parts. |
1966 |
// Build a MIME part holding the version information |
1953 |
// Build a MIME part holding the version information |
Lines 1993-2010
Link Here
|
1993 |
codeCStr += '\n' + QCString( ciphertext.data(), ciphertext.size() + 1 ); |
1980 |
codeCStr += '\n' + QCString( ciphertext.data(), ciphertext.size() + 1 ); |
1994 |
|
1981 |
|
1995 |
|
1982 |
|
1996 |
QCString mainStr = "--" + boundaryCStr; |
1983 |
QByteArray mainStr; |
|
|
1984 |
KMail::Util::append( mainStr, "--" ); |
1985 |
KMail::Util::append( mainStr, boundaryCStr ); |
1997 |
if ( signing && includeCleartextWhenSigning( format ) && |
1986 |
if ( signing && includeCleartextWhenSigning( format ) && |
1998 |
!clearCStr.isEmpty() ) |
1987 |
!clearCStr.isEmpty() ) { |
1999 |
mainStr += "\n" + clearCStr + "\n--" + boundaryCStr; |
1988 |
KMail::Util::append( mainStr, "\n" ); |
|
|
1989 |
// clearCStr is the one that can be very big for large attachments, don't merge with the other lines |
1990 |
KMail::Util::append( mainStr, clearCStr ); |
1991 |
KMail::Util::append( mainStr, "\n--" + boundaryCStr ); |
1992 |
} |
2000 |
if ( !versCStr.isEmpty() ) |
1993 |
if ( !versCStr.isEmpty() ) |
2001 |
mainStr += "\n" + versCStr + "\n--" + boundaryCStr; |
1994 |
KMail::Util::append( mainStr, "\n" + versCStr + "\n--" + boundaryCStr ); |
2002 |
if( !codeCStr.isEmpty() ) |
1995 |
if( !codeCStr.isEmpty() ) |
2003 |
mainStr += "\n" + codeCStr + "\n--" + boundaryCStr; |
1996 |
KMail::Util::append( mainStr, "\n" + codeCStr + "\n--" + boundaryCStr ); |
2004 |
mainStr += "--\n"; |
1997 |
KMail::Util::append( mainStr, "--\n" ); |
2005 |
|
1998 |
|
2006 |
//kdDebug(5006) << "processStructuringInfo: mainStr=" << mainStr << endl; |
1999 |
//kdDebug(5006) << "processStructuringInfo: mainStr=" << mainStr << endl; |
2007 |
resultingPart.setBodyEncoded( mainStr ); |
2000 |
resultingPart.setBodyEncodedBinary( mainStr ); |
2008 |
} |
2001 |
} |
2009 |
|
2002 |
|
2010 |
} else { // not making a mime object, build a plain message body. |
2003 |
} else { // not making a mime object, build a plain message body. |
Lines 2014-2027
Link Here
|
2014 |
resultingPart.setSubtypeStr( contentSubtypeClear ); |
2007 |
resultingPart.setSubtypeStr( contentSubtypeClear ); |
2015 |
resultingPart.setContentDisposition( contentDispClear ); |
2008 |
resultingPart.setContentDisposition( contentDispClear ); |
2016 |
resultingPart.setContentTransferEncodingStr( contentTEncClear ); |
2009 |
resultingPart.setContentTransferEncodingStr( contentTEncClear ); |
2017 |
QCString resultingBody; |
2010 |
QByteArray resultingBody; |
2018 |
|
2011 |
|
2019 |
if ( signing && includeCleartextWhenSigning( format ) ) { |
2012 |
if ( signing && includeCleartextWhenSigning( format ) ) { |
2020 |
if( !clearCStr.isEmpty() ) |
2013 |
if( !clearCStr.isEmpty() ) |
2021 |
resultingBody += clearCStr; |
2014 |
KMail::Util::append( resultingBody, clearCStr ); |
2022 |
} |
2015 |
} |
2023 |
if ( !ciphertext.isEmpty() ) |
2016 |
if ( !ciphertext.isEmpty() ) |
2024 |
resultingBody += QCString( ciphertext.data(), ciphertext.size() + 1 ); // null-terminate |
2017 |
KMail::Util::append( resultingBody, ciphertext ); |
2025 |
else { |
2018 |
else { |
2026 |
// Plugin error! |
2019 |
// Plugin error! |
2027 |
KMessageBox::sorry( mComposeWin, |
2020 |
KMessageBox::sorry( mComposeWin, |
Lines 2031-2037
Link Here
|
2031 |
.arg( bugURL ) ); |
2024 |
.arg( bugURL ) ); |
2032 |
bOk = false; |
2025 |
bOk = false; |
2033 |
} |
2026 |
} |
2034 |
resultingPart.setBodyEncoded( resultingBody ); |
2027 |
resultingPart.setBodyEncodedBinary( resultingBody ); |
2035 |
} |
2028 |
} |
2036 |
|
2029 |
|
2037 |
return bOk; |
2030 |
return bOk; |
Lines 2065-2071
Link Here
|
2065 |
} |
2058 |
} |
2066 |
|
2059 |
|
2067 |
//----------------------------------------------------------------------------- |
2060 |
//----------------------------------------------------------------------------- |
2068 |
QCString MessageComposer::breakLinesAndApplyCodec() |
2061 |
QByteArray MessageComposer::breakLinesAndApplyCodec() |
2069 |
{ |
2062 |
{ |
2070 |
QString text; |
2063 |
QString text; |
2071 |
QCString cText; |
2064 |
QCString cText; |
Lines 2103-2119
Link Here
|
2103 |
i18n("Lose Characters"), i18n("Change Encoding") ) == KMessageBox::Yes ); |
2096 |
i18n("Lose Characters"), i18n("Change Encoding") ) == KMessageBox::Yes ); |
2104 |
if( !anyway ) { |
2097 |
if( !anyway ) { |
2105 |
mComposeWin->mEditor->setText(oldText); |
2098 |
mComposeWin->mEditor->setText(oldText); |
2106 |
return QCString(); |
2099 |
return QByteArray(); |
2107 |
} |
2100 |
} |
2108 |
} |
2101 |
} |
2109 |
|
2102 |
|
2110 |
return cText; |
2103 |
// From RFC 3156: |
|
|
2104 |
// Note: The accepted OpenPGP convention is for signed data to end |
2105 |
// with a <CR><LF> sequence. Note that the <CR><LF> sequence |
2106 |
// immediately preceding a MIME boundary delimiter line is considered |
2107 |
// to be part of the delimiter in [3], 5.1. Thus, it is not part of |
2108 |
// the signed data preceding the delimiter line. An implementation |
2109 |
// which elects to adhere to the OpenPGP convention has to make sure |
2110 |
// it inserts a <CR><LF> pair on the last line of the data to be |
2111 |
// signed and transmitted (signed message and transmitted message |
2112 |
// MUST be identical). |
2113 |
// So make sure that the body ends with a <LF>. |
2114 |
if( cText.isEmpty() || cText[cText.length()-1] != '\n' ) { |
2115 |
kdDebug(5006) << "Added an <LF> on the last line" << endl; |
2116 |
cText += "\n"; |
2117 |
} |
2118 |
return KMail::Util::byteArrayFromQCStringNoDetach( cText ); |
2111 |
} |
2119 |
} |
2112 |
|
2120 |
|
2113 |
|
2121 |
|
2114 |
//----------------------------------------------------------------------------- |
2122 |
//----------------------------------------------------------------------------- |
2115 |
void MessageComposer::pgpSignedMsg( const QCString & cText, Kleo::CryptoMessageFormat format ) { |
2123 |
void MessageComposer::pgpSignedMsg( const QByteArray& cText, Kleo::CryptoMessageFormat format ) { |
2116 |
|
2124 |
|
|
|
2125 |
assert( cText.isEmpty() || cText[cText.size()-1] != '\0' ); // I was called with a QCString !? |
2117 |
mSignature = QByteArray(); |
2126 |
mSignature = QByteArray(); |
2118 |
|
2127 |
|
2119 |
const std::vector<GpgME::Key> signingKeys = mKeyResolver->signingKeys( format ); |
2128 |
const std::vector<GpgME::Key> signingKeys = mKeyResolver->signingKeys( format ); |
Lines 2139-2149
Link Here
|
2139 |
return; |
2148 |
return; |
2140 |
} |
2149 |
} |
2141 |
|
2150 |
|
2142 |
QByteArray plainText; |
|
|
2143 |
plainText.duplicate( cText.data(), cText.length() ); // hrmpf... |
2144 |
QByteArray signature; |
2151 |
QByteArray signature; |
2145 |
const GpgME::SigningResult res = |
2152 |
const GpgME::SigningResult res = |
2146 |
job->exec( signingKeys, plainText, signingMode( format ), signature ); |
2153 |
job->exec( signingKeys, cText, signingMode( format ), signature ); |
2147 |
if ( res.error().isCanceled() ) { |
2154 |
if ( res.error().isCanceled() ) { |
2148 |
kdDebug() << "signing was canceled by user" << endl; |
2155 |
kdDebug() << "signing was canceled by user" << endl; |
2149 |
return; |
2156 |
return; |
Lines 2165-2171
Link Here
|
2165 |
|
2172 |
|
2166 |
//----------------------------------------------------------------------------- |
2173 |
//----------------------------------------------------------------------------- |
2167 |
Kpgp::Result MessageComposer::pgpEncryptedMsg( QByteArray & encryptedBody, |
2174 |
Kpgp::Result MessageComposer::pgpEncryptedMsg( QByteArray & encryptedBody, |
2168 |
const QCString & cText, |
2175 |
const QByteArray& cText, |
2169 |
const std::vector<GpgME::Key> & encryptionKeys, |
2176 |
const std::vector<GpgME::Key> & encryptionKeys, |
2170 |
Kleo::CryptoMessageFormat format ) |
2177 |
Kleo::CryptoMessageFormat format ) |
2171 |
{ |
2178 |
{ |
Lines 2187-2197
Link Here
|
2187 |
return Kpgp::Failure; |
2194 |
return Kpgp::Failure; |
2188 |
} |
2195 |
} |
2189 |
|
2196 |
|
2190 |
QByteArray plainText; |
|
|
2191 |
plainText.duplicate( cText.data(), cText.length() ); // hrmpf... |
2192 |
|
2193 |
const GpgME::EncryptionResult res = |
2197 |
const GpgME::EncryptionResult res = |
2194 |
job->exec( encryptionKeys, plainText, false, encryptedBody ); |
2198 |
job->exec( encryptionKeys, cText, false, encryptedBody ); |
2195 |
if ( res.error().isCanceled() ) { |
2199 |
if ( res.error().isCanceled() ) { |
2196 |
kdDebug() << "encryption was canceled by user" << endl; |
2200 |
kdDebug() << "encryption was canceled by user" << endl; |
2197 |
return Kpgp::Canceled; |
2201 |
return Kpgp::Canceled; |
Lines 2205-2211
Link Here
|
2205 |
} |
2209 |
} |
2206 |
|
2210 |
|
2207 |
Kpgp::Result MessageComposer::pgpSignedAndEncryptedMsg( QByteArray & encryptedBody, |
2211 |
Kpgp::Result MessageComposer::pgpSignedAndEncryptedMsg( QByteArray & encryptedBody, |
2208 |
const QCString & cText, |
2212 |
const QByteArray& cText, |
2209 |
const std::vector<GpgME::Key> & signingKeys, |
2213 |
const std::vector<GpgME::Key> & signingKeys, |
2210 |
const std::vector<GpgME::Key> & encryptionKeys, |
2214 |
const std::vector<GpgME::Key> & encryptionKeys, |
2211 |
Kleo::CryptoMessageFormat format ) |
2215 |
Kleo::CryptoMessageFormat format ) |
Lines 2228-2238
Link Here
|
2228 |
return Kpgp::Failure; |
2232 |
return Kpgp::Failure; |
2229 |
} |
2233 |
} |
2230 |
|
2234 |
|
2231 |
QByteArray plainText; |
|
|
2232 |
plainText.duplicate( cText.data(), cText.length() ); // hrmpf... |
2233 |
|
2234 |
const std::pair<GpgME::SigningResult,GpgME::EncryptionResult> res = |
2235 |
const std::pair<GpgME::SigningResult,GpgME::EncryptionResult> res = |
2235 |
job->exec( signingKeys, encryptionKeys, plainText, false, encryptedBody ); |
2236 |
job->exec( signingKeys, encryptionKeys, cText, false, encryptedBody ); |
2236 |
if ( res.first.error().isCanceled() || res.second.error().isCanceled() ) { |
2237 |
if ( res.first.error().isCanceled() || res.second.error().isCanceled() ) { |
2237 |
kdDebug() << "encrypt/sign was canceled by user" << endl; |
2238 |
kdDebug() << "encrypt/sign was canceled by user" << endl; |
2238 |
return Kpgp::Canceled; |
2239 |
return Kpgp::Canceled; |