diff --git a/retroshare-gui/src/gui/Circles/CirclesDialog.cpp b/retroshare-gui/src/gui/Circles/CirclesDialog.cpp index f973514c8..e10c8f5fc 100644 --- a/retroshare-gui/src/gui/Circles/CirclesDialog.cpp +++ b/retroshare-gui/src/gui/Circles/CirclesDialog.cpp @@ -92,7 +92,7 @@ void CirclesDialog::todo() ""); } -void CirclesDialog::updateDisplay(bool /*initialFill*/) +void CirclesDialog::updateDisplay(bool /*complete*/) { reloadAll(); } diff --git a/retroshare-gui/src/gui/Circles/CirclesDialog.h b/retroshare-gui/src/gui/Circles/CirclesDialog.h index bdf2110e0..53623f05c 100644 --- a/retroshare-gui/src/gui/Circles/CirclesDialog.h +++ b/retroshare-gui/src/gui/Circles/CirclesDialog.h @@ -40,7 +40,7 @@ public: void loadRequest(const TokenQueue *queue, const TokenRequest &req); protected: - virtual void updateDisplay(bool initialFill); + virtual void updateDisplay(bool complete); private slots: void todo(); diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 023e38979..130f5dc86 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -505,7 +505,7 @@ void IdDialog::insertIdDetails(uint32_t token) requestRepList(data.mMeta.mGroupId); } -void IdDialog::updateDisplay(bool /*initialFill*/) +void IdDialog::updateDisplay(bool /*complete*/) { /* Update identity list */ requestIdList(); diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index 8c390f148..27bc546f1 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -46,7 +46,7 @@ public: void loadRequest(const TokenQueue *queue, const TokenRequest &req); protected: - virtual void updateDisplay(bool initialFill); + virtual void updateDisplay(bool complete); private slots: void filterComboBoxChanged(); diff --git a/retroshare-gui/src/gui/Posted/PostedListDialog.cpp b/retroshare-gui/src/gui/Posted/PostedListDialog.cpp index 30b22818b..59a420876 100644 --- a/retroshare-gui/src/gui/Posted/PostedListDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListDialog.cpp @@ -291,7 +291,7 @@ void PostedListDialog::openComments(uint32_t /*feed_type*/, const RsGxsGroupId & /*****************************************************************************************/ -void PostedListDialog::updateDisplay(bool /*initialFill*/) +void PostedListDialog::updateDisplay(bool /*complete*/) { std::cerr << "rsPosted->updateDisplay()"; std::cerr << std::endl; diff --git a/retroshare-gui/src/gui/Posted/PostedListDialog.h b/retroshare-gui/src/gui/Posted/PostedListDialog.h index 3f550d1bc..5cbefea97 100644 --- a/retroshare-gui/src/gui/Posted/PostedListDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedListDialog.h @@ -80,7 +80,7 @@ private slots: void showPrev(); protected: - virtual void updateDisplay(bool initialFill); + virtual void updateDisplay(bool complete); private: void updateShowText(); diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h index 84a49d63b..00ae0c1e6 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h @@ -25,7 +25,7 @@ protected: void showEvent(QShowEvent *e); signals: - void fillDisplay(bool initialFill); + void fillDisplay(bool complete); private slots: void updateBroadcastChanged(); diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp index 3001f2c64..68b288461 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp @@ -27,9 +27,9 @@ std::map > &RsGxsUpdateBroadcastPage:: return mBase->getMsgIds(); } -void RsGxsUpdateBroadcastPage::fillDisplay(bool initialFill) +void RsGxsUpdateBroadcastPage::fillDisplay(bool complete) { - updateDisplay(initialFill); + updateDisplay(complete); update(); // Qt flush } diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h index b1e83850a..8d17cacd3 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h @@ -30,10 +30,10 @@ protected: virtual void showEvent(QShowEvent *event); // This is overloaded in subclasses. - virtual void updateDisplay(bool initialFill) = 0; + virtual void updateDisplay(bool complete) = 0; private slots: - void fillDisplay(bool initialFill); + void fillDisplay(bool complete); private: RsGxsUpdateBroadcastBase *mBase; diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp index 813cb447f..a2f4ed8bb 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp @@ -27,9 +27,9 @@ std::map > &RsGxsUpdateBroadcastWidget return mBase->getMsgIds(); } -void RsGxsUpdateBroadcastWidget::fillDisplay(bool initialFill) +void RsGxsUpdateBroadcastWidget::fillDisplay(bool complete) { - updateDisplay(initialFill); + updateDisplay(complete); update(); // Qt flush } diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h index 7a4d6f957..74e6b8dd3 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h @@ -30,10 +30,10 @@ protected: virtual void showEvent(QShowEvent *event); // This is overloaded in subclasses. - virtual void updateDisplay(bool initialFill) = 0; + virtual void updateDisplay(bool complete) = 0; private slots: - void fillDisplay(bool initialFill); + void fillDisplay(bool complete); private: RsGxsUpdateBroadcastBase *mBase; diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 2b5a9d34a..17b1b73f6 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -20,8 +20,6 @@ ****************************************************************/ #include -#include -#include #include #include #include @@ -31,19 +29,16 @@ #include "CreateGxsChannelMsg.h" #include "gui/feeds/SubFileItem.h" #include "util/misc.h" -#include "util/TokenQueue.h" -#include #include #include -#define CREATEMSG_CHANNELINFO 0x002 - +#define CREATEMSG_CHANNELINFO 0x002 /** Constructor */ CreateGxsChannelMsg::CreateGxsChannelMsg(std::string cId) -: QDialog (NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mChannelId(cId) ,mCheckAttachment(true), mAutoMediaThumbNail(false) + : QDialog (NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mChannelId(cId) ,mCheckAttachment(true), mAutoMediaThumbNail(false) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); @@ -71,10 +66,10 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(std::string cId) thumbNailCb->setVisible(true); thumbNailCb->setEnabled(true); #endif - //buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); + //buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); setAcceptDrops(true); - + newChannelMsg(); } @@ -89,17 +84,16 @@ void CreateGxsChannelMsg::contextMenu(QPoint /*point*/) if((*it).type() == RetroShareLink::TYPE_FILE) n_file++ ; - QMenu contextMnu(this) ; + QMenu contextMnu(this) ; - QAction *action ; - - if(n_file > 1) - action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Links"), this, SLOT(pasteLink())); - else - action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); + QAction *action ; + if(n_file > 1) + action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Links"), this, SLOT(pasteLink())); + else + action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); - action->setDisabled(n_file < 1) ; - contextMnu.exec(QCursor::pos()); + action->setDisabled(n_file < 1) ; + contextMnu.exec(QCursor::pos()); } void CreateGxsChannelMsg::pasteLink() @@ -135,12 +129,11 @@ void CreateGxsChannelMsg::pasteLink() } } -CreateGxsChannelMsg::~CreateGxsChannelMsg(){ - +CreateGxsChannelMsg::~CreateGxsChannelMsg() +{ #ifdef CHANNELS_FRAME_CATCHER delete fCatcher; #endif - } /* Dropping */ @@ -325,13 +318,11 @@ void CreateGxsChannelMsg::parseRsFileListAttachments(const std::string &attachLi // TEMP NOT ALLOWED UNTIL FT WORKING. addAttachment(hash, fname, size, false, source); } - } else { std::cerr << "Error Decode: Hash size: " << hash.size() << std::endl; } - } } @@ -368,22 +359,20 @@ void CreateGxsChannelMsg::addAttachment(const std::string &hash, const std::stri return; } - void CreateGxsChannelMsg::addExtraFile() { - /* add a SubFileItem to the attachment section */ - std::cerr << "CreateGxsChannelMsg::addExtraFile() opening file dialog"; - std::cerr << std::endl; + /* add a SubFileItem to the attachment section */ + std::cerr << "CreateGxsChannelMsg::addExtraFile() opening file dialog"; + std::cerr << std::endl; - QStringList files; - if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) { - for (QStringList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { - addAttachment((*fileIt).toUtf8().constData()); + QStringList files; + if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) { + for (QStringList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { + addAttachment((*fileIt).toUtf8().constData()); + } } - } } - void CreateGxsChannelMsg::addAttachment(const std::string &path) { /* add a SubFileItem to the attachment section */ @@ -402,13 +391,10 @@ void CreateGxsChannelMsg::addAttachment(const std::string &path) for(it= mAttachments.begin(); it != mAttachments.end(); it++){ if((*it)->FilePath() == path){ - QMessageBox::warning(this, tr("RetroShare"), - tr("File already Added and Hashed"), - QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::warning(this, tr("RetroShare"), tr("File already Added and Hashed"), QMessageBox::Ok, QMessageBox::Ok); return; } - } FileInfo fInfo; @@ -481,8 +467,8 @@ bool CreateGxsChannelMsg::setThumbNail(const std::string& path, int frame){ return true; } -void CreateGxsChannelMsg::allowAutoMediaThumbNail(bool allowThumbNail){ - +void CreateGxsChannelMsg::allowAutoMediaThumbNail(bool allowThumbNail) +{ mAutoMediaThumbNail = allowThumbNail; } @@ -520,7 +506,6 @@ void CreateGxsChannelMsg::checkAttachmentReady() QTimer::singleShot( msec_rate, this, SLOT(checkAttachmentReady(void))); } - void CreateGxsChannelMsg::cancelMsg() { std::cerr << "CreateGxsChannelMsg::cancelMsg() :" @@ -533,8 +518,7 @@ void CreateGxsChannelMsg::cancelMsg() for(it = mAttachments.begin(); it != mAttachments.end(); it++) rsGxsChannels->ExtraFileRemove((*it)->FileHash()); - close(); - return; + reject(); } void CreateGxsChannelMsg::newChannelMsg() @@ -560,7 +544,6 @@ void CreateGxsChannelMsg::newChannelMsg() } } - void CreateGxsChannelMsg::saveChannelInfo(const RsGroupMetaData &meta) { mChannelMeta = meta; @@ -570,7 +553,6 @@ void CreateGxsChannelMsg::saveChannelInfo(const RsGroupMetaData &meta) subjectEdit->setFocus(); } - void CreateGxsChannelMsg::sendMsg() { std::cerr << "CreateGxsChannelMsg::sendMsg()"; @@ -609,17 +591,14 @@ void CreateGxsChannelMsg::sendMsg() } sendMessage(subject, msg, files); - } void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::string &msg, const std::list &files) { if(subject.empty()) { /* error message */ - QMessageBox::warning(this, tr("RetroShare"), - tr("Please add a Subject"), - QMessageBox::Ok, QMessageBox::Ok); - + QMessageBox::warning(this, tr("RetroShare"), tr("Please add a Subject"), QMessageBox::Ok, QMessageBox::Ok); + return; //Don't add an empty Subject!! } else @@ -627,12 +606,12 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str if (rsGxsChannels) { RsGxsChannelPost post; - + post.mMeta.mGroupId = mChannelId; post.mMeta.mParentId = ""; post.mMeta.mThreadId = ""; post.mMeta.mMsgId = ""; - + post.mMeta.mMsgName = subject; post.mMsg = msg; post.mFiles = files; @@ -648,14 +627,12 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str picture.save(&buffer, "PNG"); // writes image into ba in PNG format post.mThumbnail.copy((uint8_t *) ba.data(), ba.size()); } - + uint32_t token; rsGxsChannels->createPost(token, post); } - - close(); - return; + accept(); } void CreateGxsChannelMsg::addThumbnail() @@ -671,8 +648,6 @@ void CreateGxsChannelMsg::addThumbnail() thumbnail_label->setPixmap(picture); } - - void CreateGxsChannelMsg::loadChannelInfo(const uint32_t &token) { std::cerr << "CreateGxsChannelMsg::loadChannelInfo()"; @@ -693,7 +668,6 @@ void CreateGxsChannelMsg::loadChannelInfo(const uint32_t &token) } } - void CreateGxsChannelMsg::loadRequest(const TokenQueue *queue, const TokenRequest &req) { std::cerr << "CreateGxsChannelMsg::loadRequest() UserType: " << req.mUserType; @@ -710,12 +684,6 @@ void CreateGxsChannelMsg::loadRequest(const TokenQueue *queue, const TokenReques default: std::cerr << "CreateGxsChannelMsg::loadRequest() UNKNOWN UserType "; std::cerr << std::endl; - } } } - - - - - diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h index 2499f02aa..8366a8e67 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h @@ -23,7 +23,6 @@ #define _CREATE_GXSCHANNEL_MSG_H #include "ui_CreateGxsChannelMsg.h" -#include #include "util/TokenQueue.h" #include @@ -32,34 +31,31 @@ #endif class SubFileItem; -class RsGxsFile; class CreateGxsChannelMsg : public QDialog, public TokenResponse, private Ui::CreateGxsChannelMsg { - Q_OBJECT + Q_OBJECT public: - /** Default Constructor */ - CreateGxsChannelMsg(std::string cId); + /** Default Constructor */ + CreateGxsChannelMsg(std::string cId); - - /** Default Destructor */ - ~CreateGxsChannelMsg(); + /** Default Destructor */ + ~CreateGxsChannelMsg(); void addAttachment(const std::string &path); void addAttachment(const std::string &hash, const std::string &fname, uint64_t size, bool local, const std::string &srcId); void newChannelMsg(); - + QPixmap picture; // overload from TokenResponse -virtual void loadRequest(const TokenQueue*, const TokenRequest&); - + virtual void loadRequest(const TokenQueue*, const TokenRequest&); protected: -virtual void dragEnterEvent(QDragEnterEvent *event); -virtual void dropEvent(QDropEvent *event); + virtual void dragEnterEvent(QDragEnterEvent *event); + virtual void dropEvent(QDropEvent *event); private slots: void addExtraFile(); @@ -69,35 +65,32 @@ private slots: void sendMsg(); void pasteLink() ; void contextMenu(QPoint) ; - + void addThumbnail(); void allowAutoMediaThumbNail(bool); private: - void loadChannelInfo(const uint32_t &token); void saveChannelInfo(const RsGroupMetaData &group); void parseRsFileListAttachments(const std::string &attachList); void sendMessage(const std::string &subject, const std::string &msg, const std::list &files); bool setThumbNail(const std::string& path, int frame); - - std::string mChannelId; + + std::string mChannelId; RsGroupMetaData mChannelMeta; bool mChannelMetaLoaded; std::list mAttachments; bool mCheckAttachment; - bool mAutoMediaThumbNail; + bool mAutoMediaThumbNail; TokenQueue *mChannelQueue; #ifdef CHANNELS_FRAME_CATCHER - framecatcher* fCatcher; + framecatcher* fCatcher; #endif - }; #endif - diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index 631380d6d..f789e4496 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -20,33 +20,16 @@ ****************************************************************/ #include -#include -#include #include #include -#include -#include -#include #include "GxsChannelDialog.h" - #include "gui/feeds/GxsChannelPostItem.h" - -#include "../common/PopularityDefs.h" -#include "../settings/rsharesettings.h" - +#include "gui/settings/rsharesettings.h" #include "gui/gxschannels/GxsChannelGroupDialog.h" #include "gui/gxschannels/CreateGxsChannelMsg.h" - -//#include "../channels/ChannelDetails.h" -//#include "../channels/EditChanDetails.h" -#include "../channels/ShareKey.h" -#include "../channels/ChannelUserNotify.h" - - -#include "../notifyqt.h" -#include "../RetroShareLink.h" +#include "gui/common/UIStateHelper.h" #define CHAN_DEFAULT_IMAGE ":/images/channels.png" @@ -59,39 +42,47 @@ #define IMAGE_CHANNELYELLOW ":/images/channelsyellow.png" /**** - * #define CHAN_DEBUG + * #define DEBUG_CHANNEL ***/ #define USE_THREAD +#define TOKEN_TYPE_GROUP_CHANGE 1 // THIS MUST MIRROR GxsGroupDialog parameters. -#define TOKEN_TYPE_GROUP_CHANGE 1 // THIS MUST MIRROR GxsGroupDialog parameters. - -#define TOKEN_TYPE_MESSAGE_CHANGE 4 -#define TOKEN_TYPE_LISTING 5 -#define TOKEN_TYPE_GROUP_DATA 6 -#define TOKEN_TYPE_POSTS 7 +#define TOKEN_TYPE_MESSAGE_CHANGE 4 +#define TOKEN_TYPE_LISTING 5 +#define TOKEN_TYPE_GROUP_DATA 6 +#define TOKEN_TYPE_POSTS 7 /** Constructor */ GxsChannelDialog::GxsChannelDialog(QWidget *parent) -: RsAutoUpdatePage(1000,parent), GxsServiceDialog(dynamic_cast(parent)) + : RsGxsUpdateBroadcastPage(rsGxsChannels, parent), GxsServiceDialog(dynamic_cast(parent)) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); + /* Setup UI helper */ + mStateHelper = new UIStateHelper(this); + + mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui.progressBar, UISTATE_LOADING_VISIBLE); + mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui.progressLabel, UISTATE_LOADING_VISIBLE); + + mStateHelper->addLoadPlaceholder(TOKEN_TYPE_GROUP_DATA, ui.nameLabel); + + mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui.postButton); + mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui.logoLabel); + mChannelQueue = new TokenQueue(rsGxsChannels->getTokenService(), this); connect(ui.newChannelButton, SIGNAL(clicked()), this, SLOT(createChannel())); connect(ui.postButton, SIGNAL(clicked()), this, SLOT(createMsg())); - connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int))); - - connect(ui.refreshButton, SIGNAL(clicked()), this, SLOT(forceUpdateDisplay())); - +// connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int))); /*************** Setup Left Hand Side (List of Channels) ****************/ - connect(ui.treeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT( channelListCustomPopupMenu( QPoint ) ) ); + connect(ui.treeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(channelListCustomPopupMenu(QPoint))); connect(ui.treeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(selectChannel(QString))); + connect(ui.todoPushButton, SIGNAL(clicked()), this, SLOT(todo())); mChannelId.clear(); @@ -105,22 +96,19 @@ GxsChannelDialog::GxsChannelDialog(QWidget *parent) ownChannels = ui.treeWidget->addCategoryItem(tr("My Channels"), QIcon(IMAGE_CHANNELBLUE), true); subcribedChannels = ui.treeWidget->addCategoryItem(tr("Subscribed Channels"), QIcon(IMAGE_CHANNELRED), true); - popularChannels = ui.treeWidget->addCategoryItem(tr("Popular Channels"), QIcon(IMAGE_CHANNELGREEN ), false); + popularChannels = ui.treeWidget->addCategoryItem(tr("Popular Channels"), QIcon(IMAGE_CHANNELGREEN), false); otherChannels = ui.treeWidget->addCategoryItem(tr("Other Channels"), QIcon(IMAGE_CHANNELYELLOW), false); ui.progressLabel->hide(); ui.progressBar->hide(); - //added from ahead - //updateChannelList(); - forceUpdateDisplay(); - ui.nameLabel->setMinimumWidth(20); /* load settings */ processSettings(true); - insertChannels(); + /* Initialize empty GUI */ + requestGroupData(mChannelId); } GxsChannelDialog::~GxsChannelDialog() @@ -129,62 +117,53 @@ GxsChannelDialog::~GxsChannelDialog() processSettings(false); } - -void GxsChannelDialog::updateDisplay() +void GxsChannelDialog::todo() { - if (!rsGxsChannels) - return; + QMessageBox::information(this, "Todo", + "Open points:
    " + "
  • Threaded load of messages" + "
  • Share key" + "
  • Restore channel keys" + "
  • Copy/navigate channel link" + "
  • Display count of unread messages" + "
  • Show/Edit channel details" + "
  • Set all as read" + "
  • Set read/unread status" + "
"); +} - std::list groupIds; - std::map > msgs; +void GxsChannelDialog::updateDisplay(bool complete) +{ + std::list &grpIds = getGrpIds(); + if (complete || !grpIds.empty()) { + /* Update channel list */ + insertChannels(); + } + if (!mChannelId.empty() && std::find(grpIds.begin(), grpIds.end(), mChannelId) != grpIds.end()) { + requestGroupData(mChannelId); + } - if (rsGxsChannels->updated(true, true)) + std::map > &msgs = getMsgIds(); + if (!msgs.empty()) { - /* update Forums List */ - - rsGxsChannels->groupsChanged(groupIds); - if(!groupIds.empty()) + std::map >::iterator mit = msgs.find(mChannelId); + if(mit != msgs.end()) { - // just always update. - insertChannels(); - //std::list::iterator it = std::find(groupIds.begin(), groupIds.end(), mChannelId); - - //if(it != groupIds.end()){ - // requestGroupSummary(); - // return; - //} - } - - rsGxsChannels->msgsChanged(msgs); - if(!msgs.empty()) - { - std::map >::iterator mit = msgs.find(mChannelId); - if(mit != msgs.end()) - { - requestPosts(mChannelId); - } + requestPosts(mChannelId); } } } - - - - - - // Callback from Widget->FeedHolder->ServiceDialog->CommentContainer->CommentDialog, -void GxsChannelDialog::openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title) +void GxsChannelDialog::openComments(uint32_t /*type*/, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title) { commentLoad(groupId, msgId, title); } - -UserNotify *GxsChannelDialog::getUserNotify(QObject *parent) -{ - return new ChannelUserNotify(parent); - return NULL; -} +//UserNotify *GxsChannelDialog::getUserNotify(QObject *parent) +//{ +// return new ChannelUserNotify(parent); +//} void GxsChannelDialog::processSettings(bool load) { @@ -214,7 +193,7 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) return; } - uint32_t subscribeFlags = ui.treeWidget->subscribeFlags(QString::fromStdString(mChannelId)); + uint32_t subscribeFlags = ui.treeWidget->subscribeFlags(QString::fromStdString(mChannelId)); QMenu contextMnu(this); @@ -233,7 +212,6 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) if (isSubscribed) { - QAction *setallasreadchannelAct = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Set all as read" ), &contextMnu); connect( setallasreadchannelAct , SIGNAL( triggered() ), this, SLOT( setAllAsReadClicked() ) ); contextMnu.addAction( setallasreadchannelAct ); @@ -254,7 +232,6 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu); connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) ); contextMnu.addAction( unsubscribechannelAct ); - } else { @@ -263,7 +240,6 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) contextMnu.addAction( subscribechannelAct ); } - if (isAdmin) { QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu); @@ -296,7 +272,6 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) contextMnu.exec(QCursor::pos()); - #if 0 ChannelInfo ci; if (!rsChannels->getChannelInfo(mChannelId, ci)) { @@ -322,7 +297,7 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) QAction *autochannelAct = autoDl? (new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu)) : (new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu)) ; - + connect( autochannelAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) ); QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu); @@ -337,33 +312,33 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu); connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); - if((ci.channelFlags & RS_DISTRIB_ADMIN) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) + if((ci.channelFlags & RS_DISTRIB_ADMIN) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) contextMnu.addAction( editChannelDetailAct); - else + else contextMnu.addAction( channeldetailsAct ); if((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) - { - contextMnu.addAction( postchannelAct ); - contextMnu.addAction( shareKeyAct ); - } + { + contextMnu.addAction( postchannelAct ); + contextMnu.addAction( shareKeyAct ); + } - if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED) - { - contextMnu.addAction( unsubscribechannelAct ); - contextMnu.addAction( restoreKeysAct ); - contextMnu.addSeparator(); - contextMnu.addAction( autochannelAct ); - contextMnu.addAction( setallasreadchannelAct ); - } - else + if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED) + { + contextMnu.addAction( unsubscribechannelAct ); + contextMnu.addAction( restoreKeysAct ); + contextMnu.addSeparator(); + contextMnu.addAction( autochannelAct ); + contextMnu.addAction( setallasreadchannelAct ); + } + else contextMnu.addAction( subscribechannelAct ); - contextMnu.addSeparator(); + contextMnu.addSeparator(); QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink())); action->setEnabled(!mChannelId.empty()); -#ifdef CHAN_DEBUG +#ifdef DEBUG_CHANNEL contextMnu.addSeparator(); action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData())); action->setEnabled (!mChannelId.empty() && (ci.channelFlags & RS_DISTRIB_PUBLISH)); @@ -372,7 +347,6 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) contextMnu.exec(QCursor::pos()); #endif - } void GxsChannelDialog::createChannel() @@ -396,12 +370,11 @@ void GxsChannelDialog::deleteFeedItem(QWidget * /*item*/, uint32_t /*type*/) void GxsChannelDialog::openChat(std::string /*peerId*/) { - } void GxsChannelDialog::editChannelDetail() { -#if 0 +#if 0 EditChanDetails editUi(this, mChannelId); editUi.exec(); #endif @@ -413,12 +386,10 @@ void GxsChannelDialog::shareKey() ShareKey shareUi(this, mChannelId, CHANNEL_KEY_SHARE); shareUi.exec(); #endif - } void GxsChannelDialog::copyChannelLink() { - #if 0 if (mChannelId.empty()) { return; @@ -434,29 +405,28 @@ void GxsChannelDialog::copyChannelLink() } } #endif - } void GxsChannelDialog::createMsg() { if (mChannelId.empty()) { - return; + return; } CreateGxsChannelMsg *msgDialog = new CreateGxsChannelMsg(mChannelId); msgDialog->show(); + + /* window will destroy itself! */ } void GxsChannelDialog::restoreChannelKeys() { - #if 0 if(rsChannels->channelRestoreKeys(mChannelId)) QMessageBox::information(NULL,tr("Publish rights restored."),tr("Publish rights have been restored for this channel.")) ; else QMessageBox::warning(NULL,tr("Publish not restored."),tr("Publish rights can't be restored for this channel.
You're not the creator of this channel.")) ; #endif - } void GxsChannelDialog::selectChannel(const QString &id) @@ -466,25 +436,17 @@ void GxsChannelDialog::selectChannel(const QString &id) bool autoDl = rsGxsChannels->getChannelAutoDownload(mChannelId); setAutoDownloadButton(autoDl); + requestGroupData(mChannelId); requestPosts(mChannelId); - //updateChannelMsgs(); -} - -void GxsChannelDialog::forceUpdateDisplay() -{ - std::cerr << "GxsChannelDialog::forceUpdateDisplay()"; - std::cerr << std::endl; - - insertChannels(); } static void channelInfoToGroupItemInfo(const RsGroupMetaData &channelInfo, GroupItemInfo &groupItemInfo) { - groupItemInfo.id = QString::fromStdString(channelInfo.mGroupId); - groupItemInfo.name = QString::fromUtf8(channelInfo.mGroupName.c_str()); - groupItemInfo.popularity = channelInfo.mPop; - groupItemInfo.lastpost = QDateTime::fromTime_t(channelInfo.mLastPost); - groupItemInfo.subscribeFlags = channelInfo.mSubscribeFlags; + groupItemInfo.id = QString::fromStdString(channelInfo.mGroupId); + groupItemInfo.name = QString::fromUtf8(channelInfo.mGroupName.c_str()); + groupItemInfo.popularity = channelInfo.mPop; + groupItemInfo.lastpost = QDateTime::fromTime_t(channelInfo.mLastPost); + groupItemInfo.subscribeFlags = channelInfo.mSubscribeFlags; QPixmap chanImage = QPixmap(CHAN_DEFAULT_IMAGE); groupItemInfo.icon = QIcon(chanImage); @@ -492,7 +454,7 @@ static void channelInfoToGroupItemInfo(const RsGroupMetaData &channelInfo, Group void GxsChannelDialog::insertChannelData(const std::list &channelList) { - std::list::const_iterator it; + std::list::const_iterator it; QList adminList; QList subList; @@ -548,7 +510,7 @@ void GxsChannelDialog::insertChannelData(const std::list &chann } } - /* now we have our lists ---> update entries */ + /* now we have our lists ---> update entries */ ui.treeWidget->fillGroupItems(ownChannels, adminList); ui.treeWidget->fillGroupItems(subcribedChannels, subList); @@ -558,15 +520,13 @@ void GxsChannelDialog::insertChannelData(const std::list &chann updateMessageSummaryList(""); } - -void GxsChannelDialog::channelMsgReadSatusChanged(const QString& channelId, const QString& /*msgId*/, int /*status*/) -{ - updateMessageSummaryList(channelId.toStdString()); -} +//void GxsChannelDialog::channelMsgReadSatusChanged(const QString& channelId, const QString& /*msgId*/, int /*status*/) +//{ +// updateMessageSummaryList(channelId.toStdString()); +//} void GxsChannelDialog::updateMessageSummaryList(const std::string &channelId) { - #if 0 QTreeWidgetItem *items[2] = { ownChannels, subcribedChannels }; @@ -596,7 +556,6 @@ void GxsChannelDialog::updateMessageSummaryList(const std::string &channelId) } } #endif - } #if 0 @@ -606,11 +565,63 @@ static bool sortChannelMsgSummary(const ChannelMsgSummary &msg1, const ChannelMs } #endif + +void GxsChannelDialog::insertChannelDetails(const RsGxsChannelGroup &group) +{ + /* IMAGE */ + QPixmap chanImage; + if (group.mImage.mData != NULL) { + chanImage.loadFromData(group.mImage.mData, group.mImage.mSize, "PNG"); + } else { + chanImage = QPixmap(CHAN_DEFAULT_IMAGE); + } + ui.logoLabel->setPixmap(chanImage); + + /* set Channel name */ + ui.nameLabel->setText(QString::fromUtf8(group.mMeta.mGroupName.c_str())); + + if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH) + { + mStateHelper->setWidgetEnabled(ui.postButton, true); + } + else + { + mStateHelper->setWidgetEnabled(ui.postButton, false); + } + + if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED) + { + ui.actionEnable_Auto_Download->setEnabled(true); + } + else + { + ui.actionEnable_Auto_Download->setEnabled(false); + } +} + +void GxsChannelDialog::insertChannelPosts(const std::vector &posts) +{ + std::vector::const_iterator it; + + // Do these need sorting? probably. + // can we add that into the request? + //msgs.sort(sortChannelMsgSummary); + + uint32_t subscribeFlags = 0xffffffff; + + for (it = posts.begin(); it != posts.end(); it++) + { + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, *it, subscribeFlags, true); + mChannelPostItems.push_back(item); + ui.verticalLayout->addWidget(item); + } +} + #if 0 void GxsChannelDialog::updateChannelMsgs() { if (fillThread) { -#ifdef CHAN_DEBUG +#ifdef DEBUG_CHANNEL std::cerr << "GxsChannelDialog::updateChannelMsgs() stop current fill thread" << std::endl; #endif // stop current fill thread @@ -680,7 +691,7 @@ void GxsChannelDialog::updateChannelMsgs() connect(fillThread, SIGNAL(finished()), this, SLOT(fillThreadFinished()), Qt::BlockingQueuedConnection); connect(fillThread, SIGNAL(addMsg(QString,QString,int,int)), this, SLOT(fillThreadAddMsg(QString,QString,int,int)), Qt::BlockingQueuedConnection); -#ifdef CHAN_DEBUG +#ifdef DEBUG_CHANNEL std::cerr << "GxsChannelDialog::updateChannelMsgs() Start fill thread" << std::endl; #endif @@ -703,7 +714,7 @@ void GxsChannelDialog::updateChannelMsgs() void GxsChannelDialog::fillThreadFinished() { -#ifdef CHAN_DEBUG +#ifdef DEBUG_CHANNEL std::cerr << "GxsChannelDialog::fillThreadFinished()" << std::endl; #endif @@ -717,14 +728,14 @@ void GxsChannelDialog::fillThreadFinished() fillThread = NULL; } -#ifdef CHAN_DEBUG +#ifdef DEBUG_CHANNEL if (thread->wasStopped()) { // thread was stopped std::cerr << "GxsChannelDialog::fillThreadFinished() Thread was stopped" << std::endl; } #endif -#ifdef CHAN_DEBUG +#ifdef DEBUG_CHANNEL std::cerr << "GxsChannelDialog::fillThreadFinished() Delete thread" << std::endl; #endif @@ -732,7 +743,7 @@ void GxsChannelDialog::fillThreadFinished() thread = NULL; } -#ifdef CHAN_DEBUG +#ifdef DEBUG_CHANNEL std::cerr << "GxsChannelDialog::fillThreadFinished done()" << std::endl; #endif } @@ -758,36 +769,34 @@ void GxsChannelDialog::fillThreadAddMsg(const QString &channelId, const QString #endif - void GxsChannelDialog::unsubscribeChannel() { -#ifdef CHAN_DEBUG +#ifdef DEBUG_CHANNEL std::cerr << "GxsChannelDialog::unsubscribeChannel()"; std::cerr << std::endl; #endif - if(mChannelId.empty()) + if (mChannelId.empty()) return; uint32_t token = 0; rsGxsChannels->subscribeToGroup(token, mChannelId, false); - mChannelQueue->queueRequest(token, 0 , RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_GROUP_CHANGE); + mChannelQueue->queueRequest(token, 0 , RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_GROUP_CHANGE); } - void GxsChannelDialog::subscribeChannel() { -#ifdef CHAN_DEBUG +#ifdef DEBUG_CHANNEL std::cerr << "GxsChannelDialog::subscribeChannel()"; std::cerr << std::endl; #endif - if(mChannelId.empty()) + if (mChannelId.empty()) return; uint32_t token = 0; rsGxsChannels->subscribeToGroup(token, mChannelId, true); - mChannelQueue->queueRequest(token, 0 , RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_GROUP_CHANGE); + mChannelQueue->queueRequest(token, 0 , RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_GROUP_CHANGE); } void GxsChannelDialog::showChannelDetails() @@ -806,7 +815,6 @@ void GxsChannelDialog::showChannelDetails() channelui.showDetails(mChannelId); channelui.exec(); #endif - } void GxsChannelDialog::setAllAsReadClicked() @@ -840,13 +848,10 @@ void GxsChannelDialog::setAllAsReadClicked() void GxsChannelDialog::toggleAutoDownload() { - if(mChannelId.empty()) + if (mChannelId.empty()) return; - bool autoDl = true; - - - autoDl = rsGxsChannels->getChannelAutoDownload(mChannelId); + bool autoDl = rsGxsChannels->getChannelAutoDownload(mChannelId); if (rsGxsChannels->setChannelAutoDownload(mChannelId, !autoDl)) { setAutoDownloadButton(!autoDl); @@ -860,7 +865,6 @@ void GxsChannelDialog::toggleAutoDownload() bool GxsChannelDialog::navigate(const std::string& channelId, const std::string& msgId) { - #if 0 if (channelId.empty()) { return false; @@ -906,8 +910,6 @@ void GxsChannelDialog::setAutoDownloadButton(bool autoDl) } } - - /********************************************************************************************** * New Stuff here. *************/ @@ -918,155 +920,185 @@ void GxsChannelDialog::setAutoDownloadButton(bool autoDl) void GxsChannelDialog::insertChannels() { - requestGroupSummary(); + requestGroupSummary(); } void GxsChannelDialog::requestGroupSummary() { - std::cerr << "GxsChannelDialog::requestGroupSummary()"; - std::cerr << std::endl; + mStateHelper->setLoading(TOKEN_TYPE_LISTING, true); - std::list tokens; - mChannelQueue->activeRequestTokens(TOKEN_TYPE_LISTING, tokens); - if (!tokens.empty()) { - std::list::iterator tokenIt; - for (tokenIt = tokens.begin(); tokenIt != tokens.end(); ++tokenIt) { - std::cerr << "GxsChannelDialog::requestGroupSummary() Canceling Request: " << *tokenIt; - std::cerr << std::endl; +#ifdef DEBUG_CHANNEL + std::cerr << "GxsChannelDialog::requestGroupSummary()"; + std::cerr << std::endl; +#endif - mChannelQueue->cancelRequest(*tokenIt); - } - } + mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_LISTING); - RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; - uint32_t token; - mChannelQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_LISTING); + uint32_t token; + mChannelQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_LISTING); } void GxsChannelDialog::loadGroupSummary(const uint32_t &token) { - std::cerr << "GxsChannelDialog::loadGroupSummary()"; - std::cerr << std::endl; +#ifdef DEBUG_CHANNEL + std::cerr << "GxsChannelDialog::loadGroupSummary()"; + std::cerr << std::endl; +#endif - std::list groupInfo; - rsGxsChannels->getGroupSummary(token, groupInfo); + std::list groupInfo; + rsGxsChannels->getGroupSummary(token, groupInfo); - if (groupInfo.size() > 0) - { - insertChannelData(groupInfo); - } - else - { - std::cerr << "GxsChannelDialog::loadGroupSummary() ERROR No Groups..."; - std::cerr << std::endl; - } + if (groupInfo.size() > 0) + { + mStateHelper->setActive(TOKEN_TYPE_LISTING, true); + + insertChannelData(groupInfo); + } + else + { + std::cerr << "GxsChannelDialog::loadGroupSummary() ERROR No Groups..."; + std::cerr << std::endl; + + mStateHelper->setActive(TOKEN_TYPE_LISTING, false); + mStateHelper->clear(TOKEN_TYPE_LISTING); + } + + mStateHelper->setLoading(TOKEN_TYPE_LISTING, false); } - void GxsChannelDialog::requestGroupData(const RsGxsGroupId &grpId) { - std::cerr << "GxsChannelDialog::requestGroupData()"; - std::cerr << std::endl; +#ifdef DEBUG_CHANNEL + std::cerr << "GxsChannelDialog::requestGroupData()"; + std::cerr << std::endl; +#endif - std::list tokens; - mChannelQueue->activeRequestTokens(TOKEN_TYPE_GROUP_DATA, tokens); - if (!tokens.empty()) { - std::list::iterator tokenIt; - for (tokenIt = tokens.begin(); tokenIt != tokens.end(); ++tokenIt) { - std::cerr << "GxsChannelDialog::requestGroupData() Canceling Request: " << *tokenIt; - std::cerr << std::endl; + mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUP_DATA); - mChannelQueue->cancelRequest(*tokenIt); - } - } + if (grpId.empty()) { + mStateHelper->setActive(TOKEN_TYPE_GROUP_DATA, false); + mStateHelper->setLoading(TOKEN_TYPE_GROUP_DATA, false); + mStateHelper->clear(TOKEN_TYPE_GROUP_DATA); + + ui.nameLabel->setText(tr("No Channel Selected")); + ui.logoLabel->setPixmap(QPixmap(":/images/channels.png")); + + return; + } + + mStateHelper->setLoading(TOKEN_TYPE_GROUP_DATA, true); std::list groupIds; groupIds.push_back(grpId); - RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; - - uint32_t token; - mChannelQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_GROUP_DATA); + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; + uint32_t token; + mChannelQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_GROUP_DATA); } void GxsChannelDialog::loadGroupData(const uint32_t &token) { - std::cerr << "GxsChannelDialog::loadGroupData()"; - std::cerr << std::endl; +#ifdef DEBUG_CHANNEL + std::cerr << "GxsChannelDialog::loadGroupData()"; + std::cerr << std::endl; +#endif std::vector groups; rsGxsChannels->getGroupData(token, groups); - if (groups.size() == 1) - { - insertChannelDetails(groups[0]); - } - else - { - std::cerr << "GxsChannelDialog::loadGroupData() ERROR Not just one Group"; - std::cerr << std::endl; - } -} + mStateHelper->setLoading(TOKEN_TYPE_GROUP_DATA, false); + if (groups.size() == 1) + { + mStateHelper->setActive(TOKEN_TYPE_GROUP_DATA, true); + + insertChannelDetails(groups[0]); + } + else + { + std::cerr << "GxsChannelDialog::loadGroupData() ERROR Not just one Group"; + std::cerr << std::endl; + + mStateHelper->setActive(TOKEN_TYPE_GROUP_DATA, false); + mStateHelper->clear(TOKEN_TYPE_GROUP_DATA); + } +} void GxsChannelDialog::requestPosts(const RsGxsGroupId &grpId) { - std::cerr << "GxsChannelDialog::requestPosts()"; - std::cerr << std::endl; +#ifdef DEBUG_CHANNEL + std::cerr << "GxsChannelDialog::requestPosts()"; + std::cerr << std::endl; +#endif - std::list tokens; - mChannelQueue->activeRequestTokens(TOKEN_TYPE_POSTS, tokens); - if (!tokens.empty()) { - std::list::iterator tokenIt; - for (tokenIt = tokens.begin(); tokenIt != tokens.end(); ++tokenIt) { - std::cerr << "GxsChannelDialog::requestPosts() Canceling Request: " << *tokenIt; - std::cerr << std::endl; + /* replace all the messages with new ones */ + QList::iterator mit; + for (mit = mChannelPostItems.begin(); mit != mChannelPostItems.end(); mit++) { + delete (*mit); + } + mChannelPostItems.clear(); - mChannelQueue->cancelRequest(*tokenIt); - } - } + mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_POSTS); + + if (grpId.empty()) { + mStateHelper->setActive(TOKEN_TYPE_POSTS, false); + mStateHelper->setLoading(TOKEN_TYPE_POSTS, false); + mStateHelper->clear(TOKEN_TYPE_POSTS); + return; + } + + mStateHelper->setLoading(TOKEN_TYPE_POSTS, true); std::list groupIds; groupIds.push_back(grpId); - RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; - uint32_t token; - mChannelQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_POSTS); + uint32_t token; + mChannelQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_POSTS); } void GxsChannelDialog::loadPosts(const uint32_t &token) { - std::cerr << "GxsChannelDialog::loadPosts()"; - std::cerr << std::endl; +#ifdef DEBUG_CHANNEL + std::cerr << "GxsChannelDialog::loadPosts()"; + std::cerr << std::endl; +#endif std::vector posts; rsGxsChannels->getPostData(token, posts); - insertChannelPosts(posts); -} + mStateHelper->setActive(TOKEN_TYPE_POSTS, true); + insertChannelPosts(posts); + + mStateHelper->setLoading(TOKEN_TYPE_POSTS, false); +} void GxsChannelDialog::acknowledgeGroupUpdate(const uint32_t &token) { - std::cerr << "GxsChannelDialog::acknowledgeGroupUpdate()"; - std::cerr << std::endl; +#ifdef DEBUG_CHANNEL + std::cerr << "GxsChannelDialog::acknowledgeGroupUpdate()"; + std::cerr << std::endl; +#endif RsGxsGroupId grpId; rsGxsChannels->acknowledgeGrp(token, grpId); insertChannels(); } - void GxsChannelDialog::acknowledgeMessageUpdate(const uint32_t &token) { - std::cerr << "GxsChannelDialog::acknowledgeMessageUpdate() TODO"; - std::cerr << std::endl; +#ifdef DEBUG_CHANNEL + std::cerr << "GxsChannelDialog::acknowledgeMessageUpdate() TODO"; + std::cerr << std::endl; +#endif std::pair msgId; rsGxsChannels->acknowledgeMsg(token, msgId); @@ -1076,110 +1108,37 @@ void GxsChannelDialog::acknowledgeMessageUpdate(const uint32_t &token) } } - void GxsChannelDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req) { - std::cerr << "GxsChannelDialog::loadRequest() UserType: " << req.mUserType; - std::cerr << std::endl; +#ifdef DEBUG_CHANNEL + std::cerr << "GxsChannelDialog::loadRequest() UserType: " << req.mUserType; + std::cerr << std::endl; +#endif - if (queue == mChannelQueue) - { - /* now switch on req */ - switch(req.mUserType) - { - case TOKEN_TYPE_GROUP_CHANGE: - acknowledgeGroupUpdate(req.mToken); - break; - case TOKEN_TYPE_MESSAGE_CHANGE: - acknowledgeMessageUpdate(req.mToken); - break; - case TOKEN_TYPE_LISTING: - loadGroupSummary(req.mToken); - break; - case TOKEN_TYPE_GROUP_DATA: - loadGroupData(req.mToken); - break; - case TOKEN_TYPE_POSTS: - loadPosts(req.mToken); - break; - default: - std::cerr << "GxsChannelDialog::loadRequest() ERROR: INVALID TYPE"; - std::cerr << std::endl; - break; - } - } -} - - -void GxsChannelDialog::insertChannelDetails(const RsGxsChannelGroup &group) -{ - /* replace all the messages with new ones */ - QList::iterator mit; - for (mit = mChannelPostItems.begin(); mit != mChannelPostItems.end(); mit++) { - delete (*mit); - } - - mChannelPostItems.clear(); - - /* IMAGE */ - QPixmap chanImage; - if (group.mImage.mData != NULL) { - chanImage.loadFromData(group.mImage.mData, group.mImage.mSize, "PNG"); - } else { - chanImage = QPixmap(CHAN_DEFAULT_IMAGE); - } - ui.logoLabel->setPixmap(chanImage); - ui.logoLabel->setEnabled(true); - - /* set Channel name */ - ui.nameLabel->setText(QString::fromUtf8(group.mMeta.mGroupName.c_str())); - - if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH) + if (queue == mChannelQueue) { - ui.postButton->setEnabled(true); - } - else - { - ui.postButton->setEnabled(false); - } - - if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED) - { - ui.actionEnable_Auto_Download->setEnabled(true); - } - else - { - ui.actionEnable_Auto_Download->setEnabled(false); + /* now switch on req */ + switch(req.mUserType) + { + case TOKEN_TYPE_GROUP_CHANGE: + acknowledgeGroupUpdate(req.mToken); + break; + case TOKEN_TYPE_MESSAGE_CHANGE: + acknowledgeMessageUpdate(req.mToken); + break; + case TOKEN_TYPE_LISTING: + loadGroupSummary(req.mToken); + break; + case TOKEN_TYPE_GROUP_DATA: + loadGroupData(req.mToken); + break; + case TOKEN_TYPE_POSTS: + loadPosts(req.mToken); + break; + default: + std::cerr << "GxsChannelDialog::loadRequest() ERROR: INVALID TYPE"; + std::cerr << std::endl; + break; + } } } - - - -void GxsChannelDialog::insertChannelPosts(const std::vector &posts) -{ - std::vector::const_iterator it; - - // Do these need sorting? probably. - // can we add that into the request? - //msgs.sort(sortChannelMsgSummary); - - /* replace all the messages with new ones */ - QList::iterator mit; - for (mit = mChannelPostItems.begin(); mit != mChannelPostItems.end(); mit++) { - delete (*mit); - } - mChannelPostItems.clear(); - - uint32_t subscribeFlags = 0xffffffff; - - for (it = posts.begin(); it != posts.end(); it++) - { - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, *it, subscribeFlags, true); - mChannelPostItems.push_back(item); - ui.verticalLayout->addWidget(item); - } -} - - - - diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h index a0f09932c..49ac28dbc 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h @@ -22,14 +22,9 @@ #ifndef _GXS_CHANNEL_DIALOG_H #define _GXS_CHANNEL_DIALOG_H -#include - -#include -#include #include -#include "mainpage.h" -#include "RsAutoUpdatePage.h" +#include "gui/gxs/RsGxsUpdateBroadcastPage.h" #include "ui_GxsChannelDialog.h" @@ -41,9 +36,9 @@ //class ChanMsgItem; class GxsChannelPostItem; class QTreeWidgetItem; +class UIStateHelper; -class GxsChannelDialog : public RsAutoUpdatePage, public TokenResponse, public GxsServiceDialog, - public FeedHolder +class GxsChannelDialog : public RsGxsUpdateBroadcastPage, public TokenResponse, public GxsServiceDialog, public FeedHolder { Q_OBJECT @@ -53,7 +48,7 @@ public: /** Default Destructor */ ~GxsChannelDialog(); - virtual UserNotify *getUserNotify(QObject *parent); +// virtual UserNotify *getUserNotify(QObject *parent); /* FeedHolder */ virtual QScrollArea *getScrollArea(); @@ -63,16 +58,15 @@ public: bool navigate(const std::string& channelId, const std::string& msgId); - /* overloaded from RsAuthUpdatePage */ - virtual void updateDisplay(); - - /* NEW GXS FNS */ void loadRequest(const TokenQueue *queue, const TokenRequest &req); +protected: + virtual void updateDisplay(bool complete); private slots: - void channelListCustomPopupMenu( QPoint point ); + void todo(); + void channelListCustomPopupMenu(QPoint point); void selectChannel(const QString &id); void createChannel(); @@ -90,18 +84,13 @@ private slots: void shareKey(); void copyChannelLink(); - void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status); +// void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status); //void generateMassData(); //void fillThreadFinished(); //void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count); - /* NEW GXS FNS */ - void forceUpdateDisplay(); - - - private: //void updateChannelList(); //void updateChannelMsgs(); @@ -134,7 +123,6 @@ private: std::string mChannelId; /* current Channel */ TokenQueue *mChannelQueue; - /* Layout Pointers */ QBoxLayout *mMsgLayout; @@ -148,6 +136,8 @@ private: QTreeWidgetItem *popularChannels; QTreeWidgetItem *otherChannels; + UIStateHelper *mStateHelper; + /* UI - from Designer */ Ui::GxsChannelDialog ui; }; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.ui index c5c10263e..c45264419 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.ui @@ -54,7 +54,7 @@ - :/images/channels32.png + :/images/channels32.png true @@ -89,9 +89,9 @@ - + - refresh + Todo @@ -104,7 +104,7 @@ Display - + :/images/looknfeel.png:/images/looknfeel.png @@ -133,7 +133,7 @@ Create Channel - + :/images/add_channel24.png:/images/add_channel24.png @@ -194,7 +194,7 @@ - :/images/channels.png + :/images/channels.png true @@ -236,7 +236,7 @@ 0 0 - 380 + 362 16 @@ -299,7 +299,7 @@ Post to Channel - + :/images/mail_send.png:/images/mail_send.png @@ -360,7 +360,7 @@ - + diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp index fe4ccec16..e0b73142a 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp @@ -25,7 +25,7 @@ #include // To start with we only have open forums - with distribution controls. - + const uint32_t ChannelCreateEnabledFlags = ( GXS_GROUP_FLAGS_ICON | GXS_GROUP_FLAGS_DESCRIPTION | GXS_GROUP_FLAGS_DISTRIBUTION | @@ -38,16 +38,16 @@ const uint32_t ChannelCreateEnabledFlags = ( GXS_GROUP_FLAGS_ICON | const uint32_t ChannelCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC | //GXS_GROUP_DEFAULTS_DISTRIB_GROUP | //GXS_GROUP_DEFAULTS_DISTRIB_LOCAL | - + GXS_GROUP_DEFAULTS_PUBLISH_OPEN | //GXS_GROUP_DEFAULTS_PUBLISH_THREADS | //GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED | //GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED | - + //GXS_GROUP_DEFAULTS_PERSONAL_GPG | GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED | //GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB | - + GXS_GROUP_DEFAULTS_COMMENTS_YES | //GXS_GROUP_DEFAULTS_COMMENTS_NO | 0); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index c6eea5203..4b83a10b4 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -309,9 +309,9 @@ void GxsForumThreadWidget::changeEvent(QEvent *e) } } -void GxsForumThreadWidget::updateDisplay(bool initialFill) +void GxsForumThreadWidget::updateDisplay(bool complete) { - if (initialFill) { + if (complete) { /* Not needed */ return; } diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index fca9c51e2..f55773c1d 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -61,7 +61,7 @@ signals: protected: bool eventFilter(QObject *obj, QEvent *ev); void changeEvent(QEvent *e); - virtual void updateDisplay(bool initialFill); + virtual void updateDisplay(bool complete); private slots: /** Create the context popup menu and it's submenus */ diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index 02ff14fd6..ddafb9439 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -257,10 +257,12 @@ void GxsForumsDialog::restoreForumKeys(void) #endif } -void GxsForumsDialog::updateDisplay(bool /*initialFill*/) +void GxsForumsDialog::updateDisplay(bool complete) { - /* Update forums list */ - insertForums(); + if (complete || !getGrpIds().empty()) { + /* Update forums list */ + insertForums(); + } } void GxsForumsDialog::forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo, GroupItemInfo &groupItemInfo) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h index 0520cbc53..7aa3c3b58 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h @@ -55,7 +55,7 @@ public: virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); protected: - virtual void updateDisplay(bool initialFill); + virtual void updateDisplay(bool complete); private slots: void settingsChanged(); diff --git a/retroshare-gui/src/lang/retroshare_en.ts b/retroshare-gui/src/lang/retroshare_en.ts index de6c7df58..42ba6f4b0 100644 --- a/retroshare-gui/src/lang/retroshare_en.ts +++ b/retroshare-gui/src/lang/retroshare_en.ts @@ -5039,10 +5039,6 @@ p, li { white-space: pre-wrap; } Message Group - - Add Friend - - Edit Group @@ -5051,10 +5047,6 @@ p, li { white-space: pre-wrap; } Remove Group - - Chat lobbies - - Chat @@ -5071,10 +5063,6 @@ p, li { white-space: pre-wrap; } Recommend this Friend to... - - Connect To Friend - - Copy certificate link @@ -5115,26 +5103,6 @@ p, li { white-space: pre-wrap; } Remove from all groups - - Create new - - - - Invite this group - - - - Invite this friend - - - - Show - - - - Unsubscribe - - Expand all @@ -5151,22 +5119,10 @@ p, li { white-space: pre-wrap; } Do you want to remove this Friend? - - Unsubscribe to lobby - - - - You are about to unsubscribe a chat lobby<br>You can only re-enter if your friends invite you again. - - Columns - - Sort by - - IP @@ -5179,6 +5135,22 @@ p, li { white-space: pre-wrap; } Show IP Column + + Attempt to connect + + + + Create new group + + + + Recommend many friends to each others + + + + Service permissions matrix + + FriendRecommendDialog @@ -5255,10 +5227,6 @@ p, li { white-space: pre-wrap; } Display - - Add - - Edit status message @@ -5375,10 +5343,6 @@ p, li { white-space: pre-wrap; } Local network - - Known people - - Welcome to RetroShare's group chat. @@ -5411,6 +5375,10 @@ p, li { white-space: pre-wrap; } Text File (*.txt );;All Files (*) + + Keyring + + GamesDialog @@ -6254,10 +6222,6 @@ p, li { white-space: pre-wrap; } Channels - - refresh - - Display @@ -6350,6 +6314,10 @@ p, li { white-space: pre-wrap; } No Channel Selected + + Todo + + GxsChannelGroupDialog @@ -8902,10 +8870,6 @@ Do you want to save message ? Search Network - - Show all accessible keys - - Name @@ -9112,6 +9076,10 @@ Right-click and select 'make friend' to be able to connect. Data inconsistency in the keyring. This is most probably a bug. Please contact the developers. + + Only show people you trusted + + NetworkPage @@ -9176,6 +9144,10 @@ Right-click and select 'make friend' to be able to connect. This is a test. + + <h1><img width="32" src=":/images/64px_help.png">&nbsp;&nbsp;News Feed</h1> <p>The News Feed displays the last events on your network, sorted by the time you received them. This gives you a summary of the activity of your friends. You can configure which events to show by pressing on <b>Options</b>. </p> <p>The various events shown are: <ul> <li>Connection attempts (useful to make friends with new people and control who's trying to reach you)</li> <li>Channel and Forum posts</li> <li>New Channels and Forums you can subscribe to</li> <li>Private messages from your friends</li> </ul> </p> + + NotifyPage