From 7e3a342a9a45d125dc5435d20a12ba5726641194 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Tue, 11 Oct 2011 23:29:38 +0000 Subject: [PATCH] Fixed utf8 issues (Patch from Asamk #3393353) SearchDialog: enable search for strings containing utf8 characters, I assume that filenames are always stored as utf8 on all platforms ConnectFriendWizard: adding friends with gpg key or from file, now sets location name correctly notifyqt: setting status message in chatwindow works correctly now, when a friend changes his message while the chat window is open git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4635 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/SearchDialog.cpp | 6 ++-- retroshare-gui/src/gui/msgs/MessageWidget.cpp | 6 ++-- retroshare-gui/src/gui/notifyqt.cpp | 28 +++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/retroshare-gui/src/gui/SearchDialog.cpp b/retroshare-gui/src/gui/SearchDialog.cpp index e00e55d4e..fefd11257 100644 --- a/retroshare-gui/src/gui/SearchDialog.cpp +++ b/retroshare-gui/src/gui/SearchDialog.cpp @@ -338,7 +338,7 @@ void SearchDialog::download() std::string hash = item->text(SR_HASH_COL).toStdString(); getSourceFriendsForHash(hash,srcIds) ; - if(!rsFiles -> FileRequest((item->text(SR_NAME_COL)).toStdString(), hash, (item->text(SR_SIZE_COL)).toULongLong(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) + if(!rsFiles -> FileRequest((item->text(SR_NAME_COL)).toUtf8().constData(), hash, (item->text(SR_SIZE_COL)).toULongLong(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) attemptDownloadLocal = true ; else { @@ -366,10 +366,10 @@ void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString getSourceFriendsForHash(hash,srcIds) ; - rsFiles->FileRequest(item->text(SR_NAME_COL).toStdString(), + rsFiles->FileRequest(item->text(SR_NAME_COL).toUtf8().constData(), hash, item->text(SR_SIZE_COL).toULongLong(), - cleanPath.toStdString(),RS_FILE_HINTS_NETWORK_WIDE, srcIds); + cleanPath.toUtf8().constData(),RS_FILE_HINTS_NETWORK_WIDE, srcIds); std::cout << "SearchDialog::downloadDirectory(): "\ "issuing file request from search dialog: -" diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index d20118c42..5ec4be72f 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -271,7 +271,7 @@ void MessageWidget::getcurrentrecommended() switch (it->column()) { case COLUMN_FILE_NAME: - fi.fname = it->data().toString().toStdString() ; + fi.fname = it->data().toString().toUtf8().constData(); break ; case COLUMN_FILE_SIZE: fi.size = it->data().toULongLong() ; @@ -287,7 +287,7 @@ void MessageWidget::getcurrentrecommended() std::cout << "Requesting file " << fi.fname << ", size=" << fi.size << ", hash=" << fi.hash << std::endl ; if (rsFiles->FileRequest(fi.fname, fi.hash, fi.size, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds) == false) { - QMessageBox mb(QObject::tr("File Request canceled"), QObject::tr("The following has not been added to your download list, because you already have it:\n ") + QString::fromStdString(fi.fname), QMessageBox::Critical, QMessageBox::Ok, 0, 0); + QMessageBox mb(QObject::tr("File Request canceled"), QObject::tr("The following has not been added to your download list, because you already have it:\n ") + QString::fromUtf8(fi.fname.c_str()), QMessageBox::Critical, QMessageBox::Ok, 0, 0); mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); mb.exec(); } @@ -436,7 +436,7 @@ void MessageWidget::fill(const std::string &msgId) QList items; for (it = recList.begin(); it != recList.end(); it++) { QTreeWidgetItem *item = new QTreeWidgetItem; - item->setText(COLUMN_FILE_NAME, QString::fromStdString(it->fname)); + item->setText(COLUMN_FILE_NAME, QString::fromUtf8(it->fname.c_str())); item->setText(COLUMN_FILE_SIZE, QString::number(it->size)); item->setText(COLUMN_FILE_HASH, QString::fromStdString(it->hash)); diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 07f25124d..35bd51ff8 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -192,9 +192,9 @@ void NotifyQt::notifyPeerStatusChanged(const std::string& peer_id, uint32_t stat /* one or more peers has changed the states */ void NotifyQt::notifyPeerStatusChangedSummary() { - #ifdef NOTIFY_DEBUG +#ifdef NOTIFY_DEBUG std::cerr << "Notifyqt:: notified that one peer has changed the state" << std::endl; - #endif +#endif emit peerStatusChangedSummary(); } @@ -206,41 +206,41 @@ void NotifyQt::notifyChannelMsgReadSatusChanged(const std::string& channelId, co void NotifyQt::notifyOwnStatusMessageChanged() { - #ifdef NOTIFY_DEBUG +#ifdef NOTIFY_DEBUG std::cerr << "Notifyqt:: notified that own avatar changed" << std::endl ; - #endif +#endif emit ownStatusMessageChanged() ; } void NotifyQt::notifyPeerHasNewAvatar(std::string peer_id) { - #ifdef NOTIFY_DEBUG +#ifdef NOTIFY_DEBUG std::cerr << "notifyQt: notification of new avatar." << std::endl ; - #endif +#endif emit peerHasNewAvatar(QString::fromStdString(peer_id)) ; } void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& status_string) { - #ifdef NOTIFY_DEBUG +#ifdef NOTIFY_DEBUG std::cerr << "notifyQt: Received custom status string notification" << std::endl ; - #endif - emit peerHasNewCustomStateString(QString::fromStdString(peer_id), QString::fromStdString(status_string)) ; +#endif + emit peerHasNewCustomStateString(QString::fromStdString(peer_id), QString::fromUtf8(status_string.c_str())) ; } void NotifyQt::notifyChatStatus(const std::string& peer_id,const std::string& status_string,bool is_private) { - #ifdef NOTIFY_DEBUG +#ifdef NOTIFY_DEBUG std::cerr << "notifyQt: Received chat status string: " << status_string << std::endl ; - #endif - emit chatStatusChanged(QString::fromStdString(peer_id),QString::fromStdString(status_string),is_private) ; +#endif + emit chatStatusChanged(QString::fromStdString(peer_id),QString::fromUtf8(status_string.c_str()),is_private) ; } void NotifyQt::notifyTurtleSearchResult(uint32_t search_id,const std::list& files) { - #ifdef NOTIFY_DEBUG +#ifdef NOTIFY_DEBUG std::cerr << "in notify search result..." << std::endl ; - #endif +#endif for(std::list::const_iterator it(files.begin());it!=files.end();++it) {