Commit 306c1877 authored by Ronan Abhamon's avatar Ronan Abhamon

fix(Cli): better code to convert from base 64 (uri command)

parent 833be4c6
...@@ -149,24 +149,14 @@ void Cli::Command::execute (QHash<QString, QString> &args) const { ...@@ -149,24 +149,14 @@ void Cli::Command::execute (QHash<QString, QString> &args) const {
} }
} }
void Cli::Command::decode (QHash <QString,QString> &args) const{
QByteArray qa;
for (const auto &argName : args.keys()) {
if (argName != QString("sip-address")) {
qa.append(args[argName]);
args[argName] = QByteArray::fromBase64(qa);
qa.clear();
}
}
}
void Cli::Command::executeUri (const shared_ptr<linphone::Address> &address) const { void Cli::Command::executeUri (const shared_ptr<linphone::Address> &address) const {
QHash<QString, QString> args; QHash<QString, QString> args;
for (const auto &argName : mArgsScheme.keys()) for (const auto &argName : mArgsScheme.keys()) {
args[argName] = ::Utils::coreStringToAppString(address->getHeader(::Utils::appStringToCoreString(argName))); const string header = address->getHeader(::Utils::appStringToCoreString(argName));
args[argName] = QByteArray::fromBase64(QByteArray(header.c_str(), header.length()));
}
address->clean(); address->clean();
args["sip-address"] = ::Utils::coreStringToAppString(address->asStringUriOnly()); args["sip-address"] = ::Utils::coreStringToAppString(address->asStringUriOnly());
decode(args);
execute(args); execute(args);
} }
...@@ -237,7 +227,7 @@ void Cli::executeCommand (const QString &command, CommandFormat *format) const { ...@@ -237,7 +227,7 @@ void Cli::executeCommand (const QString &command, CommandFormat *format) const {
return; return;
} }
//TODO: check if there is any header when the `method` header is missing. // TODO: Check if there is any header when the `method` header is missing.
const QString functionName = ::Utils::coreStringToAppString(address->getHeader("method")).isEmpty() const QString functionName = ::Utils::coreStringToAppString(address->getHeader("method")).isEmpty()
? QStringLiteral("call") ? QStringLiteral("call")
: ::Utils::coreStringToAppString(address->getHeader("method")); : ::Utils::coreStringToAppString(address->getHeader("method"));
......
...@@ -63,7 +63,6 @@ class Cli : public QObject { ...@@ -63,7 +63,6 @@ class Cli : public QObject {
const QHash<QString, Argument> &argsScheme const QHash<QString, Argument> &argsScheme
); );
void decode (QHash<QString, QString> &args) const;
void execute (QHash<QString, QString> &args) const; void execute (QHash<QString, QString> &args) const;
void executeUri (const std::shared_ptr<linphone::Address> &address) const; void executeUri (const std::shared_ptr<linphone::Address> &address) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment