2018-11-15 15:49:12 -05:00
/*******************************************************************************
* retroshare - gui / src / gui / Identity / IdDialog . cpp *
* *
* Copyright ( C ) 2012 by Robert Fernie < retroshare . project @ gmail . com > *
* *
* This program is free software : you can redistribute it and / or modify *
* it under the terms of the GNU Affero 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 Affero General Public License for more details . *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program . If not , see < https : //www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2012-02-13 13:43:15 -05:00
2016-03-12 10:41:35 -05:00
# include <unistd.h>
2018-01-05 11:48:18 -05:00
# include <QCheckBox>
2013-07-10 17:57:23 -04:00
# include <QMessageBox>
2019-01-19 09:54:07 -05:00
# include <QDateTime>
2014-05-03 13:56:12 -04:00
# include <QMenu>
2016-08-05 12:15:21 -04:00
# include <QWidgetAction>
2016-12-23 16:53:57 -05:00
# include <QStyledItemDelegate>
# include <QPainter>
2013-07-10 17:57:23 -04:00
2012-02-13 13:43:15 -05:00
# include "IdDialog.h"
2014-12-24 09:43:06 -05:00
# include "ui_IdDialog.h"
# include "IdEditDialog.h"
2018-01-05 11:48:18 -05:00
# include "gui/RetroShareLink.h"
# include "gui/chat/ChatDialog.h"
# include "gui/Circles/CreateCircleDialog.h"
# include "gui/common/UIStateHelper.h"
2020-01-27 17:02:04 -05:00
# include "gui/common/UserNotify.h"
2014-09-14 12:28:02 -04:00
# include "gui/gxs/GxsIdDetails.h"
2020-02-11 16:14:55 -05:00
# include "gui/gxs/GxsIdTreeWidgetItem.h"
2020-02-06 13:57:23 -05:00
//#include "gui/gxs/RsGxsUpdateBroadcastBase.h"
2015-01-23 11:35:06 -05:00
# include "gui/msgs/MessageComposer.h"
2018-01-05 11:48:18 -05:00
# include "gui/settings/rsharesettings.h"
2020-01-27 17:02:04 -05:00
# include "util/qtthreadsutils.h"
2018-01-05 11:48:18 -05:00
# include "retroshare-gui/RsAutoUpdatePage.h"
# include "util/misc.h"
2015-12-22 18:29:27 -05:00
# include "util/QtVersion.h"
2018-10-07 08:34:28 -04:00
# include "util/rstime.h"
2012-02-13 13:43:15 -05:00
2013-02-28 16:58:38 -05:00
# include "retroshare/rsgxsflags.h"
2015-01-23 11:35:06 -05:00
# include "retroshare/rsmsgs.h"
2018-01-05 11:48:18 -05:00
# include "retroshare/rspeers.h"
2017-01-04 14:21:49 -05:00
# include "retroshare/rsservicecontrol.h"
2018-01-05 11:48:18 -05:00
2012-02-13 13:43:15 -05:00
# include <iostream>
2014-12-24 09:43:06 -05:00
# include <algorithm>
2012-02-13 13:43:15 -05:00
/******
* # define ID_DEBUG 1
* * * * */
2012-06-13 20:36:25 -04:00
// Data Requests.
2017-04-10 14:02:14 -04:00
# define IDDIALOG_IDLIST 1
# define IDDIALOG_IDDETAILS 2
# define IDDIALOG_REPLIST 3
# define IDDIALOG_REFRESH 4
# define IDDIALOG_SERIALIZED_GROUP 5
2012-02-13 13:43:15 -05:00
2016-05-06 22:12:44 -04:00
# define CIRCLEGROUP_CIRCLE_COL_GROUPNAME 0
# define CIRCLEGROUP_CIRCLE_COL_GROUPID 1
# define CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS 2
# define CIRCLEGROUP_CIRCLE_COL_SUBSCRIBEFLAGS 3
2015-09-06 23:53:21 -04:00
# define CIRCLEGROUP_FRIEND_COL_NAME 0
# define CIRCLEGROUP_FRIEND_COL_ID 1
# define CLEAR_BACKGROUND 0
# define GREEN_BACKGROUND 1
# define BLUE_BACKGROUND 2
# define RED_BACKGROUND 3
# define GRAY_BACKGROUND 4
2016-06-08 21:00:26 -04:00
# define CIRCLESDIALOG_GROUPMETA 1
# define CIRCLESDIALOG_GROUPDATA 2
# define CIRCLESDIALOG_GROUPUPDATE 3
2016-03-24 18:41:15 -04:00
2012-02-13 13:43:15 -05:00
/****************************************************************
*/
2013-07-11 04:14:38 -04:00
# define RSID_COL_NICKNAME 0
# define RSID_COL_KEYID 1
2015-12-22 18:29:27 -05:00
# define RSID_COL_IDTYPE 2
# define RSID_COL_VOTES 3
2012-02-13 13:43:15 -05:00
2013-07-11 04:14:38 -04:00
# define RSIDREP_COL_NAME 0
# define RSIDREP_COL_OPINION 1
# define RSIDREP_COL_COMMENT 2
# define RSIDREP_COL_REPUTATION 3
2012-02-13 13:43:15 -05:00
2015-02-05 15:37:24 -05:00
# define RSID_FILTER_OWNED_BY_YOU 0x0001
2013-07-10 17:57:23 -04:00
# define RSID_FILTER_FRIENDS 0x0002
# define RSID_FILTER_OTHERS 0x0004
# define RSID_FILTER_PSEUDONYMS 0x0008
2015-02-05 15:37:24 -05:00
# define RSID_FILTER_YOURSELF 0x0010
2016-08-15 13:53:43 -04:00
# define RSID_FILTER_BANNED 0x0020
2013-07-10 17:57:23 -04:00
# define RSID_FILTER_ALL 0xffff
2012-06-07 13:11:57 -04:00
2014-05-03 13:56:12 -04:00
# define IMAGE_EDIT ": / images / edit_16.png"
2016-04-10 10:53:21 -04:00
# define IMAGE_CREATE ": / icons / circle_new_128.png"
2016-05-25 18:34:12 -04:00
# define IMAGE_INVITED ": / icons / bullet_yellow_128.png"
# define IMAGE_MEMBER ": / icons / bullet_green_128.png"
2016-06-05 15:15:40 -04:00
# define IMAGE_UNKNOWN ": / icons / bullet_grey_128.png"
2016-06-14 18:08:45 -04:00
# define IMAGE_ADMIN ": / icons / bullet_blue_128.png"
# define IMAGE_INFO ": / images / info16.png"
2016-04-10 10:53:21 -04:00
2016-05-26 21:16:21 -04:00
// comment this out in order to remove the sorting of circles into "belong to" and "other visible circles"
# define CIRCLE_MEMBERSHIP_CATEGORIES 1
2017-01-12 15:59:44 -05:00
static const uint32_t SortRole = Qt : : UserRole + 1 ;
2016-01-16 08:50:12 -05:00
// quick solution for RSID_COL_VOTES sorting
2017-01-12 15:59:44 -05:00
class TreeWidgetItem : public QTreeWidgetItem
{
2016-01-16 08:50:12 -05:00
public :
TreeWidgetItem ( int type = Type ) : QTreeWidgetItem ( type ) { }
TreeWidgetItem ( QTreeWidget * tree ) : QTreeWidgetItem ( tree ) { }
TreeWidgetItem ( const QStringList & strings ) : QTreeWidgetItem ( strings ) { }
2017-01-12 15:59:44 -05:00
bool operator < ( const QTreeWidgetItem & other ) const
{
2016-01-16 08:50:12 -05:00
int column = treeWidget ( ) - > sortColumn ( ) ;
2017-01-12 15:59:44 -05:00
if ( column = = RSID_COL_VOTES )
{
const unsigned int v1 = data ( column , SortRole ) . toUInt ( ) ;
const unsigned int v2 = other . data ( column , SortRole ) . toUInt ( ) ;
return v1 < v2 ;
}
2019-01-06 14:29:45 -05:00
else // case insensitive sorting
return data ( column , Qt : : DisplayRole ) . toString ( ) . toUpper ( ) < other . data ( column , Qt : : DisplayRole ) . toString ( ) . toUpper ( ) ;
2016-01-16 08:50:12 -05:00
}
} ;
2016-12-23 16:53:57 -05:00
2012-02-13 13:43:15 -05:00
/** Constructor */
2020-02-06 13:57:23 -05:00
IdDialog : : IdDialog ( QWidget * parent ) : MainPage ( parent ) , ui ( new Ui : : IdDialog )
2012-02-13 13:43:15 -05:00
{
2014-12-24 09:43:06 -05:00
ui - > setupUi ( this ) ;
2012-02-13 13:43:15 -05:00
2020-01-28 16:22:04 -05:00
mEventHandlerId_identity = 0 ;
rsEvents - > registerEventsHandler ( RsEventType : : GXS_IDENTITY , [ this ] ( std : : shared_ptr < const RsEvent > event ) { RsQThreadUtils : : postToObject ( [ = ] ( ) { handleEvent_main_thread ( event ) ; } , this ) ; } , mEventHandlerId_identity ) ;
mEventHandlerId_circles = 0 ;
rsEvents - > registerEventsHandler ( RsEventType : : GXS_CIRCLES , [ this ] ( std : : shared_ptr < const RsEvent > event ) { RsQThreadUtils : : postToObject ( [ = ] ( ) { handleEvent_main_thread ( event ) ; } , this ) ; } , mEventHandlerId_circles ) ;
2020-01-27 17:02:04 -05:00
2020-02-06 13:57:23 -05:00
// This is used to grab the broadcast of changes from p3GxsCircles, which is discarded by the current dialog, since it expects data for p3Identity only.
//mCirclesBroadcastBase = new RsGxsUpdateBroadcastBase(rsGxsCircles, this);
//connect(mCirclesBroadcastBase, SIGNAL(fillDisplay(bool)), this, SLOT(updateCirclesDisplay(bool)));
2016-03-17 18:17:58 -04:00
2016-04-09 17:50:46 -04:00
ownItem = new QTreeWidgetItem ( ) ;
ownItem - > setText ( 0 , tr ( " My own identities " ) ) ;
2016-12-24 08:13:02 -05:00
ownItem - > setData ( RSID_COL_VOTES , Qt : : DecorationRole , 0xff ) ; // this is in order to prevent displaying a reputaiton icon next to these items.
2016-04-09 17:50:46 -04:00
2015-12-22 18:29:27 -05:00
allItem = new QTreeWidgetItem ( ) ;
allItem - > setText ( 0 , tr ( " All " ) ) ;
2016-12-23 16:53:57 -05:00
allItem - > setData ( RSID_COL_VOTES , Qt : : DecorationRole , 0xff ) ;
2015-12-22 18:29:27 -05:00
2015-12-23 12:12:34 -05:00
contactsItem = new QTreeWidgetItem ( ) ;
2016-04-09 17:50:46 -04:00
contactsItem - > setText ( 0 , tr ( " My contacts " ) ) ;
2016-12-23 16:53:57 -05:00
contactsItem - > setData ( RSID_COL_VOTES , Qt : : DecorationRole , 0xff ) ;
2015-12-23 12:12:34 -05:00
2016-03-16 20:59:52 -04:00
ui - > treeWidget_membership - > clear ( ) ;
2020-02-17 17:13:41 -05:00
ui - > treeWidget_membership - > setItemDelegateForColumn ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , new GxsIdTreeItemDelegate ( ) ) ;
2016-03-16 20:59:52 -04:00
mExternalOtherCircleItem = NULL ;
2016-04-19 22:00:32 -04:00
mExternalBelongingCircleItem = NULL ;
2013-07-10 17:57:23 -04:00
/* Setup UI helper */
mStateHelper = new UIStateHelper ( this ) ;
2015-08-11 10:01:43 -04:00
// mStateHelper->addWidget(IDDIALOG_IDLIST, ui->idTreeWidget);
mStateHelper - > addLoadPlaceholder ( IDDIALOG_IDLIST , ui - > idTreeWidget , false ) ;
mStateHelper - > addClear ( IDDIALOG_IDLIST , ui - > idTreeWidget ) ;
2014-12-24 09:43:06 -05:00
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > lineEdit_Nickname ) ;
2019-01-19 09:54:07 -05:00
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > lineEdit_PublishTS ) ;
2014-12-24 09:43:06 -05:00
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > lineEdit_KeyId ) ;
2018-01-05 11:48:18 -05:00
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > lineEdit_Type ) ;
2014-12-24 09:43:06 -05:00
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > lineEdit_GpgId ) ;
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > lineEdit_GpgName ) ;
2015-12-22 18:29:27 -05:00
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > lineEdit_LastUsed ) ;
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > ownOpinion_CB ) ;
2018-01-05 11:48:18 -05:00
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > autoBanIdentities_CB ) ;
2015-12-22 18:29:27 -05:00
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > neighborNodesOpinion_TF ) ;
2018-01-05 11:48:18 -05:00
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > overallOpinion_TF ) ;
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > usageStatistics_TB ) ;
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > inviteButton ) ;
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > label_positive ) ;
mStateHelper - > addWidget ( IDDIALOG_IDDETAILS , ui - > label_negative ) ;
2014-12-24 09:43:06 -05:00
mStateHelper - > addLoadPlaceholder ( IDDIALOG_IDDETAILS , ui - > lineEdit_Nickname ) ;
2019-01-19 09:54:07 -05:00
mStateHelper - > addLoadPlaceholder ( IDDIALOG_IDDETAILS , ui - > lineEdit_PublishTS ) ;
2014-12-24 09:43:06 -05:00
mStateHelper - > addLoadPlaceholder ( IDDIALOG_IDDETAILS , ui - > lineEdit_KeyId ) ;
mStateHelper - > addLoadPlaceholder ( IDDIALOG_IDDETAILS , ui - > lineEdit_Type ) ;
2018-01-05 11:48:18 -05:00
mStateHelper - > addLoadPlaceholder ( IDDIALOG_IDDETAILS , ui - > lineEdit_GpgId ) ;
2014-12-24 09:43:06 -05:00
mStateHelper - > addLoadPlaceholder ( IDDIALOG_IDDETAILS , ui - > lineEdit_GpgName ) ;
2015-12-22 18:29:27 -05:00
mStateHelper - > addLoadPlaceholder ( IDDIALOG_IDDETAILS , ui - > lineEdit_LastUsed ) ;
2018-01-05 11:48:18 -05:00
mStateHelper - > addLoadPlaceholder ( IDDIALOG_IDDETAILS , ui - > neighborNodesOpinion_TF ) ;
mStateHelper - > addLoadPlaceholder ( IDDIALOG_IDDETAILS , ui - > overallOpinion_TF ) ;
mStateHelper - > addLoadPlaceholder ( IDDIALOG_IDDETAILS , ui - > usageStatistics_TB ) ;
2014-12-24 09:43:06 -05:00
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > lineEdit_Nickname ) ;
2019-01-19 09:54:07 -05:00
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > lineEdit_PublishTS ) ;
2014-12-24 09:43:06 -05:00
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > lineEdit_KeyId ) ;
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > lineEdit_Type ) ;
2018-01-05 11:48:18 -05:00
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > lineEdit_GpgId ) ;
2015-12-22 18:29:27 -05:00
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > lineEdit_GpgName ) ;
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > lineEdit_LastUsed ) ;
2018-01-05 11:48:18 -05:00
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > neighborNodesOpinion_TF ) ;
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > overallOpinion_TF ) ;
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > usageStatistics_TB ) ;
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > label_positive ) ;
mStateHelper - > addClear ( IDDIALOG_IDDETAILS , ui - > label_negative ) ;
2014-12-24 09:43:06 -05:00
//mStateHelper->addWidget(IDDIALOG_REPLIST, ui->treeWidget_RepList);
//mStateHelper->addLoadPlaceholder(IDDIALOG_REPLIST, ui->treeWidget_RepList);
//mStateHelper->addClear(IDDIALOG_REPLIST, ui->treeWidget_RepList);
2013-07-10 17:57:23 -04:00
/* Connect signals */
2015-01-24 14:27:19 -05:00
2014-12-24 09:43:06 -05:00
connect ( ui - > removeIdentity , SIGNAL ( triggered ( ) ) , this , SLOT ( removeIdentity ( ) ) ) ;
connect ( ui - > editIdentity , SIGNAL ( triggered ( ) ) , this , SLOT ( editIdentity ( ) ) ) ;
connect ( ui - > chatIdentity , SIGNAL ( triggered ( ) ) , this , SLOT ( chatIdentity ( ) ) ) ;
2014-05-03 13:56:12 -04:00
2015-08-11 10:01:43 -04:00
connect ( ui - > idTreeWidget , SIGNAL ( itemSelectionChanged ( ) ) , this , SLOT ( updateSelection ( ) ) ) ;
connect ( ui - > idTreeWidget , SIGNAL ( customContextMenuRequested ( QPoint ) ) , this , SLOT ( IdListCustomPopupMenu ( QPoint ) ) ) ;
2012-02-13 13:43:15 -05:00
2014-12-24 09:43:06 -05:00
connect ( ui - > filterLineEdit , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( filterChanged ( QString ) ) ) ;
2015-12-22 18:29:27 -05:00
connect ( ui - > ownOpinion_CB , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( modifyReputation ( ) ) ) ;
2015-02-09 20:14:44 -05:00
2015-12-24 08:31:52 -05:00
connect ( ui - > inviteButton , SIGNAL ( clicked ( ) ) , this , SLOT ( sendInvite ( ) ) ) ;
2014-09-09 15:45:38 -04:00
2018-11-19 18:11:00 -05:00
connect ( ui - > idTreeWidget , & RSTreeWidget : : itemDoubleClicked ,
this , & IdDialog : : chatIdentityItem ) ;
2019-01-19 16:36:19 -05:00
ui - > avlabel_Circles - > setPixmap ( QPixmap ( " :/icons/png/circles.png " ) ) ;
ui - > headerTextLabel_Circles - > setText ( tr ( " Circles " ) ) ;
2014-12-24 09:43:06 -05:00
/* Initialize splitter */
2016-07-29 14:54:26 -04:00
ui - > mainSplitter - > setStretchFactor ( 0 , 0 ) ;
ui - > mainSplitter - > setStretchFactor ( 1 , 1 ) ;
2016-03-30 11:06:34 -04:00
2018-01-05 11:48:18 -05:00
clearPerson ( ) ;
2015-02-16 10:45:53 -05:00
2013-07-10 17:57:23 -04:00
/* Add filter types */
2016-08-05 12:15:21 -04:00
QMenu * idTWHMenu = new QMenu ( tr ( " Show Items " ) , this ) ;
ui - > idTreeWidget - > addContextMenuMenu ( idTWHMenu ) ;
2016-07-29 14:54:26 -04:00
QActionGroup * idTWHActionGroup = new QActionGroup ( this ) ;
QAction * idTWHAction = new QAction ( QIcon ( ) , tr ( " All " ) , this ) ;
idTWHAction - > setActionGroup ( idTWHActionGroup ) ;
idTWHAction - > setCheckable ( true ) ;
idTWHAction - > setChecked ( true ) ;
filter = RSID_FILTER_ALL ;
idTWHAction - > setData ( RSID_FILTER_ALL ) ;
connect ( idTWHAction , SIGNAL ( toggled ( bool ) ) , this , SLOT ( filterToggled ( bool ) ) ) ;
idTWHMenu - > addAction ( idTWHAction ) ;
idTWHAction = new QAction ( QIcon ( ) , tr ( " Owned by myself " ) , this ) ;
idTWHAction - > setActionGroup ( idTWHActionGroup ) ;
idTWHAction - > setCheckable ( true ) ;
idTWHAction - > setData ( RSID_FILTER_OWNED_BY_YOU ) ;
connect ( idTWHAction , SIGNAL ( toggled ( bool ) ) , this , SLOT ( filterToggled ( bool ) ) ) ;
idTWHMenu - > addAction ( idTWHAction ) ;
idTWHAction = new QAction ( QIcon ( ) , tr ( " Linked to my node " ) , this ) ;
idTWHAction - > setActionGroup ( idTWHActionGroup ) ;
idTWHAction - > setCheckable ( true ) ;
idTWHAction - > setData ( RSID_FILTER_YOURSELF ) ;
connect ( idTWHAction , SIGNAL ( toggled ( bool ) ) , this , SLOT ( filterToggled ( bool ) ) ) ;
idTWHMenu - > addAction ( idTWHAction ) ;
idTWHAction = new QAction ( QIcon ( ) , tr ( " Linked to neighbor nodes " ) , this ) ;
idTWHAction - > setActionGroup ( idTWHActionGroup ) ;
idTWHAction - > setCheckable ( true ) ;
idTWHAction - > setData ( RSID_FILTER_FRIENDS ) ;
connect ( idTWHAction , SIGNAL ( toggled ( bool ) ) , this , SLOT ( filterToggled ( bool ) ) ) ;
idTWHMenu - > addAction ( idTWHAction ) ;
idTWHAction = new QAction ( QIcon ( ) , tr ( " Linked to distant nodes " ) , this ) ;
idTWHAction - > setActionGroup ( idTWHActionGroup ) ;
idTWHAction - > setCheckable ( true ) ;
idTWHAction - > setData ( RSID_FILTER_OTHERS ) ;
connect ( idTWHAction , SIGNAL ( toggled ( bool ) ) , this , SLOT ( filterToggled ( bool ) ) ) ;
idTWHMenu - > addAction ( idTWHAction ) ;
idTWHAction = new QAction ( QIcon ( ) , tr ( " Anonymous " ) , this ) ;
idTWHAction - > setActionGroup ( idTWHActionGroup ) ;
idTWHAction - > setCheckable ( true ) ;
idTWHAction - > setData ( RSID_FILTER_PSEUDONYMS ) ;
connect ( idTWHAction , SIGNAL ( toggled ( bool ) ) , this , SLOT ( filterToggled ( bool ) ) ) ;
idTWHMenu - > addAction ( idTWHAction ) ;
2013-07-10 17:57:23 -04:00
2016-08-15 13:53:43 -04:00
idTWHAction = new QAction ( QIcon ( ) , tr ( " Banned " ) , this ) ;
idTWHAction - > setActionGroup ( idTWHActionGroup ) ;
idTWHAction - > setCheckable ( true ) ;
idTWHAction - > setData ( RSID_FILTER_BANNED ) ;
connect ( idTWHAction , SIGNAL ( toggled ( bool ) ) , this , SLOT ( filterToggled ( bool ) ) ) ;
idTWHMenu - > addAction ( idTWHAction ) ;
2016-08-25 20:48:46 -04:00
QAction * CreateIDAction = new QAction ( QIcon ( " :/icons/png/person.png " ) , tr ( " Create new Identity " ) , this ) ;
connect ( CreateIDAction , SIGNAL ( triggered ( ) ) , this , SLOT ( addIdentity ( ) ) ) ;
QAction * CreateCircleAction = new QAction ( QIcon ( " :/icons/png/circles.png " ) , tr ( " Create new circle " ) , this ) ;
connect ( CreateCircleAction , SIGNAL ( triggered ( ) ) , this , SLOT ( createExternalCircle ( ) ) ) ;
QMenu * menu = new QMenu ( ) ;
menu - > addAction ( CreateIDAction ) ;
menu - > addAction ( CreateCircleAction ) ;
ui - > toolButton_New - > setMenu ( menu ) ;
2013-07-10 17:57:23 -04:00
/* Add filter actions */
2015-08-11 10:01:43 -04:00
QTreeWidgetItem * headerItem = ui - > idTreeWidget - > headerItem ( ) ;
2013-07-10 17:57:23 -04:00
QString headerText = headerItem - > text ( RSID_COL_NICKNAME ) ;
2014-12-24 09:43:06 -05:00
ui - > filterLineEdit - > addFilter ( QIcon ( ) , headerText , RSID_COL_NICKNAME , QString ( " %1 %2 " ) . arg ( tr ( " Search " ) , headerText ) ) ;
2016-01-01 15:15:19 -05:00
2017-03-02 16:35:21 -05:00
headerItem - > setData ( RSID_COL_VOTES , Qt : : UserRole , tr ( " Reputation " ) ) ;
2015-09-10 11:37:42 -04:00
/* Set initial section sizes */
QHeaderView * circlesheader = ui - > treeWidget_membership - > header ( ) ;
2016-05-25 19:04:45 -04:00
circlesheader - > resizeSection ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , QFontMetricsF ( ui - > idTreeWidget - > font ( ) ) . width ( " Circle name " ) * 1.5 ) ;
2016-06-10 07:40:24 -04:00
ui - > treeWidget_membership - > setColumnWidth ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , 270 ) ;
2013-07-10 17:57:23 -04:00
2015-12-22 18:29:27 -05:00
ui - > filterLineEdit - > addFilter ( QIcon ( ) , tr ( " ID " ) , RSID_COL_KEYID , tr ( " Search ID " ) ) ;
2014-12-24 09:43:06 -05:00
/* Setup tree */
2015-08-11 10:01:43 -04:00
ui - > idTreeWidget - > sortByColumn ( RSID_COL_NICKNAME , Qt : : AscendingOrder ) ;
ui - > idTreeWidget - > enableColumnCustomize ( true ) ;
ui - > idTreeWidget - > setColumnCustomizable ( RSID_COL_NICKNAME , false ) ;
2016-01-01 15:15:19 -05:00
2015-09-10 11:37:42 -04:00
ui - > idTreeWidget - > setColumnHidden ( RSID_COL_IDTYPE , true ) ;
2015-12-22 18:29:27 -05:00
ui - > idTreeWidget - > setColumnHidden ( RSID_COL_KEYID , true ) ;
2015-09-10 11:37:42 -04:00
2015-08-11 10:01:43 -04:00
/* Set initial column width */
int fontWidth = QFontMetricsF ( ui - > idTreeWidget - > font ( ) ) . width ( " W " ) ;
2015-12-22 18:29:27 -05:00
ui - > idTreeWidget - > setColumnWidth ( RSID_COL_NICKNAME , 14 * fontWidth ) ;
ui - > idTreeWidget - > setColumnWidth ( RSID_COL_KEYID , 20 * fontWidth ) ;
2015-08-11 10:01:43 -04:00
ui - > idTreeWidget - > setColumnWidth ( RSID_COL_IDTYPE , 18 * fontWidth ) ;
2017-01-02 19:37:16 -05:00
ui - > idTreeWidget - > setColumnWidth ( RSID_COL_VOTES , 2 * fontWidth ) ;
2015-12-22 18:29:27 -05:00
2019-02-16 09:42:22 -05:00
ui - > idTreeWidget - > setItemDelegateForColumn (
RSID_COL_VOTES ,
new ReputationItemDelegate ( RsReputationLevel ( 0xff ) ) ) ;
2016-12-23 16:53:57 -05:00
2017-01-02 19:37:16 -05:00
/* Set header resize modes and initial section sizes */
QHeaderView * idheader = ui - > idTreeWidget - > header ( ) ;
QHeaderView_setSectionResizeModeColumn ( idheader , RSID_COL_VOTES , QHeaderView : : ResizeToContents ) ;
2015-08-11 10:01:43 -04:00
2013-07-10 17:57:23 -04:00
mStateHelper - > setActive ( IDDIALOG_IDDETAILS , false ) ;
mStateHelper - > setActive ( IDDIALOG_REPLIST , false ) ;
2014-02-19 06:11:06 -05:00
2014-09-09 15:45:38 -04:00
QString hlp_str = tr (
2015-06-30 12:44:58 -04:00
" <h1><img width= \" 32 \" src= \" :/icons/help_64.png \" > Identities</h1> \
2016-04-17 18:05:31 -04:00
< p > In this tab you can create / edit < b > pseudo - anonymous identities < / b > , and < b > circles < / b > . < / p > \
< p > < b > Identities < / b > are used to securely identify your data : sign messages in chat lobbies , forum and channel posts , \
receive feedback using the Retroshare built - in email system , post comments \
after channel posts , chat using secured tunnels , etc . < / p > \
< p > Identities can optionally be < b > signed < / b > by your Retroshare node ' s certificate . \
2015-09-06 23:53:21 -04:00
Signed identities are easier to trust but are easily linked to your node ' s IP address . < / p > \
2016-04-17 18:05:31 -04:00
< p > < b > Anonymous identities < / b > allow you to anonymously interact with other users . They cannot be \
spoofed , but noone can prove who really owns a given identity . < / p > \
2016-08-30 08:18:36 -04:00
< p > < b > Circles < / b > are groups of identities ( anonymous or signed ) , that are shared at a distance over the network . They can be \
2016-04-17 18:05:31 -04:00
used to restrict the visibility to forums , channels , etc . < / p > \
2016-08-30 08:18:36 -04:00
< p > An < b > circle < / b > can be restricted to another circle , thereby limiting its visibility to members of that circle \
or even self - restricted , meaning that it is only visible to invited members . < / p > " ) ;
2014-09-09 15:45:38 -04:00
2017-02-25 17:52:57 -05:00
registerHelpButton ( ui - > helpButton , hlp_str , " PeopleDialog " ) ;
2014-12-24 09:43:06 -05:00
// load settings
processSettings ( true ) ;
2015-02-18 17:09:51 -05:00
2015-09-06 23:53:21 -04:00
// circles stuff
2016-05-25 19:04:45 -04:00
//connect(ui->treeWidget_membership, SIGNAL(itemSelectionChanged()), this, SLOT(circle_selected()));
2015-09-10 20:46:34 -04:00
connect ( ui - > treeWidget_membership , SIGNAL ( customContextMenuRequested ( QPoint ) ) , this , SLOT ( CircleListCustomPopupMenu ( QPoint ) ) ) ;
2016-08-04 05:43:35 -04:00
connect ( ui - > autoBanIdentities_CB , SIGNAL ( toggled ( bool ) ) , this , SLOT ( toggleAutoBanIdentities ( bool ) ) ) ;
2015-09-10 20:46:34 -04:00
2020-02-10 16:33:21 -05:00
updateCircles ( ) ;
updateIdList ( ) ;
2018-01-05 11:48:18 -05:00
}
2020-01-27 17:02:04 -05:00
void IdDialog : : handleEvent_main_thread ( std : : shared_ptr < const RsEvent > event )
{
2020-01-28 16:22:04 -05:00
if ( event - > mType = = RsEventType : : GXS_IDENTITY )
{
const RsGxsIdentityEvent * e = dynamic_cast < const RsGxsIdentityEvent * > ( event . get ( ) ) ;
2020-01-27 17:02:04 -05:00
2020-01-28 16:22:04 -05:00
if ( ! e )
return ;
2020-01-27 17:02:04 -05:00
2020-01-28 16:22:04 -05:00
switch ( e - > mIdentityEventCode )
{
case RsGxsIdentityEventCode : : DELETED_IDENTITY :
case RsGxsIdentityEventCode : : NEW_IDENTITY :
2020-02-06 13:57:23 -05:00
case RsGxsIdentityEventCode : : UPDATED_IDENTITY :
2020-01-27 17:02:04 -05:00
2020-02-10 16:33:21 -05:00
updateIdList ( ) ;
2020-02-06 13:57:23 -05:00
if ( ! mId . isNull ( ) & & mId = = e - > mIdentityId )
2020-02-11 02:36:35 -05:00
updateIdentity ( ) ;
2020-02-06 13:57:23 -05:00
break ;
2020-01-28 16:22:04 -05:00
default :
break ;
}
}
else if ( event - > mType = = RsEventType : : GXS_CIRCLES )
{
const RsGxsCircleEvent * e = dynamic_cast < const RsGxsCircleEvent * > ( event . get ( ) ) ;
2020-01-27 17:02:04 -05:00
2020-01-28 16:22:04 -05:00
if ( ! e )
return ;
2020-01-27 17:02:04 -05:00
2020-01-28 16:22:04 -05:00
switch ( e - > mCircleEventType )
{
case RsGxsCircleEventCode : : NEW_CIRCLE :
case RsGxsCircleEventCode : : CIRCLE_MEMBERSHIP_REQUEST :
case RsGxsCircleEventCode : : CIRCLE_MEMBERSHIP_INVITE :
case RsGxsCircleEventCode : : CIRCLE_MEMBERSHIP_LEAVE :
case RsGxsCircleEventCode : : CIRCLE_MEMBERSHIP_JOIN :
case RsGxsCircleEventCode : : CIRCLE_MEMBERSHIP_REVOQUED :
2020-02-11 10:37:53 -05:00
case RsGxsCircleEventCode : : CACHE_DATA_UPDATED :
2020-01-28 16:22:04 -05:00
2020-02-10 16:33:21 -05:00
updateCircles ( ) ;
2020-01-28 16:22:04 -05:00
default :
break ;
}
}
2020-01-27 17:02:04 -05:00
}
2018-01-05 11:48:18 -05:00
void IdDialog : : clearPerson ( )
{
QFontMetricsF f ( ui - > avLabel_Person - > font ( ) ) ;
ui - > avLabel_Person - > setPixmap ( QPixmap ( " :/icons/png/people.png " ) . scaled ( f . height ( ) * 4 , f . height ( ) * 4 , Qt : : IgnoreAspectRatio , Qt : : SmoothTransformation ) ) ;
ui - > headerTextLabel_Person - > setText ( tr ( " People " ) ) ;
ui - > inviteFrame - > hide ( ) ;
ui - > avatarLabel - > clear ( ) ;
whileBlocking ( ui - > ownOpinion_CB ) - > setCurrentIndex ( 1 ) ;
whileBlocking ( ui - > autoBanIdentities_CB ) - > setChecked ( false ) ;
}
2015-09-06 23:53:21 -04:00
2016-08-04 05:43:35 -04:00
void IdDialog : : toggleAutoBanIdentities ( bool b )
{
RsPgpId id ( ui - > lineEdit_GpgId - > text ( ) . left ( 16 ) . toStdString ( ) ) ;
if ( ! id . isNull ( ) )
{
rsReputations - > banNode ( id , b ) ;
2020-02-10 16:33:21 -05:00
updateIdList ( ) ;
2016-08-04 05:43:35 -04:00
}
}
2016-04-17 00:51:45 -04:00
void IdDialog : : updateCirclesDisplay ( )
2016-03-17 18:17:58 -04:00
{
2016-04-17 00:51:45 -04:00
if ( RsAutoUpdatePage : : eventsLocked ( ) )
return ;
if ( ! isVisible ( ) )
return ;
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2016-03-17 18:17:58 -04:00
std : : cerr < < " !!Updating circles display! " < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2020-02-10 16:33:21 -05:00
updateCircles ( ) ;
2016-03-17 18:17:58 -04:00
}
2015-09-06 23:53:21 -04:00
/************************** Request / Response *************************/
/*** Loading Main Index ***/
2020-02-10 16:33:21 -05:00
# ifdef TO_REMOVE
2015-09-06 23:53:21 -04:00
void IdDialog : : requestCircleGroupMeta ( )
{
mStateHelper - > setLoading ( CIRCLESDIALOG_GROUPMETA , true ) ;
2016-05-06 22:12:44 -04:00
# ifdef ID_DEBUG
2015-09-06 23:53:21 -04:00
std : : cerr < < " CirclesDialog::requestGroupMeta() " ;
std : : cerr < < std : : endl ;
2016-05-06 22:12:44 -04:00
# endif
2015-09-06 23:53:21 -04:00
mCircleQueue - > cancelActiveRequestTokens ( CIRCLESDIALOG_GROUPMETA ) ;
RsTokReqOptions opts ;
opts . mReqType = GXS_REQUEST_TYPE_GROUP_META ;
uint32_t token ;
mCircleQueue - > requestGroupInfo ( token , RS_TOKREQ_ANSTYPE_SUMMARY , opts , CIRCLESDIALOG_GROUPMETA ) ;
2012-02-13 13:43:15 -05:00
}
2016-03-24 18:41:15 -04:00
void IdDialog : : requestCircleGroupData ( const RsGxsCircleId & circle_id )
{
mStateHelper - > setLoading ( CIRCLESDIALOG_GROUPDATA , true ) ;
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2016-03-24 18:41:15 -04:00
std : : cerr < < " CirclesDialog::requestGroupData() " ;
std : : cerr < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2016-03-24 18:41:15 -04:00
mCircleQueue - > cancelActiveRequestTokens ( CIRCLESDIALOG_GROUPDATA ) ;
RsTokReqOptions opts ;
opts . mReqType = GXS_REQUEST_TYPE_GROUP_DATA ;
2016-06-05 15:49:33 -04:00
std : : list < RsGxsGroupId > grps ;
grps . push_back ( RsGxsGroupId ( circle_id ) ) ;
2016-03-24 18:41:15 -04:00
uint32_t token ;
mCircleQueue - > requestGroupInfo ( token , RS_TOKREQ_ANSTYPE_DATA , opts , grps , CIRCLESDIALOG_GROUPDATA ) ;
}
2016-06-08 21:00:26 -04:00
# endif
2016-03-24 18:41:15 -04:00
2020-02-10 16:33:21 -05:00
void IdDialog : : updateCircles ( )
2015-09-06 23:53:21 -04:00
{
2020-02-10 16:33:21 -05:00
RsThread : : async ( [ this ] ( )
{
// 1 - get message data from p3GxsForums
2015-09-06 23:53:21 -04:00
2020-02-10 16:33:21 -05:00
# ifdef DEBUG_FORUMS
std : : cerr < < " Retrieving post data for post " < < mThreadId < < std : : endl ;
# endif
std : : list < RsGroupMetaData > circle_metas ;
if ( ! rsGxsCircles - > getCirclesSummaries ( circle_metas ) )
{
std : : cerr < < __PRETTY_FUNCTION__ < < " failed to retrieve circles group info list " < < std : : endl ;
return ;
}
RsQThreadUtils : : postToObject ( [ circle_metas , this ] ( )
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread , for example to update the data model with new information
* after a blocking call to RetroShare API complete */
loadCircles ( circle_metas ) ;
} , this ) ;
} ) ;
}
void IdDialog : : loadCircles ( const std : : list < RsGroupMetaData > & groupInfo )
{
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2016-05-21 16:50:50 -04:00
std : : cerr < < " CirclesDialog::loadCircleGroupMeta() " ;
std : : cerr < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2015-09-06 23:53:21 -04:00
2016-05-21 16:50:50 -04:00
mStateHelper - > setActive ( CIRCLESDIALOG_GROUPMETA , true ) ;
2015-09-06 23:53:21 -04:00
2016-05-21 16:50:50 -04:00
/* add the top level item */
//QTreeWidgetItem *personalCirclesItem = new QTreeWidgetItem();
//personalCirclesItem->setText(0, tr("Personal Circles"));
//ui->treeWidget_membership->addTopLevelItem(personalCirclesItem);
2016-04-16 22:44:06 -04:00
2016-05-26 21:16:21 -04:00
# ifdef CIRCLE_MEMBERSHIP_CATEGORIES
2016-05-21 16:50:50 -04:00
if ( ! mExternalOtherCircleItem )
{
mExternalOtherCircleItem = new QTreeWidgetItem ( ) ;
2016-06-14 18:08:45 -04:00
mExternalOtherCircleItem - > setText ( 0 , tr ( " Other circles " ) ) ;
2016-04-16 22:44:06 -04:00
2016-05-21 16:50:50 -04:00
ui - > treeWidget_membership - > addTopLevelItem ( mExternalOtherCircleItem ) ;
}
2016-04-16 22:44:06 -04:00
2016-05-21 16:50:50 -04:00
if ( ! mExternalBelongingCircleItem )
{
mExternalBelongingCircleItem = new QTreeWidgetItem ( ) ;
2016-06-14 18:08:45 -04:00
mExternalBelongingCircleItem - > setText ( 0 , tr ( " Circles I belong to " ) ) ;
2016-05-21 16:50:50 -04:00
ui - > treeWidget_membership - > addTopLevelItem ( mExternalBelongingCircleItem ) ;
}
2016-05-26 21:16:21 -04:00
# endif
2016-04-16 22:44:06 -04:00
2016-05-21 16:50:50 -04:00
std : : list < RsGxsId > own_identities ;
rsIdentity - > getOwnIds ( own_identities ) ;
2020-02-10 16:33:21 -05:00
for ( auto vit = groupInfo . begin ( ) ; vit ! = groupInfo . end ( ) ; + + vit )
2016-05-21 16:50:50 -04:00
{
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2016-05-21 16:50:50 -04:00
std : : cerr < < " CirclesDialog::loadCircleGroupMeta() GroupId: " < < vit - > mGroupId < < " Group: " < < vit - > mGroupName < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2016-05-21 16:50:50 -04:00
RsGxsCircleDetails details ;
rsGxsCircles - > getCircleDetails ( RsGxsCircleId ( vit - > mGroupId ) , details ) ;
bool should_re_add = true ;
bool am_I_in_circle = details . mAmIAllowed ;
2016-05-28 20:58:28 -04:00
bool am_I_admin ( vit - > mSubscribeFlags & GXS_SERV : : GROUP_SUBSCRIBE_ADMIN ) ;
bool am_I_subscribed ( vit - > mSubscribeFlags & GXS_SERV : : GROUP_SUBSCRIBE_SUBSCRIBED ) ;
2016-05-21 16:50:50 -04:00
QTreeWidgetItem * item = NULL ;
2016-04-16 22:44:06 -04:00
2016-04-17 00:51:45 -04:00
# ifdef ID_DEBUG
2016-05-22 18:21:48 -04:00
std : : cerr < < " Loaded info for circle " < < vit - > mGroupId < < " . am_I_in_circle= " < < am_I_in_circle < < std : : endl ;
2016-04-17 00:51:45 -04:00
# endif
2016-04-16 22:44:06 -04:00
2016-05-21 16:50:50 -04:00
// find already existing items for this circle
2016-04-16 22:44:06 -04:00
2016-06-05 15:49:33 -04:00
// implement the search manually, because there's no find based on user role.
2016-05-25 17:51:23 -04:00
//QList<QTreeWidgetItem*> clist = ui->treeWidget_membership->findItems( QString::fromStdString(vit->mGroupId.toStdString()), Qt::MatchExactly|Qt::MatchRecursive, CIRCLEGROUP_CIRCLE_COL_GROUPID);
QList < QTreeWidgetItem * > clist ;
2016-06-05 15:49:33 -04:00
QString test_str = QString : : fromStdString ( vit - > mGroupId . toStdString ( ) ) ;
for ( QTreeWidgetItemIterator itt ( ui - > treeWidget_membership ) ; * itt ; + + itt )
if ( ( * itt ) - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole ) . toString ( ) = = test_str )
clist . push_back ( * itt ) ;
2016-04-16 22:44:06 -04:00
2016-05-21 16:50:50 -04:00
if ( ! clist . empty ( ) )
{
// delete all duplicate items. This should not happen, but just in case it does.
2016-04-16 22:44:06 -04:00
2016-05-21 16:50:50 -04:00
while ( clist . size ( ) > 1 )
{
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2016-05-21 16:50:50 -04:00
std : : cerr < < " more than 1 item correspond to this ID. Removing! " < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2016-05-21 16:50:50 -04:00
delete clist . front ( ) ;
}
2016-04-16 22:44:06 -04:00
2016-05-21 16:50:50 -04:00
item = clist . front ( ) ;
2016-04-16 22:44:06 -04:00
2016-05-26 21:16:21 -04:00
# ifdef CIRCLE_MEMBERSHIP_CATEGORIES
2016-05-21 16:50:50 -04:00
if ( am_I_in_circle & & item - > parent ( ) ! = mExternalBelongingCircleItem )
{
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2016-05-21 16:50:50 -04:00
std : : cerr < < " Existing circle is not in subscribed items although it is subscribed. Removing. " < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2016-05-21 16:50:50 -04:00
delete item ;
item = NULL ;
}
else if ( ! am_I_in_circle & & item - > parent ( ) ! = mExternalOtherCircleItem )
{
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2016-05-21 16:50:50 -04:00
std : : cerr < < " Existing circle is not in subscribed items although it is subscribed. Removing. " < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2016-05-21 16:50:50 -04:00
delete item ;
item = NULL ;
}
else
2016-05-26 21:16:21 -04:00
# endif
2016-05-21 16:50:50 -04:00
should_re_add = false ; // item already exists
}
/* Add Widget, and request Pages */
if ( should_re_add )
{
item = new QTreeWidgetItem ( ) ;
item - > setText ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , QString : : fromUtf8 ( vit - > mGroupName . c_str ( ) ) ) ;
2016-05-23 21:09:06 -04:00
item - > setData ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole , QString : : fromStdString ( vit - > mGroupId . toStdString ( ) ) ) ;
2016-05-21 16:50:50 -04:00
item - > setData ( CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS , Qt : : UserRole , QVariant ( vit - > mSubscribeFlags ) ) ;
2016-04-16 22:44:06 -04:00
2016-05-26 21:16:21 -04:00
# ifdef CIRCLE_MEMBERSHIP_CATEGORIES
2016-05-21 16:50:50 -04:00
if ( am_I_in_circle )
{
2016-04-16 22:44:06 -04:00
# ifdef ID_DEBUG
2016-05-21 16:50:50 -04:00
std : : cerr < < " adding item for circle " < < vit - > mGroupId < < " to own circles " < < std : : endl ;
2016-04-16 22:44:06 -04:00
# endif
2016-05-21 16:50:50 -04:00
mExternalBelongingCircleItem - > addChild ( item ) ;
}
else
{
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2016-05-21 16:50:50 -04:00
std : : cerr < < " adding item for circle " < < vit - > mGroupId < < " to others " < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2016-05-21 16:50:50 -04:00
mExternalOtherCircleItem - > addChild ( item ) ;
}
2016-05-26 21:16:21 -04:00
# else
2016-06-05 15:49:33 -04:00
ui - > treeWidget_membership - > addTopLevelItem ( item ) ;
2016-05-26 21:16:21 -04:00
# endif
2016-05-21 16:50:50 -04:00
}
else if ( item - > text ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME ) ! = QString : : fromUtf8 ( vit - > mGroupName . c_str ( ) ) )
{
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2016-05-21 16:50:50 -04:00
std : : cerr < < " Existing circle has a new name. Updating it in the tree. " < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2016-05-21 16:50:50 -04:00
item - > setText ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , QString : : fromUtf8 ( vit - > mGroupName . c_str ( ) ) ) ;
}
// just in case.
2016-04-16 22:44:06 -04:00
2016-05-21 16:50:50 -04:00
item - > setData ( CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS , Qt : : UserRole , QVariant ( vit - > mSubscribeFlags ) ) ;
2016-06-05 15:49:33 -04:00
2016-05-29 16:09:56 -04:00
QString tooltip ;
tooltip + = tr ( " Circle ID: " ) + QString : : fromStdString ( vit - > mGroupId . toStdString ( ) ) ;
2016-06-05 15:49:33 -04:00
tooltip + = " \n " + tr ( " Visibility: " ) ;
if ( details . mRestrictedCircleId = = details . mCircleId )
tooltip + = tr ( " Private (only visible to invited members) " ) ;
else if ( ! details . mRestrictedCircleId . isNull ( ) )
tooltip + = tr ( " Only visible to full members of circle " ) + QString : : fromStdString ( details . mRestrictedCircleId . toStdString ( ) ) ;
else
tooltip + = tr ( " Public " ) ;
tooltip + = " \n " + tr ( " Your role: " ) ;
2016-05-29 16:09:56 -04:00
if ( am_I_admin )
tooltip + = tr ( " Administrator (Can edit invite list, and request membership). " ) ;
else
tooltip + = tr ( " User (Can only request membership). " ) ;
tooltip + = " \n " + tr ( " Distribution: " ) ;
if ( am_I_subscribed )
tooltip + = tr ( " subscribed (Receive/forward membership requests from others and invite list). " ) ;
else
tooltip + = tr ( " unsubscribed (Only receive invite list). " ) ;
2016-06-05 15:49:33 -04:00
tooltip + = " \n " + tr ( " Your status: " ) ;
2016-05-29 16:09:56 -04:00
if ( am_I_in_circle )
2016-06-05 15:49:33 -04:00
tooltip + = tr ( " Full member (you have access to data limited to this circle) " ) ;
2016-05-29 16:09:56 -04:00
else
tooltip + = tr ( " Not a member (do not have access to data limited to this circle) " ) ;
item - > setToolTip ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , tooltip ) ;
2016-05-21 16:50:50 -04:00
2016-05-28 20:58:28 -04:00
if ( am_I_admin )
2016-05-21 16:50:50 -04:00
{
QFont font = item - > font ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME ) ;
font . setBold ( true ) ;
item - > setFont ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , font ) ;
item - > setFont ( CIRCLEGROUP_CIRCLE_COL_GROUPID , font ) ;
item - > setFont ( CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS , font ) ;
}
// now determine for this circle wether we have pending invites
// we add a sub-item to the circle (to show the invite system info) in the following two cases:
// - own GXS id is in admin list but not subscribed
// - own GXS id is is admin and subscribed
// - own GXS id is is subscribed
2016-06-05 15:49:33 -04:00
bool am_I_invited = false ;
bool am_I_pending = false ;
2016-05-22 18:21:48 -04:00
# ifdef ID_DEBUG
std : : cerr < < " updating status of all identities for this circle: " < < std : : endl ;
# endif
2016-06-05 15:49:33 -04:00
// remove any identity that has an item, but no subscription flag entry
2016-05-28 17:18:25 -04:00
std : : vector < QTreeWidgetItem * > to_delete ;
2016-07-29 14:54:26 -04:00
for ( uint32_t k = 0 ; k < ( uint32_t ) item - > childCount ( ) ; + + k )
2016-05-28 17:18:25 -04:00
if ( details . mSubscriptionFlags . find ( RsGxsId ( item - > child ( k ) - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole ) . toString ( ) . toStdString ( ) ) ) = = details . mSubscriptionFlags . end ( ) )
to_delete . push_back ( item - > child ( k ) ) ;
2016-06-05 15:49:33 -04:00
for ( uint32_t k = 0 ; k < to_delete . size ( ) ; + + k )
delete to_delete [ k ] ;
2016-05-25 18:34:12 -04:00
for ( std : : map < RsGxsId , uint32_t > : : const_iterator it ( details . mSubscriptionFlags . begin ( ) ) ; it ! = details . mSubscriptionFlags . end ( ) ; + + it )
2016-05-21 16:50:50 -04:00
{
2016-05-22 18:21:48 -04:00
# ifdef ID_DEBUG
2020-01-28 16:47:30 -05:00
std : : cerr < < " ID " < < it - > first < < " : " ;
2016-05-22 18:21:48 -04:00
# endif
2016-05-25 18:34:12 -04:00
bool is_own_id = rsIdentity - > isOwnId ( it - > first ) ;
bool invited ( it - > second & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST ) ;
bool subscrb ( it - > second & GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED ) ;
2016-05-21 16:50:50 -04:00
2016-05-22 18:21:48 -04:00
# ifdef ID_DEBUG
std : : cerr < < " invited: " < < invited < < " , subscription: " < < subscrb ;
# endif
2020-02-17 17:13:41 -05:00
RSTreeWidgetItem * subitem = NULL ;
2016-06-05 15:49:33 -04:00
// see if the item already exists
2016-07-29 14:54:26 -04:00
for ( uint32_t k = 0 ; k < ( uint32_t ) item - > childCount ( ) ; + + k )
2016-05-25 18:34:12 -04:00
if ( item - > child ( k ) - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole ) . toString ( ) . toStdString ( ) = = it - > first . toStdString ( ) )
2016-06-05 15:49:33 -04:00
{
2020-02-17 17:13:41 -05:00
subitem = dynamic_cast < RSTreeWidgetItem * > ( item - > child ( k ) ) ;
2016-05-22 18:21:48 -04:00
# ifdef ID_DEBUG
2016-06-05 15:49:33 -04:00
std : : cerr < < " found existing sub item. " < < std : : endl ;
2016-05-22 18:21:48 -04:00
# endif
2016-06-05 15:49:33 -04:00
break ;
}
2016-05-21 16:50:50 -04:00
if ( ! ( invited | | subscrb ) )
2016-06-05 15:49:33 -04:00
{
if ( subitem ! = NULL )
delete subitem ;
2016-05-22 18:21:48 -04:00
# ifdef ID_DEBUG
std : : cerr < < " . not relevant. Skipping. " < < std : : endl ;
# endif
2016-05-21 16:50:50 -04:00
continue ;
2016-06-05 15:49:33 -04:00
}
// remove item if flags are not ok.
if ( subitem & & subitem - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS , Qt : : UserRole ) . toUInt ( ) ! = it - > second )
{
delete subitem ;
subitem = NULL ;
}
2016-05-21 16:50:50 -04:00
2016-05-22 18:21:48 -04:00
if ( ! subitem )
2016-05-25 17:51:23 -04:00
{
2016-05-22 18:21:48 -04:00
# ifdef ID_DEBUG
std : : cerr < < " no existing sub item. Creating new one. " < < std : : endl ;
# endif
2020-02-17 17:13:41 -05:00
subitem = new RSTreeWidgetItem ( NULL ) ;
subitem - > setData ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , Qt : : UserRole , QString : : fromStdString ( it - > first . toStdString ( ) ) ) ;
2016-05-21 16:50:50 -04:00
2016-05-25 17:51:23 -04:00
RsIdentityDetails idd ;
2016-05-25 18:34:12 -04:00
bool has_id = rsIdentity - > getIdDetails ( it - > first , idd ) ;
2016-05-21 16:50:50 -04:00
2020-02-11 16:14:55 -05:00
// QPixmap pixmap ;
2016-05-21 16:50:50 -04:00
2020-02-11 16:14:55 -05:00
// if(idd.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idd.mAvatar.mData, idd.mAvatar.mSize, pixmap,GxsIdDetails::SMALL))
// pixmap = GxsIdDetails::makeDefaultIcon(it->first,GxsIdDetails::SMALL) ;
2016-05-21 16:50:50 -04:00
2020-02-11 16:14:55 -05:00
// if(has_id)
// subitem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QString::fromUtf8(idd.mNickname.c_str())) ;
// else
// subitem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, tr("Unknown ID:")+QString::fromStdString(it->first.toStdString())) ;
2016-06-05 15:49:33 -04:00
QString tooltip ;
tooltip + = tr ( " Identity ID: " ) + QString : : fromStdString ( it - > first . toStdString ( ) ) ;
tooltip + = " \n " + tr ( " Status: " ) ;
2016-05-28 20:58:28 -04:00
if ( invited )
if ( subscrb )
tooltip + = tr ( " Full member " ) ;
else
tooltip + = tr ( " Invited by admin " ) ;
else
if ( subscrb )
tooltip + = tr ( " Subscription request pending " ) ;
else
tooltip + = tr ( " unknown " ) ;
2016-06-05 15:49:33 -04:00
2016-05-28 20:58:28 -04:00
subitem - > setToolTip ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , tooltip ) ;
2016-06-05 15:49:33 -04:00
2016-05-25 18:34:12 -04:00
subitem - > setData ( CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS , Qt : : UserRole , QVariant ( it - > second ) ) ;
subitem - > setData ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole , QString : : fromStdString ( it - > first . toStdString ( ) ) ) ;
2016-05-25 17:51:23 -04:00
2020-02-11 16:14:55 -05:00
//subitem->setIcon(RSID_COL_NICKNAME, QIcon(pixmap));
2016-05-25 17:51:23 -04:00
item - > addChild ( subitem ) ;
}
2016-05-21 16:50:50 -04:00
if ( invited & & ! subscrb )
2016-06-05 15:49:33 -04:00
{
2016-05-25 17:51:23 -04:00
subitem - > setText ( CIRCLEGROUP_CIRCLE_COL_GROUPID , tr ( " Invited " ) ) ;
2016-06-05 15:49:33 -04:00
if ( is_own_id )
2016-05-25 18:34:12 -04:00
am_I_invited = true ;
2016-06-05 15:49:33 -04:00
}
2016-05-21 16:50:50 -04:00
if ( ! invited & & subscrb )
2016-05-25 18:34:12 -04:00
{
2016-05-25 17:51:23 -04:00
subitem - > setText ( CIRCLEGROUP_CIRCLE_COL_GROUPID , tr ( " Subscription pending " ) ) ;
2016-06-05 15:49:33 -04:00
if ( is_own_id )
2016-05-25 18:34:12 -04:00
am_I_pending = true ;
2016-06-05 15:49:33 -04:00
}
2016-05-21 16:50:50 -04:00
if ( invited & & subscrb )
2016-05-25 17:51:23 -04:00
subitem - > setText ( CIRCLEGROUP_CIRCLE_COL_GROUPID , tr ( " Member " ) ) ;
2016-06-05 15:49:33 -04:00
if ( is_own_id )
2016-05-25 19:04:45 -04:00
{
QFont font = subitem - > font ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME ) ;
font . setBold ( true ) ;
subitem - > setFont ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , font ) ;
subitem - > setFont ( CIRCLEGROUP_CIRCLE_COL_GROUPID , font ) ;
subitem - > setFont ( CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS , font ) ;
}
2016-05-21 16:50:50 -04:00
}
2016-06-05 15:49:33 -04:00
2016-06-16 23:17:40 -04:00
// The bullet colors below are for the *Membership*. This is independent from admin rights, which cannot be shown as a color.
// Admin/non admin is shows using Bold font.
2016-06-05 15:49:33 -04:00
if ( am_I_in_circle )
item - > setIcon ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , QIcon ( IMAGE_MEMBER ) ) ;
else if ( am_I_invited | | am_I_pending )
item - > setIcon ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , QIcon ( IMAGE_INVITED ) ) ;
else
item - > setIcon ( CIRCLEGROUP_CIRCLE_COL_GROUPNAME , QIcon ( IMAGE_UNKNOWN ) ) ;
2016-05-21 16:50:50 -04:00
}
2015-09-06 23:53:21 -04:00
}
2016-03-24 18:41:15 -04:00
static void mark_matching_tree ( QTreeWidget * w , const std : : set < RsGxsId > & members , int col )
{
w - > selectionModel ( ) - > clearSelection ( ) ;
for ( std : : set < RsGxsId > : : const_iterator it ( members . begin ( ) ) ; it ! = members . end ( ) ; + + it )
{
QList < QTreeWidgetItem * > clist = w - > findItems ( QString : : fromStdString ( ( * it ) . toStdString ( ) ) , Qt : : MatchExactly | Qt : : MatchRecursive , col ) ;
foreach ( QTreeWidgetItem * item , clist )
item - > setSelected ( true ) ;
}
}
2020-02-10 16:33:21 -05:00
# ifdef TO_REMOVE
2016-03-24 18:41:15 -04:00
void IdDialog : : loadCircleGroupData ( const uint32_t & token )
{
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2016-03-24 18:41:15 -04:00
std : : cerr < < " Loading circle info " < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2017-04-10 14:02:14 -04:00
2016-03-24 18:41:15 -04:00
std : : vector < RsGxsCircleGroup > circle_grp_v ;
rsGxsCircles - > getGroupData ( token , circle_grp_v ) ;
if ( circle_grp_v . empty ( ) )
{
std : : cerr < < " (EE) unexpected empty result from getGroupData. Cannot process circle now! " < < std : : endl ;
return ;
}
if ( circle_grp_v . size ( ) ! = 1 )
{
std : : cerr < < " (EE) very weird result from getGroupData. Should get exactly one circle " < < std : : endl ;
return ;
}
RsGxsCircleGroup cg = circle_grp_v . front ( ) ;
RsGxsCircleId requested_cid ( cg . mMeta . mGroupId ) ;
QTreeWidgetItem * item = ui - > treeWidget_membership - > currentItem ( ) ;
2016-05-26 21:16:21 -04:00
RsGxsCircleId id ;
if ( ! getItemCircleId ( item , id ) )
return ;
2016-03-24 18:41:15 -04:00
if ( requested_cid ! = id )
{
std : : cerr < < " (WW) not the same circle. Dropping request. " < < std : : endl ;
return ;
}
/* now mark all the members */
std : : set < RsGxsId > members = cg . mInvitedMembers ;
mark_matching_tree ( ui - > idTreeWidget , members , RSID_COL_KEYID ) ;
mStateHelper - > setLoading ( CIRCLESDIALOG_GROUPDATA , false ) ;
}
2015-09-06 23:53:21 -04:00
2016-06-08 21:00:26 -04:00
void IdDialog : : updateCircleGroup ( const uint32_t & token )
{
# ifdef ID_DEBUG
std : : cerr < < " Loading circle info " < < std : : endl ;
# endif
std : : vector < RsGxsCircleGroup > circle_grp_v ;
rsGxsCircles - > getGroupData ( token , circle_grp_v ) ;
if ( circle_grp_v . empty ( ) )
{
std : : cerr < < " (EE) unexpected empty result from getGroupData. Cannot process circle now! " < < std : : endl ;
return ;
}
if ( circle_grp_v . size ( ) ! = 1 )
{
std : : cerr < < " (EE) very weird result from getGroupData. Should get exactly one circle " < < std : : endl ;
return ;
}
RsGxsCircleGroup cg = circle_grp_v . front ( ) ;
/* now mark all the members */
std : : set < RsGxsId > members = cg . mInvitedMembers ;
std : : map < uint32_t , CircleUpdateOrder > : : iterator it = mCircleUpdates . find ( token ) ;
if ( it = = mCircleUpdates . end ( ) )
{
std : : cerr < < " (EE) Cannot find token " < < token < < " to perform group update! " < < std : : endl ;
return ;
}
if ( it - > second . action = = CircleUpdateOrder : : GRANT_MEMBERSHIP )
cg . mInvitedMembers . insert ( it - > second . gxs_id ) ;
else if ( it - > second . action = = CircleUpdateOrder : : REVOKE_MEMBERSHIP )
cg . mInvitedMembers . erase ( it - > second . gxs_id ) ;
else
{
std : : cerr < < " (EE) unrecognised membership action to perform: " < < it - > second . action < < " ! " < < std : : endl ;
return ;
}
uint32_t token2 ;
rsGxsCircles - > updateGroup ( token2 , cg ) ;
mCircleUpdates . erase ( it ) ;
}
2020-02-10 16:33:21 -05:00
# endif
2016-06-08 21:00:26 -04:00
2016-05-26 21:16:21 -04:00
bool IdDialog : : getItemCircleId ( QTreeWidgetItem * item , RsGxsCircleId & id )
{
# ifdef CIRCLE_MEMBERSHIP_CATEGORIES
if ( ( ! item ) | | ( ! item - > parent ( ) ) )
return false ;
QString coltext = ( item - > parent ( ) - > parent ( ) ) ? ( item - > parent ( ) - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole ) . toString ( ) ) : ( item - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole ) . toString ( ) ) ;
id = RsGxsCircleId ( coltext . toStdString ( ) ) ;
# else
if ( ! item )
return false ;
QString coltext = ( item - > parent ( ) ) ? ( item - > parent ( ) - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole ) . toString ( ) ) : ( item - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole ) . toString ( ) ) ;
id = RsGxsCircleId ( coltext . toStdString ( ) ) ;
# endif
return true ;
}
2015-09-06 23:53:21 -04:00
void IdDialog : : createExternalCircle ( )
{
CreateCircleDialog dlg ;
dlg . editNewId ( true ) ;
dlg . exec ( ) ;
}
2016-03-12 11:05:03 -05:00
void IdDialog : : showEditExistingCircle ( )
2015-09-06 23:53:21 -04:00
{
2016-05-26 21:16:21 -04:00
RsGxsCircleId id ;
2016-03-10 22:57:04 -05:00
2016-05-26 21:16:21 -04:00
if ( ! getItemCircleId ( ui - > treeWidget_membership - > currentItem ( ) , id ) )
return ;
uint32_t subscribe_flags = ui - > treeWidget_membership - > currentItem ( ) - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS , Qt : : UserRole ) . toUInt ( ) ;
2016-03-10 22:57:04 -05:00
2016-05-26 21:16:21 -04:00
CreateCircleDialog dlg ;
2016-03-10 22:57:04 -05:00
2016-05-26 21:16:21 -04:00
dlg . editExistingId ( RsGxsGroupId ( id ) , true , ! ( subscribe_flags & GXS_SERV : : GROUP_SUBSCRIBE_ADMIN ) ) ;
dlg . exec ( ) ;
2015-09-06 23:53:21 -04:00
}
2016-06-08 21:00:26 -04:00
void IdDialog : : grantCircleMembership ( )
{
2020-02-11 02:36:35 -05:00
RsGxsCircleId circle_id ;
2016-06-08 21:00:26 -04:00
if ( ! getItemCircleId ( ui - > treeWidget_membership - > currentItem ( ) , circle_id ) )
return ;
2020-02-11 02:36:35 -05:00
RsGxsId gxs_id_to_grant ( qobject_cast < QAction * > ( sender ( ) ) - > data ( ) . toString ( ) . toStdString ( ) ) ;
2016-06-08 21:00:26 -04:00
2020-02-11 02:36:35 -05:00
RsThread : : async ( [ circle_id , gxs_id_to_grant ] ( )
{
// 1 - get message data from p3GxsForums
2016-06-08 21:00:26 -04:00
2020-02-11 02:36:35 -05:00
rsGxsCircles - > inviteIdsToCircle ( std : : set < RsGxsId > ( { gxs_id_to_grant } ) , circle_id ) ;
} ) ;
2016-06-08 21:00:26 -04:00
}
void IdDialog : : revokeCircleMembership ( )
{
2020-02-11 02:36:35 -05:00
RsGxsCircleId circle_id ;
2016-06-08 21:00:26 -04:00
if ( ! getItemCircleId ( ui - > treeWidget_membership - > currentItem ( ) , circle_id ) )
return ;
RsGxsId gxs_id_to_revoke ( qobject_cast < QAction * > ( sender ( ) ) - > data ( ) . toString ( ) . toStdString ( ) ) ;
2020-02-11 02:36:35 -05:00
RsThread : : async ( [ circle_id , gxs_id_to_revoke ] ( )
{
// 1 - get message data from p3GxsForums
2016-06-08 21:00:26 -04:00
2020-02-11 02:36:35 -05:00
rsGxsCircles - > revokeIdsFromCircle ( std : : set < RsGxsId > ( { gxs_id_to_revoke } ) , circle_id ) ;
} ) ;
2016-06-08 21:00:26 -04:00
}
2016-05-06 22:12:44 -04:00
void IdDialog : : acceptCircleSubscription ( )
{
2016-05-26 21:16:21 -04:00
RsGxsCircleId circle_id ;
2016-05-06 22:12:44 -04:00
2016-05-26 21:16:21 -04:00
if ( ! getItemCircleId ( ui - > treeWidget_membership - > currentItem ( ) , circle_id ) )
return ;
RsGxsId own_id ( qobject_cast < QAction * > ( sender ( ) ) - > data ( ) . toString ( ) . toStdString ( ) ) ;
2016-05-22 18:21:48 -04:00
2016-05-11 17:59:42 -04:00
rsGxsCircles - > requestCircleMembership ( own_id , circle_id ) ;
2016-05-06 22:12:44 -04:00
}
2016-05-23 21:09:06 -04:00
void IdDialog : : cancelCircleSubscription ( )
2016-05-06 22:12:44 -04:00
{
2016-05-26 21:16:21 -04:00
RsGxsCircleId circle_id ;
2016-05-11 17:59:42 -04:00
2016-05-26 21:16:21 -04:00
if ( ! getItemCircleId ( ui - > treeWidget_membership - > currentItem ( ) , circle_id ) )
return ;
2016-05-06 22:12:44 -04:00
2016-05-26 21:16:21 -04:00
RsGxsId own_id ( qobject_cast < QAction * > ( sender ( ) ) - > data ( ) . toString ( ) . toStdString ( ) ) ;
rsGxsCircles - > cancelCircleMembership ( own_id , circle_id ) ;
2016-05-06 22:12:44 -04:00
}
2015-09-10 20:46:34 -04:00
void IdDialog : : CircleListCustomPopupMenu ( QPoint )
{
2016-05-22 18:21:48 -04:00
QMenu contextMnu ( this ) ;
2015-09-10 20:46:34 -04:00
2016-05-26 21:16:21 -04:00
RsGxsCircleId circle_id ;
2016-05-22 18:21:48 -04:00
QTreeWidgetItem * item = ui - > treeWidget_membership - > currentItem ( ) ;
2016-05-26 21:16:21 -04:00
if ( ! getItemCircleId ( item , circle_id ) )
return ;
2016-05-22 18:21:48 -04:00
RsGxsId current_gxs_id ;
2016-05-23 21:09:06 -04:00
RsGxsId item_id ( item - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole ) . toString ( ) . toStdString ( ) ) ;
2016-05-22 18:21:48 -04:00
bool is_circle ;
2016-06-08 21:00:26 -04:00
bool am_I_circle_admin = false ;
2016-04-10 10:53:21 -04:00
2016-05-26 21:16:21 -04:00
if ( item_id = = RsGxsId ( circle_id ) ) // is it a circle?
2016-05-12 22:30:12 -04:00
{
uint32_t group_flags = item - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS , Qt : : UserRole ) . toUInt ( ) ;
2015-09-10 20:46:34 -04:00
2016-05-26 21:16:21 -04:00
# ifdef CIRCLE_MEMBERSHIP_CATEGORIES
2016-05-12 22:30:12 -04:00
if ( item - > parent ( ) ! = NULL )
{
2016-05-26 21:16:21 -04:00
# endif
2016-05-12 22:30:12 -04:00
if ( group_flags & GXS_SERV : : GROUP_SUBSCRIBE_ADMIN )
2016-06-08 21:00:26 -04:00
{
2016-05-12 22:30:12 -04:00
contextMnu . addAction ( QIcon ( IMAGE_EDIT ) , tr ( " Edit Circle " ) , this , SLOT ( showEditExistingCircle ( ) ) ) ;
2016-06-08 21:00:26 -04:00
am_I_circle_admin = true ;
}
2016-05-12 22:30:12 -04:00
else
2016-06-14 18:08:45 -04:00
contextMnu . addAction ( QIcon ( IMAGE_INFO ) , tr ( " See details " ) , this , SLOT ( showEditExistingCircle ( ) ) ) ;
2016-05-26 21:16:21 -04:00
# ifdef CIRCLE_MEMBERSHIP_CATEGORIES
2016-06-08 21:00:26 -04:00
}
2016-05-26 21:16:21 -04:00
# endif
2016-05-22 18:21:48 -04:00
2017-07-20 08:29:31 -04:00
# ifdef ID_DEBUG
2016-05-22 18:21:48 -04:00
std : : cerr < < " Item is a circle item. Adding Edit/Details menu entry. " < < std : : endl ;
2017-07-20 08:29:31 -04:00
# endif
2016-05-22 18:21:48 -04:00
is_circle = true ;
contextMnu . addSeparator ( ) ;
2016-05-12 22:30:12 -04:00
}
2016-06-08 21:00:26 -04:00
else
2016-05-26 21:16:21 -04:00
{
current_gxs_id = RsGxsId ( item_id ) ;
2016-06-08 21:00:26 -04:00
is_circle = false ;
if ( item - > parent ( ) ! = NULL )
{
uint32_t group_flags = item - > parent ( ) - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS , Qt : : UserRole ) . toUInt ( ) ;
am_I_circle_admin = bool ( group_flags & GXS_SERV : : GROUP_SUBSCRIBE_ADMIN ) ;
}
2016-05-26 21:16:21 -04:00
2017-07-20 08:29:31 -04:00
# ifdef ID_DEBUG
2016-05-26 21:16:21 -04:00
std : : cerr < < " Item is a GxsId item. Requesting flags/group id from parent: " < < circle_id < < std : : endl ;
2017-07-20 08:29:31 -04:00
# endif
2016-05-26 21:16:21 -04:00
}
2016-05-12 22:30:12 -04:00
RsGxsCircleDetails details ;
2016-05-22 18:21:48 -04:00
if ( ! rsGxsCircles - > getCircleDetails ( circle_id , details ) ) // grab real circle ID from parent. Make sure circle id is used correctly afterwards!
{
std : : cerr < < " (EE) cannot get circle info for ID " < < circle_id < < " . Not in cache? " < < std : : endl ;
return ;
}
static const int REQUES = 0 ; // Admin list: no Subscription request: no
static const int ACCEPT = 1 ; // Admin list: yes Subscription request: no
static const int REMOVE = 2 ; // Admin list: yes Subscription request: yes
static const int CANCEL = 3 ; // Admin list: no Subscription request: yes
const QString menu_titles [ 4 ] = { tr ( " Request subscription " ) , tr ( " Accept circle invitation " ) , tr ( " Quit this circle " ) , tr ( " Cancel subscribe request " ) } ;
2016-06-14 18:08:45 -04:00
const QString image_names [ 4 ] = { " :/images/edit_add24.png " , " :/images/accepted16.png " , " :/images/door_in.png " , " :/images/cancel.png " } ;
2016-05-22 18:21:48 -04:00
2016-05-14 11:13:54 -04:00
std : : vector < std : : vector < RsGxsId > > ids ( 4 ) ;
2016-05-22 18:21:48 -04:00
2016-05-12 22:30:12 -04:00
std : : list < RsGxsId > own_identities ;
rsIdentity - > getOwnIds ( own_identities ) ;
2016-05-06 22:12:44 -04:00
2016-05-22 18:21:48 -04:00
// policy is:
// - if on a circle item
// => add possible subscription requests for all ids
// - if on a Id item
// => only add subscription requests for that ID
for ( std : : list < RsGxsId > : : const_iterator it ( own_identities . begin ( ) ) ; it ! = own_identities . end ( ) ; + + it )
if ( is_circle | | current_gxs_id = = * it )
{
std : : map < RsGxsId , uint32_t > : : const_iterator vit = details . mSubscriptionFlags . find ( * it ) ;
uint32_t subscribe_flags = ( vit = = details . mSubscriptionFlags . end ( ) ) ? 0 : ( vit - > second ) ;
if ( subscribe_flags & GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED )
if ( subscribe_flags & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST )
ids [ REMOVE ] . push_back ( * it ) ;
else
ids [ CANCEL ] . push_back ( * it ) ;
else
if ( subscribe_flags & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST )
ids [ ACCEPT ] . push_back ( * it ) ;
else
ids [ REQUES ] . push_back ( * it ) ;
}
2016-05-06 22:12:44 -04:00
contextMnu . addSeparator ( ) ;
2016-05-12 22:30:12 -04:00
for ( int i = 0 ; i < 4 ; + + i )
{
2016-05-22 18:21:48 -04:00
if ( ids [ i ] . size ( ) = = 1 )
2016-05-12 22:30:12 -04:00
{
2016-05-22 18:21:48 -04:00
RsIdentityDetails det ;
QString id_name ;
if ( rsIdentity - > getIdDetails ( ids [ i ] [ 0 ] , det ) )
2016-06-14 18:08:45 -04:00
id_name = tr ( " for identity " ) + QString : : fromUtf8 ( det . mNickname . c_str ( ) ) + " (ID= " + QString : : fromStdString ( ids [ i ] [ 0 ] . toStdString ( ) ) + " ) " ;
2016-05-22 18:21:48 -04:00
else
id_name = tr ( " for identity " ) + QString : : fromStdString ( ids [ i ] [ 0 ] . toStdString ( ) ) ;
QAction * action ;
if ( is_circle )
action = new QAction ( QIcon ( image_names [ i ] ) , menu_titles [ i ] + " " + id_name , this ) ;
else
action = new QAction ( QIcon ( image_names [ i ] ) , menu_titles [ i ] , this ) ;
if ( i < 2 )
2016-05-14 11:48:23 -04:00
QObject : : connect ( action , SIGNAL ( triggered ( ) ) , this , SLOT ( acceptCircleSubscription ( ) ) ) ;
2016-05-22 18:21:48 -04:00
else
2016-05-14 11:48:23 -04:00
QObject : : connect ( action , SIGNAL ( triggered ( ) ) , this , SLOT ( cancelCircleSubscription ( ) ) ) ;
2016-05-22 18:21:48 -04:00
action - > setData ( QString : : fromStdString ( ids [ i ] [ 0 ] . toStdString ( ) ) ) ;
contextMnu . addAction ( action ) ;
}
else if ( ids [ i ] . size ( ) > 1 )
{
QMenu * menu = new QMenu ( menu_titles [ i ] , this ) ;
for ( uint32_t j = 0 ; j < ids [ i ] . size ( ) ; + + j )
{
RsIdentityDetails det ;
QString id_name ;
if ( rsIdentity - > getIdDetails ( ids [ i ] [ j ] , det ) )
2016-06-14 18:08:45 -04:00
id_name = tr ( " for identity " ) + QString : : fromUtf8 ( det . mNickname . c_str ( ) ) + " (ID= " + QString : : fromStdString ( ids [ i ] [ j ] . toStdString ( ) ) + " ) " ;
2016-05-22 18:21:48 -04:00
else
id_name = tr ( " for identity " ) + QString : : fromStdString ( ids [ i ] [ j ] . toStdString ( ) ) ;
QAction * action = new QAction ( QIcon ( image_names [ i ] ) , id_name , this ) ;
if ( i < 2 )
QObject : : connect ( action , SIGNAL ( triggered ( ) ) , this , SLOT ( acceptCircleSubscription ( ) ) ) ;
else
QObject : : connect ( action , SIGNAL ( triggered ( ) ) , this , SLOT ( cancelCircleSubscription ( ) ) ) ;
action - > setData ( QString : : fromStdString ( ids [ i ] [ j ] . toStdString ( ) ) ) ;
menu - > addAction ( action ) ;
}
contextMnu . addMenu ( menu ) ;
2016-05-12 22:30:12 -04:00
}
}
2016-06-08 21:00:26 -04:00
if ( ! is_circle & & am_I_circle_admin ) // I am circle admin. I can therefore revoke/accept membership
{
std : : map < RsGxsId , uint32_t > : : const_iterator it = details . mSubscriptionFlags . find ( current_gxs_id ) ;
if ( ! current_gxs_id . isNull ( ) & & it ! = details . mSubscriptionFlags . end ( ) )
{
contextMnu . addSeparator ( ) ;
if ( it - > second & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST )
{
QAction * action = new QAction ( tr ( " Revoke this member " ) , this ) ;
action - > setData ( QString : : fromStdString ( current_gxs_id . toStdString ( ) ) ) ;
QObject : : connect ( action , SIGNAL ( triggered ( ) ) , this , SLOT ( revokeCircleMembership ( ) ) ) ;
contextMnu . addAction ( action ) ;
}
else
{
QAction * action = new QAction ( tr ( " Grant membership " ) , this ) ;
action - > setData ( QString : : fromStdString ( current_gxs_id . toStdString ( ) ) ) ;
QObject : : connect ( action , SIGNAL ( triggered ( ) ) , this , SLOT ( grantCircleMembership ( ) ) ) ;
contextMnu . addAction ( action ) ;
}
}
}
2016-05-22 18:21:48 -04:00
2016-05-12 22:30:12 -04:00
contextMnu . exec ( QCursor : : pos ( ) ) ;
2015-09-10 20:46:34 -04:00
}
2017-04-07 13:29:27 -04:00
# ifdef SUSPENDED
2015-09-06 23:53:21 -04:00
static void set_item_background ( QTreeWidgetItem * item , uint32_t type )
{
QBrush brush ;
switch ( type )
{
default :
case CLEAR_BACKGROUND :
brush = QBrush ( Qt : : white ) ;
break ;
case GREEN_BACKGROUND :
brush = QBrush ( Qt : : green ) ;
break ;
case BLUE_BACKGROUND :
brush = QBrush ( Qt : : blue ) ;
break ;
case RED_BACKGROUND :
brush = QBrush ( Qt : : red ) ;
break ;
case GRAY_BACKGROUND :
brush = QBrush ( Qt : : gray ) ;
break ;
}
item - > setBackground ( 0 , brush ) ;
}
static void update_children_background ( QTreeWidgetItem * item , uint32_t type )
{
int count = item - > childCount ( ) ;
for ( int i = 0 ; i < count ; + + i )
{
QTreeWidgetItem * child = item - > child ( i ) ;
if ( child - > childCount ( ) > 0 )
{
update_children_background ( child , type ) ;
}
set_item_background ( child , type ) ;
}
}
static void set_tree_background ( QTreeWidget * tree , uint32_t type )
{
std : : cerr < < " CirclesDialog set_tree_background() " ;
std : : cerr < < std : : endl ;
/* grab all toplevel */
int count = tree - > topLevelItemCount ( ) ;
for ( int i = 0 ; i < count ; + + i )
{
QTreeWidgetItem * item = tree - > topLevelItem ( i ) ;
/* resursively clear child backgrounds */
update_children_background ( item , type ) ;
set_item_background ( item , type ) ;
}
}
static void check_mark_item ( QTreeWidgetItem * item , const std : : set < RsPgpId > & names , uint32_t col , uint32_t type )
{
QString coltext = item - > text ( col ) ;
RsPgpId colstr ( coltext . toStdString ( ) ) ;
if ( names . end ( ) ! = names . find ( colstr ) )
{
set_item_background ( item , type ) ;
std : : cerr < < " CirclesDialog check_mark_item: found match: " < < colstr ;
std : : cerr < < std : : endl ;
}
}
2016-05-26 21:16:21 -04:00
2015-09-06 23:53:21 -04:00
void IdDialog : : circle_selected ( )
{
QTreeWidgetItem * item = ui - > treeWidget_membership - > currentItem ( ) ;
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2015-09-06 23:53:21 -04:00
std : : cerr < < " CirclesDialog::circle_selected() valid circle chosen " ;
std : : cerr < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2016-03-12 10:41:35 -05:00
//set_item_background(item, BLUE_BACKGROUND);
2015-09-06 23:53:21 -04:00
2016-05-23 21:09:06 -04:00
QString coltext = ( item - > parent ( ) - > parent ( ) ) ? ( item - > parent ( ) - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole ) . toString ( ) ) : ( item - > data ( CIRCLEGROUP_CIRCLE_COL_GROUPID , Qt : : UserRole ) . toString ( ) ) ;
2016-03-08 00:02:16 -05:00
RsGxsCircleId id ( coltext . toStdString ( ) ) ;
2015-09-06 23:53:21 -04:00
2016-03-24 18:41:15 -04:00
requestCircleGroupData ( id ) ;
2015-09-06 23:53:21 -04:00
}
2016-05-26 21:16:21 -04:00
# endif
2016-03-24 18:41:15 -04:00
2014-10-12 06:46:09 -04:00
IdDialog : : ~ IdDialog ( )
{
2020-01-31 16:37:21 -05:00
rsEvents - > unregisterEventsHandler ( mEventHandlerId_identity ) ;
rsEvents - > unregisterEventsHandler ( mEventHandlerId_circles ) ;
2014-12-24 09:43:06 -05:00
// save settings
processSettings ( false ) ;
delete ( ui ) ;
2014-10-12 06:46:09 -04:00
}
2015-09-10 11:37:42 -04:00
static QString getHumanReadableDuration ( uint32_t seconds )
{
if ( seconds < 60 )
return QString ( QObject : : tr ( " %1 seconds ago " ) ) . arg ( seconds ) ;
else if ( seconds < 120 )
return QString ( QObject : : tr ( " %1 minute ago " ) ) . arg ( seconds / 60 ) ;
else if ( seconds < 3600 )
return QString ( QObject : : tr ( " %1 minutes ago " ) ) . arg ( seconds / 60 ) ;
else if ( seconds < 7200 )
return QString ( QObject : : tr ( " %1 hour ago " ) ) . arg ( seconds / 3600 ) ;
else if ( seconds < 24 * 3600 )
return QString ( QObject : : tr ( " %1 hours ago " ) ) . arg ( seconds / 3600 ) ;
else if ( seconds < 2 * 24 * 3600 )
return QString ( QObject : : tr ( " %1 day ago " ) ) . arg ( seconds / 86400 ) ;
else
return QString ( QObject : : tr ( " %1 days ago " ) ) . arg ( seconds / 86400 ) ;
}
2014-12-24 09:43:06 -05:00
void IdDialog : : processSettings ( bool load )
{
Settings - > beginGroup ( " IdDialog " ) ;
2015-08-11 10:01:43 -04:00
// state of peer tree
ui - > idTreeWidget - > processSettings ( load ) ;
2014-12-24 09:43:06 -05:00
if ( load ) {
// load settings
// filterColumn
ui - > filterLineEdit - > setCurrentFilter ( Settings - > value ( " filterColumn " , RSID_COL_NICKNAME ) . toInt ( ) ) ;
// state of splitter
2016-07-29 14:54:26 -04:00
ui - > mainSplitter - > restoreState ( Settings - > value ( " splitter " ) . toByteArray ( ) ) ;
2014-12-24 09:43:06 -05:00
} else {
// save settings
// filterColumn
Settings - > setValue ( " filterColumn " , ui - > filterLineEdit - > currentFilter ( ) ) ;
// state of splitter
2016-07-29 14:54:26 -04:00
Settings - > setValue ( " splitter " , ui - > mainSplitter - > saveState ( ) ) ;
2015-12-27 13:14:20 -05:00
//save expanding
Settings - > setValue ( " ExpandAll " , allItem - > isExpanded ( ) ) ;
Settings - > setValue ( " ExpandContacts " , contactsItem - > isExpanded ( ) ) ;
2016-04-09 17:50:46 -04:00
Settings - > setValue ( " ExpandOwn " , ownItem - > isExpanded ( ) ) ;
2014-12-24 09:43:06 -05:00
}
Settings - > endGroup ( ) ;
2013-07-10 17:57:23 -04:00
}
2016-07-29 14:54:26 -04:00
void IdDialog : : filterChanged ( const QString & /*text*/ )
2013-07-11 04:14:38 -04:00
{
2016-07-29 14:54:26 -04:00
filterIds ( ) ;
2013-07-11 04:14:38 -04:00
}
2012-02-13 13:43:15 -05:00
2016-07-29 14:54:26 -04:00
void IdDialog : : filterToggled ( const bool & value )
2013-07-10 17:57:23 -04:00
{
2016-07-29 14:54:26 -04:00
if ( value ) {
QAction * source = qobject_cast < QAction * > ( QObject : : sender ( ) ) ;
if ( source ) {
filter = source - > data ( ) . toInt ( ) ;
2020-02-10 16:33:21 -05:00
updateIdList ( ) ;
2016-07-29 14:54:26 -04:00
}
}
2013-07-10 17:57:23 -04:00
}
2012-02-13 13:43:15 -05:00
void IdDialog : : updateSelection ( )
{
2015-08-11 10:01:43 -04:00
QTreeWidgetItem * item = ui - > idTreeWidget - > currentItem ( ) ;
2014-12-24 09:43:06 -05:00
RsGxsGroupId id ;
2013-07-10 17:57:23 -04:00
2014-12-24 09:43:06 -05:00
if ( item ) {
id = RsGxsGroupId ( item - > text ( RSID_COL_KEYID ) . toStdString ( ) ) ;
2013-07-10 17:57:23 -04:00
}
2014-12-24 09:43:06 -05:00
if ( id ! = mId ) {
mId = id ;
2020-02-11 02:36:35 -05:00
updateIdentity ( ) ;
2020-02-10 16:33:21 -05:00
//updateRepList();
2014-12-24 09:43:06 -05:00
}
2013-07-10 17:57:23 -04:00
}
2017-04-10 14:02:14 -04:00
2020-02-10 16:33:21 -05:00
void IdDialog : : updateIdList ( )
2013-07-10 17:57:23 -04:00
{
2014-12-24 09:43:06 -05:00
//Disable by default, will be enable by insertIdDetails()
2015-01-25 09:14:03 -05:00
ui - > removeIdentity - > setEnabled ( false ) ;
ui - > editIdentity - > setEnabled ( false ) ;
2014-12-24 09:43:06 -05:00
2020-02-10 16:33:21 -05:00
int accept = filter ;
2013-07-10 17:57:23 -04:00
2020-02-10 16:33:21 -05:00
RsThread : : async ( [ this ] ( )
{
// 1 - get message data from p3GxsForums
2013-07-10 17:57:23 -04:00
2020-02-10 16:33:21 -05:00
# ifdef DEBUG_FORUMS
std : : cerr < < " Retrieving post data for post " < < mThreadId < < std : : endl ;
# endif
std : : list < RsGroupMetaData > identity_metas ;
if ( ! rsIdentity - > getIdentitiesSummaries ( identity_metas ) )
{
std : : cerr < < " IdDialog::insertIdList() Error getting GroupData " < < std : : endl ;
return ;
}
2013-07-10 17:57:23 -04:00
2020-02-10 16:33:21 -05:00
std : : set < RsGxsId > ids ;
for ( auto it ( identity_metas . begin ( ) ) ; it ! = identity_metas . end ( ) ; + + it )
ids . insert ( RsGxsId ( ( * it ) . mGroupId ) ) ;
std : : vector < RsGxsIdGroup > groups ;
if ( ! rsIdentity - > getIdentitiesInfo ( ids , groups ) )
{
std : : cerr < < " IdDialog::insertIdList() Error getting identities info " < < std : : endl ;
return ;
}
std : : map < RsGxsGroupId , RsGxsIdGroup > ids_set ;
for ( auto it ( groups . begin ( ) ) ; it ! = groups . end ( ) ; + + it )
ids_set [ ( * it ) . mMeta . mGroupId ] = * it ;
RsQThreadUtils : : postToObject ( [ ids_set , this ] ( )
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread , for example to update the data model with new information
* after a blocking call to RetroShare API complete */
loadIdentities ( ids_set ) ;
} , this ) ;
} ) ;
2013-07-10 17:57:23 -04:00
}
2014-03-17 16:56:06 -04:00
bool IdDialog : : fillIdListItem ( const RsGxsIdGroup & data , QTreeWidgetItem * & item , const RsPgpId & ownPgpId , int accept )
2013-07-10 17:57:23 -04:00
{
2016-08-15 13:53:43 -04:00
bool isLinkedToOwnNode = ( data . mPgpKnown & & ( data . mPgpId = = ownPgpId ) ) ;
bool isOwnId = ( data . mMeta . mSubscribeFlags & GXS_SERV : : GROUP_SUBSCRIBE_ADMIN ) ;
RsIdentityDetails idd ;
rsIdentity - > getIdDetails ( RsGxsId ( data . mMeta . mGroupId ) , idd ) ;
2016-12-23 11:52:02 -05:00
2019-02-16 09:42:22 -05:00
bool isBanned = idd . mReputation . mOverallReputationLevel = =
RsReputationLevel : : LOCALLY_NEGATIVE ;
uint32_t item_flags = 0 ;
2013-07-10 17:57:23 -04:00
/* do filtering */
bool ok = false ;
2017-02-07 14:15:55 -05:00
if ( data . mMeta . mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility )
2015-02-05 15:37:24 -05:00
{
if ( isLinkedToOwnNode & & ( accept & RSID_FILTER_YOURSELF ) )
{
ok = true ;
item_flags | = RSID_FILTER_YOURSELF ;
}
if ( data . mPgpKnown & & ( accept & RSID_FILTER_FRIENDS ) )
{
ok = true ;
item_flags | = RSID_FILTER_FRIENDS ;
}
if ( accept & RSID_FILTER_OTHERS )
{
ok = true ;
item_flags | = RSID_FILTER_OTHERS ;
}
}
else if ( accept & RSID_FILTER_PSEUDONYMS )
{
ok = true ;
item_flags | = RSID_FILTER_PSEUDONYMS ;
}
if ( isOwnId & & ( accept & RSID_FILTER_OWNED_BY_YOU ) )
{
ok = true ;
item_flags | = RSID_FILTER_OWNED_BY_YOU ;
}
2013-07-10 17:57:23 -04:00
2016-08-15 13:53:43 -04:00
if ( isBanned & & ( accept & RSID_FILTER_BANNED ) )
{
ok = true ;
item_flags | = RSID_FILTER_BANNED ;
}
2013-07-10 17:57:23 -04:00
if ( ! ok )
return false ;
2012-02-13 13:43:15 -05:00
if ( ! item )
2020-02-11 16:14:55 -05:00
{
2016-01-16 08:50:12 -05:00
item = new TreeWidgetItem ( ) ;
2020-02-11 16:14:55 -05:00
}
2015-12-22 18:29:27 -05:00
2015-02-05 15:37:24 -05:00
2015-04-09 15:53:01 -04:00
item - > setText ( RSID_COL_NICKNAME , QString : : fromUtf8 ( data . mMeta . mGroupName . c_str ( ) ) . left ( RSID_MAXIMUM_NICKNAME_SIZE ) ) ;
2015-02-05 15:37:24 -05:00
item - > setText ( RSID_COL_KEYID , QString : : fromStdString ( data . mMeta . mGroupId . toStdString ( ) ) ) ;
2015-09-10 11:37:42 -04:00
2016-08-15 13:53:43 -04:00
if ( isBanned )
2016-07-03 18:12:50 -04:00
{
2016-07-03 22:02:23 -04:00
item - > setForeground ( RSID_COL_NICKNAME , QBrush ( Qt : : red ) ) ;
item - > setForeground ( RSID_COL_KEYID , QBrush ( Qt : : red ) ) ;
item - > setForeground ( RSID_COL_IDTYPE , QBrush ( Qt : : red ) ) ;
2016-08-15 13:53:43 -04:00
item - > setForeground ( RSID_COL_VOTES , QBrush ( Qt : : red ) ) ;
2016-07-03 22:02:23 -04:00
}
else
{
item - > setForeground ( RSID_COL_NICKNAME , QBrush ( Qt : : black ) ) ;
item - > setForeground ( RSID_COL_KEYID , QBrush ( Qt : : black ) ) ;
item - > setForeground ( RSID_COL_IDTYPE , QBrush ( Qt : : black ) ) ;
2016-08-15 13:53:43 -04:00
item - > setForeground ( RSID_COL_VOTES , QBrush ( Qt : : black ) ) ;
2016-07-03 18:12:50 -04:00
}
2016-07-03 22:02:23 -04:00
2015-02-05 15:37:24 -05:00
item - > setData ( RSID_COL_KEYID , Qt : : UserRole , QVariant ( item_flags ) ) ;
2016-08-15 13:53:43 -04:00
item - > setTextAlignment ( RSID_COL_VOTES , Qt : : AlignRight | Qt : : AlignVCenter ) ;
2019-02-16 09:42:22 -05:00
item - > setData (
RSID_COL_VOTES , Qt : : DecorationRole ,
static_cast < uint32_t > ( idd . mReputation . mOverallReputationLevel ) ) ;
item - > setData (
RSID_COL_VOTES , SortRole ,
static_cast < uint32_t > ( idd . mReputation . mOverallReputationLevel ) ) ;
2014-09-24 17:00:40 -04:00
2016-06-17 22:21:06 -04:00
if ( isOwnId )
{
QFont font = item - > font ( RSID_COL_NICKNAME ) ;
font . setBold ( true ) ;
item - > setFont ( RSID_COL_NICKNAME , font ) ;
item - > setFont ( RSID_COL_IDTYPE , font ) ;
item - > setFont ( RSID_COL_KEYID , font ) ;
QString tooltip = tr ( " This identity is owned by you " ) ;
if ( idd . mFlags & RS_IDENTITY_FLAGS_IS_DEPRECATED )
{
item - > setForeground ( RSID_COL_NICKNAME , QBrush ( Qt : : red ) ) ;
item - > setForeground ( RSID_COL_KEYID , QBrush ( Qt : : red ) ) ;
item - > setForeground ( RSID_COL_IDTYPE , QBrush ( Qt : : red ) ) ;
tooltip + = tr ( " \n This identity has a unsecure fingerprint (It's probably quite old). \n You should get rid of it now and use a new one. \n These identities will soon be not supported anymore. " ) ;
}
item - > setToolTip ( RSID_COL_NICKNAME , tooltip ) ;
item - > setToolTip ( RSID_COL_KEYID , tooltip ) ;
item - > setToolTip ( RSID_COL_IDTYPE , tooltip ) ;
}
2014-09-24 16:13:19 -04:00
2015-01-25 17:09:12 -05:00
QPixmap pixmap ;
2019-06-04 05:49:26 -04:00
if ( data . mImage . mSize = = 0 | | ! GxsIdDetails : : loadPixmapFromData ( data . mImage . mData , data . mImage . mSize , pixmap , GxsIdDetails : : SMALL ) )
pixmap = GxsIdDetails : : makeDefaultIcon ( RsGxsId ( data . mMeta . mGroupId ) , GxsIdDetails : : SMALL ) ;
2015-01-25 17:09:12 -05:00
item - > setIcon ( RSID_COL_NICKNAME , QIcon ( pixmap ) ) ;
2014-09-15 19:28:53 -04:00
2015-02-17 16:31:14 -05:00
QString tooltip ;
2017-02-07 14:15:55 -05:00
if ( data . mMeta . mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility )
2013-07-10 17:57:23 -04:00
{
if ( data . mPgpKnown )
{
RsPeerDetails details ;
rsPeers - > getGPGDetails ( data . mPgpId , details ) ;
item - > setText ( RSID_COL_IDTYPE , QString : : fromUtf8 ( details . name . c_str ( ) ) ) ;
2016-04-02 16:54:30 -04:00
item - > setToolTip ( RSID_COL_IDTYPE , " Verified signature from node " + QString : : fromStdString ( data . mPgpId . toStdString ( ) ) ) ;
2015-02-17 16:31:14 -05:00
2015-06-12 04:27:26 -04:00
tooltip + = tr ( " Node name: " ) + " " + QString : : fromUtf8 ( details . name . c_str ( ) ) + " \n " ;
tooltip + = tr ( " Node Id : " ) + " " + QString : : fromStdString ( data . mPgpId . toStdString ( ) ) ;
2015-02-17 16:31:14 -05:00
item - > setToolTip ( RSID_COL_KEYID , tooltip ) ;
2013-07-10 17:57:23 -04:00
}
2016-04-02 14:04:08 -04:00
else
2014-04-14 11:37:06 -04:00
{
2016-04-02 14:04:08 -04:00
QString txt = tr ( " [Unknown node] " ) ;
item - > setText ( RSID_COL_IDTYPE , txt ) ;
2016-04-02 16:50:22 -04:00
if ( ! data . mPgpId . isNull ( ) )
{
2016-04-02 16:54:30 -04:00
item - > setToolTip ( RSID_COL_IDTYPE , tr ( " Unverified signature from node " ) + QString : : fromStdString ( data . mPgpId . toStdString ( ) ) ) ;
item - > setToolTip ( RSID_COL_KEYID , tr ( " Unverified signature from node " ) + QString : : fromStdString ( data . mPgpId . toStdString ( ) ) ) ;
2016-04-02 16:50:22 -04:00
}
else
{
2016-04-02 16:54:30 -04:00
item - > setToolTip ( RSID_COL_IDTYPE , tr ( " Unchecked signature " ) ) ;
item - > setToolTip ( RSID_COL_KEYID , tr ( " Unchecked signature " ) ) ;
2016-04-02 16:50:22 -04:00
}
2014-04-14 11:37:06 -04:00
}
2012-06-07 13:11:57 -04:00
}
2013-07-10 17:57:23 -04:00
else
{
2014-09-24 16:13:19 -04:00
item - > setText ( RSID_COL_IDTYPE , QString ( ) ) ;
item - > setToolTip ( RSID_COL_IDTYPE , QString ( ) ) ;
2013-07-10 17:57:23 -04:00
}
2012-02-13 13:43:15 -05:00
2013-07-10 17:57:23 -04:00
return true ;
}
2012-02-13 13:43:15 -05:00
2020-02-10 16:33:21 -05:00
void IdDialog : : loadIdentities ( const std : : map < RsGxsGroupId , RsGxsIdGroup > & ids_set_const )
2012-06-07 13:11:57 -04:00
{
2020-02-10 16:33:21 -05:00
auto ids_set ( ids_set_const ) ;
2017-07-20 08:29:31 -04:00
//First: Get current item to restore after
RsGxsGroupId oldCurrentId = mIdToNavigate ;
{
QTreeWidgetItem * oldCurrent = ui - > idTreeWidget - > currentItem ( ) ;
if ( oldCurrent ) {
oldCurrentId = RsGxsGroupId ( oldCurrent - > text ( RSID_COL_KEYID ) . toStdString ( ) ) ;
}
}
2020-02-10 16:33:21 -05:00
int accept = filter ;
2012-02-13 13:43:15 -05:00
2013-07-10 17:57:23 -04:00
mStateHelper - > setActive ( IDDIALOG_IDLIST , true ) ;
2014-03-17 16:56:06 -04:00
RsPgpId ownPgpId = rsPeers - > getGPGOwnId ( ) ;
2012-02-13 13:43:15 -05:00
2015-12-23 12:08:20 -05:00
// Update existing and remove not existing items
// Also remove items that do not have the correct parent
2015-08-11 10:01:43 -04:00
QTreeWidgetItemIterator itemIterator ( ui - > idTreeWidget ) ;
2013-07-10 17:57:23 -04:00
QTreeWidgetItem * item = NULL ;
2015-12-23 12:08:20 -05:00
while ( ( item = * itemIterator ) ! = NULL )
{
2014-10-21 18:33:02 -04:00
+ + itemIterator ;
2020-02-10 16:33:21 -05:00
auto it = ids_set . find ( RsGxsGroupId ( item - > text ( RSID_COL_KEYID ) . toStdString ( ) ) ) ;
2012-06-13 20:36:25 -04:00
2015-12-23 12:08:20 -05:00
if ( it = = ids_set . end ( ) )
2013-07-10 17:57:23 -04:00
{
2016-04-09 17:50:46 -04:00
if ( item ! = allItem & & item ! = contactsItem & & item ! = ownItem )
2013-07-10 17:57:23 -04:00
delete ( item ) ;
2020-02-10 16:33:21 -05:00
continue ;
}
QTreeWidgetItem * parent_item = item - > parent ( ) ;
if ( ( parent_item = = allItem & & it - > second . mIsAContact ) | | ( parent_item = = contactsItem & & ! it - > second . mIsAContact ) )
{
delete item ; // do not remove from the list, so that it is added again in the correct place.
continue ;
}
2015-12-23 12:08:20 -05:00
if ( ! fillIdListItem ( it - > second , item , ownPgpId , accept ) )
delete ( item ) ;
2020-02-10 16:33:21 -05:00
2015-12-23 12:08:20 -05:00
ids_set . erase ( it ) ; // erase, so it is not considered to be a new item
2013-07-10 17:57:23 -04:00
}
/* Insert new items */
2015-12-23 12:08:20 -05:00
for ( std : : map < RsGxsGroupId , RsGxsIdGroup > : : const_iterator vit = ids_set . begin ( ) ; vit ! = ids_set . end ( ) ; + + vit )
2018-01-05 11:48:18 -05:00
{
RsGxsIdGroup data = vit - > second ;
2013-07-10 17:57:23 -04:00
2016-04-09 17:50:46 -04:00
item = NULL ;
2015-12-22 18:29:27 -05:00
2016-04-09 17:50:46 -04:00
ui - > idTreeWidget - > insertTopLevelItem ( 0 , ownItem ) ;
ui - > idTreeWidget - > insertTopLevelItem ( 0 , allItem ) ;
ui - > idTreeWidget - > insertTopLevelItem ( 0 , contactsItem ) ;
2015-12-22 18:29:27 -05:00
2016-04-09 17:50:46 -04:00
Settings - > beginGroup ( " IdDialog " ) ;
allItem - > setExpanded ( Settings - > value ( " ExpandAll " , QVariant ( true ) ) . toBool ( ) ) ;
ownItem - > setExpanded ( Settings - > value ( " ExpandOwn " , QVariant ( true ) ) . toBool ( ) ) ;
contactsItem - > setExpanded ( Settings - > value ( " ExpandContacts " , QVariant ( true ) ) . toBool ( ) ) ;
Settings - > endGroup ( ) ;
2018-01-05 11:48:18 -05:00
if ( fillIdListItem ( data , item , ownPgpId , accept ) )
{
if ( data . mMeta . mSubscribeFlags & GXS_SERV : : GROUP_SUBSCRIBE_ADMIN )
ownItem - > addChild ( item ) ;
else if ( data . mIsAContact )
contactsItem - > addChild ( item ) ;
else
allItem - > addChild ( item ) ;
}
2020-02-11 16:14:55 -05:00
GxsIdLabel * label = new GxsIdLabel ( ) ;
label - > setId ( RsGxsId ( data . mMeta . mGroupId ) ) ;
ui - > treeWidget_membership - > setItemWidget ( item , 0 , label ) ;
2018-01-05 11:48:18 -05:00
}
2015-12-24 11:46:02 -05:00
/* count items */
2016-04-09 17:50:46 -04:00
int itemCount = contactsItem - > childCount ( ) + allItem - > childCount ( ) + ownItem - > childCount ( ) ;
2015-12-24 11:46:02 -05:00
ui - > label_count - > setText ( " ( " + QString : : number ( itemCount ) + " ) " ) ;
2013-07-10 17:57:23 -04:00
2017-07-20 08:29:31 -04:00
navigate ( RsGxsId ( oldCurrentId ) ) ;
2013-07-10 17:57:23 -04:00
filterIds ( ) ;
updateSelection ( ) ;
}
2012-06-13 20:36:25 -04:00
2020-02-11 02:36:35 -05:00
void IdDialog : : updateIdentity ( )
2012-02-13 13:43:15 -05:00
{
2014-12-24 09:43:06 -05:00
if ( mId . isNull ( ) )
2013-07-10 17:57:23 -04:00
{
mStateHelper - > setActive ( IDDIALOG_IDDETAILS , false ) ;
mStateHelper - > setLoading ( IDDIALOG_IDDETAILS , false ) ;
mStateHelper - > clear ( IDDIALOG_IDDETAILS ) ;
2018-01-05 11:48:18 -05:00
clearPerson ( ) ;
2013-07-10 17:57:23 -04:00
return ;
}
mStateHelper - > setLoading ( IDDIALOG_IDDETAILS , true ) ;
2020-02-11 02:36:35 -05:00
RsThread : : async ( [ this ] ( )
{
# ifdef ID_DEBUG
std : : cerr < < " Retrieving post data for identity " < < mThreadId < < std : : endl ;
# endif
2012-02-13 13:43:15 -05:00
2020-02-11 02:36:35 -05:00
std : : set < RsGxsId > ids ( { RsGxsId ( mId ) } ) ;
std : : vector < RsGxsIdGroup > ids_data ;
2013-07-10 17:57:23 -04:00
2020-02-11 02:36:35 -05:00
if ( ! rsIdentity - > getIdentitiesInfo ( ids , ids_data ) )
{
std : : cerr < < __PRETTY_FUNCTION__ < < " failed to retrieve identities group info for id " < < mId < < std : : endl ;
return ;
}
2013-07-10 17:57:23 -04:00
2020-02-11 02:36:35 -05:00
if ( ids_data . size ( ) ! = 1 )
{
std : : cerr < < __PRETTY_FUNCTION__ < < " failed to retrieve exactly one group info for id " < < mId < < std : : endl ;
return ;
}
RsGxsIdGroup group ( ids_data [ 0 ] ) ;
2013-07-10 17:57:23 -04:00
2020-02-11 02:36:35 -05:00
RsQThreadUtils : : postToObject ( [ group , this ] ( )
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread , for example to update the data model with new information
* after a blocking call to RetroShare API complete */
2012-06-07 13:11:57 -04:00
2020-02-11 02:36:35 -05:00
loadIdentity ( group ) ;
2013-07-10 17:57:23 -04:00
2020-02-11 02:36:35 -05:00
} , this ) ;
} ) ;
}
2013-07-10 17:57:23 -04:00
2020-02-11 02:36:35 -05:00
void IdDialog : : loadIdentity ( RsGxsIdGroup data )
{
mStateHelper - > setLoading ( IDDIALOG_IDDETAILS , false ) ;
2013-07-10 17:57:23 -04:00
2020-02-11 02:36:35 -05:00
/* get details from libretroshare */
2012-11-01 20:49:06 -04:00
2013-07-10 17:57:23 -04:00
mStateHelper - > setActive ( IDDIALOG_IDDETAILS , true ) ;
2012-06-07 13:11:57 -04:00
/* get GPG Details from rsPeers */
2014-03-17 16:56:06 -04:00
RsPgpId ownPgpId = rsPeers - > getGPGOwnId ( ) ;
2013-07-11 04:14:38 -04:00
2019-01-28 05:26:30 -05:00
ui - > lineEdit_PublishTS - > setText ( QDateTime : : fromMSecsSinceEpoch ( qint64 ( 1000 ) * data . mMeta . mPublishTs ) . toString ( Qt : : SystemLocaleShortDate ) ) ;
2015-04-21 14:42:56 -04:00
ui - > lineEdit_Nickname - > setText ( QString : : fromUtf8 ( data . mMeta . mGroupName . c_str ( ) ) . left ( RSID_MAXIMUM_NICKNAME_SIZE ) ) ;
2014-12-24 09:43:06 -05:00
ui - > lineEdit_KeyId - > setText ( QString : : fromStdString ( data . mMeta . mGroupId . toStdString ( ) ) ) ;
//ui->lineEdit_GpgHash->setText(QString::fromStdString(data.mPgpIdHash.toStdString()));
2016-04-02 14:04:08 -04:00
if ( data . mPgpKnown )
ui - > lineEdit_GpgId - > setText ( QString : : fromStdString ( data . mPgpId . toStdString ( ) ) ) ;
else
ui - > lineEdit_GpgId - > setText ( QString : : fromStdString ( data . mPgpId . toStdString ( ) ) + tr ( " [unverified] " ) ) ;
2015-03-14 10:33:23 -04:00
2016-08-04 05:43:35 -04:00
ui - > autoBanIdentities_CB - > setVisible ( ! data . mPgpId . isNull ( ) ) ;
2016-08-23 21:28:57 -04:00
ui - > banoption_label - > setVisible ( ! data . mPgpId . isNull ( ) ) ;
2016-08-04 05:43:35 -04:00
2015-03-14 10:33:23 -04:00
time_t now = time ( NULL ) ;
ui - > lineEdit_LastUsed - > setText ( getHumanReadableDuration ( now - data . mLastUsageTS ) ) ;
2016-07-29 14:54:26 -04:00
ui - > headerTextLabel_Person - > setText ( QString : : fromUtf8 ( data . mMeta . mGroupName . c_str ( ) ) . left ( RSID_MAXIMUM_NICKNAME_SIZE ) ) ;
2012-11-05 17:32:52 -05:00
2015-01-25 17:09:12 -05:00
QPixmap pixmap ;
2019-06-04 05:49:26 -04:00
if ( data . mImage . mSize = = 0 | | ! GxsIdDetails : : loadPixmapFromData ( data . mImage . mData , data . mImage . mSize , pixmap , GxsIdDetails : : LARGE ) )
pixmap = GxsIdDetails : : makeDefaultIcon ( RsGxsId ( data . mMeta . mGroupId ) , GxsIdDetails : : LARGE ) ;
2015-01-25 17:09:12 -05:00
2014-10-25 09:16:47 -04:00
# ifdef ID_DEBUG
2016-04-14 23:47:42 -04:00
std : : cerr < < " Setting header frame image : " < < pixmap . width ( ) < < " x " < < pixmap . height ( ) < < std : : endl ;
2014-10-25 09:16:47 -04:00
# endif
2015-09-10 11:37:42 -04:00
2017-12-07 11:20:27 -05:00
//ui->avLabel_Person->setPixmap(pixmap);
//ui->avatarLabel->setPixmap(pixmap);
QFontMetricsF f ( ui - > avLabel_Person - > font ( ) ) ;
ui - > avLabel_Person - > setPixmap ( pixmap . scaled ( f . height ( ) * 4 , f . height ( ) * 4 , Qt : : KeepAspectRatio , Qt : : SmoothTransformation ) ) ;
QFontMetricsF g ( ui - > inviteButton - > font ( ) ) ;
ui - > avatarLabel - > setPixmap ( pixmap . scaled ( ui - > inviteButton - > width ( ) , ui - > inviteButton - > width ( ) , Qt : : IgnoreAspectRatio , Qt : : SmoothTransformation ) ) ;
ui - > avatarLabel - > setScaledContents ( true ) ;
2014-09-14 12:28:02 -04:00
2012-11-06 14:18:56 -05:00
if ( data . mPgpKnown )
2012-06-07 13:11:57 -04:00
{
2012-11-06 14:18:56 -05:00
RsPeerDetails details ;
rsPeers - > getGPGDetails ( data . mPgpId , details ) ;
2014-12-24 09:43:06 -05:00
ui - > lineEdit_GpgName - > setText ( QString : : fromUtf8 ( details . name . c_str ( ) ) ) ;
2012-06-07 13:11:57 -04:00
}
2012-11-06 14:18:56 -05:00
else
2012-06-07 13:11:57 -04:00
{
2017-02-07 14:15:55 -05:00
if ( data . mMeta . mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility )
2016-04-02 14:04:08 -04:00
ui - > lineEdit_GpgName - > setText ( tr ( " [Unknown node] " ) ) ;
2012-11-06 14:18:56 -05:00
else
2014-12-24 09:43:06 -05:00
ui - > lineEdit_GpgName - > setText ( tr ( " Anonymous Id " ) ) ;
2012-06-07 13:11:57 -04:00
}
2012-11-06 14:18:56 -05:00
2014-09-24 16:13:19 -04:00
if ( data . mPgpId . isNull ( ) )
{
2014-12-24 09:43:06 -05:00
ui - > lineEdit_GpgId - > hide ( ) ;
2016-07-29 14:54:26 -04:00
ui - > label_GpgId - > hide ( ) ;
2014-09-24 16:13:19 -04:00
}
else
{
2014-12-24 09:43:06 -05:00
ui - > lineEdit_GpgId - > show ( ) ;
2016-07-29 14:54:26 -04:00
ui - > label_GpgId - > show ( ) ;
2014-09-24 16:13:19 -04:00
}
2016-04-02 14:04:08 -04:00
if ( data . mPgpKnown )
{
ui - > lineEdit_GpgName - > show ( ) ;
2016-07-29 14:54:26 -04:00
ui - > label_GpgName - > show ( ) ;
2016-04-02 14:04:08 -04:00
}
else
{
ui - > lineEdit_GpgName - > hide ( ) ;
2016-07-29 14:54:26 -04:00
ui - > label_GpgName - > hide ( ) ;
2016-04-02 14:04:08 -04:00
}
2014-09-24 16:13:19 -04:00
2015-02-05 15:37:24 -05:00
bool isLinkedToOwnPgpId = ( data . mPgpKnown & & ( data . mPgpId = = ownPgpId ) ) ;
bool isOwnId = ( data . mMeta . mSubscribeFlags & GXS_SERV : : GROUP_SUBSCRIBE_ADMIN ) ;
if ( isOwnId )
if ( isLinkedToOwnPgpId )
ui - > lineEdit_Type - > setText ( tr ( " Identity owned by you, linked to your Retroshare node " ) ) ;
else
2018-01-05 11:48:18 -05:00
if ( data . mMeta . mGroupFlags & ( GXS_SERV : : FLAG_PRIVACY_PRIVATE | RSGXSID_GROUPFLAG_REALID ) )
ui - > lineEdit_Type - > setText ( tr ( " Identity owned by you, linked to your Retroshare node but not yet validated " ) ) ;
else
ui - > lineEdit_Type - > setText ( tr ( " Anonymous identity, owned by you " ) ) ;
2017-02-07 14:15:55 -05:00
else if ( data . mMeta . mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility )
2015-02-05 15:37:24 -05:00
{
if ( data . mPgpKnown )
if ( rsPeers - > isGPGAccepted ( data . mPgpId ) )
ui - > lineEdit_Type - > setText ( tr ( " Linked to a friend Retroshare node " ) ) ;
else
ui - > lineEdit_Type - > setText ( tr ( " Linked to a known Retroshare node " ) ) ;
else
ui - > lineEdit_Type - > setText ( tr ( " Linked to unknown Retroshare node " ) ) ;
}
else
2016-07-29 14:54:26 -04:00
{
2015-02-05 15:37:24 -05:00
ui - > lineEdit_Type - > setText ( tr ( " Anonymous identity " ) ) ;
2016-07-29 14:54:26 -04:00
}
2015-02-05 15:37:24 -05:00
2012-11-06 14:18:56 -05:00
if ( isOwnId )
2012-06-07 13:11:57 -04:00
{
2015-12-22 18:29:27 -05:00
mStateHelper - > setWidgetEnabled ( ui - > ownOpinion_CB , false ) ;
2019-04-04 16:52:25 -04:00
mStateHelper - > setWidgetEnabled ( ui - > autoBanIdentities_CB , false ) ;
2015-01-25 09:14:03 -05:00
ui - > editIdentity - > setEnabled ( true ) ;
ui - > removeIdentity - > setEnabled ( true ) ;
2014-12-24 09:43:06 -05:00
ui - > chatIdentity - > setEnabled ( false ) ;
2015-12-24 08:31:52 -05:00
ui - > inviteButton - > setEnabled ( false ) ;
2012-06-07 13:11:57 -04:00
}
else
{
2013-07-10 17:57:23 -04:00
// No Reputation yet!
2015-12-22 18:29:27 -05:00
mStateHelper - > setWidgetEnabled ( ui - > ownOpinion_CB , true ) ;
2019-04-04 16:52:25 -04:00
mStateHelper - > setWidgetEnabled ( ui - > autoBanIdentities_CB , true ) ;
2015-01-25 09:14:03 -05:00
ui - > editIdentity - > setEnabled ( false ) ;
ui - > removeIdentity - > setEnabled ( false ) ;
2014-12-24 09:43:06 -05:00
ui - > chatIdentity - > setEnabled ( true ) ;
2015-12-24 08:31:52 -05:00
ui - > inviteButton - > setEnabled ( true ) ;
2012-06-07 13:11:57 -04:00
}
2013-06-04 17:00:43 -04:00
2016-08-04 05:43:35 -04:00
ui - > autoBanIdentities_CB - > setChecked ( rsReputations - > isNodeBanned ( data . mPgpId ) ) ;
2013-06-04 17:00:43 -04:00
/* now fill in the reputation information */
2015-12-22 18:29:27 -05:00
# ifdef SUSPENDED
2013-06-04 17:00:43 -04:00
if ( data . mPgpKnown )
{
2015-06-01 14:46:33 -04:00
ui - > line_RatingImplicit - > setText ( tr ( " +50 Known PGP " ) ) ;
2013-06-04 17:00:43 -04:00
}
else if ( data . mMeta . mGroupFlags & RSGXSID_GROUPFLAG_REALID )
{
2015-06-01 14:46:33 -04:00
ui - > line_RatingImplicit - > setText ( tr ( " +10 UnKnown PGP " ) ) ;
2013-06-04 17:00:43 -04:00
}
2013-07-11 04:14:38 -04:00
else
2013-06-04 17:00:43 -04:00
{
2015-06-01 14:46:33 -04:00
ui - > line_RatingImplicit - > setText ( tr ( " +5 Anon Id " ) ) ;
2013-06-04 17:00:43 -04:00
}
2014-02-19 06:11:06 -05:00
{
QString rating = QString : : number ( data . mReputation . mIdScore ) ;
2014-12-24 09:43:06 -05:00
ui - > line_RatingImplicit - > setText ( rating ) ;
2014-02-19 06:11:06 -05:00
}
2015-12-22 18:29:27 -05:00
# endif
2014-02-19 06:11:06 -05:00
2019-02-16 09:42:22 -05:00
RsReputationInfo info ;
2016-07-03 18:06:01 -04:00
rsReputations - > getReputationInfo ( RsGxsId ( data . mMeta . mGroupId ) , data . mPgpId , info ) ;
2015-12-22 18:29:27 -05:00
2016-12-23 11:52:02 -05:00
QString frep_string ;
2016-12-23 16:53:57 -05:00
if ( info . mFriendsPositiveVotes > 0 ) frep_string + = QString : : number ( info . mFriendsPositiveVotes ) + tr ( " positive " ) ;
if ( info . mFriendsNegativeVotes > 0 ) frep_string + = QString : : number ( info . mFriendsNegativeVotes ) + tr ( " negative " ) ;
2016-12-23 11:52:02 -05:00
if ( info . mFriendsPositiveVotes = = 0 & & info . mFriendsNegativeVotes = = 0 )
2016-12-23 16:53:57 -05:00
frep_string = tr ( " No votes from friends " ) ;
2016-12-23 11:52:02 -05:00
ui - > neighborNodesOpinion_TF - > setText ( frep_string ) ;
2017-01-03 10:43:31 -05:00
ui - > label_positive - > setText ( QString : : number ( info . mFriendsPositiveVotes ) ) ;
ui - > label_negative - > setText ( QString : : number ( info . mFriendsNegativeVotes ) ) ;
2016-07-03 22:02:23 -04:00
2019-02-16 09:42:22 -05:00
switch ( info . mOverallReputationLevel )
{
case RsReputationLevel : : LOCALLY_POSITIVE :
ui - > overallOpinion_TF - > setText ( tr ( " Positive " ) ) ; break ;
case RsReputationLevel : : LOCALLY_NEGATIVE :
ui - > overallOpinion_TF - > setText ( tr ( " Negative (Banned by you) " ) ) ; break ;
case RsReputationLevel : : REMOTELY_POSITIVE :
ui - > overallOpinion_TF - > setText ( tr ( " Positive (according to your friends) " ) ) ;
break ;
case RsReputationLevel : : REMOTELY_NEGATIVE :
ui - > overallOpinion_TF - > setText ( tr ( " Negative (according to your friends) " ) ) ;
break ;
case RsReputationLevel : : NEUTRAL : // fallthrough
default :
ui - > overallOpinion_TF - > setText ( tr ( " Neutral " ) ) ; break ;
}
switch ( info . mOwnOpinion )
2014-02-19 06:11:06 -05:00
{
2019-02-16 09:42:22 -05:00
case RsOpinion : : NEGATIVE : ui - > ownOpinion_CB - > setCurrentIndex ( 0 ) ; break ;
case RsOpinion : : NEUTRAL : ui - > ownOpinion_CB - > setCurrentIndex ( 1 ) ; break ;
case RsOpinion : : POSITIVE : ui - > ownOpinion_CB - > setCurrentIndex ( 2 ) ; break ;
default :
std : : cerr < < " Unexpected value in own opinion: "
< < static_cast < uint32_t > ( info . mOwnOpinion ) < < std : : endl ;
break ;
2014-02-19 06:11:06 -05:00
}
2016-12-20 18:34:07 -05:00
// now fill in usage cases
RsIdentityDetails det ;
rsIdentity - > getIdDetails ( RsGxsId ( data . mMeta . mGroupId ) , det ) ;
QString usage_txt ;
2018-10-07 08:34:28 -04:00
std : : map < rstime_t , RsIdentityUsage > rmap ;
for ( auto it ( det . mUseCases . begin ( ) ) ; it ! = det . mUseCases . end ( ) ; + + it )
rmap . insert ( std : : make_pair ( it - > second , it - > first ) ) ;
2016-12-20 18:34:07 -05:00
2018-10-07 08:34:28 -04:00
for ( auto it ( rmap . begin ( ) ) ; it ! = rmap . end ( ) ; + + it )
2017-01-03 17:31:29 -05:00
usage_txt + = QString ( " <b> " ) + getHumanReadableDuration ( now - data . mLastUsageTS ) + " </b> \t : " + createUsageString ( it - > second ) + " <br/> " ;
2016-12-20 18:34:07 -05:00
if ( usage_txt . isNull ( ) )
2016-12-22 05:21:49 -05:00
usage_txt = tr ( " <b>[No record in current session]</b> " ) ;
2016-12-20 18:34:07 -05:00
ui - > usageStatistics_TB - > setText ( usage_txt ) ;
2014-02-19 06:11:06 -05:00
}
2017-01-03 17:31:29 -05:00
QString IdDialog : : createUsageString ( const RsIdentityUsage & u ) const
{
2017-01-04 15:49:52 -05:00
QString service_name ;
RetroShareLink : : enumType service_type = RetroShareLink : : TYPE_UNKNOWN ;
2017-01-04 14:21:49 -05:00
switch ( u . mServiceId )
2019-06-12 13:01:19 -04:00
{
case RsServiceType : : CHANNELS : service_name = tr ( " Channels " ) ; service_type = RetroShareLink : : TYPE_CHANNEL ; break ;
case RsServiceType : : FORUMS : service_name = tr ( " Forums " ) ; service_type = RetroShareLink : : TYPE_FORUM ; break ;
case RsServiceType : : POSTED : service_name = tr ( " Posted " ) ; service_type = RetroShareLink : : TYPE_POSTED ; break ;
case RsServiceType : : CHAT : service_name = tr ( " Chat " ) ; service_type = RetroShareLink : : TYPE_CHAT_ROOM ; break ;
2017-01-04 14:21:49 -05:00
default :
2017-01-04 15:49:52 -05:00
service_name = tr ( " Unknown " ) ; service_type = RetroShareLink : : TYPE_UNKNOWN ;
2017-01-04 14:21:49 -05:00
}
2017-01-03 17:31:29 -05:00
switch ( u . mUsageCode )
{
2017-01-04 14:21:49 -05:00
case RsIdentityUsage : : UNKNOWN_USAGE :
return tr ( " [Unknown] " ) ;
case RsIdentityUsage : : GROUP_ADMIN_SIGNATURE_CREATION : // These 2 are normally not normal GXS identities, but nothing prevents it to happen either.
return tr ( " Admin signature in service %1 " ) . arg ( service_name ) ;
case RsIdentityUsage : : GROUP_ADMIN_SIGNATURE_VALIDATION :
return tr ( " Admin signature verification in service %1 " ) . arg ( service_name ) ;
case RsIdentityUsage : : GROUP_AUTHOR_SIGNATURE_CREATION : // not typically used, since most services do not require group author signatures
return tr ( " Creation of author signature in service %1 " ) . arg ( service_name ) ;
case RsIdentityUsage : : MESSAGE_AUTHOR_SIGNATURE_CREATION : // most common use case. Messages are signed by authors in e.g. forums.
2020-02-01 17:07:19 -05:00
return tr ( " Message signature creation in group %1 of service %2 " ) . arg ( QString : : fromStdString ( u . mGrpId . toStdString ( ) ) ) . arg ( service_name ) ;
2017-01-04 14:21:49 -05:00
case RsIdentityUsage : : GROUP_AUTHOR_KEEP_ALIVE : // Identities are stamped regularly by crawlign the set of messages for all groups. That helps keepign the useful identities in hand.
2020-02-01 17:07:19 -05:00
case RsIdentityUsage : : GROUP_AUTHOR_SIGNATURE_VALIDATION :
return tr ( " Group author for group %1 in service %2 " ) . arg ( QString : : fromStdString ( u . mGrpId . toStdString ( ) ) ) . arg ( service_name ) ;
2017-01-04 14:21:49 -05:00
break ;
case RsIdentityUsage : : MESSAGE_AUTHOR_SIGNATURE_VALIDATION :
case RsIdentityUsage : : MESSAGE_AUTHOR_KEEP_ALIVE : // Identities are stamped regularly by crawlign the set of messages for all groups. That helps keepign the useful identities in hand.
{
2017-07-16 07:11:47 -04:00
RetroShareLink l = RetroShareLink : : createGxsMessageLink ( service_type , u . mGrpId , u . mMsgId , tr ( " Message/vote/comment " ) ) ;
2017-01-04 15:49:52 -05:00
return tr ( " %1 in %2 tab " ) . arg ( l . toHtml ( ) ) . arg ( service_name ) ;
2017-01-04 14:21:49 -05:00
}
case RsIdentityUsage : : CHAT_LOBBY_MSG_VALIDATION : // Chat lobby msgs are signed, so each time one comes, or a chat lobby event comes, a signature verificaiton happens.
{
2018-05-25 17:59:02 -04:00
ChatId id = ChatId ( ChatLobbyId ( u . mAdditionalId ) ) ;
2019-10-11 11:34:17 -04:00
ChatLobbyInfo linfo ;
rsMsgs - > getChatLobbyInfo ( ChatLobbyId ( u . mAdditionalId ) , linfo ) ;
RetroShareLink l = RetroShareLink : : createChatRoom ( id , QString : : fromUtf8 ( linfo . lobby_name . c_str ( ) ) ) ;
2018-02-04 11:51:26 -05:00
return tr ( " Message in chat room %1 " ) . arg ( l . toHtml ( ) ) ;
2017-01-04 14:21:49 -05:00
}
case RsIdentityUsage : : GLOBAL_ROUTER_SIGNATURE_CHECK : // Global router message validation
{
return tr ( " Distant message signature validation. " ) ;
}
case RsIdentityUsage : : GLOBAL_ROUTER_SIGNATURE_CREATION : // Global router message signature
{
return tr ( " Distant message signature creation. " ) ;
}
case RsIdentityUsage : : GXS_TUNNEL_DH_SIGNATURE_CHECK : //
{
return tr ( " Signature validation in distant tunnel system. " ) ;
}
case RsIdentityUsage : : GXS_TUNNEL_DH_SIGNATURE_CREATION : //
{
return tr ( " Signature in distant tunnel system. " ) ;
}
case RsIdentityUsage : : IDENTITY_DATA_UPDATE : // Group update on that identity data. Can be avatar, name, etc.
{
return tr ( " Update of identity data. " ) ;
}
case RsIdentityUsage : : IDENTITY_GENERIC_SIGNATURE_CHECK : // Any signature verified for that identity
{
return tr ( " Generic signature validation. " ) ;
}
case RsIdentityUsage : : IDENTITY_GENERIC_SIGNATURE_CREATION : // Any signature made by that identity
{
return tr ( " Generic signature. " ) ;
}
2020-02-01 17:07:19 -05:00
case RsIdentityUsage : : IDENTITY_GENERIC_ENCRYPTION : return tr ( " Generic encryption. " ) ;
case RsIdentityUsage : : IDENTITY_GENERIC_DECRYPTION : return tr ( " Generic decryption. " ) ;
case RsIdentityUsage : : CIRCLE_MEMBERSHIP_CHECK : return tr ( " Membership verification in circle %1. " ) . arg ( QString : : fromStdString ( u . mGrpId . toStdString ( ) ) ) ;
2017-01-04 14:21:49 -05:00
2017-03-18 05:19:31 -04:00
# warning TODO! csoler 2017-01-03: Add the different strings and translations here.
2017-01-04 14:21:49 -05:00
default :
return QString ( " Undone yet " ) ;
2017-01-03 17:31:29 -05:00
}
2017-01-12 15:59:44 -05:00
return QString ( " Unknown " ) ;
2017-01-03 17:31:29 -05:00
}
2014-02-19 06:11:06 -05:00
void IdDialog : : modifyReputation ( )
{
2014-10-25 09:16:47 -04:00
# ifdef ID_DEBUG
2014-02-19 06:11:06 -05:00
std : : cerr < < " IdDialog::modifyReputation() " ;
std : : cerr < < std : : endl ;
2014-10-25 09:16:47 -04:00
# endif
2014-02-19 06:11:06 -05:00
2014-12-24 09:43:06 -05:00
RsGxsId id ( ui - > lineEdit_KeyId - > text ( ) . toStdString ( ) ) ;
2014-02-19 06:11:06 -05:00
2019-02-16 09:42:22 -05:00
RsOpinion op ;
switch ( ui - > ownOpinion_CB - > currentIndex ( ) )
{
case 0 : op = RsOpinion : : NEGATIVE ; break ;
case 1 : op = RsOpinion : : NEUTRAL ; break ;
case 2 : op = RsOpinion : : POSITIVE ; break ;
default :
std : : cerr < < " Wrong value from opinion combobox. Bug?? " < < std : : endl ;
2019-04-04 16:52:25 -04:00
return ;
2019-02-16 09:42:22 -05:00
}
rsReputations - > setOwnOpinion ( id , op ) ;
2014-02-19 06:11:06 -05:00
2014-10-25 09:16:47 -04:00
# ifdef ID_DEBUG
2020-01-28 16:47:30 -05:00
std : : cerr < < " IdDialog::modifyReputation() ID: " < < id < < " Mod: " < < static_cast < int > ( op ) ;
2014-02-19 06:11:06 -05:00
std : : cerr < < std : : endl ;
2014-10-25 09:16:47 -04:00
# endif
2014-02-19 06:11:06 -05:00
2015-12-22 18:29:27 -05:00
# ifdef SUSPENDED
// Cyril: apparently the old reputation system was in used here. It's based on GXS data exchange, and probably not
// very efficient because of this.
2014-02-19 06:11:06 -05:00
uint32_t token ;
2015-12-22 18:29:27 -05:00
if ( ! rsIdentity - > submitOpinion ( token , id , false , op ) )
2014-02-19 06:11:06 -05:00
{
2014-10-25 09:16:47 -04:00
# ifdef ID_DEBUG
2014-02-19 06:11:06 -05:00
std : : cerr < < " IdDialog::modifyReputation() Error submitting Opinion " ;
std : : cerr < < std : : endl ;
2014-10-25 09:16:47 -04:00
# endif
2014-02-19 06:11:06 -05:00
}
2015-12-22 18:29:27 -05:00
# endif
2014-02-19 06:11:06 -05:00
// trigger refresh when finished.
// basic / anstype are not needed.
2020-02-11 02:36:35 -05:00
updateIdentity ( ) ;
2020-02-10 16:33:21 -05:00
updateIdList ( ) ;
2014-02-19 06:11:06 -05:00
return ;
2012-02-13 13:43:15 -05:00
}
2014-02-19 06:11:06 -05:00
2016-12-27 14:42:47 -05:00
void IdDialog : : navigate ( const RsGxsId & gxs_id )
{
2017-07-20 08:29:31 -04:00
# ifdef ID_DEBUG
std : : cerr < < " IdDialog::navigate to " < < gxs_id . toStdString ( ) < < std : : endl ;
# endif
2016-12-27 14:42:47 -05:00
2017-07-20 08:29:31 -04:00
// in order to do this, we just select the correct ID in the ID list
if ( ! gxs_id . isNull ( ) )
{
QList < QTreeWidgetItem * > select = ui - > idTreeWidget - > findItems ( QString : : fromStdString ( gxs_id . toStdString ( ) ) , Qt : : MatchExactly | Qt : : MatchRecursive | Qt : : MatchWrap , RSID_COL_KEYID ) ;
2016-12-27 14:42:47 -05:00
2017-07-20 08:29:31 -04:00
if ( select . empty ( ) )
{
mIdToNavigate = RsGxsGroupId ( gxs_id ) ;
std : : cerr < < " Cannot find item with ID " < < gxs_id < < " in ID list. " < < std : : endl ;
return ;
}
ui - > idTreeWidget - > setCurrentItem ( * select . begin ( ) , true ) ;
}
2016-12-27 14:42:47 -05:00
2017-07-20 08:29:31 -04:00
mIdToNavigate = RsGxsGroupId ( ) ;
2016-12-27 14:42:47 -05:00
}
2017-07-20 08:29:31 -04:00
2014-12-24 09:43:06 -05:00
void IdDialog : : updateDisplay ( bool complete )
2012-02-13 13:43:15 -05:00
{
2013-07-14 14:48:40 -04:00
/* Update identity list */
2014-12-24 09:43:06 -05:00
if ( complete ) {
/* Fill complete */
2020-02-10 16:33:21 -05:00
updateIdList ( ) ;
2018-06-21 11:27:15 -04:00
//requestIdDetails();
2020-02-11 02:36:35 -05:00
//requestRepList();
2014-12-24 09:43:06 -05:00
2020-02-10 16:33:21 -05:00
updateCircles ( ) ;
2014-12-24 09:43:06 -05:00
return ;
}
2020-02-06 13:57:23 -05:00
// std::set<RsGxsGroupId> grpIds;
// getAllGrpIds(grpIds);
// if (!getGrpIds().empty()) {
// requestIdList();
//
// if (!mId.isNull() && grpIds.find(mId)!=grpIds.end()) {
// requestIdDetails();
// requestRepList();
// }
// }
2012-02-13 13:43:15 -05:00
}
2013-07-10 17:57:23 -04:00
void IdDialog : : addIdentity ( )
2012-02-13 13:43:15 -05:00
{
2013-07-10 17:57:23 -04:00
IdEditDialog dlg ( this ) ;
dlg . setupNewId ( false ) ;
dlg . exec ( ) ;
2014-04-14 11:37:06 -04:00
}
2012-02-13 13:43:15 -05:00
2014-05-06 13:15:20 -04:00
void IdDialog : : removeIdentity ( )
{
2015-08-11 10:01:43 -04:00
QTreeWidgetItem * item = ui - > idTreeWidget - > currentItem ( ) ;
2014-05-06 13:15:20 -04:00
if ( ! item )
{
2014-10-25 09:16:47 -04:00
# ifdef ID_DEBUG
2014-05-06 13:15:20 -04:00
std : : cerr < < " IdDialog::editIdentity() Invalid item " ;
std : : cerr < < std : : endl ;
2014-10-25 09:16:47 -04:00
# endif
2014-05-06 13:15:20 -04:00
return ;
}
2015-06-12 04:27:26 -04:00
if ( ( QMessageBox : : question ( this , tr ( " Really delete? " ) , tr ( " Do you really want to delete this identity? " ) , QMessageBox : : Yes | QMessageBox : : No , QMessageBox : : No ) ) = = QMessageBox : : Yes )
2014-12-24 09:43:06 -05:00
{
std : : string keyId = item - > text ( RSID_COL_KEYID ) . toStdString ( ) ;
2014-05-06 13:15:20 -04:00
2014-12-24 09:43:06 -05:00
uint32_t dummyToken = 0 ;
RsGxsIdGroup group ;
group . mMeta . mGroupId = RsGxsGroupId ( keyId ) ;
rsIdentity - > deleteIdentity ( dummyToken , group ) ;
}
2014-05-06 13:15:20 -04:00
}
2013-07-10 17:57:23 -04:00
void IdDialog : : editIdentity ( )
2012-02-13 13:43:15 -05:00
{
2015-08-11 10:01:43 -04:00
QTreeWidgetItem * item = ui - > idTreeWidget - > currentItem ( ) ;
2012-02-13 13:43:15 -05:00
if ( ! item )
{
2014-10-25 09:16:47 -04:00
# ifdef ID_DEBUG
2013-07-10 17:57:23 -04:00
std : : cerr < < " IdDialog::editIdentity() Invalid item " ;
2012-02-13 13:43:15 -05:00
std : : cerr < < std : : endl ;
2014-10-25 09:16:47 -04:00
# endif
2012-02-13 13:43:15 -05:00
return ;
}
2015-02-10 07:55:16 -05:00
RsGxsGroupId keyId = RsGxsGroupId ( item - > text ( RSID_COL_KEYID ) . toStdString ( ) ) ;
if ( keyId . isNull ( ) ) {
return ;
}
2012-02-13 13:43:15 -05:00
2013-07-10 17:57:23 -04:00
IdEditDialog dlg ( this ) ;
dlg . setupExistingId ( keyId ) ;
dlg . exec ( ) ;
2014-04-14 11:37:06 -04:00
}
2012-02-13 13:43:15 -05:00
2013-07-10 17:57:23 -04:00
void IdDialog : : filterIds ( )
2012-02-13 13:43:15 -05:00
{
2014-12-24 09:43:06 -05:00
int filterColumn = ui - > filterLineEdit - > currentFilter ( ) ;
QString text = ui - > filterLineEdit - > text ( ) ;
2012-02-13 13:43:15 -05:00
2015-08-11 10:01:43 -04:00
ui - > idTreeWidget - > filterItems ( filterColumn , text ) ;
2012-02-13 13:43:15 -05:00
}
2020-02-11 02:36:35 -05:00
# ifdef TO_REMOVE
2014-12-24 09:43:06 -05:00
void IdDialog : : requestRepList ( )
2012-02-13 13:43:15 -05:00
{
2014-12-24 09:43:06 -05:00
// Removing this for the moment.
return ;
2013-07-10 17:57:23 -04:00
mStateHelper - > setLoading ( IDDIALOG_REPLIST , true ) ;
2012-02-13 13:43:15 -05:00
2013-07-10 17:57:23 -04:00
mIdQueue - > cancelActiveRequestTokens ( IDDIALOG_REPLIST ) ;
2012-02-13 13:43:15 -05:00
2013-07-11 04:14:38 -04:00
std : : list < RsGxsGroupId > groupIds ;
2014-12-24 09:43:06 -05:00
groupIds . push_back ( mId ) ;
2013-06-04 17:00:43 -04:00
2013-07-11 04:14:38 -04:00
RsTokReqOptions opts ;
opts . mReqType = GXS_REQUEST_TYPE_MSG_DATA ;
2013-06-04 17:00:43 -04:00
2013-07-11 04:14:38 -04:00
uint32_t token ;
mIdQueue - > requestMsgInfo ( token , RS_TOKREQ_ANSTYPE_DATA , opts , groupIds , IDDIALOG_REPLIST ) ;
2013-06-04 17:00:43 -04:00
}
void IdDialog : : insertRepList ( uint32_t token )
{
2014-05-06 13:15:20 -04:00
Q_UNUSED ( token )
2013-07-10 17:57:23 -04:00
mStateHelper - > setLoading ( IDDIALOG_REPLIST , false ) ;
2014-02-19 06:11:06 -05:00
mStateHelper - > setActive ( IDDIALOG_REPLIST , true ) ;
2013-06-04 17:00:43 -04:00
}
2017-04-10 14:02:14 -04:00
void IdDialog : : handleSerializedGroupData ( uint32_t token )
{
std : : map < RsGxsId , std : : string > serialized_group_map ;
rsIdentity - > getGroupSerializedData ( token , serialized_group_map ) ;
if ( serialized_group_map . size ( ) < 1 )
{
std : : cerr < < " (EE) Cannot get radix data " < < std : : endl ;
return ;
}
if ( serialized_group_map . size ( ) > 1 )
{
std : : cerr < < " (EE) Too many results for serialized data " < < std : : endl ;
return ;
}
RsGxsId gxs_id = serialized_group_map . begin ( ) - > first ;
std : : string radix = serialized_group_map . begin ( ) - > second ;
RsIdentityDetails details ;
if ( ! rsIdentity - > getIdDetails ( gxs_id , details ) )
{
std : : cerr < < " (EE) Cannot get id details for key " < < gxs_id < < std : : endl ;
return ;
}
QList < RetroShareLink > urls ;
2017-07-16 07:11:47 -04:00
RetroShareLink link = RetroShareLink : : createIdentity ( gxs_id , QString : : fromUtf8 ( details . mNickname . c_str ( ) ) , QString : : fromStdString ( radix ) ) ;
urls . push_back ( link ) ;
2017-04-10 14:02:14 -04:00
RSLinkClipboard : : copyLinks ( urls ) ;
QMessageBox : : information ( NULL , tr ( " information " ) , tr ( " This identity link was copied to your clipboard. Paste it in a mail, or a message to transmit the identity to someone. " ) ) ;
}
2015-09-06 23:53:21 -04:00
void IdDialog : : loadRequest ( const TokenQueue * queue , const TokenRequest & req )
2012-02-13 13:43:15 -05:00
{
2014-10-25 09:16:47 -04:00
# ifdef ID_DEBUG
2013-07-11 04:14:38 -04:00
std : : cerr < < " IdDialog::loadRequest() UserType: " < < req . mUserType ;
std : : cerr < < std : : endl ;
2014-10-25 09:16:47 -04:00
# endif
2013-07-11 04:14:38 -04:00
2015-09-06 23:53:21 -04:00
if ( queue = = mIdQueue )
{
switch ( req . mUserType )
{
2020-02-11 02:36:35 -05:00
# ifdef TO_REMOVE
case IDDIALOG_IDLIST :
insertIdList ( req . mToken ) ;
break ;
2015-09-06 23:53:21 -04:00
case IDDIALOG_IDDETAILS :
insertIdDetails ( req . mToken ) ;
break ;
case IDDIALOG_REPLIST :
insertRepList ( req . mToken ) ;
break ;
2017-04-10 14:02:14 -04:00
case IDDIALOG_SERIALIZED_GROUP :
handleSerializedGroupData ( req . mToken ) ;
break ;
2015-09-06 23:53:21 -04:00
case IDDIALOG_REFRESH :
// replaced by RsGxsUpdateBroadcastPage
// updateDisplay(true);
break ;
default :
std : : cerr < < " IdDialog::loadRequest() ERROR " ;
std : : cerr < < std : : endl ;
break ;
2020-02-11 02:36:35 -05:00
# endif
2015-09-06 23:53:21 -04:00
}
}
2020-02-10 16:33:21 -05:00
# ifdef TO_REMOVE
2015-09-06 23:53:21 -04:00
if ( queue = = mCircleQueue )
{
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2015-09-06 23:53:21 -04:00
std : : cerr < < " CirclesDialog::loadRequest() UserType: " < < req . mUserType ;
std : : cerr < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2015-09-06 23:53:21 -04:00
/* now switch on req */
switch ( req . mUserType )
{
2020-02-10 16:33:21 -05:00
// case CIRCLESDIALOG_GROUPMETA:
// loadCircleGroupMeta(req.mToken);
// break;
2015-09-06 23:53:21 -04:00
2020-02-10 16:33:21 -05:00
// case CIRCLESDIALOG_GROUPDATA:
// loadCircleGroupData(req.mToken);
// break;
//
// case CIRCLESDIALOG_GROUPUPDATE:
// updateCircleGroup(req.mToken);
// break;
2016-06-08 21:00:26 -04:00
2015-09-06 23:53:21 -04:00
default :
std : : cerr < < " CirclesDialog::loadRequest() ERROR: INVALID TYPE " ;
std : : cerr < < std : : endl ;
break ;
}
}
2020-02-10 16:33:21 -05:00
# endif
2012-02-13 13:43:15 -05:00
}
2020-02-11 02:36:35 -05:00
# endif
2014-05-03 13:56:12 -04:00
void IdDialog : : IdListCustomPopupMenu ( QPoint )
{
2017-04-08 15:12:48 -04:00
QMenu * contextMenu = new QMenu ( this ) ;
2014-05-03 13:56:12 -04:00
2015-02-09 20:14:44 -05:00
2018-11-19 18:11:00 -05:00
std : : list < RsGxsId > own_identities ;
rsIdentity - > getOwnIds ( own_identities ) ;
2014-11-18 10:55:31 -05:00
2017-04-08 15:12:48 -04:00
// make some stats about what's selected. If the same value is used for all selected items, it can be switched.
2015-01-23 11:35:06 -05:00
2017-04-08 15:12:48 -04:00
QList < QTreeWidgetItem * > selected_items = ui - > idTreeWidget - > selectedItems ( ) ;
2014-11-20 18:18:14 -05:00
2017-04-08 15:12:48 -04:00
bool root_node_present = false ;
bool one_item_owned_by_you = false ;
uint32_t n_positive_reputations = 0 ;
uint32_t n_negative_reputations = 0 ;
uint32_t n_neutral_reputations = 0 ;
uint32_t n_is_a_contact = 0 ;
uint32_t n_is_not_a_contact = 0 ;
uint32_t n_selected_items = 0 ;
2014-11-18 10:55:31 -05:00
2017-04-08 15:12:48 -04:00
for ( QList < QTreeWidgetItem * > : : const_iterator it ( selected_items . begin ( ) ) ; it ! = selected_items . end ( ) ; + + it )
{
if ( * it = = allItem | | * it = = contactsItem | | * it = = ownItem )
{
root_node_present = true ;
continue ;
}
2014-11-18 10:55:31 -05:00
2017-04-08 15:12:48 -04:00
uint32_t item_flags = ( * it ) - > data ( RSID_COL_KEYID , Qt : : UserRole ) . toUInt ( ) ;
if ( item_flags & RSID_FILTER_OWNED_BY_YOU )
one_item_owned_by_you = true ;
2015-01-25 17:09:12 -05:00
2016-03-24 19:46:08 -04:00
# ifdef ID_DEBUG
2017-04-08 15:12:48 -04:00
std : : cerr < < " item flags = " < < item_flags < < std : : endl ;
2016-03-24 19:46:08 -04:00
# endif
2017-04-08 15:12:48 -04:00
RsGxsId keyId ( ( * it ) - > text ( RSID_COL_KEYID ) . toStdString ( ) ) ;
2014-11-18 10:55:31 -05:00
2017-04-08 15:12:48 -04:00
RsIdentityDetails det ;
rsIdentity - > getIdDetails ( keyId , det ) ;
2015-02-05 15:37:24 -05:00
2017-04-08 15:12:48 -04:00
switch ( det . mReputation . mOwnOpinion )
{
2019-02-16 09:42:22 -05:00
case RsOpinion : : NEGATIVE : + + n_negative_reputations ; break ;
case RsOpinion : : POSITIVE : + + n_positive_reputations ; break ;
case RsOpinion : : NEUTRAL : + + n_neutral_reputations ; break ;
2017-04-08 15:12:48 -04:00
}
2015-12-22 18:29:27 -05:00
2019-02-16 09:42:22 -05:00
+ + n_selected_items ;
2016-01-16 20:44:52 -05:00
2017-04-08 15:12:48 -04:00
if ( rsIdentity - > isARegularContact ( keyId ) )
+ + n_is_a_contact ;
else
+ + n_is_not_a_contact ;
}
if ( ! root_node_present ) // don't show menu if some of the root nodes are present
{
2016-01-16 20:44:52 -05:00
2017-04-08 15:12:48 -04:00
if ( ! one_item_owned_by_you )
{
QWidget * widget = new QWidget ( contextMenu ) ;
widget - > setStyleSheet ( " .QWidget{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #FEFEFE, stop:1 #E8E8E8); border: 1px solid #CCCCCC;} " ) ;
// create menu header
QHBoxLayout * hbox = new QHBoxLayout ( widget ) ;
hbox - > setMargin ( 0 ) ;
hbox - > setSpacing ( 6 ) ;
2016-01-16 20:44:52 -05:00
2017-04-08 15:12:48 -04:00
QLabel * iconLabel = new QLabel ( widget ) ;
QPixmap pix = QPixmap ( " :/images/user/friends24.png " ) . scaledToHeight ( QFontMetricsF ( iconLabel - > font ( ) ) . height ( ) * 1.5 ) ;
iconLabel - > setPixmap ( pix ) ;
iconLabel - > setMaximumSize ( iconLabel - > frameSize ( ) . height ( ) + pix . height ( ) , pix . width ( ) ) ;
hbox - > addWidget ( iconLabel ) ;
2016-01-16 20:44:52 -05:00
2017-04-08 15:12:48 -04:00
QLabel * textLabel = new QLabel ( " <strong> " + ui - > titleBarLabel - > text ( ) + " </strong> " , widget ) ;
hbox - > addWidget ( textLabel ) ;
2016-01-16 20:44:52 -05:00
2017-04-08 15:12:48 -04:00
QSpacerItem * spacerItem = new QSpacerItem ( 40 , 20 , QSizePolicy : : Expanding , QSizePolicy : : Minimum ) ;
hbox - > addItem ( spacerItem ) ;
2016-01-16 20:44:52 -05:00
2017-04-08 15:12:48 -04:00
widget - > setLayout ( hbox ) ;
2016-01-16 20:44:52 -05:00
2017-04-08 15:12:48 -04:00
QWidgetAction * widgetAction = new QWidgetAction ( this ) ;
widgetAction - > setDefaultWidget ( widget ) ;
contextMenu - > addAction ( widgetAction ) ;
2016-01-16 20:44:52 -05:00
2017-04-08 15:12:48 -04:00
if ( n_selected_items = = 1 ) // if only one item is selected, allow to chat with this item
{
if ( own_identities . size ( ) < = 1 )
2016-08-05 12:15:21 -04:00
{
2017-04-08 15:12:48 -04:00
QAction * action = contextMenu - > addAction ( QIcon ( " :/images/chat_24.png " ) , tr ( " Chat with this person " ) , this , SLOT ( chatIdentity ( ) ) ) ;
2016-08-05 12:15:21 -04:00
2017-04-08 15:12:48 -04:00
if ( own_identities . empty ( ) )
action - > setEnabled ( false ) ;
2016-08-05 12:15:21 -04:00
else
2017-04-08 15:12:48 -04:00
action - > setData ( QString : : fromStdString ( ( own_identities . front ( ) ) . toStdString ( ) ) ) ;
}
else
{
QMenu * mnu = contextMenu - > addMenu ( QIcon ( " :/images/chat_24.png " ) , tr ( " Chat with this person as... " ) ) ;
2015-12-22 18:29:27 -05:00
2017-04-08 15:12:48 -04:00
for ( std : : list < RsGxsId > : : const_iterator it = own_identities . begin ( ) ; it ! = own_identities . end ( ) ; + + it )
{
RsIdentityDetails idd ;
rsIdentity - > getIdDetails ( * it , idd ) ;
2015-12-22 18:29:27 -05:00
2017-04-08 15:12:48 -04:00
QPixmap pixmap ;
2015-12-22 18:29:27 -05:00
2019-06-04 05:49:26 -04:00
if ( idd . mAvatar . mSize = = 0 | | ! GxsIdDetails : : loadPixmapFromData ( idd . mAvatar . mData , idd . mAvatar . mSize , pixmap , GxsIdDetails : : SMALL ) )
pixmap = GxsIdDetails : : makeDefaultIcon ( * it , GxsIdDetails : : SMALL ) ;
2015-02-05 15:37:24 -05:00
2017-04-08 15:12:48 -04:00
QAction * action = mnu - > addAction ( QIcon ( pixmap ) , QString ( " %1 (%2) " ) . arg ( QString : : fromUtf8 ( idd . mNickname . c_str ( ) ) , QString : : fromStdString ( ( * it ) . toStdString ( ) ) ) , this , SLOT ( chatIdentity ( ) ) ) ;
action - > setData ( QString : : fromStdString ( ( * it ) . toStdString ( ) ) ) ;
2016-08-05 12:15:21 -04:00
}
}
2017-04-08 15:12:48 -04:00
}
2015-01-23 11:35:06 -05:00
2017-04-18 06:02:34 -04:00
if ( n_selected_items = = 1 )
contextMenu - > addAction ( QIcon ( " :/images/chat_24.png " ) , tr ( " Copy identity to clipboard " ) , this , SLOT ( copyRetroshareLink ( ) ) ) ;
2015-02-07 15:24:27 -05:00
2017-04-08 15:12:48 -04:00
// always allow to send messages
contextMenu - > addAction ( QIcon ( " :/images/mail_new.png " ) , tr ( " Send message " ) , this , SLOT ( sendMsg ( ) ) ) ;
2016-01-16 20:44:52 -05:00
2017-04-08 15:12:48 -04:00
contextMenu - > addSeparator ( ) ;
2016-01-16 20:44:52 -05:00
2017-04-08 15:12:48 -04:00
if ( n_is_a_contact = = 0 )
contextMenu - > addAction ( QIcon ( ) , tr ( " Add to Contacts " ) , this , SLOT ( addtoContacts ( ) ) ) ;
2016-08-05 12:15:21 -04:00
2017-04-08 15:12:48 -04:00
if ( n_is_not_a_contact = = 0 )
contextMenu - > addAction ( QIcon ( " :/images/cancel.png " ) , tr ( " Remove from Contacts " ) , this , SLOT ( removefromContacts ( ) ) ) ;
2016-08-05 12:15:21 -04:00
2017-04-08 15:12:48 -04:00
contextMenu - > addSeparator ( ) ;
2016-08-05 12:15:21 -04:00
2017-04-08 15:12:48 -04:00
if ( n_positive_reputations = = 0 ) // only unban when all items are banned
contextMenu - > addAction ( QIcon ( " :/icons/png/thumbs-up.png " ) , tr ( " Set positive opinion " ) , this , SLOT ( positivePerson ( ) ) ) ;
2016-08-05 12:15:21 -04:00
2017-04-08 15:12:48 -04:00
if ( n_neutral_reputations = = 0 ) // only unban when all items are banned
contextMenu - > addAction ( QIcon ( " :/icons/png/thumbs-neutral.png " ) , tr ( " Set neutral opinion " ) , this , SLOT ( neutralPerson ( ) ) ) ;
2016-08-05 12:15:21 -04:00
2017-04-08 15:12:48 -04:00
if ( n_negative_reputations = = 0 )
contextMenu - > addAction ( QIcon ( " :/icons/png/thumbs-down.png " ) , tr ( " Set negative opinion " ) , this , SLOT ( negativePerson ( ) ) ) ;
}
2016-08-05 12:15:21 -04:00
2017-04-08 15:12:48 -04:00
if ( one_item_owned_by_you & & n_selected_items = = 1 )
{
contextMenu - > addSeparator ( ) ;
2016-08-05 12:15:21 -04:00
2017-04-15 13:01:13 -04:00
contextMenu - > addAction ( QIcon ( " :/images/chat_24.png " ) , tr ( " Copy identity to clipboard " ) , this , SLOT ( copyRetroshareLink ( ) ) ) ;
2017-04-08 15:12:48 -04:00
contextMenu - > addAction ( ui - > editIdentity ) ;
contextMenu - > addAction ( ui - > removeIdentity ) ;
2016-08-05 12:15:21 -04:00
}
2017-04-08 15:12:48 -04:00
}
contextMenu = ui - > idTreeWidget - > createStandardContextMenu ( contextMenu ) ;
contextMenu - > exec ( QCursor : : pos ( ) ) ;
delete contextMenu ;
}
void IdDialog : : copyRetroshareLink ( )
{
QTreeWidgetItem * item = ui - > idTreeWidget - > currentItem ( ) ;
if ( ! item )
{
std : : cerr < < " IdDialog::editIdentity() Invalid item " ;
std : : cerr < < std : : endl ;
return ;
}
2017-04-10 14:02:14 -04:00
RsGxsId gxs_id ( item - > text ( RSID_COL_KEYID ) . toStdString ( ) ) ;
if ( gxs_id . isNull ( ) )
{
std : : cerr < < " Null GXS id. Something went wrong. " < < std : : endl ;
return ;
}
2017-04-08 15:12:48 -04:00
RsIdentityDetails details ;
2017-05-08 06:25:29 -04:00
if ( ! rsIdentity - > getIdDetails ( gxs_id , details ) )
return ;
2017-04-08 15:12:48 -04:00
2020-02-11 02:36:35 -05:00
RsThread : : async ( [ gxs_id , details , this ] ( )
{
# ifdef ID_DEBUG
std : : cerr < < " Retrieving post data for identity " < < mThreadId < < std : : endl ;
# endif
std : : string radix , errMsg ;
2017-04-08 15:12:48 -04:00
2020-02-11 02:36:35 -05:00
if ( ! rsIdentity - > exportIdentityLink ( radix , gxs_id , true , std : : string ( ) , errMsg ) )
{
std : : cerr < < " Cannot retrieve identity data " < < mId < < " to create a link. Error: " < < errMsg < < std : : endl ;
return ;
}
RsQThreadUtils : : postToObject ( [ radix , details , this ] ( )
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread , for example to update the data model with new information
* after a blocking call to RetroShare API complete */
2017-04-08 15:12:48 -04:00
2020-02-11 02:36:35 -05:00
QList < RetroShareLink > urls ;
2016-08-05 12:15:21 -04:00
2020-02-11 02:36:35 -05:00
RetroShareLink link = RetroShareLink : : createIdentity ( details . mId , QString : : fromUtf8 ( details . mNickname . c_str ( ) ) , QString : : fromStdString ( radix ) ) ;
urls . push_back ( link ) ;
2017-04-10 14:02:14 -04:00
2020-02-11 02:36:35 -05:00
RSLinkClipboard : : copyLinks ( urls ) ;
2017-04-10 14:02:14 -04:00
2020-02-11 02:36:35 -05:00
QMessageBox : : information ( NULL , tr ( " information " ) , tr ( " This identity link was copied to your clipboard. Paste it in a mail, or a message to transmit the identity to someone. " ) ) ;
2017-04-10 14:02:14 -04:00
2020-02-11 02:36:35 -05:00
} , this ) ;
} ) ;
2014-05-06 13:15:20 -04:00
}
2014-06-12 06:28:23 -04:00
void IdDialog : : chatIdentity ( )
{
2018-11-19 18:11:00 -05:00
QTreeWidgetItem * item = ui - > idTreeWidget - > currentItem ( ) ;
2014-06-12 06:28:23 -04:00
if ( ! item )
{
2018-11-19 18:11:00 -05:00
std : : cerr < < __PRETTY_FUNCTION__ < < " Error. Invalid item! " < < std : : endl ;
2014-06-12 06:28:23 -04:00
return ;
}
2018-11-19 18:11:00 -05:00
chatIdentityItem ( item ) ;
}
2014-11-18 10:55:31 -05:00
2018-11-19 18:11:00 -05:00
void IdDialog : : chatIdentityItem ( QTreeWidgetItem * item )
{
if ( ! item )
{
std : : cerr < < __PRETTY_FUNCTION__ < < " Error. Invalid item. " < < std : : endl ;
return ;
}
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 ;
}
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 ;
}
2014-06-12 06:28:23 -04:00
2018-11-19 18:11:00 -05:00
uint32_t error_code ;
DistantChatPeerId did ;
2014-06-12 06:28:23 -04:00
2018-11-19 18:11:00 -05:00
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 ) ) ;
2015-01-23 11:35:06 -05:00
}
void IdDialog : : sendMsg ( )
{
2016-01-16 20:44:52 -05:00
QList < QTreeWidgetItem * > selected_items = ui - > idTreeWidget - > selectedItems ( ) ;
2015-01-23 11:35:06 -05:00
2016-01-16 20:44:52 -05:00
if ( selected_items . empty ( ) )
return ;
2015-01-23 11:35:06 -05:00
2016-01-16 20:44:52 -05:00
MessageComposer * nMsgDialog = MessageComposer : : newMsg ( ) ;
if ( nMsgDialog = = NULL )
return ;
2015-01-23 11:35:06 -05:00
2016-01-16 20:44:52 -05:00
for ( QList < QTreeWidgetItem * > : : const_iterator it ( selected_items . begin ( ) ) ; it ! = selected_items . end ( ) ; + + it )
{
QTreeWidgetItem * item = * it ;
2015-01-23 11:35:06 -05:00
2016-01-16 20:44:52 -05:00
std : : string keyId = item - > text ( RSID_COL_KEYID ) . toStdString ( ) ;
2015-01-23 11:35:06 -05:00
2016-01-16 20:44:52 -05:00
nMsgDialog - > addRecipient ( MessageComposer : : TO , RsGxsId ( keyId ) ) ;
}
nMsgDialog - > show ( ) ;
nMsgDialog - > activateWindow ( ) ;
2015-12-22 18:29:27 -05:00
2016-01-16 20:44:52 -05:00
/* window will destroy itself! */
2014-06-12 06:28:23 -04:00
}
2015-12-22 18:29:27 -05:00
2015-12-24 08:31:52 -05:00
QString IdDialog : : inviteMessage ( )
{
return tr ( " Hi,<br>I want to be friends with you on RetroShare.<br> " ) ;
}
void IdDialog : : sendInvite ( )
{
QTreeWidgetItem * item = ui - > idTreeWidget - > currentItem ( ) ;
if ( ! item )
{
return ;
}
2017-01-29 13:01:38 -05:00
RsGxsId id ( ui - > lineEdit_KeyId - > text ( ) . toStdString ( ) ) ;
2015-12-24 08:31:52 -05:00
2018-02-23 08:26:23 -05:00
//if ((QMessageBox::question(this, tr("Send invite?"),tr("Do you really want send a invite with your Certificate?"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes)
2017-02-02 11:15:32 -05:00
{
2018-02-23 08:26:23 -05:00
MessageComposer : : sendInvite ( id , false ) ;
2017-02-02 11:15:32 -05:00
ui - > inviteFrame - > show ( ) ;
ui - > inviteButton - > setEnabled ( false ) ;
}
2015-12-24 08:31:52 -05:00
2017-02-02 11:15:32 -05:00
2015-12-24 08:31:52 -05:00
}
2016-01-16 20:44:52 -05:00
void IdDialog : : negativePerson ( )
2015-12-22 18:29:27 -05:00
{
2016-01-16 20:44:52 -05:00
QList < QTreeWidgetItem * > selected_items = ui - > idTreeWidget - > selectedItems ( ) ;
for ( QList < QTreeWidgetItem * > : : const_iterator it ( selected_items . begin ( ) ) ; it ! = selected_items . end ( ) ; + + it )
{
QTreeWidgetItem * item = * it ;
2015-12-22 18:29:27 -05:00
std : : string Id = item - > text ( RSID_COL_KEYID ) . toStdString ( ) ;
2019-02-16 09:42:22 -05:00
rsReputations - > setOwnOpinion ( RsGxsId ( Id ) , RsOpinion : : NEGATIVE ) ;
2016-01-16 20:44:52 -05:00
}
2015-12-22 18:29:27 -05:00
2020-02-11 02:36:35 -05:00
updateIdentity ( ) ;
2020-02-10 16:33:21 -05:00
updateIdList ( ) ;
2015-12-22 18:29:27 -05:00
}
2016-01-16 20:44:52 -05:00
void IdDialog : : neutralPerson ( )
2015-12-22 18:29:27 -05:00
{
2016-01-16 20:44:52 -05:00
QList < QTreeWidgetItem * > selected_items = ui - > idTreeWidget - > selectedItems ( ) ;
for ( QList < QTreeWidgetItem * > : : const_iterator it ( selected_items . begin ( ) ) ; it ! = selected_items . end ( ) ; + + it )
{
QTreeWidgetItem * item = * it ;
std : : string Id = item - > text ( RSID_COL_KEYID ) . toStdString ( ) ;
2019-02-16 09:42:22 -05:00
rsReputations - > setOwnOpinion ( RsGxsId ( Id ) , RsOpinion : : NEUTRAL ) ;
2016-01-16 20:44:52 -05:00
}
2020-02-11 02:36:35 -05:00
updateIdentity ( ) ;
2020-02-10 16:33:21 -05:00
updateIdList ( ) ;
2016-01-16 20:44:52 -05:00
}
void IdDialog : : positivePerson ( )
{
QList < QTreeWidgetItem * > selected_items = ui - > idTreeWidget - > selectedItems ( ) ;
for ( QList < QTreeWidgetItem * > : : const_iterator it ( selected_items . begin ( ) ) ; it ! = selected_items . end ( ) ; + + it )
{
QTreeWidgetItem * item = * it ;
2015-12-22 18:29:27 -05:00
2019-02-16 09:42:22 -05:00
std : : string Id = item - > text ( RSID_COL_KEYID ) . toStdString ( ) ;
2015-12-22 18:29:27 -05:00
2019-02-16 09:42:22 -05:00
rsReputations - > setOwnOpinion ( RsGxsId ( Id ) , RsOpinion : : POSITIVE ) ;
2016-01-16 20:44:52 -05:00
}
2015-12-22 18:29:27 -05:00
2020-02-11 02:36:35 -05:00
updateIdentity ( ) ;
2020-02-10 16:33:21 -05:00
updateIdList ( ) ;
2015-12-22 18:29:27 -05:00
}
void IdDialog : : addtoContacts ( )
{
2016-01-16 20:44:52 -05:00
QList < QTreeWidgetItem * > selected_items = ui - > idTreeWidget - > selectedItems ( ) ;
for ( QList < QTreeWidgetItem * > : : const_iterator it ( selected_items . begin ( ) ) ; it ! = selected_items . end ( ) ; + + it )
{
QTreeWidgetItem * item = * it ;
2015-12-22 18:29:27 -05:00
std : : string Id = item - > text ( RSID_COL_KEYID ) . toStdString ( ) ;
rsIdentity - > setAsRegularContact ( RsGxsId ( Id ) , true ) ;
2016-01-16 20:44:52 -05:00
}
2015-12-22 18:29:27 -05:00
2020-02-10 16:33:21 -05:00
updateIdList ( ) ;
2015-12-22 18:29:27 -05:00
}
void IdDialog : : removefromContacts ( )
{
2016-01-16 20:44:52 -05:00
QList < QTreeWidgetItem * > selected_items = ui - > idTreeWidget - > selectedItems ( ) ;
for ( QList < QTreeWidgetItem * > : : const_iterator it ( selected_items . begin ( ) ) ; it ! = selected_items . end ( ) ; + + it )
{
QTreeWidgetItem * item = * it ;
2015-12-22 18:29:27 -05:00
std : : string Id = item - > text ( RSID_COL_KEYID ) . toStdString ( ) ;
rsIdentity - > setAsRegularContact ( RsGxsId ( Id ) , false ) ;
2016-01-16 20:44:52 -05:00
}
2015-12-22 18:29:27 -05:00
2020-02-10 16:33:21 -05:00
updateIdList ( ) ;
2015-12-22 18:29:27 -05:00
}
2017-01-29 13:01:38 -05:00
void IdDialog : : on_closeInfoFrameButton_clicked ( )
{
ui - > inviteFrame - > setVisible ( false ) ;
}