Merging branches/v0.6-initdev into trunk.

These split at 6672 -> 7075, so quite a bit merge.
libretroshare compiles - but untested.
retroshare-gui needs GenCertDialog.ui and IdEditDialog.ui to be properly merged. (compile errors).
some plugins will be broken.
retroshare-nogui is untested.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7078 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2014-02-01 14:16:15 +00:00
commit c0738eec7f
407 changed files with 23716 additions and 50779 deletions

View file

@ -48,15 +48,15 @@ AboutDialog::AboutDialog(QWidget* parent)
tWidget = NULL;
installAWidget();
QString title = tr("About RetroShare ");
/* get libretroshare version */
std::map<std::string, std::string>::iterator vit;
std::map<std::string, std::string> versions;
bool retv = rsDisc->getDiscVersions(versions);
if (retv && versions.end() != (vit = versions.find(rsPeers->getOwnId())))
std::string version;
if (rsDisc->getPeerVersion(rsPeers->getOwnId(), version))
{
QString version = QString::fromStdString(vit->second);
setWindowTitle(tr("About RetroShare %1").arg(version));
title += QString::fromStdString(version);
}
setWindowTitle(title);
#ifdef Q_OS_WIN
setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
@ -132,20 +132,20 @@ void AboutDialog::sl_levelChanged(int level) {
void AboutDialog::updateTitle() {
if (tWidget == NULL) {
/* get libretroshare version */
std::map<std::string, std::string>::iterator vit;
std::map<std::string, std::string> versions;
bool retv = rsDisc->getDiscVersions(versions);
if (retv && versions.end() != (vit = versions.find(rsPeers->getOwnId())))
{
QString version = QString::fromStdString(vit->second);
setWindowTitle(tr("About RetroShare %1").arg(version));
}
} else {
if (tWidget == NULL)
{
QString title = tr("About RetroShare ");
/* get libretroshare version */
std::string version;
if (rsDisc->getPeerVersion(rsPeers->getOwnId(), version))
{
title += QString::fromStdString(version);
}
setWindowTitle(title);
}
else
{
setWindowTitle(tr("Have fun ;-)"));
}
}
@ -185,21 +185,22 @@ AWidget::AWidget() {
font.setPointSizeF(11);
p.setFont(font);
/* get libretroshare version */
std::map<std::string, std::string>::iterator vit;
std::map<std::string, std::string> versions;
bool retv = rsDisc->getDiscVersions(versions);
if (retv && versions.end() != (vit = versions.find(rsPeers->getOwnId())))
QString title = tr("About RetroShare ");
/* get libretroshare version */
std::string version;
if (rsDisc->getPeerVersion(rsPeers->getOwnId(), version))
{
QString version = QString("RetroShare %1 : \n%2").arg(tr("version"), QString::fromStdString(vit->second));
p.drawText(QRect(10, 10, width()-10, 60), version);
QString versionq = QString::fromStdString("RetroShare version : \n") + QString::fromStdString(version);
p.drawText(QRect(10, 10, width()-10, 60), versionq);
}
/* Draw Qt's version number */
p.drawText(QRect(10, 50, width()-10, 60), QString("Qt %1 : \n%2").arg(tr("version"), QT_VERSION_STR));
p.end();
image1 = image2 = image;
setFixedSize(image1.size());

View file

@ -1,962 +0,0 @@
/****************************************************************
* 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 <QTimer>
#include <QFile>
#include <QStandardItemModel>
#include <QMessageBox>
#include <QFileDialog>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <time.h>
#include <retroshare/rsfiles.h>
#include "ChannelFeed.h"
#include "feeds/ChanMsgItem.h"
#include "common/PopularityDefs.h"
#include "settings/rsharesettings.h"
#include "channels/CreateChannel.h"
#include "channels/ChannelDetails.h"
#include "channels/CreateChannelMsg.h"
#include "channels/EditChanDetails.h"
#include "channels/ShareKey.h"
#include "channels/ChannelUserNotify.h"
#include "notifyqt.h"
#include "RetroShareLink.h"
#define CHAN_DEFAULT_IMAGE ":/images/channels.png"
#define WARNING_LIMIT 3600*24*2
/* Images for TreeWidget */
#define IMAGE_CHANNELBLUE ":/images/channelsblue.png"
#define IMAGE_CHANNELGREEN ":/images/channelsgreen.png"
#define IMAGE_CHANNELRED ":/images/channelsred.png"
#define IMAGE_CHANNELYELLOW ":/images/channelsyellow.png"
/****
* #define CHAN_DEBUG
***/
#define USE_THREAD
/** Constructor */
ChannelFeed::ChannelFeed(QWidget *parent)
: RsAutoUpdatePage(1000,parent)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
connect(postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
/*************** Setup Left Hand Side (List of Channels) ****************/
connect(treeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT( channelListCustomPopupMenu( QPoint ) ) );
connect(treeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(selectChannel(QString)));
connect( subscribeButton , SIGNAL( clicked() ), this, SLOT( subscribeChannel() ) );
mChannelId.clear();
/* Set initial size the splitter */
QList<int> sizes;
sizes << 300 << width(); // Qt calculates the right sizes
splitter->setSizes(sizes);
/* Initialize group tree */
QToolButton *newChannelButton = new QToolButton(this);
newChannelButton->setIcon(QIcon(":/images/add_channel24.png"));
newChannelButton->setToolTip(tr("Create Channel"));
connect(newChannelButton, SIGNAL(clicked()), this, SLOT(createChannel()));
treeWidget->addToolButton(newChannelButton);
ownChannels = treeWidget->addCategoryItem(tr("My Channels"), QIcon(IMAGE_CHANNELBLUE), true);
subcribedChannels = treeWidget->addCategoryItem(tr("Subscribed Channels"), QIcon(IMAGE_CHANNELRED), true);
popularChannels = treeWidget->addCategoryItem(tr("Popular Channels"), QIcon(IMAGE_CHANNELGREEN ), false);
otherChannels = treeWidget->addCategoryItem(tr("Other Channels"), QIcon(IMAGE_CHANNELYELLOW), false);
progressLabel->hide();
progressBar->hide();
fillThread = NULL;
//added from ahead
updateChannelList();
nameLabel->setMinimumWidth(20);
unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), this );
connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) );
/* load settings */
processSettings(true);
updateChannelMsgs();
QString help_str = tr(
" <h1><img width=\"32\" src=\":/images/64px_help.png\">&nbsp;&nbsp;Channels</h1> \
<p>Channels allow you to post data (e.g. movies, music) that will spread in the network \
among people who subscribed your channel. If you activate auto-download on a channel, files attached to each post will start \
downloading automatically when the post is received.</p> \
<p>You see channels your friends are subscribed to, and forward subscribed channels to \
your friends. This promotes good channels in the network. \
When you first connect to a new friend, it's likely \
you will receive many such cache files, and new channels will appear. \
</p> \
<p>Only the channel's creator can post on that channel. Other peers \
in the network can only read from it, unless the channel is private. You can however share the posting rights or the reading rights \
with your friends.</p> \
") ;
registerHelpButton(helpButton,help_str) ;
}
ChannelFeed::~ChannelFeed()
{
if (fillThread) {
fillThread->stop();
delete(fillThread);
fillThread = NULL;
}
// save settings
processSettings(false);
}
UserNotify *ChannelFeed::getUserNotify(QObject *parent)
{
return new ChannelUserNotify(parent);
}
void ChannelFeed::processSettings(bool load)
{
Settings->beginGroup(QString("ChannelFeed"));
if (load) {
// load settings
// state of splitter
splitter->restoreState(Settings->value("Splitter").toByteArray());
} else {
// save settings
// state of splitter
Settings->setValue("Splitter", splitter->saveState());
}
treeWidget->processSettings(Settings, load);
Settings->endGroup();
}
void ChannelFeed::channelListCustomPopupMenu( QPoint /*point*/ )
{
ChannelInfo ci;
if (!rsChannels->getChannelInfo(mChannelId, ci)) {
return;
}
QMenu contextMnu(this);
QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu);
connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) );
QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu);
connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) );
QAction *setallasreadchannelAct = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Set all as read" ), &contextMnu);
connect( setallasreadchannelAct , SIGNAL( triggered() ), this, SLOT( setAllAsReadClicked() ) );
bool autoDl = false;
rsChannels->channelGetAutoDl(mChannelId, autoDl);
QAction *autochannelAct = autoDl? (new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu))
: (new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu)) ;
connect( autochannelAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) );
QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu);
connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) );
QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu);
connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) );
QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu);
connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) );
QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu);
connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) );
if((ci.channelFlags & RS_DISTRIB_ADMIN) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED))
contextMnu.addAction( editChannelDetailAct);
else
contextMnu.addAction( channeldetailsAct );
if((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED))
{
contextMnu.addAction( postchannelAct );
contextMnu.addAction( shareKeyAct );
}
if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
{
QMenu *directoryMenu = contextMnu.addMenu(QIcon(":/images/folderopen.png"),tr("Set destination directory")) ;
QAction *specifyDestinationDirectoryAct = new QAction(QIcon(":/images/filefind.png"), tr("Other..."), &contextMnu);
directoryMenu->addAction(specifyDestinationDirectoryAct);
connect(specifyDestinationDirectoryAct,SIGNAL(triggered()),this,SLOT(chooseDestinationDirectory())) ;
// Now get the list of existing directories.
std::list<SharedDirInfo> dirs ;
rsFiles->getSharedDirectories(dirs) ;
bool found = false ;
for(std::list<SharedDirInfo>::const_iterator it(dirs.begin());it!=dirs.end();++it)
{
// check for existence of directory name
QFile directory(QString::fromUtf8((*it).filename.c_str())) ;
if(!directory.exists()) continue ;
if(!(directory.permissions() & QFile::WriteOwner)) continue ;
QAction *act ;
if(ci.destination_directory == (*it).filename)
{
act = new QAction(QIcon(":/images/start.png"),QString::fromUtf8((*it).virtualname.c_str()),directoryMenu) ;
found = true ;
}
else
act = new QAction(QString::fromUtf8((*it).virtualname.c_str()),directoryMenu) ;
act->setData(QString::fromUtf8((*it).filename.c_str())) ;
connect(act,SIGNAL(triggered()),this,SLOT(setDestinationDirectory())) ;
directoryMenu->addAction(act) ;
}
QAction *defaultDestinationDirectoryAct = new QAction(tr("[Default]"), &contextMnu);
defaultDestinationDirectoryAct->setData(QString()) ;
connect(defaultDestinationDirectoryAct,SIGNAL(triggered()),this,SLOT(setDestinationDirectory())) ;
directoryMenu->addAction(defaultDestinationDirectoryAct);
if(ci.destination_directory.empty())
defaultDestinationDirectoryAct->setIcon(QIcon(":/images/start.png")) ;
else if(!found)
specifyDestinationDirectoryAct->setIcon(QIcon(":/images/start.png")) ;
}
if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
{
contextMnu.addAction( unsubscribechannelAct );
contextMnu.addAction( restoreKeysAct );
contextMnu.addSeparator();
contextMnu.addAction( autochannelAct );
contextMnu.addAction( setallasreadchannelAct );
}
else
contextMnu.addAction( subscribechannelAct );
contextMnu.addSeparator();
QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink()));
action->setEnabled(!mChannelId.empty());
#ifdef CHAN_DEBUG
contextMnu.addSeparator();
action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData()));
action->setEnabled (!mChannelId.empty() && (ci.channelFlags & RS_DISTRIB_PUBLISH));
#endif
contextMnu.exec(QCursor::pos());
}
void ChannelFeed::setDestinationDirectory()
{
ChannelInfo ci;
if (!rsChannels->getChannelInfo(mChannelId, ci))
return;
std::string dest_dir(qobject_cast<QAction*>(sender())->data().toString().toUtf8().data()) ;
std::cerr << "Setting new directory " << dest_dir << " to channel " << mChannelId << std::endl;
rsChannels->channelSetDestinationDirectory(mChannelId,dest_dir) ;
}
void ChannelFeed::chooseDestinationDirectory()
{
ChannelInfo ci;
if (!rsChannels->getChannelInfo(mChannelId, ci))
return;
QString dirname = QFileDialog::getExistingDirectory(NULL,tr("Select channel destination directory"),QString::fromUtf8(ci.destination_directory.c_str()),QFileDialog::ShowDirsOnly) ;
if(dirname.isNull())
return ;
std::cerr << "Setting new directory " << dirname.toStdString() << " to channel " << mChannelId << std::endl;
rsChannels->channelSetDestinationDirectory(mChannelId, dirname.toUtf8().constData()) ;
}
void ChannelFeed::createChannel()
{
CreateChannel *cf = new CreateChannel();
cf->show();
/* window will destroy itself! */
}
/*************************************************************************************/
/*************************************************************************************/
/*************************************************************************************/
QScrollArea *ChannelFeed::getScrollArea()
{
return scrollArea;
}
void ChannelFeed::deleteFeedItem(QWidget */*item*/, uint32_t /*type*/)
{
}
void ChannelFeed::openChat(std::string /*peerId*/)
{
}
void ChannelFeed::openComments(uint32_t /*type*/ , const RsGxsGroupId & /*grpId */, const RsGxsMessageId & /*msgId*/, const QString & /* title */)
{
}
void ChannelFeed::editChannelDetail(){
EditChanDetails editUi(this, mChannelId);
editUi.exec();
}
void ChannelFeed::shareKey()
{
ShareKey shareUi(this, mChannelId, CHANNEL_KEY_SHARE);
shareUi.exec();
}
void ChannelFeed::copyChannelLink()
{
if (mChannelId.empty()) {
return;
}
ChannelInfo ci;
if (rsChannels->getChannelInfo(mChannelId, ci)) {
RetroShareLink link;
if (link.createChannel(ci.channelId, "")) {
QList<RetroShareLink> urls;
urls.push_back(link);
RSLinkClipboard::copyLinks(urls);
}
}
}
void ChannelFeed::createMsg()
{
if (mChannelId.empty()) {
return;
}
CreateChannelMsg *msgDialog = new CreateChannelMsg(mChannelId);
msgDialog->show();
/* window will destroy itself! */
}
void ChannelFeed::restoreChannelKeys()
{
if(rsChannels->channelRestoreKeys(mChannelId))
QMessageBox::information(NULL,tr("Publish rights restored."),tr("Publish rights have been restored for this channel.")) ;
else
QMessageBox::warning(NULL,tr("Publish not restored."),tr("Publish rights can't be restored for this channel.<br/>You're not the creator of this channel.")) ;
}
void ChannelFeed::selectChannel(const QString &id)
{
mChannelId = id.toStdString();
bool autoDl = false;
rsChannels->channelGetAutoDl(mChannelId, autoDl);
setAutoDownloadButton(autoDl);
updateChannelMsgs();
}
void ChannelFeed::updateDisplay()
{
if (!rsChannels) {
return;
}
std::list<std::string> chanIds;
std::list<std::string>::iterator it;
if (rsChannels->channelsChanged(chanIds)) {
/* update channel list */
updateChannelList();
it = std::find(chanIds.begin(), chanIds.end(), mChannelId);
if (it != chanIds.end()) {
updateChannelMsgs();
}
}
}
static void channelInfoToGroupItemInfo(const ChannelInfo &channelInfo, GroupItemInfo &groupItemInfo)
{
groupItemInfo.id = QString::fromStdString(channelInfo.channelId);
groupItemInfo.name = QString::fromStdWString(channelInfo.channelName);
groupItemInfo.description = QString::fromStdWString(channelInfo.channelDesc);
groupItemInfo.popularity = channelInfo.pop;
groupItemInfo.lastpost = QDateTime::fromTime_t(channelInfo.lastPost);
QPixmap chanImage;
if (channelInfo.pngImageLen) {
chanImage.loadFromData(channelInfo.pngChanImage, channelInfo.pngImageLen, "PNG");
} else {
chanImage = QPixmap(CHAN_DEFAULT_IMAGE);
}
groupItemInfo.icon = QIcon(chanImage);
}
void ChannelFeed::updateChannelList()
{
if (!rsChannels) {
return;
}
std::list<ChannelInfo> channelList;
std::list<ChannelInfo>::iterator it;
rsChannels->getChannelList(channelList);
std::list<std::string> keysAvailable;
std::list<std::string>::iterator keyIt;
rsChannels->getPubKeysAvailableGrpIds(keysAvailable);
/* get the ids for our lists */
QList<GroupItemInfo> adminList;
QList<GroupItemInfo> subList;
QList<GroupItemInfo> popList;
QList<GroupItemInfo> otherList;
std::multimap<uint32_t, GroupItemInfo> popMap;
for(it = channelList.begin(); it != channelList.end(); it++) {
/* sort it into Publish (Own), Subscribed, Popular and Other */
uint32_t flags = it->channelFlags;
GroupItemInfo groupItemInfo;
channelInfoToGroupItemInfo(*it, groupItemInfo);
if ((flags & RS_DISTRIB_ADMIN) && (flags & RS_DISTRIB_PUBLISH) && (flags & RS_DISTRIB_SUBSCRIBED)) {
adminList.push_back(groupItemInfo);
} else {
for (keyIt = keysAvailable.begin(); keyIt != keysAvailable.end(); keyIt++) {
if (it->channelId == *keyIt) {
/* Found Key, set title text to bold and colored blue */
groupItemInfo.privatekey = true;
break;
}
}
if ((flags & RS_DISTRIB_SUBSCRIBED) || ((flags & RS_DISTRIB_SUBSCRIBED) && (flags & RS_DISTRIB_PUBLISH)) ) {
subList.push_back(groupItemInfo);
} else {
/* rate the others by popularity */
popMap.insert(std::make_pair(it->pop, 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;
std::multimap<uint32_t, GroupItemInfo>::reverse_iterator rit;
for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) {
if (i < popCount) {
popList.push_back(rit->second);
i++;
} else {
otherList.push_back(rit->second);
}
}
/* now we have our lists ---> update entries */
treeWidget->fillGroupItems(ownChannels, adminList);
treeWidget->fillGroupItems(subcribedChannels, subList);
treeWidget->fillGroupItems(popularChannels, popList);
treeWidget->fillGroupItems(otherChannels, otherList);
updateMessageSummaryList("");
}
void ChannelFeed::channelMsgReadSatusChanged(const QString& channelId, const QString& /*msgId*/, int /*status*/)
{
updateMessageSummaryList(channelId.toStdString());
}
void ChannelFeed::updateMessageSummaryList(const std::string &channelId)
{
QTreeWidgetItem *items[2] = { ownChannels, subcribedChannels };
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);
std::string childId = treeWidget->itemId(childItem).toStdString();
if (childId.empty()) {
continue;
}
if (channelId.empty() || childId == channelId) {
/* Calculate unread messages */
unsigned int newMessageCount = 0;
unsigned int unreadMessageCount = 0;
rsChannels->getMessageCount(childId, newMessageCount, unreadMessageCount);
treeWidget->setUnreadCount(childItem, unreadMessageCount);
if (channelId.empty() == false) {
/* Calculate only this channel */
break;
}
}
}
}
}
static bool sortChannelMsgSummary(const ChannelMsgSummary &msg1, const ChannelMsgSummary &msg2)
{
return (msg1.ts > msg2.ts);
}
void ChannelFeed::updateChannelMsgs()
{
if (fillThread) {
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::updateChannelMsgs() stop current fill thread" << std::endl;
#endif
// stop current fill thread
ChannelFillThread *thread = fillThread;
fillThread = NULL;
thread->stop();
delete(thread);
progressLabel->hide();
progressBar->hide();
}
if (!rsChannels) {
return;
}
/* replace all the messages with new ones */
QList<ChanMsgItem *>::iterator mit;
for (mit = mChanMsgItems.begin(); mit != mChanMsgItems.end(); mit++) {
delete (*mit);
}
mChanMsgItems.clear();
QMenu *subscribemenu = new QMenu();
ChannelInfo ci;
if (!rsChannels->getChannelInfo(mChannelId, ci)) {
postButton->setEnabled(false);
nameLabel->setText(tr("No Channel Selected"));
logoLabel->setPixmap(QPixmap(":/images/channels.png"));
logoLabel->setEnabled(false);
subscribeButton->setEnabled(false);
subscribeButton->setPopupMode(QToolButton::InstantPopup);
subscribeButton->setMenu(NULL);
subscribeButton->setIcon(QIcon(""));
subscribeButton->setText(tr("Subscribe"));
return;
}
QPixmap chanImage;
if (ci.pngImageLen != 0) {
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
} else {
chanImage = QPixmap(CHAN_DEFAULT_IMAGE);
}
logoLabel->setPixmap(chanImage);
logoLabel->setEnabled(true);
/* set Channel name */
nameLabel->setText(QString::fromStdWString(ci.channelName));
if (ci.channelFlags & RS_DISTRIB_PUBLISH) {
postButton->setEnabled(true);
} else {
postButton->setEnabled(false);
}
if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED) {
actionEnable_Auto_Download->setEnabled(true);
subscribeButton->setEnabled(true);
subscribeButton->setPopupMode(QToolButton::MenuButtonPopup);
subscribeButton->setIcon(QIcon(":/images/accepted16.png"));
subscribeButton->setText(tr("Subscribed"));
//subscribemenu->addAction(autochannelAct );
subscribemenu->addSeparator();
subscribemenu->addAction(unsubscribechannelAct);
subscribeButton->setMenu(subscribemenu);
} else {
actionEnable_Auto_Download->setEnabled(false);
subscribeButton->setEnabled(true);
subscribeButton->setPopupMode(QToolButton::InstantPopup);
subscribeButton->setMenu(NULL);
subscribeButton->setIcon(QIcon(""));
subscribeButton->setText(tr("Subscribe"));
}
#ifdef USE_THREAD
progressLabel->show();
progressBar->reset();
progressBar->show();
// create fill thread
fillThread = new ChannelFillThread(this, mChannelId);
// connect thread
connect(fillThread, SIGNAL(finished()), this, SLOT(fillThreadFinished()), Qt::BlockingQueuedConnection);
connect(fillThread, SIGNAL(addMsg(QString,QString,int,int)), this, SLOT(fillThreadAddMsg(QString,QString,int,int)), Qt::BlockingQueuedConnection);
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::updateChannelMsgs() Start fill thread" << std::endl;
#endif
// start thread
fillThread->start();
#else
std::list<ChannelMsgSummary> msgs;
std::list<ChannelMsgSummary>::iterator it;
rsChannels->getChannelMsgList(mChannelId, msgs);
msgs.sort(sortChannelMsgSummary);
for (it = msgs.begin(); it != msgs.end(); it++) {
ChanMsgItem *cmi = new ChanMsgItem(this, 0, mChannelId, it->msgId, true);
mChanMsgItems.push_back(cmi);
verticalLayout_2->addWidget(cmi);
}
#endif
}
void ChannelFeed::fillThreadFinished()
{
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::fillThreadFinished()" << std::endl;
#endif
// thread has finished
ChannelFillThread *thread = dynamic_cast<ChannelFillThread*>(sender());
if (thread) {
if (thread == fillThread) {
// current thread has finished, hide progressbar and release thread
progressBar->hide();
progressLabel->hide();
fillThread = NULL;
}
#ifdef CHAN_DEBUG
if (thread->wasStopped()) {
// thread was stopped
std::cerr << "ChannelFeed::fillThreadFinished() Thread was stopped" << std::endl;
}
#endif
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::fillThreadFinished() Delete thread" << std::endl;
#endif
thread->deleteLater();
thread = NULL;
}
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::fillThreadFinished done()" << std::endl;
#endif
}
void ChannelFeed::fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count)
{
if (sender() == fillThread) {
// show fill progress
if (count) {
progressBar->setValue(current * progressBar->maximum() / count);
}
lockLayout(NULL, true);
ChanMsgItem *cmi = new ChanMsgItem(this, 0, channelId.toStdString(), channelMsgId.toStdString(), true);
mChanMsgItems.push_back(cmi);
verticalLayout->addWidget(cmi);
cmi->show();
lockLayout(cmi, false);
}
}
void ChannelFeed::unsubscribeChannel()
{
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::unsubscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels) {
rsChannels->channelSubscribe(mChannelId, false, false);
}
updateChannelMsgs();
}
void ChannelFeed::subscribeChannel()
{
#ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::subscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels) {
rsChannels->channelSubscribe(mChannelId, true, false);
}
updateChannelMsgs();
}
void ChannelFeed::showChannelDetails()
{
if (mChannelId.empty()) {
return;
}
if (!rsChannels) {
return;
}
ChannelDetails channelui (this);
channelui.showDetails(mChannelId);
channelui.exec();
}
void ChannelFeed::setAllAsReadClicked()
{
if (mChannelId.empty()) {
return;
}
if (!rsChannels) {
return;
}
ChannelInfo ci;
if (rsChannels->getChannelInfo(mChannelId, ci) == false) {
return;
}
if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED) {
std::list<ChannelMsgSummary> msgs;
std::list<ChannelMsgSummary>::iterator it;
rsChannels->getChannelMsgList(mChannelId, msgs);
for(it = msgs.begin(); it != msgs.end(); it++) {
rsChannels->setMessageStatus(mChannelId, it->msgId, CHANNEL_MSG_STATUS_READ, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER);
}
}
}
void ChannelFeed::toggleAutoDownload(){
if(mChannelId.empty())
return;
bool autoDl = true;
if(rsChannels->channelGetAutoDl(mChannelId, autoDl)){
// if auto dl is set true, then set false
if(autoDl){
rsChannels->channelSetAutoDl(mChannelId, false);
}else{
rsChannels->channelSetAutoDl(mChannelId, true);
}
setAutoDownloadButton(!autoDl);
}
else{
std::cerr << "Auto Download failed to set"
<< std::endl;
}
}
bool ChannelFeed::navigate(const std::string& channelId, const std::string& msgId)
{
if (channelId.empty()) {
return false;
}
if (treeWidget->activateId(QString::fromStdString(channelId), msgId.empty()) == NULL) {
return false;
}
/* Messages are filled in selectChannel */
if (mChannelId != channelId) {
return false;
}
if (msgId.empty()) {
return true;
}
//update channel thread
updateChannelMsgs();
//Waiting thread finished
time_t now=time(NULL);
while(fillThread && ((now+300)>time(NULL)))
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
/* Search exisiting item */
QList<ChanMsgItem*>::iterator mit;
for (mit = mChanMsgItems.begin(); mit != mChanMsgItems.end(); mit++) {
ChanMsgItem *item = *mit;
if (item->msgId() == msgId) {
// the next two lines are necessary to calculate the layout of the widgets in the scroll area (maybe there is a better solution)
item->show();
QCoreApplication::processEvents();
scrollArea->ensureWidgetVisible(item, 0, 0);
return true;
}
}
return false;
}
void ChannelFeed::setAutoDownloadButton(bool autoDl)
{
if (autoDl) {
actionEnable_Auto_Download->setText(tr("Disable Auto-Download"));
}else{
actionEnable_Auto_Download->setText(tr("Enable Auto-Download"));
}
}
void ChannelFeed::generateMassData()
{
#ifdef CHAN_DEBUG
if (mChannelId.empty ()) {
return;
}
if (QMessageBox::question(this, "Generate mass data", "Do you really want to generate mass data ?", QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
return;
}
for (int thread = 1; thread < 1000; thread++) {
ChannelMsgInfo msgInfo;
msgInfo.channelId = mChannelId;
msgInfo.subject = QString("Test %1").arg(thread, 3, 10, QChar('0')).toStdWString();
msgInfo.msg = QString("That is only a test").toStdWString();
if (rsChannels->ChannelMessageSend(msgInfo) == false) {
return;
}
}
#endif
}
// ForumsFillThread
ChannelFillThread::ChannelFillThread(ChannelFeed *parent, const std::string &channelId)
: QThread(parent)
{
stopped = false;
this->channelId = channelId;
}
ChannelFillThread::~ChannelFillThread()
{
#ifdef CHAN_DEBUG
std::cerr << "ChannelFillThread::~ChannelFillThread" << std::endl;
#endif
}
void ChannelFillThread::stop()
{
disconnect();
stopped = true;
QApplication::processEvents();
wait();
}
void ChannelFillThread::run()
{
#ifdef CHAN_DEBUG
std::cerr << "ChannelFillThread::run()" << std::endl;
#endif
std::list<ChannelMsgSummary> msgs;
std::list<ChannelMsgSummary>::iterator it;
rsChannels->getChannelMsgList(channelId, msgs);
msgs.sort(sortChannelMsgSummary);
int count = msgs.size();
int pos = 0;
for (it = msgs.begin(); it != msgs.end(); it++) {
if (stopped) {
break;
}
emit addMsg(QString::fromStdString(channelId), QString::fromStdString(it->msgId), ++pos, count);
}
#ifdef CHAN_DEBUG
std::cerr << "ChannelFillThread::run() stopped: " << (wasStopped() ? "yes" : "no") << std::endl;
#endif
}

View file

@ -1,144 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _CHANNEL_FEED_DIALOG_H
#define _CHANNEL_FEED_DIALOG_H
#include <retroshare/rschannels.h>
#include <QStandardItemModel>
#include <QThread>
#include <map>
#include "mainpage.h"
#include "RsAutoUpdatePage.h"
#include "ui_ChannelFeed.h"
#include "gui/feeds/FeedHolder.h"
class ChanMsgItem;
class QTreeWidgetItem;
class ChannelFillThread;
class ChannelFeed : public RsAutoUpdatePage, public FeedHolder, private Ui::ChannelFeed
{
Q_OBJECT
public:
/** Default Constructor */
ChannelFeed(QWidget *parent = 0);
/** Default Destructor */
~ChannelFeed();
virtual UserNotify *getUserNotify(QObject *parent);
/* FeedHolder */
virtual QScrollArea *getScrollArea();
virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void openChat(std::string peerId);
virtual void openComments(uint32_t /*type*/ , const RsGxsGroupId & /*grpId */, const RsGxsMessageId & /*msgId*/, const QString & /*title */);
bool navigate(const std::string& channelId, const std::string& msgId);
/* overloaded from RsAuthUpdatePage */
virtual void updateDisplay();
private slots:
void channelListCustomPopupMenu( QPoint point );
void selectChannel(const QString &id);
void createChannel();
void subscribeChannel();
void unsubscribeChannel();
void setAllAsReadClicked();
void toggleAutoDownload();
void createMsg();
void showChannelDetails();
void restoreChannelKeys();
void editChannelDetail();
void shareKey();
void copyChannelLink();
void setDestinationDirectory();
void chooseDestinationDirectory();
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
void generateMassData();
void fillThreadFinished();
void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
private:
void updateChannelList();
void updateChannelMsgs();
void updateMessageSummaryList(const std::string &channelId);
void processSettings(bool load);
void setAutoDownloadButton(bool autoDl);
std::string mChannelId; /* current Channel */
/* Layout Pointers */
QBoxLayout *mMsgLayout;
QList<ChanMsgItem *> mChanMsgItems;
std::map<std::string, uint32_t> mChanSearchScore; //chanId, score
QTreeWidgetItem *ownChannels;
QTreeWidgetItem *subcribedChannels;
QTreeWidgetItem *popularChannels;
QTreeWidgetItem *otherChannels;
ChannelFillThread *fillThread;
/** Defines the actions for the context menu */
QAction* unsubscribechannelAct;
};
class ChannelFillThread : public QThread
{
Q_OBJECT
public:
ChannelFillThread(ChannelFeed *parent, const std::string &channelId);
~ChannelFillThread();
void run();
void stop();
bool wasStopped() { return stopped; }
signals:
void addMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
public:
std::string channelId;
private:
volatile bool stopped;
};
#endif

View file

@ -1,336 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChannelFeed</class>
<widget class="QWidget" name="ChannelFeed">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>681</width>
<height>476</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QFrame" name="titleBarFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="titleBarPixmap">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/channels32.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="titleBarLabel">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Channels</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="helpButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/64px_help.png</normaloff>:/images/64px_help.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="GroupTreeWidget" name="treeWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="headFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="margin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="logoLabel">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/channels.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="nameLabel">
<property name="palette">
<palette>
<active/>
<inactive/>
<disabled/>
</palette>
</property>
<property name="font">
<font>
<pointsize>21</pointsize>
</font>
</property>
<property name="text">
<string notr="true">Channel Name</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="toolBarFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>2</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>314</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="subscribeButton">
<property name="text">
<string>Subscribe</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="postButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Post to Channel</string>
</property>
<property name="text">
<string>Post</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/mail_send.png</normaloff>:/images/mail_send.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="progressLayout">
<item>
<widget class="QLabel" name="progressLabel">
<property name="text">
<string>Loading</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>534</width>
<height>16</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
<action name="actionsetAllAsRead">
<property name="text">
<string>Set all as read</string>
</property>
<property name="toolTip">
<string>Set all as read</string>
</property>
</action>
<action name="actionEnable_Auto_Download">
<property name="text">
<string>Enable Auto-Download</string>
</property>
<property name="toolTip">
<string>Enable Auto-Download</string>
</property>
</action>
<zorder>splitter</zorder>
<zorder>titleBarFrame</zorder>
</widget>
<customwidgets>
<customwidget>
<class>GroupTreeWidget</class>
<extends>QWidget</extends>
<header>gui/common/GroupTreeWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -65,7 +65,7 @@ CirclesDialog::CirclesDialog(QWidget *parent)
mStateHelper->addWidget(CIRCLESDIALOG_GROUPMETA, ui.treeWidget_friends, UISTATE_ACTIVE_ENABLED);
mStateHelper->addWidget(CIRCLESDIALOG_GROUPMETA, ui.treeWidget_category, UISTATE_ACTIVE_ENABLED);
mStateHelper->setWidgetEnabled(ui.pushButton_editCircle, false); // not implemented
mStateHelper->setWidgetEnabled(ui.pushButton_editCircle, false);
/* Connect signals */
connect(ui.pushButton_extCircle, SIGNAL(clicked()), this, SLOT(createExternalCircle()));
@ -121,12 +121,18 @@ void CirclesDialog::createPersonalCircle()
void CirclesDialog::editExistingCircle()
{
#if 0
std::string id;
QTreeWidgetItem *item = ui.treeWidget_membership->currentItem();
if ((!item) || (!item->parent()))
{
return;
}
QString coltext = item->text(CIRCLEGROUP_CIRCLE_COL_GROUPID);
std::string id = coltext.toStdString();
CreateCircleDialog dlg;
dlg.editExistingId(id);
dlg.exec();
#endif
}
void CirclesDialog::reloadAll()
@ -357,6 +363,7 @@ void CirclesDialog::circle_selected()
if ((!item) || (!item->parent()))
{
mStateHelper->setWidgetEnabled(ui.pushButton_editCircle, false);
return;
}
@ -385,6 +392,7 @@ void CirclesDialog::circle_selected()
{
set_tree_background(ui.treeWidget_friends, GRAY_BACKGROUND);
}
mStateHelper->setWidgetEnabled(ui.pushButton_editCircle, true);
}
void CirclesDialog::friend_selected()

View file

@ -79,7 +79,7 @@ CreateCircleDialog::CreateCircleDialog()
mIsExternalCircle = true;
ui.idChooser->loadIds(0,"");
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL);
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, "");
}
CreateCircleDialog::~CreateCircleDialog()
@ -92,22 +92,10 @@ void CreateCircleDialog::editExistingId(std::string circleId)
{
/* load this circle */
mIsExistingCircle = true;
/* setup personal or external circle */
bool isExternal = false;
if (isExternal)
{
setupForExternalCircle();
}
else
{
setupForPersonalCircle();
}
/* lock stuff they cannot edit */
requestCircle(circleId);
}
void CreateCircleDialog::editNewId(bool isExternal)
{
/* load this circle */
@ -179,7 +167,15 @@ void CreateCircleDialog::addMember()
}
/* check that its not there already */
QString keyId = item->text(RSCIRCLEID_COL_KEYID);
QString keyId = item->text(RSCIRCLEID_COL_KEYID);
QString idtype = item->text(RSCIRCLEID_COL_IDTYPE);
QString nickname = item->text(RSCIRCLEID_COL_NICKNAME);
addMember(keyId, idtype, nickname);
}
void CreateCircleDialog::addMember(const QString& keyId, const QString& idtype, const QString& nickname )
{
QTreeWidget *tree = ui.treeWidget_membership;
int count = tree->topLevelItemCount();
@ -195,9 +191,9 @@ void CreateCircleDialog::addMember()
}
QTreeWidgetItem *member = new QTreeWidgetItem();
member->setText(RSCIRCLEID_COL_NICKNAME, item->text(RSCIRCLEID_COL_NICKNAME));
member->setText(RSCIRCLEID_COL_KEYID, item->text(RSCIRCLEID_COL_KEYID));
member->setText(RSCIRCLEID_COL_IDTYPE, item->text(RSCIRCLEID_COL_IDTYPE));
member->setText(RSCIRCLEID_COL_NICKNAME, nickname);
member->setText(RSCIRCLEID_COL_KEYID, keyId);
member->setText(RSCIRCLEID_COL_IDTYPE, idtype);
tree->addTopLevelItem(member);
}
@ -352,6 +348,58 @@ void CreateCircleDialog::createCircle()
close();
}
void CreateCircleDialog::updateCircleGUI()
{
std::cerr << "CreateCircleDialog::updateCircleGUI()";
std::cerr << std::endl;
ui.circleName->setText(QString::fromUtf8(mCircleGroup.mMeta.mGroupName.c_str()));
bool isExternal = true;
switch(mCircleGroup.mMeta.mCircleType)
{
case GXS_CIRCLE_TYPE_LOCAL:
isExternal = false;
break;
case GXS_CIRCLE_TYPE_PUBLIC:
ui.radioButton_Public->setChecked(true);
break;
case GXS_CIRCLE_TYPE_EXT_SELF:
case GXS_CIRCLE_TYPE_EXTERNAL:
if (mCircleGroup.mMeta.mCircleId == mCircleGroup.mMeta.mGroupId)
{
ui.radioButton_Self->setChecked(true);
}
else
{
ui.radioButton_Restricted->setChecked(true);
}
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, mCircleGroup.mMeta.mCircleId);
break;
default:
std::cerr << "CreateCircleDialog::updateCircleGUI() INVALID mCircleType";
std::cerr << std::endl;
break;
}
// set preferredId.
ui.idChooser->loadIds(0,mCircleGroup.mMeta.mAuthorId);
/* setup personal or external circle */
if (isExternal)
{
setupForExternalCircle();
}
else
{
setupForPersonalCircle();
}
}
void CreateCircleDialog::requestCircle(const RsGxsGroupId &groupId)
{
RsTokReqOptions opts;
@ -397,7 +445,8 @@ void CreateCircleDialog::loadCircle(uint32_t token)
std::cerr << "CreateCircleDialog::loadCircle() Unfinished Loading";
std::cerr << std::endl;
//mCircleGroup = groups[0];
mCircleGroup = groups[0];
updateCircleGUI();
}
void CreateCircleDialog::getPgpIdentities()
@ -408,24 +457,38 @@ void CreateCircleDialog::getPgpIdentities()
QTreeWidget *tree = ui.treeWidget_IdList;
tree->clear();
std::list<std::string> ids;
std::list<std::string>::iterator it;
rsPeers->getGPGAcceptedList(ids);
for(it = ids.begin(); it != ids.end(); it++)
{
QTreeWidgetItem *item = new QTreeWidgetItem();
RsPeerDetails details;
rsPeers->getGPGDetails(*it, details);
item->setText(RSCIRCLEID_COL_IDTYPE, "PGP Identity");
item->setText(RSCIRCLEID_COL_NICKNAME, QString::fromUtf8(details.name.c_str()));
item->setText(RSCIRCLEID_COL_KEYID, QString::fromStdString(details.gpg_id));
QString keyId = QString::fromStdString(details.gpg_id);
QString nickname = QString::fromUtf8(details.name.c_str());
QString idtype = tr("PGP Identity");
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(RSCIRCLEID_COL_NICKNAME, nickname);
item->setText(RSCIRCLEID_COL_KEYID, keyId);
item->setText(RSCIRCLEID_COL_IDTYPE, idtype);
tree->addTopLevelItem(item);
// Local Circle.
if (mIsExistingCircle)
{
// check if its in the circle.
std::list<RsPgpId>::const_iterator it;
it = std::find(mCircleGroup.mLocalFriends.begin(), mCircleGroup.mLocalFriends.end(), details.gpg_id);
if (it != mCircleGroup.mLocalFriends.end())
{
/* found it */
addMember(keyId, idtype, nickname);
}
}
}
filterIds();
@ -494,27 +557,44 @@ void CreateCircleDialog::loadIdentities(uint32_t token)
continue;
}
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(RSCIRCLEID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str()));
item->setText(RSCIRCLEID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId));
QString keyId = QString::fromStdString(data.mMeta.mGroupId);
QString nickname = QString::fromUtf8(data.mMeta.mGroupName.c_str());
QString idtype = tr("Anon Id");
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
{
if (data.mPgpKnown)
{
RsPeerDetails details;
rsPeers->getGPGDetails(data.mPgpId, details);
item->setText(RSCIRCLEID_COL_IDTYPE, QString::fromUtf8(details.name.c_str()));
idtype = QString::fromUtf8(details.name.c_str());
}
else
{
item->setText(RSCIRCLEID_COL_IDTYPE, "PGP Linked Id");
idtype = tr("PGP Linked Id");
}
}
else
{
item->setText(RSCIRCLEID_COL_IDTYPE, "Anon Id");
}
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(RSCIRCLEID_COL_NICKNAME, nickname);
item->setText(RSCIRCLEID_COL_KEYID, keyId);
item->setText(RSCIRCLEID_COL_IDTYPE, idtype);
tree->addTopLevelItem(item);
// External Circle.
if (mIsExistingCircle)
{
// check if its in the circle.
std::list<RsGxsId>::const_iterator it;
it = std::find(mCircleGroup.mInvitedMembers.begin(),
mCircleGroup.mInvitedMembers.end(), data.mMeta.mGroupId);
if (it != mCircleGroup.mInvitedMembers.end())
{
/* found it */
addMember(keyId, idtype, nickname);
}
}
}
}

View file

@ -55,6 +55,10 @@ private slots:
void filterChanged(const QString &text);
private:
void updateCircleGUI();
void addMember(const QString& keyId, const QString& idtype, const QString& nickname );
void setupForPersonalCircle();
void setupForExternalCircle();
@ -73,6 +77,8 @@ private:
TokenQueue *mCircleQueue;
TokenQueue *mIdQueue;
RsGxsCircleGroup mCircleGroup; // for editting existing Circles.
/** Qt Designer generated object */
Ui::CreateCircleDialog ui;
};

View file

@ -64,9 +64,10 @@
/****
* #define SHOW_RTT_STATISTICS 1
****/
#define SHOW_RTT_STATISTICS 1
#ifdef SHOW_RTT_STATISTICS
#include "VoipStatistics.h"
#include "gui/RttStatistics.h"
#endif
/* Images for context menu icons */
@ -337,6 +338,10 @@ TransfersDialog::TransfersDialog(QWidget *parent)
ui.tabWidget->addTab(localSharedFiles = new LocalSharedFilesDialog(), QIcon(IMAGE_MYFILES), tr("My files")) ;
#ifdef SHOW_RTT_STATISTICS
ui.tabWidget->addTab( new RttStatistics(), tr("RTT Statistics")) ;
#endif
//ui.tabWidget->addTab( new TurtleRouterStatistics(), tr("Router Statistics")) ;
//ui.tabWidget->addTab( new TurtleRouterDialog(), tr("Router Requests")) ;
@ -903,7 +908,7 @@ void TransfersDialog::setDestinationDirectory()
}
}
int TransfersDialog::addItem(int row, const FileInfo &fileInfo, const std::map<std::string, std::string> &versions)
int TransfersDialog::addItem(int row, const FileInfo &fileInfo)
{
QString fileHash = QString::fromStdString(fileInfo.hash);
double fileDlspeed = (fileInfo.downloadStatus == FT_STATE_DOWNLOADING) ? (fileInfo.tfRate * 1024.0) : 0.0;
@ -1031,8 +1036,10 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo, const std::map<s
//unique combination: fileHash + peerId, variant: hash + peerName (too long)
QString hashFileAndPeerId = fileHash + QString::fromStdString(transferInfo.peerId);
QString version;
if (versions.end() != (vit = versions.find(transferInfo.peerId))) {
version = tr("version: ") + QString::fromStdString(vit->second);
std::string rsversion;
if (rsDisc->getPeerVersion(transferInfo.peerId, rsversion))
{
version = tr("version: ") + QString::fromStdString(rsversion);
}
double peerDlspeed = 0;
@ -1228,10 +1235,6 @@ void TransfersDialog::insertTransfers()
std::list<std::string> downHashes;
rsFiles->FileDownloads(downHashes);
/* get only once */
std::map<std::string, std::string> versions;
rsDisc->getDiscVersions(versions);
/* build set for quick search */
std::set<std::string> hashs;
std::list<std::string>::iterator it;
@ -1272,7 +1275,7 @@ void TransfersDialog::insertTransfers()
hashs.erase(hashIt);
if (addItem(row, fileInfo, versions) < 0) {
if (addItem(row, fileInfo) < 0) {
DLListModel->removeRow(row);
rowCount = DLListModel->rowCount();
continue;
@ -1294,7 +1297,7 @@ void TransfersDialog::insertTransfers()
continue;
}
addItem(-1, fileInfo, versions);
addItem(-1, fileInfo);
}
ui.downloadList->setSortingEnabled(true);

View file

@ -236,7 +236,7 @@ private:
public slots:
// these two functions add entries to the transfers dialog, and return the row id of the entry modified/added
//
int addItem(int row, const FileInfo &fileInfo, const std::map<std::string, std::string> &versions);
int addItem(int row, const FileInfo &fileInfo);
int addPeerToItem(QStandardItem *dlItem, const QString& name, const QString& coreID, double dlspeed, uint32_t status, const FileProgressInfo& peerInfo);
int addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources,const QString& source_id, const QString& status, qlonglong completed, qlonglong remaining);

File diff suppressed because it is too large Load diff

View file

@ -1,217 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _FORUMSDIALOG_H
#define _FORUMSDIALOG_H
#include <QThread>
#include "mainpage.h"
#include "RsAutoUpdatePage.h"
#include "ui_ForumsDialog.h"
class ForumInfo;
class ForumsFillThread;
class ForumMsgInfo;
class RSTreeWidgetItemCompareRole;
class ForumsDialog : public RsAutoUpdatePage
{
Q_OBJECT
Q_PROPERTY(QColor textColorRead READ textColorRead WRITE setTextColorRead)
Q_PROPERTY(QColor textColorUnread READ textColorUnread WRITE setTextColorUnread)
Q_PROPERTY(QColor textColorUnreadChildren READ textColorUnreadChildren WRITE setTextColorUnreadChildren)
Q_PROPERTY(QColor textColorNotSubscribed READ textColorNotSubscribed WRITE setTextColorNotSubscribed)
Q_PROPERTY(QColor textColorMissing READ textColorMissing WRITE setTextColorMissing)
public:
ForumsDialog(QWidget *parent = 0);
~ForumsDialog();
virtual UserNotify *getUserNotify(QObject *parent);
bool navigate(const std::string& forumId, const std::string& msgId);
/* overloaded from RsAuthUpdatePage */
virtual void updateDisplay();
static QString titleFromInfo(ForumMsgInfo &msgInfo);
static QString messageFromInfo(ForumMsgInfo &msgInfo);
QColor textColorRead() const { return mTextColorRead; }
QColor textColorUnread() const { return mTextColorUnread; }
QColor textColorUnreadChildren() const { return mTextColorUnreadChildren; }
QColor textColorNotSubscribed() const { return mTextColorNotSubscribed; }
QColor textColorMissing() const { return mTextColorMissing; }
void setTextColorRead(QColor color) { mTextColorRead = color; }
void setTextColorUnread(QColor color) { mTextColorUnread = color; }
void setTextColorUnreadChildren(QColor color) { mTextColorUnreadChildren = color; }
void setTextColorNotSubscribed(QColor color) { mTextColorNotSubscribed = color; }
void setTextColorMissing(QColor color) { mTextColorMissing = color; }
protected:
bool eventFilter(QObject *obj, QEvent *ev);
void changeEvent(QEvent *e);
private slots:
/** Create the context popup menu and it's submenus */
void forumListCustomPopupMenu( QPoint point );
void threadListCustomPopupMenu( QPoint point );
void restoreForumKeys();
void newforum();
void changedForum(const QString &id);
void changedThread();
void clickedThread (QTreeWidgetItem *item, int column);
void forumMsgReadSatusChanged(const QString &forumId, const QString &msgId, int status);
void replytomessage();
//void print();
//void printpreview();
//void removemessage();
void markMsgAsRead();
void markMsgAsReadChildren();
void markMsgAsReadAll();
void markMsgAsUnread();
void markMsgAsUnreadAll();
void markMsgAsUnreadChildren();
void copyForumLink();
void copyMessageLink();
/* handle splitter */
void togglethreadview();
void createthread();
void createmessage();
void subscribeToForum();
void unsubscribeToForum();
void showForumDetails();
void editForumDetails();
void previousMessage ();
void nextMessage ();
void nextUnreadMessage();
void downloadAllFiles();
void changedViewBox();
void filterColumnChanged(int column);
void filterItems(const QString &text);
void generateMassData();
void fillThreadFinished();
void fillThreadProgress(int current, int count);
void shareKey();
void loadImagesAlways();
void threadTitle_elisionChanged(bool elided);
private:
void insertForums();
void insertThreads();
void insertPost();
void updateMessageSummaryList(std::string forumId);
void forumInfoToGroupItemInfo(const ForumInfo &forumInfo, GroupItemInfo &groupItemInfo);
void forumSubscribe(bool subscribe);
void FillThreads(QList<QTreeWidgetItem *> &ThreadList, bool bExpandNewMessages, QList<QTreeWidgetItem*> &itemToExpand);
void FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent, bool bExpandNewMessages, QList<QTreeWidgetItem*> &itemToExpand);
int getSelectedMsgCount(QList<QTreeWidgetItem*> *pRows, QList<QTreeWidgetItem*> *pRowsRead, QList<QTreeWidgetItem*> *pRowsUnread);
void setMsgAsReadUnread(QList<QTreeWidgetItem*> &Rows, bool bRead);
void markMsgAsReadUnread(bool bRead, bool bChildren, bool bForum);
void CalculateIconsAndFonts(QTreeWidgetItem *pItem = NULL);
void CalculateIconsAndFonts(QTreeWidgetItem *pItem, bool &bHasReadChilddren, bool &bHasUnreadChilddren);
void processSettings(bool bLoad);
void togglethreadview_internal();
bool filterItem(QTreeWidgetItem *pItem, const QString &text, int filterColumn);
bool m_bProcessSettings;
bool inMsgAsReadUnread;
QTreeWidgetItem *yourForums;
QTreeWidgetItem *subscribedForums;
QTreeWidgetItem *popularForums;
QTreeWidgetItem *otherForums;
RSTreeWidgetItemCompareRole *threadCompareRole;
std::string mCurrForumId;
std::string mCurrThreadId;
int subscribeFlags;
int lastViewType;
std::string lastForumID;
ForumsFillThread *fillThread;
/* Color definitions (for standard see qss.default) */
QColor mTextColorRead;
QColor mTextColorUnread;
QColor mTextColorUnreadChildren;
QColor mTextColorNotSubscribed;
QColor mTextColorMissing;
/** Qt Designer generated object */
Ui::ForumsDialog ui;
};
class ForumsFillThread : public QThread
{
Q_OBJECT
public:
ForumsFillThread(ForumsDialog *parent);
~ForumsFillThread();
void run();
void stop();
bool wasStopped() { return stopped; }
signals:
void progress(int current, int count);
public:
std::string forumId;
int filterColumn;
int subscribeFlags;
bool fillComplete;
int viewType;
bool expandNewMessages;
std::string focusMsgId;
RSTreeWidgetItemCompareRole *compareRole;
QList<QTreeWidgetItem*> items;
QList<QTreeWidgetItem*> itemToExpand;
private:
volatile bool stopped;
};
#endif

View file

@ -1,624 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ForumsDialog</class>
<widget class="QWidget" name="ForumsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>769</width>
<height>519</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="titleBarFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="titleBarPixmap">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/konversation.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="titleBarLabel">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Forums</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>123</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="helpButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/64px_help.png</normaloff>:/images/64px_help.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="GroupTreeWidget" name="forumTreeWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<widget class="QSplitter" name="threadSplitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="toolBarFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QToolButton" name="newthreadButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Start new Thread for Selected Forum</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/mail_new.png</normaloff>:/images/mail_new.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="newmessageButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Reply Message</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/mail_reply.png</normaloff>:/images/mail_reply.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="LineEditClear" name="filterLineEdit"/>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_17">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Forum:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="forumName">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="viewBox">
<item>
<property name="text">
<string>Last Post</string>
</property>
</item>
<item>
<property name="text">
<string>Threaded View</string>
</property>
</item>
<item>
<property name="text">
<string>Flat View</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="threadTreeWidget">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Title</string>
</property>
</column>
<column>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/message-state-header.png</normaloff>:/images/message-state-header.png</iconset>
</property>
</column>
<column>
<property name="text">
<string>Date</string>
</property>
</column>
<column>
<property name="text">
<string>Author</string>
</property>
</column>
<column>
<property name="text">
<string>Signed</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="progressBarLayOut">
<item>
<widget class="QLabel" name="progLayOutTxt">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Loading</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout">
<item row="0" column="1">
<widget class="QLabel" name="threadlabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Thread:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="ElidedLabel" name="threadTitle">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="previousButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Previous Thread</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/back.png</normaloff>:/images/back.png</iconset>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="nextButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Next Thread</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/forward.png</normaloff>:/images/forward.png</iconset>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QPushButton" name="expandButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/edit_remove24.png</normaloff>:/images/edit_remove24.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QPushButton" name="downloadButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Download all files</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/down.png</normaloff>:/images/down.png</iconset>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="nextUnreadButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Next unread</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QFrame" name="postFrame">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="RSImageBlockWidget" name="imageBlockWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="RSTextBrowser" name="postText">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
</layout>
<action name="actionPrint">
<property name="text">
<string>Print</string>
</property>
</action>
<action name="actionPrintPreview">
<property name="text">
<string>PrintPreview</string>
</property>
</action>
<zorder>splitter</zorder>
<zorder>titleBarFrame</zorder>
</widget>
<customwidgets>
<customwidget>
<class>RSTextBrowser</class>
<extends>QTextBrowser</extends>
<header>gui/common/RSTextBrowser.h</header>
</customwidget>
<customwidget>
<class>RSImageBlockWidget</class>
<extends>QWidget</extends>
<header>gui/common/RSImageBlockWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GroupTreeWidget</class>
<extends>QWidget</extends>
<header>gui/common/GroupTreeWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
<customwidget>
<class>ElidedLabel</class>
<extends>QLabel</extends>
<header location="global">gui/common/ElidedLabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -495,7 +495,7 @@ void FriendsDialog::insertChat()
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
QString name = QString::fromUtf8(rsPeers->getPeerName(it->rsid).c_str());
QString msg = QString::fromStdWString(it->msg);
QString msg = QString::fromUtf8(it->msg.c_str());
#ifdef FRIENDS_DEBUG
std::cerr << "FriendsDialog::insertChat(): " << msg.toStdString() << std::endl;
@ -566,7 +566,7 @@ void FriendsDialog::sendMsg()
QString text;
RsHtml::optimizeHtml(lineWidget, text);
std::wstring message = text.toStdWString();
std::string message = text.toUtf8().constData();
#ifdef FRIENDS_DEBUG
std::string msg(message.begin(), message.end());

View file

@ -119,6 +119,7 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent)
ui.headerFrame->setHeaderText(tr("Create a new Identity"));
connect(ui.new_gpg_key_checkbox, SIGNAL(clicked()), this, SLOT(newGPGKeyGenUiSetup()));
connect(ui.hidden_checkbox, SIGNAL(clicked()), this, SLOT(hiddenUiSetup()));
connect(ui.genButton, SIGNAL(clicked()), this, SLOT(genPerson()));
connect(ui.importIdentity_PB, SIGNAL(clicked()), this, SLOT(importIdentity()));
@ -181,12 +182,12 @@ void GenCertDialog::init()
std::list<std::string>::iterator it;
bool foundGPGKeys = false;
if (!mOnlyGenerateIdentity) {
if (RsInit::GetPGPLogins(pgpIds)) {
if (RsAccounts::GetPGPLogins(pgpIds)) {
for(it = pgpIds.begin(); it != pgpIds.end(); it++)
{
QVariant userData(QString::fromStdString(*it));
std::string name, email;
RsInit::GetPGPLoginDetails(*it, name, email);
RsAccounts::GetPGPLoginDetails(*it, name, email);
std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl;
QString gid = QString::fromStdString(*it).right(8) ;
ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")", userData);
@ -225,6 +226,7 @@ void GenCertDialog::init()
ui.header_label->setText(text);
newGPGKeyGenUiSetup();
hiddenUiSetup();
}
void GenCertDialog::mouseMoveEvent(QMouseEvent *e)
@ -278,6 +280,28 @@ void GenCertDialog::newGPGKeyGenUiSetup() {
}
}
void GenCertDialog::hiddenUiSetup()
{
if (ui.hidden_checkbox->isChecked())
{
ui.hiddenaddr_input->show();
ui.hiddenaddr_label->show();
ui.label_hiddenaddr2->show();
ui.hiddenport_label->show();
ui.hiddenport_spinBox->show();
}
else
{
ui.hiddenaddr_input->hide();
ui.hiddenaddr_label->hide();
ui.label_hiddenaddr2->hide();
ui.hiddenport_label->hide();
ui.hiddenport_spinBox->hide();
}
}
void GenCertDialog::exportIdentity()
{
QString fname = QFileDialog::getSaveFileName(this,tr("Export Identity"), "",tr("RetroShare Identity files (*.asc)")) ;
@ -288,7 +312,7 @@ void GenCertDialog::exportIdentity()
QVariant data = ui.genPGPuser->itemData(ui.genPGPuser->currentIndex());
std::string gpg_id = data.toString().toStdString() ;
if(RsInit::exportIdentity(fname.toStdString(),gpg_id))
if(RsAccounts::ExportIdentity(fname.toStdString(),gpg_id))
QMessageBox::information(this,tr("Identity saved"),tr("Your identity was successfully saved\nIt is encrypted\n\nYou can now copy it to another computer\nand use the import button to load it")) ;
else
QMessageBox::information(this,tr("Identity not saved"),tr("Your identity was not saved. An error occurred.")) ;
@ -304,7 +328,7 @@ void GenCertDialog::importIdentity()
std::string gpg_id ;
std::string err_string ;
if(!RsInit::importIdentity(fname.toStdString(),gpg_id,err_string))
if(!RsAccounts::ImportIdentity(fname.toStdString(),gpg_id,err_string))
{
QMessageBox::information(this,tr("Identity not loaded"),tr("Your identity was not loaded properly:")+" \n "+QString::fromStdString(err_string)) ;
return ;
@ -313,7 +337,7 @@ void GenCertDialog::importIdentity()
{
std::string name,email ;
RsInit::GetPGPLoginDetails(gpg_id, name, email);
RsAccounts::GetPGPLoginDetails(gpg_id, name, email);
std::cerr << "Adding PGPUser: " << name << " id: " << gpg_id << std::endl;
QMessageBox::information(this,tr("New identity imported"),tr("Your identity was imported successfully:")+" \n"+"\nName :"+QString::fromStdString(name)+"\nemail: " + QString::fromStdString(email)+"\nKey ID: "+QString::fromStdString(gpg_id)+"\n\n"+tr("You can use it now to create a new location.")) ;
@ -327,6 +351,23 @@ void GenCertDialog::genPerson()
/* Check the data from the GUI. */
std::string genLoc = ui.location_input->text().toUtf8().constData();
std::string PGPId;
bool isHiddenLoc = false;
if (ui.hidden_checkbox->isChecked())
{
std::string hl = ui.hiddenaddr_input->text().toStdString();
uint16_t port = ui.hiddenport_spinBox->value();
if (!RsInit::SetHiddenLocation(hl, port)) /* parses it */
{
/* Message Dialog */
QMessageBox::warning(this,
tr("Invalid Hidden Location"),
tr("Please put in a valid address of the form: 31769173498.onion:7800"),
QMessageBox::Ok);
return;
}
isHiddenLoc = true;
}
if (!genNewGPGKey) {
if (genLoc.length() < 3) {
@ -394,7 +435,7 @@ void GenCertDialog::genPerson()
while(QAbstractEventDispatcher::instance()->processEvents(QEventLoop::AllEvents)) ;
std::string email_str = "" ;
RsInit::GeneratePGPCertificate(ui.name_input->text().toUtf8().constData(), email_str.c_str(), ui.password_input->text().toUtf8().constData(), PGPId, err_string);
RsAccounts::GeneratePGPCertificate(ui.name_input->text().toUtf8().constData(), email_str.c_str(), ui.password_input->text().toUtf8().constData(), PGPId, err_string);
setCursor(Qt::ArrowCursor) ;
}
@ -402,19 +443,19 @@ void GenCertDialog::genPerson()
//generate a random ssl password
std::string sslPasswd = RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()) ;
/* Initialise the PGP user first */
RsInit::SelectGPGAccount(PGPId);
/* GenerateSSLCertificate - selects the PGP Account */
//RsInit::SelectGPGAccount(PGPId);
std::string sslId;
std::cerr << "GenCertDialog::genPerson() Generating SSL cert with gpg id : " << PGPId << std::endl;
std::string err;
bool okGen = RsInit::GenerateSSLCertificate(PGPId, "", genLoc, "", sslPasswd, sslId, err);
bool okGen = RsAccounts::GenerateSSLCertificate(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err);
if (okGen)
{
/* complete the process */
RsInit::LoadPassword(sslId, sslPasswd);
if (Rshare::loadCertificate(sslId, false, PGPId)) {
RsInit::LoadPassword(sslPasswd);
if (Rshare::loadCertificate(sslId, false)) {
accept();
}
}

View file

@ -42,6 +42,7 @@ private slots:
void exportIdentity();
void newGPGKeyGenUiSetup();
void grabMouse();
void hiddenUiSetup();
private:
void init();

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>691</width>
<height>442</height>
<width>618</width>
<height>641</height>
</rect>
</property>
<property name="windowTitle">
@ -32,14 +32,26 @@
<height>30</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>0</number>
</property>
<item row="2" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>You can install retroshare on different locations using the same identity. For this, just export the selected identity, and import it on the new computer, then create a new location with it.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="no_gpg_key_label">
<property name="text">
<string>It looks like you don't own any profile (PGP keys). Please fill in the form below to create one, or import an existing profile.</string>
@ -49,7 +61,7 @@
</property>
</widget>
</item>
<item>
<item row="1" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0,0">
<property name="spacing">
<number>6</number>
@ -118,152 +130,204 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="genPGPuserlabel">
<property name="text">
<string>Use identity</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="name_label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="email_label">
<property name="text">
<string>Email</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="password_label">
<property name="toolTip">
<string>This Password is for PGP</string>
</property>
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="password_label_2">
<property name="toolTip">
<string>This Password is for PGP</string>
</property>
<property name="text">
<string>Password (check)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="location_label">
<property name="text">
<string>Location</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="genPGPuser">
<property name="toolTip">
<string>Your profile is associated with a PGP key. RetroShare currently ignores DSA keys.</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="name_input">
<property name="toolTip">
<string>Enter your nickname here</string>
</property>
<property name="maxLength">
<number>64</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="email_input">
<property name="toolTip">
<string>Be careful: this email will be visible to your friends and friends
<item row="2" column="0">
<widget class="QLabel" name="genPGPuserlabel">
<property name="text">
<string>Use identity</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="genPGPuser">
<property name="toolTip">
<string>Your profile is associated with a PGP key. RetroShare currently ignores DSA keys.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="name_label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QLineEdit" name="name_input">
<property name="toolTip">
<string>Enter your nickname here</string>
</property>
<property name="maxLength">
<number>64</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="email_label">
<property name="text">
<string>Email</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QLineEdit" name="email_input">
<property name="toolTip">
<string>Be careful: this email will be visible to your friends and friends
of your friends. This information is required by PGP, but to stay
anonymous, you can use a fake email.</string>
</property>
<property name="maxLength">
<number>64</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="password_input">
<property name="toolTip">
<string>Put a strong password here. This password protects your PGP key.</string>
</property>
<property name="inputMask">
<string/>
</property>
<property name="maxLength">
<number>1024</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="password_input_2">
<property name="toolTip">
<string>Put a strong password here. This password protects your PGP key.</string>
</property>
<property name="inputMask">
<string/>
</property>
<property name="maxLength">
<number>1024</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="location_input">
<property name="maxLength">
<number>64</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</property>
<property name="maxLength">
<number>64</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="entropy_label">
<item row="5" column="0">
<widget class="QLabel" name="password_label">
<property name="toolTip">
<string>This Password is for PGP</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;Before proceeding, move your mouse around to help Retroshare collect as much randomness as possible. Filling the progressbar to 20% is needed, 100% is advised.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Password</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="3">
<widget class="QLineEdit" name="password_input">
<property name="toolTip">
<string>Put a strong password here. This password protects your PGP key.</string>
</property>
<property name="inputMask">
<string/>
</property>
<property name="maxLength">
<number>1024</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="location_label">
<property name="text">
<string>Location</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="3">
<widget class="QLineEdit" name="location_input">
<property name="maxLength">
<number>64</number>
</property>
</widget>
</item>
<item row="7" column="1" colspan="3">
<widget class="QLabel" name="label_location2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="text">
<string>Put a meaningful location. ex : home, laptop, etc. This field will be used to differentiate different installations with the same identity (PGP key).</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="entropy_bar">
<property name="value">
<number>24</number>
<item row="8" column="0" colspan="4">
<widget class="QCheckBox" name="hidden_checkbox">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>Your profile is associated with a PGP key</string>
</property>
<property name="text">
<string>Create a Hidden Location.</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/contact_new128.png</normaloff>:/images/contact_new128.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<item row="9" column="0">
<widget class="QLabel" name="hiddenaddr_label">
<property name="text">
<string>Tor Address</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="hiddenaddr_input">
<property name="maxLength">
<number>64</number>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLabel" name="hiddenport_label">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item row="9" column="3">
<widget class="QSpinBox" name="hiddenport_spinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>7812</number>
</property>
</widget>
</item>
<item row="10" column="1" colspan="3">
<widget class="QLabel" name="label_hiddenaddr2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="text">
<string>This is a TOR Onion address of the form: xa76giaf6ifda7ri63i263.onion and your selected port, you must first launch TOR and create a new hidden service to generate this address.</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="1" colspan="3">
<widget class="QPushButton" name="genButton">
<property name="maximumSize">
<size>
@ -271,76 +335,41 @@ anonymous, you can use a fake email.</string>
<height>26</height>
</size>
</property>
<property name="font">
<font>
<family>Arial</family>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>Create new identity</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/contact_new.png</normaloff>:/images/contact_new.png</iconset>
</property>
</widget>
</item>
<item row="12" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="header_label">
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>RetroShare uses PGP keys for identity management.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="genprofileinfo_label">
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>You can install retroshare on different locations using the same identity. For this, just export the selected identity, and import it on the new computer, then create a new location with it.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="HeaderFrame" name="headerFrame">
<property name="styleSheet">
<string notr="true"/>
<widget class="QFrame" name="headerFrame">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>140</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@ -348,22 +377,71 @@ anonymous, you can use a fake email.</string>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QLabel" name="headerImage">
<property name="minimumSize">
<size>
<width>128</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/contact_new128.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="headerLayout">
<item>
<widget class="QLabel" name="headerLabel">
<property name="font">
<font>
<pointsize>16</pointsize>
</font>
</property>
<property name="text">
<string>Create a new Identity</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="headerLabel2">
<property name="text">
<string>RetroShare uses PGP keys for identity management.</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>genPGPuser</tabstop>
<tabstop>name_input</tabstop>
<tabstop>email_input</tabstop>
<tabstop>password_input</tabstop>
<tabstop>location_input</tabstop>
</tabstops>
<resources>

View file

@ -335,15 +335,7 @@ void GetStartedDialog::emailSupport()
{
RsAutoUpdatePage::lockAllEvents();
/* set retroshare version */
std::map<std::string, std::string>::iterator vit;
std::map<std::string, std::string> versions;
bool retv = rsDisc->getDiscVersions(versions);
std::string id = rsPeers->getOwnId();
if (retv && versions.end() != (vit = versions.find(id)))
{
versionString = vit->second;
}
rsDisc->getPeerVersion(rsPeers->getOwnId(), versionString);
userLevel = rsConfig->getUserLevel();
RsAutoUpdatePage::unlockAllEvents() ;

View file

@ -473,8 +473,7 @@ void IdDialog::insertIdDetails(uint32_t token)
mStateHelper->setWidgetEnabled(ui.toolButton_Reputation, false);
// No Delete Ids yet!
mStateHelper->setWidgetEnabled(ui.toolButton_Delete, /*true*/ false);
// No Editing Ids yet!
mStateHelper->setWidgetEnabled(ui.toolButton_EditId, /*true*/ false);
mStateHelper->setWidgetEnabled(ui.toolButton_EditId, true);
}
else
{

View file

@ -64,10 +64,19 @@ IdEditDialog::IdEditDialog(QWidget *parent)
/* Connect signals */
connect(ui.radioButton_GpgId, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
connect(ui.radioButton_Pseudo, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(updateId()));
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(submit()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect(ui.plainTextEdit_Tag, SIGNAL(textChanged()), this, SLOT(checkNewTag()));
connect(ui.pushButton_Tag, SIGNAL(clicked(bool)), this, SLOT(addRecognTag()));
connect(ui.toolButton_Tag1, SIGNAL(clicked(bool)), this, SLOT(rmTag1()));
connect(ui.toolButton_Tag2, SIGNAL(clicked(bool)), this, SLOT(rmTag2()));
connect(ui.toolButton_Tag3, SIGNAL(clicked(bool)), this, SLOT(rmTag3()));
connect(ui.toolButton_Tag4, SIGNAL(clicked(bool)), this, SLOT(rmTag4()));
connect(ui.toolButton_Tag5, SIGNAL(clicked(bool)), this, SLOT(rmTag5()));
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
ui.pushButton_Tag->setEnabled(false);
}
void IdEditDialog::setupNewId(bool pseudo)
@ -92,6 +101,10 @@ void IdEditDialog::setupNewId(bool pseudo)
// force - incase it wasn't triggered.
idTypeToggled(true);
ui.frame_Tags->setHidden(true);
ui.radioButton_GpgId->setEnabled(true);
ui.radioButton_Pseudo->setEnabled(true);
}
void IdEditDialog::idTypeToggled(bool checked)
@ -147,7 +160,6 @@ void IdEditDialog::loadExistingId(uint32_t token)
mStateHelper->setLoading(IDEDITDIALOG_LOADID, false);
/* get details from libretroshare */
RsGxsIdGroup data;
std::vector<RsGxsIdGroup> datavector;
if (!rsIdentity->getGroupData(token, datavector))
{
@ -169,9 +181,9 @@ void IdEditDialog::loadExistingId(uint32_t token)
return;
}
data = datavector[0];
mEditGroup = datavector[0];
bool realid = (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
bool realid = (mEditGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
if (realid)
{
@ -181,25 +193,28 @@ void IdEditDialog::loadExistingId(uint32_t token)
{
ui.radioButton_Pseudo->setChecked(true);
}
// these are not editable for existing Id.
ui.radioButton_GpgId->setEnabled(false);
ui.radioButton_Pseudo->setEnabled(false);
// DOES THIS TRIGGER ALREADY???
// force - incase it wasn't triggered.
idTypeToggled(true);
ui.lineEdit_Nickname->setText(QString::fromUtf8(data.mMeta.mGroupName.c_str()));
ui.lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId));
ui.lineEdit_Nickname->setText(QString::fromUtf8(mEditGroup.mMeta.mGroupName.c_str()));
ui.lineEdit_KeyId->setText(QString::fromStdString(mEditGroup.mMeta.mGroupId));
if (realid)
{
ui.lineEdit_GpgHash->setText(QString::fromStdString(data.mPgpIdHash));
ui.lineEdit_GpgHash->setText(QString::fromStdString(mEditGroup.mPgpIdHash));
if (data.mPgpKnown)
if (mEditGroup.mPgpKnown)
{
RsPeerDetails details;
rsPeers->getGPGDetails(data.mPgpId, details);
rsPeers->getGPGDetails(mEditGroup.mPgpId, details);
ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
ui.lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId));
ui.lineEdit_GpgId->setText(QString::fromStdString(mEditGroup.mPgpId));
}
else
{
@ -213,53 +228,216 @@ void IdEditDialog::loadExistingId(uint32_t token)
ui.lineEdit_GpgId->setText(tr("N/A"));
ui.lineEdit_GpgName->setText(tr("N/A"));
}
// RecognTags.
ui.frame_Tags->setHidden(false);
loadRecognTags();
}
void IdEditDialog::updateId()
#define MAX_RECOGN_TAGS 5
void IdEditDialog::checkNewTag()
{
RsGxsIdGroup rid;
// Must set, Nickname, KeyId(if existing), mIdType, GpgId.
std::string tag = ui.plainTextEdit_Tag->toPlainText().toStdString();
std::string id = ui.lineEdit_KeyId->text().toStdString();
std::string name = ui.lineEdit_Nickname->text().toUtf8().data();
rid.mMeta.mGroupName = ui.lineEdit_Nickname->text().toUtf8().constData();
QString desc;
bool ok = tagDetails(id, name, tag, desc);
ui.label_TagCheck->setText(desc);
if (rid.mMeta.mGroupName.size() < 2)
// hack to allow add invalid tags (for testing).
if (!tag.empty())
{
std::cerr << "IdEditDialog::updateId() Nickname too short";
ok = true;
}
if (mEditGroup.mRecognTags.size() >= MAX_RECOGN_TAGS)
{
ok = false;
}
ui.pushButton_Tag->setEnabled(ok);
}
void IdEditDialog::addRecognTag()
{
std::string tag = ui.plainTextEdit_Tag->toPlainText().toStdString();
if (mEditGroup.mRecognTags.size() >= MAX_RECOGN_TAGS)
{
std::cerr << "IdEditDialog::addRecognTag() Too many Tags, delete one first";
std::cerr << std::endl;
}
mEditGroup.mRecognTags.push_back(tag);
loadRecognTags();
}
void IdEditDialog::rmTag1()
{
rmTag(0);
}
void IdEditDialog::rmTag2()
{
rmTag(1);
}
void IdEditDialog::rmTag3()
{
rmTag(2);
}
void IdEditDialog::rmTag4()
{
rmTag(3);
}
void IdEditDialog::rmTag5()
{
rmTag(4);
}
void IdEditDialog::rmTag(int idx)
{
std::list<std::string>::iterator it;
int i = 0;
for(it = mEditGroup.mRecognTags.begin(); it != mEditGroup.mRecognTags.end() && (idx < i); it++, i++) ;
if (it != mEditGroup.mRecognTags.end())
{
mEditGroup.mRecognTags.erase(it);
}
loadRecognTags();
}
bool IdEditDialog::tagDetails(const std::string &id, const std::string &name, const std::string &tag, QString &desc)
{
if (tag.empty())
{
desc += "Empty Tag";
return false;
}
/* extract details for each tag */
RsRecognTagDetails tagDetails;
bool ok = false;
if (rsIdentity->parseRecognTag(id, name, tag, tagDetails))
{
desc += QString::number(tagDetails.tag_class);
desc += ":";
desc += QString::number(tagDetails.tag_type);
if (tagDetails.is_valid)
{
ok = true;
desc += " Valid";
}
else
{
desc += " Invalid";
}
if (tagDetails.is_pending)
{
ok = true;
desc += " Pending";
}
}
else
{
desc += "Unparseable";
}
return ok;
}
void IdEditDialog::loadRecognTags()
{
std::cerr << "IdEditDialog::loadRecognTags()";
std::cerr << std::endl;
// delete existing items.
ui.label_Tag1->setHidden(true);
ui.label_Tag2->setHidden(true);
ui.label_Tag3->setHidden(true);
ui.label_Tag4->setHidden(true);
ui.label_Tag5->setHidden(true);
ui.toolButton_Tag1->setHidden(true);
ui.toolButton_Tag2->setHidden(true);
ui.toolButton_Tag3->setHidden(true);
ui.toolButton_Tag4->setHidden(true);
ui.toolButton_Tag5->setHidden(true);
ui.plainTextEdit_Tag->setPlainText("");
int i = 0;
std::list<std::string>::const_iterator it;
for(it = mEditGroup.mRecognTags.begin(); it != mEditGroup.mRecognTags.end(); it++, i++)
{
QString recognTag;
tagDetails(mEditGroup.mMeta.mGroupId, mEditGroup.mMeta.mGroupName, *it, recognTag);
switch(i)
{
default:
case 0:
ui.label_Tag1->setText(recognTag);
ui.label_Tag1->setHidden(false);
ui.toolButton_Tag1->setHidden(false);
break;
case 1:
ui.label_Tag2->setText(recognTag);
ui.label_Tag2->setHidden(false);
ui.toolButton_Tag2->setHidden(false);
break;
case 2:
ui.label_Tag3->setText(recognTag);
ui.label_Tag3->setHidden(false);
ui.toolButton_Tag3->setHidden(false);
break;
case 3:
ui.label_Tag4->setText(recognTag);
ui.label_Tag4->setHidden(false);
ui.toolButton_Tag4->setHidden(false);
break;
case 4:
ui.label_Tag5->setText(recognTag);
ui.label_Tag5->setHidden(false);
ui.toolButton_Tag5->setHidden(false);
break;
}
}
}
void IdEditDialog::submit()
{
if (mIsNew)
{
createId();
}
else
{
updateId();
}
}
void IdEditDialog::createId()
{
std::string groupname = ui.lineEdit_Nickname->text().toUtf8().constData();
if (groupname.size() < 2)
{
std::cerr << "IdEditDialog::createId() Nickname too short";
std::cerr << std::endl;
return;
}
//rid.mIdType = RSID_RELATION_YOURSELF;
if (mIsNew)
{
rid.mMeta.mGroupId = "";
}
else
{
rid.mMeta.mGroupId = ui.lineEdit_KeyId->text().toStdString();
}
if (ui.radioButton_GpgId->isChecked())
{
//rid.mIdType |= RSID_TYPE_REALID;
//rid.mGpgId = ui.lineEdit_GpgId->text().toStdString();
rid.mPgpIdHash = ui.lineEdit_GpgHash->text().toStdString();
//rid.mGpgName = ui.lineEdit_GpgName->text().toUtf8().constData();
}
else
{
//rid.mIdType |= RSID_TYPE_PSEUDONYM;
//rid.mGpgId = "";
rid.mPgpIdHash = "";
//rid.mGpgName = "";
//rid.mGpgEmail = "";
}
// Can only create Identities for the moment!
RsIdentityParameters params;
params.nickname = rid.mMeta.mGroupName;
params.nickname = groupname;
params.isPgpLinked = (ui.radioButton_GpgId->isChecked());
uint32_t dummyToken = 0;
@ -268,6 +446,30 @@ void IdEditDialog::updateId()
close();
}
void IdEditDialog::updateId()
{
/* submit updated details */
std::string groupname = ui.lineEdit_Nickname->text().toUtf8().constData();
if (groupname.size() < 2)
{
std::cerr << "IdEditDialog::updateId() Nickname too short";
std::cerr << std::endl;
return;
}
mEditGroup.mMeta.mGroupName = groupname;
uint32_t dummyToken = 0;
rsIdentity->updateIdentity(dummyToken, mEditGroup);
close();
}
void IdEditDialog::loadRequest(const TokenQueue */*queue*/, const TokenRequest &req)
{
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;

View file

@ -29,6 +29,7 @@
#include <inttypes.h>
#include "util/TokenQueue.h"
#include <retroshare/rsidentity.h>
class UIStateHelper;
@ -46,16 +47,33 @@ public:
private slots:
void idTypeToggled(bool checked);
void updateId();
void submit();
void addRecognTag();
void checkNewTag();
void rmTag1();
void rmTag2();
void rmTag3();
void rmTag4();
void rmTag5();
private:
void createId();
void updateId();
void updateIdType(bool pseudo);
void loadExistingId(uint32_t token);
void loadRecognTags();
// extract details.
bool tagDetails(const std::string &id, const std::string &name, const std::string &tag, QString &desc);
void rmTag(int idx);
protected:
Ui::IdEditDialog ui;
bool mIsNew;
UIStateHelper *mStateHelper;
RsGxsIdGroup mEditGroup;
TokenQueue *mIdQueue;
};

View file

@ -48,12 +48,12 @@
#include "NewsFeed.h"
#include "ShareManager.h"
#include "NetworkView.h"
#include "ForumsDialog.h"
//#include "ForumsDialog.h"
#include "FriendsDialog.h"
#include "ChatLobbyWidget.h"
#include "HelpDialog.h"
#include "AboutDialog.h"
#include "ChannelFeed.h"
//#include "ChannelFeed.h"
#include "bwgraph/bwgraph.h"
#include "help/browser/helpbrowser.h"
#include "chat/ChatDialog.h"
@ -88,8 +88,6 @@
#include <retroshare/rsiface.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsfiles.h>
#include <retroshare/rsforums.h>
#include <retroshare/rschannels.h>
#include <retroshare/rsnotify.h>
#include "gui/connect/ConnectFriendWizard.h"
@ -269,17 +267,21 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
action = createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));
notify.push_back(QPair<MainPage*, QAction*>(messagesDialog, action));
#if 0
ui->stackPages->add(channelFeed = new ChannelFeed(ui->stackPages),
action = createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp));
notify.push_back(QPair<MainPage*, QAction*>(channelFeed, action));
#endif
#ifdef BLOGS
ui->stackPages->add(blogsFeed = new BlogsDialog(ui->stackPages), createPageAction(QIcon(IMAGE_BLOGS), tr("Blogs"), grp));
#endif
#if 0
ui->stackPages->add(forumsDialog = new ForumsDialog(ui->stackPages),
action = createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp));
notify.push_back(QPair<MainPage*, QAction*>(forumsDialog, action));
#endif
std::cerr << "Looking for interfaces in existing plugins:" << std::endl;
for(int i = 0;i<rsPlugins->nbPlugins();++i)
@ -820,12 +822,14 @@ void SetForegroundWindowInternal(HWND hWnd)
case Messages:
_instance->ui->stackPages->setCurrentPage( _instance->messagesDialog );
break;
#if 0
case Channels:
_instance->ui->stackPages->setCurrentPage( _instance->channelFeed );
return true ;
case Forums:
_instance->ui->stackPages->setCurrentPage( _instance->forumsDialog );
return true ;
#endif
#ifdef BLOGS
case Blogs:
Page = _instance->blogsFeed;
@ -870,12 +874,14 @@ void SetForegroundWindowInternal(HWND hWnd)
return Links;
}
#endif
#if 0
if (page == _instance->channelFeed) {
return Channels;
}
if (page == _instance->forumsDialog) {
return Forums;
}
#endif
#ifdef BLOGS
if (page == _instance->blogsFeed) {
return Blogs;
@ -912,10 +918,12 @@ void SetForegroundWindowInternal(HWND hWnd)
case Links:
return _instance->linksDialog;
#endif
#if 0
case Channels:
return _instance->channelFeed;
case Forums:
return _instance->forumsDialog;
#endif
#ifdef BLOGS
case Blogs:
return _instance->blogsFeed;

View file

@ -41,7 +41,7 @@ class RatesStatus;
class DiscStatus;
class DHTStatus;
class HashingStatus;
class ForumsDialog;
//class ForumsDialog;
class FriendsDialog;
class ChatLobbyWidget;
class ChatDialog;
@ -52,7 +52,7 @@ class MessagesDialog;
class SharedFilesDialog;
class MessengerWindow;
class PluginsPage;
class ChannelFeed;
//class ChannelFeed;
class BandwidthGraph;
class MainPage;
class NewsFeed;
@ -84,8 +84,8 @@ public:
Transfers = 3, /** Transfers page. */
SharedDirectories = 4, /** Shared Directories page. */
Messages = 5, /** Messages page. */
Channels = 6, /** Channels page. */
Forums = 7, /** Forums page. */
// Channels = 6, /** Channels page. */
// Forums = 7, /** Forums page. */
Search = 8, /** Search page. */
#ifdef BLOGS
Blogs = 9, /** Blogs page. */
@ -129,8 +129,8 @@ public:
ChatLobbyWidget *chatLobbyDialog;
MessagesDialog *messagesDialog;
SharedFilesDialog *sharedfilesDialog;
ForumsDialog *forumsDialog;
ChannelFeed *channelFeed;
// ForumsDialog *forumsDialog;
// ChannelFeed *channelFeed;
Idle *idle;
#ifdef RS_USE_LINKS

View file

@ -1141,7 +1141,7 @@ void MessagesDialog::insertMessages()
text = tr("Encrypted message. Right-click to decrypt it.") ;
else
text = QString::fromStdWString(it->title);
text = QString::fromUtf8(it->title.c_str());
item[COLUMN_SUBJECT]->setText(text);
item[COLUMN_SUBJECT]->setData(text + dateString, ROLE_SORT);
@ -1209,7 +1209,7 @@ void MessagesDialog::insertMessages()
if (gotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
gotInfo = true;
QTextDocument doc;
doc.setHtml(QString::fromStdWString(msgInfo.msg));
doc.setHtml(QString::fromUtf8(msgInfo.msg.c_str()));
item[COLUMN_CONTENT]->setText(doc.toPlainText().replace(QString("\n"), QString(" ")));
} else {
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;

View file

@ -142,11 +142,10 @@ NetworkDialog::NetworkDialog(QWidget *parent)
ui.onlyTrustedKeys->setMinimumWidth(20);
QString version = "-";
std::map<std::string, std::string>::iterator vit;
std::map<std::string, std::string> versions;
bool retv = rsDisc->getDiscVersions(versions);
if (retv && versions.end() != (vit = versions.find(rsPeers->getOwnId()))) {
version = QString::fromStdString(vit->second);
std::string rsversion;
if (rsDisc->getPeerVersion(rsPeers->getOwnId(), rsversion))
{
version = QString::fromStdString(rsversion);
}
QMenu *menu = new QMenu();

View file

@ -186,7 +186,7 @@ void NetworkView::updateDisplay()
}
std::list<std::string> friendList;
rsDisc->getDiscGPGFriends(info.gpg_id, friendList);
rsDisc->getDiscPgpFriends(info.gpg_id, friendList);
#ifdef DEBUG_NETWORKVIEW
std::cerr << " Got a list of " << friendList.size() << " friends for this peer." << std::endl ;
@ -214,7 +214,7 @@ void NetworkView::updateDisplay()
{
std::list<std::string> friendList ;
if(rsDisc->getDiscGPGFriends(it->first,friendList))
if(rsDisc->getDiscPgpFriends(it->first,friendList))
for(std::list<std::string>::const_iterator sit(friendList.begin()); sit != friendList.end(); sit++)
{
#ifdef DEBUG_NETWORKVIEW

View file

@ -25,15 +25,17 @@
#include <retroshare/rsnotify.h>
#include <retroshare/rspeers.h>
#include <retroshare/rschannels.h>
#include <retroshare/rsforums.h>
//#include <retroshare/rschannels.h>
//#include <retroshare/rsforums.h>
#include <retroshare/rsmsgs.h>
#include <retroshare/rsplugin.h>
#if 0
#include "feeds/ChanNewItem.h"
#include "feeds/ChanMsgItem.h"
#include "feeds/ForumNewItem.h"
#include "feeds/ForumMsgItem.h"
#endif
#include "settings/rsettingswin.h"
#ifdef BLOGS
@ -53,12 +55,16 @@
#include "common/FeedNotify.h"
const uint32_t NEWSFEED_PEERLIST = 0x0001;
#if 0
const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002;
const uint32_t NEWSFEED_FORUMMSGLIST = 0x0003;
const uint32_t NEWSFEED_CHANNEWLIST = 0x0004;
const uint32_t NEWSFEED_CHANMSGLIST = 0x0005;
const uint32_t NEWSFEED_BLOGNEWLIST = 0x0006;
const uint32_t NEWSFEED_BLOGMSGLIST = 0x0007;
#endif
const uint32_t NEWSFEED_MESSAGELIST = 0x0008;
const uint32_t NEWSFEED_CHATMSGLIST = 0x0009;
const uint32_t NEWSFEED_SECLIST = 0x000a;
@ -168,6 +174,7 @@ void NewsFeed::updateDisplay()
addFeedItemSecurityUnknownOut(fi);
break;
#if 0
case RS_FEED_ITEM_CHAN_NEW:
if (flags & RS_FEED_TYPE_CHAN)
addFeedItemChanNew(fi);
@ -202,6 +209,7 @@ void NewsFeed::updateDisplay()
if (flags & RS_FEED_TYPE_BLOG)
addFeedItemBlogMsg(fi);
break;
#endif
case RS_FEED_ITEM_CHAT_NEW:
if (flags & RS_FEED_TYPE_CHAT)
@ -275,6 +283,7 @@ void NewsFeed::testFeeds(uint notifyFlags)
instance->addFeedItemSecurityUnknownOut(fi);
break;
#if 0
case RS_FEED_TYPE_CHAN:
{
std::list<ChannelInfo> channelList;
@ -390,6 +399,7 @@ void NewsFeed::testFeeds(uint notifyFlags)
// instance->addFeedItemBlogNew(fi);
// instance->addFeedItemBlogMsg(fi);
break;
#endif
case RS_FEED_TYPE_CHAT:
fi.mId1 = rsPeers->getOwnId();
@ -635,8 +645,10 @@ void NewsFeed::addFeedItemSecurityUnknownOut(RsFeedItem &fi)
#endif
}
#if 0
void NewsFeed::addFeedItemChanNew(RsFeedItem &fi)
{
/* make new widget */
ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, true);
@ -773,6 +785,8 @@ void NewsFeed::addFeedItemBlogMsg(RsFeedItem &fi)
#endif
}
#endif
void NewsFeed::addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck)
{
#ifdef NEWS_DEBUG

View file

@ -80,6 +80,7 @@ private:
void addFeedItemSecurityUnknownIn(RsFeedItem &fi);
void addFeedItemSecurityUnknownOut(RsFeedItem &fi);
#if 0
void addFeedItemChanNew(RsFeedItem &fi);
void addFeedItemChanUpdate(RsFeedItem &fi);
void addFeedItemChanMsg(RsFeedItem &fi);
@ -88,6 +89,8 @@ private:
void addFeedItemForumMsg(RsFeedItem &fi);
void addFeedItemBlogNew(RsFeedItem &fi);
void addFeedItemBlogMsg(RsFeedItem &fi);
#endif
void addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck);
void addFeedItemMessage(RsFeedItem &fi);
void addFeedItemFilesNew(RsFeedItem &fi);

View file

@ -26,7 +26,9 @@
#include <retroshare/rswiki.h>
#include <iostream>
const uint32_t PostedCreateEnabledFlags = ( // GXS_GROUP_FLAGS_ICON |
const uint32_t PostedCreateEnabledFlags = (
GXS_GROUP_FLAGS_NAME |
// GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN |
@ -52,13 +54,16 @@ uint32_t PostedCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
GXS_GROUP_DEFAULTS_COMMENTS_NO |
0);
uint32_t PostedEditEnabledFlags = PostedCreateEnabledFlags;
uint32_t PostedEditDefaultsFlags = PostedCreateDefaultsFlags;
PostedGroupDialog::PostedGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
:GxsGroupDialog(tokenQueue, PostedCreateEnabledFlags, PostedCreateDefaultsFlags, parent)
{
}
PostedGroupDialog::PostedGroupDialog(const RsPostedGroup &group, QWidget *parent)
:GxsGroupDialog(group.mMeta, MODE_SHOW, parent)
PostedGroupDialog::PostedGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
:GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, PostedEditEnabledFlags, PostedEditDefaultsFlags, parent)
{
}
@ -100,3 +105,9 @@ bool PostedGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaDa
return true;
}
bool PostedGroupDialog::service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta)
{
return false;
}

View file

@ -33,12 +33,13 @@ class PostedGroupDialog : public GxsGroupDialog
public:
PostedGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
PostedGroupDialog(const RsPostedGroup &topic, QWidget *parent);
PostedGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent);
protected:
virtual void initUi();
virtual QPixmap serviceImage();
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
virtual bool service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta);
private:
RsPostedGroup mTopic;

View file

@ -372,8 +372,8 @@ void PostedListDialog::showGroupDetails()
{
return;
}
PostedGroupDialog cf(mGroups[mCurrTopicId], this);
PostedGroupDialog cf(mPostedQueue, rsPosted->getTokenService(), GxsGroupDialog::MODE_SHOW, mCurrTopicId, this);
cf.exec ();
}

View file

@ -1,311 +1,311 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PostedListDialog</class>
<widget class="QWidget" name="PostedListDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>756</width>
<height>428</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="handleWidth">
<number>5</number>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="GroupTreeWidget" name="groupTreeWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QFrame" name="frame">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="submitPostButton">
<property name="text">
<string>Submit a new Post</string>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/posted_24.png</normaloff>:/images/posted_24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Todo</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="showLabel">
<property name="text">
<string>Showing 1-100</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="prevButton">
<property name="text">
<string>Prev</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="nextButton">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<item>
<widget class="QGroupBox" name="sortGroup">
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="hotSortButton">
<property name="text">
<string>Hot</string>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/hot_24.png</normaloff>:/images/hot_24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="newSortButton">
<property name="text">
<string>New</string>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/new_24.png</normaloff>:/images/new_24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="topSortButton">
<property name="text">
<string>Top</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/vote_up.png</normaloff>:/images/vote_up.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="periodComboBox">
<item>
<property name="text">
<string>Today</string>
</property>
</item>
<item>
<property name="text">
<string>Yesterday</string>
</property>
</item>
<item>
<property name="text">
<string>This Week</string>
</property>
</item>
<item>
<property name="text">
<string>This Month</string>
</property>
</item>
<item>
<property name="text">
<string>This Year</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="GxsIdChooser" name="idChooser"/>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>711</width>
<height>16</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GroupTreeWidget</class>
<extends>QWidget</extends>
<header>gui/common/GroupTreeWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GxsIdChooser</class>
<extends>QComboBox</extends>
<header>gui/gxs/GxsIdChooser.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="Posted_images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PostedListDialog</class>
<widget class="QWidget" name="PostedListDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>756</width>
<height>428</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="handleWidth">
<number>5</number>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="GroupTreeWidget" name="groupTreeWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QFrame" name="frame">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="submitPostButton">
<property name="text">
<string>Submit a new Post</string>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/posted_24.png</normaloff>:/images/posted_24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Todo</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="showLabel">
<property name="text">
<string>Showing 1-100</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="prevButton">
<property name="text">
<string>Prev</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="nextButton">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<item>
<widget class="QGroupBox" name="sortGroup">
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="hotSortButton">
<property name="text">
<string>Hot</string>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/hot_24.png</normaloff>:/images/hot_24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="newSortButton">
<property name="text">
<string>New</string>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/new_24.png</normaloff>:/images/new_24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="topSortButton">
<property name="text">
<string>Top</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/vote_up.png</normaloff>:/images/vote_up.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="periodComboBox">
<item>
<property name="text">
<string>Today</string>
</property>
</item>
<item>
<property name="text">
<string>Yesterday</string>
</property>
</item>
<item>
<property name="text">
<string>This Week</string>
</property>
</item>
<item>
<property name="text">
<string>This Month</string>
</property>
</item>
<item>
<property name="text">
<string>This Year</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="GxsIdChooser" name="idChooser"/>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>711</width>
<height>16</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GroupTreeWidget</class>
<extends>QWidget</extends>
<header>gui/common/GroupTreeWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GxsIdChooser</class>
<extends>QComboBox</extends>
<header>gui/gxs/GxsIdChooser.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="Posted_images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -123,32 +123,40 @@ void QuickStartWizard::on_pushButtonConnectionNext_clicked()
rsPeers->setNetworkMode(rsPeers->getOwnId(), netMode);
/* Check if vis has changed */
uint32_t visState = 0;
switch(ui.discoveryComboBox->currentIndex())
{
case 0:
visState |= (RS_VS_DISC_ON | RS_VS_DHT_ON);
break;
case 1:
visState |= RS_VS_DISC_ON;
break;
case 2:
visState |= RS_VS_DHT_ON;
break;
case 3:
default:
break;
}
uint16_t vs_disc = 0;
uint16_t vs_dht = 0;
switch(ui.discoveryComboBox->currentIndex())
{
case 0:
vs_disc = RS_VS_DISC_FULL;
vs_dht = RS_VS_DHT_FULL;
break;
case 1:
vs_disc = RS_VS_DISC_FULL;
vs_dht = RS_VS_DHT_OFF;
break;
case 2:
vs_disc = RS_VS_DISC_OFF;
vs_dht = RS_VS_DHT_FULL;
break;
case 3:
default:
vs_disc = RS_VS_DISC_OFF;
vs_dht = RS_VS_DHT_OFF;
break;
}
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail))
{
return;
}
if (visState != detail.visState)
{
rsPeers->setVisState(rsPeers->getOwnId(), visState);
}
if ((vs_disc != detail.vs_disc) || (vs_dht != detail.vs_dht))
{
rsPeers->setVisState(rsPeers->getOwnId(), vs_disc, vs_dht);
}
rsConfig->SetMaxDataRates( ui.doubleSpinBoxDownloadSpeed->value(), ui.doubleSpinBoxUploadSpeed->value() );
ui.pagesWizard->setCurrentIndex(2);
@ -425,9 +433,9 @@ void QuickStartWizard::loadNetwork()
*/
netIndex = 3; // NONE.
if (detail.visState & RS_VS_DHT_ON)
if (detail.vs_dht != RS_VS_DISC_OFF)
{
if (detail.visState & RS_VS_DISC_ON)
if (detail.vs_disc != RS_VS_DISC_OFF)
{
netIndex = 0; // PUBLIC
}
@ -438,7 +446,7 @@ void QuickStartWizard::loadNetwork()
}
else
{
if (detail.visState & RS_VS_DISC_ON)
if (detail.vs_disc != RS_VS_DISC_OFF)
{
netIndex = 1; // PRIVATE
}
@ -450,7 +458,7 @@ void QuickStartWizard::loadNetwork()
ui.discoveryComboBox->setCurrentIndex(netIndex);
int dlrate = 0;
int dlrate = 0;
int ulrate = 0;
rsConfig->GetMaxDataRates(dlrate, ulrate);
ui.doubleSpinBoxDownloadSpeed->setValue(dlrate);
@ -494,28 +502,34 @@ void QuickStartWizard::saveChanges()
rsPeers->setNetworkMode(ownId, netMode);
uint32_t visState = 0;
/* Check if vis has changed */
switch(ui.discoveryComboBox->currentIndex())
{
case 0:
visState |= (RS_VS_DISC_ON | RS_VS_DHT_ON);
break;
case 1:
visState |= RS_VS_DISC_ON;
break;
case 2:
visState |= RS_VS_DHT_ON;
break;
case 3:
default:
break;
}
if (visState != detail.visState)
{
rsPeers->setVisState(ownId, visState);
}
/* Check if vis has changed */
uint16_t vs_disc = 0;
uint16_t vs_dht = 0;
switch(ui.discoveryComboBox->currentIndex())
{
case 0:
vs_disc = RS_VS_DISC_FULL;
vs_dht = RS_VS_DHT_FULL;
break;
case 1:
vs_disc = RS_VS_DISC_FULL;
vs_dht = RS_VS_DHT_OFF;
break;
case 2:
vs_disc = RS_VS_DISC_OFF;
vs_dht = RS_VS_DHT_FULL;
break;
case 3:
default:
vs_disc = RS_VS_DISC_OFF;
vs_dht = RS_VS_DHT_OFF;
break;
}
if ((vs_disc != detail.vs_disc) || (vs_dht != detail.vs_dht))
{
rsPeers->setVisState(ownId, vs_disc, vs_dht);
}
/*if (0 != netIndex)
{

View file

@ -28,6 +28,7 @@
#include <QMessageBox>
#include <QIcon>
#include <QObject>
#include <time.h>
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
#include <QUrlQuery>
@ -35,8 +36,8 @@
#include "RetroShareLink.h"
#include "MainWindow.h"
#include "ForumsDialog.h"
#include "ChannelFeed.h"
//#include "ForumsDialog.h"
//#include "ChannelFeed.h"
#include "SearchDialog.h"
#include "msgs/MessageComposer.h"
#include "util/misc.h"
@ -49,8 +50,8 @@
#include <retroshare/rsfiles.h>
#include <retroshare/rsmsgs.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsforums.h>
#include <retroshare/rschannels.h>
//#include <retroshare/rsforums.h>
//#include <retroshare/rschannels.h>
//#define DEBUG_RSLINK 1
@ -481,6 +482,7 @@ bool RetroShareLink::createForum(const std::string& id, const std::string& msgId
{
clear();
#if 0
if (!id.empty()) {
_hash = QString::fromStdString(id);
_msgId = QString::fromStdString(msgId);
@ -499,6 +501,7 @@ bool RetroShareLink::createForum(const std::string& id, const std::string& msgId
}
}
}
#endif
check();
@ -509,6 +512,7 @@ bool RetroShareLink::createChannel(const std::string& id, const std::string& msg
{
clear();
#if 0
if (!id.empty()) {
_hash = QString::fromStdString(id);
_msgId = QString::fromStdString(msgId);
@ -527,6 +531,7 @@ bool RetroShareLink::createChannel(const std::string& id, const std::string& msg
}
}
}
#endif
check();
@ -1370,6 +1375,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
break;
}
#if 0
case TYPE_FORUM:
{
#ifdef DEBUG_RSLINK
@ -1461,6 +1467,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
}
break;
}
#endif
case TYPE_SEARCH:
{

View file

@ -0,0 +1,391 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 20011, RetroShare Team
*
* 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 <iostream>
#include <QTimer>
#include <QObject>
#include <QPainter>
#include <QStylePainter>
#include <retroshare/rsrtt.h>
#include <retroshare/rspeers.h>
#include "RttStatistics.h"
#include "time.h"
#include "gui/settings/rsharesettings.h"
#define PLOT_HEIGHT 100
#define PLOT_WIDTH 500
#define MAX_DISPLAY_PERIOD 300
double convertDtToPixels(double refTs, double minTs, double ts)
{
double dt = refTs - ts;
double maxdt = refTs - minTs;
double pix = PLOT_WIDTH - dt / maxdt * PLOT_WIDTH;
return pix;
}
double convertRttToPixels(double maxRTT, double rtt)
{
double pix = rtt / maxRTT * PLOT_HEIGHT;
return PLOT_HEIGHT - pix;
}
class RttPlot
{
public:
RttPlot(const std::map<std::string, std::list<RsRttPongResult> > &info,
double refTS, double maxRTT, double minTS, double maxTS)
:mInfo(info), mRefTS(refTS), mMaxRTT(maxRTT), mMinTS(minTS), mMaxTS(maxTS) {}
QColor colorScale(float f)
{
if(f == 0)
return QColor::fromHsv(0,0,192) ;
else
return QColor::fromHsv((int)((1.0-f)*280),200,255) ;
}
virtual void draw(QPainter *painter,int& ox,int& oy,const QString& title)
{
static const int cellx = 7 ;
static const int celly = 12 ;
//int save_ox = ox ;
painter->setPen(QColor::fromRgb(0,0,0)) ;
painter->drawText(2+ox,celly+oy,title) ;
oy+=2+2*celly ;
painter->drawRect(ox, oy, PLOT_WIDTH, PLOT_HEIGHT);
if(mInfo.empty())
return ;
double maxdt = mRefTS - mMinTS;
if (maxdt > MAX_DISPLAY_PERIOD)
{
mMinTS = mRefTS - MAX_DISPLAY_PERIOD;
}
/* draw a different line for each peer */
std::map<std::string, std::list<RsRttPongResult> >::const_iterator mit;
int i = 0;
int nLines = mInfo.size();
for(mit = mInfo.begin(); mit != mInfo.end(); mit++, i++)
{
QPainterPath path;
std::list<RsRttPongResult>::const_iterator it = mit->second.begin();
if (it != mit->second.end())
{
double x = convertDtToPixels(mRefTS, mMinTS, it->mTS);
double y = convertRttToPixels(mMaxRTT, it->mRTT);
path.moveTo(ox + x, oy + y);
it++;
}
for(; it != mit->second.end(); it++)
{
/* skip old elements */
if (it->mTS < mMinTS)
{
continue;
}
double x = convertDtToPixels(mRefTS, mMinTS, it->mTS);
double y = convertRttToPixels(mMaxRTT, it->mRTT);
path.lineTo(ox + x, oy + y);
}
/* draw line */
painter->setPen(QColor::fromRgb(((255.0 * i) / (nLines-1)),0, 255 - (255.0 * i) / (nLines-1))) ;
painter->drawPath(path);
/* draw name */
}
painter->setPen(QColor::fromRgb(0,0,0)) ;
painter->drawText(ox+PLOT_WIDTH + cellx ,oy + celly / 2, QString::number(mMaxRTT)+" "+QObject::tr("secs")) ;
oy += PLOT_HEIGHT / 2;
painter->drawText(ox+PLOT_WIDTH + cellx ,oy + celly / 2, QString::number(mMaxRTT / 2.0)+" "+QObject::tr("secs")) ;
oy += PLOT_HEIGHT / 2;
painter->drawText(ox+PLOT_WIDTH + cellx ,oy + celly / 2, QString::number(0.0)+" "+QObject::tr("secs")) ;
oy += celly;
painter->drawText(ox ,oy, QObject::tr("Old"));
painter->drawText(ox + PLOT_WIDTH - cellx ,oy, QObject::tr("Now"));
oy += celly;
// Now do names.
i = 0;
for(mit = mInfo.begin(); mit != mInfo.end(); mit++, i++)
{
painter->fillRect(ox,oy,cellx,celly,
QColor::fromRgb(((255.0 * i) / (nLines-1)),0, 255 - (255.0 * i) / (nLines-1))) ;
painter->setPen(QColor::fromRgb(0,0,0)) ;
painter->drawRect(ox,oy,cellx,celly) ;
painter->drawText(ox + cellx + 4,oy + celly / 2,RttStatistics::getPeerName(mit->first));
oy += 2 * celly;
}
}
private:
const std::map<std::string, std::list<RsRttPongResult> > &mInfo;
double mRefTS;
double mMaxRTT;
double mMinTS;
double mMaxTS;
};
RttStatistics::RttStatistics(QWidget *parent)
: RsAutoUpdatePage(2000,parent)
{
setupUi(this) ;
m_bProcessSettings = false;
_tunnel_statistics_F->setWidget( _tst_CW = new RttStatisticsWidget() ) ;
_tunnel_statistics_F->setWidgetResizable(true);
_tunnel_statistics_F->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
_tunnel_statistics_F->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
_tunnel_statistics_F->viewport()->setBackgroundRole(QPalette::NoRole);
_tunnel_statistics_F->setFrameStyle(QFrame::NoFrame);
_tunnel_statistics_F->setFocusPolicy(Qt::NoFocus);
// load settings
processSettings(true);
}
RttStatistics::~RttStatistics()
{
// save settings
processSettings(false);
}
void RttStatistics::processSettings(bool bLoad)
{
m_bProcessSettings = true;
Settings->beginGroup(QString("RttStatistics"));
if (bLoad) {
// load settings
// state of splitter
//splitter->restoreState(Settings->value("Splitter").toByteArray());
} else {
// save settings
// state of splitter
//Settings->setValue("Splitter", splitter->saveState());
}
Settings->endGroup();
m_bProcessSettings = false;
}
void RttStatistics::updateDisplay()
{
std::map<std::string, std::list<RsRttPongResult> > info;
if (!rsRtt)
{
return;
}
std::list<std::string> idList;
std::list<std::string>::iterator it;
rsPeers->getOnlineList(idList);
time_t now = time(NULL);
time_t minTS = now;
time_t maxTS = 0;
double maxRTT = 0;
for(it = idList.begin(); it != idList.end(); it++)
{
std::list<RsRttPongResult> results;
std::list<RsRttPongResult>::iterator rit;
#define MAX_RESULTS 60
rsRtt->getPongResults(*it, MAX_RESULTS, results);
for(rit = results.begin(); rit != results.end(); rit++)
{
/* only want maxRTT to include plotted bit */
double dt = now - rit->mTS;
if (dt < MAX_DISPLAY_PERIOD)
{
if (maxRTT < rit->mRTT)
{
maxRTT = rit->mRTT;
}
}
if (minTS > rit->mTS)
{
minTS = rit->mTS;
}
if (maxTS < rit->mTS)
{
maxTS = rit->mTS;
}
}
info[*it] = results;
}
_tst_CW->updateRttStatistics(info, maxRTT, minTS, maxTS);
_tst_CW->update();
}
QString RttStatistics::getPeerName(const std::string& peer_id)
{
static std::map<std::string, QString> names ;
std::map<std::string,QString>::const_iterator it = names.find(peer_id) ;
if( it != names.end())
return it->second ;
else
{
RsPeerDetails detail ;
if(!rsPeers->getPeerDetails(peer_id,detail))
return "unknown peer";
return (names[peer_id] = QString::fromUtf8(detail.name.c_str())) ;
}
}
RttStatisticsWidget::RttStatisticsWidget(QWidget *parent)
: QWidget(parent)
{
maxWidth = 200 ;
maxHeight = 0 ;
}
void RttStatisticsWidget::updateRttStatistics(const std::map<std::string, std::list<RsRttPongResult> >& info,
double maxRTT, double minTS, double maxTS)
{
//static const int cellx = 6 ;
//static const int celly = 10+4 ;
QPixmap tmppixmap(maxWidth, maxHeight);
tmppixmap.fill(this, 0, 0);
setFixedHeight(maxHeight);
QPainter painter(&tmppixmap);
painter.initFrom(this);
maxHeight = 500 ;
//std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl;
// draw...
int ox=5,oy=5 ;
double refTS = time(NULL);
//painter.setPen(QColor::fromRgb(70,70,70)) ;
//painter.drawLine(0,oy,maxWidth,oy) ;
//oy += celly ;
//painter.setPen(QColor::fromRgb(0,0,0)) ;
// round up RTT to nearest
double roundedRTT = maxRTT;
if (maxRTT < 0.018)
{
roundedRTT = 0.02;
}
else if (maxRTT < 0.045)
{
roundedRTT = 0.05;
}
else if (maxRTT < 0.09)
{
roundedRTT = 0.1;
}
else if (maxRTT < 0.18)
{
roundedRTT = 0.2;
}
else if (maxRTT < 0.4)
{
roundedRTT = 0.5;
}
else if (maxRTT < 0.8)
{
roundedRTT = 1.0;
}
else if (maxRTT < 1.8)
{
roundedRTT = 2.0;
}
else if (maxRTT < 4.5)
{
roundedRTT = 5.0;
}
RttPlot(info, refTS, roundedRTT, minTS, maxTS).draw(&painter,ox,oy,QObject::tr("Round Trip Time:")) ;
// update the pixmap
pixmap = tmppixmap;
maxHeight = oy; // + PLOT_HEIGHT * 2;
}
QString RttStatisticsWidget::speedString(float f)
{
if(f < 1.0f)
return QString("0 B/s") ;
if(f < 1024.0f)
return QString::number((int)f)+" B/s" ;
return QString::number(f/1024.0,'f',2) + " KB/s";
}
void RttStatisticsWidget::paintEvent(QPaintEvent */*event*/)
{
QStylePainter(this).drawPixmap(0, 0, pixmap);
}
void RttStatisticsWidget::resizeEvent(QResizeEvent *event)
{
QRect TaskGraphRect = geometry();
maxWidth = TaskGraphRect.width();
maxHeight = TaskGraphRect.height() ;
QWidget::resizeEvent(event);
update();
}

View file

@ -0,0 +1,68 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 20011, RetroShare Team
*
* 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.
****************************************************************/
#pragma once
#include <QPoint>
#include <retroshare/rsrtt.h>
#include "ui_RttStatistics.h"
#include "RsAutoUpdatePage.h"
class RttStatisticsWidget ;
class RttStatistics: public RsAutoUpdatePage, public Ui::RttStatistics
{
public:
RttStatistics(QWidget *parent = NULL) ;
~RttStatistics();
// Cache for peer names.
static QString getPeerName(const std::string& peer_id) ;
private:
void processSettings(bool bLoad);
bool m_bProcessSettings;
virtual void updateDisplay() ;
RttStatisticsWidget *_tst_CW ;
} ;
class RttStatisticsWidget: public QWidget
{
public:
RttStatisticsWidget(QWidget *parent = NULL) ;
virtual void paintEvent(QPaintEvent *event) ;
virtual void resizeEvent(QResizeEvent *event);
void updateRttStatistics(const std::map<std::string, std::list<RsRttPongResult> >& info,
double maxRTT, double minTS, double maxTS);
private:
static QString speedString(float f) ;
QPixmap pixmap ;
int maxWidth,maxHeight ;
};

View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RttStatistics</class>
<widget class="QWidget" name="RttStatistics">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<height>408</height>
</rect>
</property>
<property name="windowTitle">
<string>RTT Statistics</string>
</property>
<property name="windowIcon">
<iconset resource="images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QScrollArea" name="_tunnel_statistics_F">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>587</width>
<height>384</height>
</rect>
</property>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -48,17 +48,17 @@ StartDialog::StartDialog(QWidget *parent)
std::list<std::string> accountIds;
std::list<std::string>::iterator it;
std::string preferedId;
RsInit::getPreferedAccountId(preferedId);
RsAccounts::GetPreferredAccountId(preferedId);
int pidx = -1;
int i;
if (RsInit::getAccountIds(accountIds))
if (RsAccounts::GetAccountIds(accountIds))
{
for(it = accountIds.begin(), i = 0; it != accountIds.end(); it++, i++)
{
const QVariant & userData = QVariant(QString::fromStdString(*it));
std::string gpgid, name, email, location;
RsInit::getAccountDetails(*it, gpgid, name, email, location);
RsAccounts::GetAccountDetails(*it, gpgid, name, email, location);
QString accountName = QString::fromUtf8(name.c_str()) + " (" + QString::fromStdString(gpgid).right(8) + ") - " + QString::fromUtf8(location.c_str());
ui.loadName->addItem(accountName, userData);
@ -97,8 +97,6 @@ void StartDialog::loadPerson()
QVariant data = ui.loadName->itemData(pgpidx);
accountId = (data.toString()).toStdString();
RsInit::LoadPassword(accountId, "");
if (Rshare::loadCertificate(accountId, ui.autologin_checkbox->isChecked())) {
accept();
}

View file

@ -1,114 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2009 RetroShare Team
*
* 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 "ChannelDetails.h"
#include "util/DateTime.h"
#include <retroshare/rsiface.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsdisc.h>
#include <retroshare/rschannels.h>
#include <QTime>
#include <QDateTime>
#include <list>
#include <iostream>
#include <string>
/** Default constructor */
ChannelDetails::ChannelDetails(QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
ui.typeEncrypted->setEnabled(false);
ui.typePrivate->setEnabled(false);
}
/**
Overloads the default show() slot so we can set opacity*/
void
ChannelDetails::show()
{
//loadSettings();
if(!this->isVisible()) {
QDialog::show();
}
}
void ChannelDetails::showDetails(std::string mChannelId)
{
cId = mChannelId;
loadChannel();
}
void ChannelDetails::loadChannel()
{
if (!rsChannels)
{
return;
}
uint32_t flags = 0;
ChannelInfo ci;
rsChannels->getChannelInfo(cId, ci);
flags = ci.channelFlags;
// Set Channel Name
ui.nameline->setText(QString::fromStdWString(ci.channelName));
// Set Channel Popularity
{
ui.popline -> setText(QString::number(ci.pop));
}
// Set Last Channel Post Date
if (ci.lastPost) {
ui.postline->setText(DateTime::formatLongDateTime(ci.lastPost));
}
// Set Channel ID
ui.IDline->setText(QString::fromStdString(ci.channelId));
// Set Channel Description
ui.DescriptiontextEdit->setText(QString::fromStdWString(ci.channelDesc));
if (flags |= RS_DISTRIB_PRIVATE)
{
ui.typeEncrypted->setChecked(false);
ui.typePrivate->setChecked(true);
}
else if (flags |= RS_DISTRIB_ENCRYPTED)
{
ui.typeEncrypted->setChecked(true);
ui.typePrivate->setChecked(false);
}
// Set destination directory
ui.destinationDirectoryLineEdit->setText(QString::fromUtf8(ci.destination_directory.c_str()));
}

View file

@ -1,57 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2009 RetroShare Team
*
* 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.
****************************************************************/
#ifndef _CHANNELDETAILS_H
#define _CHANNELDETAILS_H
#include <QDialog>
#include "ui_ChannelDetails.h"
class ChannelDetails : public QDialog
{
Q_OBJECT
public:
/** Default constructor */
ChannelDetails(QWidget *parent = 0);
void showDetails(std::string mChannelId);
signals:
void configChanged() ;
public slots:
/** Overloaded QWidget.show */
void show();
private:
void loadChannel();
std::string cId;
/** Qt Designer generated object */
Ui::ChannelDetails ui;
};
#endif

View file

@ -1,186 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChannelDetails</class>
<widget class="QDialog" name="ChannelDetails">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>455</width>
<height>417</height>
</rect>
</property>
<property name="windowTitle">
<string>Channel Details</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="stabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/info16.png</normaloff>:/images/info16.png</iconset>
</attribute>
<attribute name="title">
<string>Channel Details</string>
</attribute>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Channel Info</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Channel Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameline">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Popularity</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="popline">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Last Post</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="postline">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Channel ID</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="IDline">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Channel Description</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QTextEdit" name="DescriptiontextEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Type</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="typePrivate">
<property name="text">
<string>Restricted - Anyone can read, limited publishing (Private Publish Key)</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="typeEncrypted">
<property name="text">
<string>Private - (Private Publish Key required to view Messages)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Destination directory</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="destinationDirectoryLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="_2">
<item row="0" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>stabWidget</tabstop>
<tabstop>nameline</tabstop>
<tabstop>popline</tabstop>
<tabstop>postline</tabstop>
<tabstop>IDline</tabstop>
<tabstop>destinationDirectoryLineEdit</tabstop>
<tabstop>DescriptiontextEdit</tabstop>
<tabstop>typePrivate</tabstop>
<tabstop>typeEncrypted</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,106 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 RetroShare Team
*
* 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 "ChannelUserNotify.h"
#include "gui/settings/rsharesettings.h"
#include "gui/notifyqt.h"
#include "gui/MainWindow.h"
#include <retroshare/rschannels.h>
ChannelUserNotify::ChannelUserNotify(QObject *parent) :
UserNotify(parent)
{
connect(NotifyQt::getInstance(), SIGNAL(channelsChanged(int)), this, SLOT(updateIcon()), Qt::QueuedConnection);
}
bool ChannelUserNotify::hasSetting(QString &name)
{
name = tr("Channel Post");
return true;
}
bool ChannelUserNotify::notifyEnabled()
{
return (Settings->getTrayNotifyFlags() & TRAYNOTIFY_CHANNELS);
}
bool ChannelUserNotify::notifyCombined()
{
return (Settings->getTrayNotifyFlags() & TRAYNOTIFY_CHANNELS_COMBINED);
}
bool ChannelUserNotify::notifyBlink()
{
return (Settings->getTrayNotifyBlinkFlags() & TRAYNOTIFY_BLINK_CHANNELS);
}
void ChannelUserNotify::setNotifyEnabled(bool enabled, bool combined, bool blink)
{
uint notifyFlags = Settings->getTrayNotifyFlags();
uint blinkFlags = Settings->getTrayNotifyBlinkFlags();
if (enabled) {
notifyFlags |= TRAYNOTIFY_CHANNELS;
} else {
notifyFlags &= ~TRAYNOTIFY_CHANNELS;
}
if (combined) {
notifyFlags |= TRAYNOTIFY_CHANNELS_COMBINED;
} else {
notifyFlags &= ~TRAYNOTIFY_CHANNELS_COMBINED;
}
if (blink) {
blinkFlags |= TRAYNOTIFY_BLINK_CHANNELS;
} else {
blinkFlags &= ~TRAYNOTIFY_BLINK_CHANNELS;
}
Settings->setTrayNotifyFlags(notifyFlags);
Settings->setTrayNotifyBlinkFlags(blinkFlags);
}
QIcon ChannelUserNotify::getIcon()
{
return QIcon(":/images/channels16.png");
}
QIcon ChannelUserNotify::getMainIcon(bool hasNew)
{
return hasNew ? QIcon(":/images/channels_new.png") : QIcon(":/images/channels.png");
}
unsigned int ChannelUserNotify::getNewCount()
{
unsigned int newMessageCount = 0;
unsigned int unreadMessageCount = 0;
rsChannels->getMessageCount("", newMessageCount, unreadMessageCount);
return newMessageCount;
}
void ChannelUserNotify::iconClicked()
{
MainWindow::showWindow(MainWindow::Channels);
}

View file

@ -1,47 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 RetroShare Team
*
* 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.
****************************************************************/
#ifndef CHANNELUSERNOTIFY_H
#define CHANNELUSERNOTIFY_H
#include "gui/common/UserNotify.h"
class ChannelUserNotify : public UserNotify
{
Q_OBJECT
public:
ChannelUserNotify(QObject *parent = 0);
virtual bool hasSetting(QString &name);
virtual bool notifyEnabled();
virtual bool notifyCombined();
virtual bool notifyBlink();
virtual void setNotifyEnabled(bool enabled, bool combined, bool blink);
private:
virtual QIcon getIcon();
virtual QIcon getMainIcon(bool hasNew);
virtual unsigned int getNewCount();
virtual void iconClicked();
};
#endif // CHANNELUSERNOTIFY_H

View file

@ -1,149 +0,0 @@
/****************************************************************
* 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 <QMessageBox>
#include <QBuffer>
#include <algorithm>
#include "CreateChannel.h"
#include "gui/common/PeerDefs.h"
#include "util/misc.h"
#include <retroshare/rschannels.h>
#include <retroshare/rspeers.h>
/** Constructor */
CreateChannel::CreateChannel()
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
ui.headerFrame->setHeaderImage(QPixmap(":/images/add_channel64.png"));
ui.headerFrame->setHeaderText(tr("New Channel"));
// connect up the buttons.
connect( ui.buttonBox, SIGNAL(accepted()), this, SLOT(createChannel()));
connect( ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect( ui.logoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo()));
connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) ));
if (!ui.pubKeyShare_cb->isChecked()) {
ui.contactsdockWidget->hide();
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
/* initialize key share list */
ui.keyShareList->setHeaderText(tr("Contacts:"));
ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
ui.keyShareList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
ui.keyShareList->start();
newChannel();
}
void CreateChannel::setShareList(){
if (ui.pubKeyShare_cb->isChecked()){
this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height());
ui.contactsdockWidget->show();
} else {
ui.contactsdockWidget->hide();
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
}
void CreateChannel::newChannel()
{
/* enforce Private for the moment */
ui.typePrivate->setChecked(true);
ui.typeEncrypted->setEnabled(true);
ui.msgAnon->setChecked(true);
ui.msgAuth->setEnabled(false);
ui.msgGroupBox->hide();
ui.channelName->setFocus();
}
void CreateChannel::createChannel()
{
QString name = misc::removeNewLine(ui.channelName->text());
QString desc = ui.channelDesc->toPlainText();
uint32_t flags = 0;
if (name.isEmpty()) {
/* error message */
QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty name!!
}
if (ui.typePrivate->isChecked()) {
flags |= RS_DISTRIB_PRIVATE;
} else if (ui.typeEncrypted->isChecked()) {
flags |= RS_DISTRIB_ENCRYPTED;
}
if (ui.msgAuth->isChecked()) {
flags |= RS_DISTRIB_AUTHEN_REQ;
} else if (ui.msgAnon->isChecked()) {
flags |= RS_DISTRIB_AUTHEN_ANON;
}
QByteArray ba;
QBuffer buffer(&ba);
if (!picture.isNull()) {
// send chan image
buffer.open(QIODevice::WriteOnly);
picture.save(&buffer, "PNG"); // writes image into ba in PNG format
}
if (rsChannels) {
std::string chId = rsChannels->createChannel(name.toStdWString(), desc.toStdWString(), flags, (unsigned char*)ba.data(), ba.size());
if (ui.pubKeyShare_cb->isChecked()) {
std::list<std::string> shareList;
ui.keyShareList->selectedSslIds(shareList, false);
rsChannels->channelShareKeys(chId, shareList);
}
}
close();
}
void CreateChannel::addChannelLogo() // the same function as in EditChanDetails
{
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load channel logo"), 64, 64);
if (img.isNull())
return;
picture = img;
// to show the selected
ui.logoLabel->setPixmap(picture);
}

View file

@ -1,51 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _CREATE_CHANNEL_DIALOG_H
#define _CREATE_CHANNEL_DIALOG_H
#include "ui_CreateChannel.h"
class CreateChannel : public QDialog
{
Q_OBJECT
public:
CreateChannel();
void newChannel(); /* cleanup */
private slots:
/* actions to take.... */
void createChannel();
void addChannelLogo();
void setShareList();
private:
QPixmap picture;
/** Qt Designer generated object */
Ui::CreateChannel ui;
};
#endif

View file

@ -1,371 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateChannel</class>
<widget class="QDialog" name="CreateChannel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>703</width>
<height>611</height>
</rect>
</property>
<property name="windowTitle">
<string>Create a new Channel</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="HeaderFrame" name="headerFrame"/>
</item>
<item>
<widget class="QFrame" name="frame">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="channelName"/>
</item>
</layout>
</item>
<item row="0" column="1" rowspan="6">
<widget class="QDockWidget" name="contactsdockWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>524287</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>check peers you would like to share private publish key with</string>
</property>
<property name="floating">
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Share Key With</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="_2">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="FriendSelectionWidget" name="keyShareList" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>4</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="channelDesc"/>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="tyoeGroupBox">
<property name="title">
<string>Type:</string>
</property>
<layout class="QVBoxLayout" name="_3">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QRadioButton" name="typePrivate">
<property name="text">
<string>Restricted - Anyone can read, limited publishing (Private Publish Key)</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="typeEncrypted">
<property name="text">
<string>Private - (Private Publish Key required to view Messages)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="msgGroupBox">
<property name="title">
<string>Allowed Messages</string>
</property>
<layout class="QVBoxLayout" name="_4">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QRadioButton" name="msgAnon">
<property name="text">
<string>Anonymous Messages</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="msgAuth">
<property name="text">
<string>Authenticated Messages</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QGroupBox" name="msgGroupBox_2">
<property name="title">
<string>Key Sharing</string>
</property>
<layout class="QVBoxLayout" name="_5">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="pubKeyShare_cb">
<property name="toolTip">
<string>Key recipients can publish to restricted-type channels, and can view and publish for private-type channels</string>
</property>
<property name="text">
<string>Share Private Publish Key</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="0">
<widget class="QGroupBox" name="groupBoxLogo">
<property name="title">
<string>Channel Logo</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="logoLabel">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/channels.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="logoButton">
<property name="text">
<string>Add Channel Logo</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>118</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="6" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>FriendSelectionWidget</class>
<extends>QWidget</extends>
<header>gui/common/FriendSelectionWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,649 +0,0 @@
/****************************************************************
* 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 <QDragEnterEvent>
#include <QUrl>
#include <QTimer>
#include <QMessageBox>
#include <QBuffer>
#include <QMenu>
#include <QDir>
#include <QMimeData>
#include <gui/RetroShareLink.h>
#include "CreateChannelMsg.h"
#include "gui/feeds/SubFileItem.h"
#include "util/misc.h"
#include <retroshare/rschannels.h>
#include <retroshare/rsfiles.h>
#include <iostream>
/** Constructor */
CreateChannelMsg::CreateChannelMsg(std::string cId)
: QDialog (NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mChannelId(cId) ,mCheckAttachment(true), mAutoMediaThumbNail(false)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
headerFrame->setHeaderImage(QPixmap(":/images/channels.png"));
headerFrame->setHeaderText(tr("New Channel Post"));
setAttribute ( Qt::WA_DeleteOnClose, true );
connect(buttonBox, SIGNAL(accepted()), this, SLOT(sendMsg()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancelMsg()));
connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail()));
connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool)));
connect(tabWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
thumbNailCb->setVisible(false);
thumbNailCb->setEnabled(false);
#ifdef CHANNELS_FRAME_CATCHER
fCatcher = new framecatcher();
thumbNailCb->setVisible(true);
thumbNailCb->setEnabled(true);
#endif
//buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
setAcceptDrops(true);
newChannelMsg();
}
void CreateChannelMsg::contextMenu(QPoint /*point*/)
{
QList<RetroShareLink> links ;
RSLinkClipboard::pasteLinks(links) ;
int n_file = 0 ;
for(QList<RetroShareLink>::const_iterator it(links.begin());it!=links.end();++it)
if((*it).type() == RetroShareLink::TYPE_FILE)
n_file++ ;
QMenu contextMnu(this) ;
QAction *action ;
if(n_file > 1)
action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Links"), this, SLOT(pasteLink()));
else
action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
action->setDisabled(n_file < 1) ;
contextMnu.exec(QCursor::pos());
}
void CreateChannelMsg::pasteLink()
{
std::cerr << "Pasting links: " << std::endl;
QList<RetroShareLink> links,not_have ;
RSLinkClipboard::pasteLinks(links) ;
for(QList<RetroShareLink>::const_iterator it(links.begin());it!=links.end();++it)
if((*it).type() == RetroShareLink::TYPE_FILE)
{
// 0 - check that we actually have the file!
//
std::cerr << "Pasting " << (*it).toString().toStdString() << std::endl;
FileInfo info ;
if(rsFiles->alreadyHaveFile( (*it).hash().toStdString(),info ) )
addAttachment((*it).hash().toStdString(), (*it).name().toUtf8().constData(), (*it).size(), true, "") ;
else
not_have.push_back( *it ) ;
}
if(!not_have.empty())
{
QString msg = tr("You are about to add files you're not actually sharing. Do you still want this to happen?")+"<br><br>" ;
for(QList<RetroShareLink>::const_iterator it(not_have.begin());it!=not_have.end();++it)
msg += (*it).toString() + "<br>" ;
if(QMessageBox::YesToAll == QMessageBox::question(NULL,tr("About to post un-owned files to a channel."),msg,QMessageBox::YesToAll | QMessageBox::No))
for(QList<RetroShareLink>::const_iterator it(not_have.begin());it!=not_have.end();++it)
addAttachment((*it).hash().toStdString(), (*it).name().toUtf8().constData(), (*it).size(), false, "") ;
}
}
CreateChannelMsg::~CreateChannelMsg(){
#ifdef CHANNELS_FRAME_CATCHER
delete fCatcher;
#endif
}
/* Dropping */
void CreateChannelMsg::dragEnterEvent(QDragEnterEvent *event)
{
/* print out mimeType */
std::cerr << "CreateChannelMsg::dragEnterEvent() Formats";
std::cerr << std::endl;
QStringList formats = event->mimeData()->formats();
QStringList::iterator it;
for(it = formats.begin(); it != formats.end(); it++)
{
std::cerr << "Format: " << (*it).toStdString();
std::cerr << std::endl;
}
if (event->mimeData()->hasFormat("text/plain"))
{
std::cerr << "CreateChannelMsg::dragEnterEvent() Accepting PlainText";
std::cerr << std::endl;
event->acceptProposedAction();
}
else if (event->mimeData()->hasUrls())
{
std::cerr << "CreateChannelMsg::dragEnterEvent() Accepting Urls";
std::cerr << std::endl;
event->acceptProposedAction();
}
else if (event->mimeData()->hasFormat("application/x-rsfilelist"))
{
std::cerr << "CreateChannelMsg::dragEnterEvent() accepting Application/x-qabs...";
std::cerr << std::endl;
event->acceptProposedAction();
}
else
{
std::cerr << "CreateChannelMsg::dragEnterEvent() No PlainText/Urls";
std::cerr << std::endl;
}
}
void CreateChannelMsg::dropEvent(QDropEvent *event)
{
if (!(Qt::CopyAction & event->possibleActions()))
{
std::cerr << "CreateChannelMsg::dropEvent() Rejecting uncopyable DropAction";
std::cerr << std::endl;
/* can't do it */
return;
}
std::cerr << "CreateChannelMsg::dropEvent() Formats" << std::endl;
QStringList formats = event->mimeData()->formats();
QStringList::iterator it;
for(it = formats.begin(); it != formats.end(); it++)
{
std::cerr << "Format: " << (*it).toStdString();
std::cerr << std::endl;
}
if (event->mimeData()->hasText())
{
std::cerr << "CreateChannelMsg::dropEvent() Plain Text:";
std::cerr << std::endl;
std::cerr << event->mimeData()->text().toStdString();
std::cerr << std::endl;
}
if (event->mimeData()->hasUrls())
{
std::cerr << "CreateChannelMsg::dropEvent() Urls:" << std::endl;
QList<QUrl> urls = event->mimeData()->urls();
QList<QUrl>::iterator uit;
for(uit = urls.begin(); uit != urls.end(); uit++)
{
QString localpath = uit->toLocalFile();
std::cerr << "Whole URL: " << uit->toString().toStdString() << std::endl;
std::cerr << "or As Local File: " << localpath.toStdString() << std::endl;
if (localpath.isEmpty() == false)
{
// Check that the file does exist and is not a directory
QDir dir(localpath);
if (dir.exists()) {
std::cerr << "CreateChannelMsg::dropEvent() directory not accepted."<< std::endl;
QMessageBox mb(tr("Drop file error."), tr("Directory can't be dropped, only files are accepted."),QMessageBox::Information,QMessageBox::Ok,0,0,this);
mb.exec();
} else if (QFile::exists(localpath)) {
addAttachment(localpath.toUtf8().constData());
} else {
std::cerr << "CreateChannelMsg::dropEvent() file does not exists."<< std::endl;
QMessageBox mb(tr("Drop file error."), tr("File not found or file name not accepted."),QMessageBox::Information,QMessageBox::Ok,0,0,this);
mb.exec();
}
}
}
}
else if (event->mimeData()->hasFormat("application/x-rsfilelist"))
{
std::cerr << "CreateChannelMsg::dropEvent() Application/x-rsfilelist";
std::cerr << std::endl;
QByteArray data = event->mimeData()->data("application/x-rsfilelist");
std::cerr << "Data Len:" << data.length();
std::cerr << std::endl;
std::cerr << "Data is:" << data.data();
std::cerr << std::endl;
std::string newattachments(data.data());
parseRsFileListAttachments(newattachments);
}
event->setDropAction(Qt::CopyAction);
event->accept();
}
void CreateChannelMsg::parseRsFileListAttachments(const std::string &attachList)
{
/* split into lines */
QString input = QString::fromStdString(attachList);
QStringList attachItems = input.split("\n");
QStringList::iterator it;
QStringList::iterator it2;
for(it = attachItems.begin(); it != attachItems.end(); it++)
{
std::cerr << "CreateChannelMsg::parseRsFileListAttachments() Entry: ";
QStringList parts = (*it).split("/");
bool ok = false;
quint64 qsize = 0;
std::string fname;
std::string hash;
uint64_t size = 0;
std::string source;
int i = 0;
for(it2 = parts.begin(); it2 != parts.end(); it2++, i++)
{
std::cerr << "\"" << it2->toStdString() << "\" ";
switch(i)
{
case 0:
fname = it2->toStdString();
break;
case 1:
hash = it2->toStdString();
break;
case 2:
qsize = it2->toULongLong(&ok, 10);
size = qsize;
break;
case 3:
source = it2->toStdString();
break;
}
}
std::cerr << std::endl;
std::cerr << "\tfname: " << fname << std::endl;
std::cerr << "\thash: " << hash << std::endl;
std::cerr << "\tsize: " << size << std::endl;
std::cerr << "\tsource: " << source << std::endl;
/* basic error checking */
if ((ok) && (hash.size() == 40))
{
std::cerr << "Item Ok" << std::endl;
if (source == "Local")
{
addAttachment(hash, fname, size, true, "");
}
else
{
// TEMP NOT ALLOWED UNTIL FT WORKING.
addAttachment(hash, fname, size, false, source);
}
}
else
{
std::cerr << "Error Decode: Hash size: " << hash.size() << std::endl;
}
}
}
void CreateChannelMsg::addAttachment(const std::string &hash, const std::string &fname, uint64_t size, bool local, const std::string &srcId)
{
/* add a SubFileItem to the attachment section */
std::cerr << "CreateChannelMsg::addAttachment()";
std::cerr << std::endl;
/* add widget in for new destination */
uint32_t flags = SFI_TYPE_CHANNEL;
if (local)
{
flags |= SFI_STATE_LOCAL;
}
else
{
flags |= SFI_STATE_REMOTE;
}
SubFileItem *file = new SubFileItem(hash, fname, "", size, flags, srcId); // destroyed when fileFrame (this subfileitem) is destroyed
mAttachments.push_back(file);
QLayout *layout = fileFrame->layout();
layout->addWidget(file);
if (mCheckAttachment)
{
checkAttachmentReady();
}
return;
}
void CreateChannelMsg::addExtraFile()
{
/* add a SubFileItem to the attachment section */
std::cerr << "CreateChannelMsg::addExtraFile() opening file dialog";
std::cerr << std::endl;
QStringList files;
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) {
for (QStringList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) {
addAttachment((*fileIt).toUtf8().constData());
}
}
}
void CreateChannelMsg::addAttachment(const std::string &path)
{
/* add a SubFileItem to the attachment section */
std::cerr << "CreateChannelMsg::addAttachment()";
std::cerr << std::endl;
if(mAutoMediaThumbNail)
setThumbNail(path, 2000);
/* add widget in for new destination */
uint32_t flags = SFI_TYPE_CHANNEL | SFI_STATE_EXTRA | SFI_FLAG_CREATE;
// check attachment if hash exists already
std::list<SubFileItem* >::iterator it;
for(it= mAttachments.begin(); it != mAttachments.end(); it++){
if((*it)->FilePath() == path){
QMessageBox::warning(this, tr("RetroShare"),
tr("File already Added and Hashed"),
QMessageBox::Ok, QMessageBox::Ok);
return;
}
}
// channels creates copy of file into channels directory and shares this
FileInfo fInfo;
rsChannels->channelExtraFileHash(path, mChannelId, fInfo);
// file is not innitial
SubFileItem *file = new SubFileItem(fInfo.hash, fInfo.fname, fInfo.path, fInfo.size,
flags, mChannelId); // destroyed when fileFrame (this subfileitem) is destroyed
mAttachments.push_back(file);
QLayout *layout = fileFrame->layout();
layout->addWidget(file);
if (mCheckAttachment)
{
checkAttachmentReady();
}
return;
}
bool CreateChannelMsg::setThumbNail(const std::string& path, int frame){
#ifdef CHANNELS_FRAME_CATCHER
unsigned char* imageBuffer = NULL;
int width = 0, height = 0, errCode = 0;
int length;
std::string errString;
if(1 != (errCode = fCatcher->open(path))){
fCatcher->getError(errCode, errString);
std::cerr << errString << std::endl;
return false;
}
length = fCatcher->getLength();
// make sure frame chosen is at lease a quarter length of video length if not choose quarter length
if(frame < (int) (0.25 * length))
frame = 0.25 * length;
if(1 != (errCode = fCatcher->getRGBImage(frame, imageBuffer, width, height))){
fCatcher->getError(errCode, errString);
std::cerr << errString << std::endl;
return false;
}
if(imageBuffer == NULL)
return false;
QImage tNail(imageBuffer, width, height, QImage::Format_RGB32);
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
tNail.save(&buffer, "PNG");
QPixmap img;
img.loadFromData(ba, "PNG");
img = img.scaled(thumbnail_label->width(), thumbnail_label->height(), Qt::KeepAspectRatio);
thumbnail_label->setPixmap(img);
delete[] imageBuffer;
#else
Q_UNUSED(path);
Q_UNUSED(frame);
#endif
return true;
}
void CreateChannelMsg::allowAutoMediaThumbNail(bool allowThumbNail){
mAutoMediaThumbNail = allowThumbNail;
}
void CreateChannelMsg::checkAttachmentReady()
{
std::list<SubFileItem *>::iterator fit;
mCheckAttachment = false;
for(fit = mAttachments.begin(); fit != mAttachments.end(); fit++)
{
if (!(*fit)->isHidden())
{
if (!(*fit)->ready())
{
/* ensure file is hashed or file will be hashed, thus
* recognized by librs but not correctly by gui (can't
* formally remove it)
*/
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
break;
}
}
}
if (fit == mAttachments.end())
{
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(true);
}
/* repeat... */
int msec_rate = 1000;
QTimer::singleShot( msec_rate, this, SLOT(checkAttachmentReady(void)));
}
void CreateChannelMsg::cancelMsg()
{
std::cerr << "CreateChannelMsg::cancelMsg() :"
<< "Deleting EXTRA attachments" << std::endl;
std::cerr << std::endl;
std::list<SubFileItem* >::const_iterator it;
for(it = mAttachments.begin(); it != mAttachments.end(); it++)
rsChannels->channelExtraFileRemove((*it)->FileHash(), mChannelId);
close();
return;
}
void CreateChannelMsg::newChannelMsg()
{
if (!rsChannels)
return;
ChannelInfo ci;
if (!rsChannels->getChannelInfo(mChannelId, ci))
{
return;
}
channelName->setText(QString::fromStdWString(ci.channelName));
subjectEdit->setFocus();
}
void CreateChannelMsg::sendMsg()
{
std::cerr << "CreateChannelMsg::sendMsg()";
std::cerr << std::endl;
/* construct message bits */
std::wstring subject = misc::removeNewLine(subjectEdit->text()).toStdWString();
std::wstring msg = msgEdit->toPlainText().toStdWString();
std::list<FileInfo> files;
std::list<SubFileItem *>::iterator fit;
for(fit = mAttachments.begin(); fit != mAttachments.end(); fit++)
{
if (!(*fit)->isHidden())
{
FileInfo fi;
fi.hash = (*fit)->FileHash();
fi.fname = (*fit)->FileName();
fi.size = (*fit)->FileSize();
files.push_back(fi);
/* commence downloads - if we don't have the file */
if (!(*fit)->done())
{
if ((*fit)->ready())
{
(*fit)->download();
}
// Skips unhashed files.
}
}
}
sendMessage(subject, msg, files);
}
void CreateChannelMsg::sendMessage(std::wstring subject, std::wstring msg, std::list<FileInfo> &files)
{
QString name = misc::removeNewLine(subjectEdit->text());
if(name.isEmpty())
{ /* error message */
QMessageBox::warning(this, tr("RetroShare"),
tr("Please add a Subject"),
QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add an empty Subject!!
}
else
/* rsChannels */
if (rsChannels)
{
ChannelMsgInfo msgInfo;
msgInfo.channelId = mChannelId;
msgInfo.msgId = "";
msgInfo.subject = subject;
msgInfo.msg = msg;
msgInfo.files = files;
QByteArray ba;
QBuffer buffer(&ba);
if(!picture.isNull()){
// send chan image
buffer.open(QIODevice::WriteOnly);
picture.save(&buffer, "PNG"); // writes image into ba in PNG format
msgInfo.thumbnail.image_thumbnail = (unsigned char*) ba.data();
msgInfo.thumbnail.im_thumbnail_size = ba.size();
}
rsChannels->ChannelMessageSend(msgInfo);
}
close();
return;
}
void CreateChannelMsg::addThumbnail()
{
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load thumbnail picture"), 156, 107);
if (img.isNull())
return;
picture = img;
// to show the selected
thumbnail_label->setPixmap(picture);
}

View file

@ -1,91 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _CREATECHANNELMSG_H
#define _CREATECHANNELMSG_H
#include "ui_CreateChannelMsg.h"
#include <stdint.h>
#ifdef CHANNELS_FRAME_CATCHER
#include "util/framecatcher.h"
#endif
class SubFileItem;
class FileInfo;
class CreateChannelMsg : public QDialog, private Ui::CreateChannelMsg
{
Q_OBJECT
public:
/** Default Constructor */
CreateChannelMsg(std::string cId);
/** Default Destructor */
~CreateChannelMsg();
void addAttachment(const std::string &path);
void addAttachment(const std::string &hash, const std::string &fname, uint64_t size, bool local, const std::string &srcId);
void newChannelMsg();
QPixmap picture;
protected:
virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event);
private slots:
void addExtraFile();
void checkAttachmentReady();
void cancelMsg();
void sendMsg();
void pasteLink() ;
void contextMenu(QPoint) ;
void addThumbnail();
void allowAutoMediaThumbNail(bool);
private:
void parseRsFileListAttachments(const std::string &attachList);
void sendMessage(std::wstring subject, std::wstring msg, std::list<FileInfo> &files);
bool setThumbNail(const std::string& path, int frame);
std::string mChannelId;
std::list<SubFileItem *> mAttachments;
bool mCheckAttachment;
bool mAutoMediaThumbNail;
#ifdef CHANNELS_FRAME_CATCHER
framecatcher* fCatcher;
#endif
};
#endif

View file

@ -1,365 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateChannelMsg</class>
<widget class="QDialog" name="CreateChannelMsg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>581</width>
<height>479</height>
</rect>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>New Channel Post</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="HeaderFrame" name="headerFrame"/>
</item>
<item row="1" column="0">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Channel Post</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Channel Post to:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="channelName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;&quot;&gt;Attachments:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;:/images/feedback_arrow.png&quot; /&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt; Use Drag and Drop / Add Files button, to Hash new files.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;:/images/feedback_arrow.png&quot; /&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt; Copy/Paste RetroShare links from your shares&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="addfilepushButton">
<property name="text">
<string>Add File to Attach</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="addThumbnailButton">
<property name="text">
<string>Add Channel Thumbnail</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QLabel" name="thumbnail_label">
<property name="maximumSize">
<size>
<width>156</width>
<height>107</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/thumb-default-video.png</pixmap>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>12</width>
<height>98</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Message</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Subject :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="subjectEdit"/>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QTextEdit" name="msgEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/attachment.png</normaloff>:/images/attachment.png</iconset>
</attribute>
<attribute name="title">
<string>Attachments</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/attachment.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>26</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Attachments</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>334</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="addFileButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>34</width>
<height>34</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QCheckBox" name="thumbNailCb">
<property name="toolTip">
<string>Allow channels to get frame for message thumbnail from movie media attachments or not</string>
</property>
<property name="text">
<string>Auto Thumbnail</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="5">
<widget class="QScrollArea" name="scrollArea">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>24</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<number>3</number>
</property>
<item>
<widget class="QFrame" name="fileFrame">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Drag and Drop Files from Search Results</string>
</property>
<layout class="QGridLayout" name="gridLayout_3"/>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,116 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2010 Christopher Evi-Parker
*
* 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 "EditChanDetails.h"
#include <retroshare/rschannels.h>
#include "util/misc.h"
#include <list>
#include <iostream>
#include <string>
#define CHAN_DEFAULT_IMAGE ":/images/channels.png"
/** Default constructor */
EditChanDetails::EditChanDetails(QWidget *parent, std::string cId)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mChannelId(cId)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(applyDialog()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect( ui.logoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo()));
ui.logoButton->setDisabled(true);
ui.logoLabel->setDisabled(true);
loadChannel();
}
void EditChanDetails::loadChannel()
{
if (!rsChannels)
{
return;
}
ChannelInfo ci;
rsChannels->getChannelInfo(mChannelId, ci);
// Set Channel Name
ui.nameline->setText(QString::fromStdWString(ci.channelName));
// Set Channel Description
ui.DescriptiontextEdit->setText(QString::fromStdWString(ci.channelDesc));
// Set Channel Logo
QPixmap chanImage;
if(ci.pngImageLen != 0)
{
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
}
else
{
chanImage = QPixmap(CHAN_DEFAULT_IMAGE);
}
ui.logoLabel->setPixmap(chanImage);
}
void EditChanDetails::applyDialog()
{
if(!rsChannels)
return;
// if text boxes have not been edited leave alone
if(!ui.nameline->isModified() && !ui.DescriptiontextEdit->document()->isModified())
return;
ChannelInfo ci;
ci.channelName = misc::removeNewLine(ui.nameline->text()).toStdWString();
ci.channelDesc = ui.DescriptiontextEdit->document()->toPlainText().toStdWString();
/* reload now */
rsChannels->channelEditInfo(mChannelId, ci);
/* close the Dialog after the Changes applied */
close();
return;
}
void EditChanDetails::addChannelLogo() // the same function as in CreateChannel
{
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load channel logo"), 64, 64);
if (img.isNull())
return;
picture = img;
// to show the selected
ui.logoLabel->setPixmap(picture);
}

View file

@ -1,55 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2010 Christopher Evi-Parker
*
* 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.
****************************************************************/
#ifndef _EDITCHANDETAILS_H
#define _EDITCHANDETAILS_H
#include <QDialog>
#include "ui_EditChanDetails.h"
class EditChanDetails : public QDialog
{
Q_OBJECT
public:
/** Default constructor */
EditChanDetails(QWidget *parent = 0, std::string cId = 0);
signals:
void configChanged();
private slots:
void applyDialog();
void addChannelLogo();
private:
void loadChannel();
std::string mChannelId;
QPixmap picture;
/** Qt Designer generated object */
Ui::EditChanDetails ui;
};
#endif

View file

@ -1,143 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditChanDetails</class>
<widget class="QDialog" name="EditChanDetails">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>436</width>
<height>355</height>
</rect>
</property>
<property name="windowTitle">
<string>Channel Details</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<layout class="QGridLayout" name="_2">
<item row="0" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="stabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/info16.png</normaloff>:/images/info16.png</iconset>
</attribute>
<attribute name="title">
<string>Edit Channel Details</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Channel Info</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Channel Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameline"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Channel Description</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTextEdit" name="DescriptiontextEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>118</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="logoButton">
<property name="text">
<string>Add Channel Logo</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="logoLabel">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/channels.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -24,8 +24,8 @@
#include <QMessageBox>
#include <algorithm>
#include <retroshare/rschannels.h>
#include <retroshare/rsforums.h>
//#include <retroshare/rschannels.h>
//#include <retroshare/rsforums.h>
#include <retroshare/rspeers.h>
#include "gui/common/PeerDefs.h"
@ -77,6 +77,7 @@ void ShareKey::shareKey()
return;
}
#if 0
if (mGrpType & CHANNEL_KEY_SHARE) {
if (!rsChannels)
return;
@ -97,6 +98,7 @@ void ShareKey::shareKey()
// incorrect type
return;
}
#endif
close();
}

View file

@ -286,7 +286,7 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
{
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
QString message = QString::fromStdWString(info.msg);
QString message = QString::fromUtf8(info.msg.c_str());
QString name = QString::fromUtf8(info.peer_nickname.c_str());
QString rsid = QString::fromUtf8(info.rsid.c_str());
@ -333,7 +333,7 @@ void ChatLobbyDialog::updateParticipantsList()
std::list<ChatLobbyInfo>::const_iterator it(lInfos.begin());
// Set it to the current ChatLobby
for (; it!=lInfos.end() && (*it).lobby_id != lobbyId; ++it);
for (; it!=lInfos.end() && (*it).lobby_id != lobbyId; ++it) ;
if (it != lInfos.end()) {
ChatLobbyInfo cliInfo=(*it);
@ -484,7 +484,7 @@ bool ChatLobbyDialog::isNicknameInLobby(const QString &nickname) {
std::list<ChatLobbyInfo>::const_iterator it(linfos.begin());
// Set it to the current ChatLobby
for (; it!=linfos.end() && (*it).lobby_id != lobbyId; ++it);
for (; it!=linfos.end() && (*it).lobby_id != lobbyId; ++it) ;
if (it != linfos.end()) {
for (std::map<std::string,time_t>::const_iterator it2((*it).nick_names.begin()); it2 != (*it).nick_names.end(); ++it2) {

View file

@ -145,7 +145,7 @@ void ChatStyle::styleChanged(int styleType)
static QString getBaseDir()
{
// application path
QString baseDir = QString::fromUtf8(RsInit::RsConfigDirectory().c_str());
QString baseDir = QString::fromUtf8(RsAccounts::ConfigDirectory().c_str());
#ifdef WIN32
if (RsInit::isPortable ()) {

View file

@ -725,7 +725,7 @@ void ChatWidget::sendChat()
QString text;
RsHtml::optimizeHtml(chatWidget, text);
std::wstring msg = text.toStdWString();
std::string msg = text.toUtf8().constData();
if (msg.empty()) {
// nothing to send
@ -738,7 +738,7 @@ void ChatWidget::sendChat()
if (rsMsgs->sendPrivateChat(peerId, msg)) {
QDateTime currentTime = QDateTime::currentDateTime();
addChatMsg(false, name, currentTime, currentTime, QString::fromStdWString(msg), MSGTYPE_NORMAL);
addChatMsg(false, name, currentTime, currentTime, text, MSGTYPE_NORMAL);
}
chatWidget->clear();

View file

@ -132,7 +132,7 @@ void PopupChatDialog::addIncomingChatMsg(const ChatInfo& info)
if (cw) {
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
QString message = QString::fromStdWString(info.msg);
QString message = QString::fromUtf8(info.msg.c_str());
QString name = getPeerName(info.rsid) ;
cw->addChatMsg(true, name, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL);
@ -169,7 +169,7 @@ void PopupChatDialog::onChatChanged(int list, int type)
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
QString message = QString::fromStdWString(it->msg);
QString message = QString::fromUtf8(it->msg.c_str());
ui.chatWidget->addChatMsg(false, name, sendTime, recvTime, message, ChatWidget::MSGTYPE_OFFLINE);
}
@ -188,7 +188,7 @@ void PopupChatDialog::onChatChanged(int list, int type)
for(it = savedOfflineChat.begin(); it != savedOfflineChat.end(); ++it) {
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
QString message = QString::fromStdWString(it->msg);
QString message = QString::fromUtf8(it->msg.c_str());
ui.chatWidget->addChatMsg(false, name, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL);
}

View file

@ -144,9 +144,6 @@ QString StatusDefs::connectStateString(RsPeerDetails &details)
case 0:
stateString = peerStateString(details.state);
break;
case RS_PEER_CONNECTSTATE_TRYING_TUNNEL:
stateString = qApp->translate("StatusDefs", "Trying tunnel connection");
break;
case RS_PEER_CONNECTSTATE_TRYING_TCP:
stateString = qApp->translate("StatusDefs", "Trying TCP");
break;
@ -159,9 +156,6 @@ QString StatusDefs::connectStateString(RsPeerDetails &details)
case RS_PEER_CONNECTSTATE_CONNECTED_UDP:
stateString = qApp->translate("StatusDefs", "Connected: UDP");
break;
case RS_PEER_CONNECTSTATE_CONNECTED_TUNNEL:
stateString = qApp->translate("StatusDefs", "Connected: Tunnel");
break;
case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN:
stateString = qApp->translate("StatusDefs", "Connected: Unknown");
break;

View file

@ -197,11 +197,9 @@ void ConfCertDialog::load()
ui.lastcontact->setText(DateTime::formatLongDateTime(detail.lastConnect));
/* set retroshare version */
std::map<std::string, std::string>::iterator vit;
std::map<std::string, std::string> versions;
bool retv = rsDisc->getDiscVersions(versions);
if (retv && versions.end() != (vit = versions.find(detail.id)))
ui.version->setText(QString::fromStdString(vit->second));
std::string version;
rsDisc->getPeerVersion(detail.id, version);
ui.version->setText(QString::fromStdString(version));
RsPeerCryptoParams cdet ;
if(RsControl::instance()->getPeerCryptoDetails(detail.id,cdet) && cdet.connexion_state!=0)
@ -215,15 +213,29 @@ void ConfCertDialog::load()
else
ui.crypto_info->setText(tr("Not connected")) ;
/* set local address */
ui.localAddress->setText(QString::fromStdString(detail.localAddr));
ui.localPort -> setValue(detail.localPort);
/* set the server address */
ui.extAddress->setText(QString::fromStdString(detail.extAddr));
ui.extPort -> setValue(detail.extPort);
ui.dynDNS->setText(QString::fromStdString(detail.dyndns));
if (detail.isHiddenNode)
{
/* set local address */
ui.localAddress->setText("hidden");
ui.localPort -> setValue(0);
/* set the server address */
ui.extAddress->setText("hidden");
ui.extPort -> setValue(0);
ui.dynDNS->setText(QString::fromStdString(detail.hiddenNodeAddress));
}
else
{
/* set local address */
ui.localAddress->setText(QString::fromStdString(detail.localAddr));
ui.localPort -> setValue(detail.localPort);
/* set the server address */
ui.extAddress->setText(QString::fromStdString(detail.extAddr));
ui.extPort -> setValue(detail.extPort);
ui.dynDNS->setText(QString::fromStdString(detail.dyndns));
}
ui.statusline->setText(StatusDefs::connectStateString(detail));
ui.ipAddressList->clear();
@ -398,7 +410,7 @@ void ConfCertDialog::loadInvitePage()
return;
}
std::string invite = rsPeers->GetRetroshareInvite(detail.id,ui._shouldAddSignatures_CB->isChecked(),ui._useOldFormat_CB->isChecked()) ; // this needs to be a SSL id
std::string invite = rsPeers->GetRetroshareInvite(detail.id,ui._shouldAddSignatures_CB->isChecked()) ; // this needs to be a SSL id
ui.userCertificateText->setReadOnly(true);
ui.userCertificateText->setMinimumHeight(200);

File diff suppressed because it is too large Load diff

View file

@ -1,189 +0,0 @@
/****************************************************************
* 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 <QTimer>
#include "BlogMsgItem.h"
#include "FeedHolder.h"
#include "SubFileItem.h"
/****
* #define DEBUG_ITEM 1
****/
/** Constructor */
BlogMsgItem::BlogMsgItem(FeedHolder *parent, uint32_t feedId, std::string peerId, std::string msgId, bool isHome)
:QWidget(NULL), mParent(parent), mFeedId(feedId),
mPeerId(peerId), mMsgId(msgId), mIsHome(isHome)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
//connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
/* specific ones */
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( playMedia ( void ) ) );
small();
updateItemStatic();
updateItem();
}
void BlogMsgItem::updateItemStatic()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "BlogMsgItem::updateItemStatic()";
std::cerr << std::endl;
#endif
msgLabel->setText("What did you expect? \nThe Blogs will be up and running shortly!");
titleLabel->setText("Blog Feed: Jacki @ Friday");
subjectLabel->setText("Brand new exciting Blog stuff");
/* add Files */
int total = (int) (10.0 * (rand() / (RAND_MAX + 1.0)));
int i;
total = 0;
for(i = 0; i < total; i++)
{
/* add file */
SubFileItem *fi = new SubFileItem("dummyHash", "dummy_File", "", 1283918, SFI_STATE_REMOTE, mPeerId);
mFileItems.push_back(fi);
QLayout *layout = expandFrame->layout();
layout->addWidget(fi);
}
playButton->setEnabled(false);
if (mIsHome)
{
/* disable buttons */
clearButton->setEnabled(false);
//gotoButton->setEnabled(false);
clearButton->hide();
}
}
void BlogMsgItem::updateItem()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "BlogMsgItem::updateItem()";
std::cerr << std::endl;
#endif
int msec_rate = 10000;
/* Very slow Tick to check when all files are downloaded */
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
if (!(*it)->done())
{
/* loop again */
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
return;
}
}
if (mFileItems.size() > 0)
{
playButton->setEnabled(true);
}
}
void BlogMsgItem::small()
{
expandFrame->hide();
}
void BlogMsgItem::toggle()
{
mParent->lockLayout(this, true);
if (expandFrame->isHidden())
{
expandFrame->show();
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip(tr("Hide"));
}
else
{
expandFrame->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand"));
}
mParent->lockLayout(this, false);
}
void BlogMsgItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "BlogMsgItem::removeItem()";
std::cerr << std::endl;
#endif
mParent->lockLayout(this, true);
hide();
mParent->lockLayout(this, false);
if (mParent)
{
mParent->deleteFeedItem(this, mFeedId);
}
}
void BlogMsgItem::gotoHome()
{
#ifdef DEBUG_ITEM
std::cerr << "BlogMsgItem::gotoHome()";
std::cerr << std::endl;
#endif
}
/*********** SPECIFIC FUNCTIOSN ***********************/
void BlogMsgItem::playMedia()
{
#ifdef DEBUG_ITEM
std::cerr << "BlogMsgItem::playMedia()";
std::cerr << std::endl;
#endif
}

View file

@ -1,65 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _BLOG_MSG_ITEM_DIALOG_H
#define _BLOG_MSG_ITEM_DIALOG_H
#include "ui_BlogMsgItem.h"
#include <stdint.h>
class FeedHolder;
class SubFileItem;
class BlogMsgItem : public QWidget, private Ui::BlogMsgItem
{
Q_OBJECT
public:
/** Default Constructor */
BlogMsgItem(FeedHolder *parent, uint32_t feedId, const std::string &peerId, const std::string &msgId, bool isHome);
void updateItemStatic();
void small();
private slots:
/* default stuff */
void gotoHome();
void removeItem();
void toggle();
void playMedia();
void updateItem();
private:
FeedHolder *mParent;
uint32_t mFeedId;
std::string mPeerId;
std::string mMsgId;
bool mIsHome;
std::list<SubFileItem *> mFileItems;
};
#endif

View file

@ -1,242 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BlogMsgItem</class>
<widget class="QWidget" name="BlogMsgItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>552</width>
<height>238</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QFrame#frame{
border: 2px solid #6ACEFF;
border-radius: 10px;
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #0076B1, stop:1 #12A3EB);}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Blog</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1000</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Subject</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="subjectLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">subjectLabel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>500</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="playButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Play Media</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/startall.png</normaloff>:/images/startall.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="expandFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QLabel" name="msgLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Long
message here</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,219 +0,0 @@
/****************************************************************
* 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 "BlogNewItem.h"
#include "FeedHolder.h"
#include <retroshare/rsblogs.h>
#define BLOG_DEFAULT_IMAGE ":/images/hi64-app-kblogger.png"
/****
* #define DEBUG_ITEM 1
****/
/** Constructor */
BlogNewItem::BlogNewItem(FeedHolder *parent, uint32_t feedId, std::string blogId, bool isHome, bool isNew)
:QWidget(NULL), mParent(parent), mFeedId(feedId),
mBlogId(blogId), mIsHome(isHome), mIsNew(isNew)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
/* specific ones */
connect( subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeBlog ( void ) ) );
small();
updateItemStatic();
updateItem();
}
void BlogNewItem::updateItemStatic()
{
if (!rsBlogs)
return;
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "BlogNewItem::updateItemStatic()";
std::cerr << std::endl;
#endif
BlogInfo bi;
if (rsBlogs->getBlogInfo(mBlogId, bi))
{
nameLabel->setText(QString::fromStdWString(bi.blogName));
descLabel->setText(QString::fromStdWString(bi.blogDesc));
if(bi.pngImageLen != 0){
QPixmap blogImage;
blogImage.loadFromData(bi.pngChanImage, bi.pngImageLen, "PNG");
logo_label->setPixmap(QPixmap(blogImage));
}else{
QPixmap defaulImage(BLOG_DEFAULT_IMAGE);
logo_label->setPixmap(QPixmap(defaulImage));
}
if (bi.blogFlags & RS_DISTRIB_SUBSCRIBED)
{
subscribeButton->setEnabled(false);
//postButton->setEnabled(true);
}
else
{
subscribeButton->setEnabled(true);
//postButton->setEnabled(false);
}
/* should also check the other flags */
}
else
{
nameLabel->setText(tr("Unknown Blog"));
titleLabel->setText("Blog ???");
descLabel->setText("");
}
if (mIsNew)
{
titleLabel->setText(tr("New Blog"));
}
else
{
titleLabel->setText(tr("Updated Blog"));
}
if (mIsHome)
{
/* disable buttons */
clearButton->setEnabled(false);
//gotoButton->setEnabled(false);
}
}
void BlogNewItem::updateItem()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "BlogNewItem::updateItem()";
std::cerr << std::endl;
#endif
}
void BlogNewItem::small()
{
expandFrame->hide();
}
void BlogNewItem::toggle()
{
mParent->lockLayout(this, true);
if (expandFrame->isHidden())
{
expandFrame->show();
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip(tr("Hide"));
}
else
{
expandFrame->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand"));
}
mParent->lockLayout(this, false);
}
void BlogNewItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "BlogNewItem::removeItem()";
std::cerr << std::endl;
#endif
mParent->lockLayout(this, true);
hide();
mParent->lockLayout(this, false);
if (mParent)
{
mParent->deleteFeedItem(this, mFeedId);
}
}
void BlogNewItem::gotoHome()
{
#ifdef DEBUG_ITEM
std::cerr << "BlogNewItem::gotoHome()";
std::cerr << std::endl;
#endif
}
/*********** SPECIFIC FUNCTIOSN ***********************/
void BlogNewItem::unsubscribeBlog()
{
#ifdef DEBUG_ITEM
std::cerr << "BlogNewItem::unsubscribeBlog()";
std::cerr << std::endl;
#endif
if (rsBlogs)
{
rsBlogs->blogSubscribe(mBlogId, false);
}
updateItemStatic();
}
void BlogNewItem::subscribeBlog()
{
#ifdef DEBUG_ITEM
std::cerr << "BlogNewItem::subscribeBlog()";
std::cerr << std::endl;
#endif
if (rsBlogs)
{
rsBlogs->blogSubscribe(mBlogId, true);
}
updateItemStatic();
}

View file

@ -1,62 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _BLOG_NEW_ITEM_DIALOG_H
#define _BLOG_NEW_ITEM_DIALOG_H
#include "ui_BlogNewItem.h"
#include <stdint.h>
class FeedHolder;
class BlogNewItem : public QWidget, private Ui::BlogNewItem
{
Q_OBJECT
public:
/** Default Constructor */
BlogNewItem(FeedHolder *parent, uint32_t feedId, const std::string &blogId, bool isHome, bool isNew);
void updateItemStatic();
void small();
private slots:
/* default stuff */
void gotoHome();
void removeItem();
void toggle();
void unsubscribeBlog();
void subscribeBlog();
void updateItem();
private:
FeedHolder *mParent;
uint32_t mFeedId;
std::string mBlogId;
bool mIsHome;
bool mIsNew;
};
#endif

View file

@ -1,260 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BlogNewItem</class>
<widget class="QWidget" name="BlogNewItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>109</height>
</rect>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QFrame#frame{
border: 2px solid #6ACEFF;
border-radius: 10px;
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #0076B1, stop:1 #12A3EB);}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout">
<property name="topMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">New Blog</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="logo_label">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string notr="true">Logo</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="nameLabel">
<property name="text">
<string notr="true">name</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>500</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="subscribeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Subscribe to Blog</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/directoryadd_24x24_shadow.png</normaloff>:/images/directoryadd_24x24_shadow.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="expandFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Blog Description</string>
</property>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="iconLabel">
<property name="text">
<string notr="true"/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/contacts24.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="descLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Description
of Blog</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,475 +0,0 @@
/****************************************************************
* 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 <QDateTime>
#include <QTimer>
#include <QFileInfo>
#include "rshare.h"
#include "ChanMsgItem.h"
#include "FeedHolder.h"
#include "SubFileItem.h"
#include "gui/notifyqt.h"
#include "util/misc.h"
#include "gui/RetroShareLink.h"
#include "util/HandleRichText.h"
#include "util/DateTime.h"
#include <retroshare/rschannels.h>
/****
* #define DEBUG_ITEM 1
****/
#define COLOR_NORMAL QColor(248, 248, 248)
#define COLOR_NEW QColor(220, 236, 253)
/** Constructor */
ChanMsgItem::ChanMsgItem(FeedHolder *parent, uint32_t feedId, const std::string &chanId, const std::string &msgId, bool isHome)
:QWidget(NULL), mParent(parent), mFeedId(feedId),
mChanId(chanId), mMsgId(msgId), mIsHome(isHome)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
m_inUpdateItemStatic = false;
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
/* specific */
connect(readAndClearButton, SIGNAL(clicked()), this, SLOT(readAndClearItem()));
connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) );
connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( download ( void ) ) );
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) );
connect( copyLinkButton, SIGNAL( clicked( void ) ), this, SLOT( copyLink ( void ) ) );
connect( readButton, SIGNAL( toggled(bool) ), this, SLOT( readToggled(bool) ) );
connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
downloadButton->hide();
playButton->hide();
warn_image_label->hide();
warning_label->hide();
titleLabel->setMinimumWidth(100);
subjectLabel->setMinimumWidth(100);
warning_label->setMinimumWidth(100);
frame->setProperty("state", "");
QPalette palette = frame->palette();
palette.setColor(frame->backgroundRole(), COLOR_NORMAL);
frame->setPalette(palette);
expandFrame->hide();
updateItemStatic();
updateItem();
}
void ChanMsgItem::updateItemStatic()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "ChanMsgItem::updateItemStatic()";
std::cerr << std::endl;
#endif
ChannelMsgInfo cmi;
if (!rsChannels)
return;
if (!rsChannels->getChannelMessage(mChanId, mMsgId, cmi))
return;
m_inUpdateItemStatic = true;
QString title;
ChannelInfo ci;
rsChannels->getChannelInfo(mChanId, ci);
if (!mIsHome)
{
title = tr("Channel Feed") + ": ";
RetroShareLink link;
link.createChannel(ci.channelId, "");
title += link.toHtml();
titleLabel->setText(title);
RetroShareLink msgLink;
msgLink.createChannel(cmi.channelId, cmi.msgId);
subjectLabel->setText(msgLink.toHtml());
if ((ci.channelFlags & RS_DISTRIB_SUBSCRIBED) || (ci.channelFlags & RS_DISTRIB_ADMIN)) {
unsubscribeButton->setEnabled(true);
} else {
unsubscribeButton->setEnabled(false);
}
readButton->hide();
newLabel->hide();
copyLinkButton->hide();
}
else
{
/* subject */
titleLabel->setText(QString::fromStdWString(cmi.subject));
subjectLabel->setText(RsHtml().formatText(NULL, QString::fromStdWString(cmi.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
/* disable buttons: deletion facility not enabled with cache services yet */
clearButton->setEnabled(false);
unsubscribeButton->setEnabled(false);
clearButton->hide();
readAndClearButton->hide();
unsubscribeButton->hide();
copyLinkButton->show();
if ((ci.channelFlags & RS_DISTRIB_SUBSCRIBED) || (ci.channelFlags & RS_DISTRIB_ADMIN)) {
readButton->setVisible(true);
uint32_t status = 0;
rsChannels->getMessageStatus(mChanId, mMsgId, status);
if ((status & CHANNEL_MSG_STATUS_READ) == 0 || (status & CHANNEL_MSG_STATUS_UNREAD_BY_USER)) {
readButton->setChecked(true);
readButton->setIcon(QIcon(":/images/message-state-unread.png"));
} else {
readButton->setChecked(false);
readButton->setIcon(QIcon(":/images/message-state-read.png"));
}
bool newState;
QColor color;
if (status & CHANNEL_MSG_STATUS_READ) {
newLabel->setVisible(false);
newState = false;
color = COLOR_NORMAL;
} else {
newLabel->setVisible(true);
newState = true;
color = COLOR_NEW;
}
/* unpolish widget to clear the stylesheet's palette cache */
frame->style()->unpolish(frame);
QPalette palette = frame->palette();
palette.setColor(frame->backgroundRole(), color);
frame->setPalette(palette);
frame->setProperty("new", newState);
Rshare::refreshStyleSheet(frame, false);
} else {
readButton->setVisible(false);
newLabel->setVisible(false);
}
}
msgLabel->setText(RsHtml().formatText(NULL, QString::fromStdWString(cmi.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
msgFrame->setVisible(!cmi.msg.empty());
datetimelabel->setText(DateTime::formatLongDateTime(cmi.ts));
filelabel->setText(QString("(%1 %2) %3").arg(cmi.count).arg(tr("Files")).arg(misc::friendlyUnit(cmi.size)));
if (mFileItems.empty() == false) {
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
delete(*it);
}
mFileItems.clear();
}
std::list<FileInfo>::iterator it;
for(it = cmi.files.begin(); it != cmi.files.end(); it++)
{
/* add file */
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size,
SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, "");
fi->setChannelId(mChanId);
mFileItems.push_back(fi);
/* check if the file is a media file */
if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->fname.c_str())).suffix()))
{
fi->mediatype();
playButton->setText(tr("Open"));
playButton->setToolTip(tr("Open File"));
}
else
{
playButton->setText(tr("Play"));
playButton->setToolTip(tr("Play Media"));
}
QLayout *layout = expandFrame->layout();
layout->addWidget(fi);
}
if(cmi.thumbnail.image_thumbnail != NULL)
{
QPixmap thumbnail;
thumbnail.loadFromData(cmi.thumbnail.image_thumbnail, cmi.thumbnail.im_thumbnail_size, "PNG");
logoLabel->setPixmap(thumbnail);
}
m_inUpdateItemStatic = false;
}
void ChanMsgItem::setFileCleanUpWarning(uint32_t time_left)
{
int hours = (int)time_left/3600;
int minutes = (time_left - hours*3600)%60;
warning_label->setText(tr("Warning! You have less than %1 hours and %2 minute before this file is deleted Consider saving it.").arg(
QString::number(hours)).arg(QString::number(minutes)));
QFont warnFont = warning_label->font();
warnFont.setBold(true);
warning_label->setFont(warnFont);
warn_image_label->setVisible(true);
warning_label->setVisible(true);
return;
}
void ChanMsgItem::updateItem()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "ChanMsgItem::updateItem()";
std::cerr << std::endl;
#endif
int msec_rate = 10000;
int downloadCount = 0;
int downloadStartable = 0;
int playCount = 0;
int playStartable = 0;
bool startable;
bool loopAgain = false;
/* Very slow Tick to check when all files are downloaded */
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
SubFileItem *item = *it;
if (item->isDownloadable(startable)) {
downloadCount++;
if (startable) {
downloadStartable++;
}
}
if (item->isPlayable(startable)) {
playCount++;
if (startable) {
playStartable++;
}
}
if (!item->done())
{
/* loop again */
loopAgain = true;
}
}
if (downloadCount) {
downloadButton->show();
if (downloadStartable) {
downloadButton->setEnabled(true);
} else {
downloadButton->setEnabled(false);
}
} else {
downloadButton->hide();
}
if (playCount) {
/* one file is playable */
playButton->show();
if (playStartable == 1) {
playButton->setEnabled(true);
} else {
playButton->setEnabled(false);
}
} else {
playButton->hide();
}
if (loopAgain) {
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
}
}
void ChanMsgItem::toggle()
{
mParent->lockLayout(this, true);
if (expandFrame->isHidden())
{
expandFrame->show();
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip(tr("Hide"));
readToggled(false);
}
else
{
expandFrame->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand"));
}
mParent->lockLayout(this, false);
}
void ChanMsgItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "ChanMsgItem::removeItem()";
std::cerr << std::endl;
#endif
mParent->lockLayout(this, true);
hide();
mParent->lockLayout(this, false);
if (mParent)
{
mParent->deleteFeedItem(this, mFeedId);
}
}
/*********** SPECIFIC FUNCTIONS ***********************/
void ChanMsgItem::readAndClearItem()
{
#ifdef DEBUG_ITEM
std::cerr << "ChanMsgItem::readAndClearItem()";
std::cerr << std::endl;
#endif
readToggled(false);
removeItem();
}
void ChanMsgItem::unsubscribeChannel()
{
#ifdef DEBUG_ITEM
std::cerr << "ChanMsgItem::unsubscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels)
{
rsChannels->channelSubscribe(mChanId, false, false);
}
updateItemStatic();
}
void ChanMsgItem::download()
{
readToggled(false);
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
(*it)->download();
}
updateItem();
}
void ChanMsgItem::play()
{
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
bool startable;
if ((*it)->isPlayable(startable) && startable) {
(*it)->play();
}
}
}
void ChanMsgItem::readToggled(bool checked)
{
if (m_inUpdateItemStatic) {
return;
}
/* set always as read ... */
uint32_t statusNew = CHANNEL_MSG_STATUS_READ;
if (checked) {
/* ... and as unread by user */
statusNew |= CHANNEL_MSG_STATUS_UNREAD_BY_USER;
} else {
/* ... and as read by user */
statusNew &= ~CHANNEL_MSG_STATUS_UNREAD_BY_USER;
}
if (!mIsHome) {
disconnect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
}
rsChannels->setMessageStatus(mChanId, mMsgId, statusNew, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER);
if (!mIsHome) {
connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
}
}
void ChanMsgItem::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status)
{
if (channelId.toStdString() == mChanId && msgId.toStdString() == mMsgId) {
if (!mIsHome) {
if (status & CHANNEL_MSG_STATUS_READ) {
close();
return;
}
}
updateItemStatic();
}
}
void ChanMsgItem::copyLink()
{
if (mChanId.empty() || mMsgId.empty()) {
return;
}
ChannelMsgInfo cmi;
if (rsChannels->getChannelMessage(mChanId, mMsgId, cmi)) {
RetroShareLink link;
if (link.createChannel(cmi.channelId, cmi.msgId)) {
QList<RetroShareLink> urls;
urls.push_back(link);
RSLinkClipboard::copyLinks(urls);
}
}
}

View file

@ -1,74 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _CHAN_MSG_ITEM_DIALOG_H
#define _CHAN_MSG_ITEM_DIALOG_H
#include "ui_ChanMsgItem.h"
#include <stdint.h>
class FeedHolder;
class SubFileItem;
class ChanMsgItem : public QWidget, private Ui::ChanMsgItem
{
Q_OBJECT
public:
/** Default Constructor */
ChanMsgItem(FeedHolder *parent, uint32_t feedId, const std::string &chanId, const std::string &msgId, bool isHome);
void updateItemStatic();
void setFileCleanUpWarning(uint32_t time_left);
const std::string &msgId() { return mMsgId; }
private slots:
/* default stuff */
void removeItem();
void toggle();
void readAndClearItem();
void unsubscribeChannel();
void download();
void play();
void copyLink();
void readToggled(bool checked);
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
void updateItem();
private:
FeedHolder *mParent;
uint32_t mFeedId;
std::string mChanId;
std::string mMsgId;
bool mIsHome;
bool m_inUpdateItemStatic;
std::list<SubFileItem *> mFileItems;
};
#endif

View file

@ -1,496 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChanMsgItem</class>
<widget class="QWidget" name="ChanMsgItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>629</width>
<height>175</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<property name="margin">
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="logoLabel">
<property name="minimumSize">
<size>
<width>158</width>
<height>108</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>158</width>
<height>108</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/thumb-default-video.png</pixmap>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="text">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:11pt; font-weight:600; font-style:italic;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:normal; color:#656565;&quot;&gt;Channel Subject&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="datetimelabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="text">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; color:#666666;&quot;&gt;DateTime&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="subjectLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="text">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; color:#666666;&quot;&gt;Short Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="filelabel">
<property name="font">
<font>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="text">
<string notr="true">fileLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="warn_image_label">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/status_unknown.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="warning_label">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>8</number>
</property>
<item>
<widget class="QPushButton" name="readButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Toggle Message Read Status</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/message-state-unread.png</normaloff>:/images/message-state-unread.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="newLabel">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>21</height>
</size>
</property>
<property name="text">
<string>New</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="downloadButton">
<property name="font">
<font/>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Download</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/download16.png</normaloff>:/images/download16.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="playButton">
<property name="font">
<font/>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Play</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/player_play.png</normaloff>:/images/player_play.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="copyLinkButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Copy RetroShare Link</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/copyrslink.png</normaloff>:/images/copyrslink.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="unsubscribeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Unsubscribe From Channel</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_delete.png</normaloff>:/images/mail_delete.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="readAndClearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Set as read and remove item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/cancel.png</normaloff>:/images/cancel.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="expandFrame">
<layout class="QVBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="msgFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="msgLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>6</number>
</property>
<property name="indent">
<number>-1</number>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,205 +0,0 @@
/****************************************************************
* 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 "ChanNewItem.h"
#include "FeedHolder.h"
#include "gui/RetroShareLink.h"
#include <retroshare/rschannels.h>
#define CHAN_DEFAULT_IMAGE ":/images/channels.png"
/****
* #define DEBUG_ITEM 1
****/
/** Constructor */
ChanNewItem::ChanNewItem(FeedHolder *parent, uint32_t feedId, const std::string &chanId, bool isHome, bool isNew)
:QWidget(NULL), mParent(parent), mFeedId(feedId),
mChanId(chanId), mIsHome(isHome), mIsNew(isNew)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
/* specific ones */
connect( subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeChannel ( void ) ) );
expandFrame->hide();
updateItemStatic();
updateItem();
}
void ChanNewItem::updateItemStatic()
{
if (!rsChannels)
return;
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "ChanNewItem::updateItemStatic()";
std::cerr << std::endl;
#endif
ChannelInfo ci;
if (rsChannels->getChannelInfo(mChanId, ci))
{
RetroShareLink link;
link.createChannel(ci.channelId, "");
nameLabel->setText(link.toHtml());
descLabel->setText(QString::fromStdWString(ci.channelDesc));
if(ci.pngImageLen != 0){
QPixmap chanImage;
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
logoLabel->setPixmap(QPixmap(chanImage));
} else {
QPixmap defaulImage(CHAN_DEFAULT_IMAGE);
logoLabel->setPixmap(QPixmap(defaulImage));
}
if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
{
subscribeButton->setEnabled(false);
//postButton->setEnabled(true);
}
else
{
subscribeButton->setEnabled(true);
//postButton->setEnabled(false);
}
/* should also check the other flags */
}
else
{
nameLabel->setText(tr("Unknown Channel"));
titleLabel->setText("Channel ???");
descLabel->setText("");
}
if (mIsNew)
{
titleLabel->setText(tr("New Channel"));
}
else
{
titleLabel->setText(tr("Updated Channel"));
}
if (mIsHome)
{
/* disable buttons */
clearButton->setEnabled(false);
}
}
void ChanNewItem::updateItem()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "ChanNewItem::updateItem()";
std::cerr << std::endl;
#endif
}
void ChanNewItem::toggle()
{
mParent->lockLayout(this, true);
if (expandFrame->isHidden())
{
expandFrame->show();
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip(tr("Hide"));
}
else
{
expandFrame->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand"));
}
mParent->lockLayout(this, false);
}
void ChanNewItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "ChanNewItem::removeItem()";
std::cerr << std::endl;
#endif
mParent->lockLayout(this, true);
hide();
mParent->lockLayout(this, false);
if (mParent)
{
mParent->deleteFeedItem(this, mFeedId);
}
}
/*********** SPECIFIC FUNCTIOSN ***********************/
void ChanNewItem::unsubscribeChannel()
{
#ifdef DEBUG_ITEM
std::cerr << "ChanNewItem::unsubscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels)
{
rsChannels->channelSubscribe(mChanId, false, false);
}
updateItemStatic();
}
void ChanNewItem::subscribeChannel()
{
#ifdef DEBUG_ITEM
std::cerr << "ChanNewItem::subscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels)
{
rsChannels->channelSubscribe(mChanId, true, true);
}
updateItemStatic();
}

View file

@ -1,60 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _CHANNEL_NEW_ITEM_DIALOG_H
#define _CHANNEL_NEW_ITEM_DIALOG_H
#include "ui_ChanNewItem.h"
#include <stdint.h>
class FeedHolder;
class ChanNewItem : public QWidget, private Ui::ChanNewItem
{
Q_OBJECT
public:
/** Default Constructor */
ChanNewItem(FeedHolder *parent, uint32_t feedId, const std::string &chanId, bool isHome, bool isNew);
void updateItemStatic();
private slots:
/* default stuff */
void removeItem();
void toggle();
void unsubscribeChannel();
void subscribeChannel();
void updateItem();
private:
FeedHolder *mParent;
uint32_t mFeedId;
std::string mChanId;
bool mIsHome;
bool mIsNew;
};
#endif

View file

@ -1,284 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChanNewItem</class>
<widget class="QWidget" name="ChanNewItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>157</height>
</rect>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>248</red>
<green>248</green>
<blue>248</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>248</red>
<green>248</green>
<blue>248</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>248</red>
<green>248</green>
<blue>248</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout">
<item row="0" column="0" rowspan="2">
<layout class="QGridLayout">
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="logoLabel">
<property name="minimumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string notr="true">name</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">New Channel</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>338</width>
<height>28</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="subscribeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Subscribe to Channel</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/directoryadd_24x24_shadow.png</normaloff>:/images/directoryadd_24x24_shadow.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>455</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<widget class="QFrame" name="expandFrame">
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Channel Description</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="iconLabel">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/contacts24.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="descLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Description
of Channel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -243,8 +243,8 @@ void ChatMsgItem::sendMessage()
/* construct a message */
MessageInfo mi;
mi.title = tr("Quick Message").toStdWString();
mi.msg = quickmsgText->toHtml().toStdWString();
mi.title = tr("Quick Message").toUtf8().constData();
mi.msg = quickmsgText->toHtml().toUtf8().constData();
mi.msgto.push_back(mPeerId);
rsMsgs->MessageSend(mi);

View file

@ -1,442 +0,0 @@
/****************************************************************
* 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 <QDateTime>
#include <QMessageBox>
#include "ForumMsgItem.h"
#include "FeedHolder.h"
#include "gui/RetroShareLink.h"
#include <retroshare/rsforums.h>
#include <retroshare/rsmsgs.h>
#include <retroshare/rspeers.h>
#include "gui/forums/CreateForumMsg.h"
#include "util/HandleRichText.h"
#include "util/DateTime.h"
#include "gui/common/AvatarDefs.h"
#include "gui/notifyqt.h"
#include "gui/ForumsDialog.h"
//#include "gui/settings/rsharesettings.h"
/****
* #define DEBUG_ITEM 1
****/
/** Constructor */
ForumMsgItem::ForumMsgItem(FeedHolder *parent, uint32_t feedId, const std::string &forumId, const std::string &postId, bool isHome)
:QWidget(NULL), mParent(parent), mFeedId(feedId), mForumId(forumId), mPostId(postId), mIsHome(isHome), mIsTop(false)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
/* specific ones */
connect(readAndClearButton, SIGNAL(clicked()), this, SLOT(readAndClearItem()));
connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeForum ( void ) ) );
connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyToPost ( void ) ) );
connect( sendButton, SIGNAL( clicked( ) ), this, SLOT( sendMsg() ) );
connect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
subjectLabel->setMinimumWidth(20);
nextFrame->hide();
prevFrame->hide();
updateItemStatic();
updateItem();
textEdit->hide();
sendButton->hide();
signedcheckBox->hide();
}
void ForumMsgItem::updateItemStatic()
{
if (!rsForums)
return;
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "ForumMsgItem::updateItemStatic()";
std::cerr << std::endl;
#endif
canReply = false;
ForumInfo fi;
if (rsForums->getForumInfo(mForumId, fi))
{
RetroShareLink link;
link.createForum(fi.forumId, "");
QString title = tr("Forum Post") + ": ";
title += link.toHtml();
titleLabel->setText(title);
if (fi.subscribeFlags & (RS_DISTRIB_ADMIN | RS_DISTRIB_SUBSCRIBED))
{
unsubscribeButton->setEnabled(true);
replyButton->setEnabled(true);
if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ)
{
signedcheckBox->setChecked(true);
signedcheckBox->setEnabled(false);
}
canReply = true;
}
else
{
unsubscribeButton->setEnabled(false);
replyButton->setEnabled(false);
}
}
else
{
titleLabel->setText(tr("Unknown Forum Post"));
}
if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ) {
iconLabel->setPixmap(QPixmap(":/images/konv_message64.png"));
} else {
iconLabel->setPixmap(QPixmap(":/images/konversation64.png"));
}
/* get actual Message */
ForumMsgInfo msg;
if (rsForums->getForumMessage(mForumId, mPostId, msg))
{
#ifdef DEBUG_ITEM
std::cerr << "Ids: MsgId: " << msg.msgId;
std::cerr << std::endl;
std::cerr << "Ids: ParentId: " << msg.parentId;
std::cerr << std::endl;
std::cerr << "Ids: ThreadId: " << msg.threadId;
std::cerr << std::endl;
#endif
/* decide if top or not */
if ((msg.msgId == msg.threadId) || (msg.threadId == ""))
{
mIsTop = true;
}
RetroShareLink link;
link.createForum(msg.forumId, msg.msgId);
if (mIsTop)
{
avatar->setId(msg.srcId, true);
if (rsPeers->getPeerName(msg.srcId) !="")
{
RetroShareLink linkMessage;
linkMessage.createMessage(msg.srcId, "");
nameLabel->setText(linkMessage.toHtml());
}
else
{
nameLabel->setText(tr("Anonymous"));
}
prevSubLabel->setText(link.toHtml());
prevMsgLabel->setText(RsHtml().formatText(NULL, ForumsDialog::messageFromInfo(msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
timestamplabel->setText(DateTime::formatLongDateTime(msg.ts));
nextFrame->hide();
}
else
{
nextAvatar->setId(msg.srcId, true);
if (rsPeers->getPeerName(msg.srcId) !="")
{
RetroShareLink linkMessage;
linkMessage.createMessage(msg.srcId, "");
nextNameLabel->setText(linkMessage.toHtml());
}
else
{
nextNameLabel->setText(tr("Anonymous"));
}
nextSubLabel->setText(link.toHtml());
nextMsgLabel->setText(RsHtml().formatText(NULL, ForumsDialog::messageFromInfo(msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
timestamplabel->setText(DateTime::formatLongDateTime(msg.ts));
prevSHLabel->setText(tr("In Reply to") + ": ");
ForumMsgInfo msgParent;
if (rsForums->getForumMessage(mForumId, msg.parentId, msgParent))
{
avatar->setId(msgParent.srcId, true);
RetroShareLink linkParent;
linkParent.createForum(msgParent.forumId, msgParent.msgId);
prevSubLabel->setText(linkParent.toHtml());
prevMsgLabel->setText(RsHtml().formatText(NULL, ForumsDialog::messageFromInfo(msgParent), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
if (rsPeers->getPeerName(msgParent.srcId) !="")
{
RetroShareLink linkMessage;
linkMessage.createMessage(msgParent.srcId, "");
nameLabel->setText(linkMessage.toHtml());
}
else
{
nameLabel->setText(tr("Anonymous"));
}
}
else
{
prevSubLabel->setText("???");
prevMsgLabel->setText("???");
}
}
/* header stuff */
subjectLabel->setText(link.toHtml());
//srcLabel->setText(QString::fromStdString(msg.srcId));
}
if (mIsHome)
{
/* disable buttons */
clearButton->setEnabled(false);
//gotoButton->setEnabled(false);
clearButton->hide();
}
unsubscribeButton->hide();
}
void ForumMsgItem::updateItem()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "ForumMsgItem::updateItem()";
std::cerr << std::endl;
#endif
}
void ForumMsgItem::toggle()
{
mParent->lockLayout(this, true);
if (prevFrame->isHidden())
{
prevFrame->show();
textEdit->setVisible(canReply);
sendButton->setVisible(canReply);
signedcheckBox->setVisible(canReply);
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip(tr("Hide"));
if (!mIsTop)
{
nextFrame->show();
}
setAsRead();
}
else
{
prevFrame->hide();
nextFrame->hide();
textEdit->hide();
sendButton->hide();
signedcheckBox->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand"));
}
mParent->lockLayout(this, false);
}
void ForumMsgItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "ForumMsgItem::removeItem()";
std::cerr << std::endl;
#endif
mParent->lockLayout(this, true);
hide();
mParent->lockLayout(this, false);
if (mParent)
{
mParent->deleteFeedItem(this, mFeedId);
}
}
/*********** SPECIFIC FUNCTIOSN ***********************/
void ForumMsgItem::readAndClearItem()
{
#ifdef DEBUG_ITEM
std::cerr << "ForumMsgItem::readAndClearItem()";
std::cerr << std::endl;
#endif
setAsRead();
removeItem();
}
void ForumMsgItem::unsubscribeForum()
{
#ifdef DEBUG_ITEM
std::cerr << "ForumMsgItem::unsubscribeForum()";
std::cerr << std::endl;
#endif
if (rsForums)
{
rsForums->forumSubscribe(mForumId, false);
}
updateItemStatic();
}
void ForumMsgItem::subscribeForum()
{
#ifdef DEBUG_ITEM
std::cerr << "ForumMsgItem::subscribeForum()";
std::cerr << std::endl;
#endif
if (rsForums)
{
rsForums->forumSubscribe(mForumId, true);
}
updateItemStatic();
}
void ForumMsgItem::replyToPost()
{
if (canReply == false) {
return;
}
#ifdef DEBUG_ITEM
std::cerr << "ForumMsgItem::replyToPost()";
std::cerr << std::endl;
#endif
if (mParent)
{
CreateForumMsg *cfm = new CreateForumMsg(mForumId, mPostId);
cfm->show();
}
}
void ForumMsgItem::sendMsg()
{
if (canReply == false) {
return;
}
if(textEdit->toPlainText().isEmpty())
{ /* error message */
QMessageBox::warning(this, "RetroShare",tr("Please give a Text Message"),
QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty Message!!
}
ForumMsgInfo msg;
/* get message */
if (rsForums->getForumMessage(mForumId, mPostId, msg)) {
ForumMsgInfo msgInfo;
msgInfo.forumId = mForumId;
msgInfo.threadId = "";
msgInfo.parentId = mPostId;
msgInfo.msgId = "";
/* modify title */
QString text = QString::fromStdWString(msg.title);
if (text.startsWith("Re:", Qt::CaseInsensitive)) {
msgInfo.title = msg.title;
} else {
msgInfo.title = L"Re: " + msg.title;
}
QString desc;
RsHtml::optimizeHtml(textEdit, desc);
msgInfo.msg = desc.toStdWString();
msgInfo.msgflags = 0;
if (signedcheckBox->isChecked())
{
msgInfo.msgflags = RS_DISTRIB_AUTHEN_REQ;
}
if ((msgInfo.msg == L"") && (msgInfo.title == L""))
return; /* do nothing */
if (rsForums->ForumMessageSend(msgInfo) == true) {
textEdit->clear();
}
}
}
void ForumMsgItem::forumMsgReadSatusChanged(const QString &forumId, const QString &msgId, int status)
{
if (mForumId == forumId.toStdString() && mPostId == msgId.toStdString()) {
if (status & FORUM_MSG_STATUS_READ) {
close();
}
}
}
void ForumMsgItem::setAsRead()
{
if (canReply) {
uint32_t status;
rsForums->getMessageStatus(mForumId, mPostId, status);
/* set always to read ... */
uint32_t statusNew = status | FORUM_MSG_STATUS_READ;
// bool setToReadOnActive = Settings->getForumMsgSetToReadOnActivate();
// if (setToReadOnActive) {
/* ... and to read by user */
statusNew &= ~FORUM_MSG_STATUS_UNREAD_BY_USER;
// } else {
// /* ... and to unread by user */
// statusNew |= FORUM_MSG_STATUS_UNREAD_BY_USER;
// }
if (status != statusNew) {
disconnect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int)));
rsForums->setMessageStatus(mForumId, mPostId, statusNew, FORUM_MSG_STATUS_READ | FORUM_MSG_STATUS_UNREAD_BY_USER);
connect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
}
}
}

View file

@ -1,69 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _FORUM_MSG_ITEM_DIALOG_H
#define _FORUM_MSG_ITEM_DIALOG_H
#include "ui_ForumMsgItem.h"
class FeedHolder;
#include <stdint.h>
class ForumMsgItem : public QWidget, private Ui::ForumMsgItem
{
Q_OBJECT
public:
/** Default Constructor */
ForumMsgItem(FeedHolder *parent, uint32_t feedId, const std::string &forumId, const std::string &postId, bool isHome);
void updateItemStatic();
private slots:
/* default stuff */
void removeItem();
void toggle();
void readAndClearItem();
void unsubscribeForum();
void subscribeForum();
void replyToPost();
void sendMsg();
void forumMsgReadSatusChanged(const QString &forumId, const QString &msgId, int status);
void updateItem();
private:
void setAsRead();
FeedHolder *mParent;
uint32_t mFeedId;
bool canReply;
std::string mForumId;
std::string mPostId;
bool mIsHome;
bool mIsTop;
};
#endif

View file

@ -1,664 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ForumMsgItem</class>
<widget class="QWidget" name="ForumMsgItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>577</width>
<height>387</height>
</rect>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="2" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="iconLabel">
<property name="minimumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/konversation64.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Forum Name</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QGridLayout">
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>358</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLabel" name="timestamplabel">
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Timestamp</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>518</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Subject: </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="subjectLabel">
<property name="text">
<string notr="true">Subject...</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="unsubscribeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Unsubscribe To Forum</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_delete.png</normaloff>:/images/mail_delete.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="replyButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Reply</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/replymail24.png</normaloff>:/images/replymail24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="readAndClearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Set as read and remove item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/cancel.png</normaloff>:/images/cancel.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QFrame" name="prevFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout">
<item row="0" column="0" rowspan="2">
<widget class="AvatarWidget" name="avatar">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="nameLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Friend Name</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="2">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="prevSHLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Subject: </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="prevSubLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Message is about ???</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0" rowspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>9</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="prevMsgLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Previous Message...</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QFrame" name="nextFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout">
<item row="0" column="0" rowspan="3">
<widget class="AvatarWidget" name="nextAvatar">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="nextNameLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Next Name</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Subject: </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="nextSubLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Message is about ???</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>27</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2" rowspan="2">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="nextMsgLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Current Message..</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QTextEdit" name="textEdit">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QGridLayout">
<item row="0" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>2</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="sendButton">
<property name="text">
<string>Send</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="signedcheckBox">
<property name="text">
<string>Signed</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>AvatarWidget</class>
<extends>QLabel</extends>
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,212 +0,0 @@
/****************************************************************
* 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 "ForumNewItem.h"
#include "FeedHolder.h"
#include <retroshare/rsforums.h>
#include "gui/forums/CreateForumMsg.h"
#include "gui/RetroShareLink.h"
/****
* #define DEBUG_ITEM 1
****/
/** Constructor */
ForumNewItem::ForumNewItem(FeedHolder *parent, uint32_t feedId, const std::string &forumId, bool isHome, bool isNew)
:QWidget(NULL), mParent(parent), mFeedId(feedId),
mForumId(forumId), mIsHome(isHome), mIsNew(isNew)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
/* specific ones */
connect( subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeForum ( void ) ) );
// To Cheeky to post on a brand new forum....
connect( postButton, SIGNAL( clicked( void ) ), this, SLOT( postToForum ( void ) ) );
expandFrame->hide();
updateItemStatic();
updateItem();
}
void ForumNewItem::updateItemStatic()
{
if (!rsForums)
return;
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "ForumNewItem::updateItemStatic()";
std::cerr << std::endl;
#endif
ForumInfo fi;
if (rsForums->getForumInfo(mForumId, fi))
{
RetroShareLink link;
link.createForum(fi.forumId, "");
nameLabel->setText(link.toHtml());
descLabel->setText(QString::fromStdWString(fi.forumDesc));
if (fi.subscribeFlags & RS_DISTRIB_SUBSCRIBED)
{
subscribeButton->setEnabled(false);
postButton->setEnabled(true);
}
else
{
subscribeButton->setEnabled(true);
postButton->setEnabled(false);
}
if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ) {
forumlogo_label->setPixmap(QPixmap(":/images/konv_message64.png"));
} else {
forumlogo_label->setPixmap(QPixmap(":/images/konversation64.png"));
}
/* should also check the other flags */
}
else
{
nameLabel->setText(tr("Unknown Forum"));
titleLabel->setText(tr("New Forum"));
descLabel->setText("");
}
if (mIsNew)
{
titleLabel->setText(tr("New Forum"));
}
else
{
titleLabel->setText(tr("Updated Forum"));
}
if (mIsHome)
{
/* disable buttons */
clearButton->setEnabled(false);
}
}
void ForumNewItem::updateItem()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "ForumNewItem::updateItem()";
std::cerr << std::endl;
#endif
}
void ForumNewItem::toggle()
{
mParent->lockLayout(this, true);
if (expandFrame->isHidden())
{
expandFrame->show();
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip(tr("Hide"));
}
else
{
expandFrame->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand"));
}
mParent->lockLayout(this, false);
}
void ForumNewItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "ForumNewItem::removeItem()";
std::cerr << std::endl;
#endif
mParent->lockLayout(this, true);
hide();
mParent->lockLayout(this, false);
if (mParent)
{
mParent->deleteFeedItem(this, mFeedId);
}
}
/*********** SPECIFIC FUNCTIOSN ***********************/
void ForumNewItem::unsubscribeForum()
{
#ifdef DEBUG_ITEM
std::cerr << "ForumNewItem::unsubscribeForum()";
std::cerr << std::endl;
#endif
if (rsForums)
{
rsForums->forumSubscribe(mForumId, false);
}
updateItemStatic();
}
void ForumNewItem::subscribeForum()
{
#ifdef DEBUG_ITEM
std::cerr << "ForumNewItem::subscribeForum()";
std::cerr << std::endl;
#endif
if (rsForums)
{
rsForums->forumSubscribe(mForumId, true);
}
updateItemStatic();
}
void ForumNewItem::postToForum()
{
#ifdef DEBUG_ITEM
std::cerr << "ForumNewItem::subscribeForum()";
std::cerr << std::endl;
#endif
if (mParent)
{
//mParent->openMsg(FEEDHOLDER_MSG_FORUM, mForumId, "");
CreateForumMsg *cfm = new CreateForumMsg(mForumId, "");
cfm->show();
}
}

View file

@ -1,61 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _FORUM_NEW_ITEM_DIALOG_H
#define _FORUM_NEW_ITEM_DIALOG_H
#include "ui_ForumNewItem.h"
#include <stdint.h>
class FeedHolder;
class ForumNewItem : public QWidget, private Ui::ForumNewItem
{
Q_OBJECT
public:
/** Default Constructor */
ForumNewItem(FeedHolder *parent, uint32_t feedId, const std::string &forumId, bool isHome, bool isNew);
void updateItemStatic();
private slots:
/* default stuff */
void removeItem();
void toggle();
void unsubscribeForum();
void subscribeForum();
void postToForum();
void updateItem();
private:
FeedHolder *mParent;
uint32_t mFeedId;
std::string mForumId;
bool mIsHome;
bool mIsNew;
};
#endif

View file

@ -1,317 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ForumNewItem</class>
<widget class="QWidget" name="ForumNewItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>618</width>
<height>157</height>
</rect>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>215</red>
<green>215</green>
<blue>215</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="forumlogo_label">
<property name="minimumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/konversation64.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Forum</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="nameLabel">
<property name="text">
<string notr="true">name</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>254</width>
<height>28</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="subscribeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Subscribe to Forum</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/directoryadd_24x24_shadow.png</normaloff>:/images/directoryadd_24x24_shadow.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="postButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_new.png</normaloff>:/images/mail_new.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QFrame" name="expandFrame">
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Forum Description</string>
</property>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="iconLabel">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/contacts24.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="descLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Description
of Forum</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -127,12 +127,12 @@ void MsgItem::updateItemStatic()
title += srcName;
titleLabel->setText(title);
subjectLabel->setText(QString::fromStdWString(mi.title));
subjectLabel->setText(QString::fromUtf8(mi.title.c_str()));
if(mi.msgflags & RS_MSG_ENCRYPTED)
msgLabel->setText(RsHtml().formatText(NULL, QString("[%1]").arg(tr("Encrypted message")), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
else
msgLabel->setText(RsHtml().formatText(NULL, QString::fromStdWString(mi.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mi.msg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
std::list<FileInfo>::iterator it;
for(it = mi.files.begin(); it != mi.files.end(); it++)

View file

@ -312,8 +312,8 @@ void PeerItem::sendMessage()
/* construct a message */
MessageInfo mi;
mi.title = tr("Quick Message").toStdWString();
mi.msg = quickmsgText->toHtml().toStdWString();
mi.title = tr("Quick Message").toUtf8().constData();
mi.msg = quickmsgText->toHtml().toUtf8().constData();
mi.msgto.push_back(mPeerId);
rsMsgs->MessageSend(mi);

View file

@ -31,7 +31,7 @@
#include "util/misc.h"
#include "gui/RetroShareLink.h"
#include <retroshare/rschannels.h>
//#include <retroshare/rschannels.h>
/****
* #define DEBUG_ITEM 1
@ -601,12 +601,15 @@ void SubFileItem::download()
std::list<std::string> sources ;
std::string destination;
#if 0
if (!mChannelId.empty() && mType == SFI_TYPE_CHANNEL) {
ChannelInfo ci;
if (rsChannels->getChannelInfo(mChannelId, ci)) {
destination = ci.destination_directory;
}
}
#endif
// Add possible direct sources.
//

View file

@ -1,134 +0,0 @@
/****************************************************************
* 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 <QMessageBox>
#include "util/misc.h"
#include "CreateForum.h"
#include "gui/common/PeerDefs.h"
#include <algorithm>
#include <retroshare/rsforums.h>
#include <retroshare/rspeers.h>
/** Constructor */
CreateForum::CreateForum()
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png"));
ui.headerFrame->setHeaderText(tr("New Forum"));
// connect up the buttons.
connect( ui.buttonBox, SIGNAL(accepted()), this, SLOT(createForum()));
connect( ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) ));
if (!ui.pubKeyShare_cb->isChecked()) {
ui.contactsdockWidget->hide();
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
/* initialize key share list */
ui.keyShareList->setHeaderText(tr("Contacts:"));
ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
ui.keyShareList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
ui.keyShareList->start();
newForum();
}
void CreateForum::newForum()
{
/* enforce Public for the moment */
ui.typePublic->setChecked(true);
ui.typePrivate->setEnabled(false);
ui.typeEncrypted->setEnabled(true);
#ifdef RS_RELEASE_VERSION
ui.typePrivate->setVisible(false);
ui.typeEncrypted->setVisible(true);
#endif
ui.msgAnon->setChecked(true);
//ui.msgAuth->setEnabled(false);
ui.forumName->clear();
ui.forumDesc->clear();
ui.forumName->setFocus();
}
void CreateForum::createForum()
{
QString name = misc::removeNewLine(ui.forumName->text());
QString desc = ui.forumDesc->toPlainText(); //toHtml();
uint32_t flags = 0;
if(name.isEmpty()) {
/* error message */
QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty name!!
}
if (ui.typePublic->isChecked()) {
flags |= RS_DISTRIB_PUBLIC;
} else if (ui.typePrivate->isChecked()) {
flags |= RS_DISTRIB_PRIVATE;
} else if (ui.typeEncrypted->isChecked()) {
flags |= RS_DISTRIB_ENCRYPTED;
}
if (ui.msgAuth->isChecked()) {
flags |= RS_DISTRIB_AUTHEN_REQ;
} else if (ui.msgAnon->isChecked()) {
flags |= RS_DISTRIB_AUTHEN_ANON;
}
if (rsForums) {
std::string forumId = rsForums->createForum(name.toStdWString(), desc.toStdWString(), flags);
if (ui.pubKeyShare_cb->isChecked()) {
std::list<std::string> shareList;
ui.keyShareList->selectedSslIds(shareList, false);
rsForums->forumShareKeys(forumId, shareList);
}
}
close();
}
void CreateForum::setShareList()
{
if (ui.pubKeyShare_cb->isChecked()){
this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height());
ui.contactsdockWidget->show();
} else { // hide share widget
ui.contactsdockWidget->hide();
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
}

View file

@ -1,54 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _CREATE_FORUM_DIALOG_H
#define _CREATE_FORUM_DIALOG_H
#include "ui_CreateForum.h"
class CreateForum : public QDialog
{
Q_OBJECT
public:
CreateForum();
void newForum(); /* cleanup */
private slots:
/* actions to take.... */
void createForum();
// set private forum key share list
void setShareList();
private:
std::list<std::string> mShareList;
QPixmap picture;
/** Qt Designer generated object */
Ui::CreateForum ui;
};
#endif

View file

@ -1,314 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateForum</class>
<widget class="QDialog" name="CreateForum">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>672</width>
<height>495</height>
</rect>
</property>
<property name="windowTitle">
<string>Create new Forum</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="HeaderFrame" name="headerFrame"/>
</item>
<item>
<widget class="QFrame" name="frame">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="forumName"/>
</item>
</layout>
</item>
<item row="0" column="1" rowspan="5">
<widget class="QDockWidget" name="contactsdockWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>524287</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>check peers you would like to share private publish key with</string>
</property>
<property name="floating">
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Share Key With</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="_2">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="FriendSelectionWidget" name="keyShareList" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>4</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="forumDesc"/>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="tyoeGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Type:</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="typePublic">
<property name="text">
<string>Public - Anyone can read and publish (Shared Publish Key)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="typePrivate">
<property name="text">
<string>Restricted - Anyone can read, limited publishing (Private Publish Key)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="typeEncrypted">
<property name="text">
<string>Private - (Private Publish Key required to view Messages)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="msgGroupBox_2">
<property name="title">
<string>Key Sharing</string>
</property>
<layout class="QVBoxLayout" name="_5">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="pubKeyShare_cb">
<property name="toolTip">
<string>Key recipients can publish to restricted-type channels, and can view and publish for private-type channels</string>
</property>
<property name="text">
<string>Share Private Publish Key</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QGroupBox" name="msgGroupBox">
<property name="title">
<string>Allowed Messages</string>
</property>
<layout class="QVBoxLayout" name="_4">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QRadioButton" name="msgAuth">
<property name="text">
<string>Authenticated Messages</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="msgAnon">
<property name="text">
<string>Anonymous Messages</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>FriendSelectionWidget</class>
<extends>QWidget</extends>
<header>gui/common/FriendSelectionWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,231 +0,0 @@
/****************************************************************
* 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 "CreateForumMsg.h"
#include <QMessageBox>
#include <QFile>
#include <QDesktopWidget>
#include <QDropEvent>
#include <QPushButton>
#include <QTextDocumentFragment>
#include <retroshare/rsforums.h>
#include "gui/settings/rsharesettings.h"
#include "gui/RetroShareLink.h"
#include "gui/common/Emoticons.h"
#include "util/HandleRichText.h"
#include "util/misc.h"
#include <sys/stat.h>
/** Constructor */
CreateForumMsg::CreateForumMsg(const std::string &fId, const std::string &pId)
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
QString text = pId.empty() ? tr("Start New Thread") : tr("Post Forum Message");
setWindowTitle(text);
ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png"));
ui.headerFrame->setHeaderText(text);
Settings->loadWidgetInformation(this);
connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
// connect up the buttons.
connect( ui.buttonBox, SIGNAL(accepted()), this, SLOT(createMsg()));
connect( ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect( ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums()));
connect( ui.attachFileButton, SIGNAL(clicked() ), this , SLOT(addFile()));
connect(ui.attachPictureButton, SIGNAL(clicked()), this, SLOT(addPicture()));
setAcceptDrops(true);
ui.hashBox->setDropWidget(this);
ui.hashBox->setAutoHide(false);
newMsg();
}
void CreateForumMsg::newMsg()
{
/* clear all */
ForumInfo fi;
if (rsForums->getForumInfo(mForumId, fi))
{
ForumMsgInfo msg;
QString name = QString::fromStdWString(fi.forumName);
QString subj;
if ((mParentId != "") && (rsForums->getForumMessage(mForumId, mParentId, msg)))
{
QString title = QString::fromStdWString(msg.title);
name += " " + tr("In Reply to") + ": ";
name += title;
QString text = title;
if (text.startsWith("Re:", Qt::CaseInsensitive))
{
subj = title;
}
else
{
subj = "Re: " + title;
}
}
ui.forumName->setText(misc::removeNewLine(name));
ui.forumSubject->setText(misc::removeNewLine(subj));
if (!ui.forumSubject->text().isEmpty())
{
ui.forumMessage->setFocus();
}
else
{
ui.forumSubject->setFocus();
}
if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ)
{
ui.signBox->setChecked(true);
ui.signBox->setEnabled(false);
}
else
{
/* Uncheck sign box by default for anonymous forums */
ui.signBox->setChecked(false);
ui.signBox->setEnabled(true);
}
}
ui.forumMessage->setText("");
}
void CreateForumMsg::createMsg()
{
QString name = misc::removeNewLine(ui.forumSubject->text());
QString desc;
RsHtml::optimizeHtml(ui.forumMessage, desc);
if(name.isEmpty())
{ /* error message */
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a Forum Subject and Forum Message"),
QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty Subject!!
}
ForumMsgInfo msgInfo;
msgInfo.forumId = mForumId;
msgInfo.threadId = "";
msgInfo.parentId = mParentId;
msgInfo.msgId = "";
msgInfo.title = name.toStdWString();
msgInfo.msg = desc.toStdWString();
msgInfo.msgflags = 0;
if (ui.signBox->isChecked())
{
msgInfo.msgflags = RS_DISTRIB_AUTHEN_REQ;
}
if ((msgInfo.msg == L"") && (msgInfo.title == L""))
return; /* do nothing */
if (rsForums->ForumMessageSend(msgInfo) == true) {
close();
}
}
void CreateForumMsg::closeEvent (QCloseEvent * /*event*/)
{
Settings->saveWidgetInformation(this);
}
void CreateForumMsg::smileyWidgetForums()
{
Emoticons::showSmileyWidget(this, ui.emoticonButton, SLOT(addSmileys()), false);
}
void CreateForumMsg::addSmileys()
{
ui.forumMessage->textCursor().insertText(qobject_cast<QPushButton*>(sender())->toolTip().split("|").first());
}
void CreateForumMsg::addFile()
{
QStringList files;
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) {
ui.hashBox->addAttachments(files,RS_FILE_REQ_ANONYMOUS_ROUTING);
}
}
void CreateForumMsg::addPicture()
{
// select a picture file
QString file;
if (misc::getOpenFileName(window(), RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg *.jpeg)", file)) {
QString encodedImage;
if (RsHtml::makeEmbeddedImage(file, encodedImage, 640*480)) {
QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage);
ui.forumMessage->textCursor().insertFragment(fragment);
}
}
}
void CreateForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
{
std::cerr << "CreateForumMsg::fileHashingFinished() started." << std::endl;
QString mesgString;
QList<HashedFile>::iterator it;
for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) {
HashedFile& hashedFile = *it;
RetroShareLink link;
if (link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash))) {
mesgString += link.toHtmlSize() + "<br>";
}
}
#ifdef CHAT_DEBUG
std::cerr << "CreateForumMsg::anchorClicked mesgString : " << mesgString.toStdString() << std::endl;
#endif
if (!mesgString.isEmpty()) {
ui.forumMessage->textCursor().insertHtml(mesgString);
}
ui.forumMessage->setFocus( Qt::OtherFocusReason );
}

View file

@ -1,59 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _CREATE_FORUM_MSG_DIALOG_H
#define _CREATE_FORUM_MSG_DIALOG_H
#include "ui_CreateForumMsg.h"
class CreateForumMsg : public QDialog
{
Q_OBJECT
public:
CreateForumMsg(const std::string &fId, const std::string &pId);
void newMsg(); /* cleanup */
private slots:
void fileHashingFinished(QList<HashedFile> hashedFiles);
/* actions to take.... */
void createMsg();
void smileyWidgetForums();
void addSmileys();
void addFile();
void addPicture();
protected:
void closeEvent (QCloseEvent * event);
private:
std::string mForumId;
std::string mParentId;
/** Qt Designer generated object */
Ui::CreateForumMsg ui;
};
#endif

View file

@ -1,281 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateForumMsg</class>
<widget class="QDialog" name="CreateForumMsg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>482</width>
<height>448</height>
</rect>
</property>
<property name="windowTitle">
<string>Post Forum Message</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="HeaderFrame" name="headerFrame"/>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="subjectFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="forumLabel">
<property name="text">
<string>Forum</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="forumName">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="subjectLabel">
<property name="text">
<string>Subject</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="forumSubject"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="toolBarFrame">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>38</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout">
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QToolButton" name="attachFileButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Attach File</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="attachPictureButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Attach a Picture</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="emoticonButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/emoticons/kopete/kopete020.png</normaloff>:/images/emoticons/kopete/kopete020.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="signBox">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Sign Message</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/pgp.png</normaloff>:/images/pgp.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>15</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="messageGroupBox">
<property name="title">
<string>Forum Post</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="MimeTextEdit" name="forumMessage">
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="hashGroupBox">
<property name="title">
<string>Attach files via drag and drop</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="HashBox" name="hashBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>You can attach files via drag and drop here in this window</string>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HashBox</class>
<extends>QScrollArea</extends>
<header location="global">gui/common/HashBox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>MimeTextEdit</class>
<extends>QTextEdit</extends>
<header location="global">gui/common/MimeTextEdit.h</header>
</customwidget>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,82 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2010 RetroShare Team
*
* 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 "EditForumDetails.h"
#include <retroshare/rsforums.h>
#include "util/misc.h"
#include <list>
#include <iostream>
#include <string>
/** Default constructor */
EditForumDetails::EditForumDetails(std::string forumId, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), m_forumId(forumId)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(applyDialog()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
loadForum();
}
void EditForumDetails::loadForum()
{
if (!rsForums) {
return;
}
ForumInfo info;
rsForums->getForumInfo(m_forumId, info);
// set name
ui.nameline->setText(QString::fromStdWString(info.forumName));
// set description
ui.DescriptiontextEdit->setText(QString::fromStdWString(info.forumDesc));
}
void EditForumDetails::applyDialog()
{
if (!rsForums) {
return;
}
// if text boxes have not been edited leave alone
if (!ui.nameline->isModified() && !ui.DescriptiontextEdit->document()->isModified()) {
return;
}
ForumInfo info;
info.forumName = misc::removeNewLine(ui.nameline->text()).toStdWString();
info.forumDesc = ui.DescriptiontextEdit->document()->toPlainText().toStdWString();
rsForums->setForumInfo(m_forumId, info);
/* close the Dialog after the Changes applied */
close();
}

View file

@ -1,53 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2010 RetroShare Team
*
* 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.
****************************************************************/
#ifndef _EDITFORUMDETAILS_H
#define _EDITFORUMDETAILS_H
#include <QDialog>
#include "ui_EditForumDetails.h"
class EditForumDetails : public QDialog
{
Q_OBJECT
public:
/** Default constructor */
EditForumDetails(std::string forumId = "", QWidget *parent = 0);
signals:
void configChanged();
private slots:
void applyDialog();
private:
void loadForum();
std::string m_forumId;
/** Qt Designer generated object */
Ui::EditForumDetails ui;
};
#endif

View file

@ -1,87 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditForumDetails</class>
<widget class="QDialog" name="EditForumDetails">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>436</width>
<height>355</height>
</rect>
</property>
<property name="windowTitle">
<string>Forum Details</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<layout class="QGridLayout" name="_2">
<item row="0" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="stabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/info16.png</normaloff>:/images/info16.png</iconset>
</attribute>
<attribute name="title">
<string>Edit Forum Details</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Forum Info</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Forum Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameline"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Forum Description</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTextEdit" name="DescriptiontextEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,112 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2009 RetroShare Team
*
* 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 "ForumDetails.h"
#include "util/DateTime.h"
#include <retroshare/rsiface.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsdisc.h>
#include <retroshare/rsforums.h>
#include <QTime>
#include <QDateTime>
#include <list>
#include <iostream>
#include <string>
/** Default constructor */
ForumDetails::ForumDetails(QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
ui.nameline ->setReadOnly(true);
ui.popline ->setReadOnly(true);
ui.postline ->setReadOnly(true);
ui.IDline ->setReadOnly(true);
ui.DescriptiontextEdit ->setReadOnly(true);
ui.radioButton_authd->setEnabled(false);
ui.radioButton_anonymous->setEnabled(false);
}
/**
Overloads the default show() slot so we can set opacity*/
void
ForumDetails::show()
{
//loadSettings();
if(!this->isVisible()) {
QDialog::show();
}
}
void ForumDetails::showDetails(std::string mCurrForumId)
{
fId = mCurrForumId;
loadDialog();
}
void ForumDetails::loadDialog()
{
if (!rsForums)
{
return;
}
ForumInfo fi;
rsForums->getForumInfo(fId, fi);
// Set Forum Name
ui.nameline->setText(QString::fromStdWString(fi.forumName));
// Set Popularity
ui.popline->setText(QString::number(fi.pop));
// Set Last Post Date
if (fi.lastPost) {
ui.postline->setText(DateTime::formatLongDateTime(fi.lastPost));
}
// Set Forum ID
ui.IDline->setText(QString::fromStdString(fi.forumId));
// Set Forum Description
ui.DescriptiontextEdit->setText(QString::fromStdWString(fi.forumDesc));
if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ)
{
ui.radioButton_authd->setChecked(true);
ui.radioButton_anonymous->setChecked(false);
}
if (fi.forumFlags & RS_DISTRIB_AUTHEN_ANON)
{
ui.radioButton_authd->setChecked(false);
ui.radioButton_anonymous->setChecked(true);
}
}

View file

@ -1,57 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2009 RetroShare Team
*
* 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.
****************************************************************/
#ifndef _FORUMDETAILS_H
#define _FORUMDETAILS_H
#include <QDialog>
#include "ui_ForumDetails.h"
class ForumDetails : public QDialog
{
Q_OBJECT
public:
/** Default constructor */
ForumDetails(QWidget *parent = 0);
void showDetails(std::string mCurrForumId);
signals:
void configChanged() ;
public slots:
/** Overloaded QWidget.show */
void show();
private:
void loadDialog();
std::string fId;
/** Qt Designer generated object */
Ui::ForumDetails ui;
};
#endif

View file

@ -1,175 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ForumDetails</class>
<widget class="QDialog" name="ForumDetails">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>436</width>
<height>355</height>
</rect>
</property>
<property name="windowTitle">
<string>Forum Details</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="stabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/info16.png</normaloff>:/images/info16.png</iconset>
</attribute>
<attribute name="title">
<string>Forum Details</string>
</attribute>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Forum Info</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Forum Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameline"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Popularity</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="popline">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Last Post</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="postline">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Forum ID</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="IDline"/>
</item>
<item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Forum Description</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QTextEdit" name="DescriptiontextEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="Seite">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/encrypted22.png</normaloff>:/images/encrypted22.png</iconset>
</attribute>
<attribute name="title">
<string>Security</string>
</attribute>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Allowed Messages</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="radioButton_authd">
<property name="text">
<string>Authenticated Messages</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioButton_anonymous">
<property name="text">
<string>Anonymous Messages</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>358</width>
<height>172</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,106 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 RetroShare Team
*
* 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 "ForumUserNotify.h"
#include "gui/settings/rsharesettings.h"
#include "gui/notifyqt.h"
#include "gui/MainWindow.h"
#include <retroshare/rsforums.h>
ForumUserNotify::ForumUserNotify(QObject *parent) :
UserNotify(parent)
{
connect(NotifyQt::getInstance(), SIGNAL(forumsChanged()), this, SLOT(updateIcon()), Qt::QueuedConnection);
}
bool ForumUserNotify::hasSetting(QString &name)
{
name = tr("Forum Post");
return true;
}
bool ForumUserNotify::notifyEnabled()
{
return (Settings->getTrayNotifyFlags() & TRAYNOTIFY_FORUMS);
}
bool ForumUserNotify::notifyCombined()
{
return (Settings->getTrayNotifyFlags() & TRAYNOTIFY_FORUMS_COMBINED);
}
bool ForumUserNotify::notifyBlink()
{
return (Settings->getTrayNotifyBlinkFlags() & TRAYNOTIFY_BLINK_FORUMS);
}
void ForumUserNotify::setNotifyEnabled(bool enabled, bool combined, bool blink)
{
uint notifyFlags = Settings->getTrayNotifyFlags();
uint blinkFlags = Settings->getTrayNotifyBlinkFlags();
if (enabled) {
notifyFlags |= TRAYNOTIFY_FORUMS;
} else {
notifyFlags &= ~TRAYNOTIFY_FORUMS;
}
if (combined) {
notifyFlags |= TRAYNOTIFY_FORUMS_COMBINED;
} else {
notifyFlags &= ~TRAYNOTIFY_FORUMS_COMBINED;
}
if (blink) {
blinkFlags |= TRAYNOTIFY_BLINK_FORUMS;
} else {
blinkFlags &= ~TRAYNOTIFY_BLINK_FORUMS;
}
Settings->setTrayNotifyFlags(notifyFlags);
Settings->setTrayNotifyBlinkFlags(blinkFlags);
}
QIcon ForumUserNotify::getIcon()
{
return QIcon(":/images/konversation16.png");
}
QIcon ForumUserNotify::getMainIcon(bool hasNew)
{
return hasNew ? QIcon(":/images/forums_new.png") : QIcon(":/images/konversation.png");
}
unsigned int ForumUserNotify::getNewCount()
{
unsigned int newMessageCount = 0;
unsigned int unreadMessageCount = 0;
rsForums->getMessageCount("", newMessageCount, unreadMessageCount);
return newMessageCount;
}
void ForumUserNotify::iconClicked()
{
MainWindow::showWindow(MainWindow::Forums);
}

View file

@ -1,47 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 RetroShare Team
*
* 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.
****************************************************************/
#ifndef FORUMUSERNOTIFY_H
#define FORUMUSERNOTIFY_H
#include "gui/common/UserNotify.h"
class ForumUserNotify : public UserNotify
{
Q_OBJECT
public:
ForumUserNotify(QObject *parent = 0);
virtual bool hasSetting(QString &name);
virtual bool notifyEnabled();
virtual bool notifyCombined();
virtual bool notifyBlink();
virtual void setNotifyEnabled(bool enabled, bool combined, bool blink);
private:
virtual QIcon getIcon();
virtual QIcon getMainIcon(bool hasNew);
virtual unsigned int getNewCount();
virtual void iconClicked();
};
#endif // FORUMUSERNOTIFY_H

View file

@ -36,9 +36,10 @@ GxsCircleChooser::GxsCircleChooser(QWidget *parent)
return;
}
void GxsCircleChooser::loadCircles(uint32_t chooserFlags)
void GxsCircleChooser::loadCircles(uint32_t chooserFlags, const RsGxsCircleId &defaultId)
{
mFlags = chooserFlags;
mDefaultCircleId = defaultId;
loadGxsCircles();
}
@ -84,7 +85,9 @@ void GxsCircleChooser::loadGxsCircles()
}
std::list<RsGxsCircleId>::iterator it;
for(it = ids.begin(); it != ids.end(); it++)
int i = 0;
int def = -1;
for(it = ids.begin(); it != ids.end(); it++, i++)
{
/* add to Chooser */
QString str;
@ -97,6 +100,16 @@ void GxsCircleChooser::loadGxsCircles()
QString id = QString::fromStdString(*it);
addItem(str, id);
if (mDefaultCircleId == *it)
{
def = i;
}
}
if (def >= 0)
{
setCurrentIndex(def);
}
}

View file

@ -40,12 +40,14 @@ class GxsCircleChooser : public QComboBox
public:
GxsCircleChooser(QWidget *parent = NULL);
void loadCircles(uint32_t chooserFlags);
void loadCircles(uint32_t chooserFlags, const RsGxsCircleId &defaultId);
bool getChosenCircle(RsGxsCircleId &id);
private:
void loadGxsCircles();
uint32_t mFlags;
RsGxsCircleId mDefaultCircleId;
};
#endif

View file

@ -51,23 +51,30 @@
#define GXSGROUP_NEWGROUPID 1
#define GXSGROUP_LOADGROUP 2
#define GXSGROUP_INTERNAL_LOADGROUP 3
/** Constructor */
GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenQueue, uint32_t enableFlags, uint16_t defaultFlags, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenQueue(tokenQueue), mMode(MODE_CREATE), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags)
GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenExternalQueue, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenService(NULL), mExternalTokenQueue(tokenExternalQueue), mInternalTokenQueue(NULL), mGrpMeta(), mMode(MODE_CREATE), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
mInternalTokenQueue = NULL;
init();
}
GxsGroupDialog::GxsGroupDialog(const RsGroupMetaData &grpMeta, Mode mode, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenQueue(NULL), mGrpMeta(grpMeta), mMode(mode), mEnabledFlags(0), mReadonlyFlags(0), mDefaultsFlags(0)
GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenService(NULL), mExternalTokenQueue(tokenExternalQueue), mInternalTokenQueue(NULL), mGrpMeta(), mMode(mode), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
mTokenService = tokenService;
mInternalTokenQueue = new TokenQueue(tokenService, this);
mGrpMeta.mGroupId = groupId;
init();
}
@ -102,8 +109,8 @@ void GxsGroupDialog::init()
/* Setup Reasonable Defaults */
ui.idChooser->loadIds(0,"");
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL);
ui.localComboBox->loadCircles(GXS_CIRCLE_CHOOSER_PERSONAL);
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL,"");
ui.localComboBox->loadCircles(GXS_CIRCLE_CHOOSER_PERSONAL,"");
initMode();
}
@ -137,6 +144,7 @@ void GxsGroupDialog::setUiText(UiType uiType, const QString &text)
void GxsGroupDialog::initMode()
{
setAllReadonly();
switch (mode())
{
case MODE_CREATE:
@ -148,15 +156,18 @@ void GxsGroupDialog::initMode()
case MODE_SHOW:
{
mReadonlyFlags = 0xffffffff; // Force all to readonly.
ui.buttonBox->setStandardButtons(QDialogButtonBox::Close);
requestGroup(mGrpMeta.mGroupId);
}
break;
case MODE_EDIT:
{
ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Submit Group Changes"));
requestGroup(mGrpMeta.mGroupId);
}
break;
//TODO
// case MODE_EDIT:
// {
// ui.createButton->setText(tr("Submit Changes"));
// }
// break;
}
}
@ -255,6 +266,9 @@ void GxsGroupDialog::setupDefaults()
void GxsGroupDialog::setupVisibility()
{
{
ui.groupName->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_NAME);
}
{
ui.groupLogo->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
ui.addLogoButton->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
@ -291,14 +305,112 @@ void GxsGroupDialog::setupVisibility()
}
void GxsGroupDialog::setAllReadonly()
{
uint32_t origReadonlyFlags = mReadonlyFlags;
mReadonlyFlags = 0xffffffff;
setupReadonly();
mReadonlyFlags = origReadonlyFlags;
}
void GxsGroupDialog::setupReadonly()
{
{
ui.groupName->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_NAME));
}
{
ui.groupLogo->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_ICON));
ui.addLogoButton->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_ICON));
}
{
ui.groupDesc->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DESCRIPTION));
ui.groupDescLabel->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DESCRIPTION));
}
{
ui.distribGroupBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DISTRIBUTION));
}
{
ui.publishGroupBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_PUBLISHSIGN));
}
{
ui.pubKeyShare_cb->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_SHAREKEYS));
}
{
ui.personalGroupBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_PERSONALSIGN));
}
{
ui.commentGroupBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_COMMENTS));
}
{
ui.extraFrame->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_EXTRA));
}
}
void GxsGroupDialog::newGroup()
{
setupDefaults();
setupVisibility();
setupReadonly();
clearForm();
}
void GxsGroupDialog::updateFromExistingMeta()
{
std::cerr << "void GxsGroupDialog::updateFromExistingMeta()";
std::cerr << std::endl;
std::cerr << "void GxsGroupDialog::updateFromExistingMeta() mGrpMeta.mCircleType: ";
std::cerr << mGrpMeta.mCircleType << " Internal: " << mGrpMeta.mInternalCircle;
std::cerr << " External: " << mGrpMeta.mCircleId;
std::cerr << std::endl;
setupDefaults();
setupVisibility();
setupReadonly();
clearForm();
/* setup name */
ui.groupName->setText(QString::fromUtf8(mGrpMeta.mGroupName.c_str()));
bool isExternal = true;
switch(mGrpMeta.mCircleType)
{
case GXS_CIRCLE_TYPE_YOUREYESONLY:
ui.typeLocal->setChecked(true);
ui.localComboBox->loadCircles(GXS_CIRCLE_CHOOSER_PERSONAL, mGrpMeta.mInternalCircle);
break;
case GXS_CIRCLE_TYPE_PUBLIC:
ui.typePublic->setChecked(true);
break;
case GXS_CIRCLE_TYPE_EXTERNAL:
ui.typeGroup->setChecked(true);
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, mGrpMeta.mCircleId);
break;
default:
std::cerr << "CreateCircleDialog::updateCircleGUI() INVALID mCircleType";
std::cerr << std::endl;
break;
}
ui.idChooser->loadIds(0, mGrpMeta.mAuthorId);
updateCircleOptions();
}
void GxsGroupDialog::submitGroup()
{
std::cerr << "GxsGroupDialog::submitGroup()";
@ -323,13 +435,44 @@ void GxsGroupDialog::submitGroup()
case MODE_EDIT:
{
/* TEMP: just close if down */
cancelDialog();
editGroup();
}
break;
}
}
void GxsGroupDialog::editGroup()
{
std::cerr << "GxsGroupDialog::editGroup()" << std::endl;
QString name = misc::removeNewLine(ui.groupName->text());
uint32_t flags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
if(name.isEmpty())
{
/* error message */
QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty name!!
}
std::cerr << "GxsGroupDialog::editGroup() Unfinished" << std::endl;
#if 0
uint32_t token;
RsGxsGroupUpdateMeta updateMeta(mGrpMeta.mGroupId);
updateMeta.setMetaUpdate(RsGxsGroupUpdateMeta::NAME, std::string(name.toUtf8()));
if (service_EditGroup(token, updateMeta))
{
// get the Queue to handle response.
if(mExternalTokenQueue != NULL)
mExternalTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
}
#endif
close();
}
void GxsGroupDialog::createGroup()
{
std::cerr << "GxsGroupDialog::createGroup()";
@ -361,14 +504,18 @@ void GxsGroupDialog::createGroup()
return; //Don't add with invalid circle.
}
std::cerr << "void GxsGroupDialog::createGroup() meta.mCircleType: ";
std::cerr << meta.mCircleType << " Internal: " << meta.mInternalCircle;
std::cerr << " External: " << meta.mCircleId;
std::cerr << std::endl;
ui.idChooser->getChosenId(meta.mAuthorId);
if (service_CreateGroup(token, meta))
{
// get the Queue to handle response.
if(mTokenQueue != NULL)
mTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
if(mExternalTokenQueue != NULL)
mExternalTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
}
close();
@ -447,7 +594,7 @@ void GxsGroupDialog::updateCircleOptions()
{
if (ui.typeGroup->isChecked())
{
ui.circleComboBox->setEnabled(true);
ui.circleComboBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DISTRIBUTION));
ui.circleComboBox->setVisible(true);
}
else
@ -458,7 +605,7 @@ void GxsGroupDialog::updateCircleOptions()
if (ui.typeLocal->isChecked())
{
ui.localComboBox->setEnabled(true);
ui.circleComboBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DISTRIBUTION));
ui.localComboBox->setVisible(true);
}
else
@ -559,3 +706,69 @@ void GxsGroupDialog::setShareList()
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
}
/***********************************************************************************
Loading Group.
***********************************************************************************/
void GxsGroupDialog::requestGroup(const RsGxsGroupId &groupId)
{
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
std::list<RsGxsGroupId> groupIds;
groupIds.push_back(groupId);
std::cerr << "GxsGroupDialog::requestGroup() Requesting Group Summary(" << groupId << ")";
std::cerr << std::endl;
uint32_t token;
mInternalTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, GXSGROUP_INTERNAL_LOADGROUP);
}
void GxsGroupDialog::loadGroup(uint32_t token)
{
std::cerr << "GxsGroupDialog::loadGroup(" << token << ")";
std::cerr << std::endl;
if (service_loadGroup(token, mMode, mGrpMeta))
{
updateFromExistingMeta();
}
}
bool GxsGroupDialog::service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData)
{
std::cerr << "GxsGroupDialog::service_loadGroup(" << token << ") NOT IMPLEMENTED";
std::cerr << std::endl;
return false;
}
void GxsGroupDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
std::cerr << "GxsGroupDialog::loadRequest() UserType: " << req.mUserType;
std::cerr << std::endl;
if (queue == mInternalTokenQueue)
{
/* now switch on req */
switch(req.mUserType)
{
case GXSGROUP_INTERNAL_LOADGROUP:
loadGroup(req.mToken);
break;
default:
std::cerr << "GxsGroupDialog::loadGroup() UNKNOWN UserType ";
std::cerr << std::endl;
break;
}
}
}

View file

@ -55,13 +55,14 @@ public:
/*** Group flags affect what is visually enabled that gets input into the grpMeta ***/
#define GXS_GROUP_FLAGS_ICON 0x00000001
#define GXS_GROUP_FLAGS_DESCRIPTION 0x00000002
#define GXS_GROUP_FLAGS_DISTRIBUTION 0x00000004
#define GXS_GROUP_FLAGS_PUBLISHSIGN 0x00000008
#define GXS_GROUP_FLAGS_SHAREKEYS 0x00000010
#define GXS_GROUP_FLAGS_PERSONALSIGN 0x00000020
#define GXS_GROUP_FLAGS_COMMENTS 0x00000040
#define GXS_GROUP_FLAGS_NAME 0x00000001
#define GXS_GROUP_FLAGS_ICON 0x00000002
#define GXS_GROUP_FLAGS_DESCRIPTION 0x00000004
#define GXS_GROUP_FLAGS_DISTRIBUTION 0x00000008
#define GXS_GROUP_FLAGS_PUBLISHSIGN 0x00000010
#define GXS_GROUP_FLAGS_SHAREKEYS 0x00000020
#define GXS_GROUP_FLAGS_PERSONALSIGN 0x00000040
#define GXS_GROUP_FLAGS_COMMENTS 0x00000080
#define GXS_GROUP_FLAGS_EXTRA 0x00000100
@ -102,7 +103,7 @@ public:
* The long term plan is perhap logic structure (i.e. code) will be moved into each GXS \n
* service for better customisation of group creation, or perhaps not!
*/
class GxsGroupDialog : public QDialog
class GxsGroupDialog : public QDialog, public TokenResponse
{
Q_OBJECT
@ -132,7 +133,7 @@ public:
* @param parent The parent dialog
* @param mode
*/
GxsGroupDialog(TokenQueue* tokenQueue, uint32_t enableFlags, uint16_t defaultFlags, QWidget *parent = NULL);
GxsGroupDialog(TokenQueue* tokenQueue, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent = NULL);
/*!
* Contructs a GxsGroupDialog for display a group or editing
@ -140,10 +141,13 @@ public:
* @param mode This determines whether the dialog starts in show or edit mode (Edit not supported yet)
* @param parent
*/
GxsGroupDialog(const RsGroupMetaData& grpMeta, Mode mode, QWidget *parent = NULL);
GxsGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent = NULL);
uint32_t mode() { return mMode; }
// overloaded from TokenResponse
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private:
void newGroup();
void init();
@ -164,13 +168,24 @@ protected:
void setUiText(UiType uiType, const QString &text);
/*!
* Main purpose is to help tansfer meta data to service
*
* It is up to the service to do the actual group creation
* Service can also modify initial meta going into group
* @param token This should be set to the token retrieved
* @param meta The deriving GXS service should set their grp meta to this value
*/
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta) = 0;
/*!
* It is up to the service to do the actual group editing
* @param token This should be set to the token retrieved
* @param meta The deriving GXS service should set their grp meta to this value
*/
virtual bool service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta) = 0;
// To be overloaded by users.
// use Token to retrieve from service, fill in metaData.
virtual bool service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData);
/*!
* This returns a group logo from the ui \n
* Should be calleld by deriving service
@ -199,23 +214,36 @@ private:
void setGroupSignFlags(uint32_t signFlags);
uint32_t getGroupSignFlags();
void setAllReadonly();
void setupReadonly();
void setupDefaults();
void setupVisibility();
void clearForm();
void createGroup();
void editGroup();
void sendShareList(std::string forumId);
void loadNewGroupId(const uint32_t &token);
// loading existing Groups.
void requestGroup(const RsGxsGroupId &groupId);
void loadGroup(uint32_t token);
void updateFromExistingMeta();
std::list<std::string> mShareList;
QPixmap picture;
TokenQueue *mTokenQueue;
RsTokenService *mTokenService;
TokenQueue *mExternalTokenQueue;
TokenQueue *mInternalTokenQueue;
RsGroupMetaData mGrpMeta;
uint32_t mMode;
Mode mMode;
uint32_t mEnabledFlags;
uint32_t mReadonlyFlags;
uint32_t mDefaultsFlags;
protected:
/** Qt Designer generated object */
Ui::GxsGroupDialog ui;
};

View file

@ -67,6 +67,17 @@ bool GxsIdChooser::MakeIdDesc(const RsGxsId &id, QString &desc)
if (found)
{
desc = QString::fromUtf8(details.mNickname.c_str());
std::list<RsRecognTag>::iterator it;
for(it = details.mRecognTags.begin(); it != details.mRecognTags.end(); it++)
{
desc += " (";
desc += QString::number(it->tag_class);
desc += ":";
desc += QString::number(it->tag_type);
desc += ")";
}
if (details.mPgpLinked)
{
desc += " (PGP) [";

Some files were not shown because too many files have changed in this diff Show more