Use LocalUtf8 for all transactions rather than stdString

This commit is contained in:
Julien Wadel 2020-03-28 10:31:30 +01:00
parent b22c1c3f99
commit 7c0f80dceb
8 changed files with 27 additions and 27 deletions

View file

@ -70,7 +70,7 @@ static inline bool filePathExists (const QString &path) {
static inline void ensureDirPathExists (const QString &path) {
QDir dir(path);
if (!dir.exists() && !dir.mkpath(path))
qFatal("Unable to access at directory: `%s`", path.toStdString().c_str());
qFatal("Unable to access at directory: `%s`", Utils::appStringToCoreString(path).c_str());
}
static inline void ensureFilePathExists (const QString &path) {
@ -79,7 +79,7 @@ static inline void ensureFilePathExists (const QString &path) {
QFile file(path);
if (!file.exists() && !file.open(QIODevice::ReadWrite))
qFatal("Unable to access at path: `%s`", path.toStdString().c_str());
qFatal("Unable to access at path: `%s`", Utils::appStringToCoreString(path).c_str());
}
static inline string getReadableDirPath (const QString &dirname) {

View file

@ -105,7 +105,7 @@ QVector<MessageAppData> MessageAppData::fromListString(const QString& p_data)
// There is only one file (thumbnail) in appdata
static inline MessageAppData getMessageAppData (const shared_ptr<linphone::ChatMessage> &message) {
return MessageAppData(QString::fromStdString(message->getAppdata()));
return MessageAppData(Utils::coreStringToAppString(message->getAppdata()));
}
static inline bool fileWasDownloaded (const shared_ptr<linphone::ChatMessage> &message) {
@ -130,7 +130,7 @@ static inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &mes
if( contents.size() > 0)
{
MessageAppData thumbnailData;
thumbnailData.m_path = QString::fromStdString(contents.front()->getFilePath());
thumbnailData.m_path = Utils::coreStringToAppString(contents.front()->getFilePath());
QImage image(thumbnailData.m_path);
if (image.isNull())
return;
@ -167,7 +167,7 @@ static inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &mes
return;
}
message->setAppdata(thumbnailData.toString().toStdString());
message->setAppdata(Utils::appStringToCoreString(thumbnailData.toString()));
}
}
@ -177,7 +177,7 @@ static inline void removeFileMessageThumbnail (const shared_ptr<linphone::ChatMe
MessageAppData thumbnailFile = getMessageAppData(message);
if(thumbnailFile.m_id.size() > 0)
{
QString thumbnailPath = QString::fromStdString(Paths::getThumbnailsDirPath()) + thumbnailFile.m_id;
QString thumbnailPath = Utils::coreStringToAppString(Paths::getThumbnailsDirPath()) + thumbnailFile.m_id;
if (!QFile::remove(thumbnailPath))
qWarning() << QStringLiteral("Unable to remove `%1`.").arg(thumbnailPath);
}
@ -523,7 +523,7 @@ void ChatModel::sendFileMessage (const QString &path) {
content->setName(Utils::appStringToCoreString(QFileInfo(file).fileName()));
shared_ptr<linphone::ChatMessage> message = mChatRoom->createFileTransferMessage(content);
message->getContents().front()->setFilePath(path.toStdString());// Sending only one File Path?
message->getContents().front()->setFilePath(Utils::appStringToCoreString(path));// Sending only one File Path?
message->addListener(mMessageHandlers);
createThumbnail(message);
@ -568,7 +568,7 @@ void ChatModel::downloadFile (int id) {
}
message->addListener(mMessageHandlers);
message->getContents().front()->setFilePath(safeFilePath.toStdString());
message->getContents().front()->setFilePath(Utils::appStringToCoreString(safeFilePath));
if( !message->isFileTransfer())
QMessageBox::warning(nullptr, "Download File", "This file was already downloaded and is no more on the server. Your peer have to resend it if you want to get it");

View file

@ -107,7 +107,7 @@ static bool downloadUpdatableCodec (
qWarning() << QStringLiteral("Unable to write codec version in: `%1`.").arg(versionFilePath);
return;
}
if (versionFile.write(downloadUrl.toStdString().c_str(), downloadUrl.length()) == -1) {
if (versionFile.write(Utils::appStringToCoreString(downloadUrl).c_str(), downloadUrl.length()) == -1) {
fileExtractor->remove();
versionFile.close();
versionFile.remove();

View file

@ -117,21 +117,21 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
{
const shared_ptr<const linphone::Address> address = proxyConfig->getIdentityAddress();
map["sipAddress"] = address
? QString::fromStdString(proxyConfig->getIdentityAddress()->asString())
? Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString())
: QString("");
}
map["serverAddress"] = QString::fromStdString(proxyConfig->getServerAddr());
map["serverAddress"] = Utils::coreStringToAppString(proxyConfig->getServerAddr());
map["registrationDuration"] = proxyConfig->getPublishExpires();
if( map["serverAddress"].toString().toUpper().contains("TRANSPORT="))// transport has been specified : let the RFC select the transport
map["transport"] = QString::fromStdString(proxyConfig->getTransport());
map["transport"] = Utils::coreStringToAppString(proxyConfig->getTransport());
else// Set to TLS as default
map["transport"] = "tls";
if( proxyConfig->getRoutes().size() > 0)
map["route"] = QString::fromStdString(proxyConfig->getRoutes().front());
map["route"] = Utils::coreStringToAppString(proxyConfig->getRoutes().front());
else
map["route"] = "";
map["contactParams"] = QString::fromStdString(proxyConfig->getContactParameters());
map["contactParams"] = Utils::coreStringToAppString(proxyConfig->getContactParameters());
map["avpfInterval"] = proxyConfig->getAvpfRrInterval();
map["registerEnabled"] = proxyConfig->registerEnabled();
map["publishPresence"] = proxyConfig->publishEnabled();
@ -148,8 +148,8 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
const string &turnUser(natPolicy->getStunServerUsername());
const string &stunServer(natPolicy->getStunServer());
map["turnUser"] = QString::fromStdString(turnUser);
map["stunServer"] = QString::fromStdString(stunServer);
map["turnUser"] = Utils::coreStringToAppString(turnUser);
map["stunServer"] = Utils::coreStringToAppString(stunServer);
if (createdNat)
proxyConfig->setNatPolicy(natPolicy);
@ -251,8 +251,8 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
natPolicy->enableIce(data["iceEnabled"].toBool());
natPolicy->enableStun(data["iceEnabled"].toBool());
const string turnUser(data["turnUser"].toString().toStdString());
const string stunServer(data["stunServer"].toString().toStdString());
const string turnUser(Utils::appStringToCoreString(data["turnUser"].toString()));
const string stunServer(Utils::appStringToCoreString(data["stunServer"].toString()));
natPolicy->enableTurn(data["turnEnabled"].toBool());
natPolicy->setStunServerUsername(turnUser);
@ -267,7 +267,7 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
shared_ptr<linphone::AuthInfo> clonedAuthInfo(authInfo->clone());
clonedAuthInfo->setUserid(turnUser);
clonedAuthInfo->setUsername(turnUser);
clonedAuthInfo->setPassword(data["turnPassword"].toString().toStdString());
clonedAuthInfo->setPassword(Utils::appStringToCoreString(data["turnPassword"].toString()));
core->addAuthInfo(clonedAuthInfo);
core->removeAuthInfo(authInfo);
@ -275,7 +275,7 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
core->addAuthInfo(linphone::Factory::get()->createAuthInfo(
turnUser,
turnUser,
data["turnPassword"].toString().toStdString(),
Utils::appStringToCoreString(data["turnPassword"].toString()),
"",
"",
""

View file

@ -166,7 +166,7 @@ void SettingsModel::createCaptureGraph() {
}
if (!mSimpleCaptureGraph) {
mSimpleCaptureGraph =
new MediastreamerUtils::SimpleCaptureGraph(getCaptureDevice().toStdString(), getPlaybackDevice().toStdString());
new MediastreamerUtils::SimpleCaptureGraph(Utils::appStringToCoreString(getCaptureDevice()), Utils::appStringToCoreString(getPlaybackDevice()));
}
mSimpleCaptureGraph->start();
emit captureGraphRunningChanged(getCaptureGraphRunning());

View file

@ -454,8 +454,8 @@ void SipAddressesModel::addOrUpdateSipAddress (SipAddressEntry &sipAddressEntry,
: QDateTime::fromMSecsSinceEpoch(callLog->getStartDate() * 1000);
if (callLog->getStatus() == linphone::Call::Status::Missed) {
for (auto &observer : mObservers.values(QString::fromStdString((callLog->getRemoteAddress()->asStringUriOnly())))) {
if (observer->getLocalAddress() == QString::fromStdString(callLog->getLocalAddress()->asStringUriOnly())) {
for (auto &observer : mObservers.values(Utils::coreStringToAppString((callLog->getRemoteAddress()->asStringUriOnly())))) {
if (observer->getLocalAddress() == Utils::coreStringToAppString(callLog->getLocalAddress()->asStringUriOnly())) {
observer->setUnreadMessageCount(1);
}
}

View file

@ -37,10 +37,10 @@ SimpleCaptureGraph::SimpleCaptureGraph(const std::string &capture, const std::st
playbackCard = ms_snd_card_manager_get_card(ms_factory_get_snd_card_manager(msFactory), playbackCardId.c_str());
if (!playbackCard)
qWarning("Cannot get playback card from MSFactory with : %s", playbackCardId.c_str());
qWarning("Cannot get playback card from MSFactory with : %s", playbackCardId.c_str());
captureCard = ms_snd_card_manager_get_card(ms_factory_get_snd_card_manager(msFactory), captureCardId.c_str());
if (!captureCard)
qWarning("Cannot get capture card from MSFactory with : %s", captureCardId.c_str());
qWarning("Cannot get capture card from MSFactory with : %s", captureCardId.c_str());
if(playbackCard && captureCard)// Assure to initialize when playback and capture are available
init();

View file

@ -40,11 +40,11 @@
namespace Utils {
inline QString coreStringToAppString (const std::string &str) {
return QString::fromLocal8Bit(str.c_str(), int(str.size()));
return QString::fromLocal8Bit(str.c_str(), int(str.size()));
}
inline std::string appStringToCoreString (const QString &str) {
return qPrintable(str);
return qPrintable(str);
}
// Reverse function of strstr.