Merge branch 'dev' into dev-18.04

preferencesAboutTextFull
Clément Fauconnier 6 years ago
commit 0d6f19c067
  1. 12
      src/board/UBBoardController.cpp
  2. 2
      src/core/UBDownloadManager.cpp
  3. 35
      src/frameworks/UBCryptoUtils.cpp
  4. 5
      src/frameworks/UBCryptoUtils.h

@ -741,7 +741,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item)
return retItem; return retItem;
} }
UBItem *createdItem = downloadFinished(true, sourceUrl, srcFile, contentTypeHeader, pData, itemPos, QSize(itemSize.width(), itemSize.height()), false); UBItem *createdItem = downloadFinished(true, sourceUrl, QUrl::fromLocalFile(srcFile), contentTypeHeader, pData, itemPos, QSize(itemSize.width(), itemSize.height()), false);
if (createdItem) if (createdItem)
{ {
createdItem->setSourceUrl(item->sourceUrl()); createdItem->setSourceUrl(item->sourceUrl());
@ -1375,11 +1375,8 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl
widgetItem->setSourceUrl(QUrl::fromLocalFile(widgetUrl)); widgetItem->setSourceUrl(QUrl::fromLocalFile(widgetUrl));
qDebug() << widgetItem->getOwnFolder(); qDebug() << widgetItem->getOwnFolder();
qDebug() << widgetItem->getSnapshotPath(); qDebug() << widgetItem->getSnapshotPath();
QString ownFolder = selectedDocument()->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + widgetItem->uuid().toString() + ".wgt";
widgetItem->setOwnFolder(ownFolder); widgetItem->setSnapshotPath(widgetItem->getOwnFolder());
QString adaptedUUid = widgetItem->uuid().toString().replace("{","").replace("}","");
ownFolder = ownFolder.replace(widgetItem->uuid().toString() + ".wgt", adaptedUUid + ".png");
widgetItem->setSnapshotPath(ownFolder);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
@ -2503,6 +2500,8 @@ void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* gr
UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast<UBItem *>(graphicsWidget)); UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast<UBItem *>(graphicsWidget));
UBGraphicsWidgetItem *copyedGraphicsWidget = NULL; UBGraphicsWidgetItem *copyedGraphicsWidget = NULL;
if (toolW3C)
{
if (UBGraphicsWidgetItem::Type == toolW3C->type()) if (UBGraphicsWidgetItem::Type == toolW3C->type())
copyedGraphicsWidget = static_cast<UBGraphicsWidgetItem *>(toolW3C); copyedGraphicsWidget = static_cast<UBGraphicsWidgetItem *>(toolW3C);
@ -2517,6 +2516,7 @@ void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* gr
toolWidget->centerOn(mControlView->mapTo(mControlContainer, controlViewPos)); toolWidget->centerOn(mControlView->mapTo(mControlContainer, controlViewPos));
toolWidget->show(); toolWidget->show();
} }
}
void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget) void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget)

@ -93,7 +93,7 @@ void UBAsyncLocalFileDownloader::run()
QFile::remove(mTo); QFile::remove(mTo);
} }
else else
emit signal_asyncCopyFinished(mDesc.id, !mTo.isEmpty(), QUrl::fromLocalFile(mTo), QUrl(mDesc.originalSrcUrl), "", NULL, mDesc.pos, mDesc.size, mDesc.isBackground); emit signal_asyncCopyFinished(mDesc.id, !mTo.isEmpty(), QUrl::fromLocalFile(mTo), QUrl::fromLocalFile(mDesc.originalSrcUrl), "", NULL, mDesc.pos, mDesc.size, mDesc.isBackground);
} }
void UBAsyncLocalFileDownloader::abort() void UBAsyncLocalFileDownloader::abort()

@ -63,6 +63,10 @@ UBCryptoUtils::UBCryptoUtils(QObject * pParent)
UBCryptoUtils::~UBCryptoUtils() UBCryptoUtils::~UBCryptoUtils()
{ {
// TODO UB 4.x aes destroy // TODO UB 4.x aes destroy
#if OPENSSL_VERSION_NUMBER >= 10100000L
EVP_CIPHER_CTX_free(mAesEncryptContext);
EVP_CIPHER_CTX_free(mAesDecryptContext);
#endif
} }
@ -74,18 +78,30 @@ QString UBCryptoUtils::symetricEncrypt(const QString& clear)
int paddingLength = 0; int paddingLength = 0;
unsigned char *ciphertext = (unsigned char *)malloc(cipheredLength); unsigned char *ciphertext = (unsigned char *)malloc(cipheredLength);
#if OPENSSL_VERSION_NUMBER >= 10100000L
if(!EVP_EncryptInit_ex(mAesEncryptContext, NULL, NULL, NULL, NULL)){
#else
if(!EVP_EncryptInit_ex(&mAesEncryptContext, NULL, NULL, NULL, NULL)){ if(!EVP_EncryptInit_ex(&mAesEncryptContext, NULL, NULL, NULL, NULL)){
#endif
free(ciphertext); free(ciphertext);
return QString(); return QString();
} }
#if OPENSSL_VERSION_NUMBER >= 10100000L
if(!EVP_EncryptUpdate(mAesEncryptContext, ciphertext, &cipheredLength, (unsigned char *)clearData.data(), clearData.length())){
#else
if(!EVP_EncryptUpdate(&mAesEncryptContext, ciphertext, &cipheredLength, (unsigned char *)clearData.data(), clearData.length())){ if(!EVP_EncryptUpdate(&mAesEncryptContext, ciphertext, &cipheredLength, (unsigned char *)clearData.data(), clearData.length())){
#endif
free(ciphertext); free(ciphertext);
return QString(); return QString();
} }
/* update ciphertext with the final remaining bytes */ /* update ciphertext with the final remaining bytes */
#if OPENSSL_VERSION_NUMBER >= 10100000L
if(!EVP_EncryptFinal_ex(mAesEncryptContext, ciphertext + cipheredLength, &paddingLength)){
#else
if(!EVP_EncryptFinal_ex(&mAesEncryptContext, ciphertext + cipheredLength, &paddingLength)){ if(!EVP_EncryptFinal_ex(&mAesEncryptContext, ciphertext + cipheredLength, &paddingLength)){
#endif
free(ciphertext); free(ciphertext);
return QString(); return QString();
} }
@ -106,17 +122,29 @@ QString UBCryptoUtils::symetricDecrypt(const QString& encrypted)
int paddingLength = 0; int paddingLength = 0;
unsigned char *plaintext = (unsigned char *)malloc(encryptedLength); unsigned char *plaintext = (unsigned char *)malloc(encryptedLength);
#if OPENSSL_VERSION_NUMBER >= 10100000L
if(!EVP_DecryptInit_ex(mAesDecryptContext, NULL, NULL, NULL, NULL)){
#else
if(!EVP_DecryptInit_ex(&mAesDecryptContext, NULL, NULL, NULL, NULL)){ if(!EVP_DecryptInit_ex(&mAesDecryptContext, NULL, NULL, NULL, NULL)){
#endif
free(plaintext); free(plaintext);
return QString(); return QString();
} }
#if OPENSSL_VERSION_NUMBER >= 10100000L
if(!EVP_DecryptUpdate(mAesDecryptContext, plaintext, &encryptedLength, (const unsigned char *)encryptedData.data(), encryptedData.length())){
#else
if(!EVP_DecryptUpdate(&mAesDecryptContext, plaintext, &encryptedLength, (const unsigned char *)encryptedData.data(), encryptedData.length())){ if(!EVP_DecryptUpdate(&mAesDecryptContext, plaintext, &encryptedLength, (const unsigned char *)encryptedData.data(), encryptedData.length())){
#endif
free(plaintext); free(plaintext);
return QString(); return QString();
} }
#if OPENSSL_VERSION_NUMBER >= 10100000L
if(!EVP_DecryptFinal_ex(mAesDecryptContext, plaintext + encryptedLength, &paddingLength)){
#else
if(!EVP_DecryptFinal_ex(&mAesDecryptContext, plaintext + encryptedLength, &paddingLength)){ if(!EVP_DecryptFinal_ex(&mAesDecryptContext, plaintext + encryptedLength, &paddingLength)){
#endif
free(plaintext); free(plaintext);
return QString(); return QString();
} }
@ -146,8 +174,15 @@ void UBCryptoUtils::aesInit()
return; return;
} }
#if OPENSSL_VERSION_NUMBER >= 10100000L
mAesEncryptContext = EVP_CIPHER_CTX_new();
EVP_EncryptInit_ex(mAesEncryptContext, EVP_aes_256_cbc(), NULL, key, iv);
mAesDecryptContext = EVP_CIPHER_CTX_new();
EVP_DecryptInit_ex(mAesDecryptContext, EVP_aes_256_cbc(), NULL, key, iv);
#else
EVP_CIPHER_CTX_init(&mAesEncryptContext); EVP_CIPHER_CTX_init(&mAesEncryptContext);
EVP_EncryptInit_ex(&mAesEncryptContext, EVP_aes_256_cbc(), NULL, key, iv); EVP_EncryptInit_ex(&mAesEncryptContext, EVP_aes_256_cbc(), NULL, key, iv);
EVP_CIPHER_CTX_init(&mAesDecryptContext); EVP_CIPHER_CTX_init(&mAesDecryptContext);
EVP_DecryptInit_ex(&mAesDecryptContext, EVP_aes_256_cbc(), NULL, key, iv); EVP_DecryptInit_ex(&mAesDecryptContext, EVP_aes_256_cbc(), NULL, key, iv);
#endif
} }

@ -60,8 +60,13 @@ class UBCryptoUtils : public QObject
void aesInit(); void aesInit();
#if OPENSSL_VERSION_NUMBER >= 10100000L
EVP_CIPHER_CTX *mAesEncryptContext;
EVP_CIPHER_CTX *mAesDecryptContext;
#else
EVP_CIPHER_CTX mAesEncryptContext; EVP_CIPHER_CTX mAesEncryptContext;
EVP_CIPHER_CTX mAesDecryptContext; EVP_CIPHER_CTX mAesDecryptContext;
#endif
}; };

Loading…
Cancel
Save