use of de.janrufmonitor.framework.IMsn in project janrufmonitor by tbrandt77.
the class Sound method openDataWizard.
private void openDataWizard(String msn, String file) {
Display display = DisplayManager.getDefaultDisplay();
Shell shell = new Shell(display);
// Create the dialog
IMsn oldMsn = this.getRuntime().getMsnManager().createMsn(msn);
SoundDataObject oldSdo = new SoundDataObject(oldMsn, file);
WizardDialog.setDefaultImage(SWTImageManager.getInstance(this.getRuntime()).get(IJAMConst.IMAGE_KEY_PIM_ICON));
SoundDataWizard sdoW = new SoundDataWizard(oldSdo);
WizardDialog dlg = new WizardDialog(shell, sdoW);
dlg.open();
if (dlg.getReturnCode() == WizardDialog.OK) {
SoundDataObject result = sdoW.getResult();
this.dataList.remove(oldSdo);
this.dataList.add(result);
}
tv.setInput(this.dataList);
}
use of de.janrufmonitor.framework.IMsn in project janrufmonitor by tbrandt77.
the class Sound method getDataList.
private List getDataList() {
if (this.dataList == null || this.dataList.size() == 0) {
this.dataList = new ArrayList();
this.removableData = new ArrayList();
String msnList = this.getPreferenceStore().getString(this.CONFIG_NAMESPACE + SEPARATOR + "list");
if (msnList.trim().length() > 0) {
StringTokenizer st = new StringTokenizer(msnList, ",");
while (st.hasMoreTokens()) {
String number = st.nextToken().trim();
if (number.length() > 0) {
IMsn msn = this.getRuntime().getMsnManager().createMsn(number);
String soundfile = this.getPreferenceStore().getString(this.CONFIG_NAMESPACE + SEPARATOR + number + "_soundfile");
if (soundfile != null && soundfile.length() > 0) {
SoundDataObject sdo = new SoundDataObject(msn, soundfile);
this.dataList.add(sdo);
}
}
}
}
}
return this.dataList;
}
use of de.janrufmonitor.framework.IMsn in project janrufmonitor by tbrandt77.
the class AbstractFilterManager method getFiltersToLabelText.
public String getFiltersToLabelText(IFilter[] f, int shorten) {
if (f != null && f.length > 0) {
boolean processedCaller = false;
StringBuffer sb = new StringBuffer();
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_limit", "label", this.getLanguage()));
for (int i = 0; i < f.length; i++) {
IFilter f1 = f[i];
if (f1.getType().equals(FilterType.CIP)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_cip", "label", this.getLanguage()));
sb.append(this.getRuntime().getCipManager().getCipLabel(((CipFilter) f1).getCip(), this.getLanguage()));
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.MSN)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_msn", "label", this.getLanguage()));
IMsn[] m = ((MsnFilter) f1).getMsn();
for (int k = 0, l = m.length; k < l; k++) {
sb.append(m[k].getMSN());
m[k].setAdditional(this.getRuntime().getMsnManager().getMsnLabel(m[k]));
if (m[k].getAdditional().length() > 0) {
sb.append(" (" + m[k].getAdditional() + ")");
}
if ((k + 1) < l)
sb.append(", ");
}
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.DATE)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
if (((DateFilter) f1).getTimeframe() == -1) {
Date d1 = ((DateFilter) f1).getDateFrom();
Date d2 = ((DateFilter) f1).getDateTo();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
sb.append("[");
sb.append(sdf.format(d2));
sb.append(" - ");
if (d1 != null)
sb.append(sdf.format(d1));
else {
sb.append(this.getI18nManager().getString(this.getNamespace(), "today", "label", this.getLanguage()));
}
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
} else {
sb.append("[");
sb.append(this.getI18nManager().getString(this.getNamespace(), Long.toString(((DateFilter) f1).getTimeframe()), "label", this.getLanguage()));
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
}
}
if (f1.getType().equals(FilterType.YEAR)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
sb.append("[");
sb.append(((YearFilter) f1).getYear());
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.MONTH_YEAR)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
sb.append("[");
sb.append(((MonthYearFilter) f1).getYear());
sb.append(".");
sb.append((((MonthYearFilter) f1).getMonth() > 9 ? ((MonthYearFilter) f1).getMonth() : "0" + ((MonthYearFilter) f1).getMonth()));
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.CALLER) && !processedCaller) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_caller", "label", this.getLanguage()));
if ((i + 1) < f.length && !processedCaller)
sb.append(", ");
processedCaller = true;
}
if (f1.getType().equals(FilterType.PHONENUMBER)) {
PhonenumberFilter cf = ((PhonenumberFilter) f1);
IPhonenumber pnc = getRuntime().getCallerFactory().createPhonenumber(cf.getPhonenumber().getIntAreaCode(), cf.getPhonenumber().getAreaCode(), "0000000000");
ICaller c = Identifier.identifyDefault(getRuntime(), pnc);
if (c != null) {
IAttribute city = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CITY);
if (city != null && city.getValue().trim().length() > 0) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_area", "label", this.getLanguage()).substring(2));
sb.append(city.getValue().trim());
sb.append(" (0");
sb.append(cf.getPhonenumber().getAreaCode());
sb.append(")");
if ((i + 1) < f.length)
sb.append(", ");
continue;
}
}
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_intarea", "label", this.getLanguage()));
sb.append("00" + cf.getPhonenumber().getIntAreaCode());
if (cf.getPhonenumber().getAreaCode().trim().length() > 0) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_area", "label", this.getLanguage()));
sb.append("0" + cf.getPhonenumber().getAreaCode().trim());
}
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.ITEMCOUNT)) {
ItemCountFilter cf = ((ItemCountFilter) f1);
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_itemcount", "label", this.getLanguage()));
sb.append(cf.getLimit());
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.ATTRIBUTE)) {
AttributeFilter cf = ((AttributeFilter) f1);
IAttributeMap m = cf.getAttributeMap();
if (m != null && m.size() > 0) {
Iterator it = m.iterator();
IAttribute a = null;
while (it.hasNext()) {
a = (IAttribute) it.next();
if (a.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), a.getValue(), "label", this.getLanguage()));
} else if (a.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), a.getName(), "label", this.getLanguage()));
sb.append(a.getValue());
} else {
sb.append(this.getI18nManager().getString(this.getNamespace(), a.getName(), "label", this.getLanguage()));
}
if (it.hasNext())
sb.append(", ");
}
}
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.CHARACTER)) {
CharacterFilter cf = ((CharacterFilter) f1);
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_" + cf.getAttributeName(), "label", this.getLanguage()));
sb.append("[");
sb.append(cf.getCharacter().toUpperCase());
sb.append("...]");
if ((i + 1) < f.length)
sb.append(", ");
}
}
String s = sb.toString();
if (s.trim().endsWith(","))
s = s.trim().substring(0, s.trim().length() - 1);
if (shorten > -1 && shorten < s.length()) {
return s.substring(0, Math.min(shorten, s.length())) + "...";
}
if (s.trim().length() > 0)
return s;
}
return this.getI18nManager().getString(this.getNamespace(), "view_all", "label", this.getLanguage());
}
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 GetCallList method getAllowedMsnFilter.
private IFilter[] getAllowedMsnFilter(IHttpRequest req) throws HandlerException {
try {
boolean allowedForAllMsns = (SecurityManager.getInstance().getAllowedMSNs(req.getInetAddress().getHostName()) == null && SecurityManager.getInstance().getAllowedMSNs(req.getInetAddress().getHostAddress()) == null);
if (!allowedForAllMsns) {
String[] allowedMSNs = SecurityManager.getInstance().getAllowedMSNs(req.getInetAddress().getHostName());
if (allowedMSNs == null)
allowedMSNs = SecurityManager.getInstance().getAllowedMSNs(req.getInetAddress().getHostAddress());
if (allowedMSNs != null) {
IFilter[] allowedMsnFilter = new IFilter[allowedMSNs.length];
IMsn msn = null;
for (int i = 0; i < allowedMSNs.length; i++) {
msn = getRuntime().getMsnManager().createMsn(allowedMSNs[i]);
allowedMsnFilter[i] = new MsnFilter(msn);
m_logger.info("Adding allowed MSN filter for client: " + allowedMsnFilter[i].toString());
}
return allowedMsnFilter;
}
}
} catch (Exception e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
throw new HandlerException(e.getMessage(), 500);
}
return new IFilter[0];
}
Aggregations