2008-06-20 08:43:23 -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 <QtGui>
|
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
#include <iostream>
|
2008-11-02 10:20:42 -05:00
|
|
|
#include <algorithm>
|
2008-06-24 00:36:45 -04:00
|
|
|
|
|
|
|
#include "rsiface/rschannels.h"
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
#include "ChannelFeed.h"
|
|
|
|
#include "gui/feeds/ChanGroupItem.h"
|
|
|
|
#include "gui/feeds/ChanMenuItem.h"
|
|
|
|
#include "gui/feeds/ChanMsgItem.h"
|
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
#include "gui/forums/CreateForum.h"
|
|
|
|
|
|
|
|
#include "GeneralMsgDialog.h"
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
/****
|
|
|
|
* #define CHAN_DEBUG
|
|
|
|
***/
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
/** Constructor */
|
|
|
|
ChannelFeed::ChannelFeed(QWidget *parent)
|
|
|
|
: MainPage (parent)
|
|
|
|
{
|
2008-06-24 00:36:45 -04:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
setupUi(this);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
connect(chanButton, SIGNAL(clicked()), this, SLOT(createChannel()));
|
|
|
|
connect(postButton, SIGNAL(clicked()), this, SLOT(sendMsg()));
|
2008-07-04 10:41:24 -04:00
|
|
|
connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeChannel ( void ) ) );
|
|
|
|
connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) );
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
/*************** Setup Left Hand Side (List of Channels) ****************/
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
mGroupLayout = new QVBoxLayout;
|
2008-11-27 16:26:52 -05:00
|
|
|
mGroupLayout->setSpacing(0);
|
|
|
|
mGroupLayout->setMargin(0);
|
|
|
|
mGroupLayout->setContentsMargins(0,0,0,0);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
mGroupOwn = new ChanGroupItem("Own Channels");
|
|
|
|
mGroupSub = new ChanGroupItem("Subscribed Channels");
|
|
|
|
mGroupPop = new ChanGroupItem("Popular Channels");
|
|
|
|
mGroupOther = new ChanGroupItem("Other Channels");
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
mGroupLayout->addWidget(mGroupOwn);
|
|
|
|
mGroupLayout->addWidget(mGroupSub);
|
|
|
|
mGroupLayout->addWidget(mGroupPop);
|
|
|
|
mGroupLayout->addWidget(mGroupOther);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
|
|
|
|
QWidget *middleWidget = new QWidget();
|
|
|
|
//middleWidget->setSizePolicy( QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Minimum);
|
|
|
|
middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
2008-06-24 00:36:45 -04:00
|
|
|
middleWidget->setLayout(mGroupLayout);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
QScrollArea *scrollArea = new QScrollArea;
|
2008-07-06 12:41:33 -04:00
|
|
|
//scrollArea->setBackgroundRole(QPalette::Dark);
|
2008-06-20 08:43:23 -04:00
|
|
|
scrollArea->setWidget(middleWidget);
|
|
|
|
scrollArea->setWidgetResizable(true);
|
|
|
|
scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
|
|
|
|
|
|
|
QVBoxLayout *layout2 = new QVBoxLayout;
|
|
|
|
layout2->addWidget(scrollArea);
|
2008-08-16 18:24:53 -04:00
|
|
|
layout2->setSpacing(0);
|
|
|
|
layout2->setMargin(0);
|
2008-11-27 16:26:52 -05:00
|
|
|
layout2->setContentsMargins(0,0,0,0);
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
chanFrame->setLayout(layout2);
|
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
/*************** Setup Left Hand Side (List of Channels) ****************/
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
mMsgLayout = new QVBoxLayout;
|
2008-11-27 16:26:52 -05:00
|
|
|
mMsgLayout->setSpacing(0);
|
|
|
|
mMsgLayout->setMargin(0);
|
|
|
|
mMsgLayout->setContentsMargins(0,0,0,0);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
QWidget *middleWidget2 = new QWidget();
|
|
|
|
middleWidget2->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
2008-06-24 00:36:45 -04:00
|
|
|
middleWidget2->setLayout(mMsgLayout);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
QScrollArea *scrollArea2 = new QScrollArea;
|
2008-07-06 12:41:33 -04:00
|
|
|
//scrollArea2->setBackgroundRole(QPalette::Dark);
|
2008-06-20 08:43:23 -04:00
|
|
|
scrollArea2->setWidget(middleWidget2);
|
|
|
|
scrollArea2->setWidgetResizable(true);
|
|
|
|
scrollArea2->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
|
|
|
|
|
|
|
QVBoxLayout *layout3 = new QVBoxLayout;
|
|
|
|
layout3->addWidget(scrollArea2);
|
2008-08-16 18:24:53 -04:00
|
|
|
layout3->setSpacing(0);
|
|
|
|
layout3->setMargin(0);
|
2008-11-27 16:26:52 -05:00
|
|
|
layout3->setContentsMargins(0,0,0,0);
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
msgFrame->setLayout(layout3);
|
2008-06-24 00:36:45 -04:00
|
|
|
|
|
|
|
mChannelId = "OWNID";
|
|
|
|
|
|
|
|
updateChannelList();
|
|
|
|
|
|
|
|
QTimer *timer = new QTimer(this);
|
|
|
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
|
|
|
timer->start(1000);
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
void ChannelFeed::createChannel()
|
|
|
|
{
|
|
|
|
CreateForum *cf = new CreateForum(NULL, false);
|
2009-08-14 07:49:15 -04:00
|
|
|
|
|
|
|
cf->setWindowTitle(tr("Create a new Channel"));
|
|
|
|
cf->ui.labelicon->setPixmap(QPixmap(":/images/add_channel64.png"));
|
|
|
|
QString titleStr("<span style=\"font-size:16pt; font-weight:500;"
|
|
|
|
"color:#32cd32;\">%1</span>");
|
|
|
|
cf->ui.textlabelcreatforums->setText( titleStr.arg( tr("Create a new Channel") ) ) ;
|
2008-06-24 00:36:45 -04:00
|
|
|
cf->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::channelSelection()
|
|
|
|
{
|
|
|
|
/* which item was selected? */
|
|
|
|
|
|
|
|
|
|
|
|
/* update mChannelId */
|
|
|
|
|
|
|
|
updateChannelMsgs();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::sendMsg()
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2008-06-24 00:36:45 -04:00
|
|
|
std::cerr << "ChannelFeed::sendMsg()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-24 00:36:45 -04:00
|
|
|
|
|
|
|
if (mChannelId != "")
|
|
|
|
{
|
|
|
|
openMsg(FEEDHOLDER_MSG_CHANNEL, mChannelId, "");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2008-06-24 00:36:45 -04:00
|
|
|
std::cerr << "ChannelFeed::sendMsg() no Channel Selected!";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-24 00:36:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************************/
|
|
|
|
/*************************************************************************************/
|
|
|
|
/*************************************************************************************/
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
void ChannelFeed::deleteFeedItem(QWidget *item, uint32_t type)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::openChat(std::string peerId)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
void ChannelFeed::openMsg(uint32_t type, std::string grpId, std::string inReplyTo)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2008-06-24 00:36:45 -04:00
|
|
|
std::cerr << "ChannelFeed::openMsg()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-24 00:36:45 -04:00
|
|
|
GeneralMsgDialog *msgDialog = new GeneralMsgDialog(NULL);
|
|
|
|
|
|
|
|
|
|
|
|
msgDialog->addDestination(type, grpId, inReplyTo);
|
|
|
|
|
|
|
|
msgDialog->show();
|
2008-06-20 08:43:23 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
void ChannelFeed::selectChannel( std::string cId)
|
|
|
|
{
|
|
|
|
mChannelId = cId;
|
|
|
|
|
|
|
|
updateChannelMsgs();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::checkUpdate()
|
|
|
|
{
|
|
|
|
std::list<std::string> chanIds;
|
|
|
|
std::list<std::string>::iterator it;
|
|
|
|
if (!rsChannels)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (rsChannels->channelsChanged(chanIds))
|
|
|
|
{
|
|
|
|
/* update Forums List */
|
|
|
|
updateChannelList();
|
|
|
|
|
|
|
|
it = std::find(chanIds.begin(), chanIds.end(), mChannelId);
|
|
|
|
if (it != chanIds.end())
|
|
|
|
{
|
|
|
|
updateChannelMsgs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ChannelFeed::updateChannelList()
|
|
|
|
{
|
|
|
|
|
|
|
|
std::list<ChannelInfo> channelList;
|
|
|
|
std::list<ChannelInfo>::iterator it;
|
|
|
|
if (!rsChannels)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rsChannels->getChannelList(channelList);
|
|
|
|
|
|
|
|
/* get the ids for our lists */
|
|
|
|
std::list<std::string> adminIds;
|
|
|
|
std::list<std::string> subIds;
|
|
|
|
std::list<std::string> popIds;
|
|
|
|
std::list<std::string> otherIds;
|
|
|
|
std::multimap<uint32_t, std::string> popMap;
|
|
|
|
|
|
|
|
for(it = channelList.begin(); it != channelList.end(); it++)
|
|
|
|
{
|
|
|
|
/* sort it into Publish (Own), Subscribed, Popular and Other */
|
|
|
|
uint32_t flags = it->channelFlags;
|
|
|
|
|
|
|
|
if (flags & RS_DISTRIB_ADMIN)
|
|
|
|
{
|
|
|
|
adminIds.push_back(it->channelId);
|
|
|
|
}
|
|
|
|
else if (flags & RS_DISTRIB_SUBSCRIBED)
|
|
|
|
{
|
|
|
|
subIds.push_back(it->channelId);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* rate the others by popularity */
|
|
|
|
popMap.insert(std::make_pair(it->pop, it->channelId));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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, std::string>::reverse_iterator rit;
|
|
|
|
for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++)
|
|
|
|
{
|
|
|
|
popIds.push_back(rit->second);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rit != popMap.rend())
|
|
|
|
{
|
|
|
|
popLimit = rit->first;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(it = channelList.begin(); it != channelList.end(); it++)
|
|
|
|
{
|
|
|
|
/* ignore the ones we've done already */
|
|
|
|
uint32_t flags = it->channelFlags;
|
|
|
|
|
|
|
|
if (flags & RS_DISTRIB_ADMIN)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (flags & RS_DISTRIB_SUBSCRIBED)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (it->pop < popLimit)
|
|
|
|
{
|
|
|
|
otherIds.push_back(it->channelId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now we have our lists ---> update entries */
|
|
|
|
|
|
|
|
updateChannelListOwn(adminIds);
|
|
|
|
updateChannelListSub(subIds);
|
|
|
|
updateChannelListPop(popIds);
|
|
|
|
updateChannelListOther(otherIds);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::updateChannelListOwn(std::list<std::string> &ids)
|
|
|
|
{
|
|
|
|
std::list<ChanMenuItem *>::iterator it;
|
|
|
|
std::list<std::string>::iterator iit;
|
|
|
|
|
|
|
|
/* TEMP just replace all of them */
|
|
|
|
for(it = mChannelListOwn.begin(); it != mChannelListOwn.end(); it++)
|
|
|
|
{
|
|
|
|
delete (*it);
|
|
|
|
}
|
|
|
|
mChannelListOwn.clear();
|
|
|
|
|
|
|
|
int topIndex = mGroupLayout->indexOf(mGroupOwn);
|
|
|
|
int index = topIndex + 1;
|
|
|
|
for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2008-06-24 00:36:45 -04:00
|
|
|
std::cerr << "ChannelFeed::updateChannelListOwn(): " << *iit << " at: " << index;
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-24 00:36:45 -04:00
|
|
|
|
|
|
|
ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
|
|
|
mChannelListOwn.push_back(cmi);
|
|
|
|
mGroupLayout->insertWidget(index, cmi);
|
|
|
|
|
|
|
|
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::updateChannelListSub(std::list<std::string> &ids)
|
|
|
|
{
|
|
|
|
std::list<ChanMenuItem *>::iterator it;
|
|
|
|
std::list<std::string>::iterator iit;
|
|
|
|
|
|
|
|
/* TEMP just replace all of them */
|
|
|
|
for(it = mChannelListSub.begin(); it != mChannelListSub.end(); it++)
|
|
|
|
{
|
|
|
|
delete (*it);
|
|
|
|
}
|
|
|
|
mChannelListSub.clear();
|
|
|
|
|
|
|
|
int topIndex = mGroupLayout->indexOf(mGroupSub);
|
|
|
|
int index = topIndex + 1;
|
|
|
|
for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2008-06-24 00:36:45 -04:00
|
|
|
std::cerr << "ChannelFeed::updateChannelListSub(): " << *iit << " at: " << index;
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-24 00:36:45 -04:00
|
|
|
|
|
|
|
ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
|
|
|
mChannelListSub.push_back(cmi);
|
|
|
|
mGroupLayout->insertWidget(index, cmi);
|
|
|
|
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::updateChannelListPop(std::list<std::string> &ids)
|
|
|
|
{
|
|
|
|
std::list<ChanMenuItem *>::iterator it;
|
|
|
|
std::list<std::string>::iterator iit;
|
|
|
|
|
|
|
|
/* TEMP just replace all of them */
|
|
|
|
for(it = mChannelListPop.begin(); it != mChannelListPop.end(); it++)
|
|
|
|
{
|
|
|
|
delete (*it);
|
|
|
|
}
|
|
|
|
mChannelListPop.clear();
|
|
|
|
|
|
|
|
int topIndex = mGroupLayout->indexOf(mGroupPop);
|
|
|
|
int index = topIndex + 1;
|
|
|
|
for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2008-06-24 00:36:45 -04:00
|
|
|
std::cerr << "ChannelFeed::updateChannelListPop(): " << *iit << " at: " << index;
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-24 00:36:45 -04:00
|
|
|
|
|
|
|
ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
|
|
|
mChannelListPop.push_back(cmi);
|
|
|
|
mGroupLayout->insertWidget(index, cmi);
|
|
|
|
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::updateChannelListOther(std::list<std::string> &ids)
|
|
|
|
{
|
|
|
|
std::list<ChanMenuItem *>::iterator it;
|
|
|
|
std::list<std::string>::iterator iit;
|
|
|
|
|
|
|
|
/* TEMP just replace all of them */
|
|
|
|
for(it = mChannelListOther.begin(); it != mChannelListOther.end(); it++)
|
|
|
|
{
|
|
|
|
delete (*it);
|
|
|
|
}
|
|
|
|
mChannelListOther.clear();
|
|
|
|
|
|
|
|
int topIndex = mGroupLayout->indexOf(mGroupOther);
|
|
|
|
int index = topIndex + 1;
|
|
|
|
for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2008-06-24 00:36:45 -04:00
|
|
|
std::cerr << "ChannelFeed::updateChannelListOther(): " << *iit << " at: " << index;
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-24 00:36:45 -04:00
|
|
|
|
|
|
|
ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
|
|
|
mChannelListOther.push_back(cmi);
|
|
|
|
mGroupLayout->insertWidget(index, cmi);
|
|
|
|
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::updateChannelMsgs()
|
|
|
|
{
|
|
|
|
if (!rsChannels)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ChannelInfo ci;
|
|
|
|
if (!rsChannels->getChannelInfo(mChannelId, ci))
|
|
|
|
{
|
|
|
|
postButton->setEnabled(false);
|
|
|
|
subscribeButton->setEnabled(false);
|
|
|
|
unsubscribeButton->setEnabled(false);
|
|
|
|
nameLabel->setText("No Channel Selected");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* set channel name */
|
|
|
|
nameLabel->setText(QString::fromStdWString(ci.channelName));
|
|
|
|
|
|
|
|
/* do buttons */
|
|
|
|
if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
|
|
|
|
{
|
|
|
|
subscribeButton->setEnabled(false);
|
|
|
|
unsubscribeButton->setEnabled(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
subscribeButton->setEnabled(true);
|
|
|
|
unsubscribeButton->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ci.channelFlags & RS_DISTRIB_PUBLISH)
|
|
|
|
{
|
|
|
|
postButton->setEnabled(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
postButton->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* replace all the messages with new ones */
|
|
|
|
std::list<ChanMsgItem *>::iterator mit;
|
|
|
|
for(mit = mChanMsgItems.begin(); mit != mChanMsgItems.end(); mit++)
|
|
|
|
{
|
|
|
|
delete (*mit);
|
|
|
|
}
|
|
|
|
mChanMsgItems.clear();
|
|
|
|
|
|
|
|
std::list<ChannelMsgSummary> msgs;
|
|
|
|
std::list<ChannelMsgSummary>::iterator it;
|
|
|
|
|
|
|
|
rsChannels->getChannelMsgList(mChannelId, msgs);
|
|
|
|
|
|
|
|
for(it = msgs.begin(); it != msgs.end(); it++)
|
|
|
|
{
|
|
|
|
ChanMsgItem *cmi = new ChanMsgItem(this, 0, mChannelId, it->msgId, true);
|
|
|
|
|
|
|
|
mChanMsgItems.push_back(cmi);
|
|
|
|
mMsgLayout->addWidget(cmi);
|
|
|
|
}
|
|
|
|
}
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-04 10:41:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ChannelFeed::unsubscribeChannel()
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2008-07-04 10:41:24 -04:00
|
|
|
std::cerr << "ChannelFeed::unsubscribeChannel()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
if (rsChannels)
|
|
|
|
{
|
|
|
|
rsChannels->channelSubscribe(mChannelId, false);
|
|
|
|
}
|
|
|
|
updateChannelMsgs();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChannelFeed::subscribeChannel()
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2008-07-04 10:41:24 -04:00
|
|
|
std::cerr << "ChannelFeed::subscribeChannel()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
if (rsChannels)
|
|
|
|
{
|
|
|
|
rsChannels->channelSubscribe(mChannelId, true);
|
|
|
|
}
|
|
|
|
updateChannelMsgs();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|