Search in sources :

Example 6 with DeleteCallListException

use of de.janrufmonitor.fritzbox.firmware.exception.DeleteCallListException 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;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) FritzBoxLoginException(de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException) Message(de.janrufmonitor.exception.Message) FirmwareManager(de.janrufmonitor.fritzbox.firmware.FirmwareManager) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) DeleteCallListException(de.janrufmonitor.fritzbox.firmware.exception.DeleteCallListException)

Example 7 with DeleteCallListException

use of de.janrufmonitor.fritzbox.firmware.exception.DeleteCallListException in project janrufmonitor by tbrandt77.

the class TR064FritzBoxFirmware method deleteCallList.

public void deleteCallList() throws DeleteCallListException, IOException {
    if (!this.isInitialized())
        throw new DeleteCallListException("Could not delete call list from FritzBox: FritzBox firmware not initialized.");
    String u = "http://" + this.m_server + ":" + this.m_port + "/fon_num/foncalls_list.lua";
    String body = "usejournal=on&clear=&callstab=all&sid=" + FritzBoxTR064Manager.getInstance().getSID(this.m_user, this.m_password, this.m_server, (this.m_useHttp ? FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064Port() : FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064SecurePort(this.m_server)), (this.m_useHttp ? "http" : "https"));
    doHttpCall(u, "POST", body, new String[][] { { "Content-Length", Integer.toString(body.length()) } });
    if (this.m_logger.isLoggable(Level.INFO))
        this.m_logger.info("Callist from FritzBox succuessfully deleted.");
}
Also used : DeleteCallListException(de.janrufmonitor.fritzbox.firmware.exception.DeleteCallListException)

Aggregations

DeleteCallListException (de.janrufmonitor.fritzbox.firmware.exception.DeleteCallListException)7 Message (de.janrufmonitor.exception.Message)2 FirmwareManager (de.janrufmonitor.fritzbox.firmware.FirmwareManager)2 FritzBoxLoginException (de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ICall (de.janrufmonitor.framework.ICall)1 ICallList (de.janrufmonitor.framework.ICallList)1 ICip (de.janrufmonitor.framework.ICip)1 IEventBroker (de.janrufmonitor.framework.event.IEventBroker)1 FritzBoxCallCsv (de.janrufmonitor.fritzbox.FritzBoxCallCsv)1 GetCallListException (de.janrufmonitor.fritzbox.firmware.exception.GetCallListException)1 ICallManager (de.janrufmonitor.repository.ICallManager)1 DateFilter (de.janrufmonitor.repository.filter.DateFilter)1 IFilter (de.janrufmonitor.repository.filter.IFilter)1 ICallExporter (de.janrufmonitor.repository.imexport.ICallExporter)1 IImExporter (de.janrufmonitor.repository.imexport.IImExporter)1 IReadCallRepository (de.janrufmonitor.repository.types.IReadCallRepository)1 IWriteCallRepository (de.janrufmonitor.repository.types.IWriteCallRepository)1 File (java.io.File)1