Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 718a55cb76 | |||
| 233cd3614e | |||
| 5322961234 | |||
| 38a3f3f402 | |||
| 2dd6525e22 | |||
| b20c563b93 | |||
| e9252aa18a |
@@ -1,3 +1,5 @@
|
||||
eclipse II
|
||||
|
||||
https://speedport.ip/index/login.cgi
|
||||
|
||||
POST /index/login.cgi HTTP/1.1
|
||||
|
||||
+13
-29
@@ -1,4 +1,4 @@
|
||||
package de.tilman.callerId;
|
||||
package de.tilman.callerid;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -30,7 +30,6 @@ import com.google.gdata.client.contacts.ContactsService;
|
||||
import com.google.gdata.data.contacts.ContactEntry;
|
||||
import com.google.gdata.data.contacts.ContactFeed;
|
||||
import com.google.gdata.data.extensions.PhoneNumber;
|
||||
import com.martiansoftware.jsap.FlaggedOption;
|
||||
import com.martiansoftware.jsap.JSAP;
|
||||
import com.martiansoftware.jsap.JSAPException;
|
||||
import com.martiansoftware.jsap.JSAPResult;
|
||||
@@ -75,10 +74,10 @@ public class CallerIdClient {
|
||||
if (calls.size() > 0) {
|
||||
|
||||
List<ContactEntry> contacts = null;
|
||||
if (config.getString("google username") != null) {
|
||||
if (config.getBoolean("check contacts")) {
|
||||
log.info("retrieving Google contacts");
|
||||
ContactsService service = new ContactsService("<var>SpeedportCallerIdClient</var>");
|
||||
service.setUserCredentials(config.getString("google username"), config.getString("google password"));
|
||||
service.setUserCredentials(config.getString("e-mail adress"), config.getString("e-mail password"));
|
||||
URL feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full");
|
||||
Query myQuery = new Query(feedUrl);
|
||||
myQuery.setMaxResults(1000);
|
||||
@@ -187,9 +186,6 @@ public class CallerIdClient {
|
||||
if (cookie != null) {
|
||||
connection.setRequestProperty("Cookie", "SessionID_R3=" + cookie);
|
||||
}
|
||||
// connection.setRequestProperty("Referer",
|
||||
// "https://speedport.ip/auth/hcti_status_telanrl.php?cookie=SessionID_R3,"
|
||||
// + cookie);
|
||||
|
||||
OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
|
||||
if (payload.length() > 0) {
|
||||
@@ -235,17 +231,15 @@ public class CallerIdClient {
|
||||
}
|
||||
|
||||
private void sendNotification(String time, String caller) throws Exception {
|
||||
String host = config.getString("SMTP server address");
|
||||
String host = "smtp.gmail.com";
|
||||
String from = config.getString("e-mail adress");
|
||||
String pass = config.getString("e-mail password");
|
||||
Properties props = System.getProperties();
|
||||
props.put("mail.smtp.ssl.enable", "true");
|
||||
// props.put("mail.smtp.starttls.enable", "true");
|
||||
props.put("mail.smtp.starttls.enable", "true");
|
||||
props.put("mail.smtp.host", host);
|
||||
props.put("mail.smtp.user", from);
|
||||
props.put("mail.smtp.password", pass);
|
||||
props.put("mail.smtp.port", "465");
|
||||
// props.put("mail.smtp.port", "587");
|
||||
props.put("mail.smtp.port", "587");
|
||||
props.put("mail.smtp.auth", "true");
|
||||
|
||||
String[] to = config.getStringArray("recipient");
|
||||
@@ -275,9 +269,10 @@ public class CallerIdClient {
|
||||
transport.close();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static void main(String[] args) {
|
||||
BasicConfigurator.configure(new ConsoleAppender(new PatternLayout("%d{ISO8601} - %m%n")));
|
||||
log.info("Starting CallerIdClient version 1.0.2");
|
||||
log.info("Starting CallerIdClient version 1.1.2");
|
||||
|
||||
JSAP jsap = new JSAP();
|
||||
|
||||
@@ -292,19 +287,14 @@ public class CallerIdClient {
|
||||
updateInterval.setHelp("the interval beetween runs in minutes");
|
||||
jsap.registerParameter(updateInterval);
|
||||
|
||||
UnflaggedOption smtpServer = new UnflaggedOption("SMTP server address").setStringParser(JSAP.STRING_PARSER)
|
||||
.setRequired(true);
|
||||
smtpServer.setHelp("the SMTP server to send notifications with");
|
||||
jsap.registerParameter(smtpServer);
|
||||
|
||||
UnflaggedOption fromAddress = new UnflaggedOption("e-mail adress").setStringParser(JSAP.STRING_PARSER).setRequired(
|
||||
true);
|
||||
fromAddress.setHelp("e-mail address to send from");
|
||||
fromAddress.setHelp("Google mail address to send from");
|
||||
jsap.registerParameter(fromAddress);
|
||||
|
||||
UnflaggedOption emailPassword = new UnflaggedOption("e-mail password").setStringParser(JSAP.STRING_PARSER)
|
||||
.setRequired(true);
|
||||
emailPassword.setHelp("the login password for the e-mail account");
|
||||
emailPassword.setHelp("the login password for the Google account");
|
||||
jsap.registerParameter(emailPassword);
|
||||
|
||||
UnflaggedOption recipients = new UnflaggedOption("recipient").setStringParser(JSAP.STRING_PARSER).setRequired(true)
|
||||
@@ -312,15 +302,9 @@ public class CallerIdClient {
|
||||
recipients.setHelp("e-mail addresses to send notifications to");
|
||||
jsap.registerParameter(recipients);
|
||||
|
||||
FlaggedOption googleUsername = new FlaggedOption("google username").setStringParser(JSAP.STRING_PARSER).setShortFlag(
|
||||
'u');
|
||||
googleUsername.setHelp("the Google username for contact name resolution");
|
||||
jsap.registerParameter(googleUsername);
|
||||
|
||||
FlaggedOption googlePassword = new FlaggedOption("google password").setStringParser(JSAP.STRING_PARSER).setShortFlag(
|
||||
'p');
|
||||
googleUsername.setHelp("the Google password for contact name resolution");
|
||||
jsap.registerParameter(googlePassword);
|
||||
Switch contactsSwitch = new Switch("check contacts").setLongFlag("contacts");
|
||||
contactsSwitch.setHelp("retrieve contacts from Google account and resolve caller names");
|
||||
jsap.registerParameter(contactsSwitch);
|
||||
|
||||
Switch debugSwitch = new Switch("debug").setLongFlag("debug");
|
||||
debugSwitch.setHelp("print debug messages");
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package de.tilman.callerId;
|
||||
package de.tilman.callerid;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user