update
This commit is contained in:
parent
b016db5eeb
commit
f965a38bee
BIN
.gradle/8.3/checksums/checksums.lock
Normal file
BIN
.gradle/8.3/checksums/checksums.lock
Normal file
Binary file not shown.
BIN
.gradle/8.3/checksums/md5-checksums.bin
Normal file
BIN
.gradle/8.3/checksums/md5-checksums.bin
Normal file
Binary file not shown.
BIN
.gradle/8.3/checksums/sha1-checksums.bin
Normal file
BIN
.gradle/8.3/checksums/sha1-checksums.bin
Normal file
Binary file not shown.
BIN
.gradle/8.3/dependencies-accessors/dependencies-accessors.lock
Normal file
BIN
.gradle/8.3/dependencies-accessors/dependencies-accessors.lock
Normal file
Binary file not shown.
0
.gradle/8.3/dependencies-accessors/gc.properties
Normal file
0
.gradle/8.3/dependencies-accessors/gc.properties
Normal file
BIN
.gradle/8.3/executionHistory/executionHistory.bin
Normal file
BIN
.gradle/8.3/executionHistory/executionHistory.bin
Normal file
Binary file not shown.
BIN
.gradle/8.3/executionHistory/executionHistory.lock
Normal file
BIN
.gradle/8.3/executionHistory/executionHistory.lock
Normal file
Binary file not shown.
BIN
.gradle/8.3/fileChanges/last-build.bin
Normal file
BIN
.gradle/8.3/fileChanges/last-build.bin
Normal file
Binary file not shown.
BIN
.gradle/8.3/fileHashes/fileHashes.bin
Normal file
BIN
.gradle/8.3/fileHashes/fileHashes.bin
Normal file
Binary file not shown.
BIN
.gradle/8.3/fileHashes/fileHashes.lock
Normal file
BIN
.gradle/8.3/fileHashes/fileHashes.lock
Normal file
Binary file not shown.
BIN
.gradle/8.3/fileHashes/resourceHashesCache.bin
Normal file
BIN
.gradle/8.3/fileHashes/resourceHashesCache.bin
Normal file
Binary file not shown.
0
.gradle/8.3/gc.properties
Normal file
0
.gradle/8.3/gc.properties
Normal file
Binary file not shown.
@ -1,2 +1,2 @@
|
||||
#Mon Oct 18 17:31:34 CEST 2021
|
||||
gradle.version=7.1
|
||||
#Mon Sep 18 19:46:51 CEST 2023
|
||||
gradle.version=8.3
|
||||
|
Binary file not shown.
BIN
.gradle/file-system.probe
Normal file
BIN
.gradle/file-system.probe
Normal file
Binary file not shown.
@ -1,14 +1,13 @@
|
||||
package de.vincentschweiger.calltoj;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Base64;
|
||||
import java.util.Map;
|
||||
import javax.swing.*;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
/**
|
||||
* Mo. 18/10/2021 17:32
|
||||
@ -17,60 +16,68 @@ import java.util.Map;
|
||||
*/
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public class CallToJ {
|
||||
private static final File configFile = new File(new File(System.getProperty("user.home")), ".callto.yaml");
|
||||
private static final File configFile =
|
||||
new File(new File(System.getProperty("user.home")), ".callto.yaml");
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if (!configFile.exists()) {
|
||||
configFile.createNewFile();
|
||||
FileOutputStream outputStream = new FileOutputStream(configFile);
|
||||
InputStream inputStream = CallToJ.class.getResourceAsStream("/template.yaml");
|
||||
if (inputStream != null) {
|
||||
IOUtils.copy(inputStream, outputStream);
|
||||
inputStream.close();
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "IN is null");
|
||||
outputStream.close();
|
||||
configFile.delete();
|
||||
System.exit(-1);
|
||||
}
|
||||
outputStream.close();
|
||||
JOptionPane.showMessageDialog(null, "You have to configure CallToJ!\n See .callto.yaml in your home directory!");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Yaml yaml = new Yaml();
|
||||
FileInputStream inputStream = new FileInputStream(configFile);
|
||||
Map<String, Object> obj = yaml.load(inputStream);
|
||||
|
||||
String snom_webadmin_user = obj.get("user").toString();
|
||||
String snom_webadmin_pw = obj.get("password").toString();
|
||||
String hostname_snom = obj.get("hostname").toString();
|
||||
|
||||
String number;
|
||||
if (args.length < 1) {
|
||||
number = "015904183517";
|
||||
} else {
|
||||
number = args[0];
|
||||
// Replace cause of firefox and callto handling stuff
|
||||
number = number.replace("callto://", "");
|
||||
number = number.replace("tel://", "");
|
||||
number = number.replace("sip://", "");
|
||||
number = number.replace("+49", "0");
|
||||
number = number.replace("%20", "");
|
||||
}
|
||||
|
||||
System.out.println("Using Snom phone to dial number " + number);
|
||||
|
||||
URL url = new URL("http://" + hostname_snom + "/command.htm?number=" + number + "&outgoing_uri=URI");
|
||||
String encoding = Base64.getEncoder().encodeToString((snom_webadmin_user + ":" + snom_webadmin_pw).getBytes());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(false);
|
||||
connection.setRequestProperty("Authorization", "Basic " + encoding);
|
||||
connection.getResponseCode();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if (!configFile.exists()) {
|
||||
configFile.createNewFile();
|
||||
FileOutputStream outputStream = new FileOutputStream(configFile);
|
||||
InputStream inputStream =
|
||||
CallToJ.class.getResourceAsStream("/template.yaml");
|
||||
if (inputStream != null) {
|
||||
IOUtils.copy(inputStream, outputStream);
|
||||
inputStream.close();
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "IN is null");
|
||||
outputStream.close();
|
||||
configFile.delete();
|
||||
System.exit(-1);
|
||||
}
|
||||
outputStream.close();
|
||||
JOptionPane.showMessageDialog(
|
||||
null,
|
||||
"You have to configure CallToJ!\n See .callto.yaml in your home directory!");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Yaml yaml = new Yaml();
|
||||
FileInputStream inputStream = new FileInputStream(configFile);
|
||||
Map<String, Object> obj = yaml.load(inputStream);
|
||||
|
||||
String snom_webadmin_user = obj.get("user").toString();
|
||||
String snom_webadmin_pw = obj.get("password").toString();
|
||||
String hostname_snom = obj.get("hostname").toString();
|
||||
|
||||
String number;
|
||||
if (args.length < 1) {
|
||||
number = "015904183517";
|
||||
} else {
|
||||
number = args[0];
|
||||
// Replace cause of firefox and callto handling stuff
|
||||
number = number.replace("callto:", "");
|
||||
number = number.replace("tel:", "");
|
||||
number = number.replace("callto://", "");
|
||||
number = number.replace("tel://", "");
|
||||
number = number.replace("sip://", "");
|
||||
number = number.replace("+49", "0");
|
||||
number = number.replace("%20", "");
|
||||
}
|
||||
|
||||
System.out.println("Using Snom phone to dial number " + number);
|
||||
|
||||
URL url = new URL("http://" + hostname_snom +
|
||||
"/command.htm?number=" + number + "&outgoing_uri=URI");
|
||||
String encoding = Base64.getEncoder().encodeToString(
|
||||
(snom_webadmin_user + ":" + snom_webadmin_pw).getBytes());
|
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(false);
|
||||
connection.setRequestProperty("Authorization", "Basic " + encoding);
|
||||
connection.getResponseCode();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user