Search in sources :

Example 36 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class FritzBoxPhonebookManager method getCaller.

public ICaller getCaller(IPhonenumber number) throws CallerNotFoundException {
    if (number == null)
        throw new CallerNotFoundException("Phone number is not set (null). No caller found.");
    if (number.isClired())
        throw new CallerNotFoundException("Phone number is CLIR. Identification impossible.");
    int counter = 0;
    while (this.isSyncing && counter < 5) {
        counter++;
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        }
    }
    if (counter == 5) {
        this.m_logger.warning("JAM-FritzBoxPhonebookSync-Thread still running for more then 5 sec., but caller identification requested.");
    }
    ICaller c = null;
    try {
        c = getDatabaseHandler().getCaller(number);
        if (c != null)
            return c;
    } catch (SQLException e) {
        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
    }
    throw new CallerNotFoundException("No caller entry found for phonenumber : " + number.getTelephoneNumber());
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) SQLException(java.sql.SQLException)

Example 37 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class CommentCommand method execute.

public void execute() throws Exception {
    this.isExecuting = true;
    IService s = this.getRuntime().getServiceFactory().getService("CommentService");
    if (s != null && s instanceof CommentService) {
        CommentService cs = (CommentService) s;
        if (!cs.isEnabled()) {
            new SWTExecuter(true, this.getID()) {

                protected void execute() {
                    MessageDialog.openError(new Shell(DisplayManager.getDefaultDisplay()), m_i18n.getString(getNamespace(), "servicedisabled", "label", m_language), m_i18n.getString(getNamespace(), "servicedisabled", "description", m_language));
                }
            }.start();
            this.isExecuting = false;
            return;
        }
        final ICaller c = cs.getLastCaller();
        if (c == null) {
            new SWTExecuter(true, this.getID()) {

                protected void execute() {
                    MessageDialog.openError(new Shell(DisplayManager.getDefaultDisplay()), m_i18n.getString(getNamespace(), "nocaller", "label", m_language), m_i18n.getString(getNamespace(), "nocaller", "description", m_language));
                }
            }.start();
            this.isExecuting = false;
            return;
        }
        if (c.getPhoneNumber().isClired()) {
            new SWTExecuter(true, this.getID()) {

                protected void execute() {
                    MessageDialog.openError(new Shell(DisplayManager.getDefaultDisplay()), m_i18n.getString(getNamespace(), "clircaller", "label", m_language), m_i18n.getString(getNamespace(), "clircaller", "description", m_language));
                }
            }.start();
        } else {
            new SWTExecuter(true, this.getID()) {

                protected void execute() {
                    new Comment(c).open();
                }
            }.start();
        }
    } else {
        this.m_logger.warning("Service CommentService not available.");
    }
    this.isExecuting = false;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) CommentService(de.janrufmonitor.service.comment.CommentService) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter) IService(de.janrufmonitor.service.IService)

Example 38 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class ManageAction method run.

public void run() {
    IService s = this.getRuntime().getServiceFactory().getService("CommentService");
    if (s != null && s instanceof CommentService) {
        CommentService cs = (CommentService) s;
        if (!cs.isEnabled()) {
            new SWTExecuter(true, this.getID()) {

                protected void execute() {
                    MessageDialog.openError(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespace(), "servicedisabled", "label", getLanguage()), getI18nManager().getString(getNamespace(), "servicedisabled", "description", getLanguage()));
                }
            }.start();
            return;
        }
    }
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Object o = selection.getFirstElement();
            if (o instanceof ICall) {
                Object o2 = ((ICall) o).getCaller();
                if (((ICaller) o2).getPhoneNumber().isClired())
                    return;
                new Comment(((ICall) o)).open();
            }
            if (o instanceof ICaller) {
                if (((ICaller) o).getPhoneNumber().isClired())
                    return;
                new Comment(((ICaller) o)).open();
            }
        }
    }
}
Also used : Comment(de.janrufmonitor.ui.jface.application.comment.Comment) ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) CommentService(de.janrufmonitor.service.comment.CommentService) ICall(de.janrufmonitor.framework.ICall) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter) IService(de.janrufmonitor.service.IService)

Example 39 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class PDFHistoryAction method run.

public void run() {
    FileDialog dialog = new FileDialog(new Shell(DisplayManager.getDefaultDisplay()), SWT.SAVE);
    dialog.setFilterExtensions(new String[] { "*.pdf" });
    dialog.setFilterNames(new String[] { getI18nManager().getString(getNamespace(), "pdffilter", "label", getLanguage()) });
    dialog.setText(getI18nManager().getString(getNamespace(), "pdf", "label", getLanguage()));
    String filename = dialog.open();
    if (filename != null && filename.length() > 0) {
        if (this.m_app.getApplication() instanceof Comment) {
            ICaller c = ((Comment) this.m_app.getApplication()).getCurrentCaller();
            IService srv = getRuntime().getServiceFactory().getService("CommentService");
            if (srv != null && srv instanceof CommentService) {
                CommentCallerHandler cch = ((CommentService) srv).getHandler();
                if (cch.hasCommentCaller(c)) {
                    ICommentCaller cc = cch.getCommentCaller(c);
                    try {
                        Class pdfclass = Thread.currentThread().getContextClassLoader().loadClass("de.janrufmonitor.ui.jface.application.comment.action.PDFCreator");
                        Constructor con = pdfclass.getConstructor(new Class[] { ICommentCaller.class, String.class });
                        Object pdfcreator = con.newInstance(new Object[] { cc, filename });
                        Method m = pdfclass.getMethod("createPdf", (Class) null);
                        m.invoke(pdfcreator, (Object) null);
                    } catch (ClassNotFoundException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (SecurityException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (NoSuchMethodException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (IllegalArgumentException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (InstantiationException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (IllegalAccessException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (InvocationTargetException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    }
                }
            }
        }
    }
}
Also used : Comment(de.janrufmonitor.ui.jface.application.comment.Comment) ICommentCaller(de.janrufmonitor.service.comment.api.ICommentCaller) Constructor(java.lang.reflect.Constructor) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) CommentService(de.janrufmonitor.service.comment.CommentService) CommentCallerHandler(de.janrufmonitor.service.comment.CommentCallerHandler) FileDialog(org.eclipse.swt.widgets.FileDialog) IService(de.janrufmonitor.service.IService)

Example 40 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class FritzBoxDialogPlugin method run.

public void run() {
    new SWTExecuter(this.getLabel()) {

        protected void execute() {
            ICaller o = m_dialog.getCall().getCaller();
            String dial = ((ICaller) o).getPhoneNumber().getTelephoneNumber();
            if (!((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase(getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_INTAREA))) {
                dial = "00" + ((ICaller) o).getPhoneNumber().getIntAreaCode() + dial;
            }
            if (!dial.startsWith("0"))
                dial = "0" + dial;
            String text = getI18nManager().getString(getNamespaceDial(), "dial", "description", getLanguage());
            text = StringUtils.replaceString(text, "{%1}", dial);
            if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespaceDial(), "success", "label", getLanguage()), text)) {
                Properties config = getRuntime().getConfigManagerFactory().getConfigManager().getProperties(FritzBoxMonitor.NAMESPACE);
                FirmwareManager fwm = FirmwareManager.getInstance();
                try {
                    if (!fwm.isLoggedIn())
                        fwm.login();
                    fwm.doCall(dial, config.getProperty(CFG_CLICKDIAL, "50"));
                    text = getI18nManager().getString(getNamespaceDial(), "success", "description", getLanguage());
                    text = StringUtils.replaceString(text, "{%1}", dial);
                    MessageDialog.openInformation(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespaceDial(), "success", "label", getLanguage()), text);
                } catch (IOException e) {
                    m_logger.warning(e.toString());
                    PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespaceDial(), "faileddial", e));
                } catch (FritzBoxLoginException e) {
                    m_logger.warning(e.toString());
                    PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespaceDial(), "faileddial", e));
                } catch (DoCallException e) {
                    m_logger.warning(e.toString());
                    PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespaceDial(), "faileddial", e));
                }
            }
        }
    }.start();
}
Also used : DoCallException(de.janrufmonitor.fritzbox.firmware.exception.DoCallException) ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) FritzBoxLoginException(de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException) Message(de.janrufmonitor.exception.Message) FirmwareManager(de.janrufmonitor.fritzbox.firmware.FirmwareManager) IOException(java.io.IOException) Properties(java.util.Properties) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter)

Aggregations

ICaller (de.janrufmonitor.framework.ICaller)144 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)62 ICallerList (de.janrufmonitor.framework.ICallerList)49 List (java.util.List)46 IAttribute (de.janrufmonitor.framework.IAttribute)42 ICall (de.janrufmonitor.framework.ICall)41 ArrayList (java.util.ArrayList)40 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)32 SQLException (java.sql.SQLException)26 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)25 IOException (java.io.IOException)25 Viewer (org.eclipse.jface.viewers.Viewer)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 File (java.io.File)20 Date (java.util.Date)17 Iterator (java.util.Iterator)17 Shell (org.eclipse.swt.widgets.Shell)17 IMsn (de.janrufmonitor.framework.IMsn)16 Properties (java.util.Properties)15 ICip (de.janrufmonitor.framework.ICip)14