aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2014-11-04 13:12:08 +0200
committerDamian Minkov <damencho@jitsi.org>2014-11-04 13:13:34 +0200
commita82bb9369725808151b042ed32d31a3404eb7155 (patch)
tree1d48d5727e109020616fa70e12c902a6b7da754b
parent9b3341d2c99837ad736fdaf9feda9fb4965b4e54 (diff)
downloadjitsi-a82bb9369725808151b042ed32d31a3404eb7155.zip
jitsi-a82bb9369725808151b042ed32d31a3404eb7155.tar.gz
jitsi-a82bb9369725808151b042ed32d31a3404eb7155.tar.bz2
Fixes possible NPE if OperationSetMultiUserChat is disabled for xmpp provider.
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/IncomingFileTransferRequestJabberImpl.java11
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicInstantMessagingJabberImpl.java26
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java9
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java6
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java20
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java3
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTypingNotificationsJabberImpl.java20
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/VolatileContactJabberImpl.java19
8 files changed, 69 insertions, 45 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/IncomingFileTransferRequestJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/IncomingFileTransferRequestJabberImpl.java
index f8e2acd..e57e8ca 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/IncomingFileTransferRequestJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/IncomingFileTransferRequestJabberImpl.java
@@ -81,10 +81,13 @@ public class IncomingFileTransferRequestJabberImpl
sender = opSetPersPresence.findContactByID(fromUserID);
if(sender == null)
{
- ChatRoom privateContactRoom
- = ((OperationSetMultiUserChatJabberImpl)
- jabberProvider.getOperationSet(
- OperationSetMultiUserChat.class))
+ ChatRoom privateContactRoom = null;
+ OperationSetMultiUserChatJabberImpl mucOpSet =
+ (OperationSetMultiUserChatJabberImpl)jabberProvider
+ .getOperationSet(OperationSetMultiUserChat.class);
+
+ if(mucOpSet != null)
+ privateContactRoom = mucOpSet
.getChatRoom(StringUtils.parseBareAddress(fromUserID));
if(privateContactRoom != null)
{
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicInstantMessagingJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicInstantMessagingJabberImpl.java
index 486d49f..c889981 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicInstantMessagingJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicInstantMessagingJabberImpl.java
@@ -299,7 +299,7 @@ public class OperationSetBasicInstantMessagingJabberImpl
* activity (i.e. neither outgoing nor incoming messags) for more than
* JID_INACTIVITY_TIMEOUT. Note that this method is not synchronous and that
* it is only meant for use by the {@link #getThreadIDForAddress(String)} and
- * {@link #putJidForAddress(String, String, Chat)}
+ * {@link #putJidForAddress(String, String)}
*/
private void purgeOldJids()
{
@@ -327,7 +327,7 @@ public class OperationSetBasicInstantMessagingJabberImpl
* entries that haven't seen any activity (i.e. no one has tried to get or
* remap it) for a delay longer than <tt>JID_INACTIVITY_TIMEOUT</tt>.
*
- * @param address the <tt>address</tt> that we'd like to obtain a jid for.
+ * @param jid the <tt>jid</tt> that we'd like to obtain a threadID for.
*
* @return the last jid that the party with the specified <tt>address</tt>
* contacted us from or <tt>null</tt> if we don't have a jid for the
@@ -355,8 +355,7 @@ public class OperationSetBasicInstantMessagingJabberImpl
* the specified <tt>address</tt> to the <tt>jid</tt> that they last
* contacted us from.
*
- * @param address the bare address (i.e. no resource included) of the
- * contact that we'd like to set a jid for.
+ * @param threadID the threadID of conversation.
* @param jid the jid (i.e. address/resource) that the contact with the
* specified <tt>address</tt> last contacted us from.
*/
@@ -494,10 +493,7 @@ public class OperationSetBasicInstantMessagingJabberImpl
putJidForAddress(toJID, threadID);
}
- MessageDeliveredEvent msgDeliveredEvt =
- new MessageDeliveredEvent(message, to, toResource);
-
- return msgDeliveredEvt;
+ return new MessageDeliveredEvent(message, to, toResource);
}
/**
@@ -815,9 +811,13 @@ public class OperationSetBasicInstantMessagingJabberImpl
String userBareID = StringUtils.parseBareAddress(userFullId);
boolean isPrivateMessaging = false;
- ChatRoom privateContactRoom = ((OperationSetMultiUserChatJabberImpl)
- jabberProvider.getOperationSet(OperationSetMultiUserChat.class))
- .getChatRoom(userBareID);
+ ChatRoom privateContactRoom = null;
+ OperationSetMultiUserChatJabberImpl mucOpSet =
+ (OperationSetMultiUserChatJabberImpl)jabberProvider
+ .getOperationSet(OperationSetMultiUserChat.class);
+ if(mucOpSet != null)
+ privateContactRoom = mucOpSet.getChatRoom(userBareID);
+
if(privateContactRoom != null)
{
isPrivateMessaging = true;
@@ -1128,7 +1128,7 @@ public class OperationSetBasicInstantMessagingJabberImpl
Integer.toString( threadCount )//{2} - thread count
});
- StringBuffer message = new StringBuffer(newMailHeader);
+ StringBuilder message = new StringBuilder(newMailHeader);
//we now start an html table for the threads.
message.append("<table width=100% cellpadding=2 cellspacing=0 ");
@@ -1195,7 +1195,7 @@ public class OperationSetBasicInstantMessagingJabberImpl
*/
public void processPacket(Packet packet)
{
- if(packet != null && !(packet instanceof MailboxIQ))
+ if(packet != null && !(packet instanceof MailboxIQ))
return;
MailboxIQ mailboxIQ = (MailboxIQ) packet;
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java
index 8448828..da4fbfe 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java
@@ -353,9 +353,12 @@ public class OperationSetBasicTelephonyJabberImpl
calleeAddress.indexOf('@') + 1)))
|| isGoogleVoice;
- boolean isPrivateMessagingContact = getProtocolProvider()
- .getOperationSet(OperationSetMultiUserChat.class)
- .isPrivateMessagingContact(calleeAddress);
+ boolean isPrivateMessagingContact = false;
+ OperationSetMultiUserChat mucOpSet = getProtocolProvider()
+ .getOperationSet(OperationSetMultiUserChat.class);
+ if(mucOpSet != null)
+ isPrivateMessagingContact
+ = mucOpSet.isPrivateMessagingContact(calleeAddress);
if((!getProtocolProvider().getConnection().getRoster().contains(
StringUtils.parseBareAddress(calleeAddress)) &&
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java
index a6515c1..9762fae 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java
@@ -146,8 +146,10 @@ public class OperationSetFileTransferJabberImpl
// and is with highest priority if more than one found
// if we have equals priorities
// choose the one that is more available
- if(jabberProvider.getOperationSet(OperationSetMultiUserChat.class)
- .isPrivateMessagingContact(toContact.getAddress()))
+ OperationSetMultiUserChat mucOpSet = jabberProvider
+ .getOperationSet(OperationSetMultiUserChat.class);
+ if(mucOpSet != null
+ && mucOpSet.isPrivateMessagingContact(toContact.getAddress()))
{
fullJid = toContact.getAddress();
}
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
index 732f546..8641e76 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
@@ -1298,19 +1298,23 @@ public class OperationSetPersistentPresenceJabberImpl
String userID
= StringUtils.parseBareAddress(presence.getFrom());
- List<ChatRoom> chatRooms = parentProvider.getOperationSet(
- OperationSetMultiUserChat.class)
- .getCurrentlyJoinedChatRooms();
- for(ChatRoom chatRoom : chatRooms)
+ OperationSetMultiUserChat mucOpSet =
+ parentProvider.getOperationSet(
+ OperationSetMultiUserChat.class);
+ if(mucOpSet != null)
{
- if(chatRoom.getName().equals(userID))
+ List<ChatRoom> chatRooms
+ = mucOpSet.getCurrentlyJoinedChatRooms();
+ for(ChatRoom chatRoom : chatRooms)
{
- userID = presence.getFrom();
- break;
+ if(chatRoom.getName().equals(userID))
+ {
+ userID = presence.getFrom();
+ break;
+ }
}
}
-
if (logger.isDebugEnabled())
logger.debug("Received a status update for buddy=" + userID);
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java
index 175802c..e70cfbd 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java
@@ -487,7 +487,8 @@ public class OperationSetTelephonyConferencingJabberImpl
= (OperationSetMultiUserChatJabberImpl)
parentProvider.getOperationSet(OperationSetMultiUserChat.class);
ChatRoom room = null;
- room = opSetMUC.getChatRoom(chatRoomName);
+ if(opSetMUC != null)
+ room = opSetMUC.getChatRoom(chatRoomName);
if(room != null)
return "xmpp:" + chatRoomName + "/" + room.getUserNickname();
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTypingNotificationsJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTypingNotificationsJabberImpl.java
index 2e43512..590ca9f 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTypingNotificationsJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTypingNotificationsJabberImpl.java
@@ -163,7 +163,7 @@ public class OperationSetTypingNotificationsJabberImpl
+ " to " + toJID);
- ChatState chatState = null;
+ ChatState chatState;
if(state == STATE_TYPING)
{
@@ -395,7 +395,6 @@ public class OperationSetTypingNotificationsJabberImpl
/**
* Called by smack when the state of a chat changes.
*
- * @param chat the chat that is concerned by this event.
* @param state the new state of the chat.
* @param message the message containing the new chat state
*/
@@ -410,15 +409,20 @@ public class OperationSetTypingNotificationsJabberImpl
String fromID = StringUtils.parseBareAddress(fromJID);
- List<ChatRoom> chatRooms = parentProvider.getOperationSet(
- OperationSetMultiUserChat.class).getCurrentlyJoinedChatRooms();
boolean isPrivateMessagingAddress = false;
- for(ChatRoom chatRoom : chatRooms)
+ OperationSetMultiUserChat mucOpSet = parentProvider
+ .getOperationSet(OperationSetMultiUserChat.class);
+ if(mucOpSet != null)
{
- if(chatRoom.getName().equals(fromID))
+ List<ChatRoom> chatRooms
+ = mucOpSet.getCurrentlyJoinedChatRooms();
+ for(ChatRoom chatRoom : chatRooms)
{
- isPrivateMessagingAddress = true;
- break;
+ if(chatRoom.getName().equals(fromID))
+ {
+ isPrivateMessagingAddress = true;
+ break;
+ }
}
}
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/VolatileContactJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/VolatileContactJabberImpl.java
index a5ee940..42e3d45 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/VolatileContactJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/VolatileContactJabberImpl.java
@@ -169,12 +169,19 @@ public class VolatileContactJabberImpl
{
if(!isPrivateMessagingContact)
return getAddress();
- ChatRoomMemberJabberImpl chatRoomMember
- = ((OperationSetMultiUserChatJabberImpl)getProtocolProvider()
- .getOperationSet(OperationSetMultiUserChat.class))
- .getChatRoom(StringUtils.parseBareAddress(contactId))
- .findMemberForNickName(
- StringUtils.parseResource(contactId));
+
+
+ ChatRoomMemberJabberImpl chatRoomMember = null;
+ OperationSetMultiUserChatJabberImpl mucOpSet =
+ (OperationSetMultiUserChatJabberImpl)getProtocolProvider()
+ .getOperationSet(OperationSetMultiUserChat.class);
+ if(mucOpSet != null)
+ {
+ chatRoomMember = mucOpSet
+ .getChatRoom(StringUtils.parseBareAddress(contactId))
+ .findMemberForNickName(
+ StringUtils.parseResource(contactId));
+ }
return ((chatRoomMember == null)? null : StringUtils.parseBareAddress(
chatRoomMember.getJabberID()));
}