aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/protocol/dict
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/sip/communicator/impl/protocol/dict')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java343
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/ContactGroupDictImpl.java588
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java70
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/DictActivator.java146
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/DictStatusEnum.java88
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/MessageDictImpl.java46
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/OperationSetBasicInstantMessagingDictImpl.java412
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/OperationSetPersistentPresenceDictImpl.java988
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/ProtocolIconDictImpl.java133
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderFactoryDictImpl.java200
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java364
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/dict.provider.manifest.mf15
12 files changed, 0 insertions, 3393 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java
deleted file mode 100644
index 924c0f7..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java
+++ /dev/null
@@ -1,343 +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.dict;
-
-import net.java.dict4j.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * An implementation of a Dict contact
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class ContactDictImpl
- extends AbstractContact
-{
- private Logger logger = Logger.getLogger(ContactDictImpl.class);
-
- /**
- * Icon
- */
- private static byte[] icon = DictActivator.getResources()
- .getImageInBytes("service.protocol.dict.DICT_64x64");
-
- /**
- * The id of the contact.
- */
- private String contactID = null;
-
- /**
- * The provider that created us.
- */
- private ProtocolProviderServiceDictImpl parentProvider = null;
-
- /**
- * The group that belong to.
- */
- private ContactGroupDictImpl parentGroup = null;
-
- /**
- * The presence status of the contact.
- */
- private PresenceStatus presenceStatus = DictStatusEnum.ONLINE;
-
- /**
- * Determines whether this contact is persistent, i.e. member of the contact
- * list or whether it is here only temporarily.
- */
- private boolean isPersistent = true;
-
- /**
- * Determines whether the contact has been resolved (i.e. we have a
- * confirmation that it is still on the server contact list).
- */
- private boolean isResolved = true;
-
- /**
- * The string in a "humain readable and understandable representation" of
- * the dictionnaire. In brief this is a short description of the dictionary.
- */
- private String dictName = null;
-
- /**
- * Creates an instance of a meta contact with the specified string used
- * as a name and identifier.
- *
- * @param databaseCode The identifier of this contact (also used as a name).
- * @param parentProvider The provider that created us.
- */
- public ContactDictImpl(
- String databaseCode,
- ProtocolProviderServiceDictImpl parentProvider)
- {
- this.contactID = databaseCode;
- this.parentProvider = parentProvider;
- }
-
- /**
- * This method is only called when the contact is added to a new
- * <tt>ContactGroupDictImpl</tt> by the
- * <tt>ContactGroupDictImpl</tt> itself.
- *
- * @param newParentGroup the <tt>ContactGroupDictImpl</tt> that is now
- * parent of this <tt>ContactDictImpl</tt>
- */
- void setParentGroup(ContactGroupDictImpl newParentGroup)
- {
- this.parentGroup = newParentGroup;
- }
-
- /**
- * Returns a String that can be used for identifying the contact.
- *
- * @return a String id representing and uniquely identifying the contact.
- */
- public String getContactID()
- {
- return contactID;
- }
-
- /**
- * Returns a String that can be used for identifying the contact.
- *
- * @return a String id representing and uniquely identifying the contact.
- */
- public String getAddress()
- {
- return contactID;
- }
-
- /**
- * Returns a String that could be used by any user interacting modules
- * for referring to this contact.
- *
- * @return a String that can be used for referring to this contact when
- * interacting with the user.
- */
- public String getDisplayName()
- {
- if (dictName == null)
- {
- if (this.contactID.equals("*"))
- {
- this.dictName = DictActivator.getResources()
- .getI18NString("plugin.dictaccregwizz.ANY_DICTIONARY");
- }
- else if (this.contactID.equals("!"))
- {
- this.dictName = DictActivator.getResources()
- .getI18NString("plugin.dictaccregwizz.FIRST_MATCH");
- }
- else
- {
- try
- {
- this.dictName = this.parentProvider.getConnection()
- .getDictionaryName(this.contactID);
- }
- catch (DictException dx)
- {
- logger.error("Error while getting dictionary long name", dx);
- }
-
- if (this.dictName == null)
- this.dictName = this.contactID;
- }
- }
-
- return dictName;
- }
-
- /**
- * Returns a byte array containing an image (most often a photo or an
- * avatar) that the contact uses as a representation.
- *
- * @return byte[] an image representing the contact.
- */
- public byte[] getImage()
- {
- return icon;
- }
-
- /**
- * Returns the status of the contact.
- *
- * @return always DictStatusEnum.ONLINE.
- */
- public PresenceStatus getPresenceStatus()
- {
- return this.presenceStatus;
- }
-
- /**
- * Sets <tt>dictPresenceStatus</tt> as the PresenceStatus that this
- * contact is currently in.
- * @param dictPresenceStatus the <tt>DictPresenceStatus</tt>
- * currently valid for this contact.
- */
- public void setPresenceStatus(PresenceStatus dictPresenceStatus)
- {
- this.presenceStatus = dictPresenceStatus;
- }
-
- /**
- * Returns a reference to the protocol provider that created the contact.
- *
- * @return a refererence to an instance of the ProtocolProviderService
- */
- public ProtocolProviderService getProtocolProvider()
- {
- return parentProvider;
- }
-
- /**
- * Determines whether or not this contact represents our own identity.
- *
- * @return true in case this is a contact that represents ourselves and
- * false otherwise.
- */
- public boolean isLocal()
- {
- return false;
- }
-
- /**
- * Returns the group that contains this contact.
- * @return a reference to the <tt>ContactGroupDictImpl</tt> that
- * contains this contact.
- */
- public ContactGroup getParentContactGroup()
- {
- return this.parentGroup;
- }
-
- /**
- * 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("ContactDictImpl[ DisplayName=")
- .append(getDisplayName()).append("]");
-
- return buff.toString();
- }
-
- /**
- * 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 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.
- *
- * @param isPersistent true if the contact is persistent and false
- * otherwise.
- */
- public void setPersistent(boolean isPersistent)
- {
- this.isPersistent = isPersistent;
- }
-
-
- /**
- * 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 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;
- }
-
- /**
- * Return the current status message of this contact.
- *
- * @return null as the protocol has currently no support of status messages
- */
- public String getStatusMessage()
- {
- return null;
- }
-
- /**
- * Makes the contact resolved or unresolved.
- *
- * @param resolved true to make the contact resolved; false to
- * make it unresolved
- */
- public void setResolved(boolean resolved)
- {
- this.isResolved = resolved;
- }
-
- /**
- * Returns the persistent presence operation set that this contact belongs
- * to.
- *
- * @return the <tt>OperationSetPersistentPresenceGibberishImpl</tt> that
- * this contact belongs to.
- */
- public OperationSetPersistentPresenceDictImpl
- getParentPresenceOperationSet()
- {
- return (OperationSetPersistentPresenceDictImpl) parentProvider
- .getOperationSet(OperationSetPersistentPresence.class);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/ContactGroupDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/ContactGroupDictImpl.java
deleted file mode 100644
index e52ce96..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/ContactGroupDictImpl.java
+++ /dev/null
@@ -1,588 +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.dict;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * A simple, straightforward implementation of a dict ContactGroup. Since
- * the Dict protocol is not a real one, we simply store all group details
- * in class fields. You should know that when implementing a real protocol,
- * the contact group implementation would rather encapsulate group objects from
- * the protocol stack and group property values should be returned by consulting
- * the encapsulated object.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class ContactGroupDictImpl
- implements ContactGroup
-{
-
- /**
- * The name of this Dict contact group.
- */
- private String groupName = null;
-
- /**
- * The list of this group's members.
- */
- private List<Contact> contacts = new ArrayList<Contact>();
-
- /**
- * The list of sub groups belonging to this group.
- */
- private List<ContactGroup> subGroups = new ArrayList<ContactGroup>();
-
- /**
- * The group that this group belongs to (or null if this is the root group).
- */
- private ContactGroupDictImpl parentGroup = null;
-
- /**
- * Determines whether this group is really in the contact list or whether
- * it is here only temporarily and will be gone next time we restart.
- */
- private boolean isPersistent = true;
-
- /**
- * The protocol provider that created us.
- */
- private ProtocolProviderServiceDictImpl parentProvider = null;
-
- /**
- * Determines whether this group has been resolved on the server.
- * Unresolved groups are groups that were available on previous runs and
- * that the meta contact list has stored. During all next runs, when
- * bootstrapping, the meta contact list would create these groups as
- * unresolved. Once a protocol provider implementation confirms that the
- * groups are still on the server, it would issue an event indicating that
- * the groups are now resolved.
- */
- private boolean isResolved = true;
-
- /**
- * An id uniquely identifying the group. For many protocols this could be
- * the group name itself.
- */
- private String uid = null;
- private static final String UID_SUFFIX = ".uid";
-
- /**
- * Creates a ContactGroupDictImpl with the specified name.
- *
- * @param groupName the name of the group.
- * @param parentProvider the protocol provider that created this group.
- */
- public ContactGroupDictImpl(
- String groupName,
- ProtocolProviderServiceDictImpl parentProvider)
- {
- this.groupName = groupName;
- this.uid = groupName + UID_SUFFIX;
- this.parentProvider = parentProvider;
- }
-
- /**
- * Determines whether the group may contain subgroups or not.
- *
- * @return always true in this implementation.
- */
- public boolean canContainSubgroups()
- {
- return true;
- }
-
- /**
- * 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 parentProvider;
- }
-
- /**
- * 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 contacts.iterator();
- }
-
- /**
- * Adds the specified contact to this group.
- * @param contactToAdd the ContactDictImpl to add to this group.
- */
- public void addContact(ContactDictImpl contactToAdd)
- {
- this.contacts.add(contactToAdd);
- contactToAdd.setParentGroup(this);
- }
-
- /**
- * 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 contacts.size();
- }
-
- /**
- * Returns the number of subgroups contained by this
- * <tt>ContactGroup</tt>.
- *
- * @return the number of subGroups currently added to this group.
- */
- public int countSubgroups()
- {
- return subGroups.size();
- }
-
- /**
- * Adds the specified contact group to the contained by this group.
- * @param subgroup the ContactGroupDictImpl to add as a subgroup to this group.
- */
- public void addSubgroup(ContactGroupDictImpl subgroup)
- {
- this.subGroups.add(subgroup);
- subgroup.setParentGroup(this);
- }
-
- /**
- * Sets the group that is the new parent of this group
- * @param parent ContactGroupDictImpl
- */
- void setParentGroup(ContactGroupDictImpl parent)
- {
- this.parentGroup = parent;
- }
-
- /**
- * Returns the contact group that currently contains this group or null if
- * this is the root contact group.
- * @return the contact group that currently contains this group or null if
- * this is the root contact group.
- */
- public ContactGroup getParentContactGroup()
- {
- return this.parentGroup;
- }
-
- /**
- * Removes the specified contact group from the this group's subgroups.
- * @param subgroup the ContactGroupDictImpl subgroup to remove.
- */
- public void removeSubGroup(ContactGroupDictImpl subgroup)
- {
- this.subGroups.remove(subgroup);
- subgroup.setParentGroup(null);
- }
-
- /**
- * Returns the group that is parent of the specified dictGroup or null
- * if no parent was found.
- * @param dictGroup the group whose parent we're looking for.
- * @return the ContactGroupDictImpl instance that dictGroup
- * belongs to or null if no parent was found.
- */
- public ContactGroupDictImpl findGroupParent(ContactGroupDictImpl dictGroup)
- {
- if ( subGroups.contains(dictGroup) )
- return this;
-
- Iterator<ContactGroup> subGroupsIter = subgroups();
- while (subGroupsIter.hasNext())
- {
- ContactGroupDictImpl subgroup
- = (ContactGroupDictImpl) subGroupsIter.next();
-
- ContactGroupDictImpl parent
- = subgroup.findGroupParent(dictGroup);
-
- if(parent != null)
- return parent;
- }
- return null;
- }
-
- /**
- * Returns the group that is parent of the specified dictContact or
- * null if no parent was found.
- *
- * @param dictContact the contact whose parent we're looking for.
- * @return the ContactGroupDictImpl instance that dictContact
- * belongs to or <tt>null</tt> if no parent was found.
- */
- public ContactGroupDictImpl findContactParent(
- ContactDictImpl dictContact)
- {
- if ( contacts.contains(dictContact) )
- return this;
-
- Iterator<ContactGroup> subGroupsIter = subgroups();
- while (subGroupsIter.hasNext())
- {
- ContactGroupDictImpl subgroup
- = (ContactGroupDictImpl) subGroupsIter.next();
-
- ContactGroupDictImpl parent
- = subgroup.findContactParent(dictContact);
-
- if(parent != null)
- return parent;
- }
- return null;
- }
-
-
-
- /**
- * 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)
- {
- Iterator<Contact> contactsIter = contacts();
- while (contactsIter.hasNext())
- {
- ContactDictImpl contact = (ContactDictImpl) contactsIter.next();
- if (contact.getAddress().equals(id))
- return contact;
-
- }
- 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> groupsIter = subgroups();
- while (groupsIter.hasNext())
- {
- ContactGroupDictImpl contactGroup
- = (ContactGroupDictImpl) groupsIter.next();
- if (contactGroup.getGroupName().equals(groupName))
- return contactGroup;
-
- }
- return null;
-
- }
-
- /**
- * Returns the name of this group.
- *
- * @return a String containing the name of this group.
- */
- public String getGroupName()
- {
- return this.groupName;
- }
-
- /**
- * Sets this group a new name.
- * @param newGrpName a String containing the new name of this group.
- */
- public void setGroupName(String newGrpName)
- {
- this.groupName = newGrpName;
- }
-
- /**
- * 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();
- }
-
- /**
- * Removes the specified contact from this group.
- * @param contact the ContactDictImpl to remove from this group
- */
- public void removeContact(ContactDictImpl contact)
- {
- this.contacts.remove(contact);
- }
-
- /**
- * Returns the contact with the specified id or null if no such contact
- * exists.
- * @param id the id of the contact we're looking for.
- * @return ContactDictImpl
- */
- public ContactDictImpl findContactByID(String id)
- {
- //first go through the contacts that are direct children.
- Iterator<Contact> contactsIter = contacts();
-
- while(contactsIter.hasNext())
- {
- ContactDictImpl mContact = (ContactDictImpl)contactsIter.next();
-
- if( mContact.getAddress().equals(id) )
- return mContact;
- }
-
- //if we didn't find it here, let's try in the subougroups
- Iterator<ContactGroup> groupsIter = subgroups();
-
- while( groupsIter.hasNext() )
- {
- ContactGroupDictImpl mGroup = (ContactGroupDictImpl)groupsIter.next();
-
- ContactDictImpl mContact = mGroup.findContactByID(id);
-
- if (mContact != null)
- return mContact;
- }
-
- return null;
- }
-
-
- /**
- * Returns a String representation of this group and the contacts it
- * contains (may turn out to be a relatively long string).
- * @return a String representing this group and its child contacts.
- */
- @Override
- public String toString()
- {
-
- StringBuffer buff = new StringBuffer(getGroupName());
- buff.append(".subGroups=" + countSubgroups() + ":\n");
-
- Iterator<ContactGroup> subGroups = subgroups();
- while (subGroups.hasNext())
- {
- ContactGroupDictImpl group = (ContactGroupDictImpl)subGroups.next();
- buff.append(group.toString());
- if (subGroups.hasNext())
- buff.append("\n");
- }
-
- buff.append("\nChildContacts="+countContacts()+":[");
-
- Iterator<Contact> contacts = contacts();
- while (contacts.hasNext())
- {
- ContactDictImpl contact = (ContactDictImpl) contacts.next();
- buff.append(contact.toString());
- if(contacts.hasNext())
- buff.append(", ");
- }
- return buff.append("]").toString();
- }
-
- /**
- * Specifies whether or not this contact group is being stored by the server.
- * Non persistent contact groups 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 and the contact that we
- * associated with that user is placed in a non persistent group. Non
- * persistent contact groups 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.
- *
- * @param isPersistent true if the contact group is to be persistent and
- * false otherwise.
- */
- public void setPersistent(boolean isPersistent)
- {
- this.isPersistent = isPersistent;
- }
-
- /**
- * 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 isPersistent;
- }
-
- /**
- * 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 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;
- }
-
- /**
- * Makes the group resolved or unresolved.
- *
- * @param resolved true to make the group resolved; false to
- * make it unresolved
- */
- public void setResolved(boolean resolved)
- {
- this.isResolved = resolved;
- }
-
- /**
- * Returns a <tt>String</tt> that uniquely represnets the group inside
- * the current protocol. The string MUST be persistent (it must not change
- * across connections or runs of the application). In many cases (Jabber,
- * ICQ) the string may match the name of the group as these protocols
- * only allow a single level of contact groups and there is no danger of
- * having the same name twice in the same contact list. Other protocols
- * (no examples come to mind but that doesn't bother me ;) ) may be
- * supporting mutilple levels of grooups so it might be possible for group
- * A and group B to both contain groups named C. In such cases the
- * implementation must find a way to return a unique identifier in this
- * method and this UID should never change for a given group.
- *
- * @return a String representing this group in a unique and persistent
- * way.
- */
- public String getUID()
- {
- return uid;
- }
-
- /**
- * Ugly but tricky conversion method.
- * @param uid the uid we'd like to get a name from
- * @return the name of the group with the specified <tt>uid</tt>.
- */
- static String createNameFromUID(String uid)
- {
- return uid.substring(0, uid.length() - (UID_SUFFIX.length()));
- }
-
- /**
- * Indicates whether some other object is "equal to" this one which in terms
- * of contact groups translates to having the equal names and matching
- * subgroups and child contacts. The resolved status of contactgroups and
- * contacts is deliberately ignored so that groups and/or contacts would
- * be assumed equal even if it differs.
- * <p>
- * @param obj the reference object with which to compare.
- * @return <code>true</code> if this contact group has the equal child
- * contacts and subgroups to those of the <code>obj</code> argument.
- */
- @Override
- public boolean equals(Object obj)
- {
- if(obj == null
- || !(obj instanceof ContactGroupDictImpl))
- return false;
-
- ContactGroupDictImpl dictGroup
- = (ContactGroupDictImpl)obj;
-
- if( ! dictGroup.getGroupName().equals(getGroupName())
- || ! dictGroup.getUID().equals(getUID())
- || dictGroup.countContacts() != countContacts()
- || dictGroup.countSubgroups() != countSubgroups())
- return false;
-
- //traverse child contacts
- Iterator<Contact> theirContacts = dictGroup.contacts();
-
- while(theirContacts.hasNext())
- {
- ContactDictImpl theirContact
- = (ContactDictImpl)theirContacts.next();
-
- ContactDictImpl ourContact
- = (ContactDictImpl)getContact(theirContact.getAddress());
-
- if(ourContact == null
- || !ourContact.equals(theirContact))
- return false;
- }
-
- //traverse subgroups
- Iterator<ContactGroup> theirSubgroups = dictGroup.subgroups();
-
- while(theirSubgroups.hasNext())
- {
- ContactGroupDictImpl theirSubgroup
- = (ContactGroupDictImpl)theirSubgroups.next();
-
- ContactGroupDictImpl ourSubgroup
- = (ContactGroupDictImpl)getGroup(
- theirSubgroup.getGroupName());
-
- if(ourSubgroup == null
- || !ourSubgroup.equals(theirSubgroup))
- return false;
- }
-
- return true;
- }
-}
-
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java b/src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java
deleted file mode 100644
index 538ae71..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java
+++ /dev/null
@@ -1,70 +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.dict;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The Dict implementation of a sip-communicator account id.
- * @author LITZELMANN Cedric
- * @author ROTH Damien
- */
-public class DictAccountID
- extends AccountID
-{
- /**
- * Creates an account id from the specified id and account properties.
- *
- * @param userID the user identifier correspnding to the account
- * @param accountProperties any other properties necessary for the account.
- */
- DictAccountID(String userID, Map<String, String> accountProperties)
- {
- super(userID, accountProperties, ProtocolNames.DICT, "dict.org");
- }
-
- /**
- * Returns the dict server adress
- * @return the dict server adress
- */
- public String getHost()
- {
- return getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS);
- }
-
- /**
- * Returns the dict server port
- * @return the dict server port
- */
- public int getPort()
- {
- return Integer
- .parseInt(getAccountPropertyString(ProtocolProviderFactory.SERVER_PORT));
- }
-
- /**
- * Returns the selected strategy
- * @return the selected strategy
- */
- public String getStrategy()
- {
- return getAccountPropertyString(ProtocolProviderFactory.STRATEGY);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/DictActivator.java b/src/net/java/sip/communicator/impl/protocol/dict/DictActivator.java
deleted file mode 100644
index b5976c7..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/DictActivator.java
+++ /dev/null
@@ -1,146 +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.dict;
-
-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.*;
-
-/**
- * Loads the Dict provider factory and registers its services in the OSGI
- * bundle context.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class DictActivator
- implements BundleActivator
-{
- private static final Logger logger = Logger.getLogger(DictActivator.class);
-
- /**
- * The currently valid bundle context.
- */
- private static BundleContext bundleContext = null;
-
- private ServiceRegistration dictPpFactoryServReg = null;
- private static ProtocolProviderFactoryDictImpl
- dictProviderFactory = null;
-
- private static ResourceManagementService resourceService;
-
- /**
- * Called when this bundle is started. In here we'll export the
- * dict ProtocolProviderFactory implementation so that it could be
- * possible to register accounts with it in SIP Communicator.
- *
- * @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.DICT);
-
- dictProviderFactory = new ProtocolProviderFactoryDictImpl();
-
- //reg the dict provider factory.
- dictPpFactoryServReg = context.registerService(
- ProtocolProviderFactory.class.getName(),
- dictProviderFactory,
- hashtable);
-
- if (logger.isInfoEnabled())
- logger.info("DICT protocol implementation [STARTED].");
- }
-
- /**
- * 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;
- }
-
- /**
- * 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
- {
-
- dictProviderFactory.stop();
- dictPpFactoryServReg.unregister();
-
- if (logger.isInfoEnabled())
- logger.info("DICT protocol implementation [STOPPED].");
- }
-
- /**
- * Returns a reference to the protocol provider factory that we have
- * registered.
- * @return a reference to the <tt>ProtocolProviderFactoryDictImpl</tt>
- * instance that we have registered from this package.
- */
- public static ProtocolProviderFactoryDictImpl getProtocolProviderFactory()
- {
- return dictProviderFactory;
- }
-
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourceService == null)
- {
- ServiceReference serviceReference = bundleContext
- .getServiceReference(ResourceManagementService.class.getName());
-
- if(serviceReference == null)
- return null;
-
- resourceService = (ResourceManagementService) bundleContext
- .getService(serviceReference);
- }
-
- return resourceService;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/DictStatusEnum.java b/src/net/java/sip/communicator/impl/protocol/dict/DictStatusEnum.java
deleted file mode 100644
index 87086f7..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/DictStatusEnum.java
+++ /dev/null
@@ -1,88 +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.dict;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * An implementation of <tt>PresenceStatus</tt> that enumerates all states that
- * a Dict contact can fall into.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class DictStatusEnum
- extends PresenceStatus
-{
-
- /**
- * Indicates an Offline status or status with 0 connectivity.
- */
- public static final DictStatusEnum OFFLINE
- = new DictStatusEnum(
- 0, "Offline",
- DictActivator.getResources()
- .getImageInBytes("service.protocol.dict.OFFLINE_STATUS_ICON"));
-
- /**
- * The Online status. Indicate that the user is able and willing to
- * communicate.
- */
- public static final DictStatusEnum ONLINE
- = new DictStatusEnum(
- 65, "Online",
- DictActivator.getResources()
- .getImageInBytes("service.protocol.dict.DICT_16x16"));
-
- /**
- * Initialize the list of supported status states.
- */
- private static List<PresenceStatus> supportedStatusSet = new LinkedList<PresenceStatus>();
- static
- {
- supportedStatusSet.add(OFFLINE);
- supportedStatusSet.add(ONLINE);
- }
-
- /**
- * Creates an instance of <tt>RssPresneceStatus</tt> with the
- * specified parameters.
- * @param status the connectivity level of the new presence status instance
- * @param statusName the name of the presence status.
- * @param statusIcon the icon associated with this status
- */
- private DictStatusEnum(int status,
- String statusName,
- byte[] statusIcon)
- {
- super(status, statusName, statusIcon);
- }
-
- /**
- * Returns an iterator over all status instances supproted by the rss
- * provider.
- * @return an <tt>Iterator</tt> over all status instances supported by the
- * rss provider.
- */
- static Iterator<PresenceStatus> supportedStatusSet()
- {
- return supportedStatusSet.iterator();
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/MessageDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/MessageDictImpl.java
deleted file mode 100644
index 5b95dd4..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/MessageDictImpl.java
+++ /dev/null
@@ -1,46 +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.dict;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * Very simple message implementation for the Dict protocol.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- * @author Lubomir Marinov
- */
-public class MessageDictImpl
- extends AbstractMessage
-{
-
- /**
- * Creates a message instance according to the specified parameters.
- *
- * @param content the message body
- * @param contentType message content type or null for text/plain
- * @param contentEncoding message encoding or null for UTF8
- * @param subject the subject of the message or null for no subject.
- */
- public MessageDictImpl(String content, String contentType,
- String contentEncoding, String subject)
- {
- super(content, contentType, contentEncoding, subject);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/OperationSetBasicInstantMessagingDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/OperationSetBasicInstantMessagingDictImpl.java
deleted file mode 100644
index f1f4973..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/OperationSetBasicInstantMessagingDictImpl.java
+++ /dev/null
@@ -1,412 +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.dict;
-
-import java.util.*;
-
-import net.java.dict4j.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Instant messaging functionalities for the Dict protocol.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class OperationSetBasicInstantMessagingDictImpl
- extends AbstractOperationSetBasicInstantMessaging
- implements RegistrationStateChangeListener
-{
- /**
- * The currently valid persistent presence operation set.
- */
- private OperationSetPersistentPresenceDictImpl opSetPersPresence = null;
-
- /**
- * The protocol provider that created us.
- */
- private ProtocolProviderServiceDictImpl parentProvider = null;
-
- private DictAccountID accountID;
-
- /**
- * Creates an instance of this operation set keeping a reference to the
- * parent protocol provider and presence operation set.
- *
- * @param provider The provider instance that creates us.
- * @param opSetPersPresence the currently valid
- * <tt>OperationSetPersistentPresenceDictImpl</tt> instance.
- */
- public OperationSetBasicInstantMessagingDictImpl(
- ProtocolProviderServiceDictImpl provider,
- OperationSetPersistentPresenceDictImpl opSetPersPresence)
- {
- this.opSetPersPresence = opSetPersPresence;
- this.parentProvider = provider;
- this.accountID = (DictAccountID) provider.getAccountID();
-
- parentProvider.addRegistrationStateChangeListener(this);
- }
-
- @Override
- public Message createMessage(String content)
- {
- return new MessageDictImpl(content, HTML_MIME_TYPE,
- DEFAULT_MIME_ENCODING, null);
- }
-
- @Override
- public Message createMessage(String content, String contentType,
- String encoding, String subject)
- {
- return new MessageDictImpl(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 ICQ stack is not
- * registered and initialized.
- * @throws IllegalArgumentException if <tt>to</tt> is not an instance
- * belonging to the underlying implementation.
- */
- public void sendInstantMessage(Contact to, Message message)
- throws IllegalStateException,
- IllegalArgumentException
- {
- if( !(to instanceof ContactDictImpl) )
- {
- throw new IllegalArgumentException(
- "The specified contact is not a Dict contact."
- + to);
- }
-
- // Remove all html tags from the message
- message = createMessage(Html2Text.extractText(message.getContent()));
-
- // Display the queried word
- fireMessageDelivered(message, to);
-
- this.submitDictQuery((ContactDictImpl) to, message);
- }
-
- /**
- * Determines whether the protocol provider (or the protocol itself) supports
- * 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 false;
- }
-
- /**
- * Determines whether 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))
- return true;
- else if(contentType.equals(HTML_MIME_TYPE))
- return true;
- else
- return false;
- }
-
- /**
- * Returns the protocol provider that this operation set belongs to.
- *
- * @return a reference to the <tt>ProtocolProviderServiceDictImpl</tt>
- * instance that this operation set belongs to.
- */
- public ProtocolProviderServiceDictImpl getParentProvider()
- {
- return this.parentProvider;
- }
-
- /**
- * Returns a reference to the presence operation set instance used by our
- * source provider.
- *
- * @return a reference to the <tt>OperationSetPersistentPresenceDictImpl</tt>
- * instance used by this provider.
- */
- public OperationSetPersistentPresenceDictImpl getOpSetPersPresence()
- {
- return this.opSetPersPresence;
- }
-
- /**
- * The method is called by the ProtocolProvider whenever a change in the
- * registration state of the corresponding provider has occurred.
- *
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
-
- }
-
-
- /**
- * Create, execute and display a query to a dictionary (ContactDictImpl)
- *
- * @param dictContact the contact containing the database name
- * @param message the message containing the word
- */
- private void submitDictQuery(ContactDictImpl dictContact, Message message)
- {
- Message msg = this.createMessage("");
-
- String database = dictContact.getContactID();
- DictConnection conn = this.parentProvider.getConnection();
- boolean doMatch = false;
-
- String word;
-
- // Formatting the query message, if the word as one or more spaces we
- // put it between quotes to prevent errors
- word = message.getContent().replace("\"", "").trim();
- if (word.indexOf(' ') > 0)
- {
- word = "\"" + word + "\"";
- }
-
- // Try to get the definition of the work
- try
- {
- List<Definition> definitions = conn.define(database, word);
- msg = this.createMessage(retrieveDefine(definitions, word));
- }
- catch(DictException dx)
- {
- if (dx.getErrorCode() == DictReturnCode.NO_MATCH)
- { // No word found, we are going to try the match command
- doMatch = true;
- }
- else
- { // Otherwise we display the error returned by the server
- msg = this.createMessage(manageException(dx, database));
- }
- }
-
- if (doMatch)
- {
- // Trying the match command
- try
- {
- List<MatchWord> matchWords = conn.match(database, word,
- this.accountID.getStrategy());
- msg = this.createMessage(retrieveMatch(matchWords, word));
- }
- catch(DictException dx)
- {
- msg = this.createMessage(manageException(dx, database));
- }
- }
-
- // Send message
- fireMessageReceived(msg, dictContact);
- }
-
- /**
- * Generate the display of the results of the Define command
- *
- * @param data the result of the Define command
- * @param word the queried word
- * @return the formatted result
- */
- private String retrieveDefine(List<Definition> data, String word)
- {
- StringBuffer res = new StringBuffer();
- Definition def;
-
- for (int i=0; i<data.size(); i++)
- {
- def = data.get(i);
-
- if(i != 0 && data.size() > 0)
- {
- res.append("<hr>");
- }
- res.append(def.getDefinition().replaceAll("\n", "<br>"))
- .append("<div align=\"right\"><font size=\"-2\">-- From ")
- .append(def.getDictionary())
- .append("</font></div>");
- }
-
- String result = res.toString();
- result = formatResult(result, "\\\\", "<em>", "</em>");
- result = formatResult(result, "[\\[\\]]", "<cite>", "</cite>");
- result = formatResult(result, "[\\{\\}]", "<strong>", "</strong>");
- result = formatWordDefined(result, word);
-
- return result;
- }
-
- /**
- * Makes a stronger emphasis for the word defined.
- * @param result The text containing the definition of the word.
- * @param word The word defined to display with bold font. For this we
- * had the strong HTML tag.
- * @return Returns the result text with an strong emphasis of all
- * the occurences of the word defined.
- */
- private String formatWordDefined(String result, String word)
- {
- String tmpWord;
-
- tmpWord = word.toUpperCase();
- result = result.replaceAll("\\b" + tmpWord + "\\b", "<strong>" + tmpWord + "</strong>");
- tmpWord = word.toLowerCase();
- result = result.replaceAll("\\b" + tmpWord + "\\b", "<strong>" + tmpWord + "</strong>");
- if(tmpWord.length() > 1)
- {
- tmpWord = tmpWord.substring(0, 1).toUpperCase() + tmpWord.substring(1);
- result = result.replaceAll("\\b" + tmpWord + "\\b", "<strong>" + tmpWord + "</strong>");
- }
-
- return result;
- }
-
- /**
- * Remplaces special characters into HTML tags to make some emphasis.
- * @param result The text containing the definition of the word.
- * @param regex The special character to replace with HTML tags.
- * @param startTag The start HTML tag to use.
- * @param endTag The end HTML tag to use.
- * @return The result with all special characters replaced by HTML
- * tags.
- */
- private String formatResult(String result, String regex, String startTag, String endTag)
- {
- String[] tmp = result.split(regex);
- String res = "";
-
- for(int i = 0; i < (tmp.length - 1); i += 2)
- {
- res += tmp[i] + startTag + tmp[i+1] + endTag;
- }
- if((tmp.length % 2) != 0)
- {
- res += tmp[tmp.length - 1];
- }
- return res;
- }
-
- /**
- * Generate the display of the results of the Match command
- *
- * @param data the result of the Match command
- * @param word the queried word
- * @return the formatted result
- */
- private String retrieveMatch(List<MatchWord> data, String word)
- {
- StringBuffer result = new StringBuffer();
- boolean isStart = true;
-
- result.append(DictActivator.getResources()
- .getI18NString("plugin.dictaccregwizz.MATCH_RESULT", new String[] {word}));
-
- for (int i=0; i<data.size(); i++)
- {
- if (isStart)
- isStart = false;
- else
- result.append(", ");
-
- result.append(data.get(i).getWord());
- }
-
- return result.toString();
- }
-
- /**
- * Manages the return exception of a dict query.
- *
- * @param dix The exception returned by the adapter
- * @param database The dictionary used
- * @return Exception message
- */
- private String manageException(DictException dix, String database)
- {
- int errorCode = dix.getErrorCode();
-
- // We change the text only for exception 550 (invalid dictionary) and 551 (invalid strategy)
- if (errorCode == DictReturnCode.INVALID_DATABASE)
- {
- return DictActivator.getResources()
- .getI18NString("plugin.dictaccregwizz.INVALID_DATABASE", new String[] {database});
- }
- else if (errorCode == DictReturnCode.INVALID_STRATEGY)
- {
- return DictActivator.getResources()
- .getI18NString("plugin.dictaccregwizz.INVALID_STRATEGY");
- }
- else if (errorCode == DictReturnCode.NO_MATCH)
- {
- return DictActivator.getResources()
- .getI18NString("plugin.dictaccregwizz.NO_MATCH");
- }
-
- return dix.getMessage();
- }
-
- /**
- * Sends the <tt>message</tt> to the destination indicated by the
- * <tt>to</tt>. Resources are not supported by this operation set
- * implementation.
- *
- * @param to the <tt>Contact</tt> to send <tt>message</tt> to
- * @param toResource the resource to which the message should be send
- * @param message the <tt>Message</tt> to send.
- * @throws java.lang.IllegalStateException if the underlying ICQ stack is
- * not registered and initialized.
- * @throws java.lang.IllegalArgumentException if <tt>to</tt> is not an
- * instance belonging to the underlying implementation.
- */
- @Override
- public void sendInstantMessage( Contact to,
- ContactResource toResource,
- Message message)
- throws IllegalStateException,
- IllegalArgumentException
- {
- sendInstantMessage(to, message);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/OperationSetPersistentPresenceDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/OperationSetPersistentPresenceDictImpl.java
deleted file mode 100644
index 8184fe9..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/OperationSetPersistentPresenceDictImpl.java
+++ /dev/null
@@ -1,988 +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.dict;
-
-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 org.osgi.framework.*;
-
-/**
- * A Dict implementation of a persistent presence operation set. In order
- * to simulate server persistence, this operation set would simply accept all
- * unresolved contacts and resolve them immediately. A real world protocol
- * implementation would save it on a server using methods provided by the
- * protocol stack.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class OperationSetPersistentPresenceDictImpl
- extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceDictImpl>
-{
- private static final Logger logger =
- Logger.getLogger(OperationSetPersistentPresenceDictImpl.class);
-
- /**
- * The root of the dict contact list.
- */
- private ContactGroupDictImpl contactListRoot = null;
-
- /**
- * The currently active status message.
- */
- private String statusMessage = "Default Status Message";
-
- /**
- * Our presence status.
- */
- private PresenceStatus presenceStatus = DictStatusEnum.ONLINE;
-
- /**
- * The <tt>AuthorizationHandler</tt> instance that we'd have to transmit
- * authorization requests to for approval.
- */
- private AuthorizationHandler authorizationHandler = null;
-
- /**
- * Creates an instance of this operation set keeping a reference to the
- * specified parent <tt>provider</tt>.
- * @param provider the ProtocolProviderServiceDictImpl instance that
- * created us.
- */
- public OperationSetPersistentPresenceDictImpl(
- ProtocolProviderServiceDictImpl provider)
- {
- super(provider);
-
- contactListRoot = new ContactGroupDictImpl("RootGroup", provider);
-
- //add our unregistration listener
- parentProvider.addRegistrationStateChangeListener(
- new UnregistrationListener());
- }
-
- /**
- * 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.
- */
- public void createServerStoredContactGroup(ContactGroup parent,
- String groupName)
- {
- ContactGroupDictImpl newGroup
- = new ContactGroupDictImpl(groupName, parentProvider);
-
- ((ContactGroupDictImpl)parent).addSubgroup(newGroup);
-
- this.fireServerStoredGroupEvent(
- newGroup, ServerStoredGroupEvent.GROUP_CREATED_EVENT);
- }
-
- /**
- * A Dict Provider method to use for fast filling of a contact list.
- *
- * @param contactGroup the group to add
- */
- public void addDictGroup(ContactGroupDictImpl contactGroup)
- {
- contactListRoot.addSubgroup(contactGroup);
- }
-
- /**
- * A Dict Provider method to use for fast filling of a contact list.
- * This method would add both the group and fire an event.
- *
- * @param parent the group where <tt>contactGroup</tt> should be added.
- * @param contactGroup the group to add
- */
- public void addDictGroupAndFireEvent(
- ContactGroupDictImpl parent
- , ContactGroupDictImpl contactGroup)
- {
- parent.addSubgroup(contactGroup);
-
- this.fireServerStoredGroupEvent(
- contactGroup, ServerStoredGroupEvent.GROUP_CREATED_EVENT);
- }
-
-
- /**
- * 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 contactListRoot.findContactByID(contactID);
- }
-
- /**
- * Sets the specified status message.
- * @param statusMessage a String containing the new status message.
- */
- public void setStatusMessage(String statusMessage)
- {
- this.statusMessage = statusMessage;
- }
-
- /**
- * Returns the status message that was last set through
- * setCurrentStatusMessage.
- *
- * @return the last status message that we have requested and the aim
- * server has confirmed.
- */
- public String getCurrentStatusMessage()
- {
- return statusMessage;
- }
-
- /**
- * 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 presenceStatus;
- }
-
- /**
- * 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 contactListRoot;
- }
-
- /**
- * 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 DictStatusEnum.supportedStatusSet();
- }
-
- /**
- * 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)
- {
- ContactDictImpl dictContact
- = (ContactDictImpl)contactToMove;
-
- ContactGroupDictImpl parentDictGroup
- = findContactParent(dictContact);
-
- parentDictGroup.removeContact(dictContact);
-
- //if this is a volatile contact then we haven't really subscribed to
- //them so we'd need to do so here
- if(!dictContact.isPersistent())
- {
- //first tell everyone that the volatile contact was removed
- fireSubscriptionEvent(dictContact
- , parentDictGroup
- , SubscriptionEvent.SUBSCRIPTION_REMOVED);
-
- try
- {
- //now subscribe
- this.subscribe(newParent, contactToMove.getAddress());
-
- //now tell everyone that we've added the contact
- fireSubscriptionEvent(dictContact
- , newParent
- , SubscriptionEvent.SUBSCRIPTION_CREATED);
- }
- catch (Exception ex)
- {
- logger.error("Failed to move contact "
- + dictContact.getAddress()
- , ex);
- }
- }
- else
- {
- ( (ContactGroupDictImpl) newParent)
- .addContact(dictContact);
-
- fireSubscriptionMovedEvent(contactToMove
- , parentDictGroup
- , 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
- {
- PresenceStatus oldPresenceStatus = this.presenceStatus;
- this.presenceStatus = status;
- this.statusMessage = statusMessage;
-
- this.fireProviderStatusChangeEvent(oldPresenceStatus);
-
- //since we are not a real protocol, we set the contact presence status
- //ourselves and make them have the same status as ours.
- changePresenceStatusForAllContacts( getServerStoredContactListRoot()
- , getPresenceStatus());
-
- //now check whether we are in someone else's contact list and modify
- //our status there
- List<Contact> contacts = findContactsPointingToUs();
-
- Iterator<Contact> contactsIter = contacts.iterator();
- while (contactsIter.hasNext())
- {
- ContactDictImpl contact
- = (ContactDictImpl) contactsIter.next();
-
- PresenceStatus oldStatus = contact.getPresenceStatus();
- contact.setPresenceStatus(status);
- contact.getParentPresenceOperationSet()
- .fireContactPresenceStatusChangeEvent(
- contact
- , contact.getParentContactGroup()
- , oldStatus);
-
- }
- }
-
-
-
- /**
- * 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
- {
- return findContactByID(contactIdentifier).getPresenceStatus();
- }
-
- /**
- * Sets the presence status of <tt>contact</tt> to <tt>newStatus</tt>.
- *
- * @param contact the <tt>ContactDictImpl</tt> whose status we'd like
- * to set.
- * @param newStatus the new status we'd like to set to <tt>contact</tt>.
- */
- private void changePresenceStatusForContact(
- ContactDictImpl contact
- , PresenceStatus newStatus)
- {
- PresenceStatus oldStatus = contact.getPresenceStatus();
- contact.setPresenceStatus(newStatus);
-
- fireContactPresenceStatusChangeEvent(
- contact, findContactParent(contact), oldStatus);
- }
-
- /**
- * Sets the presence status of all <tt>contact</tt>s in our contact list
- * (except those that correspond to another provider registered with SC)
- * to <tt>newStatus</tt>.
- *
- * @param newStatus the new status we'd like to set to <tt>contact</tt>.
- * @param parent the group in which we'd have to update the status of all
- * direct and indirect child contacts.
- */
- private void changePresenceStatusForAllContacts(ContactGroup parent,
- PresenceStatus newStatus)
- {
- //first set the status for contacts in this group
- Iterator<Contact> childContacts = parent.contacts();
-
- while(childContacts.hasNext())
- {
- ContactDictImpl contact
- = (ContactDictImpl)childContacts.next();
-
- if(findProviderForDictUserID(contact.getAddress()) != null)
- {
- //this is a contact corresponding to another SIP Communicator
- //provider so we won't change it's status here.
- continue;
- }
- PresenceStatus oldStatus = contact.getPresenceStatus();
- contact.setPresenceStatus(newStatus);
-
- fireContactPresenceStatusChangeEvent(
- contact, parent, oldStatus);
- }
-
- //now call this method recursively for all subgroups
- Iterator<ContactGroup> subgroups = parent.subgroups();
-
- while(subgroups.hasNext())
- {
- ContactGroup subgroup = subgroups.next();
- changePresenceStatusForAllContacts(subgroup, newStatus);
- }
- }
-
- /**
- * Returns the group that is parent of the specified dictGroup or null
- * if no parent was found.
- * @param dictGroup the group whose parent we're looking for.
- * @return the ContactGroupDictImpl instance that dictGroup
- * belongs to or null if no parent was found.
- */
- public ContactGroupDictImpl findGroupParent(
- ContactGroupDictImpl dictGroup)
- {
- return contactListRoot.findGroupParent(dictGroup);
- }
-
- /**
- * Returns the group that is parent of the specified dictContact or
- * null if no parent was found.
- * @param dictContact the contact whose parent we're looking for.
- * @return the ContactGroupDictImpl instance that dictContact
- * belongs to or null if no parent was found.
- */
- public ContactGroupDictImpl findContactParent(
- ContactDictImpl dictContact)
- {
- return (ContactGroupDictImpl)dictContact
- .getParentContactGroup();
- }
-
-
- /**
- * Removes the specified group from the server stored contact list.
- *
- * @param group the group to remove.
- *
- * @throws IllegalArgumentException if <tt>group</tt> was not found in this
- * protocol's contact list.
- */
- public void removeServerStoredContactGroup(ContactGroup group)
- throws IllegalArgumentException
- {
- ContactGroupDictImpl dictGroup
- = (ContactGroupDictImpl)group;
-
- ContactGroupDictImpl parent = findGroupParent(dictGroup);
-
- if(parent == null){
- throw new IllegalArgumentException(
- "group " + group
- + " does not seem to belong to this protocol's contact list.");
- }
-
- parent.removeSubGroup(dictGroup);
-
- this.fireServerStoredGroupEvent(
- dictGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
- }
-
- /**
- * 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)
- {
- ((ContactGroupDictImpl)group).setGroupName(newName);
-
- this.fireServerStoredGroupEvent(
- group, ServerStoredGroupEvent.GROUP_RENAMED_EVENT);
- }
-
- /**
- * 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.authorizationHandler = handler;
- }
-
- /**
- * 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
- {
- ContactDictImpl contact = new ContactDictImpl(
- contactIdentifier
- , parentProvider);
-
- ((ContactGroupDictImpl)parent).addContact(contact);
-
- fireSubscriptionEvent(contact,
- parent,
- SubscriptionEvent.SUBSCRIPTION_CREATED);
-
- //notify presence listeners for the status change.
- fireContactPresenceStatusChangeEvent(contact
- , parent
- , DictStatusEnum.ONLINE);
- }
-
-
- /**
- * Depending on whether <tt>contact</tt> corresponds to another protocol
- * provider installed in sip-communicator, this method would either deliver
- * it to that provider or simulate a corresponding request from the
- * destination contact and make return a response after it has received
- * one If the destination contact matches us, then we'll ask the user to
- * act upon the request, and return the response.
- *
- * @param request the authorization request that we'd like to deliver to the
- * destination <tt>contact</tt>.
- * @param contact the <tt>Contact</tt> to notify
- *
- * @return the <tt>AuthorizationResponse</tt> that has been given or
- * generated in response to <tt>request</tt>.
- */
- private AuthorizationResponse deliverAuthorizationRequest(
- AuthorizationRequest request,
- Contact contact)
- {
- String userID = contact.getAddress();
-
- //if the user id is our own id, then this request is being routed to us
- //from another instance of the dict provider.
- if (userID.equals(this.parentProvider.getAccountID().getUserID()))
- {
- //check who is the provider sending the message
- String sourceUserID = contact.getProtocolProvider()
- .getAccountID().getUserID();
-
- //check whether they are in our contact list
- Contact from = findContactByID(sourceUserID);
-
- //and if not - add them there as volatile.
- if (from == null)
- {
- from = createVolatileContact(sourceUserID);
- }
-
- //and now handle the request.
- return authorizationHandler.processAuthorisationRequest(
- request, from);
- }
- else
- {
- //if userID is not our own, try a check whether another provider
- //has that id and if yes - deliver the request to them.
- ProtocolProviderServiceDictImpl dictProvider
- = this.findProviderForDictUserID(userID);
- if (dictProvider != null)
- {
- OperationSetPersistentPresenceDictImpl opSetPersPresence
- = (OperationSetPersistentPresenceDictImpl)
- dictProvider.getOperationSet(
- OperationSetPersistentPresence.class);
- return opSetPersPresence
- .deliverAuthorizationRequest(request, contact);
- }
- else
- {
- //if we got here then "to" is simply someone in our contact
- //list so let's just simulate a reciproce request and generate
- //a response accordingly.
-
- //pretend that the remote contact is asking for authorization
- authorizationHandler.processAuthorisationRequest(
- request, contact);
-
- //and now pretend that the remote contact has granted us
- //authorization
- return new AuthorizationResponse(AuthorizationResponse.ACCEPT
- , "You are welcome!");
- }
- }
- }
-
- /**
- * 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
- {
- //subscribe(contactListRoot, 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
- {
- ContactGroupDictImpl parentGroup
- = (ContactGroupDictImpl)((ContactDictImpl)contact)
- .getParentContactGroup();
-
- parentGroup.removeContact((ContactDictImpl)contact);
-
- fireSubscriptionEvent(contact,
- ((ContactDictImpl)contact).getParentContactGroup()
- , SubscriptionEvent.SUBSCRIPTION_REMOVED);
- }
-
- /**
- * Creates and returns a unresolved contact from the specified
- * <tt>address</tt> and <tt>persistentData</tt>. The method will not try
- * to establish a network connection and resolve the newly created Contact
- * against the server. The protocol provider may will later try and resolve
- * the contact. When this happens the corresponding event would notify
- * interested subscription listeners.
- *
- * @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 from the specified
- * <tt>address</tt> and <tt>persistentData</tt>. The method will not try
- * to establish a network connection and resolve the newly created Contact
- * against the server. The protocol provider may will later try and resolve
- * the contact. When this happens the corresponding event would notify
- * interested subscription listeners.
- *
- * @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 parent 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 parent)
- {
-
- ContactDictImpl contact = new ContactDictImpl(
- address
- , parentProvider);
- contact.setResolved(false);
-
- ( (ContactGroupDictImpl) parent).addContact(contact);
-
- fireSubscriptionEvent(contact,
- parent,
- SubscriptionEvent.SUBSCRIPTION_CREATED);
-
- //since we don't have any server, we'll simply resolve the contact
- //ourselves as if we've just received an event from the server telling
- //us that it has been resolved.
- contact.setResolved(true);
- fireSubscriptionEvent(contact, parent, SubscriptionEvent.SUBSCRIPTION_RESOLVED);
-
- //since we are not a real protocol, we set the contact presence status
- //ourselves
- changePresenceStatusForContact( contact, getPresenceStatus());
-
- return contact;
- }
-
- /**
- * Looks for a dict protocol provider registered for a user id matching
- * <tt>dictUserID</tt>.
- *
- * @param dictUserID the ID of the Dict user whose corresponding
- * protocol provider we'd like to find.
- * @return ProtocolProviderServiceDictImpl a dict protocol
- * provider registered for a user with id <tt>dictUserID</tt> or null
- * if there is no such protocol provider.
- */
- public ProtocolProviderServiceDictImpl
- findProviderForDictUserID(String dictUserID)
- {
- BundleContext bc = DictActivator.getBundleContext();
-
- String osgiQuery = "(&"
- + "(" + ProtocolProviderFactory.PROTOCOL
- + "=Dict)"
- + "(" + ProtocolProviderFactory.USER_ID
- + "=" + dictUserID + ")"
- + ")";
-
- ServiceReference[] refs = null;
- try
- {
- refs = bc.getServiceReferences(
- ProtocolProviderService.class.getName()
- ,osgiQuery);
- }
- catch (InvalidSyntaxException ex)
- {
- logger.error("Failed to execute the following osgi query: "
- + osgiQuery
- , ex);
- }
-
- if(refs != null && refs.length > 0)
- {
- return (ProtocolProviderServiceDictImpl)bc.getService(refs[0]);
- }
-
- return null;
- }
-
- /**
- * Looks for dict protocol providers that have added us to their
- * contact list and returns list of all contacts representing us in these
- * providers.
- *
- * @return a list of all contacts in other providers' contact lists that
- * point to us.
- */
- public List<Contact> findContactsPointingToUs()
- {
- List<Contact> contacts = new LinkedList<Contact>();
- BundleContext bc = DictActivator.getBundleContext();
-
- String osgiQuery =
- "(" + ProtocolProviderFactory.PROTOCOL
- + "=Dict)";
-
- ServiceReference[] refs = null;
- try
- {
- refs = bc.getServiceReferences(
- ProtocolProviderService.class.getName()
- ,osgiQuery);
- }
- catch (InvalidSyntaxException ex)
- {
- logger.error("Failed to execute the following osgi query: "
- + osgiQuery
- , ex);
- }
-
- for (int i =0; refs != null && i < refs.length; i++)
- {
- ProtocolProviderServiceDictImpl gibProvider
- = (ProtocolProviderServiceDictImpl)bc.getService(refs[i]);
-
- OperationSetPersistentPresenceDictImpl opSetPersPresence
- = (OperationSetPersistentPresenceDictImpl)gibProvider
- .getOperationSet(OperationSetPersistentPresence.class);
-
- Contact contact = opSetPersPresence.findContactByID(
- parentProvider.getAccountID().getUserID());
-
- if (contact != null)
- contacts.add(contact);
- }
-
- return contacts;
- }
-
-
- /**
- * Creates and returns a unresolved contact group from the specified
- * <tt>address</tt> and <tt>persistentData</tt>. The method will not try
- * to establish a network connection and resolve the newly created
- * <tt>ContactGroup</tt> against the server or the contact itself. The
- * protocol provider will later resolve the contact group. When this happens
- * the corresponding event would notify interested subscription listeners.
- *
- * @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)
- {
- ContactGroupDictImpl newGroup
- = new ContactGroupDictImpl(
- ContactGroupDictImpl.createNameFromUID(groupUID)
- , parentProvider);
- newGroup.setResolved(false);
-
- //if parent is null then we're adding under root.
- if(parentGroup == null)
- parentGroup = getServerStoredContactListRoot();
-
- ((ContactGroupDictImpl)parentGroup).addSubgroup(newGroup);
-
- this.fireServerStoredGroupEvent(
- newGroup, ServerStoredGroupEvent.GROUP_CREATED_EVENT);
-
- return newGroup;
- }
-
- private class UnregistrationListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenver
- * a change in the registration state of the corresponding provider had
- * occurred. The method is particularly interested in events stating
- * that the dict provider has unregistered so that it would fire
- * status change events for all contacts in our buddy list.
- *
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (! evt.getNewState().equals(RegistrationState.UNREGISTERED)
- && !evt.getNewState().equals(RegistrationState.AUTHENTICATION_FAILED)
- && !evt.getNewState().equals(RegistrationState.CONNECTION_FAILED))
- {
- return;
- }
-
- //send event notifications saying that all our buddies are
- //offline. The icq 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())
- {
- ContactGroupDictImpl group
- = (ContactGroupDictImpl) groupsIter.next();
-
- Iterator<Contact> contactsIter = group.contacts();
-
- while (contactsIter.hasNext())
- {
- ContactDictImpl contact
- = (ContactDictImpl) contactsIter.next();
-
- PresenceStatus oldContactStatus
- = contact.getPresenceStatus();
-
- if (!oldContactStatus.isOnline())
- continue;
-
- contact.setPresenceStatus(DictStatusEnum.OFFLINE);
-
- fireContactPresenceStatusChangeEvent(
- contact
- , contact.getParentContactGroup()
- , oldContactStatus);
- }
- }
- }
- }
-
- /**
- * Returns the volatile group or null if this group has not yet been
- * created.
- *
- * @return a volatile group existing in our contact list or <tt>null</tt>
- * if such a group has not yet been created.
- */
- private ContactGroupDictImpl getNonPersistentGroup()
- {
- for (int i = 0
- ; i < getServerStoredContactListRoot().countSubgroups()
- ; i++)
- {
- ContactGroupDictImpl gr =
- (ContactGroupDictImpl)getServerStoredContactListRoot()
- .getGroup(i);
-
- if(!gr.isPersistent())
- return gr;
- }
-
- return null;
- }
-
-
- /**
- * 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 contactAddress the address of the volatile contact we'd like to
- * create.
- * @return the newly created volatile contact.
- */
- public ContactDictImpl createVolatileContact(String contactAddress)
- {
- //First create the new volatile contact;
- ContactDictImpl newVolatileContact
- = new ContactDictImpl(contactAddress
- , this.parentProvider);
- newVolatileContact.setPersistent(false);
-
-
- //Check whether a volatile group already exists and if not create
- //one
- ContactGroupDictImpl theVolatileGroup = getNonPersistentGroup();
-
-
- //if the parent volatile group is null then we create it
- if (theVolatileGroup == null)
- {
- theVolatileGroup = new ContactGroupDictImpl(
- DictActivator.getResources().getI18NString(
- "service.gui.NOT_IN_CONTACT_LIST_GROUP_NAME")
- , parentProvider);
- theVolatileGroup.setResolved(false);
- theVolatileGroup.setPersistent(false);
-
- this.contactListRoot.addSubgroup(theVolatileGroup);
-
- fireServerStoredGroupEvent(theVolatileGroup
- , ServerStoredGroupEvent.GROUP_CREATED_EVENT);
- }
-
- //now add the volatile contact instide it
- theVolatileGroup.addContact(newVolatileContact);
- fireSubscriptionEvent(newVolatileContact
- , theVolatileGroup
- , SubscriptionEvent.SUBSCRIPTION_CREATED);
-
- return newVolatileContact;
- }
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolIconDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/ProtocolIconDictImpl.java
deleted file mode 100644
index 4f09f22..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolIconDictImpl.java
+++ /dev/null
@@ -1,133 +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.dict;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * Represents the Dict protocol icon. Implements the <tt>ProtocolIcon</tt>
- * interface in order to provide a Dict logo image in two different sizes.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class ProtocolIconDictImpl
- implements ProtocolIcon
-{
- /**
- * 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,
- DictActivator.getResources()
- .getImageInBytes("service.protocol.dict.DICT_16x16"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_32x32,
- DictActivator.getResources()
- .getImageInBytes("service.protocol.dict.DICT_32x32"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_48x48,
- DictActivator.getResources()
- .getImageInBytes("service.protocol.dict.DICT_48x48"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_64x64,
- DictActivator.getResources()
- .getImageInBytes("service.protocol.dict.DICT_64x64"));
- }
-
- /**
- * A hash table containing the path to the protocol icon in different sizes.
- */
- private static Hashtable<String, String> iconPathsTable
- = new Hashtable<String, String>();
- static
- {
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_16x16,
- DictActivator.getResources()
- .getImagePath("service.protocol.dict.DICT_16x16"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_32x32,
- DictActivator.getResources()
- .getImagePath("service.protocol.dict.DICT_32x32"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_48x48,
- DictActivator.getResources()
- .getImagePath("service.protocol.dict.DICT_48x48"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_64x64,
- DictActivator.getResources()
- .getImagePath("service.protocol.dict.DICT_64x64"));
- }
-
- /**
- * Implements the <tt>ProtocolIcon.getSupportedSizes()</tt> method. Returns
- * an iterator to a set containing the supported icon sizes.
- * @return Returns an iterator to a set containing the supported icon sizes
- */
- public Iterator<String> getSupportedSizes()
- {
- return iconsTable.keySet().iterator();
- }
-
- /**
- * Returns TRUE if an icon with the given size is supported, FALSE otherwise.
- * @param iconSize The size of the icon, that we want to know if it is
- * supported.
- * @return Returns true if the 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
- * @return Returns a byte[] containing the pixels of the icon for the given
- * size.
- */
- 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 Returns the icon image used to represent the protocol connecting
- * state.
- */
- public byte[] getConnectingIcon()
- {
- return iconsTable.get(ProtocolIcon.ICON_SIZE_16x16);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderFactoryDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderFactoryDictImpl.java
deleted file mode 100644
index d7eaf30..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderFactoryDictImpl.java
+++ /dev/null
@@ -1,200 +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.dict;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.contactlist.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * The Dict protocol provider factory creates instances of the Dict
- * protocol provider service. One Service instance corresponds to one account.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class ProtocolProviderFactoryDictImpl
- extends ProtocolProviderFactory
-{
- private static final Logger logger
- = Logger.getLogger(ProtocolProviderFactoryDictImpl.class);
-
- /**
- * Creates an instance of the ProtocolProviderFactoryDictImpl.
- */
- public ProtocolProviderFactoryDictImpl()
- {
- super(DictActivator.getBundleContext(), ProtocolNames.DICT);
- }
-
- /**
- * Initializaed and creates an account corresponding to the specified
- * accountProperties and registers the resulting ProtocolProvider in the
- * <tt>context</tt> BundleContext parameter.
- *
- * @param userIDStr The user identifier uniquely representing the newly
- * created account within the protocol namespace.
- * @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 = DictActivator.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 DictAccountID(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
- //ProtocolProviderService.register() method and it needs to acces
- //the configuration service and check for a stored password.
- this.storeAccount(accountID, false);
-
- accountID = loadAccount(accountProperties);
-
- // Creates the dict contact group.
- this.createGroup();
- // Creates the default conatct for this dict server.
- this.createDefaultContact(accountID);
-
- return accountID;
- }
-
- @Override
- protected AccountID createAccountID(String userID, Map<String, String> accountProperties)
- {
- return new DictAccountID(userID, accountProperties);
- }
-
- @Override
- protected ProtocolProviderService createService(String userID,
- AccountID accountID)
- {
- ProtocolProviderServiceDictImpl service =
- new ProtocolProviderServiceDictImpl();
-
- service.initialize(userID, accountID);
- return service;
- }
-
- /**
- * Creates a group for the dict contacts
- */
- private void createGroup()
- {
- // Get MetaContactListService
- BundleContext bundleContext = getBundleContext();
- ServiceReference<MetaContactListService> mfcServiceRef
- = bundleContext.getServiceReference(MetaContactListService.class);
-
- MetaContactListService mcl = bundleContext.getService(mfcServiceRef);
-
- try
- {
- String groupName = DictActivator.getResources()
- .getI18NString("service.protocol.DICTIONARIES");
-
- mcl.createMetaContactGroup(mcl.getRoot(), groupName);
- }
- catch (MetaContactListException ex)
- {
- int errorCode = ex.getErrorCode();
- if (errorCode != MetaContactListException.CODE_GROUP_ALREADY_EXISTS_ERROR)
- {
- logger.error(ex);
- }
- }
- }
-
- /**
- * Creates a default contact for the new DICT server.
- * @param accountID The accountID of the dict protocol provider for which we
- * want to add a default contact.
- */
- private void createDefaultContact(AccountID accountID)
- {
- // Gets the MetaContactListService.
- BundleContext bundleContext = getBundleContext();
- ServiceReference<MetaContactListService> mfcServiceRef
- = bundleContext.getServiceReference(MetaContactListService.class);
- MetaContactListService mcl = bundleContext.getService(mfcServiceRef);
-
- // Gets the ProtocolProviderService.
- ServiceReference<ProtocolProviderService> serRef
- = getProviderForAccount(accountID);
- ProtocolProviderService protocolProvider
- = DictActivator.getBundleContext().getService(serRef);
-
- // Gets group name
- String groupName = DictActivator.getResources()
- .getI18NString("service.protocol.DICTIONARIES");
-
- // Gets contact name
- String contactName = DictActivator.getResources()
- .getI18NString("plugin.dictaccregwizz.ANY_DICTIONARY_FORM",
- new String[] {accountID.getUserID()});
-
- // Gets the MetaContactGroup for the "dictionaries" group.
- MetaContactGroup group = mcl.getRoot().getMetaContactSubgroup(groupName);
-
- // Sets the default contact identifier to "*" corresponding to "all the
- // dictionaries" available on the server (cf. RFC-2229).
- String dict_uin = "*";
- // Create the default contact.
- mcl.createMetaContact(protocolProvider, group, dict_uin);
- // Rename the default contact.
- mcl.renameMetaContact(
- group.getMetaContact(protocolProvider, dict_uin),
- contactName);
- }
-
- @Override
- public void modifyAccount(
- ProtocolProviderService protocolProvider,
- Map<String, String> accountProperties)
- throws NullPointerException
- {
- // TODO Auto-generated method stub
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java
deleted file mode 100644
index aa9ef50..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java
+++ /dev/null
@@ -1,364 +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.dict;
-
-import net.java.dict4j.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.version.*;
-import org.osgi.framework.*;
-
-/**
- * A Dict implementation of the ProtocolProviderService.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class ProtocolProviderServiceDictImpl
- extends AbstractProtocolProviderService
-{
- private static final Logger logger
- = Logger.getLogger(ProtocolProviderServiceDictImpl.class);
-
- /**
- * The name of this protocol.
- */
- public static final String DICT_PROTOCOL_NAME = "Dict";
-
- /**
- * The id of the account that this protocol provider represents.
- */
- private DictAccountID accountID = null;
-
- /**
- * We use this to lock access to initialization.
- */
- private Object initializationLock = new Object();
-
- /**
- * Indicates whether or not the provider is initialized and ready for use.
- */
- private boolean isInitialized = false;
-
- /**
- * The logo corresponding to the gibberish protocol.
- */
- private ProtocolIconDictImpl dictIcon = new ProtocolIconDictImpl();
-
- /**
- * The registration state that we are currently in. Note that in a real
- * world protocol implementation this field won't exist and the registration
- * state would be retrieved from the protocol stack.
- */
- private RegistrationState currentRegistrationState
- = RegistrationState.UNREGISTERED;
-
- /**
- * the <tt>DictConnection</tt> opened by this provider
- */
- private DictConnection dictConnection;
-
- /**
- * The default constructor for the Dict protocol provider.
- */
- public ProtocolProviderServiceDictImpl()
- {
- if (logger.isTraceEnabled())
- logger.trace("Creating a Dict provider.");
- }
-
- /**
- * Initializes 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 userID the user id of the gibberish account we're currently
- * initializing
- * @param accountID the identifier of the account that this protocol
- * provider represents.
- *
- * @see net.java.sip.communicator.service.protocol.AccountID
- */
- protected void initialize(String userID,
- AccountID accountID)
- {
- synchronized(initializationLock)
- {
- this.accountID = (DictAccountID) accountID;
-
- this.dictConnection = new DictConnection(this.accountID.getHost(),
- this.accountID.getPort());
- this.dictConnection.setClientName(getSCVersion());
-
- //initialize the presence operationset
- OperationSetPersistentPresenceDictImpl persistentPresence =
- new OperationSetPersistentPresenceDictImpl(this);
-
- addSupportedOperationSet(
- OperationSetPersistentPresence.class,
- persistentPresence);
- //register it once again for those that simply need presence and
- //won't be smart enough to check for a persistent presence
- //alternative
- addSupportedOperationSet(
- OperationSetPresence.class,
- persistentPresence);
-
- //initialize the IM operation set
- addSupportedOperationSet(
- OperationSetBasicInstantMessaging.class,
- new OperationSetBasicInstantMessagingDictImpl(
- this,
- persistentPresence));
-
- //initialize the typing notifications operation set
- /*OperationSetTypingNotifications typingNotifications =
- new OperationSetTypingNotificationsDictImpl(
- this, persistentPresence);
-
- supportedOperationSets.put(
- OperationSetTypingNotifications.class.getName(),
- typingNotifications);
- */
- isInitialized = true;
- }
- }
-
- /**
- * Returns the <tt>DictConnection</tt> opened by this provider
- * @return the <tt>DictConnection</tt> opened by this provider
- */
- public DictConnection getConnection()
- {
- return this.dictConnection;
- }
-
- /**
- * 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 short name of the protocol that the implementation of this
- * provider is based upon (like SIP, Jabber, ICQ/AIM, or others for
- * example).
- *
- * @return a String containing the short name of the protocol this
- * service is implementing (most often that would be a name in
- * ProtocolNames).
- */
- public String getProtocolName()
- {
- return DICT_PROTOCOL_NAME;
- }
-
- /**
- * Returns the dict protocol icon.
- * @return the dict protocol icon
- */
- public ProtocolIcon getProtocolIcon()
- {
- return this.dictIcon;
- }
-
- /**
- * Returns the state of the registration of this protocol provider with
- * the corresponding registration service.
- *
- * @return ProviderRegistrationState
- */
- public RegistrationState getRegistrationState()
- {
- return currentRegistrationState;
- }
-
- /**
- * Starts the registration process.
- *
- * @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(SecurityAuthority authority)
- throws OperationFailedException
- {
- // Try to connect to the server
- boolean connected = connect();
-
- if (connected)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.REGISTERED,
- RegistrationStateChangeEvent.REASON_USER_REQUEST,
- null);
- currentRegistrationState = RegistrationState.REGISTERED;
- }
- else
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.CONNECTION_FAILED,
- RegistrationStateChangeEvent.REASON_SERVER_NOT_FOUND,
- null);
- currentRegistrationState = RegistrationState.UNREGISTERED;
- }
- }
-
- /**
- * Checks if the connection to the dict server is open
- * @return TRUE if the connection is open - FALSE otherwise
- */
- private boolean connect()
- {
- if (this.dictConnection.isConnected())
- {
- return true;
- }
-
- try
- {
- return this.dictConnection.isAvailable();
- }
- catch (DictException dx)
- {
- if (logger.isInfoEnabled())
- logger.info(dx);
- }
-
- return false;
- }
-
- /**
- * 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()
- {
- if(!isInitialized)
- {
- return;
- }
- if (logger.isTraceEnabled())
- logger.trace("Killing the Dict Protocol Provider for account "
- + this.accountID.getUserID());
-
- closeConnection();
-
- if(isRegistered())
- {
- try
- {
- //do the unregistration
- unregister();
- }
- catch (OperationFailedException ex)
- {
- //we're shutting down so we need to silence the exception here
- logger.error(
- "Failed to properly unregister before shutting down. "
- + getAccountID()
- , ex);
- }
- }
-
- isInitialized = false;
- }
-
- /**
- * Ends the registration of this protocol provider with the current
- * registration service.
- *
- * @throws OperationFailedException with the corresponding code it the
- * registration fails for some reason (e.g. a networking error or an
- * implementation problem).
- */
- public void unregister()
- throws OperationFailedException
- {
- closeConnection();
-
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_USER_REQUEST,
- null);
- }
-
- /**
- * DICT has no support for secure transport.
- */
- 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;
- }
-
- /**
- * Close the connection to the server
- */
- private void closeConnection()
- {
- try
- {
- this.dictConnection.close();
- }
- catch (DictException dx)
- {
- if (logger.isInfoEnabled())
- logger.info(dx);
- }
- }
-
- /**
- * Returns the current version of SIP-Communicator
- * @return the current version of SIP-Communicator
- */
- private String getSCVersion()
- {
- BundleContext bc = DictActivator.getBundleContext();
- ServiceReference vsr = bc.getServiceReference(VersionService.class.getName());
-
- VersionService vs = (VersionService) bc.getService(vsr);
- return vs.getCurrentVersion().toString();
-
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/dict.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/dict/dict.provider.manifest.mf
deleted file mode 100644
index d764657..0000000
--- a/src/net/java/sip/communicator/impl/protocol/dict/dict.provider.manifest.mf
+++ /dev/null
@@ -1,15 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.impl.protocol.dict.DictActivator
-Bundle-Name: Dict Protocol Provider
-Bundle-Description: A bundle providing support for the Dict protocol.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 1.0.0
-Bundle-SymbolicName: net.java.sip.communicator.protocol.dict
-Import-Package: org.osgi.framework,
- org.jitsi.service.version,
- net.java.sip.communicator.service.contactlist,
- org.jitsi.service.configuration,
- org.jitsi.service.resources, net.java.sip.communicator.service.resources,
- net.java.sip.communicator.util,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.event,
-Export-Package: net.java.dict4j