2014-05-04 18:59:06 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Robert Fernie
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QToolButton>
|
|
|
|
|
|
|
|
#include "GxsGroupFrameDialog.h"
|
|
|
|
#include "ui_GxsGroupFrameDialog.h"
|
|
|
|
#include "GxsMessageFrameWidget.h"
|
|
|
|
|
|
|
|
#include "gui/settings/rsharesettings.h"
|
|
|
|
#include "gui/RetroShareLink.h"
|
2014-10-13 14:31:47 -04:00
|
|
|
#include "gui/gxs/GxsGroupShareKey.h"
|
2014-05-04 18:59:06 -04:00
|
|
|
#include "gui/common/RSTreeWidget.h"
|
|
|
|
#include "gui/notifyqt.h"
|
2014-05-07 17:04:54 -04:00
|
|
|
#include "gui/common/UIStateHelper.h"
|
2014-05-07 20:00:21 -04:00
|
|
|
#include "GxsCommentDialog.h"
|
2014-05-04 18:59:06 -04:00
|
|
|
|
|
|
|
//#define DEBUG_GROUPFRAMEDIALOG
|
|
|
|
|
|
|
|
/* Images for TreeWidget */
|
|
|
|
#define IMAGE_SUBSCRIBE ":/images/edit_add24.png"
|
|
|
|
#define IMAGE_UNSUBSCRIBE ":/images/cancel.png"
|
|
|
|
#define IMAGE_INFO ":/images/info16.png"
|
|
|
|
//#define IMAGE_GROUPAUTHD ":/images/konv_message2.png"
|
|
|
|
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
2014-05-06 13:15:20 -04:00
|
|
|
#define IMAGE_EDIT ":/images/edit_16.png"
|
2014-05-07 20:00:21 -04:00
|
|
|
#define IMAGE_SHARE ":/images/share-icon-16.png"
|
|
|
|
#define IMAGE_TABNEW ":/images/tab-new.png"
|
|
|
|
#define IMAGE_COMMENT ""
|
2014-05-04 18:59:06 -04:00
|
|
|
|
2014-05-07 17:04:54 -04:00
|
|
|
#define TOKEN_TYPE_GROUP_SUMMARY 1
|
2014-07-05 14:33:11 -04:00
|
|
|
//#define TOKEN_TYPE_SUBSCRIBE_CHANGE 2
|
2014-05-04 18:59:06 -04:00
|
|
|
//#define TOKEN_TYPE_CURRENTGROUP 3
|
2014-07-06 12:39:09 -04:00
|
|
|
#define TOKEN_TYPE_STATISTICS 4
|
2014-05-04 18:59:06 -04:00
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
#define MAX_COMMENT_TITLE 32
|
|
|
|
|
2014-05-04 18:59:06 -04:00
|
|
|
/*
|
|
|
|
* Transformation Notes:
|
|
|
|
* there are still a couple of things that the new groups differ from Old version.
|
|
|
|
* these will need to be addressed in the future.
|
|
|
|
* -> Child TS (for sorting) is not handled by GXS, this will probably have to be done in the GUI.
|
|
|
|
* -> Need to handle IDs properly.
|
|
|
|
* -> Popularity not handled in GXS yet.
|
|
|
|
* -> Much more to do.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent)
|
|
|
|
: RsGxsUpdateBroadcastPage(ifaceImpl, parent)
|
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui = new Ui::GxsGroupFrameDialog();
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
mInitialized = false;
|
2014-09-24 19:57:47 -04:00
|
|
|
mCountChildMsgs = false;
|
2014-05-04 18:59:06 -04:00
|
|
|
mYourGroups = NULL;
|
|
|
|
mSubscribedGroups = NULL;
|
|
|
|
mPopularGroups = NULL;
|
|
|
|
mOtherGroups = NULL;
|
|
|
|
mMessageWidget = NULL;
|
|
|
|
|
|
|
|
/* Setup Queue */
|
|
|
|
mInterface = ifaceImpl;
|
2014-07-20 15:35:33 -04:00
|
|
|
mTokenService = mInterface->getTokenService();
|
2014-05-04 18:59:06 -04:00
|
|
|
mTokenQueue = new TokenQueue(mInterface->getTokenService(), this);
|
|
|
|
|
|
|
|
/* Setup UI helper */
|
2014-05-07 17:04:54 -04:00
|
|
|
mStateHelper = new UIStateHelper(this);
|
|
|
|
|
|
|
|
mStateHelper->addWidget(TOKEN_TYPE_GROUP_SUMMARY, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
2014-05-04 18:59:06 -04:00
|
|
|
|
|
|
|
connect(ui->groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupTreeCustomPopupMenu(QPoint)));
|
|
|
|
connect(ui->groupTreeWidget, SIGNAL(treeItemActivated(QString)), this, SLOT(changedGroup(QString)));
|
|
|
|
connect(ui->groupTreeWidget->treeWidget(), SIGNAL(signalMouseMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(groupTreeMiddleButtonClicked(QTreeWidgetItem*)));
|
|
|
|
connect(ui->messageTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(messageTabCloseRequested(int)));
|
|
|
|
connect(ui->messageTabWidget, SIGNAL(currentChanged(int)), this, SLOT(messageTabChanged(int)));
|
|
|
|
|
|
|
|
connect(ui->todoPushButton, SIGNAL(clicked()), this, SLOT(todo()));
|
|
|
|
|
|
|
|
/* Set initial size the splitter */
|
|
|
|
QList<int> sizes;
|
|
|
|
sizes << 300 << width(); // Qt calculates the right sizes
|
|
|
|
ui->splitter->setSizes(sizes);
|
2014-09-10 17:38:43 -04:00
|
|
|
|
|
|
|
#ifndef UNFINISHED
|
|
|
|
ui->todoPushButton->hide();
|
|
|
|
#endif
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
GxsGroupFrameDialog::~GxsGroupFrameDialog()
|
|
|
|
{
|
|
|
|
// save settings
|
|
|
|
processSettings(false);
|
|
|
|
|
|
|
|
delete(mTokenQueue);
|
|
|
|
delete(ui);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::initUi()
|
|
|
|
{
|
2014-09-10 17:38:43 -04:00
|
|
|
registerHelpButton(ui->helpButton, getHelpString()) ;
|
|
|
|
|
2014-05-04 18:59:06 -04:00
|
|
|
ui->titleBarPixmap->setPixmap(QPixmap(icon(ICON_NAME)));
|
|
|
|
ui->titleBarLabel->setText(text(TEXT_NAME));
|
|
|
|
|
|
|
|
/* Initialize group tree */
|
|
|
|
QToolButton *newGroupButton = new QToolButton(this);
|
|
|
|
newGroupButton->setIcon(QIcon(icon(ICON_NEW)));
|
|
|
|
newGroupButton->setToolTip(text(TEXT_NEW));
|
|
|
|
connect(newGroupButton, SIGNAL(clicked()), this, SLOT(newGroup()));
|
|
|
|
ui->groupTreeWidget->addToolButton(newGroupButton);
|
|
|
|
|
|
|
|
/* Create group tree */
|
|
|
|
mYourGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_YOUR_GROUP), QIcon(icon(ICON_YOUR_GROUP)), true);
|
|
|
|
mSubscribedGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_SUBSCRIBED_GROUP), QIcon(icon(ICON_SUBSCRIBED_GROUP)), true);
|
|
|
|
mPopularGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_POPULAR_GROUP), QIcon(icon(ICON_POPULAR_GROUP)), false);
|
|
|
|
mOtherGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_OTHER_GROUP), QIcon(icon(ICON_OTHER_GROUP)), false);
|
|
|
|
|
|
|
|
if (text(TEXT_TODO).isEmpty()) {
|
|
|
|
ui->todoPushButton->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
// load settings
|
|
|
|
mSettingsName = settingsGroupName();
|
|
|
|
processSettings(true);
|
2014-07-24 10:54:23 -04:00
|
|
|
|
|
|
|
if (groupFrameSettingsType() != GroupFrameSettings::Nothing) {
|
|
|
|
connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
|
|
|
|
settingsChanged();
|
|
|
|
}
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::showEvent(QShowEvent *event)
|
|
|
|
{
|
|
|
|
if (!mInitialized) {
|
|
|
|
/* Problem: virtual methods cannot be used in constructor */
|
|
|
|
mInitialized = true;
|
|
|
|
|
|
|
|
initUi();
|
|
|
|
}
|
|
|
|
|
|
|
|
RsGxsUpdateBroadcastPage::showEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::processSettings(bool load)
|
|
|
|
{
|
|
|
|
if (mSettingsName.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings->beginGroup(mSettingsName);
|
|
|
|
|
|
|
|
if (load) {
|
|
|
|
// load settings
|
|
|
|
|
|
|
|
// state of splitter
|
|
|
|
ui->splitter->restoreState(Settings->value("Splitter").toByteArray());
|
|
|
|
} else {
|
|
|
|
// save settings
|
|
|
|
|
|
|
|
// state of splitter
|
|
|
|
Settings->setValue("Splitter", ui->splitter->saveState());
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->groupTreeWidget->processSettings(Settings, load);
|
|
|
|
|
|
|
|
Settings->endGroup();
|
|
|
|
}
|
|
|
|
|
2014-07-24 10:54:23 -04:00
|
|
|
void GxsGroupFrameDialog::settingsChanged()
|
|
|
|
{
|
|
|
|
GroupFrameSettings groupFrameSettings;
|
|
|
|
if (Settings->getGroupFrameSettings(groupFrameSettingsType(), groupFrameSettings)) {
|
|
|
|
setSingleTab(!groupFrameSettings.mOpenAllInNewTab);
|
|
|
|
setHideTabBarWithOneTab(groupFrameSettings.mHideTabBarWithOneTab);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-04 18:59:06 -04:00
|
|
|
void GxsGroupFrameDialog::setSingleTab(bool singleTab)
|
|
|
|
{
|
|
|
|
if (singleTab) {
|
|
|
|
if (!mMessageWidget) {
|
|
|
|
mMessageWidget = createMessageWidget(RsGxsGroupId());
|
|
|
|
// remove close button of the the first tab
|
|
|
|
ui->messageTabWidget->hideCloseButton(ui->messageTabWidget->indexOf(mMessageWidget));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (mMessageWidget) {
|
|
|
|
delete(mMessageWidget);
|
|
|
|
mMessageWidget = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-14 17:29:51 -04:00
|
|
|
void GxsGroupFrameDialog::setHideTabBarWithOneTab(bool hideTabBarWithOneTab)
|
|
|
|
{
|
|
|
|
ui->messageTabWidget->setHideTabBarWithOneTab(hideTabBarWithOneTab);
|
|
|
|
}
|
|
|
|
|
2014-05-04 18:59:06 -04:00
|
|
|
void GxsGroupFrameDialog::updateDisplay(bool complete)
|
|
|
|
{
|
2014-07-05 14:33:11 -04:00
|
|
|
if (complete || !getGrpIds().empty() || !getGrpIdsMeta().empty()) {
|
2014-05-04 18:59:06 -04:00
|
|
|
/* Update group list */
|
|
|
|
requestGroupSummary();
|
2014-07-06 12:39:09 -04:00
|
|
|
} else {
|
2014-07-20 15:35:33 -04:00
|
|
|
/* Update all groups of changed messages */
|
|
|
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgIds;
|
|
|
|
getAllMsgIds(msgIds);
|
|
|
|
|
|
|
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator msgIt;
|
|
|
|
for (msgIt = msgIds.begin(); msgIt != msgIds.end(); ++msgIt) {
|
|
|
|
updateMessageSummaryList(msgIt->first);
|
2014-07-06 12:39:09 -04:00
|
|
|
}
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::todo()
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, "Todo", text(TEXT_TODO));
|
|
|
|
}
|
|
|
|
|
2014-05-25 17:43:05 -04:00
|
|
|
void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
|
2014-05-04 18:59:06 -04:00
|
|
|
{
|
2014-05-29 09:34:08 -04:00
|
|
|
QString id = ui->groupTreeWidget->itemIdAt(point);
|
2014-05-25 17:43:05 -04:00
|
|
|
if (id.isEmpty()) return;
|
|
|
|
|
|
|
|
mGroupId = RsGxsGroupId(id.toStdString());
|
2014-05-04 18:59:06 -04:00
|
|
|
int subscribeFlags = ui->groupTreeWidget->subscribeFlags(QString::fromStdString(mGroupId.toStdString()));
|
|
|
|
|
|
|
|
bool isAdmin = IS_GROUP_ADMIN(subscribeFlags);
|
|
|
|
bool isPublisher = IS_GROUP_PUBLISHER(subscribeFlags);
|
|
|
|
bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags);
|
|
|
|
|
|
|
|
QMenu contextMnu(this);
|
|
|
|
|
|
|
|
QAction *action;
|
|
|
|
|
|
|
|
if (isSubscribed) {
|
|
|
|
action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeGroup()));
|
|
|
|
action->setEnabled (!mGroupId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags));
|
|
|
|
} else {
|
|
|
|
action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeGroup()));
|
|
|
|
action->setDisabled (mGroupId.isNull() || IS_GROUP_SUBSCRIBED(subscribeFlags));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mMessageWidget) {
|
2014-05-06 19:43:14 -04:00
|
|
|
action = contextMnu.addAction(QIcon(IMAGE_TABNEW), tr("Open in new tab"), this, SLOT(openInNewTab()));
|
2014-05-04 18:59:06 -04:00
|
|
|
if (mGroupId.isNull() || messageWidget(mGroupId, true)) {
|
|
|
|
action->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
|
|
|
|
contextMnu.addAction(QIcon(icon(ICON_NEW)), text(TEXT_NEW), this, SLOT(newGroup()));
|
|
|
|
|
|
|
|
action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Details"), this, SLOT(showGroupDetails()));
|
|
|
|
action->setEnabled (!mGroupId.isNull());
|
|
|
|
|
2014-05-06 13:15:20 -04:00
|
|
|
action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails()));
|
2014-05-04 18:59:06 -04:00
|
|
|
action->setEnabled (!mGroupId.isNull() && isAdmin);
|
|
|
|
|
2014-07-22 11:04:36 -04:00
|
|
|
if (shareKeyType()) {
|
|
|
|
action = contextMnu.addAction(QIcon(IMAGE_SHARE), tr("Share"), this, SLOT(shareKey()));
|
2014-10-06 15:18:09 -04:00
|
|
|
action->setEnabled(!mGroupId.isNull() && isPublisher);
|
2014-07-22 11:04:36 -04:00
|
|
|
}
|
2014-05-04 18:59:06 -04:00
|
|
|
|
2014-10-06 15:18:09 -04:00
|
|
|
//if (!mGroupId.isNull() && isPublisher && !isAdmin) {
|
|
|
|
// contextMnu.addAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights" ), this, SLOT(restoreGroupKeys()));
|
|
|
|
//}
|
2014-05-04 18:59:06 -04:00
|
|
|
|
2014-07-22 11:04:36 -04:00
|
|
|
if (getLinkType() != RetroShareLink::TYPE_UNKNOWN) {
|
|
|
|
action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyGroupLink()));
|
|
|
|
action->setEnabled(!mGroupId.isNull());
|
|
|
|
}
|
2014-05-04 18:59:06 -04:00
|
|
|
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
|
|
|
|
action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead()));
|
|
|
|
action->setEnabled (!mGroupId.isNull() && isSubscribed);
|
|
|
|
|
|
|
|
action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread()));
|
|
|
|
action->setEnabled (!mGroupId.isNull() && isSubscribed);
|
|
|
|
|
|
|
|
/* Add special actions */
|
|
|
|
QList<QAction*> actions;
|
|
|
|
groupTreeCustomActions(mGroupId, subscribeFlags, actions);
|
|
|
|
if (!actions.isEmpty()) {
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addActions(actions);
|
|
|
|
}
|
|
|
|
|
|
|
|
contextMnu.exec(QCursor::pos());
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::restoreGroupKeys(void)
|
|
|
|
{
|
|
|
|
QMessageBox::warning(this, "RetroShare", "ToDo");
|
|
|
|
|
|
|
|
#ifdef TOGXS
|
|
|
|
mInterface->groupRestoreKeys(mGroupId);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::newGroup()
|
|
|
|
{
|
|
|
|
GxsGroupDialog *dialog = createNewGroupDialog(mTokenQueue);
|
|
|
|
if (!dialog) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog->exec();
|
|
|
|
delete(dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::subscribeGroup()
|
|
|
|
{
|
|
|
|
groupSubscribe(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::unsubscribeGroup()
|
|
|
|
{
|
|
|
|
groupSubscribe(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::groupSubscribe(bool subscribe)
|
|
|
|
{
|
|
|
|
if (mGroupId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t token;
|
|
|
|
mInterface->subscribeToGroup(token, mGroupId, subscribe);
|
2014-07-05 14:33:11 -04:00
|
|
|
// Replaced by meta data changed
|
|
|
|
// mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_SUBSCRIBE_CHANGE);
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::showGroupDetails()
|
|
|
|
{
|
|
|
|
if (mGroupId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GxsGroupDialog *dialog = createGroupDialog(mTokenQueue, mInterface->getTokenService(), GxsGroupDialog::MODE_SHOW, mGroupId);
|
|
|
|
if (!dialog) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog->exec();
|
|
|
|
delete(dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::editGroupDetails()
|
|
|
|
{
|
|
|
|
if (mGroupId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GxsGroupDialog *dialog = createGroupDialog(mTokenQueue, mInterface->getTokenService(), GxsGroupDialog::MODE_EDIT, mGroupId);
|
|
|
|
if (!dialog) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog->exec();
|
|
|
|
delete(dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::copyGroupLink()
|
|
|
|
{
|
|
|
|
if (mGroupId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-26 19:52:45 -04:00
|
|
|
RetroShareLink link;
|
2014-05-04 18:59:06 -04:00
|
|
|
|
2014-07-26 19:52:45 -04:00
|
|
|
QString name;
|
|
|
|
if(!getCurrentGroupName(name)) return;
|
2014-05-27 17:14:05 -04:00
|
|
|
|
2014-07-26 19:52:45 -04:00
|
|
|
if (link.createGxsGroupLink(getLinkType(), mGroupId, name)) {
|
|
|
|
QList<RetroShareLink> urls;
|
|
|
|
urls.push_back(link);
|
|
|
|
RSLinkClipboard::copyLinks(urls);
|
|
|
|
}
|
2014-05-27 17:14:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GxsGroupFrameDialog::getCurrentGroupName(QString& name)
|
|
|
|
{
|
2014-07-26 19:52:45 -04:00
|
|
|
return ui->groupTreeWidget->getGroupName(QString::fromStdString(mGroupId.toStdString()), name);
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::markMsgAsRead()
|
|
|
|
{
|
|
|
|
GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, false);
|
|
|
|
if (msgWidget) {
|
|
|
|
msgWidget->setAllMessagesRead(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::markMsgAsUnread()
|
|
|
|
{
|
|
|
|
GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, false);
|
|
|
|
if (msgWidget) {
|
|
|
|
msgWidget->setAllMessagesRead(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::shareKey()
|
|
|
|
{
|
|
|
|
if (mGroupId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-05 15:14:05 -04:00
|
|
|
// QMessageBox::warning(this, "", "ToDo");
|
2014-07-26 17:18:03 -04:00
|
|
|
|
2014-10-13 14:31:47 -04:00
|
|
|
GroupShareKey shareUi(this, mGroupId, shareKeyType());
|
2014-10-05 15:14:05 -04:00
|
|
|
shareUi.exec();
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title)
|
|
|
|
{
|
|
|
|
RsGxsCommentService *commentService = getCommentService();
|
|
|
|
if (!commentService) {
|
|
|
|
/* No comment service available */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GxsCommentDialog *commentDialog = commentWidget(msgId);
|
|
|
|
if (!commentDialog) {
|
|
|
|
QString comments = title;
|
|
|
|
if (title.length() > MAX_COMMENT_TITLE)
|
|
|
|
{
|
|
|
|
comments.truncate(MAX_COMMENT_TITLE - 3);
|
|
|
|
comments += "...";
|
|
|
|
}
|
|
|
|
|
|
|
|
commentDialog = new GxsCommentDialog(this, mInterface->getTokenService(), commentService);
|
|
|
|
|
|
|
|
QWidget *commentHeader = createCommentHeaderWidget(grpId, msgId);
|
|
|
|
if (commentHeader) {
|
|
|
|
commentDialog->setCommentHeader(commentHeader);
|
|
|
|
}
|
|
|
|
|
|
|
|
commentDialog->commentLoad(grpId, msgId);
|
|
|
|
|
|
|
|
int index = ui->messageTabWidget->addTab(commentDialog, comments);
|
|
|
|
ui->messageTabWidget->setTabIcon(index, QIcon(IMAGE_COMMENT));
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->messageTabWidget->setCurrentWidget(commentDialog);
|
|
|
|
}
|
|
|
|
|
2014-05-27 17:14:05 -04:00
|
|
|
bool GxsGroupFrameDialog::navigate(const RsGxsGroupId groupId, const RsGxsMessageId& msgId)
|
2014-05-04 18:59:06 -04:00
|
|
|
{
|
|
|
|
if (groupId.isNull()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-27 17:14:05 -04:00
|
|
|
if (ui->groupTreeWidget->activateId(QString::fromStdString(groupId.toStdString()), msgId.isNull()) == NULL) {
|
2014-05-04 18:59:06 -04:00
|
|
|
return false;
|
2014-05-27 17:14:05 -04:00
|
|
|
}
|
|
|
|
// if (mGroupId == groupId) {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (msgId.isNull()) {
|
2014-05-04 18:59:06 -04:00
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
2014-05-27 17:14:05 -04:00
|
|
|
//#TODO
|
|
|
|
// if (mThreadLoading) {
|
|
|
|
// mThreadLoad.FocusMsgId = msgId;
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
|
|
|
|
/* Search exisiting item */
|
|
|
|
// QTreeWidgetItemIterator itemIterator(ui->threadTreeWidget);
|
|
|
|
// QTreeWidgetItem *item = NULL;
|
|
|
|
// while ((item = *itemIterator) != NULL) {
|
|
|
|
// itemIterator++;
|
|
|
|
//
|
|
|
|
// if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) {
|
|
|
|
// ui->threadTreeWidget->setCurrentItem(item);
|
|
|
|
// ui->threadTreeWidget->setFocus();
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
return true;
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
GxsMessageFrameWidget *GxsGroupFrameDialog::messageWidget(const RsGxsGroupId &groupId, bool ownTab)
|
|
|
|
{
|
|
|
|
int tabCount = ui->messageTabWidget->count();
|
|
|
|
for (int index = 0; index < tabCount; ++index) {
|
|
|
|
GxsMessageFrameWidget *childWidget = dynamic_cast<GxsMessageFrameWidget*>(ui->messageTabWidget->widget(index));
|
|
|
|
if (ownTab && mMessageWidget && childWidget == mMessageWidget) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (childWidget && childWidget->groupId() == groupId) {
|
|
|
|
return childWidget;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GxsMessageFrameWidget *GxsGroupFrameDialog::createMessageWidget(const RsGxsGroupId &groupId)
|
|
|
|
{
|
|
|
|
GxsMessageFrameWidget *msgWidget = createMessageFrameWidget(groupId);
|
|
|
|
if (!msgWidget) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = ui->messageTabWidget->addTab(msgWidget, msgWidget->groupName(true));
|
|
|
|
ui->messageTabWidget->setTabIcon(index, msgWidget->groupIcon());
|
2014-05-07 20:00:21 -04:00
|
|
|
|
2014-05-04 18:59:06 -04:00
|
|
|
connect(msgWidget, SIGNAL(groupChanged(QWidget*)), this, SLOT(messageTabInfoChanged(QWidget*)));
|
2014-05-07 20:00:21 -04:00
|
|
|
connect(msgWidget, SIGNAL(loadComment(RsGxsGroupId,RsGxsMessageId,QString)), this, SLOT(loadComment(RsGxsGroupId,RsGxsMessageId,QString)));
|
2014-05-04 18:59:06 -04:00
|
|
|
|
|
|
|
return msgWidget;
|
|
|
|
}
|
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
GxsCommentDialog *GxsGroupFrameDialog::commentWidget(const RsGxsMessageId &msgId)
|
|
|
|
{
|
|
|
|
int tabCount = ui->messageTabWidget->count();
|
|
|
|
for (int index = 0; index < tabCount; ++index) {
|
|
|
|
GxsCommentDialog *childWidget = dynamic_cast<GxsCommentDialog*>(ui->messageTabWidget->widget(index));
|
|
|
|
if (childWidget && childWidget->messageId() == msgId) {
|
|
|
|
return childWidget;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-05-04 18:59:06 -04:00
|
|
|
void GxsGroupFrameDialog::changedGroup(const QString &groupId)
|
|
|
|
{
|
|
|
|
mGroupId = RsGxsGroupId(groupId.toStdString());
|
|
|
|
if (mGroupId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* search exisiting tab */
|
|
|
|
GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, true);
|
|
|
|
|
|
|
|
if (!msgWidget) {
|
|
|
|
if (mMessageWidget) {
|
|
|
|
/* not found, use standard tab */
|
|
|
|
msgWidget = mMessageWidget;
|
|
|
|
msgWidget->setGroupId(mGroupId);
|
|
|
|
} else {
|
|
|
|
/* create new tab */
|
|
|
|
msgWidget = createMessageWidget(mGroupId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->messageTabWidget->setCurrentWidget(msgWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::groupTreeMiddleButtonClicked(QTreeWidgetItem *item)
|
|
|
|
{
|
|
|
|
openGroupInNewTab(RsGxsGroupId(ui->groupTreeWidget->itemId(item).toStdString()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::openInNewTab()
|
|
|
|
{
|
|
|
|
openGroupInNewTab(mGroupId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::openGroupInNewTab(const RsGxsGroupId &groupId)
|
|
|
|
{
|
|
|
|
if (groupId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* search exisiting tab */
|
|
|
|
GxsMessageFrameWidget *msgWidget = messageWidget(groupId, true);
|
|
|
|
if (!msgWidget) {
|
|
|
|
/* not found, create new tab */
|
|
|
|
msgWidget = createMessageWidget(groupId);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->messageTabWidget->setCurrentWidget(msgWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::messageTabCloseRequested(int index)
|
|
|
|
{
|
2014-05-07 20:00:21 -04:00
|
|
|
QWidget *widget = ui->messageTabWidget->widget(index);
|
|
|
|
if (!widget) {
|
2014-05-04 18:59:06 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
GxsMessageFrameWidget *msgWidget = dynamic_cast<GxsMessageFrameWidget*>(widget);
|
|
|
|
if (msgWidget && msgWidget == mMessageWidget) {
|
|
|
|
/* Don't close single tab */
|
2014-05-04 18:59:06 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
delete(widget);
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::messageTabChanged(int index)
|
|
|
|
{
|
|
|
|
GxsMessageFrameWidget *msgWidget = dynamic_cast<GxsMessageFrameWidget*>(ui->messageTabWidget->widget(index));
|
|
|
|
if (!msgWidget) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->groupTreeWidget->activateId(QString::fromStdString(msgWidget->groupId().toStdString()), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::messageTabInfoChanged(QWidget *widget)
|
|
|
|
{
|
|
|
|
int index = ui->messageTabWidget->indexOf(widget);
|
|
|
|
if (index < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GxsMessageFrameWidget *msgWidget = dynamic_cast<GxsMessageFrameWidget*>(ui->messageTabWidget->widget(index));
|
|
|
|
if (!msgWidget) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->messageTabWidget->setTabText(index, msgWidget->groupName(true));
|
|
|
|
ui->messageTabWidget->setTabIcon(index, msgWidget->groupIcon());
|
|
|
|
}
|
|
|
|
|
|
|
|
///***** INSERT GROUP LISTS *****/
|
2014-09-11 18:07:06 -04:00
|
|
|
void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata */*userdata*/)
|
2014-05-04 18:59:06 -04:00
|
|
|
{
|
|
|
|
groupItemInfo.id = QString::fromStdString(groupInfo.mGroupId.toStdString());
|
|
|
|
groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str());
|
|
|
|
//groupItemInfo.description =
|
|
|
|
groupItemInfo.popularity = groupInfo.mPop;
|
|
|
|
groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost);
|
2014-10-06 15:18:09 -04:00
|
|
|
groupItemInfo.subscribeFlags = groupInfo.mSubscribeFlags;
|
|
|
|
groupItemInfo.privatekey = IS_GROUP_PUBLISHER(groupInfo.mSubscribeFlags) ;
|
2014-05-04 18:59:06 -04:00
|
|
|
|
|
|
|
#if TOGXS
|
|
|
|
if (groupInfo.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) {
|
|
|
|
groupItemInfo.name += " (" + tr("AUTHD") + ")";
|
|
|
|
groupItemInfo.icon = QIcon(IMAGE_GROUPAUTHD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
groupItemInfo.icon = QIcon(icon(ICON_DEFAULT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-11 18:07:06 -04:00
|
|
|
void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGroupMetaData> &groupList, const RsUserdata *userdata)
|
2014-05-04 18:59:06 -04:00
|
|
|
{
|
|
|
|
if (!mInitialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list<RsGroupMetaData>::const_iterator it;
|
|
|
|
|
|
|
|
QList<GroupItemInfo> adminList;
|
|
|
|
QList<GroupItemInfo> subList;
|
|
|
|
QList<GroupItemInfo> popList;
|
|
|
|
QList<GroupItemInfo> otherList;
|
|
|
|
std::multimap<uint32_t, GroupItemInfo> popMap;
|
|
|
|
|
|
|
|
for (it = groupList.begin(); it != groupList.end(); it++) {
|
|
|
|
/* sort it into Publish (Own), Subscribed, Popular and Other */
|
|
|
|
uint32_t flags = it->mSubscribeFlags;
|
|
|
|
|
|
|
|
GroupItemInfo groupItemInfo;
|
2014-09-11 18:07:06 -04:00
|
|
|
groupInfoToGroupItemInfo(*it, groupItemInfo, userdata);
|
2014-05-04 18:59:06 -04:00
|
|
|
|
|
|
|
if (IS_GROUP_SUBSCRIBED(flags))
|
|
|
|
{
|
|
|
|
if (IS_GROUP_ADMIN(flags))
|
|
|
|
{
|
|
|
|
adminList.push_back(groupItemInfo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* subscribed group */
|
|
|
|
subList.push_back(groupItemInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* rate the others by popularity */
|
|
|
|
popMap.insert(std::make_pair(it->mPop, groupItemInfo));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* iterate backwards through popMap - take the top 5 or 10% of list */
|
|
|
|
uint32_t popCount = 5;
|
|
|
|
if (popCount < popMap.size() / 10)
|
|
|
|
{
|
|
|
|
popCount = popMap.size() / 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t i = 0;
|
|
|
|
uint32_t popLimit = 0;
|
|
|
|
std::multimap<uint32_t, GroupItemInfo>::reverse_iterator rit;
|
|
|
|
for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++) ;
|
|
|
|
if (rit != popMap.rend()) {
|
|
|
|
popLimit = rit->first;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) {
|
|
|
|
if (rit->second.popularity < (int) popLimit) {
|
|
|
|
otherList.append(rit->second);
|
|
|
|
} else {
|
|
|
|
popList.append(rit->second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now we can add them in as a tree! */
|
|
|
|
ui->groupTreeWidget->fillGroupItems(mYourGroups, adminList);
|
|
|
|
ui->groupTreeWidget->fillGroupItems(mSubscribedGroups, subList);
|
|
|
|
ui->groupTreeWidget->fillGroupItems(mPopularGroups, popList);
|
|
|
|
ui->groupTreeWidget->fillGroupItems(mOtherGroups, otherList);
|
|
|
|
|
2014-07-05 14:33:11 -04:00
|
|
|
/* Re-fill group */
|
|
|
|
if (!ui->groupTreeWidget->activateId(QString::fromStdString(mGroupId.toStdString()), true)) {
|
|
|
|
mGroupId.clear();
|
|
|
|
}
|
|
|
|
|
2014-05-04 18:59:06 -04:00
|
|
|
updateMessageSummaryList(RsGxsGroupId());
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::updateMessageSummaryList(RsGxsGroupId groupId)
|
|
|
|
{
|
|
|
|
if (!mInitialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-06 12:39:09 -04:00
|
|
|
if (groupId.isNull()) {
|
|
|
|
QTreeWidgetItem *items[2] = { mYourGroups, mSubscribedGroups };
|
|
|
|
for (int item = 0; item < 2; item++) {
|
|
|
|
int child;
|
|
|
|
int childCount = items[item]->childCount();
|
|
|
|
for (child = 0; child < childCount; child++) {
|
|
|
|
QTreeWidgetItem *childItem = items[item]->child(child);
|
|
|
|
QString childId = ui->groupTreeWidget->itemId(childItem);
|
|
|
|
if (childId.isEmpty()) {
|
|
|
|
continue;
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
2014-07-06 12:39:09 -04:00
|
|
|
|
2014-07-20 15:35:33 -04:00
|
|
|
requestGroupStatistics(RsGxsGroupId(childId.toLatin1().constData()));
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
}
|
2014-07-06 12:39:09 -04:00
|
|
|
} else {
|
2014-07-20 15:35:33 -04:00
|
|
|
requestGroupStatistics(groupId);
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************** **** **** **** ***********************/
|
|
|
|
/** Request / Response of Data ********************************/
|
|
|
|
/*********************** **** **** **** ***********************/
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::requestGroupSummary()
|
|
|
|
{
|
2014-05-07 17:04:54 -04:00
|
|
|
mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, true);
|
2014-05-04 18:59:06 -04:00
|
|
|
|
|
|
|
#ifdef DEBUG_GROUPFRAMEDIALOG
|
|
|
|
std::cerr << "GxsGroupFrameDialog::requestGroupSummary()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
2014-05-07 17:04:54 -04:00
|
|
|
mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUP_SUMMARY);
|
2014-05-04 18:59:06 -04:00
|
|
|
|
|
|
|
RsTokReqOptions opts;
|
2014-09-11 18:07:06 -04:00
|
|
|
opts.mReqType = requestGroupSummaryType();
|
2014-05-04 18:59:06 -04:00
|
|
|
|
|
|
|
uint32_t token;
|
2014-05-07 17:04:54 -04:00
|
|
|
mTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_GROUP_SUMMARY);
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
|
2014-09-11 18:07:06 -04:00
|
|
|
void GxsGroupFrameDialog::loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata *&/*userdata*/)
|
|
|
|
{
|
|
|
|
/* Default implementation for request type GXS_REQUEST_TYPE_GROUP_META */
|
|
|
|
mInterface->getGroupSummary(token, groupInfo);
|
|
|
|
}
|
|
|
|
|
2014-05-04 18:59:06 -04:00
|
|
|
void GxsGroupFrameDialog::loadGroupSummary(const uint32_t &token)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_GROUPFRAMEDIALOG
|
|
|
|
std::cerr << "GxsGroupFrameDialog::loadGroupSummary()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
std::list<RsGroupMetaData> groupInfo;
|
2014-09-11 18:07:06 -04:00
|
|
|
RsUserdata *userdata = NULL;
|
|
|
|
loadGroupSummaryToken(token, groupInfo, userdata);
|
2014-05-04 18:59:06 -04:00
|
|
|
|
2014-09-11 18:07:06 -04:00
|
|
|
insertGroupsData(groupInfo, userdata);
|
2014-05-04 18:59:06 -04:00
|
|
|
|
2014-09-11 18:07:06 -04:00
|
|
|
mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, false);
|
2014-05-04 18:59:06 -04:00
|
|
|
|
2014-09-11 18:07:06 -04:00
|
|
|
if (userdata) {
|
|
|
|
delete(userdata);
|
2014-05-04 18:59:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************** **** **** **** ***********************/
|
|
|
|
/*********************** **** **** **** ***********************/
|
|
|
|
|
2014-07-05 14:33:11 -04:00
|
|
|
//void GxsGroupFrameDialog::acknowledgeSubscribeChange(const uint32_t &token)
|
|
|
|
//{
|
|
|
|
//#ifdef DEBUG_GROUPFRAMEDIALOG
|
|
|
|
// std::cerr << "GxsGroupFrameDialog::acknowledgeSubscribeChange()";
|
|
|
|
// std::cerr << std::endl;
|
|
|
|
//#endif
|
2014-05-04 18:59:06 -04:00
|
|
|
|
2014-07-05 14:33:11 -04:00
|
|
|
// RsGxsGroupId groupId;
|
|
|
|
// mInterface->acknowledgeGrp(token, groupId);
|
2014-05-04 18:59:06 -04:00
|
|
|
|
2014-07-05 14:33:11 -04:00
|
|
|
// fillComplete();
|
|
|
|
//}
|
2014-05-04 18:59:06 -04:00
|
|
|
|
|
|
|
/*********************** **** **** **** ***********************/
|
|
|
|
/*********************** **** **** **** ***********************/
|
|
|
|
|
|
|
|
//void GxsGroupFrameDialog::requestGroupSummary_CurrentGroup(const RsGxsGroupId &groupId)
|
|
|
|
//{
|
|
|
|
// RsTokReqOptions opts;
|
|
|
|
// opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
|
|
|
|
|
|
|
// std::list<std::string> grpIds;
|
|
|
|
// grpIds.push_back(groupId);
|
|
|
|
|
|
|
|
// std::cerr << "GxsGroupFrameDialog::requestGroupSummary_CurrentGroup(" << groupId << ")";
|
|
|
|
// std::cerr << std::endl;
|
|
|
|
|
|
|
|
// uint32_t token;
|
|
|
|
// mInteface->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, TOKEN_TYPE_CURRENTGROUP);
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void GxsGroupFrameDialog::loadGroupSummary_CurrentGroup(const uint32_t &token)
|
|
|
|
//{
|
|
|
|
// std::cerr << "GxsGroupFrameDialog::loadGroupSummary_CurrentGroup()";
|
|
|
|
// std::cerr << std::endl;
|
|
|
|
|
|
|
|
// std::list<RsGroupMetaData> groupInfo;
|
|
|
|
// rsGxsForums->getGroupSummary(token, groupInfo);
|
|
|
|
|
|
|
|
// if (groupInfo.size() == 1)
|
|
|
|
// {
|
|
|
|
// RsGroupMetaData fi = groupInfo.front();
|
|
|
|
// mSubscribeFlags = fi.mSubscribeFlags;
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// resetData();
|
|
|
|
// std::cerr << "GxsGroupFrameDialog::loadGroupSummary_CurrentGroup() ERROR Invalid Number of Groups...";
|
|
|
|
// std::cerr << std::endl;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// setValid(true);
|
|
|
|
//}
|
|
|
|
|
|
|
|
/*********************** **** **** **** ***********************/
|
|
|
|
/*********************** **** **** **** ***********************/
|
|
|
|
|
2014-07-20 15:35:33 -04:00
|
|
|
void GxsGroupFrameDialog::requestGroupStatistics(const RsGxsGroupId &groupId)
|
2014-07-06 12:39:09 -04:00
|
|
|
{
|
|
|
|
uint32_t token;
|
2014-07-20 15:35:33 -04:00
|
|
|
mTokenService->requestGroupStatistic(token, groupId);
|
|
|
|
mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
|
2014-07-06 12:39:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GxsGroupFrameDialog::loadGroupStatistics(const uint32_t &token)
|
|
|
|
{
|
2014-07-20 15:35:33 -04:00
|
|
|
GxsGroupStatistic stats;
|
|
|
|
mInterface->getGroupStatistic(token, stats);
|
2014-07-06 12:39:09 -04:00
|
|
|
|
2014-07-20 15:35:33 -04:00
|
|
|
QTreeWidgetItem *item = ui->groupTreeWidget->getItemFromId(QString::fromStdString(stats.mGrpId.toStdString()));
|
|
|
|
if (!item) {
|
|
|
|
return;
|
2014-07-06 12:39:09 -04:00
|
|
|
}
|
2014-07-20 15:35:33 -04:00
|
|
|
|
2014-09-24 19:57:47 -04:00
|
|
|
ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread);
|
2014-07-06 12:39:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************** **** **** **** ***********************/
|
|
|
|
/*********************** **** **** **** ***********************/
|
|
|
|
|
2014-05-04 18:59:06 -04:00
|
|
|
void GxsGroupFrameDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_GROUPFRAMEDIALOG
|
|
|
|
std::cerr << "GxsGroupFrameDialog::loadRequest() UserType: " << req.mUserType;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (queue == mTokenQueue)
|
|
|
|
{
|
|
|
|
/* now switch on req */
|
|
|
|
switch(req.mUserType)
|
|
|
|
{
|
2014-05-07 17:04:54 -04:00
|
|
|
case TOKEN_TYPE_GROUP_SUMMARY:
|
2014-05-04 18:59:06 -04:00
|
|
|
loadGroupSummary(req.mToken);
|
|
|
|
break;
|
|
|
|
|
2014-07-05 14:33:11 -04:00
|
|
|
// case TOKEN_TYPE_SUBSCRIBE_CHANGE:
|
|
|
|
// acknowledgeSubscribeChange(req.mToken);
|
|
|
|
// break;
|
2014-05-04 18:59:06 -04:00
|
|
|
|
|
|
|
// case TOKEN_TYPE_CURRENTGROUP:
|
|
|
|
// loadGroupSummary_CurrentGroup(req.mToken);
|
|
|
|
// break;
|
|
|
|
|
2014-07-06 12:39:09 -04:00
|
|
|
case TOKEN_TYPE_STATISTICS:
|
|
|
|
loadGroupStatistics(req.mToken);
|
|
|
|
break;
|
|
|
|
|
2014-05-04 18:59:06 -04:00
|
|
|
default:
|
|
|
|
std::cerr << "GxsGroupFrameDialog::loadRequest() ERROR: INVALID TYPE";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|