Merge pull request #1413 from G10h4ck/disable_deprecated_messaging

0.6.5 Disable deprecated messaging
This commit is contained in:
G10h4ck 2018-12-23 12:10:55 +01:00 committed by GitHub
commit 93fed48b05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 114 additions and 48 deletions

View file

@ -848,9 +848,18 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *& ci)
RsServer::notify()->AddPopupMessage(popupChatFlag, ci->PeerId().toStdString(), name, message); /* notify private chat message */ RsServer::notify()->AddPopupMessage(popupChatFlag, ci->PeerId().toStdString(), name, message); /* notify private chat message */
else else
{ {
/* notify public chat message */ #ifdef RS_DIRECT_CHAT
RsServer::notify()->AddPopupMessage(RS_POPUP_GROUPCHAT, ci->PeerId().toStdString(), "", message); /* notify public chat message */
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_CHAT_NEW, ci->PeerId().toStdString(), message, ""); RsServer::notify()->AddPopupMessage(
RS_POPUP_GROUPCHAT,
ci->PeerId().toStdString(), "", message );
RsServer::notify()->AddFeedItem(
RS_FEED_ITEM_CHAT_NEW,
ci->PeerId().toStdString(), message, "" );
#else // def RS_DIRECT_CHAT
/* Ignore deprecated direct node broadcast chat messages */
return false;
#endif
} }
} }

View file

@ -69,9 +69,9 @@ FriendsDialog::FriendsDialog(QWidget *parent)
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
if (instance == NULL) { if (!instance) instance = this;
instance = this;
} #ifdef RS_DIRECT_CHAT
QString msg = tr("Retroshare broadcast chat: messages are sent to all connected friends."); QString msg = tr("Retroshare broadcast chat: messages are sent to all connected friends.");
// "<font color='grey'>" + DateTime::formatTime(QTime::currentTime()) + "</font> - // "<font color='grey'>" + DateTime::formatTime(QTime::currentTime()) + "</font> -
msg = QString("<font color='blue'><i>" + msg + "</i></font>"); msg = QString("<font color='blue'><i>" + msg + "</i></font>");
@ -82,6 +82,10 @@ FriendsDialog::FriendsDialog(QWidget *parent)
this, SLOT(chatMessageReceived(ChatMessage))); this, SLOT(chatMessageReceived(ChatMessage)));
connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)),
this, SLOT(chatStatusReceived(ChatId,QString))); this, SLOT(chatStatusReceived(ChatId,QString)));
#else // def RS_DIRECT_CHAT
ui.tabWidget->removeTab(ui.tabWidget->indexOf(ui.groupChatTab));
#endif // def RS_DIRECT_CHAT
connect( ui.mypersonalstatusLabel, SIGNAL(clicked()), SLOT(statusmessage())); connect( ui.mypersonalstatusLabel, SIGNAL(clicked()), SLOT(statusmessage()));
connect( ui.actionSet_your_Avatar, SIGNAL(triggered()), this, SLOT(getAvatar())); connect( ui.actionSet_your_Avatar, SIGNAL(triggered()), this, SLOT(getAvatar()));

View file

@ -229,6 +229,9 @@ IdDialog::IdDialog(QWidget *parent) :
connect(ui->inviteButton, SIGNAL(clicked()), this, SLOT(sendInvite())); connect(ui->inviteButton, SIGNAL(clicked()), this, SLOT(sendInvite()));
connect( ui->idTreeWidget, &RSTreeWidget::itemDoubleClicked,
this, &IdDialog::chatIdentityItem );
ui->avlabel_Circles->setPixmap(QPixmap(":/icons/png/circles.png")); ui->avlabel_Circles->setPixmap(QPixmap(":/icons/png/circles.png"));
@ -2339,8 +2342,8 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
QMenu *contextMenu = new QMenu(this); QMenu *contextMenu = new QMenu(this);
std::list<RsGxsId> own_identities ; std::list<RsGxsId> own_identities;
rsIdentity->getOwnIds(own_identities) ; rsIdentity->getOwnIds(own_identities);
// make some stats about what's selected. If the same value is used for all selected items, it can be switched. // make some stats about what's selected. If the same value is used for all selected items, it can be switched.
@ -2545,26 +2548,65 @@ void IdDialog::copyRetroshareLink()
void IdDialog::chatIdentity() void IdDialog::chatIdentity()
{ {
QTreeWidgetItem *item = ui->idTreeWidget->currentItem(); QTreeWidgetItem* item = ui->idTreeWidget->currentItem();
if (!item) if (!item)
{ {
std::cerr << "IdDialog::editIdentity() Invalid item"; std::cerr << __PRETTY_FUNCTION__ << " Error. Invalid item!" << std::endl;
std::cerr << std::endl;
return; return;
} }
std::string keyId = item->text(RSID_COL_KEYID).toStdString(); chatIdentityItem(item);
}
QAction *action = qobject_cast<QAction *>(QObject::sender()); void IdDialog::chatIdentityItem(QTreeWidgetItem* item)
if (!action) {
return ; if(!item)
{
std::cerr << __PRETTY_FUNCTION__ << " Error. Invalid item." << std::endl;
return;
}
RsGxsId from_gxs_id(action->data().toString().toStdString()); std::string&& toIdString(item->text(RSID_COL_KEYID).toStdString());
uint32_t error_code ; RsGxsId toGxsId(toIdString);
DistantChatPeerId did ; if(toGxsId.isNull())
{
std::cerr << __PRETTY_FUNCTION__ << " Error. Invalid destination id: "
<< toIdString << std::endl;
return;
}
if(!rsMsgs->initiateDistantChatConnexion(RsGxsId(keyId), from_gxs_id, did, error_code)) RsGxsId fromGxsId;
QMessageBox::information(NULL, tr("Distant chat cannot work"), QString("%1 %2: %3").arg(tr("Distant chat refused with this person.")).arg(tr("Error code")).arg(error_code)) ; QAction* action = qobject_cast<QAction*>(QObject::sender());
if(!action)
{
std::list<RsGxsId> ownIdentities;
rsIdentity->getOwnIds(ownIdentities);
if(ownIdentities.empty())
{
std::cerr << __PRETTY_FUNCTION__ << " Error. Own identities list "
<< " is empty!" << std::endl;
return;
}
else fromGxsId = ownIdentities.front();
}
else fromGxsId = RsGxsId(action->data().toString().toStdString());
if(fromGxsId.isNull())
{
std::cerr << __PRETTY_FUNCTION__ << " Error. Could not determine sender"
<< " identity to open chat toward: " << toIdString << std::endl;
return;
}
uint32_t error_code;
DistantChatPeerId did;
if(!rsMsgs->initiateDistantChatConnexion(toGxsId, fromGxsId, did, error_code))
QMessageBox::information(
nullptr, tr("Distant chat cannot work"),
QString("%1 %2: %3")
.arg(tr("Distant chat refused with this person."))
.arg(tr("Error code")).arg(error_code) ) ;
} }
void IdDialog::sendMsg() void IdDialog::sendMsg()

View file

@ -89,6 +89,7 @@ private slots:
void removeIdentity(); void removeIdentity();
void editIdentity(); void editIdentity();
void chatIdentity(); void chatIdentity();
void chatIdentityItem(QTreeWidgetItem* item);
void sendMsg(); void sendMsg();
void copyRetroshareLink(); void copyRetroshareLink();
void on_closeInfoFrameButton_clicked(); void on_closeInfoFrameButton_clicked();

View file

@ -120,10 +120,16 @@ FriendList::FriendList(QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
connect(ui->peerTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu())); connect(ui->peerTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu()));
connect(ui->peerTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(chatfriend(QTreeWidgetItem *)));
connect(ui->peerTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(expandItem(QTreeWidgetItem *))); connect(ui->peerTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(expandItem(QTreeWidgetItem *)));
connect(ui->peerTreeWidget, SIGNAL(itemCollapsed(QTreeWidgetItem *)), this, SLOT(collapseItem(QTreeWidgetItem *))); connect(ui->peerTreeWidget, SIGNAL(itemCollapsed(QTreeWidgetItem *)), this, SLOT(collapseItem(QTreeWidgetItem *)));
#ifdef RS_DIRECT_CHAT
connect(ui->peerTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(chatfriend(QTreeWidgetItem *)));
#else
connect( ui->peerTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
this, SLOT(expandItem(QTreeWidgetItem *)) );
#endif
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged())); connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged()));
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(insertPeers())); connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(insertPeers()));
@ -346,9 +352,10 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
case TYPE_GROUP: case TYPE_GROUP:
{ {
bool standard = c->data(COLUMN_DATA, ROLE_STANDARD).toBool(); bool standard = c->data(COLUMN_DATA, ROLE_STANDARD).toBool();
#ifdef RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgfriend())); contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgfriend()));
contextMenu->addSeparator(); contextMenu->addSeparator();
#endif // RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); contextMenu->addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup()));
QAction *action = contextMenu->addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); QAction *action = contextMenu->addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup()));
@ -357,10 +364,11 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
break; break;
case TYPE_GPG: case TYPE_GPG:
{ {
#ifdef RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); contextMenu->addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy()));
contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message"), this, SLOT(msgfriend())); contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message"), this, SLOT(msgfriend()));
contextMenu->addSeparator(); contextMenu->addSeparator();
#endif // RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configurefriend())); contextMenu->addAction(QIcon(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configurefriend()));
contextMenu->addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removefriend())); contextMenu->addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removefriend()));
@ -437,10 +445,11 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
case TYPE_SSL: case TYPE_SSL:
{ {
#ifdef RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); contextMenu->addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy()));
contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgfriend())); contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgfriend()));
contextMenu->addSeparator(); contextMenu->addSeparator();
#endif // RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configurefriend())); contextMenu->addAction(QIcon(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configurefriend()));

View file

@ -217,9 +217,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
/* initialize friends list */ /* initialize friends list */
ui.friendSelectionWidget->setHeaderText(tr("Send To:")); ui.friendSelectionWidget->setHeaderText(tr("Send To:"));
ui.friendSelectionWidget->setModus(FriendSelectionWidget::MODUS_MULTI); ui.friendSelectionWidget->setModus(FriendSelectionWidget::MODUS_MULTI);
ui.friendSelectionWidget->setShowType(//FriendSelectionWidget::SHOW_GROUP // removed this because it's too confusing. ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GXS);
FriendSelectionWidget::SHOW_SSL
| FriendSelectionWidget::SHOW_GXS);
ui.friendSelectionWidget->start(); ui.friendSelectionWidget->start();
QActionGroup *grp = new QActionGroup(this); QActionGroup *grp = new QActionGroup(this);
@ -263,11 +261,9 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
ui.respond_to_CB->setFlags(IDCHOOSER_ID_REQUIRED) ; ui.respond_to_CB->setFlags(IDCHOOSER_ID_REQUIRED) ;
/* Add filter types */ /* Add filter types */
ui.filterComboBox->addItem(tr("All addresses (mixed)"));
ui.filterComboBox->addItem(tr("Friend Nodes"));
ui.filterComboBox->addItem(tr("All people")); ui.filterComboBox->addItem(tr("All people"));
ui.filterComboBox->addItem(tr("My contacts")); ui.filterComboBox->addItem(tr("My contacts"));
ui.filterComboBox->setCurrentIndex(2); ui.filterComboBox->setCurrentIndex(0);
if(rsIdentity->nbRegularContacts() > 0) if(rsIdentity->nbRegularContacts() > 0)
ui.filterComboBox->setCurrentIndex(3); ui.filterComboBox->setCurrentIndex(3);
@ -2591,25 +2587,14 @@ void MessageComposer::filterComboBoxChanged(int i)
{ {
switch(i) switch(i)
{ {
case 0: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP default:
| FriendSelectionWidget::SHOW_SSL case 0:
| FriendSelectionWidget::SHOW_GXS) ; ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GXS);
break ; break;
case 1:
case 1: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_CONTACTS);
| FriendSelectionWidget::SHOW_SSL) ; break;
break ;
case 2: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GXS) ;
break ;
case 3: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_CONTACTS) ;
break ;
default: ;
} }
} }
void MessageComposer::friendSelectionChanged() void MessageComposer::friendSelectionChanged()

View file

@ -894,6 +894,7 @@ void NotifyQt::UpdateGUI()
} }
break; break;
case RS_POPUP_GROUPCHAT: case RS_POPUP_GROUPCHAT:
#ifdef RS_DIRECT_CHAT
if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster)
{ {
MainWindow *mainWindow = MainWindow::getInstance(); MainWindow *mainWindow = MainWindow::getInstance();
@ -907,6 +908,7 @@ void NotifyQt::UpdateGUI()
} }
toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
} }
#endif // RS_DIRECT_CHAT
break; break;
case RS_POPUP_CHATLOBBY: case RS_POPUP_CHATLOBBY:
if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster) if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster)
@ -1041,7 +1043,9 @@ void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosit
toaster = new ToasterItem(new ChatToaster(id, message)); toaster = new ToasterItem(new ChatToaster(id, message));
break; break;
case RS_POPUP_GROUPCHAT: case RS_POPUP_GROUPCHAT:
#ifdef RS_DIRECT_CHAT
toaster = new ToasterItem(new GroupChatToaster(id, message)); toaster = new ToasterItem(new GroupChatToaster(id, message));
#endif // RS_DIRECT_CHAT
break; break;
case RS_POPUP_CHATLOBBY: case RS_POPUP_CHATLOBBY:
{ {

View file

@ -322,7 +322,9 @@ void NotifyPage::load()
whileBlocking(ui.popup_NewMsg)->setChecked(notifyflags & RS_POPUP_MSG); whileBlocking(ui.popup_NewMsg)->setChecked(notifyflags & RS_POPUP_MSG);
whileBlocking(ui.popup_DownloadFinished)->setChecked(notifyflags & RS_POPUP_DOWNLOAD); whileBlocking(ui.popup_DownloadFinished)->setChecked(notifyflags & RS_POPUP_DOWNLOAD);
whileBlocking(ui.popup_PrivateChat)->setChecked(notifyflags & RS_POPUP_CHAT); whileBlocking(ui.popup_PrivateChat)->setChecked(notifyflags & RS_POPUP_CHAT);
#ifdef RS_DIRECT_CHAT
whileBlocking(ui.popup_GroupChat)->setChecked(notifyflags & RS_POPUP_GROUPCHAT); whileBlocking(ui.popup_GroupChat)->setChecked(notifyflags & RS_POPUP_GROUPCHAT);
#endif // def RS_DIRECT_CHAT
whileBlocking(ui.popup_ChatLobby)->setChecked(notifyflags & RS_POPUP_CHATLOBBY); whileBlocking(ui.popup_ChatLobby)->setChecked(notifyflags & RS_POPUP_CHATLOBBY);
whileBlocking(ui.popup_ConnectAttempt)->setChecked(notifyflags & RS_POPUP_CONNECT_ATTEMPT); whileBlocking(ui.popup_ConnectAttempt)->setChecked(notifyflags & RS_POPUP_CONNECT_ATTEMPT);

View file

@ -137,6 +137,11 @@ CONFIG *= rs_gxs_trans
CONFIG *= no_rs_async_chat CONFIG *= no_rs_async_chat
rs_async_chat:CONFIG -= no_rs_async_chat rs_async_chat:CONFIG -= no_rs_async_chat
# To enable direct chat which has been deprecated since RetroShare 0.6.5 append
# the following assignation to qmake command line "CONFIG+=direct_chat"
CONFIG *= no_direct_chat
direct_chat:CONFIG -= no_direct_chat
# To disable bitdht append the following assignation to qmake command line # To disable bitdht append the following assignation to qmake command line
# "CONFIG+=no_bitdht" # "CONFIG+=no_bitdht"
CONFIG *= bitdht CONFIG *= bitdht
@ -437,6 +442,11 @@ bitdht {
DEFINES *= RS_USE_BITDHT DEFINES *= RS_USE_BITDHT
} }
direct_chat {
warning("You have enabled RetroShare direct chat which is deprecated!")
DEFINES *= RS_DIRECT_CHAT
}
rs_async_chat { rs_async_chat {
DEFINES *= RS_ASYNC_CHAT DEFINES *= RS_ASYNC_CHAT
} }