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 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 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); } }