Search in sources :

Example 6 with ICall

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

the class LastCalled method renderAsText.

public String renderAsText() {
    if (this.m_o != null) {
        if (this.m_o instanceof ICaller) {
            this.m_o = new TreeItemCallerData(((ICaller) this.m_o).getAttributes(), ((ICaller) this.m_o).getPhoneNumber());
        }
        if (this.m_o instanceof ITreeItemCallerData) {
            IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
            List cms = PIMRuntime.getInstance().getCallManagerFactory().getTypedCallManagers(IReadCallRepository.class);
            if (cms.size() > 0) {
                ICallManager cm = null;
                for (int i = 0, j = cms.size(); i < j; i++) {
                    cm = (ICallManager) cms.get(i);
                    if (cm.isActive() && cm.isSupported(IReadCallRepository.class)) {
                        IFilter[] filters = new IFilter[] { new PhonenumberFilter(pn), new ItemCountFilter(1) };
                        ICallList cl = ((IReadCallRepository) cm).getCalls(filters, 1, 0);
                        cl.sort(0, false);
                        if (cl.size() > 0) {
                            ICall c = cl.get(0);
                            return getFormatter().parse(IJAMConst.GLOBAL_VARIABLE_CALLTIME, c.getDate());
                        }
                    }
                }
            }
        }
    }
    return "";
}
Also used : IReadCallRepository(de.janrufmonitor.repository.types.IReadCallRepository) ICall(de.janrufmonitor.framework.ICall) ICallManager(de.janrufmonitor.repository.ICallManager) ICaller(de.janrufmonitor.framework.ICaller) IFilter(de.janrufmonitor.repository.filter.IFilter) ItemCountFilter(de.janrufmonitor.repository.filter.ItemCountFilter) ICallList(de.janrufmonitor.framework.ICallList) PhonenumberFilter(de.janrufmonitor.repository.filter.PhonenumberFilter) ICallList(de.janrufmonitor.framework.ICallList) List(java.util.List) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 7 with ICall

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

the class ImagePreview method renderAsImageID.

public String renderAsImageID() {
    if (this.m_o != null) {
        if (this.m_o instanceof ICall) {
            this.m_o = ((ICall) this.m_o).getCaller();
        }
        if (this.m_o instanceof ICaller) {
            if (ImageHandler.getInstance().hasImage((ICaller) this.m_o)) {
                String path = ImageHandler.getInstance().getImagePath((ICaller) this.m_o);
                if (new File(path).exists())
                    return path;
                String newPath = PathResolver.getInstance().getTempDirectory() + File.separator + ((ICaller) this.m_o).getUUID() + ".jpg";
                try {
                    FileOutputStream fos = new FileOutputStream(newPath);
                    InputStream imgin = ImageHandler.getInstance().getImageStream((ICaller) this.m_o);
                    Stream.copy(imgin, fos, true);
                    return newPath;
                } catch (FileNotFoundException e) {
                } catch (IOException e) {
                }
            }
        }
    }
    return "";
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File)

Example 8 with ICall

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

the class HistoryAction 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) {
                History h = new History(((ICaller) o));
                h.open();
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) History(de.janrufmonitor.ui.jface.application.history.History)

Example 9 with ICall

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

the class Server method sendRequest.

private synchronized void sendRequest(IEvent event, IHttpRequest request) {
    List clients = ClientRegistry.getInstance().getAllClients();
    Client c = null;
    for (int i = 0; i < clients.size(); i++) {
        c = (Client) clients.get(i);
        Object call = event.getData();
        if (call != null && call instanceof ICall) {
            IMsn msn = ((ICall) call).getMSN();
            if (!SecurityManager.getInstance().isAllowedForMSN(c.getClientIP(), msn.getMSN()) || !SecurityManager.getInstance().isAllowedForMSN(c.getClientName(), msn.getMSN())) {
                this.m_logger.info("Client " + c + " is blocked for MSN " + msn.getMSN() + ".");
                continue;
            }
        }
        if (this.isEventClient(c.getEvents(), event.getType())) {
            this.m_logger.info("Sending event #" + event + " to client " + c + ".");
            try {
                if (request.getContent() != null)
                    c.setByteReceived(request.getContent().length);
                IRequester r = null;
                if (c.getClientName().trim().length() > 0)
                    r = RequesterFactory.getInstance().getRequester(c.getClientName(), c.getClientPort());
                else
                    r = RequesterFactory.getInstance().getRequester(c.getClientIP(), c.getClientPort());
                r.setRequest(request);
                Thread s = new Thread(new SenderThread(r));
                s.setName("JAM-" + SenderThread.class.getName() + "#" + i + "-Thread-(non-deamon)");
                s.start();
            } catch (Exception e) {
                this.m_logger.severe(e.getMessage());
            }
        }
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall) List(java.util.List) IRequester(de.janrufmonitor.service.commons.http.IRequester) IMsn(de.janrufmonitor.framework.IMsn)

Example 10 with ICall

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

the class OpenTellows 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) {
                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"))) {
                    StringBuffer url = new StringBuffer();
                    url.append("http://www.tellows.");
                    if (((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("49"))
                        url.append("de");
                    if (((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("43"))
                        url.append("at");
                    if (((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("41"))
                        url.append("ch");
                    url.append("/num/0");
                    url.append(((ICaller) o).getPhoneNumber().getTelephoneNumber());
                    if (this.m_logger.isLoggable(Level.INFO))
                        this.m_logger.info("Found valid web url to execute: " + url.toString());
                    Program.launch(url.toString());
                }
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

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