mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
ported trunk commit 2889 and 2888
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@2889 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
ac693595c9
commit
acbcf57bd8
@ -11,7 +11,7 @@ MOC_DIR = temp/moc
|
||||
|
||||
#CONFIG += debug
|
||||
debug {
|
||||
QMAKE_CXXFLAGS *= -g
|
||||
QMAKE_CFLAGS += -g
|
||||
}
|
||||
|
||||
################################# Linux ##########################################
|
||||
@ -19,8 +19,15 @@ debug {
|
||||
linux-* {
|
||||
CONFIG += version_detail_bash_script
|
||||
QMAKE_CXXFLAGS *= -D_FILE_OFFSET_BITS=64
|
||||
|
||||
system(which gpgme-config >/dev/null 2>&1) {
|
||||
INCLUDEPATH += $$system(gpgme-config --cflags | sed -e "s/-I//g")
|
||||
} else {
|
||||
message(Could not find gpgme-config on your system, assuming gpgme.h is in /usr/include)
|
||||
}
|
||||
|
||||
LIBS += ../../libretroshare/src/lib/libretroshare.a
|
||||
LIBS += -lssl -lgpgme -lupnp
|
||||
LIBS += -lssl -lgpgme -lupnp
|
||||
}
|
||||
|
||||
linux-g++ {
|
||||
@ -205,6 +212,7 @@ HEADERS += rshare.h \
|
||||
gui/profile/ProfileWidget.h \
|
||||
gui/profile/StatusMessage.h \
|
||||
gui/chat/PopupChatDialog.h \
|
||||
gui/chat/HandleRichText.h \
|
||||
gui/channels/ChannelDetails.h \
|
||||
gui/channels/CreateChannelMsg.h \
|
||||
gui/connect/ConnectDialog.h \
|
||||
@ -386,6 +394,7 @@ SOURCES += main.cpp \
|
||||
gui/channels/CreateChannelMsg.cpp \
|
||||
gui/channels/ChannelDetails.cpp \
|
||||
gui/chat/PopupChatDialog.cpp \
|
||||
gui/chat/HandleRichText.cpp \
|
||||
gui/connect/ConnectDialog.cpp \
|
||||
gui/connect/ConfCertDialog.cpp \
|
||||
gui/msgs/ChanMsgDialog.cpp \
|
||||
|
@ -952,14 +952,13 @@ void PeersDialog::insertChat()
|
||||
QString name = QString::fromStdString(it->name);
|
||||
QString line = "<span style=\"color:#C00000\">" + timestamp + "</span>" +
|
||||
"<span style=\"color:#2D84C9\"><strong>" + " " + name + "</strong></span>";
|
||||
QString msgContents = QString::fromStdWString(it->msg);
|
||||
|
||||
//std::cerr << "PeersDialog::insertChat(): 1.11\n";
|
||||
historyKeeper.addMessage(name, "THIS", QString::fromStdWString(it->msg));
|
||||
historyKeeper.addMessage(name, "THIS", msgContents);
|
||||
//std::cerr << "PeersDialog::insertChat(): 1.12\n";
|
||||
extraTxt += line;
|
||||
|
||||
extraTxt += QString::fromStdWString(it->msg);
|
||||
|
||||
// notify with a systray icon msg
|
||||
if(it->rsid != rsPeers->getOwnId())
|
||||
{
|
||||
@ -974,30 +973,19 @@ void PeersDialog::insertChat()
|
||||
emit notifyGroupChat(QString("New group chat"), notifyMsg);
|
||||
}
|
||||
|
||||
//replace http://, https:// and www. with <a href> links
|
||||
QRegExp rx("(retroshare://[^ <>]*)|(https?://[^ <>]*)|(www\\.[^ <>]*)");
|
||||
int count = 0;
|
||||
int pos = 200; //ignore the first 200 char because of the standard DTD ref
|
||||
while ( (pos = rx.indexIn(extraTxt, pos)) != -1 ) {
|
||||
//we need to look ahead to see if it's already a well formed link
|
||||
if (extraTxt.mid(pos - 6, 6) != "href=\"" && extraTxt.mid(pos - 6, 6) != "href='" && extraTxt.mid(pos - 6, 6) != "ttp://" ) {
|
||||
QString tempMessg = extraTxt.left(pos) + "<a href=\"" + rx.cap(count) + "\">" + rx.cap(count) + "</a>" + extraTxt.mid(pos + rx.matchedLength(), -1);
|
||||
extraTxt = tempMessg;
|
||||
}
|
||||
pos += rx.matchedLength() + 15;
|
||||
count ++;
|
||||
}
|
||||
// create a DOM tree object from the message and embed contents with HTML tags
|
||||
QDomDocument doc;
|
||||
doc.setContent(msgContents);
|
||||
|
||||
if(!ui.actionDisable_Emoticons->isChecked())
|
||||
{
|
||||
QHashIterator<QString, QString> i(smileys);
|
||||
while(i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
foreach(QString code, i.key().split("|"))
|
||||
extraTxt.replace(code, "<img src=\"" + i.value() + "\" />");
|
||||
}
|
||||
}
|
||||
// embed links
|
||||
QDomElement body = doc.documentElement();
|
||||
RsChat::embedHtml(doc, body, defEmbedAhref);
|
||||
|
||||
if(!ui.actionDisable_Emoticons->isChecked())
|
||||
RsChat::embedHtml(doc, body, defEmbedImg);
|
||||
|
||||
msgContents = doc.toString(-1); // -1 removes any annoying carriage return misinterpreted by QTextEdit
|
||||
extraTxt += msgContents;
|
||||
|
||||
if ((msgWidget->verticalScrollBar()->maximum() - 30) < msgWidget->verticalScrollBar()->value() ) {
|
||||
msgWidget->append(extraTxt);
|
||||
@ -1310,7 +1298,7 @@ void PeersDialog::loadEmoticonsgroupchat()
|
||||
#endif
|
||||
if(!sm_file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
std::cerr << "Could not open resouce file :/emoticons/emotes.acs" << endl ;
|
||||
std::cerr << "Could not open resouce file :/emoticons/emotes.acs" << std::endl ;
|
||||
return ;
|
||||
}
|
||||
sm_codes = sm_file.readAll();
|
||||
@ -1360,6 +1348,9 @@ void PeersDialog::loadEmoticonsgroupchat()
|
||||
smileys.insert(smcode, ":/"+smfile);
|
||||
#endif
|
||||
}
|
||||
|
||||
// init <img> embedder
|
||||
defEmbedImg.InitFromAwkwardHash(smileys);
|
||||
}
|
||||
|
||||
void PeersDialog::smileyWidgetgroupchat()
|
||||
@ -1615,13 +1606,13 @@ void PeersDialog::fileHashingFinished(AttachFileItem* file) {
|
||||
}
|
||||
|
||||
//convert fileSize from uint_64 to string for html link
|
||||
char fileSizeChar [100];
|
||||
sprintf(fileSizeChar, "%lld", file->FileSize());
|
||||
std::string fileSize = *(&fileSizeChar);
|
||||
// char fileSizeChar [100];
|
||||
// sprintf(fileSizeChar, "%lld", file->FileSize());
|
||||
// std::string fileSize = *(&fileSizeChar);
|
||||
|
||||
std::string mesgString = RetroShareLink(QString::fromStdString(file->FileName()),
|
||||
file->FileSize(),
|
||||
QString::fromStdString(file->FileHash())).toHtml().toStdString() ;
|
||||
file->FileSize(),
|
||||
QString::fromStdString(file->FileHash())).toHtml().toStdString() ;
|
||||
|
||||
// std::string mesgString = "<a href='retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "'>"
|
||||
// + "retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "</a>";
|
||||
@ -1633,13 +1624,13 @@ void PeersDialog::fileHashingFinished(AttachFileItem* file) {
|
||||
|
||||
//convert char massageString to w_char
|
||||
wchar_t* message;
|
||||
int requiredSize = mbstowcs(NULL, messageString, 0); // C4996
|
||||
size_t requiredSize = mbstowcs(NULL, messageString, 0); // C4996
|
||||
/* Add one to leave room for the NULL terminator */
|
||||
message = (wchar_t *)malloc( (requiredSize + 1) * sizeof( wchar_t ));
|
||||
if (! message) {
|
||||
std::cerr << ("Memory allocation failure.\n");
|
||||
}
|
||||
int size = mbstowcs( message, messageString, requiredSize + 1); // C4996
|
||||
size_t size = mbstowcs( message, messageString, requiredSize + 1); // C4996
|
||||
if (size == (size_t) (-1)) {
|
||||
printf("Couldn't convert string--invalid multibyte character.\n");
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "chat/PopupChatDialog.h"
|
||||
#include "chat/HandleRichText.h"
|
||||
#include "RsAutoUpdatePage.h"
|
||||
|
||||
#include "mainpage.h"
|
||||
@ -149,6 +150,15 @@ private:
|
||||
class QWidgetAction *widgetAction;
|
||||
class QSpacerItem *spacerItem;
|
||||
|
||||
///play the sound when recv a message
|
||||
void playsound();
|
||||
|
||||
QString fileName;
|
||||
|
||||
/** store default information for embedding HTML */
|
||||
RsChat::EmbedInHtmlAhref defEmbedAhref;
|
||||
RsChat::EmbedInHtmlImg defEmbedImg;
|
||||
|
||||
/* Worker Functions */
|
||||
/* (1) Update Display */
|
||||
|
||||
@ -174,7 +184,7 @@ private:
|
||||
QColor _currentColor;
|
||||
bool _underline;
|
||||
time_t last_status_send_time ;
|
||||
|
||||
|
||||
QHash<QString, QString> smileys;
|
||||
|
||||
std::map<std::string, PopupChatDialog *> chatDialogs;
|
||||
@ -188,5 +198,5 @@ private:
|
||||
Ui::PeersDialog ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1242,25 +1242,8 @@ void ChanMsgDialog::fileHashingFinished(AttachFileItem* file) {
|
||||
std::cerr << "ChanMsgDialog::anchorClicked mesgString : " << mesgString << std::endl;
|
||||
#endif
|
||||
|
||||
const char * messageString = mesgString.c_str ();
|
||||
|
||||
//convert char massageString to w_char
|
||||
wchar_t* message;
|
||||
size_t requiredSize = mbstowcs(NULL, messageString, 0); // C4996
|
||||
/* Add one to leave room for the NULL terminator */
|
||||
message = (wchar_t *)malloc( (requiredSize + 1) * sizeof( wchar_t ));
|
||||
if (! message) {
|
||||
std::cerr << ("Memory allocation failure.\n");
|
||||
}
|
||||
size_t size = mbstowcs( message, messageString, requiredSize + 1); // C4996
|
||||
if (size == (size_t) (-1)) {
|
||||
printf("Couldn't convert string--invalid multibyte character.\n");
|
||||
}
|
||||
|
||||
ui.msgText->setHtml(QString::fromStdWString(message));
|
||||
ui.msgText->textCursor().insertHtml(QString::fromStdString(mesgString));
|
||||
ui.msgText->setFocus( Qt::OtherFocusReason );
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ChanMsgDialog::checkAttachmentReady()
|
||||
|
Loading…
Reference in New Issue
Block a user