use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class OutlookContactManager method getCallers.
public ICallerList getCallers(IFilter filter) {
try {
if (filter != null && filter.getType().equals(FilterType.ATTRIBUTE)) {
IAttributeMap m = ((AttributeFilter) filter).getAttributeMap();
if (m.contains(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
IAttribute a = m.get(IJAMConst.ATTRIBUTE_NAME_CATEGORY);
return getProxy().getContacts(a.getValue());
}
}
if (filter != null && filter.getType().equals(FilterType.PHONENUMBER)) {
String intarea = ((PhonenumberFilter) filter).getPhonenumber().getIntAreaCode();
String area = ((PhonenumberFilter) filter).getPhonenumber().getAreaCode();
return getProxy().getContactsByAreaCode(intarea + area);
}
if (filter != null && filter.getType().equals(FilterType.CHARACTER)) {
ICallerList cl = getProxy().getContacts(null);
this.applyFilters(cl, new IFilter[] { filter });
return cl;
}
return getProxy().getContacts(null);
} catch (OutlookContactProxyException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
return getRuntime().getCallerFactory().createCallerList();
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class OutlookNumberType 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(IOutlookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber())) {
IAttribute type = m.get(IOutlookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber());
if (type != null) {
return PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, type.getValue(), "label", getLanguage());
}
}
}
}
return "";
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class OutlookContactProxy method getContactsByAreaCode.
public synchronized ICallerList getContactsByAreaCode(String code) throws OutlookContactProxyException {
ICallerList callers = getRuntime().getCallerFactory().createCallerList();
long outlookItemsCount = 0;
this.m_current = 0;
this.m_total = this.countAllContact();
ActiveXComponent outlook = new ActiveXComponent("Outlook.Application");
Dispatch mapiNS = null;
Dispatch contactsFolder = null;
Dispatch contactsSubFolder = null;
Dispatch items = null;
try {
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("created Outlook.Application dispatch");
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Microsoft Outlook version: " + Dispatch.get(outlook.getObject(), "Version"));
mapiNS = outlook.getProperty("Session").toDispatch();
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Microsoft Outlook namespace: " + mapiNS);
Variant contactsVariant = new Variant(10);
contactsFolder = Dispatch.call(mapiNS, "GetDefaultFolder", contactsVariant).toDispatch();
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Microsoft Outlook folder: " + contactsFolder);
contactsVariant.safeRelease();
// getting configured subfolders
List subfolders = new ArrayList();
subfolders.add("");
subfolders.addAll(getAllContactFolders());
String folder = null;
for (int i = 0, j = subfolders.size(); i < j; i++) {
folder = (String) subfolders.get(i);
items = this.getItemsOfFolder(contactsFolder, folder, false);
if (items == null)
continue;
ICallerList cl = null;
Dispatch aContact = Dispatch.call(items, "Find", new Variant("[User2]='" + code + "'")).toDispatch();
if (aContact != null && aContact.m_pDispatch > 0) {
do {
outlookItemsCount++;
this.m_current++;
// check UUID in User1 attribute
this.checkContactUUID(aContact);
cl = getCallerListFromSingleContact(aContact);
if (cl.size() > 0) {
if (folder.trim().length() > 0) {
IAttribute category = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CATEGORY, folder);
for (int l = 0, m = cl.size(); l < m; l++) {
cl.get(l).setAttribute(category);
}
}
callers.add(cl);
}
if (aContact != null)
aContact.safeRelease();
aContact = Dispatch.call(items, "FindNext").toDispatch();
} while (aContact != null && aContact.m_pDispatch > 0);
}
}
} catch (ComFailException ex) {
this.m_logger.warning("1 item (e.g. distribution list) was ignored on loading.");
if (ex.toString().indexOf("Can't get object clsid from progid") > -1) {
this.m_logger.log(Level.SEVERE, ex.toString(), ex);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "olstarterror", ex));
} else
this.m_logger.warning(ex.getMessage() + ", " + ex.getSource());
} catch (Exception ex) {
throw new OutlookContactProxyException("Error in Application Outlook.", ex);
} finally {
// added 2006/02/05: clean outlook references
if (items != null)
items.safeRelease();
if (contactsFolder != null)
contactsFolder.safeRelease();
if (contactsSubFolder != null)
contactsSubFolder.safeRelease();
if (mapiNS != null)
mapiNS.safeRelease();
if (outlook != null)
outlook.safeRelease();
}
this.m_logger.info(outlookItemsCount + " Outlook contacts found and " + callers.size() + " numbers available.");
return callers;
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class OutlookContactProxy method findContacts.
public synchronized ICallerList findContacts(String searchTerm, String f) throws OutlookContactProxyException {
if (searchTerm == null || searchTerm.trim().length() == 0)
return this.getContacts(f);
ICallerList callers = getRuntime().getCallerFactory().createCallerList();
ActiveXComponent outlook = new ActiveXComponent("Outlook.Application");
Dispatch mapiNS = null;
Dispatch contactsFolder = null;
Dispatch contactsSubFolder = null;
Dispatch items = null;
try {
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("created Outlook.Application dispatch");
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Microsoft Outlook version: " + Dispatch.get(outlook.getObject(), "Version"));
mapiNS = outlook.getProperty("Session").toDispatch();
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Microsoft Outlook namespace: " + mapiNS);
Variant contactsVariant = new Variant(10);
contactsFolder = Dispatch.call(mapiNS, "GetDefaultFolder", contactsVariant).toDispatch();
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Microsoft Outlook folder: " + contactsFolder);
contactsVariant.safeRelease();
// getting configured subfolders
List subfolders = new ArrayList();
if (f != null) {
subfolders.add(f);
} else {
subfolders.add("");
subfolders.addAll(getAllContactFolders());
}
String folder = null;
for (int i = 0, j = subfolders.size(); i < j; i++) {
folder = (String) subfolders.get(i);
items = Dispatch.get(contactsFolder, "items").toDispatch();
if (items == null)
continue;
String[] filters = { OutlookContactConst.LastName, OutlookContactConst.FirstName, OutlookContactConst.BusinessAddressCity, OutlookContactConst.BusinessAddressStreet, OutlookContactConst.BusinessAddressPostalCode, OutlookContactConst.BusinessAddressCountry, OutlookContactConst.BusinessTelephoneNumber, OutlookContactConst.Business2TelephoneNumber, OutlookContactConst.BusinessFaxNumber, OutlookContactConst.Home2TelephoneNumber, OutlookContactConst.HomeAddressCity, OutlookContactConst.HomeAddressCountry, OutlookContactConst.HomeAddressPostalCode, OutlookContactConst.HomeAddressStreet, OutlookContactConst.HomeFaxNumber, OutlookContactConst.HomeTelephoneNumber, OutlookContactConst.MobileTelephoneNumber };
for (int z = 0; z < filters.length; z++) {
String filter = String.format("[" + filters[z] + "] = '%s'", searchTerm);
Variant item = Dispatch.call(items, "find", filter);
ICallerList cl = null;
while ((item != null) && (!item.isNull())) {
try {
Dispatch contact = item.toDispatch();
// check UUID in User1 attribute
this.checkContactUUID(contact);
cl = getCallerListFromSingleContact(contact);
if (cl.size() > 0) {
if (folder.trim().length() > 0) {
IAttribute category = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CATEGORY, folder);
for (int l = 0, m = cl.size(); l < m; l++) {
cl.get(l).setAttribute(category);
}
}
for (int k = 0; k < cl.size(); k++) {
if (!callers.contains(cl.get(k)))
callers.add(cl.get(k));
}
}
if (contact != null)
contact.safeRelease();
} catch (ComFailException ex) {
this.m_logger.warning("1 item (e.g. distribution list) was ignored on loading.");
if (ex.toString().indexOf("Can't get object clsid from progid") > -1) {
this.m_logger.log(Level.SEVERE, ex.toString(), ex);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "olstarterror", ex));
} else
this.m_logger.warning(ex.getMessage() + ", " + ex.getSource());
}
if (item != null)
item.safeRelease();
item = Dispatch.call(items, "findNext");
}
}
}
} catch (ComFailException ex) {
this.m_logger.warning("1 item (e.g. distribution list) was ignored on loading.");
if (ex.toString().indexOf("Can't get object clsid from progid") > -1) {
this.m_logger.log(Level.SEVERE, ex.toString(), ex);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "olstarterror", ex));
} else
this.m_logger.warning(ex.getMessage() + ", " + ex.getSource());
} catch (Exception ex) {
throw new OutlookContactProxyException("Error in Application Outlook.", ex);
} finally {
// added 2006/02/05: clean outlook references
if (items != null)
items.safeRelease();
if (contactsFolder != null)
contactsFolder.safeRelease();
if (contactsSubFolder != null)
contactsSubFolder.safeRelease();
if (mapiNS != null)
mapiNS.safeRelease();
if (outlook != null)
outlook.safeRelease();
}
return callers;
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class OutlookContactProxy method getContacts.
public synchronized ICallerList getContacts(String f) throws OutlookContactProxyException {
ICallerList callers = getRuntime().getCallerFactory().createCallerList();
long outlookItemsCount = 0;
this.m_current = 0;
this.m_total = (f == null ? this.countAllContact() : this.countContacts(f));
ActiveXComponent outlook = new ActiveXComponent("Outlook.Application");
Dispatch mapiNS = null;
Dispatch contactsFolder = null;
Dispatch contactsSubFolder = null;
Dispatch items = null;
try {
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("created Outlook.Application dispatch");
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Microsoft Outlook version: " + Dispatch.get(outlook.getObject(), "Version"));
mapiNS = outlook.getProperty("Session").toDispatch();
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Microsoft Outlook namespace: " + mapiNS);
Variant contactsVariant = new Variant(10);
contactsFolder = Dispatch.call(mapiNS, "GetDefaultFolder", contactsVariant).toDispatch();
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Microsoft Outlook folder: " + contactsFolder);
contactsVariant.safeRelease();
// getting configured subfolders
List subfolders = new ArrayList();
if (f != null) {
subfolders.add(f);
} else {
subfolders.add("");
subfolders.addAll(getAllContactFolders());
}
String folder = null;
for (int i = 0, j = subfolders.size(); i < j; i++) {
folder = (String) subfolders.get(i);
items = this.getItemsOfFolder(contactsFolder, folder, false);
if (items == null)
continue;
Variant item = Dispatch.call(items, "GetFirst");
ICallerList cl = null;
while ((item != null) && (!item.isNull())) {
try {
outlookItemsCount++;
this.m_current++;
Dispatch contact = item.toDispatch();
// check UUID in User1 attribute
this.checkContactUUID(contact);
cl = getCallerListFromSingleContact(contact);
if (cl.size() > 0) {
if (folder.trim().length() > 0) {
IAttribute category = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CATEGORY, folder);
for (int l = 0, m = cl.size(); l < m; l++) {
cl.get(l).setAttribute(category);
}
}
callers.add(cl);
}
if (contact != null)
contact.safeRelease();
} catch (ComFailException ex) {
this.m_logger.warning("1 item (e.g. distribution list) was ignored on loading.");
if (ex.toString().indexOf("Can't get object clsid from progid") > -1) {
this.m_logger.log(Level.SEVERE, ex.toString(), ex);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "olstarterror", ex));
} else
this.m_logger.warning(ex.getMessage() + ", " + ex.getSource());
}
if (item != null)
item.safeRelease();
item = Dispatch.call(items, "GetNext");
}
}
} catch (ComFailException ex) {
this.m_logger.warning("1 item (e.g. distribution list) was ignored on loading.");
if (ex.toString().indexOf("Can't get object clsid from progid") > -1) {
this.m_logger.log(Level.SEVERE, ex.toString(), ex);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "olstarterror", ex));
} else
this.m_logger.warning(ex.getMessage() + ", " + ex.getSource());
} catch (Exception ex) {
throw new OutlookContactProxyException("Error in Application Outlook.", ex);
} finally {
// added 2006/02/05: clean outlook references
if (items != null)
items.safeRelease();
if (contactsFolder != null)
contactsFolder.safeRelease();
if (contactsSubFolder != null)
contactsSubFolder.safeRelease();
if (mapiNS != null)
mapiNS.safeRelease();
if (outlook != null)
outlook.safeRelease();
}
this.m_logger.info(outlookItemsCount + " Outlook contacts found and " + callers.size() + " numbers available.");
return callers;
}
Aggregations