Search in sources :

Example 31 with ICaller

use of de.janrufmonitor.framework.ICaller 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 32 with ICaller

use of de.janrufmonitor.framework.ICaller 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 33 with ICaller

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

the class XTapiCall method toCall.

public ICall toCall() {
    if (this.m_call == null) {
        IRuntime r = PIMRuntime.getInstance();
        IPhonenumber phone = PhonenumberAnalyzer.getInstance(r).toClirPhonenumber(this.m_number);
        if (phone == null)
            phone = PhonenumberAnalyzer.getInstance(r).toInternalPhonenumber(this.m_number, this.m_msn);
        if (phone == null)
            phone = PhonenumberAnalyzer.getInstance(r).toPhonenumber(this.m_number, this.m_msn);
        ICaller c = r.getCallerFactory().createCaller(phone);
        IMsn msn = null;
        if (this.m_msn == null) {
            msn = r.getCallFactory().createMsn(getFestnetzAlias(), "");
        } else {
            msn = r.getCallFactory().createMsn(this.m_msn, "");
        }
        msn.setAdditional(r.getMsnManager().getMsnLabel(msn));
        if (this.m_name != null && this.m_name.length() > 0) {
            c.setName(r.getCallerFactory().createName("", this.m_name));
        }
        ICip cip = r.getCallFactory().createCip(getDefaultCip(), "");
        cip.setAdditional(r.getCipManager().getCipLabel(cip, ""));
        // create attributes
        IAttributeMap am = r.getCallFactory().createAttributeMap();
        am.add(r.getCallFactory().createAttribute("tapi.device", Integer.toString(this.m_device)));
        am.add(r.getCallFactory().createAttribute("tapi.instance", Integer.toString(this.m_instance)));
        am.add(r.getCallFactory().createAttribute("tapi.key", getKey(this.m_device, this.m_instance)));
        am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
        this.m_call = r.getCallFactory().createCall(c, msn, cip, new Date());
        this.m_call.setAttributes(am);
    }
    return this.m_call;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICip(de.janrufmonitor.framework.ICip) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IMsn(de.janrufmonitor.framework.IMsn) Date(java.util.Date) IRuntime(de.janrufmonitor.runtime.IRuntime) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 34 with ICaller

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

the class FritzBoxMappingManager method toCallerList.

public ICallerList toCallerList(List l) {
    ICallerList cl = getRuntime().getCallerFactory().createCallerList(l.size());
    ICaller c = null;
    for (int i = 0; i < l.size(); i++) {
        try {
            c = this.mapFritzBoxCallerToJam((IPhonebookEntry) l.get(i));
            if (c != null)
                cl.add(c);
        } catch (IOException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
    return cl;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) IPhonebookEntry(de.janrufmonitor.fritzbox.IPhonebookEntry) IOException(java.io.IOException)

Example 35 with ICaller

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

the class FritzBoxMappingManager method toFritzBoxCallerList.

public List toFritzBoxCallerList(ICallerList l) {
    List cl = new ArrayList(l.size());
    IPhonebookEntry pe = null;
    for (int i = 0; i < l.size(); i++) {
        try {
            pe = this.mapJamCallerToFritzBox((ICaller) l.get(i));
            if (pe != null)
                cl.add(pe);
        } catch (IOException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
    return cl;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List) IPhonebookEntry(de.janrufmonitor.fritzbox.IPhonebookEntry) IOException(java.io.IOException)

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