diff --git a/retroshare-gui/src/gui/ChannelFeed.cpp b/retroshare-gui/src/gui/ChannelFeed.cpp index 35835484e..f98842edf 100644 --- a/retroshare-gui/src/gui/ChannelFeed.cpp +++ b/retroshare-gui/src/gui/ChannelFeed.cpp @@ -321,37 +321,14 @@ void ChannelFeed::updateChannelList() } uint32_t i = 0; - uint32_t popLimit = 0; std::multimap::reverse_iterator rit; - for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++) + for(rit = popMap.rbegin(); rit != popMap.rend(); rit++) { - popIds.push_back(rit->second); - } - - if (rit != popMap.rend()) - { - popLimit = rit->first; - } - - for(it = channelList.begin(); it != channelList.end(); it++) - { - /* ignore the ones we've done already */ - uint32_t flags = it->channelFlags; - - if (flags & RS_DISTRIB_ADMIN) - { - continue; - } - else if (flags & RS_DISTRIB_SUBSCRIBED) - { - continue; - } - else - { - if (it->pop < popLimit) - { - otherIds.push_back(it->channelId); - } + if(i < popCount){ + popIds.push_back(rit->second); + i++; + }else{ + otherIds.push_back(rit->second); } } @@ -606,14 +583,25 @@ void ChannelFeed::updateChannelListOther(std::list &ids) QStandardItem *chNameItem = new QStandardItem(); QStandardItem *chPopItem = new QStandardItem(); QStandardItem *chIdItem = new QStandardItem(); + chNameItem->setSizeHint( QSize( 22,22 ) ); ChannelInfo ci; if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) { chNameItem->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole); - chPopItem->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole); + chIdItem->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole); chNameItem->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3" ).arg(QString::number(ci.pop)).arg(9999).arg(9999)); + if(ci.pngImageLen != 0){ + + QPixmap chanImage; + chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG"); + chNameItem->setData(QIcon(chanImage), Qt::DecorationRole); + }else{ + QPixmap defaulImage(CHAN_DEFAULT_IMAGE); + chNameItem->setData(QIcon(defaulImage), Qt::DecorationRole); + } + /* set Popularity icon */ int popcount = ci.pop; diff --git a/retroshare-gui/src/gui/channels/CreateChannel.cpp b/retroshare-gui/src/gui/channels/CreateChannel.cpp index 4ec38643e..927c49ca1 100644 --- a/retroshare-gui/src/gui/channels/CreateChannel.cpp +++ b/retroshare-gui/src/gui/channels/CreateChannel.cpp @@ -22,9 +22,12 @@ #include #include +#include + #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 peers; + std::list::iterator it; + + rsPeers->getFriendList(peers); + + /* get a link to the table */ + QTreeWidget *shareWidget = ui.keyShareList; + + QList 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::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(); diff --git a/retroshare-gui/src/gui/channels/CreateChannel.h b/retroshare-gui/src/gui/channels/CreateChannel.h index b4e0177f9..1a2ab23c4 100644 --- a/retroshare-gui/src/gui/channels/CreateChannel.h +++ b/retroshare-gui/src/gui/channels/CreateChannel.h @@ -52,6 +52,12 @@ void createChannel(); void cancelChannel(); void addChannelLogo(); +void setShareList(); +void togglePersonItem(QTreeWidgetItem* item, int col); + +private: + +std::list mShareList; }; diff --git a/retroshare-gui/src/gui/channels/CreateChannel.ui b/retroshare-gui/src/gui/channels/CreateChannel.ui index 461ef44a0..258536e78 100644 --- a/retroshare-gui/src/gui/channels/CreateChannel.ui +++ b/retroshare-gui/src/gui/channels/CreateChannel.ui @@ -6,10 +6,16 @@ 0 0 - 534 - 535 + 703 + 611 + + + 0 + 0 + + Create a new Channel @@ -87,7 +93,7 @@ p, li { white-space: pre-wrap; } - + QFrame::NoFrame @@ -96,7 +102,7 @@ p, li { white-space: pre-wrap; } QFrame::Raised - + @@ -110,6 +116,101 @@ p, li { white-space: pre-wrap; } + + + + true + + + + 0 + 0 + + + + + 300 + 524287 + + + + + 220 + 0 + + + + + 0 + 0 + + + + check peers you would like to share private publish key with + + + false + + + QDockWidget::NoDockWidgetFeatures + + + Share Key With + + + + + 0 + + + 0 + + + + + + 0 + 4 + + + + + 20 + 0 + + + + + 300 + 16777215 + + + + + 220 + 0 + + + + + 200 + 0 + + + + true + + + + Contacts: + + + + + + + + @@ -136,13 +237,6 @@ p, li { white-space: pre-wrap; } 6 - - - - Public - Anyone can read and publish (Shared Publish Key) - - - @@ -173,16 +267,16 @@ p, li { white-space: pre-wrap; } 6 - + - Authemticated Messages + Anonymous Messages - + - Anonymous Messages + Authemticated Messages @@ -202,37 +296,42 @@ p, li { white-space: pre-wrap; } - - - - Qt::Horizontal - - - - 238 - 20 - - - - - - - - Cancel - - - - - - - Create - - - true - - - + + + Key Sharing + + + + 0 + + + 6 + + + + + Share Private Publish Key + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Channel Logo @@ -345,6 +444,36 @@ border-radius: 10px; + + + + Qt::Horizontal + + + + 238 + 20 + + + + + + + + Cancel + + + + + + + Create + + + true + + + diff --git a/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.cpp b/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.cpp index 74f219330..1ddf8efbb 100644 --- a/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.cpp +++ b/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.cpp @@ -41,7 +41,6 @@ #define BLOG_DEFAULT_IMAGE ":/images/hi64-app-kblogger.png" - /** Constructor */ BlogsDialog::BlogsDialog(QWidget *parent) : MainPage (parent) @@ -506,6 +505,7 @@ void BlogsDialog::updateBlogMsgs() } iconLabel->setEnabled(true); + /* set textcolor for Blog name */ QString blogStr("