From ed73533862f20cd313ad013d379204c02e0589b7 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 27 Apr 2010 19:07:00 +0000 Subject: [PATCH] Ported trunk commits: 2781: - fix a gui bug 2786: - The settings in the settings window are only loaded once. - Saving the settings without changing the network settings doesn't shutdown the connections 6788: - Forwarding a message keep the attached recommended files. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@2803 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/p3connmgr.cc | 25 ++++---- retroshare-gui/src/gui/MessagesDialog.cpp | 11 ++++ .../src/gui/chat/PopupChatDialog.cpp | 2 +- .../src/gui/connect/ConfCertDialog.cpp | 14 +++++ retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp | 59 +++++++++++-------- retroshare-gui/src/gui/msgs/ChanMsgDialog.h | 1 + .../src/gui/settings/rsettingswin.cpp | 21 ++++--- 7 files changed, 89 insertions(+), 44 deletions(-) diff --git a/libretroshare/src/pqi/p3connmgr.cc b/libretroshare/src/pqi/p3connmgr.cc index 5f5cfa419..c3e86ed51 100644 --- a/libretroshare/src/pqi/p3connmgr.cc +++ b/libretroshare/src/pqi/p3connmgr.cc @@ -2535,24 +2535,27 @@ bool p3ConnectMgr::setLocalAddress(std::string id, struct sockaddr_in addr) if (id == AuthSSL::getAuthSSL()->OwnId()) { + if (ownState.currentlocaladdr.sin_addr.s_addr != addr.sin_addr.s_addr || + ownState.currentlocaladdr.sin_port != addr.sin_port) { { - RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ - ownState.currentlocaladdr = addr; - //avoid 0 for port and address - if (ownState.currentlocaladdr.sin_addr.s_addr == 0) { - ownState.currentlocaladdr.sin_addr.s_addr = 1; - } - if (addr.sin_port == 0) { - ownState.currentlocaladdr.sin_port = 1; - } + RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ + ownState.currentlocaladdr = addr; + //avoid 0 for port and address + if (ownState.currentlocaladdr.sin_addr.s_addr == 0) { + ownState.currentlocaladdr.sin_addr.s_addr = 1; + } + if (addr.sin_port == 0) { + ownState.currentlocaladdr.sin_port = 1; + } } IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ if ((ownState.netMode & RS_NET_MODE_ACTUAL) == RS_NET_MODE_EXT || (ownState.netMode & RS_NET_MODE_ACTUAL) == RS_NET_MODE_UDP) { netReset(); } - return true; - } + } + return true; + } RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ /* check if it is a friend */ diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 2b3c8e371..2ba85ab1d 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -429,6 +429,17 @@ void MessagesDialog::forwardmessage() std::string cited_text(doc.toPlainText().toStdString()) ; nMsgDialog->insertForwardPastedText(cited_text) ; + + std::list& files_info = msgInfo.files; + + /* enable all files for sending */ + std::list::iterator it; + for(it = files_info.begin(); it != files_info.end(); it++) + { + it->inRecommend = true; + } + + nMsgDialog->insertFileList(files_info); //nMsgDialog->addRecipient( msgInfo.srcId ) ; nMsgDialog->show(); nMsgDialog->activateWindow(); diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 221e88fbe..602e99db7 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -859,7 +859,7 @@ void PopupChatDialog::anchorClicked (const QUrl& link ) if(!rslink.valid()) { - QMessageBox mb(tr("Badly formed RS link"), tr("This RetroShare link is malformed. This is bug. Please contact the developers."),QMessageBox::Information,QMessageBox::Ok,0,0); + QMessageBox mb(tr("Badly formed RS link"), tr("This RetroShare link is malformed. This is bug. Please contact the developers.\n\nNote: this possibly comes from a bug in Qt4.6. Try to right-click + copy link location."),QMessageBox::Information,QMessageBox::Ok,0,0); mb.setButtonText( QMessageBox::Ok, "OK" ); mb.exec(); return ; diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index 5276fadde..8a571e80a 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -260,9 +260,23 @@ void ConfCertDialog::loadDialog() ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png")); } else { ui.web_of_trust_label->setText(tr("Your trust in this peer is not set.")); + + //we have to set up the set exclusive to false in order to uncheck it all + ui.radioButton_trust_fully->setAutoExclusive(false); + ui.radioButton_trust_marginnaly->setAutoExclusive(false); + ui.radioButton_trust_never->setAutoExclusive(false); + ui.radioButton_trust_fully->setChecked(false); ui.radioButton_trust_marginnaly->setChecked(false); ui.radioButton_trust_never->setChecked(false); + + ui.radioButton_trust_fully->setAutoExclusive(true); + ui.radioButton_trust_marginnaly->setAutoExclusive(true); + ui.radioButton_trust_never->setAutoExclusive(true); + + ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png")); + ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-off-48.png")); + ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png")); } } diff --git a/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp b/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp index b931853d3..3acac56f4 100644 --- a/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp +++ b/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp @@ -60,7 +60,7 @@ /** Constructor */ ChanMsgDialog::ChanMsgDialog(bool msg, QWidget *parent, Qt::WFlags flags) -: mIsMsg(msg), QMainWindow(parent, flags), mCheckAttachment(true) +: QMainWindow(parent, flags), mIsMsg(msg), mCheckAttachment(true) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); @@ -408,41 +408,55 @@ RsCertId getSenderRsCertId(QTreeWidgetItem *i) /* get the list of peers from the RsIface. */ -void ChanMsgDialog::insertFileList(const std::list& files_info) +void ChanMsgDialog::insertFileList(const std::list& dir_info) { -// rsiface->lockData(); /* Lock Interface */ - - _recList.clear() ; - -// const std::list &recList = rsiface->getRecommendList(); + std::list files_info; std::list::const_iterator it; - /* get a link to the table */ - QTreeWidget *tree = ui.msgFileList; - - tree->clear(); - tree->setColumnCount(5); - - QList items; - for(it = files_info.begin(); it != files_info.end(); it++) + /* convert dir_info to files_info */ + for(it = dir_info.begin(); it != dir_info.end(); it++) { FileInfo info ; info.fname = it->name ; info.hash = it->hash ; info.rank = 0;//it->rank ; info.size = it->count ; - info.inRecommend = true; - _recList.push_back(info) ; + info.inRecommend = true; + files_info.push_back(info) ; + } + + insertFileList(files_info); +} + +void ChanMsgDialog::insertFileList(const std::list& files_info) +{ +// rsiface->lockData(); /* Lock Interface */ + + _recList.clear() ; + +// const std::list &recList = rsiface->getRecommendList(); + std::list::const_iterator it; + + /* get a link to the table */ + QTreeWidget *tree = ui.msgFileList; + + tree->clear(); + tree->setColumnCount(5); + + QList items; + for(it = files_info.begin(); it != files_info.end(); it++) + { + _recList.push_back(*it) ; /* make a widget per person */ QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); - item->setText(0, QString::fromStdString(it->name)); /* (0) Filename */ - item->setText(1, misc::friendlyUnit(it->count)); /* (1) Size */ + item->setText(0, QString::fromStdString(it->fname)); /* (0) Filename */ + item->setText(1, misc::friendlyUnit(it->size)); /* (1) Size */ item->setText(2, QString::number(0)) ;//it->rank)); item->setText(3, QString::fromStdString(it->hash)); item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); - item->setCheckState(0, Qt::Checked); + item->setCheckState(0, it->inRecommend ? Qt::Checked : Qt::Unchecked); /* add to the list */ items.append(item); @@ -456,7 +470,6 @@ void ChanMsgDialog::insertFileList(const std::list& files_info) tree->update(); /* update display */ } - void ChanMsgDialog::newMsg() { /* clear all */ @@ -1233,13 +1246,13 @@ void ChanMsgDialog::fileHashingFinished(AttachFileItem* file) { //convert char massageString to w_char wchar_t* message; - int requiredSize = mbstowcs(NULL, messageString, 0); // C4996 + size_t requiredSize = mbstowcs(NULL, messageString, 0); // C4996 /* Add one to leave room for the NULL terminator */ message = (wchar_t *)malloc( (requiredSize + 1) * sizeof( wchar_t )); if (! message) { std::cerr << ("Memory allocation failure.\n"); } - int size = mbstowcs( message, messageString, requiredSize + 1); // C4996 + size_t size = mbstowcs( message, messageString, requiredSize + 1); // C4996 if (size == (size_t) (-1)) { printf("Couldn't convert string--invalid multibyte character.\n"); } diff --git a/retroshare-gui/src/gui/msgs/ChanMsgDialog.h b/retroshare-gui/src/gui/msgs/ChanMsgDialog.h index 8541c8552..9b5d42b55 100644 --- a/retroshare-gui/src/gui/msgs/ChanMsgDialog.h +++ b/retroshare-gui/src/gui/msgs/ChanMsgDialog.h @@ -53,6 +53,7 @@ public: void insertSendList(); /* for Msgs */ void insertChannelSendList(); /* for Channels */ void insertFileList(const std::list&); /* for Both */ + void insertFileList(const std::list&); void insertTitleText(std::string title); void insertPastedText(std::string msg) ; void insertForwardPastedText(std::string msg); diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 3c27a402c..a14156a51 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -84,7 +84,7 @@ RSettingsWin::closeEvent (QCloseEvent * event) if (update_local) { if (_instance->stackedWidget->currentIndex() == Directories) { - ConfigPage *Page = (ConfigPage*) _instance->stackedWidget->currentWidget(); + ConfigPage *Page = dynamic_cast (_instance->stackedWidget->currentWidget()); if (Page) { Page->load(); } @@ -110,6 +110,8 @@ RSettingsWin::initStackedWidget() stackedWidget->addWidget(new SoundPage() ); #endif + loadSettings(); /* load saved settings */ + setNewPage(General); } @@ -163,7 +165,6 @@ RSettingsWin::setNewPage(int page) } pageName->setText(text); - loadSettings(); /* load saved settings */ stackedWidget->setCurrentIndex(page); listWidget->setCurrentRow(page); } @@ -171,12 +172,14 @@ RSettingsWin::setNewPage(int page) void RSettingsWin::loadSettings() { - /* Call each config page's load() method to load its data */ - int i, count = stackedWidget->count(); - for (i = 0; i < count; i++) { - ConfigPage *page = (ConfigPage *) stackedWidget->widget(i); - page->load(); - } + /* Call each config page's load() method to load its data */ + int i, count = stackedWidget->count(); + for (i = 0; i < count; i++) { + ConfigPage *page = dynamic_cast (stackedWidget->widget(i)); + if (page) { + page->load(); + } + } } /** Saves changes made to settings. */ @@ -191,7 +194,7 @@ RSettingsWin::saveChanges() { ConfigPage *page = dynamic_cast(stackedWidget->widget(i)); - if(!page->save(errmsg)) + if(page && !page->save(errmsg)) { /* Display the offending page */ stackedWidget->setCurrentWidget(page);