void ChatPage::personalInvites_copyLink() { QList<QListWidgetItem*> selected = ui._personal_invites_LW->selectedItems() ; QList<RetroShareLink> links ; std::vector<DistantChatInviteInfo> invites ; rsMsgs->getDistantChatInviteList(invites) ; for(QList<QListWidgetItem*>::const_iterator it(selected.begin());it!=selected.end();++it) { std::string hash = (*it)->data(Qt::UserRole).toString().toStdString() ; bool found = false ; for(uint32_t i=0;i<invites.size();++i) if(invites[i].hash == hash) { RetroShareLink link ; if(!link.createPrivateChatInvite(invites[i].time_of_validity,QString::fromStdString(invites[i].destination_pgp_id),QString::fromStdString(invites[i].encrypted_radix64_string))) { std::cerr << "Cannot create link." << std::endl; continue; } links.push_back(link) ; break ; } } if(!links.empty()) RSLinkClipboard::copyLinks(links) ; }
void FriendsDialog::fileHashingFinished(QList<HashedFile> hashedFiles) { std::cerr << "FriendsDialog::fileHashingFinished() started." << std::endl; QString mesgString; QList<HashedFile>::iterator it; for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) { HashedFile& hashedFile = *it; RetroShareLink link; if (!link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId()))) continue; mesgString += link.toHtmlSize(); if (it!= hashedFiles.end()) { mesgString += "<BR>"; } } #ifdef FRIENDS_DEBUG std::cerr << "FriendsDialog::fileHashingFinished mesgString : " << mesgString.toStdString() << std::endl; #endif if (!mesgString.isEmpty()) { /* convert to real html document */ QTextBrowser textBrowser; textBrowser.setHtml(mesgString); std::wstring msg = textBrowser.toHtml().toStdWString(); rsMsgs->sendPublicChat(msg); setFont(); } }
void CreateForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles) { std::cerr << "CreateForumMsg::fileHashingFinished() started." << std::endl; QString mesgString; QList<HashedFile>::iterator it; for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) { HashedFile& hashedFile = *it; RetroShareLink link; if (link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash))) { mesgString += link.toHtmlSize() + "<br>"; } } #ifdef CHAT_DEBUG std::cerr << "CreateForumMsg::anchorClicked mesgString : " << mesgString.toStdString() << std::endl; #endif if (!mesgString.isEmpty()) { ui.forumMessage->textCursor().insertHtml(mesgString); } ui.forumMessage->setFocus( Qt::OtherFocusReason ); }
void CreateForumMsg::pasteOwnCertificateLink() { RetroShareLink link ; std::string ownId = rsPeers->getOwnId() ; if( link.createCertificate(ownId) ) { ui.forumMessage->insertHtml(link.toHtml() + " "); } }
void MimeTextEdit::pasteOwnCertificateLink() { RetroShareLink link; std::string ownId = rsPeers->getOwnId(); if (link.createCertificate(ownId)) { insertHtml(link.toHtml() + " "); } }
void ChatWidget::pasteOwnCertificateLink() { std::cerr << "In paste own certificate link" << std::endl; RetroShareLink link ; std::string ownId = rsPeers->getOwnId() ; if( link.createCertificate(ownId) ) { ui->chatTextEdit->insertHtml(link.toHtml() + " "); } }
void SubFileItem::copyLink() { if (mFileName.empty() || mFileHash.empty()) { return; } RetroShareLink link; if (link.createFile(QString::fromUtf8(mFileName.c_str()), mFileSize, QString::fromStdString(mFileHash))) { QList<RetroShareLink> urls; urls.push_back(link); RSLinkClipboard::copyLinks(urls); } }
void DetailsDialog::setFileHash(const RsFileHash & hash) { dynamic_cast<FileTransferInfoWidget*>(ui.fileTransferInfoWidget->widget())->setFileHash(hash) ; FileInfo nfo ; if(!rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, nfo)) return ; RetroShareLink link ; link.createFile(QString::fromUtf8(nfo.fname.c_str()),nfo.size,QString::fromStdString(nfo.hash.toStdString())) ; ui.Linktext->setText(link.toString()) ; }
virtual void anchorTextForImg(QDomDocument &doc, QDomElement &element, const RetroShareLink &link, QString &text) { if (link.type() == RetroShareLink::TYPE_CERTIFICATE) { if (msgFlags & RS_MSG_USER_REQUEST) { text = QApplication::translate("MessageWidget", "Confirm %1 as friend").arg(link.name()); return; } if (msgFlags & RS_MSG_FRIEND_RECOMMENDATION) { text = QApplication::translate("MessageWidget", "Add %1 as friend").arg(link.name()); return; } } RsHtml::anchorTextForImg(doc, element, link, text); }
void ChannelFeed::copyChannelLink() { if (mChannelId.empty()) { return; } ChannelInfo ci; if (rsChannels->getChannelInfo(mChannelId, ci)) { RetroShareLink link; if (link.createChannel(ci.channelId, "")) { QList<RetroShareLink> urls; urls.push_back(link); RSLinkClipboard::copyLinks(urls); } } }
void ChatWidget::fileHashingFinished(QList<HashedFile> hashedFiles) { std::cerr << "ChatWidget::fileHashingFinished() started." << std::endl; QString message; QList<HashedFile>::iterator it; for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) { HashedFile& hashedFile = *it; QString ext = QFileInfo(hashedFile.filename).suffix(); RetroShareLink link; if(mDefaultExtraFileFlags & RS_FILE_REQ_ANONYMOUS_ROUTING) link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash)); else link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId())); if (hashedFile.flag & HashedFile::Picture) { message += QString("<img src=\"file:///%1\" width=\"100\" height=\"100\">").arg(hashedFile.filepath); message+="<br>"; } else { QString image = FilesDefs::getImageFromFilename(hashedFile.filename, false); if (!image.isEmpty()) { message += QString("<img src=\"%1\">").arg(image); } } message += link.toHtmlSize(); if (it != hashedFiles.end()) { message += "<BR>"; } } #ifdef CHAT_DEBUG std::cerr << "ChatWidget::fileHashingFinished message : " << message.toStdString() << std::endl; #endif /* convert to real html document */ QTextBrowser textBrowser; textBrowser.setHtml(message); std::wstring msg = textBrowser.toHtml().toStdWString(); if (rsMsgs->sendPrivateChat(peerId, msg)) { QDateTime currentTime = QDateTime::currentDateTime(); addChatMsg(false, name, currentTime, currentTime, QString::fromStdWString(msg), TYPE_NORMAL); } }
void GxsFeedItem::copyMessageLink() { if (groupId().isNull() || mMessageId.isNull()) { return; } if (getLinkType() == RetroShareLink::TYPE_UNKNOWN) { return; } RetroShareLink link; if (link.createGxsMessageLink(getLinkType(), groupId(), mMessageId, messageName())) { QList<RetroShareLink> urls; urls.push_back(link); RSLinkClipboard::copyLinks(urls); } }
void NetworkDialog::copyLink() { QTreeWidgetItem *wi = getCurrentNeighbour(); if (wi == NULL) { return; } RsPgpId peer_id ( wi->text(COLUMN_PEERID).toStdString() ) ; QList<RetroShareLink> urls; RetroShareLink link; if (link.createPerson(peer_id)) { urls.push_back(link); } RSLinkClipboard::copyLinks(urls); }
void RSTextBrowser::linkClicked(const QUrl &url) { if (!mLinkClickActive) { return; } // some links are opened directly in the QTextBrowser with open external links set to true, // so we handle links by our own #ifdef TO_DO // If we want extra file links to be anonymous, we need to insert the actual source here. if(url.host() == HOST_EXTRAFILE) { std::cerr << "Extra file link detected. Adding parent id " << _target_sslid << " to sourcelist" << std::endl; RetroShareLink link ; link.fromUrl(url) ; link.createExtraFile( link.name(),link.size(),link.hash(), _target_ssl_id) ; QDesktopServices::openUrl(link.toUrl()); } else #endif QDesktopServices::openUrl(url); }
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 SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote) { std::vector<DirDetails> dirVec; model->getDirDetailsFromSelect(lst, dirVec); QList<RetroShareLink> urls ; for (int i = 0, n = dirVec.size(); i < n; ++i) { const DirDetails& details = dirVec[i]; if (details.type == DIR_TYPE_DIR) { for(uint32_t j=0;j<details.children.size();++j) { const DirStub& dirStub = details.children[j]; DirDetails details; FileSearchFlags flags = remote?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ; // do not recursive copy sub dirs. if (!rsFiles->RequestDirDetails(dirStub.ref, details, flags) || details.type != DIR_TYPE_FILE) continue; RetroShareLink link; if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) { urls.push_back(link) ; } } } else { RetroShareLink link; if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) { urls.push_back(link) ; } } } RSLinkClipboard::copyLinks(urls) ; }
void CryptoPage::copyRSLink() { RetroShareLink link ; std::string ownId = rsPeers->getOwnId() ; if( link.createCertificate(ownId) ) { QList<RetroShareLink> urls ; urls.push_back(link) ; RSLinkClipboard::copyLinks(urls) ; QMessageBox::information(this, "RetroShare", tr("A RetroShare link with your Public Key is copied to Clipboard, paste and send it to your" " friend via email or some other way")); } else QMessageBox::warning(this, tr("Error"), tr("Your certificate could not be parsed correctly. Please contact the developers.")); }
void IdDetailsDialog::sendInvite() { /* create a message */ MessageComposer *composer = MessageComposer::newMsg(); composer->setTitleText(tr("You have a friend invite")); RsPeerId ownId = rsPeers->getOwnId(); RetroShareLink link = RetroShareLink::createCertificate(ownId); RsGxsId keyId(ui->lineEdit_KeyId->text().toStdString()); QString sMsgText = inviteMessage(); sMsgText += "<br><br>"; sMsgText += tr("Respond now:") + "<br>"; sMsgText += link.toHtml() + "<br>"; sMsgText += "<br>"; sMsgText += tr("Thanks, <br>") + QString::fromUtf8(rsPeers->getGPGName(rsPeers->getGPGOwnId()).c_str()); composer->setMsgText(sMsgText); composer->addRecipient(MessageComposer::TO, RsGxsId(keyId)); composer->show(); }
void GxsForumsDialog::copyForumLink() { if (mForumId.empty()) { return; } // THIS CODE CALLS getForumInfo() to verify that the Ids are valid. // As we are switching to Request/Response this is now harder to do... // So not bothering any more - shouldn't be necessary. // IF we get errors - fix them, rather than patching here. #if 0 ForumInfo fi; if (rsGxsForums->getForumInfo(mCurrForumId, fi)) { RetroShareLink link; if (link.createForum(fi.forumId, "")) { QList<RetroShareLink> urls; urls.push_back(link); RSLinkClipboard::copyLinks(urls); } } #endif QMessageBox::warning(this, "RetroShare", "ToDo"); }
void MessageWidget::fill(const std::string &msgId) { // if (currMsgId == msgId) { // // message doesn't changed // return; // } currMsgId = msgId; if (currMsgId.empty()) { /* blank it */ ui.dateText-> setText(""); ui.toText->setText(""); ui.fromText->setText(""); ui.filesText->setText(""); ui.ccLabel->setVisible(false); ui.ccText->setVisible(false); ui.ccText->clear(); ui.bccLabel->setVisible(false); ui.bccText->setVisible(false); ui.bccText->clear(); ui.subjectText->setText(""); ui.msgList->clear(); ui.msgText->clear(); ui.msgText->resetImagesStatus(false); clearTagLabels(); currMsgFlags = 0; return; } clearTagLabels(); MessageInfo msgInfo; if (rsMail->getMessage(currMsgId, msgInfo) == false) { std::cerr << "MessageWidget::fill() Couldn't find Msg" << std::endl; return; } if (msgInfo.msgflags & RS_MSG_USER_REQUEST){ ui.inviteFrame->show(); } else { ui.inviteFrame->hide(); } const std::list<FileInfo> &recList = msgInfo.files; std::list<FileInfo>::const_iterator it; ui.msgList->clear(); QList<QTreeWidgetItem*> items; for (it = recList.begin(); it != recList.end(); ++it) { QTreeWidgetItem *item = new QTreeWidgetItem; item->setText(COLUMN_FILE_NAME, QString::fromUtf8(it->fname.c_str())); item->setText(COLUMN_FILE_SIZE, misc::friendlyUnit(it->size)); item->setData(COLUMN_FILE_SIZE, Qt::UserRole, QVariant(qulonglong(it->size)) ); item->setText(COLUMN_FILE_HASH, QString::fromStdString(it->hash.toStdString())); item->setTextAlignment( COLUMN_FILE_SIZE, Qt::AlignRight ); /* add to the list */ items.append(item); } /* add the items in! */ ui.msgList->insertTopLevelItems(0, items); /* iterate through the sources */ RetroShareLink link; QString text; for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } for(std::set<RsGxsId >::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } ui.toText->setText(text); if (!msgInfo.rspeerid_msgcc.empty() || !msgInfo.rsgxsid_msgcc.empty()) { ui.ccLabel->setVisible(true); ui.ccText->setVisible(true); text.clear(); for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgcc.begin(); pit != msgInfo.rspeerid_msgcc.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } for(std::set<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgcc.begin(); pit != msgInfo.rsgxsid_msgcc.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } ui.ccText->setText(text); } else { ui.ccLabel->setVisible(false); ui.ccText->setVisible(false); ui.ccText->clear(); } if (!msgInfo.rspeerid_msgbcc.empty() || !msgInfo.rsgxsid_msgbcc.empty()) { ui.bccLabel->setVisible(true); ui.bccText->setVisible(true); text.clear(); for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgbcc.begin(); pit != msgInfo.rspeerid_msgbcc.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } for(std::set<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgbcc.begin(); pit != msgInfo.rsgxsid_msgbcc.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } ui.bccText->setText(text); } else { ui.bccLabel->setVisible(false); ui.bccText->setVisible(false); ui.bccText->clear(); } ui.dateText->setText(DateTime::formatDateTime(msgInfo.ts)); RsPeerId ownId = rsPeers->getOwnId(); QString tooltip_string ; // if ((msgInfo.msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) // outgoing message are from me // { // tooltip_string = PeerDefs::rsidFromId(ownId) ; // link.createMessage(ownId, ""); // } if(msgInfo.msgflags & RS_MSG_DISTANT) // distant message { tooltip_string = PeerDefs::rsidFromId(msgInfo.rsgxsid_srcId) ; link = RetroShareLink::createMessage(msgInfo.rsgxsid_srcId, ""); } else { tooltip_string = PeerDefs::rsidFromId(msgInfo.rspeerid_srcId) ; link = RetroShareLink::createMessage(msgInfo.rspeerid_srcId, ""); } if ((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.rspeerid_srcId == ownId) { ui.fromText->setText("RetroShare"); if (toolButtonReply) toolButtonReply->setEnabled(false); } else { ui.fromText->setText(link.toHtml()); ui.fromText->setToolTip(tooltip_string) ; if (toolButtonReply) toolButtonReply->setEnabled(true); } ui.subjectText->setText(QString::fromUtf8(msgInfo.title.c_str())); // emoticons disabled because of crazy cost. //text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromUtf8(msgInfo.msg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromUtf8(msgInfo.msg.c_str()), RSHTML_FORMATTEXT_EMBED_LINKS); ui.msgText->resetImagesStatus(Settings->getMsgLoadEmbeddedImages() || (msgInfo.msgflags & RS_MSG_LOAD_EMBEDDED_IMAGES)); ui.msgText->setHtml(text); ui.filesText->setText(QString("%1").arg(msgInfo.count)); ui.filesSize->setText(QString(misc::friendlyUnit(msgInfo.size))); showTagLabels(); currMsgFlags = msgInfo.msgflags; }
void MessageWidget::fill(const std::string &msgId) { if (currMsgId == msgId) { // message doesn't changed return; } currMsgId = msgId; if (currMsgId.empty()) { /* blank it */ ui.dateText-> setText(""); ui.toText->setText(""); ui.fromText->setText(""); ui.filesText->setText(""); ui.cclabel->setVisible(false); ui.ccText->setVisible(false); ui.ccText->clear(); ui.bcclabel->setVisible(false); ui.bccText->setVisible(false); ui.bccText->clear(); ui.subjectText->setText(""); ui.msgList->clear(); ui.msgText->clear(); clearTagLabels(); return; } clearTagLabels(); MessageInfo msgInfo; if (rsMsgs->getMessage(currMsgId, msgInfo) == false) { std::cerr << "MessageWidget::fill() Couldn't find Msg" << std::endl; return; } const std::list<FileInfo> &recList = msgInfo.files; std::list<FileInfo>::const_iterator it; ui.msgList->clear(); QList<QTreeWidgetItem*> items; for (it = recList.begin(); it != recList.end(); it++) { QTreeWidgetItem *item = new QTreeWidgetItem; item->setText(COLUMN_FILE_NAME, QString::fromStdString(it->fname)); item->setText(COLUMN_FILE_SIZE, QString::number(it->size)); item->setText(COLUMN_FILE_HASH, QString::fromStdString(it->hash)); /* add to the list */ items.append(item); } /* add the items in! */ ui.msgList->insertTopLevelItems(0, items); /* iterate through the sources */ std::list<std::string>::const_iterator pit; RetroShareLink link; QString text; for(pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++) { if (link.createMessage(*pit, "")) { text += link.toHtml() + " "; } } ui.toText->setText(text); if (msgInfo.msgcc.size() > 0) { ui.cclabel->setVisible(true); ui.ccText->setVisible(true); text.clear(); for(pit = msgInfo.msgcc.begin(); pit != msgInfo.msgcc.end(); pit++) { if (link.createMessage(*pit, "")) { text += link.toHtml() + " "; } } ui.ccText->setText(text); } else { ui.cclabel->setVisible(false); ui.ccText->setVisible(false); ui.ccText->clear(); } if (msgInfo.msgbcc.size() > 0) { ui.bcclabel->setVisible(true); ui.bccText->setVisible(true); text.clear(); for(pit = msgInfo.msgbcc.begin(); pit != msgInfo.msgbcc.end(); pit++) { if (link.createMessage(*pit, "")) { text += link.toHtml() + " "; } } ui.bccText->setText(text); } else { ui.bcclabel->setVisible(false); ui.bccText->setVisible(false); ui.bccText->clear(); } { QDateTime qtime; qtime.setTime_t(msgInfo.ts); QString timestamp = qtime.toString("dd.MM.yyyy hh:mm:ss"); ui.dateText->setText(timestamp); } std::string srcId; if ((msgInfo.msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) { // outgoing message are from me srcId = rsPeers->getOwnId(); } else { srcId = msgInfo.srcId; } link.createMessage(srcId, ""); ui.fromText->setText(link.toHtml()); ui.fromText->setToolTip(PeerDefs::rsidFromId(srcId)); ui.subjectText->setText(QString::fromStdWString(msgInfo.title)); text = RsHtml::formatText(QString::fromStdWString(msgInfo.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); ui.msgText->setHtml(text); ui.filesText->setText(QString("(%1 %2)").arg(msgInfo.count).arg(msgInfo.count == 1 ? tr("File") : tr("Files"))); showTagLabels(); }
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; }
void ConfCertDialog::load() { RsPeerDetails detail; if (!rsPeers->getPeerDetails(mId, detail)) { QMessageBox::information(this, tr("RetroShare"), tr("Error : cannot get peer details.")); close(); return; } if(detail.isOnlyGPGdetail && !rsPeers->isKeySupported(mId)) { ui.make_friend_button->setEnabled(false) ; ui.make_friend_button->setToolTip(tr("The supplied key algorithm is not supported by RetroShare\n(Only RSA keys are supported at the moment)")) ; } else { ui.make_friend_button->setEnabled(true) ; ui.make_friend_button->setToolTip("") ; } ui.name->setText(QString::fromUtf8(detail.name.c_str())); ui.peerid->setText(QString::fromStdString(detail.id)); RetroShareLink link; link.createPerson(detail.id); ui.rsid->setText(link.toHtml()); ui.rsid->setToolTip(link.title()); if (!detail.isOnlyGPGdetail) { ui.avatar->setId(mId, false); ui.loc->setText(QString::fromUtf8(detail.location.c_str())); // Dont Show a timestamp in RS calculate the day QDateTime date = QDateTime::fromTime_t(detail.lastConnect); QString stime = date.toString(Qt::LocalDate); ui.lastcontact-> setText(stime); /* set retroshare version */ std::map<std::string, std::string>::iterator vit; std::map<std::string, std::string> versions; bool retv = rsDisc->getDiscVersions(versions); if (retv && versions.end() != (vit = versions.find(detail.id))) { ui.version->setText(QString::fromStdString(vit->second)); } /* set local address */ ui.localAddress->setText(QString::fromStdString(detail.localAddr)); ui.localPort -> setValue(detail.localPort); /* set the server address */ ui.extAddress->setText(QString::fromStdString(detail.extAddr)); ui.extPort -> setValue(detail.extPort); ui.dynDNS->setText(QString::fromStdString(detail.dyndns)); ui.statusline->setText(StatusDefs::connectStateString(detail)); ui.ipAddressList->clear(); for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) ui.ipAddressList->addItem(QString::fromStdString(*it)); ui.loc->show(); ui.label_loc->show(); ui.statusline->show(); ui.label_status->show(); ui.lastcontact->show(); ui.label_last_contact->show(); ui.version->show(); ui.label_version->show(); ui.groupBox->show(); ui.rsid->hide(); ui.label_rsid->hide(); } else { ui.avatar->setId(mId, true); ui.rsid->show(); ui.label_rsid->show(); ui.loc->hide(); ui.label_loc->hide(); ui.statusline->hide(); ui.label_status->hide(); ui.lastcontact->hide(); ui.label_last_contact->hide(); ui.version->hide(); ui.label_version->hide(); ui.groupBox->hide(); } if (detail.gpg_id == rsPeers->getGPGOwnId()) { ui.make_friend_button->hide(); ui.signGPGKeyCheckBox->hide(); ui.signKeyButton->hide(); ui.denyFriendButton->hide(); ui.web_of_trust_label->hide(); ui.radioButton_trust_fully->hide(); ui.radioButton_trust_marginnaly->hide(); ui.radioButton_trust_never->hide(); ui.is_signing_me->hide(); ui.signersBox->setTitle(tr("Your key is signed by : ")); } else { ui.web_of_trust_label->show(); ui.radioButton_trust_fully->show(); ui.radioButton_trust_marginnaly->show(); ui.radioButton_trust_never->show(); ui.is_signing_me->show(); ui.signersBox->setTitle(tr("Peer key is signed by : ")); if (detail.accept_connection) { ui.make_friend_button->hide(); ui.denyFriendButton->show(); ui.signGPGKeyCheckBox->hide(); //connection already accepted, propose to sign gpg key if (!detail.ownsign) { ui.signKeyButton->show(); } else { ui.signKeyButton->hide(); } } else { ui.make_friend_button->show(); ui.denyFriendButton->hide(); ui.signKeyButton->hide(); if (!detail.ownsign) { ui.signGPGKeyCheckBox->show(); ui.signGPGKeyCheckBox->setChecked(false); } else { ui.signGPGKeyCheckBox->hide(); } } //web of trust if (detail.trustLvl == RS_TRUST_LVL_ULTIMATE) { //trust is ultimate, it means it's one of our own keys ui.web_of_trust_label->setText(tr("Your trust in this peer is ultimate, it's probably a key you own.")); ui.radioButton_trust_fully->hide(); ui.radioButton_trust_marginnaly->hide(); ui.radioButton_trust_never->hide(); } else { ui.radioButton_trust_fully->show(); ui.radioButton_trust_marginnaly->show(); ui.radioButton_trust_never->show(); if (detail.trustLvl == RS_TRUST_LVL_FULL) { ui.web_of_trust_label->setText(tr("Your trust in this peer is full.")); ui.radioButton_trust_fully->setChecked(true); ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-48.png")); ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png")); ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png")); } else if (detail.trustLvl == RS_TRUST_LVL_MARGINAL) { ui.web_of_trust_label->setText(tr("Your trust in this peer is marginal.")); ui.radioButton_trust_marginnaly->setChecked(true); ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-48.png")); ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png")); ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-off-48.png")); } else if (detail.trustLvl == RS_TRUST_LVL_NEVER) { ui.web_of_trust_label->setText(tr("Your trust in this peer is none.")); ui.radioButton_trust_never->setChecked(true); ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-48.png")); ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-off-48.png")); ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png")); } else { ui.web_of_trust_label->setText(tr("Your trust in this peer is not set.")); //we have to set up the set exclusive to false in order to uncheck it all ui.radioButton_trust_fully->setAutoExclusive(false); ui.radioButton_trust_marginnaly->setAutoExclusive(false); ui.radioButton_trust_never->setAutoExclusive(false); ui.radioButton_trust_fully->setChecked(false); ui.radioButton_trust_marginnaly->setChecked(false); ui.radioButton_trust_never->setChecked(false); ui.radioButton_trust_fully->setAutoExclusive(true); ui.radioButton_trust_marginnaly->setAutoExclusive(true); ui.radioButton_trust_never->setAutoExclusive(true); ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png")); ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-off-48.png")); ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png")); } } if (detail.hasSignedMe) { ui.is_signing_me->setText(tr("Peer has authenticated me as a friend and did sign my GPG key")); } else { ui.is_signing_me->setText(tr("Peer has not authenticated me as a friend and did not sign my GPG key")); } } QString text; for(std::list<std::string>::const_iterator it(detail.gpgSigners.begin());it!=detail.gpgSigners.end();++it) { link.createPerson(*it); if (link.valid()) { text += link.toHtml() + "<BR>"; } } ui.signers->setHtml(text); loadInvitePage() ; }
void ConfCertDialog::load() { RsPeerDetails detail; if(!rsPeers->getPeerDetails(peerId, detail)) { QMessageBox::information(this, tr("RetroShare"), tr("Error : cannot get peer details.")); close(); return; } ui._direct_transfer_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_DIRECT_DL ) ; ui._allow_push_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_ALLOW_PUSH) ; //ui.pgpfingerprint->setText(QString::fromUtf8(detail.name.c_str())); ui.peerid->setText(QString::fromStdString(detail.id.toStdString())); RetroShareLink link; link.createPerson(detail.gpg_id); ui.pgpfingerprint->setText(link.toHtml()); ui.pgpfingerprint->setToolTip(link.title()); ui.avatar->setId(ChatId(peerId)); ui.loc->setText(QString::fromUtf8(detail.location.c_str())); // Dont Show a timestamp in RS calculate the day ui.lastcontact->setText(DateTime::formatLongDateTime(detail.lastConnect)); /* set retroshare version */ std::string version; rsDisc->getPeerVersion(detail.id, version); ui.version->setText(QString::fromStdString(version)); RsPeerCryptoParams cdet ; if(RsControl::instance()->getPeerCryptoDetails(detail.id,cdet) && cdet.connexion_state!=0) { QString ct ; ct += QString::fromStdString(cdet.cipher_version) + ": "; ct += QString::fromStdString(cdet.cipher_name); if(cdet.cipher_version != "TLSv1.2") ct += QString::number(cdet.cipher_bits_1); ui.crypto_info->setText(ct) ; } else ui.crypto_info->setText(tr("Not connected")) ; if (detail.isHiddenNode) { // enable only the first row and set name of the first label to "Hidden Address" ui.l_localAddress->setText(tr("Hidden Address")); ui.l_extAddress->setEnabled(false); ui.extAddress->setEnabled(false); ui.l_portExternal->setEnabled(false); ui.extPort->setEnabled(false); ui.l_dynDNS->setEnabled(false); ui.dynDNS->setEnabled(false); /* set hidden address */ ui.localAddress->setText(QString::fromStdString(detail.hiddenNodeAddress)); ui.localPort -> setValue(detail.hiddenNodePort); // set everything else to none ui.extAddress->setText(tr("none")); ui.extPort->setValue(0); ui.dynDNS->setText(tr("none")); } else { // enable everything and set name of the first label to "Local Address" ui.l_localAddress->setText(tr("Local Address")); ui.l_extAddress->setEnabled(true); ui.extAddress->setEnabled(true); ui.l_portExternal->setEnabled(true); ui.extPort->setEnabled(true); ui.l_dynDNS->setEnabled(true); ui.dynDNS->setEnabled(true); /* set local address */ ui.localAddress->setText(QString::fromStdString(detail.localAddr)); ui.localPort -> setValue(detail.localPort); /* set the server address */ ui.extAddress->setText(QString::fromStdString(detail.extAddr)); ui.extPort -> setValue(detail.extPort); ui.dynDNS->setText(QString::fromStdString(detail.dyndns)); } ui.statusline->setText(StatusDefs::connectStateString(detail)); ui.ipAddressList->clear(); for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) ui.ipAddressList->addItem(QString::fromStdString(*it)); ui.loc->show(); ui.label_loc->show(); ui.statusline->show(); ui.label_status->show(); ui.lastcontact->show(); ui.label_last_contact->show(); ui.version->show(); ui.label_version->show(); ui.groupBox->show(); ui.groupBox_4->show(); ui.tabWidget->show(); //ui.rsid->hide(); //ui.label_rsid->hide(); ui.pgpfingerprint->show(); //ui.pgpfingerprint_label->show(); ui.stabWidget->setTabEnabled(2,true) ; ui.stabWidget->setTabEnabled(3,true) ; ui.stabWidget->setTabEnabled(4,true) ; loadInvitePage() ; }
void ConfCertDialog::load() { RsPeerDetails detail; if (!rsPeers->getPeerDetails(mId, detail)) { QMessageBox::information(this, tr("RetroShare"), tr("Error : cannot get peer details.")); close(); return; } if(detail.isOnlyGPGdetail && !rsPeers->isKeySupported(mId)) { ui.make_friend_button->setEnabled(false) ; ui.make_friend_button->setToolTip(tr("The supplied key algorithm is not supported by RetroShare\n(Only RSA keys are supported at the moment)")) ; } else { ui.make_friend_button->setEnabled(true) ; ui.make_friend_button->setToolTip("") ; } ui._anonymous_routing_CB->setChecked(detail.service_perm_flags & RS_SERVICE_PERM_TURTLE ) ; ui._discovery_CB->setChecked( detail.service_perm_flags & RS_SERVICE_PERM_DISCOVERY ) ; ui._forums_channels_CB->setChecked( detail.service_perm_flags & RS_SERVICE_PERM_DISTRIB ) ; ui._direct_transfer_CB->setChecked( detail.service_perm_flags & RS_SERVICE_PERM_DIRECT_DL ) ; ui.name->setText(QString::fromUtf8(detail.name.c_str())); ui.peerid->setText(QString::fromStdString(detail.id)); RetroShareLink link; link.createPerson(detail.id); ui.rsid->setText(link.toHtml()); ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr))); ui.rsid->setToolTip(link.title()); if (!detail.isOnlyGPGdetail) { ui.avatar->setId(mId, false); ui.loc->setText(QString::fromUtf8(detail.location.c_str())); // Dont Show a timestamp in RS calculate the day ui.lastcontact->setText(DateTime::formatLongDateTime(detail.lastConnect)); /* set retroshare version */ std::string version; rsDisc->getPeerVersion(detail.id, version); ui.version->setText(QString::fromStdString(version)); RsPeerCryptoParams cdet ; if(RsControl::instance()->getPeerCryptoDetails(detail.id,cdet) && cdet.connexion_state!=0) { QString ct ; ct += QString::fromStdString(cdet.cipher_name) ; ct += QString::number(cdet.cipher_bits_1) ; ct += "-"+QString::fromStdString(cdet.cipher_version) ; ui.crypto_info->setText(ct) ; } else ui.crypto_info->setText(tr("Not connected")) ; if (detail.isHiddenNode) { /* set local address */ ui.localAddress->setText("hidden"); ui.localPort -> setValue(0); /* set the server address */ ui.extAddress->setText("hidden"); ui.extPort -> setValue(0); ui.dynDNS->setText(QString::fromStdString(detail.hiddenNodeAddress)); } else { /* set local address */ ui.localAddress->setText(QString::fromStdString(detail.localAddr)); ui.localPort -> setValue(detail.localPort); /* set the server address */ ui.extAddress->setText(QString::fromStdString(detail.extAddr)); ui.extPort -> setValue(detail.extPort); ui.dynDNS->setText(QString::fromStdString(detail.dyndns)); } ui.statusline->setText(StatusDefs::connectStateString(detail)); ui.ipAddressList->clear(); for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) ui.ipAddressList->addItem(QString::fromStdString(*it)); ui.loc->show(); ui.label_loc->show(); ui.statusline->show(); ui.label_status->show(); ui.lastcontact->show(); ui.label_last_contact->show(); ui.version->show(); ui.label_version->show(); ui.groupBox->show(); ui.groupBox_4->show(); ui.tabWidget->show(); ui.rsid->hide(); ui.label_rsid->hide(); ui.pgpfingerprint->show(); ui.pgpfingerprint_label->show(); } else { ui.avatar->setId(mId, true); ui.rsid->show(); ui.peerid->hide(); ui.label_id->hide(); ui.label_rsid->show(); ui.pgpfingerprint->show(); ui.pgpfingerprint_label->show(); ui.loc->hide(); ui.label_loc->hide(); ui.statusline->hide(); ui.label_status->hide(); ui.lastcontact->hide(); ui.label_last_contact->hide(); ui.version->hide(); ui.label_version->hide(); ui.groupBox_4->hide(); ui.crypto_info->hide(); ui.crypto_label->hide(); ui.groupBox->hide(); ui.tabWidget->hide(); } if (detail.gpg_id == rsPeers->getGPGOwnId()) { ui.make_friend_button->hide(); ui.signGPGKeyCheckBox->hide(); ui.signKeyButton->hide(); ui.denyFriendButton->hide(); ui.web_of_trust_label->hide(); ui.radioButton_trust_fully->hide(); ui.radioButton_trust_marginnaly->hide(); ui.radioButton_trust_never->hide(); ui.is_signing_me->hide(); ui.signersBox->setTitle(tr("My key is signed by : ")); } else { ui.web_of_trust_label->show(); ui.radioButton_trust_fully->show(); ui.radioButton_trust_marginnaly->show(); ui.radioButton_trust_never->show(); ui.is_signing_me->show(); ui.signersBox->setTitle(tr("Peer key is signed by : ")); if (detail.accept_connection) { ui.make_friend_button->hide(); ui.denyFriendButton->show(); ui.signGPGKeyCheckBox->hide(); //connection already accepted, propose to sign gpg key if (!detail.ownsign) { ui.signKeyButton->show(); } else { ui.signKeyButton->hide(); } } else { ui.make_friend_button->show(); ui.denyFriendButton->hide(); ui.signKeyButton->hide(); if (!detail.ownsign) { ui.signGPGKeyCheckBox->show(); ui.signGPGKeyCheckBox->setChecked(false); } else { ui.signGPGKeyCheckBox->hide(); } } //web of trust if (detail.trustLvl == RS_TRUST_LVL_ULTIMATE) { //trust is ultimate, it means it's one of our own keys ui.web_of_trust_label->setText(tr("Your trust in this peer is ultimate, it's probably a key you own.")); ui.radioButton_trust_fully->hide(); ui.radioButton_trust_marginnaly->hide(); ui.radioButton_trust_never->hide(); } else { ui.radioButton_trust_fully->show(); ui.radioButton_trust_marginnaly->show(); ui.radioButton_trust_never->show(); if (detail.trustLvl == RS_TRUST_LVL_FULL) { ui.web_of_trust_label->setText(tr("Your trust in this peer is full.")); ui.radioButton_trust_fully->setChecked(true); ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-48.png")); ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png")); ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png")); } else if (detail.trustLvl == RS_TRUST_LVL_MARGINAL) { ui.web_of_trust_label->setText(tr("Your trust in this peer is marginal.")); ui.radioButton_trust_marginnaly->setChecked(true); ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-48.png")); ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png")); ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-off-48.png")); } else if (detail.trustLvl == RS_TRUST_LVL_NEVER) { ui.web_of_trust_label->setText(tr("Your trust in this peer is none.")); ui.radioButton_trust_never->setChecked(true); ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-48.png")); ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-off-48.png")); ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png")); } else { ui.web_of_trust_label->setText(tr("Your trust in this peer is not set.")); //we have to set up the set exclusive to false in order to uncheck it all ui.radioButton_trust_fully->setAutoExclusive(false); ui.radioButton_trust_marginnaly->setAutoExclusive(false); ui.radioButton_trust_never->setAutoExclusive(false); ui.radioButton_trust_fully->setChecked(false); ui.radioButton_trust_marginnaly->setChecked(false); ui.radioButton_trust_never->setChecked(false); ui.radioButton_trust_fully->setAutoExclusive(true); ui.radioButton_trust_marginnaly->setAutoExclusive(true); ui.radioButton_trust_never->setAutoExclusive(true); ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png")); ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-off-48.png")); ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png")); } } if (detail.hasSignedMe) { ui.is_signing_me->setText(tr("Peer has authenticated me as a friend and did sign my PGP key")); } else { ui.is_signing_me->setText(tr("Peer has not authenticated me as a friend and did not sign my PGP key")); } } QString text; for(std::list<std::string>::const_iterator it(detail.gpgSigners.begin());it!=detail.gpgSigners.end();++it) { link.createPerson(*it); if (link.valid()) { text += link.toHtml() + "<BR>"; } } ui.signers->setHtml(text); loadInvitePage() ; }
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 ChanNewItem::updateItemStatic() { if (!rsChannels) return; /* fill in */ #ifdef DEBUG_ITEM std::cerr << "ChanNewItem::updateItemStatic()"; std::cerr << std::endl; #endif ChannelInfo ci; if (rsChannels->getChannelInfo(mChanId, ci)) { RetroShareLink link; link.createChannel(ci.channelId, ""); nameLabel->setText(link.toHtml()); descLabel->setText(QString::fromStdWString(ci.channelDesc)); if(ci.pngImageLen != 0){ QPixmap chanImage; chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG"); logo_label->setPixmap(QPixmap(chanImage)); }else{ QPixmap defaulImage(CHAN_DEFAULT_IMAGE); logo_label->setPixmap(QPixmap(defaulImage)); } if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED) { subscribeButton->setEnabled(false); //postButton->setEnabled(true); } else { subscribeButton->setEnabled(true); //postButton->setEnabled(false); } /* should also check the other flags */ } else { nameLabel->setText(tr("Unknown Channel")); titleLabel->setText("Channel ???"); descLabel->setText(""); } if (mIsNew) { titleLabel->setText(tr("New Channel")); } else { titleLabel->setText(tr("Updated Channel")); } if (mIsHome) { /* disable buttons */ clearButton->setEnabled(false); } }