ported bugfix commits 4079,4080 and 4083 into 0.5.1 branch

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/0.5.1@4085 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2011-03-07 12:01:41 +00:00
parent fa6e9d8518
commit 21a019826b
11 changed files with 145 additions and 66 deletions

View file

@ -251,7 +251,13 @@ int ftFileCreator::locked_initializeFileAttrs()
* attempt to open file * attempt to open file
*/ */
#ifdef WINDOWS_SYS
std::wstring wfile_name;
librs::util::ConvertUtf8ToUtf16(file_name, wfile_name);
fd = _wfopen(wfile_name.c_str(), L"r+b");
#else
fd = fopen64(file_name.c_str(), "r+b"); fd = fopen64(file_name.c_str(), "r+b");
#endif
if (!fd) if (!fd)
{ {
@ -262,7 +268,11 @@ int ftFileCreator::locked_initializeFileAttrs()
std::cerr << std::endl; std::cerr << std::endl;
/* try opening for write */ /* try opening for write */
#ifdef WINDOWS_SYS
fd = _wfopen(wfile_name.c_str(), L"w+b");
#else
fd = fopen64(file_name.c_str(), "w+b"); fd = fopen64(file_name.c_str(), "w+b");
#endif
if (!fd) if (!fd)
{ {
std::cerr << "ftFileCreator::initializeFileAttrs()"; std::cerr << "ftFileCreator::initializeFileAttrs()";

View file

@ -60,7 +60,16 @@ RSA *extractPrivateKey(RsTlvSecurityKey &key);
void setRSAPublicKey(RsTlvSecurityKey &key, RSA *rsa_pub); void setRSAPublicKey(RsTlvSecurityKey &key, RSA *rsa_pub);
void setRSAPrivateKey(RsTlvSecurityKey &key, RSA *rsa_priv); void setRSAPrivateKey(RsTlvSecurityKey &key, RSA *rsa_priv);
GroupInfo::~GroupInfo()
{
delete distribGroup ;
for(std::map<std::string, RsDistribMsg *>::const_iterator it(msgs.begin());it!=msgs.end();++it)
delete it->second ;
for(std::map<std::string, RsDistribMsg *>::const_iterator it(decrypted_msg_cache.begin());it!=decrypted_msg_cache.end();++it)
delete it->second ;
}
p3GroupDistrib::p3GroupDistrib(uint16_t subtype, p3GroupDistrib::p3GroupDistrib(uint16_t subtype,
CacheStrapper *cs, CacheTransfer *cft, CacheStrapper *cs, CacheTransfer *cft,
@ -88,6 +97,14 @@ p3GroupDistrib::p3GroupDistrib(uint16_t subtype,
return; return;
} }
p3GroupDistrib::~p3GroupDistrib()
{
for(std::map<std::string, RsDistribGrpKey* >::iterator it(mRecvdPubKeys.begin());it!=mRecvdPubKeys.end();++it)
delete it->second ;
for(std::list<RsDistribSignedMsg*>::iterator it(mPendingPublish.begin());it!=mPendingPublish.end();++it)
delete *it ;
}
int p3GroupDistrib::tick() int p3GroupDistrib::tick()
{ {

View file

@ -169,6 +169,7 @@ class GroupInfo
{ {
return; return;
} }
virtual ~GroupInfo() ;
std::string grpId; /// the group id std::string grpId; /// the group id
RsDistribGrp *distribGroup; /// item which contains further information on group RsDistribGrp *distribGroup; /// item which contains further information on group
@ -297,6 +298,7 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
uint32_t configId, uint32_t configId,
uint32_t storePeriod, uint32_t pubPeriod); uint32_t storePeriod, uint32_t pubPeriod);
virtual ~p3GroupDistrib() ;
/***************************************************************************************/ /***************************************************************************************/
/******************************* CACHE SOURCE / STORE Interface ************************/ /******************************* CACHE SOURCE / STORE Interface ************************/

View file

@ -501,24 +501,18 @@ void p3MsgService::loadWelcomeMsg()
/* Load Welcome Message */ /* Load Welcome Message */
RsMsgItem *msg = new RsMsgItem(); RsMsgItem *msg = new RsMsgItem();
//msg -> PeerId(mConnMgr->getOwnId()); //msg -> PeerId(mConnMgr->getOwnId());
msg -> sendTime = time(NULL); msg -> sendTime = time(NULL);
msg -> recvTime = time(NULL); msg -> recvTime = time(NULL);
msg -> msgFlags = RS_MSG_FLAGS_NEW; msg -> msgFlags = RS_MSG_FLAGS_NEW;
msg -> subject = L"Welcome to Retroshare"; msg -> subject = L"Welcome to Retroshare";
msg -> message = L"Send and receive messages\n"; msg -> message = L"Send and receive messages with your friends...\n";
msg -> message += L"with your friends...\n\n"; msg -> message += L"These can hold recommendations from your local shared files.\n\n";
msg -> message += L"Add recommendations through the Local Files Dialog.\n\n";
msg -> message += L"These can hold recommendations\n"; msg -> message += L"Enjoy.";
msg -> message += L"from your local shared files\n\n";
msg -> message += L"Add recommendations through\n";
msg -> message += L"the Local Files Dialog\n\n";
msg -> message += L"Enjoy.\n";
msg -> msgId = getNewUniqueMsgId(); msg -> msgId = getNewUniqueMsgId();
@ -1280,11 +1274,11 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
{ {
mi.msgflags |= RS_MSG_PENDING; mi.msgflags |= RS_MSG_PENDING;
} }
if (msg->msgFlags & RS_MSG_FLAGS_DRAFT) if (msg->msgFlags & RS_MSG_FLAGS_DRAFT)
{ {
mi.msgflags |= RS_MSG_DRAFT; mi.msgflags |= RS_MSG_DRAFT;
} }
if (msg->msgFlags & RS_MSG_FLAGS_NEW) if (msg->msgFlags & RS_MSG_FLAGS_NEW)
{ {
mi.msgflags |= RS_MSG_NEW; mi.msgflags |= RS_MSG_NEW;
} }
@ -1292,7 +1286,7 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
{ {
mi.msgflags |= RS_MSG_TRASH; mi.msgflags |= RS_MSG_TRASH;
} }
if (msg->msgFlags & RS_MSG_FLAGS_UNREAD_BY_USER) if (msg->msgFlags & RS_MSG_FLAGS_UNREAD_BY_USER)
{ {
mi.msgflags |= RS_MSG_UNREAD_BY_USER; mi.msgflags |= RS_MSG_UNREAD_BY_USER;
} }
@ -1348,7 +1342,7 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
it != msg->attachment.items.end(); it++) it != msg->attachment.items.end(); it++)
{ {
FileInfo fi; FileInfo fi;
fi.fname = RsDirUtil::getTopDir(it->name); fi.fname = RsDirUtil::getTopDir(it->name);
fi.size = it->filesize; fi.size = it->filesize;
fi.hash = it->hash; fi.hash = it->hash;
fi.path = it->path; fi.path = it->path;
@ -1375,11 +1369,11 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
{ {
mis.msgflags |= RS_MSG_PENDING; mis.msgflags |= RS_MSG_PENDING;
} }
if (msg->msgFlags & RS_MSG_FLAGS_DRAFT) if (msg->msgFlags & RS_MSG_FLAGS_DRAFT)
{ {
mis.msgflags |= RS_MSG_DRAFT; mis.msgflags |= RS_MSG_DRAFT;
} }
if (msg->msgFlags & RS_MSG_FLAGS_NEW) if (msg->msgFlags & RS_MSG_FLAGS_NEW)
{ {
mis.msgflags |= RS_MSG_NEW; mis.msgflags |= RS_MSG_NEW;
} }

View file

@ -426,54 +426,70 @@ bool RsDirUtil::checkDirectory(const std::string& dir)
bool RsDirUtil::checkCreateDirectory(const std::string& dir) bool RsDirUtil::checkCreateDirectory(const std::string& dir)
{ {
#ifdef RSDIR_DEBUG #ifdef RSDIR_DEBUG
std::cerr << "RsDirUtil::checkCreateDirectory() dir: " << dir << std::endl; std::cerr << "RsDirUtil::checkCreateDirectory() dir: " << dir << std::endl;
#endif #endif
DIR *direc = opendir(dir.c_str());
if (!direc) #ifdef WINDOWS_SYS
{ std::wstring wdir;
// directory don't exist. create. librs::util::ConvertUtf8ToUtf16(dir, wdir);
_WDIR *direc = _wopendir(wdir.c_str());
if (!direc)
#else
DIR *direc = opendir(dir.c_str());
if (!direc)
#endif
{
// directory don't exist. create.
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ /******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS // UNIX #ifndef WINDOWS_SYS // UNIX
if (-1 == mkdir(dir.c_str(), 0777)) if (-1 == mkdir(dir.c_str(), 0777))
#else // WIN #else // WIN
if (-1 == mkdir(dir.c_str())) if (-1 == _wmkdir(wdir.c_str()))
#endif #endif
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ /******************************** WINDOWS/UNIX SPECIFIC PART ******************/
{ {
#ifdef RSDIR_DEBUG #ifdef RSDIR_DEBUG
std::cerr << "check_create_directory() Fatal Error et oui--"; std::cerr << "check_create_directory() Fatal Error et oui--";
std::cerr <<std::endl<< "\tcannot create:" <<dir<<std::endl; std::cerr <<std::endl<< "\tcannot create:" <<dir<<std::endl;
#endif #endif
return 0; return 0;
} }
#ifdef RSDIR_DEBUG #ifdef RSDIR_DEBUG
std::cerr << "check_create_directory()"; std::cerr << "check_create_directory()";
std::cerr <<std::endl<< "\tcreated:" <<dir<<std::endl; std::cerr <<std::endl<< "\tcreated:" <<dir<<std::endl;
#endif #endif
return 1; return 1;
} }
#ifdef RSDIR_DEBUG #ifdef RSDIR_DEBUG
std::cerr << "check_create_directory()"; std::cerr << "check_create_directory()";
std::cerr <<std::endl<< "\tDir Exists:" <<dir<<std::endl; std::cerr <<std::endl<< "\tDir Exists:" <<dir<<std::endl;
#endif #endif
closedir(direc) ;
return 1;
}
//#include <sys/types.h> #ifdef WINDOWS_SYS
//#include <sys/stat.h> _wclosedir(direc);
//#include <fcntl.h> #else
//#include <unistd.h> closedir(direc) ;
#endif
return 1;
}
bool RsDirUtil::cleanupDirectory(const std::string& cleandir, const std::list<std::string> &keepFiles) bool RsDirUtil::cleanupDirectory(const std::string& cleandir, const std::list<std::string> &keepFiles)
{ {
/* check for the dir existance */ /* check for the dir existance */
#ifdef WINDOWS_SYS
std::wstring wcleandir;
librs::util::ConvertUtf8ToUtf16(cleandir, wcleandir);
_WDIR *dir = _wopendir(wcleandir.c_str());
#else
DIR *dir = opendir(cleandir.c_str()); DIR *dir = opendir(cleandir.c_str());
#endif
std::list<std::string>::const_iterator it; std::list<std::string>::const_iterator it;
if (!dir) if (!dir)
@ -481,31 +497,60 @@ bool RsDirUtil::cleanupDirectory(const std::string& cleandir, const std::list<s
return false; return false;
} }
#ifdef WINDOWS_SYS
struct _wdirent *dent;
struct _stat buf;
while(NULL != (dent = _wreaddir(dir)))
#else
struct dirent *dent; struct dirent *dent;
struct stat buf; struct stat buf;
while(NULL != (dent = readdir(dir))) while(NULL != (dent = readdir(dir)))
#endif
{ {
/* check entry type */ /* check entry type */
#ifdef WINDOWS_SYS
const std::wstring &wfname = dent -> d_name;
std::wstring wfullname = wcleandir + L"/" + wfname;
#else
const std::string &fname = dent -> d_name; const std::string &fname = dent -> d_name;
std::string fullname = cleandir + "/" + fname; std::string fullname = cleandir + "/" + fname;
#endif
if (-1 != stat(fullname.c_str(), &buf)) #ifdef WINDOWS_SYS
if (-1 != _wstat(wfullname.c_str(), &buf))
#else
if (-1 != stat(fullname.c_str(), &buf))
#endif
{ {
/* only worry about files */ /* only worry about files */
if (S_ISREG(buf.st_mode)) if (S_ISREG(buf.st_mode))
{ {
#ifdef WINDOWS_SYS
std::string fname;
librs::util::ConvertUtf16ToUtf8(wfname, fname);
#endif
/* check if we should keep it */ /* check if we should keep it */
if (keepFiles.end() == (it = std::find(keepFiles.begin(), keepFiles.end(), fname))) if (keepFiles.end() == (it = std::find(keepFiles.begin(), keepFiles.end(), fname)))
{ {
/* can remove */ /* can remove */
#ifdef WINDOWS_SYS
_wremove(wfullname.c_str());
#else
remove(fullname.c_str()); remove(fullname.c_str());
#endif
} }
} }
} }
} }
/* close directory */ /* close directory */
#ifdef WINDOWS_SYS
_wclosedir(dir);
#else
closedir(dir); closedir(dir);
#endif
return true; return true;
} }

View file

@ -63,6 +63,12 @@ NetworkView::NetworkView(QWidget *parent)
_should_update = true ; _should_update = true ;
} }
NetworkView::~NetworkView()
{
if(mScene != NULL)
delete mScene ;
}
void NetworkView::setEdgeLength(int l) void NetworkView::setEdgeLength(int l)
{ {
ui.graphicsView->setEdgeLength(l); ui.graphicsView->setEdgeLength(l);

View file

@ -34,6 +34,7 @@ class NetworkView : public RsAutoUpdatePage
public: public:
NetworkView(QWidget *parent = 0); NetworkView(QWidget *parent = 0);
virtual ~NetworkView();
virtual void updateDisplay() ; // derived from RsAutoUpdatePage virtual void updateDisplay() ; // derived from RsAutoUpdatePage

View file

@ -67,7 +67,7 @@ ShareDialog::ShareDialog(std::string filename, QWidget *parent, Qt::WFlags flags
void ShareDialog::browseDirectory() void ShareDialog::browseDirectory()
{ {
/* select a dir*/ /* select a dir*/
QString qdir = QFileDialog::getExistingDirectory(this, tr("Select A Folder To Share"), "", QFileDialog::DontUseNativeDialog | QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); QString qdir = QFileDialog::getExistingDirectory(this, tr("Select A Folder To Share"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
/* add it to the server */ /* add it to the server */
if (qdir.isEmpty()) { if (qdir.isEmpty()) {

View file

@ -1339,7 +1339,7 @@ void TransfersDialog::openFolderTransfer()
} }
/* open folder with a suitable application */ /* open folder with a suitable application */
qinfo.setFile(path.c_str()); qinfo.setFile(QString::fromUtf8(path.c_str()));
if (qinfo.exists() && qinfo.isDir()) { if (qinfo.exists() && qinfo.isDir()) {
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) { if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
std::cerr << "openFolderTransfer(): can't open folder " << path << std::endl; std::cerr << "openFolderTransfer(): can't open folder " << path << std::endl;
@ -1379,16 +1379,16 @@ void TransfersDialog::previewTransfer()
/* open or preview them with a suitable application */ /* open or preview them with a suitable application */
QFileInfo qinfo; QFileInfo qinfo;
if (complete) { if (complete) {
qinfo.setFile(QString::fromStdString(path)); qinfo.setFile(QString::fromUtf8(path.c_str()));
if (qinfo.exists()) { if (qinfo.exists()) {
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) { if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
std::cerr << "previewTransfer(): can't preview file " << path << std::endl; std::cerr << "previewTransfer(): can't preview file " << path << std::endl;
} }
} }
} else { } else {
QString linkName = QString::fromStdString(path) + QString linkName = QString::fromUtf8(path.c_str()) +
QString::fromStdString(info.fname.substr(info.fname.find_last_of('.'))); QString::fromUtf8(info.fname.substr(info.fname.find_last_of('.')).c_str());
if (QFile::link(QString::fromStdString(path), linkName)) { if (QFile::link(QString::fromUtf8(path.c_str()), linkName)) {
qinfo.setFile(linkName); qinfo.setFile(linkName);
if (qinfo.exists()) { if (qinfo.exists()) {
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) { if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
@ -1427,7 +1427,7 @@ void TransfersDialog::openTransfer()
/* open file with a suitable application */ /* open file with a suitable application */
QFileInfo qinfo; QFileInfo qinfo;
qinfo.setFile(path.c_str()); qinfo.setFile(QString::fromUtf8(path.c_str()));
if (qinfo.exists()) { if (qinfo.exists()) {
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) { if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
std::cerr << "openTransfer(): can't open file " << path << std::endl; std::cerr << "openTransfer(): can't open file " << path << std::endl;
@ -1436,7 +1436,7 @@ void TransfersDialog::openTransfer()
} else { } else {
/* rise a message box for incompleted download file */ /* rise a message box for incompleted download file */
QMessageBox::information(this, tr("Open Transfer"), QMessageBox::information(this, tr("Open Transfer"),
tr("File %1 is not completed. If it is a media file, try to preview it.").arg(info.fname.c_str())); tr("File %1 is not completed. If it is a media file, try to preview it.").arg(QString::fromUtf8(info.fname.c_str())));
} }
} }

View file

@ -19,6 +19,7 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include <QTextBrowser>
#include "HandleRichText.h" #include "HandleRichText.h"
@ -49,7 +50,12 @@ QString formatText(const QString &text, unsigned int flag)
} }
QDomDocument doc; QDomDocument doc;
doc.setContent(text); if (doc.setContent(text) == false) {
// convert text with QTextBrowser
QTextBrowser textBrowser;
textBrowser.setText(text);
doc.setContent(textBrowser.toHtml());
}
QDomElement body = doc.documentElement(); QDomElement body = doc.documentElement();
if (flag & RSHTML_FORMATTEXT_EMBED_SMILEYS) { if (flag & RSHTML_FORMATTEXT_EMBED_SMILEYS) {

View file

@ -220,10 +220,9 @@ void DirectoriesPage::removeShareDirectory()
void DirectoriesPage::setIncomingDirectory() void DirectoriesPage::setIncomingDirectory()
{ {
QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Incoming Directory"), "", QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Incoming Directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
std::string dir = qdir.toStdString(); std::string dir = qdir.toUtf8().constData();
if (dir != "") if (dir != "")
{ {
rsFiles->setDownloadDirectory(dir); rsFiles->setDownloadDirectory(dir);
@ -249,10 +248,9 @@ void DirectoriesPage::setIncomingDirectory()
void DirectoriesPage::setPartialsDirectory() void DirectoriesPage::setPartialsDirectory()
{ {
QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Partials Directory"), "", QString qdir = QFileDialog::getExistingDirectory(this, tr("Set Partials Directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
std::string dir = qdir.toStdString(); std::string dir = qdir.toUtf8().constData();
if (dir != "") if (dir != "")
{ {
rsFiles->setPartialsDirectory(dir); rsFiles->setPartialsDirectory(dir);