~ubuntu-branches/ubuntu/precise/kgpg/precise-updates

« back to all changes in this revision

Viewing changes to keysmanager.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-12-24 23:16:12 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: package-import@ubuntu.com-20111224231612-6w15s57d2106roq2
Tags: upstream-4.7.95
Import upstream version 4.7.95

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
#include "kgpgkeygenerate.h"
83
83
#include "kgpgoptions.h"
84
84
#include "keyinfodialog.h"
85
 
#include "kgpglibrary.h"
86
85
#include "keyadaptor.h"
87
86
#include "images.h"
88
87
#include "sourceselect.h"
110
109
#include "kgpgsignuid.h"
111
110
#include "kgpgdelsign.h"
112
111
#include "kgpgdecrypt.h"
 
112
#include "kgpgencrypt.h"
113
113
 
114
114
using namespace KgpgCore;
115
115
 
456
456
        setAutoSaveSettings(cg, true);
457
457
        applyMainWindowSettings(cg);
458
458
 
459
 
        connect(s_kgpgEditor, SIGNAL(refreshImported(QStringList)), imodel, SLOT(refreshKeys(QStringList)));
460
459
        connect(this, SIGNAL(fontChanged(QFont)), s_kgpgEditor, SLOT(slotSetFont(QFont)));
461
460
 
462
461
        m_netnote = Solid::Networking::notifier();
527
526
{
528
527
        KgpgEditor *kgpgtxtedit = new KgpgEditor(this, imodel, Qt::Window);
529
528
 
530
 
        connect(kgpgtxtedit, SIGNAL(refreshImported(QStringList)), imodel, SLOT(refreshKeys(QStringList)));
531
529
        connect(kgpgtxtedit, SIGNAL(encryptFiles(KUrl::List)), this, SIGNAL(encryptFiles(KUrl::List)));
532
530
        connect(this, SIGNAL(fontChanged(QFont)), kgpgtxtedit, SLOT(slotSetFont(QFont)));
533
531
 
1540
1538
        if (nd == NULL)
1541
1539
                return;
1542
1540
 
 
1541
        if (iview->isEditing())
 
1542
                return;
 
1543
 
1543
1544
        switch (nd->getType()) {
1544
1545
        case ITYPE_GROUP:
1545
1546
                editGroup();
1640
1641
 
1641
1642
void KeysManager::renameGroup()
1642
1643
{
1643
 
        KGpgNode *nd = iview->selectedNode();
1644
 
        if (!nd || (nd->getType() != ITYPE_GROUP))
1645
 
                return;
1646
 
 
1647
 
        const QString groupName = KInputDialog::getText(i18n("Rename Group"),
1648
 
                        i18nc("Enter the new name for the key group being renamed", "Enter new group name:"),
1649
 
                        nd->getName(), 0, this);
1650
 
 
1651
 
        if ((groupName == nd->getName()) || groupName.isEmpty())
1652
 
                return;
1653
 
 
1654
 
        nd->toGroupNode()->rename(groupName);
 
1644
        if (iview->selectionModel()->selectedIndexes().isEmpty())
 
1645
                return;
 
1646
 
 
1647
        QModelIndex selectedNodeIndex = iview->selectionModel()->selectedIndexes().first();
 
1648
 
 
1649
        iview->edit(selectedNodeIndex);
1655
1650
}
1656
1651
 
1657
1652
void KeysManager::createNewGroup()
2618
2613
                return;
2619
2614
        }
2620
2615
 
2621
 
        QPointer<KgpgSelectPublicKeyDlg> dialog = new KgpgSelectPublicKeyDlg(this, imodel, goToDefaultKey->shortcut());
 
2616
        QPointer<KgpgSelectPublicKeyDlg> dialog = new KgpgSelectPublicKeyDlg(this, imodel, goToDefaultKey->shortcut(), true);
2622
2617
        if (dialog->exec() == KDialog::Accepted) {
 
2618
                KGpgEncrypt::EncryptOptions encOptions = KGpgEncrypt::AsciiArmored;
2623
2619
                QStringList options;
2624
2620
 
2625
2621
                if (!dialog->getCustomOptions().isEmpty() && KGpgSettings::allowCustomEncryptionOptions())
2626
 
                        options = dialog->getCustomOptions().split(QLatin1Char( ' ' ), QString::SkipEmptyParts);
 
2622
                        options = dialog->getCustomOptions().split(QLatin1Char(' '), QString::SkipEmptyParts);
2627
2623
 
2628
2624
                if (dialog->getUntrusted())
2629
 
                        options.append(QLatin1String( "--always-trust" ));
2630
 
                if (dialog->getArmor())
2631
 
                        options.append(QLatin1String( "--armor" ));
 
2625
                        encOptions |= KGpgEncrypt::AllowUntrustedEncryption;
2632
2626
                if (dialog->getHideId())
2633
 
                        options.append(QLatin1String( "--throw-keyid" ));
 
2627
                        encOptions |= KGpgEncrypt::HideKeyId;
2634
2628
 
2635
2629
                if (KGpgSettings::pgpCompatibility())
2636
2630
                        options.append(QLatin1String( "--pgp6" ));
2637
2631
 
2638
 
                options.append(QLatin1String( "--armor" ));
2639
 
 
2640
 
                QStringList selec;
2641
 
                if (!dialog->getSymmetric())
2642
 
                        selec = dialog->selectedKeys();
2643
 
 
2644
 
                KGpgTextInterface *txtEncrypt = new KGpgTextInterface();
2645
 
                connect (txtEncrypt, SIGNAL(txtEncryptionFinished(QString)), SLOT(slotSetClip(QString)));
 
2632
                KGpgEncrypt *enc = new KGpgEncrypt(this, dialog->selectedKeys(), cliptext, encOptions, options);
 
2633
                connect(enc, SIGNAL(done(int)), SLOT(slotSetClip(int)));
 
2634
 
2646
2635
                m_trayicon->setStatus(KStatusNotifierItem::Active);
2647
 
                txtEncrypt->encryptText(cliptext, selec, options);
 
2636
                enc->start();
2648
2637
        }
2649
2638
 
2650
2639
        delete dialog;
2651
2640
}
2652
2641
 
2653
2642
void
2654
 
KeysManager::slotSetClip(const QString &newtxt)
 
2643
KeysManager::slotSetClip(int result)
2655
2644
{
 
2645
        KGpgEncrypt *enc = qobject_cast<KGpgEncrypt *>(sender());
 
2646
        Q_ASSERT(enc != NULL);
2656
2647
        sender()->deleteLater();
2657
2648
 
2658
2649
        m_trayicon->setStatus(KStatusNotifierItem::Passive);
2659
2650
 
2660
 
        if (newtxt.isEmpty())
 
2651
        if (result != KGpgTransaction::TS_OK)
2661
2652
                return;
2662
2653
 
2663
 
        kapp->clipboard()->setText(newtxt, m_clipboardmode);
 
2654
        kapp->clipboard()->setText(enc->encryptedText().join(QLatin1String("\n")), m_clipboardmode);
2664
2655
 
2665
2656
        Q_ASSERT(m_trayicon != NULL);
2666
2657
        m_trayicon->showMessage(QString(), i18n("Text successfully encrypted."), QLatin1String( "kgpg" ));