diff options
author | hristoterezov <hristo@jitsi.org> | 2014-05-15 11:52:58 +0300 |
---|---|---|
committer | hristoterezov <hristo@jitsi.org> | 2014-05-15 11:52:58 +0300 |
commit | 395d0c818735ed8248b10d756cf6e043c7e1e693 (patch) | |
tree | aee81108d7e807fc26fbbad133a3f3f2ee75ef7c /src/net/java | |
parent | 2add59b51b699eb692f35872a426d57b8fc385fe (diff) | |
download | jitsi-395d0c818735ed8248b10d756cf6e043c7e1e693.zip jitsi-395d0c818735ed8248b10d756cf6e043c7e1e693.tar.gz jitsi-395d0c818735ed8248b10d756cf6e043c7e1e693.tar.bz2 |
Fixes NPE when creating a call and the calendar service is not registered.
Diffstat (limited to 'src/net/java')
4 files changed, 68 insertions, 64 deletions
diff --git a/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java b/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java index 520705b..b07618a 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java +++ b/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java @@ -105,7 +105,7 @@ public class AddrBookActivator /** * List of the providers with registration listener. */ - private static List<ProtocolProviderService> providers + private static List<ProtocolProviderService> providers = new ArrayList<ProtocolProviderService>(); /** @@ -116,7 +116,7 @@ public class AddrBookActivator /** * The registration change listener. */ - private static RegistrationStateChangeListener providerListener + private static RegistrationStateChangeListener providerListener = new RegistrationStateChangeListener() { @Override @@ -132,7 +132,7 @@ public class AddrBookActivator }; /** - * A listener for addition of <tt>ProtocolProviderService</tt> + * A listener for addition of <tt>ProtocolProviderService</tt> */ private static ServiceListener serviceListener = new ServiceListener() @@ -402,7 +402,7 @@ public class AddrBookActivator false)) { calendarService = new CalendarServiceImpl(); - + try { MsOutlookAddrBookContactSourceService.initMAPI(null); @@ -506,7 +506,7 @@ public class AddrBookActivator public static List<ProtocolProviderService> getProtocolProviders() { ServiceReference[] ppsRefs; - List<ProtocolProviderService> result + List<ProtocolProviderService> result = new ArrayList<ProtocolProviderService>(); try diff --git a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/calendar/CalendarServiceImpl.java b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/calendar/CalendarServiceImpl.java index 28b67ad..3f67c56 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/calendar/CalendarServiceImpl.java +++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/calendar/CalendarServiceImpl.java @@ -18,8 +18,8 @@ import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; /** - * A implementation of <tt>CalendarService</tt> for MS Outlook calendar. - * The class resolves the free busy status and also changes the presence status + * A implementation of <tt>CalendarService</tt> for MS Outlook calendar. + * The class resolves the free busy status and also changes the presence status * according to free busy status. * * @author Hristo Terezov @@ -36,7 +36,7 @@ public class CalendarServiceImpl implements CalendarService PT_BOOL, PT_BINARY }; - + /** * Response statuses of the calendar events (meeting objects). */ @@ -46,46 +46,46 @@ public class CalendarServiceImpl implements CalendarService * No response is required for this object. */ respNone(0x00000000), - + /** * This meeting belongs to the organizer. */ respOrganized(0x00000001), - + /** - * This value on the attendee's meeting indicates that the attendee has + * This value on the attendee's meeting indicates that the attendee has * tentatively accepted the meeting request. */ respTentative(0x00000002), - + /** - * This value on the attendee's meeting t indicates that the attendee + * This value on the attendee's meeting t indicates that the attendee * has accepted the meeting request. */ respAccepted(0x00000003), - + /** - * This value on the attendee's meeting indicates that the attendee has + * This value on the attendee's meeting indicates that the attendee has * declined the meeting request. */ respDeclined(0x00000004), - + /** - * This value on the attendee's meeting indicates the attendee has not + * This value on the attendee's meeting indicates the attendee has not * yet responded. */ respNotResponded(0x00000005); - + /** * The ID of the property */ private final long id; - + private ResponseStatus(int id) { this.id = id; } - + /** * Finds <tt>ResponseStatuse</tt> instance by given value of the status. * @param value the value of the status we are searching for. @@ -142,7 +142,7 @@ public class CalendarServiceImpl implements CalendarService * A property with information about the recurrent pattern of the event. */ PidLidAppointmentRecur(0x00008216, MAPIType.PT_BINARY), - + /** * A property with information about the accepted state of the event. */ @@ -159,7 +159,7 @@ public class CalendarServiceImpl implements CalendarService private final MAPIType type; /** - * Constructs new property. + * Constructs new property. * @param id the id * @param type the type */ @@ -223,7 +223,7 @@ public class CalendarServiceImpl implements CalendarService /** * A list with currently active <tt>CalendarItemTimerTask</tt>s */ - private List<CalendarItemTimerTask> currentCalendarItems + private List<CalendarItemTimerTask> currentCalendarItems = new LinkedList<CalendarItemTimerTask>(); /** @@ -239,10 +239,10 @@ public class CalendarServiceImpl implements CalendarService private BusyStatusEnum currentState = BusyStatusEnum.FREE; /** - * Instance of <tt>InMeetingStatusPolicy</tt> class which is used to update + * Instance of <tt>InMeetingStatusPolicy</tt> class which is used to update * the presence status according the current free busy status. */ - private InMeetingStatusPolicy inMeetingStatusPolicy + private InMeetingStatusPolicy inMeetingStatusPolicy = new InMeetingStatusPolicy(); /** @@ -328,12 +328,12 @@ public class CalendarServiceImpl implements CalendarService * @return array of property values for the given calendar item. * @throws MsOutlookMAPIHResultException */ - public static native Object[] IMAPIProp_GetProps(String entryId, + public static native Object[] IMAPIProp_GetProps(String entryId, long[] propIds, long flags) throws MsOutlookMAPIHResultException; /** - * Gets the property values of given calendar item and creates + * Gets the property values of given calendar item and creates * <tt>CalendarItemTimerTask</tt> instance for it. * @param id The outlook calendar item identifier. * @@ -344,15 +344,15 @@ public class CalendarServiceImpl implements CalendarService throws MsOutlookMAPIHResultException { Object[] props = null; - props - = IMAPIProp_GetProps(id, MAPICalendarProperties.getALLPropertyIDs(), + props + = IMAPIProp_GetProps(id, MAPICalendarProperties.getALLPropertyIDs(), MAPI_UNICODE); addCalendarItem(props, id); } /** - * Parses the property values of calendar item and creates + * Parses the property values of calendar item and creates * <tt>CalendarItemTimerTask</tt> instance for the calendar item. * @param props the property values. * @param id the ID of the calendar item. @@ -368,14 +368,14 @@ public class CalendarServiceImpl implements CalendarService { if(props[i] == null) continue; - MAPICalendarProperties propertyName + MAPICalendarProperties propertyName = MAPICalendarProperties.getByOrderId(i); switch(propertyName) { case PidLidAppointmentStartWhole: try { - long time + long time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z") .parse((String)props[i] + " UTC").getTime(); startTime = new Date(time); @@ -389,7 +389,7 @@ public class CalendarServiceImpl implements CalendarService case PidLidAppointmentEndWhole: try { - long time + long time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z") .parse((String)props[i] + " UTC").getTime(); endTime = new Date(time); @@ -410,12 +410,12 @@ public class CalendarServiceImpl implements CalendarService recurringData = ((byte[])props[i]); break; case PidLidResponseStatus: - responseStatus + responseStatus = ResponseStatus.getFromLong((Long) props[i]); break; } } - + if(responseStatus != ResponseStatus.respNone && responseStatus != ResponseStatus.respAccepted && responseStatus != ResponseStatus.respOrganized) @@ -434,11 +434,11 @@ public class CalendarServiceImpl implements CalendarService CalendarItemTimerTask task = null; if(recurringData != null) { - task = new CalendarItemTimerTask(status, startTime, endTime, id, + task = new CalendarItemTimerTask(status, startTime, endTime, id, executeNow, null); try { - RecurringPattern pattern + RecurringPattern pattern = new RecurringPattern(recurringData, task); task.setPattern(pattern); } @@ -474,7 +474,7 @@ public class CalendarServiceImpl implements CalendarService sb.append(String.format("%02x", b & 0xff)); return sb.toString(); } - + /** * Changes the value of the current status * @param state the new value. @@ -492,10 +492,10 @@ public class CalendarServiceImpl implements CalendarService } } - + /** * Handles presence status changed from "On the Phone" - * + * * @param presenceStatuses the remembered presence statuses * @return <tt>true</tt> if the status is changed. */ @@ -511,7 +511,7 @@ public class CalendarServiceImpl implements CalendarService } /** - * Calculates and changes the value of current status using the current + * Calculates and changes the value of current status using the current * active calendar items and their statuses. */ public void updateStateFromCurrentItems() @@ -600,7 +600,7 @@ public class CalendarServiceImpl implements CalendarService for(ProtocolProviderService pps : presenceStatuses.keySet()) rememberPresenceStatus(pps, presenceStatuses.get(pps)); } - + /** * Returns the remembered presence statuses * @return the remembered presence statuses @@ -609,7 +609,7 @@ public class CalendarServiceImpl implements CalendarService { return presenceStatuses; } - + /** * Finds the first <tt>PresenceStatus</tt> among the set of * <tt>PresenceStatus</tt>es supported by a specific @@ -695,7 +695,7 @@ public class CalendarServiceImpl implements CalendarService /** * Determines whether the free busy status is busy or not * - * @return <tt>true</tt> if the status is busy and <tt>false</tt> if the + * @return <tt>true</tt> if the status is busy and <tt>false</tt> if the * status is free */ private boolean isInMeeting() @@ -764,7 +764,7 @@ public class CalendarServiceImpl implements CalendarService } } - public void handleProtocolProvider(ProtocolProviderService pps, + public void handleProtocolProvider(ProtocolProviderService pps, Boolean isInMeeting, boolean onThePhoneStatusChanged) { if(isInMeeting == null) @@ -786,8 +786,8 @@ public class CalendarServiceImpl implements CalendarService { PresenceStatus inMeetingPresenceStatus = findInMeetingPresenceStatus(presence); - - PresenceStatus onThePhone + + PresenceStatus onThePhone = findOnThePhonePresenceStatus(presence); if (inMeetingPresenceStatus == null) @@ -814,8 +814,8 @@ public class CalendarServiceImpl implements CalendarService forgetPresenceStatus(pps); } else if (!inMeetingPresenceStatus.equals( - presenceStatus) - && (!presenceStatus.equals(onThePhone) + presenceStatus) + && (!presenceStatus.equals(onThePhone) || onThePhoneStatusChanged)) { publishPresenceStatus( @@ -940,7 +940,7 @@ public class CalendarServiceImpl implements CalendarService { inMeetingStatusPolicy.handleProtocolProvider(pps, null, false); } - + /** * Returns the remembered presence statuses * @return the remembered presence statuses diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java b/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java index cea7735..8ad4765 100644 --- a/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java +++ b/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java @@ -130,11 +130,14 @@ public class ProtocolProviderActivator {
if (calendarService == null)
{
+ ServiceReference serviceReference
+ = bundleContext.getServiceReference(
+ CalendarService.class.getName());
+ if(serviceReference == null)
+ return null;
calendarService
= (CalendarService)
- bundleContext.getService(
- bundleContext.getServiceReference(
- CalendarService.class.getName()));
+ bundleContext.getService(serviceReference);
}
return calendarService;
}
diff --git a/src/net/java/sip/communicator/service/protocol/SingleCallInProgressPolicy.java b/src/net/java/sip/communicator/service/protocol/SingleCallInProgressPolicy.java index 487a42c..865e939 100644 --- a/src/net/java/sip/communicator/service/protocol/SingleCallInProgressPolicy.java +++ b/src/net/java/sip/communicator/service/protocol/SingleCallInProgressPolicy.java @@ -701,7 +701,7 @@ public class SingleCallInProgressPolicy } return null; } - + /** * Applies this policy to the current state of the application. */ @@ -735,11 +735,11 @@ public class SingleCallInProgressPolicy else { boolean isOnThePhone = isOnThePhone(); - - CalendarService calendar + + CalendarService calendar = ProtocolProviderActivator.getCalendarService(); - - if(!isOnThePhone && + + if(!isOnThePhone && calendar != null && calendar.onThePhoneStatusChanged(presenceStatuses)) { forgetPresenceStatuses(); @@ -801,16 +801,17 @@ public class SingleCallInProgressPolicy publishPresenceStatus( presence, onThePhonePresenceStatus); - + if(presenceStatus.equals( - findInMeetingPresenceStatus(presence))) + findInMeetingPresenceStatus(presence)) + && calendar != null) { - Map<ProtocolProviderService,PresenceStatus> - statuses + Map<ProtocolProviderService,PresenceStatus> + statuses = calendar.getRememberedStatuses(); - for(ProtocolProviderService provider + for(ProtocolProviderService provider : statuses.keySet()) - rememberPresenceStatus(provider, + rememberPresenceStatus(provider, statuses.get(provider)); } else if (onThePhonePresenceStatus.equals( |