void WikiDialog::groupListCustomPopupMenu(QPoint /*point*/) { int subscribeFlags = ui.groupTreeWidget->subscribeFlags(QString::fromStdString(mGroupId)); QMenu contextMnu(this); std::cerr << "WikiDialog::groupListCustomPopupMenu()"; std::cerr << std::endl; std::cerr << " mGroupId: " << mGroupId; std::cerr << std::endl; std::cerr << " subscribeFlags: " << subscribeFlags; std::cerr << std::endl; std::cerr << " IS_GROUP_SUBSCRIBED(): " << IS_GROUP_SUBSCRIBED(subscribeFlags); std::cerr << std::endl; std::cerr << " IS_GROUP_ADMIN(): " << IS_GROUP_ADMIN(subscribeFlags); std::cerr << std::endl; std::cerr << std::endl; QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe to Group"), this, SLOT(subscribeToGroup())); action->setDisabled (mGroupId.empty() || IS_GROUP_SUBSCRIBED(subscribeFlags)); action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe to Group"), this, SLOT(unsubscribeToGroup())); action->setEnabled (!mGroupId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags)); contextMnu.addSeparator(); action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Wiki Group"), this, SLOT(showGroupDetails())); action->setEnabled (!mGroupId.empty ()); action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Wiki Group"), this, SLOT(editGroupDetails())); action->setEnabled (!mGroupId.empty() && IS_GROUP_ADMIN(subscribeFlags)); /************** NOT ENABLED YET *****************/ //if (!Settings->getForumOpenAllInNewTab()) { // action = contextMnu.addAction(QIcon(""), tr("Open in new tab"), this, SLOT(openInNewTab())); // if (mForumId.empty() || forumThreadWidget(mForumId)) { // action->setEnabled(false); // } //} //QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Forum"), &contextMnu); //connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); //shareKeyAct->setEnabled(!mForumId.empty() && IS_GROUP_ADMIN(subscribeFlags)); //contextMnu.addAction( shareKeyAct); //QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Forum" ), &contextMnu); //connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreForumKeys() ) ); //restoreKeysAct->setEnabled(!mForumId.empty() && !IS_GROUP_ADMIN(subscribeFlags)); //contextMnu.addAction( restoreKeysAct); //action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyForumLink())); //action->setEnabled(!mForumId.empty()); //contextMnu.addSeparator(); contextMnu.exec(QCursor::pos()); }
void GxsChannelPostsWidget::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); ui->subscribersLabel->setText(QString::number(group.mMeta.mPop)) ; if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH) { mStateHelper->setWidgetEnabled(ui->postButton, true); } else { mStateHelper->setWidgetEnabled(ui->postButton, false); } ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); bool autoDownload ; rsGxsChannels->getChannelAutoDownload(group.mMeta.mGroupId,autoDownload); setAutoDownload(autoDownload); if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) { ui->feedToolButton->setEnabled(true); ui->fileToolButton->setEnabled(true); ui->infoWidget->hide(); setViewMode(viewMode()); ui->infoPosts->clear(); ui->infoDescription->clear(); } else { ui->infoPosts->setText(QString::number(group.mMeta.mVisibleMsgCount)); ui->infoDescription->setText(QString::fromUtf8(group.mDescription.c_str())); ui->infoWidget->show(); ui->feedWidget->hide(); ui->fileWidget->hide(); ui->feedToolButton->setEnabled(false); ui->fileToolButton->setEnabled(false); } }
void WikiDialog::insertGroupsData(const std::list<RsGroupMetaData> &wikiList) { std::list<RsGroupMetaData>::const_iterator it; QList<GroupItemInfo> adminList; QList<GroupItemInfo> subList; QList<GroupItemInfo> popList; QList<GroupItemInfo> otherList; std::multimap<uint32_t, GroupItemInfo> popMap; for (it = wikiList.begin(); it != wikiList.end(); it++) { /* sort it into Publish (Own), Subscribed, Popular and Other */ uint32_t flags = it->mSubscribeFlags; GroupItemInfo groupItemInfo; GroupMetaDataToGroupItemInfo(*it, groupItemInfo); if (IS_GROUP_ADMIN(flags)) { adminList.push_back(groupItemInfo); } else if (IS_GROUP_SUBSCRIBED(flags)) { /* subscribed forum */ subList.push_back(groupItemInfo); } else { /* rate the others by popularity */ popMap.insert(std::make_pair(it->mPop, groupItemInfo)); } } /* iterate backwards through popMap - take the top 5 or 10% of list */ uint32_t popCount = 5; if (popCount < popMap.size() / 10) { popCount = popMap.size() / 10; } uint32_t i = 0; uint32_t popLimit = 0; std::multimap<uint32_t, GroupItemInfo>::reverse_iterator rit; for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++) ; if (rit != popMap.rend()) { popLimit = rit->first; } for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) { if (rit->second.popularity < (int) popLimit) { otherList.append(rit->second); } else { popList.append(rit->second); } } /* now we can add them in as a tree! */ ui.groupTreeWidget->fillGroupItems(mYourGroups, adminList); ui.groupTreeWidget->fillGroupItems(mSubscribedGroups, subList); ui.groupTreeWidget->fillGroupItems(mPopularGroups, popList); ui.groupTreeWidget->fillGroupItems(mOtherGroups, otherList); }
void GxsChannelPostsWidget::setAllMessagesReadDo(bool read, uint32_t &token) { if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(subscribeFlags())) { return; } GxsChannelPostsReadData data(read); ui->feedWidget->withAll(setAllMessagesReadCallback, &data); token = data.mLastToken; }
void PostedListWidget::newPost() { if (groupId().isNull()) return; if (!IS_GROUP_SUBSCRIBED(subscribeFlags())) { return; } PostedCreatePostDialog *cp = new PostedCreatePostDialog(mTokenQueue, rsPosted, groupId(), this); cp->show(); /* window will destroy itself! */ }
void GxsChannelPostsWidget::createMsg() { if (groupId().isNull()) { return; } if (!IS_GROUP_SUBSCRIBED(subscribeFlags())) { return; } CreateGxsChannelMsg *msgDialog = new CreateGxsChannelMsg(groupId()); msgDialog->show(); /* window will destroy itself! */ }
void PostedGroupItem::fill() { /* fill in */ #ifdef DEBUG_ITEM std::cerr << "PostedGroupItem::fill()"; std::cerr << std::endl; #endif // No link type at this moment RetroShareLink link; link.createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroup.mMeta.mGroupId, groupName()); ui->nameLabel->setText(link.toHtml()); // ui->nameLabel->setText(groupName()); ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str())); //TODO - nice icon for subscribed group if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) { ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png")); } else { ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png")); } if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) { ui->subscribeButton->setEnabled(false); } else { ui->subscribeButton->setEnabled(true); } // if (mIsNew) // { ui->titleLabel->setText(tr("New Posted")); // } // else // { // ui->titleLabel->setText(tr("Updated Posted")); // } if (mIsHome) { /* disable buttons */ ui->clearButton->setEnabled(false); } }
void GxsChannelDialog::insertChannelData(const std::list<RsGroupMetaData> &channelList) { std::list<RsGroupMetaData>::const_iterator it; QList<GroupItemInfo> adminList; QList<GroupItemInfo> subList; QList<GroupItemInfo> popList; QList<GroupItemInfo> otherList; std::multimap<uint32_t, GroupItemInfo> popMap; for(it = channelList.begin(); it != channelList.end(); it++) { /* sort it into Publish (Own), Subscribed, Popular and Other */ uint32_t flags = it->mSubscribeFlags; GroupItemInfo groupItemInfo; channelInfoToGroupItemInfo(*it, groupItemInfo); if (IS_GROUP_SUBSCRIBED(flags)) { if (IS_GROUP_ADMIN(flags) || IS_GROUP_PUBLISHER(flags)) { adminList.push_back(groupItemInfo); } else { /* subscribed forum */ subList.push_back(groupItemInfo); } } else { /* rate the others by popularity */ popMap.insert(std::make_pair(it->mPop, groupItemInfo)); } } /* iterate backwards through popMap - take the top 5 or 10% of list */ uint32_t popCount = 5; if (popCount < popMap.size() / 10) { popCount = popMap.size() / 10; } uint32_t i = 0; std::multimap<uint32_t, GroupItemInfo>::reverse_iterator rit; for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) { if (i < popCount) { popList.push_back(rit->second); i++; } else { otherList.push_back(rit->second); } } /* now we have our lists ---> update entries */ ui.treeWidget->fillGroupItems(ownChannels, adminList); ui.treeWidget->fillGroupItems(subcribedChannels, subList); ui.treeWidget->fillGroupItems(popularChannels, popList); ui.treeWidget->fillGroupItems(otherChannels, otherList); updateMessageSummaryList(""); }
void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) { if (mChannelId.empty()) { return; } uint32_t subscribeFlags = ui.treeWidget->subscribeFlags(QString::fromStdString(mChannelId)); QMenu contextMnu(this); bool isAdmin = IS_GROUP_ADMIN(subscribeFlags); bool isPublisher = IS_GROUP_PUBLISHER(subscribeFlags); bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags); bool autoDownload = rsGxsChannels->getChannelAutoDownload(mChannelId); if (isPublisher) { QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu); connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) ); contextMnu.addAction( postchannelAct ); contextMnu.addSeparator(); } 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 ); contextMnu.addSeparator(); QAction *autoAct = new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu); QAction *noautoAct = new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu); connect( autoAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) ); connect( noautoAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) ); contextMnu.addAction( autoAct ); contextMnu.addAction( noautoAct ); autoAct->setEnabled(autoDownload); noautoAct->setEnabled(!autoDownload); QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu); connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) ); contextMnu.addAction( unsubscribechannelAct ); } else { QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu); connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) ); contextMnu.addAction( subscribechannelAct ); } if (isAdmin) { QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu); connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) ); contextMnu.addAction( editChannelDetailAct); } else { QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu); connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) ); contextMnu.addAction( channeldetailsAct ); } if (isPublisher) { QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu); connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) ); contextMnu.addAction( restoreKeysAct ); } else { QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu); connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); contextMnu.addAction( shareKeyAct ); } contextMnu.addSeparator(); QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink())); action->setEnabled(!mChannelId.empty()); contextMnu.exec(QCursor::pos()); #if 0 ChannelInfo ci; if (!rsChannels->getChannelInfo(mChannelId, ci)) { return; } QMenu contextMnu(this); QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu); connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) ); QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu); connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) ); QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu); connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) ); QAction *setallasreadchannelAct = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Set all as read" ), &contextMnu); connect( setallasreadchannelAct , SIGNAL( triggered() ), this, SLOT( setAllAsReadClicked() ) ); bool autoDl = false; rsChannels->channelGetAutoDl(mChannelId, autoDl); QAction *autochannelAct = autoDl? (new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu)) : (new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu)) ; connect( autochannelAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) ); QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu); connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) ); QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu); connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) ); QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu); connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) ); QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu); connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); if((ci.channelFlags & RS_DISTRIB_ADMIN) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) contextMnu.addAction( editChannelDetailAct); else contextMnu.addAction( channeldetailsAct ); if((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) { contextMnu.addAction( postchannelAct ); contextMnu.addAction( shareKeyAct ); } if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED) { contextMnu.addAction( unsubscribechannelAct ); contextMnu.addAction( restoreKeysAct ); contextMnu.addSeparator(); contextMnu.addAction( autochannelAct ); contextMnu.addAction( setallasreadchannelAct ); } else contextMnu.addAction( subscribechannelAct ); contextMnu.addSeparator(); QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink())); action->setEnabled(!mChannelId.empty()); contextMnu.exec(QCursor::pos()); #endif }
void GxsChannelPostsWidget::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); ui->subscribersLabel->setText(QString::number(group.mMeta.mPop)) ; if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH) { mStateHelper->setWidgetEnabled(ui->postButton, true); } else { mStateHelper->setWidgetEnabled(ui->postButton, false); } ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); bool autoDownload ; rsGxsChannels->getChannelAutoDownload(group.mMeta.mGroupId,autoDownload); setAutoDownload(autoDownload); if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) { ui->feedToolButton->setEnabled(true); ui->fileToolButton->setEnabled(true); ui->infoWidget->hide(); setViewMode(viewMode()); ui->infoPosts->clear(); ui->infoDescription->clear(); } else { ui->infoPosts->setText(QString::number(group.mMeta.mVisibleMsgCount)); ui->infoDescription->setText(QString::fromUtf8(group.mDescription.c_str())); ui->infoAdministrator->setId(group.mMeta.mAuthorId) ; QString distrib_string ( "[unknown]" ); switch(group.mMeta.mCircleType) { case GXS_CIRCLE_TYPE_PUBLIC: distrib_string = tr("Public") ; break ; case GXS_CIRCLE_TYPE_EXTERNAL: { RsGxsCircleDetails det ; // !! What we need here is some sort of CircleLabel, which loads the circle and updates the label when done. if(rsGxsCircles->getCircleDetails(group.mMeta.mCircleId,det)) distrib_string = tr("Restricted to members of circle \"")+QString::fromUtf8(det.mCircleName.c_str()) +"\""; else distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ; } break ; case GXS_CIRCLE_TYPE_YOUR_EYES_ONLY: distrib_string = tr("Your eyes only"); break ; case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("You and your friend nodes"); break ; default: std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl; } ui->infoDistribution->setText(distrib_string); ui->infoWidget->show(); ui->feedWidget->hide(); ui->fileWidget->hide(); ui->feedToolButton->setEnabled(false); ui->fileToolButton->setEnabled(false); } }
void ForumHandler::handleWildcard(Request &req, Response &resp) { bool ok = true; if(!req.mPath.empty()) { std::string str = req.mPath.top(); req.mPath.pop(); if(str != "") { //assume we have a groupID RsGxsGroupId grpId(str); std::list<RsGxsGroupId> groupIds; groupIds.push_back(grpId); uint32_t token; RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; mRsGxsForums->getTokenService()->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds); time_t start = time(NULL); while((mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) &&(mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&((time(NULL) < (start+10))) ) { #ifdef WINDOWS_SYS Sleep(500); #else usleep(500*1000) ; #endif } if(mRsGxsForums->getTokenService()->requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) { std::vector<RsGxsForumMsg> grps; ok &= mRsGxsForums->getMsgData(token, grps); for(std::vector<RsGxsForumMsg>::iterator vit = grps.begin(); vit != grps.end(); vit++) { RsGxsForumMsg& grp = *vit; KeyValueReference<RsGxsGroupId> group_id("group_id", grp.mMeta.mGroupId); resp.mDataStream.getStreamToMember() << group_id << makeKeyValueReference("name", grp.mMeta.mMsgName) << makeKeyValueReference("id", grp.mMeta.mMsgId) << makeKeyValueReference("parent_id", grp.mMeta.mParentId) << makeKeyValueReference("author_id", grp.mMeta.mAuthorId) << makeKeyValueReference("orig_msg_id", grp.mMeta.mOrigMsgId) << makeKeyValueReference("thread_id", grp.mMeta.mThreadId) << makeKeyValueReference("message", grp.mMsg); } } else { ok = false; } } } else { // no more path element RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; uint32_t token; mRsGxsForums->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); time_t start = time(NULL); while((mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) &&(mRsGxsForums->getTokenService()->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) &&((time(NULL) < (start+10))) ) { #ifdef WINDOWS_SYS Sleep(500); #else usleep(500*1000) ; #endif } if(mRsGxsForums->getTokenService()->requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) { std::vector<RsGxsForumGroup> grps; ok &= mRsGxsForums->getGroupData(token, grps); for(std::vector<RsGxsForumGroup>::iterator vit = grps.begin(); vit != grps.end(); vit++) { RsGxsForumGroup& grp = *vit; KeyValueReference<RsGxsGroupId> id("id", grp.mMeta.mGroupId); KeyValueReference<uint32_t> vis_msg("visible_msg_count", grp.mMeta.mVisibleMsgCount); //KeyValueReference<RsPgpId> pgp_id("pgp_id",grp.mPgpId ); // not very happy about this, i think the flags should stay hidden in rsidentities bool own = (grp.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID); bool subscribed = IS_GROUP_SUBSCRIBED(grp.mMeta.mSubscribeFlags); resp.mDataStream.getStreamToMember() << id //<< pgp_id << makeKeyValueReference("name", grp.mMeta.mGroupName) //<< makeKeyValueReference("last_post", grp.mMeta.mLastPost) << makeKeyValueReference("pop", grp.mMeta.mPop) //<< makeKeyValueReference("publish_ts", grp.mMeta.mPublishTs) << vis_msg << makeKeyValueReference("group_status", grp.mMeta.mGroupStatus) << makeKeyValueReference("author_id", grp.mMeta.mAuthorId) << makeKeyValueReference("parent_grp_id", grp.mMeta.mParentGrpId) << makeKeyValueReference("description", grp.mDescription) << makeKeyValueReference("own", own) << makeKeyValueReference("subscribed", subscribed) << makeKeyValueReference("pgp_linked", pgp_linked); } } else { ok = false; } } if(ok) { resp.setOk(); } else { resp.setFail(); } }
void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/) { int subscribeFlags = ui.forumTreeWidget->subscribeFlags(QString::fromStdString(mForumId)); QMenu contextMnu(this); #ifdef DEBUG_FORUMS std::cerr << "GxsForumsDialog::forumListCustomPopupMenu()"; std::cerr << std::endl; std::cerr << " mForumId: " << mForumId; std::cerr << std::endl; std::cerr << " subscribeFlags: " << subscribeFlags; std::cerr << std::endl; std::cerr << " IS_GROUP_SUBSCRIBED(): " << IS_GROUP_SUBSCRIBED(subscribeFlags); std::cerr << std::endl; std::cerr << " IS_GROUP_ADMIN(): " << IS_GROUP_ADMIN(subscribeFlags); std::cerr << std::endl; std::cerr << std::endl; #endif QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe to Forum"), this, SLOT(subscribeToForum())); action->setDisabled (mForumId.empty() || IS_GROUP_SUBSCRIBED(subscribeFlags)); action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe to Forum"), this, SLOT(unsubscribeToForum())); action->setEnabled (!mForumId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags)); if (!Settings->getForumOpenAllInNewTab()) { action = contextMnu.addAction(QIcon(""), tr("Open in new tab"), this, SLOT(openInNewTab())); if (mForumId.empty() || forumThreadWidget(mForumId)) { action->setEnabled(false); } } contextMnu.addSeparator(); contextMnu.addAction(QIcon(IMAGE_NEWFORUM), tr("New Forum"), this, SLOT(newforum())); action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Forum Details"), this, SLOT(showForumDetails())); action->setEnabled (!mForumId.empty ()); action = contextMnu.addAction(QIcon(":/images/settings16.png"), tr("Edit Forum Details"), this, SLOT(editForumDetails())); action->setEnabled (!mForumId.empty () && IS_GROUP_ADMIN(subscribeFlags)); QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Forum"), &contextMnu); connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); shareKeyAct->setEnabled(!mForumId.empty() && IS_GROUP_ADMIN(subscribeFlags)); contextMnu.addAction( shareKeyAct); QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Forum" ), &contextMnu); connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreForumKeys() ) ); restoreKeysAct->setEnabled(!mForumId.empty() && !IS_GROUP_ADMIN(subscribeFlags)); contextMnu.addAction( restoreKeysAct); action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyForumLink())); action->setEnabled(!mForumId.empty()); contextMnu.addSeparator(); action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead())); action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread())); action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); contextMnu.exec(QCursor::pos()); }
void PostedListWidget::insertPostedDetails(const RsPostedGroup &group) { mStateHelper->setWidgetEnabled(ui->submitPostButton, IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); }
void GxsChannelPostItem::fill() { /* fill in */ if (isLoading()) { /* Wait for all requests */ return; } #ifdef DEBUG_ITEM std::cerr << "GxsChannelPostItem::fill()"; std::cerr << std::endl; #endif mInFill = true; QString title; if (!mIsHome) { if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { removeItem(); } title = tr("Channel Feed") + ": "; RetroShareLink link; link.createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, groupName()); title += link.toHtml(); ui->titleLabel->setText(title); RetroShareLink msgLink; msgLink.createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName()); ui->subjectLabel->setText(msgLink.toHtml()); if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags)) { ui->unsubscribeButton->setEnabled(true); } else { ui->unsubscribeButton->setEnabled(false); } ui->readButton->hide(); ui->newLabel->hide(); ui->copyLinkButton->hide(); if (IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { mCloseOnRead = true; } } else { /* subject */ ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); ui->subjectLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); //QString score = QString::number(post.mTopScore); // scoreLabel->setText(score); /* disable buttons: deletion facility not enabled with cache services yet */ ui->clearButton->setEnabled(false); ui->unsubscribeButton->setEnabled(false); ui->clearButton->hide(); ui->readAndClearButton->hide(); ui->unsubscribeButton->hide(); ui->copyLinkButton->show(); if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags)) { ui->readButton->setVisible(true); setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); } else { ui->readButton->setVisible(false); ui->newLabel->setVisible(false); } mCloseOnRead = false; } // differences between Feed or Top of Comment. if (mFeedHolder) { if (mIsHome) { ui->commentButton->show(); } else { ui->commentButton->hide(); } // THIS CODE IS doesn't compile - disabling until fixed. #if 0 if (post.mComments) { QString commentText = QString::number(post.mComments); commentText += " "; commentText += tr("Comments"); ui->commentButton->setText(commentText); } else { ui->commentButton->setText(tr("Comment")); } #endif } else { ui->commentButton->hide(); } // disable voting buttons - if they have already voted. /*if (post.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) { voteUpButton->setEnabled(false); voteDownButton->setEnabled(false); }*/ ui->msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); ui->msgFrame->setVisible(!mPost.mMsg.empty()); ui->datetimelabel->setText(DateTime::formatLongDateTime(mPost.mMeta.mPublishTs)); ui->filelabel->setText(QString("(%1 %2) %3").arg(mPost.mCount).arg(tr("Files")).arg(misc::friendlyUnit(mPost.mSize))); if (mFileItems.empty() == false) { std::list<SubFileItem *>::iterator it; for(it = mFileItems.begin(); it != mFileItems.end(); ++it) { delete(*it); } mFileItems.clear(); } std::list<RsGxsFile>::const_iterator it; for(it = mPost.mFiles.begin(); it != mPost.mFiles.end(); ++it) { /* add file */ std::string path; SubFileItem *fi = new SubFileItem(it->mHash, it->mName, path, it->mSize, SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, RsPeerId()); mFileItems.push_back(fi); /* check if the file is a media file */ if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->mName.c_str())).suffix())) { fi->mediatype(); /* check if the file is not a media file and change text */ ui->playButton->setText(tr("Open")); ui->playButton->setToolTip(tr("Open File")); } else { ui->playButton->setText(tr("Play")); ui->playButton->setToolTip(tr("Play Media")); } QLayout *layout = ui->expandFrame->layout(); layout->addWidget(fi); } if(mPost.mThumbnail.mData != NULL) { QPixmap thumbnail; thumbnail.loadFromData(mPost.mThumbnail.mData, mPost.mThumbnail.mSize, "PNG"); // Wiping data - as its been passed to thumbnail. ui->logoLabel->setPixmap(thumbnail); } mInFill = false; }
void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post) { /* fill in */ #ifdef DEBUG_ITEM std::cerr << "GxsChannelPostItem::loadPost()"; std::cerr << std::endl; #endif m_inUpdateItemStatic = true; mPost = post; QString title; if (!mIsHome) { title = tr("Channel Feed") + ": "; RetroShareLink link; link.createChannel(post.mMeta.mGroupId, ""); title += link.toHtml(); titleLabel->setText(title); RetroShareLink msgLink; msgLink.createChannel(post.mMeta.mGroupId, post.mMeta.mMsgId); subjectLabel->setText(msgLink.toHtml()); if (IS_GROUP_SUBSCRIBED(mSubscribeFlags) || IS_GROUP_ADMIN(mSubscribeFlags)) { unsubscribeButton->setEnabled(true); } else { unsubscribeButton->setEnabled(false); } readButton->hide(); //newLabel->hide(); copyLinkButton->hide(); } else { /* subject */ titleLabel->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str())); subjectLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); /* disable buttons: deletion facility not enabled with cache services yet */ clearButton->setEnabled(false); unsubscribeButton->setEnabled(false); clearButton->hide(); readAndClearButton->hide(); unsubscribeButton->hide(); copyLinkButton->show(); if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags)) { readButton->setVisible(true); #if 0 uint32_t status = 0; rsChannels->getMessageStatus(mChanId, mMsgId, status); #endif if (IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) { readButton->setChecked(true); readButton->setIcon(QIcon(":/images/message-state-unread.png")); } else { readButton->setChecked(false); readButton->setIcon(QIcon(":/images/message-state-read.png")); } bool newState; QColor color; if (!IS_MSG_UNREAD(post.mMeta.mMsgStatus)) { //newLabel->setVisible(false); newState = false; color = COLOR_NORMAL; } else { //newLabel->setVisible(true); newState = true; color = COLOR_NEW; } /* unpolish widget to clear the stylesheet's palette cache */ frame->style()->unpolish(frame); QPalette palette = frame->palette(); palette.setColor(frame->backgroundRole(), color); frame->setPalette(palette); frame->setProperty("new", newState); Rshare::refreshStyleSheet(frame, false); } else { readButton->setVisible(false); //newLabel->setVisible(false); } } msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); msgFrame->setVisible(!post.mMsg.empty()); datetimelabel->setText(DateTime::formatLongDateTime(post.mMeta.mPublishTs)); filelabel->setText(QString("(%1 %2) %3").arg(post.mCount).arg(tr("Files")).arg(misc::friendlyUnit(post.mSize))); if (mFileItems.empty() == false) { std::list<SubFileItem *>::iterator it; for(it = mFileItems.begin(); it != mFileItems.end(); it++) { delete(*it); } mFileItems.clear(); } std::list<RsGxsFile>::const_iterator it; for(it = post.mFiles.begin(); it != post.mFiles.end(); it++) { /* add file */ std::string path; SubFileItem *fi = new SubFileItem(it->mHash, it->mName, path, it->mSize, SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, ""); mFileItems.push_back(fi); /* check if the file is a media file */ if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->mName.c_str())).suffix())) fi->mediatype(); QLayout *layout = expandFrame->layout(); layout->addWidget(fi); } if(post.mThumbnail.mData != NULL) { QPixmap thumbnail; thumbnail.loadFromData(post.mThumbnail.mData, post.mThumbnail.mSize, "PNG"); // Wiping data - as its been passed to thumbnail. logoLabel->setPixmap(thumbnail); } m_inUpdateItemStatic = false; }