| 3351 | |
| 3352 | |
| 3353 | void NBrowserWindow::encryptButtonPressed() { |
| 3354 | EnCrypt encrypt; |
| 3355 | |
| 3356 | QString text = editor->selectedText(); |
| 3357 | if (text.trimmed() == "") |
| 3358 | return; |
| 3359 | text = text.replace("\n", "<br/>"); |
| 3360 | |
| 3361 | EnCryptDialog dialog; |
| 3362 | dialog.exec(); |
| 3363 | if (!dialog.okPressed()) { |
| 3364 | return; |
| 3365 | } |
| 3366 | |
| 3367 | EnCrypt crypt; |
| 3368 | QString encrypted; |
| 3369 | int rc = crypt.encrypt(encrypted, text, dialog.getPassword().trimmed()); |
| 3370 | |
| 3371 | if (rc != 0) { |
| 3372 | QMessageBox::information(this, tr("Error"), |
| 3373 | tr("Error Encrypting String. Please verify you have Java installed.")); |
| 3374 | return; |
| 3375 | } |
| 3376 | QString buffer; |
| 3377 | buffer.append("<img en-tag=\"en-crypt\" cipher=\"RC2\" hint=\"" |
| 3378 | + dialog.getHint().replace("'","\\'") + "\" length=\"64\" "); |
| 3379 | buffer.append("contentEditable=\"false\" alt=\""); |
| 3380 | buffer.append(encrypted); |
| 3381 | #ifndef _WIN32 |
| 3382 | buffer.append("\" src=\"file://").append(global.fileManager.getImageDirPath("encrypt.png") +"\""); |
| 3383 | #else |
| 3384 | buffer.append("\" src=\"file:///").append(global.fileManager.getImageDirPath("encrypt.png") +"\""); |
| 3385 | #endif |
| 3386 | global.cryptCounter++; |
| 3387 | buffer.append(" id=\"crypt"+QString::number(global.cryptCounter) +"\""); |
| 3388 | buffer.append(" onMouseOver=\"style.cursor=\\'hand\\'\""); |
| 3389 | buffer.append(" onClick=\"window.browserWindow.decryptText(\\'crypt"+QString::number(global.cryptCounter) |
| 3390 | +"\\', \\'"+encrypted+"\\', \\'"+dialog.getHint().replace("'", "\\&apos;")+"\\', \\'RC2\\', 64);\""); |
| 3391 | buffer.append("style=\"display:block\" />"); |
| 3392 | |
| 3393 | |
| 3394 | QString script_start = "document.execCommand('insertHtml', false, '"; |
| 3395 | QString script_end = "');"; |
| 3396 | editor->page()->mainFrame()->evaluateJavaScript( |
| 3397 | script_start + buffer + script_end); |
| 3398 | } |
| 3399 | |
| 3400 | |
| 3401 | void NBrowserWindow::sendAuthorUpdateSignal() { |
nothing calls this directly
no test coverage detected