use of de.janrufmonitor.fritzbox.IPhonebookEntry in project janrufmonitor by tbrandt77.
the class TR064FritzBoxFirmware method getCallerList.
public List getCallerList(int addressbookId, String addressbookName) throws GetCallerListException, IOException {
if (!this.isInitialized())
throw new GetCallerListException("Could not get phone book from FritzBox: FritzBox firmware not initialized.");
int size = 0;
try {
size = FritzBoxTR064Manager.getInstance().getPhonebookSize(this.m_user, this.m_password, this.m_server, (this.m_useHttp ? FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064Port() : FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064SecurePort(this.m_server)), (this.m_useHttp ? "http" : "https"), Integer.toString(addressbookId));
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Pre-calculated list size from FritzBox: " + size);
} catch (IOException e) {
throw new GetCallerListException(e.getMessage());
}
List result = new ArrayList();
for (int i = 0; i < size; i++) {
String xml = null;
try {
xml = FritzBoxTR064Manager.getInstance().getPhonebookEntry(this.m_user, this.m_password, this.m_server, (this.m_useHttp ? FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064Port() : FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064SecurePort(this.m_server)), (this.m_useHttp ? "http" : "https"), Integer.toString(addressbookId), Integer.toString(i));
} catch (IOException e) {
xml = null;
}
if (xml == null) {
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("No more data found in list. Break at list position: " + i);
break;
}
List<IPhonebookEntry> oneResult = FritzBoxMappingManager.getInstance().parseXmltoFritzBoxCallerList(new StringBuffer(xml), addressbookName);
if (oneResult.size() == 1) {
oneResult.get(0).setEntryID(Integer.toString(i));
}
result.addAll(oneResult);
}
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Phonebook from FritzBox succuessfully fetched. List size: " + result.size());
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Final result list elements {IPhonebookEntry}: " + result.toString());
return result;
}
Aggregations