2018-12-25 21:10:15 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* gui/TheWire/WireDialog.cpp *
|
|
|
|
* *
|
2020-02-29 11:47:00 +11:00
|
|
|
* Copyright (c) 2012-2020 Robert Fernie <retroshare.project@gmail.com> *
|
2018-12-25 21:10:15 +01:00
|
|
|
* *
|
|
|
|
* 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 18:43:15 +00:00
|
|
|
|
|
|
|
#include "WireDialog.h"
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
#include "WireGroupDialog.h"
|
|
|
|
#include "WireGroupItem.h"
|
|
|
|
|
2020-05-15 22:36:50 +10:00
|
|
|
#include "PulseViewGroup.h"
|
|
|
|
#include "PulseReplySeperator.h"
|
|
|
|
|
|
|
|
#include "util/qtthreadsutils.h"
|
|
|
|
|
2012-02-13 18:43:15 +00:00
|
|
|
#include <retroshare/rspeers.h>
|
2020-02-29 11:47:00 +11:00
|
|
|
#include <retroshare/rswire.h>
|
2012-02-13 18:43:15 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include <QTimer>
|
2020-02-29 11:47:00 +11:00
|
|
|
#include <QMessageBox>
|
2012-02-13 18:43:15 +00:00
|
|
|
|
|
|
|
/****************************************************************
|
2020-02-29 11:47:00 +11:00
|
|
|
* TheWire Display Widget.
|
2012-02-13 18:43:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
#define GROUP_SET_ALL (0)
|
|
|
|
#define GROUP_SET_OWN (1)
|
|
|
|
#define GROUP_SET_SUBSCRIBED (2)
|
2020-04-11 16:07:40 +10:00
|
|
|
#define GROUP_SET_OTHERS (3)
|
|
|
|
// Future Extensions.
|
|
|
|
// #define GROUP_SET_AUTO (4)
|
|
|
|
// #define GROUP_SET_RECOMMENDED (5)
|
2020-03-13 16:44:15 +11:00
|
|
|
|
|
|
|
|
|
|
|
#define WIRE_TOKEN_TYPE_SUBSCRIBE_CHANGE 1
|
|
|
|
|
2012-02-13 18:43:15 +00:00
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
WireDialog::WireDialog(QWidget *parent)
|
2020-03-13 16:44:15 +11:00
|
|
|
: MainPage(parent), mGroupSet(GROUP_SET_ALL)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
mAddDialog = NULL;
|
|
|
|
mPulseSelected = NULL;
|
2020-04-10 21:36:31 +10:00
|
|
|
mGroupSelected = NULL;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
connect( ui.toolButton_createAccount, SIGNAL(clicked()), this, SLOT(createGroup()));
|
|
|
|
connect( ui.toolButton_createPulse, SIGNAL(clicked()), this, SLOT(createPulse()));
|
|
|
|
connect( ui.toolButton_refresh, SIGNAL(clicked()), this, SLOT(refreshGroups()));
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
connect(ui.comboBox_groupSet, SIGNAL(currentIndexChanged(int)), this, SLOT(selectGroupSet(int)));
|
2020-04-11 16:07:40 +10:00
|
|
|
connect(ui.comboBox_filterTime, SIGNAL(currentIndexChanged(int)), this, SLOT(selectFilterTime(int)));
|
2020-03-13 16:44:15 +11:00
|
|
|
|
2012-02-13 18:43:15 +00:00
|
|
|
QTimer *timer = new QTimer(this);
|
|
|
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
|
|
|
timer->start(1000);
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
/* setup TokenQueue */
|
|
|
|
mWireQueue = new TokenQueue(rsWire->getTokenService(), this);
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
requestGroupData();
|
2020-05-15 22:36:50 +10:00
|
|
|
|
|
|
|
// just for testing
|
|
|
|
postTestTwitterView();
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
void WireDialog::refreshGroups()
|
|
|
|
{
|
|
|
|
requestGroupData();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WireDialog::addGroup(QWidget *item)
|
|
|
|
{
|
|
|
|
QLayout *alayout = ui.scrollAreaWidgetContents_groups->layout();
|
|
|
|
alayout->addWidget(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
// PulseHolder interface.
|
2020-03-13 16:44:15 +11:00
|
|
|
void WireDialog::deletePulseItem(PulseItem * /* item */, uint32_t /* type */)
|
2020-02-29 11:47:00 +11:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
|
|
|
|
// Actions from PulseHolder.
|
2020-05-15 22:36:50 +10:00
|
|
|
void WireDialog::focus(RsGxsGroupId &groupId, RsGxsMessageId &msgId)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::focus(";
|
|
|
|
std::cerr << groupId.toStdString() << ",";
|
|
|
|
std::cerr << msgId.toStdString();
|
|
|
|
std::cerr << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
showPulseFocus(groupId, msgId);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
void WireDialog::follow(RsGxsGroupId &groupId)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::follow(";
|
|
|
|
std::cerr << groupId.toStdString();
|
|
|
|
std::cerr << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::rate(RsGxsId &authorId)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::rate(";
|
|
|
|
std::cerr << authorId.toStdString();
|
|
|
|
std::cerr << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::reply(RsWirePulse &pulse, std::string &groupName)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::reply(";
|
|
|
|
std::cerr << pulse.mMeta.mGroupId.toStdString();
|
|
|
|
std::cerr << ",";
|
|
|
|
std::cerr << pulse.mMeta.mOrigMsgId.toStdString();
|
|
|
|
std::cerr << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
if (!mAddDialog)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
mAddDialog = new PulseAddDialog(NULL);
|
|
|
|
mAddDialog->hide();
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
2020-02-29 11:47:00 +11:00
|
|
|
|
|
|
|
int idx = ui.groupChooser->currentIndex();
|
|
|
|
if (idx < 0) {
|
|
|
|
std::cerr << "WireDialog::reply() ERROR GETTING AuthorId!";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose Wire Groupd first"), QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// publishing group.
|
|
|
|
RsWireGroup group = mOwnGroups[idx];
|
2020-04-11 12:55:04 +10:00
|
|
|
mAddDialog->cleanup();
|
2020-02-29 11:47:00 +11:00
|
|
|
mAddDialog->setGroup(group);
|
|
|
|
|
|
|
|
// establish replyTo.
|
|
|
|
mAddDialog->setReplyTo(pulse, groupName);
|
|
|
|
|
|
|
|
mAddDialog->show();
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::notifyPulseSelection(PulseItem *item)
|
|
|
|
{
|
|
|
|
if (mPulseSelected)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::notifyPulseSelection() unselecting old one : " << mPulseSelected;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
mPulseSelected->setSelected(false);
|
|
|
|
}
|
|
|
|
mPulseSelected = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
|
|
|
|
void WireDialog::subscribe(RsGxsGroupId &groupId)
|
|
|
|
{
|
|
|
|
uint32_t token;
|
|
|
|
rsWire->subscribeToGroup(token, groupId, true);
|
|
|
|
mWireQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, WIRE_TOKEN_TYPE_SUBSCRIBE_CHANGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::unsubscribe(RsGxsGroupId &groupId)
|
|
|
|
{
|
|
|
|
uint32_t token;
|
|
|
|
rsWire->subscribeToGroup(token, groupId, false);
|
|
|
|
mWireQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, WIRE_TOKEN_TYPE_SUBSCRIBE_CHANGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::notifyGroupSelection(WireGroupItem *item)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::notifyGroupSelection() from : " << item;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2020-04-10 21:36:31 +10:00
|
|
|
bool doSelection = true;
|
2020-03-13 16:44:15 +11:00
|
|
|
if (mGroupSelected)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::notifyGroupSelection() unselecting old one : " << mGroupSelected;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
mGroupSelected->setSelected(false);
|
2020-04-10 21:36:31 +10:00
|
|
|
if (mGroupSelected == item)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::notifyGroupSelection() current -> unselect";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
/* de-selection of current item */
|
|
|
|
mGroupSelected = NULL;
|
|
|
|
doSelection = false;
|
|
|
|
}
|
2020-03-13 16:44:15 +11:00
|
|
|
}
|
|
|
|
|
2020-04-10 21:36:31 +10:00
|
|
|
if (doSelection)
|
|
|
|
{
|
|
|
|
item->setSelected(true);
|
|
|
|
mGroupSelected = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update display */
|
|
|
|
showSelectedGroups();
|
2020-03-13 16:44:15 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-13 18:43:15 +00:00
|
|
|
void WireDialog::checkUpdate()
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
/* update */
|
|
|
|
if (!rsWire)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (rsWire->updated())
|
|
|
|
{
|
|
|
|
insertAlbums();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
void WireDialog::createGroup()
|
|
|
|
{
|
2020-04-05 15:04:39 +10:00
|
|
|
WireGroupDialog wireCreate(this);
|
2020-02-29 11:47:00 +11:00
|
|
|
wireCreate.exec();
|
|
|
|
}
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
void WireDialog::createPulse()
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
if (!mAddDialog)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
|
|
|
mAddDialog = new PulseAddDialog(NULL);
|
2020-02-29 11:47:00 +11:00
|
|
|
mAddDialog->hide();
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
int idx = ui.groupChooser->currentIndex();
|
|
|
|
if (idx < 0) {
|
|
|
|
std::cerr << "WireDialog::createPulse() ERROR GETTING AuthorId!";
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose Wire Groupd first"), QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
RsWireGroup group = mOwnGroups[idx];
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-04-11 12:55:04 +10:00
|
|
|
mAddDialog->cleanup();
|
2020-02-29 11:47:00 +11:00
|
|
|
mAddDialog->setGroup(group);
|
|
|
|
mAddDialog->show();
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
void WireDialog::addPulse(RsWirePulse *pulse, RsWireGroup *group,
|
|
|
|
std::map<rstime_t, RsWirePulse *> replies)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-03-13 16:44:15 +11:00
|
|
|
std::cerr << "WireDialog::addPulse() GroupId : " << pulse->mMeta.mGroupId;
|
|
|
|
std::cerr << " OrigMsgId : " << pulse->mMeta.mOrigMsgId;
|
|
|
|
std::cerr << " Replies : " << replies.size();
|
2020-02-29 11:47:00 +11:00
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
PulseItem *pulseItem = new PulseItem(this, pulse, group, replies);
|
|
|
|
|
|
|
|
/* ensure its a boxlayout */
|
|
|
|
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
|
|
|
QBoxLayout *boxlayout = dynamic_cast<QBoxLayout *>(alayout);
|
|
|
|
if (boxlayout == NULL) {
|
|
|
|
std::cerr << "WireDialog::addPulse() ERROR not boxlayout, inserting at end";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
alayout->addWidget(pulseItem);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* iterate through layout, and insert at the correct time */
|
|
|
|
for(int i = 0; i < alayout->count(); i++)
|
|
|
|
{
|
|
|
|
QLayoutItem *layoutItem = boxlayout->itemAt(i);
|
|
|
|
PulseItem *pitem = dynamic_cast<PulseItem *>(layoutItem->widget());
|
|
|
|
if (pitem != NULL)
|
|
|
|
{
|
|
|
|
if (pitem->publishTs() < pulseItem->publishTs())
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::addPulse() Inserting at index: " << i;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
/* insert at this index */
|
|
|
|
boxlayout->insertWidget(i, pulseItem);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// last item.
|
|
|
|
std::cerr << "WireDialog::addPulse() Inserting at end";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
boxlayout->addWidget(pulseItem);
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
void WireDialog::addGroup(const RsWireGroup &group)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
std::cerr << "WireDialog::addGroup() GroupId : " << group.mMeta.mGroupId;
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
addGroup(new WireGroupItem(this, group));
|
2020-02-29 11:47:00 +11:00
|
|
|
}
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
void WireDialog::deletePulses()
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
std::cerr << "WireDialog::deletePulses()";
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
|
|
|
QLayoutItem *item;
|
|
|
|
int i = 0;
|
|
|
|
while (i < alayout->count())
|
|
|
|
{
|
|
|
|
item = alayout->itemAt(i);
|
|
|
|
QWidget *widget = item->widget();
|
|
|
|
if (NULL != dynamic_cast<PulseItem *>(widget))
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
std::cerr << "WireDialog::deletePulses() Removing Item at: " << i;
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
item = alayout->takeAt(i);
|
|
|
|
delete item->widget();
|
|
|
|
delete item;
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
2020-02-29 11:47:00 +11:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::deletePulses() Leaving Item at: " << i;
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
i++;
|
|
|
|
}
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-29 11:47:00 +11:00
|
|
|
|
|
|
|
void WireDialog::deleteGroups()
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::deleteGroups()";
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-04-10 21:36:31 +10:00
|
|
|
mGroupSelected = NULL;
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
QLayout *alayout = ui.scrollAreaWidgetContents_groups->layout();
|
|
|
|
QLayoutItem *item;
|
2012-02-13 18:43:15 +00:00
|
|
|
int i = 0;
|
2020-02-29 11:47:00 +11:00
|
|
|
while (i < alayout->count())
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
item = alayout->itemAt(i);
|
|
|
|
QWidget *widget = item->widget();
|
|
|
|
if (NULL != dynamic_cast<WireGroupItem *>(widget))
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
std::cerr << "WireDialog::deleteGroups() Removing Item at: " << i;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
item = alayout->takeAt(i);
|
|
|
|
delete item->widget();
|
|
|
|
delete item;
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
2020-02-29 11:47:00 +11:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::deleteGroups() Leaving Item at: " << i;
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
i++;
|
|
|
|
}
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
void WireDialog::updateGroups(std::vector<RsWireGroup>& groups)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-03-13 16:44:15 +11:00
|
|
|
mAllGroups.clear();
|
|
|
|
mOwnGroups.clear();
|
|
|
|
ui.groupChooser->clear();
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
std::vector<RsWireGroup>::const_iterator it;
|
|
|
|
for(it = groups.begin(); it != groups.end(); it++) {
|
|
|
|
// save list of all groups.
|
|
|
|
mAllGroups[it->mMeta.mGroupId] = *it;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
if (it->mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
|
|
|
|
{
|
|
|
|
// grab own groups.
|
|
|
|
// setup Chooser too.
|
|
|
|
mOwnGroups.push_back(*it);
|
|
|
|
ui.groupChooser->addItem(QString::fromStdString(it->mMeta.mGroupName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-13 18:43:15 +00:00
|
|
|
|
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
void WireDialog::selectGroupSet(int index)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::selectGroupSet(" << index << ")";
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
mGroupSet = index;
|
|
|
|
if (mGroupSet < 0) {
|
|
|
|
mGroupSet = GROUP_SET_ALL;
|
|
|
|
}
|
|
|
|
showGroups();
|
|
|
|
}
|
|
|
|
|
2020-04-11 16:07:40 +10:00
|
|
|
void WireDialog::selectFilterTime(int index)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::selectFilterTime(" << index << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
showSelectedGroups();
|
|
|
|
}
|
|
|
|
|
2020-04-10 21:36:31 +10:00
|
|
|
void WireDialog::showSelectedGroups()
|
|
|
|
{
|
2020-04-11 16:07:40 +10:00
|
|
|
ui.comboBox_filterTime->setEnabled(false);
|
2020-04-10 21:36:31 +10:00
|
|
|
if (mGroupSelected)
|
|
|
|
{
|
|
|
|
deletePulses();
|
|
|
|
// request data.
|
|
|
|
std::list<RsGxsGroupId> grpIds;
|
|
|
|
grpIds.push_back(mGroupSelected->groupId());
|
|
|
|
requestPulseData(grpIds);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
showGroups();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
void WireDialog::showGroups()
|
|
|
|
{
|
2020-04-11 16:07:40 +10:00
|
|
|
ui.comboBox_filterTime->setEnabled(false);
|
2020-03-13 16:44:15 +11:00
|
|
|
deleteGroups();
|
|
|
|
deletePulses();
|
|
|
|
|
2020-04-10 21:36:31 +10:00
|
|
|
|
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
/* depends on the comboBox */
|
|
|
|
std::map<RsGxsGroupId, RsWireGroup>::const_iterator it;
|
|
|
|
for (it = mAllGroups.begin(); it != mAllGroups.end(); it++)
|
|
|
|
{
|
|
|
|
bool add = (mGroupSet == GROUP_SET_ALL);
|
|
|
|
if (it->second.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) {
|
|
|
|
if (mGroupSet == GROUP_SET_OWN) {
|
|
|
|
add = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (it->second.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED) {
|
|
|
|
if (mGroupSet == GROUP_SET_SUBSCRIBED) {
|
|
|
|
add = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (mGroupSet == GROUP_SET_OTHERS) {
|
|
|
|
add = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (add) {
|
|
|
|
addGroup(it->second);
|
|
|
|
// request data.
|
|
|
|
std::list<RsGxsGroupId> grpIds;
|
|
|
|
grpIds.push_back(it->second.mMeta.mGroupId);
|
|
|
|
requestPulseData(grpIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// LOAD DATA...............................................
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
void WireDialog::requestGroupData()
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::requestGroupData()";
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
RsTokReqOptions opts;
|
|
|
|
uint32_t token;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
|
|
|
mWireQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, 0);
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
bool WireDialog::loadGroupData(const uint32_t &token)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
std::cerr << "WireDialog::loadGroupData()";
|
2012-02-13 18:43:15 +00:00
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
std::vector<RsWireGroup> groups;
|
|
|
|
rsWire->getGroupData(token, groups);
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
// save list of groups.
|
|
|
|
updateGroups(groups);
|
2020-03-13 16:44:15 +11:00
|
|
|
showGroups();
|
2020-02-29 11:47:00 +11:00
|
|
|
return true;
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
void WireDialog::requestPulseData(const std::list<RsGxsGroupId>& grpIds)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
std::cerr << "WireDialog::requestPulseData()";
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
|
|
|
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
|
|
|
|
uint32_t token;
|
|
|
|
mWireQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, 0);
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
|
|
|
|
/* LoadPulseData...
|
|
|
|
*
|
|
|
|
* group into threads, using std::map<RsGxsMessageId, PulseReplySet>
|
|
|
|
* then sort by publishTS, using std::map<time, PulseOrderedReply>
|
|
|
|
* then add into gui.
|
|
|
|
* - use pointers to avoid copying everywhere.
|
|
|
|
*
|
|
|
|
* should we mutex Groups, or copy so we don't lose a pointer?
|
|
|
|
* should be fine, as mAllGroups only modified from loadData calls.
|
|
|
|
******
|
|
|
|
*
|
|
|
|
* NB: Potentially, this should be changed to use GXS to do the bulk of the work.
|
|
|
|
* - request Top-Level Msgs, sorted by PublishTS.
|
|
|
|
* - Insert into GUI.
|
|
|
|
* - for each request children Msg, and fill in "replies"
|
|
|
|
*
|
|
|
|
* This needs sorted option on GXS Data fetch.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class PulseReplySet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PulseReplySet() : group(NULL), msg(NULL) {}
|
|
|
|
PulseReplySet(RsWirePulse *m, RsWireGroup *g)
|
|
|
|
: group(g), msg(m) {}
|
|
|
|
|
|
|
|
RsWireGroup *group;
|
|
|
|
RsWirePulse *msg;
|
|
|
|
std::map<RsGxsMessageId, RsWirePulse *> replies; // orig ID -> replies.
|
|
|
|
};
|
|
|
|
|
|
|
|
class PulseOrderedReply
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PulseOrderedReply() : group(NULL), msg(NULL) {}
|
|
|
|
PulseOrderedReply(RsWirePulse *m, RsWireGroup *g)
|
|
|
|
: group(g), msg(m) {}
|
|
|
|
|
|
|
|
RsWireGroup *group;
|
|
|
|
RsWirePulse *msg;
|
|
|
|
std::map<rstime_t, RsWirePulse *> replies; // publish -> replies.
|
|
|
|
};
|
|
|
|
|
2020-04-11 16:07:40 +10:00
|
|
|
rstime_t WireDialog::getFilterTimestamp()
|
|
|
|
{
|
|
|
|
rstime_t filterTimestamp = time(NULL);
|
|
|
|
switch(ui.comboBox_filterTime->currentIndex())
|
|
|
|
{
|
|
|
|
case 1: // Last 24 Hours.
|
2020-04-11 16:23:12 +10:00
|
|
|
filterTimestamp -= (3600 * 24);
|
2020-04-11 16:07:40 +10:00
|
|
|
break;
|
|
|
|
case 2: // Last 7 Days.
|
2020-04-11 16:23:12 +10:00
|
|
|
filterTimestamp -= (3600 * 24 * 7);
|
2020-04-11 16:07:40 +10:00
|
|
|
break;
|
|
|
|
case 3: // Last 30 Days.
|
2020-04-11 16:23:12 +10:00
|
|
|
filterTimestamp -= (3600 * 24 * 30);
|
2020-04-11 16:07:40 +10:00
|
|
|
break;
|
|
|
|
case 0: // All Time.
|
|
|
|
case -1: // no index.
|
|
|
|
default:
|
|
|
|
filterTimestamp = 0; // back to Epoch! effectively all.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return filterTimestamp;
|
|
|
|
}
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
bool WireDialog::loadPulseData(const uint32_t &token)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
std::cerr << "WireDialog::loadPulseData()";
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
std::vector<RsWirePulse> pulses;
|
|
|
|
rsWire->getPulseData(token, pulses);
|
|
|
|
|
2020-05-15 22:36:50 +10:00
|
|
|
std::cerr << "WireDialog::loadPulseData() pulses.size(): " << pulses.size();
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
std::list<RsWirePulse *> references;
|
|
|
|
std::map<RsGxsMessageId, PulseReplySet> pulseGrouping;
|
|
|
|
|
2020-04-11 16:07:40 +10:00
|
|
|
// setup time filtering.
|
|
|
|
uint32_t filterTimestamp;
|
|
|
|
bool filterTime = (ui.comboBox_filterTime->currentIndex() > 0);
|
|
|
|
if (filterTime)
|
|
|
|
{
|
|
|
|
filterTimestamp = getFilterTimestamp();
|
|
|
|
}
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
std::vector<RsWirePulse>::iterator vit = pulses.begin();
|
|
|
|
for(; vit != pulses.end(); vit++)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
RsWirePulse& pulse = *vit;
|
2020-05-15 22:36:50 +10:00
|
|
|
if (pulse.mPulseType & WIRE_PULSE_TYPE_REFERENCE)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-03-13 16:44:15 +11:00
|
|
|
// store references to add in later.
|
|
|
|
std::cerr << "WireDialog::loadPulseData() REF: GroupId: " << pulse.mMeta.mGroupId;
|
2020-02-29 11:47:00 +11:00
|
|
|
std::cerr << " PulseId: " << pulse.mMeta.mMsgId;
|
2012-02-13 18:43:15 +00:00
|
|
|
std::cerr << std::endl;
|
2020-03-13 16:44:15 +11:00
|
|
|
references.push_back(&pulse);
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-11 16:07:40 +10:00
|
|
|
// Filter timestamp now. (as soon as possible).
|
|
|
|
if (filterTime && (pulse.mMeta.mPublishTs < filterTimestamp))
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::loadPulseData() SKipping OLD MSG: GroupId: " << pulse.mMeta.mGroupId;
|
|
|
|
std::cerr << " PulseId: " << pulse.mMeta.mMsgId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
RsGxsGroupId &gid = pulse.mMeta.mGroupId;
|
|
|
|
std::map<RsGxsGroupId, RsWireGroup>::iterator git = mAllGroups.find(gid);
|
|
|
|
if (git != mAllGroups.end())
|
|
|
|
{
|
|
|
|
RsWireGroup &group = git->second;
|
|
|
|
std::cerr << "WireDialog::loadPulseData() MSG: GroupId: " << pulse.mMeta.mGroupId;
|
|
|
|
std::cerr << " PulseId: " << pulse.mMeta.mMsgId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
// install into pulseGrouping.
|
|
|
|
pulseGrouping[pulse.mMeta.mOrigMsgId] = PulseReplySet(&pulse, &group);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::loadPulseData() ERROR Missing GroupId: " << pulse.mMeta.mGroupId;
|
|
|
|
std::cerr << " PulseId: " << pulse.mMeta.mMsgId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// add references.
|
|
|
|
std::list<RsWirePulse *>::iterator lrit;
|
|
|
|
for(lrit = references.begin(); lrit != references.end(); lrit++)
|
|
|
|
{
|
|
|
|
std::map<RsGxsMessageId, PulseReplySet>::iterator pgit;
|
|
|
|
pgit = pulseGrouping.find((*lrit)->mMeta.mThreadId);
|
|
|
|
if (pgit != pulseGrouping.end())
|
|
|
|
{
|
|
|
|
// install into reply map.
|
|
|
|
// TODO handle Edits / Latest MSGS.
|
|
|
|
std::map<RsGxsMessageId, RsWirePulse *>::iterator rmit;
|
|
|
|
rmit = pgit->second.replies.find((*lrit)->mMeta.mOrigMsgId);
|
|
|
|
if (rmit == pgit->second.replies.end())
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::loadPulseData() Installing REF: " << (*lrit)->mMeta.mOrigMsgId;
|
|
|
|
std::cerr << " to threadId: " << (*lrit)->mMeta.mThreadId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
pgit->second.replies[(*lrit)->mMeta.mOrigMsgId] = (*lrit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::loadPulseData() ERROR Duplicate reply REF: " << (*lrit)->mMeta.mOrigMsgId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// no original msg for REF.
|
|
|
|
std::cerr << "WireDialog::loadPulseData() ERROR No matching ThreadId REF: " << (*lrit)->mMeta.mThreadId;
|
2012-02-13 18:43:15 +00:00
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
}
|
2020-03-13 16:44:15 +11:00
|
|
|
references.clear();
|
|
|
|
|
|
|
|
// sort by publish time.
|
|
|
|
std::map<rstime_t, PulseOrderedReply> pulseOrdering;
|
|
|
|
std::map<RsGxsMessageId, PulseReplySet>::iterator pgit;
|
|
|
|
for(pgit = pulseGrouping.begin(); pgit != pulseGrouping.end(); pgit++)
|
|
|
|
{
|
2020-04-11 16:07:40 +10:00
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
PulseOrderedReply &msg = pulseOrdering[pgit->second.msg->mMeta.mPublishTs] =
|
|
|
|
PulseOrderedReply(pgit->second.msg, pgit->second.group);
|
|
|
|
std::map<RsGxsMessageId, RsWirePulse *>::iterator rmit;
|
|
|
|
for(rmit = pgit->second.replies.begin();
|
|
|
|
rmit != pgit->second.replies.end(); rmit++)
|
|
|
|
{
|
|
|
|
msg.replies[rmit->second->mMeta.mPublishTs] = rmit->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// now add to the GUI.
|
|
|
|
std::map<rstime_t, PulseOrderedReply>::reverse_iterator poit;
|
|
|
|
for (poit = pulseOrdering.rbegin(); poit != pulseOrdering.rend(); poit++)
|
|
|
|
{
|
|
|
|
// add into GUI should insert at correct time point, amongst all other ones.
|
|
|
|
addPulse(poit->second.msg, poit->second.group, poit->second.replies);
|
|
|
|
}
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-04-11 16:07:40 +10:00
|
|
|
// allow filterTime to be changed again
|
|
|
|
ui.comboBox_filterTime->setEnabled(true);
|
2020-02-29 11:47:00 +11:00
|
|
|
return true;
|
|
|
|
}
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-03-13 16:44:15 +11:00
|
|
|
void WireDialog::acknowledgeGroup(const uint32_t &token, const uint32_t &userType)
|
|
|
|
{
|
|
|
|
/* reload groups */
|
|
|
|
std::cerr << "WireDialog::acknowledgeGroup(usertype: " << userType << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
RsGxsGroupId grpId;
|
|
|
|
rsWire->acknowledgeGrp(token, grpId);
|
|
|
|
|
|
|
|
refreshGroups();
|
|
|
|
}
|
|
|
|
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
/**************************** Request / Response Filling of Data ************************/
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
void WireDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::loadRequest()";
|
|
|
|
std::cerr << std::endl;
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
if (queue == mWireQueue)
|
2012-02-13 18:43:15 +00:00
|
|
|
{
|
2020-02-29 11:47:00 +11:00
|
|
|
/* now switch on req */
|
|
|
|
switch(req.mType)
|
|
|
|
{
|
|
|
|
case TOKENREQ_GROUPINFO:
|
|
|
|
switch(req.mAnsType)
|
|
|
|
{
|
|
|
|
// case RS_TOKREQ_ANSTYPE_LIST:
|
|
|
|
// loadGroupList(req.mToken);
|
|
|
|
// break;
|
|
|
|
case RS_TOKREQ_ANSTYPE_DATA:
|
|
|
|
loadGroupData(req.mToken);
|
|
|
|
break;
|
2020-03-13 16:44:15 +11:00
|
|
|
case RS_TOKREQ_ANSTYPE_ACK:
|
|
|
|
acknowledgeGroup(req.mToken, req.mUserType);
|
|
|
|
break;
|
2020-02-29 11:47:00 +11:00
|
|
|
default:
|
|
|
|
std::cerr << "WireDialog::loadRequest() ERROR: GROUP: INVALID ANS TYPE";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TOKENREQ_MSGINFO:
|
|
|
|
switch(req.mAnsType)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
case RS_TOKREQ_ANSTYPE_LIST:
|
|
|
|
loadPhotoList(req.mToken);
|
|
|
|
break;
|
|
|
|
case RS_TOKREQ_ANSTYPE_ACK:
|
|
|
|
acknowledgeMessage(req.mToken);
|
|
|
|
break;
|
2012-02-13 18:43:15 +00:00
|
|
|
#endif
|
2020-02-29 11:47:00 +11:00
|
|
|
case RS_TOKREQ_ANSTYPE_DATA:
|
|
|
|
loadPulseData(req.mToken);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
std::cerr << "WireDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2012-02-13 18:43:15 +00:00
|
|
|
#if 0
|
2020-02-29 11:47:00 +11:00
|
|
|
case TOKENREQ_MSGRELATEDINFO:
|
|
|
|
switch(req.mAnsType)
|
|
|
|
{
|
|
|
|
case RS_TOKREQ_ANSTYPE_DATA:
|
|
|
|
loadPhotoData(req.mToken);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
std::cerr << "WireDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2012-02-13 18:43:15 +00:00
|
|
|
#endif
|
2020-02-29 11:47:00 +11:00
|
|
|
default:
|
|
|
|
std::cerr << "WireDialog::loadRequest() ERROR: INVALID TYPE";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-02-13 18:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-29 11:47:00 +11:00
|
|
|
/**************************** Request / Response Filling of Data ************************/
|
2012-02-13 18:43:15 +00:00
|
|
|
|
2020-05-15 22:36:50 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************************/
|
|
|
|
// TWITTER VIEW.
|
|
|
|
/****************************************************************************************/
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
// - Handle Groups
|
|
|
|
// - Add GroupPtr to WirePulseSPtrs (DONE)
|
|
|
|
// - Add HeadShot to WireGroup
|
|
|
|
// - Add GxsIdLabel to Pulse UI elements.
|
|
|
|
//
|
|
|
|
// - Create Groups.
|
|
|
|
// - Add HeadShot
|
|
|
|
//
|
|
|
|
// - Create Pulse.
|
|
|
|
// - Add Images.
|
|
|
|
//
|
|
|
|
// - Link up Reply / Republish / Like.
|
|
|
|
//
|
|
|
|
// - showGroupFocus
|
|
|
|
// - TODO
|
|
|
|
//
|
|
|
|
// - showPulseFocus
|
|
|
|
// - Basics (DONE).
|
|
|
|
// - MoreReplies
|
|
|
|
// - Show Actual Message.
|
|
|
|
|
|
|
|
//
|
|
|
|
// - showReplyFocus
|
|
|
|
// - TODO
|
|
|
|
|
|
|
|
|
|
|
|
// PulseDataItem interface
|
|
|
|
// Actions.
|
|
|
|
void WireDialog::PVHreply(RsWirePulse &pulse, std::string &groupName)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::PVHreply() TODO";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::PVHrepublish(RsWirePulse &pulse, std::string &groupName)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::PVHrepublish() TODO";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::PVHlike(RsWirePulse &pulse, std::string &groupName)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::PVHlike() TODO";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::PVHviewGroup(RsGxsGroupId &groupId)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::PVHviewGroup(";
|
|
|
|
std::cerr << groupId.toStdString();
|
|
|
|
std::cerr << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
showGroupFocus(groupId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::PVHviewPulse(RsGxsGroupId &groupId, RsGxsMessageId &msgId)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::PVHviewPulse(";
|
|
|
|
std::cerr << groupId.toStdString() << ",";
|
|
|
|
std::cerr << msgId.toStdString();
|
|
|
|
std::cerr << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
showPulseFocus(groupId, msgId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::PVHviewReply(RsGxsGroupId &groupId, RsGxsMessageId &msgId)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::PVHviewReply(";
|
|
|
|
std::cerr << groupId.toStdString() << ",";
|
|
|
|
std::cerr << msgId.toStdString();
|
|
|
|
std::cerr << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
// showPulseFocus(groupId, msgId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::PVHfollow(RsGxsGroupId &groupId)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::PVHfollow(";
|
|
|
|
std::cerr << groupId.toStdString();
|
|
|
|
std::cerr << ") TODO";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::PVHrate(RsGxsId &authorId)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::PVHrate(";
|
|
|
|
std::cerr << authorId.toStdString();
|
|
|
|
std::cerr << ") TODO";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::postTestTwitterView()
|
|
|
|
{
|
|
|
|
clearTwitterView();
|
|
|
|
|
|
|
|
addTwitterView(new PulseTopLevel(NULL,RsWirePulseSPtr()));
|
|
|
|
addTwitterView(new PulseReply(NULL,RsWirePulseSPtr()));
|
|
|
|
addTwitterView(new PulseReply(NULL,RsWirePulseSPtr()));
|
|
|
|
addTwitterView(new PulseReply(NULL,RsWirePulseSPtr()));
|
|
|
|
addTwitterView(new PulseReply(NULL,RsWirePulseSPtr()));
|
|
|
|
addTwitterView(new PulseReply(NULL,RsWirePulseSPtr()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::clearTwitterView()
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::clearTwitterView()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
QLayout *alayout = ui.scrollAreaWidgetContents_2->layout();
|
|
|
|
QLayoutItem *item;
|
|
|
|
int i = 0;
|
|
|
|
while (i < alayout->count())
|
|
|
|
{
|
|
|
|
item = alayout->itemAt(i);
|
|
|
|
QWidget *widget = item->widget();
|
|
|
|
if (NULL != dynamic_cast<PulseViewItem *>(widget))
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::clearTwitterView() Removing Item at: " << i;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
item = alayout->takeAt(i);
|
|
|
|
delete item->widget();
|
|
|
|
delete item;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::clearTwitterView() Leaving Item at: " << i;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::addTwitterView(PulseViewItem *item)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::addTwitterView()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
/* ensure its a boxlayout */
|
|
|
|
QLayout *alayout = ui.scrollAreaWidgetContents_2->layout();
|
|
|
|
QBoxLayout *boxlayout = dynamic_cast<QBoxLayout *>(alayout);
|
|
|
|
if (boxlayout == NULL) {
|
|
|
|
std::cerr << "WireDialog::addTwitterView() ERROR not boxlayout, not Inserting";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// inserting as last item.
|
|
|
|
std::cerr << "WireDialog::addTwitterView() Inserting at end";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
boxlayout->addWidget(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WireDialog::showPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId)
|
|
|
|
{
|
|
|
|
clearTwitterView();
|
|
|
|
|
|
|
|
// background thread for loading.
|
|
|
|
RsThread::async([this, groupId, msgId]()
|
|
|
|
{
|
|
|
|
// fetch data from backend.
|
|
|
|
RsWirePulseSPtr pPulse;
|
|
|
|
int type = 0;
|
|
|
|
bool success = rsWire->getPulseFocus(groupId, msgId, type, pPulse);
|
|
|
|
|
|
|
|
sleep(2);
|
|
|
|
|
|
|
|
/* now insert the pulse + children into the layput */
|
|
|
|
RsQThreadUtils::postToObject([pPulse,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 */
|
|
|
|
|
|
|
|
postPulseFocus(pPulse);
|
|
|
|
|
|
|
|
}, this);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WireDialog::postPulseFocus(RsWirePulseSPtr pPulse)
|
|
|
|
{
|
|
|
|
clearTwitterView();
|
|
|
|
if (!pPulse)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::postPulseFocus() Invalid pulse";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
addTwitterView(new PulseTopLevel(this, pPulse));
|
|
|
|
|
|
|
|
std::list<RsWirePulseSPtr>::iterator it;
|
|
|
|
for(it = pPulse->mReplies.begin(); it != pPulse->mReplies.end(); it++)
|
|
|
|
{
|
|
|
|
RsWirePulseSPtr reply = *it;
|
|
|
|
PulseReply *firstReply = new PulseReply(this, reply);
|
|
|
|
addTwitterView(firstReply);
|
|
|
|
|
|
|
|
if (reply->mReplies.size() > 0)
|
|
|
|
{
|
|
|
|
PulseReply *secondReply = new PulseReply(this, reply->mReplies.front());
|
|
|
|
addTwitterView(secondReply);
|
|
|
|
firstReply->showReplyLine(true);
|
|
|
|
secondReply->showReplyLine(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
firstReply->showReplyLine(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (reply->mReplies.size() > 1)
|
|
|
|
{
|
|
|
|
// addTwitterView(new PulseMoreReplies(NULL, reply));
|
|
|
|
}
|
|
|
|
|
|
|
|
addTwitterView(new PulseReplySeperator());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WireDialog::showGroupFocus(const RsGxsGroupId groupId)
|
|
|
|
{
|
|
|
|
clearTwitterView();
|
|
|
|
|
|
|
|
// background thread for loading.
|
|
|
|
RsThread::async([this, groupId]()
|
|
|
|
{
|
|
|
|
// fetch data from backend.
|
|
|
|
RsWireGroupSPtr grp;
|
|
|
|
std::list<RsWirePulseSPtr> pulses;
|
|
|
|
|
|
|
|
bool success = rsWire->getWireGroup(groupId, grp);
|
|
|
|
std::list<RsGxsGroupId> groupIds = { groupId };
|
|
|
|
success = rsWire->getPulsesForGroups(groupIds, pulses);
|
|
|
|
|
|
|
|
sleep(2);
|
|
|
|
|
|
|
|
/* now insert the pulse + children into the layput */
|
|
|
|
RsQThreadUtils::postToObject([grp, pulses,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 */
|
|
|
|
|
|
|
|
postGroupFocus(grp, pulses);
|
|
|
|
|
|
|
|
}, this);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WireDialog::postGroupFocus(RsWireGroupSPtr group, std::list<RsWirePulseSPtr> pulses)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::postGroupFocus()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
if (!group)
|
|
|
|
{
|
|
|
|
std::cerr << "WireDialog::postGroupFocus() group is INVALID";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
addTwitterView(new PulseViewGroup(this, group));
|
|
|
|
|
|
|
|
std::list<RsWirePulseSPtr>::iterator it;
|
|
|
|
for(it = pulses.begin(); it != pulses.end(); it++)
|
|
|
|
{
|
|
|
|
RsWirePulseSPtr reply = *it;
|
|
|
|
PulseReply *firstReply = new PulseReply(this, reply);
|
|
|
|
addTwitterView(firstReply);
|
|
|
|
firstReply->showReplyLine(false);
|
|
|
|
|
|
|
|
addTwitterView(new PulseReplySeperator());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|