mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-28 01:09:19 +00:00
Fix using only username in URI handlers.
This commit is contained in:
parent
02e0253241
commit
4a1cfe0c91
4 changed files with 24 additions and 4 deletions
|
|
@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- File viewer in chats (Image/Animated Image/Video/Texts) with the option to export the file.
|
||||
- Accept/decline CLI commands.
|
||||
|
||||
## 5.0.15 - undefined
|
||||
|
||||
## Fixed
|
||||
- Fix using only username in URI handlers.
|
||||
|
||||
## 5.0.14 - 2023-03-16
|
||||
|
||||
## Fixed
|
||||
|
|
|
|||
|
|
@ -336,6 +336,8 @@ void Cli::Command::execute (QHash<QString, QString> &args) const {
|
|||
void Cli::Command::executeUri (const shared_ptr<linphone::Address> &address) const {
|
||||
QHash<QString, QString> args;
|
||||
QString qAddress = Utils::coreStringToAppString(address->asString());
|
||||
if(address->getDomain() == "" && qAddress.back() == '@')
|
||||
qAddress.remove(qAddress.size()-1, 1);
|
||||
QUrl url(qAddress);
|
||||
QString query = url.query();
|
||||
|
||||
|
|
@ -355,7 +357,7 @@ void Cli::Command::executeUri (const shared_ptr<linphone::Address> &address) con
|
|||
const string header = address->getHeader(Utils::appStringToCoreString(argName));
|
||||
args[argName] = QByteArray::fromBase64(QByteArray(header.c_str(), int(header.length())));
|
||||
}
|
||||
args["sip-address"] = Utils::coreStringToAppString(address->asString());
|
||||
args["sip-address"] = qAddress;
|
||||
execute(args);
|
||||
}
|
||||
|
||||
|
|
@ -501,15 +503,21 @@ void Cli::executeCommand (const QString &command, CommandFormat *format) {
|
|||
*format = CliFormat;
|
||||
mCommands["show"].execute(args);
|
||||
}else{
|
||||
shared_ptr<linphone::Address> address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(transformedCommand));// Test if command is an address
|
||||
shared_ptr<linphone::Address> address;
|
||||
if(Utils::isUsername(transformedCommand)){
|
||||
address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(transformedCommand+"@to.remove"));
|
||||
if(address)
|
||||
address->setDomain("");
|
||||
}else
|
||||
address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(transformedCommand));// Test if command is an address
|
||||
if (format)
|
||||
*format = UriFormat;
|
||||
qInfo() << QStringLiteral("Detecting URI command: `%1`...").arg(command);
|
||||
QString functionName;
|
||||
if( address) {
|
||||
functionName = Utils::coreStringToAppString(address->getHeader("method")).isEmpty()
|
||||
? QStringLiteral("call")
|
||||
: Utils::coreStringToAppString(address->getHeader("method"));
|
||||
? QStringLiteral("call")
|
||||
: Utils::coreStringToAppString(address->getHeader("method"));
|
||||
}else{
|
||||
QStringList fields = command.split('?');
|
||||
if(fields.size() >1){
|
||||
|
|
|
|||
|
|
@ -623,6 +623,12 @@ bool Utils::isPhoneNumber(const QString& txt){
|
|||
return account && account->isPhoneNumber(Utils::appStringToCoreString(txt));
|
||||
}
|
||||
|
||||
bool Utils::isUsername(const QString& txt){
|
||||
QRegularExpression regex("^(<?sips?:)?[a-zA-Z0-9+_.\\-]+>?$");
|
||||
QRegularExpressionMatch match = regex.match(txt);
|
||||
return match.hasMatch(); // true
|
||||
}
|
||||
|
||||
QSize Utils::getImageSize(const QString& url){
|
||||
QString path;
|
||||
QUrl urlDecode(url);
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ public:
|
|||
Q_INVOKABLE static bool isMe(const QString& address);
|
||||
Q_INVOKABLE static bool isAnimatedImage(const QString& path);
|
||||
Q_INVOKABLE static bool isPhoneNumber(const QString& txt);
|
||||
Q_INVOKABLE static bool isUsername(const QString& txt); // Check with Regex
|
||||
Q_INVOKABLE QSize getImageSize(const QString& url);
|
||||
Q_INVOKABLE static QPoint getCursorPosition();
|
||||
Q_INVOKABLE static QString getFileChecksum(const QString& filePath);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue