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

kgpg

kgpgkey.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  ***************************************************************************/
00009 
00010 #include "kgpgkey.h"
00011 
00012 #include <KLocale>
00013 
00014 #include "convert.h"
00015 
00016 namespace KgpgCore
00017 {
00018 
00019 //BEGIN KeySign
00020 
00021 bool KgpgKeySignPrivate::operator==(const KgpgKeySignPrivate &other) const
00022 {
00023     if (gpgsignrevocation != other.gpgsignrevocation) return false;
00024     if (gpgsignlocal != other.gpgsignlocal) return false;
00025     if (gpgsignid != other.gpgsignid) return false;
00026     if (gpgsignname != other.gpgsignname) return false;
00027     if (gpgsignemail != other.gpgsignemail) return false;
00028     if (gpgsigncomment != other.gpgsigncomment) return false;
00029     if (gpgsignexpiration != other.gpgsignexpiration) return false;
00030     if (gpgsigncreation != other.gpgsigncreation) return false;
00031     return true;
00032 }
00033 
00034 KgpgKeySign::KgpgKeySign()
00035            : QObject()
00036 {
00037     d = new KgpgKeySignPrivate;
00038     d->gpgsignrevocation = false;
00039     d->gpgsignlocal = false;
00040 }
00041 
00042 KgpgKeySign::KgpgKeySign(const KgpgKeySign &other)
00043            : QObject()
00044 {
00045     d = other.d;
00046 }
00047 
00048 void KgpgKeySign::setId(const QString &id)
00049 {
00050     d->gpgsignid = id;
00051 }
00052 
00053 void KgpgKeySign::setName(const QString &name)
00054 {
00055     d->gpgsignname = name;
00056 }
00057 
00058 void KgpgKeySign::setEmail(const QString &email)
00059 {
00060     d->gpgsignemail = email;
00061 }
00062 
00063 void KgpgKeySign::setComment(const QString &comment)
00064 {
00065     d->gpgsigncomment = comment;
00066 }
00067 
00068 void KgpgKeySign::setExpiration(const QDate &date)
00069 {
00070     d->gpgsignexpiration = date;
00071 }
00072 
00073 void KgpgKeySign::setCreation(const QDate &date)
00074 {
00075     d->gpgsigncreation = date;
00076 }
00077 
00078 void KgpgKeySign::setLocal(const bool &local)
00079 {
00080     d->gpgsignlocal = local;
00081 }
00082 
00083 void KgpgKeySign::setRevocation(const bool &revoc)
00084 {
00085     d->gpgsignrevocation = revoc;
00086 }
00087 
00088 QString KgpgKeySign::id() const
00089 {
00090     return d->gpgsignid.right(8);
00091 }
00092 
00093 QString KgpgKeySign::fullId() const
00094 {
00095     return d->gpgsignid;
00096 }
00097 
00098 QString KgpgKeySign::name() const
00099 {
00100     return d->gpgsignname;
00101 }
00102 
00103 QString KgpgKeySign::email() const
00104 {
00105     return d->gpgsignemail;
00106 }
00107 
00108 QString KgpgKeySign::comment() const
00109 {
00110     return d->gpgsigncomment;
00111 }
00112 
00113 bool KgpgKeySign::unlimited() const
00114 {
00115     return d->gpgsignexpiration.isNull();
00116 }
00117 
00118 QDate KgpgKeySign::expirationDate() const
00119 {
00120     return d->gpgsignexpiration;
00121 }
00122 
00123 QDate KgpgKeySign::creationDate() const
00124 {
00125     return d->gpgsigncreation;
00126 }
00127 
00128 bool KgpgKeySign::local() const
00129 {
00130     return d->gpgsignlocal;
00131 }
00132 
00133 bool KgpgKeySign::revocation() const
00134 {
00135     return d->gpgsignrevocation;
00136 }
00137 
00138 QString KgpgKeySign::expiration() const
00139 {
00140     return KgpgKey::expiration(d->gpgsignexpiration);
00141 }
00142 
00143 QString KgpgKeySign::creation() const
00144 {
00145     return Convert::toString(d->gpgsigncreation);
00146 }
00147 
00148 bool KgpgKeySign::operator==(const KgpgKeySign &other) const
00149 {
00150     if (d == other.d) return true;
00151     if ((*d) == (*(other.d))) return true;
00152     return false;
00153 }
00154 
00155 KgpgKeySign& KgpgKeySign::operator=(const KgpgKeySign &other)
00156 {
00157     d = other.d;
00158     return *this;
00159 }
00160 
00161 //END KeySign
00162 
00163 
00164 //BEGIN KeyUat
00165 
00166 bool KgpgKeyUatPrivate::operator==(const KgpgKeyUatPrivate &other) const
00167 {
00168     if (gpguatid != other.gpguatid) return false;
00169     if (gpguatcreation != other.gpguatcreation) return false;
00170     if (gpgsignlist != other.gpgsignlist) return false;
00171     return true;
00172 }
00173 
00174 KgpgKeyUat::KgpgKeyUat()
00175           : QObject()
00176 {
00177     d = new KgpgKeyUatPrivate;
00178 }
00179 
00180 KgpgKeyUat::KgpgKeyUat(const KgpgKeyUat &other)
00181           : QObject()
00182 {
00183     d = other.d;
00184 }
00185 
00186 void KgpgKeyUat::setId(const QString &id)
00187 {
00188     d->gpguatid = id;
00189 }
00190 
00191 void KgpgKeyUat::setCreation(const QDate &date)
00192 {
00193     d->gpguatcreation = date;
00194 }
00195 
00196 QString KgpgKeyUat::id() const
00197 {
00198     return d->gpguatid;
00199 }
00200 
00201 QDate KgpgKeyUat::creationDate() const
00202 {
00203     return d->gpguatcreation;
00204 }
00205 
00206 QString KgpgKeyUat::creation() const
00207 {
00208     return Convert::toString(d->gpguatcreation);
00209 }
00210 
00211 void KgpgKeyUat::addSign(const KgpgKeySign &sign)
00212 {
00213     d->gpgsignlist << sign;
00214 }
00215 
00216 KgpgKeySignList KgpgKeyUat::signList() const
00217 {
00218     return d->gpgsignlist;
00219 }
00220 
00221 bool KgpgKeyUat::operator==(const KgpgKeyUat &other) const
00222 {
00223     if (d == other.d) return true;
00224     if ((*d) == (*(other.d))) return true;
00225     return false;
00226 }
00227 
00228 KgpgKeyUat& KgpgKeyUat::operator=(const KgpgKeyUat &other)
00229 {
00230     d = other.d;
00231     return *this;
00232 }
00233 
00234 //END KeyUat
00235 
00236 
00237 //BEGIN KeyUid
00238 
00239 bool KgpgKeyUidPrivate::operator==(const KgpgKeyUidPrivate &other) const
00240 {
00241     if (gpguidvalid != other.gpguidvalid) return false;
00242     if (gpguidtrust != other.gpguidtrust) return false;
00243     if (gpguidname != other.gpguidname) return false;
00244     if (gpguidemail != other.gpguidemail) return false;
00245     if (gpguidcomment != other.gpguidcomment) return false;
00246     if (gpguidindex != other.gpguidindex) return false;
00247     if (gpgsignlist != other.gpgsignlist) return false;
00248     return true;
00249 }
00250 
00251 KgpgKeyUid::KgpgKeyUid()
00252           : QObject()
00253 {
00254     d = new KgpgKeyUidPrivate;
00255     d->gpguidvalid = false;
00256     d->gpguidindex = 0;
00257 }
00258 
00259 KgpgKeyUid::KgpgKeyUid(const KgpgKeyUid &other)
00260           : QObject()
00261 {
00262     d = other.d;
00263 }
00264 
00265 void KgpgKeyUid::setName(const QString &name)
00266 {
00267     d->gpguidname = name;
00268 }
00269 
00270 void KgpgKeyUid::setEmail(const QString &email)
00271 {
00272     d->gpguidemail = email;
00273 }
00274 
00275 void KgpgKeyUid::setComment(const QString &comment)
00276 {
00277     d->gpguidcomment = comment;
00278 }
00279 
00280 void KgpgKeyUid::setValid(const bool &valid)
00281 {
00282     d->gpguidvalid = valid;
00283 }
00284 
00285 void KgpgKeyUid::setTrust(const KgpgKeyTrust &trust)
00286 {
00287     d->gpguidtrust = trust;
00288 }
00289 
00290 void KgpgKeyUid::setIndex(const unsigned int &index)
00291 {
00292     d->gpguidindex = index;
00293 }
00294 
00295 QString KgpgKeyUid::name() const
00296 {
00297     return d->gpguidname;
00298 }
00299 
00300 QString KgpgKeyUid::email() const
00301 {
00302     return d->gpguidemail;
00303 }
00304 
00305 QString KgpgKeyUid::comment() const
00306 {
00307     return d->gpguidcomment;
00308 }
00309 
00310 bool KgpgKeyUid::valid() const
00311 {
00312     return d->gpguidvalid;
00313 }
00314 
00315 KgpgKeyTrust KgpgKeyUid::trust() const
00316 {
00317     return d->gpguidtrust;
00318 }
00319 
00320 unsigned int KgpgKeyUid::index() const
00321 {
00322     return d->gpguidindex;
00323 }
00324 
00325 void KgpgKeyUid::addSign(const KgpgKeySign &sign)
00326 {
00327     d->gpgsignlist << sign;
00328 }
00329 
00330 KgpgKeySignList KgpgKeyUid::signList() const
00331 {
00332     return d->gpgsignlist;
00333 }
00334 
00335 bool KgpgKeyUid::operator==(const KgpgKeyUid &other) const
00336 {
00337     if (d == other.d) return true;
00338     if ((*d) == (*(other.d))) return true;
00339     return false;
00340 }
00341 
00342 KgpgKeyUid& KgpgKeyUid::operator=(const KgpgKeyUid &other)
00343 {
00344     d = other.d;
00345     return *this;
00346 }
00347 
00348 //END KeyUid
00349 
00350 
00351 //BEGIN KeySub
00352 
00353 bool KgpgKeySubPrivate::operator==(const KgpgKeySubPrivate &other) const
00354 {
00355     if (gpgsubvalid != other.gpgsubvalid) return false;
00356     if (gpgsubalgo != other.gpgsubalgo) return false;
00357     if (gpgsubid != other.gpgsubid) return false;
00358     if (gpgsubsize != other.gpgsubsize) return false;
00359     if (gpgsubexpiration != other.gpgsubexpiration) return false;
00360     if (gpgsubcreation != other.gpgsubcreation) return false;
00361     if (gpgsubtrust != other.gpgsubtrust) return false;
00362     if (gpgsignlist != other.gpgsignlist) return false;
00363     if (gpgsubtype != other.gpgsubtype) return false;
00364     return true;
00365 }
00366 
00367 KgpgKeySub::KgpgKeySub()
00368           : QObject()
00369 {
00370     d = new KgpgKeySubPrivate;
00371     d->gpgsubsize = 0;
00372     d->gpgsubvalid = false;
00373 }
00374 
00375 KgpgKeySub::KgpgKeySub(const KgpgKeySub &other)
00376           : QObject()
00377 {
00378     d = other.d;
00379 }
00380 
00381 void KgpgKeySub::setId(const QString &id)
00382 {
00383     d->gpgsubid = id;
00384 }
00385 
00386 void KgpgKeySub::setSize(const uint &size)
00387 {
00388     d->gpgsubsize = size;
00389 }
00390 
00391 void KgpgKeySub::setExpiration(const QDate &date)
00392 {
00393     d->gpgsubexpiration = date;
00394 }
00395 
00396 void KgpgKeySub::setCreation(const QDate &date)
00397 {
00398     d->gpgsubcreation = date;
00399 }
00400 
00401 void KgpgKeySub::setTrust(const KgpgKeyTrust &trust)
00402 {
00403     d->gpgsubtrust = trust;
00404 }
00405 
00406 void KgpgKeySub::setAlgorithm(const KgpgKeyAlgo &algo)
00407 {
00408     d->gpgsubalgo = algo;
00409 }
00410 
00411 void KgpgKeySub::setValid(const bool &valid)
00412 {
00413     d->gpgsubvalid = valid;
00414 }
00415 
00416 void KgpgKeySub::setType(const KgpgSubKeyType &type)
00417 {
00418     d->gpgsubtype = type;
00419 }
00420 
00421 QString KgpgKeySub::id() const
00422 {
00423     return d->gpgsubid;
00424 }
00425 
00426 uint KgpgKeySub::size() const
00427 {
00428     return d->gpgsubsize;
00429 }
00430 
00431 bool KgpgKeySub::unlimited() const
00432 {
00433     return d->gpgsubexpiration.isNull();
00434 }
00435 
00436 QDate KgpgKeySub::expirationDate() const
00437 {
00438     return d->gpgsubexpiration;
00439 }
00440 
00441 QDate KgpgKeySub::creationDate() const
00442 {
00443     return d->gpgsubcreation;
00444 }
00445 
00446 KgpgKeyTrust KgpgKeySub::trust() const
00447 {
00448     return d->gpgsubtrust;
00449 }
00450 
00451 KgpgKeyAlgo KgpgKeySub::algorithm() const
00452 {
00453     return d->gpgsubalgo;
00454 }
00455 
00456 bool KgpgKeySub::valid() const
00457 {
00458     return d->gpgsubvalid;
00459 }
00460 
00461 KgpgSubKeyType KgpgKeySub::type() const
00462 {
00463     return d->gpgsubtype;
00464 }
00465 
00466 QString KgpgKeySub::creation() const
00467 {
00468     return Convert::toString(d->gpgsubcreation);
00469 }
00470 
00471 QString KgpgKeySub::expiration() const
00472 {
00473     return KgpgKey::expiration(d->gpgsubexpiration);
00474 }
00475 
00476 void KgpgKeySub::addSign(const KgpgKeySign &sign)
00477 {
00478     d->gpgsignlist << sign;
00479 }
00480 
00481 KgpgKeySignList KgpgKeySub::signList() const
00482 {
00483     return d->gpgsignlist;
00484 }
00485 
00486 bool KgpgKeySub::operator==(const KgpgKeySub &other) const
00487 {
00488     if (d == other.d) return true;
00489     if ((*d) == (*(other.d))) return true;
00490     return false;
00491 }
00492 
00493 KgpgKeySub& KgpgKeySub::operator=(const KgpgKeySub &other)
00494 {
00495     d = other.d;
00496     return *this;
00497 }
00498 
00499 //END KeySub
00500 
00501 
00502 //BEGIN Key
00503 
00504 QString KgpgKey::expiration(const QDate &date)
00505 {
00506     if (date.isNull())
00507         return i18nc("Unlimited key lifetime", "Unlimited");
00508     return Convert::toString(date);
00509 }
00510 
00511 KgpgKeyPrivate::KgpgKeyPrivate()
00512 {
00513     gpguatlist = new KgpgKeyUatList;
00514     gpguidlist = new KgpgKeyUidList;
00515     gpgsublist = new KgpgKeySubList;
00516 }
00517 
00518 bool KgpgKeyPrivate::operator==(const KgpgKeyPrivate &other) const
00519 {
00520     if (gpgkeysecret != other.gpgkeysecret) return false;
00521     if (gpgkeyvalid != other.gpgkeyvalid) return false;
00522     if (gpgkeymail != other.gpgkeymail) return false;
00523     if (gpgkeyname != other.gpgkeyname) return false;
00524     if (gpgkeycomment != other.gpgkeycomment) return false;
00525     if (gpgkeyfingerprint != other.gpgkeyfingerprint) return false;
00526     if (gpgkeysize != other.gpgkeysize) return false;
00527     if (gpgkeyownertrust != other.gpgkeyownertrust) return false;
00528     if (gpgkeytrust != other.gpgkeytrust) return false;
00529     if (gpgkeycreation != other.gpgkeycreation) return false;
00530     if (gpgkeyexpiration != other.gpgkeyexpiration) return false;
00531     if (gpgkeyalgo != other.gpgkeyalgo) return false;
00532     if (gpgsignlist != other.gpgsignlist) return false;
00533     if (gpguatlist != other.gpguatlist) return false;
00534     if (gpguidlist != other.gpguidlist) return false;
00535     if (gpgsublist != other.gpgsublist) return false;
00536     return true;
00537 }
00538 
00539 KgpgKey::KgpgKey()
00540        : QObject()
00541 {
00542     d = new KgpgKeyPrivate;
00543     d->gpgkeyalgo = ALGO_UNKNOWN;
00544     d->gpgkeyvalid = false;
00545     d->gpgkeysecret = false;
00546     d->gpgkeysize = 0;
00547 }
00548 
00549 KgpgKey::KgpgKey(const KgpgKey &other)
00550        : QObject()
00551 {
00552     d = other.d;
00553 }
00554 
00555 void KgpgKey::setSecret(const bool &secret)
00556 {
00557     d->gpgkeysecret = secret;
00558 }
00559 
00560 void KgpgKey::setValid(const bool &valid)
00561 {
00562     d->gpgkeyvalid = valid;
00563 }
00564 
00565 void KgpgKey::setName(const QString &name)
00566 {
00567     d->gpgkeyname = name;
00568 }
00569 
00570 void KgpgKey::setEmail(const QString &email)
00571 {
00572     d->gpgkeymail = email;
00573 }
00574 
00575 void KgpgKey::setComment(const QString &comment)
00576 {
00577     d->gpgkeycomment = comment;
00578 }
00579 
00580 void KgpgKey::setFingerprint(const QString &fingerprint)
00581 {
00582     d->gpgkeyfingerprint = fingerprint;
00583 }
00584 
00585 void KgpgKey::setSize(const uint &size)
00586 {
00587     d->gpgkeysize = size;
00588 }
00589 
00590 void KgpgKey::setOwnerTrust(const KgpgKeyOwnerTrust &owtrust)
00591 {
00592     d->gpgkeyownertrust = owtrust;
00593 }
00594 
00595 void KgpgKey::setTrust(const KgpgKeyTrust &trust)
00596 {
00597     d->gpgkeytrust = trust;
00598 }
00599 
00600 void KgpgKey::setCreation(const QDate &date)
00601 {
00602     d->gpgkeycreation = date;
00603 }
00604 
00605 void KgpgKey::setExpiration(const QDate &date)
00606 {
00607     d->gpgkeyexpiration = date;
00608 }
00609 
00610 void KgpgKey::setAlgorithm(const KgpgKeyAlgo &algo)
00611 {
00612     d->gpgkeyalgo = algo;
00613 }
00614 
00615 bool KgpgKey::secret() const
00616 {
00617     return d->gpgkeysecret;
00618 }
00619 
00620 bool KgpgKey::valid() const
00621 {
00622     return d->gpgkeyvalid;
00623 }
00624 
00625 QString KgpgKey::id() const
00626 {
00627     return d->gpgkeyfingerprint.right(8);
00628 }
00629 
00630 QString KgpgKey::fullId() const
00631 {
00632     return d->gpgkeyfingerprint.right(16);
00633 }
00634 
00635 QString KgpgKey::name() const
00636 {
00637     return d->gpgkeyname;
00638 }
00639 
00640 QString KgpgKey::email() const
00641 {
00642     return d->gpgkeymail;
00643 }
00644 
00645 QString KgpgKey::comment() const
00646 {
00647     return d->gpgkeycomment;
00648 }
00649 
00650 QString KgpgKey::fingerprint() const
00651 {
00652     return d->gpgkeyfingerprint;
00653 }
00654 
00655 QString KgpgKey::fingerprintBeautified() const
00656 {
00657     QString fingervalue =d->gpgkeyfingerprint;
00658     uint len = fingervalue.length();
00659     if ((len > 0) && (len % 4 == 0))
00660       for (uint n = 0; 4 * (n + 1) < len; ++n)
00661         fingervalue.insert(5 * n + 4, ' ');
00662     return fingervalue;
00663 }
00664 
00665 uint KgpgKey::size() const
00666 {
00667     return d->gpgkeysize;
00668 }
00669 
00670 KgpgKeyOwnerTrust KgpgKey::ownerTrust() const
00671 {
00672     return d->gpgkeyownertrust;
00673 }
00674 
00675 KgpgKeyTrust KgpgKey::trust() const
00676 {
00677     return d->gpgkeytrust;
00678 }
00679 
00680 QDate KgpgKey::creationDate() const
00681 {
00682     return d->gpgkeycreation;
00683 }
00684 
00685 QDate KgpgKey::expirationDate() const
00686 {
00687     return d->gpgkeyexpiration;
00688 }
00689 
00690 bool KgpgKey::unlimited() const
00691 {
00692     return d->gpgkeyexpiration.isNull();
00693 }
00694 
00695 KgpgKeyAlgo KgpgKey::algorithm() const
00696 {
00697     return d->gpgkeyalgo;
00698 }
00699 
00700 QString KgpgKey::creation() const
00701 {
00702     return Convert::toString(d->gpgkeycreation);
00703 }
00704 
00705 QString KgpgKey::expiration() const
00706 {
00707     return expiration(d->gpgkeyexpiration);
00708 }
00709 
00710 QStringList KgpgKey::photoList() const
00711 {
00712     QStringList result;
00713     for (int i = 0; i < d->gpguatlist->size(); ++i)
00714         result << d->gpguatlist->at(i).id();
00715     return result;
00716 }
00717 
00718 void KgpgKey::addSign(const KgpgKeySign &sign)
00719 {
00720     d->gpgsignlist << sign;
00721 }
00722 
00723 KgpgKeySignList KgpgKey::signList() const
00724 {
00725     return d->gpgsignlist;
00726 }
00727 
00728 KgpgKeyUatListPtr KgpgKey::uatList() const
00729 {
00730     return d->gpguatlist;
00731 }
00732 
00733 KgpgKeyUidListPtr KgpgKey::uidList() const
00734 {
00735     return d->gpguidlist;
00736 }
00737 
00738 KgpgKeySubListPtr KgpgKey::subList() const
00739 {
00740     return d->gpgsublist;
00741 }
00742 
00743 bool KgpgKey::operator==(const KgpgKey &other) const
00744 {
00745     if (d == other.d) return true;
00746     if ((*d) == (*(other.d))) return true;
00747     return false;
00748 }
00749 
00750 KgpgKey& KgpgKey::operator=(const KgpgKey &other)
00751 {
00752     d = other.d;
00753     return *this;
00754 }
00755 
00756 //END Key
00757 
00758 } // namespace KgpgCore

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
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • okteta
  • printer-applet
  • superkaramba
  • sweeper
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