use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class ProviderLogo method renderAsImage.
public Image renderAsImage() {
if (this.m_o != null) {
if (this.m_o instanceof ICall) {
this.m_o = ((ICall) this.m_o).getCaller().getPhoneNumber();
}
if (this.m_o instanceof ICaller) {
this.m_o = ((ICaller) this.m_o).getPhoneNumber();
}
if (this.m_o instanceof ITreeItemCallerData) {
this.m_o = ((ITreeItemCallerData) this.m_o).getPhone();
}
if (this.m_o instanceof IPhonenumber) {
if (((IPhonenumber) this.m_o).isClired())
return null;
String key = "provider/" + ((IPhonenumber) this.m_o).getIntAreaCode() + "_" + ((IPhonenumber) this.m_o).getAreaCode() + ".jpg";
File logoFile = new File(PathResolver.getInstance(PIMRuntime.getInstance()).getImageDirectory() + key);
if (!logoFile.exists() || !logoFile.isFile()) {
key = "provider/" + ((IPhonenumber) this.m_o).getIntAreaCode() + ".jpg";
logoFile = new File(PathResolver.getInstance(PIMRuntime.getInstance()).getImageDirectory() + key);
if (!logoFile.exists() || !logoFile.isFile())
return null;
}
Image logo = SWTImageManager.getInstance(PIMRuntime.getInstance()).get(key);
if (logo == null) {
SWTImageManager.getInstance(PIMRuntime.getInstance()).loadImage(key, 40, 40);
logo = SWTImageManager.getInstance(PIMRuntime.getInstance()).get(key);
return logo;
}
return logo;
}
}
return null;
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class NumberType method renderAsText.
public String renderAsText() {
if (this.m_o != null) {
if (this.m_o instanceof ICall) {
this.m_o = ((ICall) this.m_o).getCaller();
}
if (this.m_o instanceof ICaller) {
this.m_o = new TreeItemCallerData(((ICaller) this.m_o).getAttributes(), ((ICaller) this.m_o).getPhoneNumber());
}
if (this.m_o instanceof ITreeItemCallerData) {
IAttributeMap m = ((ITreeItemCallerData) m_o).getAttributes();
IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
if (m.contains(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber())) {
IAttribute type = m.get(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber());
if (type != null) {
return PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, type.getValue(), "label", getLanguage());
}
}
}
}
return "";
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class IconBlinker method receivedIdentifiedCall.
public void receivedIdentifiedCall(IEvent event) {
super.receivedIdentifiedCall(event);
ICall aCall = (ICall) event.getData();
if (aCall != null) {
if (getRuntime().getRuleEngine().validate(this.getID(), aCall.getMSN(), aCall.getCIP(), aCall.getCaller().getPhoneNumber())) {
this.startBlinker();
} else {
this.m_logger.info("No rule assigned to execute this service for call: " + aCall);
}
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class Journaling method receivedOtherEventCall.
public void receivedOtherEventCall(IEvent event) {
if (event.getType() == IEventConst.EVENT_TYPE_CALLACCEPTED || event.getType() == IEventConst.EVENT_TYPE_CALLCLEARED || event.getType() == IEventConst.EVENT_TYPE_MANUALCALLACCEPTED || event.getType() == IEventConst.EVENT_TYPE_CALLREJECTED || event.getType() == IEventConst.EVENT_TYPE_CALLMARKEDSPAM || event.getType() == IEventConst.EVENT_TYPE_IDENTIFIED_OUTGOING_CALL_ACCEPTED) {
// checks wether this service is available for the incoming MSN or not.
ICall updateCall = (ICall) event.getData();
if (updateCall == null) {
this.m_logger.warning("Call reference is null.");
return;
}
if (this.getRuntime().getRuleEngine().validate(this.ID, updateCall.getMSN(), updateCall.getCIP(), updateCall.getCaller().getPhoneNumber())) {
List callManagerList = this.getRuntime().getCallManagerFactory().getAllCallManagers();
ICallManager icm = null;
IEventBroker eventBroker = this.getRuntime().getEventBroker();
for (int i = 0; i < callManagerList.size(); i++) {
icm = (ICallManager) callManagerList.get(i);
// check if the repository manager allows read/write access
if (icm.isActive() && icm.isSupported(IWriteCallRepository.class)) {
// try to keep old attribute information of call and caller
if (icm.isSupported(IReadCallRepository.class)) {
this.m_logger.info("Call manager <" + icm.getManagerID() + "> is supporting read mode.");
ICallList cl = ((IReadCallRepository) icm).getCalls(new UUIDFilter(new String[] { updateCall.getUUID() }));
if (cl.size() == 1) {
this.m_logger.info("Found exact 1 old call in call manager <" + icm.getManagerID() + "> with UUID " + updateCall.getUUID());
ICall oldCall = cl.get(0);
if (oldCall != null) {
this.m_logger.info("Setting old call info : " + oldCall + " to new call : " + updateCall);
oldCall.getCaller().getAttributes().addAll(updateCall.getCaller().getAttributes());
oldCall.getAttributes().addAll(updateCall.getAttributes());
updateCall = oldCall;
this.m_logger.info("Updated new call : " + updateCall);
}
}
}
((IWriteCallRepository) icm).updateCall(updateCall);
this.m_logger.info("Call update sent to repository manager <" + icm.getManagerID() + ">: " + updateCall);
eventBroker.send(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_UPDATE_CALL, updateCall));
}
}
}
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class OldDatFileCallImporter method migrateCallFromString.
private ICall migrateCallFromString(String scall, String datePattern) {
if (scall != null && scall.trim().length() == 0)
return null;
try {
StringTokenizer st = new StringTokenizer(scall, "%$");
if (st.countTokens() < 5) {
this.m_logger.warning("Invalid entry found: entry was dropped for migration.");
return null;
}
String state = st.nextToken().trim();
String msn = st.nextToken().trim();
String caller = st.nextToken().trim();
String cip = st.nextToken().trim();
String date = st.nextToken().trim();
// parse MSN
IMsn parsedMSN = this.parseMsn(msn);
ICip parsedCIP = this.parseCip(cip);
IAttribute att = this.parseState(state);
IPhonenumber phone = this.parsePhone(caller);
IName name = this.parseName(caller);
ICaller parsedCaller = PIMRuntime.getInstance().getCallerFactory().createCaller(name, phone);
Date parsedDate = this.parseDate(date, datePattern);
ICall aCall = PIMRuntime.getInstance().getCallFactory().createCall(parsedCaller, parsedMSN, parsedCIP, parsedDate);
if (!att.getName().equalsIgnoreCase("")) {
aCall.setAttribute(att);
}
this.m_logger.info(aCall.toString());
return aCall;
} catch (NoSuchElementException ex) {
this.m_logger.warning("FormatException: migration failed due to incompatible format information.");
} catch (NullPointerException ex) {
this.m_logger.warning("Invalid entry found: entry was dropped for migration.");
}
return null;
}
Aggregations