mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-20 20:34:25 -04:00
added key share list to channels
fixed problem with other channels not showing except top 5 git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3005 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
cf785bb8a3
commit
84da8eb074
5 changed files with 313 additions and 83 deletions
|
@ -22,9 +22,12 @@
|
|||
#include <QtGui>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "CreateChannel.h"
|
||||
|
||||
#include "rsiface/rschannels.h"
|
||||
#include "rsiface/rspeers.h"
|
||||
|
||||
/** Constructor */
|
||||
CreateChannel::CreateChannel(QWidget *parent)
|
||||
|
@ -41,6 +44,16 @@ CreateChannel::CreateChannel(QWidget *parent)
|
|||
|
||||
connect( ui.LogoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo()));
|
||||
connect( ui.ChannelLogoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo()));
|
||||
connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) ));
|
||||
connect(ui.keyShareList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ),
|
||||
this, SLOT(togglePersonItem( QTreeWidgetItem *, int ) ));
|
||||
|
||||
if(!ui.pubKeyShare_cb->isChecked()){
|
||||
|
||||
ui.contactsdockWidget->hide();
|
||||
this->resize(this->size().width() - ui.contactsdockWidget->size().width(),
|
||||
this->size().height());
|
||||
}
|
||||
|
||||
newChannel();
|
||||
|
||||
|
@ -55,13 +68,80 @@ void CreateChannel::show()
|
|||
}
|
||||
}
|
||||
|
||||
void CreateChannel::setShareList(){
|
||||
|
||||
if(ui.pubKeyShare_cb->isChecked()){
|
||||
this->resize(this->size().width() + ui.contactsdockWidget->size().width(),
|
||||
this->size().height());
|
||||
ui.contactsdockWidget->show();
|
||||
|
||||
|
||||
if (!rsPeers)
|
||||
{
|
||||
/* not ready yet! */
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<std::string> peers;
|
||||
std::list<std::string>::iterator it;
|
||||
|
||||
rsPeers->getFriendList(peers);
|
||||
|
||||
/* get a link to the table */
|
||||
QTreeWidget *shareWidget = ui.keyShareList;
|
||||
|
||||
QList<QTreeWidgetItem *> items;
|
||||
|
||||
for(it = peers.begin(); it != peers.end(); it++)
|
||||
{
|
||||
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(*it, detail))
|
||||
{
|
||||
continue; /* BAD */
|
||||
}
|
||||
|
||||
/* make a widget per friend */
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
|
||||
item -> setText(0, QString::fromStdString(detail.name) + " - " + QString::fromStdString(detail.location));
|
||||
if (detail.state & RS_PEER_STATE_CONNECTED) {
|
||||
item -> setTextColor(0,(Qt::darkBlue));
|
||||
}
|
||||
|
||||
item -> setText(1, QString::fromStdString(detail.id));
|
||||
|
||||
item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
||||
item -> setCheckState(0, Qt::Unchecked);
|
||||
|
||||
|
||||
/* add to the list */
|
||||
items.append(item);
|
||||
}
|
||||
|
||||
/* remove old items */
|
||||
shareWidget->clear();
|
||||
shareWidget->setColumnCount(1);
|
||||
|
||||
/* add the items in! */
|
||||
shareWidget->insertTopLevelItems(0, items);
|
||||
|
||||
shareWidget->update(); /* update display */
|
||||
|
||||
}else{
|
||||
ui.contactsdockWidget->hide();
|
||||
this->resize(this->size().width() - ui.contactsdockWidget->size().width(),
|
||||
this->size().height());
|
||||
mShareList.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CreateChannel::newChannel()
|
||||
{
|
||||
/* enforce Private for the moment */
|
||||
ui.typePrivate->setChecked(true);
|
||||
|
||||
ui.typePublic->setEnabled(false);
|
||||
ui.typeEncrypted->setEnabled(false);
|
||||
|
||||
ui.msgAnon->setChecked(true);
|
||||
|
@ -84,11 +164,7 @@ void CreateChannel::createChannel()
|
|||
}
|
||||
else
|
||||
|
||||
if (ui.typePublic->isChecked())
|
||||
{
|
||||
flags |= RS_DISTRIB_PUBLIC;
|
||||
}
|
||||
else if (ui.typePrivate->isChecked())
|
||||
if (ui.typePrivate->isChecked())
|
||||
{
|
||||
flags |= RS_DISTRIB_PRIVATE;
|
||||
}
|
||||
|
@ -117,14 +193,45 @@ void CreateChannel::createChannel()
|
|||
|
||||
if (rsChannels)
|
||||
{
|
||||
rsChannels->createChannel(name.toStdWString(), desc.toStdWString(), flags, (unsigned char*)ba.data(), ba.size());
|
||||
std::string chId = rsChannels->createChannel(name.toStdWString(), desc.toStdWString(), flags, (unsigned char*)ba.data(), ba.size());
|
||||
|
||||
if(ui.pubKeyShare_cb->isChecked())
|
||||
rsChannels->channelShareKeys(chId, mShareList);
|
||||
}
|
||||
|
||||
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void CreateChannel::togglePersonItem( QTreeWidgetItem *item, int col )
|
||||
{
|
||||
|
||||
/* extract id */
|
||||
std::string id = (item -> text(1)).toStdString();
|
||||
|
||||
/* get state */
|
||||
bool checked = (Qt::Checked == item -> checkState(0)); /* alway column 0 */
|
||||
|
||||
/* call control fns */
|
||||
std::list<std::string>::iterator lit = std::find(mShareList.begin(), mShareList.end(), id);
|
||||
|
||||
if(checked && (lit == mShareList.end())){
|
||||
|
||||
// make sure ids not added already
|
||||
mShareList.push_back(id);
|
||||
|
||||
}else
|
||||
if(lit != mShareList.end()){
|
||||
|
||||
mShareList.erase(lit);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void CreateChannel::cancelChannel()
|
||||
{
|
||||
close();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue