Commit 8c4c240c authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Restore ability to send tel: URLs to the phone

They're not http or https URLs. Add a dedicated handler with appropriate "Call on device" label and icon.
The URL pattern doesn't look like any of the listed examples, but tel://*/* would refuse on grounds that "tel"
isn't a recognized schema but just doing "tel:*" works on both Firefox and Chrome.

Differential Revision: https://phabricator.kde.org/D29691
parent 69fa227e
...@@ -159,6 +159,10 @@ ...@@ -159,6 +159,10 @@
"description": "Context menu, open link on device $1, similar to 'Open in New Tab'", "description": "Context menu, open link on device $1, similar to 'Open in New Tab'",
"message": "Open on '$1'" "message": "Open on '$1'"
}, },
"kdeconnect_call_device": {
"description": "Context menu, call phone number on device $1",
"message": "Call on '$1'"
},
"purpose_share": { "purpose_share": {
"description": "Context menu, share link or page via Purpose framework", "description": "Context menu, share link or page via Purpose framework",
......
...@@ -23,7 +23,7 @@ chrome.contextMenus.onClicked.addListener(function (info) { ...@@ -23,7 +23,7 @@ chrome.contextMenus.onClicked.addListener(function (info) {
return; return;
} }
var deviceId = info.menuItemId.substr(kdeConnectMenuIdPrefix.length); const deviceId = info.menuItemId.substr(info.menuItemId.indexOf("@") + 1);
var url = info.linkUrl || info.srcUrl || info.pageUrl; var url = info.linkUrl || info.srcUrl || info.pageUrl;
console.log("Send url", url, "to kdeconnect device", deviceId); console.log("Send url", url, "to kdeconnect device", deviceId);
...@@ -44,13 +44,10 @@ addCallback("kdeconnect", "deviceAdded", function(message) { ...@@ -44,13 +44,10 @@ addCallback("kdeconnect", "deviceAdded", function(message) {
let name = message.name; let name = message.name;
let type = message.type; let type = message.type;
let menuEntryTitle = chrome.i18n.getMessage("kdeconnect_open_device", name);
let menuId = kdeConnectMenuIdPrefix + deviceId;
let props = { let props = {
id: menuId, id: kdeConnectMenuIdPrefix + "open@" + deviceId,
contexts: ["link", "page", "image", "audio", "video"], contexts: ["link", "page", "image", "audio", "video"],
title: menuEntryTitle, title: chrome.i18n.getMessage("kdeconnect_open_device", name),
targetUrlPatterns: [ targetUrlPatterns: [
"http://*/*", "https://*/*" "http://*/*", "https://*/*"
] ]
...@@ -84,6 +81,23 @@ addCallback("kdeconnect", "deviceAdded", function(message) { ...@@ -84,6 +81,23 @@ addCallback("kdeconnect", "deviceAdded", function(message) {
chrome.contextMenus.create(props); chrome.contextMenus.create(props);
props = {
id: kdeConnectMenuIdPrefix + "call@" + deviceId,
contexts: ["link"],
title: chrome.i18n.getMessage("kdeconnect_call_device", name),
targetUrlPatterns: [
"tel:*"
]
};
if (IS_FIREFOX) {
props.icons = {
"16": "icons/call-start-symbolic.svg"
};
}
chrome.contextMenus.create(props);
kdeConnectDevices[deviceId] = { kdeConnectDevices[deviceId] = {
name, type name, type
}; };
...@@ -97,5 +111,6 @@ addCallback("kdeconnect", "deviceRemoved", function(message) { ...@@ -97,5 +111,6 @@ addCallback("kdeconnect", "deviceRemoved", function(message) {
} }
delete kdeConnectDevices[deviceId]; delete kdeConnectDevices[deviceId];
chrome.contextMenus.remove(kdeConnectMenuIdPrefix + deviceId); chrome.contextMenus.remove(kdeConnectMenuIdPrefix + "open@" + deviceId);
chrome.contextMenus.remove(kdeConnectMenuIdPrefix + "call@" + deviceId);
}); });
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#232629;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 3.4882812 2.0019531 C 3.2034307 2.0278481 2.9960938 2.2363281 2.9960938 2.2363281 L 2.4667969 2.765625 L 2.1660156 3.0664062 C 1.7230956 4.7997962 2.1655238 6.7084425 3.5273438 8.0703125 L 7.9296875 12.472656 C 9.2917475 13.834716 11.200194 14.276904 12.933594 13.833984 L 13.234375 13.533203 L 13.763672 13.003906 C 13.763672 13.003906 14.294022 12.473709 13.763672 11.943359 L 11.484375 9.6621094 C 10.954035 9.1317694 10.423828 9.6621094 10.423828 9.6621094 L 10.158203 9.9277344 C 9.7174831 10.368444 9.0071062 10.368444 8.5664062 9.9277344 L 6.0722656 7.4335938 C 5.6315656 6.9928938 5.6315456 6.2825169 6.0722656 5.8417969 L 6.3378906 5.5761719 C 6.3378906 5.5761719 6.8682206 5.045965 6.3378906 4.515625 L 4.0566406 2.2363281 C 3.8577631 2.0374544 3.6591916 1.9864161 3.4882812 2.0019531 z "
class="ColorScheme-Text"
/>
</svg>
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