use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class ConsoleSimulate method execute.
public void execute() {
this.isExecuting = true;
String number = "";
String cip = "";
String msn = "";
if (this.getExecuteParams().length < 2 || this.getExecuteParams().length > 3) {
System.out.println("ERROR: Invalid SIMULATE command.");
System.out.println("USAGE for regular call simulation: SIMULATE <number> <msn> <cip>");
System.out.println("USAGE for CLIR call simulation: SIMULATE <msn> <cip>");
this.isExecuting = false;
return;
}
if (this.getExecuteParams().length == 2) {
msn = this.getExecuteParams()[0];
cip = this.getExecuteParams()[1];
}
if (this.getExecuteParams().length == 3) {
number = this.getExecuteParams()[0];
msn = this.getExecuteParams()[1];
cip = this.getExecuteParams()[2];
}
IEventBroker evtBroker = PIMRuntime.getInstance().getEventBroker();
IPhonenumber phone = PhonenumberAnalyzer.getInstance(getRuntime()).toClirPhonenumber(number);
if (phone != null)
System.out.println("Call detected as CLIR: " + phone.isClired());
if (phone == null) {
phone = PhonenumberAnalyzer.getInstance(getRuntime()).toInternalPhonenumber(number, msn);
if (phone != null)
System.out.println("Call detected as internal: " + number.trim());
}
if (phone == null) {
phone = PhonenumberAnalyzer.getInstance(getRuntime()).toPhonenumber(number, msn);
if (phone != null)
System.out.println("Call detected as external: " + number.trim());
}
IName name = PIMRuntime.getInstance().getCallerFactory().createName("", "");
ICaller aCaller = PIMRuntime.getInstance().getCallerFactory().createCaller(name, phone);
ICip ocip = PIMRuntime.getInstance().getCallFactory().createCip(cip, "");
IMsn omsn = PIMRuntime.getInstance().getCallFactory().createMsn(msn, "");
ICall newCall = PIMRuntime.getInstance().getCallFactory().createCall(aCaller, omsn, ocip);
evtBroker.register(this);
IEvent ev = evtBroker.createEvent(IEventConst.EVENT_TYPE_INCOMINGCALL, newCall);
evtBroker.send(this, ev);
evtBroker.unregister(this);
this.isExecuting = false;
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class DatFileCallImporter method doImport.
public ICallList doImport() {
m_callList = PIMRuntime.getInstance().getCallFactory().createCallList();
Date startDate = new Date();
File db = new File(m_filename);
try {
FileReader dbReader = new FileReader(db);
BufferedReader bufReader = new BufferedReader(dbReader);
ICall aCall = null;
boolean isNewDatFormat = false;
String line = null;
Transformator tf = null;
while (bufReader.ready()) {
line = bufReader.readLine();
if (!isNewDatFormat && line != null && line.indexOf("***") > -1) {
if (tf == null)
tf = new Transformator();
} else {
isNewDatFormat = true;
}
try {
aCall = (isNewDatFormat ? Serializer.toCall(line.getBytes(), PIMRuntime.getInstance()) : tf.transform(line));
// 2008/11/07: new call status introduced in 5.0.8
migrateStatus(aCall);
this.m_callList.add(aCall);
} catch (SerializerException e) {
this.m_logger.warning(e.getMessage());
}
}
bufReader.close();
dbReader.close();
} catch (FileNotFoundException ex) {
this.m_logger.warning("Cannot find call backup file " + m_filename);
return this.m_callList;
} catch (IOException ex) {
this.m_logger.severe("IOException on file " + m_filename);
return this.m_callList;
} catch (NoSuchElementException ex) {
this.m_logger.severe("Invalid format in file " + m_filename);
return this.m_callList;
}
Date endDate = new Date();
this.m_logger.info("Successfully imported call file " + m_filename);
this.m_logger.info("Found " + new Integer(this.m_callList.size()).toString() + " call items in " + new Float((endDate.getTime() - startDate.getTime()) / 1000).toString() + " secs.");
return m_callList;
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class FritzBoxCallListImporter method processModifierServices.
private void processModifierServices(ICallList cl) {
if (cl != null && cl.size() > 0) {
List msvc = PIMRuntime.getInstance().getServiceFactory().getModifierServices();
IModifierService s = null;
for (int k = 0, l = msvc.size(); k < l; k++) {
s = (IModifierService) msvc.get(k);
if (s != null && s.isEnabled()) {
if (m_logger.isLoggable(Level.INFO))
m_logger.info("Processing modifier service <" + s.getServiceID() + ">");
ICall call = null;
for (int i = 0, j = cl.size(); i < j; i++) {
call = cl.get(i);
s.modifyObject(call);
}
}
}
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class FritzBoxCallListImporter method doImport.
public ICallList doImport() {
m_callList = PIMRuntime.getInstance().getCallFactory().createCallList();
try {
FileInputStream fin = new FileInputStream(m_filename);
List result = this.getRawCallList(fin);
if (result.size() > 0) {
FritzBoxCallCsv call = null;
Properties conf = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperties(FritzBoxMonitor.NAMESPACE);
ICall c = null;
for (int i = 0, j = result.size(); i < j; i++) {
call = new FritzBoxCallCsv((String) result.get(i), conf);
c = call.toCall();
if (c != null) {
if (!m_callList.contains(c))
m_callList.add(c);
else {
this.m_logger.warning("Call already imported from FritzBox: " + c.toString());
c.setUUID(c.getUUID() + "-1");
ICip cip = c.getCIP();
// just a dirty hack
cip.setCIP("4");
c.setCIP(cip);
if (!m_callList.contains(c))
m_callList.add(c);
}
}
}
}
} catch (FileNotFoundException e) {
this.m_logger.severe("File not found: " + m_filename);
} catch (IOException e) {
this.m_logger.severe("IO Error on file " + m_filename + ": " + e.getMessage());
}
if (m_callList != null && m_callList.size() > 0) {
if (m_logger.isLoggable(Level.INFO))
m_logger.info("Processing modifier services on call list: " + PIMRuntime.getInstance().getServiceFactory().getModifierServices());
processModifierServices(m_callList);
}
return m_callList;
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class SynchronizerService method modifyObject.
@Override
public void modifyObject(Object o) {
if (!(o instanceof ICall))
return;
boolean synctam = SynchronizerService.this.m_configuration.getProperty(CFG_SYNCTAM, "false").equalsIgnoreCase("true");
if (synctam) {
if (m_logger.isLoggable(Level.INFO))
m_logger.info("Sync TAM recordings: " + Boolean.toString(synctam));
String uuid = ((ICall) o).getUUID();
if (this.m_tamMap != null && this.m_tamMap.containsKey(uuid)) {
List l = (List) this.m_tamMap.get(uuid);
if (l.size() == 6) {
((ICall) o).getAttributes().add(this.getRuntime().getCallFactory().createAttribute("fritzbox.tamurl", (String) l.get(4)));
if (m_logger.isLoggable(Level.INFO))
m_logger.info("add TAM attribute fritzbox.tamurl: " + (String) l.get(4));
((ICall) o).getAttributes().add(this.getRuntime().getCallFactory().createAttribute("fritzbox.tamduration", (String) l.get(3)));
if (m_logger.isLoggable(Level.INFO))
m_logger.info("add TAM attribute fritzbox.tamduration: " + (String) l.get(3));
((ICall) o).getAttributes().add(this.getRuntime().getCallFactory().createAttribute("fritzbox.tam", (String) l.get(5)));
if (m_logger.isLoggable(Level.INFO))
m_logger.info("add TAM attribute fritzbox.tam: " + (String) l.get(5));
}
}
}
}
Aggregations