* Rolled back Modifications to SearchDialog and PopupChatDialog.

- unable to get windows to compile with PopupChat on windows.
	- not happy with new SearchDialog. Not an improvement on old dialog + uses Qt4.4

 * updated version numbers...
 * added a couple of windows scripts.
 


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1200 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2009-05-08 23:07:08 +00:00
parent 705a51ac1f
commit 65e02ba4de
13 changed files with 779 additions and 676 deletions

View file

@ -33,13 +33,9 @@
#include <QIcon>
#include <QPixmap>
#include <QHashIterator>
#include <QDesktopServices>
#include "rsiface/rspeers.h"
#include "rsiface/rsmsgs.h"
#include "rsiface/rsfiles.h"
#include "gui/feeds/SubFileItem.h"
#define appDir QApplication::applicationDirPath()
@ -80,8 +76,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
connect(ui.chattextEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) ));
connect(ui.sendButton, SIGNAL(clicked( ) ), this, SLOT(sendChat( ) ));
connect(ui.addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(ui.textboldButton, SIGNAL(clicked()), this, SLOT(setFont()));
connect(ui.textunderlineButton, SIGNAL(clicked()), this, SLOT(setFont()));
connect(ui.textitalicButton, SIGNAL(clicked()), this, SLOT(setFont()));
@ -90,13 +85,10 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
connect(ui.emoteiconButton, SIGNAL(clicked()), this, SLOT(smileyWidget()));
connect(ui.styleButton, SIGNAL(clicked()), SLOT(changeStyle()));
connect(ui.textBrowser, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
// Create the status bar
resetStatusBar() ;
ui.textBrowser->setOpenExternalLinks ( false );
ui.textBrowser->setOpenLinks ( false );
QString title = QString::fromStdString(name) + " :" + tr(" RetroShare - Encrypted Chat") ;
setWindowTitle(title);
@ -139,7 +131,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
void PopupChatDialog::resetStatusBar()
{
statusBar()->showMessage(tr("Chatting with ") + QString::fromStdString(dialogName) + " (" +QString::fromStdString(dialogId)+ ")") ;
statusBar()->showMessage(QString("Chatting with ") + QString::fromStdString(dialogName) + " (" +QString::fromStdString(dialogId)+ ")") ;
}
void PopupChatDialog::updateStatusTyping()
@ -251,19 +243,6 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
QString name = QString::fromStdString(ci ->name);
QString message = QString::fromStdWString(ci -> msg);
//replace url by a link
//first, avoid DTD link taht stands at the beginning of the string
QString messageSubString = message.mid(110, -1);
//replace http:// and www. with <a href> links
messageSubString.replace(QRegExp("(http://[^ <]*)|(www\\.[^ <]*)"), "<a href=\"\\1\\2\">\\1\\2</a>");
//rebuild the full message
message = message.left(109) + messageSubString;
#ifdef CHAT_DEBUG
std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() << std::endl;
#endif
/*QHashIterator<QString, QString> i(smileys);
while(i.hasNext())
{
@ -315,7 +294,7 @@ void PopupChatDialog::checkChat()
void PopupChatDialog::sendChat()
{
QTextEdit *chatWidget = ui.chattextEdit;
QTextEdit *chatWidget = ui.chattextEdit;
ChatInfo ci;
@ -699,123 +678,3 @@ void PopupChatDialog::getAvatar()
}
}
void PopupChatDialog::addExtraFile()
{
// select a file
QString qfile = QFileDialog::getOpenFileName(this, tr("Add Extra File"), "", "", 0,
QFileDialog::DontResolveSymlinks);
std::string filePath = qfile.toStdString();
if (filePath != "")
{
/* add a SubFileItem to the attachment section */
std::cerr << "PopupChatDialog::addExtraFile() hashing file.";
std::cerr << std::endl;
/* add widget in for new destination */
SubFileItem *file = new SubFileItem(filePath);
//file->
ui.vboxLayout->addWidget(file, 1, 0);
//when the file is local or is finished hashing, call the fileHashingFinished method to send a chat message
if (file->getState() == SFI_STATE_LOCAL) {
fileHashingFinished(file);
} else {
QObject::connect(file,SIGNAL(fileFinished(SubFileItem *)), SLOT(fileHashingFinished(SubFileItem *))) ;
}
}
}
void PopupChatDialog::fileHashingFinished(SubFileItem* file) {
std::cerr << "PopupChatDialog::fileHashingFinished() started.";
std::cerr << std::endl;
ChatInfo ci;
{
rsiface->lockData(); /* Lock Interface */
const RsConfig &conf = rsiface->getConfig();
ci.rsid = conf.ownId;
ci.name = conf.ownName;
rsiface->unlockData(); /* Unlock Interface */
}
//convert fileSize from uint_64 to string for html link
char fileSizeChar [100];
sprintf(fileSizeChar, "%lld", file->FileSize());
std::string fileSize = *(&fileSizeChar);
std::string mesgString = "<a href='file:?fileHash=" + (file->FileHash()) + "&fileName=" + (file->FileName()) + "&fileSize=" + fileSize + "'>" + (file->FileName()) + "</a>";
#ifdef CHAT_DEBUG
std::cerr << "PopupChatDialog::anchorClicked mesgString : " << mesgString << std::endl;
#endif
const char * messageString = mesgString.c_str ();
//convert char massageString to w_char
wchar_t* message;
int 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
if (size == (size_t) (-1))
{
printf("Couldn't convert string--invalid multibyte character.\n");
}
ci.msg = message;
ci.chatflags = RS_CHAT_PRIVATE;
addChatMsg(&ci);
/* put proper destination */
ci.rsid = dialogId;
ci.name = dialogName;
rsMsgs -> ChatSend(ci);
}
void PopupChatDialog::anchorClicked (const QUrl& link ) {
#ifdef CHAT_DEBUG
std::cerr << "PopupChatDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl;
#endif
if (link.scheme() == "file") {
std::string fileName = link.queryItemValue(QString("fileName")).toStdString();
std::string fileHash = link.queryItemValue(QString("fileHash")).toStdString();
uint32_t fileSize = link.queryItemValue(QString("fileSize")).toInt();
#ifdef CHAT_DEBUG
std::cerr << "PopupChatDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize;
std::cerr << ". source id : " << dialogId << std::endl;
#endif
if (fileName != "" &&
fileHash != "") {
std::list<std::string> srcIds;
srcIds.push_front(dialogId);
rsFiles->FileRequest(fileName, fileHash, fileSize, "", 0, srcIds);
QMessageBox mb(tr("File Request Confirmation"), tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0);
mb.setButtonText( QMessageBox::Ok, "OK" );
mb.exec();
} else {
QMessageBox mb(tr("File Request Error"), tr("The file link is malformed."),QMessageBox::Information,QMessageBox::Ok,0,0);
mb.setButtonText( QMessageBox::Ok, "OK" );
mb.exec();
}
} else if (link.scheme() == "http") {
QDesktopServices::openUrl(link);
} else if (link.scheme() == "") {
//it's probably a web adress, let's add http:// at the beginning of the link
QString newAddress = link.toString();
newAddress.prepend("http://");
QDesktopServices::openUrl(QUrl(newAddress));
}
}