use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class HttpCallerManager method addCallerManagerAttribute.
private void addCallerManagerAttribute(ICallerList l) {
// add caller manager attribute to callers
for (int i = 0; i < l.size(); i++) {
ICaller c = (ICaller) l.get(i);
if (c != null) {
IAttribute cm = this.getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, this.getID());
c.setAttribute(cm);
}
}
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class ClientClickDialAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Object o = selection.getFirstElement();
if (o instanceof ICall) {
o = ((ICall) o).getCaller();
}
if (o instanceof ICaller) {
o = ((ICaller) o).getPhoneNumber();
}
if (o instanceof ITreeItemCallerData) {
o = ((ITreeItemCallerData) o).getPhone();
}
if (o instanceof IPhonenumber) {
if (((IPhonenumber) o).isClired())
return;
String dial = ((IPhonenumber) o).getTelephoneNumber();
if (PhonenumberAnalyzer.getInstance(getRuntime()).isInternal((IPhonenumber) o)) {
dial = ((IPhonenumber) o).getCallNumber();
} else {
if (!((IPhonenumber) o).getIntAreaCode().equalsIgnoreCase(this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_INTAREA))) {
dial = "00" + ((IPhonenumber) o).getIntAreaCode() + dial;
}
if (!dial.startsWith("0"))
dial = "0" + dial;
}
ClientDialerDialog id = new ClientDialerDialog(new Shell(DisplayManager.getDefaultDisplay()), dial);
id.open();
this.m_app.updateViews(false);
}
}
}
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class IncomingCall method handleWithException.
public void handleWithException(IHttpRequest req, IMutableHttpResponse resp) throws HandlerException {
IPhonenumber pn = null;
try {
String phone = req.getParameter(IncomingCall.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(IncomingCall.PARAMETER_CIP), "");
IMsn msn = PIMRuntime.getInstance().getCallFactory().createMsn(req.getParameter(IncomingCall.PARAMETER_MSN), "");
Date date = new Date(Long.parseLong(req.getParameter(IncomingCall.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())));
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.ICaller in project janrufmonitor by tbrandt77.
the class EditorController method deleteElements.
public synchronized void deleteElements(Object list) {
if (list != null && list instanceof ICallerList) {
Map cms = new HashMap();
ICallerList tmplist = null;
ICaller c = null;
for (int i = 0; i < ((ICallerList) list).size(); i++) {
c = ((ICallerList) list).get(i);
IAttribute att = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
String cname = (att == null ? "all" : att.getValue());
if (cms.containsKey(cname)) {
tmplist = (ICallerList) cms.get(cname);
tmplist.add(c);
} else {
tmplist = this.getRuntime().getCallerFactory().createCallerList(1);
tmplist.add(c);
cms.put(cname, tmplist);
}
}
List managers = this.getActiveCallerManagers();
ICallerManager mgr = null;
for (int i = 0; i < managers.size(); i++) {
mgr = this.getRuntime().getCallerManagerFactory().getCallerManager((String) managers.get(i));
if (mgr != null) {
if (mgr.isSupported(IWriteCallerRepository.class)) {
tmplist = (ICallerList) cms.get("all");
if (tmplist != null) {
this.m_logger.info("removing " + tmplist.size() + " callers to manager: " + mgr.getManagerID());
((IWriteCallerRepository) mgr).removeCaller(tmplist);
}
tmplist = (ICallerList) cms.get(mgr.getManagerID());
if (tmplist != null) {
this.m_logger.info("removing " + tmplist.size() + " callers to manager: " + mgr.getManagerID());
((IWriteCallerRepository) mgr).removeCaller(tmplist);
}
}
}
}
}
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class DeleteAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof TreeViewer) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Iterator i = selection.iterator();
ICallerList list = getRuntime().getCallerFactory().createCallerList();
Object o = null;
while (i.hasNext()) {
o = i.next();
if (o instanceof ICaller) {
list.add((ICaller) o);
}
}
if (list.size() > 0) {
if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), this.getI18nManager().getString(this.getNamespace(), "delete", "label", this.getLanguage()), this.getI18nManager().getString(this.getNamespace(), "delete", "description", this.getLanguage()))) {
this.m_app.getController().deleteElements(list);
this.m_app.getApplication().initializeController();
this.m_app.updateViews(true);
}
}
}
}
}
Aggregations