diff --git a/.gitignore b/.gitignore index ecf9f7099..9a8091201 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ Makefile* Thumbs.db *.pro.user .kdev4 -*.kdev4 +*.kdev4 \ No newline at end of file diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 96f287425..da167a9c5 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -509,6 +509,7 @@ HEADERS += util/folderiterator.h \ util/stacktrace.h \ util/rsdeprecate.h \ util/cxx11retrocompat.h \ + util/cxx17retrocompat.h \ util/rsurl.h SOURCES += ft/ftchunkmap.cc \ diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index eced429a4..564eb44b8 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -1170,8 +1170,8 @@ bool p3PeerMgrIMPL::addSslOnlyFriend( * previously known IP addresses */ if(!dt.isHiddenNode) { - for(const std::string& locator : dt.ipAddressList) - addPeerLocator(sslId, locator); + for(const std::string& ipStr : dt.ipAddressList) + addPeerLocator(sslId, RsUrl(ipStr)); if(dt.extPort && !dt.extAddr.empty()) { diff --git a/libretroshare/src/retroshare/rsflags.h b/libretroshare/src/retroshare/rsflags.h index 51e91e9a1..cdea3f5be 100644 --- a/libretroshare/src/retroshare/rsflags.h +++ b/libretroshare/src/retroshare/rsflags.h @@ -3,7 +3,8 @@ * * * libretroshare: retroshare core library * * * - * Copyright 2012-2019 by Retroshare Team * + * Copyright (C) 2012-2019 by Retroshare Team * + * Copyright (C) 2019 Gioacchino Mazzurco * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -21,18 +22,129 @@ *******************************************************************************/ #pragma once +#include +#include + +/** Check if given type is a scoped enum */ +template +using rs_is_scoped_enum = std::integral_constant< bool, + std::is_enum::value && !std::is_convertible::value >; + +/** + * @brief Register enum class as flags type + * To use this macro define a scoped enum with your flag values, then register + * it as flags type passing it as parameter of this macro. + * The result will be type safe flags, that cannot be mixed up with flag of a + * different type, but that are very comfortable to operate like plain old + * integers. + * This macro support flag fields of different lenght depending on what + * underlining type (usually from uint8_t up to uint64_t) has been declared for + * the enum class. + * If you plan to serialize those flags it is important to specify the + * underlining type of the enum otherwise different compilers may serialize a + * flag variable with different lenght, potentially causing interoperability + * issues between differents builds. + * Usage example: +@code{.cpp} +enum class RsGrouterItemFlags : uint32_t +{ + NONE = 0x0, + ENCRYPTED = 0x1, + SERVICE_UNKNOWN = 0x2 +}; +RS_REGISTER_ENUM_FLAGS_TYPE(RsGrouterItemFlags) +@endcode + */ +#define RS_REGISTER_ENUM_FLAGS_TYPE(eft) \ +template<> struct Rs__BitFlagsOps \ +{ \ + static_assert( std::is_enum::value, \ + "Are you trying to register a non-enum type as flags?" ); \ + static_assert( rs_is_scoped_enum::value, \ + "Are you trying to register an unscoped enum as flags?" ); \ + static constexpr bool enabled = true; \ +}; + +// By defaults types are not valid flags, so bit flags operators are disabled +template struct Rs__BitFlagsOps +{ static constexpr bool enabled = false; }; + +template +typename std::enable_if::enabled, EFT>::type +/*EFT*/ operator &(EFT lhs, EFT rhs) +{ + using u_t = typename std::underlying_type::type; + return static_cast(static_cast(lhs) & static_cast(rhs)); +} + +template +typename std::enable_if::enabled, EFT>::type +/*EFT*/ operator &=(EFT& lhs, EFT rhs) { lhs = lhs & rhs; return lhs; } + +template +typename std::enable_if::enabled, EFT>::type +/*EFT*/ operator |(EFT lhs, EFT rhs) +{ + using u_t = typename std::underlying_type::type; + return static_cast(static_cast(lhs) | static_cast(rhs)); +} + +template +typename std::enable_if::enabled, EFT>::type +/*EFT*/ operator |=(EFT& lhs, EFT rhs) { lhs = lhs | rhs; return lhs; } + + +template +typename std::enable_if::enabled, EFT>::type +/*EFT*/ operator ^(EFT lhs, EFT rhs) +{ + using u_t = typename std::underlying_type::type; + return static_cast(static_cast(lhs) ^ static_cast(rhs)); +} + +template +typename std::enable_if::enabled, EFT>::type +/*EFT*/ operator ^=(EFT& lhs, EFT rhs) { lhs = lhs ^ rhs; return lhs; } + +template +typename std::enable_if::enabled, EFT>::type +operator ~(EFT val) +{ + using u_t = typename std::underlying_type::type; + return static_cast(~static_cast(val)); +} + +template +typename std::enable_if::enabled, bool>::type +operator !(EFT val) +{ + using u_t = typename std::underlying_type::type; + return static_cast(val) == 0; +} + +/// Nicely print flags bits as 1 and 0 +template +typename std::enable_if::enabled, std::ostream>::type& +operator <<(std::ostream& stream, EFT flags) +{ + using u_t = typename std::underlying_type::type; + + for(int i = sizeof(u_t); i>=0; --i) + { + stream << (flags & ( 1 << i ) ? "1" : "0"); + if( i % 8 == 0 ) stream << " "; + } + return stream; +} + #include +#include "util/rsdeprecate.h" -/* G10h4ck: TODO we should redefine flags in a way that the flag declaration and - * the flags values (bit fields) would be strongly logically linked. - * A possible way is to take an enum class containing the names of each - * bitfield and corresponding value as template parameter, this way would also - * avoid the need of dumb template parameter that is used only to make the - * types incompatible but that doesn't help finding what are the possible values - * for a kind of flag. Another appealing approach seems the first one described - * here https://softwareengineering.stackexchange.com/questions/194412/using-scoped-enums-for-bit-flags-in-c - * a few simple macros could be used instead of the template class */ +/** + * @deprecated t_RsFlags32 has been deprecated because the newer + * @see RS_REGISTER_ENUM_FLAGS_TYPE provide more convenient flags facilities. + * // This class provides a representation for flags that can be combined with bitwise // operations. However, because the class is templated with an id, it's not possible to // mixup flags belonging to different classes. This avoids many bugs due to confusion of flags types @@ -51,7 +163,8 @@ // - an explicit constructor from uint32_t // - an implicit bool operator, that allows test like if(flags & FLAGS_VALUE) // -template class t_RsFlags32 +*/ +template class RS_DEPRECATED_FOR(RS_REGISTER_ENUM_FLAGS_TYPE) t_RsFlags32 { public: inline t_RsFlags32() : _bits(0) {} diff --git a/libretroshare/src/util/cxx17retrocompat.h b/libretroshare/src/util/cxx17retrocompat.h new file mode 100644 index 000000000..58cdfe84c --- /dev/null +++ b/libretroshare/src/util/cxx17retrocompat.h @@ -0,0 +1,35 @@ +/******************************************************************************* + * libretroshare/src/util: cxx17retrocompat.h * + * * + * libretroshare: retroshare core library * + * * + * Copyright (C) 2019 Gioacchino Mazzurco * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 3 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#pragma once + +#if __cplusplus < 201703L + +#include + +namespace std +{ +using namespace std; +template constexpr typename add_const::type& as_const(T& t) noexcept +{ return t; } +template void as_const(const T&&) = delete; +} +#endif // __cplusplus < 201703L diff --git a/libretroshare/src/util/rsmemory.h b/libretroshare/src/util/rsmemory.h index 8bbbc335a..01dc4d8d8 100644 --- a/libretroshare/src/util/rsmemory.h +++ b/libretroshare/src/util/rsmemory.h @@ -62,6 +62,35 @@ bool myFunnyFunction( */ #define RS_DEFAULT_STORAGE_PARAM(Type,...) *std::unique_ptr(new Type(__VA_ARGS__)) + +/** @brief Safely dynamic cast between std::unique_ptr of different types + * std::unique_ptr semantic rely on the invariant that only one instance own + * the object, when casting between differents types one would be tempted to do + * it in a one liner that easly end up breaking that condition ending up in a + * double delete and crash or in a silent memleak. + * With this function one can do that with same comfort of a plain dynamic_cast, + * plus the std::unique_ptr safety. + * @param[inout] src reference to source pointer. If the cast is successfull it + * is released, otherwise it is left untouched. + * @param[out] dst reference to destination pointer. If the cast is successful + * it get reseated to the object address, otherwise it is left untouched. + * @return true on success, false otherwise + */ +template +bool rs_unique_cast( + std::unique_ptr& src, std::unique_ptr& dst ) +{ + T_DST* dstPtr = dynamic_cast(src.get()); + if(dstPtr) + { + src.release(); + dst.reset(dstPtr); + return true; + } + return false; +} + + void *rs_malloc(size_t size) ; // This is a scope guard to release the memory block when going of of the current scope. diff --git a/libretroshare/src/util/rsurl.cc b/libretroshare/src/util/rsurl.cc index e625815e4..dd01d7384 100644 --- a/libretroshare/src/util/rsurl.cc +++ b/libretroshare/src/util/rsurl.cc @@ -1,6 +1,6 @@ /* * RetroShare - * Copyright (C) 2018 Gioacchino Mazzurco + * Copyright (C) 2018-2019 Gioacchino Mazzurco * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -17,15 +17,16 @@ */ -#include "rsurl.h" -#include "serialiser/rstypeserializer.h" - #include #include #include #include #include +#include "rsurl.h" +#include "serialiser/rstypeserializer.h" +#include "util/rsnet.h" + using namespace std; RsUrl::RsUrl() : mPort(0), mHasPort(false) {} @@ -33,6 +34,26 @@ RsUrl::RsUrl() : mPort(0), mHasPort(false) {} RsUrl::RsUrl(const std::string& urlStr) : mPort(0), mHasPort(false) { fromString(urlStr); } +RsUrl::RsUrl(const sockaddr_storage& addr): mPort(0), mHasPort(false) +{ + switch(addr.ss_family) + { + case AF_INET: setScheme("ipv4"); break; + case AF_INET6: setScheme("ipv6"); break; + default: + { + std::string addrDump; + sockaddr_storage_dump(addr, &addrDump); + RsErr() << __PRETTY_FUNCTION__ << " got invalid addr: " << addrDump + << std::endl; + return; + } + } + + setHost(sockaddr_storage_iptostring(addr)); + setPort(sockaddr_storage_port(addr)); +} + RsUrl& RsUrl::fromString(const std::string& urlStr) { size_t endI = urlStr.size()-1; @@ -55,7 +76,7 @@ RsUrl& RsUrl::fromString(const std::string& urlStr) { if(++hostBeginI >= endI) return *this; hostEndI = urlStr.find(ipv6WrapClose, hostBeginI); - mHost = urlStr.substr(hostBeginI, hostEndI - hostBeginI - 1); + mHost = urlStr.substr(hostBeginI, hostEndI - hostBeginI); ++hostEndI; } else @@ -250,10 +271,10 @@ RsUrl& RsUrl::setFragment(const std::string& fragment) size_t boundary = len-2; // % Encoded char must be at least 2 hex char for (size_t i = 0; i < len; ++i) { - if(str[i] == '%' && i < boundary) { - decoded << static_cast(std::stoi(str.substr(++i, 2), 0, 16)); + decoded << static_cast(std::stoi( + str.substr(++i, 2), nullptr, 16 )); ++i; } else decoded << str[i]; diff --git a/libretroshare/src/util/rsurl.h b/libretroshare/src/util/rsurl.h index f02c7f636..0610585c5 100644 --- a/libretroshare/src/util/rsurl.h +++ b/libretroshare/src/util/rsurl.h @@ -22,6 +22,8 @@ #include "serialiser/rsserializable.h" +struct sockaddr_storage; + /** * Very simplistic and minimal URL helper class for RetroShare, after looking * for a small and self-contained C/C++ URL parsing and manipulation library, @@ -36,7 +38,8 @@ struct RsUrl : RsSerializable { RsUrl(); - RsUrl(const std::string& urlStr); + explicit RsUrl(const std::string& urlStr); + explicit RsUrl(const sockaddr_storage& ssas); RsUrl& fromString(const std::string& urlStr); std::string toString() const; diff --git a/retroshare-gui/src/Info.plist b/retroshare-gui/src/Info.plist index 1dfea76cf..93b6d131a 100755 --- a/retroshare-gui/src/Info.plist +++ b/retroshare-gui/src/Info.plist @@ -44,5 +44,6 @@ + NSRequiresAquaSystemAppearance diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index dea3ea4e2..884355d87 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -71,14 +71,14 @@ #define IMAGE_CREATE "" #define IMAGE_PUBLIC ":/icons/png/chats.png" #define IMAGE_PRIVATE ":/icons/png/chats-private.png" -#define IMAGE_SUBSCRIBE ":/images/edit_add24.png" -#define IMAGE_UNSUBSCRIBE ":/images/cancel.png" +#define IMAGE_SUBSCRIBE ":/icons/png/enter.png" +#define IMAGE_UNSUBSCRIBE ":/icons/png/leave2.png" #define IMAGE_PEER_ENTERING ":images/user/add_user24.png" #define IMAGE_PEER_LEAVING ":images/user/remove_user24.png" -#define IMAGE_TYPING ":images/typing.png" +#define IMAGE_TYPING ":images/typing.png" #define IMAGE_MESSAGE ":images/chat.png" #define IMAGE_AUTOSUBSCRIBE ":images/accepted16.png" -#define IMAGE_COPYRSLINK ":/images/copyrslink.png" +#define IMAGE_COPYRSLINK ":/icons/png/copy.png" ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) : RsAutoUpdatePage(5000, parent, flags) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index e410ff215..72d422db0 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -121,8 +121,11 @@ #include #define IMAGE_QUIT ":/icons/png/exit.png" -#define IMAGE_PREFERENCES ":/icons/png/options.png" +#define IMAGE_PREFERENCES ":/icons/png/options2.png" #define IMAGE_ABOUT ":/icons/png/info.png" +#define IMAGE_STATS ":/icons/png/netgraph2.png" +#define IMAGE_CLOSE ":/icons/png/exit2.png" + #define IMAGE_ADDFRIEND ":/icons/png/invite.png" #define IMAGE_RETROSHARE ":/icons/logo_128.png" #define IMAGE_NOONLINE ":/icons/logo_0_connected_128.png" @@ -130,9 +133,8 @@ #define IMAGE_TWOONLINE ":/icons/logo_2_connected_128.png" #define IMAGE_OVERLAY ":/icons/star_overlay_128.png" -#define IMAGE_BWGRAPH ":/images/ksysguard.png" +#define IMAGE_BWGRAPH ":/icons/png/bandwidth.png" #define IMAGE_MESSENGER ":/images/rsmessenger48.png" -#define IMAGE_CLOSE ":/images/close_normal.png" #define IMAGE_BLOCK ":/images/blockdevice.png" #define IMAGE_COLOR ":/images/highlight.png" #define IMAGE_GAMES ":/images/kgames.png" @@ -146,7 +148,6 @@ #define IMAGE_PLUGINS ":/images/extension_32.png" #define IMAGE_BLOGS ":/images/kblogger.png" -#define IMAGE_DHT ":/images/dht16.png" /*static*/ bool MainWindow::hiddenmode = false; @@ -609,7 +610,7 @@ void MainWindow::createTrayIcon() trayMenu->addAction(QIcon(":/images/emblem-web.png"), tr("Show web interface"), this, SLOT(showWebinterface())); #endif trayMenu->addAction(QIcon(IMAGE_BWGRAPH), tr("Bandwidth Graph"), this, SLOT(showBandwidthGraph())); - trayMenu->addAction(QIcon(IMAGE_DHT), tr("Statistics"), this, SLOT(showStatisticsWindow())); + trayMenu->addAction(QIcon(IMAGE_STATS), tr("Statistics"), this, SLOT(showStatisticsWindow())); #ifdef UNFINISHED diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index da04f457a..d5bbc3d2b 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -132,8 +132,8 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi // Add a button to invite friends. // inviteFriendsButton = new QToolButton ; - inviteFriendsButton->setMinimumSize(icon_size); - inviteFriendsButton->setMaximumSize(icon_size); + //inviteFriendsButton->setMinimumSize(icon_size); + //inviteFriendsButton->setMaximumSize(icon_size); inviteFriendsButton->setText(QString()) ; inviteFriendsButton->setAutoRaise(true) ; inviteFriendsButton->setToolTip(tr("Invite friends to this lobby")); @@ -177,8 +177,8 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi connect(ownIdChooser,SIGNAL(currentIndexChanged(int)),this,SLOT(changeNickname())) ; unsubscribeButton = new QToolButton; - unsubscribeButton->setMinimumSize(icon_size); - unsubscribeButton->setMaximumSize(icon_size); + //unsubscribeButton->setMinimumSize(icon_size); + //unsubscribeButton->setMaximumSize(icon_size); unsubscribeButton->setText(QString()) ; unsubscribeButton->setAutoRaise(true) ; unsubscribeButton->setToolTip(tr("Leave this chat room (Unsubscribe)")); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 94fca3d99..326a95d4a 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -92,26 +92,26 @@ ChatWidget::ChatWidget(QWidget *parent) lastMsgDate = QDate::currentDate(); //Resize Tool buttons - ui->emoteiconButton->setFixedSize(buttonSize); + //ui->emoteiconButton->setFixedSize(buttonSize); ui->emoteiconButton->setIconSize(iconSize); - ui->stickerButton->setFixedSize(buttonSize); + //ui->stickerButton->setFixedSize(buttonSize); ui->stickerButton->setIconSize(iconSize); - ui->attachPictureButton->setFixedSize(buttonSize); + //ui->attachPictureButton->setFixedSize(buttonSize); ui->attachPictureButton->setIconSize(iconSize); - ui->addFileButton->setFixedSize(buttonSize); + //ui->addFileButton->setFixedSize(buttonSize); ui->addFileButton->setIconSize(iconSize); - ui->pushtoolsButton->setFixedSize(buttonSize); + //ui->pushtoolsButton->setFixedSize(buttonSize); ui->pushtoolsButton->setIconSize(iconSize); - ui->notifyButton->setFixedSize(buttonSize); + //ui->notifyButton->setFixedSize(buttonSize); ui->notifyButton->setIconSize(iconSize); - ui->markButton->setFixedSize(buttonSize); + //ui->markButton->setFixedSize(buttonSize); ui->markButton->setIconSize(iconSize); ui->leSearch->setFixedHeight(iconHeight); ui->searchBefore->setFixedHeight(iconHeight); ui->searchAfter->setFixedHeight(iconHeight); - ui->searchButton->setFixedSize(buttonSize); + //ui->searchButton->setFixedSize(buttonSize); ui->searchButton->setIconSize(iconSize); - ui->sendButton->setFixedHeight(iconHeight); + //ui->sendButton->setFixedHeight(iconHeight); ui->sendButton->setIconSize(iconSize); ui->typingLabel->setMaximumHeight(QFontMetricsF(font()).height()*1.2); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.ui b/retroshare-gui/src/gui/chat/ChatWidget.ui index a7af7c79f..144eeae6f 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.ui +++ b/retroshare-gui/src/gui/chat/ChatWidget.ui @@ -332,6 +332,9 @@ border-image: url(:/images/closepressed.png) QFrame::Sunken + + 3 + 2 @@ -804,17 +807,20 @@ border-image: url(:/images/closepressed.png) QFrame::Plain + + 3 + 2 - 2 + 0 2 - 2 + 0 diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index e71750ac0..7ea64e7b5 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -80,9 +80,6 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) : mTitleFontSize = 0; // Standard mTitleFontWeight = 0; // Standard - - // (csoler) I'm hiding this, since it is not needed anymore with the new Home page. - ui->userFrame->hide(); // ui->userFileFrame->hide(); // in homepage dropmenu now @@ -138,7 +135,6 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) : } else { - ui->userFrame->hide(); // certificates page - top half with own cert and it's functions ui->cp_Frame->hide(); // Advanced options - key sign, whitelist, direct source ... AdvancedVisible=false; ui->trustLabel->hide(); @@ -302,6 +298,7 @@ void ConnectFriendWizard::setCertificate(const QString &certificate, bool friend ui->requestinfolabel->show(); setTitleText(ui->ConclusionPage, tr("Friend request")); ui->ConclusionPage->setSubTitle(tr("Details about the request")); + setButtonText(QWizard::FinishButton , tr("Accept")); } } } @@ -326,6 +323,7 @@ void ConnectFriendWizard::setCertificate(const QString &certificate, bool friend ui->requestinfolabel->show(); setTitleText(ui->ConclusionPage, tr("Friend request")); ui->ConclusionPage->setSubTitle(tr("Details about the request")); + setButtonText(QWizard::FinishButton , tr("Accept")); } } } @@ -351,10 +349,11 @@ void ConnectFriendWizard::setGpgId(const RsPgpId &gpgId, const RsPeerId &sslId, //setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion); setStartId(Page_Conclusion); if (friendRequest){ - ui->cp_Label->show(); - ui->requestinfolabel->show(); - setTitleText(ui->ConclusionPage,tr("Friend request")); - ui->ConclusionPage->setSubTitle(tr("Details about the request")); + ui->cp_Label->show(); + ui->requestinfolabel->show(); + setTitleText(ui->ConclusionPage,tr("Friend request")); + ui->ConclusionPage->setSubTitle(tr("Details about the request")); + setButtonText(QWizard::FinishButton , tr("Accept")); } } @@ -383,14 +382,9 @@ void ConnectFriendWizard::initializePage(int id) { switch ((Page) id) { case Page_Text: - connect(ui->userCertHelpButton, SIGNAL( clicked()), this, SLOT(showHelpUserCert())); - connect(ui->userCertIncludeSignaturesButton, SIGNAL(clicked()), this, SLOT(toggleSignatureState())); - connect(ui->userCertOldFormatButton, SIGNAL(clicked()), this, SLOT(toggleFormatState())); - connect(ui->userCertCopyButton, SIGNAL(clicked()), this, SLOT(copyCert())); + connect(ui->userCertPasteButton, SIGNAL(clicked()), this, SLOT(pasteCert())); connect(ui->userCertOpenButton, SIGNAL(clicked()), this, SLOT(openCert())); - connect(ui->userCertSaveButton, SIGNAL(clicked()), this, SLOT(saveCert())); - connect(ui->userCertMailButton, SIGNAL(clicked()), this, SLOT(runEmailClient())); connect(ui->friendCertEdit, SIGNAL(textChanged()), this, SLOT(friendCertChanged())); cleanfriendCertTimer = new QTimer(this); @@ -398,13 +392,6 @@ void ConnectFriendWizard::initializePage(int id) cleanfriendCertTimer->setInterval(1000); // 1 second connect(cleanfriendCertTimer, SIGNAL(timeout()), this, SLOT(cleanFriendCert())); - ui->userCertOldFormatButton->setChecked(false); - ui->userCertOldFormatButton->hide() ; - - toggleFormatState(true); - toggleSignatureState(false); - updateOwnCert(); - cleanFriendCert(); break; @@ -780,52 +767,6 @@ void ConnectFriendWizard::accept() //============================= TextPage ===================================== -void ConnectFriendWizard::updateOwnCert() -{ - std::string invite = rsPeers->GetRetroshareInvite( rsPeers->getOwnId(), - ui->userCertIncludeSignaturesButton->isChecked() ); - - std::cerr << "TextPage() getting Invite: " << invite << std::endl; - - ui->userCertEdit->setPlainText(QString::fromUtf8(invite.c_str())); -} - -void ConnectFriendWizard::toggleFormatState(bool doUpdate) -{ - if (ui->userCertOldFormatButton->isChecked()) - { - ui->userCertOldFormatButton->setToolTip(tr("Use new certificate format (safer, more robust)")); - ui->userCertOldFormatButton->setIcon(QIcon(":/images/ledoff1.png")) ; - } - else - { - ui->userCertOldFormatButton->setToolTip(tr("Use old (backward compatible) certificate format")); - ui->userCertOldFormatButton->setIcon(QIcon(":/images/ledon1.png")) ; - } - - if (doUpdate) { - updateOwnCert(); - } -} - -void ConnectFriendWizard::toggleSignatureState(bool doUpdate) -{ - if (ui->userCertIncludeSignaturesButton->isChecked()) { - ui->userCertIncludeSignaturesButton->setToolTip(tr("Remove signatures")); - } else { - ui->userCertIncludeSignaturesButton->setToolTip(tr("Include signatures")); - } - - if (doUpdate) { - updateOwnCert(); - } -} - -void ConnectFriendWizard::runEmailClient() -{ - sendMail("", tr("RetroShare Invite"), ui->userCertEdit->toPlainText()); -} - void ConnectFriendWizard::friendCertChanged() { ui->TextPage->setComplete(false); @@ -893,18 +834,6 @@ void ConnectFriendWizard::cleanFriendCert() ui->TextPage->setComplete(certValid); } -void ConnectFriendWizard::showHelpUserCert() -{ - QMessageBox::information(this, tr("Connect Friend Help"), tr("You can copy this text and send it to your friend via email or some other way")); -} - -void ConnectFriendWizard::copyCert() -{ - QClipboard *clipboard = QApplication::clipboard(); - clipboard->setText(ui->userCertEdit->toPlainText()); - QMessageBox::information(this, "RetroShare", tr("Your Cert is copied to Clipboard, paste and send it to your friend via email or some other way")); -} - void ConnectFriendWizard::pasteCert() { QClipboard *clipboard = QApplication::clipboard(); @@ -927,23 +856,6 @@ void ConnectFriendWizard::openCert() } } -void ConnectFriendWizard::saveCert() -{ - QString fileName = QFileDialog::getSaveFileName(this, tr("Save as..."), "", tr("RetroShare Certificate (*.rsc );;All Files (*)")); - if (fileName.isEmpty()) - return; - - QFile file(fileName); - if (!file.open(QFile::WriteOnly)) - return; - - //Todo: move save to file to p3Peers::SaveCertificateToFile - - QTextStream ts(&file); - ts.setCodec(QTextCodec::codecForName("UTF-8")); - ts << ui->userCertEdit->document()->toPlainText(); -} - #ifdef TO_BE_REMOVED //========================== CertificatePage ================================= diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.h b/retroshare-gui/src/gui/connect/ConnectFriendWizard.h index 5951fd7c2..f740da676 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.h +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.h @@ -78,16 +78,9 @@ protected: private slots: /* TextPage */ - void updateOwnCert(); - void toggleSignatureState(bool doUpdate = true); - void toggleFormatState(bool doUpdate = true); - void runEmailClient(); void runEmailClient2(); - void showHelpUserCert(); - void copyCert(); void pasteCert(); void openCert(); - void saveCert(); void friendCertChanged(); void cleanFriendCert(); diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui b/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui index 1c097627e..a950d3ceb 100644 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.ui @@ -7,7 +7,7 @@ 0 0 600 - 500 + 437 @@ -28,192 +28,6 @@ ConnectFriendWizard::Page_Text - - - - - - - - - - 20 - 20 - - - - Qt::NoFocus - - - - :/images/info16.png:/images/info16.png - - - true - - - - - - - - 20 - 20 - - - - Qt::NoFocus - - - Include signatures - - - - :/images/gpgp_key_generate.png:/images/gpgp_key_generate.png - - - true - - - true - - - - - - - - 20 - 20 - - - - Qt::NoFocus - - - Copy your Cert to Clipboard - - - - :/images/copyrslink.png:/images/copyrslink.png - - - true - - - - - - - - 20 - 20 - - - - Qt::NoFocus - - - Save your Cert into a File - - - - :/images/document_save.png:/images/document_save.png - - - true - - - - - - - - 20 - 20 - - - - Qt::NoFocus - - - Run Email program - - - - :/images/mail_send.png:/images/mail_send.png - - - true - - - - - - - - 20 - 20 - - - - Qt::NoFocus - - - - :/images/ledon1.png:/images/ledon1.png - - - true - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Courier New - - - - QPlainTextEdit::NoWrap - - - true - - - 80 - - - - - - - The text below is your Retroshare ID. You have to provide it to your friend - - - - - - @@ -938,7 +752,7 @@ QFrame::Box - To accept the Friend Request, click the Finish button. + To accept the Friend Request, click the Accept button. 2 diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 66e871fd1..fa038f7fc 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "CreateGxsChannelMsg.h" #include "gui/gxs/GxsIdDetails.h" @@ -72,7 +73,8 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool))); connect(tabWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint))); connect(generateCheckBox, SIGNAL(toggled(bool)), generateSpinBox, SLOT(setEnabled(bool))); - + connect(addPictureButton, SIGNAL(clicked()), this, SLOT(addPicture())); + connect(msgEdit, SIGNAL(textChanged()), this, SLOT(checkLength())); generateSpinBox->setEnabled(false); thumbNailCb->setVisible(false); @@ -94,6 +96,26 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId #endif } +static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000; + +void CreateGxsChannelMsg::checkLength() +{ + QString text; + RsHtml::optimizeHtml(msgEdit, text); + std::wstring msg = text.toStdWString(); + int charRemains = MAX_ALLOWED_GXS_MESSAGE_SIZE - msg.length(); + if(charRemains >= 0) { + text = tr("It remains %1 characters after HTML conversion.").arg(charRemains); + infoLabel->setStyleSheet("QLabel#infoLabel { }"); + }else{ + text = tr("Warning: This message is too big of %1 characters after HTML conversion.").arg((0-charRemains)); + infoLabel->setStyleSheet("QLabel#infoLabel {color: red; font: bold; }"); + } + buttonBox->button(QDialogButtonBox::Ok)->setToolTip(text); + buttonBox->button(QDialogButtonBox::Ok)->setEnabled(charRemains>=0); + infoLabel->setText(text); +} + CreateGxsChannelMsg::~CreateGxsChannelMsg() { Settings->saveWidgetInformation(this); @@ -741,6 +763,18 @@ void CreateGxsChannelMsg::addThumbnail() thumbnail_label->setPixmap(picture); } +void CreateGxsChannelMsg::addPicture() +{ + QString file; + if (misc::getOpenFileName(window(), RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg *.jpeg)", file)) { + QString encodedImage; + if (RsHtml::makeEmbeddedImage(file, encodedImage, 640*480, MAX_ALLOWED_GXS_MESSAGE_SIZE - 200)) { + QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage); + msgEdit->textCursor().insertFragment(fragment); + } + } +} + void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token) { #ifdef DEBUG_CREATE_GXS_MSG diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h index bb8f15518..96b9dd6d3 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h @@ -69,6 +69,8 @@ private slots: void contextMenu(QPoint) ; void addThumbnail(); + void addPicture(); + void checkLength(); void allowAutoMediaThumbNail(bool); private: diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index 3f4cd7d4b..8b53c93d6 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -6,8 +6,8 @@ 0 0 - 875 - 659 + 671 + 513 @@ -96,19 +96,6 @@ - - - - <!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:'Ubuntu'; font-size:11pt; 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:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;">Attachments:</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Use Drag and Drop / Add Files button, to Hash new files.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Copy/Paste RetroShare links from your shares</span></p></body></html> - - - @@ -131,6 +118,30 @@ p, li { white-space: pre-wrap; } + + + + Add Picture + + + + :/images/add_image24.png:/images/add_image24.png + + + + + + + <!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:'Ubuntu'; font-size:11pt; 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:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;">Attachments:</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Use Drag and Drop / Add Files button, to Hash new files.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Copy/Paste RetroShare links from your shares</span></p></body></html> + + + @@ -194,6 +205,13 @@ p, li { white-space: pre-wrap; } + + + + + + + @@ -302,8 +320,8 @@ p, li { white-space: pre-wrap; } 0 0 - 767 - 42 + 812 + 24 @@ -390,17 +408,17 @@ p, li { white-space: pre-wrap; } + + MimeTextEdit + QTextEdit +
gui/common/MimeTextEdit.h
+
HeaderFrame QFrame
gui/common/HeaderFrame.h
1
- - MimeTextEdit - QTextEdit -
gui/common/MimeTextEdit.h
-
diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index abbdf8995..a7d13522a 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -80,6 +80,7 @@ icons/png/chat-lobbies.png icons/png/circles.png icons/png/empty-circle.png + icons/png/enter.png icons/png/exit.png icons/png/feedreader-notify.png icons/png/feedreader.png @@ -98,14 +99,16 @@ icons/png/invite.png icons/png/keyring.png icons/png/leave.png + icons/png/leave2.png icons/png/messages-notify.png icons/png/messages.png icons/png/microphone_mute.png icons/png/microphone.png icons/png/netgraph.png + icons/png/netgraph2.png icons/png/network-notify.png icons/png/network.png - icons/png/network2.png + icons/png/network2.png icons/png/network-puplic.png icons/png/newsfeed-notify.png icons/png/newsfeed.png @@ -271,12 +274,16 @@ icons/png/correct.png icons/png/comment.png icons/png/chats.png - icons/png/chats-private.png + icons/png/chats-private.png icons/png/fileshare.png icons/png/forum.png icons/png/message.png icons/png/newsfeed2.png icons/png/postedlinks.png icons/png/people2.png + icons/png/bandwidth.png + icons/png/netgraph2.png + icons/png/options2.png + icons/png/exit2.png diff --git a/retroshare-gui/src/gui/icons/png/bandwidth.png b/retroshare-gui/src/gui/icons/png/bandwidth.png new file mode 100644 index 000000000..e7032dbf6 Binary files /dev/null and b/retroshare-gui/src/gui/icons/png/bandwidth.png differ diff --git a/retroshare-gui/src/gui/icons/png/enter.png b/retroshare-gui/src/gui/icons/png/enter.png new file mode 100644 index 000000000..84b71ec4a Binary files /dev/null and b/retroshare-gui/src/gui/icons/png/enter.png differ diff --git a/retroshare-gui/src/gui/icons/png/exit2.png b/retroshare-gui/src/gui/icons/png/exit2.png new file mode 100644 index 000000000..102927bec Binary files /dev/null and b/retroshare-gui/src/gui/icons/png/exit2.png differ diff --git a/retroshare-gui/src/gui/icons/png/leave2.png b/retroshare-gui/src/gui/icons/png/leave2.png new file mode 100644 index 000000000..ea852a46c Binary files /dev/null and b/retroshare-gui/src/gui/icons/png/leave2.png differ diff --git a/retroshare-gui/src/gui/icons/png/netgraph2.png b/retroshare-gui/src/gui/icons/png/netgraph2.png new file mode 100644 index 000000000..8ee18c4a1 Binary files /dev/null and b/retroshare-gui/src/gui/icons/png/netgraph2.png differ diff --git a/retroshare-gui/src/gui/icons/png/options2.png b/retroshare-gui/src/gui/icons/png/options2.png new file mode 100644 index 000000000..bd113e887 Binary files /dev/null and b/retroshare-gui/src/gui/icons/png/options2.png differ diff --git a/retroshare-gui/src/gui/icons/svg/netgraph2.svg b/retroshare-gui/src/gui/icons/svg/netgraph2.svg new file mode 100644 index 000000000..518258a58 --- /dev/null +++ b/retroshare-gui/src/gui/icons/svg/netgraph2.svg @@ -0,0 +1,51 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/retroshare-gui/src/gui/icons/svg/options-blank.svg b/retroshare-gui/src/gui/icons/svg/options-blank.svg new file mode 100644 index 000000000..fbb3f6bf9 --- /dev/null +++ b/retroshare-gui/src/gui/icons/svg/options-blank.svg @@ -0,0 +1,59 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index 9eeb577f0..1671df268 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -26,7 +26,7 @@ #include "mainpage.h" #include "ui_MessagesDialog.h" -#define IMAGE_MESSAGES ":/icons/png/messages.png" +#define IMAGE_MESSAGES ":/icons/png/message.png" class RSTreeWidgetItemCompareRole; class MessageWidget; diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index b817dd9cc..6a4f04dd5 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -320,13 +320,13 @@ GenCertDialog > QFrame#headerFrame > QLabel#headerLabel { /* ConnectFriendWizard */ ConnectFriendWizard QWizardPage#ConclusionPage > QGroupBox#peerDetailsFrame { - border: 2px solid #CCCCCC; + border: 2px solid #039bd5; border-radius:6px; background: white; padding: 12 12px; } -ConnectFriendWizard QLabel#fr_label, QLabel#requestinfolabel +ConnectFriendWizard QLabel#fr_label, QLabel#requestinfolabel, QLabel#cp_Label { border: 1px solid #DCDC41; border-radius: 6px; @@ -334,6 +334,15 @@ ConnectFriendWizard QLabel#fr_label, QLabel#requestinfolabel background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); } +ConnectFriendWizard QGroupBox::title#peerDetailsFrame +{ + padding: 4 12px; + background: transparent; + padding: 4 12px; + background: #039bd5; + color: white; +} + /* Toaster */ ChatToaster > QFrame#windowFrame, diff --git a/retroshare.pri b/retroshare.pri index ffcff0520..73a1ebe3a 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -159,6 +159,7 @@ rs_macos10.10:CONFIG -= rs_macos10.11 rs_macos10.12:CONFIG -= rs_macos10.11 rs_macos10.13:CONFIG -= rs_macos10.11 rs_macos10.14:CONFIG -= rs_macos10.11 +rs_macos10.15:CONFIG -= rs_macos10.11 # To enable JSON API append the following assignation to qmake command line # "CONFIG+=rs_jsonapi" @@ -764,6 +765,13 @@ macx-* { QMAKE_CXXFLAGS += -Wno-nullability-completeness QMAKE_CFLAGS += -Wno-nullability-completeness } + rs_macos10.15 { + message(***retroshare.pri: Set Target and SDK to MacOS 10.15 ) + QMAKE_MACOSX_DEPLOYMENT_TARGET=10.15 + QMAKE_MAC_SDK = macosx10.15 + QMAKE_CXXFLAGS += -Wno-nullability-completeness + QMAKE_CFLAGS += -Wno-nullability-completeness + }