fixed utf8 issues in sending cert by email (patch from asamK #3393826)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4615 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2011-09-25 12:33:37 +00:00
parent ad4b0153b2
commit 4111740cb6

View file

@ -354,7 +354,7 @@ void TextPage::updateOwnCert()
//============================================================================ //============================================================================
// //
static void sendMail (std::string sAddress, std::string sSubject, std::string sBody) static void sendMail (QString sAddress, QString sSubject, QString sBody)
{ {
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
/* search and replace the end of lines with: "%0D%0A" */ /* search and replace the end of lines with: "%0D%0A" */
@ -364,20 +364,20 @@ static void sendMail (std::string sAddress, std::string sSubject, std::string sB
} }
#endif #endif
std::string mailstr = "mailto:" + sAddress; QUrl url = QUrl("mailto:" + sAddress);
mailstr += "?subject=" + sSubject; url.addEncodedQueryItem("subject", QUrl::toPercentEncoding(sSubject));
mailstr += "&body=" + sBody; url.addEncodedQueryItem("body", QUrl::toPercentEncoding(sBody));
std::cerr << "MAIL STRING:" << mailstr.c_str() << std::endl; std::cerr << "MAIL STRING:" << (std::string)url.toEncoded().constData() << std::endl;
/* pass the url directly to QDesktopServices::openUrl */ /* pass the url directly to QDesktopServices::openUrl */
QDesktopServices::openUrl (QUrl (QString::fromUtf8(mailstr.c_str()))); QDesktopServices::openUrl (url);
} }
void void
TextPage::runEmailClient() TextPage::runEmailClient()
{ {
sendMail ("", tr("RetroShare Invite").toStdString(), userCertEdit->toPlainText().toStdString()); sendMail ("", tr("RetroShare Invite"), userCertEdit->toPlainText());
} }
void TextPage::cleanFriendCert() void TextPage::cleanFriendCert()
@ -1300,10 +1300,10 @@ bool EmailPage::validatePage()
if (mailaddresses.isEmpty() == false) if (mailaddresses.isEmpty() == false)
{ {
std::string body = inviteTextEdit->toPlainText().toStdString(); QString body = inviteTextEdit->toPlainText();
body += "\n\n" + rsPeers->GetRetroshareInvite(false); body += "\n\n" + QString::fromUtf8(rsPeers->GetRetroshareInvite(false).c_str());
sendMail (mailaddresses.toStdString(), subjectEdit->text().toStdString(), body); sendMail (mailaddresses, subjectEdit->text(), body);
return true; return true;
} }