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();
}
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);
}
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);
}
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;
}
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;
}
Aggregations