diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index f574b80ca..e0e9c4ea0 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -164,6 +164,7 @@ HEADERS += rshare.h \ gui/feeds/ChanMsgItem.h \ gui/feeds/BlogMsgItem.h \ gui/feeds/SubFileItem.h \ + gui/feeds/SubDestItem.h \ FORMS += gui/ChatDialog.ui \ @@ -238,6 +239,7 @@ FORMS += gui/ChatDialog.ui \ gui/feeds/ChanMsgItem.ui \ gui/feeds/BlogMsgItem.ui \ gui/feeds/SubFileItem.ui \ + gui/feeds/SubDestItem.ui \ SOURCES += main.cpp \ rshare.cpp \ @@ -350,6 +352,7 @@ SOURCES += main.cpp \ gui/feeds/ChanMsgItem.cpp \ gui/feeds/BlogMsgItem.cpp \ gui/feeds/SubFileItem.cpp \ + gui/feeds/SubDestItem.cpp \ RESOURCES += gui/images.qrc lang/lang.qrc games/qcheckers/qcheckers.qrc apps/smplayer/icons.qrc TRANSLATIONS += \ diff --git a/retroshare-gui/src/gui/BlogDialog.cpp b/retroshare-gui/src/gui/BlogDialog.cpp index 1791fc15a..8fbcec0cf 100644 --- a/retroshare-gui/src/gui/BlogDialog.cpp +++ b/retroshare-gui/src/gui/BlogDialog.cpp @@ -22,6 +22,8 @@ #include "BlogDialog.h" +#include "GeneralMsgDialog.h" + #include "rsiface/rsQblog.h" #include "rsiface/rspeers.h" //to retrieve peer/usrId info @@ -188,8 +190,15 @@ void BlogDialog::postBlog() void BlogDialog::openMsg(uint32_t type, std::string grpId, std::string inReplyTo) { - std::cerr << "BlogDialog::openMsg()"; - std::cerr << std::endl; + std::cerr << "BlogDialog::openMsg()"; + std::cerr << std::endl; + GeneralMsgDialog *msgDialog = new GeneralMsgDialog(NULL); + + + msgDialog->addDestination(type, grpId, inReplyTo); + + msgDialog->show(); + return; } diff --git a/retroshare-gui/src/gui/ChannelFeed.cpp b/retroshare-gui/src/gui/ChannelFeed.cpp index 3ba7103f4..ba9ebc216 100644 --- a/retroshare-gui/src/gui/ChannelFeed.cpp +++ b/retroshare-gui/src/gui/ChannelFeed.cpp @@ -20,55 +20,49 @@ ****************************************************************/ #include +#include + +#include "rsiface/rschannels.h" + #include "ChannelFeed.h" #include "gui/feeds/ChanGroupItem.h" #include "gui/feeds/ChanMenuItem.h" #include "gui/feeds/ChanMsgItem.h" +#include "gui/forums/CreateForum.h" + +#include "GeneralMsgDialog.h" + + /** Constructor */ ChannelFeed::ChannelFeed(QWidget *parent) : MainPage (parent) { - /* Invoke the Qt Designer generated object setup routine */ - setupUi(this); + /* Invoke the Qt Designer generated object setup routine */ + setupUi(this); - /* add dynamic widgets in */ + connect(chanButton, SIGNAL(clicked()), this, SLOT(createChannel())); + connect(postButton, SIGNAL(clicked()), this, SLOT(sendMsg())); - /* add layout */ + /*************** Setup Left Hand Side (List of Channels) ****************/ - /* add form */ + mGroupLayout = new QVBoxLayout; - QVBoxLayout *layout = new QVBoxLayout; + mGroupOwn = new ChanGroupItem("Own Channels"); + mGroupSub = new ChanGroupItem("Subscribed Channels"); + mGroupPop = new ChanGroupItem("Popular Channels"); + mGroupOther = new ChanGroupItem("Other Channels"); - ChanGroupItem *cg1 = new ChanGroupItem("Own Channels"); - ChanGroupItem *cg2 = new ChanGroupItem("Subscribed Channels"); - ChanGroupItem *cg3 = new ChanGroupItem("Popular Channels"); - ChanGroupItem *cg4 = new ChanGroupItem("Other Channels"); + mGroupLayout->addWidget(mGroupOwn); + mGroupLayout->addWidget(mGroupSub); + mGroupLayout->addWidget(mGroupPop); + mGroupLayout->addWidget(mGroupOther); - ChanMenuItem *cm1 = new ChanMenuItem("Channel with long name"); - ChanMenuItem *cm2 = new ChanMenuItem("Channel with very very very very long name"); - ChanMenuItem *cm3 = new ChanMenuItem("Channel with long name"); - ChanMenuItem *cm4 = new ChanMenuItem("Retroshare Releases"); - ChanMenuItem *cm5 = new ChanMenuItem("Popular Channel"); - - layout->addWidget(cg1); - layout->addWidget(cm1); - - layout->addWidget(cg2); - layout->addWidget(cm2); - layout->addWidget(cm3); - layout->addWidget(cm4); - - layout->addWidget(cg3); - layout->addWidget(cm5); - - layout->addWidget(cg4); QWidget *middleWidget = new QWidget(); //middleWidget->setSizePolicy( QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Minimum); middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); - middleWidget->setLayout(layout); - + middleWidget->setLayout(mGroupLayout); QScrollArea *scrollArea = new QScrollArea; scrollArea->setBackgroundRole(QPalette::Dark); @@ -81,32 +75,13 @@ ChannelFeed::ChannelFeed(QWidget *parent) chanFrame->setLayout(layout2); - /***** SECOND HALF *****/ + /*************** Setup Left Hand Side (List of Channels) ****************/ - QVBoxLayout *msgLayout = new QVBoxLayout; - - ChanMsgItem *ni1 = new ChanMsgItem(NULL, 0, "JEZ", "MSGID:47654765476", true); - ChanMsgItem *ni2 = new ChanMsgItem(NULL, 0, "JEZ", "MSGID:47654765476", true); - ChanMsgItem *ni3 = new ChanMsgItem(NULL, 0, "JEZ", "MSGID:47654765476", true); - ChanMsgItem *ni4 = new ChanMsgItem(NULL, 0, "JEZ", "MSGID:47654765476", true); - ChanMsgItem *ni5 = new ChanMsgItem(NULL, 0, "JEZ", "MSGID:47654765476", true); - ChanMsgItem *ni6 = new ChanMsgItem(NULL, 0, "JEZ", "MSGID:47654765476", true); - ChanMsgItem *ni7 = new ChanMsgItem(NULL, 0, "JEZ", "MSGID:47654765476", true); - ChanMsgItem *ni8 = new ChanMsgItem(NULL, 0, "JEZ", "MSGID:47654765476", true); - - msgLayout->addWidget(ni1); - msgLayout->addWidget(ni2); - msgLayout->addWidget(ni3); - msgLayout->addWidget(ni4); - msgLayout->addWidget(ni5); - msgLayout->addWidget(ni6); - msgLayout->addWidget(ni7); - msgLayout->addWidget(ni8); + mMsgLayout = new QVBoxLayout; QWidget *middleWidget2 = new QWidget(); middleWidget2->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); - middleWidget2->setLayout(msgLayout); - + middleWidget2->setLayout(mMsgLayout); QScrollArea *scrollArea2 = new QScrollArea; scrollArea2->setBackgroundRole(QPalette::Dark); @@ -118,9 +93,55 @@ ChannelFeed::ChannelFeed(QWidget *parent) layout3->addWidget(scrollArea2); msgFrame->setLayout(layout3); + + mChannelId = "OWNID"; + + updateChannelList(); + + QTimer *timer = new QTimer(this); + timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); + timer->start(1000); + } +void ChannelFeed::createChannel() +{ + CreateForum *cf = new CreateForum(NULL, false); + cf->show(); +} + +void ChannelFeed::channelSelection() +{ + /* which item was selected? */ + + + /* update mChannelId */ + + updateChannelMsgs(); +} + +void ChannelFeed::sendMsg() +{ + std::cerr << "ChannelFeed::sendMsg()"; + std::cerr << std::endl; + + if (mChannelId != "") + { + openMsg(FEEDHOLDER_MSG_CHANNEL, mChannelId, ""); + } + else + { + std::cerr << "ChannelFeed::sendMsg() no Channel Selected!"; + std::cerr << std::endl; + } + +} + + +/*************************************************************************************/ +/*************************************************************************************/ +/*************************************************************************************/ void ChannelFeed::deleteFeedItem(QWidget *item, uint32_t type) { @@ -132,9 +153,304 @@ void ChannelFeed::openChat(std::string peerId) return; } + void ChannelFeed::openMsg(uint32_t type, std::string grpId, std::string inReplyTo) { + std::cerr << "ChannelFeed::openMsg()"; + std::cerr << std::endl; + GeneralMsgDialog *msgDialog = new GeneralMsgDialog(NULL); + + + msgDialog->addDestination(type, grpId, inReplyTo); + + msgDialog->show(); return; } +void ChannelFeed::selectChannel( std::string cId) +{ + mChannelId = cId; + + updateChannelMsgs(); +} + +void ChannelFeed::checkUpdate() +{ + std::list chanIds; + std::list::iterator it; + if (!rsChannels) + return; + + if (rsChannels->channelsChanged(chanIds)) + { + /* update Forums List */ + updateChannelList(); + + it = std::find(chanIds.begin(), chanIds.end(), mChannelId); + if (it != chanIds.end()) + { + updateChannelMsgs(); + } + } +} + + + + +void ChannelFeed::updateChannelList() +{ + + std::list channelList; + std::list::iterator it; + if (!rsChannels) + { + return; + } + + rsChannels->getChannelList(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->channelFlags; + + if (flags & RS_DISTRIB_ADMIN) + { + adminIds.push_back(it->channelId); + } + else if (flags & RS_DISTRIB_SUBSCRIBED) + { + subIds.push_back(it->channelId); + } + else + { + /* rate the others by popularity */ + popMap.insert(std::make_pair(it->pop, it->channelId)); + } + } + + /* iterate backwards through popMap - take the top 5 or 10% of list */ + uint32_t popCount = 5; + if (popCount < popMap.size() / 10) + { + popCount = popMap.size() / 10; + } + + uint32_t i = 0; + uint32_t popLimit = 0; + std::multimap::reverse_iterator rit; + for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++) + { + popIds.push_back(rit->second); + } + + if (rit != popMap.rend()) + { + popLimit = rit->first; + } + + for(it = channelList.begin(); it != channelList.end(); it++) + { + /* ignore the ones we've done already */ + uint32_t flags = it->channelFlags; + + if (flags & RS_DISTRIB_ADMIN) + { + continue; + } + else if (flags & RS_DISTRIB_SUBSCRIBED) + { + continue; + } + else + { + if (it->pop < popLimit) + { + otherIds.push_back(it->channelId); + } + } + } + + /* now we have our lists ---> update entries */ + + updateChannelListOwn(adminIds); + updateChannelListSub(subIds); + updateChannelListPop(popIds); + updateChannelListOther(otherIds); +} + +void ChannelFeed::updateChannelListOwn(std::list &ids) +{ + std::list::iterator it; + std::list::iterator iit; + + /* TEMP just replace all of them */ + for(it = mChannelListOwn.begin(); it != mChannelListOwn.end(); it++) + { + delete (*it); + } + mChannelListOwn.clear(); + + int topIndex = mGroupLayout->indexOf(mGroupOwn); + int index = topIndex + 1; + for (iit = ids.begin(); iit != ids.end(); iit++, index++) + { + std::cerr << "ChannelFeed::updateChannelListOwn(): " << *iit << " at: " << index; + std::cerr << std::endl; + + ChanMenuItem *cmi = new ChanMenuItem(*iit); + mChannelListOwn.push_back(cmi); + mGroupLayout->insertWidget(index, cmi); + + connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string ))); + } +} + +void ChannelFeed::updateChannelListSub(std::list &ids) +{ + std::list::iterator it; + std::list::iterator iit; + + /* TEMP just replace all of them */ + for(it = mChannelListSub.begin(); it != mChannelListSub.end(); it++) + { + delete (*it); + } + mChannelListSub.clear(); + + int topIndex = mGroupLayout->indexOf(mGroupSub); + int index = topIndex + 1; + for (iit = ids.begin(); iit != ids.end(); iit++, index++) + { + std::cerr << "ChannelFeed::updateChannelListSub(): " << *iit << " at: " << index; + std::cerr << std::endl; + + ChanMenuItem *cmi = new ChanMenuItem(*iit); + mChannelListSub.push_back(cmi); + mGroupLayout->insertWidget(index, cmi); + connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string ))); + } + +} + +void ChannelFeed::updateChannelListPop(std::list &ids) +{ + std::list::iterator it; + std::list::iterator iit; + + /* TEMP just replace all of them */ + for(it = mChannelListPop.begin(); it != mChannelListPop.end(); it++) + { + delete (*it); + } + mChannelListPop.clear(); + + int topIndex = mGroupLayout->indexOf(mGroupPop); + int index = topIndex + 1; + for (iit = ids.begin(); iit != ids.end(); iit++, index++) + { + std::cerr << "ChannelFeed::updateChannelListPop(): " << *iit << " at: " << index; + std::cerr << std::endl; + + ChanMenuItem *cmi = new ChanMenuItem(*iit); + mChannelListPop.push_back(cmi); + mGroupLayout->insertWidget(index, cmi); + connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string ))); + } + + +} + +void ChannelFeed::updateChannelListOther(std::list &ids) +{ + std::list::iterator it; + std::list::iterator iit; + + /* TEMP just replace all of them */ + for(it = mChannelListOther.begin(); it != mChannelListOther.end(); it++) + { + delete (*it); + } + mChannelListOther.clear(); + + int topIndex = mGroupLayout->indexOf(mGroupOther); + int index = topIndex + 1; + for (iit = ids.begin(); iit != ids.end(); iit++, index++) + { + std::cerr << "ChannelFeed::updateChannelListOther(): " << *iit << " at: " << index; + std::cerr << std::endl; + + ChanMenuItem *cmi = new ChanMenuItem(*iit); + mChannelListOther.push_back(cmi); + mGroupLayout->insertWidget(index, cmi); + connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string ))); + } +} + +void ChannelFeed::updateChannelMsgs() +{ + if (!rsChannels) + return; + + ChannelInfo ci; + if (!rsChannels->getChannelInfo(mChannelId, ci)) + { + postButton->setEnabled(false); + subscribeButton->setEnabled(false); + unsubscribeButton->setEnabled(false); + nameLabel->setText("No Channel Selected"); + return; + } + /* set channel name */ + nameLabel->setText(QString::fromStdWString(ci.channelName)); + + /* do buttons */ + if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED) + { + subscribeButton->setEnabled(false); + unsubscribeButton->setEnabled(true); + } + else + { + subscribeButton->setEnabled(true); + unsubscribeButton->setEnabled(false); + } + + if (ci.channelFlags & RS_DISTRIB_PUBLISH) + { + postButton->setEnabled(true); + } + else + { + postButton->setEnabled(false); + } + + /* replace all the messages with new ones */ + std::list::iterator mit; + for(mit = mChanMsgItems.begin(); mit != mChanMsgItems.end(); mit++) + { + delete (*mit); + } + mChanMsgItems.clear(); + + std::list msgs; + std::list::iterator it; + + rsChannels->getChannelMsgList(mChannelId, msgs); + + for(it = msgs.begin(); it != msgs.end(); it++) + { + ChanMsgItem *cmi = new ChanMsgItem(this, 0, mChannelId, it->msgId, true); + + mChanMsgItems.push_back(cmi); + mMsgLayout->addWidget(cmi); + } +} diff --git a/retroshare-gui/src/gui/ChannelFeed.h b/retroshare-gui/src/gui/ChannelFeed.h index 6c90266d4..68ae68e6b 100644 --- a/retroshare-gui/src/gui/ChannelFeed.h +++ b/retroshare-gui/src/gui/ChannelFeed.h @@ -27,6 +27,10 @@ #include "gui/feeds/FeedHolder.h" +class ChanGroupItem; +class ChanMenuItem; +class ChanMsgItem; + class ChannelFeed : public MainPage, public FeedHolder, private Ui::ChannelFeed { Q_OBJECT @@ -41,10 +45,49 @@ 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 ); + +private slots: + + void checkUpdate(); + + void createChannel(); + void sendMsg(); + + void channelSelection(); + private: - /* lists of feedItems */ - //std::list mChanMsgItems; + void updateChannelList(); + void updateChannelListOwn(std::list &ids); + void updateChannelListSub(std::list &ids); + void updateChannelListPop(std::list &ids); + void updateChannelListOther(std::list &ids); + + void updateChannelMsgs(); + + std::string mChannelId; /* current Channel */ + + /* Layout Pointers */ + QBoxLayout *mGroupLayout; + QBoxLayout *mMsgLayout; + + /* Group Headers */ + ChanGroupItem *mGroupOwn; + ChanGroupItem *mGroupSub; + ChanGroupItem *mGroupPop; + ChanGroupItem *mGroupOther; + + /* lists of feedItems */ + std::list mChannelListOwn; + std::list mChannelListSub; + std::list mChannelListPop; + std::list mChannelListOther; + + std::list mChanMsgItems; + }; diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index d382c455b..666f6dad7 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -743,10 +743,8 @@ void ForumsDialog::markMsgAsRead() void ForumsDialog::newforum() { - CreateForum *cf = new CreateForum(NULL); + CreateForum *cf = new CreateForum(NULL, true); cf->show(); - - //insertForums(); } diff --git a/retroshare-gui/src/gui/GeneralMsgDialog.cpp b/retroshare-gui/src/gui/GeneralMsgDialog.cpp index ea80a3b14..46cb13ac5 100644 --- a/retroshare-gui/src/gui/GeneralMsgDialog.cpp +++ b/retroshare-gui/src/gui/GeneralMsgDialog.cpp @@ -23,25 +23,150 @@ #include "GeneralMsgDialog.h" #include "gui/feeds/FeedHolder.h" +#include "gui/feeds/SubFileItem.h" +#include "gui/feeds/SubDestItem.h" + +#include "rsiface/rstypes.h" +#include "rsiface/rspeers.h" +#include "rsiface/rsforums.h" +#include "rsiface/rschannels.h" +#include "rsiface/rsmsgs.h" + #include /** Constructor */ -GeneralMsgDialog::GeneralMsgDialog(QWidget *parent) +GeneralMsgDialog::GeneralMsgDialog(QWidget *parent, uint32_t type) : QDialog (parent) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); + + connect(addButton, SIGNAL(clicked()), this, SLOT(newDestination())); + connect(typeComboBox, SIGNAL(currentIndexChanged( int )), this, SLOT(updateGroupId())); + + connect(buttonBox, SIGNAL(accepted()), this, SLOT(sendMsg())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancelMsg())); + + /* set the type to ... + * const uint32_t GMD_TYPE_MESSAGE_IDX = 0; + * const uint32_t GMD_TYPE_FORUM_IDX = 1; + * const uint32_t GMD_TYPE_CHANNEL_IDX = 2; + * const uint32_t GMD_TYPE_BLOG_IDX = 3; + * */ + + typeComboBox->clear(); + typeComboBox->addItem("Message"); + typeComboBox->addItem("Forum"); + typeComboBox->addItem("Channel"); + typeComboBox->addItem("Blog"); + + typeComboBox->setCurrentIndex(type); + + setAcceptDrops(true); } +/* Dropping */ + +void GeneralMsgDialog::dragEnterEvent(QDragEnterEvent *event) +{ + /* print out mimeType */ + std::cerr << "GeneralMsgDialog::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 << "GeneralMsgDialog::dragEnterEvent() Accepting PlainText"; + std::cerr << std::endl; + event->acceptProposedAction(); + } + else if (event->mimeData()->hasUrls()) + { + std::cerr << "GeneralMsgDialog::dragEnterEvent() Accepting Urls"; + std::cerr << std::endl; + event->acceptProposedAction(); + } + else + { + std::cerr << "GeneralMsgDialog::dragEnterEvent() No PlainText/Urls"; + std::cerr << std::endl; + } +} + +void GeneralMsgDialog::dropEvent(QDropEvent *event) +{ + std::cerr << "GeneralMsgDialog::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 << "GeneralMsgDialog::dropEvent() Plain Text:"; + std::cerr << std::endl; + std::cerr << event->mimeData()->text().toStdString(); + std::cerr << std::endl; + } + + if (event->mimeData()->hasUrls()) + { + std::cerr << "GeneralMsgDialog::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); + } + } + } + + + event->acceptProposedAction(); +} + +void GeneralMsgDialog::addAttachment(std::string path) +{ + /* add a SubFileItem to the attachment section */ + std::cerr << "GeneralMsgDialog::addAttachment()"; + std::cerr << std::endl; + + /* add widget in for new destination */ + SubFileItem *file = new SubFileItem("unknownHash", path, 12000); + + mAttachments.push_back(file); + QLayout *layout = fileFrame->layout(); + layout->addWidget(file); + + return; + +} void GeneralMsgDialog::cancelMsg() { - return; -} - -void GeneralMsgDialog::sendMsg() -{ + std::cerr << "GeneralMsgDialog::cancelMsg()"; + std::cerr << std::endl; return; } @@ -50,8 +175,250 @@ void GeneralMsgDialog::addDestination(uint32_t type, std::string grpId, std::str std::cerr << "GeneralMsgDialog::addDestination()"; std::cerr << std::endl; + /* add widget in for new destination */ + SubDestItem *dest = new SubDestItem(type, grpId, inReplyTo); + + mDestinations.push_back(dest); + QLayout *layout = destFrame->layout(); + layout->addWidget(dest); + return; } +void GeneralMsgDialog::updateGroupId() +{ + std::cerr << "GeneralMsgDialog::updateGroupId()"; + std::cerr << std::endl; + + int idx = typeComboBox->currentIndex(); + + destIdComboBox->clear(); + switch(idx) + { + case GMD_TYPE_MESSAGE_IDX: + { + /* add a list of friends */ + if (rsPeers) + { + std::list friends; + std::list::iterator it; + + rsPeers->getFriendList(friends); + for(it = friends.begin(); it != friends.end(); it++) + { + QString id = QString::fromStdString(*it); + QString name = QString::fromStdString(rsPeers->getPeerName(*it)); + + destIdComboBox->addItem(name, id); + } + } + } + break; + case GMD_TYPE_FORUM_IDX: + { + /* add a list of publishable forums */ + if (rsForums) + { + std::list forumList; + std::list::iterator it; + + rsForums->getForumList(forumList); + for(it = forumList.begin(); it != forumList.end(); it++) + { + if (it->forumFlags & RS_DISTRIB_PUBLISH) + { + QString id = QString::fromStdString(it->forumId); + QString name = QString::fromStdWString(it->forumName); + + destIdComboBox->addItem(name, id); + } + } + } + } + break; + case GMD_TYPE_CHANNEL_IDX: + { + /* add a list of publishable channels */ + if (rsChannels) + { + std::list channelList; + std::list::iterator it; + + rsChannels->getChannelList(channelList); + for(it = channelList.begin(); it != channelList.end(); it++) + { + if (it->channelFlags & RS_DISTRIB_PUBLISH) + { + QString id = QString::fromStdString(it->channelId); + QString name = QString::fromStdWString(it->channelName); + + destIdComboBox->addItem(name, id); + } + } + } + } + break; + default: + case GMD_TYPE_BLOG_IDX: + { + /* empty list */ + } + break; + } + +} + +void GeneralMsgDialog::newDestination() +{ + /* get details from uint32_t type, std::string grpId, std::string inReplyTo) + */ + + std::cerr << "GeneralMsgDialog::newDestination()"; + std::cerr << std::endl; + + int idx = typeComboBox->currentIndex(); + std::string grpId; + + if (destIdComboBox->currentIndex() >= 0) + { + QVariant qv = destIdComboBox->itemData(destIdComboBox->currentIndex()); + grpId = qv.toString().toStdString(); + } + + switch(idx) + { + case GMD_TYPE_MESSAGE_IDX: + addDestination(FEEDHOLDER_MSG_MESSAGE, grpId, ""); + break; + case GMD_TYPE_FORUM_IDX: + addDestination(FEEDHOLDER_MSG_FORUM, grpId, ""); + break; + case GMD_TYPE_CHANNEL_IDX: + addDestination(FEEDHOLDER_MSG_CHANNEL, grpId, ""); + break; + case GMD_TYPE_BLOG_IDX: + addDestination(FEEDHOLDER_MSG_BLOG, "", ""); + break; + default: + break; + } +} + + +void GeneralMsgDialog::sendMsg() +{ + std::cerr << "GeneralMsgDialog::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 it; + 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); + } + } + + /* iterate through each mDestinations that is visible, and send */ + for(it = mDestinations.begin(); it != mDestinations.end(); it++) + { + if (!(*it)->isHidden()) + { + sendMessage((*it)->DestType(), (*it)->DestGroupId(), + (*it)->DestInReplyTo(), subject, msg, files); + } + } +} + +void GeneralMsgDialog::sendMessage(uint32_t type, std::string grpId, std::string inReplyTo, + std::wstring subject, std::wstring msg, std::list &files) +{ + std::cerr << "GeneralMsgDialog::sendMessage() Type: " << type << " GroupId: " << grpId; + std::cerr << std::endl; + + /* construct specific messages */ + switch(type) + { + case FEEDHOLDER_MSG_MESSAGE: + { + if (rsMsgs) + { + /* construct a message */ + MessageInfo mi; + + mi.title = subject; + mi.msg = msg; + mi.files = files; + mi.msgto.push_back(grpId); + + rsMsgs->MessageSend(mi); + } + } + break; + case FEEDHOLDER_MSG_FORUM: + { + /* rsForum */ + if (rsForums) + { + ForumMsgInfo msgInfo; + + msgInfo.forumId = grpId; + msgInfo.threadId = ""; + msgInfo.parentId = inReplyTo; + msgInfo.msgId = ""; + + msgInfo.title = subject; + msgInfo.msg = msg; + + rsForums->ForumMessageSend(msgInfo); + } + } + break; + case FEEDHOLDER_MSG_CHANNEL: + { + /* rsChannels */ + if (rsChannels) + { + ChannelMsgInfo msgInfo; + + msgInfo.channelId = grpId; + msgInfo.msgId = ""; + + msgInfo.subject = subject; + msgInfo.msg = msg; + msgInfo.files = files; + + rsChannels->ChannelMessageSend(msgInfo); + } + } + + break; + case FEEDHOLDER_MSG_BLOG: + + break; + default: + + break; + } +} + + + + + + diff --git a/retroshare-gui/src/gui/GeneralMsgDialog.h b/retroshare-gui/src/gui/GeneralMsgDialog.h index f1785733f..78ca015f9 100644 --- a/retroshare-gui/src/gui/GeneralMsgDialog.h +++ b/retroshare-gui/src/gui/GeneralMsgDialog.h @@ -24,22 +24,46 @@ #include "ui_GeneralMsgDialog.h" +class SubDestItem; +class SubFileItem; +class FileInfo; + +const uint32_t GMD_TYPE_MESSAGE_IDX = 0; +const uint32_t GMD_TYPE_FORUM_IDX = 1; +const uint32_t GMD_TYPE_CHANNEL_IDX = 2; +const uint32_t GMD_TYPE_BLOG_IDX = 3; + class GeneralMsgDialog : public QDialog, private Ui::GeneralMsgDialog { Q_OBJECT public: /** Default Constructor */ - GeneralMsgDialog(QWidget *parent = 0); + GeneralMsgDialog(QWidget *parent = 0, uint32_t type = 0); /** Default Destructor */ -virtual void addDestination(uint32_t type, std::string grpId, std::string inReplyTo); + void addAttachment(std::string path); + void addDestination(uint32_t type, std::string grpId, std::string inReplyTo); -virtual void cancelMsg(); -virtual void sendMsg(); +protected: +virtual void dragEnterEvent(QDragEnterEvent *event); +virtual void dropEvent(QDropEvent *event); + +private slots: + void updateGroupId(); + void newDestination(); + void cancelMsg(); + void sendMsg(); private: +void sendMessage(uint32_t type, std::string grpId, std::string inReplyTo, + std::wstring subject, std::wstring msg, std::list &files); + + + /* maps of files and destinations */ + std::list mDestinations; + std::list mAttachments; }; diff --git a/retroshare-gui/src/gui/GeneralMsgDialog.ui b/retroshare-gui/src/gui/GeneralMsgDialog.ui index 4b7c5793d..5aee2e174 100644 --- a/retroshare-gui/src/gui/GeneralMsgDialog.ui +++ b/retroshare-gui/src/gui/GeneralMsgDialog.ui @@ -9,6 +9,9 @@ 516 + + true + Dialog @@ -168,9 +171,6 @@ 60 - - true - Drag and Drop Files from Search Results diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index e63659f0e..2c0db3be6 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -220,6 +220,14 @@ void NewsFeed::addFeedItemChanUpdate(RsFeedItem &fi) void NewsFeed::addFeedItemChanMsg(RsFeedItem &fi) { + /* make new widget */ + ChanMsgItem *cm = new ChanMsgItem(this, NEWSFEED_CHANMSGLIST, fi.mId1, fi.mId2, false); + + /* store in forum list */ + + /* add to layout */ + mLayout->addWidget(cm); + std::cerr << "NewsFeed::addFeedItemChanMsg()"; std::cerr << std::endl; } diff --git a/retroshare-gui/src/gui/feeds/BlogMsgItem.cpp b/retroshare-gui/src/gui/feeds/BlogMsgItem.cpp index adf17b331..404e302ab 100644 --- a/retroshare-gui/src/gui/feeds/BlogMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/BlogMsgItem.cpp @@ -70,7 +70,7 @@ void BlogMsgItem::updateItemStatic() for(i = 0; i < total; i++) { /* add file */ - SubFileItem *fi = new SubFileItem("dummyHash"); + SubFileItem *fi = new SubFileItem("dummyHash", "dummyFileName", 1283918); mFileItems.push_back(fi); QLayout *layout = expandFrame->layout(); diff --git a/retroshare-gui/src/gui/feeds/ChanMenuItem.cpp b/retroshare-gui/src/gui/feeds/ChanMenuItem.cpp index 7f49115a3..c795f3b8c 100644 --- a/retroshare-gui/src/gui/feeds/ChanMenuItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChanMenuItem.cpp @@ -20,6 +20,7 @@ ****************************************************************/ #include +#include "rsiface/rschannels.h" #include "ChanMenuItem.h" #include @@ -50,8 +51,18 @@ void ChanMenuItem::updateItemStatic() std::cerr << std::endl; #endif - titleLabel->setText(QString::fromStdString(mChanId)); - descLabel->setText("Brand new exciting Ever asvljh ljdsafl kjdsahfl kjsahf; kjsahdf; kljashfdl;kjhasfkl; asvljh ljdsafl kjdsahfl kjsahf; kjsahdf; kljashfdl;kjhasfkl; asvljh ljdsafl kjdsahfl kjsahf; kjsahdf; kljashfdl;kjhasfkl; asvljh ljdsafl kjdsahfl kjsahf; kjsahdf; kljashfdl;kjhasfkl; asvljh ljdsafl kjdsahfl kjsahf; kjsahdf; kljashfdl;kjhasfkl; asvljh ljdsafl kjdsahfl kjsahf; kjsahdf; kljashfdl;kjhasfkl; asvljh ljdsafl kjdsahfl kjsahf; kjsahdf; kljashfdl;kjhasfkl; asvljh ljdsafl kjdsahfl kjsahf; kjsahdf; kljashfdl;kjhasfkl; "); + /* extract details from channels */ + ChannelInfo ci; + if ((rsChannels) && (rsChannels->getChannelInfo(mChanId, ci))) + { + titleLabel->setText(QString::fromStdWString(ci.channelName)); + descLabel->setText(QString::fromStdWString(ci.channelDesc)); + } + else + { + titleLabel->setText("Unknown Channel"); + descLabel->setText("No Description"); + } } @@ -84,4 +95,9 @@ void ChanMenuItem::toggle() /*********** SPECIFIC FUNCTIOSN ***********************/ +void ChanMenuItem::mousePressEvent ( QMouseEvent * event ) +{ + selectMe( mChanId ); +} + diff --git a/retroshare-gui/src/gui/feeds/ChanMenuItem.h b/retroshare-gui/src/gui/feeds/ChanMenuItem.h index 008f3c0d7..aec7dab55 100644 --- a/retroshare-gui/src/gui/feeds/ChanMenuItem.h +++ b/retroshare-gui/src/gui/feeds/ChanMenuItem.h @@ -41,12 +41,18 @@ public: void updateItemStatic(); void small(); +signals: + void selectMe( std::string ); + private slots: /* default stuff */ void toggle(); void updateItem(); +protected: + virtual void mousePressEvent ( QMouseEvent * event ); + private: std::string mChanId; }; diff --git a/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp index 48d38b91c..5a03e40d0 100644 --- a/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp @@ -25,6 +25,8 @@ #include "FeedHolder.h" #include "SubFileItem.h" +#include "rsiface/rschannels.h" + #include #define DEBUG_ITEM 1 @@ -60,18 +62,39 @@ void ChanMsgItem::updateItemStatic() std::cerr << std::endl; #endif - msgLabel->setText("FFFFFFFFFFF AAAAAAAAAAAAAAA \n HHHHHHHHHHH HHHHHHHHHHHHHHHHH"); - titleLabel->setText("Channel Feed: Best Channel Ever"); - subjectLabel->setText("Brand new exciting Ever"); + ChannelMsgInfo cmi; - /* add Files */ - int total = (int) (10.0 * (rand() / (RAND_MAX + 1.0))); - int i; + if (!rsChannels) + return; - for(i = 0; i < total; i++) + if (!rsChannels->getChannelMessage(mChanId, mMsgId, cmi)) + return; + + QString title; + + if (!mIsHome) + { + ChannelInfo ci; + rsChannels->getChannelInfo(mChanId, ci); + title = "Channel Feed: "; + title += QString::fromStdWString(ci.channelName); + titleLabel->setText(title); + subjectLabel->setText(QString::fromStdWString(cmi.subject)); + } + else + { + /* subject */ + titleLabel->setText(QString::fromStdWString(cmi.subject)); + subjectLabel->setText(QString::fromStdWString(cmi.subject)); + } + + msgLabel->setText(QString::fromStdWString(cmi.msg)); + + std::list::iterator it; + for(it = cmi.files.begin(); it != cmi.files.end(); it++) { /* add file */ - SubFileItem *fi = new SubFileItem("dummyHash"); + SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->size); mFileItems.push_back(fi); QLayout *layout = expandFrame->layout(); @@ -85,6 +108,7 @@ void ChanMsgItem::updateItemStatic() /* disable buttons */ clearButton->setEnabled(false); gotoButton->setEnabled(false); + unsubscribeButton->setEnabled(false); } } diff --git a/retroshare-gui/src/gui/feeds/SubDestItem.cpp b/retroshare-gui/src/gui/feeds/SubDestItem.cpp new file mode 100644 index 000000000..5436abf92 --- /dev/null +++ b/retroshare-gui/src/gui/feeds/SubDestItem.cpp @@ -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. + ****************************************************************/ +#include + +#include "SubDestItem.h" +#include "FeedHolder.h" + +#include "rsiface/rspeers.h" +#include "rsiface/rsforums.h" +#include "rsiface/rschannels.h" + +#include + +#define DEBUG_ITEM 1 + +/** Constructor */ +SubDestItem::SubDestItem(uint32_t type, std::string groupId, std::string inReplyTo) +:QWidget(NULL), mType(type), mGroupId(groupId), mInReplyTo(inReplyTo) +{ + /* Invoke the Qt Designer generated object setup routine */ + setupUi(this); + + connect( cancelButton, SIGNAL( clicked( void ) ), this, SLOT( cancel ( void ) ) ); + + updateItemStatic(); +} + +void SubDestItem::updateItemStatic() +{ + /* fill in */ +#ifdef DEBUG_ITEM + std::cerr << "SubDestItem::updateItemStatic()"; + std::cerr << std::endl; +#endif + + QString name = "Unknown"; + switch(mType) + { + case FEEDHOLDER_MSG_MESSAGE: + { + typeLabel->setText("Message To: "); + if (rsPeers) + { + name = QString::fromStdString(rsPeers->getPeerName(mGroupId)); + } + } + break; + + case FEEDHOLDER_MSG_FORUM: + { + typeLabel->setText("Forum Post To: "); + ForumInfo fi; + if ((rsForums) && (rsForums->getForumInfo(mGroupId, fi))) + { + name = QString::fromStdWString(fi.forumName); + } + } + break; + + case FEEDHOLDER_MSG_CHANNEL: + { + typeLabel->setText("Channel Post To: "); + ChannelInfo ci; + if ((rsChannels) && (rsChannels->getChannelInfo(mGroupId, ci))) + { + name = QString::fromStdWString(ci.channelName); + } + } + break; + + case FEEDHOLDER_MSG_BLOG: + { + typeLabel->setText("Blog Post"); + name = ""; + } + break; + + } + nameLabel->setText(name); +} + +void SubDestItem::cancel() +{ +#ifdef DEBUG_ITEM + std::cerr << "SubDestItem::cancel()"; + std::cerr << std::endl; +#endif + hide(); +} + diff --git a/retroshare-gui/src/gui/feeds/SubDestItem.h b/retroshare-gui/src/gui/feeds/SubDestItem.h new file mode 100644 index 000000000..5f6baa55e --- /dev/null +++ b/retroshare-gui/src/gui/feeds/SubDestItem.h @@ -0,0 +1,58 @@ +/**************************************************************** + * 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 _SUB_DEST_ITEM_DIALOG_H +#define _SUB_DEST_ITEM_DIALOG_H + +#include "ui_SubDestItem.h" + +#include + +class SubDestItem : public QWidget, private Ui::SubDestItem +{ + Q_OBJECT + +public: + /** Default Constructor */ + SubDestItem(uint32_t type, std::string groupId, std::string inReplyTo); + + /** Default Destructor */ + + uint32_t DestType() { return mType; } + std::string DestGroupId() { return mGroupId; } + std::string DestInReplyTo() { return mInReplyTo; } + +void updateItemStatic(); + +private slots: + /* default stuff */ + void cancel(); + +private: + uint32_t mType; + std::string mGroupId; + std::string mInReplyTo; +}; + + + +#endif + diff --git a/retroshare-gui/src/gui/feeds/SubDestItem.ui b/retroshare-gui/src/gui/feeds/SubDestItem.ui new file mode 100644 index 000000000..b41200c4c --- /dev/null +++ b/retroshare-gui/src/gui/feeds/SubDestItem.ui @@ -0,0 +1,177 @@ + + SubDestItem + + + + 0 + 0 + 615 + 64 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 300 + 16777215 + + + + + 75 + true + true + + + + Type + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 300 + 16777215 + + + + + 75 + true + true + + + + Person/Channel Name + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 71 + 21 + + + + + + + + + 0 + 0 + + + + Delete FeedItem + + + + + + :/images/close-down.png + + + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.cpp b/retroshare-gui/src/gui/feeds/SubFileItem.cpp index 57eafbb26..376460b1b 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.cpp +++ b/retroshare-gui/src/gui/feeds/SubFileItem.cpp @@ -27,8 +27,8 @@ #define DEBUG_ITEM 1 /** Constructor */ -SubFileItem::SubFileItem(std::string hash) -:QWidget(NULL), mFileHash(hash) +SubFileItem::SubFileItem(std::string hash, std::string name, uint64_t size) +:QWidget(NULL), mFileHash(hash), mFileName(name), mFileSize(size) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); @@ -37,7 +37,7 @@ SubFileItem::SubFileItem(std::string hash) connect( cancelButton, SIGNAL( clicked( void ) ), this, SLOT( cancel ( void ) ) ); connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) ); - amountDone = 1; + amountDone = 1000; small(); updateItemStatic(); @@ -57,11 +57,27 @@ void SubFileItem::updateItemStatic() fileLabel->setToolTip(filename); playButton->setEnabled(false); + + if (mFileSize > 10000000) /* 10 Mb */ + { + progressBar->setRange(0, mFileSize / 1000000); + progressBar->setFormat("%v MB"); + } + else if (mFileSize > 10000) /* 10 Kb */ + { + progressBar->setRange(0, mFileSize / 1000); + progressBar->setFormat("%v kB"); + } + else + { + progressBar->setRange(0, mFileSize); + progressBar->setFormat("%v B"); + } } bool SubFileItem::done() { - return (amountDone >= 100); + return (amountDone >= mFileSize); } @@ -74,17 +90,28 @@ void SubFileItem::updateItem() #endif int msec_rate = 1000; - if (amountDone < 100) + uint64_t divisor = 1; + if (mFileSize > 10000000) /* 10 Mb */ + { + divisor = 1000000; + } + else if (mFileSize > 10000) /* 10 Kb */ + { + divisor = 1000; + } + + if (amountDone < mFileSize) { amountDone *= 1.1; - progressBar->setValue(amountDone); + progressBar->setValue(amountDone / divisor); QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) )); } else { /* complete! */ - progressBar->setValue(100); + amountDone = mFileSize + 1; + progressBar->setValue(mFileSize / divisor); playButton->setEnabled(true); } diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.h b/retroshare-gui/src/gui/feeds/SubFileItem.h index ba2436900..9afe0f09a 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.h +++ b/retroshare-gui/src/gui/feeds/SubFileItem.h @@ -31,13 +31,17 @@ class SubFileItem : public QWidget, private Ui::SubFileItem Q_OBJECT public: - /** Default Constructor */ - SubFileItem(std::string hash); + /** Default Constructor */ + SubFileItem(std::string hash, std::string name, uint64_t size); - /** Default Destructor */ + /** Default Destructor */ - void small(); - bool done(); + void small(); + bool done(); + + std::string FileHash() { return mFileHash; } + std::string FileName() { return mFileName; } + uint64_t FileSize() { return mFileSize; } void updateItemStatic(); @@ -51,6 +55,8 @@ private slots: private: std::string mFileHash; + std::string mFileName; + uint64_t mFileSize; /* for display purposes */ float amountDone; diff --git a/retroshare-gui/src/gui/forums/CreateForum.cpp b/retroshare-gui/src/gui/forums/CreateForum.cpp index 88bb4b67b..e8edb58ef 100644 --- a/retroshare-gui/src/gui/forums/CreateForum.cpp +++ b/retroshare-gui/src/gui/forums/CreateForum.cpp @@ -23,10 +23,11 @@ #include "CreateForum.h" #include "rsiface/rsforums.h" +#include "rsiface/rschannels.h" /** Constructor */ -CreateForum::CreateForum(QWidget *parent) -: QWidget(parent) +CreateForum::CreateForum(QWidget *parent, bool isForum) +: QWidget(parent), mIsForum(isForum) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); @@ -42,40 +43,74 @@ CreateForum::CreateForum(QWidget *parent) void CreateForum::newForum() { - /* clear all */ - ui.forumTypePublic->setChecked(true); - ui.forumMsgAnon->setChecked(true); + + 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 CreateForum::createForum() { QString name = ui.forumName->text(); - QString desc = ui.forumDesc->toHtml(); + QString desc = ui.forumDesc->toPlainText(); //toHtml(); uint32_t flags = 0; - if (ui.forumTypePublic->isChecked()) + if (ui.typePublic->isChecked()) { flags |= RS_DISTRIB_PUBLIC; } - else if (ui.forumTypePrivate->isChecked()) + else if (ui.typePrivate->isChecked()) { flags |= RS_DISTRIB_PRIVATE; } - else if (ui.forumTypeEncrypted->isChecked()) + else if (ui.typeEncrypted->isChecked()) { flags |= RS_DISTRIB_ENCRYPTED; } - if (ui.forumMsgAuth->isChecked()) + if (ui.msgAuth->isChecked()) { flags |= RS_DISTRIB_AUTHEN_REQ; } - else if (ui.forumMsgAnon->isChecked()) + else if (ui.msgAnon->isChecked()) { flags |= RS_DISTRIB_AUTHEN_ANON; } - rsForums->createForum(name.toStdWString(), desc.toStdWString(), flags); + if (mIsForum) + { + if (rsForums) + { + rsForums->createForum(name.toStdWString(), desc.toStdWString(), flags); + } + } + else + { + if (rsChannels) + { + rsChannels->createChannel(name.toStdWString(), desc.toStdWString(), flags); + } + } close(); return; diff --git a/retroshare-gui/src/gui/forums/CreateForum.h b/retroshare-gui/src/gui/forums/CreateForum.h index fb4b90132..4c0abaad0 100644 --- a/retroshare-gui/src/gui/forums/CreateForum.h +++ b/retroshare-gui/src/gui/forums/CreateForum.h @@ -32,7 +32,7 @@ class CreateForum : public QWidget Q_OBJECT public: - CreateForum(QWidget *parent = 0); + CreateForum(QWidget *parent = 0, bool isForum = true); void newForum(); /* cleanup */ @@ -46,6 +46,8 @@ private: /** Qt Designer generated object */ Ui::CreateForum ui; + + bool mIsForum; }; #endif diff --git a/retroshare-gui/src/gui/forums/CreateForum.ui b/retroshare-gui/src/gui/forums/CreateForum.ui index 72329f53b..5ea1a1f0b 100644 --- a/retroshare-gui/src/gui/forums/CreateForum.ui +++ b/retroshare-gui/src/gui/forums/CreateForum.ui @@ -510,7 +510,7 @@ - Forum Name + Name @@ -524,7 +524,7 @@ - Forum Description + Description @@ -534,29 +534,29 @@ - + - Forum Type: + Type: - + - Public Forum (Shared Publish Key) + Public - Anyone can read and publish (Shared Publish Key) - + - Private Forum (Private Publish Key) + Restricted - Anyone can read, limited publishing (Private Publish Key) - + - Encrypted Forum (Private Publish Key required to view Messages) + Private - (Private Publish Key required to view Messages) @@ -564,20 +564,20 @@ - + Allowed Messages - + Authemticated Messages - + Anonymous Messages @@ -604,7 +604,7 @@ - Cancel Forum + Cancel @@ -624,7 +624,7 @@ - Create Forum + Create true diff --git a/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp b/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp index 9a5eb40f6..733e6c21f 100644 --- a/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp +++ b/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp @@ -342,6 +342,7 @@ void ChanMsgDialog::insertSendList() void ChanMsgDialog::insertChannelSendList() { +#if 0 rsiface->lockData(); /* Lock Interface */ std::map::const_iterator it; @@ -399,9 +400,11 @@ void ChanMsgDialog::insertChannelSendList() /* add the items in! */ sendWidget->insertTopLevelItems(0, items); + rsiface->unlockData(); /* UnLock Interface */ sendWidget->update(); /* update display */ +#endif } diff --git a/retroshare-gui/src/rsiface/rsQblog.h b/retroshare-gui/src/rsiface/rsQblog.h index b19733fc7..fe0aa9af7 100644 --- a/retroshare-gui/src/rsiface/rsQblog.h +++ b/retroshare-gui/src/rsiface/rsQblog.h @@ -47,17 +47,6 @@ extern RsQblog *rsQblog; RsQblog() { return; } virtual ~RsQblog() { return; } - /** - * allows user to set his status - * @param status The status of the user - */ - virtual bool setStatus(const std::string &status) = 0; - - /** - * returns reference to map of usrs and their status - * @param usrStatus returns map to usr and their status - */ - virtual bool getStatus(std::map &usrStatus) = 0; /** * choose whether to filter or not @@ -82,31 +71,30 @@ extern RsQblog *rsQblog; * @param id The user's frined's id */ virtual bool removeFiltFriend(std::string &usrId) = 0; - - /** - * get users fav song - * @param usrId the usr whose fav song you want - * @param favSong puts ref for fav song here - */ - virtual bool getProfile(std::map &profile) = 0; - - /** - * for now just fav song, TODO: must find way to link to rs profile - */ - virtual bool setProfile(const std::string &favSong) = 0; /** * send blog info, will send to a data structure for transmission * @param msg The msg the usr wants to send */ - virtual bool sendBlog(const std::string &msg) = 0; + virtual bool sendBlog(const std::wstring &msg) = 0; /** * retrieve blog of a usr * @param blogs contains the blog msgs of usr along with time posted for sorting */ - virtual bool getBlogs(std::map< std::string, std::multimap > &blogs) = 0; + virtual bool getBlogs(std::map< std::string, std::multimap > &blogs) = 0; + /** + * set usr profile, send an empty second pair to delete entry + * @param entry profile entry + */ + virtual bool setProfile(std::pair entry) = 0; + + /** + * add fav file, send file info with only name to delete that entry + * @param entry file info entry + */ + virtual bool setFavorites(FileInfo favFile) = 0; /** @@ -134,8 +122,7 @@ extern RsQblog *rsQblog; * @param favs list of Files */ virtual bool getPeerFavourites(std::string id, std::list &favs) = 0; - - + }; #endif /*RSQBLOG_H_*/ diff --git a/retroshare-gui/src/rsiface/rschannels.h b/retroshare-gui/src/rsiface/rschannels.h new file mode 100644 index 000000000..fee85ee9c --- /dev/null +++ b/retroshare-gui/src/rsiface/rschannels.h @@ -0,0 +1,120 @@ +#ifndef RS_CHANNEL_GUI_INTERFACE_H +#define RS_CHANNEL_GUI_INTERFACE_H + +/* + * libretroshare/src/rsiface: rschannels.h + * + * RetroShare C++ Interface. + * + * Copyright 2008 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + + +#include +#include +#include + +#include "rsiface/rstypes.h" +#include "rsiface/rsdistrib.h" /* For FLAGS */ + +class ChannelInfo +{ + public: + ChannelInfo() {} + std::string channelId; + std::wstring channelName; + std::wstring channelDesc; + + uint32_t channelFlags; + uint32_t pop; + + time_t lastPost; +}; + +class ChannelMsgInfo +{ + public: + ChannelMsgInfo() {} + std::string channelId; + std::string msgId; + + unsigned int msgflags; + + std::wstring subject; + std::wstring msg; + time_t ts; + + std::list files; + uint32_t count; + uint64_t size; +}; + + +class ChannelMsgSummary +{ + public: + ChannelMsgSummary() {} + std::string channelId; + std::string msgId; + + uint32_t msgflags; + + std::wstring subject; + std::wstring msg; + uint32_t count; /* file count */ + time_t ts; + +}; + +std::ostream &operator<<(std::ostream &out, const ChannelInfo &info); +std::ostream &operator<<(std::ostream &out, const ChannelMsgSummary &info); +std::ostream &operator<<(std::ostream &out, const ChannelMsgInfo &info); + +class RsChannels; +extern RsChannels *rsChannels; + +class RsChannels +{ + public: + + RsChannels() { return; } +virtual ~RsChannels() { return; } + +/****************************************/ + +virtual bool channelsChanged(std::list &chanIds) = 0; + + +virtual std::string createChannel(std::wstring chanName, std::wstring chanDesc, uint32_t chanFlags) = 0; + +virtual bool getChannelInfo(std::string cId, ChannelInfo &ci) = 0; +virtual bool getChannelList(std::list &chanList) = 0; +virtual bool getChannelMsgList(std::string cId, std::list &msgs) = 0; +virtual bool getChannelMessage(std::string cId, std::string mId, ChannelMsgInfo &msg) = 0; + +virtual bool ChannelMessageSend(ChannelMsgInfo &info) = 0; + +virtual bool channelSubscribe(std::string cId, bool subscribe) = 0; +/****************************************/ + +}; + + +#endif diff --git a/retroshare-gui/src/rsiface/rsiface.h b/retroshare-gui/src/rsiface/rsiface.h index b555e122e..36e8ef4d6 100644 --- a/retroshare-gui/src/rsiface/rsiface.h +++ b/retroshare-gui/src/rsiface/rsiface.h @@ -100,21 +100,6 @@ virtual void unlockData() = 0; const PersonInfo *getPerson(std::string id); const DirInfo *getDirectory(std::string id, std::string path); - const std::map &getChannels() - { return mChannelMap; } - - const std::map &getOurChannels() - { return mChannelOwnMap; } - - //const MessageInfo *getChannelMsg(std::string chId, std::string mId); - - //std::list getChatNew() - // { - // std::list newList = mChatList; - // mChatList.clear(); - // return newList; - // } - const std::list &getRecommendList() { return mRecommendList; } @@ -160,10 +145,6 @@ void fillLists(); /* create some dummy data to display */ std::list mRemoteDirList; std::list mLocalDirList; std::list mTransferList; - //std::list mMessageList; - std::map mChannelMap; - std::map mChannelOwnMap; - //std::list mChatList; std::list mRecommendList; bool mChanged[NumOfFlags]; @@ -218,20 +199,6 @@ virtual int FileCancel(std::string fname, std::string hash, uint32_t size) = 0; virtual int FileClearCompleted() = 0; virtual int FileSetBandwidthTotals(float outkB, float inkB) = 0; -/****************************************/ - /* Message Items */ -//virtual int MessageSend(MessageInfo &info) = 0; -//virtual int MessageDelete(std::string mid) = 0; -//virtual int MessageRead(std::string mid) = 0; - - /* Channel Items */ -virtual int ChannelCreateNew(ChannelInfo &info) = 0; -virtual int ChannelSendMsg(ChannelInfo &info) = 0; - -/****************************************/ - /* Chat */ -//virtual int ChatSend(ChatInfo &ci) = 0; - /****************************************/ /* Flagging Persons / Channels / Files in or out of a set (CheckLists) */ diff --git a/retroshare-gui/src/rsiface/rstypes.h b/retroshare-gui/src/rsiface/rstypes.h index 48fc670c7..0fab36600 100644 --- a/retroshare-gui/src/rsiface/rstypes.h +++ b/retroshare-gui/src/rsiface/rstypes.h @@ -75,8 +75,8 @@ static const int kRsFiStatusDone = 2; std::string hash; std::string ext; - int size; - int avail; /* how much we have */ + uint64_t size; + uint64_t avail; /* how much we have */ int status; bool inRecommend; @@ -138,26 +138,6 @@ class FileTransferInfo: public FileInfo int downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */ }; -class ChannelInfo: public BaseInfo -{ - public: - ChannelInfo() :publisher(false) {} - RsChanId chanId; - bool publisher; - std::string chanName; - //std::list msglist; - - /* details */ - int mode; - float rank; - - bool inBroadcast; - bool inSubscribe; - - int size; /* total of msgs */ - int count; /* msg count */ -}; - /* matched to the uPnP states */ #define UPNP_STATE_UNINITIALISED 0 #define UPNP_STATE_UNAVAILABILE 1 @@ -230,7 +210,6 @@ class SearchRequest }; -std::ostream &operator<<(std::ostream &out, const ChannelInfo &info); std::ostream &operator<<(std::ostream &out, const PersonInfo &info); std::ostream &print(std::ostream &out, const DirInfo &info, int indentLvl);