Commit 0d6f19c0 authored by Clément Fauconnier's avatar Clément Fauconnier

Merge branch 'dev' into dev-18.04

parents 43977465 3506afa3
......@@ -741,7 +741,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item)
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)
{
createdItem->setSourceUrl(item->sourceUrl());
......@@ -1375,11 +1375,8 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl
widgetItem->setSourceUrl(QUrl::fromLocalFile(widgetUrl));
qDebug() << widgetItem->getOwnFolder();
qDebug() << widgetItem->getSnapshotPath();
QString ownFolder = selectedDocument()->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + widgetItem->uuid().toString() + ".wgt";
widgetItem->setOwnFolder(ownFolder);
QString adaptedUUid = widgetItem->uuid().toString().replace("{","").replace("}","");
ownFolder = ownFolder.replace(widgetItem->uuid().toString() + ".wgt", adaptedUUid + ".png");
widgetItem->setSnapshotPath(ownFolder);
widgetItem->setSnapshotPath(widgetItem->getOwnFolder());
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
......@@ -2500,22 +2497,25 @@ void UBBoardController::togglePodcast(bool checked)
void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget)
{
mActiveScene->setURStackEnable(false);
UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast<UBItem *>(graphicsWidget));
UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast<UBItem *>(graphicsWidget));
UBGraphicsWidgetItem *copyedGraphicsWidget = NULL;
if (UBGraphicsWidgetItem::Type == toolW3C->type())
copyedGraphicsWidget = static_cast<UBGraphicsWidgetItem *>(toolW3C);
if (toolW3C)
{
if (UBGraphicsWidgetItem::Type == toolW3C->type())
copyedGraphicsWidget = static_cast<UBGraphicsWidgetItem *>(toolW3C);
UBToolWidget *toolWidget = new UBToolWidget(copyedGraphicsWidget, mControlView);
UBToolWidget *toolWidget = new UBToolWidget(copyedGraphicsWidget, mControlView);
graphicsWidget->remove(false);
mActiveScene->addItemToDeletion(graphicsWidget);
graphicsWidget->remove(false);
mActiveScene->addItemToDeletion(graphicsWidget);
mActiveScene->setURStackEnable(true);
mActiveScene->setURStackEnable(true);
QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center());
toolWidget->centerOn(mControlView->mapTo(mControlContainer, controlViewPos));
toolWidget->show();
QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center());
toolWidget->centerOn(mControlView->mapTo(mControlContainer, controlViewPos));
toolWidget->show();
}
}
......
......@@ -93,7 +93,7 @@ void UBAsyncLocalFileDownloader::run()
QFile::remove(mTo);
}
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()
......
......@@ -63,6 +63,10 @@ UBCryptoUtils::UBCryptoUtils(QObject * pParent)
UBCryptoUtils::~UBCryptoUtils()
{
// 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;
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)){
#endif
free(ciphertext);
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())){
#endif
free(ciphertext);
return QString();
}
/* 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)){
#endif
free(ciphertext);
return QString();
}
......@@ -106,17 +122,29 @@ QString UBCryptoUtils::symetricDecrypt(const QString& encrypted)
int paddingLength = 0;
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)){
#endif
free(plaintext);
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())){
#endif
free(plaintext);
return QString();
}
#if OPENSSL_VERSION_NUMBER >= 10100000L
if(!EVP_DecryptFinal_ex(mAesDecryptContext, plaintext + encryptedLength, &paddingLength)){
#else
if(!EVP_DecryptFinal_ex(&mAesDecryptContext, plaintext + encryptedLength, &paddingLength)){
#endif
free(plaintext);
return QString();
}
......@@ -146,8 +174,15 @@ void UBCryptoUtils::aesInit()
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_EncryptInit_ex(&mAesEncryptContext, EVP_aes_256_cbc(), NULL, key, iv);
EVP_CIPHER_CTX_init(&mAesDecryptContext);
EVP_DecryptInit_ex(&mAesDecryptContext, EVP_aes_256_cbc(), NULL, key, iv);
#endif
}
......@@ -60,8 +60,13 @@ class UBCryptoUtils : public QObject
void aesInit();
#if OPENSSL_VERSION_NUMBER >= 10100000L
EVP_CIPHER_CTX *mAesEncryptContext;
EVP_CIPHER_CTX *mAesDecryptContext;
#else
EVP_CIPHER_CTX mAesEncryptContext;
EVP_CIPHER_CTX mAesDecryptContext;
#endif
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment