use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class ScoreNumberTellows method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Iterator iter = selection.iterator();
while (iter.hasNext()) {
Object o1 = iter.next();
Object o = null;
if (o1 instanceof ICall) {
o = ((ICall) o1).getCaller();
}
if (o1 instanceof ICaller) {
o = o1;
}
if (o != null) {
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"))) {
final Object o2 = o1;
final Object o3 = o;
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "scoring", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
try {
IAttributeMap m = TellowsProxy.getInstance().getTellowsData(((ICaller) o3).getPhoneNumber().getTelephoneNumber(), ((ICaller) o3).getPhoneNumber().getIntAreaCode());
if (m.size() > 0) {
((ICaller) o3).getAttributes().addAll(m);
if (m_app.getController() instanceof IExtendedApplicationController)
((IExtendedApplicationController) m_app.getController()).updateElement(o2, false);
else
m_app.getController().updateElement(o2);
}
} catch (Exception e) {
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), e), "Tray");
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true, pmd.getProgressMonitor(),
// DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
}
}
this.m_app.updateViews(true);
}
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class TapiClickDialAction 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(this.getRuntime()).isInternal(dial)) {
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;
// added 2010/03/06: check for dial prefix for outgoing calls
// removed 2010/06/25: double addition of prefix. Is already added in Dialogue
// if (this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).length()>0) {
// if (this.m_logger.isLoggable(Level.INFO))
// this.m_logger.info("Using dial prefix: "+this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX));
// dial = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).trim() + dial;
// }
}
TapiDialerDialog id = new TapiDialerDialog(new Shell(DisplayManager.getDefaultDisplay()), dial);
id.open();
this.m_app.updateViews(false);
}
}
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class TextFileCallManager method loadDatabase.
private void loadDatabase(String database) {
long startDate = System.currentTimeMillis();
File db = new File(database);
try {
FileReader dbReader = new FileReader(db);
BufferedReader bufReader = new BufferedReader(dbReader);
String line = null;
ICall aCall = null;
while (bufReader.ready()) {
line = bufReader.readLine();
// check for old entries
if (line.indexOf(CALL_SEPARATOR) > -1)
line = this.transformOldTextfileData(line);
try {
aCall = Serializer.toCall(line.getBytes(), this.getRuntime());
this.m_callList.add(aCall);
} catch (SerializerException e) {
this.m_logger.severe(e.getMessage());
}
}
bufReader.close();
dbReader.close();
} catch (FileNotFoundException ex) {
this.m_logger.warning("Cannot find call database: " + database);
this.m_logger.info("Creating call database: " + database);
File dbnew = new File(database);
if (!dbnew.exists()) {
try {
dbnew.createNewFile();
} catch (IOException e) {
this.m_logger.severe("Cannot create file: " + database + ". Check read/write permissions.");
}
}
} catch (IOException ex) {
this.m_logger.severe("IOException on file " + database);
} catch (NullPointerException ex) {
this.m_logger.warning("Final character in file " + database + " is null and filtered out.");
}
long endDate = System.currentTimeMillis();
this.m_logger.info("Successfully loaded call database " + database);
this.m_logger.info("Found " + new Integer(this.m_callList.size()).toString() + " call items in " + Float.toString((endDate - startDate) / 1000) + " secs.");
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class SynchronizerService method createRedundancyList.
private ICallList createRedundancyList(ICallList l, long lastsync) throws CloneNotSupportedException {
if (l == null)
return getRuntime().getCallFactory().createCallList();
ICallList cl = getRuntime().getCallFactory().createCallList(2 * l.size());
ICall c = null;
ICall cloneCall = null;
for (int i = 0, j = l.size(); i < j; i++) {
c = l.get(i);
if (c.getDate().getTime() >= lastsync) {
cloneCall = (ICall) c.clone();
cloneCall.setDate(new Date(c.getDate().getTime() - 60000));
// create UUID
cloneCall.setUUID(FritzBoxUUIDManager.getInstance().getUUID(cloneCall.getDate(), cloneCall.getCaller().getPhoneNumber(), cloneCall.getMSN()));
cl.add(c);
if (m_logger.isLoggable(Level.INFO))
m_logger.info("Cloned call with Date -60000 msec");
cl.add(cloneCall);
}
}
return cl;
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class ManageAction method run.
public void run() {
IService s = this.getRuntime().getServiceFactory().getService("CommentService");
if (s != null && s instanceof CommentService) {
CommentService cs = (CommentService) s;
if (!cs.isEnabled()) {
new SWTExecuter(true, this.getID()) {
protected void execute() {
MessageDialog.openError(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespace(), "servicedisabled", "label", getLanguage()), getI18nManager().getString(getNamespace(), "servicedisabled", "description", getLanguage()));
}
}.start();
return;
}
}
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) {
Object o2 = ((ICall) o).getCaller();
if (((ICaller) o2).getPhoneNumber().isClired())
return;
new Comment(((ICall) o)).open();
}
if (o instanceof ICaller) {
if (((ICaller) o).getPhoneNumber().isClired())
return;
new Comment(((ICaller) o)).open();
}
}
}
}
Aggregations