use of de.janrufmonitor.framework.IMsn in project janrufmonitor by tbrandt77.
the class XMLCallHandler method startElement.
public void startElement(String uri, String name, String qname, Attributes attributes) throws SAXException {
if (this.m_multi && qname.equalsIgnoreCase(TAG_CALLLIST)) {
this.m_calllist = this.getRuntime().getCallFactory().createCallList();
}
if (qname.equalsIgnoreCase(TAG_CALL)) {
this.m_call = this.getRuntime().getCallFactory().createCall(null, this.getRuntime().getCallFactory().createMsn("", ""), this.getRuntime().getCallFactory().createCip("", ""));
}
if (qname.equalsIgnoreCase(TAG_CALLER)) {
this.m_iscaller = true;
}
if (this.m_iscaller) {
super.startElement(uri, name, qname, attributes);
return;
}
if (qname.equalsIgnoreCase(TAG_UUID)) {
this.m_call.setUUID(attributes.getValue(ATTRIBUTE_VALUE));
}
if (qname.equalsIgnoreCase(TAG_DATE)) {
this.m_call.setDate(new Date(Long.parseLong(attributes.getValue(ATTRIBUTE_VALUE))));
}
if (qname.equalsIgnoreCase(TAG_CIP)) {
ICip cip = this.m_call.getCIP();
cip.setCIP(attributes.getValue(ATTRIBUTE_VALUE));
cip.setAdditional(this.getRuntime().getCipManager().getCipLabel(cip, this.getLanguage()));
this.m_call.setCIP(cip);
}
if (qname.equalsIgnoreCase(TAG_MSN)) {
IMsn msn = this.m_call.getMSN();
msn.setMSN(attributes.getValue(ATTRIBUTE_VALUE));
msn.setAdditional(decode(attributes.getValue(ATTRIBUTE_ADDITIONAL)));
this.m_call.setMSN(msn);
}
if (qname.equalsIgnoreCase(TAG_ATTRIBUTE)) {
IAttribute att = this.getRuntime().getCallerFactory().createAttribute(attributes.getValue(ATTRIBUTE_NAME), decode(attributes.getValue(ATTRIBUTE_VALUE)));
this.m_call.setAttribute(att);
}
}
use of de.janrufmonitor.framework.IMsn in project janrufmonitor by tbrandt77.
the class OutgoingCall method handleWithException.
public void handleWithException(IHttpRequest req, IMutableHttpResponse resp) throws HandlerException {
IPhonenumber pn = null;
try {
String phone = req.getParameter(OutgoingCall.PARAMETER_NUMBER);
if (phone == null || phone.length() == 0)
pn = PIMRuntime.getInstance().getCallerFactory().createPhonenumber(true);
else
pn = PIMRuntime.getInstance().getCallerFactory().createPhonenumber(phone);
IName name = PIMRuntime.getInstance().getCallerFactory().createName("", "");
ICaller c = PIMRuntime.getInstance().getCallerFactory().createCaller(name, pn);
ICip cip = PIMRuntime.getInstance().getCallFactory().createCip(req.getParameter(OutgoingCall.PARAMETER_CIP), "");
IMsn msn = PIMRuntime.getInstance().getCallFactory().createMsn(req.getParameter(OutgoingCall.PARAMETER_MSN), "");
Date date = new Date(Long.parseLong(req.getParameter(OutgoingCall.PARAMETER_DATE)));
ICall call = PIMRuntime.getInstance().getCallFactory().createCall(c, msn, cip, date);
call.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STARTRING, Long.toString(new Date().getTime())));
call.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_OUTGOING));
ClientCallMap.getInstance().setCall((pn.isClired() ? IJAMConst.CLIRED_CALL : pn.getTelephoneNumber()) + "/" + msn.getMSN(), call);
Thread sender = new Thread(new HandlerThread(call, this));
sender.start();
resp.getContentStreamForWrite().close();
} catch (Exception e) {
throw new HandlerException(e.getMessage(), 500);
}
}
use of de.janrufmonitor.framework.IMsn in project janrufmonitor by tbrandt77.
the class MailNotification method getFromList.
private MailDataObject getFromList(String msn) {
IMsn oldMsn = this.getRuntime().getMsnManager().createMsn(msn);
MailDataObject md = null;
for (int i = 0; i < this.dataList.size(); i++) {
md = (MailDataObject) this.dataList.get(i);
if (md.getMsn().equals(oldMsn))
return md;
}
return null;
}
use of de.janrufmonitor.framework.IMsn in project janrufmonitor by tbrandt77.
the class NcidCallRaw method toCall.
public ICall toCall() {
if (this.m_line == null || this.m_line.length() == 0)
return null;
if (this.m_call == null) {
IRuntime r = PIMRuntime.getInstance();
String[] call = this.m_line.split("\\*");
if (call.length >= 8 && (call[0].trim().equalsIgnoreCase("CID:") || call[0].trim().equalsIgnoreCase("CIDLOG:"))) {
// create MSN
IMsn msn = r.getCallFactory().createMsn(getFestnetzAlias(call[6]), "");
msn.setAdditional(r.getMsnManager().getMsnLabel(msn));
IPhonenumber pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toClirPhonenumber(call[8].trim());
// if no CLIR call, check internal
if (pn == null)
pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toInternalPhonenumber(call[8].trim(), msn.getMSN());
// if no internal call, check regular
if (pn == null) {
// if incoming call does not start with 0, the Provider number seems to have the wrong format
// assume it is an international format 4971657110
boolean onlyNumbers = call[8].matches("[+-]?[0-9]+");
if (!call[8].startsWith("0") && onlyNumbers) {
call[8] = "00" + call[8];
}
pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(call[8].trim(), msn.getMSN());
}
ICaller caller = r.getCallerFactory().createCaller(pn);
// create call data
// added 2009/05/01
String dateformat = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(NcidMonitor.NAMESPACE, "dateformat");
if (dateformat == null || dateformat.trim().length() == 0)
dateformat = "ddMMyyyyHHmm";
if (Logger.getLogger(IJAMConst.DEFAULT_LOGGER).isLoggable(Level.INFO))
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Setting date format to #" + dateformat + "#");
SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
Date date = new Date(0);
try {
date = sdf.parse(call[2] + call[4]);
} catch (ParseException e) {
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).severe("Wrong standard date format detected. " + call[2] + call[4] + " does not match #" + dateformat + "#");
}
ICip cip = r.getCallFactory().createCip(getCip("sip"), "");
cip.setAdditional(r.getCipManager().getCipLabel(cip, ""));
// create attributes
IAttributeMap am = r.getCallFactory().createAttributeMap();
am.add(r.getCallFactory().createAttribute("ncid.key", call[6]));
if (call.length >= 12) {
am.add(r.getCallFactory().createAttribute("ncid.msg", call[10]));
am.add(r.getCallFactory().createAttribute("ncid.callername", call[12]));
}
am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
// create UUID
StringBuffer uuid = new StringBuffer();
uuid.append(date.getTime());
uuid.append("-");
uuid.append(pn.getTelephoneNumber());
uuid.append("-");
uuid.append(msn.getMSN());
// limit uuid to 32 chars
if (uuid.length() > 31) {
// reduce byte length to append -1 for redundant calls max -1-1 --> 3 calls
uuid = new StringBuffer(uuid.substring(0, 31));
}
this.m_call = r.getCallFactory().createCall(uuid.toString(), caller, msn, cip, date);
this.m_call.setAttributes(am);
}
if (call.length >= 8 && call[0].trim().equalsIgnoreCase("OUT:")) {
// create msn
IMsn msn = r.getCallFactory().createMsn(getFestnetzAlias(call[6]), "");
msn.setAdditional(r.getMsnManager().getMsnLabel(msn));
// create caller data
String callByCall = null;
IPhonenumber pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toClirPhonenumber(call[8].trim());
// if no CLIR call, check internal
if (pn == null)
pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toInternalPhonenumber(call[8].trim(), msn.getMSN());
// if no internal call, check regular
if (pn == null) {
// added 2006/08/10: trim call-by-call information
// only can occure on state CALL (out-going calls)
callByCall = getCallByCall(call[8]);
if (callByCall != null) {
call[8] = call[8].substring(callByCall.length());
}
// requires addition of areacode
if (!call[8].startsWith("0")) {
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Assuming number " + call[8] + " has missing areacode.");
call[8] = this.getGeneralAreaCode() + call[8];
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Added areacode to number " + call[8]);
}
pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(call[8].trim(), msn.getMSN());
}
ICaller caller = r.getCallerFactory().createCaller(pn);
// create call data
// added 2009/05/27
String dateformat = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(NcidMonitor.NAMESPACE, "dateformat");
if (dateformat == null || dateformat.trim().length() == 0)
dateformat = "ddMMyyyyHHmm";
if (Logger.getLogger(IJAMConst.DEFAULT_LOGGER).isLoggable(Level.INFO))
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Setting date format to #" + dateformat + "#");
SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
Date date = new Date(0);
try {
date = sdf.parse(call[2] + call[4]);
} catch (ParseException e) {
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).severe("Wrong standard date format detected. " + call[2] + call[4] + " does not match #" + dateformat + "#");
}
ICip cip = r.getCallFactory().createCip(getCip("sip"), "");
cip.setAdditional(r.getCipManager().getCipLabel(cip, ""));
// create attributes
IAttributeMap am = r.getCallFactory().createAttributeMap();
am.add(r.getCallFactory().createAttribute("ncid.key", call[6]));
if (call.length >= 12) {
am.add(r.getCallFactory().createAttribute("ncid.msg", call[10]));
am.add(r.getCallFactory().createAttribute("ncid.callername", call[12]));
}
am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_OUTGOING));
if (callByCall != null)
am.add(r.getCallFactory().createAttribute("ncid.callbycall", callByCall));
// create UUID
StringBuffer uuid = new StringBuffer();
uuid.append(date.getTime());
uuid.append("-");
uuid.append(pn.getTelephoneNumber());
uuid.append("-");
uuid.append(msn.getMSN());
// limit uuid to 32 chars
if (uuid.length() > 31) {
// reduce byte length to append -1 for redundant calls max -1-1 --> 3 calls
uuid = new StringBuffer(uuid.substring(0, 31));
}
this.m_call = r.getCallFactory().createCall(uuid.toString(), caller, msn, cip, date);
this.m_call.setAttributes(am);
}
}
return this.m_call;
}
use of de.janrufmonitor.framework.IMsn in project janrufmonitor by tbrandt77.
the class Sound method removeSoundDataObject.
private void removeSoundDataObject(String msn, String file) {
IMsn oldMsn = this.getRuntime().getMsnManager().createMsn(msn);
SoundDataObject sdo = new SoundDataObject(oldMsn, file);
this.dataList.remove(sdo);
this.removableData.add(sdo);
tv.setInput(this.dataList);
}
Aggregations