aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/protocol/yahoo
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/sip/communicator/impl/protocol/yahoo')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/AbstractContactGroupYahooImpl.java40
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/AdHocChatRoomInvitationYahooImpl.java90
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/AdHocChatRoomYahooImpl.java581
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/ContactGroupYahooImpl.java445
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/ContactYahooImpl.java397
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/FileTransferImpl.java117
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/IncomingFileTransferRequestYahooImpl.java190
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/MessageYahooImpl.java48
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetAdHocMultiUserChatYahooImpl.java714
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetBasicInstantMessagingYahooImpl.java649
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetFileTransferYahooImpl.java466
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetPersistentPresenceYahooImpl.java954
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetTypingNotificationsYahooImpl.java153
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolIconYahooImpl.java173
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderFactoryYahooImpl.java172
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java574
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/RootContactGroupYahooImpl.java280
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/ServerStoredContactListYahooImpl.java1274
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/VolatileContactGroupYahooImpl.java97
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/YahooAccountID.java42
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/YahooActivator.java145
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/YahooSession.java76
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf22
23 files changed, 0 insertions, 7699 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/AbstractContactGroupYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/AbstractContactGroupYahooImpl.java
deleted file mode 100644
index 0514c16..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/AbstractContactGroupYahooImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The Yahoo implementation of the service.protocol.ContactGroup interface. There
- * are two types of groups possible here. <tt>RootContactGroupYahooImpl</tt>
- * which is the root node of the ContactList itself and
- * <tt>ContactGroupYahooImpl</tt> which represents standard groups. The
- * reason for having those 2 is that generally, Yahoo groups may not contain
- * subgroups. A contact list on the other hand may not directly contain buddies.
- *
- *
- * The reason for having an abstract class is only - being able to esily
- * recognize our own (Yahoo) contacts.
- * @author Damian Minkov
- */
-public abstract class AbstractContactGroupYahooImpl
- implements ContactGroup
-{
-
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/AdHocChatRoomInvitationYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/AdHocChatRoomInvitationYahooImpl.java
deleted file mode 100644
index e849f6c..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/AdHocChatRoomInvitationYahooImpl.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The Yahoo implementation of the <tt>AdHocChatRoomInvitation</tt> interface.
- *
- * @author Rupert Burchardi
- * @author Valentin Martinet
- */
-public class AdHocChatRoomInvitationYahooImpl
- implements AdHocChatRoomInvitation
-{
- /**
- * Corresponding chat room instance.
- */
- private AdHocChatRoom chatRoom;
- /**
- * The name of the inviter
- */
- private String inviter;
-
- /**
- * The invitation reason.
- */
- private String reason;
-
-
- /**
- * Creates an instance of the <tt>ChatRoomInvitationMsnImpl</tt> by
- * specifying the targetChatRoom, the inviter, the reason.
- *
- * @param targetChatRoom The <tt>AdHocChatRoom</tt> for which the invitation
- * is
- * @param inviter The <tt>Contact</tt>, which sent the invitation
- * @param reason The Reason for the invitation
- */
- public AdHocChatRoomInvitationYahooImpl( AdHocChatRoom targetChatRoom,
- String inviter,
- String reason)
- {
- this.chatRoom = targetChatRoom;
- this.inviter = inviter;
- this.reason = reason;
- }
-
- /**
- * Returns the corresponding chat room.
- * @return The ad-hoc chat room
- */
- public AdHocChatRoom getTargetAdHocChatRoom()
- {
- return chatRoom;
- }
-
- /**
- * Returns the corresponding inviter.
- * @return The name of the inviter
- */
- public String getInviter()
- {
- return inviter;
- }
-
- /**
- * Returns the invitation reason.
- * @return the invitation reason
- */
- public String getReason()
- {
- return reason;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/AdHocChatRoomYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/AdHocChatRoomYahooImpl.java
deleted file mode 100644
index 2775f6f..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/AdHocChatRoomYahooImpl.java
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import ymsg.network.*;
-
-/**
- * Represents a Yahoo ad-hoc chat room, where multiple chat users could
- * communicate in a many-to-many fashion.
- *
- * @author Rupert Burchardi
- * @author Valentin Martinet
- */
-public class AdHocChatRoomYahooImpl
- implements AdHocChatRoom
-{
- private static final Logger logger = Logger
- .getLogger(AdHocChatRoomYahooImpl.class);
-
- /**
- * Listeners that will be notified of changes in member status in the room
- * such as member joined, left or being kicked or dropped.
- */
- private Vector<AdHocChatRoomParticipantPresenceListener> memberListeners
- = new Vector<AdHocChatRoomParticipantPresenceListener>();
-
- /**
- * Listeners that will be notified every time a new message is received on
- * this ad-hoc chat room.
- */
- private Vector<AdHocChatRoomMessageListener> messageListeners
- = new Vector<AdHocChatRoomMessageListener>();
-
- /**
- * The protocol provider that created us
- */
- private ProtocolProviderServiceYahooImpl provider = null;
-
- /**
- * The operation set that created us.
- */
- private OperationSetAdHocMultiUserChatYahooImpl opSetMuc = null;
-
- /**
- * The list of participants of this chat room.
- */
- private Hashtable<String, Contact> participants
- = new Hashtable<String, Contact>();
-
- /**
- * The nickname of this chat room local user participant.
- */
- private String nickname;
-
- /**
- * The yahoo conference model of this ad-hoc chat room, its the
- * representation of an ad-hoc chat room in the lib for this protocol.
- */
- private YahooConference yahooConference = null;
-
- /**
- * Creates an instance of a chat room that has been.
- *
- * @param multiUserChat
- * MultiUserChat
- * @param provider
- * a reference to the currently valid jabber protocol provider.
- */
- public AdHocChatRoomYahooImpl( YahooConference multiUserChat,
- ProtocolProviderServiceYahooImpl provider)
- {
- this.yahooConference = multiUserChat;
- this.provider = provider;
- this.opSetMuc = (OperationSetAdHocMultiUserChatYahooImpl) provider
- .getOperationSet(OperationSetAdHocMultiUserChat.class);
- }
-
- /**
- * Registers <tt>listener</tt> so that it would receive events every time a
- * new message is received on this chat room.
- *
- * @param listener A <tt>MessageListener</tt> that would be notified every
- * time a new message is received on this chat room.
- */
- public void addMessageListener(AdHocChatRoomMessageListener listener)
- {
- synchronized (messageListeners)
- {
- if (!messageListeners.contains(listener))
- messageListeners.add(listener);
- }
- }
-
- /**
- * Removes <tt>listener</tt> so that it won't receive any further message
- * events from this room.
- *
- * @param listener The <tt>MessageListener</tt> to remove from this room
- */
- public void removeMessageListener(AdHocChatRoomMessageListener listener)
- {
- synchronized (messageListeners)
- {
- messageListeners.remove(listener);
- }
- }
-
- /**
- * Adds a listener that will be notified of changes in our status in the
- * room.
- *
- * @param listener A participant status listener.
- */
- public void addParticipantPresenceListener(
- AdHocChatRoomParticipantPresenceListener listener)
- {
- synchronized (memberListeners)
- {
- if (!memberListeners.contains(listener))
- memberListeners.add(listener);
- }
- }
-
- /**
- * Removes a listener that was being notified of changes in the status of
- * other chat room participants.
- *
- * @param listener A participant status listener.
- */
- public void removeParticipantPresenceListener(
- AdHocChatRoomParticipantPresenceListener listener)
- {
- synchronized (memberListeners)
- {
- memberListeners.remove(listener);
- }
- }
-
- /**
- * Create a Message instance for sending a simple text messages with default
- * (text/plain) content type and encoding.
- *
- * @param messageText
- * the string content of the message.
- * @return Message the newly created message
- */
- public Message createMessage(String messageText)
- {
- Message msg = new MessageYahooImpl(messageText,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_ENCODING, null);
- return msg;
- }
-
- /**
- * Returns a <tt>List</tt> of <tt>Contact</tt>s corresponding to all members
- * currently participating in this room.
- *
- * @return a <tt>List</tt> of <tt>Contact</tt> corresponding to all room
- * members.
- */
- public List<Contact> getParticipants()
- {
- return new LinkedList<Contact>(participants.values());
- }
-
- /**
- * Updates the member list of the chat room.
- *
- */
- public void updateParticipantsList()
- {
- Iterator<?> it = yahooConference.getMembers().iterator();
-
- while (it.hasNext())
- {
- YahooUser user = (YahooUser) it.next();
- Contact contact;
- OperationSetPersistentPresenceYahooImpl presenceOpSet
- = (OperationSetPersistentPresenceYahooImpl) this
- .getParentProvider().getOperationSet(
- OperationSetPersistentPresence.class);
-
- contact = presenceOpSet.findContactByID(user.getId());
-
- if(!participants.containsKey(contact.getDisplayName()))
- {
- participants.put(contact.getDisplayName(), contact);
- }
- }
- }
-
- /**
- * Returns the identifier of this <tt>AdHocChatRoom</tt>.
- *
- * @return a <tt>String</tt> containing the identifier of this
- * <tt>AdHocChatRoom</tt>.
- */
- public String getIdentifier()
- {
- return yahooConference.getName();
- }
-
- /**
- * Returns the number of participants that are currently in this ad-hoc chat
- * room.
- *
- * @return the number of <tt>Contact</tt>s, currently participating in
- * this ad-hoc room.
- */
- public int getParticipantsCount()
- {
- return yahooConference.getMembers().size();
- }
-
- /**
- * Returns the name of this <tt>AdHocChatRoom</tt>.
- *
- * @return a <tt>String</tt> containing the name of this
- * <tt>AdHocChatRoom</tt>.
- */
- public String getName()
- {
- return yahooConference.getName();
- }
-
- /**
- * Returns the protocol provider service that created us.
- *
- * @return the protocol provider service that created us.
- */
- public ProtocolProviderService getParentProvider()
- {
- return provider;
- }
-
- /**
- * Returns the local user's nickname in the context of this chat room or
- * <tt>null</tt> if not currently joined.
- *
- * @return the nickname currently being used by the local user in the
- * context of the local ad-hoc chat room.
- */
-
- public String getUserNickname()
- {
- if(nickname == null)
- nickname = provider.getYahooSession().getLoginIdentity().getId();
-
- return nickname;
- }
-
- /**
- * Invites another user to this room. If we're not joined nothing will
- * happen.
- *
- * @param userAddress The identifier of the contact (email address or yahoo
- * id)
- * @param reason The invite reason, which is send to the invitee.
- */
- public void invite(String userAddress, String reason)
- {
- try
- {
- provider.getYahooSession().extendConference(yahooConference,
- userAddress, reason);
- }
- catch (IOException ioe)
- {
- if (logger.isDebugEnabled())
- logger.debug("Failed to invite the user: " + userAddress
- + " Error: " + ioe);
- }
- }
-
- /**
- * Indicates whether or not this chat room is corresponding to a server
- * channel. Note: Returns always <code>false</code>.
- *
- * @return Always <code>false</code> since system chat room can't be joined
- * with current yahoo library.
- */
- public boolean isSystem()
- {
- return false;
- }
-
- /**
- * Joins this chat room with the nickname of the local user so that the user
- * would start receiving events and messages for it.
- *
- * @throws OperationFailedException with the corresponding code if an error
- * occurs while joining the room.
- */
- public void join() throws OperationFailedException
- {
- this.nickname = provider.getAccountID().getUserID();
- try
- {
- provider.getYahooSession().acceptConferenceInvite(yahooConference);
-
- // We don't specify a reason.
- opSetMuc.fireLocalUserPresenceEvent(this,
- LocalUserAdHocChatRoomPresenceChangeEvent.LOCAL_USER_JOINED,
- null);
- }
- catch (Exception e)
- {
- if (logger.isDebugEnabled())
- logger.debug("Couldn't join the chat room: "
- + yahooConference.getName() + e);
- }
- }
-
- /**
- * Leave this chat room. Once this method is called, the user won't be
- * listed as a member of the chat room any more and no further chat events
- * will be delivered. Depending on the underlying protocol and
- * implementation leave() might cause the room to be destroyed if it has
- * been created by the local user.
- */
- public void leave()
- {
- try
- {
- provider.getYahooSession().leaveConference(yahooConference);
-
- Iterator< Map.Entry<String, Contact>> membersSet
- = participants.entrySet().iterator();
-
- while (membersSet.hasNext())
- {
- Map.Entry<String, Contact> memberEntry = membersSet.next();
- Contact participant = memberEntry.getValue();
-
- fireParticipantPresenceEvent(participant,
- AdHocChatRoomParticipantPresenceChangeEvent.CONTACT_LEFT,
- "Local user has left the chat room.");
- }
- }
- catch (IOException ioe)
- {
- if (logger.isDebugEnabled())
- logger.debug("Failed to leave the chat room: "
- + yahooConference.getName() + " Error: " + ioe);
- }
-
- participants.clear();
- }
-
- /**
- * Sends the <tt>message</tt> to the destination indicated by the
- * <tt>to</tt> contact.
- *
- * @param message The <tt>Message</tt> to send.
- * @throws OperationFailedException if the underlying stack is not
- * registered or initialized or if the chat room is not joined.
- */
- public void sendMessage(Message message) throws OperationFailedException
- {
- assertConnected();
-
- try
- {
- provider.getYahooSession().sendConferenceMessage(yahooConference,
- message.getContent());
-
- AdHocChatRoomMessageDeliveredEvent msgDeliveredEvt
- = new AdHocChatRoomMessageDeliveredEvent(
- this,
- new Date(),
- message,
- ChatRoomMessageDeliveredEvent.CONVERSATION_MESSAGE_DELIVERED);
-
- fireMessageEvent(msgDeliveredEvt);
- }
- catch (Exception e)
- {
- if (logger.isDebugEnabled())
- logger.debug("Failed to send a conference message.");
- }
- }
-
- /**
- * Notifies all interested listeners that a
- * <tt>AdHocChatRoomMessageDeliveredEvent</tt>,
- * <tt>AdHocChatRoomMessageReceivedEvent</tt> or a
- * <tt>AdHocChatRoomMessageDeliveryFailedEvent</tt> has been fired.
- * @param evt The specific event
- */
- public void fireMessageEvent(EventObject evt)
- {
- Iterator<AdHocChatRoomMessageListener> listeners = null;
- synchronized (messageListeners)
- {
- listeners = new ArrayList<AdHocChatRoomMessageListener>(
- messageListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- AdHocChatRoomMessageListener listener = listeners.next();
-
- if (evt instanceof AdHocChatRoomMessageDeliveredEvent)
- {
- listener.messageDelivered(
- (AdHocChatRoomMessageDeliveredEvent) evt);
- }
- else if (evt instanceof AdHocChatRoomMessageReceivedEvent)
- {
- listener.messageReceived(
- (AdHocChatRoomMessageReceivedEvent) evt);
- }
- else if (evt instanceof AdHocChatRoomMessageDeliveryFailedEvent)
- {
- listener.messageDeliveryFailed(
- (AdHocChatRoomMessageDeliveryFailedEvent) evt);
- }
- }
- }
-
- /**
- * Creates the corresponding AdHocChatRoomParticipantPresenceChangeEvent and
- * notifies all <tt>AdHocChatRoomParticipantPresenceListener</tt>s that a
- * Contact has joined or left this <tt>AdHocChatRoom</tt>.
- *
- * @param participant the <tt>Contact</tt> that this
- * @param eventID the identifier of the event
- * @param eventReason the reason of the event
- */
- public void fireParticipantPresenceEvent(Contact participant, String eventID,
- String eventReason)
- {
- AdHocChatRoomParticipantPresenceChangeEvent evt
- = new AdHocChatRoomParticipantPresenceChangeEvent(this,
- participant,
- eventID,
- eventReason);
-
- if (logger.isTraceEnabled())
- logger.trace("Will dispatch the following ChatRoom event: " + evt);
-
- Iterator<AdHocChatRoomParticipantPresenceListener> listeners = null;
- synchronized (memberListeners)
- {
- listeners = new ArrayList<AdHocChatRoomParticipantPresenceListener>
- (memberListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- AdHocChatRoomParticipantPresenceListener listener = listeners.next();
-
- listener.participantPresenceChanged(evt);
- }
- }
-
- /**
- * Finds the participant of this ad-hoc chat room corresponding to the
- * given address.
- *
- * @param address the address to search for.
- * @return the participant of this chat room corresponding to the given
- * nick name.
- */
- public Contact findParticipantForAddress(String address)
- {
- Iterator<Contact> participantsIter
- = this.participants.values().iterator();
-
- while (participantsIter.hasNext())
- {
- Contact contact = participantsIter.next();
-
- if (contact.getAddress().equals(address))
- {
- return contact;
- }
- }
-
- return null;
- }
-
- /**
- * Removes the specified ad-hoc chat room participant from the participants
- * list of this ad-hoc chat room.
- * @param participant The member, who should be removed from the ad-hoc chat room
- * participants list.
- */
- public void removeChatRoomParticipant(Contact participant)
- {
- if(participant == null)
- return;
-
- participants.remove(participant.getDisplayName());
-
- fireParticipantPresenceEvent(participant,
- AdHocChatRoomParticipantPresenceChangeEvent.CONTACT_LEFT, null);
- }
-
- /**
- * Adds a participant to the ad-hoc chat room participant list.
- * @param participant The participant, who should be added to the ad-hoc
- * chat room participant list.
- */
- public void addChatRoomParticipant(Contact participant)
- {
- if (participant == null)
- return;
-
- if (!participants.containsKey(participant.getDisplayName()))
- {
- participants.put(participant.getDisplayName(), participant);
-
- fireParticipantPresenceEvent(participant,
- AdHocChatRoomParticipantPresenceChangeEvent.CONTACT_JOINED,
- null);
- }
- }
-
- /**
- * Returns the yahoo conference model of this chat room.
- * @return The yahoo conference.
- */
- public YahooConference getYahooConference()
- {
- return yahooConference;
- }
-
- /**
- * Utility method throwing an exception if the stack is not properly
- * initialized.
- * @throws java.lang.IllegalStateException if the underlying stack is
- * not registered and initialized.
- */
- private void assertConnected() throws IllegalStateException
- {
- if (provider == null)
- throw new IllegalStateException(
- "The provider must be non-null and signed on the "
- +"service before being able to communicate.");
- if (!provider.isRegistered())
- throw new IllegalStateException(
- "The provider must be signed on the service before "
- +"being able to communicate.");
- }
-
- /**
- * Determines whether this chat room should be stored in the configuration
- * file or not. If the chat room is persistent it still will be shown after a
- * restart in the chat room list. A non-persistent chat room will be only in
- * the chat room list until the the program is running.
- *
- * @return true if this chat room is persistent, false otherwise
- */
- public boolean isPersistent()
- {
- return false;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ContactGroupYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ContactGroupYahooImpl.java
deleted file mode 100644
index 1f73aac..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/ContactGroupYahooImpl.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import ymsg.network.*;
-
-/**
- * The Yahoo implementation of the ContactGroup interface. Intances of this class
- * (contrary to <tt>RootContactGroupYahooImpl</tt>) may only contain buddies
- * and cannot have sub groups. Note that instances of this class only use the
- * corresponding smack source group for reading their names and only
- * initially fill their <tt>buddies</tt> <tt>java.util.List</tt> with
- * the ContactYahooImpl objects corresponding to those contained in the source
- * group at the moment it is being created. They would, however, never try to
- * sync or update their contents ulteriorly. This would have to be done through
- * the addContact()/removeContact() methods.
- * The content of buddies is created on creating of the group and when the smack
- * source group is changed.
- *
- * @author Damian Minkov
- * @author Emil Ivov
- */
-public class ContactGroupYahooImpl
- extends AbstractContactGroupYahooImpl
-{
- private final Map<String, Contact> buddies
- = new Hashtable<String, Contact>();
-
- private boolean isResolved = false;
-
- /**
- * The Yahoo Group corresponding to this contact group.
- */
- private YahooGroup yahooGroup = null;
-
- /**
- * a list that would always remain empty. We only use it so that we're able
- * to extract empty iterators
- */
- private final List<ContactGroup> dummyGroupsList
- = new LinkedList<ContactGroup>();
-
- private String tempId = null;
-
- private final ServerStoredContactListYahooImpl ssclCallback;
-
- /**
- * Creates an Yahoo group using the specified <tt>YahooGroup</tt> as
- * a source. The newly created group will always return the name of the
- * underlying RosterGroup and would thus automatically adapt to changes.
- * It would, however, not receive or try to poll for modifications of the
- * buddies it contains and would therefore have to be updated manually by
- * ServerStoredContactListImpl update will only be done if source group
- * is changed.
-
- * @param yahooGroup the Yahoo Group correspoinding to the group
- * @param groupMembers the group members that we should add to the group.
- * @param ssclCallback a callback to the server stored contact list
- * we're creating.
- * @param isResolved a boolean indicating whether or not the group has been
- * resolved against the server.
- */
- ContactGroupYahooImpl(
- YahooGroup yahooGroup,
- Vector<YahooUser> groupMembers,
- ServerStoredContactListYahooImpl ssclCallback,
- boolean isResolved)
- {
- this.yahooGroup = yahooGroup;
- this.isResolved = isResolved;
- this.ssclCallback = ssclCallback;
-
- for (YahooUser yahooUser : groupMembers)
- {
- //only add the contact if it doesn't already exist in some other
- //group. this would be necessary if Yahoo! one day start allowing
- //the same contact in more than one group, which is not quite
- //unlikely since most of the other protocols do it.
- if(ssclCallback.findContactByYahooUser(yahooUser) != null)
- {
- continue;
- }
-
-
- addContact(
- new ContactYahooImpl(yahooUser,ssclCallback, true, true));
- }
- }
-
- ContactGroupYahooImpl( String id,
- ServerStoredContactListYahooImpl ssclCallback)
- {
- this.tempId = id;
- this.isResolved = false;
- this.ssclCallback = ssclCallback;
- }
-
-
- /**
- * Returns the number of <tt>Contact</tt> members of this
- * <tt>ContactGroup</tt>
- *
- * @return an int indicating the number of <tt>Contact</tt>s,
- * members of this <tt>ContactGroup</tt>.
- */
- public int countContacts()
- {
- return buddies.size();
- }
-
- /**
- * Returns a reference to the root group which in Yahoo is the parent of
- * any other group since the protocol does not support subgroups.
- * @return a reference to the root group.
- */
- public ContactGroup getParentContactGroup()
- {
- return ssclCallback.getRootGroup();
- }
-
- /**
- * Adds the specified contact to the end of this group.
- * @param contact the new contact to add to this group
- */
- void addContact(ContactYahooImpl contact)
- {
- buddies.put(contact.getAddress().toLowerCase(), contact);
- }
-
-
- /**
- * Removes the specified contact from this contact group
- * @param contact the contact to remove.
- */
- void removeContact(ContactYahooImpl contact)
- {
- buddies.remove(contact.getAddress().toLowerCase());
- }
-
- /**
- * Returns an Iterator over all contacts, member of this
- * <tt>ContactGroup</tt>.
- *
- * @return a java.util.Iterator over all contacts inside this
- * <tt>ContactGroup</tt>. In case the group doesn't contain any
- * memebers it will return an empty iterator.
- */
- public Iterator<Contact> contacts()
- {
- return buddies.values().iterator();
- }
-
- /**
- * Returns the <tt>Contact</tt> with the specified address or
- * identifier.
- * @param id the addres or identifier of the <tt>Contact</tt> we are
- * looking for.
- * @return the <tt>Contact</tt> with the specified id or address.
- */
- public Contact getContact(String id)
- {
- return this.findContact(id);
- }
-
- /**
- * Returns the name of this group.
- * @return a String containing the name of this group.
- */
- public String getGroupName()
- {
- if(isResolved)
- return ServerStoredContactListYahooImpl
- .replaceIllegalChars(yahooGroup.getName());
- else
- return tempId;
- }
-
- /**
- * Determines whether the group may contain subgroups or not.
- *
- * @return always false since only the root group may contain subgroups.
- */
- public boolean canContainSubgroups()
- {
- return false;
- }
-
- /**
- * Returns the subgroup with the specified index (i.e. always null since
- * this group may not contain subgroups).
- *
- * @param index the index of the <tt>ContactGroup</tt> to retrieve.
- * @return always null
- */
- public ContactGroup getGroup(int index)
- {
- return null;
- }
-
- /**
- * Returns the subgroup with the specified name.
- * @param groupName the name of the <tt>ContactGroup</tt> to retrieve.
- * @return the <tt>ContactGroup</tt> with the specified index.
- */
- public ContactGroup getGroup(String groupName)
- {
- return null;
- }
-
- /**
- * Returns an empty iterator. Subgroups may only be present in the root
- * group.
- *
- * @return an empty iterator
- */
- public Iterator<ContactGroup> subgroups()
- {
- return dummyGroupsList.iterator();
- }
-
- /**
- * Returns the number of subgroups contained by this group, which is
- * always 0 since sub groups in the protocol may only be contained
- * by the root group - <tt>RootContactGroupImpl</tt>.
- * @return a 0 int.
- */
- public int countSubgroups()
- {
- return 0;
- }
-
- /**
- * Returns a hash code value for the object, which is actually the hashcode
- * value of the groupname.
- *
- * @return a hash code value for this ContactGroup.
- */
- @Override
- public int hashCode()
- {
- return getGroupName().hashCode();
- }
-
- /**
- * Indicates whether some other object is "equal to" this group.
- *
- * @param obj the reference object with which to compare.
- * @return <tt>true</tt> if this object is the same as the obj
- * argument; <tt>false</tt> otherwise.
- */
- @Override
- public boolean equals(Object obj)
- {
- if( obj == this )
- return true;
-
- if (obj == null
- || !(obj instanceof ContactGroupYahooImpl) )
- return false;
-
- if(!((ContactGroup)obj).getGroupName().equals(getGroupName()))
- return false;
-
- if(getProtocolProvider() != ((ContactGroup)obj).getProtocolProvider())
- return false;
-
- //since Yahoo does not support having two groups with the same name
- // at this point we could bravely state that the groups are the same
- // and not bother to compare buddies. (gotta check that though)
- return true;
- }
-
- /**
- * Returns the protocol provider that this group belongs to.
- * @return a reference to the ProtocolProviderService instance that this
- * ContactGroup belongs to.
- */
- public ProtocolProviderService getProtocolProvider()
- {
- return this.ssclCallback.getParentProvider();
- }
-
- /**
- * Returns a string representation of this group, in the form
- * YahooGroup.GroupName[size]{ buddy1.toString(), buddy2.toString(), ...}.
- * @return a String representation of the object.
- */
- @Override
- public String toString()
- {
- StringBuffer buff = new StringBuffer("YahooGroup.");
- buff.append(getGroupName());
- buff.append(", childContacts="+countContacts()+":[");
-
- Iterator<Contact> contacts = contacts();
- while (contacts.hasNext())
- {
- Contact contact = contacts.next();
- buff.append(contact.toString());
- if(contacts.hasNext())
- buff.append(", ");
- }
- return buff.append("]").toString();
- }
-
- /**
- * Returns the contact encapsulating with the spcieified name or
- * null if no such contact was found.
- *
- * @param id the id for the contact we're looking for.
- * @return the <tt>ContactYahooImpl</tt> corresponding to the specified
- * screnname or null if no such contact existed.
- */
- ContactYahooImpl findContact(String id)
- {
- if(id == null)
- return null;
- return (ContactYahooImpl)buddies.get(id.toLowerCase());
- }
-
- /**
- * Determines whether or not this contact group is being stored by the
- * server. Non persistent contact groups exist for the sole purpose of
- * containing non persistent contacts.
- * @return true if the contact group is persistent and false otherwise.
- */
- public boolean isPersistent()
- {
- return true;
- }
-
- /**
- * Returns null as no persistent data is required and the contact address is
- * sufficient for restoring the contact.
- * <p>
- * @return null as no such data is needed.
- */
- public String getPersistentData()
- {
- return null;
- }
-
- /**
- * Determines whether or not this contact group has been resolved against
- * the server. Unresolved group are used when initially loading a contact
- * list that has been stored in a local file until the presence operation
- * set has managed to retrieve all the contact list from the server and has
- * properly mapped contacts and groups to their corresponding on-line
- * buddies.
- * @return true if the contact has been resolved (mapped against a buddy)
- * and false otherwise.
- */
- public boolean isResolved()
- {
- return isResolved;
- }
-
- /**
- * Resolve this contact group against the specified group
- * @param yahooGroup the server stored group
- */
- @SuppressWarnings("unchecked") //jymsg legacy code
- void setResolved(YahooGroup yahooGroup)
- {
- if(isResolved)
- return;
-
- this.isResolved = true;
-
- this.yahooGroup = yahooGroup;
-
- Vector<YahooUser> contacts = yahooGroup.getMembers();
- for (YahooUser item : contacts)
- {
- ContactYahooImpl contact =
- ssclCallback.findContactById(item.getId());
- if(contact != null)
- {
- contact.setResolved(item);
-
- ssclCallback.fireContactResolved(this, contact);
- }
- else
- {
- ContactYahooImpl newContact =
- new ContactYahooImpl(item, ssclCallback, true, true);
- addContact(newContact);
-
- ssclCallback.fireContactAdded(this, newContact);
- }
- }
- }
-
- /**
- * Returns a <tt>String</tt> that uniquely represnets the group. In this we
- * use the name of the group as an identifier. This may cause problems
- * though, in clase the name is changed by some other application between
- * consecutive runs of the sip-communicator.
- *
- * @return a String representing this group in a unique and persistent
- * way.
- */
- public String getUID()
- {
- return getGroupName();
- }
-
- /**
- * The source group we are encapsulating
- * @return YahooGroup
- */
- YahooGroup getSourceGroup()
- {
- return yahooGroup;
- }
-
- /**
- * Change the source group
- * change the buddies
- *
- * @param newGroup YahooGroup
- */
- void setSourceGroup(YahooGroup newGroup)
- {
- this.yahooGroup = newGroup;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ContactYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ContactYahooImpl.java
deleted file mode 100644
index b23ee3d..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/ContactYahooImpl.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.yahooconstants.*;
-import net.java.sip.communicator.util.*;
-import ymsg.network.*;
-
-/**
- * The Yahoo implementation of the service.protocol.Contact interface.
- * @author Damian Minkov
- * @author Emil Ivov
- */
-public class ContactYahooImpl
- extends AbstractContact
-{
- private static final Logger logger =
- Logger.getLogger(ContactYahooImpl.class);
-
- private YahooUser contact = null;
- private byte[] image = null;
- private PresenceStatus status = YahooStatusEnum.OFFLINE;
- private ServerStoredContactListYahooImpl ssclCallback = null;
- private boolean isPersistent = false;
- private boolean isResolved = false;
- private boolean isVolatile = false;
-
- private String yahooID = null;
- private String id = null;
-
- private String statusMessage = null;
-
- /**
- * Creates an YahooContactImpl with custom yahooID
- * @param yahooID sets the contact Id if its different from the YahooUser id
- * @param contact the contact object that we will be encapsulating.
- * @param ssclCallback a reference to the ServerStoredContactListImpl
- * instance that created us.
- * @param isPersistent determines whether this contact is persistent or not.
- * @param isResolved specifies whether the contact has been resolved against
- * the server contact list
- */
- ContactYahooImpl(
- String yahooID,
- YahooUser contact,
- ServerStoredContactListYahooImpl ssclCallback,
- boolean isPersistent,
- boolean isResolved)
- {
- this.yahooID = yahooID;
-
- this.contact = contact;
- this.ssclCallback = ssclCallback;
- this.isPersistent = isPersistent;
- this.isResolved = isResolved;
-
- if(contact != null)
- id = contact.getId();
- else if(yahooID != null)
- id = YahooSession.getYahooUserID(yahooID);
- }
-
- /**
- * Creates an YahooContactImpl
- * @param contact the contact object that we will be encapsulating.
- * @param ssclCallback a reference to the ServerStoredContactListImpl
- * instance that created us.
- * @param isPersistent determines whether this contact is persistent or not.
- * @param isResolved specifies whether the contact has been resolved against
- * the server contact list
- */
- ContactYahooImpl(
- YahooUser contact,
- ServerStoredContactListYahooImpl ssclCallback,
- boolean isPersistent,
- boolean isResolved)
- {
- this(null, contact, ssclCallback, isPersistent, isResolved);
- }
-
- /**
- * Creates volatile or unresolved contact
- */
- ContactYahooImpl(
- String id,
- ServerStoredContactListYahooImpl ssclCallback,
- boolean isResolved,
- boolean isPersistent,
- boolean isVolatile)
- {
- this.yahooID = id;
- this.ssclCallback = ssclCallback;
- this.isPersistent = isPersistent;
- this.isResolved = isResolved;
- this.isVolatile = isVolatile;
-
- if(id != null)
- this.id = YahooSession.getYahooUserID(yahooID);
- }
-
- /**
- * Returns the Yahoo Userid of this contact
- * @return the Yahoo Userid of this contact
- */
- public String getAddress()
- {
- // if the contact is volatile or with custom id return it
- if(yahooID != null)
- return yahooID;
- // otherwise return the supplied contact id
- else
- return contact.getId();
- }
-
- /**
- * Returns the custom yahooID if set
- */
- String getYahooID()
- {
- return yahooID;
- }
-
- /**
- * Returns the contact Id.
- * If contact missing the yahooID without @yahoo.com part is returned
- */
- String getID()
- {
- return id;
- }
-
- /**
- * Returns whether the contact is volatile.
- */
- boolean isVolatile()
- {
- return isVolatile;
- }
-
- /**
- * Returns an avatar if one is already present or <tt>null</tt> in case it
- * is not in which case it the method also queues the contact for image
- * updates.
- *
- * @return the avatar of this contact or <tt>null</tt> if no avatar is
- * currently available.
- */
- public byte[] getImage()
- {
- return getImage(true);
- }
-
- /**
- * Returns a reference to the image assigned to this contact. If no image
- * is present and the retrieveIfNecessary flag is true, we schedule the
- * image for retrieval from the server.
- *
- * @param retrieveIfNecessary specifies whether the method should queue
- * this contact for avatar update from the server.
- *
- * @return a reference to the image currently stored by this contact.
- */
- public byte[] getImage(boolean retrieveIfNecessary)
- {
- try
- {
- if(retrieveIfNecessary)
- {
- if(ssclCallback.getParentProvider() == null
- || !ssclCallback.getParentProvider().isRegistered())
- {
- throw new IllegalStateException(
- "The provider must be signed on the service before "
- +"being able to communicate.");
- }
-
- YahooSession ses = ssclCallback.getParentProvider().
- getYahooSession();
- if(image == null && ses != null)
- ses.requestPicture(id);
- }
- }
- catch (Exception e)
- {
- if (logger.isInfoEnabled())
- logger.info("Error requesting image!", e);
- }
-
- if(logger.isDebugEnabled())
- logger.debug("returning picture " + image);
-
- return image;
- }
-
- /**
- * Used to set the image of the contact if it is updated
- *
- * @param image a photo/avatar associated with this contact.
- */
- protected void setImage(byte[] image)
- {
- if (logger.isInfoEnabled())
- logger.info("setting image " + image);
-
- this.image = image;
- }
-
- /**
- * Returns a string representation of this contact, containing most of its
- * representative details.
- *
- * @return a string representation of this contact.
- */
- @Override
- public String toString()
- {
- StringBuffer buff = new StringBuffer("YahooContact[ id=");
- buff.append(getAddress()).append("]");
-
- return buff.toString();
- }
-
- /**
- * Sets the status that this contact is currently in. The method is to
- * only be called as a result of a status update received from the server.
- *
- * @param status the YahooStatusEnum that this contact is currently in.
- */
- void updatePresenceStatus(PresenceStatus status)
- {
- this.status = status;
- }
-
- /**
- * Returns the status of the contact as per the last status update we've
- * received for it. Note that this method is not to perform any network
- * operations and will simply return the status received in the last
- * status update message. If you want a reliable way of retrieving someone's
- * status, you should use the <tt>queryContactStatus()</tt> method in
- * <tt>OperationSetPresence</tt>.
- * @return the PresenceStatus that we've received in the last status update
- * pertaining to this contact.
- */
- public PresenceStatus getPresenceStatus()
- {
- return status;
- }
-
- /**
- * Returns a String that could be used by any user interacting modules for
- * referring to this contact. An alias is not necessarily unique but is
- * often more human readable than an address (or id).
- * @return a String that can be used for referring to this contact when
- * interacting with the user.
- */
- public String getDisplayName()
- {
- return getAddress();
- }
-
- /**
- * Returns a reference to the contact group that this contact is currently
- * a child of or null if the underlying protocol does not suppord persistent
- * presence.
- * @return a reference to the contact group that this contact is currently
- * a child of or null if the underlying protocol does not suppord persistent
- * presence.
- */
- public ContactGroup getParentContactGroup()
- {
- return ssclCallback.findContactGroup(this);
- }
-
-
- /**
- * Returns a reference to the protocol provider that created the contact.
- * @return a refererence to an instance of the ProtocolProviderService
- */
- public ProtocolProviderService getProtocolProvider()
- {
- return ssclCallback.getParentProvider();
- }
-
- /**
- * Determines whether or not this contact is being stored by the server.
- * Non persistent contacts are common in the case of simple, non-persistent
- * presence operation sets. They could however also be seen in persistent
- * presence operation sets when for example we have received an event
- * from someone not on our contact list. Non persistent contacts are
- * volatile even when coming from a persistent presence op. set. They would
- * only exist until the application is closed and will not be there next
- * time it is loaded.
- * @return true if the contact is persistent and false otherwise.
- */
- public boolean isPersistent()
- {
- return isPersistent;
- }
-
- /**
- * Specifies whether this contact is to be considered persistent or not. The
- * method is to be used _only_ when a non-persistent contact has been added
- * to the contact list and its encapsulated VolatileBuddy has been repalced
- * with a standard buddy.
- * @param persistent true if the buddy is to be considered persistent and
- * false for volatile.
- */
- void setPersistent(boolean persistent)
- {
- this.isPersistent = persistent;
- }
-
- /**
- * Resolve this contact against the given entry
- * @param entry the server stored entry
- */
- void setResolved(YahooUser entry)
- {
- if(isResolved)
- return;
-
- this.isResolved = true;
- contact = entry;
- isVolatile = false;
- }
-
- /**
- * Returns the persistent data
- * @return the persistent data
- */
- public String getPersistentData()
- {
- return null;
- }
-
- /**
- * Determines whether or not this contact has been resolved against the
- * server. Unresolved contacts are used when initially loading a contact
- * list that has been stored in a local file until the presence operation
- * set has managed to retrieve all the contact list from the server and has
- * properly mapped contacts to their on-line buddies.
- * @return true if the contact has been resolved (mapped against a buddy)
- * and false otherwise.
- */
- public boolean isResolved()
- {
- return isResolved;
- }
-
- public void setPersistentData(String persistentData)
- {
- }
-
- /**
- * Get source contact
- * @return YahooContact
- */
- YahooUser getSourceContact()
- {
- return contact;
- }
-
- /**
- * Return the current status message of this contact.
- *
- * @return the current status message
- */
- public String getStatusMessage()
- {
- return statusMessage;
- }
-
- /**
- * Sets the current status message for this contact
- * @param statusMessage the message
- */
- protected void setStatusMessage(String statusMessage)
- {
- this.statusMessage = statusMessage;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/FileTransferImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/FileTransferImpl.java
deleted file mode 100644
index 3f42079..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/FileTransferImpl.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.io.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The Filetransfer imeplementation for yahoo.
- * @author Damian Minkov
- */
-public class FileTransferImpl
- extends AbstractFileTransfer
-
-{
- private ProtocolProviderServiceYahooImpl yahooProvider;
- private String id = null;
- private Contact contact = null;
- private File file = null;
- private int direction = -1;
- private long transferedBytes;
-
- public FileTransferImpl(ProtocolProviderServiceYahooImpl yahooProvider,
- String id, Contact contact, File file, int direction)
- {
- this.yahooProvider = yahooProvider;
- this.id = id;
- this.contact = contact;
- this.file = file;
- this.direction = direction;
- }
-
- /**
- * Cancels this file transfer. When this method is called transfer should
- * be interrupted.
- */
- @Override
- public void cancel()
- {
- yahooProvider.getYahooSession().cancelRunningFileTransfer(id);
- }
-
- /**
- * Returns the number of bytes already transfered through this file transfer.
- *
- * @return the number of bytes already transfered through this file transfer
- */
- @Override
- public long getTransferedBytes()
- {
- return transferedBytes;
- }
-
- /**
- * Uniquie ID that is identifying the FileTransfer
- * if the request has been accepted.
- *
- * @return the id.
- */
- public String getID()
- {
- return id;
- }
-
- /**
- * The file transfer direction.
- * @return returns the direction of the file transfer : IN or OUT.
- */
- public int getDirection()
- {
- return direction;
- }
-
- /**
- * Returns the file that is transfered.
- *
- * @return the file
- */
- public File getLocalFile()
- {
- return file;
- }
-
- /**
- * Returns the contact that we are transfering files with.
- * @return the contact.
- */
- public Contact getContact()
- {
- return contact;
- }
-
- /**
- * @param transferedBytes the transferedBytes to set
- */
- public void setTransferedBytes(long transferedBytes)
- {
- this.transferedBytes = transferedBytes;
- }
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/IncomingFileTransferRequestYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/IncomingFileTransferRequestYahooImpl.java
deleted file mode 100644
index 25561d0..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/IncomingFileTransferRequestYahooImpl.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-
-/**
- * Implementation of the incoming file transfer request.
- *
- * @author Damian Minkov
- */
-public class IncomingFileTransferRequestYahooImpl
- implements IncomingFileTransferRequest
-{
- private String id;
-
- /**
- * The yahoo provider.
- */
- private ProtocolProviderServiceYahooImpl yahooProvider;
-
- private final OperationSetFileTransferYahooImpl fileTransferOpSet;
-
- private Contact sender;
-
- private Date date;
-
- private String fileName;
-
- private long fileSize;
-
- public IncomingFileTransferRequestYahooImpl(
- ProtocolProviderServiceYahooImpl yahooProvider,
- OperationSetFileTransferYahooImpl fileTransferOpSet,
- Contact sender,
- Date date,
- String fileName,
- String fileSize,
- String id)
- {
- this.yahooProvider = yahooProvider;
- this.fileTransferOpSet = fileTransferOpSet;
- this.sender = sender;
- this.date = date;
- this.fileName = fileName;
-
- try
- {
- this.fileSize = Long.valueOf(fileSize);
- }
- catch (NumberFormatException e)
- {}
-
- this.id = id;
- }
-
- /**
- * Unique ID that is identifying the request and then the FileTransfer
- * if the request has been accepted.
- *
- * @return the id.
- */
- public String getID()
- {
- return id;
- }
-
- /**
- * Returns a String that represents the name of the file that is being
- * received.
- * If there is no name, returns null.
- * @return a String that represents the name of the file
- */
- public String getFileName()
- {
- return fileName;
- }
-
- /**
- * Returns a String that represents the description of the file that is
- * being received.
- * If there is no description available, returns null.
- *
- * @return a String that represents the description of the file
- */
- public String getFileDescription()
- {
- return "";
- }
-
- /**
- * Returns a long that represents the size of the file that is being
- * received.
- * If there is no file size available, returns null.
- *
- * @return a long that represents the size of the file
- */
- public long getFileSize()
- {
- return fileSize;
- }
-
- /**
- * Returns a String that represents the name of the sender of the file
- * being received.
- * If there is no sender name available, returns null.
- *
- * @return a String that represents the name of the sender
- */
- public Contact getSender()
- {
- return sender;
- }
-
- /**
- * Function called to accept and receive the file.
- *
- * @param file the file to accept
- * @return the <tt>FileTransfer</tt> object managing the transfer
- */
- public FileTransfer acceptFile(File file)
- {
- AbstractFileTransfer incomingTransfer = null;
-
- incomingTransfer =
- new FileTransferImpl(yahooProvider,
- id, sender, file, FileTransfer.IN);
-
- yahooProvider.getYahooSession().fileTransferAccept(id, file);
-
- FileTransferCreatedEvent event
- = new FileTransferCreatedEvent(incomingTransfer, new Date());
-
- fileTransferOpSet.fireFileTransferCreated(event);
-
- incomingTransfer.fireStatusChangeEvent(
- FileTransferStatusChangeEvent.PREPARING);
-
- return incomingTransfer;
- }
-
- /**
- * Function called to refuse the file.
- */
- public void rejectFile()
- {
- yahooProvider.getYahooSession().fileTransferReject(id);
-
- fileTransferOpSet.fireFileTransferRequestRejected(
- new FileTransferRequestEvent(
- fileTransferOpSet, this, this.getDate()));
- }
-
- /**
- * @return the date
- */
- public Date getDate()
- {
- return date;
- }
-
- /**
- * Returns the thumbnail contained in this request.
- *
- * @return the thumbnail contained in this request
- */
- public byte[] getThumbnail()
- {
- return null;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/MessageYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/MessageYahooImpl.java
deleted file mode 100644
index e35a3c1..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/MessageYahooImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * A simple implementation of the <tt>Message</tt> interface. Right now the
- * message only supports test contents and no binary data.
- *
- * @author Damian Minkov
- * @author Lubomir Marinov
- */
-public class MessageYahooImpl
- extends AbstractMessage
-{
-
- /**
- * Creates an instance of this Message with the specified parameters.
- *
- * @param content the text content of the message.
- * @param contentType a MIME string indicating the content type of the
- * <tt>content</tt> String.
- * @param contentEncoding a MIME String indicating the content encoding of
- * the <tt>content</tt> String.
- * @param subject the subject of the message or null for empty.
- */
- public MessageYahooImpl(String content, String contentType,
- String contentEncoding, String subject)
- {
- super(content, contentType, contentEncoding, subject);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetAdHocMultiUserChatYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetAdHocMultiUserChatYahooImpl.java
deleted file mode 100644
index dd5f73f..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetAdHocMultiUserChatYahooImpl.java
+++ /dev/null
@@ -1,714 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import ymsg.network.*;
-import ymsg.network.event.*;
-
-/**
- * A Yahoo implementation of the ad-hoc multi user chat operation set.
- *
- * @author Rupert Burchardi
- * @author Valentin Martinet
- * @author Yana Stamcheva
- */
-public class OperationSetAdHocMultiUserChatYahooImpl
-implements OperationSetAdHocMultiUserChat
-{
- private static final Logger logger =
- Logger.getLogger(OperationSetAdHocMultiUserChatYahooImpl.class);
-
- /**
- * A list of listeners subscribed for invitations multi user chat events.
- */
- private final List<AdHocChatRoomInvitationListener> invitationListeners
- = new Vector<AdHocChatRoomInvitationListener>();
-
- /**
- * A list of listeners subscribed for events indicating rejection of a multi
- * user chat invitation sent by us.
- */
- private final List<AdHocChatRoomInvitationRejectionListener>
- invitationRejectionListeners
- = new Vector<AdHocChatRoomInvitationRejectionListener>();
-
- /**
- * Listeners that will be notified of changes in our status in the room such
- * as us being kicked, banned, or granted admin permissions.
- */
- private final List<LocalUserAdHocChatRoomPresenceListener> presenceListeners
- = new Vector<LocalUserAdHocChatRoomPresenceListener>();
-
- /**
- * A list of the rooms that are currently open by this account.
- */
- private final Hashtable<String, AdHocChatRoomYahooImpl> chatRoomCache
- = new Hashtable<String, AdHocChatRoomYahooImpl>();
-
- /**
- * The currently valid Yahoo protocol provider service implementation.
- */
- private final ProtocolProviderServiceYahooImpl yahooProvider;
-
- /**
- * The operation set for the basic instant messaging, provides some message
- * format functions.
- */
- private final OperationSetBasicInstantMessagingYahooImpl opSetBasic;
-
- /**
- * Instantiates the user operation set with a currently valid instance of
- * the Yahoo protocol provider.
- *
- * @param yahooProvider a currently valid instance of
- * ProtocolProviderServiceYahooImpl.
- */
- OperationSetAdHocMultiUserChatYahooImpl(
- ProtocolProviderServiceYahooImpl yahooProvider)
- {
- this.yahooProvider = yahooProvider;
-
- yahooProvider
- .addRegistrationStateChangeListener(new RegistrationStateListener());
-
- opSetBasic =
- (OperationSetBasicInstantMessagingYahooImpl) yahooProvider
- .getOperationSet(OperationSetBasicInstantMessaging.class);
- }
-
- /**
- * Adds a listener to invitation notifications.
- *
- * @param listener An invitation listener.
- */
- public void addInvitationListener(AdHocChatRoomInvitationListener listener)
- {
- synchronized (invitationListeners)
- {
- if (!invitationListeners.contains(listener))
- invitationListeners.add(listener);
- }
- }
-
- /**
- * Removes a listener that was being notified of changes in our status in a
- * room such as us being kicked, banned or dropped.
- *
- * @param listener the <tt>LocalUserAdHocChatRoomPresenceListener</tt>.
- */
- public void removeInvitationListener(
- AdHocChatRoomInvitationListener listener)
- {
- synchronized (invitationListeners)
- {
- invitationListeners.remove(listener);
- }
- }
-
- /**
- * Subscribes <tt>listener</tt> so that it would receive events indicating
- * rejection of a multi user chat invitation that we've sent earlier.
- *
- * @param listener the listener that we'll subscribe for invitation
- * rejection events.
- */
-
- public void addInvitationRejectionListener(
- AdHocChatRoomInvitationRejectionListener listener)
- {
- synchronized (invitationRejectionListeners)
- {
- if (!invitationRejectionListeners.contains(listener))
- invitationRejectionListeners.add(listener);
- }
- }
-
- /**
- * Removes <tt>listener</tt> from the list of invitation listeners
- * registered to receive invitation rejection events.
- *
- * @param listener the invitation listener to remove.
- */
- public void removeInvitationRejectionListener(
- AdHocChatRoomInvitationRejectionListener listener)
- {
- synchronized (invitationRejectionListeners)
- {
- invitationRejectionListeners.remove(listener);
- }
- }
-
- /**
- * Adds a listener that will be notified of changes in our status in a chat
- * room such as us being kicked, banned or dropped.
- *
- * @param listener the <tt>LocalUserAdHocChatRoomPresenceListener</tt>.
- */
- public void addPresenceListener(
- LocalUserAdHocChatRoomPresenceListener listener)
- {
- synchronized (presenceListeners)
- {
- if (!presenceListeners.contains(listener))
- presenceListeners.add(listener);
- }
- }
-
- /**
- * Removes a listener that was being notified of changes in our status in a
- * room such as us being kicked, banned or dropped.
- *
- * @param listener the <tt>LocalUserChatRoomPresenceListener</tt>.
- */
- public void removePresenceListener(
- LocalUserAdHocChatRoomPresenceListener listener)
- {
- synchronized (presenceListeners)
- {
- presenceListeners.remove(listener);
- }
- }
-
- /**
- * Creates a room with the named <tt>roomName</tt> and according to the
- * specified <tt>roomProperties</tt> on the server that this protocol
- * provider is currently connected to. Note the roomProperties also contain
- * users that we like to invite to the chatRoom, this is required in the
- * yahoo protocol.
- *
- * @param roomName the name of the <tt>AdHocChatRoom</tt> to create.
- * @param roomProperties properties specifying how the room should be
- * created.
- *
- * @throws OperationFailedException if the room couldn't be created for some
- * reason (e.g. room already exists; user already joined to an
- * existent room or user has no permissions to create a chat
- * room).
- *
- * @return ChatRoom the chat room that we've just created.
- */
- public AdHocChatRoom createAdHocChatRoom(String roomName,
- Map<String, Object> roomProperties)
- throws OperationFailedException
- {
- return createAdHocChatRoom(roomName, (String[]) null, "");
- }
-
- /**
- * Creates an ad-hoc room with the named <tt>adHocRoomName</tt> and in
- * including to the specified <tt>contacts</tt>. When the method returns the
- * ad-hoc room the local user will have joined it.
- *
- * @return the ad-hoc room that has been just created
- * @param adHocRoomName the name of the room to be created
- * @param contacts the list of contacts ID
- * @param reason the reason for contacts' invitation
- * @throws OperationFailedException if the room couldn't be created for
- * some reason
- */
- public AdHocChatRoom createAdHocChatRoom( String adHocRoomName,
- List<String> contacts,
- String reason)
- throws OperationFailedException
- {
- String[] contactsToInvite = new String[contacts.size()];
- for(int i=0; i<contacts.size(); i++)
- {
- contactsToInvite[i] = contacts.get(i);
- }
- return createAdHocChatRoom(
- adHocRoomName, contactsToInvite, reason);
- }
-
- /**
- * Creates an ad-hoc room with the named <tt>adHocRoomName</tt> and in
- * including to the specified <tt>contacts</tt>. When the method returns the
- * ad-hoc room the local user will have joined it.
- *
- * @param roomName name of the chatroom
- * @param invitedContacts contacts to be invited to this room
- * @param reason reason of this invitation
- * @return AdHocChatRoom the ad-hoc room that has been just created
- * @throws OperationFailedException
- */
- private AdHocChatRoom createAdHocChatRoom(
- String roomName,
- String[] invitedContacts,
- String reason)
- throws OperationFailedException
- {
- if (invitedContacts == null)
- invitedContacts = new String[0];
-
- AdHocChatRoom chatRoom = null;
-
- try
- {
- YahooConference conference =
- yahooProvider.getYahooSession().createConference(
- invitedContacts, // users invited to this conference
- reason, // invite message / topic
- yahooProvider.getYahooSession().getLoginIdentity());
-
- chatRoom = createLocalChatRoomInstance(conference);
- }
- catch (Exception e)
- {
- String errorMessage
- = "Failed to create chat room with name: " + roomName;
-
- if (logger.isDebugEnabled())
- logger.debug(errorMessage, e);
- throw new OperationFailedException(errorMessage,
- OperationFailedException.CHAT_ROOM_NOT_JOINED, e);
- }
- chatRoom.join();
- return chatRoom;
- }
-
- /**
- * Creates a <tt>AdHocChatRoom</tt> instance from the specified Yahoo
- * conference.
- *
- * @param yahooConference The chat room model from the yahoo lib.
- *
- * @return AdHocChatRoom the chat room that we've just created.
- */
- private AdHocChatRoomYahooImpl createLocalChatRoomInstance(
- YahooConference yahooConference)
- {
- synchronized (chatRoomCache)
- {
- AdHocChatRoomYahooImpl newChatRoom
- = new AdHocChatRoomYahooImpl(yahooConference, yahooProvider);
-
- chatRoomCache.put(yahooConference.getName(), newChatRoom);
-
- return newChatRoom;
- }
- }
-
- /**
- * Creates a <tt>AdHocChatRoom</tt> instance (where the inviter is
- * represented by inviterID parameter) from the specified Yahoo conference.
- *
- * @param yahooConference The chat room model from the yahoo lib.
- * @param inviterID inviter's Yahoo ID which has to be added as room member
- *
- * @return AdHocChatRoom the chat room that we've just created.
- */
- private AdHocChatRoomYahooImpl createLocalChatRoomInstance(
- YahooConference yahooConference, String inviterID)
- {
- synchronized (chatRoomCache)
- {
- AdHocChatRoomYahooImpl newChatRoom
- = new AdHocChatRoomYahooImpl(yahooConference, yahooProvider);
-
- OperationSetPersistentPresenceYahooImpl opSetPresence =
- (OperationSetPersistentPresenceYahooImpl) yahooProvider
- .getOperationSet(OperationSetPersistentPresence.class);
-
- newChatRoom.addChatRoomParticipant(
- opSetPresence.findContactByID(inviterID));
- chatRoomCache.put(yahooConference.getName(), newChatRoom);
-
- return newChatRoom;
- }
- }
-
- /**
- * Returns the <tt>AdHocChatRoomYahooImpl</tt> corresponding to the given
- * <tt>conference</tt> if such exists, otherwise returns null.
- *
- * @param conference the <tt>YahooConference</tt>, for which we're searching
- * correspondence
- * @return the <tt>AdHocChatRoomYahooImpl</tt> corresponding to the given
- * <tt>conference</tt> if such exists, otherwise returns null
- */
- private AdHocChatRoomYahooImpl getLocalChatRoomInstance(
- YahooConference conference)
- {
- synchronized (chatRoomCache)
- {
- for (AdHocChatRoomYahooImpl chatRoom : chatRoomCache.values())
- {
- if (chatRoom.getYahooConference().equals(conference))
- return chatRoom;
- }
- }
-
- return null;
- }
-
- /**
- * Informs the sender of an invitation that we decline their invitation.
- *
- * @param invitation the connection to use for sending the rejection.
- * @param rejectReason the reason to reject the given invitation
- */
- public void rejectInvitation(AdHocChatRoomInvitation invitation,
- String rejectReason)
- {
- AdHocChatRoomYahooImpl chatRoom =
- (AdHocChatRoomYahooImpl) invitation.getTargetAdHocChatRoom();
-
- try
- {
- yahooProvider.getYahooSession().declineConferenceInvite(
- chatRoom.getYahooConference(), rejectReason);
- }
- catch (IOException e)
- {
- if (logger.isDebugEnabled())
- logger.debug("Failed to reject Invitation: " + e);
- }
- }
-
- /**
- * Delivers a <tt>AdHocChatRoomInvitationReceivedEvent</tt> to all
- * registered <tt>AdHocChatRoomInvitationListener</tt>s.
- *
- * @param targetChatRoom the room that invitation refers to
- * @param inviter the inviter that sent the invitation
- * @param reason the reason why the inviter sent the invitation
- */
- public void fireInvitationEvent(AdHocChatRoom targetChatRoom,
- String inviter, String reason)
- {
- AdHocChatRoomInvitationYahooImpl invitation =
- new AdHocChatRoomInvitationYahooImpl(targetChatRoom, inviter,
- reason);
-
- AdHocChatRoomInvitationReceivedEvent evt =
- new AdHocChatRoomInvitationReceivedEvent(this, invitation,
- new Date(System.currentTimeMillis()));
-
- Iterable<AdHocChatRoomInvitationListener> listeners;
- synchronized (invitationListeners)
- {
- listeners
- = new ArrayList<AdHocChatRoomInvitationListener>(
- invitationListeners);
- }
-
- for (AdHocChatRoomInvitationListener listener : listeners)
- listener.invitationReceived(evt);
- }
-
- /**
- * Delivers a <tt>AdHocChatRoomInvitationRejectedEvent</tt> to all
- * registered <tt>AdHocChatRoomInvitationRejectionListener</tt>s.
- *
- * @param sourceChatRoom the room that invitation refers to
- * @param invitee the name of the invitee that rejected the invitation
- * @param reason the reason of the rejection
- */
- public void fireInvitationRejectedEvent(AdHocChatRoom sourceChatRoom,
- String invitee, String reason)
- {
- AdHocChatRoomInvitationRejectedEvent evt =
- new AdHocChatRoomInvitationRejectedEvent(
- this, sourceChatRoom, invitee,
- reason, new Date(System.currentTimeMillis()));
-
- Iterable<AdHocChatRoomInvitationRejectionListener> listeners;
- synchronized (invitationRejectionListeners)
- {
- listeners
- = new ArrayList<AdHocChatRoomInvitationRejectionListener>(
- invitationRejectionListeners);
- }
-
- for (AdHocChatRoomInvitationRejectionListener listener : listeners)
- listener.invitationRejected(evt);
- }
-
- /**
- * Delivers a <tt>LocalUserAdHocChatRoomPresenceChangeEvent</tt> to all
- * registered <tt>LocalUserAdHocChatRoomPresenceListener</tt>s.
- *
- * @param chatRoom the <tt>ChatRoom</tt> which has been joined, left, etc.
- * @param eventType the type of this event; one of LOCAL_USER_JOINED,
- * LOCAL_USER_LEFT, etc.
- * @param reason the reason
- */
- public void fireLocalUserPresenceEvent(AdHocChatRoom chatRoom,
- String eventType, String reason)
- {
- LocalUserAdHocChatRoomPresenceChangeEvent evt =
- new LocalUserAdHocChatRoomPresenceChangeEvent(
- this, chatRoom, eventType,
- reason);
-
- Iterable<LocalUserAdHocChatRoomPresenceListener> listeners;
- synchronized (presenceListeners)
- {
- listeners =
- new ArrayList<LocalUserAdHocChatRoomPresenceListener>(
- presenceListeners);
- }
-
- for (LocalUserAdHocChatRoomPresenceListener listener : listeners)
- listener.localUserAdHocPresenceChanged(evt);
- }
-
- /**
- * Create a Message instance for sending arbitrary MIME-encoding content.
- *
- * @param content content value
- * @param contentType the MIME-type for <tt>content</tt>
- * @param contentEncoding encoding used for <tt>content</tt>
- * @param subject a <tt>String</tt> subject or <tt>null</tt> for now
- * subject.
- * @return the newly created message.
- * @throws UnsupportedEncodingException missing utf-8 in platform we use.
- */
- private Message createMessage(byte[] content, String contentType,
- String contentEncoding, String subject)
- throws UnsupportedEncodingException
- {
- return new MessageYahooImpl(new String(content, "UTF-8"), contentType,
- contentEncoding, subject);
- }
-
- /**
- * Creates a message by a given message text.
- *
- * @param messageText The message text.
- * @return the newly created message.
- */
- public Message createMessage(String messageText)
- {
- return new MessageYahooImpl(messageText,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_ENCODING, null);
- }
-
- /**
- * Our listener that will tell us when we're registered to yahoo network.
- *
- */
- private class RegistrationStateListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenever a
- * change in the registration state of the corresponding provider had
- * occurred.
- *
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (evt.getNewState() == RegistrationState.REGISTERED)
- {
- yahooProvider.getYahooSession().addSessionListener(
- new YahooMessageListener());
- }
- }
- }
-
- /**
- * Our group chat message listener, it extends the SessionAdapter from the
- * the Yahoo library.
- *
- */
- private class YahooMessageListener
- extends SessionAdapter
- {
-
- @Override
- public void conferenceInviteDeclinedReceived(SessionConferenceEvent ev)
- {
- if (logger.isDebugEnabled())
- logger.debug("Group Chat invite declined received. "
- + ev.toString());
- try
- {
- AdHocChatRoom chatRoom = getLocalChatRoomInstance(ev.getRoom());
-
- fireInvitationRejectedEvent(chatRoom, ev.getFrom(), ev
- .getMessage());
- }
- catch (Exception e)
- {
- if (logger.isDebugEnabled())
- logger.debug("Error: " + e);
- }
- }
-
- @Override
- public void conferenceInviteReceived(SessionConferenceEvent ev)
- {
- if (logger.isDebugEnabled())
- logger.debug("Conference Invite Received: " + ev.toString());
-
- try
- {
- AdHocChatRoom chatRoom = getLocalChatRoomInstance(ev.getRoom());
-
- if (chatRoom == null)
- {
- chatRoom =
- createLocalChatRoomInstance(ev.getRoom(), ev.getFrom());
-
- fireInvitationEvent(
- chatRoom, ev.getFrom(), ev.getMessage());
- }
-
- }
- catch (Exception e)
- {
- if (logger.isDebugEnabled())
- logger.debug("Error: " + e);
- }
- }
-
- @Override
- public void conferenceLogoffReceived(SessionConferenceEvent ev)
- {
- if (logger.isDebugEnabled())
- logger.debug("Conference Logoff Received: " + ev.toString());
-
- try
- {
- AdHocChatRoomYahooImpl chatRoom
- = getLocalChatRoomInstance(ev.getRoom());
-
- if (chatRoom != null)
- {
- Contact participant =
- chatRoom.findParticipantForAddress(ev.getFrom());
-
- chatRoom.removeChatRoomParticipant(participant);
- }
- }
- catch (Exception e)
- {
- logger
- .debug("Failed to remove a user from the chat room. " + e);
- }
- }
-
- @Override
- public void conferenceLogonReceived(SessionConferenceEvent ev)
- {
- if (logger.isDebugEnabled())
- logger.debug("Conference Logon Received: " + ev.toString());
-
- try
- {
- AdHocChatRoomYahooImpl chatRoom
- = getLocalChatRoomInstance(ev.getRoom());
-
- if (chatRoom != null)
- {
- OperationSetPersistentPresenceYahooImpl presenceOpSet =
- (OperationSetPersistentPresenceYahooImpl) chatRoom
- .getParentProvider().getOperationSet(
- OperationSetPersistentPresence.class);
-
- Contact participant =
- presenceOpSet.findContactByID(ev.getFrom());
-
- chatRoom.addChatRoomParticipant(participant);
- }
- }
- catch (Exception e)
- {
- if (logger.isDebugEnabled())
- logger.debug("Failed to add a user to the chat room. " + e);
- }
- }
-
- @Override
- public void conferenceMessageReceived(SessionConferenceEvent ev)
- {
- if (logger.isDebugEnabled())
- logger.debug("Conference Message Received: " + ev.toString());
-
- try
- {
- String formattedMessage = ev.getMessage();
- if (logger.isDebugEnabled())
- logger.debug("original message received : " + formattedMessage);
-
- formattedMessage = opSetBasic.decodeMessage(formattedMessage);
- if (logger.isDebugEnabled())
- logger.debug("formatted Message : " + formattedMessage);
- // As no indications in the protocol is it html or not. No harm
- // to set all messages html - doesn't affect the appearance of
- // the gui
-
- Message newMessage =
- createMessage(
- formattedMessage.getBytes("UTF-8"),
- OperationSetBasicInstantMessaging.HTML_MIME_TYPE,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_ENCODING,
- null);
-
- AdHocChatRoomYahooImpl chatRoom =
- getLocalChatRoomInstance(ev.getRoom());
-
- if (chatRoom != null)
- {
- Contact member =
- chatRoom.findParticipantForAddress(ev.getFrom());
-
- AdHocChatRoomMessageReceivedEvent msgReceivedEvent =
- new AdHocChatRoomMessageReceivedEvent(
- chatRoom,
- member,
- new Date(),
- newMessage,
- AdHocChatRoomMessageReceivedEvent
- .CONVERSATION_MESSAGE_RECEIVED);
-
- chatRoom.fireMessageEvent(msgReceivedEvent);
- }
- }
- catch (Exception e)
- {
- logger
- .debug("Error while receiving a multi user chat message: "
- + e);
- }
-
- }
-
- @Override
- public void connectionClosed(SessionEvent ev)
- {
- if (logger.isDebugEnabled())
- logger.debug("Connection Closed: " + ev.toString());
- }
- }
-
- public List<AdHocChatRoom> getAdHocChatRooms()
- {
- return new ArrayList<AdHocChatRoom>(chatRoomCache.values());
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetBasicInstantMessagingYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetBasicInstantMessagingYahooImpl.java
deleted file mode 100644
index 84059de..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetBasicInstantMessagingYahooImpl.java
+++ /dev/null
@@ -1,649 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.io.*;
-import java.util.*;
-import java.util.regex.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import ymsg.network.event.*;
-import ymsg.support.*;
-
-/**
- * A straightforward implementation of the basic instant messaging operation
- * set.
- *
- * @author Damian Minkov
- * @author Symphorien Wanko
- * @author Keio Kraaner
- */
-public class OperationSetBasicInstantMessagingYahooImpl
- extends AbstractOperationSetBasicInstantMessaging
- implements OperationSetInstantMessageFiltering
-{
- /**
- * Logger for this class
- */
- private static final Logger logger =
- Logger.getLogger(OperationSetBasicInstantMessagingYahooImpl.class);
-
- /**
- * Yahoo has limit of message length. If exceeded
- * message is not delivered and no notification is received for that.
- */
- private static final int MAX_MESSAGE_LENGTH = 800; // 949
-
- /**
- * A regexp that is used to escape some chars in messages.
- */
- private static final Pattern MESSAGE_CHARS_ESCAPE = Pattern.compile("([.()^&$*|])");
-
- /**
- * A list of filters registered for message events.
- */
- private final List<EventFilter> eventFilters = new ArrayList<EventFilter>();
-
- /**
- * The provider that created us.
- */
- private ProtocolProviderServiceYahooImpl yahooProvider = null;
-
- /**
- * Message decoder allows to convert Yahoo formated messages, which can
- * contains some specials characters, to HTML or to plain text.
- */
- private final MessageDecoder messageDecoder = new MessageDecoder();
-
- /**
- * A reference to the persistent presence operation set that we use
- * to match incoming messages to <tt>Contact</tt>s and vice versa.
- */
- private OperationSetPersistentPresenceYahooImpl opSetPersPresence = null;
- private static final Pattern FONT_SIZE_0_PATTERN = Pattern.compile("(<font) (.*) size=\"0\">");
- private static final Pattern FONT_SIZE_INT_PATTERN = Pattern.compile("(<font) (.*) size=\"(\\d+)\">");
-
- /**
- * Creates an instance of this operation set.
- * @param provider a ref to the <tt>ProtocolProviderServiceImpl</tt>
- * that created us and that we'll use for retrieving the underlying aim
- * connection.
- */
- OperationSetBasicInstantMessagingYahooImpl(
- ProtocolProviderServiceYahooImpl provider)
- {
- this.yahooProvider = provider;
- provider.addRegistrationStateChangeListener(
- new RegistrationStateListener());
- }
-
- /**
- * Determines wheter the protocol provider (or the protocol itself) support
- * sending and receiving offline messages. Most often this method would
- * return true for protocols that support offline messages and false for
- * those that don't. It is however possible for a protocol to support these
- * messages and yet have a particular account that does not (i.e. feature
- * not enabled on the protocol server). In cases like this it is possible
- * for this method to return true even when offline messaging is not
- * supported, and then have the sendMessage method throw an
- * OperationFailedException with code - OFFLINE_MESSAGES_NOT_SUPPORTED.
- *
- * @return <tt>true</tt> if the protocol supports offline messages and
- * <tt>false</tt> otherwise.
- */
- public boolean isOfflineMessagingSupported()
- {
- return true;
- }
-
- /**
- * Determines wheter the protocol supports the supplied content type
- *
- * @param contentType the type we want to check
- * @return <tt>true</tt> if the protocol supports it and
- * <tt>false</tt> otherwise.
- */
- public boolean isContentTypeSupported(String contentType)
- {
- if(contentType.equals(DEFAULT_MIME_TYPE) ||
- contentType.equals(HTML_MIME_TYPE))
- return true;
- else
- return false;
- }
-
- @Override
- public Message createMessage(String content, String contentType,
- String encoding, String subject)
- {
- return new MessageYahooImpl(content, contentType, encoding, subject);
- }
-
- /**
- * Sends the <tt>message</tt> to the destination indicated by the
- * <tt>to</tt> contact.
- *
- * @param to the <tt>Contact</tt> to send <tt>message</tt> to
- * @param message the <tt>Message</tt> to send.
- * @throws IllegalStateException if the underlying stack is
- * not registered and initialized.
- * @throws IllegalArgumentException if <tt>to</tt> is not an
- * instance of ContactImpl.
- */
- public void sendInstantMessage(Contact to, Message message)
- throws IllegalStateException, IllegalArgumentException
- {
- assertConnected();
-
- if( !(to instanceof ContactYahooImpl) )
- throw new IllegalArgumentException(
- "The specified contact is not a Yahoo contact."
- + to);
-
- try
- {
- String toUserID = ((ContactYahooImpl) to).getID();
-
- MessageDeliveredEvent msgDeliveryPendingEvt =
- new MessageDeliveredEvent(message, to, new Date());
-
- MessageDeliveredEvent[] msgDeliveryPendingEvts = messageDeliveryPendingTransform(msgDeliveryPendingEvt);
-
- if (msgDeliveryPendingEvts == null || msgDeliveryPendingEvts.length == 0)
- return;
-
- for (MessageDeliveredEvent event : msgDeliveryPendingEvts)
- {
- byte[] msgBytesToBeSent =
- event.getSourceMessage().getContent().trim()
- .getBytes("UTF-8");
-
- // split the message in parts with max allowed length
- // and send them all
- do
- {
- if (msgBytesToBeSent.length > MAX_MESSAGE_LENGTH)
- {
- byte[] tmp1 = new byte[MAX_MESSAGE_LENGTH];
- System.arraycopy(msgBytesToBeSent, 0, tmp1, 0,
- MAX_MESSAGE_LENGTH);
-
- byte[] tmp2 =
- new byte[msgBytesToBeSent.length
- - MAX_MESSAGE_LENGTH];
- System.arraycopy(msgBytesToBeSent, MAX_MESSAGE_LENGTH,
- tmp2, 0, tmp2.length);
-
- msgBytesToBeSent = tmp2;
-
- yahooProvider.getYahooSession().sendMessage(toUserID,
- new String(tmp1, "UTF-8"));
- }
- else
- {
- yahooProvider.getYahooSession().sendMessage(toUserID,
- new String(msgBytesToBeSent, "UTF-8"));
- }
-
- MessageDeliveredEvent msgDeliveredEvt =
- new MessageDeliveredEvent(message, to, new Date());
-
- if (msgDeliveredEvt != null)
- fireMessageEvent(msgDeliveredEvt);
- }
- while (msgBytesToBeSent.length > MAX_MESSAGE_LENGTH);
- }
- }
- catch (IOException ex)
- {
- logger.fatal("Cannot Send Message! " + ex.getMessage());
- MessageDeliveryFailedEvent evt =
- new MessageDeliveryFailedEvent(
- message,
- to,
- MessageDeliveryFailedEvent.NETWORK_FAILURE);
-
- if (evt != null)
- fireMessageEvent(evt);
- }
- }
-
- /**
- * Utility method throwing an exception if the stack is not properly
- * initialized.
- * @throws IllegalStateException if the underlying stack is
- * not registered and initialized.
- */
- private void assertConnected() throws IllegalStateException
- {
- if (yahooProvider == null)
- throw new IllegalStateException(
- "The provider must be non-null and signed on the "
- +"service before being able to communicate.");
- if (!yahooProvider.isRegistered())
- throw new IllegalStateException(
- "The provider must be signed on the service before "
- +"being able to communicate.");
- }
-
- /**
- * Our listener that will tell us when we're registered to
- */
- private class RegistrationStateListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenver
- * a change in the registration state of the corresponding provider had
- * occurred.
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (logger.isDebugEnabled())
- logger.debug("The provider changed state from: "
- + evt.getOldState()
- + " to: " + evt.getNewState());
-
- if (evt.getNewState() == RegistrationState.REGISTERED)
- {
- opSetPersPresence =
- (OperationSetPersistentPresenceYahooImpl) yahooProvider
- .getOperationSet(OperationSetPersistentPresence.class);
-
- yahooProvider.getYahooSession().
- addSessionListener(new YahooMessageListener());
- }
- }
- }
-
- /**
- * Delivers the specified event to all registered message listeners.
- * @param evt the <tt>EventObject</tt> that we'd like delivered to all
- * registered message listerners.
- */
- @Override
- protected void fireMessageEvent(EventObject evt)
- {
- // check if this event should be filtered out
- Iterator<EventFilter> filters;
- synchronized (eventFilters)
- {
- filters = new ArrayList<EventFilter>(eventFilters).iterator();
- }
- // return if a filter has filtered this event out
- boolean filtered = false;
- while (filters.hasNext())
- {
- try
- {
- if (filters.next().filterEvent(evt))
- {
- filtered = true;
- }
- }
- catch(Exception exc)
- {
- logger.error("An exception occurred while filtering an event.",
- exc);
- }
- }
-
- if (filtered)
- {
- if (logger.isTraceEnabled())
- logger.trace("Message event filtered.");
- return;
- }
-
- super.fireMessageEvent(evt);
- }
-
- /**
- * This class provides methods to listen for yahoo events which interest us.
- */
- private class YahooMessageListener
- extends SessionAdapter
- {
- /**
- * Overrides <tt>messageReceived</tt> from <tt>SessionAdapter</tt>,
- * called when we receive a new intant message.
- *
- * @param ev Event with information on the received message
- */
- @Override
- public void messageReceived(SessionEvent ev)
- {
- handleNewMessage(ev);
- }
-
- /**
- * Overrides <tt>offlineMessageReceived</tt> from <tt>SessionAdapter</tt>,
- * called when we receive a message which has been sent to us
- * when we were offline.
- *
- * @param ev Event with information on the received message
- */
- @Override
- public void offlineMessageReceived(SessionEvent ev)
- {
- handleNewMessage(ev);
- }
-
- /**
- * Overrides <tt>newMailReceived</tt> from <tt>SessionAdapter</tt>,
- * called when yahoo alert us that there is a new message in our mailbox.
- * There is two types of notification, the first one provides only
- * the number of unread mails and the second gives informations about
- * a precise new mail. Here, we care about only the second case in which
- * we should always have the email of the sender of the mail.
- *
- * @param ev Event with information on the received email
- */
- @Override
- public void newMailReceived(SessionNewMailEvent ev)
- {
- // why, if I provide mail@yahoo.FR when registering my account,
- // SC later tells me that my email address is mail@yahoo.COM ??
- // because of this users will always be sent on yahoo.com mail
- // login page rather than their usual (yahoo.XXX) login page.
- String myEmail = yahooProvider.getAccountID().getAccountAddress();
-
- // we don't process incoming email event without source address.
- // it allows us to avoid some spams
- if ((ev.getEmailAddress() == null)
- || (ev.getEmailAddress().indexOf('@') < 0))
- {
- return;
- }
-
- String yahooMailLogon = "http://mail."
- + myEmail.substring(myEmail.indexOf('@') + 1);
-
- yahooMailLogon = "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\""
- + yahooMailLogon + "\">"
- + yahooMailLogon + "</a>";
-
- // FIXME Escape HTML!
- String newMail = YahooActivator.getResources().getI18NString(
- "service.gui.NEW_MAIL",
- new String[]{ev.getFrom(),
- "&lt;" + ev.getEmailAddress() + "&gt;",
- ev.getSubject(),
- "&nbsp;&nbsp;&nbsp;&nbsp;"+yahooMailLogon}) ;
-
- Message newMailMessage = new MessageYahooImpl(
- newMail,
- HTML_MIME_TYPE,
- DEFAULT_MIME_ENCODING,
- null);
-
- Contact sourceContact = opSetPersPresence.
- findContactByID(ev.getEmailAddress());
-
- if (sourceContact == null)
- {
- if (logger.isDebugEnabled())
- logger.debug("received a new mail from an unknown contact: "
- + ev.getFrom()
- + " &lt;" + ev.getEmailAddress() + "&gt;");
- //create the volatile contact
- sourceContact = opSetPersPresence
- .createVolatileContact(ev.getEmailAddress());
- }
- MessageReceivedEvent msgReceivedEvt
- = new MessageReceivedEvent(
- newMailMessage, sourceContact, new Date(),
- MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
-
- fireMessageEvent(msgReceivedEvt);
- }
-
- /**
- * Handle incoming message by creating an appropriate Sip Communicator
- * <tt>Message</tt> and firing a <tt>MessageReceivedEvent</tt>
- * to interested listeners.
- *
- * @param ev The original <tt>SessionEvent</tt> which noticed us
- * of an incoming message.
- */
- private void handleNewMessage(SessionEvent ev)
- {
- if (logger.isDebugEnabled())
- logger.debug("Message received : " + ev);
-
- // to keep things simple, we can decodeToText()
- //String formattedMessage = processLinks(
- // messageDecoder.decodeToText(ev.getMessage()));
-
- String formattedMessage = ev.getMessage();
- if (logger.isDebugEnabled())
- logger.debug("original message received : " + formattedMessage);
-
- formattedMessage = decodeMessage(formattedMessage);
-
- if (logger.isDebugEnabled())
- logger.debug("formatted Message : " + formattedMessage);
- // As no indications in the protocol is it html or not. No harm
- // to set all messages html - doesn't affect the appearance of the
- // gui
- Message newMessage =
- createMessage(formattedMessage, HTML_MIME_TYPE,
- DEFAULT_MIME_ENCODING, null);
-
- Contact sourceContact = opSetPersPresence.
- findContactByID(ev.getFrom());
-
- if(sourceContact == null)
- {
- if (logger.isDebugEnabled())
- logger.debug("received a message from an unknown contact: "
- + ev.getFrom());
- //create the volatile contact
- sourceContact = opSetPersPresence
- .createVolatileContact(ev.getFrom());
- }
-
- MessageReceivedEvent msgReceivedEvt
- = new MessageReceivedEvent(
- newMessage, sourceContact , new Date());
-
- // msgReceivedEvt = messageReceivedTransform(msgReceivedEvt);
-
- if (msgReceivedEvt != null)
- fireMessageEvent(msgReceivedEvt);
- }
- }
-
- /**
- * Decode the received chat message.
- * If the message contains \u001b the following text is decoded by
- * the MessageDecoder of yahoo api
- * Then make http links clickable and fix the font size of html code
- *
- * @param message the chat message
- * @return a decoded message.
- */
- String decodeMessage(String message)
- {
- message = messageDecoder.decodeToHTML(message);
- message = processLinks(message);
- message =
- FONT_SIZE_0_PATTERN.matcher(message)
- .replaceAll("$1 $2 size=\"10\">");
- message =
- FONT_SIZE_INT_PATTERN.matcher(message)
- .replaceAll("$1 $2 style=\"font-size: $3px;\">");
- return message;
- }
-
- /**
- * Format links in the given message. Skips all links, which are already in
- * HTML format and converts all other links.
- *
- * @param message The source message string.
- * @return The message string with properly formatted links.
- */
- public String processLinks(String message)
- {
- StringBuffer msgBuffer = new StringBuffer();
-
- // We match two groups of Strings. The first group is the group of any
- // String. The second group is a well formatted HTML link.
- Pattern p = Pattern.compile("(.*?)(<a[\\s][^<]*(/>|</a>))",
- Pattern.CASE_INSENSITIVE);
-
- Matcher m = p.matcher(message);
-
- int lastMatchIndex = 0;
- while (m.find())
- {
- lastMatchIndex = m.end();
-
- String matchGroup1 = m.group(1);
- String matchGroup2 = m.group(2);
-
- String formattedString = formatLinksToHTML(matchGroup1);
-
- m.appendReplacement(msgBuffer,
- replaceSpecialRegExpChars(formattedString) + matchGroup2);
- }
-
- String tailString = message.substring(lastMatchIndex);
-
- String formattedTailString = formatLinksToHTML(tailString);
-
- msgBuffer.append(formattedTailString);
-
- return msgBuffer.toString();
- }
-
- /**
- * Replaces some chars that are special in a regular expression.
- *
- * @param text The initial text.
- * @return the formatted text
- */
- private static String replaceSpecialRegExpChars(String text)
- {
- return MESSAGE_CHARS_ESCAPE.matcher(text).replaceAll("\\\\$1");
- }
-
- /**
- * Goes through the given text and converts all links to HTML links.
- * <p>
- * For example all occurrences of http://jitsi.org/ will be
- * replaced by <a href="http://jitsi.org/">
- * http://jitsi.org/</a>. The same is true for all strings
- * starting with "www".
- *
- * @param text the text on which the regular expression would be performed
- * @return the initial text containing only HTML links
- */
- private static String formatLinksToHTML(String text)
- {
- String wwwURL = "(www\\." + // Matches the "www" string.
- "[^/?#<\"'\\s]+" + // Matches at least one char of
- // any type except / ? # < " '
- // and space.
- "[\\.]" + // Matches the second point of the link.
- "[^?#<\"'\\s]+" + // Matches at least one char of
- // any type except ? # < " '
- // and space.
- "(\\?[^#<\"'\\s]*)?" +
- "(#.*)?)";
-
- String protocolURL
- = "([^\"'<>:/?#\\s]+" + // Matches at least one char of
- // any type except " ' < > : / ? #
- // and space.
- "://" + // Matches the :// delimiter in links
- "[^/?#<\"'\\s]*" + // Matches any number of times any char
- // except / ? # < " ' and space.
- "[^?#<\"'\\s]*" + // Matches any number of times any char
- // except ? # < " ' and space.
- "(\\?[^#<\"'\\s]*)?" +
- "(#.*)?)";
-
- String url = '(' + wwwURL + '|' + protocolURL + ')';
-
- Pattern p = Pattern.compile(url, Pattern.CASE_INSENSITIVE);
-
- Matcher m = p.matcher(text);
-
- StringBuffer linkBuffer = new StringBuffer();
-
- while (m.find())
- {
- String linkGroup = m.group();
-
- String replacement;
- if (linkGroup.startsWith("www"))
- {
- replacement = "<A href=\"" + "http://"
- + linkGroup + "\">" + linkGroup + "</A>";
- }
- else
- {
- replacement = "<A href=\"" + linkGroup
- + "\">" + linkGroup + "</A>";
- }
-
- m.appendReplacement(linkBuffer,
- replaceSpecialRegExpChars(replacement));
- }
-
- m.appendTail(linkBuffer);
-
- return linkBuffer.toString();
- }
-
- /**
- * Registers an <tt>EventFilter</tt> with this operation set so that
- * events, that do not need processing, are filtered out.
- *
- * @param filter the <tt>EventFilter</tt> to register.
- */
- public void addEventFilter(EventFilter filter)
- {
- synchronized(eventFilters)
- {
- if(!eventFilters.contains(filter))
- {
- eventFilters.add(filter);
- }
- }
- }
-
- /**
- * Unregisteres an <tt>EventFilter</tt> so that it won't check any more
- * if an event should be filtered out.
- *
- * @param filter the <tt>EventFilter</tt> to unregister.
- */
- public void removeEventFilter(EventFilter filter)
- {
- synchronized(eventFilters)
- {
- eventFilters.remove(filter);
- }
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetFileTransferYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetFileTransferYahooImpl.java
deleted file mode 100644
index 85f25b1..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetFileTransferYahooImpl.java
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import ymsg.network.event.*;
-
-/**
- * The Yahoo protocol filetransfer OperationSet.
- *
- * @author Damian Minkov
- */
-public class OperationSetFileTransferYahooImpl
- implements OperationSetFileTransfer,
- SessionFileTransferListener
-{
- /**
- * The logger for this class.
- */
- private static final Logger logger =
- Logger.getLogger(OperationSetFileTransferYahooImpl.class);
-
- /**
- * The provider that created us.
- */
- private final ProtocolProviderServiceYahooImpl yahooProvider;
-
- /**
- * A list of listeners registered for file transfer events.
- */
- private ArrayList<FileTransferListener> fileTransferListeners
- = new ArrayList<FileTransferListener>();
-
- /**
- * A list of active fileTransfers.
- */
- private Hashtable<String, Object> activeFileTransfers
- = new Hashtable<String, Object>();
-
- /**
- * Constructor
- * @param provider is the provider that created us
- */
- public OperationSetFileTransferYahooImpl(
- ProtocolProviderServiceYahooImpl provider)
- {
- this.yahooProvider = provider;
-
- provider.addRegistrationStateChangeListener(
- new RegistrationStateListener());
- }
-
- /**
- * Sends a file transfer request to the given <tt>toContact</tt> by
- * specifying the local and remote file path and the <tt>fromContact</tt>,
- * sending the file.
- *
- * @param toContact the contact that should receive the file
- * @param file the file to send
- *
- * @return the transfer object
- *
- * @throws IllegalStateException if the protocol provider is not registered
- * or connected
- * @throws IllegalArgumentException if some of the arguments doesn't fit the
- * protocol requirements
- */
- public FileTransfer sendFile( Contact toContact,
- File file)
- throws IllegalStateException,
- IllegalArgumentException
- {
- try
- {
- assertConnected();
-
- if(file.length() > getMaximumFileLength())
- throw new IllegalArgumentException(
- "File length exceeds the allowed one for this protocol");
-
- ArrayList<String> filesToSend = new ArrayList<String>();
- filesToSend.add(file.getCanonicalPath());
- Date sentDate = new Date();
- String id = yahooProvider.getYahooSession().sendFiles(
- filesToSend, toContact.getAddress());
-
- FileTransferImpl ft =
- new FileTransferImpl(yahooProvider,
- id, toContact, file, FileTransfer.OUT);
-
- // Notify all interested listeners that a file transfer has been
- // created.
- FileTransferCreatedEvent event
- = new FileTransferCreatedEvent(ft, sentDate);
-
- fireFileTransferCreated(event);
-
- ft.fireStatusChangeEvent(FileTransferStatusChangeEvent.PREPARING);
-
- return ft;
- }
- catch(IOException e)
- {
- logger.error("Cannot send fileTransfer", e);
- return null;
- }
- }
-
- /**
- * Sends a file transfer request to the given <tt>toContact</tt> by
- * specifying the local and remote file path and the <tt>fromContact</tt>,
- * sending the file.
- *
- * @param toContact the contact that should receive the file
- * @param fromContact the contact sending the file
- * @param remotePath the remote file path
- * @param localPath the local file path
- *
- * @return the transfer object
- *
- * @throws IllegalStateException if the protocol provider is not registered
- * or connected
- * @throws IllegalArgumentException if some of the arguments doesn't fit the
- * protocol requirements
- */
- public FileTransfer sendFile( Contact toContact,
- Contact fromContact,
- String remotePath,
- String localPath)
- throws IllegalStateException,
- IllegalArgumentException
- {
- return this.sendFile(toContact, new File(localPath));
- }
-
- /**
- * Adds the given <tt>FileTransferListener</tt> that would listen for
- * file transfer requests and created file transfers.
- *
- * @param listener the <tt>FileTransferListener</tt> to add
- */
- public void addFileTransferListener(
- FileTransferListener listener)
- {
- synchronized(fileTransferListeners)
- {
- if(!fileTransferListeners.contains(listener))
- {
- this.fileTransferListeners.add(listener);
- }
- }
- }
-
- /**
- * Removes the given <tt>FileTransferListener</tt> that listens for
- * file transfer requests and created file transfers.
- *
- * @param listener the <tt>FileTransferListener</tt> to remove
- */
- public void removeFileTransferListener(
- FileTransferListener listener)
- {
- synchronized(fileTransferListeners)
- {
- this.fileTransferListeners.remove(listener);
- }
- }
-
- /**
- * Utility method throwing an exception if the stack is not properly
- * initialized.
- * @throws java.lang.IllegalStateException if the underlying stack is
- * not registered and initialized.
- */
- private void assertConnected()
- throws IllegalStateException
- {
- if (yahooProvider == null)
- throw new IllegalStateException(
- "The provider must be non-null and signed on the "
- +"service before being able to send a file.");
- else if (!yahooProvider.isRegistered())
- throw new IllegalStateException(
- "The provider must be signed on the service before "
- +"being able to send a file.");
- }
-
- /**
- * Delivers the file transfer to all registered listeners.
- *
- * @param event the <tt>FileTransferEvent</tt> that we'd like delivered to
- * all registered file transfer listeners.
- */
- void fireFileTransferCreated(FileTransferCreatedEvent event)
- {
- activeFileTransfers.put(
- event.getFileTransfer().getID(), event.getFileTransfer());
-
- Iterator<FileTransferListener> listeners = null;
- synchronized (fileTransferListeners)
- {
- listeners = new ArrayList<FileTransferListener>
- (fileTransferListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- FileTransferListener listener = listeners.next();
- listener.fileTransferCreated(event);
- }
- }
-
- /**
- * Delivers the specified event to all registered file transfer listeners.
- *
- * @param event the <tt>EventObject</tt> that we'd like delivered to all
- * registered file transfer listeners.
- */
- void fireFileTransferRequestRejected(FileTransferRequestEvent event)
- {
- Iterator<FileTransferListener> listeners = null;
- synchronized (fileTransferListeners)
- {
- listeners = new ArrayList<FileTransferListener>
- (fileTransferListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- FileTransferListener listener = listeners.next();
-
- listener.fileTransferRequestRejected(event);
- }
- }
-
- /**
- * Delivers the specified event to all registered file transfer listeners.
- *
- * @param event the <tt>EventObject</tt> that we'd like delivered to all
- * registered file transfer listeners.
- */
- private void fireFileTransferRequest(FileTransferRequestEvent event)
- {
- Iterator<FileTransferListener> listeners = null;
- synchronized (fileTransferListeners)
- {
- listeners = new ArrayList<FileTransferListener>
- (fileTransferListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- FileTransferListener listener = listeners.next();
-
- listener.fileTransferRequestReceived(event);
- }
- }
-
- /**
- * Delivers the specified event to all registered file transfer listeners.
- *
- * @param event the <tt>EventObject</tt> that we'd like delivered to all
- * registered file transfer listeners.
- */
- void fireFileTransferRequestCanceled(FileTransferRequestEvent event)
- {
- Iterator<FileTransferListener> listeners = null;
- synchronized (fileTransferListeners)
- {
- listeners = new ArrayList<FileTransferListener>
- (fileTransferListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- FileTransferListener listener = listeners.next();
-
- listener.fileTransferRequestCanceled(event);
- }
- }
-
- private int getStateMapping(int s)
- {
- switch(s)
- {
- case SessionFileTransferEvent.REFUSED :
- return FileTransferStatusChangeEvent.REFUSED;
- case SessionFileTransferEvent.CANCEL :
- return FileTransferStatusChangeEvent.CANCELED;
- case SessionFileTransferEvent.FAILED :
- return FileTransferStatusChangeEvent.FAILED;
- case SessionFileTransferEvent.IN_PROGRESS :
- return FileTransferStatusChangeEvent.IN_PROGRESS;
- case SessionFileTransferEvent.RECEIVED :
- return FileTransferStatusChangeEvent.COMPLETED;
- case SessionFileTransferEvent.SENT :
- return FileTransferStatusChangeEvent.COMPLETED;
- default: return FileTransferStatusChangeEvent.WAITING;
- }
- }
-
- /**
- * Starting point for incoming filetransfer.
- * @param ev
- */
- public void fileTransferRequestReceived(SessionFileTransferEvent ev)
- {
- OperationSetPersistentPresenceYahooImpl opSetPersPresence
- = (OperationSetPersistentPresenceYahooImpl)
- yahooProvider.getOperationSet(
- OperationSetPersistentPresence.class);
-
- Contact sender = opSetPersPresence.findContactByID(ev.getFrom());
-
- if(sender == null)
- return;
-
- Date recvDate = new Date();
-
- for(int i = 0; i < ev.getFileNames().size(); i++)
- {
- String fileName = ev.getFileNames().get(i);
- String fileSize = ev.getFileSizes().get(i);
-
- IncomingFileTransferRequest req =
- new IncomingFileTransferRequestYahooImpl(
- yahooProvider, this, sender, recvDate,
- fileName, fileSize,
- ev.getId());
-
- activeFileTransfers.put(ev.getId(), req);
- fireFileTransferRequest(
- new FileTransferRequestEvent(this, req, recvDate));
- }
- }
-
- /**
- * Status changed for filetransfer.
- * @param ev
- */
- public void statusChanged(SessionFileTransferEvent ev)
- {
- if(ev.getId() == null)
- return;
-
- Object ftObj = activeFileTransfers.get(ev.getId());
-
- if(ftObj == null)
- {
- logger.warn("File Transfer or request not found. " + ev.getId() + "/ " + ev.getState());
- return;
- }
-
- int newState = ev.getState();
-
- if(newState == SessionFileTransferEvent.CANCEL
- || newState == SessionFileTransferEvent.FAILED
- || newState == SessionFileTransferEvent.RECEIVED
- || newState == SessionFileTransferEvent.REFUSED
- || newState == SessionFileTransferEvent.SENT)
- {
- // this is an final state so remove it from active filetransfers
- activeFileTransfers.remove(ev.getId());
- }
-
- if(ftObj instanceof IncomingFileTransferRequest)
- {
- if(newState == SessionFileTransferEvent.REFUSED)
- {
- IncomingFileTransferRequestYahooImpl req =
- (IncomingFileTransferRequestYahooImpl)ftObj;
- fireFileTransferRequestCanceled(
- new FileTransferRequestEvent(this, req, req.getDate()));
- return;
- }
- }
-
- if(!(ftObj instanceof FileTransferImpl))
- {
- logger.warn("File Transfer not found." + ftObj);
- return;
- }
-
- FileTransferImpl ft = (FileTransferImpl)ftObj;
-
- if( newState == SessionFileTransferEvent.IN_PROGRESS)
- {
- // if we start sending progress fire that we are in progress
- if(ev.getProgress() == 0)
- ft.fireStatusChangeEvent(
- FileTransferStatusChangeEvent.IN_PROGRESS);
-
- ft.setTransferedBytes(ev.getProgress());
- ft.fireProgressChangeEvent(
- System.currentTimeMillis(), ev.getProgress());
- }
- else
- ft.fireStatusChangeEvent(getStateMapping(newState));
- }
-
- /**
- * Returns the maximum file length supported by the protocol in bytes.
- * Supports up to 256MB.
- *
- * @return the file length that is supported.
- */
- public long getMaximumFileLength()
- {
- return 268435456l;// = 256*1024*1024;
- }
-
- /**
- * Our listener that will tell us when we're registered to
- */
- private class RegistrationStateListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenever
- * a change in the registration state of the corresponding provider had
- * occurred.
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (logger.isDebugEnabled())
- logger.debug("The provider changed state from: "
- + evt.getOldState()
- + " to: " + evt.getNewState());
-
- if (evt.getNewState() == RegistrationState.REGISTERED)
- {
- yahooProvider.getYahooSession().addSessionFileListener(
- OperationSetFileTransferYahooImpl.this);
- }
- else if (evt.getNewState() == RegistrationState.UNREGISTERED)
- {
- YahooSession ys = yahooProvider.getYahooSession();
- if(ys != null)
- ys.removeSessionFileListener(
- OperationSetFileTransferYahooImpl.this);
- }
- }
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetPersistentPresenceYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetPersistentPresenceYahooImpl.java
deleted file mode 100644
index a99bdb7..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetPersistentPresenceYahooImpl.java
+++ /dev/null
@@ -1,954 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.service.protocol.yahooconstants.*;
-import net.java.sip.communicator.util.*;
-import ymsg.network.*;
-import ymsg.network.event.*;
-
-/**
- * The Yahoo implementation of a Persistent Presence Operation set. This class
- * manages our own presence status as well as subscriptions for the presence
- * status of our buddies. It also offers methods for retrieving and modifying
- * the buddy contact list and adding listeners for changes in its layout.
- *
- * @author Damian Minkov
- */
-public class OperationSetPersistentPresenceYahooImpl
- extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceYahooImpl>
-{
- private static final Logger logger =
- Logger.getLogger(OperationSetPersistentPresenceYahooImpl.class);
-
- /**
- * Contains our current status message. Note that this field would only
- * be changed once the server has confirmed the new status message and
- * not immediately upon setting a new one..
- */
- private String currentStatusMessage = "";
-
- /**
- * The presence status that we were last notified of entering.
- * The initial one is OFFLINE
- */
- private PresenceStatus currentStatus = YahooStatusEnum.OFFLINE;
-
- /**
- * Sometimes status changes are received before the contact list is inited
- * here we store such events so we can show them correctly
- */
-// private Hashtable earlyStatusChange = new Hashtable();
-
- /**
- * The array list we use when returning from the getSupportedStatusSet()
- * method.
- */
- private static final List<PresenceStatus> supportedPresenceStatusSet = new ArrayList<PresenceStatus>();
- static{
- supportedPresenceStatusSet.add(YahooStatusEnum.AVAILABLE);
- supportedPresenceStatusSet.add(YahooStatusEnum.BE_RIGHT_BACK);
- supportedPresenceStatusSet.add(YahooStatusEnum.BUSY);
- supportedPresenceStatusSet.add(YahooStatusEnum.IDLE);
- supportedPresenceStatusSet.add(YahooStatusEnum.INVISIBLE);
- supportedPresenceStatusSet.add(YahooStatusEnum.NOT_AT_DESK);
- supportedPresenceStatusSet.add(YahooStatusEnum.NOT_AT_HOME);
- supportedPresenceStatusSet.add(YahooStatusEnum.NOT_IN_OFFICE);
- supportedPresenceStatusSet.add(YahooStatusEnum.OFFLINE);
- supportedPresenceStatusSet.add(YahooStatusEnum.ON_THE_PHONE);
- supportedPresenceStatusSet.add(YahooStatusEnum.ON_VACATION);
- supportedPresenceStatusSet.add(YahooStatusEnum.OUT_TO_LUNCH);
- supportedPresenceStatusSet.add(YahooStatusEnum.STEPPED_OUT);
- }
-
- /**
- * A map containing bindings between SIP Communicator's yahoo presence status
- * instances and Yahoo status codes
- */
- private static final Map<PresenceStatus, Long> scToYahooModesMappings
- = new Hashtable<PresenceStatus, Long>();
- static{
- scToYahooModesMappings.put(YahooStatusEnum.AVAILABLE,
- StatusConstants.STATUS_AVAILABLE);
- scToYahooModesMappings.put(YahooStatusEnum.BE_RIGHT_BACK,
- StatusConstants.STATUS_BRB);
- scToYahooModesMappings.put(YahooStatusEnum.BUSY,
- StatusConstants.STATUS_BUSY);
- scToYahooModesMappings.put(YahooStatusEnum.IDLE,
- StatusConstants.STATUS_IDLE);
- scToYahooModesMappings.put(YahooStatusEnum.INVISIBLE,
- StatusConstants.STATUS_INVISIBLE);
- scToYahooModesMappings.put(YahooStatusEnum.NOT_AT_DESK,
- StatusConstants.STATUS_NOTATDESK);
- scToYahooModesMappings.put(YahooStatusEnum.NOT_AT_HOME,
- StatusConstants.STATUS_NOTATHOME);
- scToYahooModesMappings.put(YahooStatusEnum.NOT_IN_OFFICE,
- StatusConstants.STATUS_NOTINOFFICE);
- scToYahooModesMappings.put(YahooStatusEnum.OFFLINE,
- StatusConstants.STATUS_OFFLINE);
- scToYahooModesMappings.put(YahooStatusEnum.ON_THE_PHONE,
- StatusConstants.STATUS_ONPHONE);
- scToYahooModesMappings.put(YahooStatusEnum.ON_VACATION,
- StatusConstants.STATUS_ONVACATION);
- scToYahooModesMappings.put(YahooStatusEnum.OUT_TO_LUNCH,
- StatusConstants.STATUS_OUTTOLUNCH);
- scToYahooModesMappings.put(YahooStatusEnum.STEPPED_OUT,
- StatusConstants.STATUS_STEPPEDOUT);
- }
-
- /**
- * The server stored contact list that will be encapsulating smack's
- * buddy list.
- */
- private ServerStoredContactListYahooImpl ssContactList = null;
-
- /**
- * Listens for events that are fired while registering to server.
- * After we are registered instance is cleared and never used.
- */
- private EarlyEventListener earlyEventListener = null;
-
- /**
- * Status events are received before subscription one.
- * And when subscription is received we deliver
- * and the status events.
- */
- private StatusUpdater statusUpdater = new StatusUpdater();
-
- public OperationSetPersistentPresenceYahooImpl(
- ProtocolProviderServiceYahooImpl provider)
- {
- super(provider);
-
- ssContactList = new ServerStoredContactListYahooImpl( this , provider);
-
- parentProvider.addRegistrationStateChangeListener(
- new RegistrationStateListener());
- }
-
- /**
- * Registers a listener that would receive events upong changes in server
- * stored groups.
- *
- * @param listener a ServerStoredGroupChangeListener impl that would
- * receive events upong group changes.
- */
- @Override
- public void addServerStoredGroupChangeListener(ServerStoredGroupListener
- listener)
- {
- ssContactList.addGroupListener(listener);
- }
-
- /**
- * Creates a group with the specified name and parent in the server
- * stored contact list.
- *
- * @param parent the group where the new group should be created
- * @param groupName the name of the new group to create.
- * @throws OperationFailedException if such group already exists
- */
- public void createServerStoredContactGroup(ContactGroup parent,
- String groupName)
- throws OperationFailedException
- {
- assertConnected();
-
- if (!parent.canContainSubgroups())
- throw new IllegalArgumentException(
- "The specified contact group cannot contain child groups. Group:"
- + parent );
-
- ssContactList.createGroup(groupName);
- }
-
- /**
- * Creates a non persistent contact for the specified address. This would
- * also create (if necessary) a group for volatile contacts that would not
- * be added to the server stored contact list. The volatile contact would
- * remain in the list until it is really added to the contact list or
- * until the application is terminated.
- * @param id the address of the contact to create.
- * @return the newly created volatile <tt>ContactImpl</tt>
- */
- public ContactYahooImpl createVolatileContact(String id)
- {
- return ssContactList.createVolatileContact(id);
- }
-
- /**
- * Creates and returns a unresolved contact from the specified
- * <tt>address</tt> and <tt>persistentData</tt>.
- *
- * @param address an identifier of the contact that we'll be creating.
- * @param persistentData a String returned Contact's getPersistentData()
- * method during a previous run and that has been persistently stored
- * locally.
- * @param parentGroup the group where the unresolved contact is supposed
- * to belong to.
- * @return the unresolved <tt>Contact</tt> created from the specified
- * <tt>address</tt> and <tt>persistentData</tt>
- */
- public Contact createUnresolvedContact(String address,
- String persistentData,
- ContactGroup parentGroup)
- {
- if(! (parentGroup instanceof ContactGroupYahooImpl ||
- parentGroup instanceof RootContactGroupYahooImpl) )
- throw new IllegalArgumentException(
- "Argument is not an yahoo contact group (group="
- + parentGroup + ")");
-
- ContactYahooImpl contact =
- ssContactList.createUnresolvedContact(parentGroup, address);
-
- contact.setPersistentData(persistentData);
-
- return contact;
- }
-
- /**
- * Creates and returns a unresolved contact from the specified
- * <tt>address</tt> and <tt>persistentData</tt>.
- *
- * @param address an identifier of the contact that we'll be creating.
- * @param persistentData a String returned Contact's getPersistentData()
- * method during a previous run and that has been persistently stored
- * locally.
- * @return the unresolved <tt>Contact</tt> created from the specified
- * <tt>address</tt> and <tt>persistentData</tt>
- */
- public Contact createUnresolvedContact(String address,
- String persistentData)
- {
- return createUnresolvedContact( address
- , persistentData
- , getServerStoredContactListRoot());
- }
-
- /**
- * Creates and returns a unresolved contact group from the specified
- * <tt>address</tt> and <tt>persistentData</tt>.
- *
- * @param groupUID an identifier, returned by ContactGroup's
- * getGroupUID, that the protocol provider may use in order to create
- * the group.
- * @param persistentData a String returned ContactGroups's
- * getPersistentData() method during a previous run and that has been
- * persistently stored locally.
- * @param parentGroup the group under which the new group is to be
- * created or null if this is group directly underneath the root.
- * @return the unresolved <tt>ContactGroup</tt> created from the
- * specified <tt>uid</tt> and <tt>persistentData</tt>
- */
- public ContactGroup createUnresolvedContactGroup(String groupUID,
- String persistentData, ContactGroup parentGroup)
- {
- return ssContactList.createUnresolvedContactGroup(groupUID);
- }
-
- /**
- * Returns a reference to the contact with the specified ID in case we
- * have a subscription for it and null otherwise/
- *
- * @param contactID a String identifier of the contact which we're
- * seeking a reference of.
- * @return a reference to the Contact with the specified
- * <tt>contactID</tt> or null if we don't have a subscription for the
- * that identifier.
- */
- public Contact findContactByID(String contactID)
- {
- return ssContactList.findContactById(contactID);
- }
-
- /**
- * Returns the status message that was confirmed by the serfver
- *
- * @return the last status message that we have requested and the aim
- * server has confirmed.
- */
- public String getCurrentStatusMessage()
- {
- return currentStatusMessage;
- }
-
- /**
- * Returns the protocol specific contact instance representing the local
- * user.
- *
- * @return the Contact (address, phone number, or uin) that the Provider
- * implementation is communicating on behalf of.
- */
- public Contact getLocalContact()
- {
- return null;
- }
-
- /**
- * Returns a PresenceStatus instance representing the state this provider
- * is currently in.
- *
- * @return the PresenceStatus last published by this provider.
- */
- public PresenceStatus getPresenceStatus()
- {
- return currentStatus;
- }
-
- /**
- * Returns the root group of the server stored contact list.
- *
- * @return the root ContactGroup for the ContactList stored by this
- * service.
- */
- public ContactGroup getServerStoredContactListRoot()
- {
- return ssContactList.getRootGroup();
- }
-
- /**
- * Returns the set of PresenceStatus objects that a user of this service
- * may request the provider to enter.
- *
- * @return Iterator a PresenceStatus array containing "enterable" status
- * instances.
- */
- public Iterator<PresenceStatus> getSupportedStatusSet()
- {
- return supportedPresenceStatusSet.iterator();
- }
-
- /**
- * Removes the specified contact from its current parent and places it
- * under <tt>newParent</tt>.
- *
- * @param contactToMove the <tt>Contact</tt> to move
- * @param newParent the <tt>ContactGroup</tt> where <tt>Contact</tt>
- * would be placed.
- */
- public void moveContactToGroup(Contact contactToMove,
- ContactGroup newParent)
- {
- assertConnected();
-
- if( !(contactToMove instanceof ContactYahooImpl) )
- throw new IllegalArgumentException(
- "The specified contact is not an yahoo contact." + contactToMove);
- if( !(newParent instanceof ContactGroupYahooImpl) )
- throw new IllegalArgumentException(
- "The specified group is not an yahoo contact group."
- + newParent);
-
- ssContactList.moveContact((ContactYahooImpl)contactToMove,
- (ContactGroupYahooImpl)newParent);
- }
-
- /**
- * Requests the provider to enter into a status corresponding to the
- * specified paramters.
- *
- * @param status the PresenceStatus as returned by
- * getRequestableStatusSet
- * @param statusMessage the message that should be set as the reason to
- * enter that status
- * @throws IllegalArgumentException if the status requested is not a
- * valid PresenceStatus supported by this provider.
- * @throws IllegalStateException if the provider is not currently
- * registered.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * publishing the status fails due to a network error.
- */
- public void publishPresenceStatus(PresenceStatus status,
- String statusMessage) throws
- IllegalArgumentException, IllegalStateException,
- OperationFailedException
- {
- assertConnected();
-
- if (!(status instanceof YahooStatusEnum))
- throw new IllegalArgumentException(
- status + " is not a valid Yahoo status");
-
- if(status.equals(YahooStatusEnum.OFFLINE))
- {
- parentProvider.unregister();
- return;
- }
-
- try
- {
- if(statusMessage != null && statusMessage.length() != 0)
- {
- boolean isAvailable = false;
-
- if(status.equals(YahooStatusEnum.AVAILABLE))
- isAvailable = true;
-
- // false - away
- // true - available
- parentProvider.getYahooSession().
- setStatus(statusMessage, isAvailable);
- }
-
- parentProvider.getYahooSession().setStatus(
- scToYahooModesMappings.get(status).longValue());
-
- fireProviderStatusChangeEvent(currentStatus, status);
- }
- catch(IOException ex)
- {
- throw new OperationFailedException("Failed to set Status",
- OperationFailedException.NETWORK_FAILURE);
- }
- }
-
- /**
- * Get the PresenceStatus for a particular contact.
- *
- * @param contactIdentifier the identifier of the contact whose status
- * we're interested in.
- * @return PresenceStatus the <tt>PresenceStatus</tt> of the specified
- * <tt>contact</tt>
- * @throws IllegalArgumentException if <tt>contact</tt> is not a contact
- * known to the underlying protocol provider
- * @throws IllegalStateException if the underlying protocol provider is
- * not registered/signed on a public service.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * retrieving the status fails due to errors experienced during
- * network communication
- */
- public PresenceStatus queryContactStatus(String contactIdentifier) throws
- IllegalArgumentException, IllegalStateException,
- OperationFailedException
- {
-
- ContactYahooImpl contact = ssContactList.findContactById(contactIdentifier);
- if(contact == null)
- {
- if (logger.isInfoEnabled())
- logger.info("Contact not found id :" + contactIdentifier);
- return null;
- }
- else
- return yahooStatusToPresenceStatus(contact.getSourceContact().getStatus());
- }
-
- /**
- * Removes the specified group from the server stored contact list.
- *
- * @param group the group to remove.
- */
- public void removeServerStoredContactGroup(ContactGroup group)
- {
- assertConnected();
-
- if( !(group instanceof ContactGroupYahooImpl) )
- throw new IllegalArgumentException(
- "The specified group is not an yahoo contact group: " + group);
-
- ssContactList.removeGroup(((ContactGroupYahooImpl)group));
- }
-
- /**
- * Removes the specified group change listener so that it won't receive
- * any further events.
- *
- * @param listener the ServerStoredGroupChangeListener to remove
- */
- @Override
- public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
- listener)
- {
- ssContactList.removeGroupListener(listener);
- }
-
- /**
- * Renames the specified group from the server stored contact list.
- *
- * @param group the group to rename.
- * @param newName the new name of the group.
- */
- public void renameServerStoredContactGroup(ContactGroup group,
- String newName)
- {
- assertConnected();
-
- if( !(group instanceof ContactGroupYahooImpl) )
- throw new IllegalArgumentException(
- "The specified group is not an yahoo contact group: " + group);
-
- throw new UnsupportedOperationException("Renaming group not supported!");
- //ssContactList.renameGroup((ContactGroupYahooImpl)group, newName);
- }
-
- /**
- * Handler for incoming authorization requests.
- *
- * @param handler an instance of an AuthorizationHandler for
- * authorization requests coming from other users requesting
- * permission add us to their contact list.
- */
- public void setAuthorizationHandler(AuthorizationHandler handler)
- {
- ssContactList.setAuthorizationHandler(handler);
-
- // we got a handler. Lets process if something has came
- // during login process
- if(earlyEventListener != null)
- {
- earlyEventListener.processEarlyAuthorizations();
- earlyEventListener = null;
- }
- }
-
- /**
- * Persistently adds a subscription for the presence status of the
- * contact corresponding to the specified contactIdentifier and indicates
- * that it should be added to the specified group of the server stored
- * contact list.
- *
- * @param parent the parent group of the server stored contact list
- * where the contact should be added. <p>
- * @param contactIdentifier the contact whose status updates we are
- * subscribing for.
- * @throws IllegalArgumentException if <tt>contact</tt> or
- * <tt>parent</tt> are not a contact known to the underlying protocol
- * provider.
- * @throws IllegalStateException if the underlying protocol provider is
- * not registered/signed on a public service.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * subscribing fails due to errors experienced during network
- * communication
- */
- public void subscribe(ContactGroup parent, String contactIdentifier) throws
- IllegalArgumentException, IllegalStateException,
- OperationFailedException
- {
- assertConnected();
-
- if(! (parent instanceof ContactGroupYahooImpl) )
- throw new IllegalArgumentException(
- "Argument is not an yahoo contact group (group=" + parent + ")");
-
- ssContactList.addContact((ContactGroupYahooImpl)parent, contactIdentifier);
- }
-
- /**
- * Adds a subscription for the presence status of the contact
- * corresponding to the specified contactIdentifier.
- *
- * @param contactIdentifier the identifier of the contact whose status
- * updates we are subscribing for. <p>
- * @throws IllegalArgumentException if <tt>contact</tt> is not a contact
- * known to the underlying protocol provider
- * @throws IllegalStateException if the underlying protocol provider is
- * not registered/signed on a public service.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * subscribing fails due to errors experienced during network
- * communication
- */
- public void subscribe(String contactIdentifier) throws
- IllegalArgumentException, IllegalStateException,
- OperationFailedException
- {
- assertConnected();
-
- ssContactList.addContact(contactIdentifier);
- }
-
- /**
- * Removes a subscription for the presence status of the specified
- * contact.
- *
- * @param contact the contact whose status updates we are unsubscribing
- * from.
- * @throws IllegalArgumentException if <tt>contact</tt> is not a contact
- * known to the underlying protocol provider
- * @throws IllegalStateException if the underlying protocol provider is
- * not registered/signed on a public service.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * unsubscribing fails due to errors experienced during network
- * communication
- */
- public void unsubscribe(Contact contact) throws IllegalArgumentException,
- IllegalStateException, OperationFailedException
- {
- assertConnected();
-
- if(! (contact instanceof ContactYahooImpl) )
- throw new IllegalArgumentException(
- "Argument is not an yahoo contact (contact=" + contact + ")");
-
- ssContactList.removeContact((ContactYahooImpl)contact);
- }
-
- /**
- * Converts the specified yahoo status to one of the status fields of the
- * YahooStatusEnum class.
- *
- * @param status the yahoo Status
- * @return a PresenceStatus instance representation of the yahoo Status
- * parameter. The returned result is one of the YahooStatusEnum fields.
- */
- YahooStatusEnum yahooStatusToPresenceStatus(long status)
- {
- if(status == StatusConstants.STATUS_AVAILABLE)
- return YahooStatusEnum.AVAILABLE;
- else if(status == StatusConstants.STATUS_BRB)
- return YahooStatusEnum.BE_RIGHT_BACK;
- else if(status == StatusConstants.STATUS_BUSY)
- return YahooStatusEnum.BUSY;
- else if(status == StatusConstants.STATUS_NOTATHOME)
- return YahooStatusEnum.NOT_AT_HOME;
- else if(status == StatusConstants.STATUS_NOTATDESK)
- return YahooStatusEnum.NOT_AT_DESK;
- else if(status == StatusConstants.STATUS_NOTINOFFICE)
- return YahooStatusEnum.NOT_IN_OFFICE;
- else if(status == StatusConstants.STATUS_ONPHONE)
- return YahooStatusEnum.ON_THE_PHONE;
- else if(status == StatusConstants.STATUS_ONVACATION)
- return YahooStatusEnum.ON_VACATION;
- else if(status == StatusConstants.STATUS_OUTTOLUNCH)
- return YahooStatusEnum.OUT_TO_LUNCH;
- else if(status == StatusConstants.STATUS_STEPPEDOUT)
- return YahooStatusEnum.STEPPED_OUT;
- else if(status == StatusConstants.STATUS_INVISIBLE)
- return YahooStatusEnum.INVISIBLE;
- else if(status == StatusConstants.STATUS_IDLE)
- return YahooStatusEnum.IDLE;
- else if(status == StatusConstants.STATUS_OFFLINE)
- return YahooStatusEnum.OFFLINE;
- // Yahoo supports custom statuses so if such is set just return available
- else
- return YahooStatusEnum.AVAILABLE;
- }
-
- /**
- * Utility method throwing an exception if the stack is not properly
- * initialized.
- * @throws java.lang.IllegalStateException if the underlying stack is
- * not registered and initialized.
- */
- private void assertConnected() throws IllegalStateException
- {
- if (parentProvider == null)
- throw new IllegalStateException(
- "The provider must be non-null and signed on the yahoo "
- +"service before being able to communicate.");
- if (!parentProvider.isRegistered())
- throw new IllegalStateException(
- "The provider must be signed on the yahoo service before "
- +"being able to communicate.");
- }
-
- /**
- * Notify all provider presence listeners of the corresponding event change
- *
- * @param oldStatus
- * the status our stack had so far
- * @param newStatus
- * the status we have from now on
- */
- @Override
- protected void fireProviderStatusChangeEvent(
- PresenceStatus oldStatus,
- PresenceStatus newStatus)
- {
- if (!oldStatus.equals(newStatus))
- {
- currentStatus = newStatus;
-
- super.fireProviderStatusChangeEvent(oldStatus, newStatus);
- }
- }
-
- /**
- * Statuses have been received durring login process
- * so we will init them once we are logged in
- */
- private void initContactStatuses()
- {
- YahooGroup[] groups = parentProvider.getYahooSession().getGroups();
-
- for (YahooGroup item : groups)
- {
- @SuppressWarnings("unchecked")
- Iterable<YahooUser> members = item.getMembers();
-
- for (YahooUser user : members)
- {
- ContactYahooImpl sourceContact =
- ssContactList.findContactById(user.getId());
-
- if(sourceContact != null)
- handleContactStatusChange(sourceContact, user);
- }
- }
- }
-
- /**
- * Our listener that will tell us when we're registered to server
- * and is ready to accept us as a listener.
- */
- private class RegistrationStateListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenever
- * a change in the registration state of the corresponding provider had
- * occurred.
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (logger.isDebugEnabled())
- logger.debug("The yahoo provider changed state from: "
- + evt.getOldState()
- + " to: " + evt.getNewState());
-
- if(evt.getNewState() == RegistrationState.REGISTERING)
- {
- // add new listener waiting for events during login process
- earlyEventListener
- = new EarlyEventListener(parentProvider.getYahooSession());
- }
- else if(evt.getNewState() == RegistrationState.REGISTERED)
- {
- parentProvider.getYahooSession().
- addSessionListener(new StatusChangedListener());
-
- ssContactList.setYahooSession(parentProvider.getYahooSession());
-
- initContactStatuses();
-
- addSubscriptionListener(statusUpdater);
-
- if(earlyEventListener != null)
- {
- earlyEventListener.dispose();
- earlyEventListener = null;
- }
- }
- else if(evt.getNewState() == RegistrationState.UNREGISTERED
- || evt.getNewState() == RegistrationState.AUTHENTICATION_FAILED
- || evt.getNewState() == RegistrationState.CONNECTION_FAILED)
- {
- //since we are disconnected, we won't receive any further status
- //updates so we need to change by ourselves our own status as
- //well as set to offline all contacts in our contact list that
- //were online
- PresenceStatus oldStatus = currentStatus;
- currentStatus = YahooStatusEnum.OFFLINE;
-
- fireProviderStatusChangeEvent(oldStatus, currentStatus);
-
- removeSubscriptionListener(statusUpdater);
-
- //send event notifications saying that all our buddies are
- //offline. The protocol does not implement top level buddies
- //nor subgroups for top level groups so a simple nested loop
- //would be enough.
- Iterator<ContactGroup> groupsIter =
- getServerStoredContactListRoot().subgroups();
- while(groupsIter.hasNext())
- {
- ContactGroup group = groupsIter.next();
- Iterator<Contact> contactsIter = group.contacts();
-
- while(contactsIter.hasNext())
- {
- ContactYahooImpl contact
- = (ContactYahooImpl)contactsIter.next();
-
- PresenceStatus oldContactStatus
- = contact.getPresenceStatus();
-
- if(!oldContactStatus.isOnline())
- continue;
-
- contact.updatePresenceStatus(YahooStatusEnum.OFFLINE);
-
- fireContactPresenceStatusChangeEvent(
- contact
- , contact.getParentContactGroup()
- , oldContactStatus, YahooStatusEnum.OFFLINE);
- }
- }
-
- // clear listener
- if(earlyEventListener != null)
- {
- earlyEventListener.dispose();
- earlyEventListener = null;
- }
- }
- }
- }
-
- private void handleContactStatusChange(YahooUser yFriend)
- {
- ContactYahooImpl sourceContact =
- ssContactList.findContactById(yFriend.getId());
-
- if(sourceContact == null)
- {
- if(parentProvider.getAccountID().getUserID().
- equals(yFriend.getId()))
- {
- // thats my own status
- if (logger.isTraceEnabled())
- logger.trace("Own status changed to " + yFriend.getStatus());
- PresenceStatus oldStatus = currentStatus;
- currentStatus =
- yahooStatusToPresenceStatus(yFriend.getStatus());
- fireProviderStatusChangeEvent(oldStatus, currentStatus);
-
- return;
- }
- // strange
- else
- return;
- }
-
- handleContactStatusChange(sourceContact, yFriend);
- }
-
- void handleContactStatusChange(ContactYahooImpl sourceContact, YahooUser yFriend)
- {
- PresenceStatus oldStatus
- = sourceContact.getPresenceStatus();
-
- PresenceStatus newStatus = yahooStatusToPresenceStatus(yFriend.getStatus());
-
- // statuses maybe the same and only change in status message
- sourceContact.setStatusMessage(yFriend.getCustomStatusMessage());
-
- // when old and new status are the same do nothing - no change
- if(oldStatus.equals(newStatus))
- {
- if (logger.isDebugEnabled())
- logger.debug("old(" + oldStatus + ") and new("+ newStatus + ") statuses are the same!");
- return;
- }
-
- sourceContact.updatePresenceStatus(newStatus);
-
- ContactGroup parent
- = ssContactList.findContactGroup(sourceContact);
-
- if (logger.isDebugEnabled())
- logger.debug("Will Dispatch the contact status event.");
- fireContactPresenceStatusChangeEvent(sourceContact, parent,
- oldStatus, newStatus);
- }
-
- private class StatusChangedListener
- extends SessionAdapter
- {
- @Override
- public void friendsUpdateReceived(SessionFriendEvent evt)
- {
- if (logger.isDebugEnabled())
- logger.debug("Received a status update for contact " + evt);
-
- if(evt.getFriend() != null)
- {
- handleContactStatusChange(evt.getFriend());
- }
- else if(evt.getFriends() != null)
- {
- YahooUser[] yfs = evt.getFriends();
- for (int i = 0; i < yfs.length; i++)
- handleContactStatusChange(yfs[i]);
- }
- }
- }
-
- /**
- * Updates the statuses of newly created persistent contacts
- */
- private class StatusUpdater
- extends SubscriptionAdapter
- {
- @Override
- public void subscriptionCreated(SubscriptionEvent evt)
- {
- ContactYahooImpl contact =
- (ContactYahooImpl)evt.getSourceContact();
-
- if(!contact.isPersistent() || !contact.isResolved())
- return;
-
- handleContactStatusChange(contact, contact.getSourceContact());
- }
- }
-
- private class EarlyEventListener
- extends SessionAdapter
- {
- private final List<SessionAuthorizationEvent> receivedAuthorizations
- = new Vector<SessionAuthorizationEvent>();
-
- /**
- * The <code>YahooSession</code> this instance is listening to because
- * the <code>YahooSession</code> isn't available in
- * <code>parentProvider</code> after
- * {@link RegistrationState#UNREGISTERED} and then this listener cannot
- * be removed.
- */
- private final YahooSession yahooSession;
-
- public EarlyEventListener(YahooSession yahooSession)
- {
- this.yahooSession = yahooSession;
- this.yahooSession.addSessionListener(this);
- }
-
- @Override
- public void authorizationReceived(SessionAuthorizationEvent ev)
- {
- if(ev.isAuthorizationRequest())
- {
- if (logger.isTraceEnabled())
- logger.trace("authorizationRequestReceived from " +
- ev.getFrom());
- receivedAuthorizations.add(ev);
- }
- }
-
- public void dispose()
- {
- yahooSession.removeSessionListener(this);
- }
-
- public void processEarlyAuthorizations()
- {
- for (SessionAuthorizationEvent e : receivedAuthorizations)
- {
- ssContactList.processAuthorizationRequest(e);
- }
- }
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetTypingNotificationsYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetTypingNotificationsYahooImpl.java
deleted file mode 100644
index 81e266a..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetTypingNotificationsYahooImpl.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import ymsg.network.event.*;
-
-/**
- * Maps SIP Communicator typing notifications to those going and coming from
- * smack lib.
- *
- * @author Damian Minkov
- */
-public class OperationSetTypingNotificationsYahooImpl
- extends AbstractOperationSetTypingNotifications<ProtocolProviderServiceYahooImpl>
-{
- private static final Logger logger =
- Logger.getLogger(OperationSetTypingNotificationsYahooImpl.class);
-
- /**
- * An active instance of the opSetPersPresence operation set. We're using
- * it to map incoming events to contacts in our contact list.
- */
- private OperationSetPersistentPresenceYahooImpl opSetPersPresence = null;
-
- /**
- * @param provider a ref to the <tt>ProtocolProviderServiceImpl</tt>
- * that created us and that we'll use for retrieving the underlying aim
- * connection.
- */
- OperationSetTypingNotificationsYahooImpl(
- ProtocolProviderServiceYahooImpl provider)
- {
- super(provider);
-
- provider.addRegistrationStateChangeListener(new ProviderRegListener());
- }
-
- /**
- * Sends a notification to <tt>notifiedContatct</tt> that we have entered
- * <tt>typingState</tt>.
- *
- * @param notifiedContact the <tt>Contact</tt> to notify
- * @param typingState the typing state that we have entered.
- *
- * @throws java.lang.IllegalStateException if the underlying stack is
- * not registered and initialized.
- * @throws java.lang.IllegalArgumentException if <tt>notifiedContact</tt> is
- * not an instance belonging to the underlying implementation.
- */
- public void sendTypingNotification(Contact notifiedContact, int typingState)
- throws IllegalStateException, IllegalArgumentException
- {
- assertConnected();
-
- if( !(notifiedContact instanceof ContactYahooImpl) )
- throw new IllegalArgumentException(
- "The specified contact is not an yahoo contact."
- + notifiedContact);
-
- if(typingState == OperationSetTypingNotifications.STATE_TYPING)
- {
-
- parentProvider.getYahooSession().
- keyTyped(notifiedContact.getAddress(),
- parentProvider.getAccountID().getUserID());
- }
- else
- if(typingState == OperationSetTypingNotifications.STATE_STOPPED ||
- typingState == OperationSetTypingNotifications.STATE_PAUSED)
- {
- parentProvider.getYahooSession().
- stopTyping(notifiedContact.getAddress(),
- parentProvider.getAccountID().getUserID());
- }
- }
-
- private class TypingListener
- extends SessionAdapter
- {
- @Override
- public void notifyReceived(SessionNotifyEvent evt)
- {
- if(evt.isTyping())
- {
- String typingUserID = evt.getFrom();
-
- if(typingUserID != null)
- {
- Contact sourceContact =
- opSetPersPresence.findContactByID(typingUserID);
-
- if(sourceContact == null)
- return;
-
- // typing on
- fireTypingNotificationsEvent(
- sourceContact,
- (evt.getMode() == 1) ? STATE_TYPING : STATE_STOPPED);
- }
- }
- }
- }
-
- /**
- * Our listener that will tell us when we're registered and
- * ready to accept us as a listener.
- */
- private class ProviderRegListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenever
- * a change in the registration state of the corresponding provider had
- * occurred.
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (logger.isDebugEnabled())
- logger.debug("The provider changed state from: "
- + evt.getOldState()
- + " to: " + evt.getNewState());
- if (evt.getNewState() == RegistrationState.REGISTERED)
- {
- opSetPersPresence =
- (OperationSetPersistentPresenceYahooImpl) parentProvider
- .getOperationSet(OperationSetPersistentPresence.class);
-
- parentProvider
- .getYahooSession().addSessionListener(new TypingListener());
- }
- }
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolIconYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolIconYahooImpl.java
deleted file mode 100644
index 34befc9..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolIconYahooImpl.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.resources.*;
-import org.osgi.framework.*;
-
-/**
- * Represents the Yahoo protocol icon. Implements the <tt>ProtocolIcon</tt>
- * interface in order to provide an Yahoo icon image in two different sizes.
- *
- * @author Yana Stamcheva
- */
-public class ProtocolIconYahooImpl
- implements ProtocolIcon
-{
- private static Logger logger = Logger.getLogger(ProtocolIconYahooImpl.class);
-
- private static ResourceManagementService resourcesService;
-
- /**
- * A hash table containing the protocol icon in different sizes.
- */
- private static Hashtable<String, byte[]> iconsTable
- = new Hashtable<String, byte[]>();
- static
- {
- iconsTable.put(ProtocolIcon.ICON_SIZE_16x16,
- getImageInBytes("service.protocol.yahoo.YAHOO_16x16"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_32x32,
- getImageInBytes("service.protocol.yahoo.YAHOO_32x32"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_48x48,
- getImageInBytes("service.protocol.yahoo.YAHOO_48x48"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_64x64,
- getImageInBytes("service.protocol.yahoo.YAHOO_64x64"));
- }
-
- /**
- * A hash table containing the protocol icon in different sizes.
- */
- private static Hashtable<String, String> iconPathsTable
- = new Hashtable<String, String>();
- static
- {
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_16x16,
- getResources().getImagePath("service.protocol.yahoo.YAHOO_16x16"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_32x32,
- getResources().getImagePath("service.protocol.yahoo.YAHOO_32x32"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_48x48,
- getResources().getImagePath("service.protocol.yahoo.YAHOO_48x48"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_64x64,
- getResources().getImagePath("service.protocol.yahoo.YAHOO_64x64"));
- }
-
- /**
- * Implements the <tt>ProtocolIcon.getSupportedSizes()</tt> method. Returns
- * an iterator to a set containing the supported icon sizes.
- * @return an iterator to a set containing the supported icon sizes
- */
- public Iterator<String> getSupportedSizes()
- {
- return iconsTable.keySet().iterator();
- }
-
- /**
- * Returns TRUE if a icon with the given size is supported, FALSE-otherwise.
- */
- public boolean isSizeSupported(String iconSize)
- {
- return iconsTable.containsKey(iconSize);
- }
-
- /**
- * Returns the icon image in the given size.
- * @param iconSize the icon size; one of ICON_SIZE_XXX constants
- */
- public byte[] getIcon(String iconSize)
- {
- return iconsTable.get(iconSize);
- }
-
- /**
- * Returns a path to the icon with the given size.
- * @param iconSize the size of the icon we're looking for
- * @return the path to the icon with the given size
- */
- public String getIconPath(String iconSize)
- {
- return iconPathsTable.get(iconSize);
- }
-
- /**
- * Returns the icon image used to represent the protocol connecting state.
- * @return the icon image used to represent the protocol connecting state
- */
- public byte[] getConnectingIcon()
- {
- return getImageInBytes("yahooConnectingIcon");
- }
-
- /**
- * Returns the byte representation of the image corresponding to the given
- * identifier.
- *
- * @param imageID the identifier of the image
- * @return the byte representation of the image corresponding to the given
- * identifier.
- */
- public static byte[] getImageInBytes(String imageID)
- {
- InputStream in = getResources().getImageInputStream(imageID);
-
- if (in == null)
- return null;
- byte[] image = null;
- try
- {
- image = new byte[in.available()];
-
- in.read(image);
- }
- catch (IOException e)
- {
- logger.error("Failed to load image:" + imageID, e);
- }
-
- return image;
- }
-
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- {
- ServiceReference serviceReference = YahooActivator.getBundleContext()
- .getServiceReference(ResourceManagementService.class.getName());
-
- if(serviceReference == null)
- return null;
-
- resourcesService = (ResourceManagementService)
- YahooActivator.getBundleContext().getService(serviceReference);
- }
-
- return resourcesService;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderFactoryYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderFactoryYahooImpl.java
deleted file mode 100644
index 358286c..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderFactoryYahooImpl.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-import org.osgi.framework.*;
-
-/**
- * The Yahoo implementation of the ProtocolProviderFactory.
- * @author Damian Minkov
- */
-public class ProtocolProviderFactoryYahooImpl
- extends ProtocolProviderFactory
-{
-
- /**
- * Creates an instance of the ProtocolProviderFactoryYahooImpl.
- */
- protected ProtocolProviderFactoryYahooImpl()
- {
- super(YahooActivator.getBundleContext(), ProtocolNames.YAHOO);
- }
-
- /**
- * Initializes and creates an account corresponding to the specified
- * accountProperties and registers the resulting ProtocolProvider in the
- * <tt>context</tt> BundleContext parameter. This method has a persistent
- * effect. Once created the resulting account will remain installed until
- * removed through the uninstall account method.
- *
- * @param userIDStr the user identifier for the new account
- * @param accountProperties a set of protocol (or implementation)
- * specific properties defining the new account.
- * @return the AccountID of the newly created account
- */
- @Override
- public AccountID installAccount( String userIDStr,
- Map<String, String> accountProperties)
- {
- BundleContext context
- = YahooActivator.getBundleContext();
- if (context == null)
- throw new NullPointerException("The specified BundleContext was null");
-
- if (userIDStr == null)
- throw new NullPointerException("The specified AccountID was null");
-
- if (accountProperties == null)
- throw new NullPointerException("The specified property map was null");
-
- accountProperties.put(USER_ID, userIDStr);
-
- AccountID accountID = new YahooAccountID(userIDStr, accountProperties);
-
- //make sure we haven't seen this account id before.
- if( registeredAccounts.containsKey(accountID) )
- throw new IllegalStateException(
- "An account for id " + userIDStr + " was already installed!");
-
- //first store the account and only then load it as the load generates
- //an osgi event, the osgi event triggers (through the UI) a call to
- //the register() method and it needs to access the configuration service
- //and check for a password.
- this.storeAccount(accountID, false);
-
- accountID = loadAccount(accountProperties);
-
- return accountID;
- }
-
- @Override
- protected AccountID createAccountID(String userID, Map<String, String> accountProperties)
- {
- return new YahooAccountID(userID, accountProperties);
- }
-
- @Override
- protected ProtocolProviderService createService(String userID,
- AccountID accountID)
- {
- ProtocolProviderServiceYahooImpl service =
- new ProtocolProviderServiceYahooImpl();
-
- service.initialize(userID, accountID);
- return service;
- }
-
- @Override
- public void modifyAccount( ProtocolProviderService protocolProvider,
- Map<String, String> accountProperties)
- throws NullPointerException
- {
- BundleContext context
- = YahooActivator.getBundleContext();
-
- if (context == null)
- throw new NullPointerException(
- "The specified BundleContext was null");
-
- if (protocolProvider == null)
- throw new NullPointerException(
- "The specified Protocol Provider was null");
-
- YahooAccountID accountID
- = (YahooAccountID) protocolProvider.getAccountID();
-
- // If the given accountID doesn't correspond to an existing account
- // we return.
- if(!registeredAccounts.containsKey(accountID))
- return;
-
- ServiceRegistration registration = registeredAccounts.get(accountID);
-
- // kill the service
- if (registration != null)
- registration.unregister();
-
- if (accountProperties == null)
- throw new NullPointerException(
- "The specified property map was null");
-
- accountProperties.put(USER_ID, accountID.getUserID());
-
- if (!accountProperties.containsKey(PROTOCOL))
- accountProperties.put(PROTOCOL, ProtocolNames.YAHOO);
-
- accountID.setAccountProperties(accountProperties);
-
- // First store the account and only then load it as the load generates
- // an osgi event, the osgi event triggers (trhgough the UI) a call to
- // the register() method and it needs to acces the configuration service
- // and check for a password.
- this.storeAccount(accountID);
-
- Hashtable<String, String> properties = new Hashtable<String, String>();
- properties.put(PROTOCOL, ProtocolNames.YAHOO);
- properties.put(USER_ID, accountID.getUserID());
-
- ((ProtocolProviderServiceYahooImpl)protocolProvider)
- .initialize(accountID.getUserID(), accountID);
-
- // We store again the account in order to store all properties added
- // during the protocol provider initialization.
- this.storeAccount(accountID);
-
- registration
- = context.registerService(
- ProtocolProviderService.class.getName(),
- protocolProvider,
- properties);
-
- registeredAccounts.put(accountID, registration);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java
deleted file mode 100644
index 264aaab..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java
+++ /dev/null
@@ -1,574 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.io.*;
-
-import net.java.sip.communicator.service.dns.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import ymsg.network.*;
-import ymsg.network.event.*;
-
-/**
- * An implementation of the protocol provider service over the Yahoo protocol
- *
- * @author Damian Minkov
- */
-public class ProtocolProviderServiceYahooImpl
- extends AbstractProtocolProviderService
-{
- /**
- * This class logger.
- */
- private static final Logger logger =
- Logger.getLogger(ProtocolProviderServiceYahooImpl.class);
-
- /**
- * The current yahoo session.
- */
- private YahooSession yahooSession = null;
-
- /**
- * indicates whether or not the provider is initialized and ready for use.
- */
- private boolean isInitialized = false;
-
- /**
- * We use this to lock access to initialization.
- */
- private final Object initializationLock = new Object();
-
- /**
- * The identifier of the account that this provider represents.
- */
- private AccountID accountID = null;
-
- /**
- * Used when we need to re-register
- */
- private SecurityAuthority authority = null;
-
- /**
- * The persistent presence operations set.
- */
- private OperationSetPersistentPresenceYahooImpl persistentPresence = null;
-
- /**
- * Typing notifications operations set.
- */
- private OperationSetTypingNotificationsYahooImpl typingNotifications = null;
-
- /**
- * The logo corresponding to the msn protocol.
- */
- private ProtocolIconYahooImpl yahooIcon
- = new ProtocolIconYahooImpl();
-
- /**
- * The connection listener.
- */
- private YahooConnectionListener connectionListener = null;
-
- /**
- * Returns the state of the registration of this protocol provider
- * @return the <tt>RegistrationState</tt> that this provider is
- * currently in or null in case it is in a unknown state.
- */
- public RegistrationState getRegistrationState()
- {
- if(yahooSession != null &&
- yahooSession.getSessionStatus() == StatusConstants.MESSAGING)
- return RegistrationState.REGISTERED;
- else
- return RegistrationState.UNREGISTERED;
- }
-
- /**
- * Starts the registration process. Connection details such as
- * registration server, user name/number are provided through the
- * configuration service through implementation specific properties.
- *
- * @param authority the security authority that will be used for resolving
- * any security challenges that may be returned during the
- * registration or at any moment while wer're registered.
- * @throws OperationFailedException with the corresponding code it the
- * registration fails for some reason (e.g. a networking error or an
- * implementation problem).
- */
- public void register(final SecurityAuthority authority)
- throws OperationFailedException
- {
- if(authority == null)
- throw new IllegalArgumentException(
- "The register method needs a valid non-null authority impl "
- + " in order to be able and retrieve passwords.");
-
- this.authority = authority;
-
- connectAndLogin(authority, SecurityAuthority.AUTHENTICATION_REQUIRED);
- }
-
- /**
- * Connects and logins to the server
- * @param authority SecurityAuthority
- * @param authReasonCode the authentication reason code, which should
- * indicate why are making an authentication request
- * @throws OperationFailedException if login parameters
- * as server port are not correct
- */
- private void connectAndLogin( SecurityAuthority authority,
- int authReasonCode)
- throws OperationFailedException
- {
- synchronized(initializationLock)
- {
- //verify whether a password has already been stored for this account
- String password = YahooActivator.
- getProtocolProviderFactory().loadPassword(getAccountID());
-
- // If the password hasn't been saved or the reason is one of those
- // listed below we need to ask the user for credentials again.
- if (password == null
- || authReasonCode == SecurityAuthority.WRONG_PASSWORD
- || authReasonCode == SecurityAuthority.WRONG_USERNAME)
- {
- //create a default credentials object
- UserCredentials credentials = new UserCredentials();
- credentials.setUserName(getAccountID().getUserID());
-
- //request a password from the user
- credentials = authority.obtainCredentials(
- getAccountID().getDisplayName(),
- credentials,
- authReasonCode);
-
- // in case user has canceled the login window
- if(credentials == null)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_USER_REQUEST, "");
- return;
- }
-
- //extract the password the user passed us.
- char[] pass = credentials.getPassword();
-
- // the user didn't provide us a password (canceled the operation)
- if(pass == null)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_USER_REQUEST, "");
- return;
- }
- password = new String(pass);
-
- if (credentials.isPasswordPersistent())
- {
- YahooActivator.getProtocolProviderFactory()
- .storePassword(getAccountID(), password);
- }
- }
-
- yahooSession = new YahooSession();
- connectionListener = new YahooConnectionListener();
- yahooSession.addSessionListener(connectionListener);
-
- try
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.REGISTERING,
- RegistrationStateChangeEvent.REASON_NOT_SPECIFIED, null);
-
- yahooSession.login(getAccountID().getUserID(), password);
-
- if(yahooSession.getSessionStatus()==StatusConstants.MESSAGING)
- {
- persistentPresence.fireProviderStatusChangeEvent(
- persistentPresence.getPresenceStatus(),
- persistentPresence.yahooStatusToPresenceStatus(
- yahooSession.getStatus()));
-
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.REGISTERED,
- RegistrationStateChangeEvent.REASON_NOT_SPECIFIED, null);
- }
- else
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_NOT_SPECIFIED, null);
- }
- }
- catch (LoginRefusedException ex)
- {
- if(ex.getStatus() == StatusConstants.STATUS_BADUSERNAME)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.AUTHENTICATION_FAILED,
- RegistrationStateChangeEvent.REASON_NON_EXISTING_USER_ID,
- null);
-
- reregister(SecurityAuthority.WRONG_USERNAME);
- }
- else if(ex.getStatus() == StatusConstants.STATUS_BAD)
- {
- YahooActivator.getProtocolProviderFactory()
- .storePassword(getAccountID(), null);
-
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.AUTHENTICATION_FAILED,
- RegistrationStateChangeEvent.REASON_AUTHENTICATION_FAILED,
- null);
-
- // Try to re-register and ask the user to retype the password.
- reregister(SecurityAuthority.WRONG_PASSWORD);
- }
- else if(ex.getStatus() == StatusConstants.STATUS_LOCKED)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.AUTHENTICATION_FAILED,
- RegistrationStateChangeEvent.REASON_RECONNECTION_RATE_LIMIT_EXCEEDED,
- null);
- }
- }
- catch (IOException ex)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.CONNECTION_FAILED,
- RegistrationStateChangeEvent.REASON_NOT_SPECIFIED, null);
- }
- catch (DnssecRuntimeException ex)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_USER_REQUEST, null);
- }
- }
- }
-
- /**
- * Reconnects if fails fire connection failed.
- * @param reasonCode the appropriate <tt>SecurityAuthority</tt> reasonCode,
- * which would specify the reason for which we're re-calling the login.
- */
- void reregister(int reasonCode)
- {
- try
- {
- connectAndLogin(authority, reasonCode);
- }
- catch (OperationFailedException ex)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.CONNECTION_FAILED,
- RegistrationStateChangeEvent.REASON_NOT_SPECIFIED, null);
- }
- }
-
- /**
- * Ends the registration of this protocol provider with the service.
- */
- public void unregister()
- {
- unregisterInternal(true);
- }
-
- /**
- * Unregister and fire the event if requested
- * @param fireEvent boolean
- */
- void unregisterInternal(boolean fireEvent)
- {
- RegistrationState currRegState = getRegistrationState();
-
- if(fireEvent)
- fireRegistrationStateChanged(
- currRegState,
- RegistrationState.UNREGISTERING,
- RegistrationStateChangeEvent.REASON_USER_REQUEST,
- null);
-
- try
- {
- if(connectionListener != null && yahooSession != null)
- {
- yahooSession.removeSessionListener(connectionListener);
- connectionListener = null;
- }
-
- if((yahooSession != null)
- && (yahooSession.getSessionStatus() == StatusConstants.MESSAGING))
- yahooSession.logout();
- }
- catch(Exception ex)
- {
- logger.error("Cannot logout! ", ex);
- }
-
- yahooSession = null;
-
- if(fireEvent)
- fireRegistrationStateChanged(
- currRegState,
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_USER_REQUEST,
- null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see net.java.sip.communicator.service.protocol.ProtocolProviderService#
- * isSignallingTransportSecure()
- */
- public boolean isSignalingTransportSecure()
- {
- return false;
- }
-
- /**
- * Returns the "transport" protocol of this instance used to carry the
- * control channel for the current protocol service.
- *
- * @return The "transport" protocol of this instance: TCP.
- */
- public TransportProtocol getTransportProtocol()
- {
- return TransportProtocol.TCP;
- }
-
- /**
- * Returns the short name of the protocol that the implementation of this
- * provider is based upon (like SIP, Msn, ICQ/AIM, or others for
- * example).
- *
- * @return a String containing the short name of the protocol this
- * service is taking care of.
- */
- public String getProtocolName()
- {
- return ProtocolNames.YAHOO;
- }
-
- /**
- * Initialized the service implementation, and puts it in a sate where it
- * could interoperate with other services. It is strongly recomended that
- * properties in this Map be mapped to property names as specified by
- * <tt>AccountProperties</tt>.
- *
- * @param screenname the account id/uin/screenname of the account that
- * we're about to create
- * @param accountID the identifier of the account that this protocol
- * provider represents.
- *
- * @see net.java.sip.communicator.service.protocol.AccountID
- */
- protected void initialize(String screenname,
- AccountID accountID)
- {
- synchronized(initializationLock)
- {
- this.accountID = accountID;
-
- addSupportedOperationSet(
- OperationSetInstantMessageTransform.class,
- new OperationSetInstantMessageTransformImpl());
-
- //initialize the presence operationset
- persistentPresence
- = new OperationSetPersistentPresenceYahooImpl(this);
- addSupportedOperationSet(
- OperationSetPersistentPresence.class,
- persistentPresence);
- //register it once again for those that simply need presence
- addSupportedOperationSet(
- OperationSetPresence.class,
- persistentPresence);
-
- //initialize the IM operation set
- addSupportedOperationSet(
- OperationSetBasicInstantMessaging.class,
- new OperationSetBasicInstantMessagingYahooImpl(this));
-
- //initialize the multi user chat operation set
- addSupportedOperationSet(
- OperationSetAdHocMultiUserChat.class,
- new OperationSetAdHocMultiUserChatYahooImpl(this));
-
- //initialize the typing notifications operation set
- typingNotifications
- = new OperationSetTypingNotificationsYahooImpl(this);
- addSupportedOperationSet(
- OperationSetTypingNotifications.class,
- typingNotifications);
-
- addSupportedOperationSet(
- OperationSetFileTransfer.class,
- new OperationSetFileTransferYahooImpl(this));
-
- isInitialized = true;
- }
- }
-
- /**
- * Makes the service implementation close all open sockets and release
- * any resources that it might have taken and prepare for
- * shutdown/garbage collection.
- */
- public void shutdown()
- {
- synchronized(initializationLock){
- unregisterInternal(false);
- yahooSession = null;
- isInitialized = false;
- }
- }
-
- /**
- * Returns true if the provider service implementation is initialized and
- * ready for use by other services, and false otherwise.
- *
- * @return true if the provider is initialized and ready for use and false
- * otherwise
- */
- public boolean isInitialized()
- {
- return isInitialized;
- }
-
- /**
- * Returns the AccountID that uniquely identifies the account represented
- * by this instance of the ProtocolProviderService.
- * @return the id of the account represented by this provider.
- */
- public AccountID getAccountID()
- {
- return accountID;
- }
-
- /**
- * Returns the Yahoo<tt>Session</tt>opened by this provider
- * @return a reference to the <tt>Session</tt> last opened by this
- * provider.
- */
- YahooSession getYahooSession()
- {
- return yahooSession;
- }
-
- /**
- * Creates a RegistrationStateChange event corresponding to the specified
- * old and new states and notifies all currently registered listeners.
- *
- * @param oldState the state that the provider had before the change
- * occurred
- * @param newState the state that the provider is currently in.
- * @param reasonCode a value corresponding to one of the REASON_XXX fields
- * of the RegistrationStateChangeEvent class, indicating the reason for
- * this state transition.
- * @param reason a String further explaining the reason code or null if
- * no such explanation is necessary.
- */
- @Override
- public void fireRegistrationStateChanged( RegistrationState oldState,
- RegistrationState newState,
- int reasonCode,
- String reason)
- {
- if(newState.equals(RegistrationState.UNREGISTERED))
- {
- unregisterInternal(false);
- yahooSession = null;
- }
-
- super.fireRegistrationStateChanged(oldState, newState, reasonCode, reason);
- }
-
- /**
- * Listens when we are logged in the server
- * or incoming exception in the lib impl.
- */
- private class YahooConnectionListener
- extends SessionAdapter
- {
- /**
- * Yahoo has logged us off the system, or the connection was lost
- *
- * @param ev the event
- */
- @Override
- public void connectionClosed(SessionEvent ev)
- {
- if(isRegistered())
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.CONNECTION_FAILED,
- RegistrationStateChangeEvent.REASON_NOT_SPECIFIED, null);
- }
-
- /**
- * Some exception has occurred in stack.
- * @param ev
- */
- @Override
- public void inputExceptionThrown(SessionExceptionEvent ev)
- {
- if(ev.getException() instanceof YMSG9BadFormatException)
- {
- logger.error("Yahoo protocol exception occured exception",
- ev.getException());
- logger.error("Yahoo protocol exception occured exception cause",
- ev.getException().getCause());
- }
- else
- logger.error(
- "Yahoo protocol exception occured", ev.getException());
-
- unregisterInternal(false);
- if(isRegistered())
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_INTERNAL_ERROR, null);
- }
- }
-
- /**
- * Returns the yahoo protocol icon.
- * @return the yahoo protocol icon
- */
- public ProtocolIcon getProtocolIcon()
- {
- return yahooIcon;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/RootContactGroupYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/RootContactGroupYahooImpl.java
deleted file mode 100644
index 856bb30..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/RootContactGroupYahooImpl.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * A dummy ContactGroup implementation representing the ContactList root for
- * Yahoo contact lists.
- * @author Damian Minkov
- */
-public class RootContactGroupYahooImpl
- extends AbstractContactGroupYahooImpl
-{
- private String ROOT_CONTACT_GROUP_NAME = "ContactListRoot";
- private List<ContactGroup> subGroups = new LinkedList<ContactGroup>();
- private boolean isResolved = false;
-
- /**
- * An empty list that we use when returning an iterator.
- */
- private List<Contact> dummyContacts = new LinkedList<Contact>();
-
- private final ProtocolProviderServiceYahooImpl protocolProvider;
-
- /**
- * Creates a ContactGroup instance.
- */
- RootContactGroupYahooImpl(ProtocolProviderServiceYahooImpl protocolProvider)
- {
- this.protocolProvider = protocolProvider;
- }
-
- /**
- * The ContactListRoot is the only group that can contain subgroups.
- *
- * @return true (always)
- */
- public boolean canContainSubgroups()
- {
- return true;
- }
-
- /**
- * Returns the name of this group which is always
- * <tt>ROOT_CONTACT_GROUP_NAME</tt>.
- *
- * @return a String containing the name of this group.
- */
- public String getGroupName()
- {
- return ROOT_CONTACT_GROUP_NAME;
- }
-
- /**
- * Adds the specified group to the end of the list of sub groups.
- * @param group the group to add.
- */
- void addSubGroup(ContactGroupYahooImpl group)
- {
- subGroups.add(group);
- }
-
- /**
- * Removes the specified from the list of sub groups
- * @param group the group to remove.
- */
- void removeSubGroup(ContactGroupYahooImpl group)
- {
- removeSubGroup(subGroups.indexOf(group));
- }
-
- /**
- * Removes the sub group with the specified index.
- * @param index the index of the group to remove
- */
- void removeSubGroup(int index)
- {
- subGroups.remove(index);
- }
-
- /**
- * Returns the number of subgroups contained by this
- * <tt>RootContactGroupImpl</tt>.
- *
- * @return an int indicating the number of subgroups that this
- * ContactGroup contains.
- */
- public int countSubgroups()
- {
- return subGroups.size();
- }
-
- /**
- * Returns null as this is the root contact group.
- * @return null as this is the root contact group.
- */
- public ContactGroup getParentContactGroup()
- {
- return null;
- }
-
- /**
- * Returns the subgroup with the specified index.
- *
- * @param index the index of the <tt>ContactGroup</tt> to retrieve.
- * @return the <tt>ContactGroup</tt> with the specified index.
- */
- public ContactGroup getGroup(int index)
- {
- return subGroups.get(index);
- }
-
- /**
- * Returns the subgroup with the specified name.
- * @param groupName the name of the <tt>ContactGroup</tt> to retrieve.
- * @return the <tt>ContactGroup</tt> with the specified index.
- */
- public ContactGroup getGroup(String groupName)
- {
- Iterator<ContactGroup> subgroups = subgroups();
- while (subgroups.hasNext())
- {
- ContactGroup grp = subgroups.next();
-
- if (grp.getGroupName().equals(groupName))
- return grp;
- }
-
- return null;
- }
-
- /**
- * Returns an iterator over the sub groups that this
- * <tt>ContactGroup</tt> contains.
- *
- * @return a java.util.Iterator over the <tt>ContactGroup</tt>
- * children of this group (i.e. subgroups).
- */
- public Iterator<ContactGroup> subgroups()
- {
- return subGroups.iterator();
- }
-
- /**
- * Returns the number, which is always 0, of <tt>Contact</tt> members
- * of this <tt>ContactGroup</tt>
- * @return an int indicating the number of <tt>Contact</tt>s, members
- * of this <tt>ContactGroup</tt>.
- */
- public int countContacts()
- {
- return dummyContacts.size();
- }
-
- /**
- * Returns an Iterator over all contacts, member of this
- * <tt>ContactGroup</tt>.
- * @return a java.util.Iterator over all contacts inside this
- * <tt>ContactGroup</tt>
- */
- public Iterator<Contact> contacts()
- {
- return dummyContacts.iterator();
- }
-
- /**
- * Returns the <tt>Contact</tt> with the specified address or
- * identifier.
- * @param id the addres or identifier of the <tt>Contact</tt> we are
- * looking for.
- * @return the <tt>Contact</tt> with the specified id or address.
- */
- public Contact getContact(String id)
- {
- //no contacts in the root group for this yahoo impl.
- return null;
- }
-
-
- /**
- * Returns a string representation of the root contact group that contains
- * all subgroups and subcontacts of this group.
- *
- * @return a string representation of this root contact group.
- */
- @Override
- public String toString()
- {
- StringBuffer buff = new StringBuffer(getGroupName());
- buff.append(".subGroups=" + countSubgroups() + ":\n");
-
- Iterator<ContactGroup> subGroups = subgroups();
- while (subGroups.hasNext())
- {
- ContactGroup group = subGroups.next();
- buff.append(group.toString());
- if (subGroups.hasNext())
- buff.append("\n");
- }
- return buff.toString();
- }
-
- /**
- * Returns the protocol provider that this group belongs to.
- * @return a regerence to the ProtocolProviderService instance that this
- * ContactGroup belongs to.
- */
- public ProtocolProviderService getProtocolProvider()
- {
- return protocolProvider;
- }
-
- /**
- * Determines whether or not this contact group is being stored by the
- * server. Non persistent contact groups exist for the sole purpose of
- * containing non persistent contacts.
- * @return true if the contact group is persistent and false otherwise.
- */
- public boolean isPersistent()
- {
- return true;
- }
-
- /**
- * Returns null as no persistent data is required and the group name is
- * sufficient for restoring the contact.
- * <p>
- * @return null as no such data is needed.
- */
- public String getPersistentData()
- {
- return null;
- }
-
- /**
- * Determines whether or not this group has been resolved against the
- * server. Unresolved groups are used when initially loading a contact
- * list that has been stored in a local file until the presence operation
- * set has managed to retrieve all the contact list from the server and has
- * properly mapped groups to their on-line buddies.
- * @return true if the group has been resolved (mapped against a buddy)
- * and false otherwise.
- */
- public boolean isResolved()
- {
- return isResolved;
- }
-
- /**
- * Returns a <tt>String</tt> that uniquely represnets the group. In this we
- * use the name of the group as an identifier. This may cause problems
- * though, in clase the name is changed by some other application between
- * consecutive runs of the sip-communicator.
- *
- * @return a String representing this group in a unique and persistent
- * way.
- */
- public String getUID()
- {
- return getGroupName();
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ServerStoredContactListYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ServerStoredContactListYahooImpl.java
deleted file mode 100644
index e732b84..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/ServerStoredContactListYahooImpl.java
+++ /dev/null
@@ -1,1274 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import ymsg.network.*;
-import ymsg.network.event.*;
-
-/**
- * This class encapsulates the Roster class. Once created, it will
- * register itself as a listener to the encapsulated Roster and modify it's
- * local copy of Contacts and ContactGroups every time an event is generated
- * by the underlying framework. The class would also generate
- * corresponding sip-communicator events to all events coming from smack.
- *
- * @author Damian Minkov
- * @author Emil Ivov
- */
-public class ServerStoredContactListYahooImpl
-{
- private static final Logger logger =
- Logger.getLogger(ServerStoredContactListYahooImpl.class);
-
- /**
- * If there is no group and we add contact with no parent
- * a default group is created with name : DEFAULT_GROUP_NAME
- */
- private static final String DEFAULT_GROUP_NAME = "General";
-
- /**
- * The root contagroup. The container for all yahoo buddies and groups.
- */
- private final RootContactGroupYahooImpl rootGroup;
-
- /**
- * The operation set that created us and that we could use when dispatching
- * subscription events.
- */
- private final OperationSetPersistentPresenceYahooImpl parentOperationSet;
-
- /**
- * The provider that is on top of us.
- */
- private final ProtocolProviderServiceYahooImpl yahooProvider;
-
- private YahooSession yahooSession = null;
-
- /**
- * Listeners that would receive event notifications for changes in group
- * names or other properties, removal or creation of groups.
- */
- private Vector<ServerStoredGroupListener> serverStoredGroupListeners
- = new Vector<ServerStoredGroupListener>();
-
- private ContactListModListenerImpl contactListModListenerImpl
- = new ContactListModListenerImpl();
-
- /**
- * Handler for incoming authorization requests.
- */
- private AuthorizationHandler handler = null;
-
- private Hashtable<String, String> addedCustomYahooIds
- = new Hashtable<String, String>();
-
- /**
- * Creates a ServerStoredContactList wrapper for the specified BuddyList.
- *
- * @param parentOperationSet the operation set that created us and that
- * we could use for dispatching subscription events
- * @param provider the provider that has instantiated us.
- */
- ServerStoredContactListYahooImpl(
- OperationSetPersistentPresenceYahooImpl parentOperationSet,
- ProtocolProviderServiceYahooImpl provider)
- {
- //We need to init these as early as possible to ensure that the provider
- //and the operationsset would not be null in the incoming events.
- this.parentOperationSet = parentOperationSet;
-
- this.yahooProvider = provider;
- this.rootGroup = new RootContactGroupYahooImpl(this.yahooProvider);
- }
-
- /**
- * Handler for incoming authorization requests.
- *
- * @param handler an instance of an AuthorizationHandler for
- * authorization requests coming from other users requesting
- * permission add us to their contact list.
- */
- public void setAuthorizationHandler(AuthorizationHandler handler)
- {
- this.handler = handler;
- }
-
- /**
- * Returns the root group of the contact list.
- *
- * @return the root ContactGroup for the ContactList
- */
- public ContactGroup getRootGroup()
- {
- return rootGroup;
- }
-
- /**
- * Registers the specified group listener so that it would receive events
- * on group modification/creation/destruction.
- * @param listener the ServerStoredGroupListener to register for group
- * events
- */
- void addGroupListener(ServerStoredGroupListener listener)
- {
- synchronized(serverStoredGroupListeners)
- {
- if(!serverStoredGroupListeners.contains(listener))
- serverStoredGroupListeners.add(listener);
- }
- }
-
- /**
- * Removes the specified group listener so that it won't receive further
- * events on group modification/creation/destruction.
- * @param listener the ServerStoredGroupListener to unregister
- */
- void removeGroupListener(ServerStoredGroupListener listener)
- {
- synchronized(serverStoredGroupListeners)
- {
- this.serverStoredGroupListeners.remove(listener);
- }
- }
-
- /**
- * Creates the corresponding event and notifies all
- * <tt>ServerStoredGroupListener</tt>s that the source group has been
- * removed, changed, renamed or whatever happened to it.
- * @param group the ContactGroup that has been created/modified/removed
- * @param eventID the id of the event to generate.
- */
- private void fireGroupEvent(ContactGroupYahooImpl group, int eventID)
- {
- //bail out if no one's listening
- if(parentOperationSet == null){
- if (logger.isDebugEnabled())
- logger.debug("No presence op. set available. Bailing out.");
- return;
- }
-
- ServerStoredGroupEvent evt = new ServerStoredGroupEvent(
- group
- , eventID
- , parentOperationSet.getServerStoredContactListRoot()
- , yahooProvider
- , parentOperationSet);
-
- if (logger.isTraceEnabled())
- logger.trace("Will dispatch the following grp event: " + evt);
-
- Iterable<ServerStoredGroupListener> listeners;
- synchronized (serverStoredGroupListeners)
- {
- listeners
- = new ArrayList<ServerStoredGroupListener>(
- serverStoredGroupListeners);
- }
-
- for (ServerStoredGroupListener listener : listeners)
- {
- try{
- if (eventID == ServerStoredGroupEvent.GROUP_REMOVED_EVENT)
- listener.groupRemoved(evt);
- else if (eventID == ServerStoredGroupEvent.GROUP_RENAMED_EVENT)
- listener.groupNameChanged(evt);
- else if (eventID == ServerStoredGroupEvent.GROUP_CREATED_EVENT)
- listener.groupCreated(evt);
- else if (eventID == ServerStoredGroupEvent.GROUP_RESOLVED_EVENT)
- listener.groupResolved(evt);
- }catch(Exception ex){
- logger.warn("Unhandled Exception! ", ex);
- }
- }
- }
-
- /**
- * Make the parent persistent presence operation set dispatch a contact
- * removed event.
- * @param parentGroup the group where that the removed contact belonged to.
- * @param contact the contact that was removed.
- */
- private void fireContactRemoved( ContactGroup parentGroup,
- ContactYahooImpl contact)
- {
- //bail out if no one's listening
- if(parentOperationSet == null){
- if (logger.isDebugEnabled())
- logger.debug("No presence op. set available. Bailing out.");
- return;
- }
-
- //dispatch
- parentOperationSet.fireSubscriptionEvent(
- contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_REMOVED);
- }
-
- /**
- * Make the parent persistent presence operation set dispatch a subscription
- * moved event.
- * @param oldParentGroup the group where the source contact was located
- * before being moved
- * @param newParentGroup the group that the source contact is currently in.
- * @param contact the contact that was added
- */
- private void fireContactMoved( ContactGroup oldParentGroup,
- ContactGroupYahooImpl newParentGroup,
- ContactYahooImpl contact)
- {
- //bail out if no one's listening
- if(parentOperationSet == null){
- if (logger.isDebugEnabled())
- logger.debug("No presence op. set available. Bailing out.");
- return;
- }
-
- //dispatch
- parentOperationSet.fireSubscriptionMovedEvent(
- contact, oldParentGroup, newParentGroup);
- }
-
- /**
- * Returns a reference to the provider that created us.
- * @return a reference to a ProtocolProviderServiceImpl instance.
- */
- ProtocolProviderServiceYahooImpl getParentProvider()
- {
- return yahooProvider;
- }
-
- /**
- * Returns the ConntactGroup with the specified name or null if no such
- * group was found.
- * <p>
- * @param name the name of the group we're looking for.
- * @return a reference to the ContactGroupYahooImpl instance we're looking
- * for or null if no such group was found.
- */
- public ContactGroupYahooImpl findContactGroup(String name)
- {
- String nameToLookFor = replaceIllegalChars(name);
- Iterator<ContactGroup> contactGroups = rootGroup.subgroups();
-
- while(contactGroups.hasNext())
- {
- ContactGroupYahooImpl contactGroup
- = (ContactGroupYahooImpl) contactGroups.next();
-
- if (contactGroup.getGroupName().equals(nameToLookFor))
- return contactGroup;
- }
-
- return null;
- }
-
- /**
- * Returns the Contact with the specified id or null if
- * no such id was found.
- *
- * @param id the id of the contact to find.
- * @return the <tt>Contact</tt> carrying the specified
- * <tt>screenName</tt> or <tt>null</tt> if no such contact exits.
- */
- public ContactYahooImpl findContactById(String id)
- {
- Iterator<ContactGroup> contactGroups = rootGroup.subgroups();
- ContactYahooImpl result = null;
-
- while(contactGroups.hasNext())
- {
- ContactGroupYahooImpl contactGroup
- = (ContactGroupYahooImpl) contactGroups.next();
-
- result = contactGroup.findContact(id);
-
- if (result != null)
- return result;
- }
-
- return null;
- }
-
- /**
- * Returns the Contact corresponding to the specified <tt>YahooUser</tt>
- * or null if no such id was found.
- *
- * @param yahooUser the YahooUser of the contact to find.
- * @return the <tt>Contact</tt> carrying the specified
- * <tt>screenName</tt> or <tt>null</tt> if no such contact exits.
- */
- public ContactYahooImpl findContactByYahooUser(YahooUser yahooUser)
- {
- return findContactById(yahooUser.getId().toLowerCase());
- }
-
- /**
- * Returns the ContactGroup containing the specified contact or null
- * if no such group or contact exist.
- *
- * @param child the contact whose parent group we're looking for.
- * @return the <tt>ContactGroup</tt> containing the specified
- * <tt>contact</tt> or <tt>null</tt> if no such groupo or contact
- * exist.
- */
- public ContactGroup findContactGroup(ContactYahooImpl child)
- {
- Iterator<ContactGroup> contactGroups = rootGroup.subgroups();
- String contactAddress = child.getAddress();
-
- while(contactGroups.hasNext())
- {
- ContactGroupYahooImpl contactGroup
- = (ContactGroupYahooImpl) contactGroups.next();
-
- if( contactGroup.findContact(contactAddress)!= null)
- return contactGroup;
- }
-
- return null;
- }
-
- /**
- * Adds a new contact with the specified screenname to the list under a
- * default location.
- * @param id the id of the contact to add.
- * @throws OperationFailedException
- */
- public void addContact(String id)
- throws OperationFailedException
- {
- ContactGroupYahooImpl parent = getFirstPersistentGroup();
-
- if(parent == null)
- {
- // if there is no group create it
- parent = createUnresolvedContactGroup(DEFAULT_GROUP_NAME);
- }
-
- addContact(parent, id);
- }
-
- /**
- * Adds a new contact with the specified screenname to the list under the
- * specified group.
- * @param id the id of the contact to add.
- * @param parent the group under which we want the new contact placed.
- * @throws OperationFailedException if the contact already exist
- */
- public void addContact(final ContactGroupYahooImpl parent, String id)
- throws OperationFailedException
- {
- if (logger.isTraceEnabled())
- logger.trace("Adding contact " + id + " to parent=" + parent);
-
- //if the contact is already in the contact list and is not volatile,
- //then only broadcast an event
- ContactYahooImpl existingContact = findContactById(id);
-
- if( existingContact != null
- && existingContact.isPersistent() )
- {
- if (logger.isDebugEnabled())
- logger.debug("Contact " + id + " already exists.");
- throw new OperationFailedException(
- "Contact " + id + " already exists.",
- OperationFailedException.SUBSCRIPTION_ALREADY_EXISTS);
- }
-
- if(id.indexOf("@") > -1 )
- addedCustomYahooIds.put(YahooSession.getYahooUserID(id), id);
-
- try
- {
- yahooSession.addFriend(YahooSession.getYahooUserID(id),
- parent.getGroupName());
- }
- catch(IOException ex)
- {
- throw new OperationFailedException(
- "Contact cannot be added " + id,
- OperationFailedException.NETWORK_FAILURE);
- }
- }
-
- /**
- * Creates a non persistent contact for the specified address. This would
- * also create (if necessary) a group for volatile contacts that would not
- * be added to the server stored contact list. This method would have no
- * effect on the server stored contact list.
- * @param id the address of the contact to create.
- * @return the newly created volatile <tt>ContactImpl</tt>
- */
- ContactYahooImpl createVolatileContact(String id)
- {
- if (logger.isTraceEnabled())
- logger.trace("Creating volatile contact " + id);
- ContactYahooImpl newVolatileContact =
- new ContactYahooImpl(id, this, false, false, true);
-
- //Check whether a volatile group already exists and if not create one
- ContactGroupYahooImpl theVolatileGroup = getNonPersistentGroup();
-
- //if the parent group is null then create it
- if (theVolatileGroup == null)
- {
- theVolatileGroup = new VolatileContactGroupYahooImpl(
- YahooActivator.getResources().getI18NString(
- "service.gui.NOT_IN_CONTACT_LIST_GROUP_NAME"),
- this);
-
- theVolatileGroup.addContact(newVolatileContact);
-
- this.rootGroup.addSubGroup(theVolatileGroup);
-
- fireGroupEvent(theVolatileGroup
- , ServerStoredGroupEvent.GROUP_CREATED_EVENT);
- }
- else
- {
- theVolatileGroup.addContact(newVolatileContact);
-
- fireContactAdded(theVolatileGroup, newVolatileContact);
- }
-
- return newVolatileContact;
- }
-
-
- /**
- * Creates a non resolved contact for the specified address and inside the
- * specified group. The newly created contact would be added to the local
- * contact list as a standard contact but when an event is received from the
- * server concerning this contact, then it will be reused and only its
- * isResolved field would be updated instead of creating the whole contact
- * again.
- *
- * @param parentGroup the group where the unersolved contact is to be
- * created
- * @param id the Address of the contact to create.
- * @return the newly created unresolved <tt>ContactImpl</tt>
- */
- ContactYahooImpl createUnresolvedContact(ContactGroup parentGroup,
- String id)
- {
- if (logger.isTraceEnabled())
- logger.trace("Creating unresolved contact " + id
- + " to parent=" + parentGroup);
-
- ContactYahooImpl existingContact = findContactById(id);
-
- if( existingContact != null)
- {
- return existingContact;
- }
-
- ContactYahooImpl newUnresolvedContact
- = new ContactYahooImpl(id, this, false, true, false);
-
- if(parentGroup instanceof ContactGroupYahooImpl)
- ((ContactGroupYahooImpl)parentGroup).
- addContact(newUnresolvedContact);
-
- fireContactAdded(parentGroup, newUnresolvedContact);
-
- return newUnresolvedContact;
- }
-
- /**
- * Creates a non resolved contact group for the specified name. The newly
- * created group would be added to the local contact list as any other group
- * but when an event is received from the server concerning this group, then
- * it will be reused and only its isResolved field would be updated instead
- * of creating the whole group again.
- * <p>
- * @param groupName the name of the group to create.
- * @return the newly created unresolved <tt>ContactGroupImpl</tt>
- */
- ContactGroupYahooImpl createUnresolvedContactGroup(String groupName)
- {
- ContactGroupYahooImpl existingGroup = findContactGroup(groupName);
-
- if( existingGroup != null )
- {
- if (logger.isDebugEnabled())
- logger.debug("ContactGroup " + groupName + " already exists.");
- return existingGroup;
- }
-
- ContactGroupYahooImpl newUnresolvedGroup =
- new ContactGroupYahooImpl(groupName, this);
-
- this.rootGroup.addSubGroup(newUnresolvedGroup);
-
- fireGroupEvent(newUnresolvedGroup
- , ServerStoredGroupEvent.GROUP_CREATED_EVENT);
-
- return newUnresolvedGroup;
- }
-
- /**
- * Creates the specified group on the server stored contact list.
- * @param groupName a String containing the name of the new group.
- * @throws OperationFailedException with code CONTACT_GROUP_ALREADY_EXISTS
- * if the group we're trying to create is already in our contact list.
- */
- public void createGroup(String groupName)
- throws OperationFailedException
- {
- if (logger.isTraceEnabled())
- logger.trace("Creating group: " + groupName);
-
- ContactGroupYahooImpl existingGroup = findContactGroup(groupName);
-
- if( existingGroup != null && existingGroup.isPersistent() )
- {
- if (logger.isDebugEnabled())
- logger.debug("ContactGroup " + groupName + " already exists.");
- throw new OperationFailedException(
- "ContactGroup " + groupName + " already exists.",
- OperationFailedException.CONTACT_GROUP_ALREADY_EXISTS);
- }
-
- // create unresolved group if friend is added - group will be resolved
- createUnresolvedContactGroup(groupName);
- }
-
- /**
- * Removes the specified group from the buddy list.
- * @param groupToRemove the group that we'd like removed.
- */
- @SuppressWarnings("unchecked") //jymsg legacy code
- public void removeGroup(ContactGroupYahooImpl groupToRemove)
- {
- // to remove group just remove all the contacts in it
-
- if (logger.isTraceEnabled())
- logger.trace("removing group " + groupToRemove);
-
- // if its not persistent group just remove it
- if(!groupToRemove.isPersistent() || !groupToRemove.isResolved())
- {
- rootGroup.removeSubGroup(groupToRemove);
- fireGroupEvent(groupToRemove,
- ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
- return;
- }
-
- Vector<YahooUser> contacts
- = groupToRemove.getSourceGroup().getMembers();
-
- if(contacts.size() == 0)
- {
- // the group is empty just remove it
- rootGroup.removeSubGroup(groupToRemove);
- fireGroupEvent(groupToRemove,
- ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
- return;
- }
-
- /*
- * ContactGroupYahooImpl#getGroupName() isn't a plain getter so
- * performance-wise we're better off not calling it multiple times in
- * the following loop.
- */
- String groupToRemoveName = groupToRemove.getGroupName();
-
- for (YahooUser item : contacts)
- {
- try
- {
- yahooSession.removeFriend(item.getId(), groupToRemoveName);
- }
- catch(IOException ex)
- {
- if (logger.isInfoEnabled())
- logger.info("Cannot Remove contact " + item.getId());
- }
- }
- }
-
- /**
- * Removes a contact from the serverside list
- * Event will come for successful operation
- * @param contactToRemove ContactYahooImpl
- */
- void removeContact(ContactYahooImpl contactToRemove)
- {
- if (logger.isTraceEnabled())
- logger.trace("Removing yahoo contact "
- + contactToRemove.getSourceContact());
-
- if(contactToRemove.isVolatile())
- {
- ContactGroupYahooImpl parent =
- (ContactGroupYahooImpl)contactToRemove.getParentContactGroup();
-
- parent.removeContact(contactToRemove);
- fireContactRemoved(parent, contactToRemove);
- return;
- }
-
- try
- {
- yahooSession.removeFriend(
- contactToRemove.getSourceContact().getId(),
- contactToRemove.getParentContactGroup().getGroupName());
- }
- catch(IOException ex)
- {
- if (logger.isInfoEnabled())
- logger.info("Cannot Remove contact " + contactToRemove);
- }
- }
-
- /**
- * Renames the specified group according to the specified new name..
- * @param groupToRename the group that we'd like removed.
- * @param newName the new name of the group
- */
- public void renameGroup(ContactGroupYahooImpl groupToRename, String newName)
- {
- // not working
- /*
- try
- {
- yahooSession.renameGroup(groupToRename.getGroupName(), newName);
- }
- catch(IOException ex)
- {
- if (logger.isInfoEnabled())
- logger.info("Cannot rename group " + groupToRename);
- }
-
- fireGroupEvent(groupToRename,
- ServerStoredGroupEvent.GROUP_RENAMED_EVENT);
- */
- }
-
- /**
- * Moves the specified <tt>contact</tt> to the group indicated by
- * <tt>newParent</tt>.
- * @param contact the contact that we'd like moved under the new group.
- * @param newParent the group where we'd like the parent placed.
- */
- public void moveContact(ContactYahooImpl contact,
- ContactGroupYahooImpl newParent)
- {
- String userID = contact.getID();
- try
- {
- contactListModListenerImpl.
- waitForMove(userID,
- contact.getParentContactGroup().getGroupName());
-
- yahooSession.addFriend(
- userID,
- newParent.getGroupName());
- }
- catch(IOException ex)
- {
- contactListModListenerImpl.removeWaitForMove(userID);
- logger.error("Contact cannot be added " + ex.getMessage());
- }
- }
-
- /**
- * Returns the volatile group
- *
- * @return ContactGroupYahooImpl
- */
- private ContactGroupYahooImpl getNonPersistentGroup()
- {
- for (int i = 0; i < getRootGroup().countSubgroups(); i++)
- {
- ContactGroupYahooImpl gr =
- (ContactGroupYahooImpl)getRootGroup().getGroup(i);
-
- if(!gr.isPersistent())
- return gr;
- }
-
- return null;
- }
-
- /**
- * Returns the first persistent group
- *
- * @return ContactGroupIcqImpl
- */
- private ContactGroupYahooImpl getFirstPersistentGroup()
- {
- for (int i = 0; i < getRootGroup().countSubgroups(); i++)
- {
- ContactGroupYahooImpl gr =
- (ContactGroupYahooImpl)getRootGroup().getGroup(i);
-
- if(gr.isPersistent())
- return gr;
- }
-
- return null;
- }
-
- /**
- * Make the parent persistent presence operation set dispatch a contact
- * added event.
- * @param parentGroup the group where the new contact was added
- * @param contact the contact that was added
- */
- void fireContactAdded( ContactGroup parentGroup,
- ContactYahooImpl contact)
- {
- //bail out if no one's listening
- if(parentOperationSet == null){
- if (logger.isDebugEnabled())
- logger.debug("No presence op. set available. Bailing out.");
- return;
- }
-
- //dispatch
- parentOperationSet.fireSubscriptionEvent(
- contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_CREATED);
- }
-
- /**
- * Make the parent persistent presence operation set dispatch a contact
- * resolved event.
- * @param parentGroup the group that the resolved contact belongs to.
- * @param contact the contact that was resolved
- */
- void fireContactResolved( ContactGroup parentGroup,
- ContactYahooImpl contact)
- {
- //bail out if no one's listening
- if(parentOperationSet == null){
- if (logger.isDebugEnabled())
- logger.debug("No presence op. set available. Bailing out.");
- return;
- }
-
- //dispatch
- parentOperationSet.fireSubscriptionEvent(
- contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_RESOLVED);
- }
-
- /**
- * When the protocol is online this method is used to fill or resolve
- * the current contact list
- */
- @SuppressWarnings("unchecked") //jymsg legacy code
- private void initList()
- {
- if (logger.isTraceEnabled())
- logger.trace("Start init list of "
- + yahooProvider.getAccountID().getUserID());
-
- for (YahooGroup item : yahooSession.getGroups())
- {
- ContactGroupYahooImpl group = findContactGroup(item.getName());
-
- if(group == null)
- {
- // create the group as it doesn't exist
- group = new ContactGroupYahooImpl(
- item, item.getMembers(), this, true);
-
- rootGroup.addSubGroup(group);
-
- //tell listeners about the added group
- fireGroupEvent(group,
- ServerStoredGroupEvent.GROUP_CREATED_EVENT);
- }
- else
- {
- // the group exist so just resolved. The group will check and
- // create or resolve its entries
- group.setResolved(item);
-
- //fire an event saying that the group has been resolved
- fireGroupEvent(group
- , ServerStoredGroupEvent.GROUP_RESOLVED_EVENT);
-
- /** @todo if something to delete . delete it */
- }
-
- if (logger.isTraceEnabled())
- logger.trace("Init of group done! : " + group);
- }
- }
-
- /**
- * @param name Name of the group to search
- * @return The yahoo group with given name
- */
- private YahooGroup findGroup(String name)
- {
- for (YahooGroup elem : yahooSession.getGroups())
- {
- if(elem.getName().equals(name))
- return elem;
- }
- return null;
- }
-
- /**
- * Process incoming authorization requests.
- * @param ev the event to process.
- */
- void processAuthorizationRequest(SessionAuthorizationEvent ev)
- {
- if(handler == null)
- return;
-
- Contact srcContact = findContactById(ev.getFrom());
-
- // if there is no such contact we create it as
- // volatile so we can fire notification
- // and then if accepted add it in the protocol
- // so we can receive its states
- boolean isCurrentlyCreated = false;
- if(srcContact == null)
- {
- srcContact = createVolatileContact(ev.getFrom());
- isCurrentlyCreated = true;
- }
-
- AuthorizationRequest authRequest = new AuthorizationRequest();
- authRequest.setReason(ev.getMessage());
-
- AuthorizationResponse authResponse =
- handler.processAuthorisationRequest(
- authRequest, srcContact);
-
- if (authResponse.getResponseCode() == AuthorizationResponse.IGNORE)
- {
- return;
- }
- else if (authResponse.getResponseCode() == AuthorizationResponse.REJECT)
- {
- removeContact((ContactYahooImpl)srcContact);
- try
- {
- yahooSession.rejectFriendAuthorization(
- ev, ev.getFrom(), authResponse.getReason());
- }
- catch(IOException ex)
- {
- logger.error("cannot send auth deny", ex);
- }
-
- return;
- }
-
- // else we accepted it
- try
- {
- yahooSession.acceptFriendAuthorization(ev, ev.getFrom());
- }
- catch(IOException ex)
- {
- logger.error("cannot send auth deny", ex);
- }
-
- if(isCurrentlyCreated)
- try
- {
- addContact(ev.getFrom());
- }
- catch (OperationFailedException ex)
- {
- logger.error("Cannot add friend", ex);
- }
- }
-
- /**
- * Imulates firing adding contact in group and moving contact to group.
- * When moving contact it is first adding to the new group then
- * it is removed from the old one.
- */
- private class ContactListModListenerImpl
- extends SessionAdapter
- {
- private final Hashtable<String, Object> waitMove
- = new Hashtable<String, Object>();
-
- public void waitForMove(String id, String oldParent)
- {
- waitMove.put(id, oldParent);
- }
-
- public void removeWaitForMove(String id)
- {
- waitMove.remove(id);
- }
-
- /**
- * Successfully added a friend
- * friend - YahooUser of friend
- * group - name of group added to
- * @param ev fired event
- */
- @Override
- public void friendAddedReceived(SessionFriendEvent ev)
- {
- if (logger.isTraceEnabled())
- logger.trace("Receive event for adding a friend : " + ev);
-
- ContactGroupYahooImpl group =
- findContactGroup(ev.getGroup());
-
- if(group == null){
- if (logger.isTraceEnabled())
- logger.trace("Group not found!" + ev.getGroup());
- return;
- }
-
- String contactID = ev.getFriend().getId();
- ContactYahooImpl contactToAdd = findContactById(contactID);
-
- // if group is note resolved resolve it
- // this means newly created group
- if(!group.isResolved())
- {
- // if the contact is volatile me must remove it
- // as new one will be created
- if(contactToAdd != null && contactToAdd.isVolatile())
- {
- ContactGroupYahooImpl parent
- = (ContactGroupYahooImpl)contactToAdd
- .getParentContactGroup();
-
- parent.removeContact(contactToAdd);
- fireContactRemoved(parent, contactToAdd);
- }
-
- YahooGroup gr = findGroup(ev.getGroup());
-
- if(gr != null)
- group.setResolved(gr);
-
- // contact will be added when resolving the group
-
- return;
- }
-
-
- boolean isVolatile = false;
-
- if(contactToAdd == null)
- {
- if(addedCustomYahooIds.containsKey(contactID))
- {
- String expectedContactID =
- addedCustomYahooIds.remove(contactID);
-
- contactToAdd =
- new ContactYahooImpl(expectedContactID, ev.getFriend(),
- ServerStoredContactListYahooImpl.this, true, true);
- }
- else
- {
- contactToAdd =
- new ContactYahooImpl(ev.getFriend(),
- ServerStoredContactListYahooImpl.this, true, true);
- }
- }
- else
- {
- isVolatile = contactToAdd.isVolatile();
- }
-
- //first check is contact is moving from a group
- Object isWaitingForMove = waitMove.get(contactID);
-
- if(isWaitingForMove != null && isWaitingForMove instanceof String)
- {
- // waits for move into group
- // will remove it from old group and will wait for event remove
- // from group, then will fire moved to group event
- String oldParent = (String)isWaitingForMove;
-
- group.addContact(contactToAdd);
- waitMove.put(contactID, group.getSourceGroup());
- try
- {
- yahooSession.removeFriend(contactID, oldParent);
- }
- catch(IOException ex)
- {
- if (logger.isInfoEnabled())
- logger.info("Cannot Remove(till moving) contact :" +
- contactToAdd + " from group " + oldParent);
- }
- return;
- }
-
- if(isVolatile)
- {
- // we must remove the volatile buddy as we will add
- // the persistent one.
- // Volatile buddy is moving from the volatile group
- // to the new one
- ContactGroupYahooImpl parent =
- (ContactGroupYahooImpl)contactToAdd.getParentContactGroup();
-
- parent.removeContact(contactToAdd);
- fireContactRemoved(parent, contactToAdd);
-
- contactToAdd.setPersistent(true);
- contactToAdd.setResolved(ev.getFriend());
-
- group.addContact(contactToAdd);
-
- fireContactAdded(group, contactToAdd);
- waitMove.remove(contactID);
-
- return;
- }
-
- group.addContact(contactToAdd);
- fireContactAdded(group, contactToAdd);
- }
-
- /**
- * Successfully removed a friend
- * friend - YahooUser of friend
- * group - name of group removed from
- * @param ev fired event
- */
- @Override
- public void friendRemovedReceived(SessionFriendEvent ev)
- {
- if (logger.isTraceEnabled())
- logger.trace("Receive event for removing a friend : " + ev);
-
- String contactID = ev.getFriend().getId();
-
- // first check is this part of move action
- Object waitForMoveObj = waitMove.get(contactID);
- if(waitForMoveObj != null && waitForMoveObj instanceof YahooGroup)
- {
- // first get the group - oldParent
- ContactGroupYahooImpl oldParent
- = findContactGroup(ev.getGroup());
- ContactYahooImpl contactToRemove
- = oldParent.findContact(contactID);
-
- oldParent.removeContact(contactToRemove);
- waitMove.remove(contactID);
-
- ContactGroupYahooImpl newParent =
- findContactGroup(((YahooGroup)waitForMoveObj).getName());
-
- fireContactMoved(oldParent, newParent, contactToRemove);
- return;
- }
-
- ContactYahooImpl contactToRemove = findContactById(contactID);
-
- // strange we cannot find the contact to be removed
- if(contactToRemove == null)
- return;
-
- ContactGroupYahooImpl parentGroup =
- (ContactGroupYahooImpl)contactToRemove.
- getParentContactGroup();
- parentGroup.removeContact(contactToRemove);
- fireContactRemoved(parentGroup, contactToRemove);
-
- // check if the group is deleted. If the contact is the last one in
- // the group. The group is also deleted
- if(findGroup(ev.getGroup()) == null)
- {
- rootGroup.removeSubGroup(parentGroup);
- fireGroupEvent(parentGroup,
- ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
- }
- }
-
- /**
- * Someone wants to add us to their friends list
- * to - the target (us!)
- * from - the user who wants to add us
- * message - the request message text
- * @param ev fired event
- */
- @Override
- public void contactRequestReceived(SessionEvent ev)
- {
- if (logger.isInfoEnabled())
- logger.info("contactRequestReceived : " + ev);
-
- if(handler == null || ev.getFrom() == null)
- return;
-
- ContactYahooImpl contact = findContactById(ev.getFrom());
-
- if(contact == null)
- contact = createVolatileContact(ev.getFrom());
-
- AuthorizationRequest request = new AuthorizationRequest();
- request.setReason(ev.getMessage());
-
- AuthorizationResponse resp =
- handler.processAuthorisationRequest(request, contact);
-
- if (resp.getResponseCode() == AuthorizationResponse.REJECT)
- {
- try{
- yahooSession.rejectContact(ev, resp.getReason());
- }catch(IOException ex){
- logger.error("Cannot send reject : " + ex.getMessage());
- }
- }
- }
-
- /**
- * Someone has rejected our attempts to add them to our friends list
- * from - the user who rejected us
- * message - rejection message text
- * @param ev fired event
- */
- @Override
- public void contactRejectionReceived(SessionEvent ev)
- {
- if (logger.isInfoEnabled())
- logger.info("contactRejectionReceived : " + ev);
-
- if(handler == null)
- return;
-
- ContactYahooImpl contact = findContactById(ev.getFrom());
-
- AuthorizationResponse resp =
- new AuthorizationResponse(AuthorizationResponse.REJECT,
- ev.getMessage());
- handler.processAuthorizationResponse(resp, contact);
- }
-
- /**
- * Invoked on picture received.
- * @param ev fired event
- */
- @Override
- public void pictureReceived(SessionPictureEvent ev)
- {
- ContactYahooImpl contact = findContactById(ev.getFrom());
-
- if(contact == null)
- return;
-
- contact.setImage(ev.getPictureData());
-
- parentOperationSet.fireContactPropertyChangeEvent(
- ContactPropertyChangeEvent.PROPERTY_IMAGE,
- contact, null, ev.getPictureData());
- }
-
- /**
- * Process Authorization responses
- * @param ev the event to process
- */
- @Override
- public void authorizationReceived(SessionAuthorizationEvent ev)
- {
- if(ev.isAuthorizationAccepted())
- {
- if (logger.isTraceEnabled())
- logger.trace("authorizationAccepted from " + ev.getFrom());
- Contact srcContact = findContactById(ev.getFrom());
-
- if(srcContact == null)
- if (logger.isTraceEnabled())
- logger.trace("No contact found");
- else
- handler.processAuthorizationResponse(
- new AuthorizationResponse(
- AuthorizationResponse.ACCEPT,
- ev.getMessage()),
- srcContact);
- }
- else if(ev.isAuthorizationDenied())
- {
- if (logger.isTraceEnabled())
- logger.trace("authorizationDenied from " + ev.getFrom());
- Contact srcContact = findContactById(ev.getFrom());
-
- if(srcContact == null)
- if (logger.isTraceEnabled())
- logger.trace("No contact found");
- else
- {
- handler.processAuthorizationResponse(
- new AuthorizationResponse(
- AuthorizationResponse.REJECT,
- ev.getMessage()),
- srcContact);
- try
- {
- removeContact((ContactYahooImpl)srcContact);
- } catch (Exception ex)
- {
- logger.error("cannot remove denied contact : " +
- srcContact, ex);
- }
- }
- }
- else if(ev.isAuthorizationRequest())
- {
- if (logger.isTraceEnabled())
- logger.trace("authorizationRequestReceived from "
- + ev.getFrom());
- processAuthorizationRequest(ev);
- }
- }
- }
-
- /**
- * Sets the yahoo session instance of the lib
- * which comunicates with the server
- * @param session YahooSession
- */
- void setYahooSession(YahooSession session)
- {
- this.yahooSession = session;
- session.addSessionListener(contactListModListenerImpl);
- initList();
- }
-
- /**
- * It seems that ymsg (or the Yahoo! service itself as the problem also
- * appears with libpurple) would return illegal chars for names that were
- * entered in cyrillic. We use this method to translate their names into
- * something that we could actually display and store here.
- *
- * @param ymsgString the <tt>String</tt> containing illegal chars.
- *
- * @return a String where all illegal chars are converted into human
- * readable ones
- */
- static String replaceIllegalChars(String ymsgString)
- {
- return ymsgString.replace((char)26, '?');
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/VolatileContactGroupYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/VolatileContactGroupYahooImpl.java
deleted file mode 100644
index e2c589a..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/VolatileContactGroupYahooImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The Yahoo implementation of the Volatile ContactGroup interface.
- *
- * @author Damian Minkov
- */
-public class VolatileContactGroupYahooImpl
- extends ContactGroupYahooImpl
-{
- /**
- * This contact group name
- */
- private String contactGroupName = null;
-
- /**
- * Creates an Yahoo group using the specified group name
- * @param groupName String groupname
- * @param ssclCallback a callback to the server stored contact list
- * we're creating.
- */
- VolatileContactGroupYahooImpl(
- String groupName,
- ServerStoredContactListYahooImpl ssclCallback)
- {
- super(groupName, ssclCallback);
- this.contactGroupName = groupName;
- }
-
- /**
- * Returns the name of this group.
- * @return a String containing the name of this group.
- */
- @Override
- public String getGroupName()
- {
- return contactGroupName;
- }
-
- /**
- * Returns a string representation of this group, in the form
- * YahooGroup.GroupName[size]{ buddy1.toString(), buddy2.toString(), ...}.
- * @return a String representation of the object.
- */
- @Override
- public String toString()
- {
- StringBuffer buff = new StringBuffer("VolatileYahooGroup.");
- buff.append(getGroupName());
- buff.append(", childContacts="+countContacts()+":[");
-
- Iterator<Contact> contacts = contacts();
-
- while (contacts.hasNext())
- {
- Contact contact = contacts.next();
-
- buff.append(contact.toString());
- if(contacts.hasNext())
- buff.append(", ");
- }
- return buff.append("]").toString();
- }
-
- /**
- * Determines whether or not this contact group is being stored by the
- * server. Non persistent contact groups exist for the sole purpose of
- * containing non persistent contacts.
- * @return true if the contact group is persistent and false otherwise.
- */
- @Override
- public boolean isPersistent()
- {
- return false;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/YahooAccountID.java b/src/net/java/sip/communicator/impl/protocol/yahoo/YahooAccountID.java
deleted file mode 100644
index 0eb0e86..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/YahooAccountID.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The Yahoo implementation of a sip-communicator AccountID
- *
- * @author Damian Minkov
- */
-public class YahooAccountID
- extends AccountID
-{
- /**
- * Creates an account id from the specified id and account properties.
- * @param id the id identifying this account
- * @param accountProperties any other properties necessary for the account.
- */
- YahooAccountID(String id, Map<String, String> accountProperties )
- {
- super(YahooSession.getYahooUserID(id),
- accountProperties, ProtocolNames.YAHOO, "yahoo.com");
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/YahooActivator.java b/src/net/java/sip/communicator/impl/protocol/yahoo/YahooActivator.java
deleted file mode 100644
index 1e7ca01..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/YahooActivator.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-import org.jitsi.service.configuration.*;
-import org.jitsi.service.resources.*;
-import org.osgi.framework.*;
-
-/**
- * Loads the Yahoo provider factory and registers it with service in the OSGI
- * bundle context.
- *
- * @author Damian Minkov
- */
-public class YahooActivator
- implements BundleActivator
-{
- private ServiceRegistration yahooPpFactoryServReg = null;
- private static BundleContext bundleContext = null;
- private static ConfigurationService configurationService = null;
-
- private static ProtocolProviderFactoryYahooImpl yahooProviderFactory = null;
-
- private static ResourceManagementService resourcesService;
-
- /**
- * Called when this bundle is started so the Framework can perform the
- * bundle-specific activities necessary to start this bundle.
- *
- * @param context The execution context of the bundle being started.
- * @throws Exception If this method throws an exception, this bundle is
- * marked as stopped and the Framework will remove this bundle's
- * listeners, unregister all services registered by this bundle, and
- * release all services used by this bundle.
- */
- public void start(BundleContext context) throws Exception
- {
- bundleContext = context;
-
- Hashtable<String, String> hashtable = new Hashtable<String, String>();
- hashtable.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.YAHOO);
-
- yahooProviderFactory = new ProtocolProviderFactoryYahooImpl();
-
- //reg the yahoo account man.
- yahooPpFactoryServReg = context.registerService(
- ProtocolProviderFactory.class.getName(),
- yahooProviderFactory,
- hashtable);
- }
-
- /**
- * Returns a reference to a ConfigurationService implementation currently
- * registered in the bundle context or null if no such implementation was
- * found.
- *
- * @return ConfigurationService a currently valid implementation of the
- * configuration service.
- */
- public static ConfigurationService getConfigurationService()
- {
- if(configurationService == null)
- {
- ServiceReference confReference
- = bundleContext.getServiceReference(
- ConfigurationService.class.getName());
- configurationService
- = (ConfigurationService) bundleContext.getService(confReference);
- }
- return configurationService;
- }
-
- /**
- * Returns a reference to the bundle context that we were started with.
- * @return a reference to the BundleContext instance that we were started
- * witn.
- */
- public static BundleContext getBundleContext()
- {
- return bundleContext;
- }
-
- /**
- * Retrurns a reference to the protocol provider factory that we have
- * registered.
- * @return a reference to the <tt>ProtocolProviderFactoryYahooImpl</tt>
- * instance that we have registered from this package.
- */
- static ProtocolProviderFactoryYahooImpl getProtocolProviderFactory()
- {
- return yahooProviderFactory;
- }
-
- /**
- * Called when this bundle is stopped so the Framework can perform the
- * bundle-specific activities necessary to stop the bundle.
- *
- * @param context The execution context of the bundle being stopped.
- * @throws Exception If this method throws an exception, the bundle is
- * still marked as stopped, and the Framework will remove the bundle's
- * listeners, unregister all services registered by the bundle, and
- * release all services used by the bundle.
- */
- public void stop(BundleContext context) throws Exception
- {
- yahooProviderFactory.stop();
- yahooPpFactoryServReg.unregister();
- }
-
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- {
- ServiceReference serviceReference = bundleContext
- .getServiceReference(ResourceManagementService.class.getName());
-
- if(serviceReference == null)
- return null;
-
- resourcesService = (ResourceManagementService) bundleContext
- .getService(serviceReference);
- }
-
- return resourcesService;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/YahooSession.java b/src/net/java/sip/communicator/impl/protocol/yahoo/YahooSession.java
deleted file mode 100644
index f24e50c..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/YahooSession.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.impl.protocol.yahoo;
-
-import java.io.*;
-
-import ymsg.network.*;
-
-/**
- * Extends The Yahoo session to have access to some
- * protected functionality
- * Not working for now.
- *
- * @author Damian Minkov
- */
-public class YahooSession
- extends Session
-{
- /**
- * Renames a group. Not working for now
- */
- public void renameGroup(String oldName, String newName)
- throws IOException
- {
- transmitGroupRename(oldName, newName);
- }
-
- /**
- * Removes the server part from the given id
- */
- public static String getYahooUserID(String id)
- {
- return (id.indexOf("@") > -1 )
- ? id.substring(0, id.indexOf("@"))
- : id;
- }
-
- /**
- * Sending typing notifications
- * @param to user we are notifing
- * @param from our user id
- */
- void keyTyped(String to, String from)
- {
- try {
- transmitNotify(to, from, true, " ", NOTIFY_TYPING);
- }catch(IOException e){}
- }
-
- /**
- * Sending stop typing notifications
- * @param to user we are notifing
- * @param from our user id
- */
- void stopTyping(String to, String from)
- {
- try {
- transmitNotify(to, from, false, " ", NOTIFY_TYPING);
- }catch(IOException e){}
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf
deleted file mode 100644
index 39e23bf..0000000
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf
+++ /dev/null
@@ -1,22 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.impl.protocol.yahoo.YahooActivator
-Bundle-Name: Yahoo Protocol Provider Implementation
-Bundle-Description: An Yahoo implementation of the Protocol Provider Service.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 0.0.1
-Bundle-SymbolicName: net.java.sip.communicator.protocol.yahoo
-Import-Package: org.osgi.framework,
- javax.net.ssl,
- javax.swing,
- javax.swing.text,
- javax.xml.parsers,
- javax.naming,
- javax.naming.directory,
- org.xml.sax,
- sun.security.action,
- org.jitsi.service.configuration,
- org.jitsi.service.resources, net.java.sip.communicator.service.resources,
- net.java.sip.communicator.util,
- net.java.sip.communicator.service.dns,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.yahooconstants,
- net.java.sip.communicator.service.protocol.event