Search in sources :

Example 11 with ICall

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

the class ScoreNumberTellows method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Iterator iter = selection.iterator();
            while (iter.hasNext()) {
                Object o1 = iter.next();
                Object o = null;
                if (o1 instanceof ICall) {
                    o = ((ICall) o1).getCaller();
                }
                if (o1 instanceof ICaller) {
                    o = o1;
                }
                if (o != null) {
                    if (!((ICaller) o).getPhoneNumber().isClired() && !PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(((ICaller) o).getPhoneNumber()) && (((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("49") || ((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("41") || ((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("43"))) {
                        final Object o2 = o1;
                        final Object o3 = o;
                        ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
                        try {
                            IRunnableWithProgress r = new IRunnableWithProgress() {

                                public void run(IProgressMonitor progressMonitor) {
                                    progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "scoring", "label", getLanguage()), IProgressMonitor.UNKNOWN);
                                    progressMonitor.worked(1);
                                    try {
                                        IAttributeMap m = TellowsProxy.getInstance().getTellowsData(((ICaller) o3).getPhoneNumber().getTelephoneNumber(), ((ICaller) o3).getPhoneNumber().getIntAreaCode());
                                        if (m.size() > 0) {
                                            ((ICaller) o3).getAttributes().addAll(m);
                                            if (m_app.getController() instanceof IExtendedApplicationController)
                                                ((IExtendedApplicationController) m_app.getController()).updateElement(o2, false);
                                            else
                                                m_app.getController().updateElement(o2);
                                        }
                                    } catch (Exception e) {
                                        PropagationFactory.getInstance().fire(new Message(Message.ERROR, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), e), "Tray");
                                    }
                                    progressMonitor.done();
                                }
                            };
                            pmd.setBlockOnOpen(false);
                            pmd.run(true, false, r);
                        // 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);
                        }
                    }
                }
            }
            this.m_app.updateViews(true);
        }
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall) Message(de.janrufmonitor.exception.Message) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ICaller(de.janrufmonitor.framework.ICaller) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Iterator(java.util.Iterator) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IExtendedApplicationController(de.janrufmonitor.ui.jface.application.IExtendedApplicationController)

Example 12 with ICall

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

the class TapiClickDialAction method run.

public void run() {
    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) {
                o = ((ICall) o).getCaller();
            }
            if (o instanceof ICaller) {
                o = ((ICaller) o).getPhoneNumber();
            }
            if (o instanceof ITreeItemCallerData) {
                o = ((ITreeItemCallerData) o).getPhone();
            }
            if (o instanceof IPhonenumber) {
                if (((IPhonenumber) o).isClired())
                    return;
                String dial = ((IPhonenumber) o).getTelephoneNumber();
                if (PhonenumberAnalyzer.getInstance(this.getRuntime()).isInternal(dial)) {
                    dial = ((IPhonenumber) o).getCallNumber();
                } else {
                    if (!((IPhonenumber) o).getIntAreaCode().equalsIgnoreCase(this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_INTAREA))) {
                        dial = "00" + ((IPhonenumber) o).getIntAreaCode() + dial;
                    }
                    if (!dial.startsWith("0"))
                        dial = "0" + dial;
                // added 2010/03/06: check for dial prefix for outgoing calls
                // removed 2010/06/25: double addition of prefix. Is already added in Dialogue
                // if (this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).length()>0) {
                // if (this.m_logger.isLoggable(Level.INFO))
                // this.m_logger.info("Using dial prefix: "+this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX));
                // dial = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).trim() + dial;
                // }
                }
                TapiDialerDialog id = new TapiDialerDialog(new Shell(DisplayManager.getDefaultDisplay()), dial);
                id.open();
                this.m_app.updateViews(false);
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) ICall(de.janrufmonitor.framework.ICall) Viewer(org.eclipse.jface.viewers.Viewer) TapiDialerDialog(de.janrufmonitor.ui.jface.application.dialer.TapiDialerDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 13 with ICall

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

the class TextFileCallManager method loadDatabase.

private void loadDatabase(String database) {
    long startDate = System.currentTimeMillis();
    File db = new File(database);
    try {
        FileReader dbReader = new FileReader(db);
        BufferedReader bufReader = new BufferedReader(dbReader);
        String line = null;
        ICall aCall = null;
        while (bufReader.ready()) {
            line = bufReader.readLine();
            // check for old entries
            if (line.indexOf(CALL_SEPARATOR) > -1)
                line = this.transformOldTextfileData(line);
            try {
                aCall = Serializer.toCall(line.getBytes(), this.getRuntime());
                this.m_callList.add(aCall);
            } catch (SerializerException e) {
                this.m_logger.severe(e.getMessage());
            }
        }
        bufReader.close();
        dbReader.close();
    } catch (FileNotFoundException ex) {
        this.m_logger.warning("Cannot find call database: " + database);
        this.m_logger.info("Creating call database: " + database);
        File dbnew = new File(database);
        if (!dbnew.exists()) {
            try {
                dbnew.createNewFile();
            } catch (IOException e) {
                this.m_logger.severe("Cannot create file: " + database + ". Check read/write permissions.");
            }
        }
    } catch (IOException ex) {
        this.m_logger.severe("IOException on file " + database);
    } catch (NullPointerException ex) {
        this.m_logger.warning("Final character in file " + database + " is null and filtered out.");
    }
    long endDate = System.currentTimeMillis();
    this.m_logger.info("Successfully loaded call database " + database);
    this.m_logger.info("Found " + new Integer(this.m_callList.size()).toString() + " call items in " + Float.toString((endDate - startDate) / 1000) + " secs.");
}
Also used : ICall(de.janrufmonitor.framework.ICall) SerializerException(de.janrufmonitor.util.io.SerializerException)

Example 14 with ICall

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

the class SynchronizerService method createRedundancyList.

private ICallList createRedundancyList(ICallList l, long lastsync) throws CloneNotSupportedException {
    if (l == null)
        return getRuntime().getCallFactory().createCallList();
    ICallList cl = getRuntime().getCallFactory().createCallList(2 * l.size());
    ICall c = null;
    ICall cloneCall = null;
    for (int i = 0, j = l.size(); i < j; i++) {
        c = l.get(i);
        if (c.getDate().getTime() >= lastsync) {
            cloneCall = (ICall) c.clone();
            cloneCall.setDate(new Date(c.getDate().getTime() - 60000));
            // create UUID
            cloneCall.setUUID(FritzBoxUUIDManager.getInstance().getUUID(cloneCall.getDate(), cloneCall.getCaller().getPhoneNumber(), cloneCall.getMSN()));
            cl.add(c);
            if (m_logger.isLoggable(Level.INFO))
                m_logger.info("Cloned call with Date -60000 msec");
            cl.add(cloneCall);
        }
    }
    return cl;
}
Also used : ICall(de.janrufmonitor.framework.ICall) ICallList(de.janrufmonitor.framework.ICallList) Date(java.util.Date)

Example 15 with ICall

use of de.janrufmonitor.framework.ICall 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)

Aggregations

ICall (de.janrufmonitor.framework.ICall)89 ICaller (de.janrufmonitor.framework.ICaller)41 List (java.util.List)23 Viewer (org.eclipse.jface.viewers.Viewer)20 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)19 ArrayList (java.util.ArrayList)19 IAttribute (de.janrufmonitor.framework.IAttribute)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)18 ICallList (de.janrufmonitor.framework.ICallList)17 IOException (java.io.IOException)14 Properties (java.util.Properties)14 Date (java.util.Date)13 Iterator (java.util.Iterator)13 Shell (org.eclipse.swt.widgets.Shell)13 File (java.io.File)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)11 ICip (de.janrufmonitor.framework.ICip)10 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)10