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 */
else
{
/* notify public chat message */
RsServer::notify()->AddPopupMessage(RS_POPUP_GROUPCHAT, ci->PeerId().toStdString(), "", message);
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_CHAT_NEW, ci->PeerId().toStdString(), message, "");
#ifdef RS_DIRECT_CHAT
/* notify public chat 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 */
ui.setupUi(this);
if (instance == NULL) {
instance = this;
}
if (!instance) instance = this;
#ifdef RS_DIRECT_CHAT
QString msg = tr("Retroshare broadcast chat: messages are sent to all connected friends.");
// "<font color='grey'>" + DateTime::formatTime(QTime::currentTime()) + "</font> -
msg = QString("<font color='blue'><i>" + msg + "</i></font>");
@ -82,6 +82,10 @@ FriendsDialog::FriendsDialog(QWidget *parent)
this, SLOT(chatMessageReceived(ChatMessage)));
connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(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.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->idTreeWidget, &RSTreeWidget::itemDoubleClicked,
this, &IdDialog::chatIdentityItem );
ui->avlabel_Circles->setPixmap(QPixmap(":/icons/png/circles.png"));
@ -2339,8 +2342,8 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
QMenu *contextMenu = new QMenu(this);
std::list<RsGxsId> own_identities ;
rsIdentity->getOwnIds(own_identities) ;
std::list<RsGxsId> 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.
@ -2545,26 +2548,65 @@ void IdDialog::copyRetroshareLink()
void IdDialog::chatIdentity()
{
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
QTreeWidgetItem* item = ui->idTreeWidget->currentItem();
if (!item)
{
std::cerr << "IdDialog::editIdentity() Invalid item";
std::cerr << std::endl;
std::cerr << __PRETTY_FUNCTION__ << " Error. Invalid item!" << std::endl;
return;
}
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
chatIdentityItem(item);
}
QAction *action = qobject_cast<QAction *>(QObject::sender());
if (!action)
return ;
void IdDialog::chatIdentityItem(QTreeWidgetItem* item)
{
if(!item)
{
std::cerr << __PRETTY_FUNCTION__ << " Error. Invalid item." << std::endl;
return;
}
RsGxsId from_gxs_id(action->data().toString().toStdString());
uint32_t error_code ;
DistantChatPeerId did ;
std::string&& toIdString(item->text(RSID_COL_KEYID).toStdString());
RsGxsId toGxsId(toIdString);
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))
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)) ;
RsGxsId fromGxsId;
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()

View File

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

View File

@ -120,10 +120,16 @@ FriendList::FriendList(QWidget *parent) :
ui->setupUi(this);
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(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(friendsChanged()), this, SLOT(insertPeers()));
@ -346,9 +352,10 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
case TYPE_GROUP:
{
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->addSeparator();
#endif // RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup()));
QAction *action = contextMenu->addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup()));
@ -357,10 +364,11 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
break;
case TYPE_GPG:
{
#ifdef RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy()));
contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message"), this, SLOT(msgfriend()));
contextMenu->addSeparator();
#endif // RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configurefriend()));
contextMenu->addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removefriend()));
@ -437,10 +445,11 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
case TYPE_SSL:
{
#ifdef RS_DIRECT_CHAT
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->addSeparator();
#endif // RS_DIRECT_CHAT
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 */
ui.friendSelectionWidget->setHeaderText(tr("Send To:"));
ui.friendSelectionWidget->setModus(FriendSelectionWidget::MODUS_MULTI);
ui.friendSelectionWidget->setShowType(//FriendSelectionWidget::SHOW_GROUP // removed this because it's too confusing.
FriendSelectionWidget::SHOW_SSL
| FriendSelectionWidget::SHOW_GXS);
ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GXS);
ui.friendSelectionWidget->start();
QActionGroup *grp = new QActionGroup(this);
@ -263,11 +261,9 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
ui.respond_to_CB->setFlags(IDCHOOSER_ID_REQUIRED) ;
/* 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("My contacts"));
ui.filterComboBox->setCurrentIndex(2);
ui.filterComboBox->setCurrentIndex(0);
if(rsIdentity->nbRegularContacts() > 0)
ui.filterComboBox->setCurrentIndex(3);
@ -2591,25 +2587,14 @@ void MessageComposer::filterComboBoxChanged(int i)
{
switch(i)
{
case 0: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP
| FriendSelectionWidget::SHOW_SSL
| FriendSelectionWidget::SHOW_GXS) ;
break ;
case 1: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP
| FriendSelectionWidget::SHOW_SSL) ;
break ;
case 2: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GXS) ;
break ;
case 3: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_CONTACTS) ;
break ;
default: ;
default:
case 0:
ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GXS);
break;
case 1:
ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_CONTACTS);
break;
}
}
void MessageComposer::friendSelectionChanged()

View File

@ -894,6 +894,7 @@ void NotifyQt::UpdateGUI()
}
break;
case RS_POPUP_GROUPCHAT:
#ifdef RS_DIRECT_CHAT
if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster)
{
MainWindow *mainWindow = MainWindow::getInstance();
@ -907,6 +908,7 @@ void NotifyQt::UpdateGUI()
}
toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
}
#endif // RS_DIRECT_CHAT
break;
case RS_POPUP_CHATLOBBY:
if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster)
@ -1041,7 +1043,9 @@ void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosit
toaster = new ToasterItem(new ChatToaster(id, message));
break;
case RS_POPUP_GROUPCHAT:
#ifdef RS_DIRECT_CHAT
toaster = new ToasterItem(new GroupChatToaster(id, message));
#endif // RS_DIRECT_CHAT
break;
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_DownloadFinished)->setChecked(notifyflags & RS_POPUP_DOWNLOAD);
whileBlocking(ui.popup_PrivateChat)->setChecked(notifyflags & RS_POPUP_CHAT);
#ifdef RS_DIRECT_CHAT
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_ConnectAttempt)->setChecked(notifyflags & RS_POPUP_CONNECT_ATTEMPT);

View File

@ -137,6 +137,11 @@ CONFIG *= rs_gxs_trans
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
# "CONFIG+=no_bitdht"
CONFIG *= bitdht
@ -437,6 +442,11 @@ bitdht {
DEFINES *= RS_USE_BITDHT
}
direct_chat {
warning("You have enabled RetroShare direct chat which is deprecated!")
DEFINES *= RS_DIRECT_CHAT
}
rs_async_chat {
DEFINES *= RS_ASYNC_CHAT
}