diff --git a/retroshare-gui/src/gui/ForumsV2Dialog.cpp b/retroshare-gui/src/gui/ForumsV2Dialog.cpp index 9de6661e9..afc2ed43f 100644 --- a/retroshare-gui/src/gui/ForumsV2Dialog.cpp +++ b/retroshare-gui/src/gui/ForumsV2Dialog.cpp @@ -127,6 +127,18 @@ static int FilterColumnToComboBox(int nIndex) return FilterColumnToComboBox(COLUMN_THREAD_TITLE); } + +/* + * Transformation Notes: + * there are still a couple of things that the new forums differ from Old version. + * these will need to be addressed in the future. + * -> Missing Messages are not handled yet. + * -> Child TS (for sorting) is not handled by GXS, this will probably have to be done in the GUI. + * -> Need to handle IDs properly. + * -> Popularity not handled in GXS yet. + * -> Much more to do. + */ + /** Constructor */ ForumsV2Dialog::ForumsV2Dialog(QWidget *parent) : RsAutoUpdatePage(1000,parent) @@ -1484,14 +1496,11 @@ void ForumsV2Dialog::copyMessageLink() } } -//#define DISABLE_OTHERCLASSES 1 void ForumsV2Dialog::newforum() { -#ifndef DISABLE_OTHERCLASSES CreateForumV2 cf (this); cf.exec (); -#endif } void ForumsV2Dialog::createmessage() @@ -1500,10 +1509,8 @@ void ForumsV2Dialog::createmessage() return; } -#ifndef DISABLE_OTHERCLASSES CreateForumV2Msg *cfm = new CreateForumV2Msg(mCurrForumId, mCurrThreadId); cfm->show(); -#endif /* window will destroy itself! */ } @@ -1515,11 +1522,9 @@ void ForumsV2Dialog::createthread() return; } -#ifndef DISABLE_OTHERCLASSES CreateForumV2Msg *cfm = new CreateForumV2Msg(mCurrForumId, ""); cfm->setWindowTitle(tr("Start New Thread")); cfm->show(); -#endif /* window will destroy itself! */ } diff --git a/retroshare-gui/src/gui/ForumsV2Dialog.h b/retroshare-gui/src/gui/ForumsV2Dialog.h index bc48f4104..39c831d57 100644 --- a/retroshare-gui/src/gui/ForumsV2Dialog.h +++ b/retroshare-gui/src/gui/ForumsV2Dialog.h @@ -80,6 +80,9 @@ public: /* overloaded from RsAuthUpdatePage */ virtual void updateDisplay(); + // Callback for all Loads. +virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); + protected: bool eventFilter(QObject *obj, QEvent *ev); @@ -199,9 +202,6 @@ private: bool convertMsgToThreadWidget(const RsForumV2Msg &msgInfo, std::string authorName, bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item); - // Callback for all Loads. - void loadRequest(const TokenQueue *queue, const TokenRequest &req); - TokenQueue *mForumQueue; diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2.cpp b/retroshare-gui/src/gui/forumsv2/CreateForumV2.cpp index 90d31dbcf..0463b7941 100644 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2.cpp +++ b/retroshare-gui/src/gui/forumsv2/CreateForumV2.cpp @@ -27,34 +27,42 @@ #include -#include +#include #include +#include + +#define CREATEFORUMSV2_NEWFORUMID 1 + + /** Constructor */ CreateForumV2::CreateForumV2(QWidget *parent) : QDialog(parent) { - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - - // connect up the buttons. - connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelForum( ) ) ); - connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createForum( ) ) ); - connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) )); - connect( ui.keyShareList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ), - this, SLOT(togglePersonItem( QTreeWidgetItem *, int ) )); + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); - if(!ui.pubKeyShare_cb->isChecked()){ + mForumQueue = new TokenQueue(rsForumsV2, this); + // connect up the buttons. + connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelForum( ) ) ); + connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createForum( ) ) ); + connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) )); + + if (!ui.pubKeyShare_cb->isChecked()) { ui.contactsdockWidget->hide(); - this->resize(this->size().width() - ui.contactsdockWidget->size().width(), - this->size().height()); + this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); } - newForum(); + /* initialize key share list */ + ui.keyShareList->setHeaderText(tr("Contacts:")); + ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK); + ui.keyShareList->start(); + + newForum(); } -void CreateForumV2::newForum() +void CreateForumV2::newForum() { /* enforce Public for the moment */ ui.typePublic->setChecked(true); @@ -72,156 +80,151 @@ void CreateForumV2::newForum() ui.forumName->clear(); ui.forumDesc->clear(); + + ui.forumName->setFocus(); } -void CreateForumV2::togglePersonItem( QTreeWidgetItem *item, int /*col*/ ) -{ - - /* extract id */ - std::string id = (item -> text(1)).toStdString(); - - /* get state */ - bool checked = (Qt::Checked == item -> checkState(0)); /* alway column 0 */ - - /* call control fns */ - std::list::iterator lit = std::find(mShareList.begin(), mShareList.end(), id); - - if(checked && (lit == mShareList.end())){ - - // make sure ids not added already - mShareList.push_back(id); - - }else - if(lit != mShareList.end()){ - - mShareList.erase(lit); - - } - - return; -} - -void CreateForumV2::createForum() +void CreateForumV2::createForum() { QString name = misc::removeNewLine(ui.forumName->text()); QString desc = ui.forumDesc->toPlainText(); //toHtml(); uint32_t flags = 0; - if(name.isEmpty()) - { /* error message */ - QMessageBox::warning(this, "RetroShare", - tr("Please add a Name"), - QMessageBox::Ok, QMessageBox::Ok); + if(name.isEmpty()) { + /* error message */ + QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok); return; //Don't add a empty name!! } - else - if (ui.typePublic->isChecked()) - { + if (ui.typePublic->isChecked()) { flags |= RS_DISTRIB_PUBLIC; - } - else if (ui.typePrivate->isChecked()) - { + } else if (ui.typePrivate->isChecked()) { flags |= RS_DISTRIB_PRIVATE; - } - else if (ui.typeEncrypted->isChecked()) - { + } else if (ui.typeEncrypted->isChecked()) { flags |= RS_DISTRIB_ENCRYPTED; } - if (ui.msgAuth->isChecked()) - { + if (ui.msgAuth->isChecked()) { flags |= RS_DISTRIB_AUTHEN_REQ; - } - else if (ui.msgAnon->isChecked()) - { + } else if (ui.msgAnon->isChecked()) { flags |= RS_DISTRIB_AUTHEN_ANON; } - if (rsForums) - { - std::string forumId = rsForums->createForum(name.toStdWString(), - desc.toStdWString(), flags); - - if(ui.pubKeyShare_cb->isChecked()) - rsForums->forumShareKeys(forumId, mShareList); + if (rsForumsV2) { + + + uint32_t token; + RsForumV2Group grp; + grp.mMeta.mGroupName = std::string(name.toUtf8()); + grp.mDescription = std::string(desc.toUtf8()); + grp.mMeta.mGroupFlags = flags; + + rsForumsV2->createGroup(token, grp, true); + + // get the Queue to handle response. + mForumQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_SUMMARY, CREATEFORUMSV2_NEWFORUMID); + } +} +void CreateForumV2::completeCreateNewForum(const RsGroupMetaData &newForumMeta) +{ + sendShareList(newForumMeta.mGroupId); + close(); } -void CreateForumV2::setShareList(){ - if(ui.pubKeyShare_cb->isChecked()){ - this->resize(this->size().width() + ui.contactsdockWidget->size().width(), - this->size().height()); - ui.contactsdockWidget->show(); - - - if (!rsPeers) - { - /* not ready yet! */ - return; - } - - std::list peers; - std::list::iterator it; - - rsPeers->getFriendList(peers); - - /* get a link to the table */ - QTreeWidget *shareWidget = ui.keyShareList; - - QList items; - - for(it = peers.begin(); it != peers.end(); it++) - { - - RsPeerDetails detail; - if (!rsPeers->getPeerDetails(*it, detail)) - { - continue; /* BAD */ - } - - /* make a widget per friend */ - QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); - - item -> setText(0, PeerDefs::nameWithLocation(detail)); - if (detail.state & RS_PEER_STATE_CONNECTED) { - item -> setTextColor(0,(Qt::darkBlue)); - } - item -> setSizeHint(0, QSize( 17,17 ) ); - - item -> setText(1, QString::fromStdString(detail.id)); - - item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); - item -> setCheckState(0, Qt::Unchecked); - - - /* add to the list */ - items.append(item); - } - - /* remove old items */ - shareWidget->clear(); - shareWidget->setColumnCount(1); - - /* add the items in! */ - shareWidget->insertTopLevelItems(0, items); - - shareWidget->update(); /* update display */ - - }else{ // hide share widget - ui.contactsdockWidget->hide(); - this->resize(this->size().width() - ui.contactsdockWidget->size().width(), - this->size().height()); - mShareList.clear(); +void CreateForumV2::sendShareList(std::string forumId) +{ + if (!rsForumsV2) + { + std::cerr << "CreateForumV2::sendShareList() ForumsV2 not active"; + std::cerr << std::endl; + return; } - + + if (ui.pubKeyShare_cb->isChecked()) + { + std::list shareList; + ui.keyShareList->selectedSslIds(shareList, false); + rsForumsV2->groupShareKeys(forumId, shareList); + } + close(); } -void CreateForumV2::cancelForum() + + + + +void CreateForumV2::setShareList() +{ + if (ui.pubKeyShare_cb->isChecked()){ + this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height()); + ui.contactsdockWidget->show(); + } else { // hide share widget + ui.contactsdockWidget->hide(); + this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); + } +} + +void CreateForumV2::cancelForum() { close(); } + + + + +void CreateForumV2::loadNewForumId(const uint32_t &token) +{ + std::cerr << "CreateForumV2::loadNewForumId()"; + std::cerr << std::endl; + + std::list groupInfo; + rsForumsV2->getGroupSummary(token, groupInfo); + + if (groupInfo.size() == 1) + { + RsGroupMetaData fi = groupInfo.front(); + completeCreateNewForum(fi); + } + else + { + std::cerr << "CreateForumV2::loadNewForumId() ERROR INVALID Number of Forums Created"; + std::cerr << std::endl; + } +} + + + + + + + + +void CreateForumV2::loadRequest(const TokenQueue *queue, const TokenRequest &req) +{ + std::cerr << "CreateForumV2::loadRequest() UserType: " << req.mUserType; + std::cerr << std::endl; + + if (queue == mForumQueue) + { + /* now switch on req */ + switch(req.mUserType) + { + + case CREATEFORUMSV2_NEWFORUMID: + loadNewForumId(req.mToken); + break; + default: + std::cerr << "CreateForumV2::loadRequest() UNKNOWN UserType "; + std::cerr << std::endl; + + } + } +} + + + diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2.h b/retroshare-gui/src/gui/forumsv2/CreateForumV2.h index ae88827fe..0aa72e26e 100644 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2.h +++ b/retroshare-gui/src/gui/forumsv2/CreateForumV2.h @@ -25,36 +25,42 @@ #include "ui_CreateForumV2.h" -class CreateForumV2 : public QDialog +#include "util/TokenQueue.h" + +class CreateForumV2 : public QDialog, public TokenResponse { - Q_OBJECT + Q_OBJECT public: - CreateForumV2(QWidget *parent = 0); + CreateForumV2(QWidget *parent = 0); -void newForum(); /* cleanup */ + void newForum(); /* cleanup */ - /** Qt Designer generated object */ - Ui::CreateForumV2 ui; - - QPixmap picture; + // Callback for all Loads. +virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); private slots: - /* actions to take.... */ -void createForum(); -void cancelForum(); + void createForum(); + void cancelForum(); -// set private forum key share list -void setShareList(); - -// when user checks a person in share list checkboxes -void togglePersonItem(QTreeWidgetItem* item, int col); + // set private forum key share list + void setShareList(); private: + void sendShareList(std::string forumId); + void completeCreateNewForum(const RsGroupMetaData &newForumMeta); + void loadNewForumId(const uint32_t &token); -std::list mShareList; + std::list mShareList; + + QPixmap picture; + + TokenQueue *mForumQueue; + + /** Qt Designer generated object */ + Ui::CreateForumV2 ui; }; #endif diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2.ui b/retroshare-gui/src/gui/forumsv2/CreateForumV2.ui index 6ab6dcf95..0cfcb4ca5 100644 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2.ui +++ b/retroshare-gui/src/gui/forumsv2/CreateForumV2.ui @@ -160,7 +160,7 @@ p, li { white-space: pre-wrap; } 0 - + 0 @@ -191,14 +191,6 @@ p, li { white-space: pre-wrap; } 0 - - true - - - - Contacts: - - @@ -267,7 +259,7 @@ p, li { white-space: pre-wrap; } - Key recipients can publish to restricted-type channels, and can view and publish for private-type channels + Key recipients can publish to restricted-type channels, and can view and publish for private-type channels Share Private Publish Key @@ -367,6 +359,14 @@ p, li { white-space: pre-wrap; } + + + FriendSelectionWidget + QWidget +
gui/common/FriendSelectionWidget.h
+ 1 +
+
diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp b/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp index d20b5816f..4df3ebc3c 100644 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp +++ b/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp @@ -28,7 +28,8 @@ #include #include -#include +#include +#include #include "gui/settings/rsharesettings.h" #include "gui/RetroShareLink.h" @@ -37,6 +38,11 @@ #include "util/misc.h" #include +#include + + +#define CREATEFORUMV2MSG_FORUMINFO 1 +#define CREATEFORUMV2MSG_PARENTMSG 2 /** Constructor */ @@ -47,6 +53,9 @@ CreateForumV2Msg::CreateForumV2Msg(std::string fId, std::string pId) ui.setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); + /* Setup Queue */ + mForumQueue = new TokenQueue(rsForumsV2, this); + Settings->loadWidgetInformation(this); connect( ui.forumMessage, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumMessageCostumPopupMenu( QPoint ) ) ); @@ -64,6 +73,9 @@ CreateForumV2Msg::CreateForumV2Msg(std::string fId, std::string pId) ui.hashBox->setDropWidget(this); ui.hashBox->setAutoHide(false); + mParentMsgLoaded = false; + mForumMetaLoaded = false; + newMsg(); } @@ -75,6 +87,7 @@ void CreateForumV2Msg::forumMessageCostumPopupMenu( QPoint /*point*/ ) contextMnu->addSeparator(); QAction *pasteLinkAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); QAction *pasteLinkFullAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste full RetroShare Link"), this, SLOT(pasteLinkFull())); + contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste own certificate link"), this, SLOT(pasteOwnCertificateLink())); if (RSLinkClipboard::empty()) { pasteLinkAct->setDisabled (true); @@ -88,60 +101,126 @@ void CreateForumV2Msg::forumMessageCostumPopupMenu( QPoint /*point*/ ) void CreateForumV2Msg::newMsg() { /* clear all */ - ForumInfo fi; - if (rsForums->getForumInfo(mForumId, fi)) - { - ForumMsgInfo msg; + mParentMsgLoaded = false; + mForumMetaLoaded = false; - QString name = QString::fromStdWString(fi.forumName); - QString subj; - if ((mParentId != "") && (rsForums->getForumMessage(mForumId, mParentId, msg))) - { - QString title = QString::fromStdWString(msg.title); - name += " " + tr("In Reply to") + ": "; - name += title; + /* request Data */ + { + RsTokReqOptions opts; + + std::list groupIds; + groupIds.push_back(mForumId); + + std::cerr << "ForumsV2Dialog::newMsg() Requesting Group Summary(" << mForumId << ")"; + std::cerr << std::endl; + + uint32_t token; + mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEFORUMV2MSG_FORUMINFO); - QString text = title; + } + + if (mParentId != "") + { + + RsTokReqOptions opts; + + std::list msgIds; + msgIds.push_back(mParentId); + + std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")"; + std::cerr << std::endl; + + uint32_t token; + mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEFORUMV2MSG_PARENTMSG); + } +} - if (text.startsWith("Re:", Qt::CaseInsensitive)) - { - subj = title; - } - else - { - subj = "Re: " + title; - } - } +void CreateForumV2Msg::saveForumInfo(const RsGroupMetaData &meta) +{ + mForumMeta = meta; + mForumMetaLoaded = true; + + loadFormInformation(); +} - ui.forumName->setText(misc::removeNewLine(name)); - ui.forumSubject->setText(misc::removeNewLine(subj)); +void CreateForumV2Msg::saveParentMsg(const RsForumV2Msg &msg) +{ + mParentMsg = msg; + mParentMsgLoaded = true; + + loadFormInformation(); +} - if (!ui.forumSubject->text().isEmpty()) - { - ui.forumMessage->setFocus(); - } - else - { - ui.forumSubject->setFocus(); - } - - if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ) - { - ui.signBox->setChecked(true); - ui.signBox->setEnabled(false); - } - else - { - /* Uncheck sign box by default for anonymous forums */ - ui.signBox->setChecked(false); - ui.signBox->setEnabled(true); - } - } +void CreateForumV2Msg::loadFormInformation() +{ + if ((!mParentMsgLoaded) && (mParentId != "")) + { + std::cerr << "CreateForumV2Msg::loadMsgInformation() ParentMsg not Loaded Yet"; + std::cerr << std::endl; + return; + } + + if (!mForumMetaLoaded) + { + std::cerr << "CreateForumV2Msg::loadMsgInformation() ForumMeta not Loaded Yet"; + std::cerr << std::endl; + return; + } + + std::cerr << "CreateForumV2Msg::loadMsgInformation() Data Available!"; + std::cerr << std::endl; + + QString name = QString::fromUtf8(mForumMeta.mGroupName.c_str()); + QString subj; + if (mParentId != "") + { + QString title = QString::fromUtf8(mParentMsg.mMeta.mMsgName.c_str()); + name += " " + tr("In Reply to") + ": "; + name += title; + + QString text = title; + + if (text.startsWith("Re:", Qt::CaseInsensitive)) + { + subj = title; + } + else + { + subj = "Re: " + title; + } + + } + + ui.forumName->setText(misc::removeNewLine(name)); + ui.forumSubject->setText(misc::removeNewLine(subj)); + + if (!ui.forumSubject->text().isEmpty()) + { + ui.forumMessage->setFocus(); + } + else + { + ui.forumSubject->setFocus(); + } + + if (mForumMeta.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) + { + ui.signBox->setChecked(true); + ui.signBox->setEnabled(false); + } + else + { + /* Uncheck sign box by default for anonymous forums */ + ui.signBox->setChecked(false); + ui.signBox->setEnabled(true); + } ui.forumMessage->setText(""); } + + void CreateForumV2Msg::createMsg() { QString name = misc::removeNewLine(ui.forumSubject->text()); @@ -158,30 +237,56 @@ void CreateForumV2Msg::createMsg() return; //Don't add a empty Subject!! } - ForumMsgInfo msgInfo; - - msgInfo.forumId = mForumId; - msgInfo.threadId = ""; - msgInfo.parentId = mParentId; - msgInfo.msgId = ""; - - msgInfo.title = name.toStdWString(); - msgInfo.msg = desc.toStdWString(); - msgInfo.msgflags = 0; - - if (ui.signBox->isChecked()) - { - msgInfo.msgflags = RS_DISTRIB_AUTHEN_REQ; - } - - if ((msgInfo.msg == L"") && (msgInfo.title == L"")) + RsForumV2Msg msg; + msg.mMeta.mGroupId = mForumId; + msg.mMeta.mParentId = mParentId; + msg.mMeta.mMsgId = ""; + if (mParentMsgLoaded) + { + msg.mMeta.mThreadId = mParentMsg.mMeta.mThreadId; + } + + msg.mMeta.mMsgName = std::string(name.toUtf8()); + msg.mMsg = std::string(desc.toUtf8()); + msg.mMeta.mMsgFlags = RS_DISTRIB_AUTHEN_REQ; + + if ((msg.mMsg == "") && (msg.mMeta.mMsgName == "")) return; /* do nothing */ + + uint32_t token; + rsForumsV2->createMsg(token, msg, true); + close(); + + + // Previous Info - for reference. + + //ForumMsgInfo msgInfo; - if (rsForums->ForumMessageSend(msgInfo) == true) { - close(); - } + //msgInfo.forumId = mForumId; + //msgInfo.threadId = ""; + //msgInfo.parentId = mParentId; + //msgInfo.msgId = ""; + + //msgInfo.title = name.toStdWString(); + //msgInfo.msg = desc.toStdWString(); + //msgInfo.msgflags = 0; + + //if (ui.signBox->isChecked()) + //{ + // msgInfo.msgflags = RS_DISTRIB_AUTHEN_REQ; + //} + + //if ((msgInfo.msg == L"") && (msgInfo.title == L"")) + // return; /* do nothing */ + + //if (rsForumsV2->ForumMessageSend(msgInfo) == true) { + // close(); + //} } + + + void CreateForumV2Msg::closeEvent (QCloseEvent * /*event*/) { Settings->saveWidgetInformation(this); @@ -245,3 +350,75 @@ void CreateForumV2Msg::pasteLinkFull() { ui.forumMessage->insertHtml(RSLinkClipboard::toHtmlFull()) ; } + +void CreateForumV2Msg::pasteOwnCertificateLink() +{ + RetroShareLink link ; + std::string ownId = rsPeers->getOwnId() ; + if( link.createCertificate(ownId) ) { + ui.forumMessage->insertHtml(link.toHtml() + " "); + } +} + + + + +void CreateForumV2Msg::loadForumInfo(const uint32_t &token) +{ + std::cerr << "CreateForumV2Msg::loadForumInfo()"; + std::cerr << std::endl; + + std::list groupInfo; + rsForumsV2->getGroupSummary(token, groupInfo); + + if (groupInfo.size() == 1) + { + RsGroupMetaData fi = groupInfo.front(); + saveForumInfo(fi); + } + else + { + std::cerr << "CreateForumV2Msg::loadForumInfo() ERROR INVALID Number of Forums"; + std::cerr << std::endl; + } +} + + +void CreateForumV2Msg::loadParentMsg(const uint32_t &token) +{ + std::cerr << "CreateForumV2Msg::loadParentMsg()"; + std::cerr << std::endl; + + // Only grab one.... ignore more (shouldn't be any). + RsForumV2Msg msg; + rsForumsV2->getMsgData(token, msg); + saveParentMsg(msg); +} + + + +void CreateForumV2Msg::loadRequest(const TokenQueue *queue, const TokenRequest &req) +{ + std::cerr << "CreateForumV2::loadRequest() UserType: " << req.mUserType; + std::cerr << std::endl; + + if (queue == mForumQueue) + { + /* now switch on req */ + switch(req.mUserType) + { + case CREATEFORUMV2MSG_FORUMINFO: + loadForumInfo(req.mToken); + break; + + case CREATEFORUMV2MSG_PARENTMSG: + loadParentMsg(req.mToken); + break; + default: + std::cerr << "CreateForumV2::loadRequest() UNKNOWN UserType "; + std::cerr << std::endl; + + } + } +} + diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.h b/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.h index 53b670609..5b5de0194 100644 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.h +++ b/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.h @@ -25,7 +25,12 @@ #include "ui_CreateForumV2Msg.h" -class CreateForumV2Msg : public QMainWindow +#include "util/TokenQueue.h" + +#include + + +class CreateForumV2Msg : public QMainWindow, public TokenResponse { Q_OBJECT @@ -33,7 +38,8 @@ public: CreateForumV2Msg(std::string fId, std::string pId); void newMsg(); /* cleanup */ - + virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); + private slots: /** Create the context popup menu and it's submenus */ void forumMessageCostumPopupMenu( QPoint point ); @@ -44,6 +50,7 @@ private slots: void cancelMsg(); void pasteLink(); void pasteLinkFull(); + void pasteOwnCertificateLink(); void smileyWidgetForums(); void addSmileys(); @@ -53,8 +60,23 @@ protected: void closeEvent (QCloseEvent * event); private: + + void saveForumInfo(const RsGroupMetaData &meta); + void saveParentMsg(const RsForumV2Msg &msg); + void loadFormInformation(); + + void loadForumInfo(const uint32_t &token); + void loadParentMsg(const uint32_t &token); + std::string mForumId; std::string mParentId; + + bool mParentMsgLoaded; + bool mForumMetaLoaded; + RsForumV2Msg mParentMsg; + RsGroupMetaData mForumMeta; + + TokenQueue *mForumQueue; /** Qt Designer generated object */ Ui::CreateForumV2Msg ui; diff --git a/retroshare-gui/src/gui/forumsv2/EditForumV2Details.cpp b/retroshare-gui/src/gui/forumsv2/EditForumV2Details.cpp index 1be2b5a85..7d04594d9 100644 --- a/retroshare-gui/src/gui/forumsv2/EditForumV2Details.cpp +++ b/retroshare-gui/src/gui/forumsv2/EditForumV2Details.cpp @@ -21,7 +21,7 @@ #include "EditForumV2Details.h" -#include +#include #include "util/misc.h" @@ -44,23 +44,27 @@ EditForumV2Details::EditForumV2Details(std::string forumId, QWidget *parent, Qt: void EditForumV2Details::loadForum() { - if (!rsForums) { + if (!rsForumsV2) { return; } +#warning "EditForumV2Details incomplete" +#if 0 ForumInfo info; - rsForums->getForumInfo(m_forumId, info); + rsForumsV2->getForumInfo(m_forumId, info); // set name ui.nameline->setText(QString::fromStdWString(info.forumName)); // set description ui.DescriptiontextEdit->setText(QString::fromStdWString(info.forumDesc)); +#endif + } void EditForumV2Details::applyDialog() { - if (!rsForums) { + if (!rsForumsV2) { return; } @@ -69,13 +73,17 @@ void EditForumV2Details::applyDialog() return; } +#warning "EditForumV2Details incomplete" +#if 0 + ForumInfo info; info.forumName = misc::removeNewLine(ui.nameline->text()).toStdWString(); info.forumDesc = ui.DescriptiontextEdit->document()->toPlainText().toStdWString(); - rsForums->setForumInfo(m_forumId, info); - + rsForumsV2->setForumInfo(m_forumId, info); +#endif + /* close the Dialog after the Changes applied */ close(); } diff --git a/retroshare-gui/src/gui/forumsv2/ForumV2Details.cpp b/retroshare-gui/src/gui/forumsv2/ForumV2Details.cpp index 2cf05ff4f..29f0c750f 100644 --- a/retroshare-gui/src/gui/forumsv2/ForumV2Details.cpp +++ b/retroshare-gui/src/gui/forumsv2/ForumV2Details.cpp @@ -23,12 +23,11 @@ #include #include #include -#include +#include #include #include -#include #include #include #include @@ -91,13 +90,15 @@ void ForumV2Details::showDetails(std::string mCurrForumId) void ForumV2Details::loadDialog() { - if (!rsForums) + if (!rsForumsV2) { return; } +#warning "ForumV2Details Incomplete" +#if 0 ForumInfo fi; - rsForums->getForumInfo(fId, fi); + rsForumsV2->getForumInfo(fId, fi); // Set Forum Name ui.nameline->setText(QString::fromStdWString(fi.forumName)); @@ -129,6 +130,8 @@ void ForumV2Details::loadDialog() ui.radioButton_authd->setChecked(false); ui.radioButton_anonymous->setChecked(true); } +#endif + } void ForumV2Details::applyDialog() diff --git a/retroshare-gui/src/gui/forumsv2/ForumV2Details.ui b/retroshare-gui/src/gui/forumsv2/ForumV2Details.ui index 9662916c7..c9e05074b 100644 --- a/retroshare-gui/src/gui/forumsv2/ForumV2Details.ui +++ b/retroshare-gui/src/gui/forumsv2/ForumV2Details.ui @@ -121,7 +121,7 @@ - Authemticated Messages + Authenticated Messages