diff --git a/linphone-app/assets/linphone.desktop.cmake b/linphone-app/assets/linphone.desktop.cmake index 22e4f821d..2889e7b26 100644 --- a/linphone-app/assets/linphone.desktop.cmake +++ b/linphone-app/assets/linphone.desktop.cmake @@ -7,5 +7,5 @@ Exec=@EXECUTABLE_NAME@ %u Icon=@EXECUTABLE_NAME@ Terminal=false Categories=Network;Telephony; -MimeType=x-scheme-handler/sip-linphone;x-scheme-handler/sip;x-scheme-handler/sips-linphone;x-scheme-handler/sips;x-scheme-handler/tel;x-scheme-handler/callto;x-scheme-handler/linphone-config; +MimeType=x-scheme-handler/sip-@EXECUTABLE_NAME@;x-scheme-handler/sip;x-scheme-handler/sips-@EXECUTABLE_NAME@;x-scheme-handler/sips;x-scheme-handler/tel;x-scheme-handler/callto;x-scheme-handler/@EXECUTABLE_NAME@-config; X-PulseAudio-Properties=media.role=phone diff --git a/linphone-app/cmake_builder/linphone_package/macos/Info.plist.in b/linphone-app/cmake_builder/linphone_package/macos/Info.plist.in index d0a3d98c8..4d9277691 100644 --- a/linphone-app/cmake_builder/linphone_package/macos/Info.plist.in +++ b/linphone-app/cmake_builder/linphone_package/macos/Info.plist.in @@ -40,12 +40,12 @@ CFBundleURLSchemes sip - sip-linphone + sip-@EXECUTABLE_NAME@ sips - sips-linphone + sips-@EXECUTABLE_NAME@ tel callto - linphone-config + @EXECUTABLE_NAME@-config diff --git a/linphone-app/cmake_builder/linphone_package/windows/install.nsi.in b/linphone-app/cmake_builder/linphone_package/windows/install.nsi.in index f1cdc0ce7..11fc8e0d9 100644 --- a/linphone-app/cmake_builder/linphone_package/windows/install.nsi.in +++ b/linphone-app/cmake_builder/linphone_package/windows/install.nsi.in @@ -16,17 +16,17 @@ WriteRegStr HKLM "SOFTWARE\IM Providers\@APPLICATION_NAME@" "FriendlyName" "@APP WriteRegStr HKCR "sip" "" "URL:sip Protocol" WriteRegStr HKCR "sip" "URL Protocol" "" -WriteRegStr HKCR "sip-linphone" "" "URL:sip-linphone Protocol" -WriteRegStr HKCR "sip-linphone" "URL Protocol" "" +WriteRegStr HKCR "sip-@EXECUTABLE_NAME@" "" "URL:sip-@EXECUTABLE_NAME@ Protocol" +WriteRegStr HKCR "sip-@EXECUTABLE_NAME@" "URL Protocol" "" -WriteRegStr HKCR "linphone-config" "" "URL:linphone-config Protocol" -WriteRegStr HKCR "linphone-config" "URL Protocol" "" +WriteRegStr HKCR "@EXECUTABLE_NAME@-config" "" "URL:@EXECUTABLE_NAME@-config Protocol" +WriteRegStr HKCR "@EXECUTABLE_NAME@-config" "URL Protocol" "" WriteRegStr HKCR "sips" "" "URL:sips Protocol" WriteRegStr HKCR "sips" "URL Protocol" "" -WriteRegStr HKCR "sips-linphone" "" "URL:sips-linphone Protocol" -WriteRegStr HKCR "sips-linphone" "URL Protocol" "" +WriteRegStr HKCR "sips-@EXECUTABLE_NAME@" "" "URL:sips-@EXECUTABLE_NAME@ Protocol" +WriteRegStr HKCR "sips-@EXECUTABLE_NAME@" "URL Protocol" "" WriteRegStr HKCR "tel" "" "URL:tel Protocol" WriteRegStr HKCR "tel" "URL Protocol" "" @@ -44,12 +44,12 @@ WriteRegStr HKCR "@APPLICATION_NAME@.sip\Shell\Open" "" "" WriteRegStr HKCR "@APPLICATION_NAME@.sip\Shell\Open\Command" "" "$INSTDIR\bin\@EXECUTABLE_NAME@.exe $\"%1$\"" WriteRegStr HKLM "SOFTWARE\@APPLICATION_VENDOR@\@APPLICATION_NAME@\Capabilities\URLAssociations" "sip" "@APPLICATION_NAME@.sip" -## SIP-LINPHONE -WriteRegStr HKCR "@APPLICATION_NAME@.sip-linphone" "" "@APPLICATION_NAME@ sip-linphone Protocol" -WriteRegStr HKCR "@APPLICATION_NAME@.sip-linphone\Shell" "" "" -WriteRegStr HKCR "@APPLICATION_NAME@.sip-linphone\Shell\Open" "" "" -WriteRegStr HKCR "@APPLICATION_NAME@.sip-linphone\Shell\Open\Command" "" "$INSTDIR\bin\@EXECUTABLE_NAME@.exe $\"%1$\"" -WriteRegStr HKLM "SOFTWARE\@APPLICATION_VENDOR@\@APPLICATION_NAME@\Capabilities\URLAssociations" "sip-linphone" "@APPLICATION_NAME@.sip-linphone" +## SIP-@EXECUTABLE_NAME@ +WriteRegStr HKCR "@APPLICATION_NAME@.sip-@EXECUTABLE_NAME@" "" "@APPLICATION_NAME@ sip-@EXECUTABLE_NAME@ Protocol" +WriteRegStr HKCR "@APPLICATION_NAME@.sip-@EXECUTABLE_NAME@\Shell" "" "" +WriteRegStr HKCR "@APPLICATION_NAME@.sip-@EXECUTABLE_NAME@\Shell\Open" "" "" +WriteRegStr HKCR "@APPLICATION_NAME@.sip-@EXECUTABLE_NAME@\Shell\Open\Command" "" "$INSTDIR\bin\@EXECUTABLE_NAME@.exe $\"%1$\"" +WriteRegStr HKLM "SOFTWARE\@APPLICATION_VENDOR@\@APPLICATION_NAME@\Capabilities\URLAssociations" "sip-@EXECUTABLE_NAME@" "@APPLICATION_NAME@.sip-@EXECUTABLE_NAME@" ## SIPS WriteRegStr HKCR "@APPLICATION_NAME@.sips" "" "@APPLICATION_NAME@ sips Protocol" @@ -58,19 +58,19 @@ WriteRegStr HKCR "@APPLICATION_NAME@.sips\Shell\Open" "" "" WriteRegStr HKCR "@APPLICATION_NAME@.sips\Shell\Open\Command" "" "$INSTDIR\bin\@EXECUTABLE_NAME@.exe $\"%1$\"" WriteRegStr HKLM "SOFTWARE\@APPLICATION_VENDOR@\@APPLICATION_NAME@\Capabilities\URLAssociations" "sips" "@APPLICATION_NAME@.sips" -## SIPS-LINPHONE -WriteRegStr HKCR "@APPLICATION_NAME@.sips-linphone" "" "@APPLICATION_NAME@ sips-linphone Protocol" -WriteRegStr HKCR "@APPLICATION_NAME@.sips-linphone\Shell" "" "" -WriteRegStr HKCR "@APPLICATION_NAME@.sips-linphone\Shell\Open" "" "" -WriteRegStr HKCR "@APPLICATION_NAME@.sips-linphone\Shell\Open\Command" "" "$INSTDIR\bin\@EXECUTABLE_NAME@.exe $\"%1$\"" -WriteRegStr HKLM "SOFTWARE\@APPLICATION_VENDOR@\@APPLICATION_NAME@\Capabilities\URLAssociations" "sips-linphone" "@APPLICATION_NAME@.sips-linphone" +## SIPS-@EXECUTABLE_NAME@ +WriteRegStr HKCR "@APPLICATION_NAME@.sips-@EXECUTABLE_NAME@" "" "@APPLICATION_NAME@ sips-@EXECUTABLE_NAME@ Protocol" +WriteRegStr HKCR "@APPLICATION_NAME@.sips-@EXECUTABLE_NAME@\Shell" "" "" +WriteRegStr HKCR "@APPLICATION_NAME@.sips-@EXECUTABLE_NAME@\Shell\Open" "" "" +WriteRegStr HKCR "@APPLICATION_NAME@.sips-@EXECUTABLE_NAME@\Shell\Open\Command" "" "$INSTDIR\bin\@EXECUTABLE_NAME@.exe $\"%1$\"" +WriteRegStr HKLM "SOFTWARE\@APPLICATION_VENDOR@\@APPLICATION_NAME@\Capabilities\URLAssociations" "sips-@EXECUTABLE_NAME@" "@APPLICATION_NAME@.sips-@EXECUTABLE_NAME@" -## LINPHONE-CONFIG -WriteRegStr HKCR "@APPLICATION_NAME@.linphone-config" "" "@APPLICATION_NAME@ linphone-config Protocol" -WriteRegStr HKCR "@APPLICATION_NAME@.linphone-config\Shell" "" "" -WriteRegStr HKCR "@APPLICATION_NAME@.linphone-config\Shell\Open" "" "" -WriteRegStr HKCR "@APPLICATION_NAME@.linphone-config\Shell\Open\Command" "" "$INSTDIR\bin\@EXECUTABLE_NAME@.exe $\"%1$\"" -WriteRegStr HKLM "SOFTWARE\@APPLICATION_VENDOR@\@APPLICATION_NAME@\Capabilities\URLAssociations" "linphone-config" "@APPLICATION_NAME@.linphone-config" +## @EXECUTABLE_NAME@-CONFIG +WriteRegStr HKCR "@APPLICATION_NAME@.@EXECUTABLE_NAME@-config" "" "@APPLICATION_NAME@ @EXECUTABLE_NAME@-config Protocol" +WriteRegStr HKCR "@APPLICATION_NAME@.@EXECUTABLE_NAME@-config\Shell" "" "" +WriteRegStr HKCR "@APPLICATION_NAME@.@EXECUTABLE_NAME@-config\Shell\Open" "" "" +WriteRegStr HKCR "@APPLICATION_NAME@.@EXECUTABLE_NAME@-config\Shell\Open\Command" "" "$INSTDIR\bin\@EXECUTABLE_NAME@.exe $\"%1$\"" +WriteRegStr HKLM "SOFTWARE\@APPLICATION_VENDOR@\@APPLICATION_NAME@\Capabilities\URLAssociations" "@EXECUTABLE_NAME@-config" "@APPLICATION_NAME@.@EXECUTABLE_NAME@-config" ## TEL WriteRegStr HKCR "@APPLICATION_NAME@.tel" "" "@APPLICATION_NAME@ tel Protocol" diff --git a/linphone-app/cmake_builder/linphone_package/windows/uninstall.nsi.in b/linphone-app/cmake_builder/linphone_package/windows/uninstall.nsi.in index e7b3d0f82..c27c43a66 100644 --- a/linphone-app/cmake_builder/linphone_package/windows/uninstall.nsi.in +++ b/linphone-app/cmake_builder/linphone_package/windows/uninstall.nsi.in @@ -14,10 +14,10 @@ DeleteRegValue HKLM "SOFTWARE\RegisteredApplications" "@APPLICATION_NAME@" ## Handlers DeleteRegKey HKCR "@APPLICATION_NAME@.sip" -DeleteRegKey HKCR "@APPLICATION_NAME@.sip-linphone" +DeleteRegKey HKCR "@APPLICATION_NAME@.sip-@EXECUTABLE_NAME@" DeleteRegKey HKCR "@APPLICATION_NAME@.sips" -DeleteRegKey HKCR "@APPLICATION_NAME@.sips-linphone" -DeleteRegKey HKCR "@APPLICATION_NAME@.linphone-config" +DeleteRegKey HKCR "@APPLICATION_NAME@.sips-@EXECUTABLE_NAME@" +DeleteRegKey HKCR "@APPLICATION_NAME@.@EXECUTABLE_NAME@-config" DeleteRegKey HKCR "@APPLICATION_NAME@.tel" DeleteRegKey HKCR "@APPLICATION_NAME@.callto" diff --git a/linphone-app/src/app/cli/Cli.cpp b/linphone-app/src/app/cli/Cli.cpp index 0e02fe723..3d84ad63d 100644 --- a/linphone-app/src/app/cli/Cli.cpp +++ b/linphone-app/src/app/cli/Cli.cpp @@ -51,6 +51,8 @@ static void cliShow (QHash &args) { } static void cliCall (QHash &args) { + QString addressToCall = args["sip-address"]; + if(args.size() > 1){// Call with options App *app = App::getInstance(); args["call"] = args["sip-address"];// Swap cli def to parser @@ -429,42 +431,65 @@ QMap Cli::mCommands = { }; // ----------------------------------------------------------------------------- - -void Cli::executeCommand (const QString &command, CommandFormat *format) { - shared_ptr address; - QStringList tempSipAddress = command.split(':'); - bool ok = false; +/* +string Cli::getScheme(const QString& address){ + QStringList tempSipAddress = address->split(':'); + if( tempSipAddress.size() > 0) + return tempSipAddress[0].toStdString(); + else + return ""; +} +bool Cli::changeScheme(QString * address){ + QStringList tempSipAddress = address->split(':'); string scheme; + bool ok = false; if(tempSipAddress.size() > 1) { scheme = tempSipAddress[0].toStdString(); - for (const string &validScheme : { "sip", "sip-linphone", "sips", "sips-linphone", "tel", "callto", "linphone-config" }) + for (const string &validScheme : { string("sip"), "sip-"+string(EXECUTABLE_NAME), string("sips"), "sips-"+string(EXECUTABLE_NAME), string("tel"), string("callto"), string(EXECUTABLE_NAME)+ "-config" }) if (scheme == validScheme) ok = true; if( !ok){ - qWarning() << QStringLiteral("Not a valid uri: `%1` Unsupported scheme: `%2`.").arg(command).arg(Utils::coreStringToAppString(scheme)); + qWarning() << QStringLiteral("Not a valid uri: `%1` Unsupported scheme: `%2`.").arg(*address).arg(Utils::coreStringToAppString(scheme)); }else{ tempSipAddress[0] = "sip";// In order to pass bellesip parsing. - QString bellesipAddress = tempSipAddress.join(':'); - address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(bellesipAddress)); + *address = tempSipAddress.join(':'); } } + return ok; +} +*/ +void Cli::executeCommand (const QString &command, CommandFormat *format) { - // Execute cli command. - if (!address) { +// Detect if command is a CLI by testing commands + const QString &functionName = parseFunctionName(command); + + if(!functionName.isEmpty()){// It is a CLI qInfo() << QStringLiteral("Detecting cli command: `%1`...").arg(command); - const QString &functionName = parseFunctionName(command); - if (!functionName.isEmpty()) { - QHash args = parseArgs(command); - mCommands[functionName].execute(args); - if (format) - *format = CliFormat; - return; + QHash args = parseArgs(command); + mCommands[functionName].execute(args); + if (format) + *format = CliFormat; + return; + }else{// It is a URI + QStringList tempSipAddress = command.split(':'); + string scheme="sip"; + QString transformedCommand; // In order to pass bellesip parsing, set scheme to 'sip:'. + if( tempSipAddress.size() == 1){ + transformedCommand = "sip:"+command; + }else{ + scheme = tempSipAddress[0].toStdString(); + bool ok = false; + for (const string &validScheme : { string("sip"), "sip-"+string(EXECUTABLE_NAME), string("sips"), "sips-"+string(EXECUTABLE_NAME), string("tel"), string("callto"), string(EXECUTABLE_NAME)+ "-config" }) + if (scheme == validScheme) + ok = true; + if( !ok){ + qWarning() << QStringLiteral("Not a valid URI: `%1` Unsupported scheme: `%2`.").arg(command).arg(Utils::coreStringToAppString(scheme)); + return; + } + tempSipAddress[0] = "sip"; + transformedCommand = tempSipAddress.join(':'); } - } - - // Execute uri - if(ok){ - if( scheme == "linphone-config" ){ + if( scheme == string(EXECUTABLE_NAME)+"-config" ){ QHash args = parseArgs(command); if(args.contains("fetch-config")) args["fetch-config"] = QByteArray::fromBase64(args["fetch-config"].toUtf8() ); @@ -477,9 +502,10 @@ void Cli::executeCommand (const QString &command, CommandFormat *format) { *format = CliFormat; mCommands["show"].execute(args); }else{ + shared_ptr 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); + qInfo() << QStringLiteral("Detecting URI command: `%1`...").arg(command); QString functionName; if( address) { functionName = Utils::coreStringToAppString(address->getHeader("method")).isEmpty()