From b98dc7930a2e49829f0ea2a95d28ce9fa9df521d Mon Sep 17 00:00:00 2001 From: chrisparker126 Date: Wed, 3 Feb 2010 23:01:38 +0000 Subject: [PATCH] added blogs git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2183 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/blogs/BlogsDialog.cpp | 585 +++++++++++++++++ retroshare-gui/src/gui/blogs/BlogsDialog.h | 108 ++++ retroshare-gui/src/gui/blogs/BlogsDialog.ui | 591 ++++++++++++++++++ retroshare-gui/src/gui/blogs/BlogsMsgItem.cpp | 238 +++++++ retroshare-gui/src/gui/blogs/BlogsMsgItem.h | 73 +++ retroshare-gui/src/gui/blogs/BlogsMsgItem.ui | 287 +++++++++ retroshare-gui/src/gui/blogs/CreateBlog.cpp | 138 ++++ retroshare-gui/src/gui/blogs/CreateBlog.h | 61 ++ retroshare-gui/src/gui/blogs/CreateBlog.ui | 245 ++++++++ .../src/gui/blogs/CreateBlogMsg.cpp | 463 ++++++++++++++ retroshare-gui/src/gui/blogs/CreateBlogMsg.h | 76 +++ retroshare-gui/src/gui/blogs/CreateBlogMsg.ui | 360 +++++++++++ 12 files changed, 3225 insertions(+) create mode 100644 retroshare-gui/src/gui/blogs/BlogsDialog.cpp create mode 100644 retroshare-gui/src/gui/blogs/BlogsDialog.h create mode 100644 retroshare-gui/src/gui/blogs/BlogsDialog.ui create mode 100644 retroshare-gui/src/gui/blogs/BlogsMsgItem.cpp create mode 100644 retroshare-gui/src/gui/blogs/BlogsMsgItem.h create mode 100644 retroshare-gui/src/gui/blogs/BlogsMsgItem.ui create mode 100644 retroshare-gui/src/gui/blogs/CreateBlog.cpp create mode 100644 retroshare-gui/src/gui/blogs/CreateBlog.h create mode 100644 retroshare-gui/src/gui/blogs/CreateBlog.ui create mode 100644 retroshare-gui/src/gui/blogs/CreateBlogMsg.cpp create mode 100644 retroshare-gui/src/gui/blogs/CreateBlogMsg.h create mode 100644 retroshare-gui/src/gui/blogs/CreateBlogMsg.ui diff --git a/retroshare-gui/src/gui/blogs/BlogsDialog.cpp b/retroshare-gui/src/gui/blogs/BlogsDialog.cpp new file mode 100644 index 000000000..0d85d499a --- /dev/null +++ b/retroshare-gui/src/gui/blogs/BlogsDialog.cpp @@ -0,0 +1,585 @@ +/**************************************************************** + * 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 +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "rsiface/rsblogs.h" +#include "rsiface/rspeers.h" //to retrieve peer/usrId info + +#include "BlogsDialog.h" + +#include "BlogsMsgItem.h" +#include "CreateBlog.h" +#include "CreateBlogMsg.h" + +#include "gui/ChanGroupDelegate.h" +#include "gui/GeneralMsgDialog.h" + + +/** Constructor */ +BlogsDialog::BlogsDialog(QWidget *parent) +: MainPage (parent) +{ + /* Invoke the Qt Designer generated object setup routine */ + setupUi(this); + + connect(actionCreate_Channel, SIGNAL(triggered()), this, SLOT(createChannel())); + connect(postButton, SIGNAL(clicked()), this, SLOT(createMsg())); + connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeChannel ( void ) ) ); + connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) ); + + + mBlogId = ""; + mPeerId = rsPeers->getOwnId(); // add your id + + model = new QStandardItemModel(0, 2, this); + model->setHeaderData(0, Qt::Horizontal, tr("Name"), Qt::DisplayRole); + model->setHeaderData(1, Qt::Horizontal, tr("ID"), Qt::DisplayRole); + + treeView->setModel(model); + treeView->setEditTriggers(QAbstractItemView::NoEditTriggers); + + treeView->setItemDelegate(new ChanGroupDelegate()); + //treeView->setRootIsDecorated(false); + + // hide header and id column + treeView->setHeaderHidden(true); + treeView->hideColumn(1); + + QStandardItem *item1 = new QStandardItem(tr("Own Blogs")); + QStandardItem *item2 = new QStandardItem(tr("Subscribed Blogs")); + QStandardItem *item3 = new QStandardItem(tr("Popular Blogs")); + QStandardItem *item4 = new QStandardItem(tr("Other Blogs")); + + model->appendRow(item1); + model->appendRow(item2); + model->appendRow(item3); + model->appendRow(item4); + + connect(treeView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(selectChannel(const QModelIndex &))); + connect(treeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(toggleSelection(const QModelIndex &))); + connect(treeView, SIGNAL(customContextMenuRequested( QPoint ) ), this, SLOT( channelListCustomPopupMenu( QPoint ) ) ); + + //added from ahead + updateChannelList(); + + mChannelFont = QFont("MS SANS SERIF", 22); + nameLabel->setFont(mChannelFont); + + nameLabel->setMinimumWidth(20); + + itemFont = QFont("ARIAL", 10); + itemFont.setBold(true); + item1->setFont(itemFont); + item2->setFont(itemFont); + item3->setFont(itemFont); + item4->setFont(itemFont); + + item1->setForeground(QBrush(QColor(79, 79, 79))); + item2->setForeground(QBrush(QColor(79, 79, 79))); + item3->setForeground(QBrush(QColor(79, 79, 79))); + item4->setForeground(QBrush(QColor(79, 79, 79))); + + QMenu *channelmenu = new QMenu(); + channelmenu->addAction(actionCreate_Channel); + channelmenu->addSeparator(); + channelpushButton->setMenu(channelmenu); + + + QTimer *timer = new QTimer(this); + timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); + timer->start(1000); +} + +void BlogsDialog::channelListCustomPopupMenu( QPoint point ) +{ + QMenu contextMnu( this ); + QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier ); + + QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), this ); + connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) ); + + contextMnu.clear(); + contextMnu.addAction( channeldetailsAct ); + + contextMnu.exec( mevent->globalPos() ); + + +} + +void BlogsDialog::createChannel() +{ + CreateBlog *cf = new CreateBlog(NULL, false); + + cf->setWindowTitle(tr("Create a new Blog")); + cf->show(); +} + +void BlogsDialog::channelSelection() +{ + /* which item was selected? */ + + + /* update mBlogId */ + + updateChannelMsgs(); +} + + +/*************************************************************************************/ +/*************************************************************************************/ +/*************************************************************************************/ + +void BlogsDialog::deleteFeedItem(QWidget *item, uint32_t type) +{ + return; +} + +void BlogsDialog::openChat(std::string peerId) +{ + return; +} + +void BlogsDialog::openMsg(uint32_t type, std::string grpId, std::string inReplyTo) +{ +#ifdef CHAN_DEBUG + std::cerr << "BlogsDialog::openMsg()"; + std::cerr << std::endl; +#endif + GeneralMsgDialog *msgDialog = new GeneralMsgDialog(NULL); + + + msgDialog->addDestination(type, grpId, inReplyTo); + + msgDialog->show(); + return; +} + + +void BlogsDialog::createMsg() +{ + if (mBlogId == "") + { + return; + } + + CreateBlogMsg *msgDialog = new CreateBlogMsg(mBlogId); + + msgDialog->show(); + return; +} + +void BlogsDialog::selectChannel( std::string cId) +{ + mBlogId = cId; + + updateChannelMsgs(); +} + +void BlogsDialog::selectChannel(const QModelIndex &index) +{ + int row = index.row(); + int col = index.column(); + if (col != 1) { + QModelIndex sibling = index.sibling(row, 1); + if (sibling.isValid()) + mBlogId = sibling.data().toString().toStdString(); + } else + mBlogId = index.data().toString().toStdString(); + updateChannelMsgs(); +} + +void BlogsDialog::checkUpdate() +{ + std::list blogIds; + std::list::iterator it; + if (!rsBlogs) + return; + + if (rsBlogs->blogsChanged(blogIds)) + { + /* update Forums List */ + updateChannelList(); + + it = std::find(blogIds.begin(), blogIds.end(), mBlogId); + if (it != blogIds.end()) + { + updateChannelMsgs(); + } + } +} + + +void BlogsDialog::updateChannelList() +{ + + std::list channelList; + std::list::iterator it; + if (!rsBlogs) + { + return; + } + + rsBlogs->getBlogList(channelList); + + /* get the ids for our lists */ + std::list adminIds; + std::list subIds; + std::list popIds; + std::list otherIds; + std::multimap popMap; + + for(it = channelList.begin(); it != channelList.end(); it++) + { + /* sort it into Publish (Own), Subscribed, Popular and Other */ + uint32_t flags = it->blogFlags; + + if (flags & RS_DISTRIB_ADMIN) + { + adminIds.push_back(it->blogId); + } + else if (flags & RS_DISTRIB_SUBSCRIBED) + { + subIds.push_back(it->blogId); + } + else + { + /* rate the others by popularity */ + popMap.insert(std::make_pair(it->pop, it->blogId)); + } + } + + /* iterate backwards through popMap - take the top 5 or 10% of list */ + uint32_t popCount = 5; + if (popCount < popMap.size() / 10) + { + popCount = popMap.size() / 10; + } + + uint32_t i = 0; + uint32_t popLimit = 0; + std::multimap::reverse_iterator rit; + for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++) + { + popIds.push_back(rit->second); + } + + if (rit != popMap.rend()) + { + popLimit = rit->first; + } + + for(it = channelList.begin(); it != channelList.end(); it++) + { + /* ignore the ones we've done already */ + uint32_t flags = it->blogFlags; + + if (flags & RS_DISTRIB_ADMIN) + { + continue; + } + else if (flags & RS_DISTRIB_SUBSCRIBED) + { + continue; + } + else + { + if (it->pop < popLimit) + { + otherIds.push_back(it->blogId); + } + } + } + + /* now we have our lists ---> update entries */ + + updateChannelListOwn(adminIds); + updateChannelListSub(subIds); + updateChannelListPop(popIds); + updateChannelListOther(otherIds); +} + +void BlogsDialog::updateChannelListOwn(std::list &ids) +{ + std::list::iterator iit; + + /* remove rows with groups before adding new ones */ + model->item(OWN)->removeRows(0, model->item(OWN)->rowCount()); + + for (iit = ids.begin(); iit != ids.end(); iit ++) { +#ifdef CHAN_DEBUG + std::cerr << "BlogsDialog::updateChannelListOwn(): " << *iit << std::endl; +#endif + QStandardItem *ownGroup = model->item(OWN); + QList channel; + QStandardItem *item1 = new QStandardItem(); + QStandardItem *item2 = new QStandardItem(); + + BlogInfo ci; + if (rsBlogs && rsBlogs->getBlogInfo(*iit, ci)) { + item1->setData(QVariant(QString::fromStdWString(ci.blogName)), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(ci.blogId)), Qt::DisplayRole); + item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3" + ).arg(QString::number(ci.pop)).arg(9999).arg(9999)); + } else { + item1->setData(QVariant(QString("Unknown Blog")), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole); + item1->setToolTip("Unknown Blog\nNo Description"); + } + + channel.append(item1); + channel.append(item2); + ownGroup->appendRow(channel); + } +} + +void BlogsDialog::updateChannelListSub(std::list &ids) +{ + std::list::iterator iit; + + /* remove rows with groups before adding new ones */ + model->item(SUBSCRIBED)->removeRows(0, model->item(SUBSCRIBED)->rowCount()); + + for (iit = ids.begin(); iit != ids.end(); iit ++) { +#ifdef CHAN_DEBUG + std::cerr << "BlogsDialog::updateChannelListSub(): " << *iit << std::endl; +#endif + QStandardItem *ownGroup = model->item(SUBSCRIBED); + QList channel; + QStandardItem *item1 = new QStandardItem(); + QStandardItem *item2 = new QStandardItem(); + + BlogInfo ci; + if (rsBlogs && rsBlogs->getBlogInfo(*iit, ci)) { + item1->setData(QVariant(QString::fromStdWString(ci.blogName)), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(ci.blogId)), Qt::DisplayRole); + item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3" + ).arg(QString::number(ci.pop)).arg(9999).arg(9999)); + } else { + item1->setData(QVariant(QString("Unknown Channel")), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole); + item1->setToolTip("Unknown Channel\nNo Description"); + } + + channel.append(item1); + channel.append(item2); + ownGroup->appendRow(channel); + } + +} + +void BlogsDialog::updateChannelListPop(std::list &ids) +{ + std::list::iterator iit; + + /* remove rows with groups before adding new ones */ + model->item(POPULAR)->removeRows(0, model->item(POPULAR)->rowCount()); + + for (iit = ids.begin(); iit != ids.end(); iit ++) { +#ifdef CHAN_DEBUG + std::cerr << "BlogsDialog::updateChannelListPop(): " << *iit << std::endl; +#endif + QStandardItem *ownGroup = model->item(POPULAR); + QList channel; + QStandardItem *item1 = new QStandardItem(); + QStandardItem *item2 = new QStandardItem(); + + BlogInfo ci; + if (rsBlogs && rsBlogs->getBlogInfo(*iit, ci)) { + item1->setData(QVariant(QString::fromStdWString(ci.blogName)), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(ci.blogId)), Qt::DisplayRole); + item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3" + ).arg(QString::number(ci.pop)).arg(9999).arg(9999)); + } else { + item1->setData(QVariant(QString("Unknown Channel")), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole); + item1->setToolTip("Unknown Channel\nNo Description"); + } + + channel.append(item1); + channel.append(item2); + ownGroup->appendRow(channel); + } +} + +void BlogsDialog::updateChannelListOther(std::list &ids) +{ + std::list::iterator iit; + + /* remove rows with groups before adding new ones */ + model->item(OTHER)->removeRows(0, model->item(OTHER)->rowCount()); + + for (iit = ids.begin(); iit != ids.end(); iit ++) { +#ifdef CHAN_DEBUG + std::cerr << "BlogsDialog::updateChannelListOther(): " << *iit << std::endl; +#endif + QStandardItem *ownGroup = model->item(OTHER); + QList channel; + QStandardItem *item1 = new QStandardItem(); + QStandardItem *item2 = new QStandardItem(); + + BlogInfo ci; + if (rsBlogs && rsBlogs->getBlogInfo(*iit, ci)) { + item1->setData(QVariant(QString::fromStdWString(ci.blogName)), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(ci.blogId)), Qt::DisplayRole); + item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3" + ).arg(QString::number(ci.pop)).arg(9999).arg(9999)); + } else { + item1->setData(QVariant(QString("Unknown Blog")), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole); + item1->setToolTip("Unknown Blog\nNo Description"); + } + + channel.append(item1); + channel.append(item2); + ownGroup->appendRow(channel); + } +} + +void BlogsDialog::updateChannelMsgs() +{ + if (!rsBlogs) + return; + + BlogInfo ci; + if (!rsBlogs->getBlogInfo(mBlogId, ci)) + { + postButton->setEnabled(false); + subscribeButton->setEnabled(false); + unsubscribeButton->setEnabled(false); + nameLabel->setText("No Blog Selected"); + iconLabel->setEnabled(false); + return; + } + + iconLabel->setEnabled(true); + + /* set textcolor for Channel name */ + QString channelStr("%1"); + + /* set Channel name */ + QString cname = QString::fromStdWString(ci.blogName); + nameLabel->setText(channelStr.arg(cname)); + + /* do buttons */ + if (ci.blogFlags & RS_DISTRIB_SUBSCRIBED) + { + subscribeButton->setEnabled(false); + unsubscribeButton->setEnabled(true); + } + else + { + subscribeButton->setEnabled(true); + unsubscribeButton->setEnabled(false); + } + + if (ci.blogFlags & RS_DISTRIB_PUBLISH) + { + postButton->setEnabled(true); + } + else + { + postButton->setEnabled(false); + } + + /* replace all the messages with new ones */ + std::list::iterator mit; + for(mit = mBlogMsgItems.begin(); mit != mBlogMsgItems.end(); mit++) + { + delete (*mit); + } + mBlogMsgItems.clear(); + + std::list msgs; + std::list::iterator it; + + rsBlogs->getBlogMsgList(mBlogId, msgs); + + for(it = msgs.begin(); it != msgs.end(); it++) + { + BlogsMsgItem *cmi = new BlogsMsgItem(this, 0, mPeerId, mBlogId, it->msgId, true); + + mBlogMsgItems.push_back(cmi); + verticalLayout->addWidget(cmi); + } +} + + +void BlogsDialog::unsubscribeChannel() +{ +#ifdef BLOG_DEBUG + std::cerr << "BlogsDialog::unsubscribeChannel()"; + std::cerr << std::endl; +#endif + if (rsBlogs) + { + rsBlogs->blogSubscribe(mBlogId, false); + } + updateChannelMsgs(); +} + + +void BlogsDialog::subscribeChannel() +{ +#ifdef BLOG_DEBUG + std::cerr << "BlogsDialog::subscribeChannel()"; + std::cerr << std::endl; +#endif + if (rsBlogs) + { + rsBlogs->blogSubscribe(mBlogId, true); + } + updateChannelMsgs(); +} + + +void BlogsDialog::toggleSelection(const QModelIndex &index) +{ + QItemSelectionModel *selectionModel = treeView->selectionModel(); + if (index.child(0, 0).isValid()) + selectionModel->select(index, QItemSelectionModel::Toggle); +} + +void BlogsDialog::showChannelDetails() +{ + if (mBlogId == "") + { + return; + } + + if (!rsBlogs) + return; + + //static ChannelDetails *channelui = new ChannelDetails(); + + //channelui->showDetails(mBlogId); + //channelui->show(); + +} diff --git a/retroshare-gui/src/gui/blogs/BlogsDialog.h b/retroshare-gui/src/gui/blogs/BlogsDialog.h new file mode 100644 index 000000000..29ef9b628 --- /dev/null +++ b/retroshare-gui/src/gui/blogs/BlogsDialog.h @@ -0,0 +1,108 @@ +/**************************************************************** + * 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 _BLOGSDIALOG_H +#define _BLOGSDIALOG_H + +#include "gui/mainpage.h" +#include "ui_BlogsDialog.h" + +#include + +#include "gui/feeds/FeedHolder.h" + +#define OWN 0 +#define SUBSCRIBED 1 +#define POPULAR 2 +#define OTHER 3 + +class BlogsMsgItem; + + +class BlogsDialog : public MainPage, public FeedHolder, private Ui::BlogsDialog +{ + Q_OBJECT + +public: + /** Default Constructor */ + BlogsDialog(QWidget *parent = 0); + /** Default Destructor */ + + +virtual void deleteFeedItem(QWidget *item, uint32_t type); +virtual void openChat(std::string peerId); +virtual void openMsg(uint32_t type, std::string grpId, std::string inReplyTo); + +public slots: + + void selectChannel( std::string ); + void selectChannel(const QModelIndex &); + void toggleSelection(const QModelIndex &); + +private slots: + + void channelListCustomPopupMenu( QPoint point ); + + void checkUpdate(); + + void createChannel(); + //void sendMsg(); + + void channelSelection(); + + void subscribeChannel(); + void unsubscribeChannel(); + + void createMsg(); + + void showChannelDetails(); + +private: + + void updateChannelList(); + void updateChannelListOwn(std::list &ids); + void updateChannelListSub(std::list &ids); + void updateChannelListPop(std::list &ids); + void updateChannelListOther(std::list &ids); + + void updateChannelMsgs(); + + QStandardItemModel *model; + + std::string mBlogId; /* current Channel */ + std::string mPeerId; + + /* Layout Pointers */ + QBoxLayout *mMsgLayout; + + + + std::list mBlogMsgItems; + + QFont mChannelFont; + QFont itemFont; + +}; + + + +#endif + diff --git a/retroshare-gui/src/gui/blogs/BlogsDialog.ui b/retroshare-gui/src/gui/blogs/BlogsDialog.ui new file mode 100644 index 000000000..6956f2c4f --- /dev/null +++ b/retroshare-gui/src/gui/blogs/BlogsDialog.ui @@ -0,0 +1,591 @@ + + + BlogsDialog + + + + 0 + 0 + 681 + 476 + + + + + 0 + 0 + + + + + 0 + 0 + + + + Form + + + + + + + 0 + 0 + + + + + 222 + 0 + + + + + 222 + 16777215 + + + + + 0 + 0 + + + + + 221 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + + + + 220 + 0 + + + + + 220 + 16777215 + + + + + 220 + 0 + + + + QFrame#chheaderframe{ +background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, + stop:0 #FEFEFE, stop:1 #E8E8E8); + +border: 1px solid #CCCCCC;} + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + + + 0 + + + + + + 24 + 24 + + + + + + + :/images/kblogger.png + + + true + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:10pt; font-weight:600;">Blogs</span></p></body></html> + + + + + + + + + Qt::Horizontal + + + + 123 + 13 + + + + + + + + Add + + + QPushButton::menu-indicator { + subcontrol-origin: padding; + subcontrol-position: bottom right; + } + + QPushButton::menu-indicator:pressed, QPushButton::menu-indicator:open { + position: relative; + top: 2px; left: 2px; /* shift the arrow by 2 px */ + } + + QPushButton:hover { + border: 1px solid #CCCCCC; + } + + + + + + + :/images/edit_add24.png:/images/edit_add24.png + + + + 16 + 16 + + + + false + + + true + + + + + + + + + + Qt::CustomContextMenu + + + + + + + + + + + + QFrame#frame{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, + stop:0 #F2F2F2, stop:1 #E6E6E6);} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + + + 16 + + + 9 + + + + + + 64 + 64 + + + + + 64 + 64 + + + + QLabel{ +border: 2px solid white; +border-radius: 10px; +} + + + + + + :/images/hi64-app-kblogger.png + + + false + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:14pt;">Blog Name</span></p></body></html> + + + true + + + + + + + + + Qt::Horizontal + + + + + + + 9 + + + 9 + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Post To Channel + + + QToolButton, QPushButton, QComboBox { +border-image: url(:/images/btn_26.png) 4; +border-width: 4; +padding: 0px 6px; +font-size: 12px; +} + +QToolButton:hover, QPushButton:hover, QComboBox:hover { +border-image: url(:/images/btn_26_hover.png) 4; +} + +QToolButton:disabled, QPushButton:disabled, QComboBox::disabled { +color:gray; +} + +QToolButton:pressed, QPushButton:pressed{ +border-image: url(:/images/btn_26_pressed.png) 4; +} + + + + + + + :/images/mail_send.png:/images/mail_send.png + + + + + + + + 0 + 0 + + + + + 26 + 26 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:9pt;">Unsubcribe To Blog</span></p></body></html> + + + QToolButton, QPushButton, QComboBox { +border-image: url(:/images/btn_26.png) 4; +border-width: 4; +padding: 0px 6px; +font-size: 12px; +} + +QToolButton:hover, QPushButton:hover, QComboBox:hover { +border-image: url(:/images/btn_26_hover.png) 4; +} + +QToolButton:disabled, QPushButton:disabled, QComboBox::disabled { +color:gray; +} + +QToolButton:pressed, QPushButton:pressed{ +border-image: url(:/images/btn_26_pressed.png) 4; +} + + + Unsubscribe + + + + + + + + 0 + 0 + + + + + 26 + 26 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:9pt;">Subscribe To Blog</span></p></body></html> + + + QToolButton, QPushButton, QComboBox { +border-image: url(:/images/btn_26.png) 4; +border-width: 4; +padding: 0px 6px; +font-size: 12px; +} + +QToolButton:hover, QPushButton:hover, QComboBox:hover { +border-image: url(:/images/btn_26_hover.png) 4; +} + +QToolButton:disabled, QPushButton:disabled, QComboBox::disabled { +color:gray; +} + +QToolButton:pressed, QPushButton:pressed{ +border-image: url(:/images/btn_26_pressed.png) 4; +} + + + Subscribe + + + + :/images/konqsidebar_news24.png:/images/konqsidebar_news24.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + 1 + 0 + + + + + 0 + 0 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + + + true + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + 0 + 0 + 429 + 331 + + + + QWidget#scrollAreaWidgetContents{border: none;} + + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Qt::Vertical + + + + 391 + 266 + + + + + + + + + + + + + + + + + + :/images/kblogger.png:/images/kblogger.png + + + Create New Blog + + + Create New Blog + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/blogs/BlogsMsgItem.cpp b/retroshare-gui/src/gui/blogs/BlogsMsgItem.cpp new file mode 100644 index 000000000..989a5fd4e --- /dev/null +++ b/retroshare-gui/src/gui/blogs/BlogsMsgItem.cpp @@ -0,0 +1,238 @@ +/**************************************************************** + * 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 +#include + +#include "BlogsMsgItem.h" + +#include "gui/feeds/FeedHolder.h" +#include "gui/feeds/SubFileItem.h" + +#include "rsiface/rsblogs.h" + +#include +#include + + +/**** + * #define DEBUG_ITEM 1 + ****/ + +/** Constructor */ +BlogsMsgItem::BlogsMsgItem(FeedHolder *parent, uint32_t feedId, std::string peerId, std::string blogId, std::string msgId, bool isHome) +:QWidget(NULL), mParent(parent), mFeedId(feedId), + mPeerId(peerId), mBlogId(blogId), mMsgId(msgId), mIsHome(isHome) +{ + /* Invoke the Qt Designer generated object setup routine */ + setupUi(this); + + /* 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 ) ) ); + connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) ); + + small(); + updateItemStatic(); + updateItem(); + +} + + +void BlogsMsgItem::updateItemStatic() +{ + /* fill in */ +#ifdef DEBUG_ITEM + std::cerr << "ChanMsgItem::updateItemStatic()"; + std::cerr << std::endl; +#endif + + BlogMsgInfo cmi; + + if (!rsBlogs) + return; + + if (!rsBlogs->getBlogMessage(mBlogId, mMsgId, cmi)) + return; + + QString title; + + if (!mIsHome) + { + BlogInfo ci; + rsBlogs->getBlogInfo(mBlogId, ci); + title = "Channel Feed: "; + title += QString::fromStdWString(ci.blogName); + titleLabel->setText(title); + subjectLabel->setText(QString::fromStdWString(cmi.subject)); + } + else + { + /* subject */ + titleLabel->setText(QString::fromStdWString(cmi.subject)); + subjectLabel->setText(QString::fromStdWString(cmi.msg)); + } + + msgLabel->setText(QString::fromStdWString(cmi.msg)); + + QDateTime qtime; + qtime.setTime_t(cmi.ts); + QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm:ss"); + datetimelabel->setText(timestamp); + + { + std::ostringstream out; + out << "(" << cmi.count << " Files)"; + filelabel->setText(QString::fromStdString(out.str())); + } + + + std::list::iterator it; + for(it = cmi.files.begin(); it != cmi.files.end(); it++) + { + /* add file */ + SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->size, + SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, ""); + mFileItems.push_back(fi); + + QLayout *layout = expandFrame->layout(); + layout->addWidget(fi); + } + + //playButton->setEnabled(false); + + if (mIsHome) + { + /* disable buttons */ + clearButton->setEnabled(false); + //gotoButton->setEnabled(false); + unsubscribeButton->setEnabled(false); + + clearButton->hide(); + } + + /* don't really want this at all! */ + unsubscribeButton->hide(); + //playButton->hide(); +} + + +void BlogsMsgItem::updateItem() +{ + /* fill in */ +#ifdef DEBUG_ITEM + std::cerr << "ChanMsgItem::updateItem()"; + std::cerr << std::endl; +#endif + int msec_rate = 10000; + + /* Very slow Tick to check when all files are downloaded */ + std::list::iterator it; + for(it = mFileItems.begin(); it != mFileItems.end(); it++) + { + if (!(*it)->done()) + { + /* loop again */ + QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) )); + return; + } + } + + /*** + * At this point cannot create a playlist.... + * so can't enable play for all. + + if (mFileItems.size() > 0) + { + playButton->setEnabled(true); + } + ***/ +} + + +void BlogsMsgItem::small() +{ + expandFrame->hide(); +} + +void BlogsMsgItem::toggle() +{ + 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")); + } +} + + +void BlogsMsgItem::removeItem() +{ +#ifdef DEBUG_ITEM + std::cerr << "ChanMsgItem::removeItem()"; + std::cerr << std::endl; +#endif + hide(); + if (mParent) + { + mParent->deleteFeedItem(this, mFeedId); + } +} + + +void BlogsMsgItem::gotoHome() +{ +#ifdef DEBUG_ITEM + std::cerr << "ChanMsgItem::gotoHome()"; + std::cerr << std::endl; +#endif +} + +/*********** SPECIFIC FUNCTIOSN ***********************/ + + +void BlogsMsgItem::unsubscribeChannel() +{ +#ifdef DEBUG_ITEM + std::cerr << "ChanMsgItem::unsubscribeChannel()"; + std::cerr << std::endl; +#endif +} + + +void BlogsMsgItem::playMedia() +{ +#ifdef DEBUG_ITEM + std::cerr << "ChanMsgItem::playMedia()"; + std::cerr << std::endl; +#endif +} + + diff --git a/retroshare-gui/src/gui/blogs/BlogsMsgItem.h b/retroshare-gui/src/gui/blogs/BlogsMsgItem.h new file mode 100644 index 000000000..58a135080 --- /dev/null +++ b/retroshare-gui/src/gui/blogs/BlogsMsgItem.h @@ -0,0 +1,73 @@ +/**************************************************************** + * 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 _BLOGS_MSG_ITEM_DIALOG_H +#define _BLOGS_MSG_ITEM_DIALOG_H + +#include "ui_BlogsMsgItem.h" + +#include +#include + +class FeedHolder; +class SubFileItem; + +class BlogsMsgItem : public QWidget, private Ui::BlogsMsgItem +{ + Q_OBJECT + +public: + /** Default Constructor */ + BlogsMsgItem(FeedHolder *parent, uint32_t feedId, std::string peerId, std::string blogId, std::string msgId, bool isHome); + + /** Default Destructor */ + + void updateItemStatic(); + void small(); + +private slots: + /* default stuff */ + void gotoHome(); + void removeItem(); + void toggle(); + + void playMedia(); + void unsubscribeChannel(); + + void updateItem(); + +private: + FeedHolder *mParent; + uint32_t mFeedId; + + std::string mBlogId; + std::string mMsgId; + std::string mPeerId; + + bool mIsHome; + + std::list mFileItems; +}; + + + +#endif + diff --git a/retroshare-gui/src/gui/blogs/BlogsMsgItem.ui b/retroshare-gui/src/gui/blogs/BlogsMsgItem.ui new file mode 100644 index 000000000..5027c0df8 --- /dev/null +++ b/retroshare-gui/src/gui/blogs/BlogsMsgItem.ui @@ -0,0 +1,287 @@ + + + BlogsMsgItem + + + + 0 + 0 + 538 + 272 + + + + Form + + + QToolButton, QPushButton, QComboBox { +border-image: url(:/images/btn_26.png) 4; +border-width: 4; +padding: 0px 6px; +font-size: 12px; +} + +QToolButton:hover, QPushButton:hover, QComboBox:hover { +border-image: url(:/images/btn_26_hover.png) 4; +} + +QToolButton:disabled, QPushButton:disabled, QComboBox::disabled { +color:gray; +} + +QToolButton:pressed, QPushButton:pressed{ +border-image: url(:/images/btn_26_pressed.png) 4; +} + + + + 0 + + + 6 + + + + + + 0 + 0 + + + + QFrame#frame{border: 3px solid #407AC1; +background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, +stop:0 #FFFFFF, stop:1 #F2F2F2);; +border-radius: 10px;} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + 0 + 0 + + + + + 11 + 75 + true + true + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:11pt; font-weight:600; font-style:italic;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#656565;">Blog Subject</span></p></body></html> + + + + + + + + 75 + true + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; color:#666666;">DateTime</span></p></body></html> + + + + + + + + 0 + 0 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Blog Message</span></p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 67 + 21 + + + + + + + + + 0 + 0 + + + + Unsubscribe From Channel + + + + + + + :/images/mail_delete.png:/images/mail_delete.png + + + + + + + + 0 + 0 + + + + Remove Item + + + + + + + :/images/close_normal.png:/images/close_normal.png + + + + + + + + 0 + 0 + + + + Expand + + + + + + + + + + :/images/edit_add24.png:/images/edit_add24.png + + + + + + + TextLabel + + + + + + + + + QFrame#expandFrame{border: 2px solid #D3D3D3; +background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, +stop:0 #FFFFFF, stop:1 #F2F2F2);; +border-radius: 10px;} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 0 + 0 + + + + Comments here + + + + + + + + + + + + + Qt::Vertical + + + + 200 + 200 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/blogs/CreateBlog.cpp b/retroshare-gui/src/gui/blogs/CreateBlog.cpp new file mode 100644 index 000000000..6a72fbbac --- /dev/null +++ b/retroshare-gui/src/gui/blogs/CreateBlog.cpp @@ -0,0 +1,138 @@ +/**************************************************************** + * 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 +#include + +#include "CreateBlog.h" + +#include "rsiface/rsblogs.h" + +/** Constructor */ +CreateBlog::CreateBlog(QWidget *parent, bool isForum) +: QDialog(parent), mIsForum(isForum) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + // connect up the buttons. + connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelBlog( ) ) ); + connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createBlog( ) ) ); + + + newBlog(); + +} + +void CreateBlog::show() +{ + //loadSettings(); + if(!this->isVisible()) { + QWidget::show(); + + } +} + + +void CreateBlog::newBlog() +{ + + if (mIsForum) + { + /* enforce Public for the moment */ + ui.typePublic->setChecked(true); + + ui.typePrivate->setEnabled(false); + ui.typeEncrypted->setEnabled(false); + + ui.msgAnon->setChecked(true); + //ui.msgAuth->setEnabled(false); + } + else + { + /* enforce Private for the moment */ + ui.typePrivate->setChecked(true); + + ui.typePublic->setEnabled(false); + ui.typeEncrypted->setEnabled(false); + + ui.msgAnon->setChecked(true); + ui.msgAuth->setEnabled(false); + ui.msgGroupBox->hide(); + } +} + +void CreateBlog::createBlog() +{ + QString name = ui.forumName->text(); + QString desc = ui.forumDesc->toPlainText(); //toHtml(); + uint32_t flags = 0; + + if(name.isEmpty()) + { /* error message */ + int ret = QMessageBox::warning(this, tr("RetroShare"), + tr("Please add a Name"), + QMessageBox::Ok, QMessageBox::Ok); + + return; //Don't add a empty name!! + } + else + + 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 (rsBlogs) + { + rsBlogs->createBlog(name.toStdWString(), desc.toStdWString(), flags); + } + + + close(); + return; +} + + +void CreateBlog::cancelBlog() +{ + close(); + return; +} + + diff --git a/retroshare-gui/src/gui/blogs/CreateBlog.h b/retroshare-gui/src/gui/blogs/CreateBlog.h new file mode 100644 index 000000000..2b9e1578b --- /dev/null +++ b/retroshare-gui/src/gui/blogs/CreateBlog.h @@ -0,0 +1,61 @@ +/**************************************************************** + * 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_BLOG_DIALOG_H +#define _CREATE_BLOG_DIALOG_H + +#include + +#include "ui_CreateBlog.h" + +class CreateBlog : public QDialog +{ + Q_OBJECT + +public: + CreateBlog(QWidget *parent = 0, bool isForum = true); + +void newBlog(); /* cleanup */ + + /** Qt Designer generated object */ + Ui::CreateBlog ui; + + QPixmap picture; + +public slots: + /** Overloaded QWidget.show */ + void show(); + +private slots: + + /* actions to take.... */ +void createBlog(); +void cancelBlog(); + + +private: + + + bool mIsForum; +}; + +#endif + diff --git a/retroshare-gui/src/gui/blogs/CreateBlog.ui b/retroshare-gui/src/gui/blogs/CreateBlog.ui new file mode 100644 index 000000000..6c789e907 --- /dev/null +++ b/retroshare-gui/src/gui/blogs/CreateBlog.ui @@ -0,0 +1,245 @@ + + + CreateBlog + + + + 0 + 0 + 534 + 481 + + + + Create new Blog + + + + :/images/rstray3.png:/images/rstray3.png + + + + 0 + + + 0 + + + + + + 16777215 + 64 + + + + QFrame#frame_2{background-image: url(:/images/connect/connectFriendBanner.png);} + + + QFrame::NoFrame + + + QFrame::Raised + + + + 6 + + + 6 + + + + + + 48 + 48 + + + + + + + + + + :/images/hi48-app-kblogger.png + + + true + + + + + + + color: rgb(255, 255, 255); + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:24pt; font-weight:600; color:#ffffff;">New Blog</span></p></body></html> + + + + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + + + Name + + + + + + + + + + + + + + Description + + + + + + + + + + + + Type: + + + + 0 + + + 6 + + + + + Public - Anyone can read and publish (Shared Publish Key) + + + + + + + Restricted - Anyone can read, limited publishing (Private Publish Key) + + + + + + + Private - (Private Publish Key required to view Messages) + + + + + + + + + + Allowed Messages + + + + 0 + + + 6 + + + + + Authemticated Messages + + + + + + + Anonymous Messages + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Qt::Horizontal + + + + 238 + 20 + + + + + + + + Cancel + + + + + + + Create + + + true + + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/blogs/CreateBlogMsg.cpp b/retroshare-gui/src/gui/blogs/CreateBlogMsg.cpp new file mode 100644 index 000000000..1dd31d0a9 --- /dev/null +++ b/retroshare-gui/src/gui/blogs/CreateBlogMsg.cpp @@ -0,0 +1,463 @@ +/**************************************************************** + * 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 + +#include "CreateBlogMsg.h" + +#include "gui/feeds/SubFileItem.h" + +#include "rsiface/rstypes.h" +#include "rsiface/rspeers.h" +#include "rsiface/rsforums.h" +#include "rsiface/rsblogs.h" +#include "rsiface/rsmsgs.h" +#include "rsiface/rsfiles.h" + +#include + +/** Constructor */ +CreateBlogMsg::CreateBlogMsg(std::string cId) +: QDialog (NULL), mBlogId(cId) ,mCheckAttachment(true) +{ + /* Invoke the Qt Designer generated object setup routine */ + setupUi(this); + + connect(buttonBox, SIGNAL(accepted()), this, SLOT(sendMsg())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancelMsg())); + + connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); + + setAcceptDrops(true); + + newBlogMsg(); +} + +/* Dropping */ + +void CreateBlogMsg::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 CreateBlogMsg::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::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()->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::cerr << std::endl; + + QList urls = event->mimeData()->urls(); + QList::iterator uit; + for(uit = urls.begin(); uit != urls.end(); uit++) + { + std::string localpath = uit->toLocalFile().toStdString(); + std::cerr << "Whole URL: " << uit->toString().toStdString(); + std::cerr << std::endl; + std::cerr << "or As Local File: " << localpath; + std::cerr << std::endl; + + if (localpath.size() > 0) + { + + addAttachment(localpath); + } + } + } + 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 CreateBlogMsg::parseRsFileListAttachments(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 CreateBlogMsg::addAttachment(std::string hash, std::string fname, uint64_t size, bool local, 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_ATTACH; + if (local) + { + flags |= SFI_STATE_LOCAL; + } + else + { + flags |= SFI_STATE_REMOTE; + // TMP REMOVED REMOTE ADD FOR DEMONSTRATOR + return; + } + + SubFileItem *file = new SubFileItem(hash, fname, size, flags, srcId); + + mAttachments.push_back(file); + QLayout *layout = fileFrame->layout(); + layout->addWidget(file); + + if (mCheckAttachment) + { + checkAttachmentReady(); + } + + return; +} + + +void CreateBlogMsg::addExtraFile() +{ + /* add a SubFileItem to the attachment section */ + std::cerr << "CreateChannelMsg::addExtraFile() opening file dialog"; + std::cerr << std::endl; + + // select a file + QString qfile = QFileDialog::getOpenFileName(this, tr("Add Extra File"), "", "", 0, + QFileDialog::DontResolveSymlinks); + std::string filePath = qfile.toStdString(); + if (filePath != "") + { + addAttachment(filePath); + } +} + + +void CreateBlogMsg::addAttachment(std::string path) +{ + /* add a SubFileItem to the attachment section */ + std::cerr << "CreateChannelMsg::addAttachment()"; + std::cerr << std::endl; + + /* add to ExtraList here, + * use default TIMEOUT of 30 days (time to fetch it). + */ + //uint32_t period = 30 * 24 * 60 * 60; + //uint32_t flags = 0; + //rsFiles->ExtraFileHash(localpath, period, flags); + + /* add widget in for new destination */ + SubFileItem *file = new SubFileItem(path); + + mAttachments.push_back(file); + QLayout *layout = fileFrame->layout(); + layout->addWidget(file); + + if (mCheckAttachment) + { + checkAttachmentReady(); + } + + return; + +} + +void CreateBlogMsg::checkAttachmentReady() +{ + std::list::iterator fit; + + mCheckAttachment = false; + + for(fit = mAttachments.begin(); fit != mAttachments.end(); fit++) + { + if (!(*fit)->isHidden()) + { + if (!(*fit)->ready()) + { + /* + */ + buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); + break; + + + return; + } + } + } + + if (fit == mAttachments.end()) + { + buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); + } + + /* repeat... */ + int msec_rate = 1000; + QTimer::singleShot( msec_rate, this, SLOT(checkAttachmentReady(void))); +} + + +void CreateBlogMsg::cancelMsg() +{ + std::cerr << "CreateChannelMsg::cancelMsg()"; + std::cerr << std::endl; + close(); + return; +} + +void CreateBlogMsg::newBlogMsg() +{ + + if (!rsBlogs) + return; + + BlogInfo ci; + if (!rsBlogs->getBlogInfo(mBlogId, ci)) + { + + return; + } + + channelName->setText(QString::fromStdWString(ci.blogName)); + + + +} + + +void CreateBlogMsg::sendMsg() +{ + std::cerr << "CreateChannelMsg::sendMsg()"; + std::cerr << std::endl; + + /* construct message bits */ + std::wstring subject = subjectEdit->text().toStdWString(); + std::wstring msg = msgEdit->toPlainText().toStdWString(); + + std::list files; + + std::list::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 CreateBlogMsg::sendMessage(std::wstring subject, std::wstring msg, std::list &files) +{ + QString name = subjectEdit->text(); + + if(name.isEmpty()) + { /* error message */ + int ret = QMessageBox::warning(this, tr("RetroShare"), + tr("Please add a Subject"), + QMessageBox::Ok, QMessageBox::Ok); + + return; //Don't add a empty Subject!! + } + else + + /* rsChannels */ + if (rsBlogs) + { + BlogMsgInfo msgInfo; + + msgInfo.blogId = mBlogId; + msgInfo.msgId = ""; + + msgInfo.subject = subject; + msgInfo.msg = msg; + msgInfo.files = files; + + rsBlogs->BlogMessageSend(msgInfo); + } + + close(); + return; + +} + + + + + + + diff --git a/retroshare-gui/src/gui/blogs/CreateBlogMsg.h b/retroshare-gui/src/gui/blogs/CreateBlogMsg.h new file mode 100644 index 000000000..24b2e5889 --- /dev/null +++ b/retroshare-gui/src/gui/blogs/CreateBlogMsg.h @@ -0,0 +1,76 @@ +/**************************************************************** + * 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 _CREATEBLOGMSG_H +#define _CREATEBLOGMSG_H + +#include "ui_CreateBlogMsg.h" +#include + +class SubFileItem; +class FileInfo; + +class CreateBlogMsg : public QDialog, private Ui::CreateBlogMsg +{ + Q_OBJECT + +public: + /** Default Constructor */ + CreateBlogMsg(std::string cId); + /** Default Destructor */ + + void addAttachment(std::string path); + void addAttachment(std::string hash, std::string fname, uint64_t size, + bool local, std::string srcId); + + void newBlogMsg(); + + QPixmap picture; + +protected: +virtual void dragEnterEvent(QDragEnterEvent *event); +virtual void dropEvent(QDropEvent *event); + +private slots: + void addExtraFile(); + void checkAttachmentReady(); + + void cancelMsg(); + void sendMsg(); + + +private: + + void parseRsFileListAttachments(std::string attachList); + + void sendMessage(std::wstring subject, std::wstring msg, std::list &files); + + std::string mBlogId; + + std::list mAttachments; + + bool mCheckAttachment; +}; + + + +#endif + diff --git a/retroshare-gui/src/gui/blogs/CreateBlogMsg.ui b/retroshare-gui/src/gui/blogs/CreateBlogMsg.ui new file mode 100644 index 000000000..3813f0cf6 --- /dev/null +++ b/retroshare-gui/src/gui/blogs/CreateBlogMsg.ui @@ -0,0 +1,360 @@ + + + CreateBlogMsg + + + + 0 + 0 + 627 + 464 + + + + true + + + New Blog Post + + + + :/images/rstray3.png:/images/rstray3.png + + + + 0 + + + 0 + + + + + + 16777215 + 64 + + + + QFrame#frame{background-image: url(:/images/connect/connectFriendBanner.png);} + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + + 48 + 48 + + + + + 48 + 48 + + + + + + + :/images/hi48-app-kblogger.png + + + true + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:26pt; color:#ffffff;">New Blog Post</span></p></body></html> + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 0 + + + + Blog Post + + + + + + + + + 75 + true + + + + Blog Post to: + + + + + + + true + + + true + + + + + + + + + Blog Message + + + + + + + + + 75 + true + + + + Subject : + + + + + + + + + + + + + + + + + + + + :/images/attachment.png:/images/attachment.png + + + Attachments + + + + 0 + + + 0 + + + + + 0 + + + 6 + + + 6 + + + + + + + + :/images/attachment.png + + + + + + + + 16777215 + 26 + + + + + 75 + true + + + + Attachments + + + + + + + Qt::Horizontal + + + + 334 + 26 + + + + + + + + + 0 + 0 + + + + + 34 + 34 + + + + + + + + :/images/add-share24.png:/images/add-share24.png + + + + 24 + 24 + + + + + + + + + + Qt::ScrollBarAlwaysOn + + + true + + + + + 0 + 0 + 582 + 282 + + + + + + + + 0 + 0 + + + + true + + + Drag and Drop Files from Search Results + + + QFrame#fileFrame{border: 2px solid black; +background: white;} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + Qt::Vertical + + + + 438 + 137 + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + + + + + + +