diff --git a/retroshare-gui/src/gui/channels/CreateChannel.cpp b/retroshare-gui/src/gui/channels/CreateChannel.cpp index 927c49ca1..0192eb218 100644 --- a/retroshare-gui/src/gui/channels/CreateChannel.cpp +++ b/retroshare-gui/src/gui/channels/CreateChannel.cpp @@ -142,7 +142,7 @@ void CreateChannel::newChannel() /* enforce Private for the moment */ ui.typePrivate->setChecked(true); - ui.typeEncrypted->setEnabled(false); + ui.typeEncrypted->setEnabled(true); ui.msgAnon->setChecked(true); ui.msgAuth->setEnabled(false); @@ -243,20 +243,9 @@ void CreateChannel::addChannelLogo() QString fileName = QFileDialog::getOpenFileName(this, "Load File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)"); if(!fileName.isEmpty()) { - picture = QPixmap(fileName).scaled(64,64, Qt::IgnoreAspectRatio); - - // to show the selected - ui.ChannelLogoButton->setIcon(picture); - - std::cerr << "Sending avatar image down the pipe" << std::endl ; - - // send avatar down the pipe for other peers to get it. - QByteArray ba; - QBuffer buffer(&ba); - buffer.open(QIODevice::WriteOnly); - picture.save(&buffer, "PNG"); // writes image into ba in PNG format - - std::cerr << "Image size = " << ba.size() << std::endl ; + picture = QPixmap(fileName).scaled(64,64, Qt::IgnoreAspectRatio); + // to show the selected + ui.ChannelLogoButton->setIcon(picture); } } diff --git a/retroshare-gui/src/gui/channels/ShareKey.cpp b/retroshare-gui/src/gui/channels/ShareKey.cpp new file mode 100644 index 000000000..75de4f51b --- /dev/null +++ b/retroshare-gui/src/gui/channels/ShareKey.cpp @@ -0,0 +1,183 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2010 Christopher Evi-Parker + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include "ShareKey.h" + +#include +#include + +#include "rsiface/rschannels.h" +#include "rsiface/rspeers.h" + +ShareKey::ShareKey(QWidget *parent, Qt::WFlags flags, std::string chanId) : + QDialog(parent, flags), mChannelId(chanId) +{ + ui = new Ui::ShareKey(); + ui->setupUi(this); + + + connect( ui->shareButton, SIGNAL( clicked ( bool ) ), this, SLOT( shareKey( ) ) ); + connect( ui->cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancel( ) ) ); + + connect(ui->keyShareList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ), + this, SLOT(togglePersonItem( QTreeWidgetItem *, int ) )); + + setShareList(); + +} + + +ShareKey::~ShareKey() +{ + delete ui; +} + +void ShareKey::closeEvent (QCloseEvent * event) +{ + QWidget::closeEvent(event); +} + +void ShareKey::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void ShareKey::shareKey() +{ + + if(!rsChannels) + return; + + if(mShareList.empty()) + { + QMessageBox::warning(this, tr("RetroShare"),tr("Please select at least one peer"), + QMessageBox::Ok, QMessageBox::Ok); + + return; + } + + if(!rsChannels->channelShareKeys(mChannelId, mShareList)){ + + std::cerr << "Failed to share keys!" << std::endl; + + return; + } + + close(); + return; +} + +void ShareKey::cancel() +{ + close(); + return; +} + +void ShareKey::setShareList(){ + + 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 */ + +} + +void ShareKey::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; +} + diff --git a/retroshare-gui/src/gui/channels/ShareKey.h b/retroshare-gui/src/gui/channels/ShareKey.h new file mode 100644 index 000000000..b8b6456e1 --- /dev/null +++ b/retroshare-gui/src/gui/channels/ShareKey.h @@ -0,0 +1,43 @@ +#ifndef SHAREKEY_H +#define SHAREKEY_H + +#include + +#include "ui_ShareKey.h" + + +class ShareKey : public QDialog { + Q_OBJECT +public: + /* + *@param chanId The channel id to send request for + */ + ShareKey(QWidget *parent = 0, Qt::WFlags flags = 0, std::string chanId = ""); + ~ShareKey(); + + + +protected: + void changeEvent(QEvent *e); + void closeEvent (QCloseEvent * event); + +private: + + void setShareList(); + + Ui::ShareKey *ui; + + std::string mChannelId; + std::list mShareList; + + +private slots: + + void shareKey(); + void cancel(); + void togglePersonItem(QTreeWidgetItem* item, int col); + + +}; + +#endif // SHAREKEY_H diff --git a/retroshare-gui/src/gui/channels/ShareKey.ui b/retroshare-gui/src/gui/channels/ShareKey.ui new file mode 100644 index 000000000..ed9202282 --- /dev/null +++ b/retroshare-gui/src/gui/channels/ShareKey.ui @@ -0,0 +1,211 @@ + + + ShareKey + + + + 0 + 0 + 241 + 327 + + + + Share Key + + + + 0 + + + 0 + + + + + + + + 239 + 49 + + + + background-color: rgb(255, 255, 255); +background-image: url(:/images/connect/connectFriendBanner.png); + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:18pt; font-weight:600; color:#ffffff;">Share Key</span></p></body></html> + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 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: + + + + + + + + + + + + QLayout::SetDefaultConstraint + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Share + + + + + + + Cancel + + + + + + + + + + + + +