use of de.janrufmonitor.fritzbox.firmware.FirmwareManager in project janrufmonitor by tbrandt77.
the class FritzBoxMonitor method release.
public void release() {
if (this.cmn != null) {
this.cmn.disconnect();
// added: 2007/05/30: set cmn to null
this.cmn = null;
}
int count = 0;
while (this.cmnThread != null && this.cmnThread.isAlive() && count < 5) {
this.cmnThread.interrupt();
this.m_logger.info("Try to release FritzBoxMonitor. Attempt #" + (count + 1));
count++;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
if (this.cmnThread != null && this.cmnThread.isAlive()) {
this.cmnThread.interrupt();
if (this.cmnThread != null && this.cmnThread.isAlive())
this.m_logger.warning("Could not release FritzBoxMonitor after " + count + " attempts.");
}
this.cmnThread = null;
FirmwareManager fwm = FirmwareManager.getInstance();
fwm.shutdown();
this.m_logger.info("FritzBoxMonitor released FritzBox.");
}
use of de.janrufmonitor.fritzbox.firmware.FirmwareManager in project janrufmonitor by tbrandt77.
the class QuickDialer method dial.
public static void dial(IPhonenumber n, String msn) throws Exception {
if (n.isClired())
throw new Exception("no number provided");
String dial = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toCallable(n.getTelephoneNumber());
// added 2010/03/06: check for dial prefix for outgoing calls
if (PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).length() > 0) {
dial = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).trim() + dial;
}
Properties config = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperties(FritzBoxMonitor.NAMESPACE);
// FritzBox m_fb = new FritzBox(config.getProperty(CFG_IP, "fritz.box"), config.getProperty(CFG_PASSWORD, ""), config.getProperty(CFG_PORT, "80"));
FirmwareManager fwm = FirmwareManager.getInstance();
try {
if (!fwm.isLoggedIn())
fwm.login();
fwm.doCall(dial + "#", config.getProperty(CFG_CLICKDIAL, "50"));
} catch (IOException e) {
throw new Exception(e.getMessage());
}
}
use of de.janrufmonitor.fritzbox.firmware.FirmwareManager in project janrufmonitor by tbrandt77.
the class ConsoleDial method execute.
public void execute() {
this.isExecuting = true;
if (this.getExecuteParams().length != 2) {
System.out.println("ERROR: Parameters are invalid. Please specify a valid number e.g. +4930123456 or 030123456 and a fritzbox extension");
System.out.println();
System.out.println("Valid extensions:");
System.out.println("-----------------");
System.out.println("1 for Fon1, 2 for Fon2, 3 for Fon3");
System.out.println("51 for ISDN1 ... 59 for ISDN 6, 50 for all ISDN devices");
this.isExecuting = false;
return;
}
String dial = this.getExecuteParams()[0];
if (dial.length() < 5) {
System.out.println("ERROR: Invalid number length. Number must contain at least be 5 digits and start with 0.");
this.isExecuting = false;
return;
}
if (!dial.startsWith("0"))
dial = "0" + dial;
String ext = this.getExecuteParams()[1];
int i = Integer.parseInt(ext);
if ((i >= 0 && i <= 9) || (i >= 50 && i <= 59)) {
FirmwareManager fwm = FirmwareManager.getInstance();
try {
fwm.login();
fwm.doCall(dial + "#", ext);
} catch (Exception e) {
System.out.println("ERROR: Dialing fritzbox failed: " + e.getMessage());
}
} else {
System.out.println("ERROR: Invalid fritzbox extension: " + i + "; allowed values 1 for Fon1, 2 for Fon2, 3 for Fon3, 51 for ISDN1 ... 59 for ISDN 6, 50 for all ISDN devices.");
}
this.isExecuting = false;
}
use of de.janrufmonitor.fritzbox.firmware.FirmwareManager in project janrufmonitor by tbrandt77.
the class Delete method run.
public void run() {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), this.getI18nManager().getString(this.getNamespace(), "delete", "label", this.getLanguage()), this.getI18nManager().getString(this.getNamespace(), "delete", "description", this.getLanguage()))) {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "deleteprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "loginprogress", "label", getLanguage()));
FirmwareManager fwm = FirmwareManager.getInstance();
try {
if (!fwm.isLoggedIn())
fwm.login();
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "deleteprogress", "label", getLanguage()));
fwm.deleteCallList();
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "finished", "label", getLanguage()));
} catch (IOException e) {
m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "faileddelete", e));
} catch (FritzBoxLoginException e) {
m_logger.warning(e.toString());
} catch (DeleteCallListException e) {
m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "faileddelete", e));
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
m_app.updateViews(true);
}
// ModalContext.run(r, true, pmd.getProgressMonitor(), DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
return;
}
Aggregations