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