use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class LastCalled method renderAsText.
public String renderAsText() {
if (this.m_o != null) {
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) {
IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
List cms = PIMRuntime.getInstance().getCallManagerFactory().getTypedCallManagers(IReadCallRepository.class);
if (cms.size() > 0) {
ICallManager cm = null;
for (int i = 0, j = cms.size(); i < j; i++) {
cm = (ICallManager) cms.get(i);
if (cm.isActive() && cm.isSupported(IReadCallRepository.class)) {
IFilter[] filters = new IFilter[] { new PhonenumberFilter(pn), new ItemCountFilter(1) };
ICallList cl = ((IReadCallRepository) cm).getCalls(filters, 1, 0);
cl.sort(0, false);
if (cl.size() > 0) {
ICall c = cl.get(0);
return getFormatter().parse(IJAMConst.GLOBAL_VARIABLE_CALLTIME, c.getDate());
}
}
}
}
}
}
return "";
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class ImagePreview method renderAsImageID.
public String renderAsImageID() {
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) {
if (ImageHandler.getInstance().hasImage((ICaller) this.m_o)) {
String path = ImageHandler.getInstance().getImagePath((ICaller) this.m_o);
if (new File(path).exists())
return path;
String newPath = PathResolver.getInstance().getTempDirectory() + File.separator + ((ICaller) this.m_o).getUUID() + ".jpg";
try {
FileOutputStream fos = new FileOutputStream(newPath);
InputStream imgin = ImageHandler.getInstance().getImageStream((ICaller) this.m_o);
Stream.copy(imgin, fos, true);
return newPath;
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
}
}
}
return "";
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class HistoryAction 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) {
History h = new History(((ICaller) o));
h.open();
}
}
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class Server method sendRequest.
private synchronized void sendRequest(IEvent event, IHttpRequest request) {
List clients = ClientRegistry.getInstance().getAllClients();
Client c = null;
for (int i = 0; i < clients.size(); i++) {
c = (Client) clients.get(i);
Object call = event.getData();
if (call != null && call instanceof ICall) {
IMsn msn = ((ICall) call).getMSN();
if (!SecurityManager.getInstance().isAllowedForMSN(c.getClientIP(), msn.getMSN()) || !SecurityManager.getInstance().isAllowedForMSN(c.getClientName(), msn.getMSN())) {
this.m_logger.info("Client " + c + " is blocked for MSN " + msn.getMSN() + ".");
continue;
}
}
if (this.isEventClient(c.getEvents(), event.getType())) {
this.m_logger.info("Sending event #" + event + " to client " + c + ".");
try {
if (request.getContent() != null)
c.setByteReceived(request.getContent().length);
IRequester r = null;
if (c.getClientName().trim().length() > 0)
r = RequesterFactory.getInstance().getRequester(c.getClientName(), c.getClientPort());
else
r = RequesterFactory.getInstance().getRequester(c.getClientIP(), c.getClientPort());
r.setRequest(request);
Thread s = new Thread(new SenderThread(r));
s.setName("JAM-" + SenderThread.class.getName() + "#" + i + "-Thread-(non-deamon)");
s.start();
} catch (Exception e) {
this.m_logger.severe(e.getMessage());
}
}
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class OpenTellows 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) {
if (!((ICaller) o).getPhoneNumber().isClired() && !PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(((ICaller) o).getPhoneNumber()) && (((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("49") || ((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("41") || ((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("43"))) {
StringBuffer url = new StringBuffer();
url.append("http://www.tellows.");
if (((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("49"))
url.append("de");
if (((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("43"))
url.append("at");
if (((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("41"))
url.append("ch");
url.append("/num/0");
url.append(((ICaller) o).getPhoneNumber().getTelephoneNumber());
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Found valid web url to execute: " + url.toString());
Program.launch(url.toString());
}
}
}
}
}
Aggregations