- Added a drop-down item to allow removing unused keys, in the Network dialog.

- added key removal method in OpenPGP-SDK
- improved FriendSelectionDialog/Widget to enable select all/none keys, and show non friend keys
- added safe key removal method in PGPHandler. Removed keys from other locations will not cause errors.
- added backup system to public keyring, impossibility to remove public parts of owned secret keys, etc.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6382 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-05-29 21:32:02 +00:00
parent 02890c737a
commit 0266329dc8
17 changed files with 314 additions and 81 deletions

View File

@ -22,6 +22,7 @@ extern "C" {
}
#include "pgphandler.h"
#include "retroshare/rsiface.h" // For rsicontrol.
#include "retroshare/rspeers.h" // For rsicontrol.
#include "util/rsdir.h"
#include "pgp/pgpkeyutil.h"
@ -823,6 +824,7 @@ void PGPHandler::addNewKeyToOPSKeyring(ops_keyring_t *kr,const ops_keydata_t& ke
memset(&kr->keys[kr->nkeys],0,sizeof(ops_keydata_t)) ;
ops_keydata_copy(&kr->keys[kr->nkeys],&key) ;
kr->nkeys++ ;
kr->nkeys_allocated = kr->nkeys ;
}
bool PGPHandler::LoadCertificateFromString(const std::string& pgp_cert,PGPIdType& id,std::string& error_string)
@ -1539,4 +1541,95 @@ void PGPHandler::mergeKeyringFromDisk( ops_keyring_t *keyring,
ops_keyring_free(tmp_keyring) ;
}
bool PGPHandler::removeKeysFromPGPKeyring(const std::list<PGPIdType>& keys_to_remove,std::string& backup_file,uint32_t& error_code)
{
// 1 - lock everything.
//
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
RsStackFileLock flck(_pgp_lock_filename) ; // lock access to PGP directory.
error_code = PGP_KEYRING_REMOVAL_ERROR_NO_ERROR ;
for(std::list<PGPIdType>::const_iterator it(keys_to_remove.begin());it!=keys_to_remove.end();++it)
if(locked_getSecretKey(*it) != NULL)
{
std::cerr << "(EE) PGPHandler:: can't remove key " << (*it).toStdString() << " since its shared by a secret key! Operation cancelled." << std::endl;
error_code = PGP_KEYRING_REMOVAL_ERROR_CANT_REMOVE_SECRET_KEYS ;
return false ;
}
// 2 - sync everything.
//
locked_syncPublicKeyring() ;
// 3 - make a backup of the public keyring
//
char template_name[_pubring_path.length()+8] ;
sprintf(template_name,"%s.XXXXXX",_pubring_path.c_str()) ;
if(mktemp(template_name) == NULL)
{
std::cerr << "PGPHandler::removeKeysFromPGPKeyring(): cannot create keyring backup file. Giving up." << std::endl;
error_code = PGP_KEYRING_REMOVAL_ERROR_CANNOT_CREATE_BACKUP ;
return false ;
}
if(!ops_write_keyring_to_file(_pubring,ops_false,template_name,ops_true))
{
std::cerr << "PGPHandler::removeKeysFromPGPKeyring(): cannot write keyring backup file. Giving up." << std::endl;
error_code = PGP_KEYRING_REMOVAL_ERROR_CANNOT_WRITE_BACKUP ;
return false ;
}
backup_file = std::string(template_name,_pubring_path.length()+7) ;
std::cerr << "Keyring was backed up to file " << backup_file << std::endl;
// Remove keys from the keyring, and update the keyring map.
//
for(std::list<PGPIdType>::const_iterator it(keys_to_remove.begin());it!=keys_to_remove.end();++it)
{
if(locked_getSecretKey(*it) != NULL)
{
std::cerr << "(EE) PGPHandler:: can't remove key " << (*it).toStdString() << " since its shared by a secret key!" << std::endl;
continue ;
}
std::map<std::string,PGPCertificateInfo>::iterator res = _public_keyring_map.find((*it).toStdString()) ;
if(res == _public_keyring_map.end())
{
std::cerr << "(EE) PGPHandler:: can't remove key " << (*it).toStdString() << " from keyring: key not found." << std::endl;
continue ;
}
// Move the last key to the freed place. This deletes the key in place.
//
ops_keyring_remove_key(_pubring,res->second._key_index) ;
// Erase the info from the keyring map.
//
_public_keyring_map.erase(res) ;
}
// now update all indices back
int i=0 ;
const ops_keydata_t *keydata ;
while( (keydata = ops_keyring_get_key_by_index(_pubring,i)) != NULL )
{
PGPCertificateInfo& cert(_public_keyring_map[ PGPIdType(keydata->key_id).toStdString() ]) ;
cert._key_index = i ;
++i ;
}
// Everything went well, sync back the keyring on disk
_pubring_changed = true ;
_trustdb_changed = true ;
locked_syncPublicKeyring() ;
locked_syncTrustDatabase() ;
return true ;
}

View File

@ -101,6 +101,11 @@ class PGPHandler
void setAcceptConnexion(const PGPIdType&,bool) ;
void updateOwnSignatureFlag(const PGPIdType& ownId) ;
// Removes the given keys from the keyring. Also backup the keyring to a file which name is automatically generated
// and given pack for proper display.
//
bool removeKeysFromPGPKeyring(const std::list<PGPIdType>& key_ids,std::string& backup_file,uint32_t& error_code) ;
//bool isKeySupported(const PGPIdType& id) const ;
bool privateTrustCertificate(const PGPIdType& id,int valid_level) ;

View File

@ -60,6 +60,16 @@ bool AuthGPG::decryptTextFromFile(std::string& text,const std::string& inputfile
return PGPHandler::decryptTextFromFile(mOwnGpgId,text,inputfile) ;
}
bool AuthGPG::removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code)
{
std::list<PGPIdType> pids ;
for(std::list<std::string>::const_iterator it(pgp_ids.begin());it!=pgp_ids.end();++it)
pids.push_back(PGPIdType(*it)) ;
return PGPHandler::removeKeysFromPGPKeyring(pids,backup_file,error_code) ;
}
bool AuthGPG::encryptTextToFile(const std::string& text,const std::string& outfile)
{
return PGPHandler::encryptTextToFile(mOwnGpgId,text,outfile) ;

View File

@ -173,6 +173,8 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
virtual bool importProfile(const std::string& filename,std::string& gpg_id,std::string& import_error) ;
virtual bool exportProfile(const std::string& filename,const std::string& gpg_id) ;
virtual bool removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code) ;
/*********************************************************************************/
/************************* STAGE 4 ***********************************************/
/*********************************************************************************/

View File

@ -104,6 +104,11 @@ const uint32_t CERTIFICATE_PARSING_ERROR_CHECKSUM_ERROR = 0x16 ;
const uint32_t CERTIFICATE_PARSING_ERROR_UNKNOWN_SECTION_PTAG = 0x17 ;
const uint32_t CERTIFICATE_PARSING_ERROR_MISSING_CHECKSUM = 0x18 ;
const uint32_t PGP_KEYRING_REMOVAL_ERROR_NO_ERROR = 0x20 ;
const uint32_t PGP_KEYRING_REMOVAL_ERROR_CANT_REMOVE_SECRET_KEYS = 0x21 ;
const uint32_t PGP_KEYRING_REMOVAL_ERROR_CANNOT_CREATE_BACKUP = 0x22 ;
const uint32_t PGP_KEYRING_REMOVAL_ERROR_CANNOT_WRITE_BACKUP = 0x23 ;
/* LinkType Flags */
// CONNECTION
@ -277,6 +282,9 @@ class RsPeers
virtual bool removeFriend(const std::string &ssl_or_gpg_id) = 0;
virtual bool removeFriendLocation(const std::string &sslId) = 0;
/* keyring management */
virtual bool removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code)=0 ;
/* Network Stuff */
virtual bool connectAttempt(const std::string &ssl_id) = 0;
virtual bool setLocation(const std::string &ssl_id, const std::string &location) = 0;//location is shown in the gui to differentiate ssl certs

View File

@ -619,10 +619,10 @@ bool p3Peers::addFriend(const std::string &ssl_id, const std::string &gpg_id,Se
return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VIS_STATE_STD, now, perm_flags);
}
bool p3Peers::removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code)
{
return AuthGPG::getAuthGPG()->removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ;
}
bool p3Peers::removeFriendLocation(const std::string &sslId)
{

View File

@ -77,6 +77,9 @@ virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id,Serv
virtual bool removeFriend(const std::string &ssl_or_gpgid);
virtual bool removeFriendLocation(const std::string &sslId);
/* keyring management */
virtual bool removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code);
/* Network Stuff */
virtual bool connectAttempt(const std::string &id);
virtual bool setLocation(const std::string &ssl_id, const std::string &location);//location is shown in the gui to differentiate ssl certs

View File

@ -156,6 +156,7 @@ void ops_keydata_copy(ops_keydata_t *dst,const ops_keydata_t *src)
{
unsigned n;
keydata_internal_free(dst) ;
memset(dst,0,sizeof(ops_keydata_t)) ;
dst->uids = (ops_user_id_t*)ops_mallocz(src->nuids * sizeof(ops_user_id_t)) ;
@ -863,6 +864,29 @@ void ops_keyring_free(ops_keyring_t *keyring)
keyring->nkeys_allocated=0;
}
void ops_keyring_remove_key(ops_keyring_t *keyring,int index)
{
if(index > keyring->nkeys-1)
{
fprintf(stderr,"ops_keyring_remove_key: ERROR: cannot remove key with index %d > %d.",index,keyring->nkeys-1) ;
return ;
}
if(index < keyring->nkeys-1)
ops_keydata_copy(&keyring->keys[index],&keyring->keys[keyring->nkeys-1]) ;
keydata_internal_free(&keyring->keys[keyring->nkeys-1]) ;
if(NULL == realloc(keyring->keys,(keyring->nkeys-1)*sizeof(ops_keydata_t)) )
{
fprintf(stderr,"ops_keyring_remove_key: ERROR: cannot re-alloc keyring memory.") ;
return ;
}
keyring->nkeys-- ;
keyring->nkeys_allocated-- ;
}
/**
\ingroup HighLevel_KeyringFind

View File

@ -77,6 +77,7 @@ unsigned ops_get_user_id_count(const ops_keydata_t *key);
const unsigned char* ops_get_user_id(const ops_keydata_t *key, unsigned index);
ops_boolean_t ops_is_key_supported(const ops_keydata_t *key);
const ops_keydata_t* ops_keyring_get_key_by_index(const ops_keyring_t *keyring, int index);
void ops_keyring_remove_key(ops_keyring_t *keyring,int index) ;
ops_user_id_t* ops_add_userid_to_keydata(ops_keydata_t* keydata, const ops_user_id_t* userid);
ops_packet_t* ops_add_packet_to_keydata(ops_keydata_t* keydata, const ops_packet_t* packet);

View File

@ -31,6 +31,7 @@
#include "common/vmessagebox.h"
#include "common/RSTreeWidgetItem.h"
#include <gui/common/FriendSelectionDialog.h>
#include "NetworkDialog.h"
//#include "TrustView.h"
#include "NetworkView.h"
@ -45,6 +46,7 @@
#define IMAGE_LOADCERT ":/images/loadcert16.png"
#define IMAGE_PEERDETAILS ":/images/peerdetails_16x16.png"
#define IMAGE_AUTH ":/images/encrypted16.png"
#define IMAGE_CLEAN_UNUSED ":/images/deletemail24.png"
#define IMAGE_MAKEFRIEND ":/images/user/add_user16.png"
#define IMAGE_EXPORT ":/images/exportpeers_16x16.png"
#define IMAGE_COPYLINK ":/images/copyrslink.png"
@ -218,45 +220,77 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint /*point*/ )
if(peer_id != rsPeers->getGPGOwnId())
{
if(detail.accept_connection)
{
QAction* denyFriendAct = new QAction(QIcon(IMAGE_DENIED), tr( "Deny friend" ), contextMnu );
connect( denyFriendAct , SIGNAL( triggered() ), this, SLOT( denyFriend() ) );
contextMnu->addAction( denyFriendAct);
}
contextMnu->addAction(QIcon(IMAGE_DENIED), tr("Deny friend"), this, SLOT(denyFriend()));
else // not a friend
{
QAction* makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Make friend" ), contextMnu );
connect( makefriendAct , SIGNAL( triggered() ), this, SLOT( makeFriend() ) );
contextMnu->addAction( makefriendAct);
#ifdef TODO
if(detail.validLvl > RS_TRUST_LVL_MARGINAL) // it's a denied old friend.
{
QAction* deleteCertAct = new QAction(QIcon(IMAGE_PEERDETAILS), tr( "Delete certificate" ), contextMnu );
connect( deleteCertAct, SIGNAL( triggered() ), this, SLOT( deleteCert() ) );
contextMnu->addAction( deleteCertAct );
}
#endif
}
contextMnu->addAction(QIcon(IMAGE_MAKEFRIEND), tr("Make friend"), this, SLOT(makeFriend()));
}
if(peer_id == rsPeers->getGPGOwnId())
{
QAction* exportcertAct = new QAction(QIcon(IMAGE_EXPORT), tr( "Export my Cert" ), contextMnu );
connect( exportcertAct , SIGNAL( triggered() ), this, SLOT( on_actionExportKey_activated() ) );
contextMnu->addAction( exportcertAct);
}
QAction* peerdetailsAct = new QAction(QIcon(IMAGE_PEERDETAILS), tr( "Peer details..." ), contextMnu );
connect( peerdetailsAct , SIGNAL( triggered() ), this, SLOT( peerdetails() ) );
contextMnu->addAction( peerdetailsAct);
contextMnu->addAction(QIcon(IMAGE_EXPORT), tr("Export my certificate..."), this, SLOT(on_actionExportKey_activated()));
contextMnu->addAction(QIcon(IMAGE_PEERDETAILS), tr("Peer details..."), this, SLOT(peerdetails()));
contextMnu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink()));
contextMnu->addSeparator() ;
contextMnu->addAction(QIcon(IMAGE_CLEAN_UNUSED), tr("Remove unused keys..."), this, SLOT(removeUnusedKeys()));
contextMnu->exec(QCursor::pos());
}
void NetworkDialog::removeUnusedKeys()
{
std::list<std::string> pre_selected ;
std::list<std::string> ids ;
rsPeers->getGPGAllList(ids) ;
RsPeerDetails details ;
time_t now = time(NULL) ;
time_t THREE_MONTHS = 86400*31*3 ;
for(std::list<std::string>::const_iterator it(ids.begin());it!=ids.end();++it)
{
rsPeers->getPeerDetails(*it,details) ;
if(now > THREE_MONTHS + details.lastUsed)
{
std::cerr << "Adding " << *it << " to pre-selection." << std::endl;
pre_selected.push_back(*it) ;
}
}
std::list<std::string> selected = FriendSelectionDialog::selectFriends(NULL,
tr("Clean keyring"),
tr("The selected keys below haven't been used in the last 3 months. \nDo you want to delete them permanently ? \n\nNotes: Your old keyring will be backed up.\n The removal may fail when running multiple Retroshare instances on the same machine."),FriendSelectionWidget::MODUS_CHECK,FriendSelectionWidget::SHOW_GPG | FriendSelectionWidget::SHOW_NON_FRIEND_GPG,
FriendSelectionWidget::IDTYPE_GPG, pre_selected) ;
std::cerr << "Removing these keys from the keyring: " << std::endl;
for(std::list<std::string>::const_iterator it(selected.begin());it!=selected.end();++it)
std::cerr << " " << *it << std::endl;
std::string backup_file ;
uint32_t error_code ;
if( rsPeers->removeKeysFromPGPKeyring(selected,backup_file,error_code) )
QMessageBox::information(NULL,tr("Keyring info"),tr("%1 keys have been deleted from your keyring. \nFor security, your keyring was previously backed-up to file \n\n").arg(selected.size())+QString::fromStdString(backup_file) ) ;
else
{
QString error_string ;
switch(error_code)
{
default:
case PGP_KEYRING_REMOVAL_ERROR_NO_ERROR: error_string = tr("Unknown error") ;
break ;
case PGP_KEYRING_REMOVAL_ERROR_CANT_REMOVE_SECRET_KEYS: error_string = tr("Cannot delete secret keys") ;
break ;
case PGP_KEYRING_REMOVAL_ERROR_CANNOT_WRITE_BACKUP:
case PGP_KEYRING_REMOVAL_ERROR_CANNOT_CREATE_BACKUP: error_string = tr("Cannot create backup file. Check for permissions in pgp directory, disk space, etc.") ;
break ;
}
QMessageBox::warning(NULL,tr("Keyring info"),tr("Key removal has failed. Your keyring remains intact.\n\nReported error: ")+error_string ) ;
}
}
void NetworkDialog::denyFriend()
{
QTreeWidgetItem *wi = getCurrentNeighbour();

View File

@ -66,6 +66,7 @@ protected:
private slots:
void removeUnusedKeys() ;
void makeFriend() ;
void denyFriend() ;
void deleteCert() ;

View File

@ -106,7 +106,7 @@ void ChatLobbyDialog::inviteFriends()
{
std::cerr << "Inviting friends" << std::endl;
std::list<std::string> ids = FriendSelectionDialog::selectFriends() ;
std::list<std::string> ids = FriendSelectionDialog::selectFriends(NULL,tr("Invite friends"),tr("Select friends to invite:")) ;
std::cerr << "Inviting these friends:" << std::endl;

View File

@ -4,29 +4,40 @@
#include <QDialogButtonBox>
#include "FriendSelectionDialog.h"
std::list<std::string> FriendSelectionDialog::selectFriends()
std::list<std::string> FriendSelectionDialog::selectFriends(QWidget *parent,const QString& caption,const QString& header_text,
FriendSelectionWidget::Modus modus,
FriendSelectionWidget::ShowTypes show_type,
FriendSelectionWidget::IdType pre_selected_id_type,
const std::list<std::string>& pre_selected_ids)
{
FriendSelectionDialog dialog ;
FriendSelectionDialog dialog(parent,header_text,modus,show_type,pre_selected_id_type,pre_selected_ids) ;
dialog.friends_widget->start() ;
dialog.setWindowTitle(tr("Choose some friends")) ;
dialog.friends_widget->setSelectedIds(pre_selected_id_type,pre_selected_ids,true) ;
dialog.setWindowTitle(caption) ;
if(QDialog::Rejected == dialog.exec())
return std::list<std::string>() ;
std::list<std::string> ids ;
dialog.friends_widget->selectedSslIds(ids,false) ;
dialog.friends_widget->selectedIds(pre_selected_id_type,ids,false) ;
return ids ;
}
FriendSelectionDialog::FriendSelectionDialog(QWidget *parent)
FriendSelectionDialog::FriendSelectionDialog(QWidget *parent,const QString& header_text,
FriendSelectionWidget::Modus modus,
FriendSelectionWidget::ShowTypes show_type,
FriendSelectionWidget::IdType pre_selected_id_type,
const std::list<std::string>& pre_selected_ids)
: QDialog(parent)
{
friends_widget = new FriendSelectionWidget(this) ;
friends_widget->setHeaderText(tr("Contacts:"));
friends_widget->setModus(FriendSelectionWidget::MODUS_CHECK);
friends_widget->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
friends_widget->setHeaderText(header_text);
friends_widget->setModus(modus) ;
friends_widget->setShowType(show_type) ;
QLayout *l = new QVBoxLayout ;
setLayout(l) ;

View File

@ -6,11 +6,16 @@
class FriendSelectionDialog : public QDialog
{
public:
static std::list<std::string> selectFriends() ;
static std::list<std::string> selectFriends(QWidget *parent,const QString& caption,const QString& header_string,
FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI,
FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL,
FriendSelectionWidget::IdType pre_selected_id_type = FriendSelectionWidget::IDTYPE_SSL,
const std::list<std::string>& pre_selected_ids = std::list<std::string>()) ;
private:
virtual ~FriendSelectionDialog() ;
FriendSelectionDialog(QWidget *parent = NULL) ;
FriendSelectionDialog(QWidget *parent,const QString& header_string,FriendSelectionWidget::Modus modus,FriendSelectionWidget::ShowTypes show_type,
FriendSelectionWidget::IdType pre_selected_id_type,
const std::list<std::string>& pre_selected_ids) ;
FriendSelectionWidget *friends_widget ;
};

View File

@ -89,6 +89,8 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) :
connect(ui->friendList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
connect(ui->friendList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
connect(ui->friendList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int)));
connect(ui->selectAll_PB, SIGNAL(clicked()), this, SLOT(selectAll()));
connect(ui->deselectAll_PB, SIGNAL(clicked()), this, SLOT(deselectAll()));
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(fillList()));
@ -148,6 +150,17 @@ void FriendSelectionWidget::setModus(Modus modus)
break;
}
if(modus == MODUS_CHECK)
{
ui->selectAll_PB->setHidden(false) ;
ui->deselectAll_PB->setHidden(false) ;
}
else
{
ui->selectAll_PB->setHidden(true) ;
ui->deselectAll_PB->setHidden(true) ;
}
fillList();
}
@ -221,7 +234,7 @@ void FriendSelectionWidget::fillList()
}
std::list<std::string> gpgIdsSelected;
if (mShowTypes & SHOW_GPG) {
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) {
selectedGpgIds(gpgIdsSelected, true);
}
@ -235,10 +248,15 @@ void FriendSelectionWidget::fillList()
std::list<std::string> gpgIds;
std::list<std::string>::iterator gpgIt;
rsPeers->getGPGAcceptedList(gpgIds);
if(mShowTypes & SHOW_NON_FRIEND_GPG)
rsPeers->getGPGAllList(gpgIds);
else
rsPeers->getGPGAcceptedList(gpgIds);
std::list<std::string> sslIds;
std::list<std::string>::iterator sslIt;
if ((mShowTypes & (SHOW_SSL | SHOW_GPG)) == SHOW_SSL) {
rsPeers->getFriendList(sslIds);
}
@ -295,7 +313,7 @@ void FriendSelectionWidget::fillList()
}
}
if (mShowTypes & SHOW_GPG) {
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) {
// iterate through gpg ids
for (gpgIt = gpgIds.begin(); gpgIt != gpgIds.end(); gpgIt++) {
if (groupInfo) {
@ -466,7 +484,7 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
QString gpgId;
int gpgStatus = RS_STATUS_OFFLINE;
if (mShowTypes & SHOW_GPG) {
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) {
/* need gpg id and online state */
RsPeerDetails detail;
if (rsPeers->getPeerDetails(peerId.toStdString(), detail)) {
@ -763,6 +781,17 @@ void FriendSelectionWidget::selectedIds(IdType idType, std::list<std::string> &i
}
}
void FriendSelectionWidget::deselectAll()
{
for(QTreeWidgetItemIterator itemIterator(ui->friendList);*itemIterator!=NULL;++itemIterator)
setSelected(mListModus, *itemIterator, false);
}
void FriendSelectionWidget::selectAll()
{
for(QTreeWidgetItemIterator itemIterator(ui->friendList);*itemIterator!=NULL;++itemIterator)
setSelected(mListModus, *itemIterator, true);
}
void FriendSelectionWidget::setSelectedIds(IdType idType, const std::list<std::string> &ids, bool add)
{
QTreeWidgetItemIterator itemIterator(ui->friendList);

View File

@ -56,9 +56,10 @@ public:
};
enum ShowType {
SHOW_GROUP = 1,
SHOW_GPG = 2,
SHOW_SSL = 4
SHOW_GROUP = 1,
SHOW_GPG = 2,
SHOW_SSL = 4,
SHOW_NON_FRIEND_GPG = 8,
};
Q_DECLARE_FLAGS(ShowTypes, ShowType)
@ -110,6 +111,8 @@ private slots:
void contextMenuRequested(const QPoint &pos);
void itemDoubleClicked(QTreeWidgetItem *item, int column);
void itemChanged(QTreeWidgetItem *item, int column);
void selectAll() ;
void deselectAll() ;
private:
bool filterItem(QTreeWidgetItem *item, const QString &text);
@ -130,6 +133,8 @@ private:
QColor mTextColorOnline;
Ui::FriendSelectionWidget *ui;
friend class FriendSelectionDialog ;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(FriendSelectionWidget::ShowTypes)

View File

@ -6,37 +6,11 @@
<rect>
<x>0</x>
<y>0</y>
<width>211</width>
<height>358</height>
<width>446</width>
<height>320</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>1</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="filterLabel">
<property name="text">
<string>Search for Name:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="LineEditClear" name="filterLineEdit"/>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="friendList">
<property name="minimumSize">
@ -67,6 +41,34 @@
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="filterLabel">
<property name="text">
<string>Search :</string>
</property>
</widget>
</item>
<item>
<widget class="LineEditClear" name="filterLineEdit"/>
</item>
<item>
<widget class="QPushButton" name="selectAll_PB">
<property name="text">
<string>All</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deselectAll_PB">
<property name="text">
<string>None</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>