• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeutils
  • Sitemap
  • Contact Us
 

kgpg

kgpginterface.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           kgpginterface.h  -  description
00003                              -------------------
00004     begin                : Sat Jun 29 2002
00005     copyright          : (C) 2002 by Jean-Baptiste Mardelle
00006     email                : bj@altern.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef KGPGINTERFACE_H
00019 #define KGPGINTERFACE_H
00020 
00021 #include <QDateTime>
00022 #include <QPixmap>
00023 
00024 
00025 #include <KUrl>
00026 
00027 #include <kgpgkey.h>
00028 
00029 class KTemporaryFile;
00030 class K3Process;
00031 class K3ProcIO;
00032 class KProcess;
00033 class GPGProc;
00034 
00038 class KgpgInterface : public QObject
00039 {
00040     Q_OBJECT
00041 
00042 public:
00046     KgpgInterface();
00047     ~KgpgInterface();
00048 
00049     static QString checkForUtf8(QString txt);
00050     static QString checkForUtf8bis(QString txt);
00051 
00052     static int gpgVersion();
00053 
00054     static QStringList getGpgGroupNames(const QString &configfile);
00055     static QStringList getGpgGroupSetting(const QString &name, const QString &configfile);
00056     static void setGpgGroupSetting(const QString &name, const QStringList &values, const QString &configfile);
00057     static void delGpgGroup(const QString &name, const QString &configfile);
00058 
00059     static QString getGpgSetting(QString name, const QString &configfile);
00060     static void setGpgSetting(const QString &name, const QString &value, const QString &url);
00061 
00062     static bool getGpgBoolSetting(const QString &name, const QString &configfile);
00063     static void setGpgBoolSetting(const QString &name, const bool &enable, const QString &url);
00064 
00065 /************** function to send a passphrase to gpg **************/
00066 private:
00067     KProcess *m_workProcess;
00068 
00076     int sendPassphrase(const QString &text, K3ProcIO *process, const bool isnew = true);
00077     int sendPassphrase(const QString &text, KProcess *process, const bool isnew = true);
00078 /******************************************************************/
00079 
00080 
00081 /************** function update the userIDs variable **************/
00082 private:
00083     void updateIDs(QString txt);
00084 
00085 /******************************************************************/
00086 
00087 
00088 /************** extract public keys **************/
00089 signals:
00090     void readPublicKeysFinished(KgpgCore::KgpgKeyList, KgpgInterface*);
00091 
00092 public slots:
00093     KgpgCore::KgpgKeyList readPublicKeys(const bool &block = false, const QStringList &ids = QStringList(), const bool &withsigs = false);
00094     KgpgCore::KgpgKeyList readPublicKeys(const bool &block, const QString &ids, const bool &withsigs = false)
00095     { return readPublicKeys(block, QStringList(ids), withsigs); }
00096 
00097 private slots:
00098     void readPublicKeysProcess(GPGProc *p);
00099     void readPublicKeysFin(GPGProc *p, const bool &block = false);
00100 
00101 private:
00102     int m_numberid;
00103     QString cycle;
00104     KgpgCore::KgpgKey m_publickey;
00105     KgpgCore::KgpgKeyList m_publiclistkeys;
00106 
00107 /*************************************************/
00108 
00109 
00110 /************** extract secret keys **************/
00111 public slots:
00112     KgpgCore::KgpgKeyList readSecretKeys(const QStringList &ids = QStringList());
00113     KgpgCore::KgpgKeyList readJoinedKeys(const KgpgCore::KgpgKeyTrust &trust, const QStringList &ids = QStringList());
00114 
00115 private slots:
00116     void readSecretKeysProcess(GPGProc *p);
00117 
00118 private:
00119     bool m_secretactivate;
00120     KgpgCore::KgpgKey m_secretkey;
00121     KgpgCore::KgpgKeyList m_secretlistkeys;
00122 
00123 /*************************************************/
00124 
00125 
00126 /************** get keys as a text **************/
00127 signals:
00128     void getKeysStarted(KgpgInterface*);
00129     void getKeysFinished(QString, KgpgInterface*);
00130 
00131 public slots:
00132     QString getKeys(const bool &block = false, const QString *attributes = NULL, const QStringList &ids = QStringList());
00133 
00134 private slots:
00135     void getKeysProcess(K3ProcIO *p);
00136     void getKeysFin(K3Process *p);
00137 
00138 private:
00139     QString m_keystring;
00140 
00141 /************************************************/
00142 
00143 
00144 /************** encrypt a text **************/
00145 signals:
00149     void txtEncryptionStarted();
00150 
00154     void txtEncryptionFinished(QString, KgpgInterface*);
00155 
00156 public slots:
00163     void encryptText(const QString &text, const QStringList &userids, const QStringList &options = QStringList());
00164 
00165 private slots:
00166     void encryptTextProcess(K3ProcIO *p);
00167     void encryptTextFin(K3Process *p);
00168 
00169 /********************************************/
00170 
00171 
00172 /************** decrypt a text **************/
00173 signals:
00177     void txtDecryptionStarted();
00178 
00182     void txtDecryptionFinished(QString, KgpgInterface*);
00183 
00187     void txtDecryptionFailed(QString, KgpgInterface*);
00188 
00189 public slots:
00195     void decryptText(const QString &text, const QStringList &options = QStringList());
00196 
00197 private slots:
00198     void decryptTextStdOut(K3Process *p, char *data, int);
00199     void decryptTextStdErr(K3Process *, char *data, int);
00200     void decryptTextFin(K3Process *p);
00201 
00202 private:
00203     int m_textlength;
00204 
00205 /********************************************/
00206 
00207 
00208 /************** sign a text **************/
00209 signals:
00210     void txtSigningStarted();
00211     void txtSigningFinished(QString, KgpgInterface*);
00212     void txtSigningFailed(QString, KgpgInterface*);
00213 
00214 public slots:
00221     void signText(const QString &text, const QString &userid, const QStringList &options);
00222 
00223 private slots:
00224     void signTextProcess(K3ProcIO *p);
00225     void signTextFin(K3Process *p);
00226 
00227 /*****************************************/
00228 
00229 
00230 /************** verify a text **************/
00231 signals:
00232     void txtVerifyStarted();
00233     void txtVerifyMissingSignature(QString, KgpgInterface*);
00234     void txtVerifyFinished(QString, QString, KgpgInterface*);
00235 
00236 public slots:
00241     void verifyText(const QString &text);
00242 
00243 private slots:
00244     void verifyTextProcess(K3ProcIO *p);
00245     void verifyTextFin(K3Process*);
00246 
00247 /*******************************************/
00248 
00249 
00250 /************** encrypt a file **************/
00251 signals:
00255     void processstarted(QString);
00256 
00260     void errorMessage(const QString &, KgpgInterface*);
00261 
00265     void fileEncryptionFinished(KUrl, KgpgInterface*);
00266 
00267 public slots:
00276     void encryptFile(const QStringList &encryptkeys, const KUrl &srcurl, const KUrl &desturl, const QStringList &options = QStringList(), const bool &symetrical = false);
00277 
00278 private slots:
00282     void fileReadEncProcess(K3ProcIO *p);
00283 
00287     void fileEncryptFin(K3Process *p);
00288 
00289 /********************************************/
00290 
00291 
00292 /************** sign a key **************/
00293 signals:
00302     void signKeyFinished(int, const QString &, KgpgInterface*);
00303 
00304 public slots:
00313     void signKey(const QString &keyid, const QString &signkeyid, const bool &local, const int &checking, const bool &terminal = false);
00314 
00315 private slots:
00319     void signKeyProcess();
00320 
00324     void signKeyFin();
00325 
00330     void signKeyOpenConsole();
00331 
00332 private:
00333     QString m_signkey;
00334     QString m_keyid;
00335     int m_checking;
00336     bool m_local;
00337 
00338 /****************************************/
00339 
00340 
00341 /************** change key expiration **************/
00342 signals:
00349     void keyExpireFinished(int, KgpgInterface*);
00350 
00351 public slots:
00352     void keyExpire(const QString &keyid, const QDate &date);
00353 
00354 private slots:
00355     void keyExpireProcess();
00356     void keyExpireFin();
00357 
00358 /***************************************************/
00359 
00360 
00361 /************** change key password **************/
00362 signals:
00369     void changePassFinished(int, KgpgInterface*);
00370 
00371 public slots:
00372     void changePass(const QString &keyid);
00373 
00374 private slots:
00375     void changePassProcess();
00376     void changePassFin();
00377 
00378 /*************************************************/
00379 
00380 
00381 /************** change key trust **************/
00382 signals:
00383     void changeTrustFinished(KgpgInterface*);
00384 
00385 public slots:
00391     void changeTrust(const QString &keyid, const KgpgCore::KgpgKeyOwnerTrust &keytrust);
00392 
00393 private slots:
00394     void changeTrustProcess();
00395     void changeTrustFin();
00396 
00397 private:
00398     int m_trustvalue;
00399 
00400 /**********************************************/
00401 
00402 
00403 /************** change disable key **************/
00404 signals:
00405     void changeDisableFinished(KgpgInterface*, int res);
00406 
00407 public slots:
00408     void changeDisable(const QString &keyid, const bool &ison);
00409 
00410 private slots:
00411     void changeDisableFin(int res);
00412 
00413 /************************************************/
00414 
00415 
00416 /************** load a photo in a QPixmap **************/
00417 signals:
00418     void loadPhotoFinished(QPixmap, KgpgInterface*);
00419 
00420 public slots:
00421     QPixmap loadPhoto(const QString &keyid, const QString &uid, const bool &block = false);
00422 
00423 private slots:
00424     void loadPhotoFin(K3Process *p, const bool &block = false);
00425 
00426 private:
00427     QPixmap m_pixmap;
00428     KTemporaryFile *m_kgpginfotmp;
00429 
00430 /*******************************************************/
00431 
00432 
00433 /************** add a photo in a key **************/
00434 signals:
00441     void addPhotoFinished(int, KgpgInterface*);
00442 
00443 public slots:
00444     void addPhoto(const QString &keyid, const QString &imagepath);
00445 
00446 private slots:
00447     void addPhotoProcess(K3ProcIO *p);
00448     void addPhotoFin(K3Process *p);
00449 
00450 /**************************************************/
00451 
00452 
00453 /************** delete a photo of a key **************/
00454 signals:
00461     void deletePhotoFinished(int, KgpgInterface*);
00462 
00463 public slots:
00464     void deletePhoto(const QString &keyid, const QString &uid);
00465 
00466 private slots:
00467     void deletePhotoProcess(K3ProcIO *p);
00468     void deletePhotoFin(K3Process *p);
00469 
00470 /*****************************************************/
00471 
00472 
00473 // TODO : ajouter KgpgInterface a importKeyFinished
00474 /************** import a key **************/
00475 signals:
00476     void importKeyFinished(QStringList);
00477     void importKeyOrphaned();
00478 
00479 public slots:
00484     void importKey(const KUrl &url);
00485 
00490     void importKey(const QString &keystr);
00491 
00492 private slots:
00496     void importKeyProcess(K3ProcIO *p);
00497     void importKeyFinished(K3Process *p);
00498 
00499 private:
00500     QString m_tempkeyfile;
00501 
00502 /******************************************/
00503 
00504 
00505 /************** add uid **************/
00506 signals:
00514     void addUidFinished(int, KgpgInterface*);
00515 
00516 public slots:
00520     void addUid(const QString &keyid, const QString &name, const QString &email, const QString &comment);
00521 
00522 private slots:
00523     void addUidProcess(K3ProcIO *p);
00524     void addUidFin(K3Process *p);
00525 
00526 private:
00527     QString uidName;
00528     QString uidEmail;
00529     QString uidComment;
00530 
00531 /*************************************/
00532 
00533 
00534 /************** generate a key **************/
00535 signals:
00551     void generateKeyFinished(int, KgpgInterface*, QString, QString, QString, QString);
00552     void generateKeyStarted(KgpgInterface*);
00553 
00554 public slots:
00570     void generateKey(const QString &keyname, const QString &keyemail, const QString &keycomment, const KgpgCore::KgpgKeyAlgo &keyalgo, const uint &keysize, const uint &keyexp, const uint &keyexpnumber);
00571 
00572 private slots:
00573     void generateKeyProcess(K3ProcIO *p);
00574     void generateKeyFin(K3Process *p);
00575 
00576 private:
00577     QString m_newkeyid;
00578     QString m_newfingerprint;
00579     QString m_keyname;
00580     QString m_keyemail;
00581     QString m_keycomment;
00582     KgpgCore::KgpgKeyAlgo m_keyalgo;
00583     uint m_keysize;
00584     uint m_keyexpnumber;
00585     uint m_keyexp;
00586 
00587 /********************************************/
00588 
00589 
00590 /************** decrypt file **************/
00591 signals:
00599     void decryptFileStarted(KUrl url);
00600     void decryptFileFinished(int, KgpgInterface*);
00601 
00602 public slots:
00609     void decryptFile(const KUrl &src, const KUrl &dest, const QStringList &Options = QStringList());
00610 
00611 private slots:
00612     void decryptFileProcess(K3ProcIO *p);
00613     void decryptFileFin(K3Process *p);
00614 
00615 private:
00616     KUrl decryptFileUrl;
00617 
00618 /******************************************/
00619 
00620 
00621 /************** download keys from keys server **************/
00622 signals:
00623     /*
00624     0 : keys processed
00625     1 : keys without id
00626     2 : keys imported
00627     3 : RSA keys
00628     4 : unchanged
00629     5 : Uid imported
00630     6 : Subkey imported
00631     7 : Sign imported
00632     8 : Revocation imported
00633     9 : secret keys processed
00634     10 : secret keys imported
00635     11 : secret keys unchanged
00636     12 : secret keys not imported
00637     */
00638     void downloadKeysFinished(QList<int>, QStringList, bool, QString, KgpgInterface*);
00639     void downloadKeysAborted(KgpgInterface*);
00640 
00641 public slots:
00642     void downloadKeys(const QStringList &keys, const QString &keyserver, const bool &refresh, const QString &proxy = "");
00643     void downloadKeysAbort();
00644 
00645 private slots:
00646     void downloadKeysProcess(K3ProcIO *p);
00647     void downloadKeysFin(K3Process *p);
00648 
00649 private:
00650     K3ProcIO *m_downloadprocess;
00651     QString m_downloadkeys;
00652     QString m_downloadkeys_log;
00653 
00654 /***********************************************************/
00655 
00656 
00657 
00658 /************** upload keys to keys server **************/
00659 signals:
00660     void uploadKeysFinished(QString, KgpgInterface*);
00661     void uploadKeysAborted(KgpgInterface*);
00662 
00663 public slots:
00664     void uploadKeys(const QStringList &keys, const QString &keyserver, const QString &attributes, const QString &proxy = "");
00665     void uploadKeysAbort();
00666 
00667 private slots:
00668     void uploadKeysProcess(K3ProcIO *p);
00669     void uploadKeysFin(K3Process *p);
00670 
00671 private:
00672     K3ProcIO *m_uploadprocess;
00673     QString m_uploadkeys_log;
00674 
00675 /********************************************************/
00676 
00677 
00678 
00679 
00680 
00681 
00682 
00683 
00684 
00685 
00686 
00687 
00688 
00689 public slots:
00690 
00696     void KgpgDecryptFileToText(const KUrl &srcUrl, const QStringList &Options);
00697 
00704     void KgpgSignFile(const QString &keyID, const KUrl &srcUrl, const QStringList &Options = QStringList());
00705 
00710     void KgpgVerifyFile(const KUrl &sigUrl, const KUrl &srcUrl = KUrl()) ;
00711 
00717     void KgpgDelSignature(const QString &keyID, const QString &uid, QString signKeyID);
00718 
00719     void KgpgRevokeKey(const QString &keyID, const QString &revokeUrl, const int reason, const QString &description);
00720     void revokeover(GPGProc *);
00721     void revokeprocess(GPGProc *p);
00722 
00723 
00724 private slots:
00728     void signfin(K3Process *p);
00729 
00733     void delsigprocess(K3ProcIO *p);
00734 
00738     void delsignover(K3Process *p);
00739 
00743     void findSigns(const QString &keyID, const QStringList &ids, const QString &uid, QList<int> *res);
00744 
00748     void importURLover(K3Process *p);
00749 
00753     void readprocess(K3ProcIO *p);
00754 
00758     void readsignprocess(K3ProcIO *p);
00759 
00763     void verifyfin(K3Process *p);
00764 
00765 signals:
00769     void delsigfinished(bool);
00770 
00774     void processaborted(bool);
00775 
00779     void badpassphrase(bool);
00780 
00784     void verifyfinished();
00785 
00789     void verifyquerykey(QString ID);
00790 
00794     void signfinished();
00795 
00796     void revokecertificate(QString);
00797     void revokeurl(QString);
00798 
00799 private:
00800     // Globals private
00801     int m_success;
00802     QString m_partialline;
00803     QByteArray m_readin;
00804     bool m_ispartial;
00805     QString message;
00806     QString tmp_message;
00807     QString userIDs;
00808     QString log;
00809     bool encok;                 // encrypt ok
00810     bool decok;                 // decrypt ok
00811     bool badmdc;                // bad mdc
00812     bool badpassword;           // bad password
00813     KProcess *editprocess;
00814     static K3ProcIO *gpgProc(const int &statusfd = -1, const int &cmdfd = -1);
00815 
00819     QString output;
00820 
00821     bool deleteSuccess;
00822     bool anonymous;
00823     bool decfinished;
00824     bool revokeSuccess;
00825     bool addSuccess;
00826     bool delSuccess;
00827     bool signmiss;
00828 
00829     QString signID;
00830     int expSuccess;
00831     int step;
00832     int signb;
00833     int sigsearch;
00834     int expirationDelay;
00835     int revokeReason;
00836     int photoCount;
00837     QString revokeDescription;
00838     QString certificateUrl;
00839     QString photoUrl;
00840     KUrl sourceFile;
00841     QString decryptUrl;
00842 
00843     QString gpgOutput;
00844 
00848     KUrl file;
00849 };
00850 
00851 #endif // KGPGINTERFACE_H

kgpg

Skip menu "kgpg"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdelirc
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • kjots
  • klaptopdaemon
  • kmilo
  • ksim
  • ktimer
  • kwallet
  • superkaramba
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal