Fixes warnings, removes whitespace, simplifies source code.

fix-message-formatting
Lyubomir Marinov 13 years ago
parent 03aef9b6ba
commit 33d1d27d6e

@ -39,6 +39,7 @@ public class AddrBookActivator
*/
public static final String PNAME_ENABLE_MICROSOFT_OUTLOOK_SEARCH =
"plugin.addrbook.ENABLE_MICROSOFT_OUTLOOK_SEARCH";
/**
* Boolean property that defines whether the integration of the OS X
* address book is enabled.
@ -95,12 +96,12 @@ public class AddrBookActivator
* properties.
*/
private static ConfigurationService configService;
/**
* The calendar service
*/
private static CalendarServiceImpl calendarService = null;
/**
* List of the providers with registration listener.
*/
@ -111,66 +112,62 @@ public class AddrBookActivator
* The registered PhoneNumberI18nService.
*/
private static PhoneNumberI18nService phoneNumberI18nService;
/**
* The registration change listener.
*/
private static RegistrationStateChangeListener providerListener
= new RegistrationStateChangeListener()
{
@Override
public void registrationStateChanged(
RegistrationStateChangeEvent ev)
{
@Override
public void registrationStateChanged(
RegistrationStateChangeEvent evt)
if(ev.getNewState().equals(RegistrationState.REGISTERED)
&& (calendarService != null))
{
if(evt.getNewState().equals(RegistrationState.REGISTERED))
{
if(calendarService != null)
calendarService.handleProviderAdded(
evt.getProvider());
}
calendarService.handleProviderAdded(ev.getProvider());
}
};
}
};
/**
* A listener for addition of <tt>ProtocolProviderService</tt>
*/
private static ServiceListener serviceListener = new ServiceListener()
{
@Override
public void serviceChanged(ServiceEvent event)
private static ServiceListener serviceListener
= new ServiceListener()
{
Object sService
= bundleContext.getService(event.getServiceReference());
// we don't care if the source service is not a protocol provider
if (! (sService instanceof ProtocolProviderService))
@Override
public void serviceChanged(ServiceEvent ev)
{
return;
}
ProtocolProviderService pps = (ProtocolProviderService)sService;
if (event.getType() == ServiceEvent.REGISTERED)
{
synchronized(providers)
{
providers.add(pps);
}
pps.addRegistrationStateChangeListener(providerListener);
}
if (event.getType() == ServiceEvent.UNREGISTERING)
{
synchronized(providers)
Object service
= bundleContext.getService(ev.getServiceReference());
if (! (service instanceof ProtocolProviderService))
return;
ProtocolProviderService pps = (ProtocolProviderService) service;
switch (ev.getType())
{
providers.remove(pps);
case ServiceEvent.REGISTERED:
synchronized(providers)
{
providers.add(pps);
}
pps.addRegistrationStateChangeListener(providerListener);
break;
case ServiceEvent.UNREGISTERING:
synchronized(providers)
{
providers.remove(pps);
}
pps.removeRegistrationStateChangeListener(providerListener);
break;
}
pps.removeRegistrationStateChangeListener(providerListener);
}
}
};
};
/**
* Gets the <tt>ResourceManagementService</tt> to be used by the
@ -190,7 +187,7 @@ public static ResourceManagementService getResources()
}
return resourceService;
}
public static CalendarServiceImpl getCalendarService()
{
return calendarService;
@ -228,9 +225,11 @@ public void start(BundleContext bundleContext)
throws Exception
{
if (logger.isInfoEnabled())
logger.info("Address book \""
+ "plugin.addrbook.ADDRESS_BOOKS"
+ "\" ... [STARTED]");
{
logger.info(
"Address book \"plugin.addrbook.ADDRESS_BOOKS\" ..."
+ " [STARTED]");
}
AddrBookActivator.bundleContext = bundleContext;
@ -241,15 +240,16 @@ public void start(BundleContext bundleContext)
ConfigurationForm.CONTACT_SOURCE_TYPE);
bundleContext.registerService(
ConfigurationForm.class.getName(),
new LazyConfigurationForm(
AdvancedConfigForm.class.getName(),
getClass().getClassLoader(),
null,
"plugin.addrbook.ADDRESS_BOOKS",
101, false),
ConfigurationForm.class.getName(),
new LazyConfigurationForm(
AdvancedConfigForm.class.getName(),
getClass().getClassLoader(),
null,
"plugin.addrbook.ADDRESS_BOOKS",
101,
false),
properties);
startService();
startCalendarService();
}
@ -267,9 +267,11 @@ public void stop(BundleContext bundleContext)
throws Exception
{
if (logger.isInfoEnabled())
logger.info("Address book \""
+ "plugin.addrbook.ADDRESS_BOOKS"
+ "\" ... [STOPPED]");
{
logger.info(
"Address book \"plugin.addrbook.ADDRESS_BOOKS\" ..."
+ " [STOPPED]");
}
stopService();
stopCalendarService();
@ -283,9 +285,11 @@ static void startService()
/* Register the ContactSourceService implementation (if any). */
String cssClassName;
ConfigurationService configService = getConfigService();
if (OSUtils.IS_WINDOWS
&& configService.getBoolean(
PNAME_ENABLE_MICROSOFT_OUTLOOK_SEARCH, true))
&& configService.getBoolean(
PNAME_ENABLE_MICROSOFT_OUTLOOK_SEARCH,
true))
{
cssClassName
@ -293,8 +297,9 @@ static void startService()
+ ".msoutlook.MsOutlookAddrBookContactSourceService";
}
else if (OSUtils.IS_MAC
&& configService.getBoolean(
PNAME_ENABLE_MACOSX_ADDRESS_BOOK_SEARCH, true))
&& configService.getBoolean(
PNAME_ENABLE_MACOSX_ADDRESS_BOOK_SEARCH,
true))
{
cssClassName
= "net.java.sip.communicator.plugin.addrbook"
@ -304,31 +309,31 @@ else if (OSUtils.IS_MAC
return;
if (OSUtils.IS_WINDOWS
&& configService.getBoolean(
PNAME_ENABLE_DEFAULT_IM_APPLICATION_CHANGE, true))
&& configService.getBoolean(
PNAME_ENABLE_DEFAULT_IM_APPLICATION_CHANGE,
true))
{
String isDefaultIMAppString = configService.getString(
PNAME_MAKE_JITSI_DEFAULT_IM_APPLICATION);
String isDefaultIMAppString
= configService.getString(
PNAME_MAKE_JITSI_DEFAULT_IM_APPLICATION);
if(isDefaultIMAppString == null)
{
configService.setProperty(
PNAME_MAKE_JITSI_DEFAULT_IM_APPLICATION,
DefaultIMApp.isJitsiDefaultIMApp());
PNAME_MAKE_JITSI_DEFAULT_IM_APPLICATION,
DefaultIMApp.isJitsiDefaultIMApp());
}
else
{
boolean isDefaultIMApp
= Boolean.parseBoolean(isDefaultIMAppString);
if(DefaultIMApp.isJitsiDefaultIMApp() != isDefaultIMApp)
{
if(isDefaultIMApp)
{
setAsDefaultIMApplication();
}
else
{
unsetDefaultIMApplication();
}
}
}
}
@ -338,11 +343,13 @@ else if (OSUtils.IS_MAC
css
= (ContactSourceService)
Class.forName(cssClassName).newInstance();
if(cssClassName.equals("net.java.sip.communicator.plugin.addrbook"
+ ".msoutlook.MsOutlookAddrBookContactSourceService"))
if(cssClassName.equals(
"net.java.sip.communicator.plugin.addrbook"
+ ".msoutlook.MsOutlookAddrBookContactSourceService"))
{
MsOutlookAddrBookContactSourceService contactSource
= ((MsOutlookAddrBookContactSourceService)css);
= (MsOutlookAddrBookContactSourceService) css;
MsOutlookAddrBookContactSourceService.initMAPI(
contactSource.createNotificationDelegate());
}
@ -358,7 +365,7 @@ else if (OSUtils.IS_MAC
logger.debug(msg, ex);
return;
}
try
{
cssServiceRegistration
@ -366,7 +373,6 @@ else if (OSUtils.IS_MAC
ContactSourceService.class.getName(),
css,
null);
}
finally
{
@ -376,23 +382,24 @@ else if (OSUtils.IS_MAC
((AsyncContactSourceService) css).stop();
css = null;
}
else
else if (logger.isInfoEnabled())
{
if (logger.isInfoEnabled())
logger.info("Address book \""
+ css.getDisplayName()
logger.info(
"Address book \"" + css.getDisplayName()
+ "\" ... [REGISTERED]");
}
}
}
/**
* Tries to start the calendar service.
*/
static void startCalendarService()
{
if(OSUtils.IS_WINDOWS && !getConfigService().getBoolean(
CalendarService.PNAME_FREE_BUSY_STATUS_DISABLED, false))
if(OSUtils.IS_WINDOWS
&& !getConfigService().getBoolean(
CalendarService.PNAME_FREE_BUSY_STATUS_DISABLED,
false))
{
calendarService = new CalendarServiceImpl();
try
@ -401,16 +408,14 @@ static void startCalendarService()
}
catch (MsOutlookMAPIHResultException ex)
{
String msg
= "Failed to initialize MAPI: "
+ ex.getMessage();
String msg = "Failed to initialize MAPI: " + ex.getMessage();
logger.error(msg);
if (logger.isDebugEnabled())
logger.debug(msg, ex);
return;
}
bundleContext.addServiceListener(serviceListener);
for(ProtocolProviderService pps : getProtocolProviders())
{
@ -423,22 +428,22 @@ static void startCalendarService()
calendarService.start();
}
}
/**
* Stops the calendar service.
*/
static void stopCalendarService()
{
if(OSUtils.IS_WINDOWS && !getConfigService().getBoolean(
CalendarService.PNAME_FREE_BUSY_STATUS_DISABLED, false))
if(OSUtils.IS_WINDOWS
&& !getConfigService().getBoolean(
CalendarService.PNAME_FREE_BUSY_STATUS_DISABLED,
false))
{
bundleContext.removeServiceListener(serviceListener);
synchronized(providers)
{
for(ProtocolProviderService pps : providers)
{
pps.removeRegistrationStateChangeListener(providerListener);
}
}
calendarService = null;
MsOutlookAddrBookContactSourceService.UninitializeMAPI();
@ -466,9 +471,11 @@ static void stopService()
((AsyncContactSourceService) css).stop();
if (logger.isInfoEnabled())
logger.info("Address book \""
+ css.getDisplayName()
+ "\" ... [UNREGISTERED]");
{
logger.info(
"Address book \"" + css.getDisplayName()
+ "\" ... [UNREGISTERED]");
}
css = null;
}
@ -481,9 +488,7 @@ static void stopService()
public static void setAsDefaultIMApplication()
{
if (OSUtils.IS_WINDOWS)
{
DefaultIMApp.setJitsiAsDefaultApp();
}
}
/**
@ -492,16 +497,15 @@ public static void setAsDefaultIMApplication()
public static void unsetDefaultIMApplication()
{
if (OSUtils.IS_WINDOWS)
{
DefaultIMApp.unsetDefaultApp();
}
}
public static List<ProtocolProviderService> getProtocolProviders()
{
ServiceReference[] ppsRefs;
List<ProtocolProviderService> result
= new ArrayList<ProtocolProviderService>();
try
{
ppsRefs
@ -513,19 +517,17 @@ public static List<ProtocolProviderService> getProtocolProviders()
{
ppsRefs = null;
}
if ((ppsRefs == null) || (ppsRefs.length == 0))
if ((ppsRefs != null) && (ppsRefs.length != 0))
{
return result;
}
for (ServiceReference ppsRef : ppsRefs)
{
ProtocolProviderService pps
= (ProtocolProviderService)
bundleContext.getService(ppsRef);
result.add(pps);
for (ServiceReference ppsRef : ppsRefs)
{
ProtocolProviderService pps
= (ProtocolProviderService)
bundleContext.getService(ppsRef);
result.add(pps);
}
}
return result;
}
@ -538,11 +540,11 @@ public static PhoneNumberI18nService getPhoneNumberI18nService()
{
if(phoneNumberI18nService == null)
{
phoneNumberI18nService = ServiceUtils.getService(
bundleContext,
PhoneNumberI18nService.class);
phoneNumberI18nService
= ServiceUtils.getService(
bundleContext,
PhoneNumberI18nService.class);
}
return phoneNumberI18nService;
}
}

@ -108,7 +108,7 @@ public void actionPerformed(ActionEvent arg0)
});
return checkBox;
}
/**
* Creates the default IM application check box.
*

@ -7,13 +7,8 @@
package net.java.sip.communicator.plugin.addrbook.macosx;
import java.util.*;
//import java.util.regex.*;
//import net.java.sip.communicator.plugin.addrbook.*;
import net.java.sip.communicator.service.contactsource.*;
//import net.java.sip.communicator.service.contactsource.ContactDetail.*;
//import net.java.sip.communicator.service.protocol.*;
//import net.java.sip.communicator.util.*;
/**
* The editable detail, change get changed and in addressbook.

@ -1168,6 +1168,7 @@ protected void run()
query.toString(),
new PtrCallback()
{
@Override
public boolean callback(long person)
{
return onPerson(person);

@ -23,13 +23,13 @@ public class DefaultIMApp
*/
private static String REGISTRY_DEFAULT_IM_APPLICATION_KEY
= "Software\\IM Providers";
/**
* The value under which the default IM application is placed.
*/
private static String REGISTRY_DEFAULT_IM_APPLICATION_VALUE
= "DefaultIMApp";
/**
* Default IM application for communicator. This value is used to unset
* Jitsi as default application.
@ -49,7 +49,7 @@ public static boolean isDefaultIMApp(String appName)
REGISTRY_DEFAULT_IM_APPLICATION_KEY,
REGISTRY_DEFAULT_IM_APPLICATION_VALUE).equals(appName);
}
/**
* Checks whether Jitsi is the default IM application.
* @return is Jitsi the default IM application or not.
@ -60,7 +60,7 @@ public static boolean isJitsiDefaultIMApp()
REGISTRY_DEFAULT_IM_APPLICATION_KEY,
REGISTRY_DEFAULT_IM_APPLICATION_VALUE))
return false;
return Advapi32Util.registryGetStringValue(
WinReg.HKEY_CURRENT_USER,
REGISTRY_DEFAULT_IM_APPLICATION_KEY,
@ -82,7 +82,7 @@ public static void setDefaultIMApp(String appName)
REGISTRY_DEFAULT_IM_APPLICATION_VALUE,
appName);
}
/**
* Sets Jitsi as default IM application.
*/
@ -92,7 +92,7 @@ public static void setJitsiAsDefaultApp()
if(!isDefaultIMApp(appName))
setDefaultIMApp(appName);
}
/**
* Unsets Jitsi as default IM application. Overrides the registry value
* with setting communicator as default IM application.
@ -102,7 +102,7 @@ public static void unsetDefaultApp()
if(isDefaultIMApp(getApplicationName()))
setDefaultIMApp(REGISTRY_DEFAULT_IM_APPLICATION_COMMUNICATOR);
}
/**
* Returns the application name.
* @return the application name

@ -645,121 +645,110 @@ public static long getProperty(
ContactDetail.Category category,
Collection<ContactDetail.SubCategory> subCategories)
{
int i = -1;
switch(category)
{
case Personal:
if(subCategories.contains(ContactDetail.SubCategory.Name))
return MAPI_MAILUSER_PROP_IDS[PR_GIVEN_NAME];
i = PR_GIVEN_NAME;
else if(subCategories.contains(
ContactDetail.SubCategory.LastName))
return MAPI_MAILUSER_PROP_IDS[PR_SURNAME];
i = PR_SURNAME;
else if(subCategories.contains(
ContactDetail.SubCategory.Nickname))
return MAPI_MAILUSER_PROP_IDS[PR_NICKNAME];
i = PR_NICKNAME;
else if(subCategories.contains(
ContactDetail.SubCategory.HomePage))
return MAPI_MAILUSER_PROP_IDS[PR_PERSONAL_HOME_PAGE];
i = PR_PERSONAL_HOME_PAGE;
else
return MAPI_MAILUSER_PROP_IDS[PR_DISPLAY_NAME_PREFIX];
i = PR_DISPLAY_NAME_PREFIX;
break;
case Organization:
if(subCategories.contains(ContactDetail.SubCategory.Name))
return MAPI_MAILUSER_PROP_IDS[PR_COMPANY_NAME];
i = PR_COMPANY_NAME;
else if(subCategories.contains(ContactDetail.SubCategory.JobTitle))
return MAPI_MAILUSER_PROP_IDS[PR_TITLE];
i = PR_TITLE;
else
return MAPI_MAILUSER_PROP_IDS[PR_BUSINESS_HOME_PAGE];
i = PR_BUSINESS_HOME_PAGE;
break;
case Email:
if(subCategories.contains(ContactDetail.SubCategory.Work))
return MAPI_MAILUSER_PROP_IDS[dispidEmail2EmailAddress];
i = dispidEmail2EmailAddress;
else if(subCategories.contains(
ContactDetail.SubCategory.Home))
return MAPI_MAILUSER_PROP_IDS[dispidEmail1EmailAddress];
i = dispidEmail1EmailAddress;
else if(subCategories.contains(
ContactDetail.SubCategory.Other))
return MAPI_MAILUSER_PROP_IDS[dispidEmail3EmailAddress];
i = dispidEmail3EmailAddress;
break;
case Phone:
if(subCategories.contains(ContactDetail.SubCategory.Fax))
return MAPI_MAILUSER_PROP_IDS[dispidFax1EmailAddress];
i = dispidFax1EmailAddress;
else if(subCategories.contains(ContactDetail.SubCategory.Work))
return MAPI_MAILUSER_PROP_IDS[PR_BUSINESS_TELEPHONE_NUMBER];
i = PR_BUSINESS_TELEPHONE_NUMBER;
else if(subCategories.contains(ContactDetail.SubCategory.Home))
return MAPI_MAILUSER_PROP_IDS[PR_HOME_TELEPHONE_NUMBER];
i = PR_HOME_TELEPHONE_NUMBER;
else if(subCategories.contains(
ContactDetail.SubCategory.Mobile))
return MAPI_MAILUSER_PROP_IDS[PR_MOBILE_TELEPHONE_NUMBER];
i = PR_MOBILE_TELEPHONE_NUMBER;
else if(subCategories.contains(
ContactDetail.SubCategory.Other))
return MAPI_MAILUSER_PROP_IDS[PR_OTHER_TELEPHONE_NUMBER];
i = PR_OTHER_TELEPHONE_NUMBER;
break;
case InstantMessaging:
return MAPI_MAILUSER_PROP_IDS[dispidInstMsg];
i = dispidInstMsg;
break;
case Address:
if(subCategories.contains(ContactDetail.SubCategory.Work))
{
if(subCategories.contains(ContactDetail.SubCategory.City))
{
return MAPI_MAILUSER_PROP_IDS[PR_BUSINESS_ADDRESS_CITY];
}
i = PR_BUSINESS_ADDRESS_CITY;
else if(subCategories.contains(
ContactDetail.SubCategory.Country))
{
return MAPI_MAILUSER_PROP_IDS[PR_BUSINESS_ADDRESS_COUNTRY];
}
i = PR_BUSINESS_ADDRESS_COUNTRY;
else if(subCategories.contains(
ContactDetail.SubCategory.PostalCode))
{
return MAPI_MAILUSER_PROP_IDS[
PR_BUSINESS_ADDRESS_POSTAL_CODE];
}
i = PR_BUSINESS_ADDRESS_POSTAL_CODE;
else if(subCategories.contains(ContactDetail.SubCategory.State))
{
return MAPI_MAILUSER_PROP_IDS[
PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE];
}
i = PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE;
else if(subCategories.contains(
ContactDetail.SubCategory.Street))
{
return MAPI_MAILUSER_PROP_IDS[PR_BUSINESS_ADDRESS_STREET];
}
i = PR_BUSINESS_ADDRESS_STREET;
else
{
return MAPI_MAILUSER_PROP_IDS[dispidWorkAddress];
}
i = dispidWorkAddress;
}
else if(subCategories.contains(ContactDetail.SubCategory.Home))
{
if(subCategories.contains(ContactDetail.SubCategory.City))
{
return MAPI_MAILUSER_PROP_IDS[PR_HOME_ADDRESS_CITY];
}
i = PR_HOME_ADDRESS_CITY;
else if(subCategories.contains(
ContactDetail.SubCategory.Country))
{
return MAPI_MAILUSER_PROP_IDS[PR_HOME_ADDRESS_COUNTRY];
}
i = PR_HOME_ADDRESS_COUNTRY;
else if(subCategories.contains(
ContactDetail.SubCategory.PostalCode))
{
return MAPI_MAILUSER_PROP_IDS[PR_HOME_ADDRESS_POSTAL_CODE];
}
i = PR_HOME_ADDRESS_POSTAL_CODE;
else if(subCategories.contains(ContactDetail.SubCategory.State))
{
return MAPI_MAILUSER_PROP_IDS[
PR_HOME_ADDRESS_STATE_OR_PROVINCE];
}
i = PR_HOME_ADDRESS_STATE_OR_PROVINCE;
else if(subCategories.contains(
ContactDetail.SubCategory.Street))
{
return MAPI_MAILUSER_PROP_IDS[PR_HOME_ADDRESS_STREET];
}
i = PR_HOME_ADDRESS_STREET;
else
{
return MAPI_MAILUSER_PROP_IDS[dispidHomeAddress];
}
i = dispidHomeAddress;
}
break;
case Web:
default:
break;
}
return -1;
return (i >= 0) ? MAPI_MAILUSER_PROP_IDS[i] : -1;
}
public static native Object[] IMAPIProp_GetProps(
@ -869,13 +858,17 @@ private synchronized boolean onMailUser(String id)
}
catch(MsOutlookMAPIHResultException ex)
{
if(ex.getHresultString().equals("MAPI_E_0x57")
&& firstIMAPIPropGetPropFailureLogged == false)
String hresult = ex.getHresultString();
if("MAPI_E_0x57".equals(hresult))
{
firstIMAPIPropGetPropFailureLogged = true;
throw ex;
if (!firstIMAPIPropGetPropFailureLogged)
{
firstIMAPIPropGetPropFailureLogged = true;
throw ex;
}
}
else if(!ex.getHresultString().equals("MAPI_E_0x57"))
else
{
throw ex;
}
@ -883,7 +876,7 @@ else if(!ex.getHresultString().equals("MAPI_E_0x57"))
{
logger.trace(
MsOutlookAddrBookContactQuery.class.getSimpleName()
+ "#onMailUser(String)",
+ "#onMailUser(String)",
ex);
}
return true;
@ -963,17 +956,20 @@ && matches(propIndex, (String) prop)
if (logger.isTraceEnabled())
{
logger.trace(
"Retrieving the image property of the " +
"contact failed.",
"Retrieving the image property of the "
+ "contact failed.",
ex);
}
}
}
if(logger.isTraceEnabled())
logger.trace("For query: " + query + " found contact:"
+ sourceContact.getDisplayName() + ", "
+ sourceContact.getContactAddress());
{
logger.trace(
"For query: " + query + " found contact:"
+ sourceContact.getDisplayName() + ", "
+ sourceContact.getContactAddress());
}
addQueryResult(sourceContact);
}
@ -1058,12 +1054,15 @@ protected void run()
long start = System.currentTimeMillis();
foreachMailUser(
query.toString(),
new PtrOutlookContactCallback());
query.toString(),
new PtrOutlookContactCallback());
if(logger.isTraceEnabled())
logger.trace("Query " + query + " took "
+ (System.currentTimeMillis() - start) + " ms.");
{
logger.trace(
"Query " + query + " took "
+ (System.currentTimeMillis() - start) + " ms.");
}
}
}
@ -1124,10 +1123,9 @@ public void insertedOrUpdated(String id, int maxLevel)
{
logger.debug(
MsOutlookAddrBookContactQuery.class.getSimpleName()
+ "#onMailUser(String)",
+ "#onMailUser(String)",
e);
}
}
}
}
@ -1179,7 +1177,7 @@ boolean callback(String id)
{
logger.debug(
MsOutlookAddrBookContactQuery.class.getSimpleName()
+ "#onMailUser(String)",
+ "#onMailUser(String)",
e);
}
return false;

@ -66,12 +66,12 @@ public class MsOutlookAddrBookContactSourceService
* The latest query created.
*/
private MsOutlookAddrBookContactQuery latestQuery = null;
/**
* Indicates whether MAPI is initialized or not.
*/
private static boolean isMAPIInitialized = false;
static
{
String lib = "jmsoutlookaddrbook";
@ -135,7 +135,7 @@ public static void initMAPI(NotificationsDelegate notificationDelegate)
isMAPIInitialized = true;
}
}
/**
* Creates new <tt>NotificationsDelegate</tt> instance.
* @return the <tt>NotificationsDelegate</tt> instance
@ -188,7 +188,7 @@ public static void UninitializeMAPI()
isMAPIInitialized = false;
}
}
private static native void MAPIUninitialize();
public static native int getOutlookBitnessVersion();
@ -213,7 +213,7 @@ public ContactQuery createContactQuery(Pattern query)
latestQuery.clear();
latestQuery = new MsOutlookAddrBookContactQuery(this, query);
return latestQuery;
}
@ -584,7 +584,7 @@ public int getVersion()
public int getNbRemainingNotifications()
{
int nbNotifications = 0;
synchronized(notificationThreadMutex)
{
if(notificationThread != null)

@ -386,7 +386,7 @@ private void setDisplayPostalAddress()
synchronized(this)
{
MsOutlookAddrBookContactDetail detail;
// Setting the display work postal address.
boolean firstLineCR = false;
boolean secondLineCR = false;

@ -23,45 +23,45 @@ public class CalendarItemTimerTask
* The status of the calendar item.
*/
private final CalendarService.BusyStatusEnum state;
/**
* The start date of the calendar item.
*/
private final Date startDate;
/**
* The end date of the calendar item.
*/
private final Date endDate;
/**
* The ID of the calendar item.
*/
private final String id;
/**
* Indicates if the start task should be executed immediately or not. This
* flag is <tt>true</tt> if the start date is before the current date.
*/
private final boolean executeNow;
/**
* The <tt>CalendarServiceImpl</tt> instance.
*/
private final CalendarServiceImpl calendarService
= AddrBookActivator.getCalendarService();
/**
* The <tt>Timer</tt> instance that schedules the tasks.
*/
private static Timer timer = new Timer();
/**
* The <tt>RecurringPattern</tt> instance associated with the calendar item.
* This must be <tt>null</tt> if the calendar item is not recurring.
*/
private RecurringPattern pattern;
/**
* The task that will be executed at the beginning of the task.
*/
@ -73,7 +73,7 @@ public void run()
start();
}
};
/**
* The task that will be executed at the end of the task.
*/
@ -85,7 +85,7 @@ public void run()
stop();
}
};
/**
* Constructs new <tt>CalendarItemTimerTask</tt> instance.
* @param state the state of the calendar item.
@ -110,7 +110,7 @@ public CalendarItemTimerTask(CalendarService.BusyStatusEnum state,
this.executeNow = executeNow;
this.pattern = pattern;
}
/**
* Returns the <tt>RecurringPattern</tt> instance associated with the
* calendar item.
@ -155,7 +155,7 @@ protected void stop()
this.pattern = null;
nextTask.scheduleTasks();
}
}
/**
@ -173,7 +173,7 @@ public void scheduleTasks()
}
timer.schedule(endTask, endDate);
}
/**
* Removes the task.
*/
@ -185,7 +185,7 @@ public void remove()
calendarService.removeFromCurrentItems(this);
calendarService.updateStateFromCurrentItems();
}
/**
* Returns the free busy status of the calendar item.
* @return the free busy status of the calendar item.
@ -194,8 +194,8 @@ public CalendarService.BusyStatusEnum getStatus()
{
return state;
}
/**
* Returns the start date of the calendar item
* @return the start date of the calendar item
@ -213,7 +213,7 @@ public Date getEndDate()
{
return endDate;
}
/**
* Sets the <tt>RecurringPattern</tt> associated with the calendar item.
* @param pattern the pattern to set
@ -222,4 +222,4 @@ public void setPattern(RecurringPattern pattern)
{
this.pattern = pattern;
}
}
}

@ -6,17 +6,15 @@
*/
package net.java.sip.communicator.plugin.addrbook.msoutlook.calendar;
import java.text.*;
import java.util.*;
import java.util.regex.*;
import net.java.sip.communicator.plugin.addrbook.*;
import net.java.sip.communicator.plugin.addrbook.msoutlook.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.service.calendar.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
/**
* A implementation of <tt>CalendarService</tt> for MS Outlook calendar.
@ -37,7 +35,7 @@ public enum MAPIType
PT_BOOL,
PT_BINARY
};
/**
* MAPI properties that we use to get information about the calendar items.
*/
@ -47,37 +45,37 @@ public static enum MAPICalendarProperties
* A property for the start date of the calendar item.
*/
PidLidAppointmentStartWhole(0x0000820D, MAPIType.PT_SYSTIME),
/**
* A property for the end date of the calendar item.
*/
PidLidAppointmentEndWhole(0x0000820E, MAPIType.PT_SYSTIME),
/**
* A property for the free busy status of the calendar item.
*/
PidLidBusyStatus(0x00008205, MAPIType.PT_LONG),
/**
* A property that indicates if the calendar item is recurring or not.
*/
PidLidRecurring(0x00008223, MAPIType.PT_BOOL),
/**
* A property with information about the recurrent pattern of the event.
*/
PidLidAppointmentRecur(0x00008216, MAPIType.PT_BINARY);
/**
* The id of the property
*/
private final long id;
/**
* The <tt>MAPIType</tt> of the property.
*/
private final MAPIType type;
/**
* Constructs new property.
* @param id the id
@ -88,7 +86,7 @@ public static enum MAPICalendarProperties
this.id = id;
this.type = type;
}
/**
* Returns array of IDs of created properties.
* @return array of IDs of created properties.
@ -108,12 +106,12 @@ public long getID()
{
return id;
}
public MAPIType getType()
{
return type;
}
/**
* Returns <tt>MAPICalendarProperties</tt> instance by given order ID
* @param i the order ID
@ -124,50 +122,50 @@ public static MAPICalendarProperties getByOrderId(int i)
return values()[i];
}
}
/**
* The <tt>Logger</tt> used by the <tt>CalendarServiceImpl</tt>
* class and its instances for logging output.
*/
private static final Logger logger
= Logger.getLogger(CalendarServiceImpl.class);
/**
* A list with currently active <tt>CalendarItemTimerTask</tt>s
*/
private List<CalendarItemTimerTask> currentCalendarItems
= new LinkedList<CalendarItemTimerTask>();
/**
* A map with the calendar items IDs and <tt>CalendarItemTimerTask</tt>s.
* The map contains the current and future calendar items.
*/
private Map<String, CalendarItemTimerTask> taskMap
= new HashMap<String, CalendarItemTimerTask>();
/**
* The current free busy status.
*/
private BusyStatusEnum currentState = BusyStatusEnum.FREE;
/**
* Instance of <tt>InMeetingStatusPolicy</tt> class which is used to update
* the presence status according the current free busy status.
*/
private InMeetingStatusPolicy inMeetingStatusPolicy
= new InMeetingStatusPolicy();
/**
* The flag which signals that MAPI strings should be returned in the
* unicode character set.
*/
public static final long MAPI_UNICODE = 0x80000000;
static
{
System.loadLibrary("jmsoutlookaddrbook");
}
/**
* Adds <tt>CalendarItemTimerTask</tt> to the map of tasks.
* @param id the id of the calendar item to be added.
@ -180,7 +178,7 @@ public void addToTaskMap(String id, CalendarItemTimerTask task)
taskMap.put(id, task);
}
}
/**
* Removes <tt>CalendarItemTimerTask</tt> from the map of tasks.
* @param id the id of the calendar item to be removed.
@ -192,7 +190,7 @@ public void removeFromTaskMap(String id)
taskMap.remove(id);
}
}
/**
* Adds <tt>CalendarItemTimerTask</tt> to the list of current tasks.
* @param task the <tt>CalendarItemTimerTask</tt> instance to be added.
@ -204,7 +202,7 @@ public void addToCurrentItems(CalendarItemTimerTask task)
currentCalendarItems.add(task);
}
}
/**
* Removes <tt>CalendarItemTimerTask</tt> from the list of current tasks.
* @param task the task of the calendar item to be removed.
@ -216,7 +214,7 @@ public void removeFromCurrentItems(CalendarItemTimerTask task)
currentCalendarItems.remove(task);
}
}
/**
* Retrieves, parses and stores all the calendar items from the outlook.
*/
@ -224,7 +222,7 @@ public void start()
{
getAllCalendarItems(new NotificationsDelegate());
}
/**
* Retrieves, parses and stores all the calendar items from the outlook.
* @param callback the callback object that receives the results.
@ -243,7 +241,7 @@ private static native void getAllCalendarItems(
public static native Object[] IMAPIProp_GetProps(String entryId,
long[] propIds, long flags)
throws MsOutlookMAPIHResultException;
/**
* Gets the property values of given calendar item and creates
* <tt>CalendarItemTimerTask</tt> instance for it.
@ -259,10 +257,10 @@ private synchronized void insert(String id)
props
= IMAPIProp_GetProps(id, MAPICalendarProperties.getALLPropertyIDs(),
MAPI_UNICODE);
addCalendarItem(props, id);
}
/**
* Parses the property values of calendar item and creates
* <tt>CalendarItemTimerTask</tt> instance for the calendar item.
@ -322,17 +320,17 @@ private void addCalendarItem(Object[] props, String id)
break;
}
}
if(status == BusyStatusEnum.FREE || startTime == null || endTime == null)
return;
Date currentTime = new Date();
boolean executeNow = false;
if(startTime.before(currentTime) || startTime.equals(currentTime))
executeNow = true;
CalendarItemTimerTask task = null;
if(recurringData != null)
{
@ -342,7 +340,7 @@ private void addCalendarItem(Object[] props, String id)
= new RecurringPattern(recurringData, task);
task.setPattern(pattern);
}
if(endTime.before(currentTime) || endTime.equals(currentTime))
{
if(isRecurring)
@ -352,11 +350,11 @@ private void addCalendarItem(Object[] props, String id)
else
return;
}
if(task == null)
task = new CalendarItemTimerTask(status, startTime, endTime, id,
executeNow, null);
task.scheduleTasks();
}
@ -375,9 +373,9 @@ protected void setCurrentState(BusyStatusEnum state)
{
inMeetingStatusPolicy.freeBusyStateChanged();
}
}
/**
* Calculates and changes the value of current status using the current
* active calendar items and their statuses.
@ -410,16 +408,16 @@ public BusyStatusEnum getStatus()
@Override
public void addFreeBusySateListener(FreeBusySateListener listener)
{
}
/**
* The method is not implemented yet.
*/
@Override
public void removeFreeBusySateListener(FreeBusySateListener listener)
{
}
/**
@ -560,7 +558,7 @@ private void run()
{
List<ProtocolProviderService> providers
= AddrBookActivator.getProtocolProviders();
if ((providers == null) || (providers.size() == 0))
{
forgetPresenceStatuses();
@ -578,16 +576,16 @@ private void run()
}
}
}
public void handleProtocolProvider(ProtocolProviderService pps,
Boolean isInMeeting)
{
if(isInMeeting == null)
isInMeeting = isInMeeting();
OperationSetPresence presence
= pps.getOperationSet(OperationSetPresence.class);
if (presence == null)
{
/*
@ -601,7 +599,7 @@ else if (pps.isRegistered())
{
PresenceStatus inMeetingPresenceStatus
= findInMeetingPresenceStatus(presence);
if (inMeetingPresenceStatus == null)
{
/*
@ -615,7 +613,7 @@ else if (isInMeeting)
{
PresenceStatus presenceStatus
= presence.getPresenceStatus();
if (presenceStatus == null)
{
/*
@ -646,7 +644,7 @@ else if (!inMeetingPresenceStatus.equals(
{
PresenceStatus presenceStatus
= forgetPresenceStatus(pps);
if ((presenceStatus != null)
&& inMeetingPresenceStatus.equals(
presence.getPresenceStatus()))
@ -663,10 +661,10 @@ else if (!inMeetingPresenceStatus.equals(
*/
forgetPresenceStatus(pps);
}
}
}
/**
* Delegate class to be notified for calendar changes.
*/
@ -720,7 +718,7 @@ public void deleted(String id)
task.remove();
}
}
/**
* Callback method when receiving notifications for deleted items.
*/
@ -742,5 +740,4 @@ public void handleProviderAdded(ProtocolProviderService pps)
{
inMeetingStatusPolicy.handleProtocolProvider(pps, null);
}
}

@ -11,7 +11,6 @@
import java.util.*;
import net.java.sip.communicator.service.calendar.*;
import net.java.sip.communicator.util.*;
/**
* The class represents the recurring pattern structure of calendar item.
@ -20,13 +19,6 @@
*/
public class RecurringPattern
{
/**
* The <tt>Logger</tt> used by the <tt>RecurringPattern</tt> class and its
* instances for logging output.
*/
private static final Logger logger
= Logger.getLogger(RecurringPattern.class);
/**
* Enum for the type of the pattern.
*/
@ -116,114 +108,114 @@ public static PatternType getFromShort(short value)
* The value of recurFrequency field.
*/
private short recurFrequency;
/**
* The value of patternType field.
*/
private PatternType patternType;
/**
* The value of calendarType field.
*/
private short calendarType;
/**
* The value of firstDateTime field.
*/
private int firstDateTime;
/**
* The value of period field.
*/
private int period;
/**
* The value of slidingFlag field.
*/
private int slidingFlag;
/**
* The value of patternSpecific1 field.
*/
private int patternSpecific1;
/**
* The value of patternSpecific2 field.
*/
private int patternSpecific2;
/**
* The value of endType field.
*/
private int endType;
/**
* The value of occurenceCount field.
*/
private int occurenceCount;
/**
* The value of firstDow field.
*/
private int firstDow;
/**
* The value of deletedInstanceCount field.
*/
private int deletedInstanceCount;
/**
* The value of modifiedInstanceCount field.
*/
private int modifiedInstanceCount;
/**
* The value of startDate field.
*/
private int startDate;
/**
* The value of endDate field.
*/
private int endDate;
/**
* List with the start dates of deleted instances.
*/
private List<Date> deletedInstances = new ArrayList<Date>();
/**
* Array with the start dates of modified instances.
*/
private int[] modifiedInstances;
/**
* List of exception info structures included in the pattern.
*/
private List<ExceptionInfo> exceptionInfo;
/**
* The source calendar item of the recurrent series.
*/
private CalendarItemTimerTask sourceTask;
/**
* List of days of week when the calendar item occurred.
*/
private List<Integer> allowedDaysOfWeek = new LinkedList<Integer>();
/**
* The binary data of the pattern.
*/
private ByteBuffer dataBuffer;
/**
* Array with masks for days of week when the calendar item occurs.
*/
public static int[] weekOfDayMask
= {0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010,
0x00000020, 0x00000040};
/**
* Parses the binary data that describes the recurrent pattern.
* @param data the binary data.
@ -232,28 +224,27 @@ public static PatternType getFromShort(short value)
public RecurringPattern(byte[] data, CalendarItemTimerTask sourceTask)
{
this.sourceTask = sourceTask;
dataBuffer
= ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
dataBuffer = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
int offset = 4;
recurFrequency = dataBuffer.getShort(offset);
offset += 2;
patternType = PatternType.getFromShort(dataBuffer.getShort(offset));
offset += 2;
calendarType = dataBuffer.getShort(offset);
offset += 2;
firstDateTime = dataBuffer.getInt(offset);
offset += 4;
period = dataBuffer.getInt(offset);
offset += 4;
slidingFlag = dataBuffer.getInt(offset);
offset += 4;
switch(patternType)
{
case Week:
@ -291,20 +282,20 @@ public RecurringPattern(byte[] data, CalendarItemTimerTask sourceTask)
default:
break;
}
//endType
endType = dataBuffer.getInt(offset);
offset += 4;
occurenceCount = dataBuffer.getInt(offset);
offset += 4;
firstDow = dataBuffer.getInt(offset);
offset += 4;
deletedInstanceCount = dataBuffer.getInt(offset);
offset += 4;
//deleted instances
for(int i = 0; i < deletedInstanceCount; i ++)
{
@ -312,29 +303,29 @@ public RecurringPattern(byte[] data, CalendarItemTimerTask sourceTask)
windowsTimeToDateObject(dataBuffer.getInt(offset)));
offset += 4;
}
modifiedInstanceCount = dataBuffer.getInt(offset);
offset += 4;
//modified instances
modifiedInstances = new int[modifiedInstanceCount];
for(int i = 0; i < modifiedInstanceCount; i ++)
{
modifiedInstances[i] = dataBuffer.getInt(offset);
offset += 4;
}
startDate = dataBuffer.getInt(offset);
offset += 4;
endDate = dataBuffer.getInt(offset);
offset += 4;
offset += 16;
short exceptionCount = dataBuffer.getShort(offset);
offset += 2;
exceptionInfo = new ArrayList<ExceptionInfo>(exceptionCount);
@ -343,7 +334,7 @@ public RecurringPattern(byte[] data, CalendarItemTimerTask sourceTask)
ExceptionInfo tmpExceptionInfo = new ExceptionInfo(offset);
exceptionInfo.add(tmpExceptionInfo);
offset += tmpExceptionInfo.sizeInBytes();
CalendarService.BusyStatusEnum status
= tmpExceptionInfo.getBusyStatus();
Date startTime = tmpExceptionInfo.getStartDate();
@ -352,22 +343,22 @@ public RecurringPattern(byte[] data, CalendarItemTimerTask sourceTask)
|| startTime == null || endTime == null)
continue;
Date currentTime = new Date();
if(endTime.before(currentTime) || endTime.equals(currentTime))
return;
boolean executeNow = false;
if(startTime.before(currentTime) || startTime.equals(currentTime))
executeNow = true;
CalendarItemTimerTask task = new CalendarItemTimerTask(status,
startTime, endTime, sourceTask.getId(), executeNow, this);
task.scheduleTasks();
}
}
/**
* Converts windows time in minutes from 1/1/1601 to <tt>Date</tt> object.
* @param time the number of minutes from 1/1/1601
@ -379,7 +370,7 @@ public static Date windowsTimeToDateObject(long time) {
date -= TimeZone.getDefault().getOffset(date);
return new Date(date);
}
/**
* Prints the properties of the class for debugging purpose.
*/
@ -395,7 +386,7 @@ public String toString()
result += "calendarType: "
+ String.format("%#02x", this.calendarType) + "\n";
result += "endType: " + String.format("%#04x", this.endType) + "\n";
result += "period: " + this.period + "\n";
result += "occurenceCount: "
+ String.format("%#04x", this.occurenceCount) + "\n";
@ -406,25 +397,25 @@ public String toString()
result += "startDate hex: " + String.format("%#04x", this.startDate)
+ "\n";
result += "endDate hex: " + String.format("%#04x", this.endDate) + "\n";
result += "startDate: "
+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(
windowsTimeToDateObject(this.startDate)) + "\n";
result += "endDate: "
+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(
windowsTimeToDateObject(this.endDate)) + "\n";
for(int i = 0; i < modifiedInstanceCount; i++)
{
result += "modified Instance date hex: "
+ String.format("%#04x", this.modifiedInstances[i]) + "\n";
result += "modified Instance date: "
+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z").format(
windowsTimeToDateObject(this.modifiedInstances[i])) + "\n";
}
for(int i = 0; i < deletedInstanceCount; i++)
{
result += "deleted Instance date: "
@ -433,16 +424,16 @@ public String toString()
}
result += "patternSpecific2: "
+ String.format("%#04x", this.patternSpecific2) + "\n";
result += "\n\n =====================Exeptions====================\n\n";
for(ExceptionInfo info : exceptionInfo)
{
result += info.toString() + "\n\n";
}
return result;
}
/**
* Checks whether the given date is in the recurrent pattern range or not
* @param date the date
@ -462,7 +453,7 @@ private boolean dateOutOfRange(Date date)
}
return false;
}
/**
* Calculates and creates the next calendar item.
* @param previousStartDate the start date of the previous occurrence.
@ -500,11 +491,11 @@ public CalendarItemTimerTask next(Date previousStartDate,
{
offset += period * 60000;
}
startDate = new Date(startDate.getTime() + offset);
}
Calendar cal = Calendar.getInstance();
cal.setTime(startDate);
Calendar cal2 = (Calendar) cal.clone();
@ -517,7 +508,7 @@ public CalendarItemTimerTask next(Date previousStartDate,
cal.add(Calendar.MINUTE, period);
cal2.add(Calendar.MINUTE, period);
}
if(dateOutOfRange(cal.getTime()))
{
return null;
@ -528,7 +519,7 @@ public CalendarItemTimerTask next(Date previousStartDate,
{
executeNow = true;
}
return new CalendarItemTimerTask(
sourceTask.getStatus(),
startDate, endDate, sourceTask.getId(), executeNow, this);
@ -563,7 +554,7 @@ public CalendarItemTimerTask next(Date previousStartDate,
cal.set(Calendar.DAY_OF_WEEK, allowedDaysOfWeek.get(0));
endDate = new Date(cal.getTimeInMillis() + duration);
long offset = (currentDate.getTime() - endDate.getTime());
//1 week = 604800000 is milliseconds
offset -= offset % (period * 604800000);
if(endDate.getTime() + offset < currentDate.getTime())
@ -582,7 +573,7 @@ public CalendarItemTimerTask next(Date previousStartDate,
cal.set(Calendar.DAY_OF_WEEK, allowedDaysOfWeek.get(i));
i++;
}
startDate = cal.getTime();
}
else
@ -590,7 +581,7 @@ public CalendarItemTimerTask next(Date previousStartDate,
startDate = new Date(cal.getTimeInMillis() + offset);
}
}
cal.setTime(startDate);
Calendar cal2 = (Calendar) cal.clone();
cal.set(Calendar.HOUR_OF_DAY, 0);
@ -610,7 +601,7 @@ public CalendarItemTimerTask next(Date previousStartDate,
cal.set(Calendar.DAY_OF_WEEK, allowedDaysOfWeek.get(index));
cal2.set(Calendar.DAY_OF_WEEK, allowedDaysOfWeek.get(index));
index++;
}
startDate = cal2.getTime();
endDate = new Date(startDate.getTime() + duration);
@ -620,7 +611,7 @@ public CalendarItemTimerTask next(Date previousStartDate,
{
executeNow = true;
}
return new CalendarItemTimerTask(
sourceTask.getStatus(),
startDate, endDate, sourceTask.getId(), executeNow, this);
@ -636,18 +627,14 @@ public CalendarItemTimerTask next(Date previousStartDate,
case HjMonthNth:
{
if(patternSpecific1 == 0x7f && patternSpecific2 == 0x05)
{
return nextMonth(startDate, endDate, true);
}
return nextMonthN(startDate, endDate);
else
return nextMonthN(startDate, endDate);
}
}
return null;
}
/**
* Finds the occurrence of the events in the next months
* @param cal the calendar object
@ -664,11 +651,11 @@ private Calendar incrementMonths(Calendar cal, boolean lastDay,
if(lastDay
|| (cal.getActualMaximum(Calendar.DAY_OF_MONTH) < dayOfMonth))
dayOfMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
return cal;
}
/**
* Finds the next occurrence for monthly recurrence.
* @param startDate the start date of the previous calendar item.
@ -702,7 +689,7 @@ public CalendarItemTimerTask nextMonth(Date startDate, Date endDate,
cal = incrementMonths(cal, lastDay, period);
}
}
Calendar cal2 = (Calendar) cal.clone();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
@ -713,25 +700,21 @@ public CalendarItemTimerTask nextMonth(Date startDate, Date endDate,
cal = incrementMonths(cal, lastDay, period);
cal2 = incrementMonths(cal2, lastDay, period);
}
startDate = cal2.getTime();
endDate = new Date(startDate.getTime() + duration);
if(dateOutOfRange(endDate))
{
return null;
}
boolean executeNow = false;
if(startDate.before(currentDate))
{
executeNow = true;
}
boolean executeNow = startDate.before(currentDate);
return new CalendarItemTimerTask(
sourceTask.getStatus(),
startDate, endDate, sourceTask.getId(), executeNow, this);
}
/**
* Finds the occurrence of the events in the next months
* @param startDate the start date if the calendar item
@ -742,7 +725,7 @@ private Date getMonthNStartDate(Date startDate, int dayOfWeekInMonth)
{
Calendar cal = Calendar.getInstance();
cal.setTime(startDate);
if(dayOfWeekInMonth == -1)
{
Date result = null;
@ -763,11 +746,11 @@ private Date getMonthNStartDate(Date startDate, int dayOfWeekInMonth)
dayOfWeekInMonth--;
if(dayOfWeekInMonth > 0)
cal.add(Calendar.DAY_OF_MONTH, 1);
}
return cal.getTime();
}
/**
* Finds the next occurrence for monthly Nth recurrence.
* @param startDate the start date of the previous calendar item.
@ -805,7 +788,7 @@ public CalendarItemTimerTask nextMonthN(Date startDate, Date endDate)
cal.setTime(getMonthNStartDate(cal.getTime(), dayOfWeekInMonth));
}
}
Calendar cal2 = (Calendar) cal.clone();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
@ -831,24 +814,24 @@ public CalendarItemTimerTask nextMonthN(Date startDate, Date endDate)
}
}
}
startDate = cal2.getTime();
endDate = new Date(startDate.getTime() + duration);
if(dateOutOfRange(endDate))
return null;
boolean executeNow = false;
if(startDate.before(currentDate))
{
executeNow = true;
}
return new CalendarItemTimerTask(
sourceTask.getStatus(),
startDate, endDate, sourceTask.getId(), executeNow, this);
}
/**
* Represents the exception info structure.
*/
@ -858,32 +841,32 @@ public class ExceptionInfo
* The start date of the exception.
*/
private final Date startDate;
/**
* The end date of the exception.
*/
private final Date endDate;
/**
* The original start date of the exception.
*/
private final Date originalStartDate;
/**
* The modified flags of the exception.
*/
private final short overrideFlags;
/**
* The new busy status of the exception.
*/
private CalendarService.BusyStatusEnum busyStatus;
/**
* The size of the fixed fields.
*/
private int size = 22;
/**
* Parses the data of the exception.
* @param offset the position where the exception starts in the binary
@ -893,14 +876,14 @@ public ExceptionInfo(int offset)
{
startDate = windowsTimeToDateObject(dataBuffer.getInt(offset));
offset += 4;
endDate = windowsTimeToDateObject(dataBuffer.getInt(offset));
offset += 4;
originalStartDate
= windowsTimeToDateObject(dataBuffer.getInt(offset));
offset += 4;
overrideFlags = dataBuffer.getShort(offset);
offset += 2;
int[] fieldMasks = {0x0001, 0x0002, 0x0004, 0x0008, 0x0010,
@ -914,13 +897,13 @@ public ExceptionInfo(int offset)
busyStatus = CalendarService.BusyStatusEnum.getFromLong(
(long)dataBuffer.getInt(offset));
}
if(busyStatus == null)
{
busyStatus = sourceTask.getStatus();
}
}
if((overrideFlags & mask) != 0)
{
if(mask == 0x0010 || mask == 0x0001)
@ -933,11 +916,11 @@ public ExceptionInfo(int offset)
size += 4;
}
}
offset += 4;
int reservedBlockSize = dataBuffer.getShort(offset);
size += reservedBlockSize;
}
/**
@ -948,7 +931,7 @@ public int sizeInBytes()
{
return size;
}
/**
* Returns the start date
* @return the start date
@ -975,7 +958,7 @@ public CalendarService.BusyStatusEnum getBusyStatus()
{
return busyStatus;
}
/**
* Prints the properties of the class for debugging purpose.
*/
@ -995,4 +978,4 @@ public String toString()
return result;
}
}
}
}

Loading…
Cancel
Save