Merge branch 'RetroShare:master' into new_token_service

This commit is contained in:
Tushar Garg 2023-12-15 00:03:01 +05:30 committed by GitHub
commit 74e0692f69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
75 changed files with 1456 additions and 888 deletions

View file

@ -609,7 +609,9 @@ void GenCertDialog::genPerson()
QCoreApplication::processEvents();
QAbstractEventDispatcher* ed = QAbstractEventDispatcher::instance();
std::cout << "Waiting ed->processEvents()" << std::endl;
#ifdef DEBUG_GENCERTDIALOG
std::cout << "Waiting ed->processEvents()" << std::endl;
#endif
time_t waitEnd = time(NULL) + 10;//Wait no more than 10 sec to processEvents
if (ed->hasPendingEvents())
while(ed->processEvents(QEventLoop::AllEvents) && (time(NULL) < waitEnd));

View file

@ -301,8 +301,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>456</width>
<height>731</height>
<width>466</width>
<height>738</height>
</rect>
</property>
<layout class="QVBoxLayout" name="scrollAreaWidgetContentsVLayout">
@ -573,17 +573,68 @@ border-image: url(:/images/closepressed.png)
<string>Identity info</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<widget class="QLabel" name="label_GpgId">
<item row="13" column="0">
<widget class="QLabel" name="neighborNodesOpinion_LB">
<property name="text">
<string>Owner node ID :</string>
<string>Friend votes:</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLineEdit" name="overallOpinion_TF">
<item row="9" column="0" colspan="2">
<widget class="Line" name="line_IdInfo">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_GpgName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_KeyId">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_LastUsed">
<property name="text">
<string>Last used:</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QCheckBox" name="autoBanIdentities_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Overall reputation score, accounting for yours and your friends'.&lt;/p&gt;&lt;p&gt;Negative is bad, positive is good. Zero is neutral. If the score is too low,&lt;/p&gt;&lt;p&gt;the identity is flagged as bad, and will be filtered out in forums, chat lobbies,&lt;/p&gt;&lt;p&gt;channels, etc.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Auto-Ban all identities signed by the same node</string>
</property>
<property name="text">
<string>Auto-Ban profile</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEdit_PublishTS">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Nickname">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
@ -600,61 +651,253 @@ border-image: url(:/images/closepressed.png)
</property>
</widget>
</item>
<item row="0" column="2" rowspan="14">
<item row="14" column="1">
<widget class="QLineEdit" name="overallOpinion_TF">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Overall reputation score, accounting for yours and your friends'.&lt;/p&gt;&lt;p&gt;Negative is bad, positive is good. Zero is neutral. If the score is too low,&lt;/p&gt;&lt;p&gt;the identity is flagged as bad, and will be filtered out in forums, chat lobbies,&lt;/p&gt;&lt;p&gt;channels, etc.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="0" rowspan="2">
<widget class="QLabel" name="label_YourOpinion">
<property name="text">
<string>Your opinion:</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="overallOpinion_LB">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Overall:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_PublishTS">
<property name="text">
<string>Created on :</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_Nickname">
<property name="text">
<string>Identity name :</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_KeyId">
<property name="text">
<string>Identity ID :</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLineEdit" name="neighborNodesOpinion_TF">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Average opinion of neighbor nodes about this identity. Negative is bad,&lt;/p&gt;&lt;p&gt;positive is good. Zero is neutral.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_Type">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_Type">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEdit_LastUsed">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="15" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_GpgId">
<property name="text">
<string>Owner node ID :</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_GpgName">
<property name="text">
<string>Owner node name :</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="banoption_label">
<property name="text">
<string>Ban-option:</string>
</property>
</widget>
</item>
<item row="10" column="1" rowspan="2">
<widget class="RSComboBox" name="ownOpinion_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-family:'Sans'; font-size:9pt;&quot;&gt;Your own opinion about an identity rules the visibility of that identity for yourself and your friend nodes. Your own opinion is shared among friends and used to compute a reputation score: If your opinion about an identity is neutral, the reputation score is the difference between friend's positive and negative opinions. If not, your own opinion gives the score.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'Sans'; font-size:9pt;&quot;&gt;The overall score is used in chat lobbies, forums and channels to decide on the actions to take for each specific identity. When the overall score is lower than -1, the identity is banned, which prevents all messages and forums/channels authored by this identity to be forwarded, both ways. Some forums also have special anti-spam flags that require a non negative reputation level, making them more sensitive to bad opinions. Banned identities gradually lose their activity and eventually disappear (after 5 days).&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'Sans'; font-size:9pt;&quot;&gt;You can change the thresholds and the time of inactivity to delete identities in preferences -&amp;gt; people. &lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<item>
<property name="text">
<string>Negative</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/thumbs-down.png</normaloff>:/icons/png/thumbs-down.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Neutral</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/thumbs-neutral.png</normaloff>:/icons/png/thumbs-neutral.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Positive</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/thumbs-up.png</normaloff>:/icons/png/thumbs-up.png</iconset>
</property>
</item>
</widget>
</item>
<item row="0" column="2" rowspan="15">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="avatarLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string extracomment="Click here to change your avatar">Your Avatar</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="inviteButton">
<property name="text">
<string>Send Invite</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editButton">
<property name="text">
<string>Edit Identity</string>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QLabel" name="avatarLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string extracomment="Click here to change your avatar">Your Avatar</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="editButton">
<property name="text">
<string>Edit Identity</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="inviteButton">
<property name="text">
<string>Send Invite</string>
</property>
</widget>
</item>
<item row="0" column="2" rowspan="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>6</width>
<height>128</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" rowspan="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>6</width>
<height>128</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="avatarOpinionHLayout">
@ -756,200 +999,6 @@ border-image: url(:/images/closepressed.png)
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_Type">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_Type">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="overallOpinion_LB">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Overall:</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_LastUsed">
<property name="text">
<string>Last used:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_KeyId">
<property name="text">
<string>Identity ID :</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_PublishTS">
<property name="text">
<string>Created on :</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_GpgName">
<property name="text">
<string>Owner node name :</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="banoption_label">
<property name="text">
<string>Ban-option:</string>
</property>
</widget>
</item>
<item row="9" column="0" rowspan="2">
<widget class="QLabel" name="label_YourOpinion">
<property name="text">
<string>Your opinion:</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QLineEdit" name="neighborNodesOpinion_TF">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Average opinion of neighbor nodes about this identity. Negative is bad,&lt;/p&gt;&lt;p&gt;positive is good. Zero is neutral.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEdit_LastUsed">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="1" rowspan="2">
<widget class="RSComboBox" name="ownOpinion_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-family:'Sans'; font-size:9pt;&quot;&gt;Your own opinion about an identity rules the visibility of that identity for yourself and your friend nodes. Your own opinion is shared among friends and used to compute a reputation score: If your opinion about an identity is neutral, the reputation score is the difference between friend's positive and negative opinions. If not, your own opinion gives the score.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'Sans'; font-size:9pt;&quot;&gt;The overall score is used in chat lobbies, forums and channels to decide on the actions to take for each specific identity. When the overall score is lower than -1, the identity is banned, which prevents all messages and forums/channels authored by this identity to be forwarded, both ways. Some forums also have special anti-spam flags that require a non negative reputation level, making them more sensitive to bad opinions. Banned identities gradually lose their activity and eventually disappear (after 5 days).&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'Sans'; font-size:9pt;&quot;&gt;You can change the thresholds and the time of inactivity to delete identities in preferences -&amp;gt; people. &lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<item>
<property name="text">
<string>Negative</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/thumbs-down.png</normaloff>:/icons/png/thumbs-down.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Neutral</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/thumbs-neutral.png</normaloff>:/icons/png/thumbs-neutral.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Positive</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/thumbs-up.png</normaloff>:/icons/png/thumbs-up.png</iconset>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_Nickname">
<property name="text">
<string>Identity name :</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="autoBanIdentities_CB">
<property name="toolTip">
<string>Auto-Ban all identities signed by the same node</string>
</property>
<property name="text">
<string>Auto-Ban profile</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_GpgName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEdit_PublishTS">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="neighborNodesOpinion_LB">
<property name="text">
<string>Friend votes:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Nickname">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="Line" name="line_IdInfo">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_KeyId">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View file

@ -83,7 +83,7 @@ NetworkDialog::NetworkDialog(QWidget */*parent*/)
ui.connectTreeWidget->setUpdatesEnabled(true);
ui.connectTreeWidget->setSortingEnabled(true);
ui.connectTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui.connectTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui.connectTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(ui.connectTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connectTreeWidgetCostumPopupMenu( QPoint ) ) );
connect(ui.connectTreeWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(peerdetails()));
@ -117,24 +117,12 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
{
return;
}
QMenu *contextMnu = new QMenu;
RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()) ;
// That's what context menus are made for
RsPeerDetails detail;
if(!rsPeers->getGPGDetails(peer_id, detail)) // that is not suppose to fail.
return ;
if(peer_id == rsPeers->getGPGOwnId())
contextMnu->addAction(QIcon(), tr("Export/create a new node"), this, SLOT(on_actionExportKey_activated()));
contextMnu->addAction(QIcon(IMAGE_PEERDETAILS), tr("Profile details..."), this, SLOT(peerdetails()));
contextMnu->addSeparator() ;
contextMnu->addAction(QIcon(), tr("Remove unused keys..."), this, SLOT(removeUnusedKeys()));
contextMnu->addAction(QIcon(), tr("Remove this key"), this, SLOT(removeSelectedKeys()));
contextMnu->exec(QCursor::pos());
}
@ -177,11 +165,34 @@ void NetworkDialog::removeSelectedKeys()
QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
if(l.empty())
return;
std::set<RsPgpId> selected;
selected.insert(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()));
removeKeys(selected);
std::set<RsPgpId> friends;
for (int i = 0; i < l.size(); i++)
{
RsPgpId peer_id = RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l[i].row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString());
RsPeerDetails details ;
if(rsPeers->getGPGDetails(peer_id,details))
{
if(details.accept_connection)
friends.insert(peer_id);
else
selected.insert(peer_id);
}
}
if(!friends.empty())
{
if ((QMessageBox::question(this, "RetroShare", tr("You have selected %1 accepted peers among others,\n Are you sure you want to un-friend them?").arg(friends.size()), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes)
{
for(std::set<RsPgpId>::const_iterator it(friends.begin());it!=friends.end();++it)
rsPeers->removeFriend(*it);
selected.insert(friends.begin(),friends.end());
}
}
if(!selected.empty())
removeKeys(selected);
updateDisplay();
}
void NetworkDialog::removeKeys(std::set<RsPgpId> selected)

View file

@ -299,7 +299,7 @@ void NewsFeed::handleChannelEvent(std::shared_ptr<const RsEvent> event)
addFeedItem(new GxsChannelPostItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId, false, true));
break;
case RsChannelEventCode::NEW_COMMENT:
addFeedItem(new ChannelsCommentsItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId, false, true));
addFeedItem(new ChannelsCommentsItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId,pe->mChannelThreadId, false, true));
break;
case RsChannelEventCode::RECEIVED_PUBLISH_KEY:
addFeedItem(new GxsChannelGroupItem(this, NEWSFEED_CHANNELPUBKEYLIST, pe->mChannelGroupId, false, true));

View file

@ -216,7 +216,7 @@ void PulseAddDialog::setReplyTo(const RsWirePulse &pulse, RsWirePulseSPtr pPulse
mReplyToPulse = pulse;
mReplyType = replyType;
ui.frame_reply->setVisible(true);
ui.pushButton_picture->show();
ui.pushButton_picture->hide();
ui.topheadshot->hide();
{
@ -245,10 +245,12 @@ void PulseAddDialog::setReplyTo(const RsWirePulse &pulse, RsWirePulseSPtr pPulse
if (mReplyType & WIRE_PULSE_TYPE_REPUBLISH) {
ui.postButton->setText(tr("Republish Pulse"));
ui.pushButton_picture->hide();
ui.pushButton_Browse->hide();
}
else if (mReplyType & WIRE_PULSE_TYPE_LIKE) {
ui.postButton->setText(tr("Like Pulse"));
ui.pushButton_picture->hide();
ui.pushButton_Browse->hide();
}
}

View file

@ -140,7 +140,7 @@
<widget class="QWidget" name="widget_sentiment" native="true">
<layout class="QHBoxLayout" name="widget_sentiment_HL">
<property name="leftMargin">
<number>20</number>
<number>9</number>
</property>
<property name="topMargin">
<number>0</number>

View file

@ -40,10 +40,7 @@
</size>
</property>
<property name="styleSheet">
<string notr="true">QFrame#frame{border: 2px solid #CCCCCC;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #EEEEEE, stop: 1 #CCCCCC);
border-radius: 10px}</string>
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>

View file

@ -154,9 +154,16 @@ void WireDialog::processSettings(bool load)
// state of splitter
ui.splitter->restoreState(Settings->value("SplitterWire").toByteArray());
// state of filter combobox
int index = Settings->value("ShowGroup", 0).toInt();
ui.comboBox_groupSet->setCurrentIndex(index);
} else {
// save settings
// state of filter combobox
Settings->setValue("ShowGroup", ui.comboBox_groupSet->currentIndex());
// state of splitter
Settings->setValue("SplitterWire", ui.splitter->saveState());
}
@ -1064,4 +1071,3 @@ void WireDialog::postGroupsPulses(std::list<RsWirePulseSPtr> pulses)
}
}

View file

@ -1145,8 +1145,6 @@ void RsFriendListModel::updateInternalData()
mLocations.clear();
mTopLevel.clear();
endResetModel();
auto TL = mTopLevel ; // This allows to fill TL without touching mTopLevel outside of [begin/end]InsertRows().
// create a map of profiles and groups
@ -1282,7 +1280,8 @@ void RsFriendListModel::updateInternalData()
endInsertRows();
}
postMods();
endResetModel();
postMods();
mLastInternalDataUpdate = time(NULL);
}

View file

@ -1619,7 +1619,9 @@ bool NewFriendList::isColumnVisible(int col) const
}
void NewFriendList::setColumnVisible(int col,bool visible)
{
#ifdef DEBUG_NEW_FRIEND_LIST
std::cerr << "Setting column " << col << " to be visible: " << visible << std::endl;
#endif
ui->peerTreeWidget->setColumnHidden(col, !visible);
}
void NewFriendList::toggleColumnVisible()

View file

@ -34,6 +34,7 @@
#endif
#include "gui/common/FilesDefs.h"
#include "gui/RetroShareLink.h"
#include "gui/settings/rsharesettings.h"
#include "util/misc.h"
#include "ConnectFriendWizard.h"
@ -449,8 +450,9 @@ void ConnectFriendWizard::initializePage(int id)
}
sockaddr_storage addr ;
#ifdef DEBUG_FRIENDWIZARD
std::cerr << "Cert IP = " << peerDetails.extAddr << std::endl;
#endif
if(sockaddr_storage_ipv4_aton(addr,peerDetails.extAddr.c_str()) && sockaddr_storage_isValidNet(addr))
{
@ -870,7 +872,18 @@ void ConnectFriendWizard::cleanFriendCert()
bool certValid = false;
QString errorMsg ;
QString certDetail;
std::string cert = ui->friendCertEdit->toPlainText().toUtf8().constData();
std::string cert ;
RetroShareLink rslink(ui->friendCertEdit->toPlainText());
if(rslink.valid() && rslink.type() == RetroShareLink::TYPE_CERTIFICATE)
cert = rslink.radix().toStdString();
else
cert = ui->friendCertEdit->toPlainText().toUtf8().constData();
#ifdef DEBUG_FRIENDWIZARD
std::cerr << "Friend cert:\"" << cert << "\"" << std::endl;
#endif
if (cert.empty()) {
ui->friendCertCleanLabel->setToolTip("");
@ -936,7 +949,7 @@ void ConnectFriendWizard::cleanFriendCert()
void ConnectFriendWizard::pasteCert()
{
QClipboard *clipboard = QApplication::clipboard();
ui->friendCertEdit->setPlainText(clipboard->text());
ui->friendCertEdit->setPlainText(clipboard->text());
}
void ConnectFriendWizard::openCert()

View file

@ -49,46 +49,41 @@
* #define DEBUG_ITEM 1
****/
ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group_meta, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set<RsGxsMessageId>& older_versions) :
GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate),
mGroupMeta(group_meta)
// ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group_meta, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set<RsGxsMessageId>& older_versions) :
// GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate),
// mGroupMeta(group_meta)
// {
// mLoadingGroup = false;
// mLoadingMessage = false;
// mLoadingComment = false;
//
// mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded
// mPost.mMeta.mGroupId = mGroupMeta.mGroupId;
//
// QVector<RsGxsMessageId> v;
// //bool self = false;
//
// for(std::set<RsGxsMessageId>::const_iterator it(older_versions.begin());it!=older_versions.end();++it)
// v.push_back(*it) ;
//
// if(older_versions.find(messageId) == older_versions.end())
// v.push_back(messageId);
//
// setMessageVersions(v) ;
// setup();
//
// // no call to loadGroup() here because we have it already.
// }
ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &commentId, const RsGxsMessageId &threadId, bool isHome, bool autoUpdate) :
GxsFeedItem(feedHolder, feedId, groupId, commentId, isHome, rsGxsChannels, autoUpdate), // this one should be in GxsFeedItem
mThreadId(threadId)
{
mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded
mPost.mMeta.mGroupId = mGroupMeta.mGroupId;
mLoading= false;
QVector<RsGxsMessageId> v;
//bool self = false;
for(std::set<RsGxsMessageId>::const_iterator it(older_versions.begin());it!=older_versions.end();++it)
v.push_back(*it) ;
if(older_versions.find(messageId) == older_versions.end())
v.push_back(messageId);
setMessageVersions(v) ;
setup();
// no call to loadGroup() here because we have it already.
}
ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set<RsGxsMessageId>& older_versions) :
GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsGxsChannels, autoUpdate) // this one should be in GxsFeedItem
{
mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded
QVector<RsGxsMessageId> v;
//bool self = false;
for(std::set<RsGxsMessageId>::const_iterator it(older_versions.begin());it!=older_versions.end();++it)
v.push_back(*it) ;
if(older_versions.find(messageId) == older_versions.end())
v.push_back(messageId);
setMessageVersions(v) ;
setup();
loadGroup();
}
void ChannelsCommentsItem::paintEvent(QPaintEvent *e)
@ -99,21 +94,22 @@ void ChannelsCommentsItem::paintEvent(QPaintEvent *e)
if(!mLoaded)
{
mLoaded = true ;
std::set<RsGxsMessageId> older_versions; // not so nice. We need to use std::set everywhere
for(auto& m:messageVersions())
older_versions.insert(m);
fill();
requestMessage();
requestComment();
}
load();
}
GxsFeedItem::paintEvent(e) ;
}
ChannelsCommentsItem::~ChannelsCommentsItem()
{
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300);
while( mLoading && std::chrono::steady_clock::now() < timeout )
{
RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for data to load " << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
delete(ui);
}
@ -182,21 +178,19 @@ void ChannelsCommentsItem::setup()
ui->expandFrame->hide();
}
bool ChannelsCommentsItem::setPost(const RsGxsChannelPost &post, bool doFill)
bool ChannelsCommentsItem::setPost(const RsGxsChannelPost& post, bool doFill)
{
if (groupId() != post.mMeta.mGroupId || messageId() != post.mMeta.mMsgId) {
std::cerr << "ChannelsCommentsItem::setPost() - Wrong id, cannot set post";
std::cerr << std::endl;
return false;
}
mPost = post;
if (doFill) {
if (doFill)
fill();
}
return true;
return true;
}
bool ChannelsCommentsItem::setMissingPost()
{
fill(true);
return true;
}
QString ChannelsCommentsItem::getTitleLabel()
@ -230,168 +224,148 @@ void ChannelsCommentsItem::loadComments()
void ChannelsCommentsItem::loadGroup()
{
#ifdef DEBUG_ITEM
std::cerr << "GxsChannelGroupItem::loadGroup()";
std::cerr << std::endl;
#endif
RsThread::async([this]()
{
// 1 - get group data
std::vector<RsGxsChannelGroup> groups;
const std::list<RsGxsGroupId> groupIds = { groupId() };
if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group
{
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
return;
}
if (groups.size() != 1)
{
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
std::cerr << std::endl;
return;
}
RsGxsChannelGroup group(groups[0]);
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 */
mGroupMeta = group.mMeta;
}, this );
});
//#ifdef DEBUG_ITEM
// std::cerr << "GxsChannelGroupItem::loadGroup()";
// std::cerr << std::endl;
//#endif
// if(mLoading)
// return;
//
// mLoading= true;
//
// std::cerr << "Loading group" << std::endl;
// RsThread::async([this]()
// {
// // 1 - get group data
//
// std::vector<RsGxsChannelGroup> groups;
// const std::list<RsGxsGroupId> groupIds = { groupId() };
//
// if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group
// {
// RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
// return;
// }
//
// if (groups.size() != 1)
// {
// std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
// std::cerr << std::endl;
// return;
// }
// RsGxsChannelGroup group(groups[0]);
//
// 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 */
//
// mGroupMeta = group.mMeta;
// mLoading= false;
//
// std::cerr << "End loading group" << std::endl;
// }, this );
// });
}
void ChannelsCommentsItem::loadMessage()
void ChannelsCommentsItem::load()
{
// This function loads everything that's needed:
// - the comment text
// - the comment parent message
#ifdef DEBUG_ITEM
std::cerr << "ChannelsCommentsItem::loadMessage()";
std::cerr << std::endl;
#endif
RsThread::async([this]()
if(mLoading)
return;
mLoading= true;
RsThread::async([this]()
{
// 1 - get group data
// 1 - get group meta data
std::vector<RsGxsChannelGroup> groups;
const std::list<RsGxsGroupId> groupIds = { groupId() };
if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group
{
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
return;
}
if (groups.size() != 1)
{
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items" << std::endl;
return;
}
RsGxsChannelGroup group(groups[0]);
// 2 - get message and comment data
std::vector<RsGxsChannelPost> posts;
std::vector<RsGxsComment> comments;
std::vector<RsGxsVote> votes;
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments,votes))
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId(),mThreadId } ),posts,comments,votes))
{
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
return;
}
if (posts.size() == 1)
{
#ifdef DEBUG_ITEM
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
#endif
RsGxsChannelPost post(posts[0]); // no reference to temporary here, because we pass this to a thread
// now that everything is in place, update the UI
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
}
else if(comments.size() == 1)
{
RsGxsComment cmt(comments[0]);
#ifdef DEBUG_ITEM
std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl;
#endif
RsQThreadUtils::postToObject( [group,posts,comments,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 */
RsQThreadUtils::postToObject( [cmt,this]()
{
uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height())
/ QFontMetricsF(ui->subjectLabel->font()).height());
mGroupMeta = group.mMeta;
ui->commLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(cmt.mComment.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_LINKS));
if(comments.size()==1)
{
RsGxsComment cmt(comments[0]);
ui->nameLabel->setId(cmt.mMeta.mAuthorId);
ui->datetimeLabel->setText(DateTime::formatLongDateTime(cmt.mMeta.mPublishTs));
uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height())
/ QFontMetricsF(ui->subjectLabel->font()).height());
RsIdentityDetails idDetails ;
rsIdentity->getIdDetails(cmt.mMeta.mAuthorId,idDetails);
QPixmap pixmap ;
ui->commLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(cmt.mComment.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_LINKS));
ui->nameLabel->setId(cmt.mMeta.mAuthorId);
ui->datetimeLabel->setText(DateTime::formatLongDateTime(cmt.mMeta.mPublishTs));
if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL))
pixmap = GxsIdDetails::makeDefaultIcon(cmt.mMeta.mAuthorId,GxsIdDetails::LARGE);
ui->avatarLabel->setPixmap(pixmap);
RsIdentityDetails idDetails ;
rsIdentity->getIdDetails(cmt.mMeta.mAuthorId,idDetails);
QPixmap pixmap ;
//Change this item to be uploaded with thread element.
setMessageId(cmt.mMeta.mThreadId);
requestMessage();
if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL))
pixmap = GxsIdDetails::makeDefaultIcon(cmt.mMeta.mAuthorId,GxsIdDetails::LARGE);
ui->avatarLabel->setPixmap(pixmap);
}, this );
//Change this item to be uploaded with thread element. This is really bad practice.
}
else
{
mLoading=false;
removeItem();
}
}
else
{
#ifdef DEBUG_ITEM
std::cerr << "ChannelsCommentsItem::loadMessage() Wrong number of Items. Remove It.";
std::cerr << std::endl;
#endif
if (posts.size() == 1)
setPost(posts[0]);
else
setMissingPost();
RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
}
});
emit sizeChanged(this);
emit sizeChanged(this);
mLoading=false;
}, this );
});
}
void ChannelsCommentsItem::loadComment()
void ChannelsCommentsItem::fill(bool missing_post)
{
#ifdef DEBUG_ITEM
std::cerr << "ChannelsCommentsItem::loadComment()";
std::cerr << std::endl;
#endif
RsThread::async([this]()
{
// 1 - get group data
std::set<RsGxsMessageId> msgIds;
for(auto MsgId: messageVersions())
msgIds.insert(MsgId);
std::vector<RsGxsChannelPost> posts;
std::vector<RsGxsComment> comments;
if(! rsGxsChannels->getChannelComments( groupId(),msgIds,comments))
{
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
return;
}
int comNb = comments.size();
RsQThreadUtils::postToObject( [comNb]()
{
QString sComButText = tr("Comment");
if (comNb == 1)
sComButText = sComButText.append("(1)");
else if(comNb > 1)
sComButText = tr("Comments ").append("(%1)").arg(comNb);
//ui->commentButton->setText(sComButText);
}, this );
});
}
void ChannelsCommentsItem::fill()
{
/* fill in */
// if (isLoading()) {
// /* Wait for all requests */
//return;
// }
#ifdef DEBUG_ITEM
std::cerr << "ChannelsCommentsItem::fill()";
std::cerr << std::endl;
@ -399,9 +373,6 @@ void ChannelsCommentsItem::fill()
mInFill = true;
//QString title;
//float f = QFontMetricsF(font()).height()/14.0 ;
if (!mIsHome)
{
if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) {
@ -412,19 +383,14 @@ void ChannelsCommentsItem::fill()
//title += link.toHtml();
//ui->titleLabel->setText(title);
RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName());
ui->subjectLabel->setText(msgLink.toHtml());
RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName());
if(missing_post)
ui->subjectLabel->setText("[" + QObject::tr("Missing channel post")+"]");
else
ui->subjectLabel->setText(msgLink.toHtml());
if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags))
{
//ui->unsubscribeButton->setEnabled(true);
}
else
{
//ui->unsubscribeButton->setEnabled(false);
}
ui->readButton->hide();
//ui->titleLabel->hide();
if (IS_MSG_NEW(mPost.mMeta.mMsgStatus)) {
mCloseOnRead = true;
@ -432,19 +398,10 @@ void ChannelsCommentsItem::fill()
}
else
{
/* subject */
//ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str()));
//uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height())
// / QFontMetricsF(ui->subjectLabel->font()).height());
// fill first 4 lines of message. (csoler) Disabled the replacement of smileys and links, because the cost is too crazy
//ui->subjectLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ;
//QString score = QString::number(post.mTopScore);
// scoreLabel->setText(score);
if(missing_post)
ui->subjectLabel->setText("[" + QObject::tr("Missing channel post")+"]");
else
ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ;
/* disable buttons: deletion facility not enabled with cache services yet */
ui->clearButton->setEnabled(false);
@ -467,50 +424,9 @@ void ChannelsCommentsItem::fill()
mCloseOnRead = false;
}
// differences between Feed or Top of Comment.
if (mFeedHolder)
{
//ui->commentButton->show();
// Not yet functional
/*if (mPost.mCommentCount)
{
QString commentText = QString::number(mPost.mCommentCount);
commentText += " ";
commentText += tr("Comments");
ui->commentButton->setText(commentText);
}
else
{
ui->commentButton->setText(tr("Comment"));
}*/
}
else
{
//ui->commentButton->hide();
}
// disable voting buttons - if they have already voted.
/*if (post.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK)
{
voteUpButton->setEnabled(false);
voteDownButton->setEnabled(false);
}*/
if (wasExpanded() || ui->expandFrame->isVisible()) {
fillExpandFrame();
}
mInFill = false;
}
void ChannelsCommentsItem::fillExpandFrame()
{
//ui->msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
}
QString ChannelsCommentsItem::messageName()
{
return QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
@ -574,10 +490,6 @@ void ChannelsCommentsItem::doExpand(bool open)
void ChannelsCommentsItem::expandFill(bool first)
{
GxsFeedItem::expandFill(first);
if (first) {
fillExpandFrame();
}
}
void ChannelsCommentsItem::toggle()

View file

@ -42,12 +42,17 @@ public:
// It can be used for all apparences of channel posts. But in rder to merge comments from the previous versions of the post, the list of
// previous posts should be supplied. It's optional. If not supplied only the comments of the new version will be displayed.
ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set<RsGxsMessageId>& older_versions = std::set<RsGxsMessageId>());
ChannelsCommentsItem(FeedHolder *feedHolder,
uint32_t feedId,
const RsGxsGroupId& groupId,
const RsGxsMessageId& commentId,
const RsGxsMessageId& threadId,
bool isHome,
bool autoUpdate);
// This one is used in channel thread widget. We don't want the group data to reload at every post, so we load it in the hosting
// GxsChannelsPostsWidget and pass it to created items.
ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set<RsGxsMessageId>& older_versions = std::set<RsGxsMessageId>());
// ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set<RsGxsMessageId>& older_versions = std::set<RsGxsMessageId>());
virtual ~ChannelsCommentsItem();
@ -55,6 +60,7 @@ public:
bool setGroup(const RsGxsChannelGroup& group, bool doFill = true);
bool setPost(const RsGxsChannelPost& post, bool doFill = true);
bool setMissingPost();
QString getTitleLabel();
QString getMsgLabel();
@ -85,8 +91,8 @@ protected:
/* GxsFeedItem */
virtual QString messageName();
virtual void loadMessage();
virtual void loadComment();
virtual void loadMessage() override {}
virtual void loadComment() override {}
private slots:
/* default stuff */
@ -104,17 +110,20 @@ signals:
void vote(const RsGxsGrpMsgIdPair& msgId, bool up);
private:
void setup();
void fill();
void fillExpandFrame();
void load();
void setup();
void fill(bool missing_post=false);
private:
bool mInFill;
bool mCloseOnRead;
bool mLoaded;
bool mLoading;
RsGroupMetaData mGroupMeta;
RsGxsChannelPost mPost;
RsGxsMessageId mThreadId;
/** Qt Designer generated object */
Ui::ChannelsCommentsItem *ui;

View file

@ -37,20 +37,47 @@ GxsChannelGroupItem::GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId
GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsChannels, autoUpdate)
{
setup();
requestGroup();
addEventHandler();
}
GxsChannelGroupItem::GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup &group, bool isHome, bool autoUpdate) :
GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsChannels, autoUpdate)
{
setup();
setup();
setGroup(group);
addEventHandler();
}
setGroup(group);
void GxsChannelGroupItem::addEventHandler()
{
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
{
RsQThreadUtils::postToObject([=]()
{
const auto *e = dynamic_cast<const RsGxsChannelEvent*>(event.get());
if(!e || e->mChannelGroupId != this->groupId())
return;
switch(e->mChannelEventCode)
{
case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED:
case RsChannelEventCode::UPDATED_CHANNEL:
case RsChannelEventCode::RECEIVED_PUBLISH_KEY:
loadGroup();
break;
default:
break;
}
}, this );
}, mEventHandlerId, RsEventType::GXS_CHANNELS );
}
GxsChannelGroupItem::~GxsChannelGroupItem()
{
rsEvents->unregisterEventsHandler(mEventHandlerId);
delete(ui);
}

View file

@ -60,12 +60,14 @@ private slots:
private:
void fill();
void setup();
void addEventHandler();
private:
RsGxsChannelGroup mGroup;
/** Qt Designer generated object */
Ui::GxsChannelGroupItem *ui;
RsEventsHandlerId_t mEventHandlerId;
};
#endif

View file

@ -251,7 +251,7 @@
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Subscribe to Channel</string>
<string>Subscribe this Channel</string>
</property>
<property name="text">
<string>Subscribe</string>

View file

@ -49,6 +49,10 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId,
GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate),
mGroupMeta(group_meta)
{
mLoadingGroup = false;
mLoadingMessage = false;
mLoadingComment = false;
mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded
mPost.mMeta.mGroupId = mGroupMeta.mGroupId;
@ -136,6 +140,19 @@ void GxsChannelPostItem::paintEvent(QPaintEvent *e)
GxsChannelPostItem::~GxsChannelPostItem()
{
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300);
while( (mLoadingGroup || mLoadingMessage || mLoadingComment)
&& std::chrono::steady_clock::now() < timeout)
{
RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for "
<< (mLoadingGroup ? "Group " : "")
<< (mLoadingMessage ? "Message " : "")
<< (mLoadingComment ? "Comment " : "")
<< "loading." << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
delete(ui);
}
@ -277,6 +294,7 @@ void GxsChannelPostItem::loadGroup()
std::cerr << "GxsChannelGroupItem::loadGroup()";
std::cerr << std::endl;
#endif
mLoadingGroup = true;
RsThread::async([this]()
{
@ -306,6 +324,7 @@ void GxsChannelPostItem::loadGroup()
* after a blocking call to RetroShare API complete */
mGroupMeta = group.mMeta;
mLoadingGroup = false;
}, this );
});
@ -316,6 +335,8 @@ void GxsChannelPostItem::loadMessage()
std::cerr << "GxsChannelPostItem::loadMessage()";
std::cerr << std::endl;
#endif
mLoadingMessage = true;
RsThread::async([this]()
{
// 1 - get group data
@ -337,7 +358,11 @@ void GxsChannelPostItem::loadMessage()
#endif
const RsGxsChannelPost& post(posts[0]);
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
RsQThreadUtils::postToObject( [post,this]()
{
setPost(post);
mLoadingMessage = false;
}, this );
}
else if(comments.size() == 1)
{
@ -356,7 +381,8 @@ void GxsChannelPostItem::loadMessage()
setMessageId(cmt.mMeta.mThreadId);
requestMessage();
}, this );
mLoadingMessage = false;
}, this );
}
else
@ -366,7 +392,11 @@ void GxsChannelPostItem::loadMessage()
std::cerr << std::endl;
#endif
RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
RsQThreadUtils::postToObject( [this]()
{
removeItem();
mLoadingMessage = false;
}, this );
}
});
}
@ -377,6 +407,7 @@ void GxsChannelPostItem::loadComment()
std::cerr << "GxsChannelPostItem::loadComment()";
std::cerr << std::endl;
#endif
mLoadingComment = true;
RsThread::async([this]()
{
@ -407,6 +438,7 @@ void GxsChannelPostItem::loadComment()
sComButText = tr("Comments ").append("(%1)").arg(comNb);
ui->commentButton->setText(sComButText);
mLoadingComment = false;
}, this );
});

View file

@ -119,7 +119,12 @@ private:
private:
bool mInFill;
bool mCloseOnRead;
bool mLoaded;
bool mLoaded;
bool mLoadingMessage;
bool mLoadingGroup;
bool mLoadingComment;
RsGroupMetaData mGroupMeta;
RsGxsChannelPost mPost;

View file

@ -35,8 +35,8 @@ GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, co
GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsForums, autoUpdate)
{
setup();
requestGroup();
addEventHandler();
}
GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const std::list<RsGxsId>& added_moderators,const std::list<RsGxsId>& removed_moderators,bool isHome, bool autoUpdate):
@ -45,21 +45,48 @@ GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, co
mRemovedModerators(removed_moderators)
{
setup();
requestGroup();
addEventHandler();
}
void GxsForumGroupItem::addEventHandler()
{
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
{
RsQThreadUtils::postToObject([=]()
{
const auto *e = dynamic_cast<const RsGxsForumEvent*>(event.get());
if(!e || e->mForumGroupId != this->groupId())
return;
switch(e->mForumEventCode)
{
case RsForumEventCode::SUBSCRIBE_STATUS_CHANGED:
case RsForumEventCode::UPDATED_FORUM:
case RsForumEventCode::MODERATOR_LIST_CHANGED:
loadGroup();
break;
default:
break;
}
}, this );
}, mEventHandlerId, RsEventType::GXS_FORUMS );
}
GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate) :
GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsForums, autoUpdate)
{
setup();
setGroup(group);
addEventHandler();
}
GxsForumGroupItem::~GxsForumGroupItem()
{
delete(ui);
rsEvents->unregisterEventsHandler(mEventHandlerId);
delete(ui);
}
void GxsForumGroupItem::setup()

View file

@ -22,6 +22,7 @@
#define _GXSFORUMGROUPITEM_H
#include <retroshare/rsgxsforums.h>
#include <retroshare/rsevents.h>
#include "gui/gxs/GxsGroupFeedItem.h"
namespace Ui {
@ -39,27 +40,28 @@ public:
GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate);
GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const std::list<RsGxsId>& added_moderators,const std::list<RsGxsId>& removed_moderators,bool isHome, bool autoUpdate);
GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate);
~GxsForumGroupItem();
virtual ~GxsForumGroupItem() override;
bool setGroup(const RsGxsForumGroup &group);
uint64_t uniqueIdentifier() const override { return hash_64bits("GxsForumGroupItem " + groupId().toStdString()) ; }
protected:
/* FeedItem */
virtual void doExpand(bool open);
void toggle() override;
virtual void doExpand(bool open) override;
/* GxsGroupFeedItem */
virtual QString groupName();
virtual QString groupName() override;
virtual void loadGroup() override;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
virtual RetroShareLink::enumType getLinkType() override { return RetroShareLink::TYPE_FORUM; }
private slots:
void subscribeForum();
void toggle() override;
private:
void fill();
void setup();
void addEventHandler();
private:
RsGxsForumGroup mGroup;
@ -69,6 +71,8 @@ private:
std::list<RsGxsId> mAddedModerators;
std::list<RsGxsId> mRemovedModerators;
RsEventsHandlerId_t mEventHandlerId;
};
#endif

View file

@ -47,7 +47,13 @@ GxsForumMsgItem::GxsForumMsgItem(FeedHolder *feedHolder, uint32_t feedId, const
{
mMessage.mMeta.mMsgId = messageId; // useful for uniqueIdentifier() before the post is actually loaded
mMessage.mMeta.mGroupId = groupId;
setup();
mLoadingGroup = false;
mLoadingMessage = false;
mLoadingSetAsRead = false;
mLoadingParentMessage = false;
setup();
requestGroup();
requestMessage();

View file

@ -29,6 +29,8 @@
#include <QMessageBox>
#include <QDateTime>
//#define DEBUG_COMMENT_DIALOG 1
/** Constructor */
GxsCommentDialog::GxsCommentDialog(QWidget *parent, const RsGxsId &default_author, RsGxsCommentService *comment_service)
: QWidget(parent), ui(new Ui::GxsCommentDialog)
@ -95,8 +97,11 @@ void GxsCommentDialog::commentClear()
}
void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const std::set<RsGxsMessageId>& msg_versions,const RsGxsMessageId& most_recent_msgId,bool use_cache)
{
std::cerr << "GxsCommentDialog::commentLoad(" << grpId << ", most recent msg version: " << most_recent_msgId << ")";
std::cerr << std::endl;
#ifdef DEBUG_COMMENT_DIALOG
std::cerr << "GxsCommentDialog::commentLoad(" << grpId << ", most recent msg version: " << most_recent_msgId << ")" << std::endl;
for(const auto& mid:msg_versions)
std::cerr << " msg version: " << mid << std::endl;
#endif
mGrpId = grpId;
mMostRecentMsgId = most_recent_msgId;

View file

@ -42,6 +42,8 @@
#include <iostream>
//#define DEBUG_COMMENT_TREE_WIDGET
#define PCITEM_COLUMN_COMMENT 0
#define PCITEM_COLUMN_AUTHOR 1
#define PCITEM_COLUMN_DATE 2
@ -73,6 +75,7 @@ std::map<RsGxsMessageId, std::vector<RsGxsComment> > GxsCommentTreeWidget::mComm
QMutex GxsCommentTreeWidget::mCacheMutex;
//#define USE_NEW_DELEGATE 1
//#define DEBUG_GXSCOMMENT_TREEWIDGET 1
// This class allows to draw the item using an appropriate size
@ -508,6 +511,8 @@ void GxsCommentTreeWidget::service_requestComments(const RsGxsGroupId& group_id,
/* request comments */
#ifdef DEBUG_GXSCOMMENT_TREEWIDGET
std::cerr << "GxsCommentTreeWidget::service_requestComments for group " << group_id << std::endl;
for(const auto& mid:msgIds)
std::cerr << " including message " << mid << std::endl;
#endif
RsThread::async([this,group_id,msgIds]()
@ -765,8 +770,10 @@ void GxsCommentTreeWidget::insertComments(const std::vector<RsGxsComment>& comme
new_comments.push_back(comment.mMeta.mMsgId);
/* convert to a QTreeWidgetItem */
#ifdef DEBUG_COMMENT_TREE_WIDGET
std::cerr << "GxsCommentTreeWidget::service_loadThread() Got Comment: " << comment.mMeta.mMsgId;
std::cerr << std::endl;
#endif
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(NULL,GxsIdDetails::ICON_TYPE_AVATAR) ;
QString text;

View file

@ -35,6 +35,7 @@
#include "util/rsdir.h"
#include "util/qtthreadsutils.h"
#include "util/RichTextEdit.h"
#include "util/imageutil.h"
#include <retroshare/rsfiles.h>
@ -607,11 +608,13 @@ bool CreateGxsChannelMsg::setThumbNail(const std::string& path, int frame){
if(imageBuffer == NULL)
return false;
QImage tNail(imageBuffer, width, height, QImage::Format_RGB32);
QImage tNail(imageBuffer, width, height, QImage::Format_RGBA32);
QByteArray ba;
QBuffer buffer(&ba);
bool has_transparency = ImageUtil::hasAlphaContent(tNail.toImage());
buffer.open(QIODevice::WriteOnly);
tNail.save(&buffer, "JPG");
tNail.save(&buffer, has_transparency?"PNG":"JPG");
QPixmap img;
img.loadFromData(ba, "PNG");
img = img.scaled(thumbnail_label->width(), thumbnail_label->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
@ -797,15 +800,19 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str
QByteArray ba;
QBuffer buffer(&ba);
RsGxsImage image;
RsGxsImage image;
QPixmap pixmap;
pixmap = preview_W->getCroppedScaledPicture();
QImage qimg = pixmap.toImage();
bool has_transparency = ImageUtil::hasAlphaContent(qimg);
if(!picture.isNull())
{
// send chan image
buffer.open(QIODevice::WriteOnly);
preview_W->getCroppedScaledPicture().save(&buffer, "JPG"); // writes image into ba in PNG format
image.copy((uint8_t *) ba.data(), ba.size());
preview_W->getCroppedScaledPicture().save(&buffer, has_transparency?"PNG":"JPG"); // writes image into ba in PNG format
image.copy((uint8_t *) ba.data(), ba.size());
}
std::string error_string;

View file

@ -176,6 +176,25 @@ int RsGxsChannelPostsModel::rowCount(const QModelIndex& parent) const
return 0;
}
int RsGxsChannelPostsModel::columnCount(int row) const
{
if(mTreeMode == TREE_MODE_GRID)
{
if(row+1 == rowCount())
{
int r = ((int)mFilteredPosts.size() % (int)mColumns);
if(r > 0)
return r;
else
return columnCount();
}
else
return columnCount();
}
else
return 2;
}
int RsGxsChannelPostsModel::columnCount(const QModelIndex &/*parent*/) const
{
if(mTreeMode == TREE_MODE_GRID)
@ -245,7 +264,7 @@ bool RsGxsChannelPostsModel::convertRefPointerToTabEntry(quintptr ref, uint32_t&
QModelIndex RsGxsChannelPostsModel::index(int row, int column, const QModelIndex & parent) const
{
if(row < 0 || column < 0 || column >= (int)mColumns)
if(row < 0 || column < 0 || row >= rowCount() || column >= columnCount(row))
return QModelIndex();
quintptr ref = getChildRef(parent.internalId(),(mTreeMode == TREE_MODE_GRID)?(column + row*mColumns):row);

View file

@ -105,6 +105,7 @@ public:
QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;}
QModelIndex getIndexOfMessage(const RsGxsMessageId& mid) const;
int columnCount(int row) const; // columns in the row of this particular index.
std::vector<std::pair<time_t,RsGxsMessageId> > getPostVersions(const RsGxsMessageId& mid) const;

View file

@ -504,6 +504,30 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
}, mEventHandlerId, RsEventType::GXS_CHANNELS );
}
void GxsChannelPostsWidgetWithModel::keyPressEvent(QKeyEvent *e)
{
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
if(index.isValid() && mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID)
{
int n = mChannelPostsModel->columnCount(index.row())-1;
if(e->key() == Qt::Key_Left && index.column()==0)
{
ui->postsTree->setCurrentIndex(index.sibling(index.row(),n));
e->accept();
return;
}
if(e->key() == Qt::Key_Right && index.column()==n)
{
ui->postsTree->setCurrentIndex(index.sibling(index.row(),0));
e->accept();
return;
}
}
GxsMessageFrameWidget::keyPressEvent(e);
}
void GxsChannelPostsWidgetWithModel::resizeEvent(QResizeEvent *e)
{
GxsMessageFrameWidget::resizeEvent(e);

View file

@ -139,6 +139,7 @@ protected:
/* GxsMessageFrameWidget */
virtual void setAllMessagesReadDo(bool read) override;
virtual void resizeEvent(QResizeEvent *e) override;
virtual void keyPressEvent(QKeyEvent *e) override;
private slots:
void showPostDetails();

View file

@ -255,7 +255,7 @@ private:
QList<QLabel*> tagLabels;
// needed to send system flags with reply
unsigned msgFlags;
unsigned int msgFlags;
RSTreeWidgetItemCompareRole *m_compareRole;
QCompleter *m_completer;

View file

@ -690,6 +690,10 @@ void RsMessageModel::setCurrentBox(Rs::Msgs::BoxName bn)
}
}
Rs::Msgs::BoxName RsMessageModel::currentBox() const
{
return mCurrentBox;
}
void RsMessageModel::setQuickViewFilter(QuickViewFilter fn)
{
if(fn != mQuickViewFilter)

View file

@ -100,6 +100,7 @@ public:
// This method will asynchroneously update the data
void setCurrentBox(Rs::Msgs::BoxName bn) ;
Rs::Msgs::BoxName currentBox() const ;
void setQuickViewFilter(QuickViewFilter fn) ;
void setFilter(FilterType filter_type, const QStringList& strings) ;

View file

@ -738,7 +738,8 @@ void MessageWidget::remove()
return;
}
bool deleteReal = false;
#ifdef TO_REMOVE
bool deleteReal = false;
if (msgInfo.msgflags & RS_MSG_TRASH) {
deleteReal = true;
} else {
@ -763,8 +764,8 @@ void MessageWidget::remove()
deleteLater();
}
}
emit messageRemoved();
#endif
emit messageRemovalRequested(currMsgId);
}
void MessageWidget::print()

View file

@ -61,6 +61,7 @@ public:
signals:
void messageRemoved();
void messageRemovalRequested(std::string);
private slots:
void reply();

View file

@ -95,6 +95,7 @@
#define ROW_SENTBOX 3
#define ROW_TRASHBOX 4
// #define DEBUG_MESSAGES_DIALOG 1
class MessageSortFilterProxyModel: public QSortFilterProxyModel
{
@ -144,7 +145,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
msgWidget = new MessageWidget(true, this);
ui.msgLayout->addWidget(msgWidget);
connect(msgWidget, SIGNAL(messageRemoved()), this, SLOT(messageRemoved()));
connect(msgWidget, SIGNAL(messageRemovalRequested(std::string)), this, SLOT(removemessage()));
connectActions();
@ -365,15 +366,18 @@ void MessagesDialog::preModelUpdate()
if (m.isValid()) {
mTmpSavedCurrentId = m.sibling(m.row(), RsMessageModel::COLUMN_THREAD_MSGID).data(RsMessageModel::MsgIdRole).toString();
}
#ifdef DEBUG_MESSAGES_DIALOG
std::cerr << "Pre-change: saving selection for " << mTmpSavedSelectedIds.size() << " indexes" << std::endl;
#endif
}
void MessagesDialog::postModelUpdate()
{
// restore selection
#ifdef DEBUG_MESSAGES_DIALOG
std::cerr << "Post-change: restoring selection for " << mTmpSavedSelectedIds.size() << " indexes" << std::endl;
#endif
QItemSelection sel;
foreach(const QString& s,mTmpSavedSelectedIds)
@ -838,7 +842,7 @@ void MessagesDialog::openAsWindow()
}
msgWidget->activateWindow();
connect(msgWidget, SIGNAL(messageRemoved()), this, SLOT(messageRemoved()));
connect(msgWidget, SIGNAL(messageRemovalRequested(std::string)), this, SLOT(removemessage()));
/* window will destroy itself! */
}
@ -858,7 +862,7 @@ void MessagesDialog::openAsTab()
ui.tabWidget->addTab(msgWidget,FilesDefs::getIconFromQtResourcePath(IMAGE_MAIL), msgWidget->subject(true));
ui.tabWidget->setCurrentWidget(msgWidget);
connect(msgWidget, SIGNAL(messageRemoved()), this, SLOT(messageRemoved()));
connect(msgWidget, SIGNAL(messageRemovalRequested(std::string)), this, SLOT(removemessage()));
/* window will destroy itself! */
}
@ -921,9 +925,9 @@ void MessagesDialog::changeBox(int box_row)
ui.messageTreeWidget->setPlaceholderText(placeholderText);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_READ,box_row!=ROW_INBOX);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_STAR,box_row==ROW_OUTBOX);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_SPAM,box_row==ROW_OUTBOX);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_TAGS,box_row==ROW_OUTBOX);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_STAR,box_row!=ROW_INBOX);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_SPAM,box_row!=ROW_INBOX);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_TAGS,box_row!=ROW_INBOX);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_MSGID,true);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_CONTENT,true);
}
@ -1292,7 +1296,7 @@ void MessagesDialog::updateMessageSummaryList()
/* calculating the new messages */
std::list<MsgInfoSummary> msgList;
rsMail->getMessageSummaries(Rs::Msgs::BoxName::BOX_ALL,msgList);
rsMail->getMessageSummaries(mMessageModel->currentBox(),msgList);
QMap<int, int> tagCount;

View file

@ -2436,7 +2436,7 @@ WireGroupItem QFrame#wire_frame QLabel{
background: transparent;
}
WireGroupItem QFrame#wire_frame:hover {
background-color: #2e8bab;
background-color: #346792;
}
PulseTopLevel QFrame#frame,
@ -2446,13 +2446,6 @@ PulseReply QFrame#frame {
border-radius: 6px;
}
PulseAddDialog QTextEdit#textEdit_Pulse {
border: 2px solid #c4cfd6;
border-radius: 6px;
background: white;
color: black;
}
PulseReply #line_replyLine,
PulseMessage #line{
color: #c4cfd6;
@ -2462,6 +2455,16 @@ PulseReply QLabel#label_groupName{
color: #5b7083;
}
PulseReplySeperator QFrame#frame {
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #455364, stop: 0.5 #54687A,stop: 0.6 #44586A, stop:1 #455364);
border-radius: 10px;
}
QLabel#label_masthead{
border: 2px solid #CCCCCC;
border-radius: 4px;
}
/**** Color definitions ****/
ForumsDialog, GxsForumThreadWidget
@ -2552,10 +2555,3 @@ OpModeStatus[opMode="Minimal"] {
[WrongValue="true"] {
background-color: #702020;
}
/**** The Wire ****/
QLabel#label_masthead{
border: 2px solid #CCCCCC;
border-radius: 4px;
}

View file

@ -2687,6 +2687,12 @@ PulseReply QLabel#label_groupName{
color: #5b7083;
}
PulseReplySeperator QFrame#frame {
border: 2px solid #CCCCCC;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #EEEEEE, stop: 1 #CCCCCC);
border-radius: 10px}
}
QLabel#label_masthead{
border: 2px solid #CCCCCC;
border-radius: 4px;

View file

@ -74,8 +74,13 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags)
foreach (QString code, LanguageSupport::languageCodes()) {
ui.cmboLanguage->addItem(FilesDefs::getIconFromQtResourcePath(":/images/flags/" + code + ".png"), LanguageSupport::languageName(code), code);
}
foreach (QString style, QStyleFactory::keys()) {
ui.cmboStyle->addItem(style, style.toLower());
// Note: apparently, on some linux systems (e.g. Debian 11), the gtk2 style makes Qt libs crash when the environment variable is not set.
// So we first check that it's here before start.
foreach (QString style, QStyleFactory::keys()) {
if(style.toLower() != "gtk2" || (getenv("QT_QPA_PLATFORMTHEME")!=nullptr && !strcmp(getenv("QT_QPA_PLATFORMTHEME"),"gtk2")))
ui.cmboStyle->addItem(style, style.toLower());
}
QMap<QString, QString> styleSheets;
@ -266,9 +271,9 @@ void AppearancePage::load()
index = ui.mainPageButtonType_CB->findData(Settings->getPageButtonLoc());
if (index != 0) {
ui.cmboTollButtonsStyle->hide();
}else {
ui.cmboTollButtonsStyle->show();
ui.cmboTollButtonsStyle->show();
}else {
ui.cmboTollButtonsStyle->hide();
}
whileBlocking(ui.mainPageButtonType_CB)->setCurrentIndex(!Settings->getPageButtonLoc());

View file

@ -23,11 +23,14 @@
#include "rsharesettings.h"
#include "jsonapi/jsonapi.h"
#include "util/misc.h"
#include "util/qtthreadsutils.h"
#include <QTimer>
#include <QStringListModel>
#include <QProgressDialog>
#define IMAGE_LEDOFF ":/images/ledoff1.png"
#define IMAGE_LEDON ":/images/ledon1.png"
JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
{
@ -57,9 +60,41 @@ JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
QRegExpValidator *ipValidator = new QRegExpValidator(ipRegex, this);
ui.listenAddressLineEdit->setValidator(ipValidator);
ui.providersListView->setSelectionMode(QAbstractItemView::NoSelection); // prevents edition.
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e)
{
if(e->mType != RsEventType::JSON_API)
return;
auto je = dynamic_cast<const RsJsonApiEvent*>(e.get());
if(!je)
return;
#ifdef DEBUG
std::cerr << "Caught JSONAPI event! code=" << static_cast<int>(je->mJsonApiEventCode) << std::endl;
#endif
RsQThreadUtils::postToObject([=]() { load(); }, this );
},
mEventHandlerId, RsEventType::JSON_API );
}
JsonApiPage::~JsonApiPage()
{
rsEvents->unregisterEventsHandler(mEventHandlerId);
}
QString JsonApiPage::helpText() const
{
return tr("<h1><img width=\"24\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Webinterface</h1> \
<p>Retroshare provides a JSON API allowing other softwares to communicate with its core using token-controlled HTTP requests to http://localhost:[port]. \
Please refer to the Retroshare documentation for how to use this feature. </p>\
<p>Unless you know what you're doing, you shouldn't need to change anything in this page. \
The web interface for instance will automatically register its own token to the JSON API which will be visible \
in the list of authenticated tokens after you enable it.</p>");
}
void JsonApiPage::enableJsonApi(bool checked)
{
ui.addTokenPushButton->setEnabled(checked);
@ -93,9 +128,9 @@ bool JsonApiPage::updateParams()
void JsonApiPage::load()
{
whileBlocking(ui.portSpinBox)->setValue(Settings->getJsonApiPort());
whileBlocking(ui.listenAddressLineEdit)->setText(Settings->getJsonApiListenAddress());
whileBlocking(ui.enableCheckBox)->setChecked(Settings->getJsonApiEnabled());
whileBlocking(ui.portSpinBox)->setValue(rsJsonApi->listeningPort());
whileBlocking(ui.listenAddressLineEdit)->setText(QString::fromStdString(rsJsonApi->getBindingAddress()));
whileBlocking(ui.enableCheckBox)->setChecked(rsJsonApi->isRunning());
QStringList newTk;
@ -104,10 +139,20 @@ void JsonApiPage::load()
QString::fromStdString(it.first) + ":" +
QString::fromStdString(it.second) );
whileBlocking(ui.tokensListView)->setModel(new QStringListModel(newTk));
}
whileBlocking(ui.tokensListView)->setModel(new QStringListModel(newTk));
QString JsonApiPage::helpText() const { return ""; }
QStringList newTk2;
for(const auto& it : rsJsonApi->getResourceProviders())
newTk2.push_back( QString::fromStdString(it.get().getName())) ;
whileBlocking(ui.providersListView)->setModel(new QStringListModel(newTk2));
if(rsJsonApi->isRunning())
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDON)) ;
else
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDOFF)) ;
}
bool JsonApiPage::checkStartJsonApi()
{

View file

@ -20,6 +20,8 @@
#pragma once
#include "retroshare/rsevents.h"
#include "retroshare-gui/configpage.h"
#include "gui/common/FilesDefs.h"
#include "ui_JsonApiPage.h"
@ -31,7 +33,7 @@ class JsonApiPage : public ConfigPage
public:
JsonApiPage(QWidget * parent = nullptr, Qt::WindowFlags flags = 0);
~JsonApiPage() override = default;
~JsonApiPage() override ;
virtual QPixmap iconPixmap() const override
{
@ -63,4 +65,6 @@ public slots:
private:
Ui::JsonApiPage ui; /// Qt Designer generated object
RsEventsHandlerId_t mEventHandlerId;
};

View file

@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="WebuiPageVLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="jsonApiGroupBox">
<property name="minimumSize">
@ -25,13 +25,65 @@
<property name="title">
<string>JSON API Server</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="enableCheckBox">
<property name="text">
<string>Enable RetroShare JSON API Server</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="enableCheckBox">
<property name="text">
<string>Enable RetroShare JSON API Server</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Status:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="statusLabelLED">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/ledoff1.png</pixmap>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Listen Address:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="listenAddressLineEdit">
<property name="text">
<string>127.0.0.1</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
@ -57,24 +109,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Listen Address:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="listenAddressLineEdit">
<property name="text">
<string>127.0.0.1</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
@ -110,13 +144,23 @@
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Authenticated Tokens</string>
<string>Authenticated Tokens:</string>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="tokensListView"/>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Registered services:</string>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="providersListView"/>
</item>
</layout>
</widget>
</item>
@ -142,6 +186,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -107,6 +107,8 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
ui.hiddenpage_proxyPort_tor->setEnabled(false) ;
ui.hiddenpage_localAddress->setEnabled(false) ;
ui.hiddenpage_localPort->setEnabled(false) ;
ui.hiddenpage_serviceAddress->setEnabled(false) ;
ui.hiddenpage_servicePort->setEnabled(false) ;
ui.testIncoming_PB->hide() ;
ui.l_incomingTestResult->hide() ;
ui.iconlabel_service_incoming->hide() ;

View file

@ -256,11 +256,14 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="iconlabel_ext">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
@ -272,6 +275,12 @@
</item>
<item row="0" column="1">
<widget class="QLabel" name="textlabel_ext">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The bullet turns green as soon as Retroshare manages to get your own IP from the websites listed below, if you enabled that action. Retroshare will also use other means to find out your own IP.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
@ -290,13 +299,29 @@
<property name="rightMargin">
<number>6</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="textlabel_netLimited">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Local network</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="iconlabel_netLimited">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
@ -306,13 +331,6 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="textlabel_netLimited">
<property name="text">
<string>Local network</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
@ -351,13 +369,29 @@
<property name="rightMargin">
<number>6</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="textlabel_upnp">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>UPnP</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="iconlabel_upnp">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
@ -367,13 +401,6 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="textlabel_upnp">
<property name="text">
<string>UPnP</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="3">
@ -386,11 +413,14 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="iconlabel_hiddenMode">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
@ -402,6 +432,12 @@
</item>
<item row="0" column="1">
<widget class="QLabel" name="textlabel_hiddenMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
@ -802,12 +838,6 @@ behind a firewall or a VPN.</string>
<layout class="QHBoxLayout" name="hiddenpage_proxyOKHLayout_tor">
<item>
<widget class="QLabel" name="iconlabel_tor_outgoing">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>

View file

@ -27,6 +27,7 @@
#include <QSpinBox>
#include "util/misc.h"
#include "util/qtthreadsutils.h"
#include "retroshare/rswebui.h"
#include "retroshare/rsjsonapi.h"
@ -40,6 +41,8 @@ resource_api::ApiServerLocal* WebuiPage::apiServerLocal = 0;
#endif
resource_api::RsControlModule* WebuiPage::controlModule = 0;
#define IMAGE_LEDOFF ":/images/ledoff1.png"
#define IMAGE_LEDON ":/images/ledon1.png"
WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
{
@ -50,11 +53,22 @@ WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
connect(ui.password_LE, SIGNAL(textChanged(QString)), this, SLOT(onPasswordValueChanged(QString)));
connect(ui.startWebBrowser_PB, SIGNAL(clicked()), this, SLOT(onStartWebBrowserClicked()));
connect(ui.webInterfaceFilesDirectory_PB, SIGNAL(clicked()), this, SLOT(selectWebInterfaceDirectory()));
mEventsHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> /* event */)
{
#ifdef DEBUG
std::cerr << "Caught JSONAPI event in webui!" << std::endl;
#endif
RsQThreadUtils::postToObject([=]() { load(); }, this );
},
mEventsHandlerId, RsEventType::JSON_API );
}
WebuiPage::~WebuiPage()
{
rsEvents->unregisterEventsHandler(mEventsHandlerId);
}
void WebuiPage::selectWebInterfaceDirectory()
@ -73,22 +87,12 @@ void WebuiPage::selectWebInterfaceDirectory()
bool WebuiPage::updateParams(QString &errmsg)
{
std::cerr << "WebuiPage::save()" << std::endl;
bool ok = true;
bool changed = false;
if(ui.enableWebUI_CB->isChecked() != Settings->getWebinterfaceEnabled())
changed = true;
if(ui.webInterfaceFiles_LE->text() != Settings->getWebinterfaceFilesDirectory())
changed = true;
if(changed)
{
// store config
Settings->setWebinterfaceEnabled(ui.enableWebUI_CB->isChecked());
Settings->setWebinterfaceFilesDirectory(ui.webInterfaceFiles_LE->text());
// store config
Settings->setWebinterfaceEnabled(ui.enableWebUI_CB->isChecked());
Settings->setWebinterfaceFilesDirectory(ui.webInterfaceFiles_LE->text());
rsWebUi->setHtmlFilesDirectory(ui.webInterfaceFiles_LE->text().toStdString());
}
return ok;
return true;
}
void WebuiPage::onPasswordValueChanged(QString password)
@ -112,12 +116,27 @@ void WebuiPage::onPasswordValueChanged(QString password)
bool WebuiPage::restart()
{
return checkStartWebui();
if(ui.password_LE->text().isNull())
{
QMessageBox::critical(nullptr,tr("Missing passphrase"),tr("Please set a passphrase to proect the access to the WEB interface."));
return false;
}
rsWebUi->setUserPassword(ui.password_LE->text().toStdString());
rsWebUi->setHtmlFilesDirectory(ui.webInterfaceFiles_LE->text().toStdString());
setCursor(Qt::WaitCursor) ;
rsWebUi->restart();
setCursor(Qt::ArrowCursor) ;
return true;
}
void WebuiPage::load()
void WebuiPage::loadParams()
{
std::cerr << "WebuiPage::load()" << std::endl;
#ifdef DEBUG
std::cerr << "WebuiPage::load()" << std::endl;
#endif
whileBlocking(ui.enableWebUI_CB)->setChecked(Settings->getWebinterfaceEnabled());
whileBlocking(ui.webInterfaceFiles_LE)->setText(Settings->getWebinterfaceFilesDirectory());
@ -127,6 +146,15 @@ void WebuiPage::load()
if(it != smap.end())
whileBlocking(ui.password_LE)->setText(QString::fromStdString(it->second));
else
whileBlocking(ui.enableWebUI_CB)->setChecked(false);
if(rsWebUi->isRunning())
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDON)) ;
else
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDOFF)) ;
#else
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDOFF)) ;
#endif
}
@ -138,13 +166,11 @@ QString WebuiPage::helpText() const
<p>Warning: don't expose the webinterface to the internet, because there is no access control and no encryption. If you want to use the webinterface over the internet, use a SSH tunnel or a proxy to secure the connection.</p>");
}
/*static*/ bool WebuiPage::checkStartWebui()
/*static*/ bool WebuiPage::checkStartWebui() // This is supposed to be called from main(). But normally the parameters below (including the paswd
// for the webUI should be saved in p3webui instead.
{
if(!Settings->getWebinterfaceEnabled())
return false;
rsWebUi->setHtmlFilesDirectory(Settings->getWebinterfaceFilesDirectory().toStdString());
rsWebUi->restart();
rsWebUi->setHtmlFilesDirectory(Settings->getWebinterfaceFilesDirectory().toStdString());
rsWebUi->restart();
return true;
}
@ -173,15 +199,21 @@ QString WebuiPage::helpText() const
void WebuiPage::onEnableCBClicked(bool checked)
{
ui.params_GB->setEnabled(checked);
ui.apply_PB->setEnabled(checked);
ui.startWebBrowser_PB->setEnabled(checked);
QString S;
QString errmsg;
updateParams(errmsg);
Settings->setWebinterfaceEnabled(checked);
ui.params_GB->setEnabled(checked);
ui.startWebBrowser_PB->setEnabled(checked);
ui.apply_PB->setEnabled(checked);
if(checked)
checkStartWebui();
{
if(!restart())
{
QMessageBox::warning(0, tr("failed to start Webinterface"), "Failed to start the webinterface.");
return;
}
}
else
checkShutdownWebui();
}
@ -199,18 +231,12 @@ void WebuiPage::onAllIPCBClicked(bool /*checked*/)
}
void WebuiPage::onApplyClicked()
{
rsWebUi->setUserPassword(ui.password_LE->text().toStdString());
QString errmsg;
updateParams(errmsg);
if(!restart())
{
QMessageBox::warning(0, tr("failed to start Webinterface"), "Failed to start the webinterface.");
return;
}
restart();
emit passwordChanged();
load();
}
void WebuiPage::onStartWebBrowserClicked() { showWebui(); }

View file

@ -20,6 +20,8 @@
#pragma once
#include "retroshare/rsevents.h"
#include "retroshare-gui/configpage.h"
#include "gui/common/FilesDefs.h"
#include "ui_WebuiPage.h"
@ -42,11 +44,11 @@ public:
~WebuiPage();
/** Loads the settings for this page */
virtual void load();
virtual void load() override { loadParams() ; }
virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/webinterface.svg") ; }
virtual QString pageName() const { return tr("Webinterface") ; }
virtual QString helpText() const;
virtual QPixmap iconPixmap() const override { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/webinterface.svg") ; }
virtual QString pageName() const override { return tr("Webinterface") ; }
virtual QString helpText() const override ;
// call this after start of libretroshare/Retroshare
// checks the settings and starts the webinterface if required
@ -67,10 +69,9 @@ public slots:
void onApplyClicked();
void onStartWebBrowserClicked();
signals:
void passwordChanged();
private:
virtual void loadParams();
/** Qt Designer generated object */
Ui::WebuiPage ui;
@ -83,4 +84,6 @@ private:
static resource_api::ApiServerLocal* apiServerLocal;
#endif
static resource_api::RsControlModule* controlModule;
RsEventsHandlerId_t mEventsHandlerId;
};

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>960</width>
<height>717</height>
<width>570</width>
<height>646</height>
</rect>
</property>
<property name="windowTitle">
@ -15,11 +15,45 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="enableWebUI_CB">
<property name="text">
<string>Enable Retroshare WEB Interface</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="enableWebUI_CB">
<property name="text">
<string>Enable Retroshare WEB Interface</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Status:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="statusLabelLED">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/ledoff1.png</pixmap>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="params_GB">

View file

@ -178,10 +178,7 @@ SettingsPage::initStackedWidget()
JsonApiPage *jsonapi_p = new JsonApiPage() ;
addPage(jsonapi_p);
#ifdef RS_WEBUI
WebuiPage *webui_p = new WebuiPage() ;
addPage(new WebuiPage() );
QObject::connect(webui_p,SIGNAL(passwordChanged()),jsonapi_p,SLOT(load()));
addPage(new WebuiPage());
#endif
#endif

View file

@ -22,6 +22,7 @@
#include "util/stacktrace.h"
#include "util/argstream.h"
#include "retroshare/rswebui.h"
CrashStackTrace gCrashStackTrace;
@ -380,7 +381,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
return 1;
}
/* recreate global settings object, now with correct path */
/* recreate global settings object, now with correct path, specific to the selected node */
RshareSettings::Create(true);
Rshare::resetLanguageAndStyle();
@ -537,8 +538,9 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
//
qRegisterMetaType<RsPeerId>("RsPeerId") ;
#ifdef DEBUG
std::cerr << "connecting signals and slots" << std::endl ;
#endif
QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ;
QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ;
QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ;
@ -571,13 +573,18 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt.
#ifdef RS_JSONAPI
JsonApiPage::checkStartJsonApi();
// Read webui params in settings. We cannot save them to some webui.cfg because cfg needs the node id and
// jsonapi is started before node ID selection in retroshare-service.
#ifdef RS_JSONAPI
#ifdef RS_WEBUI
WebuiPage::checkStartWebui(); // normally we should rather save the UI flags internally to p3webui
conf.enableWebUI = Settings->getWebinterfaceEnabled();
if(!Settings->getWebinterfaceFilesDirectory().isNull())
rsWebUi->setHtmlFilesDirectory(Settings->getWebinterfaceFilesDirectory().toStdString());
#endif
RsInit::startupWebServices(conf,false);
#endif
#endif // RS_JSONAPI
/* dive into the endless loop */
int ti = rshare.exec();

View file

@ -184,3 +184,9 @@ QLabel#label_masthead{
border: 2px solid #CCCCCC;
border-radius: 4px;
}
PulseReplySeperator QFrame#frame {
border: 2px solid #CCCCCC;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #EEEEEE, stop: 1 #CCCCCC);
border-radius: 10px}
}

View file

@ -139,17 +139,22 @@ static bool notifyRunningInstance()
// that a new process had been started
QLocalSocket localSocket;
localSocket.connectToServer(QString(TARGET));
#ifdef DEBUG
std::cerr << "Rshare::Rshare waitForConnected to other instance." << std::endl;
#endif
if( localSocket.waitForConnected(100) )
{
#ifdef DEBUG
std::cerr << "Rshare::Rshare Connection etablished. Waiting for disconnection." << std::endl;
#endif
localSocket.waitForDisconnected(1000);
return true;
}
else
{
#ifdef DEBUG
std::cerr << "Rshare::Rshare failed to connect to other instance." << std::endl;
#endif
return false;
}
}