Search in sources :

Example 76 with ICallerList

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

the class FritzBoxPhonebookManager method setCaller.

public void setCaller(ICaller caller) {
    FirmwareManager fwm = FirmwareManager.getInstance();
    fwm.startup();
    try {
        if (!fwm.isLoggedIn())
            fwm.login();
        // check if phonebook is configured
        String abId = getConfiguration().getProperty(CFG_ADDRESSBOOK, "0");
        if (this.m_logger.isLoggable(Level.INFO))
            this.m_logger.info("Getting FritzBox phonebook ID: #" + abId);
        int id = Integer.parseInt(abId);
        IPhonebookEntry pe = FritzBoxMappingManager.getInstance().mapJamCallerToFritzBox(caller);
        fwm.setCaller(id, pe);
        ICallerList cl = getRuntime().getCallerFactory().createCallerList(1);
        cl.add(caller);
        try {
            getDatabaseHandler().insertOrUpdateCallerList(cl);
            getDatabaseHandler().commit();
        } catch (SQLException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
            try {
                getDatabaseHandler().rollback();
            } catch (SQLException e1) {
                this.m_logger.log(Level.SEVERE, e1.getMessage(), e1);
            }
        }
    } catch (FritzBoxLoginException e) {
        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
    } catch (IOException e) {
        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
    } catch (SetCallerException e) {
        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
    }
    if (!this.isSyncing)
        this.createCallerListFromFritzBoxPhonebook();
}
Also used : FritzBoxLoginException(de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException) ICallerList(de.janrufmonitor.framework.ICallerList) FirmwareManager(de.janrufmonitor.fritzbox.firmware.FirmwareManager) SQLException(java.sql.SQLException) SetCallerException(de.janrufmonitor.fritzbox.firmware.exception.SetCallerException) IPhonebookEntry(de.janrufmonitor.fritzbox.IPhonebookEntry) IOException(java.io.IOException)

Example 77 with ICallerList

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

the class AbstractDatabaseCallerManager method setCaller.

public synchronized void setCaller(ICaller caller) {
    ICallerList cl = this.getRuntime().getCallerFactory().createCallerList(1);
    cl.add(caller);
    this.setCaller(cl);
}
Also used : ICallerList(de.janrufmonitor.framework.ICallerList)

Example 78 with ICallerList

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

the class AbstractDatabaseCallerManager method removeCaller.

public synchronized void removeCaller(ICaller caller) {
    ICallerList cl = this.getRuntime().getCallerFactory().createCallerList(1);
    cl.add(caller);
    this.removeCaller(cl);
}
Also used : ICallerList(de.janrufmonitor.framework.ICallerList)

Example 79 with ICallerList

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

the class CallerReaderFactory method unMultiPhoneCaller.

private ICallerList unMultiPhoneCaller(ICallerList cl, List managers) {
    ICallerList l = PIMRuntime.getInstance().getCallerFactory().createCallerList(cl.size());
    ICaller c = null;
    ICaller nc = null;
    for (int i = 0, j = cl.size(); i < j; i++) {
        c = cl.get(i);
        if (c instanceof IMultiPhoneCaller) {
            List phones = ((IMultiPhoneCaller) c).getPhonenumbers();
            IPhonenumber pn = null;
            for (int k = 0; k < phones.size(); k++) {
                pn = (IPhonenumber) phones.get(k);
                // removed due to performance issues: c = this.getCaller(pn, managers);
                nc = PIMRuntime.getInstance().getCallerFactory().createCaller(null, pn, c.getAttributes());
                if (nc != null) {
                    l.add(nc);
                }
            }
        } else
            l.add(c);
    }
    return l;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) IMultiPhoneCaller(de.janrufmonitor.framework.IMultiPhoneCaller) List(java.util.List) ICallerList(de.janrufmonitor.framework.ICallerList) ArrayList(java.util.ArrayList) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 80 with ICallerList

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

the class CallerReaderFactory method getAllCallers.

public List getAllCallers() {
    if (m_list == null) {
        List managers = this.getActiveCallerManagers();
        ICallerList list = PIMRuntime.getInstance().getCallerFactory().createCallerList();
        ICallerList manList = null;
        ICallerManager man = null;
        for (int i = 0; i < managers.size(); i++) {
            man = (ICallerManager) managers.get(i);
            if (man != null && man.isActive() && man.isSupported(IReadCallerRepository.class)) {
                this.m_currentCM = man;
                manList = ((IReadCallerRepository) man).getCallers((IFilter) null);
                list.add(unMultiPhoneCaller(manList, managers));
            }
        }
        list.sort(CallerListComparator.ORDER_CALLERNAME, false);
        m_list = new ArrayList();
        m_list.add(PIMRuntime.getInstance().getCallerFactory().createCaller(PIMRuntime.getInstance().getCallerFactory().createName("", ""), PIMRuntime.getInstance().getCallerFactory().createPhonenumber(true)));
        // added 2009/04/18: added internal numbers
        m_list.add(PIMRuntime.getInstance().getCallerFactory().createCaller(PIMRuntime.getInstance().getCallerFactory().createName("", ""), PIMRuntime.getInstance().getCallerFactory().createPhonenumber(IJAMConst.INTERNAL_CALL, "", IJAMConst.INTERNAL_CALL_NUMBER_SYMBOL)));
        for (int i = list.size() - 1; i >= 0; i--) {
            m_list.add(list.get(i));
        }
    }
    this.m_currentCM = null;
    return m_list;
}
Also used : ICallerList(de.janrufmonitor.framework.ICallerList) IFilter(de.janrufmonitor.repository.filter.IFilter) ArrayList(java.util.ArrayList) IReadCallerRepository(de.janrufmonitor.repository.types.IReadCallerRepository) List(java.util.List) ICallerList(de.janrufmonitor.framework.ICallerList) ArrayList(java.util.ArrayList) ICallerManager(de.janrufmonitor.repository.ICallerManager)

Aggregations

ICallerList (de.janrufmonitor.framework.ICallerList)81 ICaller (de.janrufmonitor.framework.ICaller)40 List (java.util.List)36 ArrayList (java.util.ArrayList)32 IAttribute (de.janrufmonitor.framework.IAttribute)24 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)24 SQLException (java.sql.SQLException)24 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)18 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)17 IOException (java.io.IOException)15 Message (de.janrufmonitor.exception.Message)14 Iterator (java.util.Iterator)11 Map (java.util.Map)11 File (java.io.File)10 HashMap (java.util.HashMap)10 Viewer (org.eclipse.jface.viewers.Viewer)10 ICallerManager (de.janrufmonitor.repository.ICallerManager)9 ComFailException (com.jacob.com.ComFailException)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)7